agentfootprint 9.67.0 → 9.68.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ /**
3
+ * adapters/hosting/a2aWire — the A2A protocol, as an `HttpWire`.
4
+ *
5
+ * ── What this is ─────────────────────────────────────────────────────────────
6
+ * **A2A** (agent-to-agent) is an open protocol for one agent calling another:
7
+ * JSON-RPC 2.0 over HTTP, a `message/send` method carrying text parts, a result
8
+ * carrying artifacts, and a discovery document — the **agent card** — that says
9
+ * what the agent is and what it can do. It is nobody's product; several
10
+ * runtimes speak it, so it lives here on its own and the runtimes that host it
11
+ * configure this rather than reimplement it.
12
+ *
13
+ * ── The subset, stated plainly ───────────────────────────────────────────────
14
+ * One method: `message/send`, text parts only. Deliberately NOT carried:
15
+ * `message/stream` and the rest of the task lifecycle (`tasks/get`,
16
+ * `tasks/cancel`, push notifications), non-text parts, and multi-turn task
17
+ * state. An agent card built here therefore declares `streaming: false` by
18
+ * default — advertising a capability this wire cannot honour is how a caller
19
+ * finds out by hanging.
20
+ *
21
+ * ── Why it fits `httpHost` without changing it ───────────────────────────────
22
+ * JSON-RPC's one hard requirement on a reply is that it ECHOES the request's
23
+ * `id`. That is possible here only because `HttpWire`'s body methods receive
24
+ * the request that produced them — a seam added for a different protocol
25
+ * entirely, and the reason this one needed no new machinery.
26
+ *
27
+ * @example A2A on paths of your own choosing
28
+ * httpHost({
29
+ * name: 'myA2AHost',
30
+ * wire: a2aWire({ card: { name: 'triage', description: '…', version: '1.0.0' } }),
31
+ * invokePath: '/',
32
+ * healthPath: '/health',
33
+ * });
34
+ */
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.a2aWire = exports.a2aAgentCardDocument = exports.readA2AMessageText = exports.JSONRPC_INTERNAL_ERROR = exports.JSONRPC_INVALID_PARAMS = exports.JSONRPC_METHOD_NOT_FOUND = exports.A2A_SEND_METHOD = exports.A2A_AGENT_CARD_PATH = exports.A2A_PROTOCOL_VERSION = void 0;
37
+ const errors_js_1 = require("../../hosting/errors.js");
38
+ /** The A2A protocol revision this wire's documents declare. */
39
+ exports.A2A_PROTOCOL_VERSION = '0.3.0';
40
+ /** Where the A2A specification puts an agent's discovery document. */
41
+ exports.A2A_AGENT_CARD_PATH = '/.well-known/agent-card.json';
42
+ /** The one method this wire carries. */
43
+ exports.A2A_SEND_METHOD = 'message/send';
44
+ /**
45
+ * JSON-RPC's own reserved codes, the two this wire can raise.
46
+ *
47
+ * `-32601` is "method not found" and `-32602` is "invalid params" — both from
48
+ * the JSON-RPC specification rather than from A2A or any runtime, which is why
49
+ * they are the only numbers this neutral file knows. A runtime's own error
50
+ * codes belong to that runtime's adapter.
51
+ */
52
+ exports.JSONRPC_METHOD_NOT_FOUND = -32601;
53
+ exports.JSONRPC_INVALID_PARAMS = -32602;
54
+ exports.JSONRPC_INTERNAL_ERROR = -32603;
55
+ function isRecord(value) {
56
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
57
+ }
58
+ /** The request's JSON-RPC id, echoed onto every reply. `null` is legal and distinct from absent. */
59
+ function requestId(facts) {
60
+ const id = facts?.body.id;
61
+ return typeof id === 'string' || typeof id === 'number' ? id : null;
62
+ }
63
+ /**
64
+ * The text of one A2A message — every part concatenated, refusing what is not text.
65
+ *
66
+ * A non-text part is refused rather than skipped for the reason every dialect
67
+ * in this library refuses rather than skips: an answer produced from the parts
68
+ * that happened to be understood is a wrong answer delivered confidently.
69
+ */
70
+ function readA2AMessageText(message) {
71
+ if (!isRecord(message)) {
72
+ throw new errors_js_1.WireRequestRefusal('invalid_params', 'params.message must be an object', 400);
73
+ }
74
+ const parts = message.parts;
75
+ if (!Array.isArray(parts) || parts.length === 0) {
76
+ throw new errors_js_1.WireRequestRefusal('invalid_params', 'params.message.parts must be a non-empty array', 400);
77
+ }
78
+ const text = [];
79
+ for (const part of parts) {
80
+ if (!isRecord(part) || part.kind !== 'text' || typeof part.text !== 'string') {
81
+ const kind = isRecord(part) && typeof part.kind === 'string' ? part.kind : 'unknown';
82
+ throw new errors_js_1.WireRequestRefusal('unsupported_part', `this agent carries text parts only; '${kind}' parts are not supported`, 400);
83
+ }
84
+ text.push(part.text);
85
+ }
86
+ return text.join('');
87
+ }
88
+ exports.readA2AMessageText = readA2AMessageText;
89
+ /**
90
+ * The agent card document, as the protocol prints it.
91
+ *
92
+ * Exported on its own because a deployment often has to serve the card from
93
+ * somewhere this wire does not own — a CDN, a route in a framework, a runtime's
94
+ * own discovery API — and the document should be built once, here, rather than
95
+ * hand-copied into each of those places.
96
+ */
97
+ function a2aAgentCardDocument(card) {
98
+ return {
99
+ name: card.name,
100
+ description: card.description,
101
+ version: card.version,
102
+ ...(card.url !== undefined && { url: card.url }),
103
+ protocolVersion: exports.A2A_PROTOCOL_VERSION,
104
+ preferredTransport: 'JSONRPC',
105
+ capabilities: { streaming: card.streaming === true },
106
+ defaultInputModes: card.defaultInputModes ?? ['text'],
107
+ defaultOutputModes: card.defaultOutputModes ?? ['text'],
108
+ skills: (card.skills ?? []).map((s) => ({
109
+ id: s.id,
110
+ name: s.name,
111
+ description: s.description,
112
+ tags: s.tags ?? [],
113
+ })),
114
+ };
115
+ }
116
+ exports.a2aAgentCardDocument = a2aAgentCardDocument;
117
+ /** An `HttpWire` speaking A2A's `message/send`. */
118
+ function a2aWire(options) {
119
+ const health = options.health ?? { status: 'ok' };
120
+ const name = options.name ?? 'a2aWire';
121
+ const codeFor = options.errorCodeFor ?? (() => exports.JSONRPC_INTERNAL_ERROR);
122
+ const envelope = (facts, body) => ({
123
+ jsonrpc: '2.0',
124
+ id: requestId(facts),
125
+ ...body,
126
+ });
127
+ return {
128
+ readRequest(facts) {
129
+ const { body } = facts;
130
+ if (body.jsonrpc !== '2.0') {
131
+ throw new errors_js_1.WireRequestRefusal('invalid_request', `${name}: every request must carry "jsonrpc": "2.0"`, 400);
132
+ }
133
+ if (body.method !== exports.A2A_SEND_METHOD) {
134
+ // Named rather than ignored: a caller using a method this agent does
135
+ // not implement learns which one it does, instead of receiving an
136
+ // empty answer to a question that was never asked.
137
+ throw new errors_js_1.WireRequestRefusal('method_not_found', `${name}: only '${exports.A2A_SEND_METHOD}' is implemented; received '${String(body.method)}'`, 404);
138
+ }
139
+ const params = isRecord(body.params) ? body.params : undefined;
140
+ const input = readA2AMessageText(params?.message);
141
+ if (input.trim() === '') {
142
+ throw new errors_js_1.WireRequestRefusal('invalid_params', `${name}: message text must not be empty`, 400);
143
+ }
144
+ // A2A carries no session of its own — the transport hosting it does, and
145
+ // the runtime adapter reads it from wherever that transport puts it.
146
+ return { input };
147
+ },
148
+ health: () => health,
149
+ output: (output, facts) => envelope(facts, {
150
+ result: {
151
+ artifacts: [
152
+ {
153
+ artifactId: String(facts?.body.id ?? 'artifact'),
154
+ name: 'agent_response',
155
+ parts: [{ kind: 'text', text: output }],
156
+ },
157
+ ],
158
+ },
159
+ }),
160
+ chunk: (text) => ({ kind: 'text', text }),
161
+ failure: (message, code, facts, origin) => envelope(facts, {
162
+ error: {
163
+ code: codeFor(code),
164
+ // A thrown exception's words are the author's note to their own logs.
165
+ // A refusal this library authored was written to be read.
166
+ message: origin === 'threw' ? 'The agent could not complete this request.' : message,
167
+ },
168
+ }),
169
+ };
170
+ }
171
+ exports.a2aWire = a2aWire;
172
+ //# sourceMappingURL=a2aWire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a2aWire.js","sourceRoot":"","sources":["../../../src/adapters/hosting/a2aWire.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;;AAEH,uDAA6D;AAG7D,+DAA+D;AAClD,QAAA,oBAAoB,GAAG,OAAO,CAAC;AAE5C,sEAAsE;AACzD,QAAA,mBAAmB,GAAG,8BAA8B,CAAC;AAElE,wCAAwC;AAC3B,QAAA,eAAe,GAAG,cAAc,CAAC;AAE9C;;;;;;;GAOG;AACU,QAAA,wBAAwB,GAAG,CAAC,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1B,gBAAgB,EAChB,GAAG,IAAI,kCAAkC,EACzC,GAAG,CACJ,CAAC;YACJ,CAAC;YACD,yEAAyE;YACzE,qEAAqE;YACrE,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,CAAC;QAED,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM;QAEpB,MAAM,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACxB,QAAQ,CAAC,KAAK,EAAE;YACd,MAAM,EAAE;gBACN,SAAS,EAAE;oBACT;wBACE,UAAU,EAAE,MAAM,CAAE,KAAK,EAAE,IAAI,CAAC,EAAyB,IAAI,UAAU,CAAC;wBACxE,IAAI,EAAE,gBAAgB;wBACtB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qBACxC;iBACF;aACF;SACF,CAAC;QAEJ,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;QAEzC,OAAO,EAAE,CAAC,OAAe,EAAE,IAAa,EAAE,KAAwB,EAAE,MAAsB,EAAE,EAAE,CAC5F,QAAQ,CAAC,KAAK,EAAE;YACd,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC;gBACnB,sEAAsE;gBACtE,0DAA0D;gBAC1D,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC,OAAO;aACrF;SACF,CAAC;KACL,CAAC;AACJ,CAAC;AAxED,0BAwEC"}
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ /**
3
+ * adapters/hosting/agentCoreA2A — an agentfootprint agent as an AWS Bedrock
4
+ * **AgentCore A2A** server, callable by other agents.
5
+ *
6
+ * ── The split, again ─────────────────────────────────────────────────────────
7
+ * Two different things are needed, and only one is Amazon's:
8
+ *
9
+ * • The **A2A protocol** — JSON-RPC 2.0, `message/send`, artifacts, the agent
10
+ * card. An open protocol several runtimes speak, so it lives in
11
+ * `a2aWire.ts` with no vendor in it.
12
+ * • The **container contract** — port 9000 (not 8080, and not 8000: each
13
+ * protocol gets its own), the agent mounted at `/`, `GET /ping` answering
14
+ * `{"status":"Healthy"}`, the session id arriving in
15
+ * `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id`, and a table of JSON-RPC
16
+ * error codes that are this runtime's exceptions rather than A2A's. That
17
+ * IS Amazon's, and it is what this file supplies.
18
+ *
19
+ * ── One deviation you must know about ────────────────────────────────────────
20
+ * The A2A specification delivers JSON-RPC errors over HTTP 200. **AgentCore
21
+ * does not** — it returns the real status code (409, 404, …) with the JSON-RPC
22
+ * error body. That is a fact about the platform in front of your container, so
23
+ * a CLIENT must parse the error body even on a non-2xx response; see
24
+ * `agentCoreA2AErrorCode` for the table this host mirrors on the way out.
25
+ *
26
+ * ── What is NOT provided ─────────────────────────────────────────────────────
27
+ * `message/stream` and the task lifecycle. The agent card this host serves
28
+ * therefore declares `streaming: false` unless you overrule it, because a card
29
+ * that advertises streaming to a wire that cannot stream is a caller left
30
+ * waiting. AWS's own sample card says `true`; ours says what is true of ours.
31
+ *
32
+ * @example An agent other agents can call
33
+ * import { agentCoreA2AHost, memorySessions, standingAgent } from 'agentfootprint/hosting';
34
+ *
35
+ * const handle = await standingAgent({
36
+ * agent,
37
+ * sessions: memorySessions(),
38
+ * host: agentCoreA2AHost({
39
+ * card: { name: 'triage', description: 'Triages SAN alerts.', version: '1.0.0' },
40
+ * }),
41
+ * });
42
+ * process.on('SIGTERM', () => void handle.close());
43
+ */
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.agentCoreA2AHost = exports.agentCoreA2AErrorCode = exports.AGENTCORE_SESSION_HEADER = exports.AGENTCORE_PING_PATH = exports.AGENTCORE_A2A_INVOKE_PATH = exports.DEFAULT_AGENTCORE_A2A_PORT = void 0;
46
+ const httpHost_js_1 = require("../../hosting/httpHost.js");
47
+ const a2aWire_js_1 = require("./a2aWire.js");
48
+ /** The port an AgentCore A2A server is expected on — its own, not HTTP's or MCP's. */
49
+ exports.DEFAULT_AGENTCORE_A2A_PORT = 9000;
50
+ /** A2A mounts the agent at the root. */
51
+ exports.AGENTCORE_A2A_INVOKE_PATH = '/';
52
+ /** The runtime's health path for every protocol. */
53
+ exports.AGENTCORE_PING_PATH = '/ping';
54
+ /** Where the platform puts the caller's session. */
55
+ exports.AGENTCORE_SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
56
+ /**
57
+ * AgentCore's own JSON-RPC error codes, mapped from this library's refusal codes.
58
+ *
59
+ * These numbers are the RUNTIME's exception table, not A2A's: `-32051`
60
+ * ResourceNotFound, `-32052` Validation, `-32053` Throttling and
61
+ * ServiceQuotaExceeded, `-32054` Conflict and RetryableConflict, `-32055`
62
+ * RuntimeClientError, `-32603` anything else. A client reads them to decide
63
+ * whether to retry — `-32054` with "Session operation in progress" is the one
64
+ * that must be retried with backoff, and A2A clients do not do that on their
65
+ * own.
66
+ *
67
+ * Exported so a client built against this host can share one table with it
68
+ * rather than keep a second copy that drifts.
69
+ */
70
+ function agentCoreA2AErrorCode(code) {
71
+ switch (code) {
72
+ case 'ERR_SESSION_NOT_FOUND':
73
+ case 'ERR_ARTIFACT_NOT_FOUND':
74
+ return -32051;
75
+ case 'ERR_INVALID_WIRE_OP':
76
+ case 'ERR_DECISION_REQUIRED':
77
+ case 'ERR_ARTIFACT_SESSION_REQUIRED':
78
+ case 'invalid_request':
79
+ case 'invalid_params':
80
+ case 'unsupported_part':
81
+ return -32052;
82
+ case 'ERR_ADMISSION_REFUSED':
83
+ case 'ERR_REQUEST_TOO_LARGE':
84
+ return -32053;
85
+ case 'ERR_CONCURRENT_RUN':
86
+ case 'ERR_HOST_CLOSED':
87
+ case 'ERR_AWAITING_DECISION':
88
+ case 'ERR_PAUSE_NOT_CARRIED':
89
+ return -32054;
90
+ case 'method_not_found':
91
+ // JSON-RPC's own "method not found" is -32601, but this runtime reports a
92
+ // route it cannot resolve as ResourceNotFound. The platform's table wins
93
+ // inside the platform's container.
94
+ return -32051;
95
+ default:
96
+ return -32603;
97
+ }
98
+ }
99
+ exports.agentCoreA2AErrorCode = agentCoreA2AErrorCode;
100
+ const DEFAULT_MAX_BODY_BYTES = 1_048_576;
101
+ /**
102
+ * An {@link HttpHost} serving AgentCore's A2A container contract.
103
+ *
104
+ * `httpHost` keeps its own promises — draining, aborting on disconnect, failing
105
+ * a handler that throws or answers nothing — and this supplies the protocol,
106
+ * the paths, the port, the session header and the error table.
107
+ */
108
+ function agentCoreA2AHost(options) {
109
+ const { server, onUnhandled, hostname, card } = options;
110
+ const cardDocument = JSON.stringify((0, a2aWire_js_1.a2aAgentCardDocument)(card));
111
+ /** The discovery document, served before anything falls through to the caller. */
112
+ const serveCard = (req, res) => {
113
+ const path = (req.url ?? '').split('?')[0];
114
+ if (req.method === 'GET' && path === a2aWire_js_1.A2A_AGENT_CARD_PATH) {
115
+ res.writeHead(200, {
116
+ 'content-type': 'application/json',
117
+ 'content-length': Buffer.byteLength(cardDocument),
118
+ });
119
+ res.end(cardDocument);
120
+ return;
121
+ }
122
+ // Not the card: the caller's own routes, if they have any. Chaining rather
123
+ // than consuming the slot — an adapter that took `onUnhandled` for itself
124
+ // would silently remove a seam the host documents as the consumer's.
125
+ if (onUnhandled) {
126
+ onUnhandled(req, res);
127
+ return;
128
+ }
129
+ res.writeHead(404, { 'content-type': 'application/json' });
130
+ res.end(JSON.stringify({ error: `no route for ${req.method ?? '?'} ${path}` }));
131
+ };
132
+ const socket = server
133
+ ? { server }
134
+ : {
135
+ port: options.port ?? exports.DEFAULT_AGENTCORE_A2A_PORT,
136
+ ...(hostname === undefined ? {} : { hostname }),
137
+ onUnhandled: serveCard,
138
+ };
139
+ const protocol = (0, a2aWire_js_1.a2aWire)({
140
+ card,
141
+ // The runtime's health contract, not A2A's — A2A has no /ping at all.
142
+ health: { status: 'Healthy' },
143
+ errorCodeFor: agentCoreA2AErrorCode,
144
+ name: 'agentCoreA2AHost',
145
+ });
146
+ return (0, httpHost_js_1.httpHost)({
147
+ name: 'agentCoreA2AHost',
148
+ wire: {
149
+ ...protocol,
150
+ // The one thing the protocol does not carry and the platform does: which
151
+ // conversation this call belongs to, in a header of the runtime's own.
152
+ readRequest(facts) {
153
+ const base = protocol.readRequest(facts);
154
+ const sessionId = (0, httpHost_js_1.headerValue)(facts, exports.AGENTCORE_SESSION_HEADER);
155
+ return { ...base, ...(sessionId !== undefined && { sessionId }) };
156
+ },
157
+ },
158
+ invokePath: exports.AGENTCORE_A2A_INVOKE_PATH,
159
+ healthPath: exports.AGENTCORE_PING_PATH,
160
+ // NOT `['streaming']`, which is this file's default. `message/send` has
161
+ // nowhere to put a chunk: a caller gets one JSON-RPC reply and nothing
162
+ // before it. Declaring streaming anyway would make `requireCapability`
163
+ // pass for a host that cannot honour it, and would contradict the agent
164
+ // card, which says `streaming: false` for the same reason. The host
165
+ // conformance suite catches exactly this — it asserts chunks IF AND ONLY IF
166
+ // the capability is declared, and it caught it here.
167
+ capabilities: [],
168
+ maxBodyBytes: options.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES,
169
+ ...socket,
170
+ });
171
+ }
172
+ exports.agentCoreA2AHost = agentCoreA2AHost;
173
+ //# sourceMappingURL=agentCoreA2A.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentCoreA2A.js","sourceRoot":"","sources":["../../../src/adapters/hosting/agentCoreA2A.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;;;AAIH,2DAAiF;AACjF,6CAKsB;AAEtB,sFAAsF;AACzE,QAAA,0BAA0B,GAAG,IAAI,CAAC;AAE/C,wCAAwC;AAC3B,QAAA,yBAAyB,GAAG,GAAG,CAAC;AAE7C,oDAAoD;AACvC,QAAA,mBAAmB,GAAG,OAAO,CAAC;AAE3C,oDAAoD;AACvC,QAAA,wBAAwB,GAAG,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AE;YACJ,GAAG,QAAQ;YACX,yEAAyE;YACzE,uEAAuE;YACvE,WAAW,CAAC,KAAK;gBACf,MAAM,IAAI,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;gBACzC,MAAM,SAAS,GAAG,IAAA,yBAAW,EAAC,KAAK,EAAE,gCAAwB,CAAC,CAAC;gBAC/D,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;YACpE,CAAC;SACF;QACD,UAAU,EAAE,iCAAyB;QACrC,UAAU,EAAE,2BAAmB;QAC/B,wEAAwE;QACxE,uEAAuE;QACvE,uEAAuE;QACvE,wEAAwE;QACxE,oEAAoE;QACpE,4EAA4E;QAC5E,qDAAqD;QACrD,YAAY,EAAE,EAAE;QAChB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,sBAAsB;QAC5D,GAAG,MAAM;KACV,CAAC,CAAC;AACL,CAAC;AAnED,4CAmEC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * adapters/hosting/a2aWire — the A2A protocol, as an `HttpWire`.
3
+ *
4
+ * ── What this is ─────────────────────────────────────────────────────────────
5
+ * **A2A** (agent-to-agent) is an open protocol for one agent calling another:
6
+ * JSON-RPC 2.0 over HTTP, a `message/send` method carrying text parts, a result
7
+ * carrying artifacts, and a discovery document — the **agent card** — that says
8
+ * what the agent is and what it can do. It is nobody's product; several
9
+ * runtimes speak it, so it lives here on its own and the runtimes that host it
10
+ * configure this rather than reimplement it.
11
+ *
12
+ * ── The subset, stated plainly ───────────────────────────────────────────────
13
+ * One method: `message/send`, text parts only. Deliberately NOT carried:
14
+ * `message/stream` and the rest of the task lifecycle (`tasks/get`,
15
+ * `tasks/cancel`, push notifications), non-text parts, and multi-turn task
16
+ * state. An agent card built here therefore declares `streaming: false` by
17
+ * default — advertising a capability this wire cannot honour is how a caller
18
+ * finds out by hanging.
19
+ *
20
+ * ── Why it fits `httpHost` without changing it ───────────────────────────────
21
+ * JSON-RPC's one hard requirement on a reply is that it ECHOES the request's
22
+ * `id`. That is possible here only because `HttpWire`'s body methods receive
23
+ * the request that produced them — a seam added for a different protocol
24
+ * entirely, and the reason this one needed no new machinery.
25
+ *
26
+ * @example A2A on paths of your own choosing
27
+ * httpHost({
28
+ * name: 'myA2AHost',
29
+ * wire: a2aWire({ card: { name: 'triage', description: '…', version: '1.0.0' } }),
30
+ * invokePath: '/',
31
+ * healthPath: '/health',
32
+ * });
33
+ */
34
+ import type { HttpWire } from '../../hosting/httpHost.js';
35
+ /** The A2A protocol revision this wire's documents declare. */
36
+ export declare const A2A_PROTOCOL_VERSION = "0.3.0";
37
+ /** Where the A2A specification puts an agent's discovery document. */
38
+ export declare const A2A_AGENT_CARD_PATH = "/.well-known/agent-card.json";
39
+ /** The one method this wire carries. */
40
+ export declare const A2A_SEND_METHOD = "message/send";
41
+ /**
42
+ * JSON-RPC's own reserved codes, the two this wire can raise.
43
+ *
44
+ * `-32601` is "method not found" and `-32602` is "invalid params" — both from
45
+ * the JSON-RPC specification rather than from A2A or any runtime, which is why
46
+ * they are the only numbers this neutral file knows. A runtime's own error
47
+ * codes belong to that runtime's adapter.
48
+ */
49
+ export declare const JSONRPC_METHOD_NOT_FOUND = -32601;
50
+ export declare const JSONRPC_INVALID_PARAMS = -32602;
51
+ export declare const JSONRPC_INTERNAL_ERROR = -32603;
52
+ /** One skill an agent card advertises. */
53
+ export interface A2ASkill {
54
+ readonly id: string;
55
+ readonly name: string;
56
+ readonly description: string;
57
+ readonly tags?: readonly string[];
58
+ }
59
+ /** The agent card this wire serves — what another agent reads to decide to call yours. */
60
+ export interface A2AAgentCard {
61
+ readonly name: string;
62
+ readonly description: string;
63
+ readonly version: string;
64
+ /** Where callers reach this agent. A runtime that mounts the agent behind its
65
+ * own URL fills this in; left out, the card simply omits it. */
66
+ readonly url?: string;
67
+ /** Default `false` — see the module note on why this wire does not claim it. */
68
+ readonly streaming?: boolean;
69
+ readonly defaultInputModes?: readonly string[];
70
+ readonly defaultOutputModes?: readonly string[];
71
+ readonly skills?: readonly A2ASkill[];
72
+ }
73
+ export interface A2AWireOptions {
74
+ /** The agent card. Required: A2A discovery is not optional in the protocol. */
75
+ readonly card: A2AAgentCard;
76
+ /** Body for the health probe. Default `{ status: 'ok' }`. */
77
+ readonly health?: unknown;
78
+ /**
79
+ * Map a refusal's stable code onto the numeric JSON-RPC code this deployment
80
+ * reports. Absent, everything that is not a malformed request is
81
+ * `-32603` (internal error) — the JSON-RPC catch-all.
82
+ *
83
+ * A runtime with its own published code table passes one; that table is the
84
+ * runtime's, and this file does not carry anybody's.
85
+ */
86
+ readonly errorCodeFor?: (code: string | undefined) => number;
87
+ /** Name used in refusal messages. Default `'a2aWire'`. */
88
+ readonly name?: string;
89
+ }
90
+ type JsonObject = Readonly<Record<string, unknown>>;
91
+ /**
92
+ * The text of one A2A message — every part concatenated, refusing what is not text.
93
+ *
94
+ * A non-text part is refused rather than skipped for the reason every dialect
95
+ * in this library refuses rather than skips: an answer produced from the parts
96
+ * that happened to be understood is a wrong answer delivered confidently.
97
+ */
98
+ export declare function readA2AMessageText(message: unknown): string;
99
+ /**
100
+ * The agent card document, as the protocol prints it.
101
+ *
102
+ * Exported on its own because a deployment often has to serve the card from
103
+ * somewhere this wire does not own — a CDN, a route in a framework, a runtime's
104
+ * own discovery API — and the document should be built once, here, rather than
105
+ * hand-copied into each of those places.
106
+ */
107
+ export declare function a2aAgentCardDocument(card: A2AAgentCard): JsonObject;
108
+ /** An `HttpWire` speaking A2A's `message/send`. */
109
+ export declare function a2aWire(options: A2AWireOptions): HttpWire;
110
+ export {};
@@ -0,0 +1,166 @@
1
+ /**
2
+ * adapters/hosting/a2aWire — the A2A protocol, as an `HttpWire`.
3
+ *
4
+ * ── What this is ─────────────────────────────────────────────────────────────
5
+ * **A2A** (agent-to-agent) is an open protocol for one agent calling another:
6
+ * JSON-RPC 2.0 over HTTP, a `message/send` method carrying text parts, a result
7
+ * carrying artifacts, and a discovery document — the **agent card** — that says
8
+ * what the agent is and what it can do. It is nobody's product; several
9
+ * runtimes speak it, so it lives here on its own and the runtimes that host it
10
+ * configure this rather than reimplement it.
11
+ *
12
+ * ── The subset, stated plainly ───────────────────────────────────────────────
13
+ * One method: `message/send`, text parts only. Deliberately NOT carried:
14
+ * `message/stream` and the rest of the task lifecycle (`tasks/get`,
15
+ * `tasks/cancel`, push notifications), non-text parts, and multi-turn task
16
+ * state. An agent card built here therefore declares `streaming: false` by
17
+ * default — advertising a capability this wire cannot honour is how a caller
18
+ * finds out by hanging.
19
+ *
20
+ * ── Why it fits `httpHost` without changing it ───────────────────────────────
21
+ * JSON-RPC's one hard requirement on a reply is that it ECHOES the request's
22
+ * `id`. That is possible here only because `HttpWire`'s body methods receive
23
+ * the request that produced them — a seam added for a different protocol
24
+ * entirely, and the reason this one needed no new machinery.
25
+ *
26
+ * @example A2A on paths of your own choosing
27
+ * httpHost({
28
+ * name: 'myA2AHost',
29
+ * wire: a2aWire({ card: { name: 'triage', description: '…', version: '1.0.0' } }),
30
+ * invokePath: '/',
31
+ * healthPath: '/health',
32
+ * });
33
+ */
34
+ import { WireRequestRefusal } from '../../hosting/errors.js';
35
+ /** The A2A protocol revision this wire's documents declare. */
36
+ export const A2A_PROTOCOL_VERSION = '0.3.0';
37
+ /** Where the A2A specification puts an agent's discovery document. */
38
+ export const A2A_AGENT_CARD_PATH = '/.well-known/agent-card.json';
39
+ /** The one method this wire carries. */
40
+ export const A2A_SEND_METHOD = 'message/send';
41
+ /**
42
+ * JSON-RPC's own reserved codes, the two this wire can raise.
43
+ *
44
+ * `-32601` is "method not found" and `-32602` is "invalid params" — both from
45
+ * the JSON-RPC specification rather than from A2A or any runtime, which is why
46
+ * they are the only numbers this neutral file knows. A runtime's own error
47
+ * codes belong to that runtime's adapter.
48
+ */
49
+ export const JSONRPC_METHOD_NOT_FOUND = -32601;
50
+ export const JSONRPC_INVALID_PARAMS = -32602;
51
+ export const JSONRPC_INTERNAL_ERROR = -32603;
52
+ function isRecord(value) {
53
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
54
+ }
55
+ /** The request's JSON-RPC id, echoed onto every reply. `null` is legal and distinct from absent. */
56
+ function requestId(facts) {
57
+ const id = facts?.body.id;
58
+ return typeof id === 'string' || typeof id === 'number' ? id : null;
59
+ }
60
+ /**
61
+ * The text of one A2A message — every part concatenated, refusing what is not text.
62
+ *
63
+ * A non-text part is refused rather than skipped for the reason every dialect
64
+ * in this library refuses rather than skips: an answer produced from the parts
65
+ * that happened to be understood is a wrong answer delivered confidently.
66
+ */
67
+ export function readA2AMessageText(message) {
68
+ if (!isRecord(message)) {
69
+ throw new WireRequestRefusal('invalid_params', 'params.message must be an object', 400);
70
+ }
71
+ const parts = message.parts;
72
+ if (!Array.isArray(parts) || parts.length === 0) {
73
+ throw new WireRequestRefusal('invalid_params', 'params.message.parts must be a non-empty array', 400);
74
+ }
75
+ const text = [];
76
+ for (const part of parts) {
77
+ if (!isRecord(part) || part.kind !== 'text' || typeof part.text !== 'string') {
78
+ const kind = isRecord(part) && typeof part.kind === 'string' ? part.kind : 'unknown';
79
+ throw new WireRequestRefusal('unsupported_part', `this agent carries text parts only; '${kind}' parts are not supported`, 400);
80
+ }
81
+ text.push(part.text);
82
+ }
83
+ return text.join('');
84
+ }
85
+ /**
86
+ * The agent card document, as the protocol prints it.
87
+ *
88
+ * Exported on its own because a deployment often has to serve the card from
89
+ * somewhere this wire does not own — a CDN, a route in a framework, a runtime's
90
+ * own discovery API — and the document should be built once, here, rather than
91
+ * hand-copied into each of those places.
92
+ */
93
+ export function a2aAgentCardDocument(card) {
94
+ return {
95
+ name: card.name,
96
+ description: card.description,
97
+ version: card.version,
98
+ ...(card.url !== undefined && { url: card.url }),
99
+ protocolVersion: A2A_PROTOCOL_VERSION,
100
+ preferredTransport: 'JSONRPC',
101
+ capabilities: { streaming: card.streaming === true },
102
+ defaultInputModes: card.defaultInputModes ?? ['text'],
103
+ defaultOutputModes: card.defaultOutputModes ?? ['text'],
104
+ skills: (card.skills ?? []).map((s) => ({
105
+ id: s.id,
106
+ name: s.name,
107
+ description: s.description,
108
+ tags: s.tags ?? [],
109
+ })),
110
+ };
111
+ }
112
+ /** An `HttpWire` speaking A2A's `message/send`. */
113
+ export function a2aWire(options) {
114
+ const health = options.health ?? { status: 'ok' };
115
+ const name = options.name ?? 'a2aWire';
116
+ const codeFor = options.errorCodeFor ?? (() => JSONRPC_INTERNAL_ERROR);
117
+ const envelope = (facts, body) => ({
118
+ jsonrpc: '2.0',
119
+ id: requestId(facts),
120
+ ...body,
121
+ });
122
+ return {
123
+ readRequest(facts) {
124
+ const { body } = facts;
125
+ if (body.jsonrpc !== '2.0') {
126
+ throw new WireRequestRefusal('invalid_request', `${name}: every request must carry "jsonrpc": "2.0"`, 400);
127
+ }
128
+ if (body.method !== A2A_SEND_METHOD) {
129
+ // Named rather than ignored: a caller using a method this agent does
130
+ // not implement learns which one it does, instead of receiving an
131
+ // empty answer to a question that was never asked.
132
+ throw new WireRequestRefusal('method_not_found', `${name}: only '${A2A_SEND_METHOD}' is implemented; received '${String(body.method)}'`, 404);
133
+ }
134
+ const params = isRecord(body.params) ? body.params : undefined;
135
+ const input = readA2AMessageText(params?.message);
136
+ if (input.trim() === '') {
137
+ throw new WireRequestRefusal('invalid_params', `${name}: message text must not be empty`, 400);
138
+ }
139
+ // A2A carries no session of its own — the transport hosting it does, and
140
+ // the runtime adapter reads it from wherever that transport puts it.
141
+ return { input };
142
+ },
143
+ health: () => health,
144
+ output: (output, facts) => envelope(facts, {
145
+ result: {
146
+ artifacts: [
147
+ {
148
+ artifactId: String(facts?.body.id ?? 'artifact'),
149
+ name: 'agent_response',
150
+ parts: [{ kind: 'text', text: output }],
151
+ },
152
+ ],
153
+ },
154
+ }),
155
+ chunk: (text) => ({ kind: 'text', text }),
156
+ failure: (message, code, facts, origin) => envelope(facts, {
157
+ error: {
158
+ code: codeFor(code),
159
+ // A thrown exception's words are the author's note to their own logs.
160
+ // A refusal this library authored was written to be read.
161
+ message: origin === 'threw' ? 'The agent could not complete this request.' : message,
162
+ },
163
+ }),
164
+ };
165
+ }
166
+ //# sourceMappingURL=a2aWire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"a2aWire.js","sourceRoot":"","sources":["../../../../src/adapters/hosting/a2aWire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,+DAA+D;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;AAE5C,sEAAsE;AACtE,MAAM,CAAC,MAAM,mBAAmB,GAAG,8BAA8B,CAAC;AAElE,wCAAwC;AACxC,MAAM,CAAC,MAAM,eAAe,GAAG,cAAc,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAK,CAAC;AAC/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAK,CAAC;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAK,CAAC;AA6C7C,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,oGAAoG;AACpG,SAAS,SAAS,CAAC,KAAmC;IACpD,MAAM,EAAE,GAAG,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;IAC1B,OAAO,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC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