Documentation
¶
Overview ¶
Package agentrun owns ResolveWorkdir, the filesystem-path canonicaliser used by internal/agentrun/trust to key into ~/.claude.json's projects map. JSONL-path encoding (the dashed ~/.claude/projects/<encoded>/ name) lives in tuidriver, not here.
MUST NOT log file contents. Callers that consume the resolved paths must uphold the same constraint at their layer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExitErrIsBenign ¶ added in v0.14.0
ExitErrIsBenign reports whether err is the OS-level "process already gone" or "self-signalled exit" shape that surfaces during expected teardown of an agent-run child. Returns false for nil and for any other error. Wrapped errors are unwrapped via errors.Is / errors.As.
Benign classes:
- syscall.ESRCH (no such process — kill/signal raced child exit)
- syscall.EPIPE (broken pipe — fd write after child exit)
- os.ErrClosed (write/close after fd already closed)
- *exec.ExitError where ExitCode() == 143 (SIGTERM) or 137 (SIGKILL)
- *exec.ExitError where the child was signal-killed by SIGTERM or SIGKILL (Signaled() with the matching signal — covers the case where the child has no signal handler and ExitCode() returns -1).
func IsNewLogicalTurn ¶ added in v0.14.0
IsNewLogicalTurn reports whether an assistant entry with message id currentID begins a new logical turn, given lastID (the previous assistant entry's id; "" before any assistant entry has been seen).
claude serialises one logical reply as multiple consecutive assistant JSONL entries sharing a message.id (2.1.158 emits a thinking line, a tool_use line, and a text line for a single reply). A new turn begins only when the message.id changes, so a logical-turn count matches claude's native num_turns regardless of how a reply is chunked. An empty currentID is ungroupable (synthetic/malformed entries) → its own turn (the empty-id floor), preserving the pre-fix per-entry behaviour for id-less entries.
This is the single source of truth shared by streamjson's num_turns reporting and budget's --max-turns enforcement, so the reported and enforced turn counts cannot drift on what a turn is. Transition-counting (comparing against the immediately-previous id) equals distinct-id-counting because claude completes one assistant message before starting the next — no A,B,A interleaving has been observed; if it ever is, this is the one place a seen-set would land.
func ResolveWorkdir ¶
ResolveWorkdir returns the resolved absolute path of workdir, mirroring how claude resolves a workdir before reading ~/.claude.json's projects map. Resolves symlinks (macOS /var → /private/var). Wraps fs.ErrNotExist when the path does not exist.
Sole remaining caller after #508: internal/agentrun/trust. A follow-up issue tracks eventual removal alongside a tuidriver-exposes-canonicalise change or a local filepath.EvalSymlinks inside trust.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package budget enforces the pyry-side --max-turns cap for agent-run by counting assistant JSONL entries and signalling the claude child when the budget is reached.
|
Package budget enforces the pyry-side --max-turns cap for agent-run by counting assistant JSONL entries and signalling the claude child when the budget is reached. |
|
Package jsonl parses claude session JSONL output into structured events, surfacing every line (assistant, user, tool_use, tool_result, system, attachment, or unrecognised) with its verbatim bytes, alongside a deterministic end-of-turn signal on assistant entries.
|
Package jsonl parses claude session JSONL output into structured events, surfacing every line (assistant, user, tool_use, tool_result, system, attachment, or unrecognised) with its verbatim bytes, alongside a deterministic end-of-turn signal on assistant entries. |
|
Package ptyrunner spawns claude as an interactive TUI under a PTY (via github.com/pyrycode/tui-driver), waits for the TUI to reach idle, submits one user prompt through a bracketed-paste sequence, tails the per-session JSONL output, re-emits each event as stream-json on cfg.Stdout, and tears the session down cleanly after the deterministic end-of-turn fires.
|
Package ptyrunner spawns claude as an interactive TUI under a PTY (via github.com/pyrycode/tui-driver), waits for the TUI to reach idle, submits one user prompt through a bracketed-paste sequence, tails the per-session JSONL output, re-emits each event as stream-json on cfg.Stdout, and tears the session down cleanly after the deterministic end-of-turn fires. |
|
Package selfcheck implements the boot-time verification that the per-agent tool-allowlist enforcement contract still refuses tools NOT in permissions.allow when claude is spawned as an interactive-TUI process under a PTY with a per-spawn deny-default settings file.
|
Package selfcheck implements the boot-time verification that the per-agent tool-allowlist enforcement contract still refuses tools NOT in permissions.allow when claude is spawned as an interactive-TUI process under a PTY with a per-spawn deny-default settings file. |
|
Package settings writes per-spawn deny-default permission JSON files for interactive claude spawned via PTY drive.
|
Package settings writes per-spawn deny-default permission JSON files for interactive claude spawned via PTY drive. |
|
Package streamjson re-emits the parsed claude session-JSONL entry stream onto a writer (typically pyry's stdout) and composes a single `type:"result"` trailer line when the run terminates.
|
Package streamjson re-emits the parsed claude session-JSONL entry stream onto a writer (typically pyry's stdout) and composes a single `type:"result"` trailer line when the run terminates. |
|
Package streamrunner spawns claude with the stream-json input/output formats as a plain subprocess (no PTY), writes one user-turn JSON envelope to its stdin, forwards stdout/stderr to caller-supplied writers, and waits for the child to exit.
|
Package streamrunner spawns claude with the stream-json input/output formats as a plain subprocess (no PTY), writes one user-turn JSON envelope to its stdin, forwards stdout/stderr to caller-supplied writers, and waits for the child to exit. |
|
Package trust pre-marks a workdir as trusted in ~/.claude.json so interactive claude (spawned via PTY drive) skips the workspace-trust modal.
|
Package trust pre-marks a workdir as trusted in ~/.claude.json so interactive claude (spawned via PTY drive) skips the workspace-trust modal. |