pkg

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPromptNotFound   = NewError("prompt not found", -32000)
	ErrResourceNotFound = NewError("resource not found", -32001)
	ErrToolNotFound     = NewError("tool not found", -32002)
	ErrNotImplemented   = NewError("not implemented", -32003)
)

Common errors

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents a protocol error with a code and message

func NewError

func NewError(message string, code int) *Error

NewError creates a new Error with the given message and code

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

type PromptProvider

type PromptProvider interface {
	// ListPrompts returns a list of available prompts with optional pagination
	ListPrompts(cursor string) ([]protocol.Prompt, string, error)

	// GetPrompt retrieves a specific prompt with the given arguments
	GetPrompt(name string, arguments map[string]string) (*protocol.PromptMessage, error)
}

PromptProvider defines the interface for serving prompts

type Provider

type Provider interface {
	PromptProvider
	ResourceProvider
	ToolProvider
}

Provider combines all provider interfaces

type ProviderRegistry

type ProviderRegistry struct {
	// contains filtered or unexported fields
}

ProviderRegistry manages a list of providers

func NewProviderRegistry

func NewProviderRegistry() *ProviderRegistry

NewProviderRegistry creates a new provider registry

func (*ProviderRegistry) GetPromptProviders

func (r *ProviderRegistry) GetPromptProviders() []PromptProvider

GetPromptProviders returns all registered prompt providers

func (*ProviderRegistry) GetResourceProviders

func (r *ProviderRegistry) GetResourceProviders() []ResourceProvider

GetResourceProviders returns all registered resource providers

func (*ProviderRegistry) GetToolProviders

func (r *ProviderRegistry) GetToolProviders() []ToolProvider

GetToolProviders returns all registered tool providers

func (*ProviderRegistry) RegisterPromptProvider

func (r *ProviderRegistry) RegisterPromptProvider(provider PromptProvider)

RegisterPromptProvider adds a prompt provider to the registry

func (*ProviderRegistry) RegisterProvider

func (r *ProviderRegistry) RegisterProvider(provider Provider)

RegisterProvider adds a combined provider to the registry

func (*ProviderRegistry) RegisterResourceProvider

func (r *ProviderRegistry) RegisterResourceProvider(provider ResourceProvider)

RegisterResourceProvider adds a resource provider to the registry

func (*ProviderRegistry) RegisterToolProvider

func (r *ProviderRegistry) RegisterToolProvider(provider ToolProvider)

RegisterToolProvider adds a tool provider to the registry

type ResourceProvider

type ResourceProvider interface {
	// ListResources returns a list of available resources with optional pagination
	ListResources(cursor string) ([]protocol.Resource, string, error)

	// ReadResource retrieves the contents of a specific resource
	ReadResource(uri string) (*protocol.ResourceContent, error)

	// ListResourceTemplates returns a list of available resource templates
	ListResourceTemplates() ([]protocol.ResourceTemplate, error)

	// SubscribeToResource registers for notifications about resource changes
	// Returns a channel that will receive notifications and a cleanup function
	SubscribeToResource(uri string) (chan struct{}, func(), error)
}

ResourceProvider defines the interface for serving resources

type ToolProvider

type ToolProvider interface {
	// ListTools returns a list of available tools with optional pagination
	ListTools(cursor string) ([]protocol.Tool, string, error)

	// CallTool invokes a specific tool with the given arguments
	CallTool(ctx context.Context, name string, arguments map[string]interface{}) (*protocol.ToolResult, error)
}

ToolProvider defines the interface for serving tools

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL