Documentation
¶
Overview ¶
Package claude is the Claude Code adapter. Every flag and field here comes from the Phase 0 runs on Claude Code 2.1.292 (docs/claude-code-runner.md, "Phase 0 findings: Claude Code, API key"); the recorded streams are in testdata/.
Index ¶
- Constants
- func SessionID(s string) bool
- func Settings(t aa.Task) ([]byte, error)
- func SettingsPath(t aa.Task) string
- type Adapter
- func (a *Adapter) Bin() string
- func (a *Adapter) Command(t aa.Task) (aa.Command, error)
- func (a *Adapter) CredentialEnv() []string
- func (a *Adapter) Denied(events [][]byte, end aa.End) (string, bool)
- func (a *Adapter) FilterStderr(line string) string
- func (a *Adapter) LogSource() string
- func (a *Adapter) MinVersion() string
- func (a *Adapter) Name() aa.Name
- func (a *Adapter) NewDecoder() aa.Decoder
- func (a *Adapter) Prepare(t aa.Task) error
- func (a *Adapter) Ready(ctx context.Context, t aa.Task) error
- func (a *Adapter) ResumeID(_, stored string) (string, bool)
- func (a *Adapter) ResumesByID() bool
- func (a *Adapter) ReviewEvidence(events [][]byte, worktrees []string) bool
- func (a *Adapter) SupportsSimulator() bool
- func (a *Adapter) VersionArgs() []string
- type Config
- type Decoder
Constants ¶
const MinVersion = "2.1.292"
MinVersion is the CLI the Phase 0 fixtures were recorded with.
Variables ¶
This section is empty.
Functions ¶
func SessionID ¶
SessionID reports a UUID-shaped session id, the only shape passed to --resume (a leading "-" would read as a flag).
func Settings ¶
Settings is the job settings for t. Fail closed (Main Dev rulings on the R1 security review and the Phase 0b probe, 2026-11-15):
- reads and edits are scoped to the handoff and the worktrees (no bare Read, Glob, Grep or Edit);
- "Bash" is allowed, because CLAUDE_CODE_SUBPROCESS_ENV_SCRUB forces the permission mode to default, where autoAllowBashIfSandboxed approves nothing (Phase 0b p5: git diff refused without it). It approves only sandboxed Bash: the sandbox can be neither escaped (allowUnsandboxedCommands false, no excludedCommands) nor missing (failIfUnavailable true), and denyRead bounds what it reads;
- every DenyRead path is denied to Bash (sandbox denyRead) and to the file tools (a Read deny), except a path that contains an allowed dir (DD's batch-jobs dir holds this job's handoff): that one is denied to Bash with this job's dirs re-allowed (allowRead), and the file tools are held to the scoped Read allow;
- the agent cannot write .claude/ settings into its own dirs;
- t.ReadOnly paths are readable like the agent's own dirs (Read allow and the allowRead re-allow) but never editable. A reviewer's cwd is its lens dir, so this is how it reads the job's BRIEF.md and fix-notes (Phase 2). On a worker it is also the job's clone .git and report evidence;
- the implementer's sandboxed shell may reach t.AllowedDomains, and nothing else; with none, the file has no network block at all;
- t.UnixSockets (a worker browser job, implementer only) adds allowAllUnixSockets to the network block, with allowedDomains written even when empty; the caller has put the host's sockets in DenyRead (probe P2 runs H–K). Without it the file is rc2's byte for byte;
- t.DenyWrite paths are read-only to the sandboxed shell, for both roles (spec §4.1.11: on a worker, its own state files and $HOME). An entry equal to or containing the cwd, a worktree or a ReadOnly path is refused: bwrap does not start with a denied cwd ancestor (P1b D/D2).
The reviewer gets the same file without any Edit allow.
func SettingsPath ¶
SettingsPath is where Prepare writes the task's settings file.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is Claude Code.
func (*Adapter) CredentialEnv ¶
CredentialEnv are Claude Code's own credential and config variables.
func (*Adapter) Denied ¶
Denied blocks a reviewer lens on any permission denial: the result's permission_denials, or a live system permission_denied event (a run killed before its result still shows it).
func (*Adapter) FilterStderr ¶
func (*Adapter) MinVersion ¶
func (*Adapter) NewDecoder ¶
NewDecoder returns a stream-json decoder.
func (*Adapter) Prepare ¶
Prepare writes the settings file (outside the handoff, so the agent cannot widen its own rules) and, in API-key mode, the per-job config dir. It runs before every spawn, so the file is always DD's.
func (*Adapter) Ready ¶
Ready checks the credential under the task's exact child env. API-key mode needs only the key (a bad key fails the run with agent_auth). Subscription mode asks the CLI whether it is logged in.
func (*Adapter) ResumeID ¶
ResumeID is the stored session id from the last result event. No stored id means the job cannot be resumed; there is no directory scan.
func (*Adapter) ResumesByID ¶
func (*Adapter) ReviewEvidence ¶
ReviewEvidence wants a Bash tool_use whose command is a git diff of a worktree, answered by a tool_result that is not an error.
func (*Adapter) SupportsSimulator ¶
func (*Adapter) VersionArgs ¶
type Config ¶
type Config struct {
// Bin is the resolved claude binary ("" when not installed).
Bin string
}
Config is what the caller resolved.
type Decoder ¶
type Decoder struct{}
Decoder decodes `claude -p --output-format stream-json --verbose`.