Skip to content

rulvar API reference


rulvar API reference / @rulvar/anthropic / mapAnthropicStream

Function: mapAnthropicStream()

ts
function mapAnthropicStream(
   stream, 
   ids, 
   emit, 
options?): Promise<TurnMapping>;

Defined in: packages/anthropic/src/wire.ts:427

Maps one Messages API stream into ChatEvents. Emits an early usage event from message_start (the input side is known immediately) and exactly one terminal finish unless the turn paused (pause_turn) or errored. carryRetained holds thinking blocks from earlier pause_turn continuations of the same turn so the terminal finish ships the whole turn's retention payload (M4-T02).

Parameters

ParameterType
streamAsyncIterable&lt;AnthropicStreamEvent&gt;
idsIdMap
emit(event) => void
options?{ carryRetained?: Block[]; }
options.carryRetained?Block[]

Returns

Promise&lt;TurnMapping&gt;