Documentation
¶
Index ¶
- func OAuthClientOpt(ctx context.Context, url string, cred *schema.OAuthCredentials, ...) client.ClientOpt
- func WithOutputDimensionality(dim uint) opt.Opt
- func WithTaskType(taskType string) opt.Opt
- func WithTitle(title string) opt.Opt
- type ConnectorFactory
- type Manager
- func (m *Manager) Ask(ctx context.Context, request schema.AskRequest, fn opt.StreamFn) (response *schema.AskResponse, err error)
- func (m *Manager) CallTool(ctx context.Context, name string, input json.RawMessage) (result *schema.CallToolResponse, err error)
- func (m *Manager) Chat(ctx context.Context, request schema.ChatRequest, fn opt.StreamFn) (response *schema.ChatResponse, err error)
- func (m *Manager) Close() error
- func (m *Manager) CreateAgent(ctx context.Context, meta schema.AgentMeta) (result *schema.Agent, err error)
- func (m *Manager) CreateAgentSession(ctx context.Context, id string, request schema.CreateAgentSessionRequest) (result *schema.CreateAgentSessionResponse, err error)
- func (m *Manager) CreateConnector(ctx context.Context, rawURL string, meta schema.ConnectorMeta) (result *schema.Connector, err error)
- func (m *Manager) CreateSession(ctx context.Context, meta schema.SessionMeta) (result *schema.Session, err error)
- func (m *Manager) DeleteAgent(ctx context.Context, id string) (result *schema.Agent, err error)
- func (m *Manager) DeleteConnector(ctx context.Context, rawURL string) (err error)
- func (m *Manager) DeleteCredential(ctx context.Context, rawURL string) (err error)
- func (m *Manager) DeleteSession(ctx context.Context, session string) (result *schema.Session, err error)
- func (m *Manager) Embedding(ctx context.Context, request *schema.EmbeddingRequest) (response *schema.EmbeddingResponse, err error)
- func (m *Manager) GetAgent(ctx context.Context, id string) (result *schema.Agent, err error)
- func (m *Manager) GetConnector(ctx context.Context, rawURL string) (result *schema.Connector, err error)
- func (m *Manager) GetCredential(ctx context.Context, rawURL string) (result *schema.OAuthCredentials, err error)
- func (m *Manager) GetModel(ctx context.Context, req schema.GetModelRequest) (result *schema.Model, err error)
- func (m *Manager) GetSession(ctx context.Context, session string) (result *schema.Session, err error)
- func (m *Manager) GetTool(ctx context.Context, name string) (result *schema.ToolMeta, err error)
- func (m *Manager) ListAgents(ctx context.Context, req schema.ListAgentRequest) (result *schema.ListAgentResponse, err error)
- func (m *Manager) ListConnectors(ctx context.Context, req schema.ListConnectorsRequest) (result *schema.ListConnectorsResponse, err error)
- func (m *Manager) ListModels(ctx context.Context, req schema.ListModelsRequest) (result *schema.ListModelsResponse, err error)
- func (m *Manager) ListSessions(ctx context.Context, req schema.ListSessionRequest) (result *schema.ListSessionResponse, err error)
- func (m *Manager) ListTools(ctx context.Context, req schema.ListToolRequest) (result *schema.ListToolResponse, err error)
- func (m *Manager) SetCredential(ctx context.Context, rawURL string, cred schema.OAuthCredentials) (err error)
- func (m *Manager) UpdateAgent(ctx context.Context, id string, meta schema.AgentMeta) (result *schema.Agent, err error)
- func (m *Manager) UpdateConnector(ctx context.Context, rawURL string, meta schema.ConnectorMeta) (result *schema.Connector, err error)
- func (m *Manager) UpdateSession(ctx context.Context, id string, meta schema.SessionMeta) (result *schema.Session, err error)
- type Opt
- func WithAgentStore(store schema.AgentStore) Opt
- func WithClient(client llm.Client) Opt
- func WithConnectorFactory(factory ConnectorFactory) Opt
- func WithConnectorStore(store schema.ConnectorStore) Opt
- func WithCredentialStore(store schema.CredentialStore) Opt
- func WithLogger(l *slog.Logger) Opt
- func WithSessionStore(store schema.SessionStore) Opt
- func WithTool(t llm.Tool) Opt
- func WithTools(tools ...llm.Tool) Opt
- func WithTracer(tracer trace.Tracer) Opt
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 ¶
WithOutputDimensionality sets the output dimensionality for embedding requests
func WithTaskType ¶
WithTaskType sets the task type for 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 (*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) 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 ¶
DeleteAgent deletes an agent by ID or name and returns it.
func (*Manager) DeleteConnector ¶ added in v0.4.2
DeleteConnector removes the connector for the given URL.
func (*Manager) DeleteCredential ¶ added in v0.4.0
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) 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) GetSession ¶
func (m *Manager) GetSession(ctx context.Context, session string) (result *schema.Session, err error)
GetSession retrieves a session by ID.
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.
type Opt ¶
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 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
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 WithTracer ¶ added in v0.4.0
WithTracer sets the OpenTelemetry tracer for distributed tracing.