agentfootprint 9.66.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.
Files changed (36) hide show
  1. package/dist/adapters/hosting/a2aWire.js +172 -0
  2. package/dist/adapters/hosting/a2aWire.js.map +1 -0
  3. package/dist/adapters/hosting/agentCoreA2A.js +173 -0
  4. package/dist/adapters/hosting/agentCoreA2A.js.map +1 -0
  5. package/dist/adapters/mcp/agentcore.js +156 -0
  6. package/dist/adapters/mcp/agentcore.js.map +1 -0
  7. package/dist/esm/adapters/hosting/a2aWire.d.ts +110 -0
  8. package/dist/esm/adapters/hosting/a2aWire.js +166 -0
  9. package/dist/esm/adapters/hosting/a2aWire.js.map +1 -0
  10. package/dist/esm/adapters/hosting/agentCoreA2A.d.ts +95 -0
  11. package/dist/esm/adapters/hosting/agentCoreA2A.js +168 -0
  12. package/dist/esm/adapters/hosting/agentCoreA2A.js.map +1 -0
  13. package/dist/esm/adapters/mcp/agentcore.d.ts +143 -0
  14. package/dist/esm/adapters/mcp/agentcore.js +149 -0
  15. package/dist/esm/adapters/mcp/agentcore.js.map +1 -0
  16. package/dist/esm/hosting-providers.d.ts +19 -0
  17. package/dist/esm/hosting-providers.js +19 -0
  18. package/dist/esm/hosting-providers.js.map +1 -1
  19. package/dist/esm/tool-providers/index.d.ts +2 -0
  20. package/dist/esm/tool-providers/index.js +5 -0
  21. package/dist/esm/tool-providers/index.js.map +1 -1
  22. package/dist/hosting-providers.js +35 -1
  23. package/dist/hosting-providers.js.map +1 -1
  24. package/dist/tool-providers/index.js +13 -1
  25. package/dist/tool-providers/index.js.map +1 -1
  26. package/dist/types/adapters/hosting/a2aWire.d.ts +111 -0
  27. package/dist/types/adapters/hosting/a2aWire.d.ts.map +1 -0
  28. package/dist/types/adapters/hosting/agentCoreA2A.d.ts +96 -0
  29. package/dist/types/adapters/hosting/agentCoreA2A.d.ts.map +1 -0
  30. package/dist/types/adapters/mcp/agentcore.d.ts +144 -0
  31. package/dist/types/adapters/mcp/agentcore.d.ts.map +1 -0
  32. package/dist/types/hosting-providers.d.ts +19 -0
  33. package/dist/types/hosting-providers.d.ts.map +1 -1
  34. package/dist/types/tool-providers/index.d.ts +2 -0
  35. package/dist/types/tool-providers/index.d.ts.map +1 -1
  36. package/package.json +1 -1
@@ -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,IA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AM,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"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * adapters/hosting/agentCoreA2A — an agentfootprint agent as an AWS Bedrock
3
+ * **AgentCore A2A** server, callable by other agents.
4
+ *
5
+ * ── The split, again ─────────────────────────────────────────────────────────
6
+ * Two different things are needed, and only one is Amazon's:
7
+ *
8
+ * • The **A2A protocol** — JSON-RPC 2.0, `message/send`, artifacts, the agent
9
+ * card. An open protocol several runtimes speak, so it lives in
10
+ * `a2aWire.ts` with no vendor in it.
11
+ * • The **container contract** — port 9000 (not 8080, and not 8000: each
12
+ * protocol gets its own), the agent mounted at `/`, `GET /ping` answering
13
+ * `{"status":"Healthy"}`, the session id arriving in
14
+ * `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id`, and a table of JSON-RPC
15
+ * error codes that are this runtime's exceptions rather than A2A's. That
16
+ * IS Amazon's, and it is what this file supplies.
17
+ *
18
+ * ── One deviation you must know about ────────────────────────────────────────
19
+ * The A2A specification delivers JSON-RPC errors over HTTP 200. **AgentCore
20
+ * does not** — it returns the real status code (409, 404, …) with the JSON-RPC
21
+ * error body. That is a fact about the platform in front of your container, so
22
+ * a CLIENT must parse the error body even on a non-2xx response; see
23
+ * `agentCoreA2AErrorCode` for the table this host mirrors on the way out.
24
+ *
25
+ * ── What is NOT provided ─────────────────────────────────────────────────────
26
+ * `message/stream` and the task lifecycle. The agent card this host serves
27
+ * therefore declares `streaming: false` unless you overrule it, because a card
28
+ * that advertises streaming to a wire that cannot stream is a caller left
29
+ * waiting. AWS's own sample card says `true`; ours says what is true of ours.
30
+ *
31
+ * @example An agent other agents can call
32
+ * import { agentCoreA2AHost, memorySessions, standingAgent } from 'agentfootprint/hosting';
33
+ *
34
+ * const handle = await standingAgent({
35
+ * agent,
36
+ * sessions: memorySessions(),
37
+ * host: agentCoreA2AHost({
38
+ * card: { name: 'triage', description: 'Triages SAN alerts.', version: '1.0.0' },
39
+ * }),
40
+ * });
41
+ * process.on('SIGTERM', () => void handle.close());
42
+ */
43
+ /// <reference types="node" />
44
+ import type { IncomingMessage, Server, ServerResponse } from 'node:http';
45
+ import { type HttpHost } from '../../hosting/httpHost.js';
46
+ import { type A2AAgentCard } from './a2aWire.js';
47
+ /** The port an AgentCore A2A server is expected on — its own, not HTTP's or MCP's. */
48
+ export declare const DEFAULT_AGENTCORE_A2A_PORT = 9000;
49
+ /** A2A mounts the agent at the root. */
50
+ export declare const AGENTCORE_A2A_INVOKE_PATH = "/";
51
+ /** The runtime's health path for every protocol. */
52
+ export declare const AGENTCORE_PING_PATH = "/ping";
53
+ /** Where the platform puts the caller's session. */
54
+ export declare const AGENTCORE_SESSION_HEADER = "X-Amzn-Bedrock-AgentCore-Runtime-Session-Id";
55
+ /**
56
+ * AgentCore's own JSON-RPC error codes, mapped from this library's refusal codes.
57
+ *
58
+ * These numbers are the RUNTIME's exception table, not A2A's: `-32051`
59
+ * ResourceNotFound, `-32052` Validation, `-32053` Throttling and
60
+ * ServiceQuotaExceeded, `-32054` Conflict and RetryableConflict, `-32055`
61
+ * RuntimeClientError, `-32603` anything else. A client reads them to decide
62
+ * whether to retry — `-32054` with "Session operation in progress" is the one
63
+ * that must be retried with backoff, and A2A clients do not do that on their
64
+ * own.
65
+ *
66
+ * Exported so a client built against this host can share one table with it
67
+ * rather than keep a second copy that drifts.
68
+ */
69
+ export declare function agentCoreA2AErrorCode(code: string | undefined): number;
70
+ export interface AgentCoreA2AHostOptions {
71
+ /** The agent card other agents read. Required — discovery is not optional in A2A. */
72
+ readonly card: A2AAgentCard;
73
+ /** Port to bind. Default {@link DEFAULT_AGENTCORE_A2A_PORT}. Pass `0` in tests. */
74
+ readonly port?: number;
75
+ /** Interface to bind. Default `'0.0.0.0'` — a container's door must be reachable. */
76
+ readonly hostname?: string;
77
+ /** Ceiling on a request body. Default one mebibyte. */
78
+ readonly maxBodyBytes?: number;
79
+ /** A `node:http` server you own. Refused together with `port`/`hostname`. */
80
+ readonly server?: Server;
81
+ /**
82
+ * Answer a path this host does not own. The agent card is served BEFORE this
83
+ * runs, and everything else falls through to you unchanged — so supplying one
84
+ * costs you nothing the card was not already going to take.
85
+ */
86
+ readonly onUnhandled?: (req: IncomingMessage, res: ServerResponse) => void;
87
+ }
88
+ /**
89
+ * An {@link HttpHost} serving AgentCore's A2A container contract.
90
+ *
91
+ * `httpHost` keeps its own promises — draining, aborting on disconnect, failing
92
+ * a handler that throws or answers nothing — and this supplies the protocol,
93
+ * the paths, the port, the session header and the error table.
94
+ */
95
+ export declare function agentCoreA2AHost(options: AgentCoreA2AHostOptions): HttpHost;
@@ -0,0 +1,168 @@
1
+ /**
2
+ * adapters/hosting/agentCoreA2A — an agentfootprint agent as an AWS Bedrock
3
+ * **AgentCore A2A** server, callable by other agents.
4
+ *
5
+ * ── The split, again ─────────────────────────────────────────────────────────
6
+ * Two different things are needed, and only one is Amazon's:
7
+ *
8
+ * • The **A2A protocol** — JSON-RPC 2.0, `message/send`, artifacts, the agent
9
+ * card. An open protocol several runtimes speak, so it lives in
10
+ * `a2aWire.ts` with no vendor in it.
11
+ * • The **container contract** — port 9000 (not 8080, and not 8000: each
12
+ * protocol gets its own), the agent mounted at `/`, `GET /ping` answering
13
+ * `{"status":"Healthy"}`, the session id arriving in
14
+ * `X-Amzn-Bedrock-AgentCore-Runtime-Session-Id`, and a table of JSON-RPC
15
+ * error codes that are this runtime's exceptions rather than A2A's. That
16
+ * IS Amazon's, and it is what this file supplies.
17
+ *
18
+ * ── One deviation you must know about ────────────────────────────────────────
19
+ * The A2A specification delivers JSON-RPC errors over HTTP 200. **AgentCore
20
+ * does not** — it returns the real status code (409, 404, …) with the JSON-RPC
21
+ * error body. That is a fact about the platform in front of your container, so
22
+ * a CLIENT must parse the error body even on a non-2xx response; see
23
+ * `agentCoreA2AErrorCode` for the table this host mirrors on the way out.
24
+ *
25
+ * ── What is NOT provided ─────────────────────────────────────────────────────
26
+ * `message/stream` and the task lifecycle. The agent card this host serves
27
+ * therefore declares `streaming: false` unless you overrule it, because a card
28
+ * that advertises streaming to a wire that cannot stream is a caller left
29
+ * waiting. AWS's own sample card says `true`; ours says what is true of ours.
30
+ *
31
+ * @example An agent other agents can call
32
+ * import { agentCoreA2AHost, memorySessions, standingAgent } from 'agentfootprint/hosting';
33
+ *
34
+ * const handle = await standingAgent({
35
+ * agent,
36
+ * sessions: memorySessions(),
37
+ * host: agentCoreA2AHost({
38
+ * card: { name: 'triage', description: 'Triages SAN alerts.', version: '1.0.0' },
39
+ * }),
40
+ * });
41
+ * process.on('SIGTERM', () => void handle.close());
42
+ */
43
+ import { headerValue, httpHost } from '../../hosting/httpHost.js';
44
+ import { a2aAgentCardDocument, a2aWire, A2A_AGENT_CARD_PATH, } from './a2aWire.js';
45
+ /** The port an AgentCore A2A server is expected on — its own, not HTTP's or MCP's. */
46
+ export const DEFAULT_AGENTCORE_A2A_PORT = 9000;
47
+ /** A2A mounts the agent at the root. */
48
+ export const AGENTCORE_A2A_INVOKE_PATH = '/';
49
+ /** The runtime's health path for every protocol. */
50
+ export const AGENTCORE_PING_PATH = '/ping';
51
+ /** Where the platform puts the caller's session. */
52
+ export const AGENTCORE_SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
53
+ /**
54
+ * AgentCore's own JSON-RPC error codes, mapped from this library's refusal codes.
55
+ *
56
+ * These numbers are the RUNTIME's exception table, not A2A's: `-32051`
57
+ * ResourceNotFound, `-32052` Validation, `-32053` Throttling and
58
+ * ServiceQuotaExceeded, `-32054` Conflict and RetryableConflict, `-32055`
59
+ * RuntimeClientError, `-32603` anything else. A client reads them to decide
60
+ * whether to retry — `-32054` with "Session operation in progress" is the one
61
+ * that must be retried with backoff, and A2A clients do not do that on their
62
+ * own.
63
+ *
64
+ * Exported so a client built against this host can share one table with it
65
+ * rather than keep a second copy that drifts.
66
+ */
67
+ export function agentCoreA2AErrorCode(code) {
68
+ switch (code) {
69
+ case 'ERR_SESSION_NOT_FOUND':
70
+ case 'ERR_ARTIFACT_NOT_FOUND':
71
+ return -32051;
72
+ case 'ERR_INVALID_WIRE_OP':
73
+ case 'ERR_DECISION_REQUIRED':
74
+ case 'ERR_ARTIFACT_SESSION_REQUIRED':
75
+ case 'invalid_request':
76
+ case 'invalid_params':
77
+ case 'unsupported_part':
78
+ return -32052;
79
+ case 'ERR_ADMISSION_REFUSED':
80
+ case 'ERR_REQUEST_TOO_LARGE':
81
+ return -32053;
82
+ case 'ERR_CONCURRENT_RUN':
83
+ case 'ERR_HOST_CLOSED':
84
+ case 'ERR_AWAITING_DECISION':
85
+ case 'ERR_PAUSE_NOT_CARRIED':
86
+ return -32054;
87
+ case 'method_not_found':
88
+ // JSON-RPC's own "method not found" is -32601, but this runtime reports a
89
+ // route it cannot resolve as ResourceNotFound. The platform's table wins
90
+ // inside the platform's container.
91
+ return -32051;
92
+ default:
93
+ return -32603;
94
+ }
95
+ }
96
+ const DEFAULT_MAX_BODY_BYTES = 1_048_576;
97
+ /**
98
+ * An {@link HttpHost} serving AgentCore's A2A container contract.
99
+ *
100
+ * `httpHost` keeps its own promises — draining, aborting on disconnect, failing
101
+ * a handler that throws or answers nothing — and this supplies the protocol,
102
+ * the paths, the port, the session header and the error table.
103
+ */
104
+ export function agentCoreA2AHost(options) {
105
+ const { server, onUnhandled, hostname, card } = options;
106
+ const cardDocument = JSON.stringify(a2aAgentCardDocument(card));
107
+ /** The discovery document, served before anything falls through to the caller. */
108
+ const serveCard = (req, res) => {
109
+ const path = (req.url ?? '').split('?')[0];
110
+ if (req.method === 'GET' && path === A2A_AGENT_CARD_PATH) {
111
+ res.writeHead(200, {
112
+ 'content-type': 'application/json',
113
+ 'content-length': Buffer.byteLength(cardDocument),
114
+ });
115
+ res.end(cardDocument);
116
+ return;
117
+ }
118
+ // Not the card: the caller's own routes, if they have any. Chaining rather
119
+ // than consuming the slot — an adapter that took `onUnhandled` for itself
120
+ // would silently remove a seam the host documents as the consumer's.
121
+ if (onUnhandled) {
122
+ onUnhandled(req, res);
123
+ return;
124
+ }
125
+ res.writeHead(404, { 'content-type': 'application/json' });
126
+ res.end(JSON.stringify({ error: `no route for ${req.method ?? '?'} ${path}` }));
127
+ };
128
+ const socket = server
129
+ ? { server }
130
+ : {
131
+ port: options.port ?? DEFAULT_AGENTCORE_A2A_PORT,
132
+ ...(hostname === undefined ? {} : { hostname }),
133
+ onUnhandled: serveCard,
134
+ };
135
+ const protocol = a2aWire({
136
+ card,
137
+ // The runtime's health contract, not A2A's — A2A has no /ping at all.
138
+ health: { status: 'Healthy' },
139
+ errorCodeFor: agentCoreA2AErrorCode,
140
+ name: 'agentCoreA2AHost',
141
+ });
142
+ return httpHost({
143
+ name: 'agentCoreA2AHost',
144
+ wire: {
145
+ ...protocol,
146
+ // The one thing the protocol does not carry and the platform does: which
147
+ // conversation this call belongs to, in a header of the runtime's own.
148
+ readRequest(facts) {
149
+ const base = protocol.readRequest(facts);
150
+ const sessionId = headerValue(facts, AGENTCORE_SESSION_HEADER);
151
+ return { ...base, ...(sessionId !== undefined && { sessionId }) };
152
+ },
153
+ },
154
+ invokePath: AGENTCORE_A2A_INVOKE_PATH,
155
+ healthPath: AGENTCORE_PING_PATH,
156
+ // NOT `['streaming']`, which is this file's default. `message/send` has
157
+ // nowhere to put a chunk: a caller gets one JSON-RPC reply and nothing
158
+ // before it. Declaring streaming anyway would make `requireCapability`
159
+ // pass for a host that cannot honour it, and would contradict the agent
160
+ // card, which says `streaming: false` for the same reason. The host
161
+ // conformance suite catches exactly this — it asserts chunks IF AND ONLY IF
162
+ // the capability is declared, and it caught it here.
163
+ capabilities: [],
164
+ maxBodyBytes: options.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES,
165
+ ...socket,
166
+ });
167
+ }
168
+ //# 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,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAiB,MAAM,2BAA2B,CAAC;AACjF,OAAO,EACL,oBAAoB,EACpB,OAAO,EACP,mBAAmB,GAEpB,MAAM,cAAc,CAAC;AAEtB,sFAAsF;AACtF,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAE/C,wCAAwC;AACxC,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C,oDAAoD;AACpD,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAE3C,oDAAoD;AACpD,MAAM,CAAC,MAAM,wBAAwB,GAAG,6CAA6C,CAAC;AAEtF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAwB;IAC5D,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AW,CAAC,KAAK,CAAC,CAAC;gBACzC,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,EAAE,wBAAwB,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,yBAAyB;QACrC,UAAU,EAAE,mBAAmB;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"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * adapters/mcp/agentcore — reaching an AWS Bedrock **AgentCore Gateway**.
3
+ *
4
+ * ── What lives here, and why it is one file ──────────────────────────────────
5
+ * A Gateway is an MCP server, and `mcpClient` + `gatewayTransport` already know
6
+ * how to talk to one of those. Neither knows — and neither should learn — the
7
+ * handful of facts that are AgentCore's alone: the hostname its endpoints take,
8
+ * the name of the tool that searches its catalogue, the header that groups a
9
+ * caller's requests into one policy session, and the service name a SigV4
10
+ * signature is computed against. Those four facts are this file, and this file
11
+ * is the only place in the library that holds them.
12
+ *
13
+ * `gatewayTransport` says of itself: *"Nothing here is vendor-specific."* That
14
+ * stays true precisely because this exists next to it.
15
+ *
16
+ * ── What it does NOT do ──────────────────────────────────────────────────────
17
+ * It does not manage a Gateway. Creating one, adding targets, attaching a
18
+ * policy engine, enabling semantic search — all control-plane operations on
19
+ * `bedrock-agentcore-control`, all things an operator does once with the
20
+ * console, the CLI or their IaC. This is the CLIENT side: an agent using a
21
+ * gateway somebody already stood up.
22
+ *
23
+ * @example An agent whose tools come from a Gateway
24
+ * import { mcpClient } from 'agentfootprint/providers';
25
+ * import { agentCoreGatewayTransport } from 'agentfootprint/providers';
26
+ * import { agentCoreIdentity } from 'agentfootprint/security';
27
+ *
28
+ * const gateway = await mcpClient({
29
+ * name: 'gateway',
30
+ * transport: agentCoreGatewayTransport({
31
+ * gatewayId: 'my-gateway-a1b2c3d4e5',
32
+ * region: 'us-east-1',
33
+ * credentials: agentCoreIdentity({ region: 'us-east-1' }),
34
+ * }),
35
+ * });
36
+ * const tools = await gateway.tools();
37
+ */
38
+ import { type FetchLike } from '../../lib/mcp/gatewayTransport.js';
39
+ import type { McpGatewayTransport } from '../../lib/mcp/types.js';
40
+ import type { CredentialProvider } from '../../identity/types.js';
41
+ import type { Tool } from '../../core/tools.js';
42
+ /**
43
+ * The Gateway's built-in semantic tool search, by its exact wire name.
44
+ *
45
+ * It is an ordinary MCP tool — `tools/call` with `{ query }` — that returns the
46
+ * catalogue entries closest to a natural-language description. It matters at
47
+ * the scale where listing every tool into a prompt stops being sensible.
48
+ *
49
+ * **It can only be enabled when the Gateway is CREATED**, never afterwards, so
50
+ * its absence from a catalogue is a fact about that gateway rather than a
51
+ * transient condition to retry.
52
+ */
53
+ export declare const AGENTCORE_GATEWAY_SEARCH_TOOL = "x_amz_bedrock_agentcore_search";
54
+ /**
55
+ * The header that groups a caller's requests into ONE policy session.
56
+ *
57
+ * AgentCore's temporal policies decide on SEQUENCES of actions — "not after
58
+ * three refunds", "only once this was approved" — and a sequence needs a
59
+ * boundary. This header is that boundary, and without it every request is its
60
+ * own history of one, which quietly makes every sequence rule unenforceable.
61
+ */
62
+ export declare const AGENTCORE_POLICY_SESSION_HEADER = "x-amzn-bedrock-agentcore-policy-session-id";
63
+ /** The service name a SigV4 signature for a Gateway is computed against. */
64
+ export declare const AGENTCORE_SIGV4_SERVICE = "bedrock-agentcore";
65
+ export interface AgentCoreGatewayUrlOptions {
66
+ /** The gateway's id, as the console and `CreateGateway`'s response give it. */
67
+ readonly gatewayId: string;
68
+ /** The region it lives in, e.g. `'us-east-1'`. */
69
+ readonly region: string;
70
+ }
71
+ /**
72
+ * The MCP endpoint of a Gateway.
73
+ *
74
+ * `https://{gatewayId}.gateway.bedrock-agentcore.{region}.amazonaws.com/mcp` —
75
+ * a shape nobody remembers correctly, which is the entire reason it is a
76
+ * function and not a line in a README.
77
+ */
78
+ export declare function agentCoreGatewayUrl(options: AgentCoreGatewayUrlOptions): string;
79
+ export interface AgentCoreGatewayTransportOptions extends AgentCoreGatewayUrlOptions {
80
+ /** Who vends the token. `agentCoreIdentity()` is the usual answer. */
81
+ readonly credentials: CredentialProvider;
82
+ /** The downstream service id your provider keys on. Default `'gateway'`. */
83
+ readonly service?: string;
84
+ /** OAuth scopes, when the provider uses them. */
85
+ readonly scopes?: readonly string[];
86
+ /** `machine` (default) or `user`, for a gateway that acts on someone's behalf. */
87
+ readonly mode?: 'machine' | 'user';
88
+ /**
89
+ * The policy session this caller's requests belong to — a string, or a
90
+ * function consulted PER REQUEST.
91
+ *
92
+ * **Prefer the function on any transport more than one person shares.** A
93
+ * fixed string on a shared transport merges every caller's action history
94
+ * into a single policy session, which is not a small mistake: it makes one
95
+ * person's earlier actions count against another person's rule. Passing
96
+ * `() => currentSessionId` keeps the boundary where it belongs, and returning
97
+ * `undefined` sends no header at all.
98
+ */
99
+ readonly policySessionId?: string | (() => string | undefined);
100
+ /** Extra static headers. **No secrets** — these live as long as the transport. */
101
+ readonly headers?: Readonly<Record<string, string>>;
102
+ /** Your own `fetch`, called underneath the per-request vending. */
103
+ readonly fetch?: FetchLike;
104
+ }
105
+ /**
106
+ * An MCP transport pointed at an AgentCore Gateway.
107
+ *
108
+ * A configuration of {@link gatewayTransport}: the endpoint built from your
109
+ * gateway's id and region, and — when you name one — the policy session header
110
+ * stamped on every request. Token vending, the once-and-dropped secrecy rule
111
+ * and the rotation behaviour are all the neutral transport's, unchanged.
112
+ */
113
+ export declare function agentCoreGatewayTransport(options: AgentCoreGatewayTransportOptions): McpGatewayTransport;
114
+ /**
115
+ * The Gateway's semantic search tool, if this gateway has one.
116
+ *
117
+ * Returns `undefined` rather than throwing, because absence is a legitimate and
118
+ * PERMANENT answer: semantic search is enabled when a Gateway is created and
119
+ * cannot be turned on afterwards, so there is nothing to retry.
120
+ *
121
+ * ── Why this finds the tool instead of calling it ────────────────────────────
122
+ * The obvious convenience would be `search(gateway, 'refund an order')`, and it
123
+ * is deliberately not here. Executing a tool needs a `ToolExecutionContext` —
124
+ * the call id, the iteration, the credential seam, the artifact store — and
125
+ * that object belongs to the agent loop. A helper would have to invent one,
126
+ * and a call made on an invented context is a call that appears in no trace:
127
+ * the model would be handed a shortlist nobody can later explain the origin of,
128
+ * which is the opposite of what this library is for.
129
+ *
130
+ * So the search tool is registered like any other tool, the model calls it when
131
+ * the catalogue is too large to reason about, and that call is an ordinary
132
+ * tool call in the trace — visible, attributable, and replayable.
133
+ *
134
+ * @example Give the model the catalogue's own search
135
+ * const tools = await gateway.tools();
136
+ * const search = gatewaySearchTool(tools);
137
+ * Agent.create({ provider, model })
138
+ * .tools(search ? [search] : tools) // search it, or list it
139
+ * .build();
140
+ */
141
+ export declare function gatewaySearchTool(tools: readonly Tool[]): Tool | undefined;
142
+ /** Whether this gateway's catalogue can be searched rather than listed. */
143
+ export declare function hasGatewaySearch(tools: readonly Tool[]): boolean;