sessionactivity

package
v0.0.226 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 8 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 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, and aborted.

Index

Constants

View Source
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 returns the DSH reader to lease-only liveness.

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 Kind

type Kind string

Kind is the live phase of one session.

const (
	Idle        Kind = "idle"
	Thinking    Kind = "thinking"
	Responding  Kind = "responding"
	ToolCalling Kind = "tool_calling"
	Waiting     Kind = "waiting"
	ErrorKind   Kind = "error"
	Aborted     Kind = "aborted"
)

func ClassifyChat

func ClassifyChat(lastKind, tool string, live bool) (Kind, string)

ClassifyChat maps a grok/codex last coalesced message onto the five activity kinds. live is PID liveness, not "the TUI is still open".

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.

func (Probe) Read

func (p Probe) Read(runner, sessionID string) (Snapshot, error)

Read reports one session's activity.

type RunStatus added in v0.0.225

type RunStatus func(sessionID string) (running bool, known bool)

RunStatus answers whether one Session is executing a turn right now, as the runner's own agent registry sees it.

known is false when the caller cannot answer for that Session: an unknown id, a runner without a registry, an unreachable daemon, or a Session started outside the daemon (a plain `dsh` TUI session, which nothing registers). A caller treats that as no opinion rather than as idle, and keeps the liveness it already reads. An answered true or false is authoritative: a Session whose lease says live while its Agent is idle is not running.

Liveness is two facts with separate owners. Loaded — some process holds the Session lock, which is what the agent catalogue reports — stays the lease's answer. Running — an Agent is executing a turn — is this hook's answer.

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"`
}

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.

func Read

func Read(runner, sessionID string) (Snapshot, error)

Read reports one session's activity using the production probe.

Jump to

Keyboard shortcuts

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