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

Function createCustomEventChunks

packages/ai-client/tests/test-utils.ts:177–203  ·  view source on GitHub ↗
(
  events: Array<{ name: string; value?: unknown }>,
  model: string = 'test',
)

Source from the content-addressed store, hash-verified

175 * Helper to create custom event chunks
176 */
177export function createCustomEventChunks(
178 events: Array<{ name: string; value?: unknown }>,
179 model: string = 'test',
180): Array<StreamChunk> {
181 const chunks: Array<StreamChunk> = []
182
183 for (const event of events) {
184 chunks.push({
185 type: 'CUSTOM',
186 model,
187 timestamp: Date.now(),
188 name: event.name,
189 value: event.value,
190 } as StreamChunk)
191 }
192
193 chunks.push({
194 type: 'RUN_FINISHED',
195 runId: 'run-1',
196 threadId: 'thread-1',
197 model,
198 timestamp: Date.now(),
199 finishReason: 'stop',
200 } as StreamChunk)
201
202 return chunks
203}
204
205/**
206 * Helper to create tool call chunks (AG-UI format)

Callers 1

Calls 2

nowMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected