Documentation
¶
Index ¶
- Variables
- func FormatAgentList(agents []config.Agent, currentAgentID string) string
- func HandleAgentCommand(ctx context.Context, ac *AgentCommander, rc *ResolvedChat, args string, ...)
- func HandleCommand(ctx context.Context, rc *ResolvedChat, text, senderID string) (string, bool)
- func IntentToCommand(intent Intent) string
- func LoadConfig[T any](store config.Store, channelID string) *T
- func ResolveAgent(ctx context.Context, store config.Store, authStore auth.AuthStore, ...) (string, error)
- func TryLinkCode(ctx context.Context, authStore auth.AuthStore, linkCodes *auth.LinkCodeStore, ...) (string, bool)
- func TryLinkCodeWithCandidates(ctx context.Context, authStore auth.AuthStore, linkCodes *auth.LinkCodeStore, ...) (string, bool)
- type AgentCommander
- type ChatContext
- type CompleteFunc
- type Coordinator
- func (c *Coordinator) HandleIncoming(ctx context.Context, msg pkgchannel.IncomingMessage, command, args string) (string, bool, *pkgchannel.ChatStream, error)
- func (c *Coordinator) ListAgents(ctx context.Context, msg pkgchannel.IncomingMessage) ([]pkgchannel.AgentInfo, string, error)
- func (c *Coordinator) ListModels() []pkgchannel.ModelOption
- func (c *Coordinator) ProvisionUser(ctx context.Context, req pkgchannel.ProvisionRequest) error
- func (c *Coordinator) SwitchAgent(ctx context.Context, msg pkgchannel.IncomingMessage, agentSlug string) error
- func (c *Coordinator) SwitchModel(provider, model string) error
- type CoordinatorOption
- type IndexedAgent
- type Intent
- type IntentClassifier
- type LLMIntentClassifier
- type ProviderGetterBuilder
- type ResolvedChat
- func (rc *ResolvedChat) Chat(ctx context.Context, message runner.MessageContent, opts ...agent.ChatOption) (<-chan runner.Event, string, error)
- func (rc *ResolvedChat) CompactSession(ctx context.Context) (string, error)
- func (rc *ResolvedChat) ResolveSession() (agent.SessionInfo, error)
- func (rc *ResolvedChat) RotateSession() (agent.SessionInfo, error)
- func (rc *ResolvedChat) UserID() int64
- type ResolvedIdentity
- type SnapshotLoader
Constants ¶
This section is empty.
Variables ¶
var ErrAgentAccessDenied = errors.New("you don't have access to this agent, contact an admin")
var ParseCommandArgs = pkgchannel.ParseCommandArgs
Functions ¶
func FormatAgentList ¶ added in v0.8.0
func HandleAgentCommand ¶ added in v0.9.0
func HandleAgentCommand(ctx context.Context, ac *AgentCommander, rc *ResolvedChat, args string, reply func(string))
func HandleCommand ¶ added in v0.8.0
HandleCommand processes common bot commands shared across all channels. /model and /agent are left to each channel because they need platform-specific UI.
func IntentToCommand ¶ added in v0.11.1
func ResolveAgent ¶ added in v0.8.0
func ResolveAgent(ctx context.Context, store config.Store, authStore auth.AuthStore, engine *auth.PolicyEngine, identity ResolvedIdentity, chat ChatContext) (string, error)
func TryLinkCode ¶ added in v0.9.0
Types ¶
type AgentCommander ¶ added in v0.8.0
type AgentCommander struct {
// contains filtered or unexported fields
}
func NewAgentCommander ¶ added in v0.8.0
func NewAgentCommander(store config.Store, authStore auth.AuthStore) *AgentCommander
func (*AgentCommander) ListForChat ¶ added in v0.10.0
func (ac *AgentCommander) ListForChat(ctx context.Context, chat ChatContext) ([]config.Agent, error)
func (*AgentCommander) Switch ¶ added in v0.8.0
func (ac *AgentCommander) Switch(ctx context.Context, user auth.AuthUser, chat ChatContext, agentSlug string) error
type ChatContext ¶ added in v0.8.0
type CompleteFunc ¶ added in v0.11.1
type CompleteFunc func(context.Context, ai.Model, ai.Context, ai.CompleteOptions, providers.ProviderGetter) (ai.AssistantMessage, error)
type Coordinator ¶ added in v0.9.0
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator implements pkgchannel.Handler. It owns all business logic that channels previously called directly: user/agent resolution, session management, command handling, account linking, and model/agent switching. A per-session message queue ensures that only one chat turn runs at a time per resolved Anna session; later messages are serialised in arrival order.
func NewCoordinator ¶ added in v0.9.0
func NewCoordinator( pm *agent.PoolManager, store config.Store, listFn func() []pkgchannel.ModelOption, switchFn func(provider, model string) error, opts ...CoordinatorOption, ) *Coordinator
NewCoordinator creates a Coordinator that satisfies pkgchannel.Handler.
func (*Coordinator) HandleIncoming ¶ added in v0.9.0
func (c *Coordinator) HandleIncoming(ctx context.Context, msg pkgchannel.IncomingMessage, command, args string) (string, bool, *pkgchannel.ChatStream, error)
HandleIncoming resolves the user once, tries command handling, and if the command is not handled, streams a chat response. This avoids double resolution when a plugin needs to try commands before messaging.
func (*Coordinator) ListAgents ¶ added in v0.9.0
func (c *Coordinator) ListAgents(ctx context.Context, msg pkgchannel.IncomingMessage) ([]pkgchannel.AgentInfo, string, error)
ListAgents returns enabled agents the user can access and the current agent ID.
func (*Coordinator) ListModels ¶ added in v0.9.0
func (c *Coordinator) ListModels() []pkgchannel.ModelOption
ListModels returns available models.
func (*Coordinator) ProvisionUser ¶ added in v0.14.0
func (c *Coordinator) ProvisionUser(ctx context.Context, req pkgchannel.ProvisionRequest) error
ProvisionUser creates or returns an existing user+identity for the given channel sender. Returns an error if auth is not configured or the user count is zero (no admin exists yet — provisioning is refused until the first admin registers to avoid stranding a deployment with zero admins).
func (*Coordinator) SwitchAgent ¶ added in v0.9.0
func (c *Coordinator) SwitchAgent(ctx context.Context, msg pkgchannel.IncomingMessage, agentSlug string) error
SwitchAgent switches the active agent for the chat context.
func (*Coordinator) SwitchModel ¶ added in v0.9.0
func (c *Coordinator) SwitchModel(provider, model string) error
SwitchModel switches the active model.
type CoordinatorOption ¶ added in v0.9.0
type CoordinatorOption func(*Coordinator)
CoordinatorOption configures the Coordinator.
func WithCoordinatorAuth ¶ added in v0.9.0
func WithCoordinatorAuth(authStore auth.AuthStore, engine *auth.PolicyEngine, linkCodes *auth.LinkCodeStore) CoordinatorOption
WithCoordinatorAuth configures the coordinator with auth support.
func WithIntentClassifier ¶ added in v0.11.1
func WithIntentClassifier(classifier IntentClassifier) CoordinatorOption
func WithVaultRecipient ¶ added in v0.15.0
func WithVaultRecipient(r *age.X25519Recipient) CoordinatorOption
WithVaultRecipient sets the master age recipient so channel-provisioned users get age keys immediately instead of waiting for the startup backfill.
func WithVaultService ¶ added in v0.15.0
func WithVaultService(svc *vault.Service) CoordinatorOption
WithVaultService configures the coordinator with vault secret management.
type IndexedAgent ¶ added in v0.9.0
func IndexAgents ¶ added in v0.9.0
func IndexAgents(agents []config.Agent) []IndexedAgent
type IntentClassifier ¶ added in v0.11.1
type LLMIntentClassifier ¶ added in v0.11.1
type LLMIntentClassifier struct {
// contains filtered or unexported fields
}
func NewLLMIntentClassifier ¶ added in v0.11.1
func NewLLMIntentClassifier(loadSnapshot SnapshotLoader, buildGetter ProviderGetterBuilder) *LLMIntentClassifier
func (*LLMIntentClassifier) Classify ¶ added in v0.11.1
func (c *LLMIntentClassifier) Classify(ctx context.Context, agentID string, content []ai.ContentBlock) Intent
type ProviderGetterBuilder ¶ added in v0.11.1
type ProviderGetterBuilder func(context.Context, string, config.ProviderCreds) (providers.ProviderGetter, error)
type ResolvedChat ¶ added in v0.8.0
type ResolvedChat struct {
Pool *agent.Pool
User auth.AuthUser
AgentID string
SessionKey string
ChatCtx ChatContext
}
func Resolve ¶ added in v0.8.0
func Resolve(ctx context.Context, pm *agent.PoolManager, store config.Store, authStore auth.AuthStore, engine *auth.PolicyEngine, platform, senderID, senderName, chatID string, isGroup bool) (*ResolvedChat, error)
func ResolveWithChannel ¶ added in v0.10.0
func (*ResolvedChat) Chat ¶ added in v0.8.0
func (rc *ResolvedChat) Chat(ctx context.Context, message runner.MessageContent, opts ...agent.ChatOption) (<-chan runner.Event, string, error)
func (*ResolvedChat) CompactSession ¶ added in v0.8.0
func (rc *ResolvedChat) CompactSession(ctx context.Context) (string, error)
func (*ResolvedChat) ResolveSession ¶ added in v0.8.0
func (rc *ResolvedChat) ResolveSession() (agent.SessionInfo, error)
func (*ResolvedChat) RotateSession ¶ added in v0.8.0
func (rc *ResolvedChat) RotateSession() (agent.SessionInfo, error)
func (*ResolvedChat) UserID ¶ added in v0.8.0
func (rc *ResolvedChat) UserID() int64