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 channelAuthStore, ...) (string, error)
- func TryLinkCode(ctx context.Context, store channelAuthStore, linkCodes *auth.LinkCodeStore, ...) (string, bool)
- func TryLinkCodeWithCandidates(ctx context.Context, store channelAuthStore, 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) (<-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 channelAuthStore, 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, users auth.UserStore) *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.User, 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
}
func NewCoordinator ¶
func NewCoordinator(
pm interface {
agent.ServiceManager
userInvalidator
},
store config.Store,
listFn func() []pkgchannel.ModelOption,
switchFn func(provider, model string) error,
opts ...CoordinatorOption,
) *Coordinator
NewCoordinator creates a Coordinator that satisfies pkgchannel.Handler. pm must implement both agent.ServiceManager (for routing) and userInvalidator (for /config secret updates). *agent.PoolManager satisfies both.
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 checks whether a channel identity exists for the sender. Returns an error if the identity is not found — the user must first log in via OIDC and link their channel account.
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(store channelAuthStore, 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 at creation time.
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 {
Service *agent.Service
User auth.User
AgentID string
SessionKey string
Channel session.Channel
ChatCtx ChatContext
}
func Resolve ¶
func Resolve(ctx context.Context, sm agent.ServiceManager, store config.Store, authStore channelAuthStore, engine *auth.PolicyEngine, platform, senderID, senderName, chatID string, isGroup bool) (*ResolvedChat, error)
func ResolveWithChannel ¶
func ResolveWithChannel(ctx context.Context, sm agent.ServiceManager, store config.Store, authStore channelAuthStore, engine *auth.PolicyEngine, platform, channelID, senderID string, senderIDs []string, senderName, chatID string, isGroup bool) (*ResolvedChat, error)
func (*ResolvedChat) Chat ¶
func (rc *ResolvedChat) Chat(ctx context.Context, message agent.MessageContent) (<-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 ResolvedIdentity ¶
func ResolveUser ¶
func ResolveUser(ctx context.Context, store channelAuthStore, platform, externalID string) (ResolvedIdentity, error)
func ResolveUserCandidates ¶
type StreamFuncBuilder ¶ added in v0.28.0
type StreamFuncBuilder func(context.Context, string, config.ProviderCreds) (providers.StreamFunc, error)