Skip to content

Interface: ModelDriver ​

Defined in: ports/model-driver.ts:14

Runtime port for LLM provider protocol drivers (@paraharness/claude, @paraharness/openai, @paraharness/gemini).

Manages wire-accurate turn invocation, KV-cache-preserving fork preparation, and in-place synchronization note injection on tool and user frames.

Methods ​

appendToolResultNotes() ​

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

Defined in: ports/model-driver.ts:57

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

Updates both rawWireFrame and frame.canonical so subsequent turns see the appended notes without breaking 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 multi-tool frame.
opts?AppendToolResultNotesOptionsOptional error status override.

Returns ​

Promise<WireFrameRecord>

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


invokeTurn() ​

ts
invokeTurn(req): Promise<ModelTurnResponse>;

Defined in: ports/model-driver.ts:29

Invokes a single model turn over req.history and returns the raw wire frame and canonical projection.

Transmits the pinned wire prefix and conversation history to the provider and extracts tool calls or structured output.

Parameters ​

ParameterTypeDescription
reqModelTurnRequestTurn request payload and wire prefix configuration.

Returns ​

Promise<ModelTurnResponse>

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


prepareFork() ​

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

Defined in: ports/model-driver.ts:42

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

Preserves byte-identical parent wire frames on same-model forks and re-encodes from CanonicalMessage (substituting compacted skill tombstones) when escalating across distinct models.

Parameters ​

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

Returns ​

Promise<readonly WireFrameRecord[]>

Synthesized wire frame chain to persist in LedgerStore.

Properties ​

PropertyModifierTypeDescriptionDefined in
vendor?readonlystringOptional alias matching vendorId.ports/model-driver.ts:18
vendorIdreadonlystringPrimary vendor identifier ('anthropic' | 'openai' | 'google' | string).ports/model-driver.ts:16

Released under the MIT License.