MCPcopy Create free account
hub / github.com/TanStack/ai / createEventRecording

Function createEventRecording

testing/panel/src/lib/recording.ts:47–529  ·  view source on GitHub ↗
(
  filePath: string,
  traceId?: string,
)

Source from the content-addressed store, hash-verified

45 * // Call recording.stop() when done to unsubscribe
46 */
47export function createEventRecording(
48 filePath: string,
49 traceId?: string,
50): {
51 stop: () => void
52 getStreamId: () => string | undefined
53} {
54 // Track active streams and their data
55 const activeStreams = new Map<
56 string,
57 {
58 streamId: string
59 requestId: string
60 model: string
61 provider: string
62 chunks: Array<{
63 chunk: StreamChunk
64 timestamp: number
65 index: number
66 }>
67 accumulatedContent: string
68 toolCalls: Map<string, RecordedToolCall>
69 finishReason: string | null
70 traceId?: string
71 }
72 >()
73
74 // Track which streamId belongs to this recording (if traceId is provided)
75 let recordingStreamId: string | undefined
76
77 let chunkIndex = 0
78
79 // Helper to reconstruct StreamChunk from events
80 const createContentChunk = (
81 content: string,
82 delta: string | undefined,
83 model: string,
84 timestamp: number,
85 id: string,
86 ): StreamChunk => ({
87 type: 'content',
88 content,
89 delta: delta ?? '',
90 model,
91 timestamp,
92 id,
93 })
94
95 const createToolCallChunk = (
96 toolCallId: string,
97 toolName: string,
98 index: number,
99 arguments_: string,
100 model: string,
101 timestamp: number,
102 id: string,
103 ): StreamChunk => ({
104 type: 'tool_call',

Callers

nothing calls this directly

Calls 15

shouldRecordFunction · 0.85
createContentChunkFunction · 0.85
createToolCallChunkFunction · 0.85
createToolResultChunkFunction · 0.85
createDoneChunkFunction · 0.85
createErrorChunkFunction · 0.85
createThinkingChunkFunction · 0.85
nowMethod · 0.80
fromMethod · 0.80
valuesMethod · 0.80
logMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected