MCPcopy
hub / github.com/TanStack/ai / process

Method process

packages/ai/src/activities/chat/stream/processor.ts:472–495  ·  view source on GitHub ↗

* Process a stream and emit events through handlers

(stream: AsyncIterable<any>)

Source from the content-addressed store, hash-verified

470 * Process a stream and emit events through handlers
471 */
472 async process(stream: AsyncIterable<any>): Promise<ProcessorResult> {
473 // Reset stream state (but keep messages)
474 this.resetStreamState()
475
476 // Start recording if enabled
477 if (this.recordingEnabled) {
478 this.startRecording()
479 }
480
481 // Process each chunk
482 for await (const chunk of stream) {
483 this.processChunk(chunk)
484 }
485
486 // Stream ended - finalize everything
487 this.finalizeStream()
488
489 // Finalize recording
490 if (this.recording) {
491 this.recording.result = this.getResult()
492 }
493
494 return this.getResult()
495 }
496
497 /**
498 * Process a single chunk from the stream.

Callers 4

mainFunction · 0.95
replayMethod · 0.95
runProcessorWithChunksFunction · 0.95

Calls 5

resetStreamStateMethod · 0.95
startRecordingMethod · 0.95
processChunkMethod · 0.95
finalizeStreamMethod · 0.95
getResultMethod · 0.95

Tested by

no test coverage detected