Exposes a Cloudflare Agent as an A2A protocol server with a browser-based A2A client UI.
- Agent Card discovery at
/.well-known/agent-card.json - JSON-RPC transport (
message/send,message/stream) via the@a2a-js/sdkserver - SSE streaming for real-time task status updates
- DO-backed TaskStore using Durable Object SQLite for persistent task state
- Workers AI (GLM 4.7 Flash) for actual AI responses
npm install
npm startOpen http://localhost:5173 to use the chat UI.
Any A2A client can discover this agent:
curl http://localhost:5173/.well-known/agent-card.jsonThe server uses the SDK's DefaultRequestHandler + AgentExecutor to avoid hand-rolling A2A protocol logic:
class AIAgentExecutor implements AgentExecutor {
async execute(ctx: RequestContext, bus: ExecutionEventBus) {
// Publish task → working status → AI response → completed status
bus.publish(initialTask);
bus.publish(workingStatus);
const result = await generateText({ model, messages });
bus.publish(responseMessage);
bus.publish(completedStatus);
bus.finished();
}
}
const handler = new DefaultRequestHandler(agentCard, taskStore, executor);
const transport = new JsonRpcTransportHandler(handler);Tasks are persisted in Durable Object SQLite via a custom TaskStore implementation.
- A2A Protocol docs
- a2a-js SDK
- AI Chat example — similar AI agent using
@cloudflare/ai-chat