Documentation
¶
Overview ¶
Package inspect reads the task store from outside the server process.
Everything the server knows already lands on disk as it happens: one JSON record per task, rewritten at every transition, and one transcript appended line by line while the worker is still running. That makes a second, read-only process enough to watch any task live — no port to open in the server, no handshake, and nothing that can disturb a run in flight. It also means this works when the server was launched by a GUI client (Claude Desktop, Cowork) whose stdio you can never see.
Both front-ends are built on this one Source: the `logs` terminal command and the `ui` local web viewer. Neither can change anything — cancelling a task requires the process that owns the worker, so that stays with the MCP tools and the in-conversation board.
Index ¶
- Variables
- func Elapsed(t task.Snapshot, now time.Time) time.Duration
- func FormatDuration(d time.Duration) string
- func LastPrompt(t task.Snapshot) string
- func Run(args []string) int
- type Source
- func (s *Source) Adapter(name string) agent.Adapter
- func (s *Source) Close()
- func (s *Source) Dir() string
- func (s *Source) Follow(id string, lastN int) (*state.Follower, error)
- func (s *Source) Lines(id string, since int) (lines []string, total int, err error)
- func (s *Source) Owner() *state.Owner
- func (s *Source) Render(agentName string, raw []string, compact bool) []string
- func (s *Source) Resolve(ref string) (task.Snapshot, error)
- func (s *Source) Task(id string) (task.Snapshot, bool)
- func (s *Source) Tasks() ([]task.Snapshot, error)
Constants ¶
This section is empty.
Variables ¶
var LiveHTML string
LiveHTML is the whole viewer — markup, styles and script in one file, with no external requests. Keeping it self-contained means the page works with no network at all, which is rather the point of a local viewer.
Functions ¶
func FormatDuration ¶
FormatDuration renders a duration the way a status line wants it: seconds while that is still informative, then minutes, then hours.
func LastPrompt ¶
LastPrompt is the instruction the task is currently working on, for one-line listings.
Types ¶
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source is a read-only view of one state directory. Its methods are safe for concurrent use.
func Open ¶
Open prepares a read-only view of dir. An empty dir resolves the same way the server does: CLI_AGENT_MCP_STATE_DIR, then the per-user default.
func (*Source) Adapter ¶
Adapter returns the adapter that produced a task's output, or nil when that agent is no longer configured here.
func (*Source) Dir ¶
Dir reports the directory being read. Every front-end prints it, because the most common reason for an empty listing is that the server was launched with a different CLI_AGENT_MCP_STATE_DIR than the shell running this.
func (*Source) Follow ¶
Follow opens an independent cursor over a task's transcript. The terminal command uses this directly: it streams forward and never needs to re-read.
func (*Source) Lines ¶
Lines returns the task's transcript from line index `since`, plus the total number of lines now on disk. Indices address the raw stream and never shift, so a caller keeps polling with the returned total as its next cursor — the same contract agent_get_output offers.
func (*Source) Owner ¶
Owner reports the live server process that owns this directory, or nil when none is running. Purely informational: it tells a viewer whether new output should be expected at all.
func (*Source) Render ¶
Render turns raw transcript lines into what the user reads. In compact mode noise (init dumps, config chatter) renders as "" and is dropped here, exactly as the tools drop it; raw mode returns the agent's own JSONL untouched.
func (*Source) Resolve ¶
Resolve turns a user-typed reference into a task. It accepts a full id, any unambiguous fragment of one, "latest" for the most recent task, or "running" for the one currently in flight — because nobody wants to retype task-12-9f3a1c04 to look at the thing they just started.