Documentation
¶
Index ¶
Constants ¶
This section is empty.
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 *OutgoingMessage) error
SendTyping(ctx context.Context, channelID string) error
RegisterCommands(ctx context.Context) error
RemoveCommands(ctx context.Context) error
OnMessage(handler func(ctx context.Context, msg *IncomingMessage))
OnInteraction(handler func(ctx context.Context, i any))
BotUserID() string
CreateChannel(ctx context.Context, guildID, name string) (string, error)
CreateThread(ctx context.Context, channelID, name string) (string, error)
GetChannelParentID(ctx context.Context, channelID string) (string, error)
}
Bot represents the Discord bot interface.
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 IncomingMessage ¶
type IncomingMessage struct {
ChannelID string
GuildID string
AuthorID string
AuthorName string
Content string
MessageID string
IsBotMention bool
IsReplyToBot bool
HasPrefix bool
IsDM bool
Timestamp time.Time
}
IncomingMessage from Discord.
type Interaction ¶
type Interaction struct {
ChannelID string
GuildID string
CommandName string
Options map[string]string
}
Interaction represents a Discord slash command interaction.
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, scheduler Scheduler, logger *slog.Logger, templates []config.TaskTemplate, containerTimeout time.Duration, loopDir string) *Orchestrator
New creates a new Orchestrator.
func (*Orchestrator) HandleInteraction ¶
func (o *Orchestrator) HandleInteraction(ctx context.Context, interaction any)
HandleInteraction processes a Discord slash command interaction.
func (*Orchestrator) HandleMessage ¶
func (o *Orchestrator) HandleMessage(ctx context.Context, msg *IncomingMessage)
HandleMessage processes an incoming Discord message.
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 OutgoingMessage ¶
OutgoingMessage to Discord.
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 Scheduler ¶
type Scheduler interface {
Start(ctx context.Context) error
Stop() error
AddTask(ctx context.Context, task *db.ScheduledTask) (int64, error)
RemoveTask(ctx context.Context, taskID int64) error
ListTasks(ctx context.Context, channelID string) ([]*db.ScheduledTask, error)
SetTaskEnabled(ctx context.Context, taskID int64, enabled bool) error
ToggleTask(ctx context.Context, taskID int64) (bool, error)
EditTask(ctx context.Context, taskID int64, schedule, taskType, prompt *string) error
}
Scheduler manages scheduled tasks.
type TaskExecutor ¶
type TaskExecutor struct {
// contains filtered or unexported fields
}
TaskExecutor implements scheduler.TaskExecutor by running an agent and delivering the response to Discord.
func NewTaskExecutor ¶
func NewTaskExecutor(runner Runner, bot Bot, store db.Store, logger *slog.Logger, containerTimeout time.Duration) *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 Discord.