cloudflare-agents
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCloudflare Agents
Cloudflare Agents
Last Updated: 2025-11-21
最后更新时间: 2025-11-21
Quick Start
快速开始
typescript
export default {
async fetch(request, env, ctx) {
const agent = {
tools: [
{ name: 'getTodo', handler: async ({id}) => ({id, title: 'Task'}) }
],
async run(input) {
return await processWithLLM(input, this.tools);
}
};
return Response.json(await agent.run(await request.text()));
}
};typescript
export default {
async fetch(request, env, ctx) {
const agent = {
tools: [
{ name: 'getTodo', handler: async ({id}) => ({id, title: 'Task'}) }
],
async run(input) {
return await processWithLLM(input, this.tools);
}
};
return Response.json(await agent.run(await request.text()));
}
};Core Features
核心功能
- Tool Integration: Register and execute tools
- LLM Providers: OpenAI, Anthropic, Google Gemini
- MCP Protocol: Model Context Protocol support
- Cloudflare Bindings: D1, KV, R2, Durable Objects
- 工具集成:注册并执行工具
- 大语言模型提供商:OpenAI、Anthropic、Google Gemini
- MCP协议:支持Model Context Protocol
- Cloudflare绑定:D1、KV、R2、Durable Objects
Agent Pattern
Agent模式
typescript
const agent = {
tools: [...],
systemPrompt: 'You are a helpful assistant',
model: 'gpt-4o',
async run(input) {
// Process with LLM
}
};typescript
const agent = {
tools: [...],
systemPrompt: 'You are a helpful assistant',
model: 'gpt-4o',
async run(input) {
// Process with LLM
}
};Resources
资源
Core Documentation
核心文档
- (317 lines) - What is Cloudflare Agents, patterns & concepts, critical rules, known issues prevention
references/patterns-concepts.md - (152 lines) - Complete configuration deep dive
references/configuration-guide.md - (115 lines) - Complete Agent Class API reference
references/agent-api.md
- (317行)- 什么是Cloudflare Agent、模式与概念、关键规则、已知问题预防
references/patterns-concepts.md - (152行)- 完整配置深度解析
references/configuration-guide.md - (115行)- 完整Agent类API参考
references/agent-api.md
Integration Guides
集成指南
- (74 lines) - HTTP & Server-Sent Events
references/http-sse-guide.md - (110 lines) - WebSocket integration
references/websockets-guide.md - (388 lines) - State management, scheduled tasks, workflows
references/state-management.md - (130 lines) - Model Context Protocol integration
references/mcp-integration.md
- (74行)- HTTP与Server-Sent Events
references/http-sse-guide.md - (110行)- WebSocket集成
references/websockets-guide.md - (388行)- 状态管理、定时任务、工作流
references/state-management.md - (130行)- Model Context Protocol集成
references/mcp-integration.md
Advanced Features
高级功能
- (637 lines) - Browser automation, RAG, AI model integration, calling agents, client APIs
references/advanced-features.md
- (637行)- 浏览器自动化、RAG、AI模型集成、Agent调用、客户端API
references/advanced-features.md
Error Reference
错误参考
- (10 lines) - Common errors and solutions
references/error-catalog.md
- (10行)- 常见错误及解决方案
references/error-catalog.md
Templates
模板
- - Basic agent setup
templates/basic-agent.ts - - Browser automation
templates/browser-agent.ts - - Calling other agents
templates/calling-agents-worker.ts - - Streaming chat agent
templates/chat-agent-streaming.ts - - Human-in-the-loop
templates/hitl-agent.ts - - MCP server integration
templates/mcp-server-basic.ts - - RAG implementation
templates/rag-agent.ts - - React client integration
templates/react-useagent-client.tsx - - Scheduled tasks
templates/scheduled-agent.ts - - State synchronization
templates/state-sync-agent.ts - - WebSocket agent
templates/websocket-agent.ts - - Workflows integration
templates/workflow-agent.ts - - Wrangler configuration
templates/wrangler-agents-config.jsonc
- - 基础Agent搭建
templates/basic-agent.ts - - 浏览器自动化
templates/browser-agent.ts - - 调用其他Agent
templates/calling-agents-worker.ts - - 流式聊天Agent
templates/chat-agent-streaming.ts - - 人在回路(Human-in-the-loop)
templates/hitl-agent.ts - - MCP服务器集成
templates/mcp-server-basic.ts - - RAG实现
templates/rag-agent.ts - - React客户端集成
templates/react-useagent-client.tsx - - 定时任务
templates/scheduled-agent.ts - - 状态同步
templates/state-sync-agent.ts - - WebSocket Agent
templates/websocket-agent.ts - - 工作流集成
templates/workflow-agent.ts - - Wrangler配置
templates/wrangler-agents-config.jsonc