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

Function teeForPhaseCapture

testing/e2e/src/routes/api.middleware-test.ts:158–166  ·  view source on GitHub ↗

* Wraps a chat stream so every chunk that leaves `chat()` (post-middleware) * is recorded into the per-testId phase capture as a yielded chunk. Used by * `phase-recorder` mode to let the spec assert what the consumer actually * sees — distinct from what `onChunk` observes inside the middleware ch

(
  source: AsyncIterable<StreamChunk>,
  captureId: string,
)

Source from the content-addressed store, hash-verified

156 * sees — distinct from what `onChunk` observes inside the middleware chain.
157 */
158async function* teeForPhaseCapture(
159 source: AsyncIterable<StreamChunk>,
160 captureId: string,
161): AsyncIterable<StreamChunk> {
162 for await (const chunk of source) {
163 recordYieldedChunk(captureId, { type: chunk.type })
164 yield chunk
165 }
166}
167
168// Minimal in-memory tracer/meter. Captures into a per-testId bucket so that
169// the Playwright spec can fetch the recorded state via GET after the stream

Callers 1

Calls 1

recordYieldedChunkFunction · 0.90

Tested by

no test coverage detected