[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-tanstack-ai-coreag-ui-protocol":3,"mdc-bpbil7-key":50,"related-org-tanstack-ai-coreag-ui-protocol":4861,"related-repo-tanstack-ai-coreag-ui-protocol":5005},{"slug":4,"name":5,"fn":6,"description":7,"org":8,"tags":12,"stars":21,"repoUrl":22,"updatedAt":23,"license":24,"forks":25,"topics":26,"repo":45,"sourceUrl":48,"mdContent":49},"ai-coreag-ui-protocol","ai-core\u002Fag-ui-protocol","implement TanStack AI streaming protocol","Server-side AG-UI streaming protocol implementation: StreamChunk event types (RUN_STARTED, TEXT_MESSAGE_START\u002FCONTENT\u002FEND, TOOL_CALL_START\u002FARGS\u002FEND, RUN_FINISHED, RUN_ERROR, STEP_STARTED\u002FSTEP_FINISHED, STATE_SNAPSHOT\u002FDELTA, CUSTOM), toServerSentEventsStream() for SSE format, toHttpStream() for NDJSON format. For backends serving AG-UI events without client packages.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},"tanstack","TanStack","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Ftanstack.png",[13,17,20],{"name":14,"slug":15,"type":16},"LLM","llm","tag",{"name":18,"slug":19,"type":16},"API Development","api-development",{"name":10,"slug":9,"type":16},2884,"https:\u002F\u002Fgithub.com\u002FTanStack\u002Fai","2026-07-16T06:04:10.093367",null,269,[27,28,29,30,31,32,33,34,15,35,36,37,38,39,40,9,41,42,43,44],"ai","ai-agents","ai-sdk","anthropic","chatbot","function-calling","gemini","generative-ai","multimodal","openai","react","solidjs","streaming","svelte","tool-calling","typescript","typescript-sdk","vue",{"repoUrl":22,"stars":21,"forks":25,"topics":46,"description":47},[27,28,29,30,31,32,33,34,15,35,36,37,38,39,40,9,41,42,43,44],"🤖 Type-safe, provider-agnostic TypeScript AI SDK for streaming chat, tool calling, agents, and multimodal apps across OpenAI, Anthropic, Gemini, React, Vue, Svelte, and Solid.","https:\u002F\u002Fgithub.com\u002FTanStack\u002Fai\u002Ftree\u002FHEAD\u002Fpackages\u002Fai\u002Fskills\u002Fai-core\u002Fag-ui-protocol","---\nname: ai-core\u002Fag-ui-protocol\ndescription: >\n  Server-side AG-UI streaming protocol implementation: StreamChunk event\n  types (RUN_STARTED, TEXT_MESSAGE_START\u002FCONTENT\u002FEND, TOOL_CALL_START\u002FARGS\u002FEND,\n  RUN_FINISHED, RUN_ERROR, STEP_STARTED\u002FSTEP_FINISHED, STATE_SNAPSHOT\u002FDELTA,\n  CUSTOM), toServerSentEventsStream() for SSE format, toHttpStream() for\n  NDJSON format. For backends serving AG-UI events without client packages.\ntype: sub-skill\nlibrary: tanstack-ai\nlibrary_version: '0.10.0'\nsources:\n  - 'TanStack\u002Fai:docs\u002Fprotocol\u002Fchunk-definitions.md'\n  - 'TanStack\u002Fai:docs\u002Fprotocol\u002Fsse-protocol.md'\n  - 'TanStack\u002Fai:docs\u002Fprotocol\u002Fhttp-stream-protocol.md'\n  - 'TanStack\u002Fai:docs\u002Fprotocol\u002Fcustom-events.md'\n---\n\n# AG-UI Protocol\n\nThis skill builds on ai-core. Read it first for critical rules.\n\n## Setup — Server Endpoint Producing AG-UI Events via SSE\n\n```typescript\nimport { chat, toServerSentEventsResponse } from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai'\n\nexport async function POST(request: Request) {\n  const { messages } = await request.json()\n  const stream = chat({\n    adapter: openaiText('gpt-5.2'),\n    messages,\n  })\n  return toServerSentEventsResponse(stream)\n}\n```\n\n`chat()` returns an `AsyncIterable\u003CStreamChunk>`. Each `StreamChunk` is a\ntyped AG-UI event (discriminated union on `type`). The `toServerSentEventsResponse()`\nhelper encodes that iterable into an SSE-formatted `Response` with correct headers.\n\n## Setup — Receiving AG-UI RunAgentInput on the Server\n\n```typescript\nimport {\n  chat,\n  chatParamsFromRequestBody,\n  mergeAgentTools,\n  toServerSentEventsResponse,\n} from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai\u002Fadapters'\nimport { serverTools } from '.\u002Ftools'\n\nexport async function POST(req: Request) {\n  let params\n  try {\n    params = await chatParamsFromRequestBody(await req.json())\n  } catch (error) {\n    return new Response(\n      error instanceof Error ? error.message : 'Bad request',\n      { status: 400 },\n    )\n  }\n\n  const stream = chat({\n    adapter: openaiText('gpt-4o'),\n    messages: params.messages,\n    tools: mergeAgentTools(serverTools, params.tools),\n  })\n\n  return toServerSentEventsResponse(stream)\n}\n```\n\n`chatParamsFromRequestBody` validates the body against `RunAgentInputSchema` from `@ag-ui\u002Fcore`. `mergeAgentTools` merges the server's tool registry with client-declared tools (server wins on collision; client-only tools become no-execute stubs that flow through the runtime's `ClientToolRequest` path).\n\n`params.messages` is a mixed array of TanStack `UIMessage` anchors (with `parts`) and AG-UI fan-out duplicates (`{role:'tool',...}`, `{role:'reasoning',...}`). The existing `convertMessagesToModelMessages` (called inside `chat()`) handles dedup automatically.\n\n**Wire shape (POST body):** AG-UI `RunAgentInput` — `{threadId, runId, parentRunId?, state, messages, tools, context, forwardedProps}`. The `messages` array carries TanStack `UIMessage` anchors with their canonical `parts` plus AG-UI mirror fields (`content`, `toolCalls`) inline; tool results and thinking parts are additionally emitted as fan-out `{role:'tool',...}` and `{role:'reasoning',...}` entries.\n\n**`forwardedProps` security:** Don't spread it directly into `chat()` — clients could override `adapter`, `model`, `tools`, etc. Always allowlist specific fields.\n\n## Core Patterns\n\n### 1. SSE Format — toServerSentEventsStream \u002F toServerSentEventsResponse\n\n**Wire format:** Each event is `data: \u003CJSON>\\n\\n`. Stream ends with `data: [DONE]\\n\\n`.\n\n```typescript\nimport {\n  chat,\n  toServerSentEventsStream,\n  toServerSentEventsResponse,\n} from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai'\n\n\u002F\u002F Option A: Get a ReadableStream (manual Response construction)\nconst abortController = new AbortController()\nconst stream = chat({\n  adapter: openaiText('gpt-5.2'),\n  messages,\n  abortController,\n})\nconst sseStream = toServerSentEventsStream(stream, abortController)\n\nconst response = new Response(sseStream, {\n  headers: {\n    'Content-Type': 'text\u002Fevent-stream',\n    'Cache-Control': 'no-cache',\n    Connection: 'keep-alive',\n  },\n})\n\n\u002F\u002F Option B: Use the helper (sets headers automatically)\nconst response2 = toServerSentEventsResponse(stream, { abortController })\n\u002F\u002F Default headers: Content-Type: text\u002Fevent-stream, Cache-Control: no-cache, Connection: keep-alive\n```\n\n**Default response headers set by `toServerSentEventsResponse()`:**\n\n| Header          | Value               |\n| --------------- | ------------------- |\n| `Content-Type`  | `text\u002Fevent-stream` |\n| `Cache-Control` | `no-cache`          |\n| `Connection`    | `keep-alive`        |\n\nCustom headers merge on top (user headers override defaults):\n\n```typescript\ntoServerSentEventsResponse(stream, {\n  headers: {\n    'X-Accel-Buffering': 'no', \u002F\u002F Disable nginx buffering\n    'Cache-Control': 'no-store', \u002F\u002F Override default\n  },\n  abortController,\n})\n```\n\n**Error handling:** If the stream throws, a `RUN_ERROR` event is emitted\nautomatically before the stream closes. If the `abortController` is already\naborted, the error event is suppressed and the stream closes silently.\n\n### 2. HTTP Stream (NDJSON) — toHttpStream \u002F toHttpResponse\n\n**Wire format:** Each event is `\u003CJSON>\\n` (newline-delimited JSON, no SSE prefix, no `[DONE]` marker).\n\n```typescript\nimport { chat, toHttpStream, toHttpResponse } from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai'\n\n\u002F\u002F Option A: Get a ReadableStream\nconst abortController = new AbortController()\nconst stream = chat({\n  adapter: openaiText('gpt-5.2'),\n  messages,\n  abortController,\n})\nconst ndjsonStream = toHttpStream(stream, abortController)\n\nconst response = new Response(ndjsonStream, {\n  headers: {\n    'Content-Type': 'application\u002Fx-ndjson',\n  },\n})\n\n\u002F\u002F Option B: Use the helper (does NOT set headers automatically)\nconst response2 = toHttpResponse(stream, { abortController })\n\u002F\u002F Note: toHttpResponse does NOT set Content-Type automatically.\n\u002F\u002F You should pass headers explicitly:\nconst response3 = toHttpResponse(stream, {\n  headers: { 'Content-Type': 'application\u002Fx-ndjson' },\n  abortController,\n})\n```\n\n**Client-side pairing:** SSE endpoints are consumed by `fetchServerSentEvents()`.\nHTTP stream endpoints are consumed by `fetchHttpStream()`. Both are connection\nadapters from `@tanstack\u002Fai-react` (or the framework-specific package).\n\n### 3. AG-UI Event Types Reference\n\nAll events extend `BaseAGUIEvent` which carries `type`, `timestamp`, optional\n`model`, and optional `rawEvent`.\n\n| Event Type             | Description                                                                                                                 |\n| ---------------------- | --------------------------------------------------------------------------------------------------------------------------- |\n| `RUN_STARTED`          | First event in a stream. Carries `runId` and optional `threadId`.                                                           |\n| `TEXT_MESSAGE_START`   | New text message begins. Carries `messageId` and `role`.                                                                    |\n| `TEXT_MESSAGE_CONTENT` | Incremental text token. Carries `messageId` and `delta` (the new text).                                                     |\n| `TEXT_MESSAGE_END`     | Text message complete. Carries `messageId`.                                                                                 |\n| `TOOL_CALL_START`      | Tool invocation begins. Carries `toolCallId`, `toolName`, and `index`.                                                      |\n| `TOOL_CALL_ARGS`       | Incremental tool arguments JSON. Carries `toolCallId` and `delta`.                                                          |\n| `TOOL_CALL_END`        | Tool call arguments complete. Carries `toolCallId` and `toolName`.                                                          |\n| `STEP_STARTED`         | Thinking\u002Freasoning step begins. Carries `stepId` and optional `stepType`.                                                   |\n| `STEP_FINISHED`        | Thinking step complete. Carries `stepId`, `delta`, and optional `content`.                                                  |\n| `MESSAGES_SNAPSHOT`    | Full conversation transcript snapshot. Carries `messages: Array\u003CUIMessage>`.                                                |\n| `STATE_SNAPSHOT`       | Full application state snapshot. Carries `state: Record\u003Cstring, unknown>`.                                                  |\n| `STATE_DELTA`          | Incremental state update. Carries `delta: Record\u003Cstring, unknown>`.                                                         |\n| `CUSTOM`               | Extension point. Carries `name` (string) and optional `value` (unknown).                                                    |\n| `RUN_FINISHED`         | Stream complete. Carries `runId` and `finishReason` (`'stop'` \u002F `'length'` \u002F `'content_filter'` \u002F `'tool_calls'` \u002F `null`). |\n| `RUN_ERROR`            | Error during stream. Carries optional `runId` and `error: { message, code? }`.                                              |\n\n**Typical event sequence for a text-only response:**\n\n```\nRUN_STARTED -> TEXT_MESSAGE_START -> TEXT_MESSAGE_CONTENT (repeated) -> TEXT_MESSAGE_END -> RUN_FINISHED\n```\n\n**Typical event sequence with tool calls:**\n\n```\nRUN_STARTED -> TEXT_MESSAGE_START -> TEXT_MESSAGE_CONTENT* -> TEXT_MESSAGE_END\n            -> TOOL_CALL_START -> TOOL_CALL_ARGS* -> TOOL_CALL_END\n            -> RUN_FINISHED (finishReason: 'tool_calls')\n```\n\n**Type aliases:** `StreamChunk` is an alias for `AGUIEvent` (the discriminated\nunion of all event interfaces). `StreamChunkType` is an alias for `AGUIEventType`\n(the string union of all event type literals).\n\n### 4. Typed CUSTOM Events — `ChatStream` and `KnownCustomEvent`\n\nThe `CUSTOM` row above describes the raw `StreamChunk` union, where the single\ngeneric `CustomEvent` member types `value` as `any` -- once merged into a\nunion, that `any` poisons every other member too, so narrowing on `name`\nstill leaves `value: any`. `chat()` doesn't return raw `StreamChunk`; by\ndefault (no `outputSchema`, `stream` not explicitly `false`) it returns\n`ChatStream`, which swaps that generic member for `KnownCustomEvent` -- a\ndiscriminated union of every `CUSTOM` event TanStack AI itself emits, each\nwith a literal `name` and a concrete `value`. Narrow with a plain `if` --\nno helper, no cast:\n\n```typescript\nimport { chat } from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai'\n\nconst stream = chat({\n  adapter: openaiText('gpt-5.2'),\n  messages,\n})\n\nfor await (const chunk of stream) {\n  if (chunk.type === 'CUSTOM' && chunk.name === 'sandbox.file.diff') {\n    console.log(chunk.value.path, chunk.value.diff) \u002F\u002F typed, no helper, no cast\n  } else if (\n    chunk.type === 'CUSTOM' &&\n    chunk.name === 'structured-output.complete'\n  ) {\n    console.log(chunk.value.object) \u002F\u002F typed, no helper, no cast\n  }\n}\n```\n\n**Caveat -- `.endsWith()` (or any non-literal check) does not narrow.**\n`SessionIdEvent['name']` is the template-literal type\n`` `${string}.session-id` ``. TypeScript's control-flow narrowing only\nunderstands exact comparisons (`===`) and `in`\u002Ftype-predicate checks against\na discriminant -- a runtime `chunk.name.endsWith('.session-id')` check\ndoesn't inform the type system, so `chunk.value` stays the union of every\n`KnownCustomEvent`'s `value`, not `{ sessionId: string }`. Compare against\nthe exact literal you expect, or write a user-defined type predicate\n(`(c): c is SessionIdEvent => c.name.endsWith('.session-id')`) and call that\nin the `if` instead.\n\n**User-emitted `emitCustomEvent` names are typed out of `ChatStream`.** Tools\nthat call `context.emitCustomEvent('my-app:progress', ...)` still stream a\n`CUSTOM` chunk at runtime, but `'my-app:progress'` isn't one of\n`KnownCustomEvent`'s literal names, so it's intentionally absent from\n`ChatStream`'s type -- including a generic fallback member would reintroduce\nthe `value: any` poison for every other event on the stream. To read your own\nevent with a type, annotate the stream as the wider `StreamChunk` instead of\n`ChatStream` for that branch; its generic `CUSTOM` member already types\n`value` as `any`, so no cast is needed there either.\n\nSource: docs\u002Fprotocol\u002Fcustom-events.md\n\n## Common Mistakes\n\n### MEDIUM: Proxy buffering breaks SSE streaming\n\nReverse proxies (nginx, Cloudflare, AWS ALB) buffer SSE responses by default,\ncausing events to arrive in batches instead of streaming token-by-token.\n\nFix: Set proxy-bypass headers on the response.\n\n```typescript\ntoServerSentEventsResponse(stream, {\n  headers: {\n    'X-Accel-Buffering': 'no', \u002F\u002F nginx\n    'X-Content-Type-Options': 'nosniff', \u002F\u002F Some CDNs\n  },\n  abortController,\n})\n```\n\nFor Cloudflare Workers, SSE streams automatically. For Cloudflare proxied\norigins, ensure \"Response Buffering\" is disabled in the dashboard.\n\nSource: docs\u002Fprotocol\u002Fsse-protocol.md\n\n### MEDIUM: Assuming all AG-UI events arrive in every response\n\nNot all event types appear in every stream:\n\n- `STEP_STARTED` \u002F `STEP_FINISHED` only appear with thinking-enabled models\n  (e.g., `o3`, `claude-sonnet-4-5` with extended thinking). Standard models\n  skip these entirely.\n- `TOOL_CALL_START` \u002F `TOOL_CALL_ARGS` \u002F `TOOL_CALL_END` only appear when\n  the model invokes tools. A text-only response has none.\n- `STATE_SNAPSHOT` \u002F `STATE_DELTA` only appear when server code explicitly\n  emits them for stateful agent workflows.\n- `MESSAGES_SNAPSHOT` only appears when the server explicitly sends a\n  full transcript snapshot.\n- `CUSTOM` events are application-defined and never emitted by default.\n\nCode that expects a fixed sequence (e.g., always waiting for `STEP_FINISHED`\nbefore processing text) will hang or break on models that don't emit those events.\n\nSource: docs\u002Fprotocol\u002Fchunk-definitions.md\n\n## Tension\n\nRESOLVED: TanStack AI is fully AG-UI compliant on both axes (server→client events\nAND client→server `RunAgentInput`). The wire format carries TanStack `UIMessage`\nanchors with their parts intact alongside AG-UI fan-out messages, so strict AG-UI\nservers see role-based messages while TanStack-aware servers read parts directly\nwithout transformation. See `docs\u002Fmigration\u002Fag-ui-compliance.md` for details.\n\n## Cross-References\n\n- See also: `ai-core\u002Fcustom-backend-integration\u002FSKILL.md` -- Custom backends must implement SSE or HTTP stream format to work with TanStack AI client connection adapters.\n- See also: `ai-core\u002Fmiddleware\u002FSKILL.md` -- `sandbox.file.diff`'s `{ path, diff }` value (one of `KnownCustomEvent`'s members) is populated from the same lazy `before()`\u002F`after()`\u002F`diff()` accessors documented there for `onFile*` middleware hooks.\n- Full CUSTOM event taxonomy: `docs\u002Fprotocol\u002Fcustom-events.md`.\n",{"data":51,"body":60},{"name":5,"description":7,"type":52,"library":53,"library_version":54,"sources":55},"sub-skill","tanstack-ai","0.10.0",[56,57,58,59],"TanStack\u002Fai:docs\u002Fprotocol\u002Fchunk-definitions.md","TanStack\u002Fai:docs\u002Fprotocol\u002Fsse-protocol.md","TanStack\u002Fai:docs\u002Fprotocol\u002Fhttp-stream-protocol.md","TanStack\u002Fai:docs\u002Fprotocol\u002Fcustom-events.md",{"type":61,"children":62},"root",[63,72,78,85,451,502,508,1171,1214,1272,1349,1393,1399,1406,1431,1976,1990,2076,2081,2235,2261,2267,2291,2846,2880,2886,2927,3430,3438,3448,3456,3465,3505,3524,3666,4210,4311,4413,4418,4424,4430,4435,4440,4592,4597,4602,4608,4613,4707,4719,4724,4730,4757,4763,4855],{"type":64,"tag":65,"props":66,"children":68},"element","h1",{"id":67},"ag-ui-protocol",[69],{"type":70,"value":71},"text","AG-UI Protocol",{"type":64,"tag":73,"props":74,"children":75},"p",{},[76],{"type":70,"value":77},"This skill builds on ai-core. Read it first for critical rules.",{"type":64,"tag":79,"props":80,"children":82},"h2",{"id":81},"setup-server-endpoint-producing-ag-ui-events-via-sse",[83],{"type":70,"value":84},"Setup — Server Endpoint Producing AG-UI Events via SSE",{"type":64,"tag":86,"props":87,"children":91},"pre",{"className":88,"code":89,"language":42,"meta":90,"style":90},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { chat, toServerSentEventsResponse } from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai'\n\nexport async function POST(request: Request) {\n  const { messages } = await request.json()\n  const stream = chat({\n    adapter: openaiText('gpt-5.2'),\n    messages,\n  })\n  return toServerSentEventsResponse(stream)\n}\n","",[92],{"type":64,"tag":93,"props":94,"children":95},"code",{"__ignoreMap":90},[96,156,194,204,262,315,345,389,402,416,442],{"type":64,"tag":97,"props":98,"children":101},"span",{"class":99,"line":100},"line",1,[102,108,114,120,125,130,135,140,145,151],{"type":64,"tag":97,"props":103,"children":105},{"style":104},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[106],{"type":70,"value":107},"import",{"type":64,"tag":97,"props":109,"children":111},{"style":110},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[112],{"type":70,"value":113}," {",{"type":64,"tag":97,"props":115,"children":117},{"style":116},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[118],{"type":70,"value":119}," chat",{"type":64,"tag":97,"props":121,"children":122},{"style":110},[123],{"type":70,"value":124},",",{"type":64,"tag":97,"props":126,"children":127},{"style":116},[128],{"type":70,"value":129}," toServerSentEventsResponse",{"type":64,"tag":97,"props":131,"children":132},{"style":110},[133],{"type":70,"value":134}," }",{"type":64,"tag":97,"props":136,"children":137},{"style":104},[138],{"type":70,"value":139}," from",{"type":64,"tag":97,"props":141,"children":142},{"style":110},[143],{"type":70,"value":144}," '",{"type":64,"tag":97,"props":146,"children":148},{"style":147},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[149],{"type":70,"value":150},"@tanstack\u002Fai",{"type":64,"tag":97,"props":152,"children":153},{"style":110},[154],{"type":70,"value":155},"'\n",{"type":64,"tag":97,"props":157,"children":159},{"class":99,"line":158},2,[160,164,168,173,177,181,185,190],{"type":64,"tag":97,"props":161,"children":162},{"style":104},[163],{"type":70,"value":107},{"type":64,"tag":97,"props":165,"children":166},{"style":110},[167],{"type":70,"value":113},{"type":64,"tag":97,"props":169,"children":170},{"style":116},[171],{"type":70,"value":172}," openaiText",{"type":64,"tag":97,"props":174,"children":175},{"style":110},[176],{"type":70,"value":134},{"type":64,"tag":97,"props":178,"children":179},{"style":104},[180],{"type":70,"value":139},{"type":64,"tag":97,"props":182,"children":183},{"style":110},[184],{"type":70,"value":144},{"type":64,"tag":97,"props":186,"children":187},{"style":147},[188],{"type":70,"value":189},"@tanstack\u002Fai-openai",{"type":64,"tag":97,"props":191,"children":192},{"style":110},[193],{"type":70,"value":155},{"type":64,"tag":97,"props":195,"children":197},{"class":99,"line":196},3,[198],{"type":64,"tag":97,"props":199,"children":201},{"emptyLinePlaceholder":200},true,[202],{"type":70,"value":203},"\n",{"type":64,"tag":97,"props":205,"children":207},{"class":99,"line":206},4,[208,213,219,224,230,235,241,246,252,257],{"type":64,"tag":97,"props":209,"children":210},{"style":104},[211],{"type":70,"value":212},"export",{"type":64,"tag":97,"props":214,"children":216},{"style":215},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[217],{"type":70,"value":218}," async",{"type":64,"tag":97,"props":220,"children":221},{"style":215},[222],{"type":70,"value":223}," function",{"type":64,"tag":97,"props":225,"children":227},{"style":226},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[228],{"type":70,"value":229}," POST",{"type":64,"tag":97,"props":231,"children":232},{"style":110},[233],{"type":70,"value":234},"(",{"type":64,"tag":97,"props":236,"children":238},{"style":237},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic",[239],{"type":70,"value":240},"request",{"type":64,"tag":97,"props":242,"children":243},{"style":110},[244],{"type":70,"value":245},":",{"type":64,"tag":97,"props":247,"children":249},{"style":248},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[250],{"type":70,"value":251}," Request",{"type":64,"tag":97,"props":253,"children":254},{"style":110},[255],{"type":70,"value":256},")",{"type":64,"tag":97,"props":258,"children":259},{"style":110},[260],{"type":70,"value":261}," {\n",{"type":64,"tag":97,"props":263,"children":265},{"class":99,"line":264},5,[266,271,275,280,284,289,294,299,304,309],{"type":64,"tag":97,"props":267,"children":268},{"style":215},[269],{"type":70,"value":270},"  const",{"type":64,"tag":97,"props":272,"children":273},{"style":110},[274],{"type":70,"value":113},{"type":64,"tag":97,"props":276,"children":277},{"style":116},[278],{"type":70,"value":279}," messages",{"type":64,"tag":97,"props":281,"children":282},{"style":110},[283],{"type":70,"value":134},{"type":64,"tag":97,"props":285,"children":286},{"style":110},[287],{"type":70,"value":288}," =",{"type":64,"tag":97,"props":290,"children":291},{"style":104},[292],{"type":70,"value":293}," await",{"type":64,"tag":97,"props":295,"children":296},{"style":116},[297],{"type":70,"value":298}," request",{"type":64,"tag":97,"props":300,"children":301},{"style":110},[302],{"type":70,"value":303},".",{"type":64,"tag":97,"props":305,"children":306},{"style":226},[307],{"type":70,"value":308},"json",{"type":64,"tag":97,"props":310,"children":312},{"style":311},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[313],{"type":70,"value":314},"()\n",{"type":64,"tag":97,"props":316,"children":318},{"class":99,"line":317},6,[319,323,328,332,336,340],{"type":64,"tag":97,"props":320,"children":321},{"style":215},[322],{"type":70,"value":270},{"type":64,"tag":97,"props":324,"children":325},{"style":116},[326],{"type":70,"value":327}," stream",{"type":64,"tag":97,"props":329,"children":330},{"style":110},[331],{"type":70,"value":288},{"type":64,"tag":97,"props":333,"children":334},{"style":226},[335],{"type":70,"value":119},{"type":64,"tag":97,"props":337,"children":338},{"style":311},[339],{"type":70,"value":234},{"type":64,"tag":97,"props":341,"children":342},{"style":110},[343],{"type":70,"value":344},"{\n",{"type":64,"tag":97,"props":346,"children":348},{"class":99,"line":347},7,[349,354,358,362,366,371,376,380,384],{"type":64,"tag":97,"props":350,"children":351},{"style":311},[352],{"type":70,"value":353},"    adapter",{"type":64,"tag":97,"props":355,"children":356},{"style":110},[357],{"type":70,"value":245},{"type":64,"tag":97,"props":359,"children":360},{"style":226},[361],{"type":70,"value":172},{"type":64,"tag":97,"props":363,"children":364},{"style":311},[365],{"type":70,"value":234},{"type":64,"tag":97,"props":367,"children":368},{"style":110},[369],{"type":70,"value":370},"'",{"type":64,"tag":97,"props":372,"children":373},{"style":147},[374],{"type":70,"value":375},"gpt-5.2",{"type":64,"tag":97,"props":377,"children":378},{"style":110},[379],{"type":70,"value":370},{"type":64,"tag":97,"props":381,"children":382},{"style":311},[383],{"type":70,"value":256},{"type":64,"tag":97,"props":385,"children":386},{"style":110},[387],{"type":70,"value":388},",\n",{"type":64,"tag":97,"props":390,"children":392},{"class":99,"line":391},8,[393,398],{"type":64,"tag":97,"props":394,"children":395},{"style":116},[396],{"type":70,"value":397},"    messages",{"type":64,"tag":97,"props":399,"children":400},{"style":110},[401],{"type":70,"value":388},{"type":64,"tag":97,"props":403,"children":405},{"class":99,"line":404},9,[406,411],{"type":64,"tag":97,"props":407,"children":408},{"style":110},[409],{"type":70,"value":410},"  }",{"type":64,"tag":97,"props":412,"children":413},{"style":311},[414],{"type":70,"value":415},")\n",{"type":64,"tag":97,"props":417,"children":419},{"class":99,"line":418},10,[420,425,429,433,438],{"type":64,"tag":97,"props":421,"children":422},{"style":104},[423],{"type":70,"value":424},"  return",{"type":64,"tag":97,"props":426,"children":427},{"style":226},[428],{"type":70,"value":129},{"type":64,"tag":97,"props":430,"children":431},{"style":311},[432],{"type":70,"value":234},{"type":64,"tag":97,"props":434,"children":435},{"style":116},[436],{"type":70,"value":437},"stream",{"type":64,"tag":97,"props":439,"children":440},{"style":311},[441],{"type":70,"value":415},{"type":64,"tag":97,"props":443,"children":445},{"class":99,"line":444},11,[446],{"type":64,"tag":97,"props":447,"children":448},{"style":110},[449],{"type":70,"value":450},"}\n",{"type":64,"tag":73,"props":452,"children":453},{},[454,460,462,468,470,476,478,484,486,492,494,500],{"type":64,"tag":93,"props":455,"children":457},{"className":456},[],[458],{"type":70,"value":459},"chat()",{"type":70,"value":461}," returns an ",{"type":64,"tag":93,"props":463,"children":465},{"className":464},[],[466],{"type":70,"value":467},"AsyncIterable\u003CStreamChunk>",{"type":70,"value":469},". Each ",{"type":64,"tag":93,"props":471,"children":473},{"className":472},[],[474],{"type":70,"value":475},"StreamChunk",{"type":70,"value":477}," is a\ntyped AG-UI event (discriminated union on ",{"type":64,"tag":93,"props":479,"children":481},{"className":480},[],[482],{"type":70,"value":483},"type",{"type":70,"value":485},"). The ",{"type":64,"tag":93,"props":487,"children":489},{"className":488},[],[490],{"type":70,"value":491},"toServerSentEventsResponse()",{"type":70,"value":493},"\nhelper encodes that iterable into an SSE-formatted ",{"type":64,"tag":93,"props":495,"children":497},{"className":496},[],[498],{"type":70,"value":499},"Response",{"type":70,"value":501}," with correct headers.",{"type":64,"tag":79,"props":503,"children":505},{"id":504},"setup-receiving-ag-ui-runagentinput-on-the-server",[506],{"type":70,"value":507},"Setup — Receiving AG-UI RunAgentInput on the Server",{"type":64,"tag":86,"props":509,"children":511},{"className":88,"code":510,"language":42,"meta":90,"style":90},"import {\n  chat,\n  chatParamsFromRequestBody,\n  mergeAgentTools,\n  toServerSentEventsResponse,\n} from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai\u002Fadapters'\nimport { serverTools } from '.\u002Ftools'\n\nexport async function POST(req: Request) {\n  let params\n  try {\n    params = await chatParamsFromRequestBody(await req.json())\n  } catch (error) {\n    return new Response(\n      error instanceof Error ? error.message : 'Bad request',\n      { status: 400 },\n    )\n  }\n\n  const stream = chat({\n    adapter: openaiText('gpt-4o'),\n    messages: params.messages,\n    tools: mergeAgentTools(serverTools, params.tools),\n  })\n\n  return toServerSentEventsResponse(stream)\n}\n",[512],{"type":64,"tag":93,"props":513,"children":514},{"__ignoreMap":90},[515,526,538,550,562,574,598,634,671,678,722,735,748,797,829,853,913,942,951,960,968,996,1037,1067,1119,1131,1139,1163],{"type":64,"tag":97,"props":516,"children":517},{"class":99,"line":100},[518,522],{"type":64,"tag":97,"props":519,"children":520},{"style":104},[521],{"type":70,"value":107},{"type":64,"tag":97,"props":523,"children":524},{"style":110},[525],{"type":70,"value":261},{"type":64,"tag":97,"props":527,"children":528},{"class":99,"line":158},[529,534],{"type":64,"tag":97,"props":530,"children":531},{"style":116},[532],{"type":70,"value":533},"  chat",{"type":64,"tag":97,"props":535,"children":536},{"style":110},[537],{"type":70,"value":388},{"type":64,"tag":97,"props":539,"children":540},{"class":99,"line":196},[541,546],{"type":64,"tag":97,"props":542,"children":543},{"style":116},[544],{"type":70,"value":545},"  chatParamsFromRequestBody",{"type":64,"tag":97,"props":547,"children":548},{"style":110},[549],{"type":70,"value":388},{"type":64,"tag":97,"props":551,"children":552},{"class":99,"line":206},[553,558],{"type":64,"tag":97,"props":554,"children":555},{"style":116},[556],{"type":70,"value":557},"  mergeAgentTools",{"type":64,"tag":97,"props":559,"children":560},{"style":110},[561],{"type":70,"value":388},{"type":64,"tag":97,"props":563,"children":564},{"class":99,"line":264},[565,570],{"type":64,"tag":97,"props":566,"children":567},{"style":116},[568],{"type":70,"value":569},"  toServerSentEventsResponse",{"type":64,"tag":97,"props":571,"children":572},{"style":110},[573],{"type":70,"value":388},{"type":64,"tag":97,"props":575,"children":576},{"class":99,"line":317},[577,582,586,590,594],{"type":64,"tag":97,"props":578,"children":579},{"style":110},[580],{"type":70,"value":581},"}",{"type":64,"tag":97,"props":583,"children":584},{"style":104},[585],{"type":70,"value":139},{"type":64,"tag":97,"props":587,"children":588},{"style":110},[589],{"type":70,"value":144},{"type":64,"tag":97,"props":591,"children":592},{"style":147},[593],{"type":70,"value":150},{"type":64,"tag":97,"props":595,"children":596},{"style":110},[597],{"type":70,"value":155},{"type":64,"tag":97,"props":599,"children":600},{"class":99,"line":347},[601,605,609,613,617,621,625,630],{"type":64,"tag":97,"props":602,"children":603},{"style":104},[604],{"type":70,"value":107},{"type":64,"tag":97,"props":606,"children":607},{"style":110},[608],{"type":70,"value":113},{"type":64,"tag":97,"props":610,"children":611},{"style":116},[612],{"type":70,"value":172},{"type":64,"tag":97,"props":614,"children":615},{"style":110},[616],{"type":70,"value":134},{"type":64,"tag":97,"props":618,"children":619},{"style":104},[620],{"type":70,"value":139},{"type":64,"tag":97,"props":622,"children":623},{"style":110},[624],{"type":70,"value":144},{"type":64,"tag":97,"props":626,"children":627},{"style":147},[628],{"type":70,"value":629},"@tanstack\u002Fai-openai\u002Fadapters",{"type":64,"tag":97,"props":631,"children":632},{"style":110},[633],{"type":70,"value":155},{"type":64,"tag":97,"props":635,"children":636},{"class":99,"line":391},[637,641,645,650,654,658,662,667],{"type":64,"tag":97,"props":638,"children":639},{"style":104},[640],{"type":70,"value":107},{"type":64,"tag":97,"props":642,"children":643},{"style":110},[644],{"type":70,"value":113},{"type":64,"tag":97,"props":646,"children":647},{"style":116},[648],{"type":70,"value":649}," serverTools",{"type":64,"tag":97,"props":651,"children":652},{"style":110},[653],{"type":70,"value":134},{"type":64,"tag":97,"props":655,"children":656},{"style":104},[657],{"type":70,"value":139},{"type":64,"tag":97,"props":659,"children":660},{"style":110},[661],{"type":70,"value":144},{"type":64,"tag":97,"props":663,"children":664},{"style":147},[665],{"type":70,"value":666},".\u002Ftools",{"type":64,"tag":97,"props":668,"children":669},{"style":110},[670],{"type":70,"value":155},{"type":64,"tag":97,"props":672,"children":673},{"class":99,"line":404},[674],{"type":64,"tag":97,"props":675,"children":676},{"emptyLinePlaceholder":200},[677],{"type":70,"value":203},{"type":64,"tag":97,"props":679,"children":680},{"class":99,"line":418},[681,685,689,693,697,701,706,710,714,718],{"type":64,"tag":97,"props":682,"children":683},{"style":104},[684],{"type":70,"value":212},{"type":64,"tag":97,"props":686,"children":687},{"style":215},[688],{"type":70,"value":218},{"type":64,"tag":97,"props":690,"children":691},{"style":215},[692],{"type":70,"value":223},{"type":64,"tag":97,"props":694,"children":695},{"style":226},[696],{"type":70,"value":229},{"type":64,"tag":97,"props":698,"children":699},{"style":110},[700],{"type":70,"value":234},{"type":64,"tag":97,"props":702,"children":703},{"style":237},[704],{"type":70,"value":705},"req",{"type":64,"tag":97,"props":707,"children":708},{"style":110},[709],{"type":70,"value":245},{"type":64,"tag":97,"props":711,"children":712},{"style":248},[713],{"type":70,"value":251},{"type":64,"tag":97,"props":715,"children":716},{"style":110},[717],{"type":70,"value":256},{"type":64,"tag":97,"props":719,"children":720},{"style":110},[721],{"type":70,"value":261},{"type":64,"tag":97,"props":723,"children":724},{"class":99,"line":444},[725,730],{"type":64,"tag":97,"props":726,"children":727},{"style":215},[728],{"type":70,"value":729},"  let",{"type":64,"tag":97,"props":731,"children":732},{"style":116},[733],{"type":70,"value":734}," params\n",{"type":64,"tag":97,"props":736,"children":738},{"class":99,"line":737},12,[739,744],{"type":64,"tag":97,"props":740,"children":741},{"style":104},[742],{"type":70,"value":743},"  try",{"type":64,"tag":97,"props":745,"children":746},{"style":110},[747],{"type":70,"value":261},{"type":64,"tag":97,"props":749,"children":751},{"class":99,"line":750},13,[752,757,761,765,770,774,779,784,788,792],{"type":64,"tag":97,"props":753,"children":754},{"style":116},[755],{"type":70,"value":756},"    params",{"type":64,"tag":97,"props":758,"children":759},{"style":110},[760],{"type":70,"value":288},{"type":64,"tag":97,"props":762,"children":763},{"style":104},[764],{"type":70,"value":293},{"type":64,"tag":97,"props":766,"children":767},{"style":226},[768],{"type":70,"value":769}," chatParamsFromRequestBody",{"type":64,"tag":97,"props":771,"children":772},{"style":311},[773],{"type":70,"value":234},{"type":64,"tag":97,"props":775,"children":776},{"style":104},[777],{"type":70,"value":778},"await",{"type":64,"tag":97,"props":780,"children":781},{"style":116},[782],{"type":70,"value":783}," req",{"type":64,"tag":97,"props":785,"children":786},{"style":110},[787],{"type":70,"value":303},{"type":64,"tag":97,"props":789,"children":790},{"style":226},[791],{"type":70,"value":308},{"type":64,"tag":97,"props":793,"children":794},{"style":311},[795],{"type":70,"value":796},"())\n",{"type":64,"tag":97,"props":798,"children":800},{"class":99,"line":799},14,[801,805,810,815,820,825],{"type":64,"tag":97,"props":802,"children":803},{"style":110},[804],{"type":70,"value":410},{"type":64,"tag":97,"props":806,"children":807},{"style":104},[808],{"type":70,"value":809}," catch",{"type":64,"tag":97,"props":811,"children":812},{"style":311},[813],{"type":70,"value":814}," (",{"type":64,"tag":97,"props":816,"children":817},{"style":116},[818],{"type":70,"value":819},"error",{"type":64,"tag":97,"props":821,"children":822},{"style":311},[823],{"type":70,"value":824},") ",{"type":64,"tag":97,"props":826,"children":827},{"style":110},[828],{"type":70,"value":344},{"type":64,"tag":97,"props":830,"children":832},{"class":99,"line":831},15,[833,838,843,848],{"type":64,"tag":97,"props":834,"children":835},{"style":104},[836],{"type":70,"value":837},"    return",{"type":64,"tag":97,"props":839,"children":840},{"style":110},[841],{"type":70,"value":842}," new",{"type":64,"tag":97,"props":844,"children":845},{"style":226},[846],{"type":70,"value":847}," Response",{"type":64,"tag":97,"props":849,"children":850},{"style":311},[851],{"type":70,"value":852},"(\n",{"type":64,"tag":97,"props":854,"children":856},{"class":99,"line":855},16,[857,862,867,872,877,882,886,891,896,900,905,909],{"type":64,"tag":97,"props":858,"children":859},{"style":116},[860],{"type":70,"value":861},"      error",{"type":64,"tag":97,"props":863,"children":864},{"style":110},[865],{"type":70,"value":866}," instanceof",{"type":64,"tag":97,"props":868,"children":869},{"style":248},[870],{"type":70,"value":871}," Error",{"type":64,"tag":97,"props":873,"children":874},{"style":110},[875],{"type":70,"value":876}," ?",{"type":64,"tag":97,"props":878,"children":879},{"style":116},[880],{"type":70,"value":881}," error",{"type":64,"tag":97,"props":883,"children":884},{"style":110},[885],{"type":70,"value":303},{"type":64,"tag":97,"props":887,"children":888},{"style":116},[889],{"type":70,"value":890},"message",{"type":64,"tag":97,"props":892,"children":893},{"style":110},[894],{"type":70,"value":895}," :",{"type":64,"tag":97,"props":897,"children":898},{"style":110},[899],{"type":70,"value":144},{"type":64,"tag":97,"props":901,"children":902},{"style":147},[903],{"type":70,"value":904},"Bad request",{"type":64,"tag":97,"props":906,"children":907},{"style":110},[908],{"type":70,"value":370},{"type":64,"tag":97,"props":910,"children":911},{"style":110},[912],{"type":70,"value":388},{"type":64,"tag":97,"props":914,"children":916},{"class":99,"line":915},17,[917,922,927,931,937],{"type":64,"tag":97,"props":918,"children":919},{"style":110},[920],{"type":70,"value":921},"      {",{"type":64,"tag":97,"props":923,"children":924},{"style":311},[925],{"type":70,"value":926}," status",{"type":64,"tag":97,"props":928,"children":929},{"style":110},[930],{"type":70,"value":245},{"type":64,"tag":97,"props":932,"children":934},{"style":933},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[935],{"type":70,"value":936}," 400",{"type":64,"tag":97,"props":938,"children":939},{"style":110},[940],{"type":70,"value":941}," },\n",{"type":64,"tag":97,"props":943,"children":945},{"class":99,"line":944},18,[946],{"type":64,"tag":97,"props":947,"children":948},{"style":311},[949],{"type":70,"value":950},"    )\n",{"type":64,"tag":97,"props":952,"children":954},{"class":99,"line":953},19,[955],{"type":64,"tag":97,"props":956,"children":957},{"style":110},[958],{"type":70,"value":959},"  }\n",{"type":64,"tag":97,"props":961,"children":963},{"class":99,"line":962},20,[964],{"type":64,"tag":97,"props":965,"children":966},{"emptyLinePlaceholder":200},[967],{"type":70,"value":203},{"type":64,"tag":97,"props":969,"children":971},{"class":99,"line":970},21,[972,976,980,984,988,992],{"type":64,"tag":97,"props":973,"children":974},{"style":215},[975],{"type":70,"value":270},{"type":64,"tag":97,"props":977,"children":978},{"style":116},[979],{"type":70,"value":327},{"type":64,"tag":97,"props":981,"children":982},{"style":110},[983],{"type":70,"value":288},{"type":64,"tag":97,"props":985,"children":986},{"style":226},[987],{"type":70,"value":119},{"type":64,"tag":97,"props":989,"children":990},{"style":311},[991],{"type":70,"value":234},{"type":64,"tag":97,"props":993,"children":994},{"style":110},[995],{"type":70,"value":344},{"type":64,"tag":97,"props":997,"children":999},{"class":99,"line":998},22,[1000,1004,1008,1012,1016,1020,1025,1029,1033],{"type":64,"tag":97,"props":1001,"children":1002},{"style":311},[1003],{"type":70,"value":353},{"type":64,"tag":97,"props":1005,"children":1006},{"style":110},[1007],{"type":70,"value":245},{"type":64,"tag":97,"props":1009,"children":1010},{"style":226},[1011],{"type":70,"value":172},{"type":64,"tag":97,"props":1013,"children":1014},{"style":311},[1015],{"type":70,"value":234},{"type":64,"tag":97,"props":1017,"children":1018},{"style":110},[1019],{"type":70,"value":370},{"type":64,"tag":97,"props":1021,"children":1022},{"style":147},[1023],{"type":70,"value":1024},"gpt-4o",{"type":64,"tag":97,"props":1026,"children":1027},{"style":110},[1028],{"type":70,"value":370},{"type":64,"tag":97,"props":1030,"children":1031},{"style":311},[1032],{"type":70,"value":256},{"type":64,"tag":97,"props":1034,"children":1035},{"style":110},[1036],{"type":70,"value":388},{"type":64,"tag":97,"props":1038,"children":1040},{"class":99,"line":1039},23,[1041,1045,1049,1054,1058,1063],{"type":64,"tag":97,"props":1042,"children":1043},{"style":311},[1044],{"type":70,"value":397},{"type":64,"tag":97,"props":1046,"children":1047},{"style":110},[1048],{"type":70,"value":245},{"type":64,"tag":97,"props":1050,"children":1051},{"style":116},[1052],{"type":70,"value":1053}," params",{"type":64,"tag":97,"props":1055,"children":1056},{"style":110},[1057],{"type":70,"value":303},{"type":64,"tag":97,"props":1059,"children":1060},{"style":116},[1061],{"type":70,"value":1062},"messages",{"type":64,"tag":97,"props":1064,"children":1065},{"style":110},[1066],{"type":70,"value":388},{"type":64,"tag":97,"props":1068,"children":1070},{"class":99,"line":1069},24,[1071,1076,1080,1085,1089,1094,1098,1102,1106,1111,1115],{"type":64,"tag":97,"props":1072,"children":1073},{"style":311},[1074],{"type":70,"value":1075},"    tools",{"type":64,"tag":97,"props":1077,"children":1078},{"style":110},[1079],{"type":70,"value":245},{"type":64,"tag":97,"props":1081,"children":1082},{"style":226},[1083],{"type":70,"value":1084}," mergeAgentTools",{"type":64,"tag":97,"props":1086,"children":1087},{"style":311},[1088],{"type":70,"value":234},{"type":64,"tag":97,"props":1090,"children":1091},{"style":116},[1092],{"type":70,"value":1093},"serverTools",{"type":64,"tag":97,"props":1095,"children":1096},{"style":110},[1097],{"type":70,"value":124},{"type":64,"tag":97,"props":1099,"children":1100},{"style":116},[1101],{"type":70,"value":1053},{"type":64,"tag":97,"props":1103,"children":1104},{"style":110},[1105],{"type":70,"value":303},{"type":64,"tag":97,"props":1107,"children":1108},{"style":116},[1109],{"type":70,"value":1110},"tools",{"type":64,"tag":97,"props":1112,"children":1113},{"style":311},[1114],{"type":70,"value":256},{"type":64,"tag":97,"props":1116,"children":1117},{"style":110},[1118],{"type":70,"value":388},{"type":64,"tag":97,"props":1120,"children":1122},{"class":99,"line":1121},25,[1123,1127],{"type":64,"tag":97,"props":1124,"children":1125},{"style":110},[1126],{"type":70,"value":410},{"type":64,"tag":97,"props":1128,"children":1129},{"style":311},[1130],{"type":70,"value":415},{"type":64,"tag":97,"props":1132,"children":1134},{"class":99,"line":1133},26,[1135],{"type":64,"tag":97,"props":1136,"children":1137},{"emptyLinePlaceholder":200},[1138],{"type":70,"value":203},{"type":64,"tag":97,"props":1140,"children":1142},{"class":99,"line":1141},27,[1143,1147,1151,1155,1159],{"type":64,"tag":97,"props":1144,"children":1145},{"style":104},[1146],{"type":70,"value":424},{"type":64,"tag":97,"props":1148,"children":1149},{"style":226},[1150],{"type":70,"value":129},{"type":64,"tag":97,"props":1152,"children":1153},{"style":311},[1154],{"type":70,"value":234},{"type":64,"tag":97,"props":1156,"children":1157},{"style":116},[1158],{"type":70,"value":437},{"type":64,"tag":97,"props":1160,"children":1161},{"style":311},[1162],{"type":70,"value":415},{"type":64,"tag":97,"props":1164,"children":1166},{"class":99,"line":1165},28,[1167],{"type":64,"tag":97,"props":1168,"children":1169},{"style":110},[1170],{"type":70,"value":450},{"type":64,"tag":73,"props":1172,"children":1173},{},[1174,1180,1182,1188,1190,1196,1198,1204,1206,1212],{"type":64,"tag":93,"props":1175,"children":1177},{"className":1176},[],[1178],{"type":70,"value":1179},"chatParamsFromRequestBody",{"type":70,"value":1181}," validates the body against ",{"type":64,"tag":93,"props":1183,"children":1185},{"className":1184},[],[1186],{"type":70,"value":1187},"RunAgentInputSchema",{"type":70,"value":1189}," from ",{"type":64,"tag":93,"props":1191,"children":1193},{"className":1192},[],[1194],{"type":70,"value":1195},"@ag-ui\u002Fcore",{"type":70,"value":1197},". ",{"type":64,"tag":93,"props":1199,"children":1201},{"className":1200},[],[1202],{"type":70,"value":1203},"mergeAgentTools",{"type":70,"value":1205}," merges the server's tool registry with client-declared tools (server wins on collision; client-only tools become no-execute stubs that flow through the runtime's ",{"type":64,"tag":93,"props":1207,"children":1209},{"className":1208},[],[1210],{"type":70,"value":1211},"ClientToolRequest",{"type":70,"value":1213}," path).",{"type":64,"tag":73,"props":1215,"children":1216},{},[1217,1223,1225,1231,1233,1239,1241,1247,1249,1255,1257,1263,1265,1270],{"type":64,"tag":93,"props":1218,"children":1220},{"className":1219},[],[1221],{"type":70,"value":1222},"params.messages",{"type":70,"value":1224}," is a mixed array of TanStack ",{"type":64,"tag":93,"props":1226,"children":1228},{"className":1227},[],[1229],{"type":70,"value":1230},"UIMessage",{"type":70,"value":1232}," anchors (with ",{"type":64,"tag":93,"props":1234,"children":1236},{"className":1235},[],[1237],{"type":70,"value":1238},"parts",{"type":70,"value":1240},") and AG-UI fan-out duplicates (",{"type":64,"tag":93,"props":1242,"children":1244},{"className":1243},[],[1245],{"type":70,"value":1246},"{role:'tool',...}",{"type":70,"value":1248},", ",{"type":64,"tag":93,"props":1250,"children":1252},{"className":1251},[],[1253],{"type":70,"value":1254},"{role:'reasoning',...}",{"type":70,"value":1256},"). The existing ",{"type":64,"tag":93,"props":1258,"children":1260},{"className":1259},[],[1261],{"type":70,"value":1262},"convertMessagesToModelMessages",{"type":70,"value":1264}," (called inside ",{"type":64,"tag":93,"props":1266,"children":1268},{"className":1267},[],[1269],{"type":70,"value":459},{"type":70,"value":1271},") handles dedup automatically.",{"type":64,"tag":73,"props":1273,"children":1274},{},[1275,1281,1283,1289,1291,1297,1299,1304,1306,1311,1313,1318,1320,1326,1327,1333,1335,1340,1342,1347],{"type":64,"tag":1276,"props":1277,"children":1278},"strong",{},[1279],{"type":70,"value":1280},"Wire shape (POST body):",{"type":70,"value":1282}," AG-UI ",{"type":64,"tag":93,"props":1284,"children":1286},{"className":1285},[],[1287],{"type":70,"value":1288},"RunAgentInput",{"type":70,"value":1290}," — ",{"type":64,"tag":93,"props":1292,"children":1294},{"className":1293},[],[1295],{"type":70,"value":1296},"{threadId, runId, parentRunId?, state, messages, tools, context, forwardedProps}",{"type":70,"value":1298},". The ",{"type":64,"tag":93,"props":1300,"children":1302},{"className":1301},[],[1303],{"type":70,"value":1062},{"type":70,"value":1305}," array carries TanStack ",{"type":64,"tag":93,"props":1307,"children":1309},{"className":1308},[],[1310],{"type":70,"value":1230},{"type":70,"value":1312}," anchors with their canonical ",{"type":64,"tag":93,"props":1314,"children":1316},{"className":1315},[],[1317],{"type":70,"value":1238},{"type":70,"value":1319}," plus AG-UI mirror fields (",{"type":64,"tag":93,"props":1321,"children":1323},{"className":1322},[],[1324],{"type":70,"value":1325},"content",{"type":70,"value":1248},{"type":64,"tag":93,"props":1328,"children":1330},{"className":1329},[],[1331],{"type":70,"value":1332},"toolCalls",{"type":70,"value":1334},") inline; tool results and thinking parts are additionally emitted as fan-out ",{"type":64,"tag":93,"props":1336,"children":1338},{"className":1337},[],[1339],{"type":70,"value":1246},{"type":70,"value":1341}," and ",{"type":64,"tag":93,"props":1343,"children":1345},{"className":1344},[],[1346],{"type":70,"value":1254},{"type":70,"value":1348}," entries.",{"type":64,"tag":73,"props":1350,"children":1351},{},[1352,1363,1365,1370,1372,1378,1379,1385,1386,1391],{"type":64,"tag":1276,"props":1353,"children":1354},{},[1355,1361],{"type":64,"tag":93,"props":1356,"children":1358},{"className":1357},[],[1359],{"type":70,"value":1360},"forwardedProps",{"type":70,"value":1362}," security:",{"type":70,"value":1364}," Don't spread it directly into ",{"type":64,"tag":93,"props":1366,"children":1368},{"className":1367},[],[1369],{"type":70,"value":459},{"type":70,"value":1371}," — clients could override ",{"type":64,"tag":93,"props":1373,"children":1375},{"className":1374},[],[1376],{"type":70,"value":1377},"adapter",{"type":70,"value":1248},{"type":64,"tag":93,"props":1380,"children":1382},{"className":1381},[],[1383],{"type":70,"value":1384},"model",{"type":70,"value":1248},{"type":64,"tag":93,"props":1387,"children":1389},{"className":1388},[],[1390],{"type":70,"value":1110},{"type":70,"value":1392},", etc. Always allowlist specific fields.",{"type":64,"tag":79,"props":1394,"children":1396},{"id":1395},"core-patterns",[1397],{"type":70,"value":1398},"Core Patterns",{"type":64,"tag":1400,"props":1401,"children":1403},"h3",{"id":1402},"_1-sse-format-toserversenteventsstream-toserversenteventsresponse",[1404],{"type":70,"value":1405},"1. SSE Format — toServerSentEventsStream \u002F toServerSentEventsResponse",{"type":64,"tag":73,"props":1407,"children":1408},{},[1409,1414,1416,1422,1424,1430],{"type":64,"tag":1276,"props":1410,"children":1411},{},[1412],{"type":70,"value":1413},"Wire format:",{"type":70,"value":1415}," Each event is ",{"type":64,"tag":93,"props":1417,"children":1419},{"className":1418},[],[1420],{"type":70,"value":1421},"data: \u003CJSON>\\n\\n",{"type":70,"value":1423},". Stream ends with ",{"type":64,"tag":93,"props":1425,"children":1427},{"className":1426},[],[1428],{"type":70,"value":1429},"data: [DONE]\\n\\n",{"type":70,"value":303},{"type":64,"tag":86,"props":1432,"children":1434},{"className":88,"code":1433,"language":42,"meta":90,"style":90},"import {\n  chat,\n  toServerSentEventsStream,\n  toServerSentEventsResponse,\n} from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai'\n\n\u002F\u002F Option A: Get a ReadableStream (manual Response construction)\nconst abortController = new AbortController()\nconst stream = chat({\n  adapter: openaiText('gpt-5.2'),\n  messages,\n  abortController,\n})\nconst sseStream = toServerSentEventsStream(stream, abortController)\n\nconst response = new Response(sseStream, {\n  headers: {\n    'Content-Type': 'text\u002Fevent-stream',\n    'Cache-Control': 'no-cache',\n    Connection: 'keep-alive',\n  },\n})\n\n\u002F\u002F Option B: Use the helper (sets headers automatically)\nconst response2 = toServerSentEventsResponse(stream, { abortController })\n\u002F\u002F Default headers: Content-Type: text\u002Fevent-stream, Cache-Control: no-cache, Connection: keep-alive\n",[1435],{"type":64,"tag":93,"props":1436,"children":1437},{"__ignoreMap":90},[1438,1449,1460,1472,1483,1506,1541,1548,1557,1588,1616,1656,1668,1680,1691,1726,1733,1770,1786,1824,1861,1890,1898,1909,1916,1924,1968],{"type":64,"tag":97,"props":1439,"children":1440},{"class":99,"line":100},[1441,1445],{"type":64,"tag":97,"props":1442,"children":1443},{"style":104},[1444],{"type":70,"value":107},{"type":64,"tag":97,"props":1446,"children":1447},{"style":110},[1448],{"type":70,"value":261},{"type":64,"tag":97,"props":1450,"children":1451},{"class":99,"line":158},[1452,1456],{"type":64,"tag":97,"props":1453,"children":1454},{"style":116},[1455],{"type":70,"value":533},{"type":64,"tag":97,"props":1457,"children":1458},{"style":110},[1459],{"type":70,"value":388},{"type":64,"tag":97,"props":1461,"children":1462},{"class":99,"line":196},[1463,1468],{"type":64,"tag":97,"props":1464,"children":1465},{"style":116},[1466],{"type":70,"value":1467},"  toServerSentEventsStream",{"type":64,"tag":97,"props":1469,"children":1470},{"style":110},[1471],{"type":70,"value":388},{"type":64,"tag":97,"props":1473,"children":1474},{"class":99,"line":206},[1475,1479],{"type":64,"tag":97,"props":1476,"children":1477},{"style":116},[1478],{"type":70,"value":569},{"type":64,"tag":97,"props":1480,"children":1481},{"style":110},[1482],{"type":70,"value":388},{"type":64,"tag":97,"props":1484,"children":1485},{"class":99,"line":264},[1486,1490,1494,1498,1502],{"type":64,"tag":97,"props":1487,"children":1488},{"style":110},[1489],{"type":70,"value":581},{"type":64,"tag":97,"props":1491,"children":1492},{"style":104},[1493],{"type":70,"value":139},{"type":64,"tag":97,"props":1495,"children":1496},{"style":110},[1497],{"type":70,"value":144},{"type":64,"tag":97,"props":1499,"children":1500},{"style":147},[1501],{"type":70,"value":150},{"type":64,"tag":97,"props":1503,"children":1504},{"style":110},[1505],{"type":70,"value":155},{"type":64,"tag":97,"props":1507,"children":1508},{"class":99,"line":317},[1509,1513,1517,1521,1525,1529,1533,1537],{"type":64,"tag":97,"props":1510,"children":1511},{"style":104},[1512],{"type":70,"value":107},{"type":64,"tag":97,"props":1514,"children":1515},{"style":110},[1516],{"type":70,"value":113},{"type":64,"tag":97,"props":1518,"children":1519},{"style":116},[1520],{"type":70,"value":172},{"type":64,"tag":97,"props":1522,"children":1523},{"style":110},[1524],{"type":70,"value":134},{"type":64,"tag":97,"props":1526,"children":1527},{"style":104},[1528],{"type":70,"value":139},{"type":64,"tag":97,"props":1530,"children":1531},{"style":110},[1532],{"type":70,"value":144},{"type":64,"tag":97,"props":1534,"children":1535},{"style":147},[1536],{"type":70,"value":189},{"type":64,"tag":97,"props":1538,"children":1539},{"style":110},[1540],{"type":70,"value":155},{"type":64,"tag":97,"props":1542,"children":1543},{"class":99,"line":347},[1544],{"type":64,"tag":97,"props":1545,"children":1546},{"emptyLinePlaceholder":200},[1547],{"type":70,"value":203},{"type":64,"tag":97,"props":1549,"children":1550},{"class":99,"line":391},[1551],{"type":64,"tag":97,"props":1552,"children":1554},{"style":1553},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[1555],{"type":70,"value":1556},"\u002F\u002F Option A: Get a ReadableStream (manual Response construction)\n",{"type":64,"tag":97,"props":1558,"children":1559},{"class":99,"line":404},[1560,1565,1570,1575,1579,1584],{"type":64,"tag":97,"props":1561,"children":1562},{"style":215},[1563],{"type":70,"value":1564},"const",{"type":64,"tag":97,"props":1566,"children":1567},{"style":116},[1568],{"type":70,"value":1569}," abortController ",{"type":64,"tag":97,"props":1571,"children":1572},{"style":110},[1573],{"type":70,"value":1574},"=",{"type":64,"tag":97,"props":1576,"children":1577},{"style":110},[1578],{"type":70,"value":842},{"type":64,"tag":97,"props":1580,"children":1581},{"style":226},[1582],{"type":70,"value":1583}," AbortController",{"type":64,"tag":97,"props":1585,"children":1586},{"style":116},[1587],{"type":70,"value":314},{"type":64,"tag":97,"props":1589,"children":1590},{"class":99,"line":418},[1591,1595,1600,1604,1608,1612],{"type":64,"tag":97,"props":1592,"children":1593},{"style":215},[1594],{"type":70,"value":1564},{"type":64,"tag":97,"props":1596,"children":1597},{"style":116},[1598],{"type":70,"value":1599}," stream ",{"type":64,"tag":97,"props":1601,"children":1602},{"style":110},[1603],{"type":70,"value":1574},{"type":64,"tag":97,"props":1605,"children":1606},{"style":226},[1607],{"type":70,"value":119},{"type":64,"tag":97,"props":1609,"children":1610},{"style":116},[1611],{"type":70,"value":234},{"type":64,"tag":97,"props":1613,"children":1614},{"style":110},[1615],{"type":70,"value":344},{"type":64,"tag":97,"props":1617,"children":1618},{"class":99,"line":444},[1619,1624,1628,1632,1636,1640,1644,1648,1652],{"type":64,"tag":97,"props":1620,"children":1621},{"style":311},[1622],{"type":70,"value":1623},"  adapter",{"type":64,"tag":97,"props":1625,"children":1626},{"style":110},[1627],{"type":70,"value":245},{"type":64,"tag":97,"props":1629,"children":1630},{"style":226},[1631],{"type":70,"value":172},{"type":64,"tag":97,"props":1633,"children":1634},{"style":116},[1635],{"type":70,"value":234},{"type":64,"tag":97,"props":1637,"children":1638},{"style":110},[1639],{"type":70,"value":370},{"type":64,"tag":97,"props":1641,"children":1642},{"style":147},[1643],{"type":70,"value":375},{"type":64,"tag":97,"props":1645,"children":1646},{"style":110},[1647],{"type":70,"value":370},{"type":64,"tag":97,"props":1649,"children":1650},{"style":116},[1651],{"type":70,"value":256},{"type":64,"tag":97,"props":1653,"children":1654},{"style":110},[1655],{"type":70,"value":388},{"type":64,"tag":97,"props":1657,"children":1658},{"class":99,"line":737},[1659,1664],{"type":64,"tag":97,"props":1660,"children":1661},{"style":116},[1662],{"type":70,"value":1663},"  messages",{"type":64,"tag":97,"props":1665,"children":1666},{"style":110},[1667],{"type":70,"value":388},{"type":64,"tag":97,"props":1669,"children":1670},{"class":99,"line":750},[1671,1676],{"type":64,"tag":97,"props":1672,"children":1673},{"style":116},[1674],{"type":70,"value":1675},"  abortController",{"type":64,"tag":97,"props":1677,"children":1678},{"style":110},[1679],{"type":70,"value":388},{"type":64,"tag":97,"props":1681,"children":1682},{"class":99,"line":799},[1683,1687],{"type":64,"tag":97,"props":1684,"children":1685},{"style":110},[1686],{"type":70,"value":581},{"type":64,"tag":97,"props":1688,"children":1689},{"style":116},[1690],{"type":70,"value":415},{"type":64,"tag":97,"props":1692,"children":1693},{"class":99,"line":831},[1694,1698,1703,1707,1712,1717,1721],{"type":64,"tag":97,"props":1695,"children":1696},{"style":215},[1697],{"type":70,"value":1564},{"type":64,"tag":97,"props":1699,"children":1700},{"style":116},[1701],{"type":70,"value":1702}," sseStream ",{"type":64,"tag":97,"props":1704,"children":1705},{"style":110},[1706],{"type":70,"value":1574},{"type":64,"tag":97,"props":1708,"children":1709},{"style":226},[1710],{"type":70,"value":1711}," toServerSentEventsStream",{"type":64,"tag":97,"props":1713,"children":1714},{"style":116},[1715],{"type":70,"value":1716},"(stream",{"type":64,"tag":97,"props":1718,"children":1719},{"style":110},[1720],{"type":70,"value":124},{"type":64,"tag":97,"props":1722,"children":1723},{"style":116},[1724],{"type":70,"value":1725}," abortController)\n",{"type":64,"tag":97,"props":1727,"children":1728},{"class":99,"line":855},[1729],{"type":64,"tag":97,"props":1730,"children":1731},{"emptyLinePlaceholder":200},[1732],{"type":70,"value":203},{"type":64,"tag":97,"props":1734,"children":1735},{"class":99,"line":915},[1736,1740,1745,1749,1753,1757,1762,1766],{"type":64,"tag":97,"props":1737,"children":1738},{"style":215},[1739],{"type":70,"value":1564},{"type":64,"tag":97,"props":1741,"children":1742},{"style":116},[1743],{"type":70,"value":1744}," response ",{"type":64,"tag":97,"props":1746,"children":1747},{"style":110},[1748],{"type":70,"value":1574},{"type":64,"tag":97,"props":1750,"children":1751},{"style":110},[1752],{"type":70,"value":842},{"type":64,"tag":97,"props":1754,"children":1755},{"style":226},[1756],{"type":70,"value":847},{"type":64,"tag":97,"props":1758,"children":1759},{"style":116},[1760],{"type":70,"value":1761},"(sseStream",{"type":64,"tag":97,"props":1763,"children":1764},{"style":110},[1765],{"type":70,"value":124},{"type":64,"tag":97,"props":1767,"children":1768},{"style":110},[1769],{"type":70,"value":261},{"type":64,"tag":97,"props":1771,"children":1772},{"class":99,"line":944},[1773,1778,1782],{"type":64,"tag":97,"props":1774,"children":1775},{"style":311},[1776],{"type":70,"value":1777},"  headers",{"type":64,"tag":97,"props":1779,"children":1780},{"style":110},[1781],{"type":70,"value":245},{"type":64,"tag":97,"props":1783,"children":1784},{"style":110},[1785],{"type":70,"value":261},{"type":64,"tag":97,"props":1787,"children":1788},{"class":99,"line":953},[1789,1794,1799,1803,1807,1811,1816,1820],{"type":64,"tag":97,"props":1790,"children":1791},{"style":110},[1792],{"type":70,"value":1793},"    '",{"type":64,"tag":97,"props":1795,"children":1796},{"style":311},[1797],{"type":70,"value":1798},"Content-Type",{"type":64,"tag":97,"props":1800,"children":1801},{"style":110},[1802],{"type":70,"value":370},{"type":64,"tag":97,"props":1804,"children":1805},{"style":110},[1806],{"type":70,"value":245},{"type":64,"tag":97,"props":1808,"children":1809},{"style":110},[1810],{"type":70,"value":144},{"type":64,"tag":97,"props":1812,"children":1813},{"style":147},[1814],{"type":70,"value":1815},"text\u002Fevent-stream",{"type":64,"tag":97,"props":1817,"children":1818},{"style":110},[1819],{"type":70,"value":370},{"type":64,"tag":97,"props":1821,"children":1822},{"style":110},[1823],{"type":70,"value":388},{"type":64,"tag":97,"props":1825,"children":1826},{"class":99,"line":962},[1827,1831,1836,1840,1844,1848,1853,1857],{"type":64,"tag":97,"props":1828,"children":1829},{"style":110},[1830],{"type":70,"value":1793},{"type":64,"tag":97,"props":1832,"children":1833},{"style":311},[1834],{"type":70,"value":1835},"Cache-Control",{"type":64,"tag":97,"props":1837,"children":1838},{"style":110},[1839],{"type":70,"value":370},{"type":64,"tag":97,"props":1841,"children":1842},{"style":110},[1843],{"type":70,"value":245},{"type":64,"tag":97,"props":1845,"children":1846},{"style":110},[1847],{"type":70,"value":144},{"type":64,"tag":97,"props":1849,"children":1850},{"style":147},[1851],{"type":70,"value":1852},"no-cache",{"type":64,"tag":97,"props":1854,"children":1855},{"style":110},[1856],{"type":70,"value":370},{"type":64,"tag":97,"props":1858,"children":1859},{"style":110},[1860],{"type":70,"value":388},{"type":64,"tag":97,"props":1862,"children":1863},{"class":99,"line":970},[1864,1869,1873,1877,1882,1886],{"type":64,"tag":97,"props":1865,"children":1866},{"style":311},[1867],{"type":70,"value":1868},"    Connection",{"type":64,"tag":97,"props":1870,"children":1871},{"style":110},[1872],{"type":70,"value":245},{"type":64,"tag":97,"props":1874,"children":1875},{"style":110},[1876],{"type":70,"value":144},{"type":64,"tag":97,"props":1878,"children":1879},{"style":147},[1880],{"type":70,"value":1881},"keep-alive",{"type":64,"tag":97,"props":1883,"children":1884},{"style":110},[1885],{"type":70,"value":370},{"type":64,"tag":97,"props":1887,"children":1888},{"style":110},[1889],{"type":70,"value":388},{"type":64,"tag":97,"props":1891,"children":1892},{"class":99,"line":998},[1893],{"type":64,"tag":97,"props":1894,"children":1895},{"style":110},[1896],{"type":70,"value":1897},"  },\n",{"type":64,"tag":97,"props":1899,"children":1900},{"class":99,"line":1039},[1901,1905],{"type":64,"tag":97,"props":1902,"children":1903},{"style":110},[1904],{"type":70,"value":581},{"type":64,"tag":97,"props":1906,"children":1907},{"style":116},[1908],{"type":70,"value":415},{"type":64,"tag":97,"props":1910,"children":1911},{"class":99,"line":1069},[1912],{"type":64,"tag":97,"props":1913,"children":1914},{"emptyLinePlaceholder":200},[1915],{"type":70,"value":203},{"type":64,"tag":97,"props":1917,"children":1918},{"class":99,"line":1121},[1919],{"type":64,"tag":97,"props":1920,"children":1921},{"style":1553},[1922],{"type":70,"value":1923},"\u002F\u002F Option B: Use the helper (sets headers automatically)\n",{"type":64,"tag":97,"props":1925,"children":1926},{"class":99,"line":1133},[1927,1931,1936,1940,1944,1948,1952,1956,1960,1964],{"type":64,"tag":97,"props":1928,"children":1929},{"style":215},[1930],{"type":70,"value":1564},{"type":64,"tag":97,"props":1932,"children":1933},{"style":116},[1934],{"type":70,"value":1935}," response2 ",{"type":64,"tag":97,"props":1937,"children":1938},{"style":110},[1939],{"type":70,"value":1574},{"type":64,"tag":97,"props":1941,"children":1942},{"style":226},[1943],{"type":70,"value":129},{"type":64,"tag":97,"props":1945,"children":1946},{"style":116},[1947],{"type":70,"value":1716},{"type":64,"tag":97,"props":1949,"children":1950},{"style":110},[1951],{"type":70,"value":124},{"type":64,"tag":97,"props":1953,"children":1954},{"style":110},[1955],{"type":70,"value":113},{"type":64,"tag":97,"props":1957,"children":1958},{"style":116},[1959],{"type":70,"value":1569},{"type":64,"tag":97,"props":1961,"children":1962},{"style":110},[1963],{"type":70,"value":581},{"type":64,"tag":97,"props":1965,"children":1966},{"style":116},[1967],{"type":70,"value":415},{"type":64,"tag":97,"props":1969,"children":1970},{"class":99,"line":1141},[1971],{"type":64,"tag":97,"props":1972,"children":1973},{"style":1553},[1974],{"type":70,"value":1975},"\u002F\u002F Default headers: Content-Type: text\u002Fevent-stream, Cache-Control: no-cache, Connection: keep-alive\n",{"type":64,"tag":73,"props":1977,"children":1978},{},[1979],{"type":64,"tag":1276,"props":1980,"children":1981},{},[1982,1984,1989],{"type":70,"value":1983},"Default response headers set by ",{"type":64,"tag":93,"props":1985,"children":1987},{"className":1986},[],[1988],{"type":70,"value":491},{"type":70,"value":245},{"type":64,"tag":1991,"props":1992,"children":1993},"table",{},[1994,2013],{"type":64,"tag":1995,"props":1996,"children":1997},"thead",{},[1998],{"type":64,"tag":1999,"props":2000,"children":2001},"tr",{},[2002,2008],{"type":64,"tag":2003,"props":2004,"children":2005},"th",{},[2006],{"type":70,"value":2007},"Header",{"type":64,"tag":2003,"props":2009,"children":2010},{},[2011],{"type":70,"value":2012},"Value",{"type":64,"tag":2014,"props":2015,"children":2016},"tbody",{},[2017,2037,2056],{"type":64,"tag":1999,"props":2018,"children":2019},{},[2020,2029],{"type":64,"tag":2021,"props":2022,"children":2023},"td",{},[2024],{"type":64,"tag":93,"props":2025,"children":2027},{"className":2026},[],[2028],{"type":70,"value":1798},{"type":64,"tag":2021,"props":2030,"children":2031},{},[2032],{"type":64,"tag":93,"props":2033,"children":2035},{"className":2034},[],[2036],{"type":70,"value":1815},{"type":64,"tag":1999,"props":2038,"children":2039},{},[2040,2048],{"type":64,"tag":2021,"props":2041,"children":2042},{},[2043],{"type":64,"tag":93,"props":2044,"children":2046},{"className":2045},[],[2047],{"type":70,"value":1835},{"type":64,"tag":2021,"props":2049,"children":2050},{},[2051],{"type":64,"tag":93,"props":2052,"children":2054},{"className":2053},[],[2055],{"type":70,"value":1852},{"type":64,"tag":1999,"props":2057,"children":2058},{},[2059,2068],{"type":64,"tag":2021,"props":2060,"children":2061},{},[2062],{"type":64,"tag":93,"props":2063,"children":2065},{"className":2064},[],[2066],{"type":70,"value":2067},"Connection",{"type":64,"tag":2021,"props":2069,"children":2070},{},[2071],{"type":64,"tag":93,"props":2072,"children":2074},{"className":2073},[],[2075],{"type":70,"value":1881},{"type":64,"tag":73,"props":2077,"children":2078},{},[2079],{"type":70,"value":2080},"Custom headers merge on top (user headers override defaults):",{"type":64,"tag":86,"props":2082,"children":2084},{"className":88,"code":2083,"language":42,"meta":90,"style":90},"toServerSentEventsResponse(stream, {\n  headers: {\n    'X-Accel-Buffering': 'no', \u002F\u002F Disable nginx buffering\n    'Cache-Control': 'no-store', \u002F\u002F Override default\n  },\n  abortController,\n})\n",[2085],{"type":64,"tag":93,"props":2086,"children":2087},{"__ignoreMap":90},[2088,2108,2123,2165,2206,2213,2224],{"type":64,"tag":97,"props":2089,"children":2090},{"class":99,"line":100},[2091,2096,2100,2104],{"type":64,"tag":97,"props":2092,"children":2093},{"style":226},[2094],{"type":70,"value":2095},"toServerSentEventsResponse",{"type":64,"tag":97,"props":2097,"children":2098},{"style":116},[2099],{"type":70,"value":1716},{"type":64,"tag":97,"props":2101,"children":2102},{"style":110},[2103],{"type":70,"value":124},{"type":64,"tag":97,"props":2105,"children":2106},{"style":110},[2107],{"type":70,"value":261},{"type":64,"tag":97,"props":2109,"children":2110},{"class":99,"line":158},[2111,2115,2119],{"type":64,"tag":97,"props":2112,"children":2113},{"style":311},[2114],{"type":70,"value":1777},{"type":64,"tag":97,"props":2116,"children":2117},{"style":110},[2118],{"type":70,"value":245},{"type":64,"tag":97,"props":2120,"children":2121},{"style":110},[2122],{"type":70,"value":261},{"type":64,"tag":97,"props":2124,"children":2125},{"class":99,"line":196},[2126,2130,2135,2139,2143,2147,2152,2156,2160],{"type":64,"tag":97,"props":2127,"children":2128},{"style":110},[2129],{"type":70,"value":1793},{"type":64,"tag":97,"props":2131,"children":2132},{"style":311},[2133],{"type":70,"value":2134},"X-Accel-Buffering",{"type":64,"tag":97,"props":2136,"children":2137},{"style":110},[2138],{"type":70,"value":370},{"type":64,"tag":97,"props":2140,"children":2141},{"style":110},[2142],{"type":70,"value":245},{"type":64,"tag":97,"props":2144,"children":2145},{"style":110},[2146],{"type":70,"value":144},{"type":64,"tag":97,"props":2148,"children":2149},{"style":147},[2150],{"type":70,"value":2151},"no",{"type":64,"tag":97,"props":2153,"children":2154},{"style":110},[2155],{"type":70,"value":370},{"type":64,"tag":97,"props":2157,"children":2158},{"style":110},[2159],{"type":70,"value":124},{"type":64,"tag":97,"props":2161,"children":2162},{"style":1553},[2163],{"type":70,"value":2164}," \u002F\u002F Disable nginx buffering\n",{"type":64,"tag":97,"props":2166,"children":2167},{"class":99,"line":206},[2168,2172,2176,2180,2184,2188,2193,2197,2201],{"type":64,"tag":97,"props":2169,"children":2170},{"style":110},[2171],{"type":70,"value":1793},{"type":64,"tag":97,"props":2173,"children":2174},{"style":311},[2175],{"type":70,"value":1835},{"type":64,"tag":97,"props":2177,"children":2178},{"style":110},[2179],{"type":70,"value":370},{"type":64,"tag":97,"props":2181,"children":2182},{"style":110},[2183],{"type":70,"value":245},{"type":64,"tag":97,"props":2185,"children":2186},{"style":110},[2187],{"type":70,"value":144},{"type":64,"tag":97,"props":2189,"children":2190},{"style":147},[2191],{"type":70,"value":2192},"no-store",{"type":64,"tag":97,"props":2194,"children":2195},{"style":110},[2196],{"type":70,"value":370},{"type":64,"tag":97,"props":2198,"children":2199},{"style":110},[2200],{"type":70,"value":124},{"type":64,"tag":97,"props":2202,"children":2203},{"style":1553},[2204],{"type":70,"value":2205}," \u002F\u002F Override default\n",{"type":64,"tag":97,"props":2207,"children":2208},{"class":99,"line":264},[2209],{"type":64,"tag":97,"props":2210,"children":2211},{"style":110},[2212],{"type":70,"value":1897},{"type":64,"tag":97,"props":2214,"children":2215},{"class":99,"line":317},[2216,2220],{"type":64,"tag":97,"props":2217,"children":2218},{"style":116},[2219],{"type":70,"value":1675},{"type":64,"tag":97,"props":2221,"children":2222},{"style":110},[2223],{"type":70,"value":388},{"type":64,"tag":97,"props":2225,"children":2226},{"class":99,"line":347},[2227,2231],{"type":64,"tag":97,"props":2228,"children":2229},{"style":110},[2230],{"type":70,"value":581},{"type":64,"tag":97,"props":2232,"children":2233},{"style":116},[2234],{"type":70,"value":415},{"type":64,"tag":73,"props":2236,"children":2237},{},[2238,2243,2245,2251,2253,2259],{"type":64,"tag":1276,"props":2239,"children":2240},{},[2241],{"type":70,"value":2242},"Error handling:",{"type":70,"value":2244}," If the stream throws, a ",{"type":64,"tag":93,"props":2246,"children":2248},{"className":2247},[],[2249],{"type":70,"value":2250},"RUN_ERROR",{"type":70,"value":2252}," event is emitted\nautomatically before the stream closes. If the ",{"type":64,"tag":93,"props":2254,"children":2256},{"className":2255},[],[2257],{"type":70,"value":2258},"abortController",{"type":70,"value":2260}," is already\naborted, the error event is suppressed and the stream closes silently.",{"type":64,"tag":1400,"props":2262,"children":2264},{"id":2263},"_2-http-stream-ndjson-tohttpstream-tohttpresponse",[2265],{"type":70,"value":2266},"2. HTTP Stream (NDJSON) — toHttpStream \u002F toHttpResponse",{"type":64,"tag":73,"props":2268,"children":2269},{},[2270,2274,2275,2281,2283,2289],{"type":64,"tag":1276,"props":2271,"children":2272},{},[2273],{"type":70,"value":1413},{"type":70,"value":1415},{"type":64,"tag":93,"props":2276,"children":2278},{"className":2277},[],[2279],{"type":70,"value":2280},"\u003CJSON>\\n",{"type":70,"value":2282}," (newline-delimited JSON, no SSE prefix, no ",{"type":64,"tag":93,"props":2284,"children":2286},{"className":2285},[],[2287],{"type":70,"value":2288},"[DONE]",{"type":70,"value":2290}," marker).",{"type":64,"tag":86,"props":2292,"children":2294},{"className":88,"code":2293,"language":42,"meta":90,"style":90},"import { chat, toHttpStream, toHttpResponse } from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai'\n\n\u002F\u002F Option A: Get a ReadableStream\nconst abortController = new AbortController()\nconst stream = chat({\n  adapter: openaiText('gpt-5.2'),\n  messages,\n  abortController,\n})\nconst ndjsonStream = toHttpStream(stream, abortController)\n\nconst response = new Response(ndjsonStream, {\n  headers: {\n    'Content-Type': 'application\u002Fx-ndjson',\n  },\n})\n\n\u002F\u002F Option B: Use the helper (does NOT set headers automatically)\nconst response2 = toHttpResponse(stream, { abortController })\n\u002F\u002F Note: toHttpResponse does NOT set Content-Type automatically.\n\u002F\u002F You should pass headers explicitly:\nconst response3 = toHttpResponse(stream, {\n  headers: { 'Content-Type': 'application\u002Fx-ndjson' },\n  abortController,\n})\n",[2295],{"type":64,"tag":93,"props":2296,"children":2297},{"__ignoreMap":90},[2298,2351,2386,2393,2401,2428,2455,2494,2505,2516,2527,2559,2566,2602,2617,2653,2660,2671,2678,2686,2729,2737,2745,2777,2824,2835],{"type":64,"tag":97,"props":2299,"children":2300},{"class":99,"line":100},[2301,2305,2309,2313,2317,2322,2326,2331,2335,2339,2343,2347],{"type":64,"tag":97,"props":2302,"children":2303},{"style":104},[2304],{"type":70,"value":107},{"type":64,"tag":97,"props":2306,"children":2307},{"style":110},[2308],{"type":70,"value":113},{"type":64,"tag":97,"props":2310,"children":2311},{"style":116},[2312],{"type":70,"value":119},{"type":64,"tag":97,"props":2314,"children":2315},{"style":110},[2316],{"type":70,"value":124},{"type":64,"tag":97,"props":2318,"children":2319},{"style":116},[2320],{"type":70,"value":2321}," toHttpStream",{"type":64,"tag":97,"props":2323,"children":2324},{"style":110},[2325],{"type":70,"value":124},{"type":64,"tag":97,"props":2327,"children":2328},{"style":116},[2329],{"type":70,"value":2330}," toHttpResponse",{"type":64,"tag":97,"props":2332,"children":2333},{"style":110},[2334],{"type":70,"value":134},{"type":64,"tag":97,"props":2336,"children":2337},{"style":104},[2338],{"type":70,"value":139},{"type":64,"tag":97,"props":2340,"children":2341},{"style":110},[2342],{"type":70,"value":144},{"type":64,"tag":97,"props":2344,"children":2345},{"style":147},[2346],{"type":70,"value":150},{"type":64,"tag":97,"props":2348,"children":2349},{"style":110},[2350],{"type":70,"value":155},{"type":64,"tag":97,"props":2352,"children":2353},{"class":99,"line":158},[2354,2358,2362,2366,2370,2374,2378,2382],{"type":64,"tag":97,"props":2355,"children":2356},{"style":104},[2357],{"type":70,"value":107},{"type":64,"tag":97,"props":2359,"children":2360},{"style":110},[2361],{"type":70,"value":113},{"type":64,"tag":97,"props":2363,"children":2364},{"style":116},[2365],{"type":70,"value":172},{"type":64,"tag":97,"props":2367,"children":2368},{"style":110},[2369],{"type":70,"value":134},{"type":64,"tag":97,"props":2371,"children":2372},{"style":104},[2373],{"type":70,"value":139},{"type":64,"tag":97,"props":2375,"children":2376},{"style":110},[2377],{"type":70,"value":144},{"type":64,"tag":97,"props":2379,"children":2380},{"style":147},[2381],{"type":70,"value":189},{"type":64,"tag":97,"props":2383,"children":2384},{"style":110},[2385],{"type":70,"value":155},{"type":64,"tag":97,"props":2387,"children":2388},{"class":99,"line":196},[2389],{"type":64,"tag":97,"props":2390,"children":2391},{"emptyLinePlaceholder":200},[2392],{"type":70,"value":203},{"type":64,"tag":97,"props":2394,"children":2395},{"class":99,"line":206},[2396],{"type":64,"tag":97,"props":2397,"children":2398},{"style":1553},[2399],{"type":70,"value":2400},"\u002F\u002F Option A: Get a ReadableStream\n",{"type":64,"tag":97,"props":2402,"children":2403},{"class":99,"line":264},[2404,2408,2412,2416,2420,2424],{"type":64,"tag":97,"props":2405,"children":2406},{"style":215},[2407],{"type":70,"value":1564},{"type":64,"tag":97,"props":2409,"children":2410},{"style":116},[2411],{"type":70,"value":1569},{"type":64,"tag":97,"props":2413,"children":2414},{"style":110},[2415],{"type":70,"value":1574},{"type":64,"tag":97,"props":2417,"children":2418},{"style":110},[2419],{"type":70,"value":842},{"type":64,"tag":97,"props":2421,"children":2422},{"style":226},[2423],{"type":70,"value":1583},{"type":64,"tag":97,"props":2425,"children":2426},{"style":116},[2427],{"type":70,"value":314},{"type":64,"tag":97,"props":2429,"children":2430},{"class":99,"line":317},[2431,2435,2439,2443,2447,2451],{"type":64,"tag":97,"props":2432,"children":2433},{"style":215},[2434],{"type":70,"value":1564},{"type":64,"tag":97,"props":2436,"children":2437},{"style":116},[2438],{"type":70,"value":1599},{"type":64,"tag":97,"props":2440,"children":2441},{"style":110},[2442],{"type":70,"value":1574},{"type":64,"tag":97,"props":2444,"children":2445},{"style":226},[2446],{"type":70,"value":119},{"type":64,"tag":97,"props":2448,"children":2449},{"style":116},[2450],{"type":70,"value":234},{"type":64,"tag":97,"props":2452,"children":2453},{"style":110},[2454],{"type":70,"value":344},{"type":64,"tag":97,"props":2456,"children":2457},{"class":99,"line":347},[2458,2462,2466,2470,2474,2478,2482,2486,2490],{"type":64,"tag":97,"props":2459,"children":2460},{"style":311},[2461],{"type":70,"value":1623},{"type":64,"tag":97,"props":2463,"children":2464},{"style":110},[2465],{"type":70,"value":245},{"type":64,"tag":97,"props":2467,"children":2468},{"style":226},[2469],{"type":70,"value":172},{"type":64,"tag":97,"props":2471,"children":2472},{"style":116},[2473],{"type":70,"value":234},{"type":64,"tag":97,"props":2475,"children":2476},{"style":110},[2477],{"type":70,"value":370},{"type":64,"tag":97,"props":2479,"children":2480},{"style":147},[2481],{"type":70,"value":375},{"type":64,"tag":97,"props":2483,"children":2484},{"style":110},[2485],{"type":70,"value":370},{"type":64,"tag":97,"props":2487,"children":2488},{"style":116},[2489],{"type":70,"value":256},{"type":64,"tag":97,"props":2491,"children":2492},{"style":110},[2493],{"type":70,"value":388},{"type":64,"tag":97,"props":2495,"children":2496},{"class":99,"line":391},[2497,2501],{"type":64,"tag":97,"props":2498,"children":2499},{"style":116},[2500],{"type":70,"value":1663},{"type":64,"tag":97,"props":2502,"children":2503},{"style":110},[2504],{"type":70,"value":388},{"type":64,"tag":97,"props":2506,"children":2507},{"class":99,"line":404},[2508,2512],{"type":64,"tag":97,"props":2509,"children":2510},{"style":116},[2511],{"type":70,"value":1675},{"type":64,"tag":97,"props":2513,"children":2514},{"style":110},[2515],{"type":70,"value":388},{"type":64,"tag":97,"props":2517,"children":2518},{"class":99,"line":418},[2519,2523],{"type":64,"tag":97,"props":2520,"children":2521},{"style":110},[2522],{"type":70,"value":581},{"type":64,"tag":97,"props":2524,"children":2525},{"style":116},[2526],{"type":70,"value":415},{"type":64,"tag":97,"props":2528,"children":2529},{"class":99,"line":444},[2530,2534,2539,2543,2547,2551,2555],{"type":64,"tag":97,"props":2531,"children":2532},{"style":215},[2533],{"type":70,"value":1564},{"type":64,"tag":97,"props":2535,"children":2536},{"style":116},[2537],{"type":70,"value":2538}," ndjsonStream ",{"type":64,"tag":97,"props":2540,"children":2541},{"style":110},[2542],{"type":70,"value":1574},{"type":64,"tag":97,"props":2544,"children":2545},{"style":226},[2546],{"type":70,"value":2321},{"type":64,"tag":97,"props":2548,"children":2549},{"style":116},[2550],{"type":70,"value":1716},{"type":64,"tag":97,"props":2552,"children":2553},{"style":110},[2554],{"type":70,"value":124},{"type":64,"tag":97,"props":2556,"children":2557},{"style":116},[2558],{"type":70,"value":1725},{"type":64,"tag":97,"props":2560,"children":2561},{"class":99,"line":737},[2562],{"type":64,"tag":97,"props":2563,"children":2564},{"emptyLinePlaceholder":200},[2565],{"type":70,"value":203},{"type":64,"tag":97,"props":2567,"children":2568},{"class":99,"line":750},[2569,2573,2577,2581,2585,2589,2594,2598],{"type":64,"tag":97,"props":2570,"children":2571},{"style":215},[2572],{"type":70,"value":1564},{"type":64,"tag":97,"props":2574,"children":2575},{"style":116},[2576],{"type":70,"value":1744},{"type":64,"tag":97,"props":2578,"children":2579},{"style":110},[2580],{"type":70,"value":1574},{"type":64,"tag":97,"props":2582,"children":2583},{"style":110},[2584],{"type":70,"value":842},{"type":64,"tag":97,"props":2586,"children":2587},{"style":226},[2588],{"type":70,"value":847},{"type":64,"tag":97,"props":2590,"children":2591},{"style":116},[2592],{"type":70,"value":2593},"(ndjsonStream",{"type":64,"tag":97,"props":2595,"children":2596},{"style":110},[2597],{"type":70,"value":124},{"type":64,"tag":97,"props":2599,"children":2600},{"style":110},[2601],{"type":70,"value":261},{"type":64,"tag":97,"props":2603,"children":2604},{"class":99,"line":799},[2605,2609,2613],{"type":64,"tag":97,"props":2606,"children":2607},{"style":311},[2608],{"type":70,"value":1777},{"type":64,"tag":97,"props":2610,"children":2611},{"style":110},[2612],{"type":70,"value":245},{"type":64,"tag":97,"props":2614,"children":2615},{"style":110},[2616],{"type":70,"value":261},{"type":64,"tag":97,"props":2618,"children":2619},{"class":99,"line":831},[2620,2624,2628,2632,2636,2640,2645,2649],{"type":64,"tag":97,"props":2621,"children":2622},{"style":110},[2623],{"type":70,"value":1793},{"type":64,"tag":97,"props":2625,"children":2626},{"style":311},[2627],{"type":70,"value":1798},{"type":64,"tag":97,"props":2629,"children":2630},{"style":110},[2631],{"type":70,"value":370},{"type":64,"tag":97,"props":2633,"children":2634},{"style":110},[2635],{"type":70,"value":245},{"type":64,"tag":97,"props":2637,"children":2638},{"style":110},[2639],{"type":70,"value":144},{"type":64,"tag":97,"props":2641,"children":2642},{"style":147},[2643],{"type":70,"value":2644},"application\u002Fx-ndjson",{"type":64,"tag":97,"props":2646,"children":2647},{"style":110},[2648],{"type":70,"value":370},{"type":64,"tag":97,"props":2650,"children":2651},{"style":110},[2652],{"type":70,"value":388},{"type":64,"tag":97,"props":2654,"children":2655},{"class":99,"line":855},[2656],{"type":64,"tag":97,"props":2657,"children":2658},{"style":110},[2659],{"type":70,"value":1897},{"type":64,"tag":97,"props":2661,"children":2662},{"class":99,"line":915},[2663,2667],{"type":64,"tag":97,"props":2664,"children":2665},{"style":110},[2666],{"type":70,"value":581},{"type":64,"tag":97,"props":2668,"children":2669},{"style":116},[2670],{"type":70,"value":415},{"type":64,"tag":97,"props":2672,"children":2673},{"class":99,"line":944},[2674],{"type":64,"tag":97,"props":2675,"children":2676},{"emptyLinePlaceholder":200},[2677],{"type":70,"value":203},{"type":64,"tag":97,"props":2679,"children":2680},{"class":99,"line":953},[2681],{"type":64,"tag":97,"props":2682,"children":2683},{"style":1553},[2684],{"type":70,"value":2685},"\u002F\u002F Option B: Use the helper (does NOT set headers automatically)\n",{"type":64,"tag":97,"props":2687,"children":2688},{"class":99,"line":962},[2689,2693,2697,2701,2705,2709,2713,2717,2721,2725],{"type":64,"tag":97,"props":2690,"children":2691},{"style":215},[2692],{"type":70,"value":1564},{"type":64,"tag":97,"props":2694,"children":2695},{"style":116},[2696],{"type":70,"value":1935},{"type":64,"tag":97,"props":2698,"children":2699},{"style":110},[2700],{"type":70,"value":1574},{"type":64,"tag":97,"props":2702,"children":2703},{"style":226},[2704],{"type":70,"value":2330},{"type":64,"tag":97,"props":2706,"children":2707},{"style":116},[2708],{"type":70,"value":1716},{"type":64,"tag":97,"props":2710,"children":2711},{"style":110},[2712],{"type":70,"value":124},{"type":64,"tag":97,"props":2714,"children":2715},{"style":110},[2716],{"type":70,"value":113},{"type":64,"tag":97,"props":2718,"children":2719},{"style":116},[2720],{"type":70,"value":1569},{"type":64,"tag":97,"props":2722,"children":2723},{"style":110},[2724],{"type":70,"value":581},{"type":64,"tag":97,"props":2726,"children":2727},{"style":116},[2728],{"type":70,"value":415},{"type":64,"tag":97,"props":2730,"children":2731},{"class":99,"line":970},[2732],{"type":64,"tag":97,"props":2733,"children":2734},{"style":1553},[2735],{"type":70,"value":2736},"\u002F\u002F Note: toHttpResponse does NOT set Content-Type automatically.\n",{"type":64,"tag":97,"props":2738,"children":2739},{"class":99,"line":998},[2740],{"type":64,"tag":97,"props":2741,"children":2742},{"style":1553},[2743],{"type":70,"value":2744},"\u002F\u002F You should pass headers explicitly:\n",{"type":64,"tag":97,"props":2746,"children":2747},{"class":99,"line":1039},[2748,2752,2757,2761,2765,2769,2773],{"type":64,"tag":97,"props":2749,"children":2750},{"style":215},[2751],{"type":70,"value":1564},{"type":64,"tag":97,"props":2753,"children":2754},{"style":116},[2755],{"type":70,"value":2756}," response3 ",{"type":64,"tag":97,"props":2758,"children":2759},{"style":110},[2760],{"type":70,"value":1574},{"type":64,"tag":97,"props":2762,"children":2763},{"style":226},[2764],{"type":70,"value":2330},{"type":64,"tag":97,"props":2766,"children":2767},{"style":116},[2768],{"type":70,"value":1716},{"type":64,"tag":97,"props":2770,"children":2771},{"style":110},[2772],{"type":70,"value":124},{"type":64,"tag":97,"props":2774,"children":2775},{"style":110},[2776],{"type":70,"value":261},{"type":64,"tag":97,"props":2778,"children":2779},{"class":99,"line":1069},[2780,2784,2788,2792,2796,2800,2804,2808,2812,2816,2820],{"type":64,"tag":97,"props":2781,"children":2782},{"style":311},[2783],{"type":70,"value":1777},{"type":64,"tag":97,"props":2785,"children":2786},{"style":110},[2787],{"type":70,"value":245},{"type":64,"tag":97,"props":2789,"children":2790},{"style":110},[2791],{"type":70,"value":113},{"type":64,"tag":97,"props":2793,"children":2794},{"style":110},[2795],{"type":70,"value":144},{"type":64,"tag":97,"props":2797,"children":2798},{"style":311},[2799],{"type":70,"value":1798},{"type":64,"tag":97,"props":2801,"children":2802},{"style":110},[2803],{"type":70,"value":370},{"type":64,"tag":97,"props":2805,"children":2806},{"style":110},[2807],{"type":70,"value":245},{"type":64,"tag":97,"props":2809,"children":2810},{"style":110},[2811],{"type":70,"value":144},{"type":64,"tag":97,"props":2813,"children":2814},{"style":147},[2815],{"type":70,"value":2644},{"type":64,"tag":97,"props":2817,"children":2818},{"style":110},[2819],{"type":70,"value":370},{"type":64,"tag":97,"props":2821,"children":2822},{"style":110},[2823],{"type":70,"value":941},{"type":64,"tag":97,"props":2825,"children":2826},{"class":99,"line":1121},[2827,2831],{"type":64,"tag":97,"props":2828,"children":2829},{"style":116},[2830],{"type":70,"value":1675},{"type":64,"tag":97,"props":2832,"children":2833},{"style":110},[2834],{"type":70,"value":388},{"type":64,"tag":97,"props":2836,"children":2837},{"class":99,"line":1133},[2838,2842],{"type":64,"tag":97,"props":2839,"children":2840},{"style":110},[2841],{"type":70,"value":581},{"type":64,"tag":97,"props":2843,"children":2844},{"style":116},[2845],{"type":70,"value":415},{"type":64,"tag":73,"props":2847,"children":2848},{},[2849,2854,2856,2862,2864,2870,2872,2878],{"type":64,"tag":1276,"props":2850,"children":2851},{},[2852],{"type":70,"value":2853},"Client-side pairing:",{"type":70,"value":2855}," SSE endpoints are consumed by ",{"type":64,"tag":93,"props":2857,"children":2859},{"className":2858},[],[2860],{"type":70,"value":2861},"fetchServerSentEvents()",{"type":70,"value":2863},".\nHTTP stream endpoints are consumed by ",{"type":64,"tag":93,"props":2865,"children":2867},{"className":2866},[],[2868],{"type":70,"value":2869},"fetchHttpStream()",{"type":70,"value":2871},". Both are connection\nadapters from ",{"type":64,"tag":93,"props":2873,"children":2875},{"className":2874},[],[2876],{"type":70,"value":2877},"@tanstack\u002Fai-react",{"type":70,"value":2879}," (or the framework-specific package).",{"type":64,"tag":1400,"props":2881,"children":2883},{"id":2882},"_3-ag-ui-event-types-reference",[2884],{"type":70,"value":2885},"3. AG-UI Event Types Reference",{"type":64,"tag":73,"props":2887,"children":2888},{},[2889,2891,2897,2899,2904,2905,2911,2913,2918,2920,2926],{"type":70,"value":2890},"All events extend ",{"type":64,"tag":93,"props":2892,"children":2894},{"className":2893},[],[2895],{"type":70,"value":2896},"BaseAGUIEvent",{"type":70,"value":2898}," which carries ",{"type":64,"tag":93,"props":2900,"children":2902},{"className":2901},[],[2903],{"type":70,"value":483},{"type":70,"value":1248},{"type":64,"tag":93,"props":2906,"children":2908},{"className":2907},[],[2909],{"type":70,"value":2910},"timestamp",{"type":70,"value":2912},", optional\n",{"type":64,"tag":93,"props":2914,"children":2916},{"className":2915},[],[2917],{"type":70,"value":1384},{"type":70,"value":2919},", and optional ",{"type":64,"tag":93,"props":2921,"children":2923},{"className":2922},[],[2924],{"type":70,"value":2925},"rawEvent",{"type":70,"value":303},{"type":64,"tag":1991,"props":2928,"children":2929},{},[2930,2946],{"type":64,"tag":1995,"props":2931,"children":2932},{},[2933],{"type":64,"tag":1999,"props":2934,"children":2935},{},[2936,2941],{"type":64,"tag":2003,"props":2937,"children":2938},{},[2939],{"type":70,"value":2940},"Event Type",{"type":64,"tag":2003,"props":2942,"children":2943},{},[2944],{"type":70,"value":2945},"Description",{"type":64,"tag":2014,"props":2947,"children":2948},{},[2949,2981,3012,3043,3066,3105,3134,3163,3194,3229,3253,3277,3301,3334,3401],{"type":64,"tag":1999,"props":2950,"children":2951},{},[2952,2961],{"type":64,"tag":2021,"props":2953,"children":2954},{},[2955],{"type":64,"tag":93,"props":2956,"children":2958},{"className":2957},[],[2959],{"type":70,"value":2960},"RUN_STARTED",{"type":64,"tag":2021,"props":2962,"children":2963},{},[2964,2966,2972,2974,2980],{"type":70,"value":2965},"First event in a stream. Carries ",{"type":64,"tag":93,"props":2967,"children":2969},{"className":2968},[],[2970],{"type":70,"value":2971},"runId",{"type":70,"value":2973}," and optional ",{"type":64,"tag":93,"props":2975,"children":2977},{"className":2976},[],[2978],{"type":70,"value":2979},"threadId",{"type":70,"value":303},{"type":64,"tag":1999,"props":2982,"children":2983},{},[2984,2993],{"type":64,"tag":2021,"props":2985,"children":2986},{},[2987],{"type":64,"tag":93,"props":2988,"children":2990},{"className":2989},[],[2991],{"type":70,"value":2992},"TEXT_MESSAGE_START",{"type":64,"tag":2021,"props":2994,"children":2995},{},[2996,2998,3004,3005,3011],{"type":70,"value":2997},"New text message begins. Carries ",{"type":64,"tag":93,"props":2999,"children":3001},{"className":3000},[],[3002],{"type":70,"value":3003},"messageId",{"type":70,"value":1341},{"type":64,"tag":93,"props":3006,"children":3008},{"className":3007},[],[3009],{"type":70,"value":3010},"role",{"type":70,"value":303},{"type":64,"tag":1999,"props":3013,"children":3014},{},[3015,3024],{"type":64,"tag":2021,"props":3016,"children":3017},{},[3018],{"type":64,"tag":93,"props":3019,"children":3021},{"className":3020},[],[3022],{"type":70,"value":3023},"TEXT_MESSAGE_CONTENT",{"type":64,"tag":2021,"props":3025,"children":3026},{},[3027,3029,3034,3035,3041],{"type":70,"value":3028},"Incremental text token. Carries ",{"type":64,"tag":93,"props":3030,"children":3032},{"className":3031},[],[3033],{"type":70,"value":3003},{"type":70,"value":1341},{"type":64,"tag":93,"props":3036,"children":3038},{"className":3037},[],[3039],{"type":70,"value":3040},"delta",{"type":70,"value":3042}," (the new text).",{"type":64,"tag":1999,"props":3044,"children":3045},{},[3046,3055],{"type":64,"tag":2021,"props":3047,"children":3048},{},[3049],{"type":64,"tag":93,"props":3050,"children":3052},{"className":3051},[],[3053],{"type":70,"value":3054},"TEXT_MESSAGE_END",{"type":64,"tag":2021,"props":3056,"children":3057},{},[3058,3060,3065],{"type":70,"value":3059},"Text message complete. Carries ",{"type":64,"tag":93,"props":3061,"children":3063},{"className":3062},[],[3064],{"type":70,"value":3003},{"type":70,"value":303},{"type":64,"tag":1999,"props":3067,"children":3068},{},[3069,3078],{"type":64,"tag":2021,"props":3070,"children":3071},{},[3072],{"type":64,"tag":93,"props":3073,"children":3075},{"className":3074},[],[3076],{"type":70,"value":3077},"TOOL_CALL_START",{"type":64,"tag":2021,"props":3079,"children":3080},{},[3081,3083,3089,3090,3096,3098,3104],{"type":70,"value":3082},"Tool invocation begins. Carries ",{"type":64,"tag":93,"props":3084,"children":3086},{"className":3085},[],[3087],{"type":70,"value":3088},"toolCallId",{"type":70,"value":1248},{"type":64,"tag":93,"props":3091,"children":3093},{"className":3092},[],[3094],{"type":70,"value":3095},"toolName",{"type":70,"value":3097},", and ",{"type":64,"tag":93,"props":3099,"children":3101},{"className":3100},[],[3102],{"type":70,"value":3103},"index",{"type":70,"value":303},{"type":64,"tag":1999,"props":3106,"children":3107},{},[3108,3117],{"type":64,"tag":2021,"props":3109,"children":3110},{},[3111],{"type":64,"tag":93,"props":3112,"children":3114},{"className":3113},[],[3115],{"type":70,"value":3116},"TOOL_CALL_ARGS",{"type":64,"tag":2021,"props":3118,"children":3119},{},[3120,3122,3127,3128,3133],{"type":70,"value":3121},"Incremental tool arguments JSON. Carries ",{"type":64,"tag":93,"props":3123,"children":3125},{"className":3124},[],[3126],{"type":70,"value":3088},{"type":70,"value":1341},{"type":64,"tag":93,"props":3129,"children":3131},{"className":3130},[],[3132],{"type":70,"value":3040},{"type":70,"value":303},{"type":64,"tag":1999,"props":3135,"children":3136},{},[3137,3146],{"type":64,"tag":2021,"props":3138,"children":3139},{},[3140],{"type":64,"tag":93,"props":3141,"children":3143},{"className":3142},[],[3144],{"type":70,"value":3145},"TOOL_CALL_END",{"type":64,"tag":2021,"props":3147,"children":3148},{},[3149,3151,3156,3157,3162],{"type":70,"value":3150},"Tool call arguments complete. Carries ",{"type":64,"tag":93,"props":3152,"children":3154},{"className":3153},[],[3155],{"type":70,"value":3088},{"type":70,"value":1341},{"type":64,"tag":93,"props":3158,"children":3160},{"className":3159},[],[3161],{"type":70,"value":3095},{"type":70,"value":303},{"type":64,"tag":1999,"props":3164,"children":3165},{},[3166,3175],{"type":64,"tag":2021,"props":3167,"children":3168},{},[3169],{"type":64,"tag":93,"props":3170,"children":3172},{"className":3171},[],[3173],{"type":70,"value":3174},"STEP_STARTED",{"type":64,"tag":2021,"props":3176,"children":3177},{},[3178,3180,3186,3187,3193],{"type":70,"value":3179},"Thinking\u002Freasoning step begins. Carries ",{"type":64,"tag":93,"props":3181,"children":3183},{"className":3182},[],[3184],{"type":70,"value":3185},"stepId",{"type":70,"value":2973},{"type":64,"tag":93,"props":3188,"children":3190},{"className":3189},[],[3191],{"type":70,"value":3192},"stepType",{"type":70,"value":303},{"type":64,"tag":1999,"props":3195,"children":3196},{},[3197,3206],{"type":64,"tag":2021,"props":3198,"children":3199},{},[3200],{"type":64,"tag":93,"props":3201,"children":3203},{"className":3202},[],[3204],{"type":70,"value":3205},"STEP_FINISHED",{"type":64,"tag":2021,"props":3207,"children":3208},{},[3209,3211,3216,3217,3222,3223,3228],{"type":70,"value":3210},"Thinking step complete. Carries ",{"type":64,"tag":93,"props":3212,"children":3214},{"className":3213},[],[3215],{"type":70,"value":3185},{"type":70,"value":1248},{"type":64,"tag":93,"props":3218,"children":3220},{"className":3219},[],[3221],{"type":70,"value":3040},{"type":70,"value":2919},{"type":64,"tag":93,"props":3224,"children":3226},{"className":3225},[],[3227],{"type":70,"value":1325},{"type":70,"value":303},{"type":64,"tag":1999,"props":3230,"children":3231},{},[3232,3241],{"type":64,"tag":2021,"props":3233,"children":3234},{},[3235],{"type":64,"tag":93,"props":3236,"children":3238},{"className":3237},[],[3239],{"type":70,"value":3240},"MESSAGES_SNAPSHOT",{"type":64,"tag":2021,"props":3242,"children":3243},{},[3244,3246,3252],{"type":70,"value":3245},"Full conversation transcript snapshot. Carries ",{"type":64,"tag":93,"props":3247,"children":3249},{"className":3248},[],[3250],{"type":70,"value":3251},"messages: Array\u003CUIMessage>",{"type":70,"value":303},{"type":64,"tag":1999,"props":3254,"children":3255},{},[3256,3265],{"type":64,"tag":2021,"props":3257,"children":3258},{},[3259],{"type":64,"tag":93,"props":3260,"children":3262},{"className":3261},[],[3263],{"type":70,"value":3264},"STATE_SNAPSHOT",{"type":64,"tag":2021,"props":3266,"children":3267},{},[3268,3270,3276],{"type":70,"value":3269},"Full application state snapshot. Carries ",{"type":64,"tag":93,"props":3271,"children":3273},{"className":3272},[],[3274],{"type":70,"value":3275},"state: Record\u003Cstring, unknown>",{"type":70,"value":303},{"type":64,"tag":1999,"props":3278,"children":3279},{},[3280,3289],{"type":64,"tag":2021,"props":3281,"children":3282},{},[3283],{"type":64,"tag":93,"props":3284,"children":3286},{"className":3285},[],[3287],{"type":70,"value":3288},"STATE_DELTA",{"type":64,"tag":2021,"props":3290,"children":3291},{},[3292,3294,3300],{"type":70,"value":3293},"Incremental state update. Carries ",{"type":64,"tag":93,"props":3295,"children":3297},{"className":3296},[],[3298],{"type":70,"value":3299},"delta: Record\u003Cstring, unknown>",{"type":70,"value":303},{"type":64,"tag":1999,"props":3302,"children":3303},{},[3304,3313],{"type":64,"tag":2021,"props":3305,"children":3306},{},[3307],{"type":64,"tag":93,"props":3308,"children":3310},{"className":3309},[],[3311],{"type":70,"value":3312},"CUSTOM",{"type":64,"tag":2021,"props":3314,"children":3315},{},[3316,3318,3324,3326,3332],{"type":70,"value":3317},"Extension point. Carries ",{"type":64,"tag":93,"props":3319,"children":3321},{"className":3320},[],[3322],{"type":70,"value":3323},"name",{"type":70,"value":3325}," (string) and optional ",{"type":64,"tag":93,"props":3327,"children":3329},{"className":3328},[],[3330],{"type":70,"value":3331},"value",{"type":70,"value":3333}," (unknown).",{"type":64,"tag":1999,"props":3335,"children":3336},{},[3337,3346],{"type":64,"tag":2021,"props":3338,"children":3339},{},[3340],{"type":64,"tag":93,"props":3341,"children":3343},{"className":3342},[],[3344],{"type":70,"value":3345},"RUN_FINISHED",{"type":64,"tag":2021,"props":3347,"children":3348},{},[3349,3351,3356,3357,3363,3364,3370,3372,3378,3379,3385,3386,3392,3393,3399],{"type":70,"value":3350},"Stream complete. Carries ",{"type":64,"tag":93,"props":3352,"children":3354},{"className":3353},[],[3355],{"type":70,"value":2971},{"type":70,"value":1341},{"type":64,"tag":93,"props":3358,"children":3360},{"className":3359},[],[3361],{"type":70,"value":3362},"finishReason",{"type":70,"value":814},{"type":64,"tag":93,"props":3365,"children":3367},{"className":3366},[],[3368],{"type":70,"value":3369},"'stop'",{"type":70,"value":3371}," \u002F ",{"type":64,"tag":93,"props":3373,"children":3375},{"className":3374},[],[3376],{"type":70,"value":3377},"'length'",{"type":70,"value":3371},{"type":64,"tag":93,"props":3380,"children":3382},{"className":3381},[],[3383],{"type":70,"value":3384},"'content_filter'",{"type":70,"value":3371},{"type":64,"tag":93,"props":3387,"children":3389},{"className":3388},[],[3390],{"type":70,"value":3391},"'tool_calls'",{"type":70,"value":3371},{"type":64,"tag":93,"props":3394,"children":3396},{"className":3395},[],[3397],{"type":70,"value":3398},"null",{"type":70,"value":3400},").",{"type":64,"tag":1999,"props":3402,"children":3403},{},[3404,3412],{"type":64,"tag":2021,"props":3405,"children":3406},{},[3407],{"type":64,"tag":93,"props":3408,"children":3410},{"className":3409},[],[3411],{"type":70,"value":2250},{"type":64,"tag":2021,"props":3413,"children":3414},{},[3415,3417,3422,3423,3429],{"type":70,"value":3416},"Error during stream. Carries optional ",{"type":64,"tag":93,"props":3418,"children":3420},{"className":3419},[],[3421],{"type":70,"value":2971},{"type":70,"value":1341},{"type":64,"tag":93,"props":3424,"children":3426},{"className":3425},[],[3427],{"type":70,"value":3428},"error: { message, code? }",{"type":70,"value":303},{"type":64,"tag":73,"props":3431,"children":3432},{},[3433],{"type":64,"tag":1276,"props":3434,"children":3435},{},[3436],{"type":70,"value":3437},"Typical event sequence for a text-only response:",{"type":64,"tag":86,"props":3439,"children":3443},{"className":3440,"code":3442,"language":70},[3441],"language-text","RUN_STARTED -> TEXT_MESSAGE_START -> TEXT_MESSAGE_CONTENT (repeated) -> TEXT_MESSAGE_END -> RUN_FINISHED\n",[3444],{"type":64,"tag":93,"props":3445,"children":3446},{"__ignoreMap":90},[3447],{"type":70,"value":3442},{"type":64,"tag":73,"props":3449,"children":3450},{},[3451],{"type":64,"tag":1276,"props":3452,"children":3453},{},[3454],{"type":70,"value":3455},"Typical event sequence with tool calls:",{"type":64,"tag":86,"props":3457,"children":3460},{"className":3458,"code":3459,"language":70},[3441],"RUN_STARTED -> TEXT_MESSAGE_START -> TEXT_MESSAGE_CONTENT* -> TEXT_MESSAGE_END\n            -> TOOL_CALL_START -> TOOL_CALL_ARGS* -> TOOL_CALL_END\n            -> RUN_FINISHED (finishReason: 'tool_calls')\n",[3461],{"type":64,"tag":93,"props":3462,"children":3463},{"__ignoreMap":90},[3464],{"type":70,"value":3459},{"type":64,"tag":73,"props":3466,"children":3467},{},[3468,3473,3475,3480,3482,3488,3490,3496,3497,3503],{"type":64,"tag":1276,"props":3469,"children":3470},{},[3471],{"type":70,"value":3472},"Type aliases:",{"type":70,"value":3474}," ",{"type":64,"tag":93,"props":3476,"children":3478},{"className":3477},[],[3479],{"type":70,"value":475},{"type":70,"value":3481}," is an alias for ",{"type":64,"tag":93,"props":3483,"children":3485},{"className":3484},[],[3486],{"type":70,"value":3487},"AGUIEvent",{"type":70,"value":3489}," (the discriminated\nunion of all event interfaces). ",{"type":64,"tag":93,"props":3491,"children":3493},{"className":3492},[],[3494],{"type":70,"value":3495},"StreamChunkType",{"type":70,"value":3481},{"type":64,"tag":93,"props":3498,"children":3500},{"className":3499},[],[3501],{"type":70,"value":3502},"AGUIEventType",{"type":70,"value":3504},"\n(the string union of all event type literals).",{"type":64,"tag":1400,"props":3506,"children":3508},{"id":3507},"_4-typed-custom-events-chatstream-and-knowncustomevent",[3509,3511,3517,3518],{"type":70,"value":3510},"4. Typed CUSTOM Events — ",{"type":64,"tag":93,"props":3512,"children":3514},{"className":3513},[],[3515],{"type":70,"value":3516},"ChatStream",{"type":70,"value":1341},{"type":64,"tag":93,"props":3519,"children":3521},{"className":3520},[],[3522],{"type":70,"value":3523},"KnownCustomEvent",{"type":64,"tag":73,"props":3525,"children":3526},{},[3527,3529,3534,3536,3541,3543,3549,3551,3556,3558,3564,3566,3571,3573,3578,3580,3586,3587,3592,3594,3599,3601,3607,3608,3613,3615,3621,3623,3628,3630,3635,3637,3642,3644,3649,3651,3656,3658,3664],{"type":70,"value":3528},"The ",{"type":64,"tag":93,"props":3530,"children":3532},{"className":3531},[],[3533],{"type":70,"value":3312},{"type":70,"value":3535}," row above describes the raw ",{"type":64,"tag":93,"props":3537,"children":3539},{"className":3538},[],[3540],{"type":70,"value":475},{"type":70,"value":3542}," union, where the single\ngeneric ",{"type":64,"tag":93,"props":3544,"children":3546},{"className":3545},[],[3547],{"type":70,"value":3548},"CustomEvent",{"type":70,"value":3550}," member types ",{"type":64,"tag":93,"props":3552,"children":3554},{"className":3553},[],[3555],{"type":70,"value":3331},{"type":70,"value":3557}," as ",{"type":64,"tag":93,"props":3559,"children":3561},{"className":3560},[],[3562],{"type":70,"value":3563},"any",{"type":70,"value":3565}," -- once merged into a\nunion, that ",{"type":64,"tag":93,"props":3567,"children":3569},{"className":3568},[],[3570],{"type":70,"value":3563},{"type":70,"value":3572}," poisons every other member too, so narrowing on ",{"type":64,"tag":93,"props":3574,"children":3576},{"className":3575},[],[3577],{"type":70,"value":3323},{"type":70,"value":3579},"\nstill leaves ",{"type":64,"tag":93,"props":3581,"children":3583},{"className":3582},[],[3584],{"type":70,"value":3585},"value: any",{"type":70,"value":1197},{"type":64,"tag":93,"props":3588,"children":3590},{"className":3589},[],[3591],{"type":70,"value":459},{"type":70,"value":3593}," doesn't return raw ",{"type":64,"tag":93,"props":3595,"children":3597},{"className":3596},[],[3598],{"type":70,"value":475},{"type":70,"value":3600},"; by\ndefault (no ",{"type":64,"tag":93,"props":3602,"children":3604},{"className":3603},[],[3605],{"type":70,"value":3606},"outputSchema",{"type":70,"value":1248},{"type":64,"tag":93,"props":3609,"children":3611},{"className":3610},[],[3612],{"type":70,"value":437},{"type":70,"value":3614}," not explicitly ",{"type":64,"tag":93,"props":3616,"children":3618},{"className":3617},[],[3619],{"type":70,"value":3620},"false",{"type":70,"value":3622},") it returns\n",{"type":64,"tag":93,"props":3624,"children":3626},{"className":3625},[],[3627],{"type":70,"value":3516},{"type":70,"value":3629},", which swaps that generic member for ",{"type":64,"tag":93,"props":3631,"children":3633},{"className":3632},[],[3634],{"type":70,"value":3523},{"type":70,"value":3636}," -- a\ndiscriminated union of every ",{"type":64,"tag":93,"props":3638,"children":3640},{"className":3639},[],[3641],{"type":70,"value":3312},{"type":70,"value":3643}," event TanStack AI itself emits, each\nwith a literal ",{"type":64,"tag":93,"props":3645,"children":3647},{"className":3646},[],[3648],{"type":70,"value":3323},{"type":70,"value":3650}," and a concrete ",{"type":64,"tag":93,"props":3652,"children":3654},{"className":3653},[],[3655],{"type":70,"value":3331},{"type":70,"value":3657},". Narrow with a plain ",{"type":64,"tag":93,"props":3659,"children":3661},{"className":3660},[],[3662],{"type":70,"value":3663},"if",{"type":70,"value":3665}," --\nno helper, no cast:",{"type":64,"tag":86,"props":3667,"children":3669},{"className":88,"code":3668,"language":42,"meta":90,"style":90},"import { chat } from '@tanstack\u002Fai'\nimport { openaiText } from '@tanstack\u002Fai-openai'\n\nconst stream = chat({\n  adapter: openaiText('gpt-5.2'),\n  messages,\n})\n\nfor await (const chunk of stream) {\n  if (chunk.type === 'CUSTOM' && chunk.name === 'sandbox.file.diff') {\n    console.log(chunk.value.path, chunk.value.diff) \u002F\u002F typed, no helper, no cast\n  } else if (\n    chunk.type === 'CUSTOM' &&\n    chunk.name === 'structured-output.complete'\n  ) {\n    console.log(chunk.value.object) \u002F\u002F typed, no helper, no cast\n  }\n}\n",[3670],{"type":64,"tag":93,"props":3671,"children":3672},{"__ignoreMap":90},[3673,3708,3743,3750,3777,3816,3827,3838,3845,3884,3969,4045,4067,4104,4136,4148,4196,4203],{"type":64,"tag":97,"props":3674,"children":3675},{"class":99,"line":100},[3676,3680,3684,3688,3692,3696,3700,3704],{"type":64,"tag":97,"props":3677,"children":3678},{"style":104},[3679],{"type":70,"value":107},{"type":64,"tag":97,"props":3681,"children":3682},{"style":110},[3683],{"type":70,"value":113},{"type":64,"tag":97,"props":3685,"children":3686},{"style":116},[3687],{"type":70,"value":119},{"type":64,"tag":97,"props":3689,"children":3690},{"style":110},[3691],{"type":70,"value":134},{"type":64,"tag":97,"props":3693,"children":3694},{"style":104},[3695],{"type":70,"value":139},{"type":64,"tag":97,"props":3697,"children":3698},{"style":110},[3699],{"type":70,"value":144},{"type":64,"tag":97,"props":3701,"children":3702},{"style":147},[3703],{"type":70,"value":150},{"type":64,"tag":97,"props":3705,"children":3706},{"style":110},[3707],{"type":70,"value":155},{"type":64,"tag":97,"props":3709,"children":3710},{"class":99,"line":158},[3711,3715,3719,3723,3727,3731,3735,3739],{"type":64,"tag":97,"props":3712,"children":3713},{"style":104},[3714],{"type":70,"value":107},{"type":64,"tag":97,"props":3716,"children":3717},{"style":110},[3718],{"type":70,"value":113},{"type":64,"tag":97,"props":3720,"children":3721},{"style":116},[3722],{"type":70,"value":172},{"type":64,"tag":97,"props":3724,"children":3725},{"style":110},[3726],{"type":70,"value":134},{"type":64,"tag":97,"props":3728,"children":3729},{"style":104},[3730],{"type":70,"value":139},{"type":64,"tag":97,"props":3732,"children":3733},{"style":110},[3734],{"type":70,"value":144},{"type":64,"tag":97,"props":3736,"children":3737},{"style":147},[3738],{"type":70,"value":189},{"type":64,"tag":97,"props":3740,"children":3741},{"style":110},[3742],{"type":70,"value":155},{"type":64,"tag":97,"props":3744,"children":3745},{"class":99,"line":196},[3746],{"type":64,"tag":97,"props":3747,"children":3748},{"emptyLinePlaceholder":200},[3749],{"type":70,"value":203},{"type":64,"tag":97,"props":3751,"children":3752},{"class":99,"line":206},[3753,3757,3761,3765,3769,3773],{"type":64,"tag":97,"props":3754,"children":3755},{"style":215},[3756],{"type":70,"value":1564},{"type":64,"tag":97,"props":3758,"children":3759},{"style":116},[3760],{"type":70,"value":1599},{"type":64,"tag":97,"props":3762,"children":3763},{"style":110},[3764],{"type":70,"value":1574},{"type":64,"tag":97,"props":3766,"children":3767},{"style":226},[3768],{"type":70,"value":119},{"type":64,"tag":97,"props":3770,"children":3771},{"style":116},[3772],{"type":70,"value":234},{"type":64,"tag":97,"props":3774,"children":3775},{"style":110},[3776],{"type":70,"value":344},{"type":64,"tag":97,"props":3778,"children":3779},{"class":99,"line":264},[3780,3784,3788,3792,3796,3800,3804,3808,3812],{"type":64,"tag":97,"props":3781,"children":3782},{"style":311},[3783],{"type":70,"value":1623},{"type":64,"tag":97,"props":3785,"children":3786},{"style":110},[3787],{"type":70,"value":245},{"type":64,"tag":97,"props":3789,"children":3790},{"style":226},[3791],{"type":70,"value":172},{"type":64,"tag":97,"props":3793,"children":3794},{"style":116},[3795],{"type":70,"value":234},{"type":64,"tag":97,"props":3797,"children":3798},{"style":110},[3799],{"type":70,"value":370},{"type":64,"tag":97,"props":3801,"children":3802},{"style":147},[3803],{"type":70,"value":375},{"type":64,"tag":97,"props":3805,"children":3806},{"style":110},[3807],{"type":70,"value":370},{"type":64,"tag":97,"props":3809,"children":3810},{"style":116},[3811],{"type":70,"value":256},{"type":64,"tag":97,"props":3813,"children":3814},{"style":110},[3815],{"type":70,"value":388},{"type":64,"tag":97,"props":3817,"children":3818},{"class":99,"line":317},[3819,3823],{"type":64,"tag":97,"props":3820,"children":3821},{"style":116},[3822],{"type":70,"value":1663},{"type":64,"tag":97,"props":3824,"children":3825},{"style":110},[3826],{"type":70,"value":388},{"type":64,"tag":97,"props":3828,"children":3829},{"class":99,"line":347},[3830,3834],{"type":64,"tag":97,"props":3831,"children":3832},{"style":110},[3833],{"type":70,"value":581},{"type":64,"tag":97,"props":3835,"children":3836},{"style":116},[3837],{"type":70,"value":415},{"type":64,"tag":97,"props":3839,"children":3840},{"class":99,"line":391},[3841],{"type":64,"tag":97,"props":3842,"children":3843},{"emptyLinePlaceholder":200},[3844],{"type":70,"value":203},{"type":64,"tag":97,"props":3846,"children":3847},{"class":99,"line":404},[3848,3853,3857,3861,3865,3870,3875,3880],{"type":64,"tag":97,"props":3849,"children":3850},{"style":104},[3851],{"type":70,"value":3852},"for",{"type":64,"tag":97,"props":3854,"children":3855},{"style":104},[3856],{"type":70,"value":293},{"type":64,"tag":97,"props":3858,"children":3859},{"style":116},[3860],{"type":70,"value":814},{"type":64,"tag":97,"props":3862,"children":3863},{"style":215},[3864],{"type":70,"value":1564},{"type":64,"tag":97,"props":3866,"children":3867},{"style":116},[3868],{"type":70,"value":3869}," chunk ",{"type":64,"tag":97,"props":3871,"children":3872},{"style":110},[3873],{"type":70,"value":3874},"of",{"type":64,"tag":97,"props":3876,"children":3877},{"style":116},[3878],{"type":70,"value":3879}," stream) ",{"type":64,"tag":97,"props":3881,"children":3882},{"style":110},[3883],{"type":70,"value":344},{"type":64,"tag":97,"props":3885,"children":3886},{"class":99,"line":418},[3887,3892,3896,3901,3905,3909,3914,3918,3922,3926,3931,3936,3940,3944,3948,3952,3957,3961,3965],{"type":64,"tag":97,"props":3888,"children":3889},{"style":104},[3890],{"type":70,"value":3891},"  if",{"type":64,"tag":97,"props":3893,"children":3894},{"style":311},[3895],{"type":70,"value":814},{"type":64,"tag":97,"props":3897,"children":3898},{"style":116},[3899],{"type":70,"value":3900},"chunk",{"type":64,"tag":97,"props":3902,"children":3903},{"style":110},[3904],{"type":70,"value":303},{"type":64,"tag":97,"props":3906,"children":3907},{"style":116},[3908],{"type":70,"value":483},{"type":64,"tag":97,"props":3910,"children":3911},{"style":110},[3912],{"type":70,"value":3913}," ===",{"type":64,"tag":97,"props":3915,"children":3916},{"style":110},[3917],{"type":70,"value":144},{"type":64,"tag":97,"props":3919,"children":3920},{"style":147},[3921],{"type":70,"value":3312},{"type":64,"tag":97,"props":3923,"children":3924},{"style":110},[3925],{"type":70,"value":370},{"type":64,"tag":97,"props":3927,"children":3928},{"style":110},[3929],{"type":70,"value":3930}," &&",{"type":64,"tag":97,"props":3932,"children":3933},{"style":116},[3934],{"type":70,"value":3935}," chunk",{"type":64,"tag":97,"props":3937,"children":3938},{"style":110},[3939],{"type":70,"value":303},{"type":64,"tag":97,"props":3941,"children":3942},{"style":116},[3943],{"type":70,"value":3323},{"type":64,"tag":97,"props":3945,"children":3946},{"style":110},[3947],{"type":70,"value":3913},{"type":64,"tag":97,"props":3949,"children":3950},{"style":110},[3951],{"type":70,"value":144},{"type":64,"tag":97,"props":3953,"children":3954},{"style":147},[3955],{"type":70,"value":3956},"sandbox.file.diff",{"type":64,"tag":97,"props":3958,"children":3959},{"style":110},[3960],{"type":70,"value":370},{"type":64,"tag":97,"props":3962,"children":3963},{"style":311},[3964],{"type":70,"value":824},{"type":64,"tag":97,"props":3966,"children":3967},{"style":110},[3968],{"type":70,"value":344},{"type":64,"tag":97,"props":3970,"children":3971},{"class":99,"line":444},[3972,3977,3981,3986,3990,3994,3998,4002,4006,4011,4015,4019,4023,4027,4031,4036,4040],{"type":64,"tag":97,"props":3973,"children":3974},{"style":116},[3975],{"type":70,"value":3976},"    console",{"type":64,"tag":97,"props":3978,"children":3979},{"style":110},[3980],{"type":70,"value":303},{"type":64,"tag":97,"props":3982,"children":3983},{"style":226},[3984],{"type":70,"value":3985},"log",{"type":64,"tag":97,"props":3987,"children":3988},{"style":311},[3989],{"type":70,"value":234},{"type":64,"tag":97,"props":3991,"children":3992},{"style":116},[3993],{"type":70,"value":3900},{"type":64,"tag":97,"props":3995,"children":3996},{"style":110},[3997],{"type":70,"value":303},{"type":64,"tag":97,"props":3999,"children":4000},{"style":116},[4001],{"type":70,"value":3331},{"type":64,"tag":97,"props":4003,"children":4004},{"style":110},[4005],{"type":70,"value":303},{"type":64,"tag":97,"props":4007,"children":4008},{"style":116},[4009],{"type":70,"value":4010},"path",{"type":64,"tag":97,"props":4012,"children":4013},{"style":110},[4014],{"type":70,"value":124},{"type":64,"tag":97,"props":4016,"children":4017},{"style":116},[4018],{"type":70,"value":3935},{"type":64,"tag":97,"props":4020,"children":4021},{"style":110},[4022],{"type":70,"value":303},{"type":64,"tag":97,"props":4024,"children":4025},{"style":116},[4026],{"type":70,"value":3331},{"type":64,"tag":97,"props":4028,"children":4029},{"style":110},[4030],{"type":70,"value":303},{"type":64,"tag":97,"props":4032,"children":4033},{"style":116},[4034],{"type":70,"value":4035},"diff",{"type":64,"tag":97,"props":4037,"children":4038},{"style":311},[4039],{"type":70,"value":824},{"type":64,"tag":97,"props":4041,"children":4042},{"style":1553},[4043],{"type":70,"value":4044},"\u002F\u002F typed, no helper, no cast\n",{"type":64,"tag":97,"props":4046,"children":4047},{"class":99,"line":737},[4048,4052,4057,4062],{"type":64,"tag":97,"props":4049,"children":4050},{"style":110},[4051],{"type":70,"value":410},{"type":64,"tag":97,"props":4053,"children":4054},{"style":104},[4055],{"type":70,"value":4056}," else",{"type":64,"tag":97,"props":4058,"children":4059},{"style":104},[4060],{"type":70,"value":4061}," if",{"type":64,"tag":97,"props":4063,"children":4064},{"style":311},[4065],{"type":70,"value":4066}," (\n",{"type":64,"tag":97,"props":4068,"children":4069},{"class":99,"line":750},[4070,4075,4079,4083,4087,4091,4095,4099],{"type":64,"tag":97,"props":4071,"children":4072},{"style":116},[4073],{"type":70,"value":4074},"    chunk",{"type":64,"tag":97,"props":4076,"children":4077},{"style":110},[4078],{"type":70,"value":303},{"type":64,"tag":97,"props":4080,"children":4081},{"style":116},[4082],{"type":70,"value":483},{"type":64,"tag":97,"props":4084,"children":4085},{"style":110},[4086],{"type":70,"value":3913},{"type":64,"tag":97,"props":4088,"children":4089},{"style":110},[4090],{"type":70,"value":144},{"type":64,"tag":97,"props":4092,"children":4093},{"style":147},[4094],{"type":70,"value":3312},{"type":64,"tag":97,"props":4096,"children":4097},{"style":110},[4098],{"type":70,"value":370},{"type":64,"tag":97,"props":4100,"children":4101},{"style":110},[4102],{"type":70,"value":4103}," &&\n",{"type":64,"tag":97,"props":4105,"children":4106},{"class":99,"line":799},[4107,4111,4115,4119,4123,4127,4132],{"type":64,"tag":97,"props":4108,"children":4109},{"style":116},[4110],{"type":70,"value":4074},{"type":64,"tag":97,"props":4112,"children":4113},{"style":110},[4114],{"type":70,"value":303},{"type":64,"tag":97,"props":4116,"children":4117},{"style":116},[4118],{"type":70,"value":3323},{"type":64,"tag":97,"props":4120,"children":4121},{"style":110},[4122],{"type":70,"value":3913},{"type":64,"tag":97,"props":4124,"children":4125},{"style":110},[4126],{"type":70,"value":144},{"type":64,"tag":97,"props":4128,"children":4129},{"style":147},[4130],{"type":70,"value":4131},"structured-output.complete",{"type":64,"tag":97,"props":4133,"children":4134},{"style":110},[4135],{"type":70,"value":155},{"type":64,"tag":97,"props":4137,"children":4138},{"class":99,"line":831},[4139,4144],{"type":64,"tag":97,"props":4140,"children":4141},{"style":311},[4142],{"type":70,"value":4143},"  ) ",{"type":64,"tag":97,"props":4145,"children":4146},{"style":110},[4147],{"type":70,"value":344},{"type":64,"tag":97,"props":4149,"children":4150},{"class":99,"line":855},[4151,4155,4159,4163,4167,4171,4175,4179,4183,4188,4192],{"type":64,"tag":97,"props":4152,"children":4153},{"style":116},[4154],{"type":70,"value":3976},{"type":64,"tag":97,"props":4156,"children":4157},{"style":110},[4158],{"type":70,"value":303},{"type":64,"tag":97,"props":4160,"children":4161},{"style":226},[4162],{"type":70,"value":3985},{"type":64,"tag":97,"props":4164,"children":4165},{"style":311},[4166],{"type":70,"value":234},{"type":64,"tag":97,"props":4168,"children":4169},{"style":116},[4170],{"type":70,"value":3900},{"type":64,"tag":97,"props":4172,"children":4173},{"style":110},[4174],{"type":70,"value":303},{"type":64,"tag":97,"props":4176,"children":4177},{"style":116},[4178],{"type":70,"value":3331},{"type":64,"tag":97,"props":4180,"children":4181},{"style":110},[4182],{"type":70,"value":303},{"type":64,"tag":97,"props":4184,"children":4185},{"style":116},[4186],{"type":70,"value":4187},"object",{"type":64,"tag":97,"props":4189,"children":4190},{"style":311},[4191],{"type":70,"value":824},{"type":64,"tag":97,"props":4193,"children":4194},{"style":1553},[4195],{"type":70,"value":4044},{"type":64,"tag":97,"props":4197,"children":4198},{"class":99,"line":915},[4199],{"type":64,"tag":97,"props":4200,"children":4201},{"style":110},[4202],{"type":70,"value":959},{"type":64,"tag":97,"props":4204,"children":4205},{"class":99,"line":944},[4206],{"type":64,"tag":97,"props":4207,"children":4208},{"style":110},[4209],{"type":70,"value":450},{"type":64,"tag":73,"props":4211,"children":4212},{},[4213,4226,4232,4234,4240,4242,4248,4250,4256,4258,4264,4266,4272,4274,4279,4281,4286,4288,4294,4296,4302,4304,4309],{"type":64,"tag":1276,"props":4214,"children":4215},{},[4216,4218,4224],{"type":70,"value":4217},"Caveat -- ",{"type":64,"tag":93,"props":4219,"children":4221},{"className":4220},[],[4222],{"type":70,"value":4223},".endsWith()",{"type":70,"value":4225}," (or any non-literal check) does not narrow.",{"type":64,"tag":93,"props":4227,"children":4229},{"className":4228},[],[4230],{"type":70,"value":4231},"SessionIdEvent['name']",{"type":70,"value":4233}," is the template-literal type\n",{"type":64,"tag":93,"props":4235,"children":4237},{"className":4236},[],[4238],{"type":70,"value":4239},"`${string}.session-id`",{"type":70,"value":4241},". TypeScript's control-flow narrowing only\nunderstands exact comparisons (",{"type":64,"tag":93,"props":4243,"children":4245},{"className":4244},[],[4246],{"type":70,"value":4247},"===",{"type":70,"value":4249},") and ",{"type":64,"tag":93,"props":4251,"children":4253},{"className":4252},[],[4254],{"type":70,"value":4255},"in",{"type":70,"value":4257},"\u002Ftype-predicate checks against\na discriminant -- a runtime ",{"type":64,"tag":93,"props":4259,"children":4261},{"className":4260},[],[4262],{"type":70,"value":4263},"chunk.name.endsWith('.session-id')",{"type":70,"value":4265}," check\ndoesn't inform the type system, so ",{"type":64,"tag":93,"props":4267,"children":4269},{"className":4268},[],[4270],{"type":70,"value":4271},"chunk.value",{"type":70,"value":4273}," stays the union of every\n",{"type":64,"tag":93,"props":4275,"children":4277},{"className":4276},[],[4278],{"type":70,"value":3523},{"type":70,"value":4280},"'s ",{"type":64,"tag":93,"props":4282,"children":4284},{"className":4283},[],[4285],{"type":70,"value":3331},{"type":70,"value":4287},", not ",{"type":64,"tag":93,"props":4289,"children":4291},{"className":4290},[],[4292],{"type":70,"value":4293},"{ sessionId: string }",{"type":70,"value":4295},". Compare against\nthe exact literal you expect, or write a user-defined type predicate\n(",{"type":64,"tag":93,"props":4297,"children":4299},{"className":4298},[],[4300],{"type":70,"value":4301},"(c): c is SessionIdEvent => c.name.endsWith('.session-id')",{"type":70,"value":4303},") and call that\nin the ",{"type":64,"tag":93,"props":4305,"children":4307},{"className":4306},[],[4308],{"type":70,"value":3663},{"type":70,"value":4310}," instead.",{"type":64,"tag":73,"props":4312,"children":4313},{},[4314,4333,4335,4341,4343,4348,4350,4356,4358,4363,4365,4370,4372,4377,4379,4384,4386,4391,4393,4398,4400,4405,4406,4411],{"type":64,"tag":1276,"props":4315,"children":4316},{},[4317,4319,4325,4327,4332],{"type":70,"value":4318},"User-emitted ",{"type":64,"tag":93,"props":4320,"children":4322},{"className":4321},[],[4323],{"type":70,"value":4324},"emitCustomEvent",{"type":70,"value":4326}," names are typed out of ",{"type":64,"tag":93,"props":4328,"children":4330},{"className":4329},[],[4331],{"type":70,"value":3516},{"type":70,"value":303},{"type":70,"value":4334}," Tools\nthat call ",{"type":64,"tag":93,"props":4336,"children":4338},{"className":4337},[],[4339],{"type":70,"value":4340},"context.emitCustomEvent('my-app:progress', ...)",{"type":70,"value":4342}," still stream a\n",{"type":64,"tag":93,"props":4344,"children":4346},{"className":4345},[],[4347],{"type":70,"value":3312},{"type":70,"value":4349}," chunk at runtime, but ",{"type":64,"tag":93,"props":4351,"children":4353},{"className":4352},[],[4354],{"type":70,"value":4355},"'my-app:progress'",{"type":70,"value":4357}," isn't one of\n",{"type":64,"tag":93,"props":4359,"children":4361},{"className":4360},[],[4362],{"type":70,"value":3523},{"type":70,"value":4364},"'s literal names, so it's intentionally absent from\n",{"type":64,"tag":93,"props":4366,"children":4368},{"className":4367},[],[4369],{"type":70,"value":3516},{"type":70,"value":4371},"'s type -- including a generic fallback member would reintroduce\nthe ",{"type":64,"tag":93,"props":4373,"children":4375},{"className":4374},[],[4376],{"type":70,"value":3585},{"type":70,"value":4378}," poison for every other event on the stream. To read your own\nevent with a type, annotate the stream as the wider ",{"type":64,"tag":93,"props":4380,"children":4382},{"className":4381},[],[4383],{"type":70,"value":475},{"type":70,"value":4385}," instead of\n",{"type":64,"tag":93,"props":4387,"children":4389},{"className":4388},[],[4390],{"type":70,"value":3516},{"type":70,"value":4392}," for that branch; its generic ",{"type":64,"tag":93,"props":4394,"children":4396},{"className":4395},[],[4397],{"type":70,"value":3312},{"type":70,"value":4399}," member already types\n",{"type":64,"tag":93,"props":4401,"children":4403},{"className":4402},[],[4404],{"type":70,"value":3331},{"type":70,"value":3557},{"type":64,"tag":93,"props":4407,"children":4409},{"className":4408},[],[4410],{"type":70,"value":3563},{"type":70,"value":4412},", so no cast is needed there either.",{"type":64,"tag":73,"props":4414,"children":4415},{},[4416],{"type":70,"value":4417},"Source: docs\u002Fprotocol\u002Fcustom-events.md",{"type":64,"tag":79,"props":4419,"children":4421},{"id":4420},"common-mistakes",[4422],{"type":70,"value":4423},"Common Mistakes",{"type":64,"tag":1400,"props":4425,"children":4427},{"id":4426},"medium-proxy-buffering-breaks-sse-streaming",[4428],{"type":70,"value":4429},"MEDIUM: Proxy buffering breaks SSE streaming",{"type":64,"tag":73,"props":4431,"children":4432},{},[4433],{"type":70,"value":4434},"Reverse proxies (nginx, Cloudflare, AWS ALB) buffer SSE responses by default,\ncausing events to arrive in batches instead of streaming token-by-token.",{"type":64,"tag":73,"props":4436,"children":4437},{},[4438],{"type":70,"value":4439},"Fix: Set proxy-bypass headers on the response.",{"type":64,"tag":86,"props":4441,"children":4443},{"className":88,"code":4442,"language":42,"meta":90,"style":90},"toServerSentEventsResponse(stream, {\n  headers: {\n    'X-Accel-Buffering': 'no', \u002F\u002F nginx\n    'X-Content-Type-Options': 'nosniff', \u002F\u002F Some CDNs\n  },\n  abortController,\n})\n",[4444],{"type":64,"tag":93,"props":4445,"children":4446},{"__ignoreMap":90},[4447,4466,4481,4521,4563,4570,4581],{"type":64,"tag":97,"props":4448,"children":4449},{"class":99,"line":100},[4450,4454,4458,4462],{"type":64,"tag":97,"props":4451,"children":4452},{"style":226},[4453],{"type":70,"value":2095},{"type":64,"tag":97,"props":4455,"children":4456},{"style":116},[4457],{"type":70,"value":1716},{"type":64,"tag":97,"props":4459,"children":4460},{"style":110},[4461],{"type":70,"value":124},{"type":64,"tag":97,"props":4463,"children":4464},{"style":110},[4465],{"type":70,"value":261},{"type":64,"tag":97,"props":4467,"children":4468},{"class":99,"line":158},[4469,4473,4477],{"type":64,"tag":97,"props":4470,"children":4471},{"style":311},[4472],{"type":70,"value":1777},{"type":64,"tag":97,"props":4474,"children":4475},{"style":110},[4476],{"type":70,"value":245},{"type":64,"tag":97,"props":4478,"children":4479},{"style":110},[4480],{"type":70,"value":261},{"type":64,"tag":97,"props":4482,"children":4483},{"class":99,"line":196},[4484,4488,4492,4496,4500,4504,4508,4512,4516],{"type":64,"tag":97,"props":4485,"children":4486},{"style":110},[4487],{"type":70,"value":1793},{"type":64,"tag":97,"props":4489,"children":4490},{"style":311},[4491],{"type":70,"value":2134},{"type":64,"tag":97,"props":4493,"children":4494},{"style":110},[4495],{"type":70,"value":370},{"type":64,"tag":97,"props":4497,"children":4498},{"style":110},[4499],{"type":70,"value":245},{"type":64,"tag":97,"props":4501,"children":4502},{"style":110},[4503],{"type":70,"value":144},{"type":64,"tag":97,"props":4505,"children":4506},{"style":147},[4507],{"type":70,"value":2151},{"type":64,"tag":97,"props":4509,"children":4510},{"style":110},[4511],{"type":70,"value":370},{"type":64,"tag":97,"props":4513,"children":4514},{"style":110},[4515],{"type":70,"value":124},{"type":64,"tag":97,"props":4517,"children":4518},{"style":1553},[4519],{"type":70,"value":4520}," \u002F\u002F nginx\n",{"type":64,"tag":97,"props":4522,"children":4523},{"class":99,"line":206},[4524,4528,4533,4537,4541,4545,4550,4554,4558],{"type":64,"tag":97,"props":4525,"children":4526},{"style":110},[4527],{"type":70,"value":1793},{"type":64,"tag":97,"props":4529,"children":4530},{"style":311},[4531],{"type":70,"value":4532},"X-Content-Type-Options",{"type":64,"tag":97,"props":4534,"children":4535},{"style":110},[4536],{"type":70,"value":370},{"type":64,"tag":97,"props":4538,"children":4539},{"style":110},[4540],{"type":70,"value":245},{"type":64,"tag":97,"props":4542,"children":4543},{"style":110},[4544],{"type":70,"value":144},{"type":64,"tag":97,"props":4546,"children":4547},{"style":147},[4548],{"type":70,"value":4549},"nosniff",{"type":64,"tag":97,"props":4551,"children":4552},{"style":110},[4553],{"type":70,"value":370},{"type":64,"tag":97,"props":4555,"children":4556},{"style":110},[4557],{"type":70,"value":124},{"type":64,"tag":97,"props":4559,"children":4560},{"style":1553},[4561],{"type":70,"value":4562}," \u002F\u002F Some CDNs\n",{"type":64,"tag":97,"props":4564,"children":4565},{"class":99,"line":264},[4566],{"type":64,"tag":97,"props":4567,"children":4568},{"style":110},[4569],{"type":70,"value":1897},{"type":64,"tag":97,"props":4571,"children":4572},{"class":99,"line":317},[4573,4577],{"type":64,"tag":97,"props":4574,"children":4575},{"style":116},[4576],{"type":70,"value":1675},{"type":64,"tag":97,"props":4578,"children":4579},{"style":110},[4580],{"type":70,"value":388},{"type":64,"tag":97,"props":4582,"children":4583},{"class":99,"line":347},[4584,4588],{"type":64,"tag":97,"props":4585,"children":4586},{"style":110},[4587],{"type":70,"value":581},{"type":64,"tag":97,"props":4589,"children":4590},{"style":116},[4591],{"type":70,"value":415},{"type":64,"tag":73,"props":4593,"children":4594},{},[4595],{"type":70,"value":4596},"For Cloudflare Workers, SSE streams automatically. For Cloudflare proxied\norigins, ensure \"Response Buffering\" is disabled in the dashboard.",{"type":64,"tag":73,"props":4598,"children":4599},{},[4600],{"type":70,"value":4601},"Source: docs\u002Fprotocol\u002Fsse-protocol.md",{"type":64,"tag":1400,"props":4603,"children":4605},{"id":4604},"medium-assuming-all-ag-ui-events-arrive-in-every-response",[4606],{"type":70,"value":4607},"MEDIUM: Assuming all AG-UI events arrive in every response",{"type":64,"tag":73,"props":4609,"children":4610},{},[4611],{"type":70,"value":4612},"Not all event types appear in every stream:",{"type":64,"tag":4614,"props":4615,"children":4616},"ul",{},[4617,4649,4671,4687,4697],{"type":64,"tag":4618,"props":4619,"children":4620},"li",{},[4621,4626,4627,4632,4634,4640,4641,4647],{"type":64,"tag":93,"props":4622,"children":4624},{"className":4623},[],[4625],{"type":70,"value":3174},{"type":70,"value":3371},{"type":64,"tag":93,"props":4628,"children":4630},{"className":4629},[],[4631],{"type":70,"value":3205},{"type":70,"value":4633}," only appear with thinking-enabled models\n(e.g., ",{"type":64,"tag":93,"props":4635,"children":4637},{"className":4636},[],[4638],{"type":70,"value":4639},"o3",{"type":70,"value":1248},{"type":64,"tag":93,"props":4642,"children":4644},{"className":4643},[],[4645],{"type":70,"value":4646},"claude-sonnet-4-5",{"type":70,"value":4648}," with extended thinking). Standard models\nskip these entirely.",{"type":64,"tag":4618,"props":4650,"children":4651},{},[4652,4657,4658,4663,4664,4669],{"type":64,"tag":93,"props":4653,"children":4655},{"className":4654},[],[4656],{"type":70,"value":3077},{"type":70,"value":3371},{"type":64,"tag":93,"props":4659,"children":4661},{"className":4660},[],[4662],{"type":70,"value":3116},{"type":70,"value":3371},{"type":64,"tag":93,"props":4665,"children":4667},{"className":4666},[],[4668],{"type":70,"value":3145},{"type":70,"value":4670}," only appear when\nthe model invokes tools. A text-only response has none.",{"type":64,"tag":4618,"props":4672,"children":4673},{},[4674,4679,4680,4685],{"type":64,"tag":93,"props":4675,"children":4677},{"className":4676},[],[4678],{"type":70,"value":3264},{"type":70,"value":3371},{"type":64,"tag":93,"props":4681,"children":4683},{"className":4682},[],[4684],{"type":70,"value":3288},{"type":70,"value":4686}," only appear when server code explicitly\nemits them for stateful agent workflows.",{"type":64,"tag":4618,"props":4688,"children":4689},{},[4690,4695],{"type":64,"tag":93,"props":4691,"children":4693},{"className":4692},[],[4694],{"type":70,"value":3240},{"type":70,"value":4696}," only appears when the server explicitly sends a\nfull transcript snapshot.",{"type":64,"tag":4618,"props":4698,"children":4699},{},[4700,4705],{"type":64,"tag":93,"props":4701,"children":4703},{"className":4702},[],[4704],{"type":70,"value":3312},{"type":70,"value":4706}," events are application-defined and never emitted by default.",{"type":64,"tag":73,"props":4708,"children":4709},{},[4710,4712,4717],{"type":70,"value":4711},"Code that expects a fixed sequence (e.g., always waiting for ",{"type":64,"tag":93,"props":4713,"children":4715},{"className":4714},[],[4716],{"type":70,"value":3205},{"type":70,"value":4718},"\nbefore processing text) will hang or break on models that don't emit those events.",{"type":64,"tag":73,"props":4720,"children":4721},{},[4722],{"type":70,"value":4723},"Source: docs\u002Fprotocol\u002Fchunk-definitions.md",{"type":64,"tag":79,"props":4725,"children":4727},{"id":4726},"tension",[4728],{"type":70,"value":4729},"Tension",{"type":64,"tag":73,"props":4731,"children":4732},{},[4733,4735,4740,4742,4747,4749,4755],{"type":70,"value":4734},"RESOLVED: TanStack AI is fully AG-UI compliant on both axes (server→client events\nAND client→server ",{"type":64,"tag":93,"props":4736,"children":4738},{"className":4737},[],[4739],{"type":70,"value":1288},{"type":70,"value":4741},"). The wire format carries TanStack ",{"type":64,"tag":93,"props":4743,"children":4745},{"className":4744},[],[4746],{"type":70,"value":1230},{"type":70,"value":4748},"\nanchors with their parts intact alongside AG-UI fan-out messages, so strict AG-UI\nservers see role-based messages while TanStack-aware servers read parts directly\nwithout transformation. See ",{"type":64,"tag":93,"props":4750,"children":4752},{"className":4751},[],[4753],{"type":70,"value":4754},"docs\u002Fmigration\u002Fag-ui-compliance.md",{"type":70,"value":4756}," for details.",{"type":64,"tag":79,"props":4758,"children":4760},{"id":4759},"cross-references",[4761],{"type":70,"value":4762},"Cross-References",{"type":64,"tag":4614,"props":4764,"children":4765},{},[4766,4779,4843],{"type":64,"tag":4618,"props":4767,"children":4768},{},[4769,4771,4777],{"type":70,"value":4770},"See also: ",{"type":64,"tag":93,"props":4772,"children":4774},{"className":4773},[],[4775],{"type":70,"value":4776},"ai-core\u002Fcustom-backend-integration\u002FSKILL.md",{"type":70,"value":4778}," -- Custom backends must implement SSE or HTTP stream format to work with TanStack AI client connection adapters.",{"type":64,"tag":4618,"props":4780,"children":4781},{},[4782,4783,4789,4791,4796,4797,4803,4805,4810,4812,4818,4820,4826,4827,4833,4835,4841],{"type":70,"value":4770},{"type":64,"tag":93,"props":4784,"children":4786},{"className":4785},[],[4787],{"type":70,"value":4788},"ai-core\u002Fmiddleware\u002FSKILL.md",{"type":70,"value":4790}," -- ",{"type":64,"tag":93,"props":4792,"children":4794},{"className":4793},[],[4795],{"type":70,"value":3956},{"type":70,"value":4280},{"type":64,"tag":93,"props":4798,"children":4800},{"className":4799},[],[4801],{"type":70,"value":4802},"{ path, diff }",{"type":70,"value":4804}," value (one of ",{"type":64,"tag":93,"props":4806,"children":4808},{"className":4807},[],[4809],{"type":70,"value":3523},{"type":70,"value":4811},"'s members) is populated from the same lazy ",{"type":64,"tag":93,"props":4813,"children":4815},{"className":4814},[],[4816],{"type":70,"value":4817},"before()",{"type":70,"value":4819},"\u002F",{"type":64,"tag":93,"props":4821,"children":4823},{"className":4822},[],[4824],{"type":70,"value":4825},"after()",{"type":70,"value":4819},{"type":64,"tag":93,"props":4828,"children":4830},{"className":4829},[],[4831],{"type":70,"value":4832},"diff()",{"type":70,"value":4834}," accessors documented there for ",{"type":64,"tag":93,"props":4836,"children":4838},{"className":4837},[],[4839],{"type":70,"value":4840},"onFile*",{"type":70,"value":4842}," middleware hooks.",{"type":64,"tag":4618,"props":4844,"children":4845},{},[4846,4848,4854],{"type":70,"value":4847},"Full CUSTOM event taxonomy: ",{"type":64,"tag":93,"props":4849,"children":4851},{"className":4850},[],[4852],{"type":70,"value":4853},"docs\u002Fprotocol\u002Fcustom-events.md",{"type":70,"value":303},{"type":64,"tag":4856,"props":4857,"children":4858},"style",{},[4859],{"type":70,"value":4860},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"items":4862,"total":5004},[4863,4879,4891,4903,4918,4930,4940,4950,4963,4973,4984,4994],{"slug":4864,"name":4864,"fn":4865,"description":4866,"org":4867,"tags":4868,"stars":4876,"repoUrl":4877,"updatedAt":4878},"aggregation","perform data aggregation in TanStack Table","Aggregate TanStack Table columns independently of grouping, including grand totals, caller-selected row totals, multiple keyed aggregations, custom context-based definitions, grouped merges, manual values, and worker constraints.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4869,4872,4875],{"name":4870,"slug":4871,"type":16},"Data Analysis","data-analysis",{"name":4873,"slug":4874,"type":16},"Frontend","frontend",{"name":10,"slug":9,"type":16},28175,"https:\u002F\u002Fgithub.com\u002FTanStack\u002Ftable","2026-07-30T05:25:59.429787",{"slug":4880,"name":4880,"fn":4881,"description":4882,"org":4883,"tags":4884,"stars":4876,"repoUrl":4877,"updatedAt":4890},"api-not-found","diagnose TanStack Table API errors","Diagnose missing TanStack Table v9 exports, options, state slices, and instance methods. Load before inventing an API when code sees a type error, undefined feature method, absent object key, adapter mismatch, or v8-shaped example.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4885,4888,4889],{"name":4886,"slug":4887,"type":16},"Debugging","debugging",{"name":4873,"slug":4874,"type":16},{"name":10,"slug":9,"type":16},"2026-07-30T05:26:05.418735",{"slug":4892,"name":4892,"fn":4893,"description":4894,"org":4895,"tags":4896,"stars":4876,"repoUrl":4877,"updatedAt":4902},"cell-selection","select rectangular cell ranges in tables","Select rectangular cell ranges with cellSelectionFeature: two-corner range state keyed by row and column id, mousedown\u002Fmouseenter handlers, selection edges, render-order resolution under pinning, and autoResetCellSelection. Load when ranges widen unexpectedly after sorting or column reordering, when a drag re-renders the whole table, or when building copy-to-clipboard from a selection.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4897,4898,4899],{"name":4870,"slug":4871,"type":16},{"name":10,"slug":9,"type":16},{"name":4900,"slug":4901,"type":16},"UI Components","ui-components","2026-07-30T05:25:38.403427",{"slug":4904,"name":4904,"fn":4905,"description":4906,"org":4907,"tags":4908,"stars":4876,"repoUrl":4877,"updatedAt":4917},"client-vs-server","manage TanStack Table data pipelines","Choose client or server ownership for filtering, grouping, sorting, expanding, and pagination in TanStack Table v9. Load for manual* flags, mixed pipelines, server counts, or deciding which dataset each row-model stage receives.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4909,4912,4913,4916],{"name":4910,"slug":4911,"type":16},"Data Pipeline","data-pipeline",{"name":4873,"slug":4874,"type":16},{"name":4914,"slug":4915,"type":16},"Performance","performance",{"name":10,"slug":9,"type":16},"2026-07-30T05:25:45.400104",{"slug":4919,"name":4919,"fn":4920,"description":4921,"org":4922,"tags":4923,"stars":4876,"repoUrl":4877,"updatedAt":4929},"column-faceting","build faceted filter UIs","Build faceted filter UIs with columnFacetingFeature, facetedRowModel, facetedUniqueValues, and facetedMinMaxValues. Load for facet counts, numeric ranges, own-filter exclusion, or server-page facet completeness.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4924,4927,4928],{"name":4925,"slug":4926,"type":16},"Data Visualization","data-visualization",{"name":4873,"slug":4874,"type":16},{"name":10,"slug":9,"type":16},"2026-07-30T05:25:41.397257",{"slug":4931,"name":4931,"fn":4932,"description":4933,"org":4934,"tags":4935,"stars":4876,"repoUrl":4877,"updatedAt":4939},"column-filtering","implement column filtering in TanStack Table","Filter columns with columnFilteringFeature, filteredRowModel, filterFns, filterMeta, nested-row direction, and manualFiltering. Load for accessor compatibility, controlled filter updaters, fuzzy metadata, or client\u002Fserver ownership.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4936,4937,4938],{"name":4870,"slug":4871,"type":16},{"name":4873,"slug":4874,"type":16},{"name":10,"slug":9,"type":16},"2026-07-30T05:25:53.391632",{"slug":4941,"name":4941,"fn":4942,"description":4943,"org":4944,"tags":4945,"stars":4876,"repoUrl":4877,"updatedAt":4949},"column-ordering","manage TanStack Table column ordering","Control TanStack Table v9 leaf columnOrder with stable IDs while accounting for pinning regions, visibility, and groupedColumnMode precedence. Load for drag-and-drop columns or rendered order that differs from state.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4946,4947,4948],{"name":4873,"slug":4874,"type":16},{"name":10,"slug":9,"type":16},{"name":4900,"slug":4901,"type":16},"2026-07-30T05:26:03.37801",{"slug":4951,"name":4951,"fn":4952,"description":4953,"org":4954,"tags":4955,"stars":4876,"repoUrl":4877,"updatedAt":4962},"column-pinning","configure column pinning in TanStack Table","Pin columns into logical start, center, and end regions with columnPinningFeature and renderer-owned sticky CSS. Load for RTL offsets, z-index, backgrounds, overflow, widths, gaps, or overlaps.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4956,4959,4960,4961],{"name":4957,"slug":4958,"type":16},"CSS","css",{"name":4873,"slug":4874,"type":16},{"name":10,"slug":9,"type":16},{"name":4900,"slug":4901,"type":16},"2026-07-30T05:25:55.377366",{"slug":4964,"name":4964,"fn":4965,"description":4966,"org":4967,"tags":4968,"stars":4876,"repoUrl":4877,"updatedAt":4972},"column-resizing","implement column resizing in TanStack Table","Wire columnResizingFeature, header.getResizeHandler, resize mode and direction, pointer or touch events, and performant CSS-variable updates. Load when resize state changes but widths do not, or large tables resize slowly.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4969,4970,4971],{"name":4873,"slug":4874,"type":16},{"name":10,"slug":9,"type":16},{"name":4900,"slug":4901,"type":16},"2026-07-30T05:25:51.400011",{"slug":4974,"name":4974,"fn":4975,"description":4976,"org":4977,"tags":4978,"stars":4876,"repoUrl":4877,"updatedAt":4983},"column-sizing","configure column sizing in TanStack Table","Use columnSizingFeature numeric size, minSize, maxSize, getSize, getStart, getAfter, and total-size APIs in table, grid, or flex CSS. Load for auto or percentage misconceptions and sizing\u002Fpinning layout mismatch.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4979,4980,4981,4982],{"name":4957,"slug":4958,"type":16},{"name":4873,"slug":4874,"type":16},{"name":10,"slug":9,"type":16},{"name":4900,"slug":4901,"type":16},"2026-07-30T05:25:48.703799",{"slug":4985,"name":4985,"fn":4986,"description":4987,"org":4988,"tags":4989,"stars":4876,"repoUrl":4877,"updatedAt":4993},"column-visibility","manage column visibility in TanStack Table","Hide columns with columnVisibilityFeature while rendering visibility-aware header, column, and cell collections. Load when hidden columns remain in the DOM, false-versus-absent state is confused, or enableHiding is misunderstood.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[4990,4991,4992],{"name":4873,"slug":4874,"type":16},{"name":10,"slug":9,"type":16},{"name":4900,"slug":4901,"type":16},"2026-07-30T05:25:47.367943",{"slug":4995,"name":4995,"fn":4996,"description":4997,"org":4998,"tags":4999,"stars":4876,"repoUrl":4877,"updatedAt":5003},"core","build data grids with TanStack Table","Use TanStack Table v9 as a headless data-grid state and row-processing engine. Load for first-table architecture, stable data and columns, row numbering with getDisplayIndex, semantic rendering, framework adapter choice, or deciding what Table owns versus the renderer.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[5000,5001,5002],{"name":4870,"slug":4871,"type":16},{"name":4873,"slug":4874,"type":16},{"name":4900,"slug":4901,"type":16},"2026-07-30T05:25:52.366295",125,{"items":5006,"total":1141},[5007,5025,5040,5054,5060,5072,5086],{"slug":5008,"name":5008,"fn":5009,"description":5010,"org":5011,"tags":5012,"stars":21,"repoUrl":22,"updatedAt":5024},"ai-code-mode","execute sandboxed TypeScript code with LLMs","LLM-generated TypeScript execution in sandboxed environments: createCodeModeTool() with isolate drivers (createNodeIsolateDriver, createQuickJSIsolateDriver, createCloudflareIsolateDriver), codeModeWithSkills() for persistent skill libraries, trust strategies, skill storage (FileSystem, LocalStorage, InMemory, Mongo), client-side execution progress via code_mode:* custom events in useChat.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[5013,5015,5018,5021,5022],{"name":5014,"slug":29,"type":16},"AI SDK",{"name":5016,"slug":5017,"type":16},"Code Execution","code-execution",{"name":5019,"slug":5020,"type":16},"Sandboxing","sandboxing",{"name":10,"slug":9,"type":16},{"name":5023,"slug":42,"type":16},"TypeScript","2026-07-16T06:04:13.597905",{"slug":5026,"name":5026,"fn":5027,"description":5028,"org":5029,"tags":5030,"stars":21,"repoUrl":22,"updatedAt":5039},"ai-core","configure TanStack AI agent features","Entry point for TanStack AI skills. Routes to chat-experience, tool-calling, media-generation, structured-outputs, adapter-configuration, ag-ui-protocol, middleware, locks, custom-backend-integration, and debug-logging, plus the skills shipped by companion packages (@tanstack\u002Fai-persistence, @tanstack\u002Fai-code-mode). Use chat() not streamText(), openaiText() not createOpenAI(), toServerSentEventsResponse() not manual SSE, middleware hooks not onEnd callbacks.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[5031,5034,5036],{"name":5032,"slug":5033,"type":16},"Agents","agents",{"name":5035,"slug":27,"type":16},"AI",{"name":5037,"slug":5038,"type":16},"Middleware","middleware","2026-07-30T05:26:10.404565",{"slug":5041,"name":5042,"fn":5043,"description":5044,"org":5045,"tags":5046,"stars":21,"repoUrl":22,"updatedAt":5053},"ai-coreadapter-configuration","ai-core\u002Fadapter-configuration","configure AI provider adapters","Provider adapter selection and configuration: openaiText, anthropicText, geminiText, ollamaText, grokText, groqText, openRouterText, bedrockText, openaiCompatible. Per-model type safety with modelOptions, reasoning\u002Fthinking configuration, runtime adapter switching, extendAdapter() for custom models, createModel(). Generic OpenAI-compatible providers (DeepSeek, Together, Fireworks, etc.) via openaiCompatible({ baseURL, apiKey, models }) from @tanstack\u002Fai-openai\u002Fcompatible. API key env vars: OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_API_KEY\u002FGEMINI_API_KEY, XAI_API_KEY, GROQ_API_KEY, OPENROUTER_API_KEY, OLLAMA_HOST, BEDROCK_API_KEY (or AWS_BEARER_TOKEN_BEDROCK).\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[5047,5048,5051,5052],{"name":5014,"slug":29,"type":16},{"name":5049,"slug":5050,"type":16},"Configuration","configuration",{"name":14,"slug":15,"type":16},{"name":10,"slug":9,"type":16},"2026-07-16T06:04:17.82075",{"slug":4,"name":5,"fn":6,"description":7,"org":5055,"tags":5056,"stars":21,"repoUrl":22,"updatedAt":23},{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[5057,5058,5059],{"name":18,"slug":19,"type":16},{"name":14,"slug":15,"type":16},{"name":10,"slug":9,"type":16},{"slug":5061,"name":5062,"fn":5063,"description":5064,"org":5065,"tags":5066,"stars":21,"repoUrl":22,"updatedAt":5071},"ai-corechat-experience","ai-core\u002Fchat-experience","implement chat experiences with TanStack AI","End-to-end chat implementation: server endpoint with chat() and toServerSentEventsResponse(), client-side useChat hook with fetchServerSentEvents(), message rendering with UIMessage parts, multimodal content, thinking\u002Freasoning display. Covers streaming states, connection adapters, and message format conversions. NOT Vercel AI SDK — uses chat() not streamText().\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[5067,5068,5069,5070],{"name":18,"slug":19,"type":16},{"name":4873,"slug":4874,"type":16},{"name":14,"slug":15,"type":16},{"name":10,"slug":9,"type":16},"2026-07-30T05:26:11.505241",{"slug":5073,"name":5074,"fn":5075,"description":5076,"org":5077,"tags":5078,"stars":21,"repoUrl":22,"updatedAt":5085},"ai-coreclient-persistence","ai-core\u002Fclient-persistence","implement browser chat persistence for TanStack AI","Browser chat persistence on useChat \u002F ChatClient: localStoragePersistence, sessionStoragePersistence, indexedDBPersistence. Client-authoritative (adapter, full transcript) vs server-authoritative (persistence: true, no client cache). Reload restore, pending interrupts, mid-stream rejoin with delivery durability. Use for SPA reload durability — NOT server history alone. No extra package: the adapters ship in the framework packages.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[5079,5080,5081,5084],{"name":5035,"slug":27,"type":16},{"name":4873,"slug":4874,"type":16},{"name":5082,"slug":5083,"type":16},"Persistence","persistence",{"name":10,"slug":9,"type":16},"2026-07-30T05:53:35.503176",{"slug":5087,"name":5088,"fn":5089,"description":5090,"org":5091,"tags":5092,"stars":21,"repoUrl":22,"updatedAt":5099},"ai-corecustom-backend-integration","ai-core\u002Fcustom-backend-integration","integrate custom backends with TanStack AI","Connect useChat to a non-TanStack-AI backend through custom connection adapters. ConnectConnectionAdapter (single async iterable) vs SubscribeConnectionAdapter (separate subscribe\u002Fsend). Customize fetchServerSentEvents() and fetchHttpStream() with auth headers, custom URLs, and request options. Import from framework package, not @tanstack\u002Fai-client.\n",{"slug":9,"name":10,"logoUrl":11,"githubOrg":10},[5093,5094,5095,5098],{"name":5035,"slug":27,"type":16},{"name":18,"slug":19,"type":16},{"name":5096,"slug":5097,"type":16},"Backend","backend",{"name":10,"slug":9,"type":16},"2026-07-17T06:06:39.855351"]