Skip to content

Class: ClaudeModelDriver ​

Defined in: claude/src/driver/claude-model-driver.ts:33

Runtime ModelDriver implementation for the Anthropic /v1/messages HTTP protocol (@paraharness/claude).

Resolves CLI subscription configDir OAuth tokens and EnvRef API keys at turn invocation time, preserves thinking blocks and cryptographic signature fields in rawWireFrame, enforces native output_config.format JSON-schema structured output, and prepares KV-cache-preserving forks.

Implements ​

Constructors ​

Constructor ​

ts
new ClaudeModelDriver(
   transport?, 
   modelNode?, 
   driverCtx?
): ClaudeModelDriver;

Defined in: claude/src/driver/claude-model-driver.ts:58

Initializes a ClaudeModelDriver with an HTTP transport, optional ClaudeModelNode, and runtime context.

Defers all credential and environment variable lookups until invokeTurn() is executed.

Parameters ​

ParameterTypeDefault valueDescription
transport?ClaudeHttpTransportdefaultClaudeHttpTransportHTTP transport for /v1/messages.
modelNode?ClaudeModelNodeundefinedOptional bound ClaudeModelNode.
driverCtx?RuntimeDriverContextundefinedOptional runtime driver context.

Returns ​

ClaudeModelDriver

Methods ​

appendToolResultNotes() ​

ts
appendToolResultNotes(
   frame, 
   notes, 
   targetCallId?, 
   opts?
): Promise<WireFrameRecord>;

Defined in: claude/src/driver/claude-model-driver.ts:134

Appends synchronization or recovery notes in-place to an Anthropic role: 'tool' or role: 'user' frame.

Updates both rawWireFrame and frame.canonical without breaking conversation role alternation.

Parameters ​

ParameterTypeDescription
frameWireFrameRecordExisting tool or user wire frame record.
notesreadonly string[]Synchronization note strings to append.
targetCallId?stringOptional tool callId to target on a tool frame.
opts?AppendToolResultNotesOptionsOptional error status override.

Returns ​

Promise<WireFrameRecord>

Updated wire frame record to persist via LedgerStore.replaceMessageFrame().

Implementation of ​

ModelDriver.appendToolResultNotes


invokeTurn() ​

ts
invokeTurn(req): Promise<ModelTurnResponse>;

Defined in: claude/src/driver/claude-model-driver.ts:80

Invokes a single Anthropic /v1/messages turn over req.history and returns the raw wire frame and canonical projection.

Validates HTTP status codes before parsing bodyText so non-JSON error payloads (502 Bad Gateway) never crash with SyntaxError, and propagates HTTP 429 rate-limit responses with { status: 429, resetAtMs }.

Parameters ​

ParameterTypeDescription
reqModelTurnRequestTurn request payload, wire prefix, and structured output schema.

Returns ​

Promise<ModelTurnResponse>

Raw wire response, canonical message, structured output, and usage metrics.

Throws ​

On HTTP 429 rate limits, non-2xx statuses, aborted signals, or outputSchema validation failures.

Implementation of ​

ModelDriver.invokeTurn


prepareFork() ​

ts
prepareFork(ctx, target): Promise<readonly WireFrameRecord[]>;

Defined in: claude/src/driver/claude-model-driver.ts:118

Synthesizes the initial WireFrameRecord[] chain for a downward fork or cross-model escalation.

Preserves byte-identical rawWireFrame payloads with cache_control: { type: 'ephemeral' } when target.substituteTombstones === false, and re-projects CanonicalMessage frames with compacted tombstones when target.substituteTombstones === true.

Parameters ​

ParameterTypeDescription
ctxForkContextFork lineage, history mode, and assistant turn-batch pairing metadata.
targetPrepareForkTargetTarget model configuration and tombstone substitution flag.

Returns ​

Promise<readonly WireFrameRecord[]>

Synthesized wire frame chain to persist in LedgerStore.

Implementation of ​

ModelDriver.prepareFork

Properties ​

vendor ​

ts
readonly vendor: "anthropic";

Defined in: claude/src/driver/claude-model-driver.ts:38

Vendor alias matching vendorId ('anthropic').

Implementation of ​

ModelDriver.vendor


vendorId ​

ts
readonly vendorId: "anthropic";

Defined in: claude/src/driver/claude-model-driver.ts:35

Primary vendor identifier ('anthropic').

Implementation of ​

ModelDriver.vendorId

Released under the MIT License.