{"version":3,"file":"streaming.js","sources":["../../../src/utils/streaming.ts"],"sourcesContent":["export type StreamingGuess = {\n isStreaming: boolean;\n};\n\n/**\n * Classifies a Response as streaming or non-streaming.\n *\n * Heuristics:\n * - No body → not streaming\n * - Known streaming Content-Types → streaming (SSE, NDJSON, JSON streaming)\n * - text/plain without Content-Length → streaming (some AI APIs)\n * - Otherwise → not streaming (conservative default, including HTML/SSR)\n *\n * We avoid probing the stream to prevent blocking on transform streams (like injectTraceMetaTags)\n * or SSR streams that may not have data ready immediately.\n */\nexport function classifyResponseStreaming(res: Response): StreamingGuess {\n if (!res.body) {\n return { isStreaming: false };\n }\n\n const contentType = res.headers.get('content-type') ?? '';\n const contentLength = res.headers.get('content-length');\n\n // Streaming: Known streaming content types\n // - text/event-stream: Server-Sent Events (Vercel AI SDK, real-time APIs)\n // - application/x-ndjson, application/ndjson: Newline-delimited JSON\n // - application/stream+json: JSON streaming\n // - text/plain (without Content-Length): Some AI APIs use this for streaming text\n if (\n /^text\\/event-stream\\b/i.test(contentType) ||\n /^application\\/(x-)?ndjson\\b/i.test(contentType) ||\n /^application\\/stream\\+json\\b/i.test(contentType) ||\n (/^text\\/plain\\b/i.test(contentType) && !contentLength)\n ) {\n return { isStreaming: true };\n }\n\n // Default: treat as non-streaming\n return { isStreaming: false };\n}\n"],"names":[],"mappings":"AAgBO,SAAS,0BAA0B,GAAA,EAA+B;AACvE,EAAA,IAAI,CAAC,IAAI,IAAA,EAAM;AACb,IAAA,OAAO,EAAE,aAAa,KAAA,EAAM;AAAA,EAC9B;AAEA,EAAA,MAAM,WAAA,GAAc,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,cAAc,CAAA,IAAK,EAAA;AACvD,EAAA,MAAM,aAAA,GAAgB,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,gBAAgB,CAAA;AAOtD,EAAA,IACE,yBAAyB,IAAA,CAAK,WAAW,CAAA,IACzC,8BAAA,CAA+B,KAAK,WAAW,CAAA,IAC/C,+BAAA,CAAgC,IAAA,CAAK,WAAW,CAAA,IAC/C,iBAAA,CAAkB,KAAK,WAAW,CAAA,IAAK,CAAC,aAAA,EACzC;AACA,IAAA,OAAO,EAAE,aAAa,IAAA,EAAK;AAAA,EAC7B;AAGA,EAAA,OAAO,EAAE,aAAa,KAAA,EAAM;AAC9B;;;;"}