Defined in: activities/chat/stream/processor.ts:168
StreamProcessor - State machine for processing AI response streams
Manages the full UIMessage[] conversation and emits events on changes.
State tracking:
Tool call completion is detected when:
new StreamProcessor(options): StreamProcessor;
new StreamProcessor(options): StreamProcessor;
Defined in: activities/chat/stream/processor.ts:197
StreamProcessor
addToolApprovalResponse(approvalId, approved): void;
addToolApprovalResponse(approvalId, approved): void;
Defined in: activities/chat/stream/processor.ts:311
Add an approval response (called by client after handling onApprovalRequest)
string
boolean
void
addToolResult(
toolCallId,
output,
error?): void;
addToolResult(
toolCallId,
output,
error?): void;
Defined in: activities/chat/stream/processor.ts:267
Add a tool result (called by client after handling onToolCall)
string
any
string
void
addUserMessage(content): UIMessage;
addUserMessage(content): UIMessage;
Defined in: activities/chat/stream/processor.ts:225
Add a user message to the conversation
string
areAllToolsComplete(): boolean;
areAllToolsComplete(): boolean;
Defined in: activities/chat/stream/processor.ts:342
Check if all tool calls in the last assistant message are complete Useful for auto-continue logic
boolean
clearMessages(): void;
clearMessages(): void;
Defined in: activities/chat/stream/processor.ts:374
Clear all messages
void
finalizeStream(): void;
finalizeStream(): void;
Defined in: activities/chat/stream/processor.ts:948
Finalize the stream - complete all pending operations
void
getMessages(): UIMessage[];
getMessages(): UIMessage[];
Defined in: activities/chat/stream/processor.ts:334
Get current messages
getRecording(): ChunkRecording | null;
getRecording(): ChunkRecording | null;
Defined in: activities/chat/stream/processor.ts:1034
Get the current recording
ChunkRecording | null
getState(): ProcessorState;
getState(): ProcessorState;
Defined in: activities/chat/stream/processor.ts:1007
Get current processor state (legacy)
process(stream): Promise<ProcessorResult>;
process(stream): Promise<ProcessorResult>;
Defined in: activities/chat/stream/processor.ts:387
Process a stream and emit events through handlers
AsyncIterable<any>
Promise<ProcessorResult>
processChunk(chunk): void;
processChunk(chunk): void;
Defined in: activities/chat/stream/processor.ts:415
Process a single chunk from the stream
void
removeMessagesAfter(index): void;
removeMessagesAfter(index): void;
Defined in: activities/chat/stream/processor.ts:366
Remove messages after a certain index (for reload/retry)
number
void
reset(): void;
reset(): void;
Defined in: activities/chat/stream/processor.ts:1057
Full reset (including messages)
void
setMessages(messages): void;
setMessages(messages): void;
Defined in: activities/chat/stream/processor.ts:217
Set the messages array (e.g., from persisted state)
void
startAssistantMessage(): string;
startAssistantMessage(): string;
Defined in: activities/chat/stream/processor.ts:243
Start streaming a new assistant message Returns the message ID
string
startRecording(): void;
startRecording(): void;
Defined in: activities/chat/stream/processor.ts:1021
Start recording chunks
void
toModelMessages(): ModelMessage<
| string
| ContentPart<unknown, unknown, unknown, unknown, unknown>[]
| null>[];
toModelMessages(): ModelMessage<
| string
| ContentPart<unknown, unknown, unknown, unknown, unknown>[]
| null>[];
Defined in: activities/chat/stream/processor.ts:323
Get the conversation as ModelMessages (for sending to LLM)
ModelMessage< | string | ContentPart<unknown, unknown, unknown, unknown, unknown>[] | null>[]
static replay(recording, options?): Promise<ProcessorResult>;
static replay(recording, options?): Promise<ProcessorResult>;
Defined in: activities/chat/stream/processor.ts:1066
Replay a recording through the processor
Promise<ProcessorResult>
