Documentation
¶
Index ¶
- Constants
- type Bot
- type BotRouter
- func (r *BotRouter) BotFor(p types.Platform) Bot
- func (r *BotRouter) BotUserID() string
- func (r *BotRouter) CreateSimpleThread(ctx context.Context, channelID, name, initialMessage string) (string, error)
- func (r *BotRouter) CreateThread(ctx context.Context, channelID, name, mentionUserID, message string) (string, error)
- func (r *BotRouter) DeleteThread(ctx context.Context, threadID string) error
- func (r *BotRouter) GetChannelName(ctx context.Context, channelID string) (string, error)
- func (r *BotRouter) GetChannelParentID(ctx context.Context, channelID string) (string, error)
- func (r *BotRouter) HandleIncomingMessage(ctx context.Context, channelID, authorID, content, mode string)
- func (r *BotRouter) HandleThreadCreated(ctx context.Context, threadID, authorID, message string)
- func (r *BotRouter) InviteUserToChannel(ctx context.Context, channelID, userID string) error
- func (r *BotRouter) IsBotUser(userID string) bool
- func (r *BotRouter) OnChannelDelete(handler func(ctx context.Context, channelID string, isThread bool))
- func (r *BotRouter) OnChannelJoin(handler func(ctx context.Context, channelID string, platform types.Platform))
- func (r *BotRouter) OnInteraction(handler func(ctx context.Context, i *bot.Interaction))
- func (r *BotRouter) OnMessage(handler func(ctx context.Context, msg *bot.IncomingMessage))
- func (r *BotRouter) PostMessage(ctx context.Context, channelID, content string) error
- func (r *BotRouter) RegisterCommands(ctx context.Context) error
- func (r *BotRouter) RemoveCommands(ctx context.Context) error
- func (r *BotRouter) RemoveStopButton(ctx context.Context, channelID, messageID string) error
- func (r *BotRouter) RenameThread(ctx context.Context, threadID, name string) error
- func (r *BotRouter) SendMessage(ctx context.Context, msg *bot.OutgoingMessage) error
- func (r *BotRouter) SendStopButton(ctx context.Context, channelID, runID string) (string, error)
- func (r *BotRouter) SendTyping(ctx context.Context, channelID string) error
- func (r *BotRouter) SetChannelTopic(ctx context.Context, channelID, topic string) error
- func (r *BotRouter) Start(ctx context.Context) error
- func (r *BotRouter) Stop() error
- type ChannelQueue
- type ChannelStore
- type Orchestrator
- func (o *Orchestrator) ActiveChatChannelIDs() map[string]struct{}
- func (o *Orchestrator) HandleChannelDelete(ctx context.Context, channelID string, isThread bool)
- func (o *Orchestrator) HandleChannelJoin(ctx context.Context, channelID string, platform types.Platform)
- func (o *Orchestrator) HandleInteraction(ctx context.Context, inter *bot.Interaction)
- func (o *Orchestrator) HandleMessage(ctx context.Context, msg *bot.IncomingMessage)
- func (o *Orchestrator) SetEventBroadcaster(eb events.Broadcaster)
- func (o *Orchestrator) Start(ctx context.Context) error
- func (o *Orchestrator) Stop() error
- type Runner
- type TaskExecutor
Constants ¶
const TypingInterval = 8 * time.Second
TypingInterval is the default interval between typing indicator refreshes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot interface {
Start(ctx context.Context) error
Stop() error
SendMessage(ctx context.Context, msg *bot.OutgoingMessage) error
SendTyping(ctx context.Context, channelID string) error
SendStopButton(ctx context.Context, channelID, runID string) (messageID string, err error)
RemoveStopButton(ctx context.Context, channelID, messageID string) error
RegisterCommands(ctx context.Context) error
RemoveCommands(ctx context.Context) error
OnMessage(handler func(ctx context.Context, msg *bot.IncomingMessage))
OnInteraction(handler func(ctx context.Context, i *bot.Interaction))
OnChannelDelete(handler func(ctx context.Context, channelID string, isThread bool))
OnChannelJoin(handler func(ctx context.Context, channelID string, platform types.Platform))
BotUserID() string
IsBotUser(userID string) bool
InviteUserToChannel(ctx context.Context, channelID, userID string) error
SetChannelTopic(ctx context.Context, channelID, topic string) error
CreateThread(ctx context.Context, channelID, name, mentionUserID, message string) (string, error)
PostMessage(ctx context.Context, channelID, content string) error
DeleteThread(ctx context.Context, threadID string) error
RenameThread(ctx context.Context, threadID, name string) error
GetChannelParentID(ctx context.Context, channelID string) (string, error)
GetChannelName(ctx context.Context, channelID string) (string, error)
CreateSimpleThread(ctx context.Context, channelID, name, initialMessage string) (string, error)
HandleIncomingMessage(ctx context.Context, channelID, authorID, content, mode string)
HandleThreadCreated(ctx context.Context, threadID, authorID, message string)
}
Bot represents the chat platform bot interface (Discord or Slack).
type BotRouter ¶ added in v0.2.0
type BotRouter struct {
// contains filtered or unexported fields
}
BotRouter implements Bot by routing calls to the correct platform-specific bot based on channel platform from the database.
func NewBotRouter ¶ added in v0.2.0
NewBotRouter creates a BotRouter wrapping the given platform bots.
func (*BotRouter) BotFor ¶ added in v0.2.0
BotFor returns the bot for the given platform, or nil if not found.
func (*BotRouter) CreateSimpleThread ¶ added in v0.2.0
func (*BotRouter) CreateThread ¶ added in v0.2.0
func (*BotRouter) DeleteThread ¶ added in v0.2.0
func (*BotRouter) GetChannelName ¶ added in v0.2.0
func (*BotRouter) GetChannelParentID ¶ added in v0.2.0
func (*BotRouter) HandleIncomingMessage ¶ added in v0.2.0
func (*BotRouter) HandleThreadCreated ¶ added in v0.2.0
func (*BotRouter) InviteUserToChannel ¶ added in v0.2.0
func (*BotRouter) IsBotUser ¶ added in v0.2.0
IsBotUser returns true if userID matches ANY bot's user ID.
func (*BotRouter) OnChannelDelete ¶ added in v0.2.0
func (*BotRouter) OnChannelJoin ¶ added in v0.2.0
func (*BotRouter) OnInteraction ¶ added in v0.2.0
func (r *BotRouter) OnInteraction(handler func(ctx context.Context, i *bot.Interaction))
func (*BotRouter) OnMessage ¶ added in v0.2.0
func (r *BotRouter) OnMessage(handler func(ctx context.Context, msg *bot.IncomingMessage))
func (*BotRouter) PostMessage ¶ added in v0.2.0
func (*BotRouter) RegisterCommands ¶ added in v0.2.0
func (*BotRouter) RemoveCommands ¶ added in v0.2.0
func (*BotRouter) RemoveStopButton ¶ added in v0.2.0
func (*BotRouter) RenameThread ¶ added in v0.2.0
func (*BotRouter) SendMessage ¶ added in v0.2.0
func (*BotRouter) SendStopButton ¶ added in v0.2.0
func (*BotRouter) SendTyping ¶ added in v0.2.0
func (*BotRouter) SetChannelTopic ¶ added in v0.2.0
type ChannelQueue ¶
type ChannelQueue struct {
// contains filtered or unexported fields
}
ChannelQueue provides per-channel concurrency control, ensuring only one agent container runs per channel at a time.
func NewChannelQueue ¶
func NewChannelQueue() *ChannelQueue
NewChannelQueue creates a new ChannelQueue.
func (*ChannelQueue) Acquire ¶
func (q *ChannelQueue) Acquire(channelID string)
Acquire blocks until the channel slot is available, then acquires it.
func (*ChannelQueue) Release ¶
func (q *ChannelQueue) Release(channelID string)
Release releases the channel slot so the next request can proceed.
type ChannelStore ¶ added in v0.2.0
type ChannelStore interface {
GetChannel(ctx context.Context, channelID string) (*db.Channel, error)
}
ChannelStore is the subset of db.Store needed by BotRouter for channel lookups.
type Orchestrator ¶
type Orchestrator struct {
// contains filtered or unexported fields
}
Orchestrator coordinates all components of the loop bot.
func New ¶
func New(store db.Store, bot Bot, runner Runner, sched scheduler.Scheduler, logger *slog.Logger, cfg config.Config) *Orchestrator
New creates a new Orchestrator.
func (*Orchestrator) ActiveChatChannelIDs ¶ added in v0.1.68
func (o *Orchestrator) ActiveChatChannelIDs() map[string]struct{}
ActiveChatChannelIDs returns the set of channel IDs that have an active chat agent run (as opposed to just having a running container for terminal use).
func (*Orchestrator) HandleChannelDelete ¶ added in v0.1.12
func (o *Orchestrator) HandleChannelDelete(ctx context.Context, channelID string, isThread bool)
HandleChannelDelete removes a deleted channel or thread from the database. For channels (not threads), it also removes all child threads. MCP config files are cleaned up on a best-effort basis.
func (*Orchestrator) HandleChannelJoin ¶ added in v0.1.22
func (o *Orchestrator) HandleChannelJoin(ctx context.Context, channelID string, platform types.Platform)
HandleChannelJoin auto-registers a channel when the bot is added to it.
func (*Orchestrator) HandleInteraction ¶
func (o *Orchestrator) HandleInteraction(ctx context.Context, inter *bot.Interaction)
HandleInteraction processes a slash command interaction.
func (*Orchestrator) HandleMessage ¶
func (o *Orchestrator) HandleMessage(ctx context.Context, msg *bot.IncomingMessage)
HandleMessage processes an incoming chat message.
func (*Orchestrator) SetEventBroadcaster ¶ added in v0.1.68
func (o *Orchestrator) SetEventBroadcaster(eb events.Broadcaster)
SetEventBroadcaster configures the event broadcaster for real-time event streaming.
func (*Orchestrator) Start ¶
func (o *Orchestrator) Start(ctx context.Context) error
Start registers handlers, slash commands, and starts the bot and scheduler.
func (*Orchestrator) Stop ¶
func (o *Orchestrator) Stop() error
Stop gracefully shuts down the bot, scheduler, and runner.
type Runner ¶
type Runner interface {
Run(ctx context.Context, req *agent.AgentRequest) (*agent.AgentResponse, error)
Cleanup(ctx context.Context) error
}
Runner runs Claude agent in a container.
type TaskExecutor ¶
type TaskExecutor struct {
// contains filtered or unexported fields
}
TaskExecutor implements scheduler.TaskExecutor by running an agent and delivering the response to the chat platform.
func NewTaskExecutor ¶
func NewTaskExecutor(runner Runner, bot Bot, store db.Store, logger *slog.Logger, containerTimeout time.Duration, streamingEnabled bool) *TaskExecutor
NewTaskExecutor creates a new TaskExecutor.
func (*TaskExecutor) ExecuteTask ¶
func (e *TaskExecutor) ExecuteTask(ctx context.Context, task *db.ScheduledTask) (string, error)
ExecuteTask runs an agent for the given scheduled task and sends the result to the chat platform.
func (*TaskExecutor) SetEventBroadcaster ¶ added in v0.1.68
func (e *TaskExecutor) SetEventBroadcaster(eb events.Broadcaster)
SetEventBroadcaster sets the event broadcaster for real-time updates.