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) ResolveUserRoot(ctx context.Context, msg pkgchannel.IncomingMessage) (string, 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 ResolvedChat
- func (rc *ResolvedChat) Chat(ctx context.Context, message agent.MessageContent, opts ...agent.ChatOption) (<-chan agent.Event, string, error)
- func (rc *ResolvedChat) CompactSession(ctx context.Context) (string, error)
- func (rc *ResolvedChat) ResolveSession(ctx context.Context) (agent.SessionInfo, error)
- func (rc *ResolvedChat) UserID() string
- type ResolvedIdentity
- type SnapshotLoader
- type StreamFuncBuilder
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 HandleAgentCommand ¶
func HandleAgentCommand(ctx context.Context, ac *AgentCommander, rc *ResolvedChat, args string, reply func(string))
func HandleCommand ¶
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 ¶
func ResolveAgent ¶
func ResolveAgent(ctx context.Context, store config.Store, authStore auth.AuthStore, engine *auth.PolicyEngine, identity ResolvedIdentity, chat ChatContext) (string, error)
func TryLinkCode ¶
Types ¶
type AgentCommander ¶
type AgentCommander struct {
// contains filtered or unexported fields
}
func NewAgentCommander ¶
func NewAgentCommander(store config.Store, authStore auth.AuthStore) *AgentCommander
func (*AgentCommander) ListForChat ¶
func (ac *AgentCommander) ListForChat(ctx context.Context, chat ChatContext) ([]config.Agent, error)
func (*AgentCommander) Switch ¶
func (ac *AgentCommander) Switch(ctx context.Context, user auth.AuthUser, chat ChatContext, agentSlug string) error
type ChatContext ¶
type CompleteFunc ¶
type CompleteFunc func(context.Context, ai.Model, ai.Context, ai.CompleteOptions, providers.StreamFunc) (ai.AssistantMessage, error)
type Coordinator ¶
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 Stella session; later messages are serialised in arrival order.
func NewCoordinator ¶
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 ¶
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 ¶
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 ¶
func (c *Coordinator) ListModels() []pkgchannel.ModelOption
ListModels returns available models.
func (*Coordinator) ProvisionUser ¶
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) ResolveUserRoot ¶
func (c *Coordinator) ResolveUserRoot(ctx context.Context, msg pkgchannel.IncomingMessage) (string, error)
ResolveUserRoot resolves the per-user writable root for the sender in msg. It performs the same user+agent resolution as HandleIncoming but stops before starting a session, so it is cheap and safe to call before file downloads.
func (*Coordinator) SwitchAgent ¶
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 ¶
func (c *Coordinator) SwitchModel(provider, model string) error
SwitchModel switches the active model.
type CoordinatorOption ¶
type CoordinatorOption func(*Coordinator)
CoordinatorOption configures the Coordinator.
func WithCoordinatorAuth ¶
func WithCoordinatorAuth(authStore auth.AuthStore, engine *auth.PolicyEngine, linkCodes *auth.LinkCodeStore) CoordinatorOption
WithCoordinatorAuth configures the coordinator with auth support.
func WithIntentClassifier ¶
func WithIntentClassifier(classifier IntentClassifier) CoordinatorOption
func WithVaultRecipient ¶
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 ¶
func WithVaultService(svc *vault.Service) CoordinatorOption
WithVaultService configures the coordinator with vault secret management.
type IndexedAgent ¶
func IndexAgents ¶
func IndexAgents(agents []config.Agent) []IndexedAgent
type IntentClassifier ¶
type LLMIntentClassifier ¶
type LLMIntentClassifier struct {
// contains filtered or unexported fields
}
func NewLLMIntentClassifier ¶
func NewLLMIntentClassifier(loadSnapshot SnapshotLoader, buildStream StreamFuncBuilder) *LLMIntentClassifier
func (*LLMIntentClassifier) Classify ¶
func (c *LLMIntentClassifier) Classify(ctx context.Context, agentID string, content []ai.ContentBlock) Intent
type ResolvedChat ¶
type ResolvedChat struct {
Pool *agent.Pool
User auth.AuthUser
AgentID string
SessionKey string
ChatCtx ChatContext
}
func Resolve ¶
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 ¶
func (*ResolvedChat) Chat ¶
func (rc *ResolvedChat) Chat(ctx context.Context, message agent.MessageContent, opts ...agent.ChatOption) (<-chan agent.Event, string, error)
func (*ResolvedChat) CompactSession ¶
func (rc *ResolvedChat) CompactSession(ctx context.Context) (string, error)
func (*ResolvedChat) ResolveSession ¶
func (rc *ResolvedChat) ResolveSession(ctx context.Context) (agent.SessionInfo, error)
func (*ResolvedChat) UserID ¶
func (rc *ResolvedChat) UserID() string
type StreamFuncBuilder ¶ added in v0.28.0
type StreamFuncBuilder func(context.Context, string, config.ProviderCreds) (providers.StreamFunc, error)