orchestrator

package
v0.1.59 Latest Latest
Warning

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

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

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 *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 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) 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.

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

Jump to

Keyboard shortcuts

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