manager

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OAuthClientOpt added in v0.4.2

func OAuthClientOpt(ctx context.Context, url string, cred *schema.OAuthCredentials, store schema.CredentialStore) client.ClientOpt

OAuthClientOpt returns a client.ClientOpt that installs an oauth2 transport which refreshes the access token automatically when it expires.

After each successful refresh the new token is persisted back to the credential store so that subsequent restarts start with a valid token.

func WithOutputDimensionality

func WithOutputDimensionality(dim uint) opt.Opt

WithOutputDimensionality sets the output dimensionality for embedding requests

func WithTaskType

func WithTaskType(taskType string) opt.Opt

WithTaskType sets the task type for embedding requests

func WithTitle

func WithTitle(title string) opt.Opt

WithTitle sets the title for the agent, which may be used in embedding requests

Types

type ConnectorFactory added in v0.4.2

type ConnectorFactory func(ctx context.Context, url string, extraOpts ...client.ClientOpt) (llm.Connector, error)

ConnectorFactory creates an llm.Connector for the given URL. The factory owns its static options (tracing, timeout, etc.). extraOpts are appended at call time and are used for per-URL dynamic options such as bearer token injection from a credential store.

func MCPConnectorFactory added in v0.4.2

func MCPConnectorFactory(name, version string, staticOpts ...mcpclient.Opt) ConnectorFactory

MCPConnectorFactory returns a ConnectorFactory that creates MCP clients. The client auto-detects the transport (Streamable HTTP, falling back to SSE). name and version are reported to the server during the MCP initialisation handshake. staticOpts are captured at construction time and applied to every connector created.

type Manager

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

func NewManager

func NewManager(name, ver string, opts ...Opt) (*Manager, error)

func (*Manager) Ask

func (m *Manager) Ask(ctx context.Context, request schema.AskRequest, fn opt.StreamFn) (response *schema.AskResponse, err error)

Ask processes a message and returns a response, outside of a session context (stateless). If fn is non-nil, text chunks are streamed to the callback as they arrive.

func (*Manager) CallTool added in v0.3.1

func (m *Manager) CallTool(ctx context.Context, name string, input json.RawMessage) (result *schema.CallToolResponse, err error)

CallTool executes a tool by name with the given input and returns the result.

func (*Manager) Chat

func (m *Manager) Chat(ctx context.Context, request schema.ChatRequest, fn opt.StreamFn) (response *schema.ChatResponse, err error)

Chat processes a message within a session context (stateful). If fn is non-nil, text chunks are streamed to the callback as they arrive.

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) CreateAgent

func (m *Manager) CreateAgent(ctx context.Context, meta schema.AgentMeta) (result *schema.Agent, err error)

CreateAgent creates a new agent from the given metadata.

func (*Manager) CreateAgentSession

func (m *Manager) CreateAgentSession(ctx context.Context, id string, request schema.CreateAgentSessionRequest) (result *schema.CreateAgentSessionResponse, err error)

CreateAgentSession resolves an agent by ID or name, validates input against the agent's schema, executes the agent's template, and creates a new session with merged GeneratorMeta and agent labels. If Parent is provided, the parent session's GeneratorMeta is used as defaults (agent fields take precedence). The returned response contains the session ID, rendered text, and tools, which the caller can pass to Chat.

func (*Manager) CreateConnector added in v0.4.2

func (m *Manager) CreateConnector(ctx context.Context, rawURL string, meta schema.ConnectorMeta) (result *schema.Connector, err error)

CreateConnector registers a new MCP connector and persists its metadata. When a connector factory is configured and the connector supports probing, the server state (name, version, capabilities) is fetched synchronously and persisted before returning. Subsequent reconnects update the state asynchronously via the background session.

func (*Manager) CreateSession

func (m *Manager) CreateSession(ctx context.Context, meta schema.SessionMeta) (result *schema.Session, err error)

CreateSession creates a new session for the given model.

func (*Manager) DeleteAgent

func (m *Manager) DeleteAgent(ctx context.Context, id string) (result *schema.Agent, err error)

DeleteAgent deletes an agent by ID or name and returns it.

func (*Manager) DeleteConnector added in v0.4.2

func (m *Manager) DeleteConnector(ctx context.Context, rawURL string) (err error)

DeleteConnector removes the connector for the given URL.

func (*Manager) DeleteCredential added in v0.4.0

func (m *Manager) DeleteCredential(ctx context.Context, rawURL string) (err error)

DeleteCredential removes the credential for the given server URL.

func (*Manager) DeleteSession

func (m *Manager) DeleteSession(ctx context.Context, session string) (result *schema.Session, err error)

DeleteSession deletes a session by ID and returns it.

func (*Manager) Embedding

func (m *Manager) Embedding(ctx context.Context, request *schema.EmbeddingRequest) (response *schema.EmbeddingResponse, err error)

func (*Manager) GetAgent

func (m *Manager) GetAgent(ctx context.Context, id string) (result *schema.Agent, err error)

GetAgent retrieves an agent by ID or name.

func (*Manager) GetConnector added in v0.4.2

func (m *Manager) GetConnector(ctx context.Context, rawURL string) (result *schema.Connector, err error)

GetConnector returns the connector for the given URL.

func (*Manager) GetCredential added in v0.4.0

func (m *Manager) GetCredential(ctx context.Context, rawURL string) (result *schema.OAuthCredentials, err error)

GetCredential retrieves the credential for the given server URL.

func (*Manager) GetModel

func (m *Manager) GetModel(ctx context.Context, req schema.GetModelRequest) (result *schema.Model, err error)

func (*Manager) GetSession

func (m *Manager) GetSession(ctx context.Context, session string) (result *schema.Session, err error)

GetSession retrieves a session by ID.

func (*Manager) GetTool

func (m *Manager) GetTool(ctx context.Context, name string) (result *schema.ToolMeta, err error)

GetTool returns tool metadata by name.

func (*Manager) ListAgents

func (m *Manager) ListAgents(ctx context.Context, req schema.ListAgentRequest) (result *schema.ListAgentResponse, err error)

ListAgents returns agents with pagination support.

func (*Manager) ListConnectors added in v0.4.2

func (m *Manager) ListConnectors(ctx context.Context, req schema.ListConnectorsRequest) (result *schema.ListConnectorsResponse, err error)

ListConnectors returns connectors matching the request filters.

func (*Manager) ListModels

func (m *Manager) ListModels(ctx context.Context, req schema.ListModelsRequest) (result *schema.ListModelsResponse, err error)

func (*Manager) ListSessions

func (m *Manager) ListSessions(ctx context.Context, req schema.ListSessionRequest) (result *schema.ListSessionResponse, err error)

ListSessions returns sessions with pagination support.

func (*Manager) ListTools

func (m *Manager) ListTools(ctx context.Context, req schema.ListToolRequest) (result *schema.ListToolResponse, err error)

ListTools returns paginated tool metadata.

func (*Manager) SetCredential added in v0.4.0

func (m *Manager) SetCredential(ctx context.Context, rawURL string, cred schema.OAuthCredentials) (err error)

SetCredential stores (or updates) the credential for the given server URL.

func (*Manager) UpdateAgent

func (m *Manager) UpdateAgent(ctx context.Context, id string, meta schema.AgentMeta) (result *schema.Agent, err error)

UpdateAgent updates an agent's metadata and creates a new version. If Model or Provider are changed, they are validated against the registered providers first.

func (*Manager) UpdateConnector added in v0.4.2

func (m *Manager) UpdateConnector(ctx context.Context, rawURL string, meta schema.ConnectorMeta) (result *schema.Connector, err error)

UpdateConnector updates the user-editable metadata for an existing connector.

func (*Manager) UpdateSession

func (m *Manager) UpdateSession(ctx context.Context, id string, meta schema.SessionMeta) (result *schema.Session, err error)

UpdateSession updates a session's metadata. If Model or Provider are changed, they are validated against the registered providers first.

type Opt

type Opt func(*Manager) error

Opt is a functional option for configuring an agent

func WithAgentStore

func WithAgentStore(store schema.AgentStore) Opt

WithAgentStore sets the agent storage backend for the manager. If not set, an in-memory store is used by default.

func WithClient

func WithClient(client llm.Client) Opt

WithClient adds an LLM client to the agent

func WithConnectorFactory added in v0.4.2

func WithConnectorFactory(factory ConnectorFactory) Opt

WithConnectorFactory sets the factory used to create MCP connectors. When set, CreateConnector probes the server before registering it. Use MCPConnectorFactory to get the standard MCP SSE implementation.

func WithConnectorStore added in v0.4.2

func WithConnectorStore(store schema.ConnectorStore) Opt

WithConnectorStore sets the MCP connector storage backend for the manager. If not set, an in-memory store is used by default.

func WithCredentialStore added in v0.4.0

func WithCredentialStore(store schema.CredentialStore) Opt

WithCredentialStore sets the credential storage backend for the manager. If not set, credential operations will return an error.

func WithLogger added in v0.4.2

func WithLogger(l *slog.Logger) Opt

WithLogger sets the logger used for connector state and diagnostic messages. If l is nil, slog.Default() is used.

func WithSessionStore

func WithSessionStore(store schema.SessionStore) Opt

WithSessionStore sets the session storage backend for the manager. If not set, an in-memory store is used by default.

func WithTool

func WithTool(t llm.Tool) Opt

WithTool registers a single tool with the manager's toolkit.

func WithTools added in v0.4.2

func WithTools(tools ...llm.Tool) Opt

WithTools registers one or more tools with the manager's toolkit.

func WithTracer added in v0.4.0

func WithTracer(tracer trace.Tracer) Opt

WithTracer sets the OpenTelemetry tracer for distributed tracing.

Jump to

Keyboard shortcuts

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