Skip to content
mercury framework
GitHub

TurnSink

TurnSink = object

Defined in: types/channel-types/index.ts:193

A provider’s output for one turn. Each optional member maps 1:1 onto an optional runTurn dep: supplying onTextChunk or onReasoningChunk puts runTurn on its streamText path. Google Chat supplies only onReasoningChunk (never onTextChunk), so answer streaming never starts there.

dispose: () => void

Defined in: types/channel-types/index.ts:211

Release per-turn resources. Idempotent.

void


finalize: (finalText, info?) => Promise<void>

Defined in: types/channel-types/index.ts:209

Deliver the model’s complete final text, with what the core says about it (see FinalizeInfo).

string

FinalizeInfo

Promise<void>


optional onReasoningChunk?: (chunk, id) => void

Defined in: types/channel-types/index.ts:201

Reasoning-token delta (Ollama extended thinking, behind OLLAMA_THINK). Present ⇒ streamText. Never reaches SessionHistory. id is the reasoning-block id; a turn can reason more than once, each burst with its own id.

string

string

void


optional onReasoningEnd?: (id, failed) => void

Defined in: types/channel-types/index.ts:203

Closes a reasoning block that started (even if the turn aborts with it open), so a live display doesn’t get stuck. Never for an id onReasoningChunk didn’t report. failed is true only on abort.

string

boolean

void


optional onStep?: (step) => void

Defined in: types/channel-types/index.ts:205

Provider-local per-step bookkeeping (the terminal’s /dump buffer).

StepInfo

void


optional onTextChunk?: (chunk) => void

Defined in: types/channel-types/index.ts:199

Present ⇒ runTurn uses streamText. Must stay undefined for Google Chat’s own answer delivery.

string

void


optional onToolFinish?: (toolCallId, outcome) => void

Defined in: types/channel-types/index.ts:197

Paired with onToolStart via toolCallId once the call settles. Optional — only Google Chat implements it (patches its status card).

string

ToolOutcome

void


onToolStart: (label, detail?, toolCallId?, toolName?) => void

Defined in: types/channel-types/index.ts:195

onToolStart for buildTools. detail/toolCallId present for a real tool call or a capture-ping with its own id; both undefined = a caller with no correlation id. toolName only for a real tool call (the model’s tool, e.g. jiraCommand), never for a capture-ping.

string

string

string

string

void


optional onUsage?: (inputTokens) => void

Defined in: types/channel-types/index.ts:207

Provider-local usage handling (the terminal’s prompt indicator, Chat’s stderr line).

number | undefined

void