Skip to main content
This package is the contract-testable shell. It does not import the Claude Agent SDK, a fresh ClaudeCodeDriver is minted per run via the injected driverFactory, and the real SDK-backed driver (createClaudeCodeDriver) lives in apps/web/server/lib/runtimes/. Mirrors the OpenClaw reference adapter pattern, generalized to a one-shot spawned/SDK runtime.

Public API

All exports come from src/index.ts. The package declares a single . export in package.json (no subpath barrels).

Classes

ClaudeCodeAdapter members:
  • capabilities(): Capabilities, returns { streaming: true, mcp: true, worktrees: true, resume: true, toolApproval: true, models: ['sonnet','opus','haiku'], contextWindowTokens: 200000, runtimeClass: 'wrapped-oneshot', nativeSkills: 'none', nativeMemory: 'none', nativeChannels: 'none', nativeScheduler: false }. nativeHome is omitted, the SDK runs against the user’s real HOME/Keychain auth, so nothing native accrues per identity.
  • sessionCodec: SessionCodec, serializes { sessionKey, sessionId } (the native session id captured during the run, falling back to runId); restore rebuilds a RunHandle from the blob. Rotation does not replay the transcript, the codec only carries the session id for lineage + optional resume.
  • health(): Promise<HealthResult>, races the injected healthCheck against a 2 s timeout; any throw → { ok: false, message }.
  • start(_task: TaskHandle, opts: StartOpts): Promise<RunHandle>, mints a driver via driverFactory(opts), stores it by opts.sessionKey, calls driver.start(), returns { adapterId: 'claude-code', sessionKey, runId: null }. The runId late-binds in events() from the first native frame carrying a session id.
  • events(run: RunHandle): AsyncIterable<RuntimeEvent>, subscribes to the run’s driver stream, late-binds runId, accumulates non-reasoning text-delta text, and yields the mapped normalized stream via a bounded createAsyncQueue (max: 1000). Consumer termination (return()) unsubscribes the driver. Returns an empty (closed) queue if no driver is registered for the run.
  • abort(run: RunHandle): Promise<void>, delegates to the run’s driver abort().
  • setModel(run: RunHandle, model: string): Promise<void>, delegates to the run’s driver setModel().
  • writeContext(run: RunHandle, key: string, value: string): Promise<void>, delegates to the run’s driver writeContext().

Functions

Types & interfaces

The Capabilities, HealthResult, RunHandle, RuntimeAdapter, RuntimeEvent, SessionCodec, StartOpts, TaskHandle, and Usage types referenced above are owned by @clawboo/executor, not re-exported here.

Used by

  • apps/web/server/lib/runtimes/index.ts, instantiates ClaudeCodeAdapter, injecting createClaudeCodeDriver (the real SDK-backed driver) and a CLI health probe.
  • apps/web/server/lib/runtimes/claudeCodeDriver.ts, imports the ClaudeCodeDriver + ClaudeNativeEvent types to implement the server-side driver against the Claude Agent SDK.

Source

packages/adapters/claude-code/src/index.ts (barrel; re-exports ./adapter, ./types, ./mapClaudeEvent).

See also

Last modified on June 26, 2026