status

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package status keeps the work state of every tab: what its agent is doing (idle, busy, waiting for an answer, done), learnt from the agent's hooks, its transcript, its screen and its process tree, and pushed to every status socket.

Index

Constants

View Source
const (
	Idle           = "idle"
	Busy           = "busy"
	Inactive       = "inactive"
	ReadyForReview = "ready-for-review"
	NeedsInput     = "needs-input"
	Cancelled      = "cancelled"
	Unknown        = "unknown"
)

Work states of a tab.

View Source
const (
	EventSessionStart = "session-start"
	EventPromptSubmit = "prompt-submit"
	EventNotification = "notification"
	EventStop         = "stop"
	EventStopFailure  = "stop-failure"
	EventInterrupt    = "interrupt"
	EventPreCompact   = "pre-compact"
	EventPostCompact  = "post-compact"
)

Event names that move the state.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentSessions added in v0.16.86

type AgentSessions interface {
	AgentSessions(children []int) []string
}

AgentSessions is a provider that can tell which sessions the agent a pane runs goes by (Claude: by its pid file), nil when it cannot. The keeper asks it to tell a hook of the tab's agent from one of an agent started inside it.

type AgentSource

type AgentSource struct {
	TabID, TmuxSession, Transcript, Provider, PanelType, CliState, LastEventName, AgentSessionID string
	EventSeq                                                                                     int
	LastEventAt, LastStartedAt                                                                   *float64
}

AgentSource is an agent tab as idle sleep and background activity read it.

type Broadcaster

type Broadcaster interface {
	Broadcast(v any, exclude *sockets.Client)
	Shutdown()
}

Broadcaster is where status messages go: the status sockets.

type ChatState

type ChatState struct {
	CliState, Event            string
	Transcript, AgentSessionID string
}

ChatState is where a chat's actor stands, in the keeper's words: CliState empty leaves the state as it is, Event names the hook the change stands for ("" none).

type ClientEntry

type ClientEntry json.RawMessage

ClientEntry is an entry ready to be written as JSON.

func (ClientEntry) MarshalJSON

func (c ClientEntry) MarshalJSON() ([]byte, error)

type ClientView

type ClientView struct {
	TabID, PanelType, CliState, AgentSummary, TabName, WorkspaceID, TmuxSession, Transcript string
	// LastEventAt is 0 when the tab has seen no event.
	LastEventAt float64
}

ClientView is what a page reads of a tab: its kind, state, names and workspace.

type Deps

type Deps struct {
	Layouts   Layouts
	Tmux      Tmux
	Procs     Procs
	Providers map[string]Provider
	Queue     Queue
	History   *history.Store
	Push      Pusher
	// ChatSession says the tab's tmux session is a chat's, which follows its agent's transcript itself (convo): the
	// poll reads no transcript and no process tree for such a tab once it knows it, and the keeper neither watches its
	// transcript nor pushes nor snapshots its folder at a turn's end: the chat's actor does (convo.Notice). nil: no
	// tab is.
	ChatSession func(session string) bool
	// TurnEnd snapshots the session folder for rewinding once a turn ended.
	TurnEnd func(tabID, cwd string)
	// AskFolderTrust leaves an agent's folder trust dialog to the person; by default the keeper answers yes for the
	// folder the tab was started in, since the dialog is not on the page.
	AskFolderTrust bool
	// AgentLaunched hears of every agent the platform starts or resumes in a tab, before the keeper marks it.
	AgentLaunched func(tabID string)
	// Mismatch reports a corrected state.
	Mismatch func(Mismatch)
	// TabRemoved: the keeper forgot a closed tab (its prompt queue goes with it).
	TabRemoved func(tabID string)
	// PromptEnter takes the time since the runtime's last Enter in a pane (ms), once.
	PromptEnter func(session string, now float64) (float64, bool)
	// CodexRateLimits caches the limits a Codex transcript carries.
	CodexRateLimits func(transcript string)
	// BackgroundTasks reads a Claude transcript's background work; ForgetTranscript drops what it remembers of one.
	BackgroundTasks  func(transcript string) []background.Task
	ForgetTranscript func(transcript string)
	// BackgroundTimings are the feed's; zero for production.
	BackgroundTimings background.Timings
	Log               func(level, msg string, kv ...any)
	Now               func() time.Time
	NewID             func() string
}

Deps are everything the keeper reads and drives.

type Entry

type Entry struct {
	CliState             string
	WorkspaceID          string
	TabName              string
	CurrentProcess       Opt[string]
	PaneTitle            Opt[string]
	TmuxSession          string
	PanelType            Opt[string]
	TerminalStatus       Opt[string]
	ListeningPorts       Opt[[]int]
	AgentProviderID      Opt[string]
	AgentSummary         Opt[string]
	LastUserMessage      Opt[string]
	LastAssistantMessage Opt[string]
	CurrentAction        Opt[agents.CurrentAction]
	ReadyForReviewAt     Opt[float64]
	BusySince            Opt[float64]
	DismissedAt          Opt[float64]
	AgentSessionID       Opt[string]
	CompactingSince      Opt[float64]
	PermissionRequest    Opt[json.RawMessage]
	LastEvent            Opt[LastEvent]
	EventSeq             int
	LaunchingSince       *float64
	LaunchFailed         bool
	HooksMissing         bool

	// Kept on the server only.
	JSONLPath       string
	ProcessRetries  int
	StuckCheckedAt  float64
	StuckBackoffMs  float64
	LastHookFiredAt *float64
	HooksCheckedFor *string
	HooksCheckedAt  *float64
	GoneSince       *float64

	LastInterruptTs       float64
	LastResumeOrStartedAt *float64
	// contains filtered or unexported fields
}

Entry is everything the keeper knows about one tab.

type HookMeta

type HookMeta struct {
	SessionID, JSONLPath, LastUserMessage, AgentSummary *Opt[string]
	PermissionRequest                                   *json.RawMessage
	ClearMessages                                       bool
}

HookMeta is what a Codex hook says about the conversation; a nil field is not mentioned.

type LastEvent

type LastEvent struct {
	Name string  `json:"name"`
	At   float64 `json:"at"`
	Seq  int     `json:"seq"`
}

LastEvent is the last event applied to a tab.

type Layouts

type Layouts interface {
	Workspaces() []Workspace
	// Tabs are a workspace's tabs in tree order; ok false when it has no readable layout.
	Tabs(wsID string) ([]Tab, bool)
	UpdateTabCliStatus(session, cliState string, dismissedAt Opt[float64], lastEventName string) error
	// UpdateTabAgentState stores what is set; a set Opt with a nil value stores null.
	UpdateTabAgentState(session, provider string, sessionID, jsonlPath, summary, lastUserMessage Opt[string]) error
	// RecoverSession gives a Claude tab that lost its session id the one its transcript or history shows, stored.
	RecoverSession(session string) (sessionID string, ok bool)
}

Layouts is the layout and workspace store.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager keeps the work state of every tab and tells the status sockets.

func New

func New(d Deps, hub Broadcaster) *Manager

New makes a keeper broadcasting on hub (a *sockets.Hub).

func (*Manager) Ack

func (m *Manager) Ack(tabID string, seq float64)

Ack: the page answered the question its last notification asked.

func (*Manager) AckCurrent

func (m *Manager) AckCurrent(tabID string)

AckCurrent acknowledges the tab's current question, whatever its number (the shadow mirrors the person's answer).

func (*Manager) AdoptSession

func (m *Manager) AdoptSession(tabID, sessionID string)

AdoptSession gives the tab's entry the agent session its layout tab took from the chat's record; an entry that keeps a session keeps it.

func (*Manager) AgentSources

func (m *Manager) AgentSources() []AgentSource

AgentSources are the agent tabs.

func (*Manager) ApplyHookMeta

func (m *Manager) ApplyHookMeta(providerID, session string, meta HookMeta) (tabID, cliState string, ok bool)

ApplyHookMeta takes a Codex hook's conversation details; ok false for an unknown session.

func (*Manager) Background

func (m *Manager) Background() any

Background is every tab with background work (background:sync).

func (*Manager) Broadcast

func (m *Manager) Broadcast(v any)

Broadcast sends any message to every status socket (queue and pane-intent updates).

func (*Manager) ClientViews

func (m *Manager) ClientViews() []ClientView

ClientViews are all tabs, in the keeper's order.

func (*Manager) Dismiss

func (m *Manager) Dismiss(tabID string, exclude *sockets.Client)

Dismiss: the person opened the finished answer. A page's own socket gets no echo of it; the relay does.

func (*Manager) EntryOfSession

func (m *Manager) EntryOfSession(session string) (string, Entry, bool)

EntryOfSession is the tab of a tmux session and a copy of its entry; false when the keeper has none.

func (*Manager) ForeignHook added in v0.16.86

func (m *Manager) ForeignHook(providerID, session string, ev agents.Event) bool

ForeignHook tells a hook to drop: one of an agent the tab's agent (or a script in its terminal) started, which inherits the tab's tmux session and its hooks — its SessionStart and Stop would end the turn of the tab's agent The hook names its agent session; it is the tab's when it is the one the keeper knows, or one the agent running in the pane goes by now (after /clear the pid file names the new session before its SessionStart fires). A hook naming no session, a provider that cannot tell, or a pane with no agent seen: not foreign, as before.

func (*Manager) HandleProviderEvent

func (m *Manager) HandleProviderEvent(providerID, session string, ev agents.Event, firedAt *float64) bool

HandleProviderEvent is a hook's event. firedAt (ms) is when it fired on the machine: the hook reports in the background, so two reports can arrive out of order, and one fired before the last applied one is dropped.

func (*Manager) History

func (m *Manager) History() any

History is the session history, clipped for the wire.

func (*Manager) HooksMissing

func (m *Manager) HooksMissing(tabID string) bool

HooksMissing is whether the agent of a tab runs without the platform's hooks.

func (*Manager) Interrupt

func (m *Manager) Interrupt(tabID string) bool

Interrupt is the Stop button: Escape, then the state settles at once (an agent interrupted before its first output writes nothing to its transcript).

func (*Manager) Interrupted

func (m *Manager) Interrupted(session string)

Interrupted settles the state of a Stop whose Escape was already sent (by the prompt routes): an interrupt hook, so the tab goes idle and its queue goes out 700 ms later.

func (*Manager) IsSessionBusy

func (m *Manager) IsSessionBusy(session string) bool

IsSessionBusy: whether the agent in a tmux session is working (the timeline reads its live reply only then).

func (*Manager) LaunchFailed

func (m *Manager) LaunchFailed(tabID string)

LaunchFailed: a launch the queue asked for cannot come up (nothing to resume); the composer shows it.

func (*Manager) MarkAgentGone

func (m *Manager) MarkAgentGone(tabID string, endLaunch bool)

MarkAgentGone: the agent was killed from the platform; say so now instead of waiting for the poll.

func (*Manager) MarkAgentLaunch

func (m *Manager) MarkAgentLaunch(tabID string, reset bool)

MarkAgentLaunch: a launch or resume line was typed into the tab. reset clears the conversation the tab showed.

func (*Manager) MarkNeedsInputFromScreen

func (m *Manager) MarkNeedsInputFromScreen(tabID string) bool

MarkNeedsInputFromScreen: after a command left a menu open, the agent waits for an answer whatever state it was in.

func (*Manager) MirrorChat

func (m *Manager) MirrorChat(session string, s ChatState)

MirrorChat puts the tab of a chat's tmux session where the chat's actor is, with the side effects a change of state has (the turn's history, the queue, the background feed); the tab of a session that is no chat's is left alone.

func (*Manager) NotifyLastUserMessage

func (m *Manager) NotifyLastUserMessage(session, message string)

NotifyLastUserMessage: the timeline saw a new prompt in the tab of a tmux session.

func (*Manager) Poll

func (m *Manager) Poll()

Poll looks at every tab once. A poll asked for while one runs runs once more after it, instead of being lost.

func (*Manager) Queues

func (m *Manager) Queues() any

Queues is the prompt queue of every tab.

func (*Manager) RateLimits

func (m *Manager) RateLimits() any

RateLimits is the last limits content.

func (*Manager) RateLimitsChanged

func (m *Manager) RateLimitsChanged(data any)

RateLimitsChanged: the limits file got a new measurement.

func (*Manager) RecheckStuck

func (m *Manager) RecheckStuck(tabID string) string

RecheckStuck runs the watchdog on a tab now, whatever its quiet time (after a command ran in it).

func (*Manager) ReconcileWorkspaceTabs

func (m *Manager) ReconcileWorkspaceTabs(wsID string, valid []string)

ReconcileWorkspaceTabs forgets the tabs of a workspace its layout no longer has.

func (*Manager) RecoverSession

func (m *Manager) RecoverSession(tabID string) bool

RecoverSession is recoverEntrySession for the queue.

func (*Manager) RecoverUnknown

func (m *Manager) RecoverUnknown(tabID string) (bool, string)

RecoverUnknown: an unknown tab whose screen shows a permission prompt is waiting for an answer.

func (*Manager) RegisterTab

func (m *Manager) RegisterTab(tabID string, e Entry)

RegisterTab adds a tab a route just created.

func (*Manager) RemoveTab

func (m *Manager) RemoveTab(tabID string)

RemoveTab forgets a closed tab; a turn cut short goes to the history as cancelled.

func (*Manager) RemoveWorkspaceTabs

func (m *Manager) RemoveWorkspaceTabs(wsID string)

RemoveWorkspaceTabs forgets every tab of a removed workspace.

func (*Manager) Rescan

func (m *Manager) Rescan()

Rescan rebuilds every entry (after a tmux reset).

func (*Manager) Start

func (m *Manager) Start(ctx context.Context)

Start scans every tab, then keeps them current until ctx ends.

func (*Manager) SynthesizeEvent

func (m *Manager) SynthesizeEvent(session, event string)

SynthesizeEvent applies an event the runtime inferred itself (a resumed agent whose SessionStart hook never came) the way a hook's event is applied, without what only a real hook proves (the hook order, the hooks being there).

func (*Manager) Tab

func (m *Manager) Tab(tabID string) (TabInfo, bool)

Tab is the queue's view of a tab; ok false when unknown.

func (*Manager) TabOfSession

func (m *Manager) TabOfSession(session string) string

TabOfSession is the agent tab of a tmux session ("" when none).

func (*Manager) Tabs

func (m *Manager) Tabs() any

Tabs is every tab as the page sees it (status:sync).

func (*Manager) Warn

func (m *Manager) Warn(msg string)

IntentsApplied and Warn complete the status socket's source; pane intents are wired by the caller.

type Mismatch

type Mismatch struct {
	Kind, Shown, Actual, Provider string
	DurationMs                    *float64
	Unhooked                      bool
}

Mismatch is a state the keeper corrected, for the team's telemetry.

type Opt

type Opt[T any] struct {
	Set bool
	Val *T
}

Opt is a field the page tells apart in three ways: absent, null, or a value. The old runtime built its entries differently on different paths, and the page reads an absent key and a null key differently.

func Null

func Null[T any]() Opt[T]

func Some

func Some[T any](v T) Opt[T]

func (Opt[T]) Has

func (o Opt[T]) Has() bool

Has is whether there is a value (not absent, not null).

func (Opt[T]) Value

func (o Opt[T]) Value() T

Value is the value, or the zero value when absent or null.

type Procs

type Procs interface {
	Children(pid int) []int
	// ListeningPorts are the TCP ports the pane's descendants listen on, sorted.
	ListeningPorts(pid int) []int
	// Unreadable: the process exists but a look cannot tell what it runs now (waits on a hung file system, or shows an
	// empty command line on its way out). A look that met one decides nothing about the agent.
	Unreadable(pid int) bool
}

Procs reads the process table.

type Provider

type Provider interface {
	ID() string
	Running(panePID int, children []int) bool
	Detect(panePID int, children []int) agents.SessionInfo
	Snapshot(transcript string, force bool) (agents.Snapshot, error)
	HistoryStats(transcript string) (*agents.HistoryStats, error)
	// LastConversationAt is unused here; sleep reads it.
	ParsePaneTitle(title string) *string
	SessionIDFromPath(transcript string) string
	ReadSessionID(t agents.TabAgent) string
	ReadJSONLPath(t agents.TabAgent) string
	ReadSummary(t agents.TabAgent) string
	// FindSession is a session's transcript by its id (Codex); "" when not found or not supported.
	FindSession(sessionID string) string
	// TranscriptIn is a session's transcript in a folder's project directory (Claude); "" when missing.
	TranscriptIn(cwd, sessionID string) string
	// RunsWithHooks: whether the agent among children runs with the platform's hooks; found false when none runs yet.
	RunsWithHooks(children []int) (hooked, found bool)
}

Provider is an agent CLI: Claude Code or Codex.

type Pusher

type Pusher interface {
	Push(tabID string, e Entry, kind string)
}

Pusher sends a web push: kind "done" or "question".

type Queue

type Queue interface {
	// Schedule looks at the tab's queue after delay (a turn just ended, a launch ended, a restart).
	Schedule(tabID string, delay time.Duration)
	// Tabs are the tabs with something queued.
	Tabs() []string
	Pending(tabID string) bool
	Snapshot() any
}

Queue is the prompt queue as the keeper drives it.

type Tab

type Tab struct {
	ID              string
	SessionName     string
	Name            string
	PanelType       Opt[string]
	CliState        string
	LastEventName   string
	DismissedAt     Opt[float64]
	LastUserMessage Opt[string]
	Agent           agents.TabAgent
}

Tab is a layout tab as the keeper reads it.

func TabFromLayout

func TabFromLayout(t *jsvalue.Object) Tab

TabFromLayout reads a tab object of a layout file.

type TabInfo

type TabInfo struct {
	CliState, Provider, PanelType, TmuxSession, Transcript, AgentSessionID string
	Launching, LaunchFailed                                                bool
}

TabInfo is what the prompt queue reads of a tab.

type Tmux

type Tmux interface {
	ReadAllPanes() (map[string]tmux.PaneInfo, bool)
	PaneTitle(session string) string
	PaneDetail(session string) tmux.PaneDetail
	PanePID(session string) int
	Capture(session string) (string, bool)
	// CaptureAtWidth may pause and resize the attached terminal (Codex readiness, recovery of an unknown tab).
	CaptureAtWidth(session string, cols, rows int) (string, bool)
	SessionCwd(session string) string
	SendRawKeys(session, keys string) error
	ParseSessionName(name string) (wsID, paneID, tabID string, ok bool)
}

Tmux is what the keeper asks tmux.

type Workspace

type Workspace struct {
	ID, Name    string
	Directories []string
}

Workspace is a workspace as the keeper needs it.

Jump to

Keyboard shortcuts

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