claude

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package claude implements adapters.HarnessAdapter for Claude Code.

Package placement: internal/adapters/claude/ (internal/adapters/ hosts the shared interface; each harness sub-package hosts its implementation).

Stopping convention (Phase 3-b): SIGUSR1 is delivered to the runtime process group by api.JobLifecycle.SignalJobRuntime. Run()'s signal.Notify(SIGUSR1) handler intercepts it and forwards SIGTERM to the claude child only, normalising the resulting exit status into Result.StoppedByDaemon=true. There is no separate "stop agent" entry on the adapter — the daemon owns the signal, the adapter owns the response.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct{}

Adapter implements adapters.HarnessAdapter for Claude Code.

func New

func New() *Adapter

New returns a new Adapter.

func (*Adapter) Bindings

func (a *Adapter) Bindings(homeDir string) []adapters.BindMount

Bindings declares the host bind-mounts claude.Adapter.Run() needs inside the sandbox.

Phase 4 PR3 (docs/plans/home-workspace-volume.md) retires every entry this method used to return: ~/.local/bin (ro, CLI dir + PATH), ~/.local/share/claude (ro), ~/.claude (rw), ~/.claude.json (rw file), and the per-embedded-skill ~/.local/share/boid/skills/<name> -> ~/.claude/skills/<name> binds. All of that state now lives directly in the sandbox's $HOME, which Runner.Dispatch (internal/dispatcher/workspace_home.go) bind-mounts from a persistent per-workspace home directory instead of a fresh tmpfs — so ~/.claude, ~/.claude.json etc. simply already exist at those paths without any adapter-declared bind. The claude CLI binary itself is expected to be installed into that same workspace home by the workspace's init.sh (see the plan doc's init.sh 契約 section); a missing binary now fails fast with an explicit message from Run() (run.go) instead of silently falling back to a bind that no longer exists.

Embedded skills DO reach ~/.claude/skills/<name> as read-only bind mounts again, one per skill — but the dispatcher declares them, not this method. PR3 of docs/plans/workspace-home-volume-persistence.md (論点 e-2) materializes the embedded set under the host-visible runtimes root (internal/dispatcher/skills_overlay.go) and homeMounts layers it onto the workspace home bind. In between, Phase 4 PR3 distributed them by copying the content into the workspace home (skills.DeployAll straight into <home>/.claude/skills); that write had to go once the home became a named volume the daemon cannot write to.

Declaring them dispatcher-side rather than restoring them here is what keeps this method nil: the mounts are a property of how boid stages a sandbox, identical for every harness, not of what the claude CLI needs.

The HarnessAdapter interface still requires this method; returning an empty slice keeps the contract satisfied for any future $HOME-independent bind a harness might need.

func (*Adapter) Run

Run is the agent-process entry point. See RunContext / Result in package adapters for the I/O contract. Run owns:

  • generating a fresh session id and, for task-bound (non-session) runs, applying it via the payload-patch RPC up front so the jsonl transcript path is recorded in the task artifact even when the child terminates abnormally (SIGKILL, OOM)
  • prompt selection (UserAnswer → bootstrap, otherwise /boid-task or "")
  • claude argv construction (always --session-id, never --resume)
  • signal.Notify(SIGUSR1 / SIGWINCH) and forwarding to the child
  • exit code normalisation (StoppedByDaemon → 0)
  • IS_SANDBOX=1 env injection (Claude CLI 2.1.181+ uid 0 bypass)

Session-id resume was removed: reopen and Q&A both start a fresh claude process. The agent (via the /boid-task skill) recovers general task/instructions/environment context via the `boid task current` / `instructions` / `env` broker RPCs on cold start (Phase 5b — the dispatch-time $HOME/.boid/context/*.yaml file distribution these replaced was retired by the Phase 5b PR6 cutover; PR3, which predates PR6, only cut over the one payload field Run() itself needs directly: the prior artifact.claude_code.sessions[] entries it merges the fresh session id into, which come from the `boid task payload` broker RPC — see readSessionsFromRPC below).

func (*Adapter) Usage

func (a *Adapter) Usage(_ context.Context, _ string) (adapters.Usage, error)

Usage is not yet implemented. It will be wired in Phase 4 when the jobs table gains usage columns and the jsonl read path is finalised.

Jump to

Keyboard shortcuts

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