dispatch

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPollInterval = 10 * time.Second

DefaultPollInterval is the default interval between Telegram polls.

View Source
const DefaultPromptTemplate = `The following task was sent via Telegram. Create an implementation ticket on Linear (HUM) for it, then execute the plan: %s`

DefaultPromptTemplate is the prompt sent to idle Claude agents. Must be a single line — tmux send-keys treats newlines as Enter keypresses.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	SessionName string
	WindowIndex int
	PaneIndex   int
	Label       string // e.g. "session:0.1"
}

Agent represents a Claude tmux pane that can receive work.

type AgentFinder

type AgentFinder interface {
	FindIdleAgents(ctx context.Context) ([]Agent, error)
}

AgentFinder discovers idle Claude tmux panes.

type AgentSender

type AgentSender interface {
	SendPrompt(ctx context.Context, agent Agent, prompt string) error
}

AgentSender sends a prompt to a tmux pane.

type CompositeNotifier

type CompositeNotifier struct {
	Notifiers []Notifier
}

CompositeNotifier fans out notifications to multiple notifiers. All notifiers are called; the first error is returned.

func (*CompositeNotifier) Notify

func (c *CompositeNotifier) Notify(ctx context.Context, chatID int64, text string) error

Notify calls all wrapped notifiers. It does not short-circuit: every notifier is called even if an earlier one fails.

type Config

type Config struct {
	PollInterval time.Duration
}

Config holds dispatcher configuration.

type Dispatcher

type Dispatcher struct {
	Source   MessageSource
	Finder   AgentFinder
	Sender   AgentSender
	Notifier Notifier
	Config   Config
	Logger   zerolog.Logger
	// contains filtered or unexported fields
}

Dispatcher polls Telegram and dispatches messages to idle Claude agents.

func (*Dispatcher) Run

func (d *Dispatcher) Run(ctx context.Context) error

Run starts the dispatch loop. It blocks until ctx is cancelled.

type MessageSource

type MessageSource interface {
	FetchMessages(ctx context.Context) ([]QueuedMessage, error)
	AckMessage(ctx context.Context, updateID int) error
}

MessageSource fetches and acknowledges Telegram messages.

type Notifier

type Notifier interface {
	Notify(ctx context.Context, chatID int64, text string) error
}

Notifier sends a notification back to the user.

type QueuedMessage

type QueuedMessage struct {
	UpdateID int
	ChatID   int64
	From     string
	Text     string
}

QueuedMessage holds a Telegram message waiting for dispatch.

type SlackNotifier

type SlackNotifier struct {
	Client SlackSender
}

SlackNotifier notifies a Slack channel about dispatch events. The channel is pre-configured on the SlackSender.

func (*SlackNotifier) Notify

func (n *SlackNotifier) Notify(ctx context.Context, _ int64, text string) error

Notify sends a text message to the configured Slack channel. The chatID parameter is ignored (it is Telegram-specific).

type SlackSender

type SlackSender interface {
	SendMessage(ctx context.Context, text string) error
}

SlackSender is the subset of slack.Client needed to send messages.

type TelegramFetcher

type TelegramFetcher interface {
	GetUpdates(ctx context.Context, limit int) ([]telegram.Update, error)
	AckUpdate(ctx context.Context, updateID int) error
}

TelegramFetcher is the subset of telegram.Client needed to fetch messages.

type TelegramNotifier

type TelegramNotifier struct {
	Client TelegramSender
}

TelegramNotifier notifies a Telegram chat about dispatch events.

func (*TelegramNotifier) Notify

func (n *TelegramNotifier) Notify(ctx context.Context, chatID int64, text string) error

Notify sends a text message to the given chat.

type TelegramSender

type TelegramSender interface {
	SendMessage(ctx context.Context, chatID int64, text string) error
}

TelegramSender is the subset of telegram.Client needed to send messages.

type TelegramSource

type TelegramSource struct {
	Client       TelegramFetcher
	AllowedUsers []int64
	AllowedChats []int64 // see telegram.Config.AllowedChats
	Logger       zerolog.Logger
	// contains filtered or unexported fields
}

TelegramSource adapts a Telegram client to the MessageSource interface.

func (*TelegramSource) AckMessage

func (s *TelegramSource) AckMessage(ctx context.Context, updateID int) error

AckMessage acknowledges a Telegram update.

func (*TelegramSource) FetchMessages

func (s *TelegramSource) FetchMessages(ctx context.Context) ([]QueuedMessage, error)

FetchMessages returns pending Telegram messages filtered by allowed (user, chat) pairs. Disallowed updates are acknowledged (via AckUpdate) so they do not remain in the Telegram pending queue, logged at WARN with structured fields, and counted in RejectedCount() for observability.

func (*TelegramSource) RejectedCount

func (s *TelegramSource) RejectedCount() uint64

RejectedCount returns the total number of updates that have been rejected (and acked) across the lifetime of this source.

type TmuxAgentFinder

type TmuxAgentFinder struct {
	InstanceFinder claude.InstanceFinder
	TmuxClient     claude.TmuxClient
	ProcessLister  claude.ProcessLister
}

TmuxAgentFinder discovers Claude tmux panes that are available for dispatch.

func (*TmuxAgentFinder) FindIdleAgents

func (f *TmuxAgentFinder) FindIdleAgents(_ context.Context) ([]Agent, error)

FindIdleAgents returns Claude tmux panes available for dispatch. Activity detection is not yet implemented — always returns nil.

type TmuxSender

type TmuxSender struct {
	Runner claude.CommandRunner
}

TmuxSender sends prompts to tmux panes via send-keys.

func (*TmuxSender) SendPrompt

func (s *TmuxSender) SendPrompt(ctx context.Context, agent Agent, prompt string) error

SendPrompt types the prompt into the target tmux pane and presses Enter.

Jump to

Keyboard shortcuts

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