Documentation
¶
Index ¶
- Constants
- type ActiveChatLister
- type ChannelCreator
- type ChannelEnsurer
- type ChannelLister
- type ContainerFinder
- type ContainerStopper
- type EnsureResult
- type Event
- type EventsHub
- func (h *EventsHub) Broadcast(evt Event)
- func (h *EventsHub) BroadcastAgentActivity(channelID string, data events.AgentActivityEventData)
- func (h *EventsHub) BroadcastAgentStatus(channelID string, data events.AgentStatusEventData)
- func (h *EventsHub) BroadcastChannelCreated(parentChannelID, channelID string)
- func (h *EventsHub) BroadcastChannelDeleted(channelID string)
- func (h *EventsHub) BroadcastMessageCreated(channelID string, data events.MessageEventData)
- func (h *EventsHub) BroadcastMessageStreaming(channelID string, data events.MessageStreamingData)
- func (h *EventsHub) BroadcastToolUse(channelID string, data events.ToolUseEventData)
- func (h *EventsHub) Register(conn *websocket.Conn, channels []string) *eventConn
- func (h *EventsHub) Unregister(ec *eventConn)
- type IncomingMessageHandler
- type InteractionHandler
- type InteractiveCmdBuilder
- type MemoryIndexer
- type MessageSender
- type RunningChannelLister
- type Server
- func (s *Server) EventsHub() *EventsHub
- func (s *Server) SetActiveChatLister(lister ActiveChatLister)
- func (s *Server) SetContainerFinder(finder ContainerFinder)
- func (s *Server) SetContainerStopper(stopper ContainerStopper)
- func (s *Server) SetEventsHub(hub *EventsHub)
- func (s *Server) SetHostTerminalManager(mgr TerminalManager)
- func (s *Server) SetIncomingMessageHandler(h IncomingMessageHandler)
- func (s *Server) SetInteractionHandler(h InteractionHandler)
- func (s *Server) SetInteractiveCmdBuilder(builder InteractiveCmdBuilder)
- func (s *Server) SetLoopDir(dir string)
- func (s *Server) SetMemoryIndexer(idx MemoryIndexer)
- func (s *Server) SetRunningChannelLister(lister RunningChannelLister)
- func (s *Server) SetStopError(err error)
- func (s *Server) SetTerminalManager(mgr TerminalManager)
- func (s *Server) Start(addr string) error
- func (s *Server) Stop(ctx context.Context) error
- type TerminalManager
- type ThreadCreator
- type ThreadEnsurer
Constants ¶
const ( EventMessageCreated = "message.created" EventMessageStreaming = "message.streaming" EventAgentStatus = "agent.status" EventToolUse = "tool.use" EventAgentActivity = "agent.activity" EventChannelCreated = "channel.created" EventChannelDeleted = "channel.deleted" )
Event type constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveChatLister ¶ added in v0.1.68
type ActiveChatLister interface {
ActiveChatChannelIDs() map[string]struct{}
}
ActiveChatLister returns channel IDs with active chat agent runs.
type ChannelCreator ¶
type ChannelCreator interface {
CreateChannel(ctx context.Context, 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
}
ChannelCreator can create channels on the chat platform.
type ChannelEnsurer ¶
type ChannelEnsurer interface {
EnsureChannel(ctx context.Context, dirPath, platform string) (string, error)
CreateChannel(ctx context.Context, name, authorID, sourceChannelID, platform string) (string, error)
EnsureChannelAllPlatforms(ctx context.Context, dirPath string) ([]EnsureResult, error)
}
ChannelEnsurer resolves a directory path to a channel ID, creating the channel if it does not yet exist.
func NewChannelService ¶
func NewChannelService(store db.Store, creators map[types.Platform]ChannelCreator) ChannelEnsurer
NewChannelService creates a new ChannelEnsurer.
type ChannelLister ¶ added in v0.1.15
type ChannelLister interface {
ListChannels(ctx context.Context) ([]*db.Channel, error)
GetChannel(ctx context.Context, channelID string) (*db.Channel, error)
GetMessagesCursor(ctx context.Context, channelID string, cursor int64, limit int) ([]*db.Message, error)
SearchMessages(ctx context.Context, query string, limit int) ([]*db.Message, error)
GetMessagesAround(ctx context.Context, channelID string, messageID int64, limit int) ([]*db.Message, error)
DeleteChannel(ctx context.Context, channelID string) error
DeleteChannelsByParentID(ctx context.Context, parentID string) error
ListDistinctMemoryFilePaths(ctx context.Context, dirPath string) ([]db.MemoryFileInfo, error)
}
ChannelLister can list, look up, and delete channels and their messages from the database.
type ContainerFinder ¶ added in v0.1.68
type ContainerFinder interface {
FindContainerByChannel(ctx context.Context, channelID, dirPath string) (string, error)
}
ContainerFinder resolves a channel ID to a running container ID.
type ContainerStopper ¶ added in v0.1.68
ContainerStopper removes a container by ID.
type EnsureResult ¶ added in v0.2.0
type EnsureResult struct {
Platform types.Platform `json:"platform"`
ChannelID string `json:"channel_id"`
Created bool `json:"created"`
}
EnsureResult describes the outcome of ensuring a channel for one platform.
type Event ¶ added in v0.1.68
type Event struct {
Type string `json:"type"`
ChannelID string `json:"channel_id"`
Data any `json:"data"`
Timestamp int64 `json:"timestamp"`
}
Event represents a server-sent event to WebSocket clients.
type EventsHub ¶ added in v0.1.68
type EventsHub struct {
// contains filtered or unexported fields
}
EventsHub manages WebSocket event subscribers and broadcasts events.
Thread-safety: The hub's subscriber set is protected by mu (RWMutex). Broadcast takes a snapshot of subscribers under RLock, then releases the lock before writing to each connection. Each connection has its own writeMu to serialize writes. This means a concurrent Unregister may remove a subscriber that Broadcast is about to write to — this is safe because writeMu still guards the connection, and a failed write triggers Unregister (idempotent delete from the map).
func NewEventsHub ¶ added in v0.1.68
NewEventsHub creates a new EventsHub.
func (*EventsHub) Broadcast ¶ added in v0.1.68
Broadcast sends an event to all subscribers whose channel filter matches.
func (*EventsHub) BroadcastAgentActivity ¶ added in v0.2.0
func (h *EventsHub) BroadcastAgentActivity(channelID string, data events.AgentActivityEventData)
BroadcastAgentActivity sends an agent.activity event (model, subagent progress, etc.).
func (*EventsHub) BroadcastAgentStatus ¶ added in v0.1.68
func (h *EventsHub) BroadcastAgentStatus(channelID string, data events.AgentStatusEventData)
BroadcastAgentStatus sends an agent.status event.
func (*EventsHub) BroadcastChannelCreated ¶ added in v0.2.0
BroadcastChannelCreated sends a channel.created event to the parent channel.
func (*EventsHub) BroadcastChannelDeleted ¶ added in v0.2.0
BroadcastChannelDeleted sends a channel.deleted event.
func (*EventsHub) BroadcastMessageCreated ¶ added in v0.1.68
func (h *EventsHub) BroadcastMessageCreated(channelID string, data events.MessageEventData)
BroadcastMessageCreated sends a message.created event.
func (*EventsHub) BroadcastMessageStreaming ¶ added in v0.1.68
func (h *EventsHub) BroadcastMessageStreaming(channelID string, data events.MessageStreamingData)
BroadcastMessageStreaming sends a message.streaming event with partial bot response.
func (*EventsHub) BroadcastToolUse ¶ added in v0.2.0
func (h *EventsHub) BroadcastToolUse(channelID string, data events.ToolUseEventData)
BroadcastToolUse sends a tool.use event.
func (*EventsHub) Unregister ¶ added in v0.1.68
func (h *EventsHub) Unregister(ec *eventConn)
Unregister removes a subscriber.
type IncomingMessageHandler ¶ added in v0.1.68
type IncomingMessageHandler interface {
HandleIncomingMessage(ctx context.Context, channelID, authorID, content, mode string)
HandleThreadCreated(ctx context.Context, threadID, authorID, message string)
}
IncomingMessageHandler processes a user message from the API, routing it through the orchestrator so Claude can respond.
type InteractionHandler ¶ added in v0.1.68
type InteractionHandler interface {
HandleInteraction(ctx context.Context, inter *bot.Interaction)
}
InteractionHandler processes a parsed slash command interaction.
type InteractiveCmdBuilder ¶ added in v0.1.68
type InteractiveCmdBuilder interface {
BuildInteractiveCmd(channelID, dirPath, sessionID string, forkSession bool) string
}
InteractiveCmdBuilder builds the interactive Claude command for a terminal session.
type MemoryIndexer ¶ added in v0.1.33
type MemoryIndexer interface {
Search(ctx context.Context, memoryDir, query string, topK int) ([]memory.SearchResult, error)
Index(ctx context.Context, memoryDir string) (int, error)
}
MemoryIndexer abstracts memory search and indexing for the memory API endpoints.
type MessageSender ¶ added in v0.1.15
MessageSender can send messages to channels or threads.
type RunningChannelLister ¶ added in v0.1.68
type RunningChannelLister interface {
RunningChannelIDs(ctx context.Context) (map[string]struct{}, error)
}
RunningChannelLister returns the set of channel IDs that have running containers.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server exposes a lightweight HTTP API for task CRUD operations.
func NewServer ¶
func NewServer(sched scheduler.Scheduler, channels ChannelEnsurer, threads ThreadEnsurer, store ChannelLister, messages MessageSender, logger *slog.Logger) *Server
NewServer creates a new API server. The channels, threads, store, and messages parameters may be nil if those features are not configured.
func (*Server) EventsHub ¶ added in v0.1.68
EventsHub returns the configured events hub, or nil if not set.
func (*Server) SetActiveChatLister ¶ added in v0.1.68
func (s *Server) SetActiveChatLister(lister ActiveChatLister)
SetActiveChatLister configures the active chat lister for the channel list endpoint.
func (*Server) SetContainerFinder ¶ added in v0.1.68
func (s *Server) SetContainerFinder(finder ContainerFinder)
SetContainerFinder configures the container finder for channel_id → container resolution.
func (*Server) SetContainerStopper ¶ added in v0.1.68
func (s *Server) SetContainerStopper(stopper ContainerStopper)
SetContainerStopper configures the container stopper for removing containers on session stop.
func (*Server) SetEventsHub ¶ added in v0.1.68
SetEventsHub configures the events hub for the /api/ws endpoint.
func (*Server) SetHostTerminalManager ¶ added in v0.2.0
func (s *Server) SetHostTerminalManager(mgr TerminalManager)
SetHostTerminalManager configures the host terminal manager for non-Docker shell sessions.
func (*Server) SetIncomingMessageHandler ¶ added in v0.1.68
func (s *Server) SetIncomingMessageHandler(h IncomingMessageHandler)
SetIncomingMessageHandler configures the handler for user messages from the API.
func (*Server) SetInteractionHandler ¶ added in v0.1.68
func (s *Server) SetInteractionHandler(h InteractionHandler)
SetInteractionHandler configures the handler for slash command interactions.
func (*Server) SetInteractiveCmdBuilder ¶ added in v0.1.68
func (s *Server) SetInteractiveCmdBuilder(builder InteractiveCmdBuilder)
SetInteractiveCmdBuilder configures the command builder for interactive terminal sessions.
func (*Server) SetLoopDir ¶ added in v0.1.33
SetLoopDir sets the loop directory used for fallback work dir resolution.
func (*Server) SetMemoryIndexer ¶ added in v0.1.33
func (s *Server) SetMemoryIndexer(idx MemoryIndexer)
SetMemoryIndexer configures the memory indexer for the /api/memory/* endpoints.
func (*Server) SetRunningChannelLister ¶ added in v0.1.68
func (s *Server) SetRunningChannelLister(lister RunningChannelLister)
SetRunningChannelLister configures the running channel lister for the channel list endpoint.
func (*Server) SetStopError ¶ added in v0.2.0
SetStopError sets a fixed error that Stop will return instead of calling Shutdown. This is intended for testing shutdown error handling in callers.
func (*Server) SetTerminalManager ¶ added in v0.1.68
func (s *Server) SetTerminalManager(mgr TerminalManager)
SetTerminalManager configures the terminal manager for WebSocket terminal sessions.
type TerminalManager ¶ added in v0.1.68
type TerminalManager interface {
CreateSession(ctx context.Context, containerID string, cmd []string) (sessionID string, output <-chan []byte, history []byte, done <-chan struct{}, err error)
AttachSession(sessionID string) (output <-chan []byte, history []byte, done <-chan struct{}, err error)
DetachSession(sessionID string, output <-chan []byte) error
SendInput(sessionID string, data []byte) error
Resize(ctx context.Context, sessionID string, rows, cols uint) error
StopSession(sessionID string) (containerID string, err error)
}
TerminalManager abstracts the terminal session operations needed by the handler.
type ThreadCreator ¶ added in v0.1.11
type ThreadCreator interface {
CreateThread(ctx context.Context, channelID, name, mentionUserID, message string) (string, error)
DeleteThread(ctx context.Context, threadID string) error
}
ThreadCreator can create and delete threads on the chat platform.
type ThreadEnsurer ¶ added in v0.1.11
type ThreadEnsurer interface {
CreateThread(ctx context.Context, channelID, name, authorID, message string) (string, error)
DeleteThread(ctx context.Context, threadID string) error
}
ThreadEnsurer manages threads on the chat platform and the DB.
func NewThreadService ¶ added in v0.1.11
func NewThreadService(store db.Store, creator ThreadCreator, logger *slog.Logger) ThreadEnsurer
NewThreadService creates a new ThreadEnsurer.
Source Files
¶
- channel_service.go
- channels_handler.go
- commands_handler.go
- diff_handler.go
- events_handler.go
- events_hub.go
- files_handler.go
- helpers.go
- memory_files_handler.go
- memory_handler.go
- message_service.go
- messages_handler.go
- readme_handler.go
- server.go
- tasks_handler.go
- terminal_handler.go
- thread_service.go
- threads_handler.go