[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill-openai-building-ai-agent-on-cloudflare":3,"mdc--xd24gl-key":36,"related-org-openai-building-ai-agent-on-cloudflare":6240,"related-repo-openai-building-ai-agent-on-cloudflare":6441},{"slug":4,"name":4,"fn":5,"description":6,"org":7,"tags":11,"stars":25,"repoUrl":26,"updatedAt":27,"license":28,"forks":29,"topics":30,"repo":31,"sourceUrl":34,"mdContent":35},"building-ai-agent-on-cloudflare","build AI agents on Cloudflare","Builds AI agents on Cloudflare using the Agents SDK with state management,\nreal-time WebSockets, scheduled tasks, tool integration, and chat capabilities.\nGenerates production-ready agent code deployed to Workers.\n\nUse when: user wants to \"build an agent\", \"AI agent\", \"chat agent\", \"stateful\nagent\", mentions \"Agents SDK\", needs \"real-time AI\", \"WebSocket AI\", or asks\nabout agent \"state management\", \"scheduled tasks\", or \"tool calling\".\nBiases towards retrieval from Cloudflare docs over pre-trained knowledge.\n",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},"openai","OpenAI","https:\u002F\u002Fpexgzepcugksgbtrxkhf.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Forg-logos\u002Fopenai.png",[12,16,19,22],{"name":13,"slug":14,"type":15},"Cloudflare Workers","cloudflare-workers","tag",{"name":17,"slug":18,"type":15},"WebSockets","websockets",{"name":20,"slug":21,"type":15},"Cloudflare","cloudflare",{"name":23,"slug":24,"type":15},"Agents","agents",3992,"https:\u002F\u002Fgithub.com\u002Fopenai\u002Fplugins","2026-04-06T18:39:54.244887",null,465,[],{"repoUrl":26,"stars":25,"forks":29,"topics":32,"description":33},[],"OpenAI Plugins","https:\u002F\u002Fgithub.com\u002Fopenai\u002Fplugins\u002Ftree\u002FHEAD\u002Fplugins\u002Fcloudflare\u002Fskills\u002Fbuilding-ai-agent-on-cloudflare","---\nname: building-ai-agent-on-cloudflare\ndescription: |\n  Builds AI agents on Cloudflare using the Agents SDK with state management,\n  real-time WebSockets, scheduled tasks, tool integration, and chat capabilities.\n  Generates production-ready agent code deployed to Workers.\n\n  Use when: user wants to \"build an agent\", \"AI agent\", \"chat agent\", \"stateful\n  agent\", mentions \"Agents SDK\", needs \"real-time AI\", \"WebSocket AI\", or asks\n  about agent \"state management\", \"scheduled tasks\", or \"tool calling\".\n  Biases towards retrieval from Cloudflare docs over pre-trained knowledge.\n---\n\n# Building Cloudflare Agents\n\nYour knowledge of the Agents SDK may be outdated. **Prefer retrieval over pre-training** for any agent-building task.\n\n## Retrieval Sources\n\n| Source | How to retrieve | Use for |\n|--------|----------------|---------|\n| Agents SDK docs | `https:\u002F\u002Fgithub.com\u002Fcloudflare\u002Fagents\u002Ftree\u002Fmain\u002Fdocs` | SDK API, state, routing, scheduling |\n| Cloudflare Agents docs | `https:\u002F\u002Fdevelopers.cloudflare.com\u002Fagents\u002F` | Platform integration, deployment |\n| Workers docs | Search tool or `https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002F` | Runtime APIs, bindings, config |\n\n## When to Use\n\n- User wants to build an AI agent or chatbot\n- User needs stateful, real-time AI interactions\n- User asks about the Cloudflare Agents SDK\n- User wants scheduled tasks or background AI work\n- User needs WebSocket-based AI communication\n\n## Prerequisites\n\n- Cloudflare account with Workers enabled\n- Node.js 18+ and npm\u002Fpnpm\u002Fyarn\n- Wrangler CLI (`npm install -g wrangler`)\n\n## Quick Start\n\n```bash\nnpm create cloudflare@latest -- my-agent --template=cloudflare\u002Fagents-starter\ncd my-agent\nnpm start\n```\n\nAgent runs at `http:\u002F\u002Flocalhost:8787`\n\n## Core Concepts\n\n### What is an Agent?\n\nAn Agent is a stateful, persistent AI service that:\n- Maintains state across requests and reconnections\n- Communicates via WebSockets or HTTP\n- Runs on Cloudflare's edge via Durable Objects\n- Can schedule tasks and call tools\n- Scales horizontally (each user\u002Fsession gets own instance)\n\n### Agent Lifecycle\n\n```\nClient connects → Agent.onConnect() → Agent processes messages\n                                    → Agent.onMessage()\n                                    → Agent.setState() (persists + syncs)\nClient disconnects → State persists → Client reconnects → State restored\n```\n\n## Basic Agent Structure\n\n```typescript\nimport { Agent, Connection } from \"agents\";\n\ninterface Env {\n  AI: Ai;  \u002F\u002F Workers AI binding\n}\n\ninterface State {\n  messages: Array\u003C{ role: string; content: string }>;\n  preferences: Record\u003Cstring, string>;\n}\n\nexport class MyAgent extends Agent\u003CEnv, State> {\n  \u002F\u002F Initial state for new instances\n  initialState: State = {\n    messages: [],\n    preferences: {},\n  };\n\n  \u002F\u002F Called when agent starts or resumes\n  async onStart() {\n    console.log(\"Agent started with state:\", this.state);\n  }\n\n  \u002F\u002F Handle WebSocket connections\n  async onConnect(connection: Connection) {\n    connection.send(JSON.stringify({\n      type: \"welcome\",\n      history: this.state.messages,\n    }));\n  }\n\n  \u002F\u002F Handle incoming messages\n  async onMessage(connection: Connection, message: string) {\n    const data = JSON.parse(message);\n\n    if (data.type === \"chat\") {\n      await this.handleChat(connection, data.content);\n    }\n  }\n\n  \u002F\u002F Handle disconnections\n  async onClose(connection: Connection) {\n    console.log(\"Client disconnected\");\n  }\n\n  \u002F\u002F React to state changes\n  onStateUpdate(state: State, source: string) {\n    console.log(\"State updated by:\", source);\n  }\n\n  private async handleChat(connection: Connection, userMessage: string) {\n    \u002F\u002F Add user message to history\n    const messages = [\n      ...this.state.messages,\n      { role: \"user\", content: userMessage },\n    ];\n\n    \u002F\u002F Call AI\n    const response = await this.env.AI.run(\"@cf\u002Fmeta\u002Fllama-3-8b-instruct\", {\n      messages,\n    });\n\n    \u002F\u002F Update state (persists and syncs to all clients)\n    this.setState({\n      ...this.state,\n      messages: [\n        ...messages,\n        { role: \"assistant\", content: response.response },\n      ],\n    });\n\n    \u002F\u002F Send response\n    connection.send(JSON.stringify({\n      type: \"response\",\n      content: response.response,\n    }));\n  }\n}\n```\n\n## Entry Point Configuration\n\n```typescript\n\u002F\u002F src\u002Findex.ts\nimport { routeAgentRequest } from \"agents\";\nimport { MyAgent } from \".\u002Fagent\";\n\nexport default {\n  async fetch(request: Request, env: Env) {\n    \u002F\u002F routeAgentRequest handles routing to \u002Fagents\u002F:class\u002F:name\n    return (\n      (await routeAgentRequest(request, env)) ||\n      new Response(\"Not found\", { status: 404 })\n    );\n  },\n};\n\nexport { MyAgent };\n```\n\nClients connect via: `wss:\u002F\u002Fmy-agent.workers.dev\u002Fagents\u002FMyAgent\u002Fsession-id`\n\n## Wrangler Configuration\n\n```toml\nname = \"my-agent\"\nmain = \"src\u002Findex.ts\"\ncompatibility_date = \"2024-12-01\"\n\n[ai]\nbinding = \"AI\"\n\n[durable_objects]\nbindings = [{ name = \"AGENT\", class_name = \"MyAgent\" }]\n\n[[migrations]]\ntag = \"v1\"\nnew_classes = [\"MyAgent\"]\n```\n\n## State Management\n\n### Reading State\n\n```typescript\n\u002F\u002F Current state is always available\nconst currentMessages = this.state.messages;\nconst userPrefs = this.state.preferences;\n```\n\n### Updating State\n\n```typescript\n\u002F\u002F setState persists AND syncs to all connected clients\nthis.setState({\n  ...this.state,\n  messages: [...this.state.messages, newMessage],\n});\n\n\u002F\u002F Partial updates work too\nthis.setState({\n  preferences: { ...this.state.preferences, theme: \"dark\" },\n});\n```\n\n### SQL Storage\n\nFor complex queries, use the embedded SQLite database:\n\n```typescript\n\u002F\u002F Create tables\nawait this.sql`\n  CREATE TABLE IF NOT EXISTS documents (\n    id INTEGER PRIMARY KEY AUTOINCREMENT,\n    title TEXT NOT NULL,\n    content TEXT,\n    created_at DATETIME DEFAULT CURRENT_TIMESTAMP\n  )\n`;\n\n\u002F\u002F Insert\nawait this.sql`\n  INSERT INTO documents (title, content)\n  VALUES (${title}, ${content})\n`;\n\n\u002F\u002F Query\nconst docs = await this.sql`\n  SELECT * FROM documents WHERE title LIKE ${`%${search}%`}\n`;\n```\n\n## Scheduled Tasks\n\nAgents can schedule future work:\n\n```typescript\nasync onMessage(connection: Connection, message: string) {\n  const data = JSON.parse(message);\n\n  if (data.type === \"schedule_reminder\") {\n    \u002F\u002F Schedule task for 1 hour from now\n    const { id } = await this.schedule(3600, \"sendReminder\", {\n      message: data.reminderText,\n      userId: data.userId,\n    });\n\n    connection.send(JSON.stringify({ type: \"scheduled\", taskId: id }));\n  }\n}\n\n\u002F\u002F Called when scheduled task fires\nasync sendReminder(data: { message: string; userId: string }) {\n  \u002F\u002F Send notification, email, etc.\n  console.log(`Reminder for ${data.userId}: ${data.message}`);\n\n  \u002F\u002F Can also update state\n  this.setState({\n    ...this.state,\n    lastReminder: new Date().toISOString(),\n  });\n}\n```\n\n### Schedule Options\n\n```typescript\n\u002F\u002F Delay in seconds\nawait this.schedule(60, \"taskMethod\", { data });\n\n\u002F\u002F Specific date\nawait this.schedule(new Date(\"2025-01-01T00:00:00Z\"), \"taskMethod\", { data });\n\n\u002F\u002F Cron expression (recurring)\nawait this.schedule(\"0 9 * * *\", \"dailyTask\", {});  \u002F\u002F 9 AM daily\nawait this.schedule(\"*\u002F5 * * * *\", \"everyFiveMinutes\", {});  \u002F\u002F Every 5 min\n\n\u002F\u002F Manage schedules\nconst schedules = await this.getSchedules();\nawait this.cancelSchedule(taskId);\n```\n\n## Chat Agent (AI-Powered)\n\nFor chat-focused agents, extend `AIChatAgent`:\n\n```typescript\nimport { AIChatAgent } from \"agents\u002Fai-chat-agent\";\n\nexport class ChatBot extends AIChatAgent\u003CEnv> {\n  \u002F\u002F Called for each user message\n  async onChatMessage(message: string) {\n    const response = await this.env.AI.run(\"@cf\u002Fmeta\u002Fllama-3-8b-instruct\", {\n      messages: [\n        { role: \"system\", content: \"You are a helpful assistant.\" },\n        ...this.messages,  \u002F\u002F Automatic history management\n        { role: \"user\", content: message },\n      ],\n      stream: true,\n    });\n\n    \u002F\u002F Stream response back to client\n    return response;\n  }\n}\n```\n\nFeatures included:\n- Automatic message history\n- Resumable streaming (survives disconnects)\n- Built-in `saveMessages()` for persistence\n\n## Client Integration\n\n### React Hook\n\n```tsx\nimport { useAgent } from \"agents\u002Freact\";\n\nfunction Chat() {\n  const { state, send, connected } = useAgent({\n    agent: \"my-agent\",\n    name: userId,  \u002F\u002F Agent instance ID\n  });\n\n  const sendMessage = (text: string) => {\n    send(JSON.stringify({ type: \"chat\", content: text }));\n  };\n\n  return (\n    \u003Cdiv>\n      {state.messages.map((msg, i) => (\n        \u003Cdiv key={i}>{msg.role}: {msg.content}\u003C\u002Fdiv>\n      ))}\n      \u003Cinput onKeyDown={(e) => e.key === \"Enter\" && sendMessage(e.target.value)} \u002F>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Vanilla JavaScript\n\n```javascript\nconst ws = new WebSocket(\"wss:\u002F\u002Fmy-agent.workers.dev\u002Fagents\u002FMyAgent\u002Fuser123\");\n\nws.onopen = () => {\n  console.log(\"Connected to agent\");\n};\n\nws.onmessage = (event) => {\n  const data = JSON.parse(event.data);\n  console.log(\"Received:\", data);\n};\n\nws.send(JSON.stringify({ type: \"chat\", content: \"Hello!\" }));\n```\n\n## Common Patterns\n\nSee [references\u002Fagent-patterns.md](references\u002Fagent-patterns.md) for:\n- Tool calling and function execution\n- Multi-agent orchestration\n- RAG (Retrieval Augmented Generation)\n- Human-in-the-loop workflows\n\n## Deployment\n\n```bash\n# Deploy\nnpx wrangler deploy\n\n# View logs\nwrangler tail\n\n# Test endpoint\ncurl https:\u002F\u002Fmy-agent.workers.dev\u002Fagents\u002FMyAgent\u002Ftest-user\n```\n\n## Troubleshooting\n\nSee [references\u002Ftroubleshooting.md](references\u002Ftroubleshooting.md) for common issues.\n\n## References\n\n- [references\u002Fexamples.md](references\u002Fexamples.md) — Official templates and production examples\n- [references\u002Fagent-patterns.md](references\u002Fagent-patterns.md) — Advanced patterns\n- [references\u002Fstate-patterns.md](references\u002Fstate-patterns.md) — State management strategies\n- [references\u002Ftroubleshooting.md](references\u002Ftroubleshooting.md) — Error solutions\n",{"data":37,"body":38},{"name":4,"description":6},{"type":39,"children":40},"root",[41,50,64,71,173,179,209,215,241,247,324,335,341,348,353,381,387,397,403,2227,2233,2587,2598,2604,2714,2720,2726,2816,2822,3046,3052,3057,3347,3353,3358,4028,4034,4452,4458,4470,4908,4913,4939,4945,4951,5626,5632,6033,6039,6052,6075,6081,6170,6176,6187,6193,6234],{"type":42,"tag":43,"props":44,"children":46},"element","h1",{"id":45},"building-cloudflare-agents",[47],{"type":48,"value":49},"text","Building Cloudflare Agents",{"type":42,"tag":51,"props":52,"children":53},"p",{},[54,56,62],{"type":48,"value":55},"Your knowledge of the Agents SDK may be outdated. ",{"type":42,"tag":57,"props":58,"children":59},"strong",{},[60],{"type":48,"value":61},"Prefer retrieval over pre-training",{"type":48,"value":63}," for any agent-building task.",{"type":42,"tag":65,"props":66,"children":68},"h2",{"id":67},"retrieval-sources",[69],{"type":48,"value":70},"Retrieval Sources",{"type":42,"tag":72,"props":73,"children":74},"table",{},[75,99],{"type":42,"tag":76,"props":77,"children":78},"thead",{},[79],{"type":42,"tag":80,"props":81,"children":82},"tr",{},[83,89,94],{"type":42,"tag":84,"props":85,"children":86},"th",{},[87],{"type":48,"value":88},"Source",{"type":42,"tag":84,"props":90,"children":91},{},[92],{"type":48,"value":93},"How to retrieve",{"type":42,"tag":84,"props":95,"children":96},{},[97],{"type":48,"value":98},"Use for",{"type":42,"tag":100,"props":101,"children":102},"tbody",{},[103,127,149],{"type":42,"tag":80,"props":104,"children":105},{},[106,112,122],{"type":42,"tag":107,"props":108,"children":109},"td",{},[110],{"type":48,"value":111},"Agents SDK docs",{"type":42,"tag":107,"props":113,"children":114},{},[115],{"type":42,"tag":116,"props":117,"children":119},"code",{"className":118},[],[120],{"type":48,"value":121},"https:\u002F\u002Fgithub.com\u002Fcloudflare\u002Fagents\u002Ftree\u002Fmain\u002Fdocs",{"type":42,"tag":107,"props":123,"children":124},{},[125],{"type":48,"value":126},"SDK API, state, routing, scheduling",{"type":42,"tag":80,"props":128,"children":129},{},[130,135,144],{"type":42,"tag":107,"props":131,"children":132},{},[133],{"type":48,"value":134},"Cloudflare Agents docs",{"type":42,"tag":107,"props":136,"children":137},{},[138],{"type":42,"tag":116,"props":139,"children":141},{"className":140},[],[142],{"type":48,"value":143},"https:\u002F\u002Fdevelopers.cloudflare.com\u002Fagents\u002F",{"type":42,"tag":107,"props":145,"children":146},{},[147],{"type":48,"value":148},"Platform integration, deployment",{"type":42,"tag":80,"props":150,"children":151},{},[152,157,168],{"type":42,"tag":107,"props":153,"children":154},{},[155],{"type":48,"value":156},"Workers docs",{"type":42,"tag":107,"props":158,"children":159},{},[160,162],{"type":48,"value":161},"Search tool or ",{"type":42,"tag":116,"props":163,"children":165},{"className":164},[],[166],{"type":48,"value":167},"https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002F",{"type":42,"tag":107,"props":169,"children":170},{},[171],{"type":48,"value":172},"Runtime APIs, bindings, config",{"type":42,"tag":65,"props":174,"children":176},{"id":175},"when-to-use",[177],{"type":48,"value":178},"When to Use",{"type":42,"tag":180,"props":181,"children":182},"ul",{},[183,189,194,199,204],{"type":42,"tag":184,"props":185,"children":186},"li",{},[187],{"type":48,"value":188},"User wants to build an AI agent or chatbot",{"type":42,"tag":184,"props":190,"children":191},{},[192],{"type":48,"value":193},"User needs stateful, real-time AI interactions",{"type":42,"tag":184,"props":195,"children":196},{},[197],{"type":48,"value":198},"User asks about the Cloudflare Agents SDK",{"type":42,"tag":184,"props":200,"children":201},{},[202],{"type":48,"value":203},"User wants scheduled tasks or background AI work",{"type":42,"tag":184,"props":205,"children":206},{},[207],{"type":48,"value":208},"User needs WebSocket-based AI communication",{"type":42,"tag":65,"props":210,"children":212},{"id":211},"prerequisites",[213],{"type":48,"value":214},"Prerequisites",{"type":42,"tag":180,"props":216,"children":217},{},[218,223,228],{"type":42,"tag":184,"props":219,"children":220},{},[221],{"type":48,"value":222},"Cloudflare account with Workers enabled",{"type":42,"tag":184,"props":224,"children":225},{},[226],{"type":48,"value":227},"Node.js 18+ and npm\u002Fpnpm\u002Fyarn",{"type":42,"tag":184,"props":229,"children":230},{},[231,233,239],{"type":48,"value":232},"Wrangler CLI (",{"type":42,"tag":116,"props":234,"children":236},{"className":235},[],[237],{"type":48,"value":238},"npm install -g wrangler",{"type":48,"value":240},")",{"type":42,"tag":65,"props":242,"children":244},{"id":243},"quick-start",[245],{"type":48,"value":246},"Quick Start",{"type":42,"tag":248,"props":249,"children":254},"pre",{"className":250,"code":251,"language":252,"meta":253,"style":253},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","npm create cloudflare@latest -- my-agent --template=cloudflare\u002Fagents-starter\ncd my-agent\nnpm start\n","bash","",[255],{"type":42,"tag":116,"props":256,"children":257},{"__ignoreMap":253},[258,296,311],{"type":42,"tag":259,"props":260,"children":263},"span",{"class":261,"line":262},"line",1,[264,270,276,281,286,291],{"type":42,"tag":259,"props":265,"children":267},{"style":266},"--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B",[268],{"type":48,"value":269},"npm",{"type":42,"tag":259,"props":271,"children":273},{"style":272},"--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D",[274],{"type":48,"value":275}," create",{"type":42,"tag":259,"props":277,"children":278},{"style":272},[279],{"type":48,"value":280}," cloudflare@latest",{"type":42,"tag":259,"props":282,"children":283},{"style":272},[284],{"type":48,"value":285}," --",{"type":42,"tag":259,"props":287,"children":288},{"style":272},[289],{"type":48,"value":290}," my-agent",{"type":42,"tag":259,"props":292,"children":293},{"style":272},[294],{"type":48,"value":295}," --template=cloudflare\u002Fagents-starter\n",{"type":42,"tag":259,"props":297,"children":299},{"class":261,"line":298},2,[300,306],{"type":42,"tag":259,"props":301,"children":303},{"style":302},"--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF",[304],{"type":48,"value":305},"cd",{"type":42,"tag":259,"props":307,"children":308},{"style":272},[309],{"type":48,"value":310}," my-agent\n",{"type":42,"tag":259,"props":312,"children":314},{"class":261,"line":313},3,[315,319],{"type":42,"tag":259,"props":316,"children":317},{"style":266},[318],{"type":48,"value":269},{"type":42,"tag":259,"props":320,"children":321},{"style":272},[322],{"type":48,"value":323}," start\n",{"type":42,"tag":51,"props":325,"children":326},{},[327,329],{"type":48,"value":328},"Agent runs at ",{"type":42,"tag":116,"props":330,"children":332},{"className":331},[],[333],{"type":48,"value":334},"http:\u002F\u002Flocalhost:8787",{"type":42,"tag":65,"props":336,"children":338},{"id":337},"core-concepts",[339],{"type":48,"value":340},"Core Concepts",{"type":42,"tag":342,"props":343,"children":345},"h3",{"id":344},"what-is-an-agent",[346],{"type":48,"value":347},"What is an Agent?",{"type":42,"tag":51,"props":349,"children":350},{},[351],{"type":48,"value":352},"An Agent is a stateful, persistent AI service that:",{"type":42,"tag":180,"props":354,"children":355},{},[356,361,366,371,376],{"type":42,"tag":184,"props":357,"children":358},{},[359],{"type":48,"value":360},"Maintains state across requests and reconnections",{"type":42,"tag":184,"props":362,"children":363},{},[364],{"type":48,"value":365},"Communicates via WebSockets or HTTP",{"type":42,"tag":184,"props":367,"children":368},{},[369],{"type":48,"value":370},"Runs on Cloudflare's edge via Durable Objects",{"type":42,"tag":184,"props":372,"children":373},{},[374],{"type":48,"value":375},"Can schedule tasks and call tools",{"type":42,"tag":184,"props":377,"children":378},{},[379],{"type":48,"value":380},"Scales horizontally (each user\u002Fsession gets own instance)",{"type":42,"tag":342,"props":382,"children":384},{"id":383},"agent-lifecycle",[385],{"type":48,"value":386},"Agent Lifecycle",{"type":42,"tag":248,"props":388,"children":392},{"className":389,"code":391,"language":48},[390],"language-text","Client connects → Agent.onConnect() → Agent processes messages\n                                    → Agent.onMessage()\n                                    → Agent.setState() (persists + syncs)\nClient disconnects → State persists → Client reconnects → State restored\n",[393],{"type":42,"tag":116,"props":394,"children":395},{"__ignoreMap":253},[396],{"type":48,"value":391},{"type":42,"tag":65,"props":398,"children":400},{"id":399},"basic-agent-structure",[401],{"type":48,"value":402},"Basic Agent Structure",{"type":42,"tag":248,"props":404,"children":408},{"className":405,"code":406,"language":407,"meta":253,"style":253},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { Agent, Connection } from \"agents\";\n\ninterface Env {\n  AI: Ai;  \u002F\u002F Workers AI binding\n}\n\ninterface State {\n  messages: Array\u003C{ role: string; content: string }>;\n  preferences: Record\u003Cstring, string>;\n}\n\nexport class MyAgent extends Agent\u003CEnv, State> {\n  \u002F\u002F Initial state for new instances\n  initialState: State = {\n    messages: [],\n    preferences: {},\n  };\n\n  \u002F\u002F Called when agent starts or resumes\n  async onStart() {\n    console.log(\"Agent started with state:\", this.state);\n  }\n\n  \u002F\u002F Handle WebSocket connections\n  async onConnect(connection: Connection) {\n    connection.send(JSON.stringify({\n      type: \"welcome\",\n      history: this.state.messages,\n    }));\n  }\n\n  \u002F\u002F Handle incoming messages\n  async onMessage(connection: Connection, message: string) {\n    const data = JSON.parse(message);\n\n    if (data.type === \"chat\") {\n      await this.handleChat(connection, data.content);\n    }\n  }\n\n  \u002F\u002F Handle disconnections\n  async onClose(connection: Connection) {\n    console.log(\"Client disconnected\");\n  }\n\n  \u002F\u002F React to state changes\n  onStateUpdate(state: State, source: string) {\n    console.log(\"State updated by:\", source);\n  }\n\n  private async handleChat(connection: Connection, userMessage: string) {\n    \u002F\u002F Add user message to history\n    const messages = [\n      ...this.state.messages,\n      { role: \"user\", content: userMessage },\n    ];\n\n    \u002F\u002F Call AI\n    const response = await this.env.AI.run(\"@cf\u002Fmeta\u002Fllama-3-8b-instruct\", {\n      messages,\n    });\n\n    \u002F\u002F Update state (persists and syncs to all clients)\n    this.setState({\n      ...this.state,\n      messages: [\n        ...messages,\n        { role: \"assistant\", content: response.response },\n      ],\n    });\n\n    \u002F\u002F Send response\n    connection.send(JSON.stringify({\n      type: \"response\",\n      content: response.response,\n    }));\n  }\n}\n","typescript",[409],{"type":42,"tag":116,"props":410,"children":411},{"__ignoreMap":253},[412,472,481,500,531,540,548,565,624,665,673,681,735,744,770,793,811,820,828,837,860,919,928,936,945,984,1029,1059,1093,1111,1119,1127,1136,1190,1239,1247,1302,1353,1362,1370,1378,1387,1424,1465,1473,1481,1490,1540,1589,1597,1605,1665,1674,1696,1721,1772,1785,1793,1802,1876,1889,1905,1913,1922,1944,1960,1976,1993,2052,2065,2081,2089,2098,2138,2166,2195,2211,2219],{"type":42,"tag":259,"props":413,"children":414},{"class":261,"line":262},[415,421,427,433,438,443,448,453,458,462,467],{"type":42,"tag":259,"props":416,"children":418},{"style":417},"--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic",[419],{"type":48,"value":420},"import",{"type":42,"tag":259,"props":422,"children":424},{"style":423},"--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF",[425],{"type":48,"value":426}," {",{"type":42,"tag":259,"props":428,"children":430},{"style":429},"--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8",[431],{"type":48,"value":432}," Agent",{"type":42,"tag":259,"props":434,"children":435},{"style":423},[436],{"type":48,"value":437},",",{"type":42,"tag":259,"props":439,"children":440},{"style":429},[441],{"type":48,"value":442}," Connection",{"type":42,"tag":259,"props":444,"children":445},{"style":423},[446],{"type":48,"value":447}," }",{"type":42,"tag":259,"props":449,"children":450},{"style":417},[451],{"type":48,"value":452}," from",{"type":42,"tag":259,"props":454,"children":455},{"style":423},[456],{"type":48,"value":457}," \"",{"type":42,"tag":259,"props":459,"children":460},{"style":272},[461],{"type":48,"value":24},{"type":42,"tag":259,"props":463,"children":464},{"style":423},[465],{"type":48,"value":466},"\"",{"type":42,"tag":259,"props":468,"children":469},{"style":423},[470],{"type":48,"value":471},";\n",{"type":42,"tag":259,"props":473,"children":474},{"class":261,"line":298},[475],{"type":42,"tag":259,"props":476,"children":478},{"emptyLinePlaceholder":477},true,[479],{"type":48,"value":480},"\n",{"type":42,"tag":259,"props":482,"children":483},{"class":261,"line":313},[484,490,495],{"type":42,"tag":259,"props":485,"children":487},{"style":486},"--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA",[488],{"type":48,"value":489},"interface",{"type":42,"tag":259,"props":491,"children":492},{"style":266},[493],{"type":48,"value":494}," Env",{"type":42,"tag":259,"props":496,"children":497},{"style":423},[498],{"type":48,"value":499}," {\n",{"type":42,"tag":259,"props":501,"children":503},{"class":261,"line":502},4,[504,510,515,520,525],{"type":42,"tag":259,"props":505,"children":507},{"style":506},"--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178",[508],{"type":48,"value":509},"  AI",{"type":42,"tag":259,"props":511,"children":512},{"style":423},[513],{"type":48,"value":514},":",{"type":42,"tag":259,"props":516,"children":517},{"style":266},[518],{"type":48,"value":519}," Ai",{"type":42,"tag":259,"props":521,"children":522},{"style":423},[523],{"type":48,"value":524},";",{"type":42,"tag":259,"props":526,"children":528},{"style":527},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic",[529],{"type":48,"value":530},"  \u002F\u002F Workers AI binding\n",{"type":42,"tag":259,"props":532,"children":534},{"class":261,"line":533},5,[535],{"type":42,"tag":259,"props":536,"children":537},{"style":423},[538],{"type":48,"value":539},"}\n",{"type":42,"tag":259,"props":541,"children":543},{"class":261,"line":542},6,[544],{"type":42,"tag":259,"props":545,"children":546},{"emptyLinePlaceholder":477},[547],{"type":48,"value":480},{"type":42,"tag":259,"props":549,"children":551},{"class":261,"line":550},7,[552,556,561],{"type":42,"tag":259,"props":553,"children":554},{"style":486},[555],{"type":48,"value":489},{"type":42,"tag":259,"props":557,"children":558},{"style":266},[559],{"type":48,"value":560}," State",{"type":42,"tag":259,"props":562,"children":563},{"style":423},[564],{"type":48,"value":499},{"type":42,"tag":259,"props":566,"children":568},{"class":261,"line":567},8,[569,574,578,583,588,593,597,602,606,611,615,619],{"type":42,"tag":259,"props":570,"children":571},{"style":506},[572],{"type":48,"value":573},"  messages",{"type":42,"tag":259,"props":575,"children":576},{"style":423},[577],{"type":48,"value":514},{"type":42,"tag":259,"props":579,"children":580},{"style":266},[581],{"type":48,"value":582}," Array",{"type":42,"tag":259,"props":584,"children":585},{"style":423},[586],{"type":48,"value":587},"\u003C{",{"type":42,"tag":259,"props":589,"children":590},{"style":506},[591],{"type":48,"value":592}," role",{"type":42,"tag":259,"props":594,"children":595},{"style":423},[596],{"type":48,"value":514},{"type":42,"tag":259,"props":598,"children":599},{"style":266},[600],{"type":48,"value":601}," string",{"type":42,"tag":259,"props":603,"children":604},{"style":423},[605],{"type":48,"value":524},{"type":42,"tag":259,"props":607,"children":608},{"style":506},[609],{"type":48,"value":610}," content",{"type":42,"tag":259,"props":612,"children":613},{"style":423},[614],{"type":48,"value":514},{"type":42,"tag":259,"props":616,"children":617},{"style":266},[618],{"type":48,"value":601},{"type":42,"tag":259,"props":620,"children":621},{"style":423},[622],{"type":48,"value":623}," }>;\n",{"type":42,"tag":259,"props":625,"children":627},{"class":261,"line":626},9,[628,633,637,642,647,652,656,660],{"type":42,"tag":259,"props":629,"children":630},{"style":506},[631],{"type":48,"value":632},"  preferences",{"type":42,"tag":259,"props":634,"children":635},{"style":423},[636],{"type":48,"value":514},{"type":42,"tag":259,"props":638,"children":639},{"style":266},[640],{"type":48,"value":641}," Record",{"type":42,"tag":259,"props":643,"children":644},{"style":423},[645],{"type":48,"value":646},"\u003C",{"type":42,"tag":259,"props":648,"children":649},{"style":266},[650],{"type":48,"value":651},"string",{"type":42,"tag":259,"props":653,"children":654},{"style":423},[655],{"type":48,"value":437},{"type":42,"tag":259,"props":657,"children":658},{"style":266},[659],{"type":48,"value":601},{"type":42,"tag":259,"props":661,"children":662},{"style":423},[663],{"type":48,"value":664},">;\n",{"type":42,"tag":259,"props":666,"children":668},{"class":261,"line":667},10,[669],{"type":42,"tag":259,"props":670,"children":671},{"style":423},[672],{"type":48,"value":539},{"type":42,"tag":259,"props":674,"children":676},{"class":261,"line":675},11,[677],{"type":42,"tag":259,"props":678,"children":679},{"emptyLinePlaceholder":477},[680],{"type":48,"value":480},{"type":42,"tag":259,"props":682,"children":684},{"class":261,"line":683},12,[685,690,695,700,705,709,713,718,722,726,731],{"type":42,"tag":259,"props":686,"children":687},{"style":417},[688],{"type":48,"value":689},"export",{"type":42,"tag":259,"props":691,"children":692},{"style":486},[693],{"type":48,"value":694}," class",{"type":42,"tag":259,"props":696,"children":697},{"style":266},[698],{"type":48,"value":699}," MyAgent",{"type":42,"tag":259,"props":701,"children":702},{"style":486},[703],{"type":48,"value":704}," extends",{"type":42,"tag":259,"props":706,"children":707},{"style":266},[708],{"type":48,"value":432},{"type":42,"tag":259,"props":710,"children":711},{"style":423},[712],{"type":48,"value":646},{"type":42,"tag":259,"props":714,"children":715},{"style":266},[716],{"type":48,"value":717},"Env",{"type":42,"tag":259,"props":719,"children":720},{"style":423},[721],{"type":48,"value":437},{"type":42,"tag":259,"props":723,"children":724},{"style":266},[725],{"type":48,"value":560},{"type":42,"tag":259,"props":727,"children":728},{"style":423},[729],{"type":48,"value":730},">",{"type":42,"tag":259,"props":732,"children":733},{"style":423},[734],{"type":48,"value":499},{"type":42,"tag":259,"props":736,"children":738},{"class":261,"line":737},13,[739],{"type":42,"tag":259,"props":740,"children":741},{"style":527},[742],{"type":48,"value":743},"  \u002F\u002F Initial state for new instances\n",{"type":42,"tag":259,"props":745,"children":747},{"class":261,"line":746},14,[748,753,757,761,766],{"type":42,"tag":259,"props":749,"children":750},{"style":506},[751],{"type":48,"value":752},"  initialState",{"type":42,"tag":259,"props":754,"children":755},{"style":423},[756],{"type":48,"value":514},{"type":42,"tag":259,"props":758,"children":759},{"style":266},[760],{"type":48,"value":560},{"type":42,"tag":259,"props":762,"children":763},{"style":423},[764],{"type":48,"value":765}," =",{"type":42,"tag":259,"props":767,"children":768},{"style":423},[769],{"type":48,"value":499},{"type":42,"tag":259,"props":771,"children":773},{"class":261,"line":772},15,[774,779,783,788],{"type":42,"tag":259,"props":775,"children":776},{"style":506},[777],{"type":48,"value":778},"    messages",{"type":42,"tag":259,"props":780,"children":781},{"style":423},[782],{"type":48,"value":514},{"type":42,"tag":259,"props":784,"children":785},{"style":429},[786],{"type":48,"value":787}," []",{"type":42,"tag":259,"props":789,"children":790},{"style":423},[791],{"type":48,"value":792},",\n",{"type":42,"tag":259,"props":794,"children":796},{"class":261,"line":795},16,[797,802,806],{"type":42,"tag":259,"props":798,"children":799},{"style":506},[800],{"type":48,"value":801},"    preferences",{"type":42,"tag":259,"props":803,"children":804},{"style":423},[805],{"type":48,"value":514},{"type":42,"tag":259,"props":807,"children":808},{"style":423},[809],{"type":48,"value":810}," {},\n",{"type":42,"tag":259,"props":812,"children":814},{"class":261,"line":813},17,[815],{"type":42,"tag":259,"props":816,"children":817},{"style":423},[818],{"type":48,"value":819},"  };\n",{"type":42,"tag":259,"props":821,"children":823},{"class":261,"line":822},18,[824],{"type":42,"tag":259,"props":825,"children":826},{"emptyLinePlaceholder":477},[827],{"type":48,"value":480},{"type":42,"tag":259,"props":829,"children":831},{"class":261,"line":830},19,[832],{"type":42,"tag":259,"props":833,"children":834},{"style":527},[835],{"type":48,"value":836},"  \u002F\u002F Called when agent starts or resumes\n",{"type":42,"tag":259,"props":838,"children":840},{"class":261,"line":839},20,[841,846,851,856],{"type":42,"tag":259,"props":842,"children":843},{"style":486},[844],{"type":48,"value":845},"  async",{"type":42,"tag":259,"props":847,"children":848},{"style":506},[849],{"type":48,"value":850}," onStart",{"type":42,"tag":259,"props":852,"children":853},{"style":423},[854],{"type":48,"value":855},"()",{"type":42,"tag":259,"props":857,"children":858},{"style":423},[859],{"type":48,"value":499},{"type":42,"tag":259,"props":861,"children":863},{"class":261,"line":862},21,[864,869,874,879,884,888,893,897,901,906,911,915],{"type":42,"tag":259,"props":865,"children":866},{"style":429},[867],{"type":48,"value":868},"    console",{"type":42,"tag":259,"props":870,"children":871},{"style":423},[872],{"type":48,"value":873},".",{"type":42,"tag":259,"props":875,"children":876},{"style":302},[877],{"type":48,"value":878},"log",{"type":42,"tag":259,"props":880,"children":881},{"style":506},[882],{"type":48,"value":883},"(",{"type":42,"tag":259,"props":885,"children":886},{"style":423},[887],{"type":48,"value":466},{"type":42,"tag":259,"props":889,"children":890},{"style":272},[891],{"type":48,"value":892},"Agent started with state:",{"type":42,"tag":259,"props":894,"children":895},{"style":423},[896],{"type":48,"value":466},{"type":42,"tag":259,"props":898,"children":899},{"style":423},[900],{"type":48,"value":437},{"type":42,"tag":259,"props":902,"children":903},{"style":423},[904],{"type":48,"value":905}," this.",{"type":42,"tag":259,"props":907,"children":908},{"style":429},[909],{"type":48,"value":910},"state",{"type":42,"tag":259,"props":912,"children":913},{"style":506},[914],{"type":48,"value":240},{"type":42,"tag":259,"props":916,"children":917},{"style":423},[918],{"type":48,"value":471},{"type":42,"tag":259,"props":920,"children":922},{"class":261,"line":921},22,[923],{"type":42,"tag":259,"props":924,"children":925},{"style":423},[926],{"type":48,"value":927},"  }\n",{"type":42,"tag":259,"props":929,"children":931},{"class":261,"line":930},23,[932],{"type":42,"tag":259,"props":933,"children":934},{"emptyLinePlaceholder":477},[935],{"type":48,"value":480},{"type":42,"tag":259,"props":937,"children":939},{"class":261,"line":938},24,[940],{"type":42,"tag":259,"props":941,"children":942},{"style":527},[943],{"type":48,"value":944},"  \u002F\u002F Handle WebSocket connections\n",{"type":42,"tag":259,"props":946,"children":948},{"class":261,"line":947},25,[949,953,958,962,968,972,976,980],{"type":42,"tag":259,"props":950,"children":951},{"style":486},[952],{"type":48,"value":845},{"type":42,"tag":259,"props":954,"children":955},{"style":506},[956],{"type":48,"value":957}," onConnect",{"type":42,"tag":259,"props":959,"children":960},{"style":423},[961],{"type":48,"value":883},{"type":42,"tag":259,"props":963,"children":965},{"style":964},"--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic",[966],{"type":48,"value":967},"connection",{"type":42,"tag":259,"props":969,"children":970},{"style":423},[971],{"type":48,"value":514},{"type":42,"tag":259,"props":973,"children":974},{"style":266},[975],{"type":48,"value":442},{"type":42,"tag":259,"props":977,"children":978},{"style":423},[979],{"type":48,"value":240},{"type":42,"tag":259,"props":981,"children":982},{"style":423},[983],{"type":48,"value":499},{"type":42,"tag":259,"props":985,"children":987},{"class":261,"line":986},26,[988,993,997,1002,1006,1011,1015,1020,1024],{"type":42,"tag":259,"props":989,"children":990},{"style":429},[991],{"type":48,"value":992},"    connection",{"type":42,"tag":259,"props":994,"children":995},{"style":423},[996],{"type":48,"value":873},{"type":42,"tag":259,"props":998,"children":999},{"style":302},[1000],{"type":48,"value":1001},"send",{"type":42,"tag":259,"props":1003,"children":1004},{"style":506},[1005],{"type":48,"value":883},{"type":42,"tag":259,"props":1007,"children":1008},{"style":429},[1009],{"type":48,"value":1010},"JSON",{"type":42,"tag":259,"props":1012,"children":1013},{"style":423},[1014],{"type":48,"value":873},{"type":42,"tag":259,"props":1016,"children":1017},{"style":302},[1018],{"type":48,"value":1019},"stringify",{"type":42,"tag":259,"props":1021,"children":1022},{"style":506},[1023],{"type":48,"value":883},{"type":42,"tag":259,"props":1025,"children":1026},{"style":423},[1027],{"type":48,"value":1028},"{\n",{"type":42,"tag":259,"props":1030,"children":1032},{"class":261,"line":1031},27,[1033,1038,1042,1046,1051,1055],{"type":42,"tag":259,"props":1034,"children":1035},{"style":506},[1036],{"type":48,"value":1037},"      type",{"type":42,"tag":259,"props":1039,"children":1040},{"style":423},[1041],{"type":48,"value":514},{"type":42,"tag":259,"props":1043,"children":1044},{"style":423},[1045],{"type":48,"value":457},{"type":42,"tag":259,"props":1047,"children":1048},{"style":272},[1049],{"type":48,"value":1050},"welcome",{"type":42,"tag":259,"props":1052,"children":1053},{"style":423},[1054],{"type":48,"value":466},{"type":42,"tag":259,"props":1056,"children":1057},{"style":423},[1058],{"type":48,"value":792},{"type":42,"tag":259,"props":1060,"children":1062},{"class":261,"line":1061},28,[1063,1068,1072,1076,1080,1084,1089],{"type":42,"tag":259,"props":1064,"children":1065},{"style":506},[1066],{"type":48,"value":1067},"      history",{"type":42,"tag":259,"props":1069,"children":1070},{"style":423},[1071],{"type":48,"value":514},{"type":42,"tag":259,"props":1073,"children":1074},{"style":423},[1075],{"type":48,"value":905},{"type":42,"tag":259,"props":1077,"children":1078},{"style":429},[1079],{"type":48,"value":910},{"type":42,"tag":259,"props":1081,"children":1082},{"style":423},[1083],{"type":48,"value":873},{"type":42,"tag":259,"props":1085,"children":1086},{"style":429},[1087],{"type":48,"value":1088},"messages",{"type":42,"tag":259,"props":1090,"children":1091},{"style":423},[1092],{"type":48,"value":792},{"type":42,"tag":259,"props":1094,"children":1096},{"class":261,"line":1095},29,[1097,1102,1107],{"type":42,"tag":259,"props":1098,"children":1099},{"style":423},[1100],{"type":48,"value":1101},"    }",{"type":42,"tag":259,"props":1103,"children":1104},{"style":506},[1105],{"type":48,"value":1106},"))",{"type":42,"tag":259,"props":1108,"children":1109},{"style":423},[1110],{"type":48,"value":471},{"type":42,"tag":259,"props":1112,"children":1114},{"class":261,"line":1113},30,[1115],{"type":42,"tag":259,"props":1116,"children":1117},{"style":423},[1118],{"type":48,"value":927},{"type":42,"tag":259,"props":1120,"children":1122},{"class":261,"line":1121},31,[1123],{"type":42,"tag":259,"props":1124,"children":1125},{"emptyLinePlaceholder":477},[1126],{"type":48,"value":480},{"type":42,"tag":259,"props":1128,"children":1130},{"class":261,"line":1129},32,[1131],{"type":42,"tag":259,"props":1132,"children":1133},{"style":527},[1134],{"type":48,"value":1135},"  \u002F\u002F Handle incoming messages\n",{"type":42,"tag":259,"props":1137,"children":1139},{"class":261,"line":1138},33,[1140,1144,1149,1153,1157,1161,1165,1169,1174,1178,1182,1186],{"type":42,"tag":259,"props":1141,"children":1142},{"style":486},[1143],{"type":48,"value":845},{"type":42,"tag":259,"props":1145,"children":1146},{"style":506},[1147],{"type":48,"value":1148}," onMessage",{"type":42,"tag":259,"props":1150,"children":1151},{"style":423},[1152],{"type":48,"value":883},{"type":42,"tag":259,"props":1154,"children":1155},{"style":964},[1156],{"type":48,"value":967},{"type":42,"tag":259,"props":1158,"children":1159},{"style":423},[1160],{"type":48,"value":514},{"type":42,"tag":259,"props":1162,"children":1163},{"style":266},[1164],{"type":48,"value":442},{"type":42,"tag":259,"props":1166,"children":1167},{"style":423},[1168],{"type":48,"value":437},{"type":42,"tag":259,"props":1170,"children":1171},{"style":964},[1172],{"type":48,"value":1173}," message",{"type":42,"tag":259,"props":1175,"children":1176},{"style":423},[1177],{"type":48,"value":514},{"type":42,"tag":259,"props":1179,"children":1180},{"style":266},[1181],{"type":48,"value":601},{"type":42,"tag":259,"props":1183,"children":1184},{"style":423},[1185],{"type":48,"value":240},{"type":42,"tag":259,"props":1187,"children":1188},{"style":423},[1189],{"type":48,"value":499},{"type":42,"tag":259,"props":1191,"children":1193},{"class":261,"line":1192},34,[1194,1199,1204,1208,1213,1217,1222,1226,1231,1235],{"type":42,"tag":259,"props":1195,"children":1196},{"style":486},[1197],{"type":48,"value":1198},"    const",{"type":42,"tag":259,"props":1200,"children":1201},{"style":429},[1202],{"type":48,"value":1203}," data",{"type":42,"tag":259,"props":1205,"children":1206},{"style":423},[1207],{"type":48,"value":765},{"type":42,"tag":259,"props":1209,"children":1210},{"style":429},[1211],{"type":48,"value":1212}," JSON",{"type":42,"tag":259,"props":1214,"children":1215},{"style":423},[1216],{"type":48,"value":873},{"type":42,"tag":259,"props":1218,"children":1219},{"style":302},[1220],{"type":48,"value":1221},"parse",{"type":42,"tag":259,"props":1223,"children":1224},{"style":506},[1225],{"type":48,"value":883},{"type":42,"tag":259,"props":1227,"children":1228},{"style":429},[1229],{"type":48,"value":1230},"message",{"type":42,"tag":259,"props":1232,"children":1233},{"style":506},[1234],{"type":48,"value":240},{"type":42,"tag":259,"props":1236,"children":1237},{"style":423},[1238],{"type":48,"value":471},{"type":42,"tag":259,"props":1240,"children":1242},{"class":261,"line":1241},35,[1243],{"type":42,"tag":259,"props":1244,"children":1245},{"emptyLinePlaceholder":477},[1246],{"type":48,"value":480},{"type":42,"tag":259,"props":1248,"children":1250},{"class":261,"line":1249},36,[1251,1256,1261,1266,1270,1275,1280,1284,1289,1293,1298],{"type":42,"tag":259,"props":1252,"children":1253},{"style":417},[1254],{"type":48,"value":1255},"    if",{"type":42,"tag":259,"props":1257,"children":1258},{"style":506},[1259],{"type":48,"value":1260}," (",{"type":42,"tag":259,"props":1262,"children":1263},{"style":429},[1264],{"type":48,"value":1265},"data",{"type":42,"tag":259,"props":1267,"children":1268},{"style":423},[1269],{"type":48,"value":873},{"type":42,"tag":259,"props":1271,"children":1272},{"style":429},[1273],{"type":48,"value":1274},"type",{"type":42,"tag":259,"props":1276,"children":1277},{"style":423},[1278],{"type":48,"value":1279}," ===",{"type":42,"tag":259,"props":1281,"children":1282},{"style":423},[1283],{"type":48,"value":457},{"type":42,"tag":259,"props":1285,"children":1286},{"style":272},[1287],{"type":48,"value":1288},"chat",{"type":42,"tag":259,"props":1290,"children":1291},{"style":423},[1292],{"type":48,"value":466},{"type":42,"tag":259,"props":1294,"children":1295},{"style":506},[1296],{"type":48,"value":1297},") ",{"type":42,"tag":259,"props":1299,"children":1300},{"style":423},[1301],{"type":48,"value":1028},{"type":42,"tag":259,"props":1303,"children":1305},{"class":261,"line":1304},37,[1306,1311,1315,1320,1324,1328,1332,1336,1340,1345,1349],{"type":42,"tag":259,"props":1307,"children":1308},{"style":417},[1309],{"type":48,"value":1310},"      await",{"type":42,"tag":259,"props":1312,"children":1313},{"style":423},[1314],{"type":48,"value":905},{"type":42,"tag":259,"props":1316,"children":1317},{"style":302},[1318],{"type":48,"value":1319},"handleChat",{"type":42,"tag":259,"props":1321,"children":1322},{"style":506},[1323],{"type":48,"value":883},{"type":42,"tag":259,"props":1325,"children":1326},{"style":429},[1327],{"type":48,"value":967},{"type":42,"tag":259,"props":1329,"children":1330},{"style":423},[1331],{"type":48,"value":437},{"type":42,"tag":259,"props":1333,"children":1334},{"style":429},[1335],{"type":48,"value":1203},{"type":42,"tag":259,"props":1337,"children":1338},{"style":423},[1339],{"type":48,"value":873},{"type":42,"tag":259,"props":1341,"children":1342},{"style":429},[1343],{"type":48,"value":1344},"content",{"type":42,"tag":259,"props":1346,"children":1347},{"style":506},[1348],{"type":48,"value":240},{"type":42,"tag":259,"props":1350,"children":1351},{"style":423},[1352],{"type":48,"value":471},{"type":42,"tag":259,"props":1354,"children":1356},{"class":261,"line":1355},38,[1357],{"type":42,"tag":259,"props":1358,"children":1359},{"style":423},[1360],{"type":48,"value":1361},"    }\n",{"type":42,"tag":259,"props":1363,"children":1365},{"class":261,"line":1364},39,[1366],{"type":42,"tag":259,"props":1367,"children":1368},{"style":423},[1369],{"type":48,"value":927},{"type":42,"tag":259,"props":1371,"children":1373},{"class":261,"line":1372},40,[1374],{"type":42,"tag":259,"props":1375,"children":1376},{"emptyLinePlaceholder":477},[1377],{"type":48,"value":480},{"type":42,"tag":259,"props":1379,"children":1381},{"class":261,"line":1380},41,[1382],{"type":42,"tag":259,"props":1383,"children":1384},{"style":527},[1385],{"type":48,"value":1386},"  \u002F\u002F Handle disconnections\n",{"type":42,"tag":259,"props":1388,"children":1390},{"class":261,"line":1389},42,[1391,1395,1400,1404,1408,1412,1416,1420],{"type":42,"tag":259,"props":1392,"children":1393},{"style":486},[1394],{"type":48,"value":845},{"type":42,"tag":259,"props":1396,"children":1397},{"style":506},[1398],{"type":48,"value":1399}," onClose",{"type":42,"tag":259,"props":1401,"children":1402},{"style":423},[1403],{"type":48,"value":883},{"type":42,"tag":259,"props":1405,"children":1406},{"style":964},[1407],{"type":48,"value":967},{"type":42,"tag":259,"props":1409,"children":1410},{"style":423},[1411],{"type":48,"value":514},{"type":42,"tag":259,"props":1413,"children":1414},{"style":266},[1415],{"type":48,"value":442},{"type":42,"tag":259,"props":1417,"children":1418},{"style":423},[1419],{"type":48,"value":240},{"type":42,"tag":259,"props":1421,"children":1422},{"style":423},[1423],{"type":48,"value":499},{"type":42,"tag":259,"props":1425,"children":1427},{"class":261,"line":1426},43,[1428,1432,1436,1440,1444,1448,1453,1457,1461],{"type":42,"tag":259,"props":1429,"children":1430},{"style":429},[1431],{"type":48,"value":868},{"type":42,"tag":259,"props":1433,"children":1434},{"style":423},[1435],{"type":48,"value":873},{"type":42,"tag":259,"props":1437,"children":1438},{"style":302},[1439],{"type":48,"value":878},{"type":42,"tag":259,"props":1441,"children":1442},{"style":506},[1443],{"type":48,"value":883},{"type":42,"tag":259,"props":1445,"children":1446},{"style":423},[1447],{"type":48,"value":466},{"type":42,"tag":259,"props":1449,"children":1450},{"style":272},[1451],{"type":48,"value":1452},"Client disconnected",{"type":42,"tag":259,"props":1454,"children":1455},{"style":423},[1456],{"type":48,"value":466},{"type":42,"tag":259,"props":1458,"children":1459},{"style":506},[1460],{"type":48,"value":240},{"type":42,"tag":259,"props":1462,"children":1463},{"style":423},[1464],{"type":48,"value":471},{"type":42,"tag":259,"props":1466,"children":1468},{"class":261,"line":1467},44,[1469],{"type":42,"tag":259,"props":1470,"children":1471},{"style":423},[1472],{"type":48,"value":927},{"type":42,"tag":259,"props":1474,"children":1476},{"class":261,"line":1475},45,[1477],{"type":42,"tag":259,"props":1478,"children":1479},{"emptyLinePlaceholder":477},[1480],{"type":48,"value":480},{"type":42,"tag":259,"props":1482,"children":1484},{"class":261,"line":1483},46,[1485],{"type":42,"tag":259,"props":1486,"children":1487},{"style":527},[1488],{"type":48,"value":1489},"  \u002F\u002F React to state changes\n",{"type":42,"tag":259,"props":1491,"children":1493},{"class":261,"line":1492},47,[1494,1499,1503,1507,1511,1515,1519,1524,1528,1532,1536],{"type":42,"tag":259,"props":1495,"children":1496},{"style":506},[1497],{"type":48,"value":1498},"  onStateUpdate",{"type":42,"tag":259,"props":1500,"children":1501},{"style":423},[1502],{"type":48,"value":883},{"type":42,"tag":259,"props":1504,"children":1505},{"style":964},[1506],{"type":48,"value":910},{"type":42,"tag":259,"props":1508,"children":1509},{"style":423},[1510],{"type":48,"value":514},{"type":42,"tag":259,"props":1512,"children":1513},{"style":266},[1514],{"type":48,"value":560},{"type":42,"tag":259,"props":1516,"children":1517},{"style":423},[1518],{"type":48,"value":437},{"type":42,"tag":259,"props":1520,"children":1521},{"style":964},[1522],{"type":48,"value":1523}," source",{"type":42,"tag":259,"props":1525,"children":1526},{"style":423},[1527],{"type":48,"value":514},{"type":42,"tag":259,"props":1529,"children":1530},{"style":266},[1531],{"type":48,"value":601},{"type":42,"tag":259,"props":1533,"children":1534},{"style":423},[1535],{"type":48,"value":240},{"type":42,"tag":259,"props":1537,"children":1538},{"style":423},[1539],{"type":48,"value":499},{"type":42,"tag":259,"props":1541,"children":1543},{"class":261,"line":1542},48,[1544,1548,1552,1556,1560,1564,1569,1573,1577,1581,1585],{"type":42,"tag":259,"props":1545,"children":1546},{"style":429},[1547],{"type":48,"value":868},{"type":42,"tag":259,"props":1549,"children":1550},{"style":423},[1551],{"type":48,"value":873},{"type":42,"tag":259,"props":1553,"children":1554},{"style":302},[1555],{"type":48,"value":878},{"type":42,"tag":259,"props":1557,"children":1558},{"style":506},[1559],{"type":48,"value":883},{"type":42,"tag":259,"props":1561,"children":1562},{"style":423},[1563],{"type":48,"value":466},{"type":42,"tag":259,"props":1565,"children":1566},{"style":272},[1567],{"type":48,"value":1568},"State updated by:",{"type":42,"tag":259,"props":1570,"children":1571},{"style":423},[1572],{"type":48,"value":466},{"type":42,"tag":259,"props":1574,"children":1575},{"style":423},[1576],{"type":48,"value":437},{"type":42,"tag":259,"props":1578,"children":1579},{"style":429},[1580],{"type":48,"value":1523},{"type":42,"tag":259,"props":1582,"children":1583},{"style":506},[1584],{"type":48,"value":240},{"type":42,"tag":259,"props":1586,"children":1587},{"style":423},[1588],{"type":48,"value":471},{"type":42,"tag":259,"props":1590,"children":1592},{"class":261,"line":1591},49,[1593],{"type":42,"tag":259,"props":1594,"children":1595},{"style":423},[1596],{"type":48,"value":927},{"type":42,"tag":259,"props":1598,"children":1600},{"class":261,"line":1599},50,[1601],{"type":42,"tag":259,"props":1602,"children":1603},{"emptyLinePlaceholder":477},[1604],{"type":48,"value":480},{"type":42,"tag":259,"props":1606,"children":1608},{"class":261,"line":1607},51,[1609,1614,1619,1624,1628,1632,1636,1640,1644,1649,1653,1657,1661],{"type":42,"tag":259,"props":1610,"children":1611},{"style":486},[1612],{"type":48,"value":1613},"  private",{"type":42,"tag":259,"props":1615,"children":1616},{"style":486},[1617],{"type":48,"value":1618}," async",{"type":42,"tag":259,"props":1620,"children":1621},{"style":506},[1622],{"type":48,"value":1623}," handleChat",{"type":42,"tag":259,"props":1625,"children":1626},{"style":423},[1627],{"type":48,"value":883},{"type":42,"tag":259,"props":1629,"children":1630},{"style":964},[1631],{"type":48,"value":967},{"type":42,"tag":259,"props":1633,"children":1634},{"style":423},[1635],{"type":48,"value":514},{"type":42,"tag":259,"props":1637,"children":1638},{"style":266},[1639],{"type":48,"value":442},{"type":42,"tag":259,"props":1641,"children":1642},{"style":423},[1643],{"type":48,"value":437},{"type":42,"tag":259,"props":1645,"children":1646},{"style":964},[1647],{"type":48,"value":1648}," userMessage",{"type":42,"tag":259,"props":1650,"children":1651},{"style":423},[1652],{"type":48,"value":514},{"type":42,"tag":259,"props":1654,"children":1655},{"style":266},[1656],{"type":48,"value":601},{"type":42,"tag":259,"props":1658,"children":1659},{"style":423},[1660],{"type":48,"value":240},{"type":42,"tag":259,"props":1662,"children":1663},{"style":423},[1664],{"type":48,"value":499},{"type":42,"tag":259,"props":1666,"children":1668},{"class":261,"line":1667},52,[1669],{"type":42,"tag":259,"props":1670,"children":1671},{"style":527},[1672],{"type":48,"value":1673},"    \u002F\u002F Add user message to history\n",{"type":42,"tag":259,"props":1675,"children":1677},{"class":261,"line":1676},53,[1678,1682,1687,1691],{"type":42,"tag":259,"props":1679,"children":1680},{"style":486},[1681],{"type":48,"value":1198},{"type":42,"tag":259,"props":1683,"children":1684},{"style":429},[1685],{"type":48,"value":1686}," messages",{"type":42,"tag":259,"props":1688,"children":1689},{"style":423},[1690],{"type":48,"value":765},{"type":42,"tag":259,"props":1692,"children":1693},{"style":506},[1694],{"type":48,"value":1695}," [\n",{"type":42,"tag":259,"props":1697,"children":1699},{"class":261,"line":1698},54,[1700,1705,1709,1713,1717],{"type":42,"tag":259,"props":1701,"children":1702},{"style":423},[1703],{"type":48,"value":1704},"      ...this.",{"type":42,"tag":259,"props":1706,"children":1707},{"style":429},[1708],{"type":48,"value":910},{"type":42,"tag":259,"props":1710,"children":1711},{"style":423},[1712],{"type":48,"value":873},{"type":42,"tag":259,"props":1714,"children":1715},{"style":429},[1716],{"type":48,"value":1088},{"type":42,"tag":259,"props":1718,"children":1719},{"style":423},[1720],{"type":48,"value":792},{"type":42,"tag":259,"props":1722,"children":1724},{"class":261,"line":1723},55,[1725,1730,1734,1738,1742,1747,1751,1755,1759,1763,1767],{"type":42,"tag":259,"props":1726,"children":1727},{"style":423},[1728],{"type":48,"value":1729},"      {",{"type":42,"tag":259,"props":1731,"children":1732},{"style":506},[1733],{"type":48,"value":592},{"type":42,"tag":259,"props":1735,"children":1736},{"style":423},[1737],{"type":48,"value":514},{"type":42,"tag":259,"props":1739,"children":1740},{"style":423},[1741],{"type":48,"value":457},{"type":42,"tag":259,"props":1743,"children":1744},{"style":272},[1745],{"type":48,"value":1746},"user",{"type":42,"tag":259,"props":1748,"children":1749},{"style":423},[1750],{"type":48,"value":466},{"type":42,"tag":259,"props":1752,"children":1753},{"style":423},[1754],{"type":48,"value":437},{"type":42,"tag":259,"props":1756,"children":1757},{"style":506},[1758],{"type":48,"value":610},{"type":42,"tag":259,"props":1760,"children":1761},{"style":423},[1762],{"type":48,"value":514},{"type":42,"tag":259,"props":1764,"children":1765},{"style":429},[1766],{"type":48,"value":1648},{"type":42,"tag":259,"props":1768,"children":1769},{"style":423},[1770],{"type":48,"value":1771}," },\n",{"type":42,"tag":259,"props":1773,"children":1775},{"class":261,"line":1774},56,[1776,1781],{"type":42,"tag":259,"props":1777,"children":1778},{"style":506},[1779],{"type":48,"value":1780},"    ]",{"type":42,"tag":259,"props":1782,"children":1783},{"style":423},[1784],{"type":48,"value":471},{"type":42,"tag":259,"props":1786,"children":1788},{"class":261,"line":1787},57,[1789],{"type":42,"tag":259,"props":1790,"children":1791},{"emptyLinePlaceholder":477},[1792],{"type":48,"value":480},{"type":42,"tag":259,"props":1794,"children":1796},{"class":261,"line":1795},58,[1797],{"type":42,"tag":259,"props":1798,"children":1799},{"style":527},[1800],{"type":48,"value":1801},"    \u002F\u002F Call AI\n",{"type":42,"tag":259,"props":1803,"children":1805},{"class":261,"line":1804},59,[1806,1810,1815,1819,1824,1828,1833,1837,1842,1846,1851,1855,1859,1864,1868,1872],{"type":42,"tag":259,"props":1807,"children":1808},{"style":486},[1809],{"type":48,"value":1198},{"type":42,"tag":259,"props":1811,"children":1812},{"style":429},[1813],{"type":48,"value":1814}," response",{"type":42,"tag":259,"props":1816,"children":1817},{"style":423},[1818],{"type":48,"value":765},{"type":42,"tag":259,"props":1820,"children":1821},{"style":417},[1822],{"type":48,"value":1823}," await",{"type":42,"tag":259,"props":1825,"children":1826},{"style":423},[1827],{"type":48,"value":905},{"type":42,"tag":259,"props":1829,"children":1830},{"style":429},[1831],{"type":48,"value":1832},"env",{"type":42,"tag":259,"props":1834,"children":1835},{"style":423},[1836],{"type":48,"value":873},{"type":42,"tag":259,"props":1838,"children":1839},{"style":429},[1840],{"type":48,"value":1841},"AI",{"type":42,"tag":259,"props":1843,"children":1844},{"style":423},[1845],{"type":48,"value":873},{"type":42,"tag":259,"props":1847,"children":1848},{"style":302},[1849],{"type":48,"value":1850},"run",{"type":42,"tag":259,"props":1852,"children":1853},{"style":506},[1854],{"type":48,"value":883},{"type":42,"tag":259,"props":1856,"children":1857},{"style":423},[1858],{"type":48,"value":466},{"type":42,"tag":259,"props":1860,"children":1861},{"style":272},[1862],{"type":48,"value":1863},"@cf\u002Fmeta\u002Fllama-3-8b-instruct",{"type":42,"tag":259,"props":1865,"children":1866},{"style":423},[1867],{"type":48,"value":466},{"type":42,"tag":259,"props":1869,"children":1870},{"style":423},[1871],{"type":48,"value":437},{"type":42,"tag":259,"props":1873,"children":1874},{"style":423},[1875],{"type":48,"value":499},{"type":42,"tag":259,"props":1877,"children":1879},{"class":261,"line":1878},60,[1880,1885],{"type":42,"tag":259,"props":1881,"children":1882},{"style":429},[1883],{"type":48,"value":1884},"      messages",{"type":42,"tag":259,"props":1886,"children":1887},{"style":423},[1888],{"type":48,"value":792},{"type":42,"tag":259,"props":1890,"children":1892},{"class":261,"line":1891},61,[1893,1897,1901],{"type":42,"tag":259,"props":1894,"children":1895},{"style":423},[1896],{"type":48,"value":1101},{"type":42,"tag":259,"props":1898,"children":1899},{"style":506},[1900],{"type":48,"value":240},{"type":42,"tag":259,"props":1902,"children":1903},{"style":423},[1904],{"type":48,"value":471},{"type":42,"tag":259,"props":1906,"children":1908},{"class":261,"line":1907},62,[1909],{"type":42,"tag":259,"props":1910,"children":1911},{"emptyLinePlaceholder":477},[1912],{"type":48,"value":480},{"type":42,"tag":259,"props":1914,"children":1916},{"class":261,"line":1915},63,[1917],{"type":42,"tag":259,"props":1918,"children":1919},{"style":527},[1920],{"type":48,"value":1921},"    \u002F\u002F Update state (persists and syncs to all clients)\n",{"type":42,"tag":259,"props":1923,"children":1925},{"class":261,"line":1924},64,[1926,1931,1936,1940],{"type":42,"tag":259,"props":1927,"children":1928},{"style":423},[1929],{"type":48,"value":1930},"    this.",{"type":42,"tag":259,"props":1932,"children":1933},{"style":302},[1934],{"type":48,"value":1935},"setState",{"type":42,"tag":259,"props":1937,"children":1938},{"style":506},[1939],{"type":48,"value":883},{"type":42,"tag":259,"props":1941,"children":1942},{"style":423},[1943],{"type":48,"value":1028},{"type":42,"tag":259,"props":1945,"children":1947},{"class":261,"line":1946},65,[1948,1952,1956],{"type":42,"tag":259,"props":1949,"children":1950},{"style":423},[1951],{"type":48,"value":1704},{"type":42,"tag":259,"props":1953,"children":1954},{"style":429},[1955],{"type":48,"value":910},{"type":42,"tag":259,"props":1957,"children":1958},{"style":423},[1959],{"type":48,"value":792},{"type":42,"tag":259,"props":1961,"children":1963},{"class":261,"line":1962},66,[1964,1968,1972],{"type":42,"tag":259,"props":1965,"children":1966},{"style":506},[1967],{"type":48,"value":1884},{"type":42,"tag":259,"props":1969,"children":1970},{"style":423},[1971],{"type":48,"value":514},{"type":42,"tag":259,"props":1973,"children":1974},{"style":506},[1975],{"type":48,"value":1695},{"type":42,"tag":259,"props":1977,"children":1979},{"class":261,"line":1978},67,[1980,1985,1989],{"type":42,"tag":259,"props":1981,"children":1982},{"style":423},[1983],{"type":48,"value":1984},"        ...",{"type":42,"tag":259,"props":1986,"children":1987},{"style":429},[1988],{"type":48,"value":1088},{"type":42,"tag":259,"props":1990,"children":1991},{"style":423},[1992],{"type":48,"value":792},{"type":42,"tag":259,"props":1994,"children":1996},{"class":261,"line":1995},68,[1997,2002,2006,2010,2014,2019,2023,2027,2031,2035,2039,2043,2048],{"type":42,"tag":259,"props":1998,"children":1999},{"style":423},[2000],{"type":48,"value":2001},"        {",{"type":42,"tag":259,"props":2003,"children":2004},{"style":506},[2005],{"type":48,"value":592},{"type":42,"tag":259,"props":2007,"children":2008},{"style":423},[2009],{"type":48,"value":514},{"type":42,"tag":259,"props":2011,"children":2012},{"style":423},[2013],{"type":48,"value":457},{"type":42,"tag":259,"props":2015,"children":2016},{"style":272},[2017],{"type":48,"value":2018},"assistant",{"type":42,"tag":259,"props":2020,"children":2021},{"style":423},[2022],{"type":48,"value":466},{"type":42,"tag":259,"props":2024,"children":2025},{"style":423},[2026],{"type":48,"value":437},{"type":42,"tag":259,"props":2028,"children":2029},{"style":506},[2030],{"type":48,"value":610},{"type":42,"tag":259,"props":2032,"children":2033},{"style":423},[2034],{"type":48,"value":514},{"type":42,"tag":259,"props":2036,"children":2037},{"style":429},[2038],{"type":48,"value":1814},{"type":42,"tag":259,"props":2040,"children":2041},{"style":423},[2042],{"type":48,"value":873},{"type":42,"tag":259,"props":2044,"children":2045},{"style":429},[2046],{"type":48,"value":2047},"response",{"type":42,"tag":259,"props":2049,"children":2050},{"style":423},[2051],{"type":48,"value":1771},{"type":42,"tag":259,"props":2053,"children":2055},{"class":261,"line":2054},69,[2056,2061],{"type":42,"tag":259,"props":2057,"children":2058},{"style":506},[2059],{"type":48,"value":2060},"      ]",{"type":42,"tag":259,"props":2062,"children":2063},{"style":423},[2064],{"type":48,"value":792},{"type":42,"tag":259,"props":2066,"children":2068},{"class":261,"line":2067},70,[2069,2073,2077],{"type":42,"tag":259,"props":2070,"children":2071},{"style":423},[2072],{"type":48,"value":1101},{"type":42,"tag":259,"props":2074,"children":2075},{"style":506},[2076],{"type":48,"value":240},{"type":42,"tag":259,"props":2078,"children":2079},{"style":423},[2080],{"type":48,"value":471},{"type":42,"tag":259,"props":2082,"children":2084},{"class":261,"line":2083},71,[2085],{"type":42,"tag":259,"props":2086,"children":2087},{"emptyLinePlaceholder":477},[2088],{"type":48,"value":480},{"type":42,"tag":259,"props":2090,"children":2092},{"class":261,"line":2091},72,[2093],{"type":42,"tag":259,"props":2094,"children":2095},{"style":527},[2096],{"type":48,"value":2097},"    \u002F\u002F Send response\n",{"type":42,"tag":259,"props":2099,"children":2101},{"class":261,"line":2100},73,[2102,2106,2110,2114,2118,2122,2126,2130,2134],{"type":42,"tag":259,"props":2103,"children":2104},{"style":429},[2105],{"type":48,"value":992},{"type":42,"tag":259,"props":2107,"children":2108},{"style":423},[2109],{"type":48,"value":873},{"type":42,"tag":259,"props":2111,"children":2112},{"style":302},[2113],{"type":48,"value":1001},{"type":42,"tag":259,"props":2115,"children":2116},{"style":506},[2117],{"type":48,"value":883},{"type":42,"tag":259,"props":2119,"children":2120},{"style":429},[2121],{"type":48,"value":1010},{"type":42,"tag":259,"props":2123,"children":2124},{"style":423},[2125],{"type":48,"value":873},{"type":42,"tag":259,"props":2127,"children":2128},{"style":302},[2129],{"type":48,"value":1019},{"type":42,"tag":259,"props":2131,"children":2132},{"style":506},[2133],{"type":48,"value":883},{"type":42,"tag":259,"props":2135,"children":2136},{"style":423},[2137],{"type":48,"value":1028},{"type":42,"tag":259,"props":2139,"children":2141},{"class":261,"line":2140},74,[2142,2146,2150,2154,2158,2162],{"type":42,"tag":259,"props":2143,"children":2144},{"style":506},[2145],{"type":48,"value":1037},{"type":42,"tag":259,"props":2147,"children":2148},{"style":423},[2149],{"type":48,"value":514},{"type":42,"tag":259,"props":2151,"children":2152},{"style":423},[2153],{"type":48,"value":457},{"type":42,"tag":259,"props":2155,"children":2156},{"style":272},[2157],{"type":48,"value":2047},{"type":42,"tag":259,"props":2159,"children":2160},{"style":423},[2161],{"type":48,"value":466},{"type":42,"tag":259,"props":2163,"children":2164},{"style":423},[2165],{"type":48,"value":792},{"type":42,"tag":259,"props":2167,"children":2169},{"class":261,"line":2168},75,[2170,2175,2179,2183,2187,2191],{"type":42,"tag":259,"props":2171,"children":2172},{"style":506},[2173],{"type":48,"value":2174},"      content",{"type":42,"tag":259,"props":2176,"children":2177},{"style":423},[2178],{"type":48,"value":514},{"type":42,"tag":259,"props":2180,"children":2181},{"style":429},[2182],{"type":48,"value":1814},{"type":42,"tag":259,"props":2184,"children":2185},{"style":423},[2186],{"type":48,"value":873},{"type":42,"tag":259,"props":2188,"children":2189},{"style":429},[2190],{"type":48,"value":2047},{"type":42,"tag":259,"props":2192,"children":2193},{"style":423},[2194],{"type":48,"value":792},{"type":42,"tag":259,"props":2196,"children":2198},{"class":261,"line":2197},76,[2199,2203,2207],{"type":42,"tag":259,"props":2200,"children":2201},{"style":423},[2202],{"type":48,"value":1101},{"type":42,"tag":259,"props":2204,"children":2205},{"style":506},[2206],{"type":48,"value":1106},{"type":42,"tag":259,"props":2208,"children":2209},{"style":423},[2210],{"type":48,"value":471},{"type":42,"tag":259,"props":2212,"children":2214},{"class":261,"line":2213},77,[2215],{"type":42,"tag":259,"props":2216,"children":2217},{"style":423},[2218],{"type":48,"value":927},{"type":42,"tag":259,"props":2220,"children":2222},{"class":261,"line":2221},78,[2223],{"type":42,"tag":259,"props":2224,"children":2225},{"style":423},[2226],{"type":48,"value":539},{"type":42,"tag":65,"props":2228,"children":2230},{"id":2229},"entry-point-configuration",[2231],{"type":48,"value":2232},"Entry Point Configuration",{"type":42,"tag":248,"props":2234,"children":2236},{"className":405,"code":2235,"language":407,"meta":253,"style":253},"\u002F\u002F src\u002Findex.ts\nimport { routeAgentRequest } from \"agents\";\nimport { MyAgent } from \".\u002Fagent\";\n\nexport default {\n  async fetch(request: Request, env: Env) {\n    \u002F\u002F routeAgentRequest handles routing to \u002Fagents\u002F:class\u002F:name\n    return (\n      (await routeAgentRequest(request, env)) ||\n      new Response(\"Not found\", { status: 404 })\n    );\n  },\n};\n\nexport { MyAgent };\n",[2237],{"type":42,"tag":116,"props":2238,"children":2239},{"__ignoreMap":253},[2240,2248,2288,2328,2335,2351,2406,2414,2427,2470,2532,2544,2552,2560,2567],{"type":42,"tag":259,"props":2241,"children":2242},{"class":261,"line":262},[2243],{"type":42,"tag":259,"props":2244,"children":2245},{"style":527},[2246],{"type":48,"value":2247},"\u002F\u002F src\u002Findex.ts\n",{"type":42,"tag":259,"props":2249,"children":2250},{"class":261,"line":298},[2251,2255,2259,2264,2268,2272,2276,2280,2284],{"type":42,"tag":259,"props":2252,"children":2253},{"style":417},[2254],{"type":48,"value":420},{"type":42,"tag":259,"props":2256,"children":2257},{"style":423},[2258],{"type":48,"value":426},{"type":42,"tag":259,"props":2260,"children":2261},{"style":429},[2262],{"type":48,"value":2263}," routeAgentRequest",{"type":42,"tag":259,"props":2265,"children":2266},{"style":423},[2267],{"type":48,"value":447},{"type":42,"tag":259,"props":2269,"children":2270},{"style":417},[2271],{"type":48,"value":452},{"type":42,"tag":259,"props":2273,"children":2274},{"style":423},[2275],{"type":48,"value":457},{"type":42,"tag":259,"props":2277,"children":2278},{"style":272},[2279],{"type":48,"value":24},{"type":42,"tag":259,"props":2281,"children":2282},{"style":423},[2283],{"type":48,"value":466},{"type":42,"tag":259,"props":2285,"children":2286},{"style":423},[2287],{"type":48,"value":471},{"type":42,"tag":259,"props":2289,"children":2290},{"class":261,"line":313},[2291,2295,2299,2303,2307,2311,2315,2320,2324],{"type":42,"tag":259,"props":2292,"children":2293},{"style":417},[2294],{"type":48,"value":420},{"type":42,"tag":259,"props":2296,"children":2297},{"style":423},[2298],{"type":48,"value":426},{"type":42,"tag":259,"props":2300,"children":2301},{"style":429},[2302],{"type":48,"value":699},{"type":42,"tag":259,"props":2304,"children":2305},{"style":423},[2306],{"type":48,"value":447},{"type":42,"tag":259,"props":2308,"children":2309},{"style":417},[2310],{"type":48,"value":452},{"type":42,"tag":259,"props":2312,"children":2313},{"style":423},[2314],{"type":48,"value":457},{"type":42,"tag":259,"props":2316,"children":2317},{"style":272},[2318],{"type":48,"value":2319},".\u002Fagent",{"type":42,"tag":259,"props":2321,"children":2322},{"style":423},[2323],{"type":48,"value":466},{"type":42,"tag":259,"props":2325,"children":2326},{"style":423},[2327],{"type":48,"value":471},{"type":42,"tag":259,"props":2329,"children":2330},{"class":261,"line":502},[2331],{"type":42,"tag":259,"props":2332,"children":2333},{"emptyLinePlaceholder":477},[2334],{"type":48,"value":480},{"type":42,"tag":259,"props":2336,"children":2337},{"class":261,"line":533},[2338,2342,2347],{"type":42,"tag":259,"props":2339,"children":2340},{"style":417},[2341],{"type":48,"value":689},{"type":42,"tag":259,"props":2343,"children":2344},{"style":417},[2345],{"type":48,"value":2346}," default",{"type":42,"tag":259,"props":2348,"children":2349},{"style":423},[2350],{"type":48,"value":499},{"type":42,"tag":259,"props":2352,"children":2353},{"class":261,"line":542},[2354,2358,2363,2367,2372,2376,2381,2385,2390,2394,2398,2402],{"type":42,"tag":259,"props":2355,"children":2356},{"style":486},[2357],{"type":48,"value":845},{"type":42,"tag":259,"props":2359,"children":2360},{"style":506},[2361],{"type":48,"value":2362}," fetch",{"type":42,"tag":259,"props":2364,"children":2365},{"style":423},[2366],{"type":48,"value":883},{"type":42,"tag":259,"props":2368,"children":2369},{"style":964},[2370],{"type":48,"value":2371},"request",{"type":42,"tag":259,"props":2373,"children":2374},{"style":423},[2375],{"type":48,"value":514},{"type":42,"tag":259,"props":2377,"children":2378},{"style":266},[2379],{"type":48,"value":2380}," Request",{"type":42,"tag":259,"props":2382,"children":2383},{"style":423},[2384],{"type":48,"value":437},{"type":42,"tag":259,"props":2386,"children":2387},{"style":964},[2388],{"type":48,"value":2389}," env",{"type":42,"tag":259,"props":2391,"children":2392},{"style":423},[2393],{"type":48,"value":514},{"type":42,"tag":259,"props":2395,"children":2396},{"style":266},[2397],{"type":48,"value":494},{"type":42,"tag":259,"props":2399,"children":2400},{"style":423},[2401],{"type":48,"value":240},{"type":42,"tag":259,"props":2403,"children":2404},{"style":423},[2405],{"type":48,"value":499},{"type":42,"tag":259,"props":2407,"children":2408},{"class":261,"line":550},[2409],{"type":42,"tag":259,"props":2410,"children":2411},{"style":527},[2412],{"type":48,"value":2413},"    \u002F\u002F routeAgentRequest handles routing to \u002Fagents\u002F:class\u002F:name\n",{"type":42,"tag":259,"props":2415,"children":2416},{"class":261,"line":567},[2417,2422],{"type":42,"tag":259,"props":2418,"children":2419},{"style":417},[2420],{"type":48,"value":2421},"    return",{"type":42,"tag":259,"props":2423,"children":2424},{"style":506},[2425],{"type":48,"value":2426}," (\n",{"type":42,"tag":259,"props":2428,"children":2429},{"class":261,"line":626},[2430,2435,2440,2444,2448,2452,2456,2460,2465],{"type":42,"tag":259,"props":2431,"children":2432},{"style":506},[2433],{"type":48,"value":2434},"      (",{"type":42,"tag":259,"props":2436,"children":2437},{"style":417},[2438],{"type":48,"value":2439},"await",{"type":42,"tag":259,"props":2441,"children":2442},{"style":302},[2443],{"type":48,"value":2263},{"type":42,"tag":259,"props":2445,"children":2446},{"style":506},[2447],{"type":48,"value":883},{"type":42,"tag":259,"props":2449,"children":2450},{"style":429},[2451],{"type":48,"value":2371},{"type":42,"tag":259,"props":2453,"children":2454},{"style":423},[2455],{"type":48,"value":437},{"type":42,"tag":259,"props":2457,"children":2458},{"style":429},[2459],{"type":48,"value":2389},{"type":42,"tag":259,"props":2461,"children":2462},{"style":506},[2463],{"type":48,"value":2464},")) ",{"type":42,"tag":259,"props":2466,"children":2467},{"style":423},[2468],{"type":48,"value":2469},"||\n",{"type":42,"tag":259,"props":2471,"children":2472},{"class":261,"line":667},[2473,2478,2483,2487,2491,2496,2500,2504,2508,2513,2517,2523,2527],{"type":42,"tag":259,"props":2474,"children":2475},{"style":423},[2476],{"type":48,"value":2477},"      new",{"type":42,"tag":259,"props":2479,"children":2480},{"style":302},[2481],{"type":48,"value":2482}," Response",{"type":42,"tag":259,"props":2484,"children":2485},{"style":506},[2486],{"type":48,"value":883},{"type":42,"tag":259,"props":2488,"children":2489},{"style":423},[2490],{"type":48,"value":466},{"type":42,"tag":259,"props":2492,"children":2493},{"style":272},[2494],{"type":48,"value":2495},"Not found",{"type":42,"tag":259,"props":2497,"children":2498},{"style":423},[2499],{"type":48,"value":466},{"type":42,"tag":259,"props":2501,"children":2502},{"style":423},[2503],{"type":48,"value":437},{"type":42,"tag":259,"props":2505,"children":2506},{"style":423},[2507],{"type":48,"value":426},{"type":42,"tag":259,"props":2509,"children":2510},{"style":506},[2511],{"type":48,"value":2512}," status",{"type":42,"tag":259,"props":2514,"children":2515},{"style":423},[2516],{"type":48,"value":514},{"type":42,"tag":259,"props":2518,"children":2520},{"style":2519},"--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C",[2521],{"type":48,"value":2522}," 404",{"type":42,"tag":259,"props":2524,"children":2525},{"style":423},[2526],{"type":48,"value":447},{"type":42,"tag":259,"props":2528,"children":2529},{"style":506},[2530],{"type":48,"value":2531},")\n",{"type":42,"tag":259,"props":2533,"children":2534},{"class":261,"line":675},[2535,2540],{"type":42,"tag":259,"props":2536,"children":2537},{"style":506},[2538],{"type":48,"value":2539},"    )",{"type":42,"tag":259,"props":2541,"children":2542},{"style":423},[2543],{"type":48,"value":471},{"type":42,"tag":259,"props":2545,"children":2546},{"class":261,"line":683},[2547],{"type":42,"tag":259,"props":2548,"children":2549},{"style":423},[2550],{"type":48,"value":2551},"  },\n",{"type":42,"tag":259,"props":2553,"children":2554},{"class":261,"line":737},[2555],{"type":42,"tag":259,"props":2556,"children":2557},{"style":423},[2558],{"type":48,"value":2559},"};\n",{"type":42,"tag":259,"props":2561,"children":2562},{"class":261,"line":746},[2563],{"type":42,"tag":259,"props":2564,"children":2565},{"emptyLinePlaceholder":477},[2566],{"type":48,"value":480},{"type":42,"tag":259,"props":2568,"children":2569},{"class":261,"line":772},[2570,2574,2578,2582],{"type":42,"tag":259,"props":2571,"children":2572},{"style":417},[2573],{"type":48,"value":689},{"type":42,"tag":259,"props":2575,"children":2576},{"style":423},[2577],{"type":48,"value":426},{"type":42,"tag":259,"props":2579,"children":2580},{"style":429},[2581],{"type":48,"value":699},{"type":42,"tag":259,"props":2583,"children":2584},{"style":423},[2585],{"type":48,"value":2586}," };\n",{"type":42,"tag":51,"props":2588,"children":2589},{},[2590,2592],{"type":48,"value":2591},"Clients connect via: ",{"type":42,"tag":116,"props":2593,"children":2595},{"className":2594},[],[2596],{"type":48,"value":2597},"wss:\u002F\u002Fmy-agent.workers.dev\u002Fagents\u002FMyAgent\u002Fsession-id",{"type":42,"tag":65,"props":2599,"children":2601},{"id":2600},"wrangler-configuration",[2602],{"type":48,"value":2603},"Wrangler Configuration",{"type":42,"tag":248,"props":2605,"children":2609},{"className":2606,"code":2607,"language":2608,"meta":253,"style":253},"language-toml shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","name = \"my-agent\"\nmain = \"src\u002Findex.ts\"\ncompatibility_date = \"2024-12-01\"\n\n[ai]\nbinding = \"AI\"\n\n[durable_objects]\nbindings = [{ name = \"AGENT\", class_name = \"MyAgent\" }]\n\n[[migrations]]\ntag = \"v1\"\nnew_classes = [\"MyAgent\"]\n","toml",[2610],{"type":42,"tag":116,"props":2611,"children":2612},{"__ignoreMap":253},[2613,2621,2629,2637,2644,2652,2660,2667,2675,2683,2690,2698,2706],{"type":42,"tag":259,"props":2614,"children":2615},{"class":261,"line":262},[2616],{"type":42,"tag":259,"props":2617,"children":2618},{},[2619],{"type":48,"value":2620},"name = \"my-agent\"\n",{"type":42,"tag":259,"props":2622,"children":2623},{"class":261,"line":298},[2624],{"type":42,"tag":259,"props":2625,"children":2626},{},[2627],{"type":48,"value":2628},"main = \"src\u002Findex.ts\"\n",{"type":42,"tag":259,"props":2630,"children":2631},{"class":261,"line":313},[2632],{"type":42,"tag":259,"props":2633,"children":2634},{},[2635],{"type":48,"value":2636},"compatibility_date = \"2024-12-01\"\n",{"type":42,"tag":259,"props":2638,"children":2639},{"class":261,"line":502},[2640],{"type":42,"tag":259,"props":2641,"children":2642},{"emptyLinePlaceholder":477},[2643],{"type":48,"value":480},{"type":42,"tag":259,"props":2645,"children":2646},{"class":261,"line":533},[2647],{"type":42,"tag":259,"props":2648,"children":2649},{},[2650],{"type":48,"value":2651},"[ai]\n",{"type":42,"tag":259,"props":2653,"children":2654},{"class":261,"line":542},[2655],{"type":42,"tag":259,"props":2656,"children":2657},{},[2658],{"type":48,"value":2659},"binding = \"AI\"\n",{"type":42,"tag":259,"props":2661,"children":2662},{"class":261,"line":550},[2663],{"type":42,"tag":259,"props":2664,"children":2665},{"emptyLinePlaceholder":477},[2666],{"type":48,"value":480},{"type":42,"tag":259,"props":2668,"children":2669},{"class":261,"line":567},[2670],{"type":42,"tag":259,"props":2671,"children":2672},{},[2673],{"type":48,"value":2674},"[durable_objects]\n",{"type":42,"tag":259,"props":2676,"children":2677},{"class":261,"line":626},[2678],{"type":42,"tag":259,"props":2679,"children":2680},{},[2681],{"type":48,"value":2682},"bindings = [{ name = \"AGENT\", class_name = \"MyAgent\" }]\n",{"type":42,"tag":259,"props":2684,"children":2685},{"class":261,"line":667},[2686],{"type":42,"tag":259,"props":2687,"children":2688},{"emptyLinePlaceholder":477},[2689],{"type":48,"value":480},{"type":42,"tag":259,"props":2691,"children":2692},{"class":261,"line":675},[2693],{"type":42,"tag":259,"props":2694,"children":2695},{},[2696],{"type":48,"value":2697},"[[migrations]]\n",{"type":42,"tag":259,"props":2699,"children":2700},{"class":261,"line":683},[2701],{"type":42,"tag":259,"props":2702,"children":2703},{},[2704],{"type":48,"value":2705},"tag = \"v1\"\n",{"type":42,"tag":259,"props":2707,"children":2708},{"class":261,"line":737},[2709],{"type":42,"tag":259,"props":2710,"children":2711},{},[2712],{"type":48,"value":2713},"new_classes = [\"MyAgent\"]\n",{"type":42,"tag":65,"props":2715,"children":2717},{"id":2716},"state-management",[2718],{"type":48,"value":2719},"State Management",{"type":42,"tag":342,"props":2721,"children":2723},{"id":2722},"reading-state",[2724],{"type":48,"value":2725},"Reading State",{"type":42,"tag":248,"props":2727,"children":2729},{"className":405,"code":2728,"language":407,"meta":253,"style":253},"\u002F\u002F Current state is always available\nconst currentMessages = this.state.messages;\nconst userPrefs = this.state.preferences;\n",[2730],{"type":42,"tag":116,"props":2731,"children":2732},{"__ignoreMap":253},[2733,2741,2779],{"type":42,"tag":259,"props":2734,"children":2735},{"class":261,"line":262},[2736],{"type":42,"tag":259,"props":2737,"children":2738},{"style":527},[2739],{"type":48,"value":2740},"\u002F\u002F Current state is always available\n",{"type":42,"tag":259,"props":2742,"children":2743},{"class":261,"line":298},[2744,2749,2754,2759,2763,2767,2771,2775],{"type":42,"tag":259,"props":2745,"children":2746},{"style":486},[2747],{"type":48,"value":2748},"const",{"type":42,"tag":259,"props":2750,"children":2751},{"style":429},[2752],{"type":48,"value":2753}," currentMessages ",{"type":42,"tag":259,"props":2755,"children":2756},{"style":423},[2757],{"type":48,"value":2758},"=",{"type":42,"tag":259,"props":2760,"children":2761},{"style":423},[2762],{"type":48,"value":905},{"type":42,"tag":259,"props":2764,"children":2765},{"style":429},[2766],{"type":48,"value":910},{"type":42,"tag":259,"props":2768,"children":2769},{"style":423},[2770],{"type":48,"value":873},{"type":42,"tag":259,"props":2772,"children":2773},{"style":429},[2774],{"type":48,"value":1088},{"type":42,"tag":259,"props":2776,"children":2777},{"style":423},[2778],{"type":48,"value":471},{"type":42,"tag":259,"props":2780,"children":2781},{"class":261,"line":313},[2782,2786,2791,2795,2799,2803,2807,2812],{"type":42,"tag":259,"props":2783,"children":2784},{"style":486},[2785],{"type":48,"value":2748},{"type":42,"tag":259,"props":2787,"children":2788},{"style":429},[2789],{"type":48,"value":2790}," userPrefs ",{"type":42,"tag":259,"props":2792,"children":2793},{"style":423},[2794],{"type":48,"value":2758},{"type":42,"tag":259,"props":2796,"children":2797},{"style":423},[2798],{"type":48,"value":905},{"type":42,"tag":259,"props":2800,"children":2801},{"style":429},[2802],{"type":48,"value":910},{"type":42,"tag":259,"props":2804,"children":2805},{"style":423},[2806],{"type":48,"value":873},{"type":42,"tag":259,"props":2808,"children":2809},{"style":429},[2810],{"type":48,"value":2811},"preferences",{"type":42,"tag":259,"props":2813,"children":2814},{"style":423},[2815],{"type":48,"value":471},{"type":42,"tag":342,"props":2817,"children":2819},{"id":2818},"updating-state",[2820],{"type":48,"value":2821},"Updating State",{"type":42,"tag":248,"props":2823,"children":2825},{"className":405,"code":2824,"language":407,"meta":253,"style":253},"\u002F\u002F setState persists AND syncs to all connected clients\nthis.setState({\n  ...this.state,\n  messages: [...this.state.messages, newMessage],\n});\n\n\u002F\u002F Partial updates work too\nthis.setState({\n  preferences: { ...this.state.preferences, theme: \"dark\" },\n});\n",[2826],{"type":42,"tag":116,"props":2827,"children":2828},{"__ignoreMap":253},[2829,2837,2857,2873,2919,2935,2942,2950,2969,3031],{"type":42,"tag":259,"props":2830,"children":2831},{"class":261,"line":262},[2832],{"type":42,"tag":259,"props":2833,"children":2834},{"style":527},[2835],{"type":48,"value":2836},"\u002F\u002F setState persists AND syncs to all connected clients\n",{"type":42,"tag":259,"props":2838,"children":2839},{"class":261,"line":298},[2840,2845,2849,2853],{"type":42,"tag":259,"props":2841,"children":2842},{"style":423},[2843],{"type":48,"value":2844},"this.",{"type":42,"tag":259,"props":2846,"children":2847},{"style":302},[2848],{"type":48,"value":1935},{"type":42,"tag":259,"props":2850,"children":2851},{"style":429},[2852],{"type":48,"value":883},{"type":42,"tag":259,"props":2854,"children":2855},{"style":423},[2856],{"type":48,"value":1028},{"type":42,"tag":259,"props":2858,"children":2859},{"class":261,"line":313},[2860,2865,2869],{"type":42,"tag":259,"props":2861,"children":2862},{"style":423},[2863],{"type":48,"value":2864},"  ...this.",{"type":42,"tag":259,"props":2866,"children":2867},{"style":429},[2868],{"type":48,"value":910},{"type":42,"tag":259,"props":2870,"children":2871},{"style":423},[2872],{"type":48,"value":792},{"type":42,"tag":259,"props":2874,"children":2875},{"class":261,"line":502},[2876,2880,2884,2889,2894,2898,2902,2906,2910,2915],{"type":42,"tag":259,"props":2877,"children":2878},{"style":506},[2879],{"type":48,"value":573},{"type":42,"tag":259,"props":2881,"children":2882},{"style":423},[2883],{"type":48,"value":514},{"type":42,"tag":259,"props":2885,"children":2886},{"style":429},[2887],{"type":48,"value":2888}," [",{"type":42,"tag":259,"props":2890,"children":2891},{"style":423},[2892],{"type":48,"value":2893},"...this.",{"type":42,"tag":259,"props":2895,"children":2896},{"style":429},[2897],{"type":48,"value":910},{"type":42,"tag":259,"props":2899,"children":2900},{"style":423},[2901],{"type":48,"value":873},{"type":42,"tag":259,"props":2903,"children":2904},{"style":429},[2905],{"type":48,"value":1088},{"type":42,"tag":259,"props":2907,"children":2908},{"style":423},[2909],{"type":48,"value":437},{"type":42,"tag":259,"props":2911,"children":2912},{"style":429},[2913],{"type":48,"value":2914}," newMessage]",{"type":42,"tag":259,"props":2916,"children":2917},{"style":423},[2918],{"type":48,"value":792},{"type":42,"tag":259,"props":2920,"children":2921},{"class":261,"line":533},[2922,2927,2931],{"type":42,"tag":259,"props":2923,"children":2924},{"style":423},[2925],{"type":48,"value":2926},"}",{"type":42,"tag":259,"props":2928,"children":2929},{"style":429},[2930],{"type":48,"value":240},{"type":42,"tag":259,"props":2932,"children":2933},{"style":423},[2934],{"type":48,"value":471},{"type":42,"tag":259,"props":2936,"children":2937},{"class":261,"line":542},[2938],{"type":42,"tag":259,"props":2939,"children":2940},{"emptyLinePlaceholder":477},[2941],{"type":48,"value":480},{"type":42,"tag":259,"props":2943,"children":2944},{"class":261,"line":550},[2945],{"type":42,"tag":259,"props":2946,"children":2947},{"style":527},[2948],{"type":48,"value":2949},"\u002F\u002F Partial updates work too\n",{"type":42,"tag":259,"props":2951,"children":2952},{"class":261,"line":567},[2953,2957,2961,2965],{"type":42,"tag":259,"props":2954,"children":2955},{"style":423},[2956],{"type":48,"value":2844},{"type":42,"tag":259,"props":2958,"children":2959},{"style":302},[2960],{"type":48,"value":1935},{"type":42,"tag":259,"props":2962,"children":2963},{"style":429},[2964],{"type":48,"value":883},{"type":42,"tag":259,"props":2966,"children":2967},{"style":423},[2968],{"type":48,"value":1028},{"type":42,"tag":259,"props":2970,"children":2971},{"class":261,"line":626},[2972,2976,2980,2984,2989,2993,2997,3001,3005,3010,3014,3018,3023,3027],{"type":42,"tag":259,"props":2973,"children":2974},{"style":506},[2975],{"type":48,"value":632},{"type":42,"tag":259,"props":2977,"children":2978},{"style":423},[2979],{"type":48,"value":514},{"type":42,"tag":259,"props":2981,"children":2982},{"style":423},[2983],{"type":48,"value":426},{"type":42,"tag":259,"props":2985,"children":2986},{"style":423},[2987],{"type":48,"value":2988}," ...this.",{"type":42,"tag":259,"props":2990,"children":2991},{"style":429},[2992],{"type":48,"value":910},{"type":42,"tag":259,"props":2994,"children":2995},{"style":423},[2996],{"type":48,"value":873},{"type":42,"tag":259,"props":2998,"children":2999},{"style":429},[3000],{"type":48,"value":2811},{"type":42,"tag":259,"props":3002,"children":3003},{"style":423},[3004],{"type":48,"value":437},{"type":42,"tag":259,"props":3006,"children":3007},{"style":506},[3008],{"type":48,"value":3009}," theme",{"type":42,"tag":259,"props":3011,"children":3012},{"style":423},[3013],{"type":48,"value":514},{"type":42,"tag":259,"props":3015,"children":3016},{"style":423},[3017],{"type":48,"value":457},{"type":42,"tag":259,"props":3019,"children":3020},{"style":272},[3021],{"type":48,"value":3022},"dark",{"type":42,"tag":259,"props":3024,"children":3025},{"style":423},[3026],{"type":48,"value":466},{"type":42,"tag":259,"props":3028,"children":3029},{"style":423},[3030],{"type":48,"value":1771},{"type":42,"tag":259,"props":3032,"children":3033},{"class":261,"line":667},[3034,3038,3042],{"type":42,"tag":259,"props":3035,"children":3036},{"style":423},[3037],{"type":48,"value":2926},{"type":42,"tag":259,"props":3039,"children":3040},{"style":429},[3041],{"type":48,"value":240},{"type":42,"tag":259,"props":3043,"children":3044},{"style":423},[3045],{"type":48,"value":471},{"type":42,"tag":342,"props":3047,"children":3049},{"id":3048},"sql-storage",[3050],{"type":48,"value":3051},"SQL Storage",{"type":42,"tag":51,"props":3053,"children":3054},{},[3055],{"type":48,"value":3056},"For complex queries, use the embedded SQLite database:",{"type":42,"tag":248,"props":3058,"children":3060},{"className":405,"code":3059,"language":407,"meta":253,"style":253},"\u002F\u002F Create tables\nawait this.sql`\n  CREATE TABLE IF NOT EXISTS documents (\n    id INTEGER PRIMARY KEY AUTOINCREMENT,\n    title TEXT NOT NULL,\n    content TEXT,\n    created_at DATETIME DEFAULT CURRENT_TIMESTAMP\n  )\n`;\n\n\u002F\u002F Insert\nawait this.sql`\n  INSERT INTO documents (title, content)\n  VALUES (${title}, ${content})\n`;\n\n\u002F\u002F Query\nconst docs = await this.sql`\n  SELECT * FROM documents WHERE title LIKE ${`%${search}%`}\n`;\n",[3061],{"type":42,"tag":116,"props":3062,"children":3063},{"__ignoreMap":253},[3064,3072,3093,3101,3109,3117,3125,3133,3141,3153,3160,3168,3187,3195,3238,3249,3256,3264,3296,3336],{"type":42,"tag":259,"props":3065,"children":3066},{"class":261,"line":262},[3067],{"type":42,"tag":259,"props":3068,"children":3069},{"style":527},[3070],{"type":48,"value":3071},"\u002F\u002F Create tables\n",{"type":42,"tag":259,"props":3073,"children":3074},{"class":261,"line":298},[3075,3079,3083,3088],{"type":42,"tag":259,"props":3076,"children":3077},{"style":417},[3078],{"type":48,"value":2439},{"type":42,"tag":259,"props":3080,"children":3081},{"style":423},[3082],{"type":48,"value":905},{"type":42,"tag":259,"props":3084,"children":3085},{"style":302},[3086],{"type":48,"value":3087},"sql",{"type":42,"tag":259,"props":3089,"children":3090},{"style":423},[3091],{"type":48,"value":3092},"`\n",{"type":42,"tag":259,"props":3094,"children":3095},{"class":261,"line":313},[3096],{"type":42,"tag":259,"props":3097,"children":3098},{"style":272},[3099],{"type":48,"value":3100},"  CREATE TABLE IF NOT EXISTS documents (\n",{"type":42,"tag":259,"props":3102,"children":3103},{"class":261,"line":502},[3104],{"type":42,"tag":259,"props":3105,"children":3106},{"style":272},[3107],{"type":48,"value":3108},"    id INTEGER PRIMARY KEY AUTOINCREMENT,\n",{"type":42,"tag":259,"props":3110,"children":3111},{"class":261,"line":533},[3112],{"type":42,"tag":259,"props":3113,"children":3114},{"style":272},[3115],{"type":48,"value":3116},"    title TEXT NOT NULL,\n",{"type":42,"tag":259,"props":3118,"children":3119},{"class":261,"line":542},[3120],{"type":42,"tag":259,"props":3121,"children":3122},{"style":272},[3123],{"type":48,"value":3124},"    content TEXT,\n",{"type":42,"tag":259,"props":3126,"children":3127},{"class":261,"line":550},[3128],{"type":42,"tag":259,"props":3129,"children":3130},{"style":272},[3131],{"type":48,"value":3132},"    created_at DATETIME DEFAULT CURRENT_TIMESTAMP\n",{"type":42,"tag":259,"props":3134,"children":3135},{"class":261,"line":567},[3136],{"type":42,"tag":259,"props":3137,"children":3138},{"style":272},[3139],{"type":48,"value":3140},"  )\n",{"type":42,"tag":259,"props":3142,"children":3143},{"class":261,"line":626},[3144,3149],{"type":42,"tag":259,"props":3145,"children":3146},{"style":423},[3147],{"type":48,"value":3148},"`",{"type":42,"tag":259,"props":3150,"children":3151},{"style":423},[3152],{"type":48,"value":471},{"type":42,"tag":259,"props":3154,"children":3155},{"class":261,"line":667},[3156],{"type":42,"tag":259,"props":3157,"children":3158},{"emptyLinePlaceholder":477},[3159],{"type":48,"value":480},{"type":42,"tag":259,"props":3161,"children":3162},{"class":261,"line":675},[3163],{"type":42,"tag":259,"props":3164,"children":3165},{"style":527},[3166],{"type":48,"value":3167},"\u002F\u002F Insert\n",{"type":42,"tag":259,"props":3169,"children":3170},{"class":261,"line":683},[3171,3175,3179,3183],{"type":42,"tag":259,"props":3172,"children":3173},{"style":417},[3174],{"type":48,"value":2439},{"type":42,"tag":259,"props":3176,"children":3177},{"style":423},[3178],{"type":48,"value":905},{"type":42,"tag":259,"props":3180,"children":3181},{"style":302},[3182],{"type":48,"value":3087},{"type":42,"tag":259,"props":3184,"children":3185},{"style":423},[3186],{"type":48,"value":3092},{"type":42,"tag":259,"props":3188,"children":3189},{"class":261,"line":737},[3190],{"type":42,"tag":259,"props":3191,"children":3192},{"style":272},[3193],{"type":48,"value":3194},"  INSERT INTO documents (title, content)\n",{"type":42,"tag":259,"props":3196,"children":3197},{"class":261,"line":746},[3198,3203,3208,3213,3217,3222,3226,3230,3234],{"type":42,"tag":259,"props":3199,"children":3200},{"style":272},[3201],{"type":48,"value":3202},"  VALUES (",{"type":42,"tag":259,"props":3204,"children":3205},{"style":423},[3206],{"type":48,"value":3207},"${",{"type":42,"tag":259,"props":3209,"children":3210},{"style":429},[3211],{"type":48,"value":3212},"title",{"type":42,"tag":259,"props":3214,"children":3215},{"style":423},[3216],{"type":48,"value":2926},{"type":42,"tag":259,"props":3218,"children":3219},{"style":272},[3220],{"type":48,"value":3221},", ",{"type":42,"tag":259,"props":3223,"children":3224},{"style":423},[3225],{"type":48,"value":3207},{"type":42,"tag":259,"props":3227,"children":3228},{"style":429},[3229],{"type":48,"value":1344},{"type":42,"tag":259,"props":3231,"children":3232},{"style":423},[3233],{"type":48,"value":2926},{"type":42,"tag":259,"props":3235,"children":3236},{"style":272},[3237],{"type":48,"value":2531},{"type":42,"tag":259,"props":3239,"children":3240},{"class":261,"line":772},[3241,3245],{"type":42,"tag":259,"props":3242,"children":3243},{"style":423},[3244],{"type":48,"value":3148},{"type":42,"tag":259,"props":3246,"children":3247},{"style":423},[3248],{"type":48,"value":471},{"type":42,"tag":259,"props":3250,"children":3251},{"class":261,"line":795},[3252],{"type":42,"tag":259,"props":3253,"children":3254},{"emptyLinePlaceholder":477},[3255],{"type":48,"value":480},{"type":42,"tag":259,"props":3257,"children":3258},{"class":261,"line":813},[3259],{"type":42,"tag":259,"props":3260,"children":3261},{"style":527},[3262],{"type":48,"value":3263},"\u002F\u002F Query\n",{"type":42,"tag":259,"props":3265,"children":3266},{"class":261,"line":822},[3267,3271,3276,3280,3284,3288,3292],{"type":42,"tag":259,"props":3268,"children":3269},{"style":486},[3270],{"type":48,"value":2748},{"type":42,"tag":259,"props":3272,"children":3273},{"style":429},[3274],{"type":48,"value":3275}," docs ",{"type":42,"tag":259,"props":3277,"children":3278},{"style":423},[3279],{"type":48,"value":2758},{"type":42,"tag":259,"props":3281,"children":3282},{"style":417},[3283],{"type":48,"value":1823},{"type":42,"tag":259,"props":3285,"children":3286},{"style":423},[3287],{"type":48,"value":905},{"type":42,"tag":259,"props":3289,"children":3290},{"style":302},[3291],{"type":48,"value":3087},{"type":42,"tag":259,"props":3293,"children":3294},{"style":423},[3295],{"type":48,"value":3092},{"type":42,"tag":259,"props":3297,"children":3298},{"class":261,"line":830},[3299,3304,3309,3314,3318,3323,3327,3331],{"type":42,"tag":259,"props":3300,"children":3301},{"style":272},[3302],{"type":48,"value":3303},"  SELECT * FROM documents WHERE title LIKE ",{"type":42,"tag":259,"props":3305,"children":3306},{"style":423},[3307],{"type":48,"value":3308},"${`",{"type":42,"tag":259,"props":3310,"children":3311},{"style":272},[3312],{"type":48,"value":3313},"%",{"type":42,"tag":259,"props":3315,"children":3316},{"style":423},[3317],{"type":48,"value":3207},{"type":42,"tag":259,"props":3319,"children":3320},{"style":429},[3321],{"type":48,"value":3322},"search",{"type":42,"tag":259,"props":3324,"children":3325},{"style":423},[3326],{"type":48,"value":2926},{"type":42,"tag":259,"props":3328,"children":3329},{"style":272},[3330],{"type":48,"value":3313},{"type":42,"tag":259,"props":3332,"children":3333},{"style":423},[3334],{"type":48,"value":3335},"`}\n",{"type":42,"tag":259,"props":3337,"children":3338},{"class":261,"line":839},[3339,3343],{"type":42,"tag":259,"props":3340,"children":3341},{"style":423},[3342],{"type":48,"value":3148},{"type":42,"tag":259,"props":3344,"children":3345},{"style":423},[3346],{"type":48,"value":471},{"type":42,"tag":65,"props":3348,"children":3350},{"id":3349},"scheduled-tasks",[3351],{"type":48,"value":3352},"Scheduled Tasks",{"type":42,"tag":51,"props":3354,"children":3355},{},[3356],{"type":48,"value":3357},"Agents can schedule future work:",{"type":42,"tag":248,"props":3359,"children":3361},{"className":405,"code":3360,"language":407,"meta":253,"style":253},"async onMessage(connection: Connection, message: string) {\n  const data = JSON.parse(message);\n\n  if (data.type === \"schedule_reminder\") {\n    \u002F\u002F Schedule task for 1 hour from now\n    const { id } = await this.schedule(3600, \"sendReminder\", {\n      message: data.reminderText,\n      userId: data.userId,\n    });\n\n    connection.send(JSON.stringify({ type: \"scheduled\", taskId: id }));\n  }\n}\n\n\u002F\u002F Called when scheduled task fires\nasync sendReminder(data: { message: string; userId: string }) {\n  \u002F\u002F Send notification, email, etc.\n  console.log(`Reminder for ${data.userId}: ${data.message}`);\n\n  \u002F\u002F Can also update state\n  this.setState({\n    ...this.state,\n    lastReminder: new Date().toISOString(),\n  });\n}\n",[3362],{"type":42,"tag":116,"props":3363,"children":3364},{"__ignoreMap":253},[3365,3396,3440,3447,3496,3504,3575,3604,3633,3648,3655,3746,3753,3760,3767,3775,3820,3828,3911,3918,3926,3946,3962,4005,4021],{"type":42,"tag":259,"props":3366,"children":3367},{"class":261,"line":262},[3368,3373,3378,3383,3387,3392],{"type":42,"tag":259,"props":3369,"children":3370},{"style":429},[3371],{"type":48,"value":3372},"async ",{"type":42,"tag":259,"props":3374,"children":3375},{"style":302},[3376],{"type":48,"value":3377},"onMessage",{"type":42,"tag":259,"props":3379,"children":3380},{"style":429},[3381],{"type":48,"value":3382},"(connection: Connection",{"type":42,"tag":259,"props":3384,"children":3385},{"style":423},[3386],{"type":48,"value":437},{"type":42,"tag":259,"props":3388,"children":3389},{"style":429},[3390],{"type":48,"value":3391}," message: string) ",{"type":42,"tag":259,"props":3393,"children":3394},{"style":423},[3395],{"type":48,"value":1028},{"type":42,"tag":259,"props":3397,"children":3398},{"class":261,"line":298},[3399,3404,3408,3412,3416,3420,3424,3428,3432,3436],{"type":42,"tag":259,"props":3400,"children":3401},{"style":486},[3402],{"type":48,"value":3403},"  const",{"type":42,"tag":259,"props":3405,"children":3406},{"style":429},[3407],{"type":48,"value":1203},{"type":42,"tag":259,"props":3409,"children":3410},{"style":423},[3411],{"type":48,"value":765},{"type":42,"tag":259,"props":3413,"children":3414},{"style":429},[3415],{"type":48,"value":1212},{"type":42,"tag":259,"props":3417,"children":3418},{"style":423},[3419],{"type":48,"value":873},{"type":42,"tag":259,"props":3421,"children":3422},{"style":302},[3423],{"type":48,"value":1221},{"type":42,"tag":259,"props":3425,"children":3426},{"style":506},[3427],{"type":48,"value":883},{"type":42,"tag":259,"props":3429,"children":3430},{"style":429},[3431],{"type":48,"value":1230},{"type":42,"tag":259,"props":3433,"children":3434},{"style":506},[3435],{"type":48,"value":240},{"type":42,"tag":259,"props":3437,"children":3438},{"style":423},[3439],{"type":48,"value":471},{"type":42,"tag":259,"props":3441,"children":3442},{"class":261,"line":313},[3443],{"type":42,"tag":259,"props":3444,"children":3445},{"emptyLinePlaceholder":477},[3446],{"type":48,"value":480},{"type":42,"tag":259,"props":3448,"children":3449},{"class":261,"line":502},[3450,3455,3459,3463,3467,3471,3475,3479,3484,3488,3492],{"type":42,"tag":259,"props":3451,"children":3452},{"style":417},[3453],{"type":48,"value":3454},"  if",{"type":42,"tag":259,"props":3456,"children":3457},{"style":506},[3458],{"type":48,"value":1260},{"type":42,"tag":259,"props":3460,"children":3461},{"style":429},[3462],{"type":48,"value":1265},{"type":42,"tag":259,"props":3464,"children":3465},{"style":423},[3466],{"type":48,"value":873},{"type":42,"tag":259,"props":3468,"children":3469},{"style":429},[3470],{"type":48,"value":1274},{"type":42,"tag":259,"props":3472,"children":3473},{"style":423},[3474],{"type":48,"value":1279},{"type":42,"tag":259,"props":3476,"children":3477},{"style":423},[3478],{"type":48,"value":457},{"type":42,"tag":259,"props":3480,"children":3481},{"style":272},[3482],{"type":48,"value":3483},"schedule_reminder",{"type":42,"tag":259,"props":3485,"children":3486},{"style":423},[3487],{"type":48,"value":466},{"type":42,"tag":259,"props":3489,"children":3490},{"style":506},[3491],{"type":48,"value":1297},{"type":42,"tag":259,"props":3493,"children":3494},{"style":423},[3495],{"type":48,"value":1028},{"type":42,"tag":259,"props":3497,"children":3498},{"class":261,"line":533},[3499],{"type":42,"tag":259,"props":3500,"children":3501},{"style":527},[3502],{"type":48,"value":3503},"    \u002F\u002F Schedule task for 1 hour from now\n",{"type":42,"tag":259,"props":3505,"children":3506},{"class":261,"line":542},[3507,3511,3515,3520,3524,3528,3532,3536,3541,3545,3550,3554,3558,3563,3567,3571],{"type":42,"tag":259,"props":3508,"children":3509},{"style":486},[3510],{"type":48,"value":1198},{"type":42,"tag":259,"props":3512,"children":3513},{"style":423},[3514],{"type":48,"value":426},{"type":42,"tag":259,"props":3516,"children":3517},{"style":429},[3518],{"type":48,"value":3519}," id",{"type":42,"tag":259,"props":3521,"children":3522},{"style":423},[3523],{"type":48,"value":447},{"type":42,"tag":259,"props":3525,"children":3526},{"style":423},[3527],{"type":48,"value":765},{"type":42,"tag":259,"props":3529,"children":3530},{"style":417},[3531],{"type":48,"value":1823},{"type":42,"tag":259,"props":3533,"children":3534},{"style":423},[3535],{"type":48,"value":905},{"type":42,"tag":259,"props":3537,"children":3538},{"style":302},[3539],{"type":48,"value":3540},"schedule",{"type":42,"tag":259,"props":3542,"children":3543},{"style":506},[3544],{"type":48,"value":883},{"type":42,"tag":259,"props":3546,"children":3547},{"style":2519},[3548],{"type":48,"value":3549},"3600",{"type":42,"tag":259,"props":3551,"children":3552},{"style":423},[3553],{"type":48,"value":437},{"type":42,"tag":259,"props":3555,"children":3556},{"style":423},[3557],{"type":48,"value":457},{"type":42,"tag":259,"props":3559,"children":3560},{"style":272},[3561],{"type":48,"value":3562},"sendReminder",{"type":42,"tag":259,"props":3564,"children":3565},{"style":423},[3566],{"type":48,"value":466},{"type":42,"tag":259,"props":3568,"children":3569},{"style":423},[3570],{"type":48,"value":437},{"type":42,"tag":259,"props":3572,"children":3573},{"style":423},[3574],{"type":48,"value":499},{"type":42,"tag":259,"props":3576,"children":3577},{"class":261,"line":550},[3578,3583,3587,3591,3595,3600],{"type":42,"tag":259,"props":3579,"children":3580},{"style":506},[3581],{"type":48,"value":3582},"      message",{"type":42,"tag":259,"props":3584,"children":3585},{"style":423},[3586],{"type":48,"value":514},{"type":42,"tag":259,"props":3588,"children":3589},{"style":429},[3590],{"type":48,"value":1203},{"type":42,"tag":259,"props":3592,"children":3593},{"style":423},[3594],{"type":48,"value":873},{"type":42,"tag":259,"props":3596,"children":3597},{"style":429},[3598],{"type":48,"value":3599},"reminderText",{"type":42,"tag":259,"props":3601,"children":3602},{"style":423},[3603],{"type":48,"value":792},{"type":42,"tag":259,"props":3605,"children":3606},{"class":261,"line":567},[3607,3612,3616,3620,3624,3629],{"type":42,"tag":259,"props":3608,"children":3609},{"style":506},[3610],{"type":48,"value":3611},"      userId",{"type":42,"tag":259,"props":3613,"children":3614},{"style":423},[3615],{"type":48,"value":514},{"type":42,"tag":259,"props":3617,"children":3618},{"style":429},[3619],{"type":48,"value":1203},{"type":42,"tag":259,"props":3621,"children":3622},{"style":423},[3623],{"type":48,"value":873},{"type":42,"tag":259,"props":3625,"children":3626},{"style":429},[3627],{"type":48,"value":3628},"userId",{"type":42,"tag":259,"props":3630,"children":3631},{"style":423},[3632],{"type":48,"value":792},{"type":42,"tag":259,"props":3634,"children":3635},{"class":261,"line":626},[3636,3640,3644],{"type":42,"tag":259,"props":3637,"children":3638},{"style":423},[3639],{"type":48,"value":1101},{"type":42,"tag":259,"props":3641,"children":3642},{"style":506},[3643],{"type":48,"value":240},{"type":42,"tag":259,"props":3645,"children":3646},{"style":423},[3647],{"type":48,"value":471},{"type":42,"tag":259,"props":3649,"children":3650},{"class":261,"line":667},[3651],{"type":42,"tag":259,"props":3652,"children":3653},{"emptyLinePlaceholder":477},[3654],{"type":48,"value":480},{"type":42,"tag":259,"props":3656,"children":3657},{"class":261,"line":675},[3658,3662,3666,3670,3674,3678,3682,3686,3690,3695,3700,3704,3708,3713,3717,3721,3726,3730,3734,3738,3742],{"type":42,"tag":259,"props":3659,"children":3660},{"style":429},[3661],{"type":48,"value":992},{"type":42,"tag":259,"props":3663,"children":3664},{"style":423},[3665],{"type":48,"value":873},{"type":42,"tag":259,"props":3667,"children":3668},{"style":302},[3669],{"type":48,"value":1001},{"type":42,"tag":259,"props":3671,"children":3672},{"style":506},[3673],{"type":48,"value":883},{"type":42,"tag":259,"props":3675,"children":3676},{"style":429},[3677],{"type":48,"value":1010},{"type":42,"tag":259,"props":3679,"children":3680},{"style":423},[3681],{"type":48,"value":873},{"type":42,"tag":259,"props":3683,"children":3684},{"style":302},[3685],{"type":48,"value":1019},{"type":42,"tag":259,"props":3687,"children":3688},{"style":506},[3689],{"type":48,"value":883},{"type":42,"tag":259,"props":3691,"children":3692},{"style":423},[3693],{"type":48,"value":3694},"{",{"type":42,"tag":259,"props":3696,"children":3697},{"style":506},[3698],{"type":48,"value":3699}," type",{"type":42,"tag":259,"props":3701,"children":3702},{"style":423},[3703],{"type":48,"value":514},{"type":42,"tag":259,"props":3705,"children":3706},{"style":423},[3707],{"type":48,"value":457},{"type":42,"tag":259,"props":3709,"children":3710},{"style":272},[3711],{"type":48,"value":3712},"scheduled",{"type":42,"tag":259,"props":3714,"children":3715},{"style":423},[3716],{"type":48,"value":466},{"type":42,"tag":259,"props":3718,"children":3719},{"style":423},[3720],{"type":48,"value":437},{"type":42,"tag":259,"props":3722,"children":3723},{"style":506},[3724],{"type":48,"value":3725}," taskId",{"type":42,"tag":259,"props":3727,"children":3728},{"style":423},[3729],{"type":48,"value":514},{"type":42,"tag":259,"props":3731,"children":3732},{"style":429},[3733],{"type":48,"value":3519},{"type":42,"tag":259,"props":3735,"children":3736},{"style":423},[3737],{"type":48,"value":447},{"type":42,"tag":259,"props":3739,"children":3740},{"style":506},[3741],{"type":48,"value":1106},{"type":42,"tag":259,"props":3743,"children":3744},{"style":423},[3745],{"type":48,"value":471},{"type":42,"tag":259,"props":3747,"children":3748},{"class":261,"line":683},[3749],{"type":42,"tag":259,"props":3750,"children":3751},{"style":423},[3752],{"type":48,"value":927},{"type":42,"tag":259,"props":3754,"children":3755},{"class":261,"line":737},[3756],{"type":42,"tag":259,"props":3757,"children":3758},{"style":423},[3759],{"type":48,"value":539},{"type":42,"tag":259,"props":3761,"children":3762},{"class":261,"line":746},[3763],{"type":42,"tag":259,"props":3764,"children":3765},{"emptyLinePlaceholder":477},[3766],{"type":48,"value":480},{"type":42,"tag":259,"props":3768,"children":3769},{"class":261,"line":772},[3770],{"type":42,"tag":259,"props":3771,"children":3772},{"style":527},[3773],{"type":48,"value":3774},"\u002F\u002F Called when scheduled task fires\n",{"type":42,"tag":259,"props":3776,"children":3777},{"class":261,"line":795},[3778,3782,3786,3791,3795,3799,3803,3808,3812,3816],{"type":42,"tag":259,"props":3779,"children":3780},{"style":429},[3781],{"type":48,"value":3372},{"type":42,"tag":259,"props":3783,"children":3784},{"style":302},[3785],{"type":48,"value":3562},{"type":42,"tag":259,"props":3787,"children":3788},{"style":429},[3789],{"type":48,"value":3790},"(data: ",{"type":42,"tag":259,"props":3792,"children":3793},{"style":423},[3794],{"type":48,"value":3694},{"type":42,"tag":259,"props":3796,"children":3797},{"style":506},[3798],{"type":48,"value":1173},{"type":42,"tag":259,"props":3800,"children":3801},{"style":423},[3802],{"type":48,"value":514},{"type":42,"tag":259,"props":3804,"children":3805},{"style":429},[3806],{"type":48,"value":3807}," string; userId: string ",{"type":42,"tag":259,"props":3809,"children":3810},{"style":423},[3811],{"type":48,"value":2926},{"type":42,"tag":259,"props":3813,"children":3814},{"style":429},[3815],{"type":48,"value":1297},{"type":42,"tag":259,"props":3817,"children":3818},{"style":423},[3819],{"type":48,"value":1028},{"type":42,"tag":259,"props":3821,"children":3822},{"class":261,"line":813},[3823],{"type":42,"tag":259,"props":3824,"children":3825},{"style":527},[3826],{"type":48,"value":3827},"  \u002F\u002F Send notification, email, etc.\n",{"type":42,"tag":259,"props":3829,"children":3830},{"class":261,"line":822},[3831,3836,3840,3844,3848,3852,3857,3861,3865,3869,3873,3877,3882,3886,3890,3894,3898,3903,3907],{"type":42,"tag":259,"props":3832,"children":3833},{"style":429},[3834],{"type":48,"value":3835},"  console",{"type":42,"tag":259,"props":3837,"children":3838},{"style":423},[3839],{"type":48,"value":873},{"type":42,"tag":259,"props":3841,"children":3842},{"style":302},[3843],{"type":48,"value":878},{"type":42,"tag":259,"props":3845,"children":3846},{"style":506},[3847],{"type":48,"value":883},{"type":42,"tag":259,"props":3849,"children":3850},{"style":423},[3851],{"type":48,"value":3148},{"type":42,"tag":259,"props":3853,"children":3854},{"style":272},[3855],{"type":48,"value":3856},"Reminder for ",{"type":42,"tag":259,"props":3858,"children":3859},{"style":423},[3860],{"type":48,"value":3207},{"type":42,"tag":259,"props":3862,"children":3863},{"style":429},[3864],{"type":48,"value":1265},{"type":42,"tag":259,"props":3866,"children":3867},{"style":423},[3868],{"type":48,"value":873},{"type":42,"tag":259,"props":3870,"children":3871},{"style":429},[3872],{"type":48,"value":3628},{"type":42,"tag":259,"props":3874,"children":3875},{"style":423},[3876],{"type":48,"value":2926},{"type":42,"tag":259,"props":3878,"children":3879},{"style":272},[3880],{"type":48,"value":3881},": ",{"type":42,"tag":259,"props":3883,"children":3884},{"style":423},[3885],{"type":48,"value":3207},{"type":42,"tag":259,"props":3887,"children":3888},{"style":429},[3889],{"type":48,"value":1265},{"type":42,"tag":259,"props":3891,"children":3892},{"style":423},[3893],{"type":48,"value":873},{"type":42,"tag":259,"props":3895,"children":3896},{"style":429},[3897],{"type":48,"value":1230},{"type":42,"tag":259,"props":3899,"children":3900},{"style":423},[3901],{"type":48,"value":3902},"}`",{"type":42,"tag":259,"props":3904,"children":3905},{"style":506},[3906],{"type":48,"value":240},{"type":42,"tag":259,"props":3908,"children":3909},{"style":423},[3910],{"type":48,"value":471},{"type":42,"tag":259,"props":3912,"children":3913},{"class":261,"line":830},[3914],{"type":42,"tag":259,"props":3915,"children":3916},{"emptyLinePlaceholder":477},[3917],{"type":48,"value":480},{"type":42,"tag":259,"props":3919,"children":3920},{"class":261,"line":839},[3921],{"type":42,"tag":259,"props":3922,"children":3923},{"style":527},[3924],{"type":48,"value":3925},"  \u002F\u002F Can also update state\n",{"type":42,"tag":259,"props":3927,"children":3928},{"class":261,"line":862},[3929,3934,3938,3942],{"type":42,"tag":259,"props":3930,"children":3931},{"style":423},[3932],{"type":48,"value":3933},"  this.",{"type":42,"tag":259,"props":3935,"children":3936},{"style":302},[3937],{"type":48,"value":1935},{"type":42,"tag":259,"props":3939,"children":3940},{"style":506},[3941],{"type":48,"value":883},{"type":42,"tag":259,"props":3943,"children":3944},{"style":423},[3945],{"type":48,"value":1028},{"type":42,"tag":259,"props":3947,"children":3948},{"class":261,"line":921},[3949,3954,3958],{"type":42,"tag":259,"props":3950,"children":3951},{"style":423},[3952],{"type":48,"value":3953},"    ...this.",{"type":42,"tag":259,"props":3955,"children":3956},{"style":429},[3957],{"type":48,"value":910},{"type":42,"tag":259,"props":3959,"children":3960},{"style":423},[3961],{"type":48,"value":792},{"type":42,"tag":259,"props":3963,"children":3964},{"class":261,"line":930},[3965,3970,3974,3979,3984,3988,3992,3997,4001],{"type":42,"tag":259,"props":3966,"children":3967},{"style":506},[3968],{"type":48,"value":3969},"    lastReminder",{"type":42,"tag":259,"props":3971,"children":3972},{"style":423},[3973],{"type":48,"value":514},{"type":42,"tag":259,"props":3975,"children":3976},{"style":423},[3977],{"type":48,"value":3978}," new",{"type":42,"tag":259,"props":3980,"children":3981},{"style":302},[3982],{"type":48,"value":3983}," Date",{"type":42,"tag":259,"props":3985,"children":3986},{"style":506},[3987],{"type":48,"value":855},{"type":42,"tag":259,"props":3989,"children":3990},{"style":423},[3991],{"type":48,"value":873},{"type":42,"tag":259,"props":3993,"children":3994},{"style":302},[3995],{"type":48,"value":3996},"toISOString",{"type":42,"tag":259,"props":3998,"children":3999},{"style":506},[4000],{"type":48,"value":855},{"type":42,"tag":259,"props":4002,"children":4003},{"style":423},[4004],{"type":48,"value":792},{"type":42,"tag":259,"props":4006,"children":4007},{"class":261,"line":938},[4008,4013,4017],{"type":42,"tag":259,"props":4009,"children":4010},{"style":423},[4011],{"type":48,"value":4012},"  }",{"type":42,"tag":259,"props":4014,"children":4015},{"style":506},[4016],{"type":48,"value":240},{"type":42,"tag":259,"props":4018,"children":4019},{"style":423},[4020],{"type":48,"value":471},{"type":42,"tag":259,"props":4022,"children":4023},{"class":261,"line":947},[4024],{"type":42,"tag":259,"props":4025,"children":4026},{"style":423},[4027],{"type":48,"value":539},{"type":42,"tag":342,"props":4029,"children":4031},{"id":4030},"schedule-options",[4032],{"type":48,"value":4033},"Schedule Options",{"type":42,"tag":248,"props":4035,"children":4037},{"className":405,"code":4036,"language":407,"meta":253,"style":253},"\u002F\u002F Delay in seconds\nawait this.schedule(60, \"taskMethod\", { data });\n\n\u002F\u002F Specific date\nawait this.schedule(new Date(\"2025-01-01T00:00:00Z\"), \"taskMethod\", { data });\n\n\u002F\u002F Cron expression (recurring)\nawait this.schedule(\"0 9 * * *\", \"dailyTask\", {});  \u002F\u002F 9 AM daily\nawait this.schedule(\"*\u002F5 * * * *\", \"everyFiveMinutes\", {});  \u002F\u002F Every 5 min\n\n\u002F\u002F Manage schedules\nconst schedules = await this.getSchedules();\nawait this.cancelSchedule(taskId);\n",[4038],{"type":42,"tag":116,"props":4039,"children":4040},{"__ignoreMap":253},[4041,4049,4115,4122,4130,4219,4226,4234,4305,4375,4382,4390,4427],{"type":42,"tag":259,"props":4042,"children":4043},{"class":261,"line":262},[4044],{"type":42,"tag":259,"props":4045,"children":4046},{"style":527},[4047],{"type":48,"value":4048},"\u002F\u002F Delay in seconds\n",{"type":42,"tag":259,"props":4050,"children":4051},{"class":261,"line":298},[4052,4056,4060,4064,4068,4073,4077,4081,4086,4090,4094,4098,4103,4107,4111],{"type":42,"tag":259,"props":4053,"children":4054},{"style":417},[4055],{"type":48,"value":2439},{"type":42,"tag":259,"props":4057,"children":4058},{"style":423},[4059],{"type":48,"value":905},{"type":42,"tag":259,"props":4061,"children":4062},{"style":302},[4063],{"type":48,"value":3540},{"type":42,"tag":259,"props":4065,"children":4066},{"style":429},[4067],{"type":48,"value":883},{"type":42,"tag":259,"props":4069,"children":4070},{"style":2519},[4071],{"type":48,"value":4072},"60",{"type":42,"tag":259,"props":4074,"children":4075},{"style":423},[4076],{"type":48,"value":437},{"type":42,"tag":259,"props":4078,"children":4079},{"style":423},[4080],{"type":48,"value":457},{"type":42,"tag":259,"props":4082,"children":4083},{"style":272},[4084],{"type":48,"value":4085},"taskMethod",{"type":42,"tag":259,"props":4087,"children":4088},{"style":423},[4089],{"type":48,"value":466},{"type":42,"tag":259,"props":4091,"children":4092},{"style":423},[4093],{"type":48,"value":437},{"type":42,"tag":259,"props":4095,"children":4096},{"style":423},[4097],{"type":48,"value":426},{"type":42,"tag":259,"props":4099,"children":4100},{"style":429},[4101],{"type":48,"value":4102}," data ",{"type":42,"tag":259,"props":4104,"children":4105},{"style":423},[4106],{"type":48,"value":2926},{"type":42,"tag":259,"props":4108,"children":4109},{"style":429},[4110],{"type":48,"value":240},{"type":42,"tag":259,"props":4112,"children":4113},{"style":423},[4114],{"type":48,"value":471},{"type":42,"tag":259,"props":4116,"children":4117},{"class":261,"line":313},[4118],{"type":42,"tag":259,"props":4119,"children":4120},{"emptyLinePlaceholder":477},[4121],{"type":48,"value":480},{"type":42,"tag":259,"props":4123,"children":4124},{"class":261,"line":502},[4125],{"type":42,"tag":259,"props":4126,"children":4127},{"style":527},[4128],{"type":48,"value":4129},"\u002F\u002F Specific date\n",{"type":42,"tag":259,"props":4131,"children":4132},{"class":261,"line":533},[4133,4137,4141,4145,4149,4154,4158,4162,4166,4171,4175,4179,4183,4187,4191,4195,4199,4203,4207,4211,4215],{"type":42,"tag":259,"props":4134,"children":4135},{"style":417},[4136],{"type":48,"value":2439},{"type":42,"tag":259,"props":4138,"children":4139},{"style":423},[4140],{"type":48,"value":905},{"type":42,"tag":259,"props":4142,"children":4143},{"style":302},[4144],{"type":48,"value":3540},{"type":42,"tag":259,"props":4146,"children":4147},{"style":429},[4148],{"type":48,"value":883},{"type":42,"tag":259,"props":4150,"children":4151},{"style":423},[4152],{"type":48,"value":4153},"new",{"type":42,"tag":259,"props":4155,"children":4156},{"style":302},[4157],{"type":48,"value":3983},{"type":42,"tag":259,"props":4159,"children":4160},{"style":429},[4161],{"type":48,"value":883},{"type":42,"tag":259,"props":4163,"children":4164},{"style":423},[4165],{"type":48,"value":466},{"type":42,"tag":259,"props":4167,"children":4168},{"style":272},[4169],{"type":48,"value":4170},"2025-01-01T00:00:00Z",{"type":42,"tag":259,"props":4172,"children":4173},{"style":423},[4174],{"type":48,"value":466},{"type":42,"tag":259,"props":4176,"children":4177},{"style":429},[4178],{"type":48,"value":240},{"type":42,"tag":259,"props":4180,"children":4181},{"style":423},[4182],{"type":48,"value":437},{"type":42,"tag":259,"props":4184,"children":4185},{"style":423},[4186],{"type":48,"value":457},{"type":42,"tag":259,"props":4188,"children":4189},{"style":272},[4190],{"type":48,"value":4085},{"type":42,"tag":259,"props":4192,"children":4193},{"style":423},[4194],{"type":48,"value":466},{"type":42,"tag":259,"props":4196,"children":4197},{"style":423},[4198],{"type":48,"value":437},{"type":42,"tag":259,"props":4200,"children":4201},{"style":423},[4202],{"type":48,"value":426},{"type":42,"tag":259,"props":4204,"children":4205},{"style":429},[4206],{"type":48,"value":4102},{"type":42,"tag":259,"props":4208,"children":4209},{"style":423},[4210],{"type":48,"value":2926},{"type":42,"tag":259,"props":4212,"children":4213},{"style":429},[4214],{"type":48,"value":240},{"type":42,"tag":259,"props":4216,"children":4217},{"style":423},[4218],{"type":48,"value":471},{"type":42,"tag":259,"props":4220,"children":4221},{"class":261,"line":542},[4222],{"type":42,"tag":259,"props":4223,"children":4224},{"emptyLinePlaceholder":477},[4225],{"type":48,"value":480},{"type":42,"tag":259,"props":4227,"children":4228},{"class":261,"line":550},[4229],{"type":42,"tag":259,"props":4230,"children":4231},{"style":527},[4232],{"type":48,"value":4233},"\u002F\u002F Cron expression (recurring)\n",{"type":42,"tag":259,"props":4235,"children":4236},{"class":261,"line":567},[4237,4241,4245,4249,4253,4257,4262,4266,4270,4274,4279,4283,4287,4292,4296,4300],{"type":42,"tag":259,"props":4238,"children":4239},{"style":417},[4240],{"type":48,"value":2439},{"type":42,"tag":259,"props":4242,"children":4243},{"style":423},[4244],{"type":48,"value":905},{"type":42,"tag":259,"props":4246,"children":4247},{"style":302},[4248],{"type":48,"value":3540},{"type":42,"tag":259,"props":4250,"children":4251},{"style":429},[4252],{"type":48,"value":883},{"type":42,"tag":259,"props":4254,"children":4255},{"style":423},[4256],{"type":48,"value":466},{"type":42,"tag":259,"props":4258,"children":4259},{"style":272},[4260],{"type":48,"value":4261},"0 9 * * *",{"type":42,"tag":259,"props":4263,"children":4264},{"style":423},[4265],{"type":48,"value":466},{"type":42,"tag":259,"props":4267,"children":4268},{"style":423},[4269],{"type":48,"value":437},{"type":42,"tag":259,"props":4271,"children":4272},{"style":423},[4273],{"type":48,"value":457},{"type":42,"tag":259,"props":4275,"children":4276},{"style":272},[4277],{"type":48,"value":4278},"dailyTask",{"type":42,"tag":259,"props":4280,"children":4281},{"style":423},[4282],{"type":48,"value":466},{"type":42,"tag":259,"props":4284,"children":4285},{"style":423},[4286],{"type":48,"value":437},{"type":42,"tag":259,"props":4288,"children":4289},{"style":423},[4290],{"type":48,"value":4291}," {}",{"type":42,"tag":259,"props":4293,"children":4294},{"style":429},[4295],{"type":48,"value":240},{"type":42,"tag":259,"props":4297,"children":4298},{"style":423},[4299],{"type":48,"value":524},{"type":42,"tag":259,"props":4301,"children":4302},{"style":527},[4303],{"type":48,"value":4304},"  \u002F\u002F 9 AM daily\n",{"type":42,"tag":259,"props":4306,"children":4307},{"class":261,"line":626},[4308,4312,4316,4320,4324,4328,4333,4337,4341,4345,4350,4354,4358,4362,4366,4370],{"type":42,"tag":259,"props":4309,"children":4310},{"style":417},[4311],{"type":48,"value":2439},{"type":42,"tag":259,"props":4313,"children":4314},{"style":423},[4315],{"type":48,"value":905},{"type":42,"tag":259,"props":4317,"children":4318},{"style":302},[4319],{"type":48,"value":3540},{"type":42,"tag":259,"props":4321,"children":4322},{"style":429},[4323],{"type":48,"value":883},{"type":42,"tag":259,"props":4325,"children":4326},{"style":423},[4327],{"type":48,"value":466},{"type":42,"tag":259,"props":4329,"children":4330},{"style":272},[4331],{"type":48,"value":4332},"*\u002F5 * * * *",{"type":42,"tag":259,"props":4334,"children":4335},{"style":423},[4336],{"type":48,"value":466},{"type":42,"tag":259,"props":4338,"children":4339},{"style":423},[4340],{"type":48,"value":437},{"type":42,"tag":259,"props":4342,"children":4343},{"style":423},[4344],{"type":48,"value":457},{"type":42,"tag":259,"props":4346,"children":4347},{"style":272},[4348],{"type":48,"value":4349},"everyFiveMinutes",{"type":42,"tag":259,"props":4351,"children":4352},{"style":423},[4353],{"type":48,"value":466},{"type":42,"tag":259,"props":4355,"children":4356},{"style":423},[4357],{"type":48,"value":437},{"type":42,"tag":259,"props":4359,"children":4360},{"style":423},[4361],{"type":48,"value":4291},{"type":42,"tag":259,"props":4363,"children":4364},{"style":429},[4365],{"type":48,"value":240},{"type":42,"tag":259,"props":4367,"children":4368},{"style":423},[4369],{"type":48,"value":524},{"type":42,"tag":259,"props":4371,"children":4372},{"style":527},[4373],{"type":48,"value":4374},"  \u002F\u002F Every 5 min\n",{"type":42,"tag":259,"props":4376,"children":4377},{"class":261,"line":667},[4378],{"type":42,"tag":259,"props":4379,"children":4380},{"emptyLinePlaceholder":477},[4381],{"type":48,"value":480},{"type":42,"tag":259,"props":4383,"children":4384},{"class":261,"line":675},[4385],{"type":42,"tag":259,"props":4386,"children":4387},{"style":527},[4388],{"type":48,"value":4389},"\u002F\u002F Manage schedules\n",{"type":42,"tag":259,"props":4391,"children":4392},{"class":261,"line":683},[4393,4397,4402,4406,4410,4414,4419,4423],{"type":42,"tag":259,"props":4394,"children":4395},{"style":486},[4396],{"type":48,"value":2748},{"type":42,"tag":259,"props":4398,"children":4399},{"style":429},[4400],{"type":48,"value":4401}," schedules ",{"type":42,"tag":259,"props":4403,"children":4404},{"style":423},[4405],{"type":48,"value":2758},{"type":42,"tag":259,"props":4407,"children":4408},{"style":417},[4409],{"type":48,"value":1823},{"type":42,"tag":259,"props":4411,"children":4412},{"style":423},[4413],{"type":48,"value":905},{"type":42,"tag":259,"props":4415,"children":4416},{"style":302},[4417],{"type":48,"value":4418},"getSchedules",{"type":42,"tag":259,"props":4420,"children":4421},{"style":429},[4422],{"type":48,"value":855},{"type":42,"tag":259,"props":4424,"children":4425},{"style":423},[4426],{"type":48,"value":471},{"type":42,"tag":259,"props":4428,"children":4429},{"class":261,"line":737},[4430,4434,4438,4443,4448],{"type":42,"tag":259,"props":4431,"children":4432},{"style":417},[4433],{"type":48,"value":2439},{"type":42,"tag":259,"props":4435,"children":4436},{"style":423},[4437],{"type":48,"value":905},{"type":42,"tag":259,"props":4439,"children":4440},{"style":302},[4441],{"type":48,"value":4442},"cancelSchedule",{"type":42,"tag":259,"props":4444,"children":4445},{"style":429},[4446],{"type":48,"value":4447},"(taskId)",{"type":42,"tag":259,"props":4449,"children":4450},{"style":423},[4451],{"type":48,"value":471},{"type":42,"tag":65,"props":4453,"children":4455},{"id":4454},"chat-agent-ai-powered",[4456],{"type":48,"value":4457},"Chat Agent (AI-Powered)",{"type":42,"tag":51,"props":4459,"children":4460},{},[4461,4463,4469],{"type":48,"value":4462},"For chat-focused agents, extend ",{"type":42,"tag":116,"props":4464,"children":4466},{"className":4465},[],[4467],{"type":48,"value":4468},"AIChatAgent",{"type":48,"value":514},{"type":42,"tag":248,"props":4471,"children":4473},{"className":405,"code":4472,"language":407,"meta":253,"style":253},"import { AIChatAgent } from \"agents\u002Fai-chat-agent\";\n\nexport class ChatBot extends AIChatAgent\u003CEnv> {\n  \u002F\u002F Called for each user message\n  async onChatMessage(message: string) {\n    const response = await this.env.AI.run(\"@cf\u002Fmeta\u002Fllama-3-8b-instruct\", {\n      messages: [\n        { role: \"system\", content: \"You are a helpful assistant.\" },\n        ...this.messages,  \u002F\u002F Automatic history management\n        { role: \"user\", content: message },\n      ],\n      stream: true,\n    });\n\n    \u002F\u002F Stream response back to client\n    return response;\n  }\n}\n",[4474],{"type":42,"tag":116,"props":4475,"children":4476},{"__ignoreMap":253},[4477,4518,4525,4565,4573,4609,4676,4691,4748,4769,4816,4827,4849,4864,4871,4879,4894,4901],{"type":42,"tag":259,"props":4478,"children":4479},{"class":261,"line":262},[4480,4484,4488,4493,4497,4501,4505,4510,4514],{"type":42,"tag":259,"props":4481,"children":4482},{"style":417},[4483],{"type":48,"value":420},{"type":42,"tag":259,"props":4485,"children":4486},{"style":423},[4487],{"type":48,"value":426},{"type":42,"tag":259,"props":4489,"children":4490},{"style":429},[4491],{"type":48,"value":4492}," AIChatAgent",{"type":42,"tag":259,"props":4494,"children":4495},{"style":423},[4496],{"type":48,"value":447},{"type":42,"tag":259,"props":4498,"children":4499},{"style":417},[4500],{"type":48,"value":452},{"type":42,"tag":259,"props":4502,"children":4503},{"style":423},[4504],{"type":48,"value":457},{"type":42,"tag":259,"props":4506,"children":4507},{"style":272},[4508],{"type":48,"value":4509},"agents\u002Fai-chat-agent",{"type":42,"tag":259,"props":4511,"children":4512},{"style":423},[4513],{"type":48,"value":466},{"type":42,"tag":259,"props":4515,"children":4516},{"style":423},[4517],{"type":48,"value":471},{"type":42,"tag":259,"props":4519,"children":4520},{"class":261,"line":298},[4521],{"type":42,"tag":259,"props":4522,"children":4523},{"emptyLinePlaceholder":477},[4524],{"type":48,"value":480},{"type":42,"tag":259,"props":4526,"children":4527},{"class":261,"line":313},[4528,4532,4536,4541,4545,4549,4553,4557,4561],{"type":42,"tag":259,"props":4529,"children":4530},{"style":417},[4531],{"type":48,"value":689},{"type":42,"tag":259,"props":4533,"children":4534},{"style":486},[4535],{"type":48,"value":694},{"type":42,"tag":259,"props":4537,"children":4538},{"style":266},[4539],{"type":48,"value":4540}," ChatBot",{"type":42,"tag":259,"props":4542,"children":4543},{"style":486},[4544],{"type":48,"value":704},{"type":42,"tag":259,"props":4546,"children":4547},{"style":266},[4548],{"type":48,"value":4492},{"type":42,"tag":259,"props":4550,"children":4551},{"style":423},[4552],{"type":48,"value":646},{"type":42,"tag":259,"props":4554,"children":4555},{"style":266},[4556],{"type":48,"value":717},{"type":42,"tag":259,"props":4558,"children":4559},{"style":423},[4560],{"type":48,"value":730},{"type":42,"tag":259,"props":4562,"children":4563},{"style":423},[4564],{"type":48,"value":499},{"type":42,"tag":259,"props":4566,"children":4567},{"class":261,"line":502},[4568],{"type":42,"tag":259,"props":4569,"children":4570},{"style":527},[4571],{"type":48,"value":4572},"  \u002F\u002F Called for each user message\n",{"type":42,"tag":259,"props":4574,"children":4575},{"class":261,"line":533},[4576,4580,4585,4589,4593,4597,4601,4605],{"type":42,"tag":259,"props":4577,"children":4578},{"style":486},[4579],{"type":48,"value":845},{"type":42,"tag":259,"props":4581,"children":4582},{"style":506},[4583],{"type":48,"value":4584}," onChatMessage",{"type":42,"tag":259,"props":4586,"children":4587},{"style":423},[4588],{"type":48,"value":883},{"type":42,"tag":259,"props":4590,"children":4591},{"style":964},[4592],{"type":48,"value":1230},{"type":42,"tag":259,"props":4594,"children":4595},{"style":423},[4596],{"type":48,"value":514},{"type":42,"tag":259,"props":4598,"children":4599},{"style":266},[4600],{"type":48,"value":601},{"type":42,"tag":259,"props":4602,"children":4603},{"style":423},[4604],{"type":48,"value":240},{"type":42,"tag":259,"props":4606,"children":4607},{"style":423},[4608],{"type":48,"value":499},{"type":42,"tag":259,"props":4610,"children":4611},{"class":261,"line":542},[4612,4616,4620,4624,4628,4632,4636,4640,4644,4648,4652,4656,4660,4664,4668,4672],{"type":42,"tag":259,"props":4613,"children":4614},{"style":486},[4615],{"type":48,"value":1198},{"type":42,"tag":259,"props":4617,"children":4618},{"style":429},[4619],{"type":48,"value":1814},{"type":42,"tag":259,"props":4621,"children":4622},{"style":423},[4623],{"type":48,"value":765},{"type":42,"tag":259,"props":4625,"children":4626},{"style":417},[4627],{"type":48,"value":1823},{"type":42,"tag":259,"props":4629,"children":4630},{"style":423},[4631],{"type":48,"value":905},{"type":42,"tag":259,"props":4633,"children":4634},{"style":429},[4635],{"type":48,"value":1832},{"type":42,"tag":259,"props":4637,"children":4638},{"style":423},[4639],{"type":48,"value":873},{"type":42,"tag":259,"props":4641,"children":4642},{"style":429},[4643],{"type":48,"value":1841},{"type":42,"tag":259,"props":4645,"children":4646},{"style":423},[4647],{"type":48,"value":873},{"type":42,"tag":259,"props":4649,"children":4650},{"style":302},[4651],{"type":48,"value":1850},{"type":42,"tag":259,"props":4653,"children":4654},{"style":506},[4655],{"type":48,"value":883},{"type":42,"tag":259,"props":4657,"children":4658},{"style":423},[4659],{"type":48,"value":466},{"type":42,"tag":259,"props":4661,"children":4662},{"style":272},[4663],{"type":48,"value":1863},{"type":42,"tag":259,"props":4665,"children":4666},{"style":423},[4667],{"type":48,"value":466},{"type":42,"tag":259,"props":4669,"children":4670},{"style":423},[4671],{"type":48,"value":437},{"type":42,"tag":259,"props":4673,"children":4674},{"style":423},[4675],{"type":48,"value":499},{"type":42,"tag":259,"props":4677,"children":4678},{"class":261,"line":550},[4679,4683,4687],{"type":42,"tag":259,"props":4680,"children":4681},{"style":506},[4682],{"type":48,"value":1884},{"type":42,"tag":259,"props":4684,"children":4685},{"style":423},[4686],{"type":48,"value":514},{"type":42,"tag":259,"props":4688,"children":4689},{"style":506},[4690],{"type":48,"value":1695},{"type":42,"tag":259,"props":4692,"children":4693},{"class":261,"line":567},[4694,4698,4702,4706,4710,4715,4719,4723,4727,4731,4735,4740,4744],{"type":42,"tag":259,"props":4695,"children":4696},{"style":423},[4697],{"type":48,"value":2001},{"type":42,"tag":259,"props":4699,"children":4700},{"style":506},[4701],{"type":48,"value":592},{"type":42,"tag":259,"props":4703,"children":4704},{"style":423},[4705],{"type":48,"value":514},{"type":42,"tag":259,"props":4707,"children":4708},{"style":423},[4709],{"type":48,"value":457},{"type":42,"tag":259,"props":4711,"children":4712},{"style":272},[4713],{"type":48,"value":4714},"system",{"type":42,"tag":259,"props":4716,"children":4717},{"style":423},[4718],{"type":48,"value":466},{"type":42,"tag":259,"props":4720,"children":4721},{"style":423},[4722],{"type":48,"value":437},{"type":42,"tag":259,"props":4724,"children":4725},{"style":506},[4726],{"type":48,"value":610},{"type":42,"tag":259,"props":4728,"children":4729},{"style":423},[4730],{"type":48,"value":514},{"type":42,"tag":259,"props":4732,"children":4733},{"style":423},[4734],{"type":48,"value":457},{"type":42,"tag":259,"props":4736,"children":4737},{"style":272},[4738],{"type":48,"value":4739},"You are a helpful assistant.",{"type":42,"tag":259,"props":4741,"children":4742},{"style":423},[4743],{"type":48,"value":466},{"type":42,"tag":259,"props":4745,"children":4746},{"style":423},[4747],{"type":48,"value":1771},{"type":42,"tag":259,"props":4749,"children":4750},{"class":261,"line":626},[4751,4756,4760,4764],{"type":42,"tag":259,"props":4752,"children":4753},{"style":423},[4754],{"type":48,"value":4755},"        ...this.",{"type":42,"tag":259,"props":4757,"children":4758},{"style":429},[4759],{"type":48,"value":1088},{"type":42,"tag":259,"props":4761,"children":4762},{"style":423},[4763],{"type":48,"value":437},{"type":42,"tag":259,"props":4765,"children":4766},{"style":527},[4767],{"type":48,"value":4768},"  \u002F\u002F Automatic history management\n",{"type":42,"tag":259,"props":4770,"children":4771},{"class":261,"line":667},[4772,4776,4780,4784,4788,4792,4796,4800,4804,4808,4812],{"type":42,"tag":259,"props":4773,"children":4774},{"style":423},[4775],{"type":48,"value":2001},{"type":42,"tag":259,"props":4777,"children":4778},{"style":506},[4779],{"type":48,"value":592},{"type":42,"tag":259,"props":4781,"children":4782},{"style":423},[4783],{"type":48,"value":514},{"type":42,"tag":259,"props":4785,"children":4786},{"style":423},[4787],{"type":48,"value":457},{"type":42,"tag":259,"props":4789,"children":4790},{"style":272},[4791],{"type":48,"value":1746},{"type":42,"tag":259,"props":4793,"children":4794},{"style":423},[4795],{"type":48,"value":466},{"type":42,"tag":259,"props":4797,"children":4798},{"style":423},[4799],{"type":48,"value":437},{"type":42,"tag":259,"props":4801,"children":4802},{"style":506},[4803],{"type":48,"value":610},{"type":42,"tag":259,"props":4805,"children":4806},{"style":423},[4807],{"type":48,"value":514},{"type":42,"tag":259,"props":4809,"children":4810},{"style":429},[4811],{"type":48,"value":1173},{"type":42,"tag":259,"props":4813,"children":4814},{"style":423},[4815],{"type":48,"value":1771},{"type":42,"tag":259,"props":4817,"children":4818},{"class":261,"line":675},[4819,4823],{"type":42,"tag":259,"props":4820,"children":4821},{"style":506},[4822],{"type":48,"value":2060},{"type":42,"tag":259,"props":4824,"children":4825},{"style":423},[4826],{"type":48,"value":792},{"type":42,"tag":259,"props":4828,"children":4829},{"class":261,"line":683},[4830,4835,4839,4845],{"type":42,"tag":259,"props":4831,"children":4832},{"style":506},[4833],{"type":48,"value":4834},"      stream",{"type":42,"tag":259,"props":4836,"children":4837},{"style":423},[4838],{"type":48,"value":514},{"type":42,"tag":259,"props":4840,"children":4842},{"style":4841},"--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC",[4843],{"type":48,"value":4844}," true",{"type":42,"tag":259,"props":4846,"children":4847},{"style":423},[4848],{"type":48,"value":792},{"type":42,"tag":259,"props":4850,"children":4851},{"class":261,"line":737},[4852,4856,4860],{"type":42,"tag":259,"props":4853,"children":4854},{"style":423},[4855],{"type":48,"value":1101},{"type":42,"tag":259,"props":4857,"children":4858},{"style":506},[4859],{"type":48,"value":240},{"type":42,"tag":259,"props":4861,"children":4862},{"style":423},[4863],{"type":48,"value":471},{"type":42,"tag":259,"props":4865,"children":4866},{"class":261,"line":746},[4867],{"type":42,"tag":259,"props":4868,"children":4869},{"emptyLinePlaceholder":477},[4870],{"type":48,"value":480},{"type":42,"tag":259,"props":4872,"children":4873},{"class":261,"line":772},[4874],{"type":42,"tag":259,"props":4875,"children":4876},{"style":527},[4877],{"type":48,"value":4878},"    \u002F\u002F Stream response back to client\n",{"type":42,"tag":259,"props":4880,"children":4881},{"class":261,"line":795},[4882,4886,4890],{"type":42,"tag":259,"props":4883,"children":4884},{"style":417},[4885],{"type":48,"value":2421},{"type":42,"tag":259,"props":4887,"children":4888},{"style":429},[4889],{"type":48,"value":1814},{"type":42,"tag":259,"props":4891,"children":4892},{"style":423},[4893],{"type":48,"value":471},{"type":42,"tag":259,"props":4895,"children":4896},{"class":261,"line":813},[4897],{"type":42,"tag":259,"props":4898,"children":4899},{"style":423},[4900],{"type":48,"value":927},{"type":42,"tag":259,"props":4902,"children":4903},{"class":261,"line":822},[4904],{"type":42,"tag":259,"props":4905,"children":4906},{"style":423},[4907],{"type":48,"value":539},{"type":42,"tag":51,"props":4909,"children":4910},{},[4911],{"type":48,"value":4912},"Features included:",{"type":42,"tag":180,"props":4914,"children":4915},{},[4916,4921,4926],{"type":42,"tag":184,"props":4917,"children":4918},{},[4919],{"type":48,"value":4920},"Automatic message history",{"type":42,"tag":184,"props":4922,"children":4923},{},[4924],{"type":48,"value":4925},"Resumable streaming (survives disconnects)",{"type":42,"tag":184,"props":4927,"children":4928},{},[4929,4931,4937],{"type":48,"value":4930},"Built-in ",{"type":42,"tag":116,"props":4932,"children":4934},{"className":4933},[],[4935],{"type":48,"value":4936},"saveMessages()",{"type":48,"value":4938}," for persistence",{"type":42,"tag":65,"props":4940,"children":4942},{"id":4941},"client-integration",[4943],{"type":48,"value":4944},"Client Integration",{"type":42,"tag":342,"props":4946,"children":4948},{"id":4947},"react-hook",[4949],{"type":48,"value":4950},"React Hook",{"type":42,"tag":248,"props":4952,"children":4956},{"className":4953,"code":4954,"language":4955,"meta":253,"style":253},"language-tsx shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import { useAgent } from \"agents\u002Freact\";\n\nfunction Chat() {\n  const { state, send, connected } = useAgent({\n    agent: \"my-agent\",\n    name: userId,  \u002F\u002F Agent instance ID\n  });\n\n  const sendMessage = (text: string) => {\n    send(JSON.stringify({ type: \"chat\", content: text }));\n  };\n\n  return (\n    \u003Cdiv>\n      {state.messages.map((msg, i) => (\n        \u003Cdiv key={i}>{msg.role}: {msg.content}\u003C\u002Fdiv>\n      ))}\n      \u003Cinput onKeyDown={(e) => e.key === \"Enter\" && sendMessage(e.target.value)} \u002F>\n    \u003C\u002Fdiv>\n  );\n}\n","tsx",[4957],{"type":42,"tag":116,"props":4958,"children":4959},{"__ignoreMap":253},[4960,5001,5008,5029,5083,5112,5138,5153,5160,5205,5286,5293,5300,5312,5330,5392,5474,5486,5591,5607,5619],{"type":42,"tag":259,"props":4961,"children":4962},{"class":261,"line":262},[4963,4967,4971,4976,4980,4984,4988,4993,4997],{"type":42,"tag":259,"props":4964,"children":4965},{"style":417},[4966],{"type":48,"value":420},{"type":42,"tag":259,"props":4968,"children":4969},{"style":423},[4970],{"type":48,"value":426},{"type":42,"tag":259,"props":4972,"children":4973},{"style":429},[4974],{"type":48,"value":4975}," useAgent",{"type":42,"tag":259,"props":4977,"children":4978},{"style":423},[4979],{"type":48,"value":447},{"type":42,"tag":259,"props":4981,"children":4982},{"style":417},[4983],{"type":48,"value":452},{"type":42,"tag":259,"props":4985,"children":4986},{"style":423},[4987],{"type":48,"value":457},{"type":42,"tag":259,"props":4989,"children":4990},{"style":272},[4991],{"type":48,"value":4992},"agents\u002Freact",{"type":42,"tag":259,"props":4994,"children":4995},{"style":423},[4996],{"type":48,"value":466},{"type":42,"tag":259,"props":4998,"children":4999},{"style":423},[5000],{"type":48,"value":471},{"type":42,"tag":259,"props":5002,"children":5003},{"class":261,"line":298},[5004],{"type":42,"tag":259,"props":5005,"children":5006},{"emptyLinePlaceholder":477},[5007],{"type":48,"value":480},{"type":42,"tag":259,"props":5009,"children":5010},{"class":261,"line":313},[5011,5016,5021,5025],{"type":42,"tag":259,"props":5012,"children":5013},{"style":486},[5014],{"type":48,"value":5015},"function",{"type":42,"tag":259,"props":5017,"children":5018},{"style":302},[5019],{"type":48,"value":5020}," Chat",{"type":42,"tag":259,"props":5022,"children":5023},{"style":423},[5024],{"type":48,"value":855},{"type":42,"tag":259,"props":5026,"children":5027},{"style":423},[5028],{"type":48,"value":499},{"type":42,"tag":259,"props":5030,"children":5031},{"class":261,"line":502},[5032,5036,5040,5045,5049,5054,5058,5063,5067,5071,5075,5079],{"type":42,"tag":259,"props":5033,"children":5034},{"style":486},[5035],{"type":48,"value":3403},{"type":42,"tag":259,"props":5037,"children":5038},{"style":423},[5039],{"type":48,"value":426},{"type":42,"tag":259,"props":5041,"children":5042},{"style":429},[5043],{"type":48,"value":5044}," state",{"type":42,"tag":259,"props":5046,"children":5047},{"style":423},[5048],{"type":48,"value":437},{"type":42,"tag":259,"props":5050,"children":5051},{"style":429},[5052],{"type":48,"value":5053}," send",{"type":42,"tag":259,"props":5055,"children":5056},{"style":423},[5057],{"type":48,"value":437},{"type":42,"tag":259,"props":5059,"children":5060},{"style":429},[5061],{"type":48,"value":5062}," connected",{"type":42,"tag":259,"props":5064,"children":5065},{"style":423},[5066],{"type":48,"value":447},{"type":42,"tag":259,"props":5068,"children":5069},{"style":423},[5070],{"type":48,"value":765},{"type":42,"tag":259,"props":5072,"children":5073},{"style":302},[5074],{"type":48,"value":4975},{"type":42,"tag":259,"props":5076,"children":5077},{"style":506},[5078],{"type":48,"value":883},{"type":42,"tag":259,"props":5080,"children":5081},{"style":423},[5082],{"type":48,"value":1028},{"type":42,"tag":259,"props":5084,"children":5085},{"class":261,"line":533},[5086,5091,5095,5099,5104,5108],{"type":42,"tag":259,"props":5087,"children":5088},{"style":506},[5089],{"type":48,"value":5090},"    agent",{"type":42,"tag":259,"props":5092,"children":5093},{"style":423},[5094],{"type":48,"value":514},{"type":42,"tag":259,"props":5096,"children":5097},{"style":423},[5098],{"type":48,"value":457},{"type":42,"tag":259,"props":5100,"children":5101},{"style":272},[5102],{"type":48,"value":5103},"my-agent",{"type":42,"tag":259,"props":5105,"children":5106},{"style":423},[5107],{"type":48,"value":466},{"type":42,"tag":259,"props":5109,"children":5110},{"style":423},[5111],{"type":48,"value":792},{"type":42,"tag":259,"props":5113,"children":5114},{"class":261,"line":542},[5115,5120,5124,5129,5133],{"type":42,"tag":259,"props":5116,"children":5117},{"style":506},[5118],{"type":48,"value":5119},"    name",{"type":42,"tag":259,"props":5121,"children":5122},{"style":423},[5123],{"type":48,"value":514},{"type":42,"tag":259,"props":5125,"children":5126},{"style":429},[5127],{"type":48,"value":5128}," userId",{"type":42,"tag":259,"props":5130,"children":5131},{"style":423},[5132],{"type":48,"value":437},{"type":42,"tag":259,"props":5134,"children":5135},{"style":527},[5136],{"type":48,"value":5137},"  \u002F\u002F Agent instance ID\n",{"type":42,"tag":259,"props":5139,"children":5140},{"class":261,"line":550},[5141,5145,5149],{"type":42,"tag":259,"props":5142,"children":5143},{"style":423},[5144],{"type":48,"value":4012},{"type":42,"tag":259,"props":5146,"children":5147},{"style":506},[5148],{"type":48,"value":240},{"type":42,"tag":259,"props":5150,"children":5151},{"style":423},[5152],{"type":48,"value":471},{"type":42,"tag":259,"props":5154,"children":5155},{"class":261,"line":567},[5156],{"type":42,"tag":259,"props":5157,"children":5158},{"emptyLinePlaceholder":477},[5159],{"type":48,"value":480},{"type":42,"tag":259,"props":5161,"children":5162},{"class":261,"line":626},[5163,5167,5172,5176,5180,5184,5188,5192,5196,5201],{"type":42,"tag":259,"props":5164,"children":5165},{"style":486},[5166],{"type":48,"value":3403},{"type":42,"tag":259,"props":5168,"children":5169},{"style":429},[5170],{"type":48,"value":5171}," sendMessage",{"type":42,"tag":259,"props":5173,"children":5174},{"style":423},[5175],{"type":48,"value":765},{"type":42,"tag":259,"props":5177,"children":5178},{"style":423},[5179],{"type":48,"value":1260},{"type":42,"tag":259,"props":5181,"children":5182},{"style":964},[5183],{"type":48,"value":48},{"type":42,"tag":259,"props":5185,"children":5186},{"style":423},[5187],{"type":48,"value":514},{"type":42,"tag":259,"props":5189,"children":5190},{"style":266},[5191],{"type":48,"value":601},{"type":42,"tag":259,"props":5193,"children":5194},{"style":423},[5195],{"type":48,"value":240},{"type":42,"tag":259,"props":5197,"children":5198},{"style":486},[5199],{"type":48,"value":5200}," =>",{"type":42,"tag":259,"props":5202,"children":5203},{"style":423},[5204],{"type":48,"value":499},{"type":42,"tag":259,"props":5206,"children":5207},{"class":261,"line":667},[5208,5213,5217,5221,5225,5229,5233,5237,5241,5245,5249,5253,5257,5261,5265,5269,5274,5278,5282],{"type":42,"tag":259,"props":5209,"children":5210},{"style":302},[5211],{"type":48,"value":5212},"    send",{"type":42,"tag":259,"props":5214,"children":5215},{"style":506},[5216],{"type":48,"value":883},{"type":42,"tag":259,"props":5218,"children":5219},{"style":429},[5220],{"type":48,"value":1010},{"type":42,"tag":259,"props":5222,"children":5223},{"style":423},[5224],{"type":48,"value":873},{"type":42,"tag":259,"props":5226,"children":5227},{"style":302},[5228],{"type":48,"value":1019},{"type":42,"tag":259,"props":5230,"children":5231},{"style":506},[5232],{"type":48,"value":883},{"type":42,"tag":259,"props":5234,"children":5235},{"style":423},[5236],{"type":48,"value":3694},{"type":42,"tag":259,"props":5238,"children":5239},{"style":506},[5240],{"type":48,"value":3699},{"type":42,"tag":259,"props":5242,"children":5243},{"style":423},[5244],{"type":48,"value":514},{"type":42,"tag":259,"props":5246,"children":5247},{"style":423},[5248],{"type":48,"value":457},{"type":42,"tag":259,"props":5250,"children":5251},{"style":272},[5252],{"type":48,"value":1288},{"type":42,"tag":259,"props":5254,"children":5255},{"style":423},[5256],{"type":48,"value":466},{"type":42,"tag":259,"props":5258,"children":5259},{"style":423},[5260],{"type":48,"value":437},{"type":42,"tag":259,"props":5262,"children":5263},{"style":506},[5264],{"type":48,"value":610},{"type":42,"tag":259,"props":5266,"children":5267},{"style":423},[5268],{"type":48,"value":514},{"type":42,"tag":259,"props":5270,"children":5271},{"style":429},[5272],{"type":48,"value":5273}," text",{"type":42,"tag":259,"props":5275,"children":5276},{"style":423},[5277],{"type":48,"value":447},{"type":42,"tag":259,"props":5279,"children":5280},{"style":506},[5281],{"type":48,"value":1106},{"type":42,"tag":259,"props":5283,"children":5284},{"style":423},[5285],{"type":48,"value":471},{"type":42,"tag":259,"props":5287,"children":5288},{"class":261,"line":675},[5289],{"type":42,"tag":259,"props":5290,"children":5291},{"style":423},[5292],{"type":48,"value":819},{"type":42,"tag":259,"props":5294,"children":5295},{"class":261,"line":683},[5296],{"type":42,"tag":259,"props":5297,"children":5298},{"emptyLinePlaceholder":477},[5299],{"type":48,"value":480},{"type":42,"tag":259,"props":5301,"children":5302},{"class":261,"line":737},[5303,5308],{"type":42,"tag":259,"props":5304,"children":5305},{"style":417},[5306],{"type":48,"value":5307},"  return",{"type":42,"tag":259,"props":5309,"children":5310},{"style":506},[5311],{"type":48,"value":2426},{"type":42,"tag":259,"props":5313,"children":5314},{"class":261,"line":746},[5315,5320,5325],{"type":42,"tag":259,"props":5316,"children":5317},{"style":423},[5318],{"type":48,"value":5319},"    \u003C",{"type":42,"tag":259,"props":5321,"children":5322},{"style":506},[5323],{"type":48,"value":5324},"div",{"type":42,"tag":259,"props":5326,"children":5327},{"style":423},[5328],{"type":48,"value":5329},">\n",{"type":42,"tag":259,"props":5331,"children":5332},{"class":261,"line":772},[5333,5337,5341,5345,5349,5353,5358,5362,5366,5371,5375,5380,5384,5388],{"type":42,"tag":259,"props":5334,"children":5335},{"style":423},[5336],{"type":48,"value":1729},{"type":42,"tag":259,"props":5338,"children":5339},{"style":429},[5340],{"type":48,"value":910},{"type":42,"tag":259,"props":5342,"children":5343},{"style":423},[5344],{"type":48,"value":873},{"type":42,"tag":259,"props":5346,"children":5347},{"style":429},[5348],{"type":48,"value":1088},{"type":42,"tag":259,"props":5350,"children":5351},{"style":423},[5352],{"type":48,"value":873},{"type":42,"tag":259,"props":5354,"children":5355},{"style":302},[5356],{"type":48,"value":5357},"map",{"type":42,"tag":259,"props":5359,"children":5360},{"style":429},[5361],{"type":48,"value":883},{"type":42,"tag":259,"props":5363,"children":5364},{"style":423},[5365],{"type":48,"value":883},{"type":42,"tag":259,"props":5367,"children":5368},{"style":964},[5369],{"type":48,"value":5370},"msg",{"type":42,"tag":259,"props":5372,"children":5373},{"style":423},[5374],{"type":48,"value":437},{"type":42,"tag":259,"props":5376,"children":5377},{"style":964},[5378],{"type":48,"value":5379}," i",{"type":42,"tag":259,"props":5381,"children":5382},{"style":423},[5383],{"type":48,"value":240},{"type":42,"tag":259,"props":5385,"children":5386},{"style":486},[5387],{"type":48,"value":5200},{"type":42,"tag":259,"props":5389,"children":5390},{"style":429},[5391],{"type":48,"value":2426},{"type":42,"tag":259,"props":5393,"children":5394},{"class":261,"line":795},[5395,5400,5404,5409,5414,5419,5424,5428,5432,5437,5441,5445,5449,5453,5457,5461,5466,5470],{"type":42,"tag":259,"props":5396,"children":5397},{"style":423},[5398],{"type":48,"value":5399},"        \u003C",{"type":42,"tag":259,"props":5401,"children":5402},{"style":506},[5403],{"type":48,"value":5324},{"type":42,"tag":259,"props":5405,"children":5406},{"style":486},[5407],{"type":48,"value":5408}," key",{"type":42,"tag":259,"props":5410,"children":5411},{"style":423},[5412],{"type":48,"value":5413},"={",{"type":42,"tag":259,"props":5415,"children":5416},{"style":429},[5417],{"type":48,"value":5418},"i",{"type":42,"tag":259,"props":5420,"children":5421},{"style":423},[5422],{"type":48,"value":5423},"}>{",{"type":42,"tag":259,"props":5425,"children":5426},{"style":429},[5427],{"type":48,"value":5370},{"type":42,"tag":259,"props":5429,"children":5430},{"style":423},[5431],{"type":48,"value":873},{"type":42,"tag":259,"props":5433,"children":5434},{"style":429},[5435],{"type":48,"value":5436},"role",{"type":42,"tag":259,"props":5438,"children":5439},{"style":423},[5440],{"type":48,"value":2926},{"type":42,"tag":259,"props":5442,"children":5443},{"style":429},[5444],{"type":48,"value":3881},{"type":42,"tag":259,"props":5446,"children":5447},{"style":423},[5448],{"type":48,"value":3694},{"type":42,"tag":259,"props":5450,"children":5451},{"style":429},[5452],{"type":48,"value":5370},{"type":42,"tag":259,"props":5454,"children":5455},{"style":423},[5456],{"type":48,"value":873},{"type":42,"tag":259,"props":5458,"children":5459},{"style":429},[5460],{"type":48,"value":1344},{"type":42,"tag":259,"props":5462,"children":5463},{"style":423},[5464],{"type":48,"value":5465},"}\u003C\u002F",{"type":42,"tag":259,"props":5467,"children":5468},{"style":506},[5469],{"type":48,"value":5324},{"type":42,"tag":259,"props":5471,"children":5472},{"style":423},[5473],{"type":48,"value":5329},{"type":42,"tag":259,"props":5475,"children":5476},{"class":261,"line":813},[5477,5482],{"type":42,"tag":259,"props":5478,"children":5479},{"style":429},[5480],{"type":48,"value":5481},"      ))",{"type":42,"tag":259,"props":5483,"children":5484},{"style":423},[5485],{"type":48,"value":539},{"type":42,"tag":259,"props":5487,"children":5488},{"class":261,"line":822},[5489,5494,5499,5504,5509,5514,5518,5522,5527,5531,5536,5541,5545,5550,5554,5559,5563,5568,5572,5577,5581,5586],{"type":42,"tag":259,"props":5490,"children":5491},{"style":423},[5492],{"type":48,"value":5493},"      \u003C",{"type":42,"tag":259,"props":5495,"children":5496},{"style":506},[5497],{"type":48,"value":5498},"input",{"type":42,"tag":259,"props":5500,"children":5501},{"style":486},[5502],{"type":48,"value":5503}," onKeyDown",{"type":42,"tag":259,"props":5505,"children":5506},{"style":423},[5507],{"type":48,"value":5508},"={(",{"type":42,"tag":259,"props":5510,"children":5511},{"style":964},[5512],{"type":48,"value":5513},"e",{"type":42,"tag":259,"props":5515,"children":5516},{"style":423},[5517],{"type":48,"value":240},{"type":42,"tag":259,"props":5519,"children":5520},{"style":486},[5521],{"type":48,"value":5200},{"type":42,"tag":259,"props":5523,"children":5524},{"style":429},[5525],{"type":48,"value":5526}," e",{"type":42,"tag":259,"props":5528,"children":5529},{"style":423},[5530],{"type":48,"value":873},{"type":42,"tag":259,"props":5532,"children":5533},{"style":429},[5534],{"type":48,"value":5535},"key ",{"type":42,"tag":259,"props":5537,"children":5538},{"style":423},[5539],{"type":48,"value":5540},"===",{"type":42,"tag":259,"props":5542,"children":5543},{"style":423},[5544],{"type":48,"value":457},{"type":42,"tag":259,"props":5546,"children":5547},{"style":272},[5548],{"type":48,"value":5549},"Enter",{"type":42,"tag":259,"props":5551,"children":5552},{"style":423},[5553],{"type":48,"value":466},{"type":42,"tag":259,"props":5555,"children":5556},{"style":423},[5557],{"type":48,"value":5558}," &&",{"type":42,"tag":259,"props":5560,"children":5561},{"style":302},[5562],{"type":48,"value":5171},{"type":42,"tag":259,"props":5564,"children":5565},{"style":429},[5566],{"type":48,"value":5567},"(e",{"type":42,"tag":259,"props":5569,"children":5570},{"style":423},[5571],{"type":48,"value":873},{"type":42,"tag":259,"props":5573,"children":5574},{"style":429},[5575],{"type":48,"value":5576},"target",{"type":42,"tag":259,"props":5578,"children":5579},{"style":423},[5580],{"type":48,"value":873},{"type":42,"tag":259,"props":5582,"children":5583},{"style":429},[5584],{"type":48,"value":5585},"value)",{"type":42,"tag":259,"props":5587,"children":5588},{"style":423},[5589],{"type":48,"value":5590},"} \u002F>\n",{"type":42,"tag":259,"props":5592,"children":5593},{"class":261,"line":830},[5594,5599,5603],{"type":42,"tag":259,"props":5595,"children":5596},{"style":423},[5597],{"type":48,"value":5598},"    \u003C\u002F",{"type":42,"tag":259,"props":5600,"children":5601},{"style":506},[5602],{"type":48,"value":5324},{"type":42,"tag":259,"props":5604,"children":5605},{"style":423},[5606],{"type":48,"value":5329},{"type":42,"tag":259,"props":5608,"children":5609},{"class":261,"line":839},[5610,5615],{"type":42,"tag":259,"props":5611,"children":5612},{"style":506},[5613],{"type":48,"value":5614},"  )",{"type":42,"tag":259,"props":5616,"children":5617},{"style":423},[5618],{"type":48,"value":471},{"type":42,"tag":259,"props":5620,"children":5621},{"class":261,"line":862},[5622],{"type":42,"tag":259,"props":5623,"children":5624},{"style":423},[5625],{"type":48,"value":539},{"type":42,"tag":342,"props":5627,"children":5629},{"id":5628},"vanilla-javascript",[5630],{"type":48,"value":5631},"Vanilla JavaScript",{"type":42,"tag":248,"props":5633,"children":5637},{"className":5634,"code":5635,"language":5636,"meta":253,"style":253},"language-javascript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const ws = new WebSocket(\"wss:\u002F\u002Fmy-agent.workers.dev\u002Fagents\u002FMyAgent\u002Fuser123\");\n\nws.onopen = () => {\n  console.log(\"Connected to agent\");\n};\n\nws.onmessage = (event) => {\n  const data = JSON.parse(event.data);\n  console.log(\"Received:\", data);\n};\n\nws.send(JSON.stringify({ type: \"chat\", content: \"Hello!\" }));\n","javascript",[5638],{"type":42,"tag":116,"props":5639,"children":5640},{"__ignoreMap":253},[5641,5691,5698,5732,5772,5779,5786,5827,5878,5926,5933,5940],{"type":42,"tag":259,"props":5642,"children":5643},{"class":261,"line":262},[5644,5648,5653,5657,5661,5666,5670,5674,5679,5683,5687],{"type":42,"tag":259,"props":5645,"children":5646},{"style":486},[5647],{"type":48,"value":2748},{"type":42,"tag":259,"props":5649,"children":5650},{"style":429},[5651],{"type":48,"value":5652}," ws ",{"type":42,"tag":259,"props":5654,"children":5655},{"style":423},[5656],{"type":48,"value":2758},{"type":42,"tag":259,"props":5658,"children":5659},{"style":423},[5660],{"type":48,"value":3978},{"type":42,"tag":259,"props":5662,"children":5663},{"style":302},[5664],{"type":48,"value":5665}," WebSocket",{"type":42,"tag":259,"props":5667,"children":5668},{"style":429},[5669],{"type":48,"value":883},{"type":42,"tag":259,"props":5671,"children":5672},{"style":423},[5673],{"type":48,"value":466},{"type":42,"tag":259,"props":5675,"children":5676},{"style":272},[5677],{"type":48,"value":5678},"wss:\u002F\u002Fmy-agent.workers.dev\u002Fagents\u002FMyAgent\u002Fuser123",{"type":42,"tag":259,"props":5680,"children":5681},{"style":423},[5682],{"type":48,"value":466},{"type":42,"tag":259,"props":5684,"children":5685},{"style":429},[5686],{"type":48,"value":240},{"type":42,"tag":259,"props":5688,"children":5689},{"style":423},[5690],{"type":48,"value":471},{"type":42,"tag":259,"props":5692,"children":5693},{"class":261,"line":298},[5694],{"type":42,"tag":259,"props":5695,"children":5696},{"emptyLinePlaceholder":477},[5697],{"type":48,"value":480},{"type":42,"tag":259,"props":5699,"children":5700},{"class":261,"line":313},[5701,5706,5710,5715,5719,5724,5728],{"type":42,"tag":259,"props":5702,"children":5703},{"style":429},[5704],{"type":48,"value":5705},"ws",{"type":42,"tag":259,"props":5707,"children":5708},{"style":423},[5709],{"type":48,"value":873},{"type":42,"tag":259,"props":5711,"children":5712},{"style":302},[5713],{"type":48,"value":5714},"onopen",{"type":42,"tag":259,"props":5716,"children":5717},{"style":423},[5718],{"type":48,"value":765},{"type":42,"tag":259,"props":5720,"children":5721},{"style":423},[5722],{"type":48,"value":5723}," ()",{"type":42,"tag":259,"props":5725,"children":5726},{"style":486},[5727],{"type":48,"value":5200},{"type":42,"tag":259,"props":5729,"children":5730},{"style":423},[5731],{"type":48,"value":499},{"type":42,"tag":259,"props":5733,"children":5734},{"class":261,"line":502},[5735,5739,5743,5747,5751,5755,5760,5764,5768],{"type":42,"tag":259,"props":5736,"children":5737},{"style":429},[5738],{"type":48,"value":3835},{"type":42,"tag":259,"props":5740,"children":5741},{"style":423},[5742],{"type":48,"value":873},{"type":42,"tag":259,"props":5744,"children":5745},{"style":302},[5746],{"type":48,"value":878},{"type":42,"tag":259,"props":5748,"children":5749},{"style":506},[5750],{"type":48,"value":883},{"type":42,"tag":259,"props":5752,"children":5753},{"style":423},[5754],{"type":48,"value":466},{"type":42,"tag":259,"props":5756,"children":5757},{"style":272},[5758],{"type":48,"value":5759},"Connected to agent",{"type":42,"tag":259,"props":5761,"children":5762},{"style":423},[5763],{"type":48,"value":466},{"type":42,"tag":259,"props":5765,"children":5766},{"style":506},[5767],{"type":48,"value":240},{"type":42,"tag":259,"props":5769,"children":5770},{"style":423},[5771],{"type":48,"value":471},{"type":42,"tag":259,"props":5773,"children":5774},{"class":261,"line":533},[5775],{"type":42,"tag":259,"props":5776,"children":5777},{"style":423},[5778],{"type":48,"value":2559},{"type":42,"tag":259,"props":5780,"children":5781},{"class":261,"line":542},[5782],{"type":42,"tag":259,"props":5783,"children":5784},{"emptyLinePlaceholder":477},[5785],{"type":48,"value":480},{"type":42,"tag":259,"props":5787,"children":5788},{"class":261,"line":550},[5789,5793,5797,5802,5806,5810,5815,5819,5823],{"type":42,"tag":259,"props":5790,"children":5791},{"style":429},[5792],{"type":48,"value":5705},{"type":42,"tag":259,"props":5794,"children":5795},{"style":423},[5796],{"type":48,"value":873},{"type":42,"tag":259,"props":5798,"children":5799},{"style":302},[5800],{"type":48,"value":5801},"onmessage",{"type":42,"tag":259,"props":5803,"children":5804},{"style":423},[5805],{"type":48,"value":765},{"type":42,"tag":259,"props":5807,"children":5808},{"style":423},[5809],{"type":48,"value":1260},{"type":42,"tag":259,"props":5811,"children":5812},{"style":964},[5813],{"type":48,"value":5814},"event",{"type":42,"tag":259,"props":5816,"children":5817},{"style":423},[5818],{"type":48,"value":240},{"type":42,"tag":259,"props":5820,"children":5821},{"style":486},[5822],{"type":48,"value":5200},{"type":42,"tag":259,"props":5824,"children":5825},{"style":423},[5826],{"type":48,"value":499},{"type":42,"tag":259,"props":5828,"children":5829},{"class":261,"line":567},[5830,5834,5838,5842,5846,5850,5854,5858,5862,5866,5870,5874],{"type":42,"tag":259,"props":5831,"children":5832},{"style":486},[5833],{"type":48,"value":3403},{"type":42,"tag":259,"props":5835,"children":5836},{"style":429},[5837],{"type":48,"value":1203},{"type":42,"tag":259,"props":5839,"children":5840},{"style":423},[5841],{"type":48,"value":765},{"type":42,"tag":259,"props":5843,"children":5844},{"style":429},[5845],{"type":48,"value":1212},{"type":42,"tag":259,"props":5847,"children":5848},{"style":423},[5849],{"type":48,"value":873},{"type":42,"tag":259,"props":5851,"children":5852},{"style":302},[5853],{"type":48,"value":1221},{"type":42,"tag":259,"props":5855,"children":5856},{"style":506},[5857],{"type":48,"value":883},{"type":42,"tag":259,"props":5859,"children":5860},{"style":429},[5861],{"type":48,"value":5814},{"type":42,"tag":259,"props":5863,"children":5864},{"style":423},[5865],{"type":48,"value":873},{"type":42,"tag":259,"props":5867,"children":5868},{"style":429},[5869],{"type":48,"value":1265},{"type":42,"tag":259,"props":5871,"children":5872},{"style":506},[5873],{"type":48,"value":240},{"type":42,"tag":259,"props":5875,"children":5876},{"style":423},[5877],{"type":48,"value":471},{"type":42,"tag":259,"props":5879,"children":5880},{"class":261,"line":626},[5881,5885,5889,5893,5897,5901,5906,5910,5914,5918,5922],{"type":42,"tag":259,"props":5882,"children":5883},{"style":429},[5884],{"type":48,"value":3835},{"type":42,"tag":259,"props":5886,"children":5887},{"style":423},[5888],{"type":48,"value":873},{"type":42,"tag":259,"props":5890,"children":5891},{"style":302},[5892],{"type":48,"value":878},{"type":42,"tag":259,"props":5894,"children":5895},{"style":506},[5896],{"type":48,"value":883},{"type":42,"tag":259,"props":5898,"children":5899},{"style":423},[5900],{"type":48,"value":466},{"type":42,"tag":259,"props":5902,"children":5903},{"style":272},[5904],{"type":48,"value":5905},"Received:",{"type":42,"tag":259,"props":5907,"children":5908},{"style":423},[5909],{"type":48,"value":466},{"type":42,"tag":259,"props":5911,"children":5912},{"style":423},[5913],{"type":48,"value":437},{"type":42,"tag":259,"props":5915,"children":5916},{"style":429},[5917],{"type":48,"value":1203},{"type":42,"tag":259,"props":5919,"children":5920},{"style":506},[5921],{"type":48,"value":240},{"type":42,"tag":259,"props":5923,"children":5924},{"style":423},[5925],{"type":48,"value":471},{"type":42,"tag":259,"props":5927,"children":5928},{"class":261,"line":667},[5929],{"type":42,"tag":259,"props":5930,"children":5931},{"style":423},[5932],{"type":48,"value":2559},{"type":42,"tag":259,"props":5934,"children":5935},{"class":261,"line":675},[5936],{"type":42,"tag":259,"props":5937,"children":5938},{"emptyLinePlaceholder":477},[5939],{"type":48,"value":480},{"type":42,"tag":259,"props":5941,"children":5942},{"class":261,"line":683},[5943,5947,5951,5955,5960,5964,5968,5972,5976,5980,5984,5988,5992,5996,6000,6004,6008,6012,6017,6021,6025,6029],{"type":42,"tag":259,"props":5944,"children":5945},{"style":429},[5946],{"type":48,"value":5705},{"type":42,"tag":259,"props":5948,"children":5949},{"style":423},[5950],{"type":48,"value":873},{"type":42,"tag":259,"props":5952,"children":5953},{"style":302},[5954],{"type":48,"value":1001},{"type":42,"tag":259,"props":5956,"children":5957},{"style":429},[5958],{"type":48,"value":5959},"(JSON",{"type":42,"tag":259,"props":5961,"children":5962},{"style":423},[5963],{"type":48,"value":873},{"type":42,"tag":259,"props":5965,"children":5966},{"style":302},[5967],{"type":48,"value":1019},{"type":42,"tag":259,"props":5969,"children":5970},{"style":429},[5971],{"type":48,"value":883},{"type":42,"tag":259,"props":5973,"children":5974},{"style":423},[5975],{"type":48,"value":3694},{"type":42,"tag":259,"props":5977,"children":5978},{"style":506},[5979],{"type":48,"value":3699},{"type":42,"tag":259,"props":5981,"children":5982},{"style":423},[5983],{"type":48,"value":514},{"type":42,"tag":259,"props":5985,"children":5986},{"style":423},[5987],{"type":48,"value":457},{"type":42,"tag":259,"props":5989,"children":5990},{"style":272},[5991],{"type":48,"value":1288},{"type":42,"tag":259,"props":5993,"children":5994},{"style":423},[5995],{"type":48,"value":466},{"type":42,"tag":259,"props":5997,"children":5998},{"style":423},[5999],{"type":48,"value":437},{"type":42,"tag":259,"props":6001,"children":6002},{"style":506},[6003],{"type":48,"value":610},{"type":42,"tag":259,"props":6005,"children":6006},{"style":423},[6007],{"type":48,"value":514},{"type":42,"tag":259,"props":6009,"children":6010},{"style":423},[6011],{"type":48,"value":457},{"type":42,"tag":259,"props":6013,"children":6014},{"style":272},[6015],{"type":48,"value":6016},"Hello!",{"type":42,"tag":259,"props":6018,"children":6019},{"style":423},[6020],{"type":48,"value":466},{"type":42,"tag":259,"props":6022,"children":6023},{"style":423},[6024],{"type":48,"value":447},{"type":42,"tag":259,"props":6026,"children":6027},{"style":429},[6028],{"type":48,"value":1106},{"type":42,"tag":259,"props":6030,"children":6031},{"style":423},[6032],{"type":48,"value":471},{"type":42,"tag":65,"props":6034,"children":6036},{"id":6035},"common-patterns",[6037],{"type":48,"value":6038},"Common Patterns",{"type":42,"tag":51,"props":6040,"children":6041},{},[6042,6044,6050],{"type":48,"value":6043},"See ",{"type":42,"tag":6045,"props":6046,"children":6048},"a",{"href":6047},"references\u002Fagent-patterns.md",[6049],{"type":48,"value":6047},{"type":48,"value":6051}," for:",{"type":42,"tag":180,"props":6053,"children":6054},{},[6055,6060,6065,6070],{"type":42,"tag":184,"props":6056,"children":6057},{},[6058],{"type":48,"value":6059},"Tool calling and function execution",{"type":42,"tag":184,"props":6061,"children":6062},{},[6063],{"type":48,"value":6064},"Multi-agent orchestration",{"type":42,"tag":184,"props":6066,"children":6067},{},[6068],{"type":48,"value":6069},"RAG (Retrieval Augmented Generation)",{"type":42,"tag":184,"props":6071,"children":6072},{},[6073],{"type":48,"value":6074},"Human-in-the-loop workflows",{"type":42,"tag":65,"props":6076,"children":6078},{"id":6077},"deployment",[6079],{"type":48,"value":6080},"Deployment",{"type":42,"tag":248,"props":6082,"children":6084},{"className":250,"code":6083,"language":252,"meta":253,"style":253},"# Deploy\nnpx wrangler deploy\n\n# View logs\nwrangler tail\n\n# Test endpoint\ncurl https:\u002F\u002Fmy-agent.workers.dev\u002Fagents\u002FMyAgent\u002Ftest-user\n",[6085],{"type":42,"tag":116,"props":6086,"children":6087},{"__ignoreMap":253},[6088,6096,6114,6121,6129,6142,6149,6157],{"type":42,"tag":259,"props":6089,"children":6090},{"class":261,"line":262},[6091],{"type":42,"tag":259,"props":6092,"children":6093},{"style":527},[6094],{"type":48,"value":6095},"# Deploy\n",{"type":42,"tag":259,"props":6097,"children":6098},{"class":261,"line":298},[6099,6104,6109],{"type":42,"tag":259,"props":6100,"children":6101},{"style":266},[6102],{"type":48,"value":6103},"npx",{"type":42,"tag":259,"props":6105,"children":6106},{"style":272},[6107],{"type":48,"value":6108}," wrangler",{"type":42,"tag":259,"props":6110,"children":6111},{"style":272},[6112],{"type":48,"value":6113}," deploy\n",{"type":42,"tag":259,"props":6115,"children":6116},{"class":261,"line":313},[6117],{"type":42,"tag":259,"props":6118,"children":6119},{"emptyLinePlaceholder":477},[6120],{"type":48,"value":480},{"type":42,"tag":259,"props":6122,"children":6123},{"class":261,"line":502},[6124],{"type":42,"tag":259,"props":6125,"children":6126},{"style":527},[6127],{"type":48,"value":6128},"# View logs\n",{"type":42,"tag":259,"props":6130,"children":6131},{"class":261,"line":533},[6132,6137],{"type":42,"tag":259,"props":6133,"children":6134},{"style":266},[6135],{"type":48,"value":6136},"wrangler",{"type":42,"tag":259,"props":6138,"children":6139},{"style":272},[6140],{"type":48,"value":6141}," tail\n",{"type":42,"tag":259,"props":6143,"children":6144},{"class":261,"line":542},[6145],{"type":42,"tag":259,"props":6146,"children":6147},{"emptyLinePlaceholder":477},[6148],{"type":48,"value":480},{"type":42,"tag":259,"props":6150,"children":6151},{"class":261,"line":550},[6152],{"type":42,"tag":259,"props":6153,"children":6154},{"style":527},[6155],{"type":48,"value":6156},"# Test endpoint\n",{"type":42,"tag":259,"props":6158,"children":6159},{"class":261,"line":567},[6160,6165],{"type":42,"tag":259,"props":6161,"children":6162},{"style":266},[6163],{"type":48,"value":6164},"curl",{"type":42,"tag":259,"props":6166,"children":6167},{"style":272},[6168],{"type":48,"value":6169}," https:\u002F\u002Fmy-agent.workers.dev\u002Fagents\u002FMyAgent\u002Ftest-user\n",{"type":42,"tag":65,"props":6171,"children":6173},{"id":6172},"troubleshooting",[6174],{"type":48,"value":6175},"Troubleshooting",{"type":42,"tag":51,"props":6177,"children":6178},{},[6179,6180,6185],{"type":48,"value":6043},{"type":42,"tag":6045,"props":6181,"children":6183},{"href":6182},"references\u002Ftroubleshooting.md",[6184],{"type":48,"value":6182},{"type":48,"value":6186}," for common issues.",{"type":42,"tag":65,"props":6188,"children":6190},{"id":6189},"references",[6191],{"type":48,"value":6192},"References",{"type":42,"tag":180,"props":6194,"children":6195},{},[6196,6206,6215,6225],{"type":42,"tag":184,"props":6197,"children":6198},{},[6199,6204],{"type":42,"tag":6045,"props":6200,"children":6202},{"href":6201},"references\u002Fexamples.md",[6203],{"type":48,"value":6201},{"type":48,"value":6205}," — Official templates and production examples",{"type":42,"tag":184,"props":6207,"children":6208},{},[6209,6213],{"type":42,"tag":6045,"props":6210,"children":6211},{"href":6047},[6212],{"type":48,"value":6047},{"type":48,"value":6214}," — Advanced patterns",{"type":42,"tag":184,"props":6216,"children":6217},{},[6218,6223],{"type":42,"tag":6045,"props":6219,"children":6221},{"href":6220},"references\u002Fstate-patterns.md",[6222],{"type":48,"value":6220},{"type":48,"value":6224}," — State management strategies",{"type":42,"tag":184,"props":6226,"children":6227},{},[6228,6232],{"type":42,"tag":6045,"props":6229,"children":6230},{"href":6182},[6231],{"type":48,"value":6182},{"type":48,"value":6233}," — Error solutions",{"type":42,"tag":6235,"props":6236,"children":6237},"style",{},[6238],{"type":48,"value":6239},"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":6241,"total":6440},[6242,6263,6286,6303,6319,6332,6351,6367,6383,6397,6409,6424],{"slug":6243,"name":6243,"fn":6244,"description":6245,"org":6246,"tags":6247,"stars":6260,"repoUrl":6261,"updatedAt":6262},"prior-auth-packet-builder","build healthcare prior authorization packets","Build a concise prior authorization packet from local case files and payer policy docs.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6248,6251,6254,6257],{"name":6249,"slug":6250,"type":15},"Documents","documents",{"name":6252,"slug":6253,"type":15},"Healthcare","healthcare",{"name":6255,"slug":6256,"type":15},"Insurance","insurance",{"name":6258,"slug":6259,"type":15},"Regulatory Compliance","regulatory-compliance",28169,"https:\u002F\u002Fgithub.com\u002Fopenai\u002Fopenai-agents-python","2026-04-16T05:11:39.180399",{"slug":6264,"name":6264,"fn":6265,"description":6266,"org":6267,"tags":6268,"stars":6283,"repoUrl":6284,"updatedAt":6285},"aspnet-core","build ASP.NET Core web applications","Build, review, refactor, or architect ASP.NET Core web applications using current official guidance for .NET web development. Use when working on Blazor Web Apps, Razor Pages, MVC, Minimal APIs, controller-based Web APIs, SignalR, gRPC, middleware, dependency injection, configuration, authentication, authorization, testing, performance, deployment, or ASP.NET Core upgrades.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6269,6272,6274,6277,6280],{"name":6270,"slug":6271,"type":15},".NET","dotnet",{"name":6273,"slug":6264,"type":15},"ASP.NET Core",{"name":6275,"slug":6276,"type":15},"Blazor","blazor",{"name":6278,"slug":6279,"type":15},"C#","csharp",{"name":6281,"slug":6282,"type":15},"Web Development","web-development",23787,"https:\u002F\u002Fgithub.com\u002Fopenai\u002Fskills","2026-04-12T05:07:02.819491",{"slug":6287,"name":6287,"fn":6288,"description":6289,"org":6290,"tags":6291,"stars":6283,"repoUrl":6284,"updatedAt":6302},"chatgpt-apps","build ChatGPT Apps SDK applications","Build, scaffold, refactor, and troubleshoot ChatGPT Apps SDK applications that combine an MCP server and widget UI. Use when Codex needs to design tools, register UI resources, wire the MCP Apps bridge or ChatGPT compatibility APIs, apply Apps SDK metadata or CSP or domain settings, or produce a docs-aligned project scaffold. Prefer a docs-first workflow by invoking the openai-docs skill or OpenAI developer docs MCP tools before generating code.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6292,6295,6298,6301],{"name":6293,"slug":6294,"type":15},"Apps SDK","apps-sdk",{"name":6296,"slug":6297,"type":15},"ChatGPT","chatgpt",{"name":6299,"slug":6300,"type":15},"MCP","mcp",{"name":9,"slug":8,"type":15},"2026-04-12T05:07:05.468097",{"slug":6304,"name":6304,"fn":6305,"description":6306,"org":6307,"tags":6308,"stars":6283,"repoUrl":6284,"updatedAt":6318},"cli-creator","build CLIs from API docs","Build a composable CLI for Codex from API docs, an OpenAPI spec, existing curl examples, an SDK, a web app, an admin tool, or a local script. Use when the user wants Codex to create a command-line tool that can run from any repo, expose composable read\u002Fwrite commands, return stable JSON, manage auth, and pair with a companion skill.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6309,6312,6315],{"name":6310,"slug":6311,"type":15},"API Development","api-development",{"name":6313,"slug":6314,"type":15},"CLI","cli",{"name":6316,"slug":6317,"type":15},"Codex","codex","2026-04-12T05:07:04.132762",{"slug":6320,"name":6320,"fn":6321,"description":6322,"org":6323,"tags":6324,"stars":6283,"repoUrl":6284,"updatedAt":6331},"cloudflare-deploy","deploy projects to Cloudflare","Deploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6325,6326,6329,6330],{"name":20,"slug":21,"type":15},{"name":6327,"slug":6328,"type":15},"Cloudflare Pages","cloudflare-pages",{"name":13,"slug":14,"type":15},{"name":6080,"slug":6077,"type":15},"2026-04-12T05:07:14.275118",{"slug":6333,"name":6333,"fn":6334,"description":6335,"org":6336,"tags":6337,"stars":6283,"repoUrl":6284,"updatedAt":6350},"define-goal","define and set measurable project goals","Help the user define a concrete, measurable goal before starting work, especially when they ask to use the goal tool, create a goal, set an objective, clarify success criteria, or turn a fuzzy intention into a quantitative outcome. Use this skill for goal creation and goal refinement only; it does not manage durable snapshots, decision logs, or long-running execution artifacts.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6338,6341,6344,6347],{"name":6339,"slug":6340,"type":15},"Productivity","productivity",{"name":6342,"slug":6343,"type":15},"Project Management","project-management",{"name":6345,"slug":6346,"type":15},"Strategy","strategy",{"name":6348,"slug":6349,"type":15},"Task Management","task-management","2026-05-23T06:17:16.870838",{"slug":6352,"name":6352,"fn":6353,"description":6354,"org":6355,"tags":6356,"stars":6283,"repoUrl":6284,"updatedAt":6366},"figma","translate Figma designs into code","Use the Figma MCP server to fetch design context, screenshots, variables, and assets from Figma, and to translate Figma nodes into production code. Trigger when a task involves Figma URLs, node IDs, design-to-code implementation, or Figma MCP setup and troubleshooting.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6357,6360,6362,6365],{"name":6358,"slug":6359,"type":15},"Design","design",{"name":6361,"slug":6352,"type":15},"Figma",{"name":6363,"slug":6364,"type":15},"Frontend","frontend",{"name":6299,"slug":6300,"type":15},"2026-04-12T05:06:47.939943",{"slug":6368,"name":6368,"fn":6369,"description":6370,"org":6371,"tags":6372,"stars":6283,"repoUrl":6284,"updatedAt":6382},"figma-code-connect-components","connect Figma designs to code components","Connects Figma design components to code components using Code Connect mapping tools. Use when user says \"code connect\", \"connect this component to code\", \"map this component\", \"link component to code\", \"create code connect mapping\", or wants to establish mappings between Figma designs and code implementations. For canvas writes via `use_figma`, use `figma-use`.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6373,6374,6377,6378,6379],{"name":6358,"slug":6359,"type":15},{"name":6375,"slug":6376,"type":15},"Design System","design-system",{"name":6361,"slug":6352,"type":15},{"name":6363,"slug":6364,"type":15},{"name":6380,"slug":6381,"type":15},"UI Components","ui-components","2026-05-10T05:59:52.971881",{"slug":6384,"name":6384,"fn":6385,"description":6386,"org":6387,"tags":6388,"stars":6283,"repoUrl":6284,"updatedAt":6396},"figma-create-design-system-rules","generate design system rules from Figma","Generates custom design system rules for the user's codebase. Use when user says \"create design system rules\", \"generate rules for my project\", \"set up design rules\", \"customize design system guidelines\", or wants to establish project-specific conventions for Figma-to-code workflows. Requires Figma MCP server connection.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6389,6390,6391,6394,6395],{"name":6358,"slug":6359,"type":15},{"name":6375,"slug":6376,"type":15},{"name":6392,"slug":6393,"type":15},"Documentation","documentation",{"name":6361,"slug":6352,"type":15},{"name":6363,"slug":6364,"type":15},"2026-05-16T06:07:47.821474",{"slug":6398,"name":6398,"fn":6399,"description":6400,"org":6401,"tags":6402,"stars":6283,"repoUrl":6284,"updatedAt":6408},"figma-implement-design","translate Figma designs into application code","Translates Figma designs into production-ready application code with 1:1 visual fidelity. Use when implementing UI code from Figma files, when user mentions \"implement design\", \"generate code\", \"implement component\", provides Figma URLs, or asks to build components matching Figma specs. For Figma canvas writes via `use_figma`, use `figma-use`.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6403,6404,6405,6406,6407],{"name":6358,"slug":6359,"type":15},{"name":6361,"slug":6352,"type":15},{"name":6363,"slug":6364,"type":15},{"name":6380,"slug":6381,"type":15},{"name":6281,"slug":6282,"type":15},"2026-05-16T06:07:40.583615",{"slug":6410,"name":6410,"fn":6411,"description":6412,"org":6413,"tags":6414,"stars":6283,"repoUrl":6284,"updatedAt":6423},"hatch-pet","create animated pets for Codex","Create, repair, validate, visually QA, and package Codex-compatible animated pets and pet spritesheets from character art, generated images, company or prospect brand cues, or visual references. Use when a user wants a lightweight-worker Codex pet workflow, a non-pixel custom pet style, a prospect or company mascot pet, or a full 8x9 animated pet atlas with transparent unused cells, QA contact sheets, and pet.json packaging. This skill composes the installed $imagegen system skill for visual generation and uses bundled scripts for deterministic spritesheet assembly.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6415,6418,6419,6422],{"name":6416,"slug":6417,"type":15},"Animation","animation",{"name":6316,"slug":6317,"type":15},{"name":6420,"slug":6421,"type":15},"Creative","creative",{"name":6358,"slug":6359,"type":15},"2026-05-02T05:31:48.48485",{"slug":6425,"name":6425,"fn":6426,"description":6427,"org":6428,"tags":6429,"stars":6283,"repoUrl":6284,"updatedAt":6439},"imagegen","generate and edit raster images","Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handled by editing existing SVG\u002Fvector\u002Fcode-native assets, extending an established icon or logo system, or building the visual directly in HTML\u002FCSS\u002Fcanvas.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6430,6431,6432,6435,6438],{"name":6420,"slug":6421,"type":15},{"name":6358,"slug":6359,"type":15},{"name":6433,"slug":6434,"type":15},"Image Generation","image-generation",{"name":6436,"slug":6437,"type":15},"Images","images",{"name":9,"slug":8,"type":15},"2026-05-15T06:23:24.312127",675,{"items":6442,"total":6552},[6443,6460,6474,6486,6502,6520,6540],{"slug":6444,"name":6444,"fn":6445,"description":6446,"org":6447,"tags":6448,"stars":25,"repoUrl":26,"updatedAt":6459},"accessibility-and-inclusive-visualization","make data visualizations accessible","Make data visualizations accessible and inclusive. Use when the user needs chart or diagram accessibility guidance, text alternatives for complex visuals, color and contrast review, keyboard support, reduced-motion behavior for animation or parallax, or an accessibility QA workflow for exported figures, UML-like diagrams, and dashboards.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6449,6452,6455,6458],{"name":6450,"slug":6451,"type":15},"Accessibility","accessibility",{"name":6453,"slug":6454,"type":15},"Charts","charts",{"name":6456,"slug":6457,"type":15},"Data Visualization","data-visualization",{"name":6358,"slug":6359,"type":15},"2026-06-30T19:00:57.102",{"slug":6461,"name":6461,"fn":6462,"description":6463,"org":6464,"tags":6465,"stars":25,"repoUrl":26,"updatedAt":6473},"agent-browser","automate browser interactions for agents","Browser automation CLI for AI agents. Use when the user needs to interact with websites, verify dev server output, test web apps, navigate pages, fill forms, click buttons, take screenshots, extract data, or automate any browser task. Also triggers when a dev server starts so you can verify it visually.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6466,6467,6470],{"name":23,"slug":24,"type":15},{"name":6468,"slug":6469,"type":15},"Browser Automation","browser-automation",{"name":6471,"slug":6472,"type":15},"Testing","testing","2026-04-06T18:41:03.44016",{"slug":6475,"name":6475,"fn":6476,"description":6477,"org":6478,"tags":6479,"stars":25,"repoUrl":26,"updatedAt":6485},"agent-browser-verify","verify dev server output with automated browser","Automated browser verification for dev servers. Triggers when a dev server starts to run a visual gut-check with agent-browser — verifies the page loads, checks for console errors, validates key UI elements, and reports pass\u002Ffail before continuing.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6480,6481,6484],{"name":6468,"slug":6469,"type":15},{"name":6482,"slug":6483,"type":15},"Local Development","local-development",{"name":6471,"slug":6472,"type":15},"2026-04-06T18:41:17.526867",{"slug":6487,"name":6487,"fn":6488,"description":6489,"org":6490,"tags":6491,"stars":25,"repoUrl":26,"updatedAt":6501},"agents-sdk","build AI agents on Cloudflare Workers","Build AI agents on Cloudflare Workers using the Agents SDK. Load when creating stateful agents, durable workflows, real-time WebSocket apps, scheduled tasks, MCP servers, or chat applications. Covers Agent class, state management, callable RPC, Workflows integration, and React hooks. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6492,6493,6494,6497,6500],{"name":23,"slug":24,"type":15},{"name":13,"slug":14,"type":15},{"name":6495,"slug":6496,"type":15},"SDK","sdk",{"name":6498,"slug":6499,"type":15},"Serverless","serverless",{"name":17,"slug":18,"type":15},"2026-04-06T18:39:51.717063",{"slug":6503,"name":6503,"fn":6504,"description":6505,"org":6506,"tags":6507,"stars":25,"repoUrl":26,"updatedAt":6519},"ai-elements","build chat UIs with AI Elements","AI Elements component library guidance — pre-built React components for AI interfaces built on shadcn\u002Fui. Use when building chat UIs, message displays, tool call rendering, streaming responses, reasoning panels, or any AI-native interface with the AI SDK.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6508,6509,6512,6515,6516],{"name":6363,"slug":6364,"type":15},{"name":6510,"slug":6511,"type":15},"React","react",{"name":6513,"slug":6514,"type":15},"shadcn\u002Fui","shadcn-ui",{"name":6380,"slug":6381,"type":15},{"name":6517,"slug":6518,"type":15},"Vercel","vercel","2026-04-06T18:40:59.619419",{"slug":6521,"name":6521,"fn":6522,"description":6523,"org":6524,"tags":6525,"stars":25,"repoUrl":26,"updatedAt":6539},"ai-gateway","configure Vercel AI Gateway","Vercel AI Gateway expert guidance. Use when configuring model routing, provider failover, cost tracking, or managing multiple AI providers through a unified API.",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6526,6529,6532,6535,6538],{"name":6527,"slug":6528,"type":15},"AI Infrastructure","ai-infrastructure",{"name":6530,"slug":6531,"type":15},"Cost Optimization","cost-optimization",{"name":6533,"slug":6534,"type":15},"LLM","llm",{"name":6536,"slug":6537,"type":15},"Performance","performance",{"name":6517,"slug":6518,"type":15},"2026-04-06T18:40:44.377464",{"slug":6541,"name":6541,"fn":6542,"description":6543,"org":6544,"tags":6545,"stars":25,"repoUrl":26,"updatedAt":6551},"ai-generation-persistence","implement persistence patterns for AI generations","AI generation persistence patterns — unique IDs, addressable URLs, database storage, and cost tracking for every LLM generation",{"slug":8,"name":9,"logoUrl":10,"githubOrg":8},[6546,6547,6550],{"name":6530,"slug":6531,"type":15},{"name":6548,"slug":6549,"type":15},"Database","database",{"name":6533,"slug":6534,"type":15},"2026-04-06T18:41:08.513425",600]