[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-trigger-dev-trigger-authoring-chat-agent":3,"mdc--yk9s8f-key":47,"related-org-trigger-dev-trigger-authoring-chat-agent":5064,"related-repo-trigger-dev-trigger-authoring-chat-agent":5221},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":12,"stars":24,"repoUrl":25,"updatedAt":26,"license":27,"forks":28,"topics":29,"repo":42,"sourceUrl":45,"mdContent":46},"trigger-authoring-chat-agent","author durable AI chat agents with Trigger.dev","Author and run a durable AI chat agent with chat.agent from @trigger.dev\u002Fsdk\u002Fai: the per-turn run loop, why you MUST spread ...chat.toStreamTextOptions() first, returning a StreamTextResult vs calling chat.pipe(), the two server actions (chat.createStartSessionAction + auth.createPublicToken), and wiring useChat to useTriggerChatTransport. Load this when building, modifying, or debugging a chat backend (the agent task or its lifecycle hooks) or its React transport, when declaring typed tools or custom data parts, or when migrating a plain AI SDK streamText route to chat.agent.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},"trigger-dev","Trigger.dev","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Ftrigger-dev.jpg","triggerdotdev",[13,15,18,21],{"name":9,"slug":8,"type":14},"tag",{"name":16,"slug":17,"type":14},"Agents","agents",{"name":19,"slug":20,"type":14},"SDK","sdk",{"name":22,"slug":23,"type":14},"Workflow Automation","workflow-automation",14401,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Ftrigger.dev","2026-07-02T17:12:52.307135",null,1131,[30,31,32,33,34,35,36,37,38,39,40,23,41],"ai","ai-agent-framework","ai-agents","automation","background-jobs","mcp","mcp-server","nextjs","orchestration","scheduler","serverless","workflows",{"repoUrl":25,"stars":24,"forks":28,"topics":43,"description":44},[30,31,32,33,34,35,36,37,38,39,40,23,41],"Trigger.dev – build and deploy fully‑managed AI agents and workflows","https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Ftrigger.dev\u002Ftree\u002FHEAD\u002Fpackages\u002Ftrigger-sdk\u002Fskills\u002Ftrigger-authoring-chat-agent","---\nname: trigger-authoring-chat-agent\ndescription: >\n  Author and run a durable AI chat agent with chat.agent from @trigger.dev\u002Fsdk\u002Fai: the per-turn\n  run loop, why you MUST spread ...chat.toStreamTextOptions() first, returning a StreamTextResult\n  vs calling chat.pipe(), the two server actions (chat.createStartSessionAction +\n  auth.createPublicToken), and wiring useChat to useTriggerChatTransport. Load this when building,\n  modifying, or debugging a chat backend (the agent task or its lifecycle hooks) or its React\n  transport, when declaring typed tools or custom data parts, or when migrating a plain AI SDK\n  streamText route to chat.agent.\ntype: core\nlibrary: trigger.dev\nsources:\n  - docs\u002Fai-chat\u002Foverview.mdx\n  - docs\u002Fai-chat\u002Fquick-start.mdx\n  - docs\u002Fai-chat\u002Fhow-it-works.mdx\n  - docs\u002Fai-chat\u002Fbackend.mdx\n  - docs\u002Fai-chat\u002Ffrontend.mdx\n  - docs\u002Fai-chat\u002Freference.mdx\n  - docs\u002Fai-chat\u002Ftypes.mdx\n  - docs\u002Fai-chat\u002Ftools.mdx\n  - docs\u002Fai-chat\u002Flifecycle-hooks.mdx\n  - docs\u002Fai-chat\u002Ferror-handling.mdx\n---\n\n# Authoring a chat agent\n\nA `chat.agent` runs an entire conversation as one long-lived Trigger.dev task. It wakes when a\nmessage arrives, freezes when none do, and in-memory state survives page refreshes, deploys, idle\ngaps, and crashes. Your code is the loop you would write anyway: messages in, `streamText` out.\nThere are no API routes. The frontend talks to the agent through a `TriggerChatTransport`, so\nhistory accumulates server-side and the client ships only the new message each turn.\n\nWorks with Vercel AI SDK v5, v6, or v7. On v7 also install `@ai-sdk\u002Fotel` so model calls are traced\n(the SDK registers it for you).\n\n## Setup\n\nThree pieces: the agent task, two server actions, and the frontend transport.\n\n### 1. Define the agent\n\n```ts trigger\u002Fchat.ts\nimport { chat } from \"@trigger.dev\u002Fsdk\u002Fai\";\nimport { streamText, stepCountIs } from \"ai\";\nimport { anthropic } from \"@ai-sdk\u002Fanthropic\";\n\nexport const myChat = chat.agent({\n  id: \"my-chat\",\n  run: async ({ messages, signal }) =>\n    streamText({\n      \u002F\u002F Spread this FIRST. See \"Common mistakes\".\n      ...chat.toStreamTextOptions(),\n      model: anthropic(\"claude-sonnet-4-5\"),\n      messages,\n      abortSignal: signal,\n      stopWhen: stepCountIs(15),\n    }),\n});\n```\n\n`run` receives `messages` already converted to `ModelMessage[]` (the SDK converts the frontend's\n`UIMessage[]` for you) plus a `signal` that aborts on stop or cancel. Returning the\n`StreamTextResult` auto-pipes it to the frontend.\n\n### 2. Add two server actions\n\nBoth run on your server, so the browser never holds your environment secret key. This is also\nwhere per-user \u002F per-plan authorization and any paired DB writes live.\n\n```ts app\u002Factions.ts\n\"use server\";\nimport { auth } from \"@trigger.dev\u002Fsdk\";\nimport { chat } from \"@trigger.dev\u002Fsdk\u002Fai\";\n\n\u002F\u002F Creates the Session + first run, returns a session PAT. Idempotent on (env, chatId).\nexport const startChatSession = chat.createStartSessionAction(\"my-chat\");\n\n\u002F\u002F Pure mint. The transport calls this on 401\u002F403 to refresh an expired token.\nexport async function mintChatAccessToken(chatId: string) {\n  return auth.createPublicToken({\n    scopes: { read: { sessions: chatId }, write: { sessions: chatId } },\n    expirationTime: \"1h\",\n  });\n}\n```\n\n### 3. Wire the frontend\n\n```tsx app\u002Fcomponents\u002Fchat.tsx\n\"use client\";\nimport { useState } from \"react\";\nimport { useChat } from \"@ai-sdk\u002Freact\";\nimport { useTriggerChatTransport } from \"@trigger.dev\u002Fsdk\u002Fchat\u002Freact\";\nimport type { myChat } from \"@\u002Ftrigger\u002Fchat\";\nimport { mintChatAccessToken, startChatSession } from \"@\u002Fapp\u002Factions\";\n\nexport function Chat() {\n  const transport = useTriggerChatTransport\u003Ctypeof myChat>({\n    task: \"my-chat\", \u002F\u002F typeof myChat gives compile-time task-id validation\n    accessToken: ({ chatId }) => mintChatAccessToken(chatId),\n    startSession: ({ chatId, clientData }) => startChatSession({ chatId, clientData }),\n  });\n\n  const { messages, sendMessage, stop, status } = useChat({ transport });\n  const [input, setInput] = useState(\"\");\n  \u002F\u002F render messages, a form that calls sendMessage({ text: input }),\n  \u002F\u002F and a Stop button (onClick={stop}) while status === \"streaming\".\n}\n```\n\nThe transport is memoized (created once, reused across renders). Passing `typeof myChat` flows the\nagent's message type through `useChat`.\n\n## Core patterns\n\n### 1. Return vs pipe\n\nReturn the `streamText` result from `run` for the simple case. When `streamText` is called deep\ninside nested helpers, call `await chat.pipe(result)` from anywhere in the task instead, and let\n`run` resolve `void`.\n\n```ts\nexport const agentChat = chat.agent({\n  id: \"agent-chat\",\n  run: async ({ messages }) => {\n    await runAgentLoop(messages); \u002F\u002F don't return; pipe inside\n  },\n});\n\nasync function runAgentLoop(messages: ModelMessage[]) {\n  const result = streamText({\n    ...chat.toStreamTextOptions(),\n    model: anthropic(\"claude-sonnet-4-5\"),\n    messages,\n  });\n  await chat.pipe(result); \u002F\u002F works from anywhere in the task\n}\n```\n\n### 2. Typed tools (declare on config AND spread back)\n\nDeclare tools on `chat.agent({ tools })`, read them back typed from the `run()` payload, and pass\nthat set to `chat.toStreamTextOptions({ tools })`. One declaration flows everywhere.\n\n```ts\nimport { tool, stepCountIs } from \"ai\";\nimport { z } from \"zod\";\n\nconst tools = {\n  searchDocs: tool({\n    description: \"Search the docs.\",\n    inputSchema: z.object({ query: z.string() }),\n    execute: async ({ query }) => searchIndex(query),\n  }),\n};\n\nexport const myChat = chat.agent({\n  id: \"my-chat\",\n  tools, \u002F\u002F so toModelOutput survives across turns\n  run: async ({ messages, tools, signal }) =>\n    streamText({\n      ...chat.toStreamTextOptions({ tools }), \u002F\u002F same set, handed back typed\n      model: anthropic(\"claude-sonnet-4-5\"),\n      messages,\n      abortSignal: signal,\n      stopWhen: stepCountIs(15),\n    }),\n});\n```\n\n`tools` also accepts a function `(event) => ToolSet` resolved per turn, where `event` carries\n`chatId`, `turn`, `continuation`, and `clientData`.\n\n### 3. Custom data parts (persisted vs transient)\n\n`data-*` parts written via `chat.response.write()` in `run()` (or `writer.write()` in hooks)\npersist into `responseMessage.parts` and surface in `onTurnComplete`. Add `transient: true` to\nstream them without persisting. Writes via `chat.stream` are always ephemeral.\n\n```ts\n\u002F\u002F In run() - persists, surfaces in onTurnComplete's responseMessage\nchat.response.write({ type: \"data-context\", data: { searchResults } });\n\n\u002F\u002F In a hook via writer - streams but does NOT persist\nwriter.write({ type: \"data-progress\", id: \"search\", data: { percent: 50 }, transient: true });\n```\n\n### 4. Custom UIMessage type, client data, and builder hooks\n\nFor typed `data-*` parts or a tool map, build the agent through `chat.withUIMessage\u003CT>()` and\n`chat.withClientData({ schema })`. Builder methods chain in any order; builder hooks run before the\nmatching task hook. `streamOptions` becomes the default `uiMessageStreamOptions` (shallow-merged,\nagent wins).\n\n```ts\nexport const myChat = chat\n  .withUIMessage\u003CMyChatUIMessage>({ streamOptions: { sendReasoning: true } })\n  .withClientData({ schema: z.object({ userId: z.string() }) })\n  .agent({\n    id: \"my-chat\",\n    tools: myTools,\n    onTurnStart: async ({ uiMessages, writer }) => {\n      writer.write({ type: \"data-turn-status\", data: { status: \"preparing\" } });\n    },\n    run: async ({ messages, tools, signal }) =>\n      streamText({ ...chat.toStreamTextOptions({ tools }), model, messages, abortSignal: signal }),\n  });\n```\n\nBuild `MyChatUIMessage` as `UIMessage\u003Cunknown, MyDataTypes, InferUITools\u003Ctypeof tools>>` (or, for\ntools only, `InferChatUIMessageFromTools\u003Ctypeof tools>` from `@trigger.dev\u002Fsdk\u002Fai`). On the\nfrontend, narrow `useChat` with `InferChatUIMessage\u003Ctypeof myChat>` from `@trigger.dev\u002Fsdk\u002Fchat\u002Freact`.\n\n### 5. Lifecycle hooks and stop\n\n`chat.agent` accepts hooks that fire in a fixed per-turn order:\n\n```text\nonValidateMessages -> hydrateMessages -> onChatStart (chat's first message only)\n  -> onTurnStart -> run() -> onBeforeTurnComplete -> onTurnComplete\n```\n\n`onBoot` fires once per worker process (every fresh boot, including continuation runs) and is where\n`chat.local`, DB connections, and per-process state belong. `onChatStart` fires only on the chat's\nfirst message. Suspend\u002Fresume use `onChatSuspend` \u002F `onChatResume`. Config options include\n`tools`, `clientDataSchema`, `maxTurns` (100), `turnTimeout` (\"1h\"), `idleTimeoutInSeconds` (30),\n`uiMessageStreamOptions`, and `exitAfterPreloadIdle`. There is no generic `retry`; `chat.agent`\nruns with `maxAttempts: 1` internally.\n\nStop is load-bearing: the `signal` passed to `run` aborts on stop or cancel. Forward it as\n`abortSignal` to `streamText`, or the Stop button updates the UI while the model keeps generating\nserver-side.\n\n```ts\nrun: async ({ messages, signal }) =>\n  streamText({ ...chat.toStreamTextOptions(), model, messages, abortSignal: signal, stopWhen: stepCountIs(15) });\n```\n\n### 6. Migrating from a plain AI SDK `streamText` route\n\nThere is no API route in this model. The transport replaces the route round-trip, so:\n\n- Delete the route handler. Move per-request auth into the two server actions from Setup step 2.\n- Move the `streamText` call into `run`. It already receives pre-converted `ModelMessage[]`.\n- Return the `StreamTextResult` (it auto-pipes) and add `...chat.toStreamTextOptions()` first.\n- On the client, swap the `api` URL for `useTriggerChatTransport`; `useChat` stays the same shape.\n\n## Common mistakes\n\n- **CRITICAL: forgetting `...chat.toStreamTextOptions()`.**\n  ```ts\n  \u002F\u002F Wrong - compaction \u002F steering \u002F background injection silently no-op\n  return streamText({ model, messages, abortSignal: signal });\n  \u002F\u002F Correct - spread FIRST so explicit overrides win\n  return streamText({ ...chat.toStreamTextOptions(), model, messages, abortSignal: signal });\n  ```\n  It wires the `prepareStep` callback behind compaction, mid-turn steering, and background\n  injection, injects the system prompt from `chat.prompt()`, resolves the registry model, and adds\n  telemetry. Omitting it makes all of those silently no-op with no error.\n\n- **Declaring tools only on `streamText`.** Also declare them on `chat.agent({ tools })`, read them\n  back from `run`, and pass `chat.toStreamTextOptions({ tools })`. Otherwise each tool's\n  `toModelOutput` runs on turn 1 but is dropped when history is re-converted on later turns.\n\n- **Not forwarding `signal` for stop.** Without `abortSignal: signal`, Stop updates the UI but the\n  model keeps generating server-side.\n\n- **Initializing `chat.local` in `onChatStart`.** Initialize it in `onBoot`. `onChatStart` fires\n  once per chat, so continuation runs skip it and crash with\n  `chat.local can only be modified after initialization`. `onBoot` fires on every fresh worker.\n\n- **Minting tokens in the browser.** Never expose the environment secret key client-side. Mint via\n  the two server actions; the transport calls them.\n\n- **Clearing `lastEventId` on `chat.endRun()`.** Keep the cursor for the Session lifetime; clear it\n  only when the Session itself closes. It is sessionId-keyed, so clearing forces a resubscribe from\n  `seq_num=0` that can hit the prior turn's stale `turn-complete` and close the stream empty.\n\n- **Returning the raw error from `uiMessageStreamOptions.onError`.** It leaks internals (keys,\n  stack traces). Return a sanitized string instead.\n\n## References\n\n- `trigger-chat-agent-advanced` skill - lifecycle hooks in depth, sessions, raw-task primitives\n  (`chat.createSession`, `chat.customAgent`, `chat.stream`), compaction, HITL approvals, recovery.\n- `trigger-realtime-and-frontend` skill - Realtime hooks and frontend streaming beyond the chat transport.\n- `trigger-authoring-tasks` skill - base `task()` semantics, `ctx`, and standard lifecycle hooks.\n\nReference docs ship beside this skill in the same package, read them locally (no network), pinned to your installed version. The `sources:` frontmatter above lists every doc this skill draws from, all under `@trigger.dev\u002Fsdk\u002Fdocs\u002Fai-chat\u002F`. Start with `quick-start.mdx`, `backend.mdx`, `tools.mdx`, `types.mdx`, `frontend.mdx`.\n\nA `chat.agent` is a Trigger.dev task, so it builds and deploys like any other. For `trigger.config.ts` and build extensions (Prisma, Playwright, Python, FFmpeg, etc. — e.g. when a tool needs them), read the bundled config docs under `@trigger.dev\u002Fsdk\u002Fdocs\u002Fconfig\u002F` (extensions are in `config\u002Fextensions\u002F`, starting with `overview.mdx`).\n\n## Version\n\nThis skill is bundled inside `@trigger.dev\u002Fsdk` and read directly from `node_modules`, so it always matches your installed SDK version (see the adjacent `package.json`). The full documentation for these APIs ships alongside it under `@trigger.dev\u002Fsdk\u002Fdocs\u002F`.\n",{"data":48,"body":62},{"name":4,"description":6,"type":49,"library":50,"sources":51},"core","trigger.dev",[52,53,54,55,56,57,58,59,60,61],"docs\u002Fai-chat\u002Foverview.mdx","docs\u002Fai-chat\u002Fquick-start.mdx","docs\u002Fai-chat\u002Fhow-it-works.mdx","docs\u002Fai-chat\u002Fbackend.mdx","docs\u002Fai-chat\u002Ffrontend.mdx","docs\u002Fai-chat\u002Freference.mdx","docs\u002Fai-chat\u002Ftypes.mdx","docs\u002Fai-chat\u002Ftools.mdx","docs\u002Fai-chat\u002Flifecycle-hooks.mdx","docs\u002Fai-chat\u002Ferror-handling.mdx",{"type":63,"children":64},"root",[65,74,105,118,125,130,137,643,694,700,705,1113,1119,1780,1800,1806,1812,1860,2254,2260,2289,2942,2998,3004,3070,3324,3330,3374,3953,4008,4014,4024,4034,4151,4185,4340,4353,4358,4439,4445,4839,4845,4918,4974,5017,5023,5058],{"type":66,"tag":67,"props":68,"children":70},"element","h1",{"id":69},"authoring-a-chat-agent",[71],{"type":72,"value":73},"text","Authoring a chat agent",{"type":66,"tag":75,"props":76,"children":77},"p",{},[78,80,87,89,95,97,103],{"type":72,"value":79},"A ",{"type":66,"tag":81,"props":82,"children":84},"code",{"className":83},[],[85],{"type":72,"value":86},"chat.agent",{"type":72,"value":88}," runs an entire conversation as one long-lived Trigger.dev task. It wakes when a\nmessage arrives, freezes when none do, and in-memory state survives page refreshes, deploys, idle\ngaps, and crashes. Your code is the loop you would write anyway: messages in, ",{"type":66,"tag":81,"props":90,"children":92},{"className":91},[],[93],{"type":72,"value":94},"streamText",{"type":72,"value":96}," out.\nThere are no API routes. The frontend talks to the agent through a ",{"type":66,"tag":81,"props":98,"children":100},{"className":99},[],[101],{"type":72,"value":102},"TriggerChatTransport",{"type":72,"value":104},", so\nhistory accumulates server-side and the client ships only the new message each turn.",{"type":66,"tag":75,"props":106,"children":107},{},[108,110,116],{"type":72,"value":109},"Works with Vercel AI SDK v5, v6, or v7. On v7 also install ",{"type":66,"tag":81,"props":111,"children":113},{"className":112},[],[114],{"type":72,"value":115},"@ai-sdk\u002Fotel",{"type":72,"value":117}," so model calls are traced\n(the SDK registers it for you).",{"type":66,"tag":119,"props":120,"children":122},"h2",{"id":121},"setup",[123],{"type":72,"value":124},"Setup",{"type":66,"tag":75,"props":126,"children":127},{},[128],{"type":72,"value":129},"Three pieces: the agent task, two server actions, and the frontend transport.",{"type":66,"tag":131,"props":132,"children":134},"h3",{"id":133},"_1-define-the-agent",[135],{"type":72,"value":136},"1. Define the agent",{"type":66,"tag":138,"props":139,"children":145},"pre",{"className":140,"code":141,"language":142,"meta":143,"style":144},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { chat } from \"@trigger.dev\u002Fsdk\u002Fai\";\nimport { streamText, stepCountIs } from \"ai\";\nimport { anthropic } from \"@ai-sdk\u002Fanthropic\";\n\nexport const myChat = chat.agent({\n  id: \"my-chat\",\n  run: async ({ messages, signal }) =>\n    streamText({\n      \u002F\u002F Spread this FIRST. See \"Common mistakes\".\n      ...chat.toStreamTextOptions(),\n      model: anthropic(\"claude-sonnet-4-5\"),\n      messages,\n      abortSignal: signal,\n      stopWhen: stepCountIs(15),\n    }),\n});\n","ts","trigger\u002Fchat.ts","",[146],{"type":66,"tag":81,"props":147,"children":148},{"__ignoreMap":144},[149,204,255,297,307,357,390,438,455,465,497,540,553,574,609,626],{"type":66,"tag":150,"props":151,"children":154},"span",{"class":152,"line":153},"line",1,[155,161,167,173,178,183,188,194,199],{"type":66,"tag":150,"props":156,"children":158},{"style":157},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[159],{"type":72,"value":160},"import",{"type":66,"tag":150,"props":162,"children":164},{"style":163},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[165],{"type":72,"value":166}," {",{"type":66,"tag":150,"props":168,"children":170},{"style":169},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[171],{"type":72,"value":172}," chat",{"type":66,"tag":150,"props":174,"children":175},{"style":163},[176],{"type":72,"value":177}," }",{"type":66,"tag":150,"props":179,"children":180},{"style":157},[181],{"type":72,"value":182}," from",{"type":66,"tag":150,"props":184,"children":185},{"style":163},[186],{"type":72,"value":187}," \"",{"type":66,"tag":150,"props":189,"children":191},{"style":190},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[192],{"type":72,"value":193},"@trigger.dev\u002Fsdk\u002Fai",{"type":66,"tag":150,"props":195,"children":196},{"style":163},[197],{"type":72,"value":198},"\"",{"type":66,"tag":150,"props":200,"children":201},{"style":163},[202],{"type":72,"value":203},";\n",{"type":66,"tag":150,"props":205,"children":207},{"class":152,"line":206},2,[208,212,216,221,226,231,235,239,243,247,251],{"type":66,"tag":150,"props":209,"children":210},{"style":157},[211],{"type":72,"value":160},{"type":66,"tag":150,"props":213,"children":214},{"style":163},[215],{"type":72,"value":166},{"type":66,"tag":150,"props":217,"children":218},{"style":169},[219],{"type":72,"value":220}," streamText",{"type":66,"tag":150,"props":222,"children":223},{"style":163},[224],{"type":72,"value":225},",",{"type":66,"tag":150,"props":227,"children":228},{"style":169},[229],{"type":72,"value":230}," stepCountIs",{"type":66,"tag":150,"props":232,"children":233},{"style":163},[234],{"type":72,"value":177},{"type":66,"tag":150,"props":236,"children":237},{"style":157},[238],{"type":72,"value":182},{"type":66,"tag":150,"props":240,"children":241},{"style":163},[242],{"type":72,"value":187},{"type":66,"tag":150,"props":244,"children":245},{"style":190},[246],{"type":72,"value":30},{"type":66,"tag":150,"props":248,"children":249},{"style":163},[250],{"type":72,"value":198},{"type":66,"tag":150,"props":252,"children":253},{"style":163},[254],{"type":72,"value":203},{"type":66,"tag":150,"props":256,"children":258},{"class":152,"line":257},3,[259,263,267,272,276,280,284,289,293],{"type":66,"tag":150,"props":260,"children":261},{"style":157},[262],{"type":72,"value":160},{"type":66,"tag":150,"props":264,"children":265},{"style":163},[266],{"type":72,"value":166},{"type":66,"tag":150,"props":268,"children":269},{"style":169},[270],{"type":72,"value":271}," anthropic",{"type":66,"tag":150,"props":273,"children":274},{"style":163},[275],{"type":72,"value":177},{"type":66,"tag":150,"props":277,"children":278},{"style":157},[279],{"type":72,"value":182},{"type":66,"tag":150,"props":281,"children":282},{"style":163},[283],{"type":72,"value":187},{"type":66,"tag":150,"props":285,"children":286},{"style":190},[287],{"type":72,"value":288},"@ai-sdk\u002Fanthropic",{"type":66,"tag":150,"props":290,"children":291},{"style":163},[292],{"type":72,"value":198},{"type":66,"tag":150,"props":294,"children":295},{"style":163},[296],{"type":72,"value":203},{"type":66,"tag":150,"props":298,"children":300},{"class":152,"line":299},4,[301],{"type":66,"tag":150,"props":302,"children":304},{"emptyLinePlaceholder":303},true,[305],{"type":72,"value":306},"\n",{"type":66,"tag":150,"props":308,"children":310},{"class":152,"line":309},5,[311,316,322,327,332,336,341,347,352],{"type":66,"tag":150,"props":312,"children":313},{"style":157},[314],{"type":72,"value":315},"export",{"type":66,"tag":150,"props":317,"children":319},{"style":318},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[320],{"type":72,"value":321}," const",{"type":66,"tag":150,"props":323,"children":324},{"style":169},[325],{"type":72,"value":326}," myChat ",{"type":66,"tag":150,"props":328,"children":329},{"style":163},[330],{"type":72,"value":331},"=",{"type":66,"tag":150,"props":333,"children":334},{"style":169},[335],{"type":72,"value":172},{"type":66,"tag":150,"props":337,"children":338},{"style":163},[339],{"type":72,"value":340},".",{"type":66,"tag":150,"props":342,"children":344},{"style":343},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[345],{"type":72,"value":346},"agent",{"type":66,"tag":150,"props":348,"children":349},{"style":169},[350],{"type":72,"value":351},"(",{"type":66,"tag":150,"props":353,"children":354},{"style":163},[355],{"type":72,"value":356},"{\n",{"type":66,"tag":150,"props":358,"children":360},{"class":152,"line":359},6,[361,367,372,376,381,385],{"type":66,"tag":150,"props":362,"children":364},{"style":363},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[365],{"type":72,"value":366},"  id",{"type":66,"tag":150,"props":368,"children":369},{"style":163},[370],{"type":72,"value":371},":",{"type":66,"tag":150,"props":373,"children":374},{"style":163},[375],{"type":72,"value":187},{"type":66,"tag":150,"props":377,"children":378},{"style":190},[379],{"type":72,"value":380},"my-chat",{"type":66,"tag":150,"props":382,"children":383},{"style":163},[384],{"type":72,"value":198},{"type":66,"tag":150,"props":386,"children":387},{"style":163},[388],{"type":72,"value":389},",\n",{"type":66,"tag":150,"props":391,"children":393},{"class":152,"line":392},7,[394,399,403,408,413,419,423,428,433],{"type":66,"tag":150,"props":395,"children":396},{"style":343},[397],{"type":72,"value":398},"  run",{"type":66,"tag":150,"props":400,"children":401},{"style":163},[402],{"type":72,"value":371},{"type":66,"tag":150,"props":404,"children":405},{"style":318},[406],{"type":72,"value":407}," async",{"type":66,"tag":150,"props":409,"children":410},{"style":163},[411],{"type":72,"value":412}," ({",{"type":66,"tag":150,"props":414,"children":416},{"style":415},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic",[417],{"type":72,"value":418}," messages",{"type":66,"tag":150,"props":420,"children":421},{"style":163},[422],{"type":72,"value":225},{"type":66,"tag":150,"props":424,"children":425},{"style":415},[426],{"type":72,"value":427}," signal",{"type":66,"tag":150,"props":429,"children":430},{"style":163},[431],{"type":72,"value":432}," })",{"type":66,"tag":150,"props":434,"children":435},{"style":318},[436],{"type":72,"value":437}," =>\n",{"type":66,"tag":150,"props":439,"children":441},{"class":152,"line":440},8,[442,447,451],{"type":66,"tag":150,"props":443,"children":444},{"style":343},[445],{"type":72,"value":446},"    streamText",{"type":66,"tag":150,"props":448,"children":449},{"style":169},[450],{"type":72,"value":351},{"type":66,"tag":150,"props":452,"children":453},{"style":163},[454],{"type":72,"value":356},{"type":66,"tag":150,"props":456,"children":458},{"class":152,"line":457},9,[459],{"type":66,"tag":150,"props":460,"children":462},{"style":461},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[463],{"type":72,"value":464},"      \u002F\u002F Spread this FIRST. See \"Common mistakes\".\n",{"type":66,"tag":150,"props":466,"children":468},{"class":152,"line":467},10,[469,474,479,483,488,493],{"type":66,"tag":150,"props":470,"children":471},{"style":163},[472],{"type":72,"value":473},"      ...",{"type":66,"tag":150,"props":475,"children":476},{"style":169},[477],{"type":72,"value":478},"chat",{"type":66,"tag":150,"props":480,"children":481},{"style":163},[482],{"type":72,"value":340},{"type":66,"tag":150,"props":484,"children":485},{"style":343},[486],{"type":72,"value":487},"toStreamTextOptions",{"type":66,"tag":150,"props":489,"children":490},{"style":169},[491],{"type":72,"value":492},"()",{"type":66,"tag":150,"props":494,"children":495},{"style":163},[496],{"type":72,"value":389},{"type":66,"tag":150,"props":498,"children":500},{"class":152,"line":499},11,[501,506,510,514,518,522,527,531,536],{"type":66,"tag":150,"props":502,"children":503},{"style":363},[504],{"type":72,"value":505},"      model",{"type":66,"tag":150,"props":507,"children":508},{"style":163},[509],{"type":72,"value":371},{"type":66,"tag":150,"props":511,"children":512},{"style":343},[513],{"type":72,"value":271},{"type":66,"tag":150,"props":515,"children":516},{"style":169},[517],{"type":72,"value":351},{"type":66,"tag":150,"props":519,"children":520},{"style":163},[521],{"type":72,"value":198},{"type":66,"tag":150,"props":523,"children":524},{"style":190},[525],{"type":72,"value":526},"claude-sonnet-4-5",{"type":66,"tag":150,"props":528,"children":529},{"style":163},[530],{"type":72,"value":198},{"type":66,"tag":150,"props":532,"children":533},{"style":169},[534],{"type":72,"value":535},")",{"type":66,"tag":150,"props":537,"children":538},{"style":163},[539],{"type":72,"value":389},{"type":66,"tag":150,"props":541,"children":543},{"class":152,"line":542},12,[544,549],{"type":66,"tag":150,"props":545,"children":546},{"style":169},[547],{"type":72,"value":548},"      messages",{"type":66,"tag":150,"props":550,"children":551},{"style":163},[552],{"type":72,"value":389},{"type":66,"tag":150,"props":554,"children":556},{"class":152,"line":555},13,[557,562,566,570],{"type":66,"tag":150,"props":558,"children":559},{"style":363},[560],{"type":72,"value":561},"      abortSignal",{"type":66,"tag":150,"props":563,"children":564},{"style":163},[565],{"type":72,"value":371},{"type":66,"tag":150,"props":567,"children":568},{"style":169},[569],{"type":72,"value":427},{"type":66,"tag":150,"props":571,"children":572},{"style":163},[573],{"type":72,"value":389},{"type":66,"tag":150,"props":575,"children":577},{"class":152,"line":576},14,[578,583,587,591,595,601,605],{"type":66,"tag":150,"props":579,"children":580},{"style":363},[581],{"type":72,"value":582},"      stopWhen",{"type":66,"tag":150,"props":584,"children":585},{"style":163},[586],{"type":72,"value":371},{"type":66,"tag":150,"props":588,"children":589},{"style":343},[590],{"type":72,"value":230},{"type":66,"tag":150,"props":592,"children":593},{"style":169},[594],{"type":72,"value":351},{"type":66,"tag":150,"props":596,"children":598},{"style":597},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[599],{"type":72,"value":600},"15",{"type":66,"tag":150,"props":602,"children":603},{"style":169},[604],{"type":72,"value":535},{"type":66,"tag":150,"props":606,"children":607},{"style":163},[608],{"type":72,"value":389},{"type":66,"tag":150,"props":610,"children":612},{"class":152,"line":611},15,[613,618,622],{"type":66,"tag":150,"props":614,"children":615},{"style":163},[616],{"type":72,"value":617},"    }",{"type":66,"tag":150,"props":619,"children":620},{"style":169},[621],{"type":72,"value":535},{"type":66,"tag":150,"props":623,"children":624},{"style":163},[625],{"type":72,"value":389},{"type":66,"tag":150,"props":627,"children":629},{"class":152,"line":628},16,[630,635,639],{"type":66,"tag":150,"props":631,"children":632},{"style":163},[633],{"type":72,"value":634},"}",{"type":66,"tag":150,"props":636,"children":637},{"style":169},[638],{"type":72,"value":535},{"type":66,"tag":150,"props":640,"children":641},{"style":163},[642],{"type":72,"value":203},{"type":66,"tag":75,"props":644,"children":645},{},[646,652,654,660,662,668,670,676,678,684,686,692],{"type":66,"tag":81,"props":647,"children":649},{"className":648},[],[650],{"type":72,"value":651},"run",{"type":72,"value":653}," receives ",{"type":66,"tag":81,"props":655,"children":657},{"className":656},[],[658],{"type":72,"value":659},"messages",{"type":72,"value":661}," already converted to ",{"type":66,"tag":81,"props":663,"children":665},{"className":664},[],[666],{"type":72,"value":667},"ModelMessage[]",{"type":72,"value":669}," (the SDK converts the frontend's\n",{"type":66,"tag":81,"props":671,"children":673},{"className":672},[],[674],{"type":72,"value":675},"UIMessage[]",{"type":72,"value":677}," for you) plus a ",{"type":66,"tag":81,"props":679,"children":681},{"className":680},[],[682],{"type":72,"value":683},"signal",{"type":72,"value":685}," that aborts on stop or cancel. Returning the\n",{"type":66,"tag":81,"props":687,"children":689},{"className":688},[],[690],{"type":72,"value":691},"StreamTextResult",{"type":72,"value":693}," auto-pipes it to the frontend.",{"type":66,"tag":131,"props":695,"children":697},{"id":696},"_2-add-two-server-actions",[698],{"type":72,"value":699},"2. Add two server actions",{"type":66,"tag":75,"props":701,"children":702},{},[703],{"type":72,"value":704},"Both run on your server, so the browser never holds your environment secret key. This is also\nwhere per-user \u002F per-plan authorization and any paired DB writes live.",{"type":66,"tag":138,"props":706,"children":709},{"className":140,"code":707,"language":142,"meta":708,"style":144},"\"use server\";\nimport { auth } from \"@trigger.dev\u002Fsdk\";\nimport { chat } from \"@trigger.dev\u002Fsdk\u002Fai\";\n\n\u002F\u002F Creates the Session + first run, returns a session PAT. Idempotent on (env, chatId).\nexport const startChatSession = chat.createStartSessionAction(\"my-chat\");\n\n\u002F\u002F Pure mint. The transport calls this on 401\u002F403 to refresh an expired token.\nexport async function mintChatAccessToken(chatId: string) {\n  return auth.createPublicToken({\n    scopes: { read: { sessions: chatId }, write: { sessions: chatId } },\n    expirationTime: \"1h\",\n  });\n}\n","app\u002Factions.ts",[710],{"type":66,"tag":81,"props":711,"children":712},{"__ignoreMap":144},[713,733,774,813,820,828,885,892,900,949,978,1060,1089,1105],{"type":66,"tag":150,"props":714,"children":715},{"class":152,"line":153},[716,720,725,729],{"type":66,"tag":150,"props":717,"children":718},{"style":163},[719],{"type":72,"value":198},{"type":66,"tag":150,"props":721,"children":722},{"style":190},[723],{"type":72,"value":724},"use server",{"type":66,"tag":150,"props":726,"children":727},{"style":163},[728],{"type":72,"value":198},{"type":66,"tag":150,"props":730,"children":731},{"style":163},[732],{"type":72,"value":203},{"type":66,"tag":150,"props":734,"children":735},{"class":152,"line":206},[736,740,744,749,753,757,761,766,770],{"type":66,"tag":150,"props":737,"children":738},{"style":157},[739],{"type":72,"value":160},{"type":66,"tag":150,"props":741,"children":742},{"style":163},[743],{"type":72,"value":166},{"type":66,"tag":150,"props":745,"children":746},{"style":169},[747],{"type":72,"value":748}," auth",{"type":66,"tag":150,"props":750,"children":751},{"style":163},[752],{"type":72,"value":177},{"type":66,"tag":150,"props":754,"children":755},{"style":157},[756],{"type":72,"value":182},{"type":66,"tag":150,"props":758,"children":759},{"style":163},[760],{"type":72,"value":187},{"type":66,"tag":150,"props":762,"children":763},{"style":190},[764],{"type":72,"value":765},"@trigger.dev\u002Fsdk",{"type":66,"tag":150,"props":767,"children":768},{"style":163},[769],{"type":72,"value":198},{"type":66,"tag":150,"props":771,"children":772},{"style":163},[773],{"type":72,"value":203},{"type":66,"tag":150,"props":775,"children":776},{"class":152,"line":257},[777,781,785,789,793,797,801,805,809],{"type":66,"tag":150,"props":778,"children":779},{"style":157},[780],{"type":72,"value":160},{"type":66,"tag":150,"props":782,"children":783},{"style":163},[784],{"type":72,"value":166},{"type":66,"tag":150,"props":786,"children":787},{"style":169},[788],{"type":72,"value":172},{"type":66,"tag":150,"props":790,"children":791},{"style":163},[792],{"type":72,"value":177},{"type":66,"tag":150,"props":794,"children":795},{"style":157},[796],{"type":72,"value":182},{"type":66,"tag":150,"props":798,"children":799},{"style":163},[800],{"type":72,"value":187},{"type":66,"tag":150,"props":802,"children":803},{"style":190},[804],{"type":72,"value":193},{"type":66,"tag":150,"props":806,"children":807},{"style":163},[808],{"type":72,"value":198},{"type":66,"tag":150,"props":810,"children":811},{"style":163},[812],{"type":72,"value":203},{"type":66,"tag":150,"props":814,"children":815},{"class":152,"line":299},[816],{"type":66,"tag":150,"props":817,"children":818},{"emptyLinePlaceholder":303},[819],{"type":72,"value":306},{"type":66,"tag":150,"props":821,"children":822},{"class":152,"line":309},[823],{"type":66,"tag":150,"props":824,"children":825},{"style":461},[826],{"type":72,"value":827},"\u002F\u002F Creates the Session + first run, returns a session PAT. Idempotent on (env, chatId).\n",{"type":66,"tag":150,"props":829,"children":830},{"class":152,"line":359},[831,835,839,844,848,852,856,861,865,869,873,877,881],{"type":66,"tag":150,"props":832,"children":833},{"style":157},[834],{"type":72,"value":315},{"type":66,"tag":150,"props":836,"children":837},{"style":318},[838],{"type":72,"value":321},{"type":66,"tag":150,"props":840,"children":841},{"style":169},[842],{"type":72,"value":843}," startChatSession ",{"type":66,"tag":150,"props":845,"children":846},{"style":163},[847],{"type":72,"value":331},{"type":66,"tag":150,"props":849,"children":850},{"style":169},[851],{"type":72,"value":172},{"type":66,"tag":150,"props":853,"children":854},{"style":163},[855],{"type":72,"value":340},{"type":66,"tag":150,"props":857,"children":858},{"style":343},[859],{"type":72,"value":860},"createStartSessionAction",{"type":66,"tag":150,"props":862,"children":863},{"style":169},[864],{"type":72,"value":351},{"type":66,"tag":150,"props":866,"children":867},{"style":163},[868],{"type":72,"value":198},{"type":66,"tag":150,"props":870,"children":871},{"style":190},[872],{"type":72,"value":380},{"type":66,"tag":150,"props":874,"children":875},{"style":163},[876],{"type":72,"value":198},{"type":66,"tag":150,"props":878,"children":879},{"style":169},[880],{"type":72,"value":535},{"type":66,"tag":150,"props":882,"children":883},{"style":163},[884],{"type":72,"value":203},{"type":66,"tag":150,"props":886,"children":887},{"class":152,"line":392},[888],{"type":66,"tag":150,"props":889,"children":890},{"emptyLinePlaceholder":303},[891],{"type":72,"value":306},{"type":66,"tag":150,"props":893,"children":894},{"class":152,"line":440},[895],{"type":66,"tag":150,"props":896,"children":897},{"style":461},[898],{"type":72,"value":899},"\u002F\u002F Pure mint. The transport calls this on 401\u002F403 to refresh an expired token.\n",{"type":66,"tag":150,"props":901,"children":902},{"class":152,"line":457},[903,907,911,916,921,925,930,934,940,944],{"type":66,"tag":150,"props":904,"children":905},{"style":157},[906],{"type":72,"value":315},{"type":66,"tag":150,"props":908,"children":909},{"style":318},[910],{"type":72,"value":407},{"type":66,"tag":150,"props":912,"children":913},{"style":318},[914],{"type":72,"value":915}," function",{"type":66,"tag":150,"props":917,"children":918},{"style":343},[919],{"type":72,"value":920}," mintChatAccessToken",{"type":66,"tag":150,"props":922,"children":923},{"style":163},[924],{"type":72,"value":351},{"type":66,"tag":150,"props":926,"children":927},{"style":415},[928],{"type":72,"value":929},"chatId",{"type":66,"tag":150,"props":931,"children":932},{"style":163},[933],{"type":72,"value":371},{"type":66,"tag":150,"props":935,"children":937},{"style":936},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[938],{"type":72,"value":939}," string",{"type":66,"tag":150,"props":941,"children":942},{"style":163},[943],{"type":72,"value":535},{"type":66,"tag":150,"props":945,"children":946},{"style":163},[947],{"type":72,"value":948}," {\n",{"type":66,"tag":150,"props":950,"children":951},{"class":152,"line":467},[952,957,961,965,970,974],{"type":66,"tag":150,"props":953,"children":954},{"style":157},[955],{"type":72,"value":956},"  return",{"type":66,"tag":150,"props":958,"children":959},{"style":169},[960],{"type":72,"value":748},{"type":66,"tag":150,"props":962,"children":963},{"style":163},[964],{"type":72,"value":340},{"type":66,"tag":150,"props":966,"children":967},{"style":343},[968],{"type":72,"value":969},"createPublicToken",{"type":66,"tag":150,"props":971,"children":972},{"style":363},[973],{"type":72,"value":351},{"type":66,"tag":150,"props":975,"children":976},{"style":163},[977],{"type":72,"value":356},{"type":66,"tag":150,"props":979,"children":980},{"class":152,"line":499},[981,986,990,994,999,1003,1007,1012,1016,1021,1026,1031,1035,1039,1043,1047,1051,1055],{"type":66,"tag":150,"props":982,"children":983},{"style":363},[984],{"type":72,"value":985},"    scopes",{"type":66,"tag":150,"props":987,"children":988},{"style":163},[989],{"type":72,"value":371},{"type":66,"tag":150,"props":991,"children":992},{"style":163},[993],{"type":72,"value":166},{"type":66,"tag":150,"props":995,"children":996},{"style":363},[997],{"type":72,"value":998}," read",{"type":66,"tag":150,"props":1000,"children":1001},{"style":163},[1002],{"type":72,"value":371},{"type":66,"tag":150,"props":1004,"children":1005},{"style":163},[1006],{"type":72,"value":166},{"type":66,"tag":150,"props":1008,"children":1009},{"style":363},[1010],{"type":72,"value":1011}," sessions",{"type":66,"tag":150,"props":1013,"children":1014},{"style":163},[1015],{"type":72,"value":371},{"type":66,"tag":150,"props":1017,"children":1018},{"style":169},[1019],{"type":72,"value":1020}," chatId",{"type":66,"tag":150,"props":1022,"children":1023},{"style":163},[1024],{"type":72,"value":1025}," },",{"type":66,"tag":150,"props":1027,"children":1028},{"style":363},[1029],{"type":72,"value":1030}," write",{"type":66,"tag":150,"props":1032,"children":1033},{"style":163},[1034],{"type":72,"value":371},{"type":66,"tag":150,"props":1036,"children":1037},{"style":163},[1038],{"type":72,"value":166},{"type":66,"tag":150,"props":1040,"children":1041},{"style":363},[1042],{"type":72,"value":1011},{"type":66,"tag":150,"props":1044,"children":1045},{"style":163},[1046],{"type":72,"value":371},{"type":66,"tag":150,"props":1048,"children":1049},{"style":169},[1050],{"type":72,"value":1020},{"type":66,"tag":150,"props":1052,"children":1053},{"style":163},[1054],{"type":72,"value":177},{"type":66,"tag":150,"props":1056,"children":1057},{"style":163},[1058],{"type":72,"value":1059}," },\n",{"type":66,"tag":150,"props":1061,"children":1062},{"class":152,"line":542},[1063,1068,1072,1076,1081,1085],{"type":66,"tag":150,"props":1064,"children":1065},{"style":363},[1066],{"type":72,"value":1067},"    expirationTime",{"type":66,"tag":150,"props":1069,"children":1070},{"style":163},[1071],{"type":72,"value":371},{"type":66,"tag":150,"props":1073,"children":1074},{"style":163},[1075],{"type":72,"value":187},{"type":66,"tag":150,"props":1077,"children":1078},{"style":190},[1079],{"type":72,"value":1080},"1h",{"type":66,"tag":150,"props":1082,"children":1083},{"style":163},[1084],{"type":72,"value":198},{"type":66,"tag":150,"props":1086,"children":1087},{"style":163},[1088],{"type":72,"value":389},{"type":66,"tag":150,"props":1090,"children":1091},{"class":152,"line":555},[1092,1097,1101],{"type":66,"tag":150,"props":1093,"children":1094},{"style":163},[1095],{"type":72,"value":1096},"  }",{"type":66,"tag":150,"props":1098,"children":1099},{"style":363},[1100],{"type":72,"value":535},{"type":66,"tag":150,"props":1102,"children":1103},{"style":163},[1104],{"type":72,"value":203},{"type":66,"tag":150,"props":1106,"children":1107},{"class":152,"line":576},[1108],{"type":66,"tag":150,"props":1109,"children":1110},{"style":163},[1111],{"type":72,"value":1112},"}\n",{"type":66,"tag":131,"props":1114,"children":1116},{"id":1115},"_3-wire-the-frontend",[1117],{"type":72,"value":1118},"3. Wire the frontend",{"type":66,"tag":138,"props":1120,"children":1125},{"className":1121,"code":1122,"language":1123,"meta":1124,"style":144},"language-tsx shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\"use client\";\nimport { useState } from \"react\";\nimport { useChat } from \"@ai-sdk\u002Freact\";\nimport { useTriggerChatTransport } from \"@trigger.dev\u002Fsdk\u002Fchat\u002Freact\";\nimport type { myChat } from \"@\u002Ftrigger\u002Fchat\";\nimport { mintChatAccessToken, startChatSession } from \"@\u002Fapp\u002Factions\";\n\nexport function Chat() {\n  const transport = useTriggerChatTransport\u003Ctypeof myChat>({\n    task: \"my-chat\", \u002F\u002F typeof myChat gives compile-time task-id validation\n    accessToken: ({ chatId }) => mintChatAccessToken(chatId),\n    startSession: ({ chatId, clientData }) => startChatSession({ chatId, clientData }),\n  });\n\n  const { messages, sendMessage, stop, status } = useChat({ transport });\n  const [input, setInput] = useState(\"\");\n  \u002F\u002F render messages, a form that calls sendMessage({ text: input }),\n  \u002F\u002F and a Stop button (onClick={stop}) while status === \"streaming\".\n}\n","tsx","app\u002Fcomponents\u002Fchat.tsx",[1126],{"type":66,"tag":81,"props":1127,"children":1128},{"__ignoreMap":144},[1129,1149,1190,1231,1272,1318,1367,1374,1398,1442,1475,1524,1598,1613,1620,1698,1754,1763,1772],{"type":66,"tag":150,"props":1130,"children":1131},{"class":152,"line":153},[1132,1136,1141,1145],{"type":66,"tag":150,"props":1133,"children":1134},{"style":163},[1135],{"type":72,"value":198},{"type":66,"tag":150,"props":1137,"children":1138},{"style":190},[1139],{"type":72,"value":1140},"use client",{"type":66,"tag":150,"props":1142,"children":1143},{"style":163},[1144],{"type":72,"value":198},{"type":66,"tag":150,"props":1146,"children":1147},{"style":163},[1148],{"type":72,"value":203},{"type":66,"tag":150,"props":1150,"children":1151},{"class":152,"line":206},[1152,1156,1160,1165,1169,1173,1177,1182,1186],{"type":66,"tag":150,"props":1153,"children":1154},{"style":157},[1155],{"type":72,"value":160},{"type":66,"tag":150,"props":1157,"children":1158},{"style":163},[1159],{"type":72,"value":166},{"type":66,"tag":150,"props":1161,"children":1162},{"style":169},[1163],{"type":72,"value":1164}," useState",{"type":66,"tag":150,"props":1166,"children":1167},{"style":163},[1168],{"type":72,"value":177},{"type":66,"tag":150,"props":1170,"children":1171},{"style":157},[1172],{"type":72,"value":182},{"type":66,"tag":150,"props":1174,"children":1175},{"style":163},[1176],{"type":72,"value":187},{"type":66,"tag":150,"props":1178,"children":1179},{"style":190},[1180],{"type":72,"value":1181},"react",{"type":66,"tag":150,"props":1183,"children":1184},{"style":163},[1185],{"type":72,"value":198},{"type":66,"tag":150,"props":1187,"children":1188},{"style":163},[1189],{"type":72,"value":203},{"type":66,"tag":150,"props":1191,"children":1192},{"class":152,"line":257},[1193,1197,1201,1206,1210,1214,1218,1223,1227],{"type":66,"tag":150,"props":1194,"children":1195},{"style":157},[1196],{"type":72,"value":160},{"type":66,"tag":150,"props":1198,"children":1199},{"style":163},[1200],{"type":72,"value":166},{"type":66,"tag":150,"props":1202,"children":1203},{"style":169},[1204],{"type":72,"value":1205}," useChat",{"type":66,"tag":150,"props":1207,"children":1208},{"style":163},[1209],{"type":72,"value":177},{"type":66,"tag":150,"props":1211,"children":1212},{"style":157},[1213],{"type":72,"value":182},{"type":66,"tag":150,"props":1215,"children":1216},{"style":163},[1217],{"type":72,"value":187},{"type":66,"tag":150,"props":1219,"children":1220},{"style":190},[1221],{"type":72,"value":1222},"@ai-sdk\u002Freact",{"type":66,"tag":150,"props":1224,"children":1225},{"style":163},[1226],{"type":72,"value":198},{"type":66,"tag":150,"props":1228,"children":1229},{"style":163},[1230],{"type":72,"value":203},{"type":66,"tag":150,"props":1232,"children":1233},{"class":152,"line":299},[1234,1238,1242,1247,1251,1255,1259,1264,1268],{"type":66,"tag":150,"props":1235,"children":1236},{"style":157},[1237],{"type":72,"value":160},{"type":66,"tag":150,"props":1239,"children":1240},{"style":163},[1241],{"type":72,"value":166},{"type":66,"tag":150,"props":1243,"children":1244},{"style":169},[1245],{"type":72,"value":1246}," useTriggerChatTransport",{"type":66,"tag":150,"props":1248,"children":1249},{"style":163},[1250],{"type":72,"value":177},{"type":66,"tag":150,"props":1252,"children":1253},{"style":157},[1254],{"type":72,"value":182},{"type":66,"tag":150,"props":1256,"children":1257},{"style":163},[1258],{"type":72,"value":187},{"type":66,"tag":150,"props":1260,"children":1261},{"style":190},[1262],{"type":72,"value":1263},"@trigger.dev\u002Fsdk\u002Fchat\u002Freact",{"type":66,"tag":150,"props":1265,"children":1266},{"style":163},[1267],{"type":72,"value":198},{"type":66,"tag":150,"props":1269,"children":1270},{"style":163},[1271],{"type":72,"value":203},{"type":66,"tag":150,"props":1273,"children":1274},{"class":152,"line":309},[1275,1279,1284,1288,1293,1297,1301,1305,1310,1314],{"type":66,"tag":150,"props":1276,"children":1277},{"style":157},[1278],{"type":72,"value":160},{"type":66,"tag":150,"props":1280,"children":1281},{"style":157},[1282],{"type":72,"value":1283}," type",{"type":66,"tag":150,"props":1285,"children":1286},{"style":163},[1287],{"type":72,"value":166},{"type":66,"tag":150,"props":1289,"children":1290},{"style":169},[1291],{"type":72,"value":1292}," myChat",{"type":66,"tag":150,"props":1294,"children":1295},{"style":163},[1296],{"type":72,"value":177},{"type":66,"tag":150,"props":1298,"children":1299},{"style":157},[1300],{"type":72,"value":182},{"type":66,"tag":150,"props":1302,"children":1303},{"style":163},[1304],{"type":72,"value":187},{"type":66,"tag":150,"props":1306,"children":1307},{"style":190},[1308],{"type":72,"value":1309},"@\u002Ftrigger\u002Fchat",{"type":66,"tag":150,"props":1311,"children":1312},{"style":163},[1313],{"type":72,"value":198},{"type":66,"tag":150,"props":1315,"children":1316},{"style":163},[1317],{"type":72,"value":203},{"type":66,"tag":150,"props":1319,"children":1320},{"class":152,"line":359},[1321,1325,1329,1333,1337,1342,1346,1350,1354,1359,1363],{"type":66,"tag":150,"props":1322,"children":1323},{"style":157},[1324],{"type":72,"value":160},{"type":66,"tag":150,"props":1326,"children":1327},{"style":163},[1328],{"type":72,"value":166},{"type":66,"tag":150,"props":1330,"children":1331},{"style":169},[1332],{"type":72,"value":920},{"type":66,"tag":150,"props":1334,"children":1335},{"style":163},[1336],{"type":72,"value":225},{"type":66,"tag":150,"props":1338,"children":1339},{"style":169},[1340],{"type":72,"value":1341}," startChatSession",{"type":66,"tag":150,"props":1343,"children":1344},{"style":163},[1345],{"type":72,"value":177},{"type":66,"tag":150,"props":1347,"children":1348},{"style":157},[1349],{"type":72,"value":182},{"type":66,"tag":150,"props":1351,"children":1352},{"style":163},[1353],{"type":72,"value":187},{"type":66,"tag":150,"props":1355,"children":1356},{"style":190},[1357],{"type":72,"value":1358},"@\u002Fapp\u002Factions",{"type":66,"tag":150,"props":1360,"children":1361},{"style":163},[1362],{"type":72,"value":198},{"type":66,"tag":150,"props":1364,"children":1365},{"style":163},[1366],{"type":72,"value":203},{"type":66,"tag":150,"props":1368,"children":1369},{"class":152,"line":392},[1370],{"type":66,"tag":150,"props":1371,"children":1372},{"emptyLinePlaceholder":303},[1373],{"type":72,"value":306},{"type":66,"tag":150,"props":1375,"children":1376},{"class":152,"line":440},[1377,1381,1385,1390,1394],{"type":66,"tag":150,"props":1378,"children":1379},{"style":157},[1380],{"type":72,"value":315},{"type":66,"tag":150,"props":1382,"children":1383},{"style":318},[1384],{"type":72,"value":915},{"type":66,"tag":150,"props":1386,"children":1387},{"style":343},[1388],{"type":72,"value":1389}," Chat",{"type":66,"tag":150,"props":1391,"children":1392},{"style":163},[1393],{"type":72,"value":492},{"type":66,"tag":150,"props":1395,"children":1396},{"style":163},[1397],{"type":72,"value":948},{"type":66,"tag":150,"props":1399,"children":1400},{"class":152,"line":457},[1401,1406,1411,1416,1420,1425,1429,1434,1438],{"type":66,"tag":150,"props":1402,"children":1403},{"style":318},[1404],{"type":72,"value":1405},"  const",{"type":66,"tag":150,"props":1407,"children":1408},{"style":169},[1409],{"type":72,"value":1410}," transport",{"type":66,"tag":150,"props":1412,"children":1413},{"style":163},[1414],{"type":72,"value":1415}," =",{"type":66,"tag":150,"props":1417,"children":1418},{"style":343},[1419],{"type":72,"value":1246},{"type":66,"tag":150,"props":1421,"children":1422},{"style":163},[1423],{"type":72,"value":1424},"\u003Ctypeof",{"type":66,"tag":150,"props":1426,"children":1427},{"style":169},[1428],{"type":72,"value":1292},{"type":66,"tag":150,"props":1430,"children":1431},{"style":163},[1432],{"type":72,"value":1433},">",{"type":66,"tag":150,"props":1435,"children":1436},{"style":363},[1437],{"type":72,"value":351},{"type":66,"tag":150,"props":1439,"children":1440},{"style":163},[1441],{"type":72,"value":356},{"type":66,"tag":150,"props":1443,"children":1444},{"class":152,"line":467},[1445,1450,1454,1458,1462,1466,1470],{"type":66,"tag":150,"props":1446,"children":1447},{"style":363},[1448],{"type":72,"value":1449},"    task",{"type":66,"tag":150,"props":1451,"children":1452},{"style":163},[1453],{"type":72,"value":371},{"type":66,"tag":150,"props":1455,"children":1456},{"style":163},[1457],{"type":72,"value":187},{"type":66,"tag":150,"props":1459,"children":1460},{"style":190},[1461],{"type":72,"value":380},{"type":66,"tag":150,"props":1463,"children":1464},{"style":163},[1465],{"type":72,"value":198},{"type":66,"tag":150,"props":1467,"children":1468},{"style":163},[1469],{"type":72,"value":225},{"type":66,"tag":150,"props":1471,"children":1472},{"style":461},[1473],{"type":72,"value":1474}," \u002F\u002F typeof myChat gives compile-time task-id validation\n",{"type":66,"tag":150,"props":1476,"children":1477},{"class":152,"line":499},[1478,1483,1487,1491,1495,1499,1504,1508,1512,1516,1520],{"type":66,"tag":150,"props":1479,"children":1480},{"style":343},[1481],{"type":72,"value":1482},"    accessToken",{"type":66,"tag":150,"props":1484,"children":1485},{"style":163},[1486],{"type":72,"value":371},{"type":66,"tag":150,"props":1488,"children":1489},{"style":163},[1490],{"type":72,"value":412},{"type":66,"tag":150,"props":1492,"children":1493},{"style":415},[1494],{"type":72,"value":1020},{"type":66,"tag":150,"props":1496,"children":1497},{"style":163},[1498],{"type":72,"value":432},{"type":66,"tag":150,"props":1500,"children":1501},{"style":318},[1502],{"type":72,"value":1503}," =>",{"type":66,"tag":150,"props":1505,"children":1506},{"style":343},[1507],{"type":72,"value":920},{"type":66,"tag":150,"props":1509,"children":1510},{"style":363},[1511],{"type":72,"value":351},{"type":66,"tag":150,"props":1513,"children":1514},{"style":169},[1515],{"type":72,"value":929},{"type":66,"tag":150,"props":1517,"children":1518},{"style":363},[1519],{"type":72,"value":535},{"type":66,"tag":150,"props":1521,"children":1522},{"style":163},[1523],{"type":72,"value":389},{"type":66,"tag":150,"props":1525,"children":1526},{"class":152,"line":542},[1527,1532,1536,1540,1544,1548,1553,1557,1561,1565,1569,1574,1578,1582,1586,1590,1594],{"type":66,"tag":150,"props":1528,"children":1529},{"style":343},[1530],{"type":72,"value":1531},"    startSession",{"type":66,"tag":150,"props":1533,"children":1534},{"style":163},[1535],{"type":72,"value":371},{"type":66,"tag":150,"props":1537,"children":1538},{"style":163},[1539],{"type":72,"value":412},{"type":66,"tag":150,"props":1541,"children":1542},{"style":415},[1543],{"type":72,"value":1020},{"type":66,"tag":150,"props":1545,"children":1546},{"style":163},[1547],{"type":72,"value":225},{"type":66,"tag":150,"props":1549,"children":1550},{"style":415},[1551],{"type":72,"value":1552}," clientData",{"type":66,"tag":150,"props":1554,"children":1555},{"style":163},[1556],{"type":72,"value":432},{"type":66,"tag":150,"props":1558,"children":1559},{"style":318},[1560],{"type":72,"value":1503},{"type":66,"tag":150,"props":1562,"children":1563},{"style":343},[1564],{"type":72,"value":1341},{"type":66,"tag":150,"props":1566,"children":1567},{"style":363},[1568],{"type":72,"value":351},{"type":66,"tag":150,"props":1570,"children":1571},{"style":163},[1572],{"type":72,"value":1573},"{",{"type":66,"tag":150,"props":1575,"children":1576},{"style":169},[1577],{"type":72,"value":1020},{"type":66,"tag":150,"props":1579,"children":1580},{"style":163},[1581],{"type":72,"value":225},{"type":66,"tag":150,"props":1583,"children":1584},{"style":169},[1585],{"type":72,"value":1552},{"type":66,"tag":150,"props":1587,"children":1588},{"style":163},[1589],{"type":72,"value":177},{"type":66,"tag":150,"props":1591,"children":1592},{"style":363},[1593],{"type":72,"value":535},{"type":66,"tag":150,"props":1595,"children":1596},{"style":163},[1597],{"type":72,"value":389},{"type":66,"tag":150,"props":1599,"children":1600},{"class":152,"line":555},[1601,1605,1609],{"type":66,"tag":150,"props":1602,"children":1603},{"style":163},[1604],{"type":72,"value":1096},{"type":66,"tag":150,"props":1606,"children":1607},{"style":363},[1608],{"type":72,"value":535},{"type":66,"tag":150,"props":1610,"children":1611},{"style":163},[1612],{"type":72,"value":203},{"type":66,"tag":150,"props":1614,"children":1615},{"class":152,"line":576},[1616],{"type":66,"tag":150,"props":1617,"children":1618},{"emptyLinePlaceholder":303},[1619],{"type":72,"value":306},{"type":66,"tag":150,"props":1621,"children":1622},{"class":152,"line":611},[1623,1627,1631,1635,1639,1644,1648,1653,1657,1662,1666,1670,1674,1678,1682,1686,1690,1694],{"type":66,"tag":150,"props":1624,"children":1625},{"style":318},[1626],{"type":72,"value":1405},{"type":66,"tag":150,"props":1628,"children":1629},{"style":163},[1630],{"type":72,"value":166},{"type":66,"tag":150,"props":1632,"children":1633},{"style":169},[1634],{"type":72,"value":418},{"type":66,"tag":150,"props":1636,"children":1637},{"style":163},[1638],{"type":72,"value":225},{"type":66,"tag":150,"props":1640,"children":1641},{"style":169},[1642],{"type":72,"value":1643}," sendMessage",{"type":66,"tag":150,"props":1645,"children":1646},{"style":163},[1647],{"type":72,"value":225},{"type":66,"tag":150,"props":1649,"children":1650},{"style":169},[1651],{"type":72,"value":1652}," stop",{"type":66,"tag":150,"props":1654,"children":1655},{"style":163},[1656],{"type":72,"value":225},{"type":66,"tag":150,"props":1658,"children":1659},{"style":169},[1660],{"type":72,"value":1661}," status",{"type":66,"tag":150,"props":1663,"children":1664},{"style":163},[1665],{"type":72,"value":177},{"type":66,"tag":150,"props":1667,"children":1668},{"style":163},[1669],{"type":72,"value":1415},{"type":66,"tag":150,"props":1671,"children":1672},{"style":343},[1673],{"type":72,"value":1205},{"type":66,"tag":150,"props":1675,"children":1676},{"style":363},[1677],{"type":72,"value":351},{"type":66,"tag":150,"props":1679,"children":1680},{"style":163},[1681],{"type":72,"value":1573},{"type":66,"tag":150,"props":1683,"children":1684},{"style":169},[1685],{"type":72,"value":1410},{"type":66,"tag":150,"props":1687,"children":1688},{"style":163},[1689],{"type":72,"value":177},{"type":66,"tag":150,"props":1691,"children":1692},{"style":363},[1693],{"type":72,"value":535},{"type":66,"tag":150,"props":1695,"children":1696},{"style":163},[1697],{"type":72,"value":203},{"type":66,"tag":150,"props":1699,"children":1700},{"class":152,"line":628},[1701,1705,1710,1715,1719,1724,1729,1733,1737,1741,1746,1750],{"type":66,"tag":150,"props":1702,"children":1703},{"style":318},[1704],{"type":72,"value":1405},{"type":66,"tag":150,"props":1706,"children":1707},{"style":163},[1708],{"type":72,"value":1709}," [",{"type":66,"tag":150,"props":1711,"children":1712},{"style":169},[1713],{"type":72,"value":1714},"input",{"type":66,"tag":150,"props":1716,"children":1717},{"style":163},[1718],{"type":72,"value":225},{"type":66,"tag":150,"props":1720,"children":1721},{"style":169},[1722],{"type":72,"value":1723}," setInput",{"type":66,"tag":150,"props":1725,"children":1726},{"style":163},[1727],{"type":72,"value":1728},"]",{"type":66,"tag":150,"props":1730,"children":1731},{"style":163},[1732],{"type":72,"value":1415},{"type":66,"tag":150,"props":1734,"children":1735},{"style":343},[1736],{"type":72,"value":1164},{"type":66,"tag":150,"props":1738,"children":1739},{"style":363},[1740],{"type":72,"value":351},{"type":66,"tag":150,"props":1742,"children":1743},{"style":163},[1744],{"type":72,"value":1745},"\"\"",{"type":66,"tag":150,"props":1747,"children":1748},{"style":363},[1749],{"type":72,"value":535},{"type":66,"tag":150,"props":1751,"children":1752},{"style":163},[1753],{"type":72,"value":203},{"type":66,"tag":150,"props":1755,"children":1757},{"class":152,"line":1756},17,[1758],{"type":66,"tag":150,"props":1759,"children":1760},{"style":461},[1761],{"type":72,"value":1762},"  \u002F\u002F render messages, a form that calls sendMessage({ text: input }),\n",{"type":66,"tag":150,"props":1764,"children":1766},{"class":152,"line":1765},18,[1767],{"type":66,"tag":150,"props":1768,"children":1769},{"style":461},[1770],{"type":72,"value":1771},"  \u002F\u002F and a Stop button (onClick={stop}) while status === \"streaming\".\n",{"type":66,"tag":150,"props":1773,"children":1775},{"class":152,"line":1774},19,[1776],{"type":66,"tag":150,"props":1777,"children":1778},{"style":163},[1779],{"type":72,"value":1112},{"type":66,"tag":75,"props":1781,"children":1782},{},[1783,1785,1791,1793,1799],{"type":72,"value":1784},"The transport is memoized (created once, reused across renders). Passing ",{"type":66,"tag":81,"props":1786,"children":1788},{"className":1787},[],[1789],{"type":72,"value":1790},"typeof myChat",{"type":72,"value":1792}," flows the\nagent's message type through ",{"type":66,"tag":81,"props":1794,"children":1796},{"className":1795},[],[1797],{"type":72,"value":1798},"useChat",{"type":72,"value":340},{"type":66,"tag":119,"props":1801,"children":1803},{"id":1802},"core-patterns",[1804],{"type":72,"value":1805},"Core patterns",{"type":66,"tag":131,"props":1807,"children":1809},{"id":1808},"_1-return-vs-pipe",[1810],{"type":72,"value":1811},"1. Return vs pipe",{"type":66,"tag":75,"props":1813,"children":1814},{},[1815,1817,1822,1824,1829,1831,1836,1838,1844,1846,1851,1853,1859],{"type":72,"value":1816},"Return the ",{"type":66,"tag":81,"props":1818,"children":1820},{"className":1819},[],[1821],{"type":72,"value":94},{"type":72,"value":1823}," result from ",{"type":66,"tag":81,"props":1825,"children":1827},{"className":1826},[],[1828],{"type":72,"value":651},{"type":72,"value":1830}," for the simple case. When ",{"type":66,"tag":81,"props":1832,"children":1834},{"className":1833},[],[1835],{"type":72,"value":94},{"type":72,"value":1837}," is called deep\ninside nested helpers, call ",{"type":66,"tag":81,"props":1839,"children":1841},{"className":1840},[],[1842],{"type":72,"value":1843},"await chat.pipe(result)",{"type":72,"value":1845}," from anywhere in the task instead, and let\n",{"type":66,"tag":81,"props":1847,"children":1849},{"className":1848},[],[1850],{"type":72,"value":651},{"type":72,"value":1852}," resolve ",{"type":66,"tag":81,"props":1854,"children":1856},{"className":1855},[],[1857],{"type":72,"value":1858},"void",{"type":72,"value":340},{"type":66,"tag":138,"props":1861,"children":1863},{"className":140,"code":1862,"language":142,"meta":144,"style":144},"export const agentChat = chat.agent({\n  id: \"agent-chat\",\n  run: async ({ messages }) => {\n    await runAgentLoop(messages); \u002F\u002F don't return; pipe inside\n  },\n});\n\nasync function runAgentLoop(messages: ModelMessage[]) {\n  const result = streamText({\n    ...chat.toStreamTextOptions(),\n    model: anthropic(\"claude-sonnet-4-5\"),\n    messages,\n  });\n  await chat.pipe(result); \u002F\u002F works from anywhere in the task\n}\n",[1864],{"type":66,"tag":81,"props":1865,"children":1866},{"__ignoreMap":144},[1867,1907,1935,1970,2005,2013,2028,2035,2081,2109,2137,2177,2189,2204,2247],{"type":66,"tag":150,"props":1868,"children":1869},{"class":152,"line":153},[1870,1874,1878,1883,1887,1891,1895,1899,1903],{"type":66,"tag":150,"props":1871,"children":1872},{"style":157},[1873],{"type":72,"value":315},{"type":66,"tag":150,"props":1875,"children":1876},{"style":318},[1877],{"type":72,"value":321},{"type":66,"tag":150,"props":1879,"children":1880},{"style":169},[1881],{"type":72,"value":1882}," agentChat ",{"type":66,"tag":150,"props":1884,"children":1885},{"style":163},[1886],{"type":72,"value":331},{"type":66,"tag":150,"props":1888,"children":1889},{"style":169},[1890],{"type":72,"value":172},{"type":66,"tag":150,"props":1892,"children":1893},{"style":163},[1894],{"type":72,"value":340},{"type":66,"tag":150,"props":1896,"children":1897},{"style":343},[1898],{"type":72,"value":346},{"type":66,"tag":150,"props":1900,"children":1901},{"style":169},[1902],{"type":72,"value":351},{"type":66,"tag":150,"props":1904,"children":1905},{"style":163},[1906],{"type":72,"value":356},{"type":66,"tag":150,"props":1908,"children":1909},{"class":152,"line":206},[1910,1914,1918,1922,1927,1931],{"type":66,"tag":150,"props":1911,"children":1912},{"style":363},[1913],{"type":72,"value":366},{"type":66,"tag":150,"props":1915,"children":1916},{"style":163},[1917],{"type":72,"value":371},{"type":66,"tag":150,"props":1919,"children":1920},{"style":163},[1921],{"type":72,"value":187},{"type":66,"tag":150,"props":1923,"children":1924},{"style":190},[1925],{"type":72,"value":1926},"agent-chat",{"type":66,"tag":150,"props":1928,"children":1929},{"style":163},[1930],{"type":72,"value":198},{"type":66,"tag":150,"props":1932,"children":1933},{"style":163},[1934],{"type":72,"value":389},{"type":66,"tag":150,"props":1936,"children":1937},{"class":152,"line":257},[1938,1942,1946,1950,1954,1958,1962,1966],{"type":66,"tag":150,"props":1939,"children":1940},{"style":343},[1941],{"type":72,"value":398},{"type":66,"tag":150,"props":1943,"children":1944},{"style":163},[1945],{"type":72,"value":371},{"type":66,"tag":150,"props":1947,"children":1948},{"style":318},[1949],{"type":72,"value":407},{"type":66,"tag":150,"props":1951,"children":1952},{"style":163},[1953],{"type":72,"value":412},{"type":66,"tag":150,"props":1955,"children":1956},{"style":415},[1957],{"type":72,"value":418},{"type":66,"tag":150,"props":1959,"children":1960},{"style":163},[1961],{"type":72,"value":432},{"type":66,"tag":150,"props":1963,"children":1964},{"style":318},[1965],{"type":72,"value":1503},{"type":66,"tag":150,"props":1967,"children":1968},{"style":163},[1969],{"type":72,"value":948},{"type":66,"tag":150,"props":1971,"children":1972},{"class":152,"line":299},[1973,1978,1983,1987,1991,1995,2000],{"type":66,"tag":150,"props":1974,"children":1975},{"style":157},[1976],{"type":72,"value":1977},"    await",{"type":66,"tag":150,"props":1979,"children":1980},{"style":343},[1981],{"type":72,"value":1982}," runAgentLoop",{"type":66,"tag":150,"props":1984,"children":1985},{"style":363},[1986],{"type":72,"value":351},{"type":66,"tag":150,"props":1988,"children":1989},{"style":169},[1990],{"type":72,"value":659},{"type":66,"tag":150,"props":1992,"children":1993},{"style":363},[1994],{"type":72,"value":535},{"type":66,"tag":150,"props":1996,"children":1997},{"style":163},[1998],{"type":72,"value":1999},";",{"type":66,"tag":150,"props":2001,"children":2002},{"style":461},[2003],{"type":72,"value":2004}," \u002F\u002F don't return; pipe inside\n",{"type":66,"tag":150,"props":2006,"children":2007},{"class":152,"line":309},[2008],{"type":66,"tag":150,"props":2009,"children":2010},{"style":163},[2011],{"type":72,"value":2012},"  },\n",{"type":66,"tag":150,"props":2014,"children":2015},{"class":152,"line":359},[2016,2020,2024],{"type":66,"tag":150,"props":2017,"children":2018},{"style":163},[2019],{"type":72,"value":634},{"type":66,"tag":150,"props":2021,"children":2022},{"style":169},[2023],{"type":72,"value":535},{"type":66,"tag":150,"props":2025,"children":2026},{"style":163},[2027],{"type":72,"value":203},{"type":66,"tag":150,"props":2029,"children":2030},{"class":152,"line":392},[2031],{"type":66,"tag":150,"props":2032,"children":2033},{"emptyLinePlaceholder":303},[2034],{"type":72,"value":306},{"type":66,"tag":150,"props":2036,"children":2037},{"class":152,"line":440},[2038,2043,2047,2051,2055,2059,2063,2068,2073,2077],{"type":66,"tag":150,"props":2039,"children":2040},{"style":318},[2041],{"type":72,"value":2042},"async",{"type":66,"tag":150,"props":2044,"children":2045},{"style":318},[2046],{"type":72,"value":915},{"type":66,"tag":150,"props":2048,"children":2049},{"style":343},[2050],{"type":72,"value":1982},{"type":66,"tag":150,"props":2052,"children":2053},{"style":163},[2054],{"type":72,"value":351},{"type":66,"tag":150,"props":2056,"children":2057},{"style":415},[2058],{"type":72,"value":659},{"type":66,"tag":150,"props":2060,"children":2061},{"style":163},[2062],{"type":72,"value":371},{"type":66,"tag":150,"props":2064,"children":2065},{"style":936},[2066],{"type":72,"value":2067}," ModelMessage",{"type":66,"tag":150,"props":2069,"children":2070},{"style":169},[2071],{"type":72,"value":2072},"[]",{"type":66,"tag":150,"props":2074,"children":2075},{"style":163},[2076],{"type":72,"value":535},{"type":66,"tag":150,"props":2078,"children":2079},{"style":163},[2080],{"type":72,"value":948},{"type":66,"tag":150,"props":2082,"children":2083},{"class":152,"line":457},[2084,2088,2093,2097,2101,2105],{"type":66,"tag":150,"props":2085,"children":2086},{"style":318},[2087],{"type":72,"value":1405},{"type":66,"tag":150,"props":2089,"children":2090},{"style":169},[2091],{"type":72,"value":2092}," result",{"type":66,"tag":150,"props":2094,"children":2095},{"style":163},[2096],{"type":72,"value":1415},{"type":66,"tag":150,"props":2098,"children":2099},{"style":343},[2100],{"type":72,"value":220},{"type":66,"tag":150,"props":2102,"children":2103},{"style":363},[2104],{"type":72,"value":351},{"type":66,"tag":150,"props":2106,"children":2107},{"style":163},[2108],{"type":72,"value":356},{"type":66,"tag":150,"props":2110,"children":2111},{"class":152,"line":467},[2112,2117,2121,2125,2129,2133],{"type":66,"tag":150,"props":2113,"children":2114},{"style":163},[2115],{"type":72,"value":2116},"    ...",{"type":66,"tag":150,"props":2118,"children":2119},{"style":169},[2120],{"type":72,"value":478},{"type":66,"tag":150,"props":2122,"children":2123},{"style":163},[2124],{"type":72,"value":340},{"type":66,"tag":150,"props":2126,"children":2127},{"style":343},[2128],{"type":72,"value":487},{"type":66,"tag":150,"props":2130,"children":2131},{"style":363},[2132],{"type":72,"value":492},{"type":66,"tag":150,"props":2134,"children":2135},{"style":163},[2136],{"type":72,"value":389},{"type":66,"tag":150,"props":2138,"children":2139},{"class":152,"line":499},[2140,2145,2149,2153,2157,2161,2165,2169,2173],{"type":66,"tag":150,"props":2141,"children":2142},{"style":363},[2143],{"type":72,"value":2144},"    model",{"type":66,"tag":150,"props":2146,"children":2147},{"style":163},[2148],{"type":72,"value":371},{"type":66,"tag":150,"props":2150,"children":2151},{"style":343},[2152],{"type":72,"value":271},{"type":66,"tag":150,"props":2154,"children":2155},{"style":363},[2156],{"type":72,"value":351},{"type":66,"tag":150,"props":2158,"children":2159},{"style":163},[2160],{"type":72,"value":198},{"type":66,"tag":150,"props":2162,"children":2163},{"style":190},[2164],{"type":72,"value":526},{"type":66,"tag":150,"props":2166,"children":2167},{"style":163},[2168],{"type":72,"value":198},{"type":66,"tag":150,"props":2170,"children":2171},{"style":363},[2172],{"type":72,"value":535},{"type":66,"tag":150,"props":2174,"children":2175},{"style":163},[2176],{"type":72,"value":389},{"type":66,"tag":150,"props":2178,"children":2179},{"class":152,"line":542},[2180,2185],{"type":66,"tag":150,"props":2181,"children":2182},{"style":169},[2183],{"type":72,"value":2184},"    messages",{"type":66,"tag":150,"props":2186,"children":2187},{"style":163},[2188],{"type":72,"value":389},{"type":66,"tag":150,"props":2190,"children":2191},{"class":152,"line":555},[2192,2196,2200],{"type":66,"tag":150,"props":2193,"children":2194},{"style":163},[2195],{"type":72,"value":1096},{"type":66,"tag":150,"props":2197,"children":2198},{"style":363},[2199],{"type":72,"value":535},{"type":66,"tag":150,"props":2201,"children":2202},{"style":163},[2203],{"type":72,"value":203},{"type":66,"tag":150,"props":2205,"children":2206},{"class":152,"line":576},[2207,2212,2216,2220,2225,2229,2234,2238,2242],{"type":66,"tag":150,"props":2208,"children":2209},{"style":157},[2210],{"type":72,"value":2211},"  await",{"type":66,"tag":150,"props":2213,"children":2214},{"style":169},[2215],{"type":72,"value":172},{"type":66,"tag":150,"props":2217,"children":2218},{"style":163},[2219],{"type":72,"value":340},{"type":66,"tag":150,"props":2221,"children":2222},{"style":343},[2223],{"type":72,"value":2224},"pipe",{"type":66,"tag":150,"props":2226,"children":2227},{"style":363},[2228],{"type":72,"value":351},{"type":66,"tag":150,"props":2230,"children":2231},{"style":169},[2232],{"type":72,"value":2233},"result",{"type":66,"tag":150,"props":2235,"children":2236},{"style":363},[2237],{"type":72,"value":535},{"type":66,"tag":150,"props":2239,"children":2240},{"style":163},[2241],{"type":72,"value":1999},{"type":66,"tag":150,"props":2243,"children":2244},{"style":461},[2245],{"type":72,"value":2246}," \u002F\u002F works from anywhere in the task\n",{"type":66,"tag":150,"props":2248,"children":2249},{"class":152,"line":611},[2250],{"type":66,"tag":150,"props":2251,"children":2252},{"style":163},[2253],{"type":72,"value":1112},{"type":66,"tag":131,"props":2255,"children":2257},{"id":2256},"_2-typed-tools-declare-on-config-and-spread-back",[2258],{"type":72,"value":2259},"2. Typed tools (declare on config AND spread back)",{"type":66,"tag":75,"props":2261,"children":2262},{},[2263,2265,2271,2273,2279,2281,2287],{"type":72,"value":2264},"Declare tools on ",{"type":66,"tag":81,"props":2266,"children":2268},{"className":2267},[],[2269],{"type":72,"value":2270},"chat.agent({ tools })",{"type":72,"value":2272},", read them back typed from the ",{"type":66,"tag":81,"props":2274,"children":2276},{"className":2275},[],[2277],{"type":72,"value":2278},"run()",{"type":72,"value":2280}," payload, and pass\nthat set to ",{"type":66,"tag":81,"props":2282,"children":2284},{"className":2283},[],[2285],{"type":72,"value":2286},"chat.toStreamTextOptions({ tools })",{"type":72,"value":2288},". One declaration flows everywhere.",{"type":66,"tag":138,"props":2290,"children":2292},{"className":140,"code":2291,"language":142,"meta":144,"style":144},"import { tool, stepCountIs } from \"ai\";\nimport { z } from \"zod\";\n\nconst tools = {\n  searchDocs: tool({\n    description: \"Search the docs.\",\n    inputSchema: z.object({ query: z.string() }),\n    execute: async ({ query }) => searchIndex(query),\n  }),\n};\n\nexport const myChat = chat.agent({\n  id: \"my-chat\",\n  tools, \u002F\u002F so toModelOutput survives across turns\n  run: async ({ messages, tools, signal }) =>\n    streamText({\n      ...chat.toStreamTextOptions({ tools }), \u002F\u002F same set, handed back typed\n      model: anthropic(\"claude-sonnet-4-5\"),\n      messages,\n      abortSignal: signal,\n      stopWhen: stepCountIs(15),\n    }),\n});\n",[2293],{"type":66,"tag":81,"props":2294,"children":2295},{"__ignoreMap":144},[2296,2344,2385,2392,2413,2437,2466,2538,2584,2599,2607,2614,2653,2680,2697,2745,2760,2808,2847,2858,2878,2910,2926],{"type":66,"tag":150,"props":2297,"children":2298},{"class":152,"line":153},[2299,2303,2307,2312,2316,2320,2324,2328,2332,2336,2340],{"type":66,"tag":150,"props":2300,"children":2301},{"style":157},[2302],{"type":72,"value":160},{"type":66,"tag":150,"props":2304,"children":2305},{"style":163},[2306],{"type":72,"value":166},{"type":66,"tag":150,"props":2308,"children":2309},{"style":169},[2310],{"type":72,"value":2311}," tool",{"type":66,"tag":150,"props":2313,"children":2314},{"style":163},[2315],{"type":72,"value":225},{"type":66,"tag":150,"props":2317,"children":2318},{"style":169},[2319],{"type":72,"value":230},{"type":66,"tag":150,"props":2321,"children":2322},{"style":163},[2323],{"type":72,"value":177},{"type":66,"tag":150,"props":2325,"children":2326},{"style":157},[2327],{"type":72,"value":182},{"type":66,"tag":150,"props":2329,"children":2330},{"style":163},[2331],{"type":72,"value":187},{"type":66,"tag":150,"props":2333,"children":2334},{"style":190},[2335],{"type":72,"value":30},{"type":66,"tag":150,"props":2337,"children":2338},{"style":163},[2339],{"type":72,"value":198},{"type":66,"tag":150,"props":2341,"children":2342},{"style":163},[2343],{"type":72,"value":203},{"type":66,"tag":150,"props":2345,"children":2346},{"class":152,"line":206},[2347,2351,2355,2360,2364,2368,2372,2377,2381],{"type":66,"tag":150,"props":2348,"children":2349},{"style":157},[2350],{"type":72,"value":160},{"type":66,"tag":150,"props":2352,"children":2353},{"style":163},[2354],{"type":72,"value":166},{"type":66,"tag":150,"props":2356,"children":2357},{"style":169},[2358],{"type":72,"value":2359}," z",{"type":66,"tag":150,"props":2361,"children":2362},{"style":163},[2363],{"type":72,"value":177},{"type":66,"tag":150,"props":2365,"children":2366},{"style":157},[2367],{"type":72,"value":182},{"type":66,"tag":150,"props":2369,"children":2370},{"style":163},[2371],{"type":72,"value":187},{"type":66,"tag":150,"props":2373,"children":2374},{"style":190},[2375],{"type":72,"value":2376},"zod",{"type":66,"tag":150,"props":2378,"children":2379},{"style":163},[2380],{"type":72,"value":198},{"type":66,"tag":150,"props":2382,"children":2383},{"style":163},[2384],{"type":72,"value":203},{"type":66,"tag":150,"props":2386,"children":2387},{"class":152,"line":257},[2388],{"type":66,"tag":150,"props":2389,"children":2390},{"emptyLinePlaceholder":303},[2391],{"type":72,"value":306},{"type":66,"tag":150,"props":2393,"children":2394},{"class":152,"line":299},[2395,2400,2405,2409],{"type":66,"tag":150,"props":2396,"children":2397},{"style":318},[2398],{"type":72,"value":2399},"const",{"type":66,"tag":150,"props":2401,"children":2402},{"style":169},[2403],{"type":72,"value":2404}," tools ",{"type":66,"tag":150,"props":2406,"children":2407},{"style":163},[2408],{"type":72,"value":331},{"type":66,"tag":150,"props":2410,"children":2411},{"style":163},[2412],{"type":72,"value":948},{"type":66,"tag":150,"props":2414,"children":2415},{"class":152,"line":309},[2416,2421,2425,2429,2433],{"type":66,"tag":150,"props":2417,"children":2418},{"style":363},[2419],{"type":72,"value":2420},"  searchDocs",{"type":66,"tag":150,"props":2422,"children":2423},{"style":163},[2424],{"type":72,"value":371},{"type":66,"tag":150,"props":2426,"children":2427},{"style":343},[2428],{"type":72,"value":2311},{"type":66,"tag":150,"props":2430,"children":2431},{"style":169},[2432],{"type":72,"value":351},{"type":66,"tag":150,"props":2434,"children":2435},{"style":163},[2436],{"type":72,"value":356},{"type":66,"tag":150,"props":2438,"children":2439},{"class":152,"line":359},[2440,2445,2449,2453,2458,2462],{"type":66,"tag":150,"props":2441,"children":2442},{"style":363},[2443],{"type":72,"value":2444},"    description",{"type":66,"tag":150,"props":2446,"children":2447},{"style":163},[2448],{"type":72,"value":371},{"type":66,"tag":150,"props":2450,"children":2451},{"style":163},[2452],{"type":72,"value":187},{"type":66,"tag":150,"props":2454,"children":2455},{"style":190},[2456],{"type":72,"value":2457},"Search the docs.",{"type":66,"tag":150,"props":2459,"children":2460},{"style":163},[2461],{"type":72,"value":198},{"type":66,"tag":150,"props":2463,"children":2464},{"style":163},[2465],{"type":72,"value":389},{"type":66,"tag":150,"props":2467,"children":2468},{"class":152,"line":392},[2469,2474,2478,2482,2486,2491,2495,2499,2504,2508,2512,2516,2521,2526,2530,2534],{"type":66,"tag":150,"props":2470,"children":2471},{"style":363},[2472],{"type":72,"value":2473},"    inputSchema",{"type":66,"tag":150,"props":2475,"children":2476},{"style":163},[2477],{"type":72,"value":371},{"type":66,"tag":150,"props":2479,"children":2480},{"style":169},[2481],{"type":72,"value":2359},{"type":66,"tag":150,"props":2483,"children":2484},{"style":163},[2485],{"type":72,"value":340},{"type":66,"tag":150,"props":2487,"children":2488},{"style":343},[2489],{"type":72,"value":2490},"object",{"type":66,"tag":150,"props":2492,"children":2493},{"style":169},[2494],{"type":72,"value":351},{"type":66,"tag":150,"props":2496,"children":2497},{"style":163},[2498],{"type":72,"value":1573},{"type":66,"tag":150,"props":2500,"children":2501},{"style":363},[2502],{"type":72,"value":2503}," query",{"type":66,"tag":150,"props":2505,"children":2506},{"style":163},[2507],{"type":72,"value":371},{"type":66,"tag":150,"props":2509,"children":2510},{"style":169},[2511],{"type":72,"value":2359},{"type":66,"tag":150,"props":2513,"children":2514},{"style":163},[2515],{"type":72,"value":340},{"type":66,"tag":150,"props":2517,"children":2518},{"style":343},[2519],{"type":72,"value":2520},"string",{"type":66,"tag":150,"props":2522,"children":2523},{"style":169},[2524],{"type":72,"value":2525},"() ",{"type":66,"tag":150,"props":2527,"children":2528},{"style":163},[2529],{"type":72,"value":634},{"type":66,"tag":150,"props":2531,"children":2532},{"style":169},[2533],{"type":72,"value":535},{"type":66,"tag":150,"props":2535,"children":2536},{"style":163},[2537],{"type":72,"value":389},{"type":66,"tag":150,"props":2539,"children":2540},{"class":152,"line":440},[2541,2546,2550,2554,2558,2562,2566,2570,2575,2580],{"type":66,"tag":150,"props":2542,"children":2543},{"style":343},[2544],{"type":72,"value":2545},"    execute",{"type":66,"tag":150,"props":2547,"children":2548},{"style":163},[2549],{"type":72,"value":371},{"type":66,"tag":150,"props":2551,"children":2552},{"style":318},[2553],{"type":72,"value":407},{"type":66,"tag":150,"props":2555,"children":2556},{"style":163},[2557],{"type":72,"value":412},{"type":66,"tag":150,"props":2559,"children":2560},{"style":415},[2561],{"type":72,"value":2503},{"type":66,"tag":150,"props":2563,"children":2564},{"style":163},[2565],{"type":72,"value":432},{"type":66,"tag":150,"props":2567,"children":2568},{"style":318},[2569],{"type":72,"value":1503},{"type":66,"tag":150,"props":2571,"children":2572},{"style":343},[2573],{"type":72,"value":2574}," searchIndex",{"type":66,"tag":150,"props":2576,"children":2577},{"style":169},[2578],{"type":72,"value":2579},"(query)",{"type":66,"tag":150,"props":2581,"children":2582},{"style":163},[2583],{"type":72,"value":389},{"type":66,"tag":150,"props":2585,"children":2586},{"class":152,"line":457},[2587,2591,2595],{"type":66,"tag":150,"props":2588,"children":2589},{"style":163},[2590],{"type":72,"value":1096},{"type":66,"tag":150,"props":2592,"children":2593},{"style":169},[2594],{"type":72,"value":535},{"type":66,"tag":150,"props":2596,"children":2597},{"style":163},[2598],{"type":72,"value":389},{"type":66,"tag":150,"props":2600,"children":2601},{"class":152,"line":467},[2602],{"type":66,"tag":150,"props":2603,"children":2604},{"style":163},[2605],{"type":72,"value":2606},"};\n",{"type":66,"tag":150,"props":2608,"children":2609},{"class":152,"line":499},[2610],{"type":66,"tag":150,"props":2611,"children":2612},{"emptyLinePlaceholder":303},[2613],{"type":72,"value":306},{"type":66,"tag":150,"props":2615,"children":2616},{"class":152,"line":542},[2617,2621,2625,2629,2633,2637,2641,2645,2649],{"type":66,"tag":150,"props":2618,"children":2619},{"style":157},[2620],{"type":72,"value":315},{"type":66,"tag":150,"props":2622,"children":2623},{"style":318},[2624],{"type":72,"value":321},{"type":66,"tag":150,"props":2626,"children":2627},{"style":169},[2628],{"type":72,"value":326},{"type":66,"tag":150,"props":2630,"children":2631},{"style":163},[2632],{"type":72,"value":331},{"type":66,"tag":150,"props":2634,"children":2635},{"style":169},[2636],{"type":72,"value":172},{"type":66,"tag":150,"props":2638,"children":2639},{"style":163},[2640],{"type":72,"value":340},{"type":66,"tag":150,"props":2642,"children":2643},{"style":343},[2644],{"type":72,"value":346},{"type":66,"tag":150,"props":2646,"children":2647},{"style":169},[2648],{"type":72,"value":351},{"type":66,"tag":150,"props":2650,"children":2651},{"style":163},[2652],{"type":72,"value":356},{"type":66,"tag":150,"props":2654,"children":2655},{"class":152,"line":555},[2656,2660,2664,2668,2672,2676],{"type":66,"tag":150,"props":2657,"children":2658},{"style":363},[2659],{"type":72,"value":366},{"type":66,"tag":150,"props":2661,"children":2662},{"style":163},[2663],{"type":72,"value":371},{"type":66,"tag":150,"props":2665,"children":2666},{"style":163},[2667],{"type":72,"value":187},{"type":66,"tag":150,"props":2669,"children":2670},{"style":190},[2671],{"type":72,"value":380},{"type":66,"tag":150,"props":2673,"children":2674},{"style":163},[2675],{"type":72,"value":198},{"type":66,"tag":150,"props":2677,"children":2678},{"style":163},[2679],{"type":72,"value":389},{"type":66,"tag":150,"props":2681,"children":2682},{"class":152,"line":576},[2683,2688,2692],{"type":66,"tag":150,"props":2684,"children":2685},{"style":169},[2686],{"type":72,"value":2687},"  tools",{"type":66,"tag":150,"props":2689,"children":2690},{"style":163},[2691],{"type":72,"value":225},{"type":66,"tag":150,"props":2693,"children":2694},{"style":461},[2695],{"type":72,"value":2696}," \u002F\u002F so toModelOutput survives across turns\n",{"type":66,"tag":150,"props":2698,"children":2699},{"class":152,"line":611},[2700,2704,2708,2712,2716,2720,2724,2729,2733,2737,2741],{"type":66,"tag":150,"props":2701,"children":2702},{"style":343},[2703],{"type":72,"value":398},{"type":66,"tag":150,"props":2705,"children":2706},{"style":163},[2707],{"type":72,"value":371},{"type":66,"tag":150,"props":2709,"children":2710},{"style":318},[2711],{"type":72,"value":407},{"type":66,"tag":150,"props":2713,"children":2714},{"style":163},[2715],{"type":72,"value":412},{"type":66,"tag":150,"props":2717,"children":2718},{"style":415},[2719],{"type":72,"value":418},{"type":66,"tag":150,"props":2721,"children":2722},{"style":163},[2723],{"type":72,"value":225},{"type":66,"tag":150,"props":2725,"children":2726},{"style":415},[2727],{"type":72,"value":2728}," tools",{"type":66,"tag":150,"props":2730,"children":2731},{"style":163},[2732],{"type":72,"value":225},{"type":66,"tag":150,"props":2734,"children":2735},{"style":415},[2736],{"type":72,"value":427},{"type":66,"tag":150,"props":2738,"children":2739},{"style":163},[2740],{"type":72,"value":432},{"type":66,"tag":150,"props":2742,"children":2743},{"style":318},[2744],{"type":72,"value":437},{"type":66,"tag":150,"props":2746,"children":2747},{"class":152,"line":628},[2748,2752,2756],{"type":66,"tag":150,"props":2749,"children":2750},{"style":343},[2751],{"type":72,"value":446},{"type":66,"tag":150,"props":2753,"children":2754},{"style":169},[2755],{"type":72,"value":351},{"type":66,"tag":150,"props":2757,"children":2758},{"style":163},[2759],{"type":72,"value":356},{"type":66,"tag":150,"props":2761,"children":2762},{"class":152,"line":1756},[2763,2767,2771,2775,2779,2783,2787,2791,2795,2799,2803],{"type":66,"tag":150,"props":2764,"children":2765},{"style":163},[2766],{"type":72,"value":473},{"type":66,"tag":150,"props":2768,"children":2769},{"style":169},[2770],{"type":72,"value":478},{"type":66,"tag":150,"props":2772,"children":2773},{"style":163},[2774],{"type":72,"value":340},{"type":66,"tag":150,"props":2776,"children":2777},{"style":343},[2778],{"type":72,"value":487},{"type":66,"tag":150,"props":2780,"children":2781},{"style":169},[2782],{"type":72,"value":351},{"type":66,"tag":150,"props":2784,"children":2785},{"style":163},[2786],{"type":72,"value":1573},{"type":66,"tag":150,"props":2788,"children":2789},{"style":169},[2790],{"type":72,"value":2404},{"type":66,"tag":150,"props":2792,"children":2793},{"style":163},[2794],{"type":72,"value":634},{"type":66,"tag":150,"props":2796,"children":2797},{"style":169},[2798],{"type":72,"value":535},{"type":66,"tag":150,"props":2800,"children":2801},{"style":163},[2802],{"type":72,"value":225},{"type":66,"tag":150,"props":2804,"children":2805},{"style":461},[2806],{"type":72,"value":2807}," \u002F\u002F same set, handed back typed\n",{"type":66,"tag":150,"props":2809,"children":2810},{"class":152,"line":1765},[2811,2815,2819,2823,2827,2831,2835,2839,2843],{"type":66,"tag":150,"props":2812,"children":2813},{"style":363},[2814],{"type":72,"value":505},{"type":66,"tag":150,"props":2816,"children":2817},{"style":163},[2818],{"type":72,"value":371},{"type":66,"tag":150,"props":2820,"children":2821},{"style":343},[2822],{"type":72,"value":271},{"type":66,"tag":150,"props":2824,"children":2825},{"style":169},[2826],{"type":72,"value":351},{"type":66,"tag":150,"props":2828,"children":2829},{"style":163},[2830],{"type":72,"value":198},{"type":66,"tag":150,"props":2832,"children":2833},{"style":190},[2834],{"type":72,"value":526},{"type":66,"tag":150,"props":2836,"children":2837},{"style":163},[2838],{"type":72,"value":198},{"type":66,"tag":150,"props":2840,"children":2841},{"style":169},[2842],{"type":72,"value":535},{"type":66,"tag":150,"props":2844,"children":2845},{"style":163},[2846],{"type":72,"value":389},{"type":66,"tag":150,"props":2848,"children":2849},{"class":152,"line":1774},[2850,2854],{"type":66,"tag":150,"props":2851,"children":2852},{"style":169},[2853],{"type":72,"value":548},{"type":66,"tag":150,"props":2855,"children":2856},{"style":163},[2857],{"type":72,"value":389},{"type":66,"tag":150,"props":2859,"children":2861},{"class":152,"line":2860},20,[2862,2866,2870,2874],{"type":66,"tag":150,"props":2863,"children":2864},{"style":363},[2865],{"type":72,"value":561},{"type":66,"tag":150,"props":2867,"children":2868},{"style":163},[2869],{"type":72,"value":371},{"type":66,"tag":150,"props":2871,"children":2872},{"style":169},[2873],{"type":72,"value":427},{"type":66,"tag":150,"props":2875,"children":2876},{"style":163},[2877],{"type":72,"value":389},{"type":66,"tag":150,"props":2879,"children":2881},{"class":152,"line":2880},21,[2882,2886,2890,2894,2898,2902,2906],{"type":66,"tag":150,"props":2883,"children":2884},{"style":363},[2885],{"type":72,"value":582},{"type":66,"tag":150,"props":2887,"children":2888},{"style":163},[2889],{"type":72,"value":371},{"type":66,"tag":150,"props":2891,"children":2892},{"style":343},[2893],{"type":72,"value":230},{"type":66,"tag":150,"props":2895,"children":2896},{"style":169},[2897],{"type":72,"value":351},{"type":66,"tag":150,"props":2899,"children":2900},{"style":597},[2901],{"type":72,"value":600},{"type":66,"tag":150,"props":2903,"children":2904},{"style":169},[2905],{"type":72,"value":535},{"type":66,"tag":150,"props":2907,"children":2908},{"style":163},[2909],{"type":72,"value":389},{"type":66,"tag":150,"props":2911,"children":2913},{"class":152,"line":2912},22,[2914,2918,2922],{"type":66,"tag":150,"props":2915,"children":2916},{"style":163},[2917],{"type":72,"value":617},{"type":66,"tag":150,"props":2919,"children":2920},{"style":169},[2921],{"type":72,"value":535},{"type":66,"tag":150,"props":2923,"children":2924},{"style":163},[2925],{"type":72,"value":389},{"type":66,"tag":150,"props":2927,"children":2929},{"class":152,"line":2928},23,[2930,2934,2938],{"type":66,"tag":150,"props":2931,"children":2932},{"style":163},[2933],{"type":72,"value":634},{"type":66,"tag":150,"props":2935,"children":2936},{"style":169},[2937],{"type":72,"value":535},{"type":66,"tag":150,"props":2939,"children":2940},{"style":163},[2941],{"type":72,"value":203},{"type":66,"tag":75,"props":2943,"children":2944},{},[2945,2951,2953,2959,2961,2967,2969,2974,2976,2982,2983,2989,2991,2997],{"type":66,"tag":81,"props":2946,"children":2948},{"className":2947},[],[2949],{"type":72,"value":2950},"tools",{"type":72,"value":2952}," also accepts a function ",{"type":66,"tag":81,"props":2954,"children":2956},{"className":2955},[],[2957],{"type":72,"value":2958},"(event) => ToolSet",{"type":72,"value":2960}," resolved per turn, where ",{"type":66,"tag":81,"props":2962,"children":2964},{"className":2963},[],[2965],{"type":72,"value":2966},"event",{"type":72,"value":2968}," carries\n",{"type":66,"tag":81,"props":2970,"children":2972},{"className":2971},[],[2973],{"type":72,"value":929},{"type":72,"value":2975},", ",{"type":66,"tag":81,"props":2977,"children":2979},{"className":2978},[],[2980],{"type":72,"value":2981},"turn",{"type":72,"value":2975},{"type":66,"tag":81,"props":2984,"children":2986},{"className":2985},[],[2987],{"type":72,"value":2988},"continuation",{"type":72,"value":2990},", and ",{"type":66,"tag":81,"props":2992,"children":2994},{"className":2993},[],[2995],{"type":72,"value":2996},"clientData",{"type":72,"value":340},{"type":66,"tag":131,"props":2999,"children":3001},{"id":3000},"_3-custom-data-parts-persisted-vs-transient",[3002],{"type":72,"value":3003},"3. Custom data parts (persisted vs transient)",{"type":66,"tag":75,"props":3005,"children":3006},{},[3007,3013,3015,3021,3023,3028,3030,3036,3038,3044,3046,3052,3054,3060,3062,3068],{"type":66,"tag":81,"props":3008,"children":3010},{"className":3009},[],[3011],{"type":72,"value":3012},"data-*",{"type":72,"value":3014}," parts written via ",{"type":66,"tag":81,"props":3016,"children":3018},{"className":3017},[],[3019],{"type":72,"value":3020},"chat.response.write()",{"type":72,"value":3022}," in ",{"type":66,"tag":81,"props":3024,"children":3026},{"className":3025},[],[3027],{"type":72,"value":2278},{"type":72,"value":3029}," (or ",{"type":66,"tag":81,"props":3031,"children":3033},{"className":3032},[],[3034],{"type":72,"value":3035},"writer.write()",{"type":72,"value":3037}," in hooks)\npersist into ",{"type":66,"tag":81,"props":3039,"children":3041},{"className":3040},[],[3042],{"type":72,"value":3043},"responseMessage.parts",{"type":72,"value":3045}," and surface in ",{"type":66,"tag":81,"props":3047,"children":3049},{"className":3048},[],[3050],{"type":72,"value":3051},"onTurnComplete",{"type":72,"value":3053},". Add ",{"type":66,"tag":81,"props":3055,"children":3057},{"className":3056},[],[3058],{"type":72,"value":3059},"transient: true",{"type":72,"value":3061}," to\nstream them without persisting. Writes via ",{"type":66,"tag":81,"props":3063,"children":3065},{"className":3064},[],[3066],{"type":72,"value":3067},"chat.stream",{"type":72,"value":3069}," are always ephemeral.",{"type":66,"tag":138,"props":3071,"children":3073},{"className":140,"code":3072,"language":142,"meta":144,"style":144},"\u002F\u002F In run() - persists, surfaces in onTurnComplete's responseMessage\nchat.response.write({ type: \"data-context\", data: { searchResults } });\n\n\u002F\u002F In a hook via writer - streams but does NOT persist\nwriter.write({ type: \"data-progress\", id: \"search\", data: { percent: 50 }, transient: true });\n",[3074],{"type":66,"tag":81,"props":3075,"children":3076},{"__ignoreMap":144},[3077,3085,3177,3184,3192],{"type":66,"tag":150,"props":3078,"children":3079},{"class":152,"line":153},[3080],{"type":66,"tag":150,"props":3081,"children":3082},{"style":461},[3083],{"type":72,"value":3084},"\u002F\u002F In run() - persists, surfaces in onTurnComplete's responseMessage\n",{"type":66,"tag":150,"props":3086,"children":3087},{"class":152,"line":206},[3088,3092,3096,3101,3105,3110,3114,3118,3122,3126,3130,3135,3139,3143,3148,3152,3156,3161,3165,3169,3173],{"type":66,"tag":150,"props":3089,"children":3090},{"style":169},[3091],{"type":72,"value":478},{"type":66,"tag":150,"props":3093,"children":3094},{"style":163},[3095],{"type":72,"value":340},{"type":66,"tag":150,"props":3097,"children":3098},{"style":169},[3099],{"type":72,"value":3100},"response",{"type":66,"tag":150,"props":3102,"children":3103},{"style":163},[3104],{"type":72,"value":340},{"type":66,"tag":150,"props":3106,"children":3107},{"style":343},[3108],{"type":72,"value":3109},"write",{"type":66,"tag":150,"props":3111,"children":3112},{"style":169},[3113],{"type":72,"value":351},{"type":66,"tag":150,"props":3115,"children":3116},{"style":163},[3117],{"type":72,"value":1573},{"type":66,"tag":150,"props":3119,"children":3120},{"style":363},[3121],{"type":72,"value":1283},{"type":66,"tag":150,"props":3123,"children":3124},{"style":163},[3125],{"type":72,"value":371},{"type":66,"tag":150,"props":3127,"children":3128},{"style":163},[3129],{"type":72,"value":187},{"type":66,"tag":150,"props":3131,"children":3132},{"style":190},[3133],{"type":72,"value":3134},"data-context",{"type":66,"tag":150,"props":3136,"children":3137},{"style":163},[3138],{"type":72,"value":198},{"type":66,"tag":150,"props":3140,"children":3141},{"style":163},[3142],{"type":72,"value":225},{"type":66,"tag":150,"props":3144,"children":3145},{"style":363},[3146],{"type":72,"value":3147}," data",{"type":66,"tag":150,"props":3149,"children":3150},{"style":163},[3151],{"type":72,"value":371},{"type":66,"tag":150,"props":3153,"children":3154},{"style":163},[3155],{"type":72,"value":166},{"type":66,"tag":150,"props":3157,"children":3158},{"style":169},[3159],{"type":72,"value":3160}," searchResults ",{"type":66,"tag":150,"props":3162,"children":3163},{"style":163},[3164],{"type":72,"value":634},{"type":66,"tag":150,"props":3166,"children":3167},{"style":163},[3168],{"type":72,"value":177},{"type":66,"tag":150,"props":3170,"children":3171},{"style":169},[3172],{"type":72,"value":535},{"type":66,"tag":150,"props":3174,"children":3175},{"style":163},[3176],{"type":72,"value":203},{"type":66,"tag":150,"props":3178,"children":3179},{"class":152,"line":257},[3180],{"type":66,"tag":150,"props":3181,"children":3182},{"emptyLinePlaceholder":303},[3183],{"type":72,"value":306},{"type":66,"tag":150,"props":3185,"children":3186},{"class":152,"line":299},[3187],{"type":66,"tag":150,"props":3188,"children":3189},{"style":461},[3190],{"type":72,"value":3191},"\u002F\u002F In a hook via writer - streams but does NOT persist\n",{"type":66,"tag":150,"props":3193,"children":3194},{"class":152,"line":309},[3195,3200,3204,3208,3212,3216,3220,3224,3228,3233,3237,3241,3246,3250,3254,3259,3263,3267,3271,3275,3279,3284,3288,3293,3297,3302,3306,3312,3316,3320],{"type":66,"tag":150,"props":3196,"children":3197},{"style":169},[3198],{"type":72,"value":3199},"writer",{"type":66,"tag":150,"props":3201,"children":3202},{"style":163},[3203],{"type":72,"value":340},{"type":66,"tag":150,"props":3205,"children":3206},{"style":343},[3207],{"type":72,"value":3109},{"type":66,"tag":150,"props":3209,"children":3210},{"style":169},[3211],{"type":72,"value":351},{"type":66,"tag":150,"props":3213,"children":3214},{"style":163},[3215],{"type":72,"value":1573},{"type":66,"tag":150,"props":3217,"children":3218},{"style":363},[3219],{"type":72,"value":1283},{"type":66,"tag":150,"props":3221,"children":3222},{"style":163},[3223],{"type":72,"value":371},{"type":66,"tag":150,"props":3225,"children":3226},{"style":163},[3227],{"type":72,"value":187},{"type":66,"tag":150,"props":3229,"children":3230},{"style":190},[3231],{"type":72,"value":3232},"data-progress",{"type":66,"tag":150,"props":3234,"children":3235},{"style":163},[3236],{"type":72,"value":198},{"type":66,"tag":150,"props":3238,"children":3239},{"style":163},[3240],{"type":72,"value":225},{"type":66,"tag":150,"props":3242,"children":3243},{"style":363},[3244],{"type":72,"value":3245}," id",{"type":66,"tag":150,"props":3247,"children":3248},{"style":163},[3249],{"type":72,"value":371},{"type":66,"tag":150,"props":3251,"children":3252},{"style":163},[3253],{"type":72,"value":187},{"type":66,"tag":150,"props":3255,"children":3256},{"style":190},[3257],{"type":72,"value":3258},"search",{"type":66,"tag":150,"props":3260,"children":3261},{"style":163},[3262],{"type":72,"value":198},{"type":66,"tag":150,"props":3264,"children":3265},{"style":163},[3266],{"type":72,"value":225},{"type":66,"tag":150,"props":3268,"children":3269},{"style":363},[3270],{"type":72,"value":3147},{"type":66,"tag":150,"props":3272,"children":3273},{"style":163},[3274],{"type":72,"value":371},{"type":66,"tag":150,"props":3276,"children":3277},{"style":163},[3278],{"type":72,"value":166},{"type":66,"tag":150,"props":3280,"children":3281},{"style":363},[3282],{"type":72,"value":3283}," percent",{"type":66,"tag":150,"props":3285,"children":3286},{"style":163},[3287],{"type":72,"value":371},{"type":66,"tag":150,"props":3289,"children":3290},{"style":597},[3291],{"type":72,"value":3292}," 50",{"type":66,"tag":150,"props":3294,"children":3295},{"style":163},[3296],{"type":72,"value":1025},{"type":66,"tag":150,"props":3298,"children":3299},{"style":363},[3300],{"type":72,"value":3301}," transient",{"type":66,"tag":150,"props":3303,"children":3304},{"style":163},[3305],{"type":72,"value":371},{"type":66,"tag":150,"props":3307,"children":3309},{"style":3308},"--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC",[3310],{"type":72,"value":3311}," true",{"type":66,"tag":150,"props":3313,"children":3314},{"style":163},[3315],{"type":72,"value":177},{"type":66,"tag":150,"props":3317,"children":3318},{"style":169},[3319],{"type":72,"value":535},{"type":66,"tag":150,"props":3321,"children":3322},{"style":163},[3323],{"type":72,"value":203},{"type":66,"tag":131,"props":3325,"children":3327},{"id":3326},"_4-custom-uimessage-type-client-data-and-builder-hooks",[3328],{"type":72,"value":3329},"4. Custom UIMessage type, client data, and builder hooks",{"type":66,"tag":75,"props":3331,"children":3332},{},[3333,3335,3340,3342,3348,3350,3356,3358,3364,3366,3372],{"type":72,"value":3334},"For typed ",{"type":66,"tag":81,"props":3336,"children":3338},{"className":3337},[],[3339],{"type":72,"value":3012},{"type":72,"value":3341}," parts or a tool map, build the agent through ",{"type":66,"tag":81,"props":3343,"children":3345},{"className":3344},[],[3346],{"type":72,"value":3347},"chat.withUIMessage\u003CT>()",{"type":72,"value":3349}," and\n",{"type":66,"tag":81,"props":3351,"children":3353},{"className":3352},[],[3354],{"type":72,"value":3355},"chat.withClientData({ schema })",{"type":72,"value":3357},". Builder methods chain in any order; builder hooks run before the\nmatching task hook. ",{"type":66,"tag":81,"props":3359,"children":3361},{"className":3360},[],[3362],{"type":72,"value":3363},"streamOptions",{"type":72,"value":3365}," becomes the default ",{"type":66,"tag":81,"props":3367,"children":3369},{"className":3368},[],[3370],{"type":72,"value":3371},"uiMessageStreamOptions",{"type":72,"value":3373}," (shallow-merged,\nagent wins).",{"type":66,"tag":138,"props":3375,"children":3377},{"className":140,"code":3376,"language":142,"meta":144,"style":144},"export const myChat = chat\n  .withUIMessage\u003CMyChatUIMessage>({ streamOptions: { sendReasoning: true } })\n  .withClientData({ schema: z.object({ userId: z.string() }) })\n  .agent({\n    id: \"my-chat\",\n    tools: myTools,\n    onTurnStart: async ({ uiMessages, writer }) => {\n      writer.write({ type: \"data-turn-status\", data: { status: \"preparing\" } });\n    },\n    run: async ({ messages, tools, signal }) =>\n      streamText({ ...chat.toStreamTextOptions({ tools }), model, messages, abortSignal: signal }),\n  });\n",[3378],{"type":66,"tag":81,"props":3379,"children":3380},{"__ignoreMap":144},[3381,3405,3479,3570,3589,3617,3638,3684,3782,3790,3838,3938],{"type":66,"tag":150,"props":3382,"children":3383},{"class":152,"line":153},[3384,3388,3392,3396,3400],{"type":66,"tag":150,"props":3385,"children":3386},{"style":157},[3387],{"type":72,"value":315},{"type":66,"tag":150,"props":3389,"children":3390},{"style":318},[3391],{"type":72,"value":321},{"type":66,"tag":150,"props":3393,"children":3394},{"style":169},[3395],{"type":72,"value":326},{"type":66,"tag":150,"props":3397,"children":3398},{"style":163},[3399],{"type":72,"value":331},{"type":66,"tag":150,"props":3401,"children":3402},{"style":169},[3403],{"type":72,"value":3404}," chat\n",{"type":66,"tag":150,"props":3406,"children":3407},{"class":152,"line":206},[3408,3413,3418,3423,3428,3432,3436,3440,3445,3449,3453,3458,3462,3466,3470,3474],{"type":66,"tag":150,"props":3409,"children":3410},{"style":163},[3411],{"type":72,"value":3412},"  .",{"type":66,"tag":150,"props":3414,"children":3415},{"style":343},[3416],{"type":72,"value":3417},"withUIMessage",{"type":66,"tag":150,"props":3419,"children":3420},{"style":163},[3421],{"type":72,"value":3422},"\u003C",{"type":66,"tag":150,"props":3424,"children":3425},{"style":936},[3426],{"type":72,"value":3427},"MyChatUIMessage",{"type":66,"tag":150,"props":3429,"children":3430},{"style":163},[3431],{"type":72,"value":1433},{"type":66,"tag":150,"props":3433,"children":3434},{"style":169},[3435],{"type":72,"value":351},{"type":66,"tag":150,"props":3437,"children":3438},{"style":163},[3439],{"type":72,"value":1573},{"type":66,"tag":150,"props":3441,"children":3442},{"style":363},[3443],{"type":72,"value":3444}," streamOptions",{"type":66,"tag":150,"props":3446,"children":3447},{"style":163},[3448],{"type":72,"value":371},{"type":66,"tag":150,"props":3450,"children":3451},{"style":163},[3452],{"type":72,"value":166},{"type":66,"tag":150,"props":3454,"children":3455},{"style":363},[3456],{"type":72,"value":3457}," sendReasoning",{"type":66,"tag":150,"props":3459,"children":3460},{"style":163},[3461],{"type":72,"value":371},{"type":66,"tag":150,"props":3463,"children":3464},{"style":3308},[3465],{"type":72,"value":3311},{"type":66,"tag":150,"props":3467,"children":3468},{"style":163},[3469],{"type":72,"value":177},{"type":66,"tag":150,"props":3471,"children":3472},{"style":163},[3473],{"type":72,"value":177},{"type":66,"tag":150,"props":3475,"children":3476},{"style":169},[3477],{"type":72,"value":3478},")\n",{"type":66,"tag":150,"props":3480,"children":3481},{"class":152,"line":257},[3482,3486,3491,3495,3499,3504,3508,3512,3516,3520,3524,3528,3533,3537,3541,3545,3549,3553,3557,3562,3566],{"type":66,"tag":150,"props":3483,"children":3484},{"style":163},[3485],{"type":72,"value":3412},{"type":66,"tag":150,"props":3487,"children":3488},{"style":343},[3489],{"type":72,"value":3490},"withClientData",{"type":66,"tag":150,"props":3492,"children":3493},{"style":169},[3494],{"type":72,"value":351},{"type":66,"tag":150,"props":3496,"children":3497},{"style":163},[3498],{"type":72,"value":1573},{"type":66,"tag":150,"props":3500,"children":3501},{"style":363},[3502],{"type":72,"value":3503}," schema",{"type":66,"tag":150,"props":3505,"children":3506},{"style":163},[3507],{"type":72,"value":371},{"type":66,"tag":150,"props":3509,"children":3510},{"style":169},[3511],{"type":72,"value":2359},{"type":66,"tag":150,"props":3513,"children":3514},{"style":163},[3515],{"type":72,"value":340},{"type":66,"tag":150,"props":3517,"children":3518},{"style":343},[3519],{"type":72,"value":2490},{"type":66,"tag":150,"props":3521,"children":3522},{"style":169},[3523],{"type":72,"value":351},{"type":66,"tag":150,"props":3525,"children":3526},{"style":163},[3527],{"type":72,"value":1573},{"type":66,"tag":150,"props":3529,"children":3530},{"style":363},[3531],{"type":72,"value":3532}," userId",{"type":66,"tag":150,"props":3534,"children":3535},{"style":163},[3536],{"type":72,"value":371},{"type":66,"tag":150,"props":3538,"children":3539},{"style":169},[3540],{"type":72,"value":2359},{"type":66,"tag":150,"props":3542,"children":3543},{"style":163},[3544],{"type":72,"value":340},{"type":66,"tag":150,"props":3546,"children":3547},{"style":343},[3548],{"type":72,"value":2520},{"type":66,"tag":150,"props":3550,"children":3551},{"style":169},[3552],{"type":72,"value":2525},{"type":66,"tag":150,"props":3554,"children":3555},{"style":163},[3556],{"type":72,"value":634},{"type":66,"tag":150,"props":3558,"children":3559},{"style":169},[3560],{"type":72,"value":3561},") ",{"type":66,"tag":150,"props":3563,"children":3564},{"style":163},[3565],{"type":72,"value":634},{"type":66,"tag":150,"props":3567,"children":3568},{"style":169},[3569],{"type":72,"value":3478},{"type":66,"tag":150,"props":3571,"children":3572},{"class":152,"line":299},[3573,3577,3581,3585],{"type":66,"tag":150,"props":3574,"children":3575},{"style":163},[3576],{"type":72,"value":3412},{"type":66,"tag":150,"props":3578,"children":3579},{"style":343},[3580],{"type":72,"value":346},{"type":66,"tag":150,"props":3582,"children":3583},{"style":169},[3584],{"type":72,"value":351},{"type":66,"tag":150,"props":3586,"children":3587},{"style":163},[3588],{"type":72,"value":356},{"type":66,"tag":150,"props":3590,"children":3591},{"class":152,"line":309},[3592,3597,3601,3605,3609,3613],{"type":66,"tag":150,"props":3593,"children":3594},{"style":363},[3595],{"type":72,"value":3596},"    id",{"type":66,"tag":150,"props":3598,"children":3599},{"style":163},[3600],{"type":72,"value":371},{"type":66,"tag":150,"props":3602,"children":3603},{"style":163},[3604],{"type":72,"value":187},{"type":66,"tag":150,"props":3606,"children":3607},{"style":190},[3608],{"type":72,"value":380},{"type":66,"tag":150,"props":3610,"children":3611},{"style":163},[3612],{"type":72,"value":198},{"type":66,"tag":150,"props":3614,"children":3615},{"style":163},[3616],{"type":72,"value":389},{"type":66,"tag":150,"props":3618,"children":3619},{"class":152,"line":359},[3620,3625,3629,3634],{"type":66,"tag":150,"props":3621,"children":3622},{"style":363},[3623],{"type":72,"value":3624},"    tools",{"type":66,"tag":150,"props":3626,"children":3627},{"style":163},[3628],{"type":72,"value":371},{"type":66,"tag":150,"props":3630,"children":3631},{"style":169},[3632],{"type":72,"value":3633}," myTools",{"type":66,"tag":150,"props":3635,"children":3636},{"style":163},[3637],{"type":72,"value":389},{"type":66,"tag":150,"props":3639,"children":3640},{"class":152,"line":392},[3641,3646,3650,3654,3658,3663,3667,3672,3676,3680],{"type":66,"tag":150,"props":3642,"children":3643},{"style":343},[3644],{"type":72,"value":3645},"    onTurnStart",{"type":66,"tag":150,"props":3647,"children":3648},{"style":163},[3649],{"type":72,"value":371},{"type":66,"tag":150,"props":3651,"children":3652},{"style":318},[3653],{"type":72,"value":407},{"type":66,"tag":150,"props":3655,"children":3656},{"style":163},[3657],{"type":72,"value":412},{"type":66,"tag":150,"props":3659,"children":3660},{"style":415},[3661],{"type":72,"value":3662}," uiMessages",{"type":66,"tag":150,"props":3664,"children":3665},{"style":163},[3666],{"type":72,"value":225},{"type":66,"tag":150,"props":3668,"children":3669},{"style":415},[3670],{"type":72,"value":3671}," writer",{"type":66,"tag":150,"props":3673,"children":3674},{"style":163},[3675],{"type":72,"value":432},{"type":66,"tag":150,"props":3677,"children":3678},{"style":318},[3679],{"type":72,"value":1503},{"type":66,"tag":150,"props":3681,"children":3682},{"style":163},[3683],{"type":72,"value":948},{"type":66,"tag":150,"props":3685,"children":3686},{"class":152,"line":440},[3687,3692,3696,3700,3704,3708,3712,3716,3720,3725,3729,3733,3737,3741,3745,3749,3753,3757,3762,3766,3770,3774,3778],{"type":66,"tag":150,"props":3688,"children":3689},{"style":169},[3690],{"type":72,"value":3691},"      writer",{"type":66,"tag":150,"props":3693,"children":3694},{"style":163},[3695],{"type":72,"value":340},{"type":66,"tag":150,"props":3697,"children":3698},{"style":343},[3699],{"type":72,"value":3109},{"type":66,"tag":150,"props":3701,"children":3702},{"style":363},[3703],{"type":72,"value":351},{"type":66,"tag":150,"props":3705,"children":3706},{"style":163},[3707],{"type":72,"value":1573},{"type":66,"tag":150,"props":3709,"children":3710},{"style":363},[3711],{"type":72,"value":1283},{"type":66,"tag":150,"props":3713,"children":3714},{"style":163},[3715],{"type":72,"value":371},{"type":66,"tag":150,"props":3717,"children":3718},{"style":163},[3719],{"type":72,"value":187},{"type":66,"tag":150,"props":3721,"children":3722},{"style":190},[3723],{"type":72,"value":3724},"data-turn-status",{"type":66,"tag":150,"props":3726,"children":3727},{"style":163},[3728],{"type":72,"value":198},{"type":66,"tag":150,"props":3730,"children":3731},{"style":163},[3732],{"type":72,"value":225},{"type":66,"tag":150,"props":3734,"children":3735},{"style":363},[3736],{"type":72,"value":3147},{"type":66,"tag":150,"props":3738,"children":3739},{"style":163},[3740],{"type":72,"value":371},{"type":66,"tag":150,"props":3742,"children":3743},{"style":163},[3744],{"type":72,"value":166},{"type":66,"tag":150,"props":3746,"children":3747},{"style":363},[3748],{"type":72,"value":1661},{"type":66,"tag":150,"props":3750,"children":3751},{"style":163},[3752],{"type":72,"value":371},{"type":66,"tag":150,"props":3754,"children":3755},{"style":163},[3756],{"type":72,"value":187},{"type":66,"tag":150,"props":3758,"children":3759},{"style":190},[3760],{"type":72,"value":3761},"preparing",{"type":66,"tag":150,"props":3763,"children":3764},{"style":163},[3765],{"type":72,"value":198},{"type":66,"tag":150,"props":3767,"children":3768},{"style":163},[3769],{"type":72,"value":177},{"type":66,"tag":150,"props":3771,"children":3772},{"style":163},[3773],{"type":72,"value":177},{"type":66,"tag":150,"props":3775,"children":3776},{"style":363},[3777],{"type":72,"value":535},{"type":66,"tag":150,"props":3779,"children":3780},{"style":163},[3781],{"type":72,"value":203},{"type":66,"tag":150,"props":3783,"children":3784},{"class":152,"line":457},[3785],{"type":66,"tag":150,"props":3786,"children":3787},{"style":163},[3788],{"type":72,"value":3789},"    },\n",{"type":66,"tag":150,"props":3791,"children":3792},{"class":152,"line":467},[3793,3798,3802,3806,3810,3814,3818,3822,3826,3830,3834],{"type":66,"tag":150,"props":3794,"children":3795},{"style":343},[3796],{"type":72,"value":3797},"    run",{"type":66,"tag":150,"props":3799,"children":3800},{"style":163},[3801],{"type":72,"value":371},{"type":66,"tag":150,"props":3803,"children":3804},{"style":318},[3805],{"type":72,"value":407},{"type":66,"tag":150,"props":3807,"children":3808},{"style":163},[3809],{"type":72,"value":412},{"type":66,"tag":150,"props":3811,"children":3812},{"style":415},[3813],{"type":72,"value":418},{"type":66,"tag":150,"props":3815,"children":3816},{"style":163},[3817],{"type":72,"value":225},{"type":66,"tag":150,"props":3819,"children":3820},{"style":415},[3821],{"type":72,"value":2728},{"type":66,"tag":150,"props":3823,"children":3824},{"style":163},[3825],{"type":72,"value":225},{"type":66,"tag":150,"props":3827,"children":3828},{"style":415},[3829],{"type":72,"value":427},{"type":66,"tag":150,"props":3831,"children":3832},{"style":163},[3833],{"type":72,"value":432},{"type":66,"tag":150,"props":3835,"children":3836},{"style":318},[3837],{"type":72,"value":437},{"type":66,"tag":150,"props":3839,"children":3840},{"class":152,"line":499},[3841,3846,3850,3854,3859,3863,3867,3871,3875,3879,3883,3887,3891,3895,3900,3904,3908,3912,3917,3921,3926,3930,3934],{"type":66,"tag":150,"props":3842,"children":3843},{"style":343},[3844],{"type":72,"value":3845},"      streamText",{"type":66,"tag":150,"props":3847,"children":3848},{"style":169},[3849],{"type":72,"value":351},{"type":66,"tag":150,"props":3851,"children":3852},{"style":163},[3853],{"type":72,"value":1573},{"type":66,"tag":150,"props":3855,"children":3856},{"style":163},[3857],{"type":72,"value":3858}," ...",{"type":66,"tag":150,"props":3860,"children":3861},{"style":169},[3862],{"type":72,"value":478},{"type":66,"tag":150,"props":3864,"children":3865},{"style":163},[3866],{"type":72,"value":340},{"type":66,"tag":150,"props":3868,"children":3869},{"style":343},[3870],{"type":72,"value":487},{"type":66,"tag":150,"props":3872,"children":3873},{"style":169},[3874],{"type":72,"value":351},{"type":66,"tag":150,"props":3876,"children":3877},{"style":163},[3878],{"type":72,"value":1573},{"type":66,"tag":150,"props":3880,"children":3881},{"style":169},[3882],{"type":72,"value":2404},{"type":66,"tag":150,"props":3884,"children":3885},{"style":163},[3886],{"type":72,"value":634},{"type":66,"tag":150,"props":3888,"children":3889},{"style":169},[3890],{"type":72,"value":535},{"type":66,"tag":150,"props":3892,"children":3893},{"style":163},[3894],{"type":72,"value":225},{"type":66,"tag":150,"props":3896,"children":3897},{"style":169},[3898],{"type":72,"value":3899}," model",{"type":66,"tag":150,"props":3901,"children":3902},{"style":163},[3903],{"type":72,"value":225},{"type":66,"tag":150,"props":3905,"children":3906},{"style":169},[3907],{"type":72,"value":418},{"type":66,"tag":150,"props":3909,"children":3910},{"style":163},[3911],{"type":72,"value":225},{"type":66,"tag":150,"props":3913,"children":3914},{"style":363},[3915],{"type":72,"value":3916}," abortSignal",{"type":66,"tag":150,"props":3918,"children":3919},{"style":163},[3920],{"type":72,"value":371},{"type":66,"tag":150,"props":3922,"children":3923},{"style":169},[3924],{"type":72,"value":3925}," signal ",{"type":66,"tag":150,"props":3927,"children":3928},{"style":163},[3929],{"type":72,"value":634},{"type":66,"tag":150,"props":3931,"children":3932},{"style":169},[3933],{"type":72,"value":535},{"type":66,"tag":150,"props":3935,"children":3936},{"style":163},[3937],{"type":72,"value":389},{"type":66,"tag":150,"props":3939,"children":3940},{"class":152,"line":542},[3941,3945,3949],{"type":66,"tag":150,"props":3942,"children":3943},{"style":163},[3944],{"type":72,"value":1096},{"type":66,"tag":150,"props":3946,"children":3947},{"style":169},[3948],{"type":72,"value":535},{"type":66,"tag":150,"props":3950,"children":3951},{"style":163},[3952],{"type":72,"value":203},{"type":66,"tag":75,"props":3954,"children":3955},{},[3956,3958,3963,3965,3971,3973,3979,3981,3986,3988,3993,3995,4001,4002,4007],{"type":72,"value":3957},"Build ",{"type":66,"tag":81,"props":3959,"children":3961},{"className":3960},[],[3962],{"type":72,"value":3427},{"type":72,"value":3964}," as ",{"type":66,"tag":81,"props":3966,"children":3968},{"className":3967},[],[3969],{"type":72,"value":3970},"UIMessage\u003Cunknown, MyDataTypes, InferUITools\u003Ctypeof tools>>",{"type":72,"value":3972}," (or, for\ntools only, ",{"type":66,"tag":81,"props":3974,"children":3976},{"className":3975},[],[3977],{"type":72,"value":3978},"InferChatUIMessageFromTools\u003Ctypeof tools>",{"type":72,"value":3980}," from ",{"type":66,"tag":81,"props":3982,"children":3984},{"className":3983},[],[3985],{"type":72,"value":193},{"type":72,"value":3987},"). On the\nfrontend, narrow ",{"type":66,"tag":81,"props":3989,"children":3991},{"className":3990},[],[3992],{"type":72,"value":1798},{"type":72,"value":3994}," with ",{"type":66,"tag":81,"props":3996,"children":3998},{"className":3997},[],[3999],{"type":72,"value":4000},"InferChatUIMessage\u003Ctypeof myChat>",{"type":72,"value":3980},{"type":66,"tag":81,"props":4003,"children":4005},{"className":4004},[],[4006],{"type":72,"value":1263},{"type":72,"value":340},{"type":66,"tag":131,"props":4009,"children":4011},{"id":4010},"_5-lifecycle-hooks-and-stop",[4012],{"type":72,"value":4013},"5. Lifecycle hooks and stop",{"type":66,"tag":75,"props":4015,"children":4016},{},[4017,4022],{"type":66,"tag":81,"props":4018,"children":4020},{"className":4019},[],[4021],{"type":72,"value":86},{"type":72,"value":4023}," accepts hooks that fire in a fixed per-turn order:",{"type":66,"tag":138,"props":4025,"children":4029},{"className":4026,"code":4028,"language":72,"meta":144},[4027],"language-text","onValidateMessages -> hydrateMessages -> onChatStart (chat's first message only)\n  -> onTurnStart -> run() -> onBeforeTurnComplete -> onTurnComplete\n",[4030],{"type":66,"tag":81,"props":4031,"children":4032},{"__ignoreMap":144},[4033],{"type":72,"value":4028},{"type":66,"tag":75,"props":4035,"children":4036},{},[4037,4043,4045,4051,4053,4059,4061,4067,4069,4075,4077,4082,4083,4089,4090,4096,4098,4104,4106,4112,4114,4119,4120,4126,4128,4134,4136,4141,4143,4149],{"type":66,"tag":81,"props":4038,"children":4040},{"className":4039},[],[4041],{"type":72,"value":4042},"onBoot",{"type":72,"value":4044}," fires once per worker process (every fresh boot, including continuation runs) and is where\n",{"type":66,"tag":81,"props":4046,"children":4048},{"className":4047},[],[4049],{"type":72,"value":4050},"chat.local",{"type":72,"value":4052},", DB connections, and per-process state belong. ",{"type":66,"tag":81,"props":4054,"children":4056},{"className":4055},[],[4057],{"type":72,"value":4058},"onChatStart",{"type":72,"value":4060}," fires only on the chat's\nfirst message. Suspend\u002Fresume use ",{"type":66,"tag":81,"props":4062,"children":4064},{"className":4063},[],[4065],{"type":72,"value":4066},"onChatSuspend",{"type":72,"value":4068}," \u002F ",{"type":66,"tag":81,"props":4070,"children":4072},{"className":4071},[],[4073],{"type":72,"value":4074},"onChatResume",{"type":72,"value":4076},". Config options include\n",{"type":66,"tag":81,"props":4078,"children":4080},{"className":4079},[],[4081],{"type":72,"value":2950},{"type":72,"value":2975},{"type":66,"tag":81,"props":4084,"children":4086},{"className":4085},[],[4087],{"type":72,"value":4088},"clientDataSchema",{"type":72,"value":2975},{"type":66,"tag":81,"props":4091,"children":4093},{"className":4092},[],[4094],{"type":72,"value":4095},"maxTurns",{"type":72,"value":4097}," (100), ",{"type":66,"tag":81,"props":4099,"children":4101},{"className":4100},[],[4102],{"type":72,"value":4103},"turnTimeout",{"type":72,"value":4105}," (\"1h\"), ",{"type":66,"tag":81,"props":4107,"children":4109},{"className":4108},[],[4110],{"type":72,"value":4111},"idleTimeoutInSeconds",{"type":72,"value":4113}," (30),\n",{"type":66,"tag":81,"props":4115,"children":4117},{"className":4116},[],[4118],{"type":72,"value":3371},{"type":72,"value":2990},{"type":66,"tag":81,"props":4121,"children":4123},{"className":4122},[],[4124],{"type":72,"value":4125},"exitAfterPreloadIdle",{"type":72,"value":4127},". There is no generic ",{"type":66,"tag":81,"props":4129,"children":4131},{"className":4130},[],[4132],{"type":72,"value":4133},"retry",{"type":72,"value":4135},"; ",{"type":66,"tag":81,"props":4137,"children":4139},{"className":4138},[],[4140],{"type":72,"value":86},{"type":72,"value":4142},"\nruns with ",{"type":66,"tag":81,"props":4144,"children":4146},{"className":4145},[],[4147],{"type":72,"value":4148},"maxAttempts: 1",{"type":72,"value":4150}," internally.",{"type":66,"tag":75,"props":4152,"children":4153},{},[4154,4156,4161,4163,4168,4170,4176,4178,4183],{"type":72,"value":4155},"Stop is load-bearing: the ",{"type":66,"tag":81,"props":4157,"children":4159},{"className":4158},[],[4160],{"type":72,"value":683},{"type":72,"value":4162}," passed to ",{"type":66,"tag":81,"props":4164,"children":4166},{"className":4165},[],[4167],{"type":72,"value":651},{"type":72,"value":4169}," aborts on stop or cancel. Forward it as\n",{"type":66,"tag":81,"props":4171,"children":4173},{"className":4172},[],[4174],{"type":72,"value":4175},"abortSignal",{"type":72,"value":4177}," to ",{"type":66,"tag":81,"props":4179,"children":4181},{"className":4180},[],[4182],{"type":72,"value":94},{"type":72,"value":4184},", or the Stop button updates the UI while the model keeps generating\nserver-side.",{"type":66,"tag":138,"props":4186,"children":4188},{"className":140,"code":4187,"language":142,"meta":144,"style":144},"run: async ({ messages, signal }) =>\n  streamText({ ...chat.toStreamTextOptions(), model, messages, abortSignal: signal, stopWhen: stepCountIs(15) });\n",[4189],{"type":66,"tag":81,"props":4190,"children":4191},{"__ignoreMap":144},[4192,4231],{"type":66,"tag":150,"props":4193,"children":4194},{"class":152,"line":153},[4195,4199,4203,4207,4211,4215,4219,4223,4227],{"type":66,"tag":150,"props":4196,"children":4197},{"style":936},[4198],{"type":72,"value":651},{"type":66,"tag":150,"props":4200,"children":4201},{"style":163},[4202],{"type":72,"value":371},{"type":66,"tag":150,"props":4204,"children":4205},{"style":318},[4206],{"type":72,"value":407},{"type":66,"tag":150,"props":4208,"children":4209},{"style":163},[4210],{"type":72,"value":412},{"type":66,"tag":150,"props":4212,"children":4213},{"style":415},[4214],{"type":72,"value":418},{"type":66,"tag":150,"props":4216,"children":4217},{"style":163},[4218],{"type":72,"value":225},{"type":66,"tag":150,"props":4220,"children":4221},{"style":415},[4222],{"type":72,"value":427},{"type":66,"tag":150,"props":4224,"children":4225},{"style":163},[4226],{"type":72,"value":432},{"type":66,"tag":150,"props":4228,"children":4229},{"style":318},[4230],{"type":72,"value":437},{"type":66,"tag":150,"props":4232,"children":4233},{"class":152,"line":206},[4234,4239,4243,4247,4251,4255,4259,4263,4267,4271,4275,4279,4283,4287,4291,4295,4299,4303,4308,4312,4316,4320,4324,4328,4332,4336],{"type":66,"tag":150,"props":4235,"children":4236},{"style":343},[4237],{"type":72,"value":4238},"  streamText",{"type":66,"tag":150,"props":4240,"children":4241},{"style":169},[4242],{"type":72,"value":351},{"type":66,"tag":150,"props":4244,"children":4245},{"style":163},[4246],{"type":72,"value":1573},{"type":66,"tag":150,"props":4248,"children":4249},{"style":163},[4250],{"type":72,"value":3858},{"type":66,"tag":150,"props":4252,"children":4253},{"style":169},[4254],{"type":72,"value":478},{"type":66,"tag":150,"props":4256,"children":4257},{"style":163},[4258],{"type":72,"value":340},{"type":66,"tag":150,"props":4260,"children":4261},{"style":343},[4262],{"type":72,"value":487},{"type":66,"tag":150,"props":4264,"children":4265},{"style":169},[4266],{"type":72,"value":492},{"type":66,"tag":150,"props":4268,"children":4269},{"style":163},[4270],{"type":72,"value":225},{"type":66,"tag":150,"props":4272,"children":4273},{"style":169},[4274],{"type":72,"value":3899},{"type":66,"tag":150,"props":4276,"children":4277},{"style":163},[4278],{"type":72,"value":225},{"type":66,"tag":150,"props":4280,"children":4281},{"style":169},[4282],{"type":72,"value":418},{"type":66,"tag":150,"props":4284,"children":4285},{"style":163},[4286],{"type":72,"value":225},{"type":66,"tag":150,"props":4288,"children":4289},{"style":363},[4290],{"type":72,"value":3916},{"type":66,"tag":150,"props":4292,"children":4293},{"style":163},[4294],{"type":72,"value":371},{"type":66,"tag":150,"props":4296,"children":4297},{"style":169},[4298],{"type":72,"value":427},{"type":66,"tag":150,"props":4300,"children":4301},{"style":163},[4302],{"type":72,"value":225},{"type":66,"tag":150,"props":4304,"children":4305},{"style":363},[4306],{"type":72,"value":4307}," stopWhen",{"type":66,"tag":150,"props":4309,"children":4310},{"style":163},[4311],{"type":72,"value":371},{"type":66,"tag":150,"props":4313,"children":4314},{"style":343},[4315],{"type":72,"value":230},{"type":66,"tag":150,"props":4317,"children":4318},{"style":169},[4319],{"type":72,"value":351},{"type":66,"tag":150,"props":4321,"children":4322},{"style":597},[4323],{"type":72,"value":600},{"type":66,"tag":150,"props":4325,"children":4326},{"style":169},[4327],{"type":72,"value":3561},{"type":66,"tag":150,"props":4329,"children":4330},{"style":163},[4331],{"type":72,"value":634},{"type":66,"tag":150,"props":4333,"children":4334},{"style":169},[4335],{"type":72,"value":535},{"type":66,"tag":150,"props":4337,"children":4338},{"style":163},[4339],{"type":72,"value":203},{"type":66,"tag":131,"props":4341,"children":4343},{"id":4342},"_6-migrating-from-a-plain-ai-sdk-streamtext-route",[4344,4346,4351],{"type":72,"value":4345},"6. Migrating from a plain AI SDK ",{"type":66,"tag":81,"props":4347,"children":4349},{"className":4348},[],[4350],{"type":72,"value":94},{"type":72,"value":4352}," route",{"type":66,"tag":75,"props":4354,"children":4355},{},[4356],{"type":72,"value":4357},"There is no API route in this model. The transport replaces the route round-trip, so:",{"type":66,"tag":4359,"props":4360,"children":4361},"ul",{},[4362,4368,4393,4412],{"type":66,"tag":4363,"props":4364,"children":4365},"li",{},[4366],{"type":72,"value":4367},"Delete the route handler. Move per-request auth into the two server actions from Setup step 2.",{"type":66,"tag":4363,"props":4369,"children":4370},{},[4371,4373,4378,4380,4385,4387,4392],{"type":72,"value":4372},"Move the ",{"type":66,"tag":81,"props":4374,"children":4376},{"className":4375},[],[4377],{"type":72,"value":94},{"type":72,"value":4379}," call into ",{"type":66,"tag":81,"props":4381,"children":4383},{"className":4382},[],[4384],{"type":72,"value":651},{"type":72,"value":4386},". It already receives pre-converted ",{"type":66,"tag":81,"props":4388,"children":4390},{"className":4389},[],[4391],{"type":72,"value":667},{"type":72,"value":340},{"type":66,"tag":4363,"props":4394,"children":4395},{},[4396,4397,4402,4404,4410],{"type":72,"value":1816},{"type":66,"tag":81,"props":4398,"children":4400},{"className":4399},[],[4401],{"type":72,"value":691},{"type":72,"value":4403}," (it auto-pipes) and add ",{"type":66,"tag":81,"props":4405,"children":4407},{"className":4406},[],[4408],{"type":72,"value":4409},"...chat.toStreamTextOptions()",{"type":72,"value":4411}," first.",{"type":66,"tag":4363,"props":4413,"children":4414},{},[4415,4417,4423,4425,4431,4432,4437],{"type":72,"value":4416},"On the client, swap the ",{"type":66,"tag":81,"props":4418,"children":4420},{"className":4419},[],[4421],{"type":72,"value":4422},"api",{"type":72,"value":4424}," URL for ",{"type":66,"tag":81,"props":4426,"children":4428},{"className":4427},[],[4429],{"type":72,"value":4430},"useTriggerChatTransport",{"type":72,"value":4135},{"type":66,"tag":81,"props":4433,"children":4435},{"className":4434},[],[4436],{"type":72,"value":1798},{"type":72,"value":4438}," stays the same shape.",{"type":66,"tag":119,"props":4440,"children":4442},{"id":4441},"common-mistakes",[4443],{"type":72,"value":4444},"Common mistakes",{"type":66,"tag":4359,"props":4446,"children":4447},{},[4448,4651,4696,4721,4771,4781,4822],{"type":66,"tag":4363,"props":4449,"children":4450},{},[4451,4463,4629,4633,4635,4641,4643,4649],{"type":66,"tag":4452,"props":4453,"children":4454},"strong",{},[4455,4457,4462],{"type":72,"value":4456},"CRITICAL: forgetting ",{"type":66,"tag":81,"props":4458,"children":4460},{"className":4459},[],[4461],{"type":72,"value":4409},{"type":72,"value":340},{"type":66,"tag":138,"props":4464,"children":4466},{"className":140,"code":4465,"language":142,"meta":144,"style":144},"\u002F\u002F Wrong - compaction \u002F steering \u002F background injection silently no-op\nreturn streamText({ model, messages, abortSignal: signal });\n\u002F\u002F Correct - spread FIRST so explicit overrides win\nreturn streamText({ ...chat.toStreamTextOptions(), model, messages, abortSignal: signal });\n",[4467],{"type":66,"tag":81,"props":4468,"children":4469},{"__ignoreMap":144},[4470,4478,4538,4546],{"type":66,"tag":150,"props":4471,"children":4472},{"class":152,"line":153},[4473],{"type":66,"tag":150,"props":4474,"children":4475},{"style":461},[4476],{"type":72,"value":4477},"\u002F\u002F Wrong - compaction \u002F steering \u002F background injection silently no-op\n",{"type":66,"tag":150,"props":4479,"children":4480},{"class":152,"line":206},[4481,4486,4490,4494,4498,4502,4506,4510,4514,4518,4522,4526,4530,4534],{"type":66,"tag":150,"props":4482,"children":4483},{"style":157},[4484],{"type":72,"value":4485},"return",{"type":66,"tag":150,"props":4487,"children":4488},{"style":343},[4489],{"type":72,"value":220},{"type":66,"tag":150,"props":4491,"children":4492},{"style":169},[4493],{"type":72,"value":351},{"type":66,"tag":150,"props":4495,"children":4496},{"style":163},[4497],{"type":72,"value":1573},{"type":66,"tag":150,"props":4499,"children":4500},{"style":169},[4501],{"type":72,"value":3899},{"type":66,"tag":150,"props":4503,"children":4504},{"style":163},[4505],{"type":72,"value":225},{"type":66,"tag":150,"props":4507,"children":4508},{"style":169},[4509],{"type":72,"value":418},{"type":66,"tag":150,"props":4511,"children":4512},{"style":163},[4513],{"type":72,"value":225},{"type":66,"tag":150,"props":4515,"children":4516},{"style":363},[4517],{"type":72,"value":3916},{"type":66,"tag":150,"props":4519,"children":4520},{"style":163},[4521],{"type":72,"value":371},{"type":66,"tag":150,"props":4523,"children":4524},{"style":169},[4525],{"type":72,"value":3925},{"type":66,"tag":150,"props":4527,"children":4528},{"style":163},[4529],{"type":72,"value":634},{"type":66,"tag":150,"props":4531,"children":4532},{"style":169},[4533],{"type":72,"value":535},{"type":66,"tag":150,"props":4535,"children":4536},{"style":163},[4537],{"type":72,"value":203},{"type":66,"tag":150,"props":4539,"children":4540},{"class":152,"line":257},[4541],{"type":66,"tag":150,"props":4542,"children":4543},{"style":461},[4544],{"type":72,"value":4545},"\u002F\u002F Correct - spread FIRST so explicit overrides win\n",{"type":66,"tag":150,"props":4547,"children":4548},{"class":152,"line":299},[4549,4553,4557,4561,4565,4569,4573,4577,4581,4585,4589,4593,4597,4601,4605,4609,4613,4617,4621,4625],{"type":66,"tag":150,"props":4550,"children":4551},{"style":157},[4552],{"type":72,"value":4485},{"type":66,"tag":150,"props":4554,"children":4555},{"style":343},[4556],{"type":72,"value":220},{"type":66,"tag":150,"props":4558,"children":4559},{"style":169},[4560],{"type":72,"value":351},{"type":66,"tag":150,"props":4562,"children":4563},{"style":163},[4564],{"type":72,"value":1573},{"type":66,"tag":150,"props":4566,"children":4567},{"style":163},[4568],{"type":72,"value":3858},{"type":66,"tag":150,"props":4570,"children":4571},{"style":169},[4572],{"type":72,"value":478},{"type":66,"tag":150,"props":4574,"children":4575},{"style":163},[4576],{"type":72,"value":340},{"type":66,"tag":150,"props":4578,"children":4579},{"style":343},[4580],{"type":72,"value":487},{"type":66,"tag":150,"props":4582,"children":4583},{"style":169},[4584],{"type":72,"value":492},{"type":66,"tag":150,"props":4586,"children":4587},{"style":163},[4588],{"type":72,"value":225},{"type":66,"tag":150,"props":4590,"children":4591},{"style":169},[4592],{"type":72,"value":3899},{"type":66,"tag":150,"props":4594,"children":4595},{"style":163},[4596],{"type":72,"value":225},{"type":66,"tag":150,"props":4598,"children":4599},{"style":169},[4600],{"type":72,"value":418},{"type":66,"tag":150,"props":4602,"children":4603},{"style":163},[4604],{"type":72,"value":225},{"type":66,"tag":150,"props":4606,"children":4607},{"style":363},[4608],{"type":72,"value":3916},{"type":66,"tag":150,"props":4610,"children":4611},{"style":163},[4612],{"type":72,"value":371},{"type":66,"tag":150,"props":4614,"children":4615},{"style":169},[4616],{"type":72,"value":3925},{"type":66,"tag":150,"props":4618,"children":4619},{"style":163},[4620],{"type":72,"value":634},{"type":66,"tag":150,"props":4622,"children":4623},{"style":169},[4624],{"type":72,"value":535},{"type":66,"tag":150,"props":4626,"children":4627},{"style":163},[4628],{"type":72,"value":203},{"type":66,"tag":4630,"props":4631,"children":4632},"br",{},[],{"type":72,"value":4634},"It wires the ",{"type":66,"tag":81,"props":4636,"children":4638},{"className":4637},[],[4639],{"type":72,"value":4640},"prepareStep",{"type":72,"value":4642}," callback behind compaction, mid-turn steering, and background\ninjection, injects the system prompt from ",{"type":66,"tag":81,"props":4644,"children":4646},{"className":4645},[],[4647],{"type":72,"value":4648},"chat.prompt()",{"type":72,"value":4650},", resolves the registry model, and adds\ntelemetry. Omitting it makes all of those silently no-op with no error.",{"type":66,"tag":4363,"props":4652,"children":4653},{},[4654,4665,4667,4672,4674,4679,4681,4686,4688,4694],{"type":66,"tag":4452,"props":4655,"children":4656},{},[4657,4659,4664],{"type":72,"value":4658},"Declaring tools only on ",{"type":66,"tag":81,"props":4660,"children":4662},{"className":4661},[],[4663],{"type":72,"value":94},{"type":72,"value":340},{"type":72,"value":4666}," Also declare them on ",{"type":66,"tag":81,"props":4668,"children":4670},{"className":4669},[],[4671],{"type":72,"value":2270},{"type":72,"value":4673},", read them\nback from ",{"type":66,"tag":81,"props":4675,"children":4677},{"className":4676},[],[4678],{"type":72,"value":651},{"type":72,"value":4680},", and pass ",{"type":66,"tag":81,"props":4682,"children":4684},{"className":4683},[],[4685],{"type":72,"value":2286},{"type":72,"value":4687},". Otherwise each tool's\n",{"type":66,"tag":81,"props":4689,"children":4691},{"className":4690},[],[4692],{"type":72,"value":4693},"toModelOutput",{"type":72,"value":4695}," runs on turn 1 but is dropped when history is re-converted on later turns.",{"type":66,"tag":4363,"props":4697,"children":4698},{},[4699,4711,4713,4719],{"type":66,"tag":4452,"props":4700,"children":4701},{},[4702,4704,4709],{"type":72,"value":4703},"Not forwarding ",{"type":66,"tag":81,"props":4705,"children":4707},{"className":4706},[],[4708],{"type":72,"value":683},{"type":72,"value":4710}," for stop.",{"type":72,"value":4712}," Without ",{"type":66,"tag":81,"props":4714,"children":4716},{"className":4715},[],[4717],{"type":72,"value":4718},"abortSignal: signal",{"type":72,"value":4720},", Stop updates the UI but the\nmodel keeps generating server-side.",{"type":66,"tag":4363,"props":4722,"children":4723},{},[4724,4741,4743,4748,4750,4755,4757,4763,4764,4769],{"type":66,"tag":4452,"props":4725,"children":4726},{},[4727,4729,4734,4735,4740],{"type":72,"value":4728},"Initializing ",{"type":66,"tag":81,"props":4730,"children":4732},{"className":4731},[],[4733],{"type":72,"value":4050},{"type":72,"value":3022},{"type":66,"tag":81,"props":4736,"children":4738},{"className":4737},[],[4739],{"type":72,"value":4058},{"type":72,"value":340},{"type":72,"value":4742}," Initialize it in ",{"type":66,"tag":81,"props":4744,"children":4746},{"className":4745},[],[4747],{"type":72,"value":4042},{"type":72,"value":4749},". ",{"type":66,"tag":81,"props":4751,"children":4753},{"className":4752},[],[4754],{"type":72,"value":4058},{"type":72,"value":4756}," fires\nonce per chat, so continuation runs skip it and crash with\n",{"type":66,"tag":81,"props":4758,"children":4760},{"className":4759},[],[4761],{"type":72,"value":4762},"chat.local can only be modified after initialization",{"type":72,"value":4749},{"type":66,"tag":81,"props":4765,"children":4767},{"className":4766},[],[4768],{"type":72,"value":4042},{"type":72,"value":4770}," fires on every fresh worker.",{"type":66,"tag":4363,"props":4772,"children":4773},{},[4774,4779],{"type":66,"tag":4452,"props":4775,"children":4776},{},[4777],{"type":72,"value":4778},"Minting tokens in the browser.",{"type":72,"value":4780}," Never expose the environment secret key client-side. Mint via\nthe two server actions; the transport calls them.",{"type":66,"tag":4363,"props":4782,"children":4783},{},[4784,4804,4806,4812,4814,4820],{"type":66,"tag":4452,"props":4785,"children":4786},{},[4787,4789,4795,4797,4803],{"type":72,"value":4788},"Clearing ",{"type":66,"tag":81,"props":4790,"children":4792},{"className":4791},[],[4793],{"type":72,"value":4794},"lastEventId",{"type":72,"value":4796}," on ",{"type":66,"tag":81,"props":4798,"children":4800},{"className":4799},[],[4801],{"type":72,"value":4802},"chat.endRun()",{"type":72,"value":340},{"type":72,"value":4805}," Keep the cursor for the Session lifetime; clear it\nonly when the Session itself closes. It is sessionId-keyed, so clearing forces a resubscribe from\n",{"type":66,"tag":81,"props":4807,"children":4809},{"className":4808},[],[4810],{"type":72,"value":4811},"seq_num=0",{"type":72,"value":4813}," that can hit the prior turn's stale ",{"type":66,"tag":81,"props":4815,"children":4817},{"className":4816},[],[4818],{"type":72,"value":4819},"turn-complete",{"type":72,"value":4821}," and close the stream empty.",{"type":66,"tag":4363,"props":4823,"children":4824},{},[4825,4837],{"type":66,"tag":4452,"props":4826,"children":4827},{},[4828,4830,4836],{"type":72,"value":4829},"Returning the raw error from ",{"type":66,"tag":81,"props":4831,"children":4833},{"className":4832},[],[4834],{"type":72,"value":4835},"uiMessageStreamOptions.onError",{"type":72,"value":340},{"type":72,"value":4838}," It leaks internals (keys,\nstack traces). Return a sanitized string instead.",{"type":66,"tag":119,"props":4840,"children":4842},{"id":4841},"references",[4843],{"type":72,"value":4844},"References",{"type":66,"tag":4359,"props":4846,"children":4847},{},[4848,4880,4891],{"type":66,"tag":4363,"props":4849,"children":4850},{},[4851,4857,4859,4865,4866,4872,4873,4878],{"type":66,"tag":81,"props":4852,"children":4854},{"className":4853},[],[4855],{"type":72,"value":4856},"trigger-chat-agent-advanced",{"type":72,"value":4858}," skill - lifecycle hooks in depth, sessions, raw-task primitives\n(",{"type":66,"tag":81,"props":4860,"children":4862},{"className":4861},[],[4863],{"type":72,"value":4864},"chat.createSession",{"type":72,"value":2975},{"type":66,"tag":81,"props":4867,"children":4869},{"className":4868},[],[4870],{"type":72,"value":4871},"chat.customAgent",{"type":72,"value":2975},{"type":66,"tag":81,"props":4874,"children":4876},{"className":4875},[],[4877],{"type":72,"value":3067},{"type":72,"value":4879},"), compaction, HITL approvals, recovery.",{"type":66,"tag":4363,"props":4881,"children":4882},{},[4883,4889],{"type":66,"tag":81,"props":4884,"children":4886},{"className":4885},[],[4887],{"type":72,"value":4888},"trigger-realtime-and-frontend",{"type":72,"value":4890}," skill - Realtime hooks and frontend streaming beyond the chat transport.",{"type":66,"tag":4363,"props":4892,"children":4893},{},[4894,4900,4902,4908,4910,4916],{"type":66,"tag":81,"props":4895,"children":4897},{"className":4896},[],[4898],{"type":72,"value":4899},"trigger-authoring-tasks",{"type":72,"value":4901}," skill - base ",{"type":66,"tag":81,"props":4903,"children":4905},{"className":4904},[],[4906],{"type":72,"value":4907},"task()",{"type":72,"value":4909}," semantics, ",{"type":66,"tag":81,"props":4911,"children":4913},{"className":4912},[],[4914],{"type":72,"value":4915},"ctx",{"type":72,"value":4917},", and standard lifecycle hooks.",{"type":66,"tag":75,"props":4919,"children":4920},{},[4921,4923,4929,4931,4937,4939,4945,4946,4952,4953,4959,4960,4966,4967,4973],{"type":72,"value":4922},"Reference docs ship beside this skill in the same package, read them locally (no network), pinned to your installed version. The ",{"type":66,"tag":81,"props":4924,"children":4926},{"className":4925},[],[4927],{"type":72,"value":4928},"sources:",{"type":72,"value":4930}," frontmatter above lists every doc this skill draws from, all under ",{"type":66,"tag":81,"props":4932,"children":4934},{"className":4933},[],[4935],{"type":72,"value":4936},"@trigger.dev\u002Fsdk\u002Fdocs\u002Fai-chat\u002F",{"type":72,"value":4938},". Start with ",{"type":66,"tag":81,"props":4940,"children":4942},{"className":4941},[],[4943],{"type":72,"value":4944},"quick-start.mdx",{"type":72,"value":2975},{"type":66,"tag":81,"props":4947,"children":4949},{"className":4948},[],[4950],{"type":72,"value":4951},"backend.mdx",{"type":72,"value":2975},{"type":66,"tag":81,"props":4954,"children":4956},{"className":4955},[],[4957],{"type":72,"value":4958},"tools.mdx",{"type":72,"value":2975},{"type":66,"tag":81,"props":4961,"children":4963},{"className":4962},[],[4964],{"type":72,"value":4965},"types.mdx",{"type":72,"value":2975},{"type":66,"tag":81,"props":4968,"children":4970},{"className":4969},[],[4971],{"type":72,"value":4972},"frontend.mdx",{"type":72,"value":340},{"type":66,"tag":75,"props":4975,"children":4976},{},[4977,4978,4983,4985,4991,4993,4999,5001,5007,5009,5015],{"type":72,"value":79},{"type":66,"tag":81,"props":4979,"children":4981},{"className":4980},[],[4982],{"type":72,"value":86},{"type":72,"value":4984}," is a Trigger.dev task, so it builds and deploys like any other. For ",{"type":66,"tag":81,"props":4986,"children":4988},{"className":4987},[],[4989],{"type":72,"value":4990},"trigger.config.ts",{"type":72,"value":4992}," and build extensions (Prisma, Playwright, Python, FFmpeg, etc. — e.g. when a tool needs them), read the bundled config docs under ",{"type":66,"tag":81,"props":4994,"children":4996},{"className":4995},[],[4997],{"type":72,"value":4998},"@trigger.dev\u002Fsdk\u002Fdocs\u002Fconfig\u002F",{"type":72,"value":5000}," (extensions are in ",{"type":66,"tag":81,"props":5002,"children":5004},{"className":5003},[],[5005],{"type":72,"value":5006},"config\u002Fextensions\u002F",{"type":72,"value":5008},", starting with ",{"type":66,"tag":81,"props":5010,"children":5012},{"className":5011},[],[5013],{"type":72,"value":5014},"overview.mdx",{"type":72,"value":5016},").",{"type":66,"tag":119,"props":5018,"children":5020},{"id":5019},"version",[5021],{"type":72,"value":5022},"Version",{"type":66,"tag":75,"props":5024,"children":5025},{},[5026,5028,5033,5035,5041,5043,5049,5051,5057],{"type":72,"value":5027},"This skill is bundled inside ",{"type":66,"tag":81,"props":5029,"children":5031},{"className":5030},[],[5032],{"type":72,"value":765},{"type":72,"value":5034}," and read directly from ",{"type":66,"tag":81,"props":5036,"children":5038},{"className":5037},[],[5039],{"type":72,"value":5040},"node_modules",{"type":72,"value":5042},", so it always matches your installed SDK version (see the adjacent ",{"type":66,"tag":81,"props":5044,"children":5046},{"className":5045},[],[5047],{"type":72,"value":5048},"package.json",{"type":72,"value":5050},"). The full documentation for these APIs ships alongside it under ",{"type":66,"tag":81,"props":5052,"children":5054},{"className":5053},[],[5055],{"type":72,"value":5056},"@trigger.dev\u002Fsdk\u002Fdocs\u002F",{"type":72,"value":340},{"type":66,"tag":5059,"props":5060,"children":5061},"style",{},[5062],{"type":72,"value":5063},"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":5065,"total":5220},[5066,5073,5085,5094,5109,5124,5138,5155,5168,5180,5191,5205],{"slug":4,"name":4,"fn":5,"description":6,"org":5067,"tags":5068,"stars":24,"repoUrl":25,"updatedAt":26},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5069,5070,5071,5072],{"name":16,"slug":17,"type":14},{"name":19,"slug":20,"type":14},{"name":9,"slug":8,"type":14},{"name":22,"slug":23,"type":14},{"slug":4899,"name":4899,"fn":5074,"description":5075,"org":5076,"tags":5077,"stars":24,"repoUrl":25,"updatedAt":5084},"author backend Trigger.dev tasks","Covers writing backend Trigger.dev tasks with @trigger.dev\u002Fsdk: defining task() and schemaTask(), the run function and its ctx, retries, waits, queues and concurrency, idempotency keys, run metadata, logging, triggering other tasks (and the Result shape), scheduled\u002Fcron tasks, and the essentials of trigger.config.ts. Load this whenever you are authoring or editing code inside a \u002Ftrigger directory, defining a task, or writing backend code that triggers tasks. Realtime\u002FReact hooks and AI chat are covered by separate skills.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5078,5081,5082,5083],{"name":5079,"slug":5080,"type":14},"Backend","backend",{"name":19,"slug":20,"type":14},{"name":9,"slug":8,"type":14},{"name":22,"slug":23,"type":14},"2026-07-02T17:12:48.396964",{"slug":4856,"name":4856,"fn":5086,"description":5087,"org":5088,"tags":5089,"stars":24,"repoUrl":25,"updatedAt":5093},"manage Trigger.dev chat sessions and transports","Advanced and operational chat.agent capabilities for Trigger.dev, loaded on demand. Load this when working on the raw Sessions primitive (sessions \u002F SessionHandle), a custom chat transport or the realtime wire protocol, durable sub-agents (AgentChat, chat.stream.writer), human-in-the-loop, steering, actions, background injection (chat.defer \u002F chat.inject), fast starts (preload, Head Start via @trigger.dev\u002Fsdk\u002Fchat-server), context resilience (compaction, recovery boot, OOM, large payloads), chat.local run-scoped state, offline testing with mockChatAgent, or prerelease\u002Fversion upgrades. For the everyday chat.agent({...}) definition and the useTriggerChatTransport happy path, use the trigger-authoring-chat-agent skill instead.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5090,5091,5092],{"name":16,"slug":17,"type":14},{"name":9,"slug":8,"type":14},{"name":22,"slug":23,"type":14},"2026-07-02T17:12:51.03018",{"slug":4888,"name":4888,"fn":5095,"description":5096,"org":5097,"tags":5098,"stars":24,"repoUrl":25,"updatedAt":5108},"subscribe to Trigger.dev runs in realtime","Trigger.dev client\u002Ffrontend surface: subscribe to runs in realtime (runs.subscribeToRun and the @trigger.dev\u002Freact-hooks hook useRealtimeRun), consume metadata and AI\u002Ftext streams in React (useRealtimeStream), trigger tasks from the browser (useTaskTrigger, useRealtimeTaskTrigger), and mint scoped frontend credentials with auth.createPublicToken \u002F auth.createTriggerPublicToken. Load when wiring a frontend (React\u002FNext.js\u002FRemix) or backend-for-frontend to show live run progress, status badges, token streams, trigger buttons, or wait-token approval UIs. NOT for writing the backend task itself (streams.define \u002F metadata.set is trigger-authoring-tasks territory); this is the consumer side.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5099,5102,5104,5107],{"name":5100,"slug":5101,"type":14},"Frontend","frontend",{"name":5103,"slug":1181,"type":14},"React",{"name":5105,"slug":5106,"type":14},"Real-time","real-time",{"name":9,"slug":8,"type":14},"2026-07-02T17:12:49.717706",{"slug":5110,"name":5110,"fn":5111,"description":5112,"org":5113,"tags":5114,"stars":5121,"repoUrl":5122,"updatedAt":5123},"trigger-agents","orchestrate AI agents with Trigger.dev","AI agent patterns with Trigger.dev - orchestration, parallelization, routing, evaluator-optimizer, and human-in-the-loop. Use when building LLM-powered tasks that need parallel workers, approval gates, tool calling, or multi-step agent workflows.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5115,5116,5119,5120],{"name":16,"slug":17,"type":14},{"name":5117,"slug":5118,"type":14},"Multi-Agent","multi-agent",{"name":9,"slug":8,"type":14},{"name":22,"slug":23,"type":14},30,"https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fskills","2026-04-06T18:54:46.023553",{"slug":5125,"name":5125,"fn":5126,"description":5127,"org":5128,"tags":5129,"stars":5121,"repoUrl":5122,"updatedAt":5137},"trigger-config","configure Trigger.dev project settings","Configure Trigger.dev projects with trigger.config.ts. Use when setting up build extensions for Prisma, Playwright, FFmpeg, Python, or customizing deployment settings.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5130,5133,5136],{"name":5131,"slug":5132,"type":14},"Configuration","configuration",{"name":5134,"slug":5135,"type":14},"Deployment","deployment",{"name":9,"slug":8,"type":14},"2026-04-06T18:54:44.764258",{"slug":5139,"name":5139,"fn":5140,"description":5141,"org":5142,"tags":5143,"stars":5121,"repoUrl":5122,"updatedAt":5154},"trigger-cost-savings","optimize Trigger.dev task costs","Analyze Trigger.dev tasks, schedules, and runs for cost optimization opportunities. Use when asked to reduce spend, optimize costs, audit usage, right-size machines, or review task efficiency. Requires Trigger.dev MCP tools for run analysis.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5144,5147,5150,5153],{"name":5145,"slug":5146,"type":14},"Analytics","analytics",{"name":5148,"slug":5149,"type":14},"Cost Optimization","cost-optimization",{"name":5151,"slug":5152,"type":14},"Operations","operations",{"name":9,"slug":8,"type":14},"2026-04-06T18:54:48.555552",{"slug":5156,"name":5156,"fn":5157,"description":5158,"org":5159,"tags":5160,"stars":5121,"repoUrl":5122,"updatedAt":5167},"trigger-realtime","monitor Trigger.dev tasks in real-time","Subscribe to Trigger.dev task runs in real-time from frontend and backend. Use when building progress indicators, live dashboards, streaming AI\u002FLLM responses, or React components that display task status.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5161,5162,5165,5166],{"name":5100,"slug":5101,"type":14},{"name":5163,"slug":5164,"type":14},"Observability","observability",{"name":5105,"slug":5106,"type":14},{"name":9,"slug":8,"type":14},"2026-04-06T18:54:47.293822",{"slug":5169,"name":5169,"fn":5170,"description":5171,"org":5172,"tags":5173,"stars":5121,"repoUrl":5122,"updatedAt":5179},"trigger-setup","set up Trigger.dev in projects","Set up Trigger.dev in your project. Use when adding Trigger.dev for the first time, creating trigger.config.ts, or initializing the trigger directory.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5174,5175,5178],{"name":5131,"slug":5132,"type":14},{"name":5176,"slug":5177,"type":14},"Local Development","local-development",{"name":9,"slug":8,"type":14},"2026-04-06T18:54:42.280816",{"slug":5181,"name":5181,"fn":5182,"description":5183,"org":5184,"tags":5185,"stars":5121,"repoUrl":5122,"updatedAt":5190},"trigger-tasks","build durable background tasks with Trigger.dev","Build AI agents, workflows and durable background tasks with Trigger.dev. Use when creating tasks, triggering jobs, handling retries, scheduling cron jobs, or implementing queues and concurrency control.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5186,5187,5188,5189],{"name":16,"slug":17,"type":14},{"name":5079,"slug":5080,"type":14},{"name":9,"slug":8,"type":14},{"name":22,"slug":23,"type":14},"2026-04-06T18:54:43.514369",{"slug":5192,"name":5192,"fn":5193,"description":5194,"org":5195,"tags":5196,"stars":257,"repoUrl":5203,"updatedAt":5204},"staff-engineering-skills-backpressure","implement backpressure in streaming pipelines","Prevent unbounded resource growth when producers outpace consumers. Use when writing producer-consumer code, queue processing, batch operations, fan-out patterns, streaming pipelines, or any code where work is generated faster than it can be processed. Activates on patterns like Promise.all on dynamic-sized arrays, unbounded in-memory queues, producer loops without depth checks, fire-and-forget async calls in loops, or any buffer between a producer and consumer without a size limit.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5197,5200],{"name":5198,"slug":5199,"type":14},"Architecture","architecture",{"name":5201,"slug":5202,"type":14},"Performance","performance","https:\u002F\u002Fgithub.com\u002Ftriggerdotdev\u002Fstaff-engineering-skills","2026-06-17T08:40:42.723559",{"slug":5206,"name":5206,"fn":5207,"description":5208,"org":5209,"tags":5210,"stars":257,"repoUrl":5203,"updatedAt":5219},"staff-engineering-skills-cache-invalidation","implement cache invalidation strategies","Prevent stale data bugs caused by missing or incomplete cache invalidation. Use when adding caching layers (Redis, in-memory Map, CDN, HTTP cache headers), optimizing read performance, or reviewing code that caches query results, API responses, or computed values. Activates on patterns like cache.set without cache.delete on write paths, unbounded Map\u002Fobject caches, TTL-only invalidation on security-sensitive data, Cache-Control headers on mutable content, or any caching where the write path doesn't invalidate the read cache.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5211,5212,5215,5218],{"name":5198,"slug":5199,"type":14},{"name":5213,"slug":5214,"type":14},"Caching","caching",{"name":5216,"slug":5217,"type":14},"Engineering","engineering",{"name":5201,"slug":5202,"type":14},"2026-06-17T08:40:45.194583",26,{"items":5222,"total":299},[5223,5230,5237,5243],{"slug":4,"name":4,"fn":5,"description":6,"org":5224,"tags":5225,"stars":24,"repoUrl":25,"updatedAt":26},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5226,5227,5228,5229],{"name":16,"slug":17,"type":14},{"name":19,"slug":20,"type":14},{"name":9,"slug":8,"type":14},{"name":22,"slug":23,"type":14},{"slug":4899,"name":4899,"fn":5074,"description":5075,"org":5231,"tags":5232,"stars":24,"repoUrl":25,"updatedAt":5084},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5233,5234,5235,5236],{"name":5079,"slug":5080,"type":14},{"name":19,"slug":20,"type":14},{"name":9,"slug":8,"type":14},{"name":22,"slug":23,"type":14},{"slug":4856,"name":4856,"fn":5086,"description":5087,"org":5238,"tags":5239,"stars":24,"repoUrl":25,"updatedAt":5093},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5240,5241,5242],{"name":16,"slug":17,"type":14},{"name":9,"slug":8,"type":14},{"name":22,"slug":23,"type":14},{"slug":4888,"name":4888,"fn":5095,"description":5096,"org":5244,"tags":5245,"stars":24,"repoUrl":25,"updatedAt":5108},{"slug":8,"name":9,"logoUrl":10,"githubOrg":11},[5246,5247,5248,5249],{"name":5100,"slug":5101,"type":14},{"name":5103,"slug":1181,"type":14},{"name":5105,"slug":5106,"type":14},{"name":9,"slug":8,"type":14}]