Documentation
¶
Overview ¶
Package channels provides shared helpers used by all chat-platform gateways.
Package channels manages the mapping from external chat platforms to agent sessions. Each unique (platform, chatID) pair is bound to a persistent session in a specific workspace so conversation history survives restarts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureSession ¶
EnsureSession returns the existing session ID for (platform, chatID) or creates a new channel session in workspacePath using the given provider/model. If provider or model is empty, it falls back to the best available provider via ai.Global.BestProvider so we never pass an empty model to the LLM.
func RunAgentTurn ¶
func RunAgentTurn(ctx context.Context, cfg TurnConfig) string
RunAgentTurn finds-or-creates a session for the chat, runs one agent turn, and returns the assistant's reply text. It handles all session lifecycle bookkeeping (ClearLiveEvents, RegisterSession, status updates).
func SplitMessage ¶
SplitMessage splits text into chunks of at most maxLen runes, breaking at word or newline boundaries where possible.
Types ¶
type Binding ¶
type Binding struct {
Platform string `json:"platform"` // e.g. "telegram"
ChatID string `json:"chatId"` // platform-specific conversation ID
SessionID string `json:"sessionId"` // tollecode session UUID
WorkspacePath string `json:"workspacePath"`
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
}
Binding maps one external chat conversation to a tollecode session.
type TurnConfig ¶
type TurnConfig struct {
Platform string // "telegram" | "discord" | "slack" | "whatsapp" | "signal"
ChatID string // platform-specific conversation identifier
WorkspacePath string
Provider string
Model string
ShellAutoAllow bool
Message string
// RequestPerm, when set, overrides the default permission handler.
// When nil, RunAgentTurn falls back to auto-allow/deny based on ShellAutoAllow.
// The function should show a prompt to the user, wait for approval, and return
// (allow, allowAll). "kind" is "shell" or "write". "detail" is e.g. the
// command or file path.
RequestPerm func(ctx context.Context, kind, detail string) (allow, allowAll bool)
}
TurnConfig is the per-message configuration passed to RunAgentTurn.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package discord implements a Discord bot gateway via the Discord Gateway WebSocket API.
|
Package discord implements a Discord bot gateway via the Discord Gateway WebSocket API. |
|
Package signal implements a Signal gateway via the signal-cli daemon.
|
Package signal implements a Signal gateway via the signal-cli daemon. |
|
Package slack implements a Slack bot gateway using the Slack Events API (webhook mode).
|
Package slack implements a Slack bot gateway using the Slack Events API (webhook mode). |
|
Package telegram implements a Telegram bot gateway via the Bot API long-polling interface.
|
Package telegram implements a Telegram bot gateway via the Bot API long-polling interface. |
|
Package whatsapp implements a WhatsApp bot gateway via the Meta Cloud API.
|
Package whatsapp implements a WhatsApp bot gateway via the Meta Cloud API. |