manager

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDelegate

func NewDelegate(name, version string, connectors map[string]llm.Connector, runagent runAgentFunc, clientopts ...client.ClientOpt) *delegate

Types

type ConnectorProbe

type ConnectorProbe interface {
	Probe(ctx context.Context, auth func(err error, config *authclient.Config) error) (*schema.ConnectorState, error)
}

We define the MCP client prober here, so we can get the details of an MCP Server before we insert it into the database. If there is a probe authentication failure, we can return the details of the auth failure to the client so they can fix it before retrying.

type Manager

type Manager struct {
	pg.PoolConn
	*providerregistry.Registry
	toolkit.Toolkit
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, name, version string, pool pg.PoolConn, opts ...Opt) (*Manager, error)

func (*Manager) Ask

func (m *Manager) Ask(ctx context.Context, request schema.AskRequest, user *auth.UserInfo, fn opt.StreamFn) (_ *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) CallAgent

func (m *Manager) CallAgent(ctx context.Context, name string, req schema.CallAgentRequest, user *auth.UserInfo) (result llm.Resource, err error)

CallAgent executes an agent by name with the given input, scoped by the user's accessible namespaces.

func (*Manager) CallTool

func (m *Manager) CallTool(ctx context.Context, name string, req schema.CallToolRequest, user *auth.UserInfo) (result llm.Resource, err error)

CallTool executes a tool by name with the given input, scoped by the user's accessible namespaces.

func (*Manager) Chat

func (m *Manager) Chat(ctx context.Context, req schema.ChatRequest, fn opt.StreamFn, user *auth.UserInfo, attachments ...llm.Resource) (_ *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) CreateConnector

func (m *Manager) CreateConnector(ctx context.Context, req schema.ConnectorInsert, user *auth.UserInfo) (_ *schema.Connector, _ *oidc.BaseConfiguration, _ []string, err error)

CreateConnector validates and persists a connector insert request.

func (*Manager) CreateCredential

func (m *Manager) CreateCredential(ctx context.Context, req schema.CredentialInsert) (_ *schema.Credential, err error)

CreateCredential persists an encrypted credential row and returns the public credential shape, excluding passphrase version and encrypted payload.

func (*Manager) CreateProvider

func (m *Manager) CreateProvider(ctx context.Context, req schema.ProviderInsert) (*schema.Provider, error)

CreateProvider validates a provider insert request and returns the persisted provider shape. Database persistence is not wired up yet.

func (*Manager) CreateSession

func (m *Manager) CreateSession(ctx context.Context, req schema.SessionInsert, user *auth.UserInfo) (_ *schema.Session, err error)

CreateSession validates and persists a new session for the authenticated user. If Parent is set, the parent session must exist, belong to the same user, and its generator settings are used as defaults for the child session. If user is nil, it creates a user-less session.

func (*Manager) CreateUsage

func (m *Manager) CreateUsage(ctx context.Context, req schema.UsageInsert) (_ *schema.Usage, err error)

func (*Manager) DeleteConnector

func (m *Manager) DeleteConnector(ctx context.Context, url string) (_ *schema.Connector, err error)

DeleteConnector removes the connector for the given URL and returns the deleted connector.

func (*Manager) DeleteModel

func (m *Manager) DeleteModel(ctx context.Context, req schema.DeleteModelRequest, user *auth.UserInfo) (result *schema.Model, err error)

func (*Manager) DeleteProvider

func (m *Manager) DeleteProvider(ctx context.Context, name string) (*schema.Provider, error)

DeleteProvider deletes a single provider by name and returns the deleted provider.

func (*Manager) DeleteSession

func (m *Manager) DeleteSession(ctx context.Context, session uuid.UUID, user *auth.UserInfo) (_ *schema.Session, err error)

DeleteSession removes a session by ID and returns the deleted session. If user is non-nil, the session must be owned by that user.

func (*Manager) DownloadModel

func (m *Manager) DownloadModel(ctx context.Context, req schema.DownloadModelRequest, user *auth.UserInfo, opts ...opt.Opt) (result *schema.Model, err error)

func (*Manager) Embedding

func (m *Manager) Embedding(ctx context.Context, request schema.EmbeddingRequest, user *auth.UserInfo) (_ *schema.EmbeddingResponse, err error)

Embedding resolves an embedding-capable model for the user-scoped request and returns one output vector per input string.

func (*Manager) GetAgent

func (m *Manager) GetAgent(ctx context.Context, name string, user *auth.UserInfo) (result *schema.AgentMeta, err error)

GetAgent returns agent metadata by name, scoped by the user's accessible namespaces.

func (*Manager) GetConnector

func (m *Manager) GetConnector(ctx context.Context, url string, user *auth.UserInfo) (_ *schema.Connector, err error)

GetConnector returns the connector for the given URL and, when user is set, scopes access to public connectors or those accessible to the user's groups.

func (*Manager) GetModel

func (m *Manager) GetModel(ctx context.Context, req schema.GetModelRequest, user *auth.UserInfo) (_ *schema.Model, err error)

func (*Manager) GetProvider

func (m *Manager) GetProvider(ctx context.Context, name string) (*schema.Provider, error)

GetProvider returns a single provider by name.

func (*Manager) GetSession

func (m *Manager) GetSession(ctx context.Context, session uuid.UUID, user *auth.UserInfo) (_ *schema.Session, err error)

GetSession returns a session by ID. If user is non-nil, the session must be owned by that user; otherwise ErrForbidden is returned.

func (*Manager) GetTool

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

GetTool returns tool metadata by name, scoped by the user's accessible namespaces.

func (*Manager) ListAgents

func (m *Manager) ListAgents(ctx context.Context, req schema.AgentListRequest, user *auth.UserInfo) (result *schema.AgentList, err error)

ListAgents returns paginated prompt metadata from the current toolkit, exposing prompts externally as agents.

func (*Manager) ListConnectors

func (m *Manager) ListConnectors(ctx context.Context, req schema.ConnectorListRequest, user *auth.UserInfo) (_ *schema.ConnectorList, err error)

ListConnectors lists connectors matching the request and, when user is set, filters results to public connectors or those accessible to the user's groups.

func (*Manager) ListMessages

func (m *Manager) ListMessages(ctx context.Context, req schema.MessageListRequest, user *auth.UserInfo) (_ *schema.MessageList, err error)

ListMessages returns messages for a single session, optionally filtered by request fields. If user is non-nil, the session must be owned by that user.

func (*Manager) ListModels

func (m *Manager) ListModels(ctx context.Context, req schema.ModelListRequest, user *auth.UserInfo) (_ *schema.ModelList, err error)

func (*Manager) ListProviders

func (m *Manager) ListProviders(ctx context.Context, req schema.ProviderListRequest) (*schema.ProviderList, error)

ListProviders returns a list of providers matching the given request parameters.

func (*Manager) ListSessions

func (m *Manager) ListSessions(ctx context.Context, req schema.SessionListRequest, user *auth.UserInfo) (_ *schema.SessionList, err error)

ListSessions returns a paginated list of sessions matching the request. If user is non-nil, only sessions owned by that user are returned.

func (*Manager) ListTools

func (m *Manager) ListTools(ctx context.Context, req schema.ToolListRequest, user *auth.UserInfo) (result *schema.ToolList, err error)

ListTools returns paginated tool metadata from the current toolkit.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, logger *slog.Logger) error

Run initializes runtime resources and tears them down when the context ends.

func (*Manager) SubscribeSession

func (m *Manager) SubscribeSession(ctx context.Context, session uuid.UUID, callback SessionFeedCallback, user *auth.UserInfo) error

SubscribeSession registers a callback for new persisted messages for a session. The subscription is automatically removed when ctx is canceled.

func (*Manager) SyncProviders

func (m *Manager) SyncProviders(ctx context.Context) ([]string, []string, error)

SyncProviders refreshes the in-memory provider registry from the database.

func (*Manager) UpdateConnector

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

UpdateConnector updates the user-editable metadata for the connector and returns the updated connector.

func (*Manager) UpdateProvider

func (m *Manager) UpdateProvider(ctx context.Context, name string, meta schema.ProviderMeta) (*schema.Provider, error)

UpdateProvider updates the writable metadata for a provider by name and returns the updated provider.

func (*Manager) UpdateSession

func (m *Manager) UpdateSession(ctx context.Context, session uuid.UUID, meta schema.SessionMeta, user *auth.UserInfo) (_ *schema.Session, err error)

UpdateSession updates the metadata for a session and returns the updated session. If user is non-nil, the session must be owned by that user. The incoming GeneratorMeta is merged over the existing one (incoming fields win).

type Opt

type Opt func(*manageropt) error

Opt configures a Manager during construction.

func WithClientOpts

func WithClientOpts(opts ...client.ClientOpt) Opt

WithClientOpts provides unified client options for the LLM model providers and connectors

func WithConnector

func WithConnector(name string, connector llm.Connector) Opt

WithConnector adds a runtime-local connector to the manager by identifier.

func WithMeter

func WithMeter(meter metric.Meter) Opt

WithMeter sets the OpenTelemetry meter used for manager metrics.

func WithNotificationChannel

func WithNotificationChannel(name string) Opt

WithNotificationChannel sets the PostgreSQL LISTEN/NOTIFY channel used by the provider table change trigger created during bootstrap.

func WithPassphrase

func WithPassphrase(version uint64, passphrase string) Opt

WithPassphrase registers an in-memory storage passphrase for a certificate passphrase version. Versions are uint64 and passphrases must be non-empty.

func WithPrompts

func WithPrompts(opts ...llm.Prompt) Opt

WithPrompts provides unified prompt options for the LLM model providers

func WithResources

func WithResources(opts ...llm.Resource) Opt

WithResources provides unified resource options for the LLM model providers

func WithSchemas

func WithSchemas(llm, auth string) Opt

WithSchemas sets the database schema names to use for all queries. If not set the default schemas are used.

func WithTools

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

WithTools provides unified tool options for the LLM model providers

func WithTracer

func WithTracer(tracer trace.Tracer) Opt

WithTracer sets the OpenTelemetry tracer used for manager spans.

type SessionFeed

type SessionFeed struct {
	pg.Conn
	// contains filtered or unexported fields
}

func NewSessionFeed

func NewSessionFeed(ctx context.Context, conn pg.Conn, delay time.Duration) (*SessionFeed, error)

func (*SessionFeed) Subscribe

func (s *SessionFeed) Subscribe(ctx context.Context, session uuid.UUID, callback SessionFeedCallback) error

type SessionFeedCallback

type SessionFeedCallback func([]*schema.Message)

Jump to

Keyboard shortcuts

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