Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

A2A Agent

Exposes a Cloudflare Agent as an A2A protocol server with a browser-based A2A client UI.

What this shows

  • Agent Card discovery at /.well-known/agent-card.json
  • JSON-RPC transport (message/send, message/stream) via the @a2a-js/sdk server
  • 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

Run it

npm install
npm start

Open http://localhost:5173 to use the chat UI.

Any A2A client can discover this agent:

curl http://localhost:5173/.well-known/agent-card.json

Key pattern

The 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.

Related