orchestrator

package
v0.1.69 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
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 AgentStatusEventData added in v0.1.68

type AgentStatusEventData struct {
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

AgentStatusEventData is the payload for agent.status events.

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))
	BotUserID() string
	CreateChannel(ctx context.Context, guildID, name string) (string, error)
	InviteUserToChannel(ctx context.Context, channelID, userID string) error
	GetOwnerUserID(ctx context.Context) (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)
	GetMemberRoles(ctx context.Context, guildID, userID string) ([]string, error)
}

Bot represents the chat platform bot interface (Discord or Slack).

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 EventBroadcaster added in v0.1.68

type EventBroadcaster interface {
	BroadcastMessageCreated(channelID string, data MessageEventData)
	BroadcastMessageStreaming(channelID string, data MessageStreamingData)
	BroadcastAgentStatus(channelID string, data AgentStatusEventData)
}

EventBroadcaster broadcasts events to connected clients.

type MessageEventData added in v0.1.68

type MessageEventData struct {
	MsgID      string `json:"msg_id"`
	AuthorID   string `json:"author_id"`
	AuthorName string `json:"author_name"`
	Content    string `json:"content"`
	IsBot      bool   `json:"is_bot"`
}

MessageEventData is the payload for message.created events.

type MessageStreamingData added in v0.1.68

type MessageStreamingData struct {
	Content string `json:"content"`
}

MessageStreamingData is the payload for message.streaming events (partial bot response).

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, platform types.Platform, 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)

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 EventBroadcaster)

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 EventBroadcaster)

SetEventBroadcaster sets the event broadcaster for real-time updates.

func (*TaskExecutor) SetPlatform added in v0.1.68

func (e *TaskExecutor) SetPlatform(p types.Platform)

SetPlatform sets the platform for local-specific behavior.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL