agentfootprint 9.67.0 → 9.69.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 (41) hide show
  1. package/dist/adapters/browser/agentcore.js +203 -0
  2. package/dist/adapters/browser/agentcore.js.map +1 -0
  3. package/dist/adapters/hosting/a2aWire.js +172 -0
  4. package/dist/adapters/hosting/a2aWire.js.map +1 -0
  5. package/dist/adapters/hosting/agentCoreA2A.js +173 -0
  6. package/dist/adapters/hosting/agentCoreA2A.js.map +1 -0
  7. package/dist/adapters/types.js.map +1 -1
  8. package/dist/doors/providers.js +9 -3
  9. package/dist/doors/providers.js.map +1 -1
  10. package/dist/esm/adapters/browser/agentcore.d.ts +141 -0
  11. package/dist/esm/adapters/browser/agentcore.js +199 -0
  12. package/dist/esm/adapters/browser/agentcore.js.map +1 -0
  13. package/dist/esm/adapters/hosting/a2aWire.d.ts +110 -0
  14. package/dist/esm/adapters/hosting/a2aWire.js +166 -0
  15. package/dist/esm/adapters/hosting/a2aWire.js.map +1 -0
  16. package/dist/esm/adapters/hosting/agentCoreA2A.d.ts +95 -0
  17. package/dist/esm/adapters/hosting/agentCoreA2A.js +168 -0
  18. package/dist/esm/adapters/hosting/agentCoreA2A.js.map +1 -0
  19. package/dist/esm/adapters/types.d.ts +82 -0
  20. package/dist/esm/adapters/types.js.map +1 -1
  21. package/dist/esm/doors/providers.d.ts +1 -0
  22. package/dist/esm/doors/providers.js +4 -0
  23. package/dist/esm/doors/providers.js.map +1 -1
  24. package/dist/esm/hosting-providers.d.ts +19 -0
  25. package/dist/esm/hosting-providers.js +19 -0
  26. package/dist/esm/hosting-providers.js.map +1 -1
  27. package/dist/hosting-providers.js +35 -1
  28. package/dist/hosting-providers.js.map +1 -1
  29. package/dist/types/adapters/browser/agentcore.d.ts +142 -0
  30. package/dist/types/adapters/browser/agentcore.d.ts.map +1 -0
  31. package/dist/types/adapters/hosting/a2aWire.d.ts +111 -0
  32. package/dist/types/adapters/hosting/a2aWire.d.ts.map +1 -0
  33. package/dist/types/adapters/hosting/agentCoreA2A.d.ts +96 -0
  34. package/dist/types/adapters/hosting/agentCoreA2A.d.ts.map +1 -0
  35. package/dist/types/adapters/types.d.ts +82 -0
  36. package/dist/types/adapters/types.d.ts.map +1 -1
  37. package/dist/types/doors/providers.d.ts +1 -0
  38. package/dist/types/doors/providers.d.ts.map +1 -1
  39. package/dist/types/hosting-providers.d.ts +19 -0
  40. package/dist/types/hosting-providers.d.ts.map +1 -1
  41. package/package.json +1 -1
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ /**
3
+ * agentCoreBrowser — AWS Bedrock AgentCore **Browser** as a {@link BrowserRunner}.
4
+ *
5
+ * A managed Chrome in AWS's account that an agent can drive, a person can watch
6
+ * live, and — the part this adapter exists for — a person can TAKE OVER
7
+ * mid-session and hand back.
8
+ *
9
+ * ── Two channels, and only one of them is here ───────────────────────────────
10
+ * A browser session has two doors, and confusing them wastes a day:
11
+ *
12
+ * 1. **The automation stream** — a CDP WebSocket. Navigate, find an element,
13
+ * fill a form: everything page-shaped happens here, driven by Playwright
14
+ * or another CDP client. This adapter hands you
15
+ * {@link BrowserSession.automationEndpoint} and stays out of the way. It
16
+ * does not depend on Playwright and does not drive the page for you.
17
+ * 2. **`InvokeBrowser`** — the data-plane operation this adapter calls. It is
18
+ * OS-LEVEL input ABOVE the page: mouse, keyboard, screenshots. Its action
19
+ * union, read off the SDK rather than remembered, is exactly
20
+ * `mouseClick | mouseMove | mouseDrag | mouseScroll | keyType | keyPress |
21
+ * keyShortcut | screenshot`. **There is no navigate action**, and a reader
22
+ * expecting one is looking at the wrong door.
23
+ *
24
+ * ── The takeover ─────────────────────────────────────────────────────────────
25
+ * `UpdateBrowserStream` with `automationStreamUpdate.streamStatus` set to
26
+ * `DISABLED` stops the automation channel and leaves the live-view user in
27
+ * control; `ENABLED` gives it back. That is `handControlTo('person' | 'agent')`
28
+ * here, and it composes with this library's check-in: the agent pauses, a
29
+ * person finishes the login, the agent resumes on the page they left — and both
30
+ * handovers are ordinary events in the trace.
31
+ *
32
+ * ── How this talks to the SDK (the 9.4.0 law) ────────────────────────────────
33
+ * Through `client.send(new SomeCommand(input))`, never a method on the client —
34
+ * a bare `@aws-sdk/client-*` Client carries `send` and `destroy` and nothing
35
+ * else. Every command name and request shape below was read off a real install
36
+ * of `@aws-sdk/client-bedrock-agentcore` **3.1118.0**, including the action
37
+ * union above and `ScreenshotResult`'s `{ status, error?, data? }`.
38
+ *
39
+ * ── One documented contradiction, left as AWS wrote it ───────────────────────
40
+ * The devguide says a session defaults to 15 minutes; `StartBrowserSession`'s
41
+ * API reference says 3600 seconds. This adapter sends nothing unless you pass
42
+ * `sessionTimeoutSeconds`, so the default is whatever the service applies —
43
+ * rather than this file picking a side in somebody else's disagreement.
44
+ *
45
+ * Pattern: Adapter (GoF) + lazy peer-dep load — the SDK is required only when
46
+ * `start()` first runs, or never, if you inject `_client` / `_sdk`.
47
+ */
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.agentCoreBrowser = exports.AWS_SYSTEM_BROWSER = void 0;
50
+ const lazyRequire_js_1 = require("../../lib/lazyRequire.js");
51
+ /** AWS's managed browser. A custom `CreateBrowser` resource id goes here instead. */
52
+ exports.AWS_SYSTEM_BROWSER = 'aws.browser.v1';
53
+ const BUTTONS = { left: 'LEFT', middle: 'MIDDLE', right: 'RIGHT' };
54
+ function createBrowserClient(options) {
55
+ let mod;
56
+ if (options._sdk) {
57
+ mod = options._sdk;
58
+ }
59
+ else {
60
+ try {
61
+ mod = (0, lazyRequire_js_1.lazyRequire)('@aws-sdk/client-bedrock-agentcore');
62
+ }
63
+ catch {
64
+ throw new Error('agentCoreBrowser requires the `@aws-sdk/client-bedrock-agentcore` peer dependency.\n' +
65
+ ' Install: npm install @aws-sdk/client-bedrock-agentcore\n' +
66
+ ' Or pass `_client` for a pre-built or mock client.');
67
+ }
68
+ }
69
+ if (!mod.BedrockAgentCoreClient) {
70
+ throw new Error('agentCoreBrowser: `@aws-sdk/client-bedrock-agentcore` is installed but ' +
71
+ '`BedrockAgentCoreClient` was not found. Update the SDK.');
72
+ }
73
+ const sdk = new mod.BedrockAgentCoreClient({ ...(options.region && { region: options.region }) });
74
+ const send = async (Ctor, name, input) => {
75
+ if (!Ctor) {
76
+ throw new Error(`agentCoreBrowser: \`@aws-sdk/client-bedrock-agentcore\` is missing ${name}. ` +
77
+ 'Upgrade the SDK, or pass `_client` with your own mapping.');
78
+ }
79
+ return sdk.send(new Ctor(input));
80
+ };
81
+ return {
82
+ async startBrowserSession(input) {
83
+ return (await send(mod.StartBrowserSessionCommand, 'StartBrowserSessionCommand', input));
84
+ },
85
+ async invokeBrowser(input) {
86
+ return (await send(mod.InvokeBrowserCommand, 'InvokeBrowserCommand', input));
87
+ },
88
+ async updateBrowserStream(input) {
89
+ await send(mod.UpdateBrowserStreamCommand, 'UpdateBrowserStreamCommand', input);
90
+ },
91
+ async stopBrowserSession(input) {
92
+ await send(mod.StopBrowserSessionCommand, 'StopBrowserSessionCommand', input);
93
+ },
94
+ };
95
+ }
96
+ /**
97
+ * Build a {@link BrowserRunner} backed by AgentCore Browser.
98
+ *
99
+ * @example A session, a person taking over, and the agent resuming
100
+ * const browser = agentCoreBrowser({ region: 'us-east-1' });
101
+ * const session = await browser.start({ key: toolSessionKey(ctx, 'run') });
102
+ *
103
+ * // Page work goes over CDP, not through this adapter:
104
+ * // const page = await chromium.connectOverCDP(session.automationEndpoint!)
105
+ *
106
+ * await session.handControlTo?.('person'); // they finish the login
107
+ * await session.handControlTo?.('agent'); // and the agent carries on
108
+ * await session.stop();
109
+ */
110
+ function agentCoreBrowser(options = {}) {
111
+ const browserIdentifier = options.browserIdentifier ?? exports.AWS_SYSTEM_BROWSER;
112
+ let client;
113
+ const getClient = () => {
114
+ client ??= options._client ?? createBrowserClient(options);
115
+ return client;
116
+ };
117
+ return {
118
+ id: options.id ?? 'agentcore-browser',
119
+ async start(req) {
120
+ const c = getClient();
121
+ const started = await c.startBrowserSession({
122
+ browserIdentifier,
123
+ name: req.key,
124
+ ...(options.sessionTimeoutSeconds !== undefined && {
125
+ sessionTimeoutSeconds: options.sessionTimeoutSeconds,
126
+ }),
127
+ ...(options.viewport !== undefined && { viewPort: options.viewport }),
128
+ });
129
+ const sessionId = started.sessionId;
130
+ if (!sessionId) {
131
+ throw new Error('agentCoreBrowser: StartBrowserSession returned no sessionId, so there is no session ' +
132
+ 'to drive. Check the browser identifier and the execution role.');
133
+ }
134
+ const act = async (action) => {
135
+ const answer = await c.invokeBrowser({ browserIdentifier, sessionId, action });
136
+ return answer.result;
137
+ };
138
+ const automationEndpoint = started.streams?.automationStream?.streamEndpoint;
139
+ const liveViewEndpoint = started.streams?.liveViewStream?.streamEndpoint;
140
+ const session = {
141
+ id: sessionId,
142
+ ...(automationEndpoint !== undefined && { automationEndpoint }),
143
+ ...(liveViewEndpoint !== undefined && { liveViewEndpoint }),
144
+ async click({ x, y, button, clicks }) {
145
+ await act({
146
+ mouseClick: {
147
+ x,
148
+ y,
149
+ ...(button !== undefined && { button: BUTTONS[button] }),
150
+ ...(clicks !== undefined && { clickCount: clicks }),
151
+ },
152
+ });
153
+ },
154
+ async type(text) {
155
+ await act({ keyType: { text } });
156
+ },
157
+ async press({ key, times }) {
158
+ await act({ keyPress: { key, ...(times !== undefined && { presses: times }) } });
159
+ },
160
+ async screenshot() {
161
+ const result = await act({ screenshot: { format: 'PNG' } });
162
+ const shot = result?.screenshot;
163
+ if (!shot?.data) {
164
+ // The result member carries its own status and error, so a failed
165
+ // screenshot says what the service said rather than answering with
166
+ // an empty image that reads as a blank page.
167
+ throw new Error(`agentCoreBrowser: the screenshot did not produce image data` +
168
+ `${shot?.status ? ` (status ${shot.status})` : ''}` +
169
+ `${shot?.error ? `: ${shot.error}` : '.'}`);
170
+ }
171
+ return { data: shot.data, format: 'png' };
172
+ },
173
+ async handControlTo(driver) {
174
+ // The person takes over by DISABLING automation: the live-view user
175
+ // is already connected, and stopping the automation stream is what
176
+ // lets their input through.
177
+ await c.updateBrowserStream({
178
+ browserIdentifier,
179
+ sessionId,
180
+ streamUpdate: {
181
+ automationStreamUpdate: {
182
+ streamStatus: driver === 'person' ? 'DISABLED' : 'ENABLED',
183
+ },
184
+ },
185
+ });
186
+ },
187
+ async stop() {
188
+ try {
189
+ await c.stopBrowserSession({ browserIdentifier, sessionId });
190
+ }
191
+ catch {
192
+ // A managed session reaped by its own idle timeout is the ordinary
193
+ // case, and stopping one that is already gone is a no-op — the port
194
+ // says so, and a throw here would fail a teardown that succeeded.
195
+ }
196
+ },
197
+ };
198
+ return session;
199
+ },
200
+ };
201
+ }
202
+ exports.agentCoreBrowser = agentCoreBrowser;
203
+ //# sourceMappingURL=agentcore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentcore.js","sourceRoot":"","sources":["../../../src/adapters/browser/agentcore.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;;AAGH,6DAAuD;AAEvD,qFAAqF;AACxE,QAAA,kBAAkB,GAAG,gBAAgB,CAAC;AAkEnD,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAW,CAAC;AAE5E,SAAS,mBAAmB,CAAC,OAAgC;IAC3D,IAAI,GAAqC,CAAC;IAC1C,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,IAAI,CAAC;YACH,GAAG,GAAG,IAAA,4BAAW,EAAmC,mCAAmC,CAAC,CAAC;QAC3F,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CACb,sFAAsF;gBACpF,6DAA6D;gBAC7D,qDAAqD,CACxD,CAAC;QACJ,CAAC;IACH,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,sBAAsB,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AC7C,MAAM,IAAI,KAAK,CACb,6DAA6D;4BAC3D,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;4BACnD,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAC7C,CAAC;oBACJ,CAAC;oBACD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;gBAC5C,CAAC;gBAED,KAAK,CAAC,aAAa,CAAC,MAAqB;oBACvC,oEAAoE;oBACpE,mEAAmE;oBACnE,4BAA4B;oBAC5B,MAAM,CAAC,CAAC,mBAAmB,CAAC;wBAC1B,iBAAiB;wBACjB,SAAS;wBACT,YAAY,EAAE;4BACZ,sBAAsB,EAAE;gCACtB,YAAY,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;6BAC3D;yBACF;qBACF,CAAC,CAAC;gBACL,CAAC;gBAED,KAAK,CAAC,IAAI;oBACR,IAAI,CAAC;wBACH,MAAM,CAAC,CAAC,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,SAAS,EAAE,CAAC,CAAC;oBAC/D,CAAC;oBAAC,MAAM,CAAC;wBACP,mEAAmE;wBACnE,oEAAoE;wBACpE,kEAAkE;oBACpE,CAAC;gBACH,CAAC;aACF,CAAC;YACF,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC;AA5GD,4CA4GC"}
@@ -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,KAAK,CAAC;AAClC,QAAA,sBAAsB,GAAG,CAAC,KAAK,CAAC;AAChC,QAAA,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,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ACT;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,6CAA6C,CAAC;AAEtF;;;;;;;;;;;;;GAaG;AACH,SAAgB,qBAAqB,CAAC,IAAwB;IAC5D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,uBAAuB,CAAC;QAC7B,KAAK,wBAAwB;YAC3B,OAAO,CAAC,KAAK,CAAC;QAChB,KAAK,qBAAqB,CAAC;QAC3B,KAAK,uBAAuB,CAAC;QAC7B,KAAK,+BAA+B,CAAC;QACrC,KAAK,iBAAiB,CAAC;QACvB,KAAK,gBAAgB,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C,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"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAsHH;;;;GAIG;AACU,QAAA,2BAA2B,GAAwB,MAAM,CAAC,MAAM,CAAC;IAC5E,MAAM;IACN,WAAW;CACZ,CAAC,CAAC;AAqsBH;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,OAAsC,EACtC,UAAgC;IAEhC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,UAAU,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;AACxD,CAAC;AAPD,wCAOC;AAqDD;;;;;;;;;GASG;AACU,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AAgGpD;uDACuD;AACvD,SAAgB,kBAAkB,CAChC,OAAoB;IAEpB,OAAO,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU,CAAC;AACnD,CAAC;AAJD,gDAIC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAsHH;;;;GAIG;AACU,QAAA,2BAA2B,GAAwB,MAAM,CAAC,MAAM,CAAC;IAC5E,MAAM;IACN,WAAW;CACZ,CAAC,CAAC;AAqsBH;;;;;;GAMG;AACH,SAAgB,cAAc,CAC5B,OAAsC,EACtC,UAAgC;IAEhC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,UAAU,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;AACxD,CAAC;AAPD,wCAOC;AAqID;;;;;;;;;GASG;AACU,QAAA,iBAAiB,GAAG,kBAAkB,CAAC;AAgGpD;uDACuD;AACvD,SAAgB,kBAAkB,CAChC,OAAoB;IAEpB,OAAO,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU,CAAC;AACnD,CAAC;AAJD,gDAIC"}
@@ -41,7 +41,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
41
41
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
42
42
  };
43
43
  Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.agentCoreCodeRunner = exports.localCodeRunner = void 0;
44
+ exports.agentCoreCodeRunner = exports.AWS_SYSTEM_BROWSER = exports.agentCoreBrowser = exports.localCodeRunner = void 0;
45
45
  __exportStar(require("../llm-providers.js"), exports);
46
46
  __exportStar(require("../embedders/index.js"), exports);
47
47
  __exportStar(require("../tool-providers/index.js"), exports);
@@ -51,6 +51,12 @@ __exportStar(require("../thinking/index.js"), exports);
51
51
  // other adapter ports.
52
52
  var local_js_1 = require("../adapters/code/local.js");
53
53
  Object.defineProperty(exports, "localCodeRunner", { enumerable: true, get: function () { return local_js_1.localCodeRunner; } });
54
- var agentcore_js_1 = require("../adapters/code/agentcore.js");
55
- Object.defineProperty(exports, "agentCoreCodeRunner", { enumerable: true, get: function () { return agentcore_js_1.agentCoreCodeRunner; } });
54
+ // A managed browser behind the `BrowserRunner` port (9.68.0). Page work goes
55
+ // over CDP through `session.automationEndpoint`; what this carries is the
56
+ // session, the OS-level input above the page, and the human takeover.
57
+ var agentcore_js_1 = require("../adapters/browser/agentcore.js");
58
+ Object.defineProperty(exports, "agentCoreBrowser", { enumerable: true, get: function () { return agentcore_js_1.agentCoreBrowser; } });
59
+ Object.defineProperty(exports, "AWS_SYSTEM_BROWSER", { enumerable: true, get: function () { return agentcore_js_1.AWS_SYSTEM_BROWSER; } });
60
+ var agentcore_js_2 = require("../adapters/code/agentcore.js");
61
+ Object.defineProperty(exports, "agentCoreCodeRunner", { enumerable: true, get: function () { return agentcore_js_2.agentCoreCodeRunner; } });
56
62
  //# sourceMappingURL=providers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/doors/providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;AAEH,sDAAoC;AACpC,wDAAsC;AACtC,6DAA2C;AAC3C,uDAAqC;AAErC,6EAA6E;AAC7E,gFAAgF;AAChF,uBAAuB;AACvB,sDAAyF;AAAhF,2GAAA,eAAe,OAAA;AACxB,8DAMuC;AALrC,mHAAA,mBAAmB,OAAA"}
1
+ {"version":3,"file":"providers.js","sourceRoot":"","sources":["../../src/doors/providers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;AAEH,sDAAoC;AACpC,wDAAsC;AACtC,6DAA2C;AAC3C,uDAAqC;AAErC,6EAA6E;AAC7E,gFAAgF;AAChF,uBAAuB;AACvB,sDAAyF;AAAhF,2GAAA,eAAe,OAAA;AACxB,6EAA6E;AAC7E,0EAA0E;AAC1E,sEAAsE;AACtE,iEAM0C;AALxC,gHAAA,gBAAgB,OAAA;AAChB,kHAAA,kBAAkB,OAAA;AAKpB,8DAMuC;AALrC,mHAAA,mBAAmB,OAAA"}