Documentation
¶
Overview ¶
Package sessionactivity reports the live phase of an agent session.
Eluc (and any other caller) should use Read rather than re-implementing per-runner log scans. Kinds are idle, thinking, responding, tool_calling, waiting, error, aborted, and not_found.
DSH logs are read in two depths. A session session/status lists is tailed and classified with its liveness, so a failed or aborted turn survives the process exiting; a session the answered map does not list is answered from its log header, because the daemon has no state for it and its tail would only cost time. not_found therefore means the log is gone, never merely "not loaded by the daemon".
Index ¶
Constants ¶
const ( RunnerDSH = "dsh" RunnerGrok = "grok" RunnerCodex = "codex" )
Variables ¶
This section is empty.
Functions ¶
func SetDefaultRunStatus ¶ added in v0.0.225
func SetDefaultRunStatus(fn RunStatus)
SetDefaultRunStatus installs the process-wide RunStatus that package-level Read and Follow consult for DSH Sessions; a nil hook uninstalls it and leaves DSH liveness unknown until a hook is installed again.
Only the DSH reader consults it. Grok and Codex report liveness from their own registries, so installing a hook can never change their answer. Install it before reading: a hook decides which daemon answers, and a Session ID is answered only by the daemon that loaded it.
Types ¶
type Lookup ¶ added in v0.0.229
type Lookup struct {
Running bool
Present bool
Answered bool
// At is when the answer was sampled. A cached hook reports the batch's
// instant, so this can be older than the call: the readers compare it with an
// open turn's start instead of assuming both reads are simultaneous.
At time.Time
}
Lookup is one Session's answer from session/status.
Answered is whether the daemon replied. Present is whether this id was in the map. Running is the map value when Present.
The map only holds sessions the daemon has loaded, so absence is not evidence that a log is gone: missing means idle, exactly like Present with Running false. Both read the log header for metadata; only true reads the tail. not_found is reserved for a header the store cannot find at all, and an unanswered RPC is error.
type Probe ¶
type Probe struct {
DSH func(sessionID string) (Snapshot, error)
Grok func(sessionID string) (Snapshot, error)
Codex func(sessionID string) (Snapshot, error)
// RunStatus decides liveness for the default DSH reader when set; nil uses
// the installed default from SetDefaultRunStatus. It does not apply when DSH
// is set, because that reader answers liveness itself, and it never applies
// to Grok or Codex.
RunStatus RunStatus
}
Probe is the injectable entry point. Nil fields use the live agent homes.
func Default ¶
func Default() Probe
Default is the production probe: every nil field reads the live agent home, and the DSH reader therefore also consults the installed RunStatus hook.
func (Probe) Follow ¶
func (p Probe) Follow(runner, sessionID string, afterSeq int64, tail int) (Snapshot, []dshsessions.TranscriptRow, error)
Follow returns activity plus a committed transcript tail.
type RunStatus ¶ added in v0.0.225
RunStatus answers whether one Session is executing a turn right now, as the runner's own agent registry sees it. A silent hook (nil, failed RPC) leaves Answered false. An id missing from a successful map is Present false.
type Snapshot ¶
type Snapshot struct {
Runner string `json:"runner"`
SessionID string `json:"session_id"`
Kind Kind `json:"kind"`
Detail string `json:"detail,omitempty"`
Live bool `json:"live"`
Workspace string `json:"workspace,omitempty"`
Title string `json:"title,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
Outcome string `json:"outcome,omitempty"`
// LiveStale marks a phase read from a log whose open turn is newer than the
// liveness answer: Live is false because the answer could not testify about
// that turn, not because the turn failed. A caller must not render a stale
// read as an error.
LiveStale bool `json:"live_stale,omitempty"`
// Unanswered marks a placeholder snapshot taken while the status source
// did not answer (RPC timeout, daemon still starting). Kind stays ErrorKind
// so every existing consumer keeps its fallback, but a caller that can show
// "not known yet" must not present this as the session's real state.
Unanswered bool `json:"unanswered,omitempty"`
}
Snapshot is one session's current phase plus durable facts the caller already needed for display.
func Follow ¶
func Follow(runner, sessionID string, afterSeq int64, tail int) (Snapshot, []dshsessions.TranscriptRow, error)
Follow returns activity plus a committed transcript tail.