ClaudeCode.Adapter that runs the Claude Code CLI through an
AgentHarness.Exec implementation instead of a local port.
This keeps the whole claude_code protocol stack — stream-json framing,
the control-protocol handshake, hook and MCP routing, questions and
approvals — on the orchestrator, while the CLI process itself runs
wherever the configured exec module puts it: locally through
AgentHarness.Exec.Local, or in a remote sandbox through an exec
implementation provided by the application.
Select it per session with auth: :inherit (the fail-closed
:subscription mode pins the local port adapter by design):
provider_options: %{
auth: :inherit,
adapter: {AgentHarness.Providers.Claude.Adapter.Exec,
exec: {MyApp.SandboxExec, sandbox: sandbox}}
}Adapter options
:exec—{module, opts}implementingAgentHarness.Exec. Defaults to{AgentHarness.Exec.Local, []}.:cli_path— executable name or path, resolved in the execution environment. Defaults to"claude".
All other options are the ordinary claude_code session options
(:model, :cwd, :env, :api_key, :can_use_tool, :resume, ...).
Differences from ClaudeCode.Adapter.Port
- The spawn spec is remote-safe:
cwdand the executable resolve in the execution environment, and only explicit entries are forwarded: the SDK vars, the:envoption, and:api_key. The Port adapter forwards the orchestrator's wholeSystem.get_env/0; this adapter never does. The execution environment's own environment remains the base, so underExec.Localthe command still inherits this VM's environment because the command runs here. cwdhas no orchestrator-side default. The Port adapter falls back toFile.cwd!(); here a missing:cwdmeans the execution environment's default working directory, and thecan_use_toolcallback context omits:cwduntil one is configured.- No reconnect-on-query. When the exec reports exit, the adapter stays disconnected — AgentHarness treats provider transport loss as session-fatal, and a dead sandbox process usually means a dead sandbox.
execute/4applies on the orchestrator node. SDK features that expect filesystem access next to the CLI (History, Plugin/skills materialization) do not reach the execution environment.
This module intentionally mirrors ClaudeCode.Adapter.Port and reuses
the SDK's protocol helpers. It is coupled to the pinned claude_code
version; treat SDK upgrades as a review point for this file.
Summary
Functions
Returns a specification to start this module under a supervisor.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.