Documentation
¶
Overview ¶
Package background tells which background work an agent conversation still has running — shells, monitors, async agents and pending wakeups started from its transcript — reconciled with the agent's own footer, and keeps that list current for every live tab.
Index ¶
Constants ¶
const ( Shell = "shell" Monitor = "monitor" Agent = "agent" Wakeup = "wakeup" )
Kinds of background work.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counts ¶
type Counts struct{ Shell, Monitor int }
Counts is what the agent's own footer says is running (`· 2 shells, 1 monitor ·`); its `← N agent` counts peers, not background work.
func ParseFooter ¶
ParseFooter reads the footer from a plain capture of the pane; nil when the last lines are not one.
type Deps ¶
type Deps struct {
ReadTasks func(transcript string) []Task
// ReadPane is a plain capture of the agent's pane: its footer is the authority on shells and monitors still running.
ReadPane func(tmuxSession string) (string, bool)
Reconcile func(tasks []Task, pane string, ok bool) []Task
Publish func(tabID string, tasks []Task)
Forget func(transcript string)
}
Deps are what the feed reads with and publishes to.
type Feed ¶
type Feed struct {
// contains filtered or unexported fields
}
Feed keeps the background work of every live agent tab, recomputed when something happened to the tab (a transcript write, a hook, a state change) and published only when it changed.
func (*Feed) Remove ¶
Remove: the agent is gone or the tab closed, so its background work is over as far as the page is concerned.
func (*Feed) Snapshot ¶
Snapshot is every tab with background work, for a client that just connected.
type Ms ¶
type Ms float64
Ms is a time in epoch milliseconds; an unparsable time is NaN and written as null.
func (Ms) MarshalJSON ¶
type Reader ¶
type Reader struct {
// TempDir is where the agent keeps task output (<TempDir>/claude-<uid>/<project>/<session>/tasks/<id>.output).
TempDir string
UID int
Now func() float64 // epoch milliseconds
// contains filtered or unexported fields
}
Reader keeps one cursor per transcript: read once from its tail, then only what was appended since, so a busy agent's every write costs the new lines, not the whole tail again.
type Source ¶
type Source struct {
TmuxSession string
Transcript string // "" when the tab has none yet
Provider string
}
Source is where a tab's background work is read from.
type Task ¶
type Task struct {
ID string `json:"id"`
Kind string `json:"kind"`
Label string `json:"label"`
StartedAt Ms `json:"startedAt"`
Until *Ms `json:"until,omitempty"` // wakeups and expiring monitors are pending only until then
Output *string `json:"outputPath,omitempty"` // gone means the task is over
}
Task is one piece of background work. Times are epoch milliseconds.
func ParseTasks ¶
ParseTasks is the background work a whole transcript leaves running; now is epoch milliseconds.
type Timings ¶
type Timings struct {
// MinInterval: one tab reads its transcript at most this often, however fast the transcript grows.
MinInterval time.Duration
// PaneRefresh: the footer is captured when the transcript's tasks changed, after an event, else at most this often.
PaneRefresh time.Duration
// Recheck: tabs with work are read again this often although nothing was written — a shell can end, a wakeup come
// due and an output file go away without a line in the transcript.
Recheck time.Duration
// MaxReads: a restart finds every live agent at once; their cold tails are read a few at a time.
MaxReads int
}
Timings of the feed; the zero value is the production one.