repository

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MPL-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientTransport

type ClientTransport interface {
	// RegisterToolProvider registers a tool provider (e.g. via the /utcp endpoint)
	// and returns the list of tools it exposes.
	RegisterToolProvider(ctx context.Context, manualProvider Provider) ([]Tool, error)

	// DeregisterToolProvider removes a previously registered provider.
	DeregisterToolProvider(ctx context.Context, manualProvider Provider) error

	// CallTool invokes a named tool with the given arguments on a specific provider.
	// It returns whatever the tool returns (often map[string]interface{} or a typed result).
	CallTool(ctx context.Context, toolName string, arguments map[string]any, toolProvider Provider, l *string) (any, error)
	CallToolStream(ctx context.Context, toolName string, args map[string]any, p Provider) (transports.StreamResult, error)
}

ClientTransport defines how a client registers, deregisters, and invokes UTCP tools.

type InMemoryToolRepository

type InMemoryToolRepository struct {
	// Tools and Providers remain exported for source compatibility. Treat them as
	// read-only after the first repository operation; mutate through the methods.
	Tools     map[string][]Tool
	Providers map[string]Provider
	// contains filtered or unexported fields
}

func (*InMemoryToolRepository) GetProvider

func (r *InMemoryToolRepository) GetProvider(ctx context.Context, providerName string) (*Provider, error)

func (*InMemoryToolRepository) GetProviders

func (r *InMemoryToolRepository) GetProviders(ctx context.Context) ([]Provider, error)

func (*InMemoryToolRepository) GetTool

func (r *InMemoryToolRepository) GetTool(ctx context.Context, toolName string) (*Tool, error)

func (*InMemoryToolRepository) GetTools

func (r *InMemoryToolRepository) GetTools(ctx context.Context) ([]Tool, error)

func (*InMemoryToolRepository) GetToolsByProvider

func (r *InMemoryToolRepository) GetToolsByProvider(ctx context.Context, providerName string) ([]Tool, error)

func (*InMemoryToolRepository) RangeTools added in v1.11.8

func (r *InMemoryToolRepository) RangeTools(ctx context.Context, visit func(Tool) bool) error

RangeTools visits a stable repository snapshot without first copying the complete catalog. Returning false stops iteration early.

func (*InMemoryToolRepository) RemoveProvider

func (r *InMemoryToolRepository) RemoveProvider(ctx context.Context, providerName string) error

func (*InMemoryToolRepository) RemoveTool

func (r *InMemoryToolRepository) RemoveTool(ctx context.Context, toolName string) error

func (*InMemoryToolRepository) SaveProviderWithTools

func (r *InMemoryToolRepository) SaveProviderWithTools(ctx context.Context, provider Provider, tools []Tool) error

func (*InMemoryToolRepository) ToolRevision added in v1.11.8

func (r *InMemoryToolRepository) ToolRevision() uint64

ToolRevision returns the current catalog revision for search-index caches.

type TextTransport

type TextTransport interface {
	ClientTransport
	SetBasePath(path string)
}

TextTransport interface for setting base path kept here for tests relying on it

type ToolRepository

type ToolRepository interface {
	// SaveProviderWithTools saves a provider and its associated tools.
	SaveProviderWithTools(ctx context.Context, provider Provider, tools []Tool) error

	// RemoveProvider removes a provider and all its tools by name.
	// Returns an error if the provider does not exist.
	RemoveProvider(ctx context.Context, providerName string) error

	// RemoveTool removes a single tool by name.
	// Returns an error if the tool does not exist.
	RemoveTool(ctx context.Context, toolName string) error

	// GetTool retrieves a tool by name.
	// Returns (nil, nil) if the tool is not found.
	GetTool(ctx context.Context, toolName string) (*Tool, error)

	// GetTools returns all tools in the repository.
	GetTools(ctx context.Context) ([]Tool, error)

	// GetToolsByProvider returns all tools for a specific provider.
	// Returns (nil, nil) if the provider is not found.
	GetToolsByProvider(ctx context.Context, providerName string) ([]Tool, error)

	// GetProvider retrieves a provider by name.
	// Returns (nil, nil) if the provider is not found.
	GetProvider(ctx context.Context, providerName string) (*Provider, error)

	// GetProviders returns all providers in the repository.
	GetProviders(ctx context.Context) ([]Provider, error)
}

ToolRepository defines the contract for persisting providers and their tools.

func NewInMemoryToolRepository

func NewInMemoryToolRepository() ToolRepository

type ToolRepositoryIterator added in v1.11.8

type ToolRepositoryIterator interface {
	RangeTools(ctx context.Context, visit func(Tool) bool) error
}

ToolRepositoryIterator is an optional fast path for repositories that can expose an immutable tool snapshot without allocating a full result slice. Search strategies should fall back to ToolRepository.GetTools when it is not implemented.

type ToolRepositoryRevision added in v1.11.8

type ToolRepositoryRevision interface {
	ToolRevision() uint64
}

ToolRepositoryRevision is implemented by repositories that can cheaply identify changes to their visible tool catalog. The value must change after every successful tool mutation performed through the repository.

Jump to

Keyboard shortcuts

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