[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-73608":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":16,"starSnapshotCount":16,"syncStatus":33,"lastSyncTime":34,"discoverSource":35},73608,"agents","cloudflare\u002Fagents","cloudflare","Build and deploy AI Agents on Cloudflare ","https:\u002F\u002Fdevelopers.cloudflare.com\u002Fagents\u002F",null,"TypeScript",5080,587,35,101,0,37,66,176,111,114.31,"MIT License",false,"main",true,[5,27,7,28,29],"ai","durable-objects","workflows","2026-06-12 04:01:10","# Cloudflare Agents\n\n[![npm version](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fv\u002Fagents)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fagents)\n[![npm downloads](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fdw\u002Fagents)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fagents)\n\n![npm install agents](assets\u002Fnpm-install-agents.svg)\n\nAgents are persistent, stateful execution environments for agentic workloads, powered by Cloudflare [Durable Objects](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fdurable-objects\u002F). Each agent has its own state, storage, and lifecycle — with built-in support for real-time communication, scheduling, AI model calls, MCP, workflows, and more.\n\nAgents hibernate when idle and wake on demand. You can run millions of them — one per user, per session, per game room — each costs nothing when inactive.\n\n```sh\nnpm create cloudflare@latest -- --template cloudflare\u002Fagents-starter\n```\n\nOr add to an existing project:\n\n```sh\nnpm install agents\n```\n\n**[Read the docs](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fagents\u002F)** — getting started, API reference, guides, and more.\n\n## Quick Example\n\nA counter agent with persistent state, callable methods, and real-time sync to a React frontend:\n\n```typescript\n\u002F\u002F server.ts\nimport { Agent, routeAgentRequest, callable } from \"agents\";\n\nexport type CounterState = { count: number };\n\nexport class CounterAgent extends Agent\u003CEnv, CounterState> {\n  initialState = { count: 0 };\n\n  @callable()\n  increment() {\n    this.setState({ count: this.state.count + 1 });\n    return this.state.count;\n  }\n\n  @callable()\n  decrement() {\n    this.setState({ count: this.state.count - 1 });\n    return this.state.count;\n  }\n}\n\nexport default {\n  async fetch(request: Request, env: Env, ctx: ExecutionContext) {\n    return (\n      (await routeAgentRequest(request, env)) ??\n      new Response(\"Not found\", { status: 404 })\n    );\n  }\n};\n```\n\n```tsx\n\u002F\u002F client.tsx\nimport { useAgent } from \"agents\u002Freact\";\nimport { useState } from \"react\";\nimport type { CounterAgent, CounterState } from \".\u002Fserver\";\n\nfunction Counter() {\n  const [count, setCount] = useState(0);\n\n  const agent = useAgent\u003CCounterAgent, CounterState>({\n    agent: \"CounterAgent\",\n    onStateUpdate: (state) => setCount(state.count)\n  });\n\n  return (\n    \u003Cdiv>\n      \u003Cspan>{count}\u003C\u002Fspan>\n      \u003Cbutton onClick={() => agent.stub.increment()}>+\u003C\u002Fbutton>\n      \u003Cbutton onClick={() => agent.stub.decrement()}>-\u003C\u002Fbutton>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\nState changes sync to all connected clients automatically. Call methods like they're local functions.\n\nThe agent is a Durable Object, so it needs a binding and a SQLite migration in `wrangler.jsonc`:\n\n```jsonc\n{\n  \"name\": \"counter\",\n  \"main\": \"server.ts\",\n  \"compatibility_date\": \"2026-01-28\",\n  \"compatibility_flags\": [\"nodejs_compat\"],\n  \"durable_objects\": {\n    \"bindings\": [{ \"name\": \"CounterAgent\", \"class_name\": \"CounterAgent\" }]\n  },\n  \"migrations\": [{ \"tag\": \"v1\", \"new_sqlite_classes\": [\"CounterAgent\"] }]\n}\n```\n\n## Features\n\n| Feature                 | Description                                                                     |\n| ----------------------- | ------------------------------------------------------------------------------- |\n| **Persistent State**    | Syncs to all connected clients, survives restarts                               |\n| **Callable Methods**    | Type-safe RPC via the `@callable()` decorator                                   |\n| **Sub-agents**          | Parent\u002Fchild DO composition via facets, nested routing, and typed parent lookup |\n| **Agent Tools**         | Run chat-capable sub-agents as tools with streaming child timelines             |\n| **Scheduling**          | One-time, recurring, and cron-based tasks                                       |\n| **WebSockets**          | Real-time bidirectional communication with lifecycle hooks                      |\n| **AI Chat**             | Message persistence, resumable streaming, server\u002Fclient tool execution          |\n| **MCP**                 | Act as MCP servers or connect as MCP clients (HTTP, SSE, RPC, elicitation)      |\n| **WebMCP**              | Expose browser-side tools to agents over WebSocket                              |\n| **Workflows**           | Durable multi-step tasks with human-in-the-loop approval                        |\n| **Email**               | Send, receive, and reply via Cloudflare Email Service                           |\n| **Voice**               | Continuous STT, streaming TTS, VAD, interruption, SFU utilities                 |\n| **Browser Agents**      | Run agents in the browser tab with `agents\u002Fbrowser`                             |\n| **Code Mode**           | LLMs generate executable TypeScript instead of individual tool calls            |\n| **Sandboxed Execution** | Run generated code inside an isolated Worker with a virtual filesystem          |\n| **x402 Payments**       | Pay-per-call APIs and tools via the x402 protocol                               |\n| **Observability**       | Built-in tracing, metrics, and structured logs                                  |\n| **SQL**                 | Direct SQLite queries via Durable Objects                                       |\n| **React Hooks**         | `useAgent`, `useAgentChat`, `useVoiceAgent` for frontend integration            |\n| **Vanilla JS Client**   | `AgentClient` and `VoiceClient` for non-React environments                      |\n\n## Packages\n\n| Package                                                 | Description                                                                                       |\n| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |\n| [`agents`](packages\u002Fagents)                             | Core SDK — `Agent` class, routing, state, scheduling, MCP, email, workflows, x402, browser agents |\n| [`@cloudflare\u002Fai-chat`](packages\u002Fai-chat)               | Higher-level AI chat — persistent messages, resumable streaming, tool execution                   |\n| [`@cloudflare\u002Fthink`](packages\u002Fthink)                   | Opinionated chat agent base — agentic loop, stream resumption, client tools, workspace tools      |\n| [`@cloudflare\u002Fcodemode`](packages\u002Fcodemode)             | LLMs write executable code that calls your tools, instead of one tool call at a time              |\n| [`@cloudflare\u002Fshell`](packages\u002Fshell)                   | Sandboxed JS execution + virtual filesystem (`Workspace`) for agents                              |\n| [`@cloudflare\u002Fvoice`](packages\u002Fvoice)                   | Voice pipeline — STT, TTS, VAD, streaming, SFU utilities                                          |\n| [`@cloudflare\u002Fworker-bundler`](packages\u002Fworker-bundler) | Build and bundle Workers at runtime, for use with the Worker Loader binding                       |\n| [`hono-agents`](packages\u002Fhono-agents)                   | Hono middleware for adding agents to Hono apps                                                    |\n\n> AI-chat modules used to live in `agents\u002Fai-chat-agent`, `agents\u002Fchat`, `agents\u002Fai-react`, and `agents\u002Fai-types`. Those entry points still re-export, but they're deprecated — import from `@cloudflare\u002Fai-chat` directly. New chat-from-scratch projects should look at `@cloudflare\u002Fthink`.\n\n## Examples\n\nThe [`examples\u002F`](examples) directory has 30+ self-contained demos. A non-exhaustive tour:\n\n- **Showcase** — [`playground\u002F`](examples\u002Fplayground) is the kitchen-sink app: state, callable methods, scheduling, chat, tools, MCP, workflows, email, voice — all in one UI\n- **Chat & assistants** — [`assistant\u002F`](examples\u002Fassistant), [`agents-as-tools\u002F`](examples\u002Fagents-as-tools), [`workspace-chat\u002F`](examples\u002Fworkspace-chat), [`resumable-stream-chat\u002F`](examples\u002Fresumable-stream-chat), [`structured-input\u002F`](examples\u002Fstructured-input), [`dynamic-tools\u002F`](examples\u002Fdynamic-tools), [`multi-ai-chat\u002F`](examples\u002Fmulti-ai-chat)\n- **MCP** — [`mcp\u002F`](examples\u002Fmcp), [`mcp-client\u002F`](examples\u002Fmcp-client), [`mcp-server\u002F`](examples\u002Fmcp-server), [`mcp-worker\u002F`](examples\u002Fmcp-worker), [`mcp-worker-authenticated\u002F`](examples\u002Fmcp-worker-authenticated), [`mcp-elicitation\u002F`](examples\u002Fmcp-elicitation), [`mcp-rpc-transport\u002F`](examples\u002Fmcp-rpc-transport), [`webmcp\u002F`](examples\u002Fwebmcp)\n- **Code Mode & sandboxes** — [`codemode\u002F`](examples\u002Fcodemode), [`codemode-mcp\u002F`](examples\u002Fcodemode-mcp), [`codemode-mcp-openapi\u002F`](examples\u002Fcodemode-mcp-openapi), [`dynamic-workers\u002F`](examples\u002Fdynamic-workers), [`dynamic-workers-playground\u002F`](examples\u002Fdynamic-workers-playground), [`worker-bundler-playground\u002F`](examples\u002Fworker-bundler-playground)\n- **Voice** — [`voice-agent\u002F`](examples\u002Fvoice-agent), [`voice-input\u002F`](examples\u002Fvoice-input), [`elevenlabs-starter\u002F`](examples\u002Felevenlabs-starter)\n- **Workflows & approvals** — [`workflows\u002F`](examples\u002Fworkflows), [`a2a\u002F`](examples\u002Fa2a)\n- **Auth, payments, comms** — [`auth-agent\u002F`](examples\u002Fauth-agent), [`cross-domain\u002F`](examples\u002Fcross-domain), [`x402\u002F`](examples\u002Fx402), [`x402-mcp\u002F`](examples\u002Fx402-mcp), [`email-agent\u002F`](examples\u002Femail-agent), [`github-webhook\u002F`](examples\u002Fgithub-webhook), [`push-notifications\u002F`](examples\u002Fpush-notifications)\n- **Game & misc** — [`tictactoe\u002F`](examples\u002Ftictactoe), [`ai-chat\u002F`](examples\u002Fai-chat)\n\nExamples using the [OpenAI Agents SDK](https:\u002F\u002Fopenai.github.io\u002Fopenai-agents-js\u002F) live in [`openai-sdk\u002F`](openai-sdk). Work-in-progress experiments live in [`experimental\u002F`](experimental) (no stability guarantees).\n\nRun any example locally:\n\n```sh\ncd examples\u002Fplayground\nnpm start\n```\n\n## Documentation\n\n- [Full docs](https:\u002F\u002Fdevelopers.cloudflare.com\u002Fagents\u002F) on developers.cloudflare.com\n- [`docs\u002F`](docs) directory in this repo (synced upstream)\n- [Anthropic Patterns guide](guides\u002Fanthropic-patterns) — sequential, routing, parallel, orchestrator, evaluator\n- [Human-in-the-Loop guide](guides\u002Fhuman-in-the-loop) — approval workflows with pause\u002Fresume\n- [`design\u002F`](design) — architecture and design decision records (chat API, sub-agents, agent tools, workspace, voice, browser tools, retries, and more)\n\n## Repository Structure\n\n| Directory                                             | Description                                              |\n| ----------------------------------------------------- | -------------------------------------------------------- |\n| [`packages\u002Fagents\u002F`](packages\u002Fagents)                 | Core SDK                                                 |\n| [`packages\u002Fai-chat\u002F`](packages\u002Fai-chat)               | AI chat layer                                            |\n| [`packages\u002Fthink\u002F`](packages\u002Fthink)                   | Opinionated chat agent base                              |\n| [`packages\u002Fcodemode\u002F`](packages\u002Fcodemode)             | Code Mode                                                |\n| [`packages\u002Fshell\u002F`](packages\u002Fshell)                   | Sandboxed execution + filesystem                         |\n| [`packages\u002Fvoice\u002F`](packages\u002Fvoice)                   | Voice pipeline                                           |\n| [`packages\u002Fworker-bundler\u002F`](packages\u002Fworker-bundler) | Runtime Workers bundler                                  |\n| [`packages\u002Fhono-agents\u002F`](packages\u002Fhono-agents)       | Hono integration                                         |\n| [`examples\u002F`](examples)                               | Self-contained demo apps                                 |\n| [`experimental\u002F`](experimental)                       | Work-in-progress experiments (not published)             |\n| [`openai-sdk\u002F`](openai-sdk)                           | Examples using the OpenAI Agents SDK                     |\n| [`guides\u002F`](guides)                                   | In-depth pattern tutorials                               |\n| [`docs\u002F`](docs)                                       | Markdown docs synced to developers.cloudflare.com        |\n| [`site\u002F`](site)                                       | Deployed websites (agents.cloudflare.com, AI playground) |\n| [`design\u002F`](design)                                   | Architecture and design decision records                 |\n| [`scripts\u002F`](scripts)                                 | Repo-wide tooling                                        |\n\n## Development\n\nNode 24+ required. npm workspaces with [Nx](https:\u002F\u002Fnx.dev) for task orchestration, caching, and affected detection.\n\n```sh\nnpm install                  # install all workspaces\nnpm run build                # build all packages (Nx, cached, dependency-ordered)\nnpm run check                # sherif + export checks + oxfmt + oxlint + typecheck\nnpm run test                 # vitest + vitest-pool-workers (Workers runtime)\nnpm run test:react           # Playwright-based React hook tests\nnpx nx affected -t build     # build only what changed\nnpx nx affected -t test      # test only what changed\n```\n\nChanges to `packages\u002F` need a changeset:\n\n```sh\nnpx changeset\n```\n\nSee [`AGENTS.md`](AGENTS.md) for deeper contributor guidance.\n\n## Contributing\n\nWe are not accepting external pull requests at this time — the SDK is evolving quickly and we want to keep the surface area manageable. That said, we'd love to hear from you:\n\n- **Bug reports & feature requests** — [open an issue](https:\u002F\u002Fgithub.com\u002Fcloudflare\u002Fagents\u002Fissues)\n- **Questions & ideas** — [start a discussion](https:\u002F\u002Fgithub.com\u002Fcloudflare\u002Fagents\u002Fdiscussions)\n\n## License\n\n[MIT](LICENSE)\n","Cloudflare Agents 项目旨在帮助开发者在 Cloudflare 平台上构建和部署 AI 代理。它利用了 Cloudflare 的 Durable Objects 技术，为每个代理提供独立的状态、存储及生命周期管理，并内置支持实时通信、调度、AI 模型调用、MCP 和工作流等功能。Agents 在空闲时会进入休眠状态以节省资源，仅在需要时唤醒，这使得即使运行数百万个代理也具有成本效益。该项目适合需要高度可扩展性和低延迟的应用场景，如个性化用户体验、在线游戏房间管理等。使用 TypeScript 编写，通过 npm 安装即可快速集成到现有项目中。",2,"2026-06-11 03:46:22","high_star"]