inspect

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 Elapsed

func Elapsed(t task.Snapshot, now time.Time) time.Duration

Elapsed is how long a task has been running, or how long it ran.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration renders a duration the way a status line wants it: seconds while that is still informative, then minutes, then hours.

func LastPrompt

func LastPrompt(t task.Snapshot) string

LastPrompt is the instruction the task is currently working on, for one-line listings.

func Run

func Run(args []string) int

Run dispatches the read-only subcommands and returns a process exit code.

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

func Open(dir string) (*Source, error)

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

func (s *Source) Adapter(name string) agent.Adapter

Adapter returns the adapter that produced a task's output, or nil when that agent is no longer configured here.

func (*Source) Close

func (s *Source) Close()

Close releases the store's handles.

func (*Source) Dir

func (s *Source) Dir() string

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

func (s *Source) Follow(id string, lastN int) (*state.Follower, error)

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

func (s *Source) Lines(id string, since int) (lines []string, total int, err error)

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

func (s *Source) Owner() *state.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

func (s *Source) Render(agentName string, raw []string, compact bool) []string

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

func (s *Source) Resolve(ref string) (task.Snapshot, error)

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.

func (*Source) Task

func (s *Source) Task(id string) (task.Snapshot, bool)

Task returns one task's current record. It re-reads from disk on every call: the owning process keeps rewriting the file, so this is how a viewer learns that a run finished.

func (*Source) Tasks

func (s *Source) Tasks() ([]task.Snapshot, error)

Tasks returns every stored task, newest first.

Jump to

Keyboard shortcuts

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