MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / streamContent

Method streamContent

apps/cli/src/agent/output-manager.ts:387–403  ·  view source on GitHub ↗

* Stream content with delta computation - only output new characters.

(ts: number, text: string, header: string)

Source from the content-addressed store, hash-verified

385 * Stream content with delta computation - only output new characters.
386 */
387 streamContent(ts: number, text: string, header: string): void {
388 const previous = this.streamedContent.get(ts)
389
390 if (!previous) {
391 // First time seeing this message - output header and initial text
392 this.writeRaw(`\n${header} `)
393 this.writeRaw(text)
394 this.streamedContent.set(ts, { ts, text, headerShown: true })
395 this.currentlyStreamingTs = ts
396 this.streamingState.next({ ts, isStreaming: true })
397 } else if (text.length > previous.text.length && text.startsWith(previous.text)) {
398 // Text has grown - output delta
399 const delta = text.slice(previous.text.length)
400 this.writeRaw(delta)
401 this.streamedContent.set(ts, { ts, text, headerShown: true })
402 }
403 }
404
405 /**
406 * Finish streaming a message (add newline).

Callers 4

outputTextMessageMethod · 0.95
outputCommandOutputMethod · 0.95

Calls 4

writeRawMethod · 0.95
nextMethod · 0.80
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected