MCPcopy
hub / github.com/claude-code-best/claude-code / writeEvent

Method writeEvent

src/cli/transports/ccrClient.ts:742–765  ·  view source on GitHub ↗

* Write a StdoutMessage as a client event via POST /sessions/{id}/worker/events. * These events are visible to frontend clients via the SSE stream. * Injects a UUID if missing to ensure server-side idempotency on retry. * * stream_event messages are held in a 100ms delay buffer and accum

(message: StdoutMessage)

Source from the content-addressed store, hash-verified

740 * ordering is preserved.
741 */
742 async writeEvent(message: StdoutMessage): Promise<void> {
743 if (message.type === 'stream_event') {
744 this.streamEventBuffer.push(message)
745 if (!this.streamEventTimer) {
746 this.streamEventTimer = setTimeout(
747 () => void this.flushStreamEventBuffer(),
748 STREAM_EVENT_FLUSH_INTERVAL_MS,
749 )
750 }
751 return
752 }
753 await this.flushStreamEventBuffer()
754 if (message.type === 'assistant') {
755 clearStreamAccumulatorForMessage(
756 this.streamTextAccumulator,
757 message as {
758 session_id: string
759 parent_tool_use_id: string | null
760 message: { id: string }
761 },
762 )
763 }
764 await this.eventUploader.enqueue(this.toClientEvent(message))
765 }
766
767 /** Wrap a StdoutMessage as a ClientEvent, injecting a UUID if missing. */
768 private toClientEvent(message: StdoutMessage): ClientEvent {

Callers 4

initializeMethod · 0.95
writeFunction · 0.80
writeBatchFunction · 0.80
writeMethod · 0.80

Calls 5

toClientEventMethod · 0.95
pushMethod · 0.45
enqueueMethod · 0.45

Tested by

no test coverage detected