A2AAdapter, exposing it as a JSON-RPC HTTP server. The client uses plain fetch() to send a task - showing the wire format every A2A client must produce.
What you’ll learn
- Wrapping a Vibes agent with
A2AAdapter - Exposing an agent as an A2A-compatible HTTP server with
adapter.handler() - Calling an A2A server using the
message/sendJSON-RPC method - The A2A wire format (JSON-RPC 2.0 message structure)
Prerequisites
- Vibes installed (
npm:@vibesjs/sdk) ANTHROPIC_API_KEYenvironment variable set (for the server)
Complete example
Run it
How it works
A2AAdapter
Wraps a Vibes agent and handles all A2A protocol details - routing, task lifecycle, JSON-RPC marshaling. The options object becomes the AgentCard served at GET /.well-known/agent.json for agent discovery.
adapter.handler()
Returns a Deno-compatible (req: Request) => Promise<Response> function. Pass directly to Deno.serve().
JSON-RPC wire format
A2A uses JSON-RPC 2.0.method: "message/send" is synchronous - the response body contains the complete A2ATask result. Use method: "message/stream" for SSE streaming.
Response shape
The result is anA2ATask object. Text responses are in result.artifacts[0].parts[0].text. The task state will be "completed" for successful runs.
The client uses plain
fetch() intentionally - this is the A2A wire protocol that any A2A-compatible client must produce. In production, you would typically use an A2A client SDK or another Vibes agent as the caller.Next steps
- A2A integration page - streaming (message/stream), task cancellation, MemoryTaskStore
- Multi-Agent concept page - agent-as-tool pattern (simpler, same process)