claude

package
v0.2.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 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 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

View Source
const MinVersion = "2.1.292"

MinVersion is the CLI the Phase 0 fixtures were recorded with.

Variables

This section is empty.

Functions

func SessionID

func SessionID(s string) bool

SessionID reports a UUID-shaped session id, the only shape passed to --resume (a leading "-" would read as a flag).

func Settings

func Settings(t aa.Task) ([]byte, error)

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.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

func SettingsPath(t aa.Task) string

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 New

func New(cfg Config) *Adapter

New returns the Claude Code adapter.

func (*Adapter) Bin

func (a *Adapter) Bin() string

func (*Adapter) Command

func (a *Adapter) Command(t aa.Task) (aa.Command, error)

Command builds `claude -p`. stdin stays nil (/dev/null).

func (*Adapter) CredentialEnv

func (a *Adapter) CredentialEnv() []string

CredentialEnv are Claude Code's own credential and config variables.

func (*Adapter) Denied

func (a *Adapter) Denied(events [][]byte, end aa.End) (string, bool)

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 (a *Adapter) FilterStderr(line string) string

func (*Adapter) LogSource

func (a *Adapter) LogSource() string

func (*Adapter) MinVersion

func (a *Adapter) MinVersion() string

func (*Adapter) Name

func (a *Adapter) Name() aa.Name

func (*Adapter) NewDecoder

func (a *Adapter) NewDecoder() aa.Decoder

NewDecoder returns a stream-json decoder.

func (*Adapter) Prepare

func (a *Adapter) Prepare(t aa.Task) error

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

func (a *Adapter) Ready(ctx context.Context, t aa.Task) error

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

func (a *Adapter) ResumeID(_, stored string) (string, bool)

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 (a *Adapter) ResumesByID() bool

func (*Adapter) ReviewEvidence

func (a *Adapter) ReviewEvidence(events [][]byte, worktrees []string) bool

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 (a *Adapter) SupportsSimulator() bool

func (*Adapter) VersionArgs

func (a *Adapter) VersionArgs() []string

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`.

func (*Decoder) Decode

func (d *Decoder) Decode(line []byte) []aa.Event

Decode maps one line. assistant text blocks become text; tool_use and tool_result blocks become tool events; the result event becomes End. The decoder keys on is_error, never on subtype: a failed run can still say subtype "success".

Jump to

Keyboard shortcuts

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