@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
34 lines (33 loc) • 1.24 kB
TypeScript
/**
* SSE Stream Interceptor
*
* A zero-overhead TransformStream that taps Anthropic SSE streaming responses
* to extract telemetry data (token usage, model info, content blocks, thinking
* blocks, tool use) while passing every byte through to the client unmodified
* and without delay.
*
* The interceptor buffers partial SSE events internally (chunks may split
* across event boundaries) but never holds back any bytes from the readable
* side of the stream.
*
* Usage:
* const { stream, telemetry } = createSSEInterceptor();
* upstreamResponse.body.pipeThrough(stream).pipeTo(clientWritable);
* const data = await telemetry; // resolves on stream end
*/
import type { SSEInterceptorOptions, SSEInterceptorResult } from "../types/index.js";
/**
* Create an SSE interceptor that extracts telemetry from an Anthropic
* streaming response while passing all bytes through unmodified.
*
* ```ts
* const { stream, telemetry } = createSSEInterceptor();
* upstreamResponse.body
* .pipeThrough(stream)
* .pipeTo(clientWritable);
*
* const data = await telemetry;
* console.log(data.usage.totalTokens);
* ```
*/
export declare function createSSEInterceptor(options?: SSEInterceptorOptions): SSEInterceptorResult;