@galdor/a2a
v0.3.1
Published
galdor-bun a2a: Google Agent-to-Agent (A2A) protocol — JSON-RPC 2.0 over HTTP client + server.
Readme
@galdor/a2a
A Google Agent-to-Agent (A2A) protocol client and server for galdor — JSON-RPC 2.0 over HTTP. Publish a galdor agent so other agents can call it, or drive a remote A2A agent as a client.
Serves the Agent Card at /.well-known/agent.json, implements tasks/send and
tasks/get, the six spec TaskStates, task history/artifacts/sessions, and an
SSRF guard on the client (same-host redirects only, bounded body, configurable
deadline).
Install
bun add @galdor/a2a # or: npm install @galdor/a2aServer
import { newServer, handlerFunc, agentText, type AgentCard } from "@galdor/a2a";
const card: AgentCard = {
name: "greeter",
description: "Greets people.",
url: "http://localhost:4000",
version: "1.0.0",
capabilities: {},
skills: [],
};
const server = newServer(card, handlerFunc(async (task) => {
const name = task.message.parts.map((p) => p.text ?? "").join(" ");
return agentText(`Hello, ${name}!`);
}));
Bun.serve({ port: 4000, fetch: server.fetch }); // Node: pass server.fetch to your HTTP layerClient
import { Client, userText } from "@galdor/a2a";
const client = new Client("http://localhost:4000");
// const client = new Client(url, { timeoutMs: 0, fetch: customFetch }); // optional
const card = await client.fetchAgentCard();
const task = await client.sendTask(userText("Ada"));
console.log(task.status.state, task.history?.at(-1)?.parts);License
Apache-2.0
