Interface: IUiChunkWriter
Defined in: entries/vercel-ui/types.ts:167
The chunks of one streamed answer, in the order the client expects: the chunk protocol has an order the gateway's events
do not have (text-start before the first delta, text-end before a tool or the end).
Created by UiMapper.createChunkWriter, one per call; driven by AIGatewayVercelUi or by an application on its own transport.
Methods
onError()
onError(
args):TGatewayUiChunk[]
Defined in: entries/vercel-ui/types.ts:232
onError -- the chunks that close the stream after a thrown error
About
errorwith the public reason, thenfinish; the open text and step closed first.
Who needs it
streamChunks of AIGatewayVercelUi, when the events or the response throw once the stream runs
(toPublicError gives the reason: a 5xx never carries its message).
Parameters
args
reason
string
Returns
onEvent()
onEvent(
args):TGatewayUiChunk[]
Defined in: entries/vercel-ui/types.ts:202
onEvent -- the chunks of one event of the running call
About
Zero or more chunks, in the order the client's reducer expects.
A text delta opens its step and its text when they are not open; a tool request closes the text first; a step end
closes both. RUN_ENDED_BY_TOOL and ANSWER_WITHDRAWN land as message-metadata; the other events add nothing,
the response carries the result.
Who needs it
streamChunks of AIGatewayVercelUi, once per event of IGatewayCall.events (D38).
Pitfalls
Events in order, one writer per call: the writer keeps the open text and the open step between the calls.
Parameters
args
event
Returns
onResponse()
onResponse(
args):TGatewayUiChunk[]
Defined in: entries/vercel-ui/types.ts:219
onResponse -- the chunks that close the stream with the call's response
About
ANSWER, PAUSED or FAILED: the results as metadata, then
finish.
ANSWER: message-metadata with the thread, usage, citations, issues, structured and endedByTool, then finish.
PAUSED: a tool-approval-request per TOOL_APPROVAL envelope, the pause as metadata, finish. FAILED: an error
chunk with the reason and a finish whose metadata carries the thread and the issues. The open text and step are
closed first.
Who needs it
streamChunks of AIGatewayVercelUi, after the last event, with the awaited IGatewayCall.response.
Parameters
args
response
Returns
start()
start():
TGatewayUiChunk[]
Defined in: entries/vercel-ui/types.ts:182
start -- the chunks that open the stream
About
One
startchunk: the message id, the date, the thread when it exists.
Called once, before the first event. A new thread's id is not known yet: it reaches the client with the response's metadata.
Who needs it
streamChunks of AIGatewayVercelUi, first thing; an application streaming on its own transport.