agentfootprint 12.0.1 → 12.2.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.
- package/AGENTS.md +1 -1
- package/CAPABILITIES.md +3 -0
- package/ai-instructions/claude-code/SKILL.md +1 -1
- package/dist/adapters/mcp/agentcoreRuntime/invoke.js +113 -7
- package/dist/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
- package/dist/adapters/mcp/agentcoreRuntime/session.js +21 -21
- package/dist/adapters/mcp/agentcoreRuntime/session.js.map +1 -1
- package/dist/adapters/mcp/agentcoreRuntime/transport.js +79 -5
- package/dist/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
- package/dist/core/Agent.js +6 -0
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/stages/toolCalls.js +4 -0
- package/dist/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/core/slots/buildToolsSlot.js +8 -0
- package/dist/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +23 -4
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +112 -6
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/session.d.ts +20 -6
- package/dist/esm/adapters/mcp/agentcoreRuntime/session.js +21 -21
- package/dist/esm/adapters/mcp/agentcoreRuntime/session.js.map +1 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +81 -7
- package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
- package/dist/esm/core/Agent.js +6 -0
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/stages/toolCalls.js +4 -0
- package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
- package/dist/esm/core/slots/buildToolsSlot.d.ts +12 -0
- package/dist/esm/core/slots/buildToolsSlot.js +8 -0
- package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +41 -0
- package/dist/esm/events/registry.d.ts +3 -1
- package/dist/esm/events/registry.js +2 -0
- package/dist/esm/events/registry.js.map +1 -1
- package/dist/esm/identity/types.d.ts +7 -3
- package/dist/esm/identity/types.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/boundedJson.d.ts +14 -7
- package/dist/esm/lib/boundedJson.js +14 -7
- package/dist/esm/lib/boundedJson.js.map +1 -1
- package/dist/esm/mcp/callChecks.d.ts +160 -0
- package/dist/esm/mcp/callChecks.js +237 -0
- package/dist/esm/mcp/callChecks.js.map +1 -0
- package/dist/esm/mcp/callLifetime.js +5 -2
- package/dist/esm/mcp/callLifetime.js.map +1 -1
- package/dist/esm/mcp/clientPort.d.ts +78 -0
- package/dist/esm/mcp/clientPort.js +33 -0
- package/dist/esm/mcp/clientPort.js.map +1 -0
- package/dist/esm/mcp/gatewayTransport.js +13 -3
- package/dist/esm/mcp/gatewayTransport.js.map +1 -1
- package/dist/esm/mcp/index.d.ts +11 -1
- package/dist/esm/mcp/index.js +15 -0
- package/dist/esm/mcp/index.js.map +1 -1
- package/dist/esm/mcp/listingGenerations.d.ts +54 -0
- package/dist/esm/mcp/listingGenerations.js +75 -0
- package/dist/esm/mcp/listingGenerations.js.map +1 -0
- package/dist/esm/mcp/mcpClient.d.ts +18 -1
- package/dist/esm/mcp/mcpClient.js +302 -57
- package/dist/esm/mcp/mcpClient.js.map +1 -1
- package/dist/esm/mcp/mockMcpClient.js +13 -0
- package/dist/esm/mcp/mockMcpClient.js.map +1 -1
- package/dist/esm/mcp/pool/boundTool.d.ts +58 -0
- package/dist/esm/mcp/pool/boundTool.js +218 -0
- package/dist/esm/mcp/pool/boundTool.js.map +1 -0
- package/dist/esm/mcp/pool/clientSet.d.ts +73 -0
- package/dist/esm/mcp/pool/clientSet.js +152 -0
- package/dist/esm/mcp/pool/clientSet.js.map +1 -0
- package/dist/esm/mcp/pool/definitions.d.ts +103 -0
- package/dist/esm/mcp/pool/definitions.js +168 -0
- package/dist/esm/mcp/pool/definitions.js.map +1 -0
- package/dist/esm/mcp/pool/errors.d.ts +76 -0
- package/dist/esm/mcp/pool/errors.js +91 -0
- package/dist/esm/mcp/pool/errors.js.map +1 -0
- package/dist/esm/mcp/pool/identityKey.d.ts +57 -0
- package/dist/esm/mcp/pool/identityKey.js +94 -0
- package/dist/esm/mcp/pool/identityKey.js.map +1 -0
- package/dist/esm/mcp/pool/lease.d.ts +36 -0
- package/dist/esm/mcp/pool/lease.js +51 -0
- package/dist/esm/mcp/pool/lease.js.map +1 -0
- package/dist/esm/mcp/pool/listTools.d.ts +33 -0
- package/dist/esm/mcp/pool/listTools.js +146 -0
- package/dist/esm/mcp/pool/listTools.js.map +1 -0
- package/dist/esm/mcp/pool/mcpClientPool.d.ts +121 -0
- package/dist/esm/mcp/pool/mcpClientPool.js +151 -0
- package/dist/esm/mcp/pool/mcpClientPool.js.map +1 -0
- package/dist/esm/mcp/pool/options.d.ts +183 -0
- package/dist/esm/mcp/pool/options.js +119 -0
- package/dist/esm/mcp/pool/options.js.map +1 -0
- package/dist/esm/mcp/pool/plan.d.ts +77 -0
- package/dist/esm/mcp/pool/plan.js +134 -0
- package/dist/esm/mcp/pool/plan.js.map +1 -0
- package/dist/esm/mcp/pool/pool.d.ts +307 -0
- package/dist/esm/mcp/pool/pool.js +1071 -0
- package/dist/esm/mcp/pool/pool.js.map +1 -0
- package/dist/esm/mcp/pool/pooledClient.d.ts +93 -0
- package/dist/esm/mcp/pool/pooledClient.js +90 -0
- package/dist/esm/mcp/pool/pooledClient.js.map +1 -0
- package/dist/esm/mcp/pool/record.d.ts +80 -0
- package/dist/esm/mcp/pool/record.js +75 -0
- package/dist/esm/mcp/pool/record.js.map +1 -0
- package/dist/esm/mcp/pool/sessionEnded.d.ts +24 -0
- package/dist/esm/mcp/pool/sessionEnded.js +31 -0
- package/dist/esm/mcp/pool/sessionEnded.js.map +1 -0
- package/dist/esm/mcp/pool/work.d.ts +116 -0
- package/dist/esm/mcp/pool/work.js +213 -0
- package/dist/esm/mcp/pool/work.js.map +1 -0
- package/dist/esm/mcp/requestGuard.d.ts +70 -0
- package/dist/esm/mcp/requestGuard.js +98 -0
- package/dist/esm/mcp/requestGuard.js.map +1 -0
- package/dist/esm/mcp/requestLedger.d.ts +35 -1
- package/dist/esm/mcp/requestLedger.js +76 -3
- package/dist/esm/mcp/requestLedger.js.map +1 -1
- package/dist/esm/mcp/seriesEvidence.d.ts +10 -6
- package/dist/esm/mcp/seriesEvidence.js +16 -7
- package/dist/esm/mcp/seriesEvidence.js.map +1 -1
- package/dist/esm/mcp/terminate.d.ts +94 -0
- package/dist/esm/mcp/terminate.js +184 -0
- package/dist/esm/mcp/terminate.js.map +1 -0
- package/dist/esm/mcp/throttleRetry.js +71 -7
- package/dist/esm/mcp/throttleRetry.js.map +1 -1
- package/dist/esm/mcp/toolList.d.ts +90 -0
- package/dist/esm/mcp/toolList.js +123 -0
- package/dist/esm/mcp/toolList.js.map +1 -0
- package/dist/esm/mcp/types.d.ts +197 -3
- package/dist/esm/redaction/knownStrings.js +34 -0
- package/dist/esm/redaction/knownStrings.js.map +1 -1
- package/dist/esm/tool-providers/index.d.ts +2 -2
- package/dist/esm/tool-providers/index.js +15 -1
- package/dist/esm/tool-providers/index.js.map +1 -1
- package/dist/esm/tools/mcpClientUse.d.ts +59 -0
- package/dist/esm/tools/mcpClientUse.js +216 -0
- package/dist/esm/tools/mcpClientUse.js.map +1 -0
- package/dist/esm/tools/toolProvider.d.ts +16 -0
- package/dist/esm/tools/toolSessions.d.ts +41 -0
- package/dist/esm/tools/toolSessions.js +41 -1
- package/dist/esm/tools/toolSessions.js.map +1 -1
- package/dist/events/registry.js +2 -0
- package/dist/events/registry.js.map +1 -1
- package/dist/identity/types.js.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/lib/boundedJson.js +14 -7
- package/dist/lib/boundedJson.js.map +1 -1
- package/dist/mcp/callChecks.js +247 -0
- package/dist/mcp/callChecks.js.map +1 -0
- package/dist/mcp/callLifetime.js +5 -2
- package/dist/mcp/callLifetime.js.map +1 -1
- package/dist/mcp/clientPort.js +38 -0
- package/dist/mcp/clientPort.js.map +1 -0
- package/dist/mcp/gatewayTransport.js +13 -3
- package/dist/mcp/gatewayTransport.js.map +1 -1
- package/dist/mcp/index.js +25 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/listingGenerations.js +80 -0
- package/dist/mcp/listingGenerations.js.map +1 -0
- package/dist/mcp/mcpClient.js +306 -59
- package/dist/mcp/mcpClient.js.map +1 -1
- package/dist/mcp/mockMcpClient.js +13 -0
- package/dist/mcp/mockMcpClient.js.map +1 -1
- package/dist/mcp/pool/boundTool.js +223 -0
- package/dist/mcp/pool/boundTool.js.map +1 -0
- package/dist/mcp/pool/clientSet.js +157 -0
- package/dist/mcp/pool/clientSet.js.map +1 -0
- package/dist/mcp/pool/definitions.js +174 -0
- package/dist/mcp/pool/definitions.js.map +1 -0
- package/dist/mcp/pool/errors.js +96 -0
- package/dist/mcp/pool/errors.js.map +1 -0
- package/dist/mcp/pool/identityKey.js +99 -0
- package/dist/mcp/pool/identityKey.js.map +1 -0
- package/dist/mcp/pool/lease.js +55 -0
- package/dist/mcp/pool/lease.js.map +1 -0
- package/dist/mcp/pool/listTools.js +150 -0
- package/dist/mcp/pool/listTools.js.map +1 -0
- package/dist/mcp/pool/mcpClientPool.js +155 -0
- package/dist/mcp/pool/mcpClientPool.js.map +1 -0
- package/dist/mcp/pool/options.js +123 -0
- package/dist/mcp/pool/options.js.map +1 -0
- package/dist/mcp/pool/plan.js +140 -0
- package/dist/mcp/pool/plan.js.map +1 -0
- package/dist/mcp/pool/pool.js +1075 -0
- package/dist/mcp/pool/pool.js.map +1 -0
- package/dist/mcp/pool/pooledClient.js +94 -0
- package/dist/mcp/pool/pooledClient.js.map +1 -0
- package/dist/mcp/pool/record.js +80 -0
- package/dist/mcp/pool/record.js.map +1 -0
- package/dist/mcp/pool/sessionEnded.js +35 -0
- package/dist/mcp/pool/sessionEnded.js.map +1 -0
- package/dist/mcp/pool/work.js +219 -0
- package/dist/mcp/pool/work.js.map +1 -0
- package/dist/mcp/requestGuard.js +106 -0
- package/dist/mcp/requestGuard.js.map +1 -0
- package/dist/mcp/requestLedger.js +76 -3
- package/dist/mcp/requestLedger.js.map +1 -1
- package/dist/mcp/seriesEvidence.js +16 -7
- package/dist/mcp/seriesEvidence.js.map +1 -1
- package/dist/mcp/terminate.js +193 -0
- package/dist/mcp/terminate.js.map +1 -0
- package/dist/mcp/throttleRetry.js +71 -7
- package/dist/mcp/throttleRetry.js.map +1 -1
- package/dist/mcp/toolList.js +128 -0
- package/dist/mcp/toolList.js.map +1 -0
- package/dist/redaction/knownStrings.js +34 -0
- package/dist/redaction/knownStrings.js.map +1 -1
- package/dist/tool-providers/index.js +20 -1
- package/dist/tool-providers/index.js.map +1 -1
- package/dist/tools/mcpClientUse.js +225 -0
- package/dist/tools/mcpClientUse.js.map +1 -0
- package/dist/tools/toolSessions.js +44 -1
- package/dist/tools/toolSessions.js.map +1 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +23 -4
- package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/session.d.ts +20 -6
- package/dist/types/adapters/mcp/agentcoreRuntime/session.d.ts.map +1 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
- package/dist/types/core/slots/buildToolsSlot.d.ts +12 -0
- package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +41 -0
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/events/registry.d.ts +3 -1
- package/dist/types/events/registry.d.ts.map +1 -1
- package/dist/types/identity/types.d.ts +7 -3
- package/dist/types/identity/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/boundedJson.d.ts +14 -7
- package/dist/types/lib/boundedJson.d.ts.map +1 -1
- package/dist/types/mcp/callChecks.d.ts +161 -0
- package/dist/types/mcp/callChecks.d.ts.map +1 -0
- package/dist/types/mcp/callLifetime.d.ts.map +1 -1
- package/dist/types/mcp/clientPort.d.ts +79 -0
- package/dist/types/mcp/clientPort.d.ts.map +1 -0
- package/dist/types/mcp/gatewayTransport.d.ts.map +1 -1
- package/dist/types/mcp/index.d.ts +11 -1
- package/dist/types/mcp/index.d.ts.map +1 -1
- package/dist/types/mcp/listingGenerations.d.ts +55 -0
- package/dist/types/mcp/listingGenerations.d.ts.map +1 -0
- package/dist/types/mcp/mcpClient.d.ts +18 -1
- package/dist/types/mcp/mcpClient.d.ts.map +1 -1
- package/dist/types/mcp/mockMcpClient.d.ts.map +1 -1
- package/dist/types/mcp/pool/boundTool.d.ts +59 -0
- package/dist/types/mcp/pool/boundTool.d.ts.map +1 -0
- package/dist/types/mcp/pool/clientSet.d.ts +74 -0
- package/dist/types/mcp/pool/clientSet.d.ts.map +1 -0
- package/dist/types/mcp/pool/definitions.d.ts +104 -0
- package/dist/types/mcp/pool/definitions.d.ts.map +1 -0
- package/dist/types/mcp/pool/errors.d.ts +77 -0
- package/dist/types/mcp/pool/errors.d.ts.map +1 -0
- package/dist/types/mcp/pool/identityKey.d.ts +58 -0
- package/dist/types/mcp/pool/identityKey.d.ts.map +1 -0
- package/dist/types/mcp/pool/lease.d.ts +37 -0
- package/dist/types/mcp/pool/lease.d.ts.map +1 -0
- package/dist/types/mcp/pool/listTools.d.ts +34 -0
- package/dist/types/mcp/pool/listTools.d.ts.map +1 -0
- package/dist/types/mcp/pool/mcpClientPool.d.ts +122 -0
- package/dist/types/mcp/pool/mcpClientPool.d.ts.map +1 -0
- package/dist/types/mcp/pool/options.d.ts +184 -0
- package/dist/types/mcp/pool/options.d.ts.map +1 -0
- package/dist/types/mcp/pool/plan.d.ts +78 -0
- package/dist/types/mcp/pool/plan.d.ts.map +1 -0
- package/dist/types/mcp/pool/pool.d.ts +308 -0
- package/dist/types/mcp/pool/pool.d.ts.map +1 -0
- package/dist/types/mcp/pool/pooledClient.d.ts +94 -0
- package/dist/types/mcp/pool/pooledClient.d.ts.map +1 -0
- package/dist/types/mcp/pool/record.d.ts +81 -0
- package/dist/types/mcp/pool/record.d.ts.map +1 -0
- package/dist/types/mcp/pool/sessionEnded.d.ts +25 -0
- package/dist/types/mcp/pool/sessionEnded.d.ts.map +1 -0
- package/dist/types/mcp/pool/work.d.ts +117 -0
- package/dist/types/mcp/pool/work.d.ts.map +1 -0
- package/dist/types/mcp/requestGuard.d.ts +71 -0
- package/dist/types/mcp/requestGuard.d.ts.map +1 -0
- package/dist/types/mcp/requestLedger.d.ts +35 -1
- package/dist/types/mcp/requestLedger.d.ts.map +1 -1
- package/dist/types/mcp/seriesEvidence.d.ts +10 -6
- package/dist/types/mcp/seriesEvidence.d.ts.map +1 -1
- package/dist/types/mcp/terminate.d.ts +95 -0
- package/dist/types/mcp/terminate.d.ts.map +1 -0
- package/dist/types/mcp/throttleRetry.d.ts.map +1 -1
- package/dist/types/mcp/toolList.d.ts +91 -0
- package/dist/types/mcp/toolList.d.ts.map +1 -0
- package/dist/types/mcp/types.d.ts +197 -3
- package/dist/types/mcp/types.d.ts.map +1 -1
- package/dist/types/redaction/knownStrings.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +2 -2
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/dist/types/tools/mcpClientUse.d.ts +60 -0
- package/dist/types/tools/mcpClientUse.d.ts.map +1 -0
- package/dist/types/tools/toolProvider.d.ts +16 -0
- package/dist/types/tools/toolProvider.d.ts.map +1 -1
- package/dist/types/tools/toolSessions.d.ts +41 -0
- package/dist/types/tools/toolSessions.d.ts.map +1 -1
- package/package.json +3 -3
package/AGENTS.md
CHANGED
|
@@ -286,7 +286,7 @@ const agent = Agent.create({ provider, model })
|
|
|
286
286
|
agent.on('agentfootprint.context.evaluated', (e) => console.log(e.payload.activeIds));
|
|
287
287
|
```
|
|
288
288
|
|
|
289
|
-
**
|
|
289
|
+
**127 typed events across 27 domains.** Two subscription shapes and no third:
|
|
290
290
|
`'*'` (every event) and `'agentfootprint.<domain>.*'` (one domain). **`'agentfootprint.*'`
|
|
291
291
|
is not a pattern** — TypeScript rejects it, and at runtime it would match nothing.
|
|
292
292
|
|
package/CAPABILITIES.md
CHANGED
|
@@ -21,7 +21,10 @@ not in this table, search `src/index.ts` for the nearest noun before writing cod
|
|
|
21
21
|
| If you are about to build… | It is | Where | Since |
|
|
22
22
|
|---|---|---|---|
|
|
23
23
|
| moving files in and out of a code sandbox exactly and bounded, and running shell commands in it — staging text as text and bytes as bytes (AgentCore: one `writeFiles` call, `blob` for bytes, refused over the 100 MB per-call limit, `AF_STAGED_INPUTS` filled as the local runner fills it); reading ONE file back whole or not at all (paired to its path by the returned URI, a missing or different one refused; text or bytes by the field the backend filled, never the extension; over `maxBytes` refused, never cut); a shell command with bounded output, the cut stated, a checkpoint read before the cut, and an exit status only when the backend reported one — off unless the runner opts in; one path rule for both runners; a gone AgentCore session as one typed error; an outcome nobody reported kept unknown (`CodeResult.ok` absent, never success), and a failed program (`exitCode`) told apart from an unconfirmed run (`serviceError`) and a stopped process (`terminatedBy`) in the result and in the `tools.code_run` record | `CodeSession.readFile` + `CodeSession.runCommand` (runner option `commands: true`) + `canReadCodeFiles` / `canRunCodeCommands` + `CodeSandboxError` + `SessionExpiredError` + `sandboxPath` (`agentfootprint`); `agentCoreCodeRunner` / `localCodeRunner` (`agentfootprint/providers`) | `src/adapters/code/` | 12.0.0 |
|
|
24
|
+
| keeping an MCP client per conversation for a stateful server (AgentCore Runtime `'reuse'`, or any server that holds per-session state) — an app-side `Map<sessionId, client>` is keyed by caller data, unbounded, blind to calls in flight, and never ends the remote sessions: one client per authenticated conversation keyed by the identity the CALLER named (`ToolDispatchContext.callerIdentity`, never a derived one; principal required by default, tenant on request), one open per key under the pool's own signal and `initTimeoutMs`, three budgets each charged until the work under it SETTLED (open clients, endings, operations on any client — a timed-out call stuck in a credential vend stays charged) with `PoolFullError` at once and no queue, a busy client never ended, idle clients swept lazily (no timer), definitions per client incarnation unless the app declares a share checked against the transport's configuration (tenant always in the context), every bound tool re-checked after each wait and at the send gate (before every attempt, after a credential arrives, after SigV4 signing) so a revoked or stale tool — or one listed under an authorization name `share` no longer gives — is never sent, a discovered list kept only under the names it was listed for (asked at its send and again before it is kept), a pooled request with no guard refused unsent and a transport whose `send` cannot be watched never opened, a just-opened client held for its waiting callers, a lost handle's local close charged until it settles, `terminate()` answered by an elapsed-time deadline even when a local close hangs or the clock moves, a server's 404 for its own session (`SessionExpiredError`) kept apart from a handle this process lost (`LocalSessionHandleLostError`), and every use recorded with ids and outcomes only | `mcpClientPool` + `PoolFullError` + `McpPoolRefusedError` (`agentfootprint/providers`): options `name`, `transport`, `maxClients`, `maxClientsPerPrincipal`, `maxEnding`, `maxOperations`, `initTimeoutMs`, `idleMs`, `maxLeaseMs`, `definitionTtlMs`, `definitions`, `requirePrincipal`, `requireTenant`, `onEvent`, `replay`; the pool's `toolProvider()`, `acquire(identity)` (an `AsyncDisposable` lease), `terminate(scope)`, `close()`, `settled()`, `permissionsChanged(scope)`, `toolsChanged()`, `sweep()`, `stats()`; the event `agentfootprint.tools.mcp_client`; `LocalSessionHandleLostError` on `agentfootprint`. Docs: the "A client per conversation" page; example `examples/features/120-mcp-client-pool.ts` | `src/mcp/pool/` | 12.2.0 |
|
|
25
|
+
| ending an MCP client's REMOTE session, and knowing whether it ended — `close()` only aborts the local requests, so a `'reuse'` runtime session ran until the platform's idle timeout and nothing said so: `terminate()` sends the transport's own session termination (the Streamable HTTP `DELETE`), reads the answer itself (the SDK reports a 405 as success), closes locally whatever happened, bounded at 5 s, at most once; `resolved` only for `terminated` / `already-gone` / `no-session`; under AgentCore Runtime `'reuse'` it is `StopRuntimeSession` for that client's runtime session (SigV4 command or bearer HTTPS, the handle forgotten first, a 409 retried in the series) | `canTerminate` + `McpTerminateOutcome` + `McpClient.terminate?()` (`agentfootprint/providers`); `McpHttpTransport.settings` (a transport's comparable settings as data) | `src/mcp/terminate.ts` | 12.2.0 |
|
|
24
26
|
| tuning how an MCP call waits before asking again — the first wait, how it grows, jitter, a cap on the scheduled wait, a deadline for the whole call — and keeping a 429 retry and AgentCore Runtime's session-busy retry from multiplying requests: each call is ONE footprintjs `attempt()` series, the 429 rule JOINS a transport's own series instead of wrapping it (one attempt count, one waiting total, one deadline), a `Retry-After` is waited whole (never cut by the cap), and `onRetry` reports the refusal's `kind` but never arguments or answers | `retryOnThrottle` / `agentCoreRuntimeMcpTransport({ retry })` / `retryingFetch(fetch, options)`: `baseDelayMs`, `multiplier`, `jitter` (none, equal or full), `maxDelayMs`, `maxElapsedMs` beside `maxAttempts`, `maxWaitMs`, `onRetry` (`agentfootprint/providers`); AgentCore default 500 ms doubling, 5 attempts = 3.75–7.5 s of waiting | `src/mcp/throttleRetry.ts` | 11.2.0 |
|
|
27
|
+
| reading an MCP server's whole tool list when it pages (`nextCursor`) — every page, at most 100 `tools/list` requests; a list that does not end (`'page-limit'`) or loops (`'cursor-repeated'`) is refused with what was listed on the error, never returned cut short; the signal checked before each request and after each answer; and every listed tool keeps the SDK `Client`'s call checks whatever `mcpClient` lists later (required task refused before sending, `structuredContent` required by and matched against `outputSchema`, the same error class or shape; left to the SDK only for a one-page list still its latest answer, so a paged list, a failed or successful `refresh()`, a held tool and a call during a listing all stay checked), with `McpOutputUncheckedError` (`sent: false`, or `sent: true` when a list was read while the call was out) only where no JSON Schema validator is reachable — ONLY while discovery runs through `tools()`/`refresh()` (any `mcpClient` over the client): a `listTools` call of your own, the SDK client's automatic refresh (`listChanged.tools`, `autoRefresh` on by default) or any other unseen cache replacement can bypass both the output and the required-task checks, validator or not, so on a `connection` set `autoRefresh: false` and route `onChanged` to `refresh()`, or give `mcpClient` its own connection, which still needs that automatic refresh off | `mcpClient(...).tools()` / `.refresh()` + `McpToolListIncompleteError`, `jsonSchemaValidator` (`McpJsonSchemaValidator`) and `McpOutputUncheckedError` (`agentfootprint/providers`) | `src/mcp/` | 12.1.0 |
|
|
25
28
|
| deciding which MCP tool calls are sent again after a 429 or a lost connection — permission declared by the APP per (server, tool) at registration, never by the model, a tool description or server annotations (`readOnlyHint`); a generic 429 is not proof nothing ran, so `'app-authorized'` (opt-in) sends a call again only on the kinds its entry names (`throttle`, `network`) and otherwise returns the refusal (`not-permitted`); today's default stays as the NAMED `'compatibility'` policy, every retry recording its assumption (`permission: { by: 'compatibility', assumes: 'refused-before-execution' }`); the adapter you chose retries its own refusal (AgentCore session-busy) as its POLICY, recording `permission: { by: 'adapter', assumes: 'refused-before-execution' }` — never proof: a busy-shaped reply can come from a server that ran the call, so every attempt sent that did not complete is `unknown` and `none` is only a request never sent; `retryOnThrottle: false` turns off the 429 rule only — a declared `network` repeat keeps its series, budget and record; the side-effect guard — a tool declared `changes: true` is never sent again unless the server is declared to deduplicate by a key the call carries (`changes-without-key`); each attempt records failure, effect (`none`/`unknown`/`applied`, footprintjs's law) and permission apart, plus `durationMs`; the end counts the requests sent and keeps uncertainty (a later refusal or success never resolves an earlier `unknown`; `applied` = the call completed, never proof of a write); under `'app-authorized'` a received refusal or error (429, 503, JSON-RPC or tool error — or a chain of them) keeps the server's error, effect `unknown`, while a call that genuinely lacked an answer (an attempt with no response, or a request accepted over HTTP — 202, a stream — whose JSON-RPC answer never came: the ledger watches it by id) and then fails, fails as "may have run" (footprintjs `UnknownEffectError`, its final error the cause, `mayHaveRun: true`); `'compatibility'` keeps today's errors; `'app-authorized'` never silently weakens: it needs each request matched to its call (a library-private `_meta` marker, stripped before sending, so a copying SDK still matches) and each answer seen (checked when the `initialize` answer passes the observer), or the call is refused BEFORE it is sent with `McpReplayUnavailableError` (`sent: false`, `reason`: `answers-unobserved` for an SDK whose `connect` replaces `onmessage`, as 1.10's does; `request-unmatched` for one that drops `_meta`; `requests-unwatched` for stdio); an answer's watch ends by request id (answer, SDK cancellation, call settled, client closed), never with the HTTP send alone; a repeat re-sends the same arguments, server, session and identity | `mcpClient({ replay: { policy, tools: { [name]: { on, changes } }, deduplicates: { argument } } })` + `McpReplayOptions` + `McpReplayUnavailableError` (`agentfootprint/providers`); `effect` / `permission` / `durationMs` on `agentfootprint.tools.request_attempts` rows; `attempts` / `effect` / `mayHaveRun` on its `end` | `src/mcp/replay.ts` | 11.5.0 |
|
|
26
29
|
| saving what an MCP call's retries did into the run that made the call — every attempt, why the series went on or stopped after it, each wait and any stated `Retry-After`, and how the request ended, a cancellation DURING A WAIT included — so a saved and re-read recording gives it back; concurrent calls and runs on one connection never mix; past 100 attempts the rest are counted (`omitted`), never dropped; a 503 received is `answered` with its status, never success and never retried; allow-listed metadata only (a thrown error is a fixed sentence and its category; the endpoint is the declared `endpointLabel`, else its origin; a filing is read as plain data). Every request sent is a row or counted; one cut in flight is `cut`, `remote: 'unknown'` (never recorded as not run), and only a request never sent has no row. Filed ONCE per request by the call's own footprintjs `attempt()` series (no second loop) through an internal per-dispatch port (`REQUEST_EVIDENCE`, not public API) and a per-connection ledger: the call's private `_meta` marker (taken out before sending) → JSON-RPC id → series. An MCP tool call honours its `ctx.signal` (the SDK request is cancelled, `notifications/cancelled` sent), its series stops with it, a wait included, filed the moment it lands, and a call that settles first cuts its series inside the call — never filed after its run, nothing re-sent | `agentfootprint.tools.request_attempts` / `SeriesEvidence` + `RequestLedger` | `src/mcp/` | 11.3.0 |
|
|
27
30
|
| refusing invalid memory list and search request sizes uniformly before backend reads or empty-result shortcuts, while keeping optional defaults, adapter upper caps and list continuation intact | `ListOptions` + `SearchOptions` | `src/memory/store/types.ts` | 10.8.1 |
|
|
@@ -286,7 +286,7 @@ const agent = Agent.create({ provider, model })
|
|
|
286
286
|
agent.on('agentfootprint.context.evaluated', (e) => console.log(e.payload.activeIds));
|
|
287
287
|
```
|
|
288
288
|
|
|
289
|
-
**
|
|
289
|
+
**127 typed events across 27 domains.** Two subscription shapes and no third:
|
|
290
290
|
`'*'` (every event) and `'agentfootprint.<domain>.*'` (one domain). **`'agentfootprint.*'`
|
|
291
291
|
is not a pattern** — TypeScript rejects it, and at runtime it would match nothing.
|
|
292
292
|
|
|
@@ -59,19 +59,36 @@
|
|
|
59
59
|
*
|
|
60
60
|
* ── What the operation cannot carry ──────────────────────────────────────────
|
|
61
61
|
* Any method but POST. A GET (the optional server-message stream) and a DELETE
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* are answered HERE with 405, which the MCP Streamable HTTP spec defines as "not
|
|
63
|
+
* offered" for both, so the MCP client carries on. And any header the operation
|
|
64
|
+
* does not model — it has no field to put one in. A `'reuse'` connection's
|
|
65
|
+
* DELETE never reaches this far: the session strategy turns it into a stop
|
|
66
|
+
* (`STOP_RUNTIME_SESSION`), sent as `StopRuntimeSessionCommand`.
|
|
67
|
+
*
|
|
68
|
+
* ── The send gate runs after signing ─────────────────────────────────────────
|
|
69
|
+
* A request the MCP client pool sent carries its send gate (`mcp/requestGuard.ts`).
|
|
70
|
+
* Signing is asynchronous work inside the AWS SDK's `send`, so the gate is a
|
|
71
|
+
* step on each COMMAND's own middleware stack, after the request is signed and
|
|
72
|
+
* before the request handler sends it — never on the client's stack, so an AWS
|
|
73
|
+
* client the app passed is not changed. A command with no stack (a double) has
|
|
74
|
+
* the gate asked just before `send`, as every command also does.
|
|
65
75
|
*
|
|
66
76
|
* Pattern: Adapter (fetch ↔ command). Role: outer ring, lazy AWS peer dep.
|
|
67
77
|
*/
|
|
68
78
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
69
|
-
exports.invokeFetch = exports.invokeSdk = void 0;
|
|
79
|
+
exports.invokeFetch = exports.invokeSdk = exports.STOP_RUNTIME_SESSION = void 0;
|
|
70
80
|
const lazyRequire_js_1 = require("../../../lib/lazyRequire.js");
|
|
81
|
+
const requestGuard_js_1 = require("../../../mcp/requestGuard.js");
|
|
71
82
|
const sdkLoadFailure_js_1 = require("../../../mcp/sdkLoadFailure.js");
|
|
72
83
|
const session_js_1 = require("./session.js");
|
|
73
84
|
const MCP_PROTOCOL_VERSION_HEADER = 'Mcp-Protocol-Version';
|
|
74
85
|
const SDK_PACKAGE = '@aws-sdk/client-bedrock-agentcore';
|
|
86
|
+
/**
|
|
87
|
+
* @internal The `init` key a `'reuse'` connection's stop rides under: the
|
|
88
|
+
* runtime session id to stop (`transport.ts` · `stopSession`). A symbol, so no
|
|
89
|
+
* request the MCP client makes can ever claim it.
|
|
90
|
+
*/
|
|
91
|
+
exports.STOP_RUNTIME_SESSION = Symbol('agentcore.stop-runtime-session');
|
|
75
92
|
/**
|
|
76
93
|
* The client and the command constructor this strategy sends with.
|
|
77
94
|
*
|
|
@@ -92,8 +109,12 @@ function invokeSdk(options) {
|
|
|
92
109
|
if (typeof Command !== 'function') {
|
|
93
110
|
throw new Error(`agentCoreRuntimeMcpTransport: ${source} \`InvokeAgentRuntimeCommand\`. ${advice}`);
|
|
94
111
|
}
|
|
112
|
+
// Ending a `'reuse'` client stops its runtime session with this command. An
|
|
113
|
+
// SDK module without it still invokes; that ending is then 'failed' (`stopFetch`).
|
|
114
|
+
const Stop = mod.StopRuntimeSessionCommand;
|
|
115
|
+
const stop = typeof Stop === 'function' ? { StopRuntimeSessionCommand: Stop } : {};
|
|
95
116
|
if (options.client)
|
|
96
|
-
return { client: options.client, InvokeAgentRuntimeCommand: Command };
|
|
117
|
+
return { client: options.client, InvokeAgentRuntimeCommand: Command, ...stop };
|
|
97
118
|
if (typeof mod.BedrockAgentCoreClient !== 'function') {
|
|
98
119
|
throw new Error(`agentCoreRuntimeMcpTransport: ${source} \`BedrockAgentCoreClient\`. ${advice}`);
|
|
99
120
|
}
|
|
@@ -101,6 +122,7 @@ function invokeSdk(options) {
|
|
|
101
122
|
// The SDK's own retry OFF: it would re-send work that may have run.
|
|
102
123
|
client: new mod.BedrockAgentCoreClient({ region: options.region, maxAttempts: 1 }),
|
|
103
124
|
InvokeAgentRuntimeCommand: Command,
|
|
125
|
+
...stop,
|
|
104
126
|
};
|
|
105
127
|
}
|
|
106
128
|
exports.invokeSdk = invokeSdk;
|
|
@@ -134,8 +156,12 @@ const NULL_BODY_STATUS = new Set([204, 205, 304]);
|
|
|
134
156
|
* reports and errors, while the invocation goes to `target` — the SDK resolves
|
|
135
157
|
* the endpoint itself, from the client's region.
|
|
136
158
|
*/
|
|
137
|
-
function invokeFetch(target, client, InvokeAgentRuntimeCommand) {
|
|
159
|
+
function invokeFetch(target, client, InvokeAgentRuntimeCommand, StopRuntimeSessionCommand) {
|
|
138
160
|
return async (_input, init) => {
|
|
161
|
+
const stopping = stopOf(init);
|
|
162
|
+
if (stopping !== undefined) {
|
|
163
|
+
return stopFetch(target, client, StopRuntimeSessionCommand, stopping, init);
|
|
164
|
+
}
|
|
139
165
|
const method = (init?.method ?? 'GET').toUpperCase();
|
|
140
166
|
if (method !== 'POST') {
|
|
141
167
|
return new Response(null, { status: 405, statusText: 'Method Not Allowed' });
|
|
@@ -154,7 +180,7 @@ function invokeFetch(target, client, InvokeAgentRuntimeCommand) {
|
|
|
154
180
|
});
|
|
155
181
|
let answer;
|
|
156
182
|
try {
|
|
157
|
-
answer = ((await client
|
|
183
|
+
answer = ((await sendGated(client, command, init)) ?? {});
|
|
158
184
|
}
|
|
159
185
|
catch (err) {
|
|
160
186
|
const answered = serviceAnswerOf(err);
|
|
@@ -166,6 +192,86 @@ function invokeFetch(target, client, InvokeAgentRuntimeCommand) {
|
|
|
166
192
|
};
|
|
167
193
|
}
|
|
168
194
|
exports.invokeFetch = invokeFetch;
|
|
195
|
+
/** The runtime session a stop request names (`STOP_RUNTIME_SESSION`), or `undefined`. */
|
|
196
|
+
function stopOf(init) {
|
|
197
|
+
const value = init?.[exports.STOP_RUNTIME_SESSION];
|
|
198
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* `StopRuntimeSession` for one runtime session, as the `Response` an HTTPS
|
|
202
|
+
* caller would read: 200 when the platform stopped it, a service exception as
|
|
203
|
+
* its status (`ResourceNotFoundException` 404, `RetryableConflictException` 409
|
|
204
|
+
* — retried by the series — `AccessDeniedException` 403, …).
|
|
205
|
+
*/
|
|
206
|
+
async function stopFetch(target, client, StopRuntimeSessionCommand, runtimeSessionId, init) {
|
|
207
|
+
if (StopRuntimeSessionCommand === undefined) {
|
|
208
|
+
throw new Error('agentCoreRuntimeMcpTransport: the AWS SDK module has no `StopRuntimeSessionCommand`, ' +
|
|
209
|
+
"so a 'reuse' client's runtime session cannot be stopped. Upgrade the SDK.");
|
|
210
|
+
}
|
|
211
|
+
const command = new StopRuntimeSessionCommand({
|
|
212
|
+
runtimeSessionId,
|
|
213
|
+
agentRuntimeArn: target.agentRuntimeArn,
|
|
214
|
+
...(target.qualifier !== undefined && { qualifier: target.qualifier }),
|
|
215
|
+
clientToken: clientTokenOf(init?.body),
|
|
216
|
+
});
|
|
217
|
+
try {
|
|
218
|
+
await sendGated(client, command, init);
|
|
219
|
+
}
|
|
220
|
+
catch (err) {
|
|
221
|
+
const answered = serviceAnswerOf(err);
|
|
222
|
+
if (answered === undefined)
|
|
223
|
+
throw err;
|
|
224
|
+
return answered;
|
|
225
|
+
}
|
|
226
|
+
return new Response(null, { status: 200 });
|
|
227
|
+
}
|
|
228
|
+
/** The stop's idempotency token, as its body carries it — one per stop, across attempts. */
|
|
229
|
+
function clientTokenOf(body) {
|
|
230
|
+
if (typeof body !== 'string')
|
|
231
|
+
return undefined;
|
|
232
|
+
try {
|
|
233
|
+
const token = JSON.parse(body).clientToken;
|
|
234
|
+
return typeof token === 'string' ? token : undefined;
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* `client.send(command)`, with a pooled request's send gate asked before it and
|
|
242
|
+
* — on a command with its own middleware stack — again after signing, and the
|
|
243
|
+
* send counted under the request until it settles (`mcp/requestGuard.ts`).
|
|
244
|
+
*/
|
|
245
|
+
function sendGated(client, command, init) {
|
|
246
|
+
const guard = (0, requestGuard_js_1.guardOf)(init);
|
|
247
|
+
if (guard !== undefined) {
|
|
248
|
+
installGate(command, guard);
|
|
249
|
+
guard.check();
|
|
250
|
+
}
|
|
251
|
+
const sent = client.send(command, init?.signal ? { abortSignal: init.signal } : undefined);
|
|
252
|
+
guard?.track(sent);
|
|
253
|
+
return sent;
|
|
254
|
+
}
|
|
255
|
+
/** The gate's name on a command's middleware stack. */
|
|
256
|
+
const GATE_STEP = 'agentfootprintSendGate';
|
|
257
|
+
/**
|
|
258
|
+
* Put `guard` on `command`'s OWN middleware stack, after signing and before the
|
|
259
|
+
* request handler: the AWS SDK signs at the `finalizeRequest` step (its signer
|
|
260
|
+
* sits right after its retry middleware, at high priority), so a low-priority
|
|
261
|
+
* `finalizeRequest` step runs after the signature and before the deserializer
|
|
262
|
+
* hands the request to the handler. The client's stack is never touched.
|
|
263
|
+
* A command without a stack is left as it is.
|
|
264
|
+
*/
|
|
265
|
+
function installGate(command, guard) {
|
|
266
|
+
const stack = command
|
|
267
|
+
?.middlewareStack;
|
|
268
|
+
if (typeof stack?.add !== 'function')
|
|
269
|
+
return;
|
|
270
|
+
stack.add.call(stack, (next) => async (args) => {
|
|
271
|
+
guard.check();
|
|
272
|
+
return next(args);
|
|
273
|
+
}, { step: 'finalizeRequest', priority: 'low', name: GATE_STEP, override: true });
|
|
274
|
+
}
|
|
169
275
|
/**
|
|
170
276
|
* An SDK service exception as the `Response` the service sent: its status, its
|
|
171
277
|
* error type, its `retry-after`. `undefined` for anything that carries no
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke.js","sourceRoot":"","sources":["../../../../src/adapters/mcp/agentcoreRuntime/invoke.ts"],"names":[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AM,EAAE,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,QAAQ,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,MAAM,CAAC,MAAe;IACnC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,YAAY,UAAU;QAAE,OAAO,MAAM,CAAC;IAC9E,MAAM,SAAS,GAAG,MAGjB,CAAC;IACF,IAAI,OAAO,SAAS,CAAC,oBAAoB,KAAK,UAAU,EAAE,CAAC;QACzD,OAAO,SAAS,CAAC,oBAAoB,EAAE,CAAC;IAC1C,CAAC;IACD,IAAI,OAAO,SAAS,CAAC,oBAAoB,KAAK,UAAU,EAAE,CAAC;QACzD,OAAO,SAAS,CAAC,oBAAoB,EAAE,CAAC;IAC1C,CAAC;IACD,MAAM,IAAI,SAAS,CACjB,sFAAsF;QACpF,oFAAoF;QACpF,4CAA4C,CAC/C,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,KAAK,UAAU,OAAO,CAAC,MAAe;IACpC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAA0E,CAAC;QAC7F,MAAM,SAAS,EAAE,oBAAoB,EAAE,EAAE,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,0EAA0E;IAC5E,CAAC;AACH,CAAC"}
|
|
@@ -34,8 +34,12 @@
|
|
|
34
34
|
* `Mcp-Session-Id` the server returns for it is stored WITH that connection,
|
|
35
35
|
* and the client is handed an opaque handle of the transport's own in its
|
|
36
36
|
* place. Every later request carrying the handle is sent in that connection's
|
|
37
|
-
* runtime session with the server's own id
|
|
38
|
-
* know
|
|
37
|
+
* runtime session with the server's own id. A handle the transport does not
|
|
38
|
+
* know — one it never issued, or one it forgot — is never sent: the request
|
|
39
|
+
* fails with `LocalSessionHandleLostError`, thrown from the transport's
|
|
40
|
+
* `fetch`. It is not a 404: no server said anything, and the runtime session
|
|
41
|
+
* behind a forgotten handle may still run — it can no longer be stopped from
|
|
42
|
+
* here, because its id went with the handle.
|
|
39
43
|
*
|
|
40
44
|
* Why a handle and not the server's id: the server's ids are unique only as far
|
|
41
45
|
* as the server makes them. One that numbers sessions per process hands every
|
|
@@ -47,12 +51,16 @@
|
|
|
47
51
|
* between users.
|
|
48
52
|
*
|
|
49
53
|
* At most {@link MAX_CONNECTIONS} connections are remembered, least recently
|
|
50
|
-
* used forgotten first
|
|
54
|
+
* used forgotten first. A client's `DELETE` — sent by `terminate()`, never by
|
|
55
|
+
* `close()`, which ends only the local side — forgets its own handle first, and
|
|
56
|
+
* then becomes `StopRuntimeSession` for that connection's runtime session
|
|
57
|
+
* (`transport.ts`), answered like a server would answer the `DELETE`.
|
|
51
58
|
*
|
|
52
59
|
* Pattern: Strategy. Role: outer ring, vendor fact. Holds no credential.
|
|
53
60
|
*/
|
|
54
61
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
62
|
exports.sessionStrategy = exports.MAX_CONNECTIONS = exports.MCP_SESSION_HEADER = exports.AGENTCORE_RUNTIME_SESSION_HEADER = void 0;
|
|
63
|
+
const toolSessions_js_1 = require("../../../tools/toolSessions.js");
|
|
56
64
|
/** The runtime session header, as `InvokeAgentRuntime` binds `runtimeSessionId` to it. */
|
|
57
65
|
exports.AGENTCORE_RUNTIME_SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
|
|
58
66
|
/** The MCP Streamable HTTP session header. */
|
|
@@ -97,15 +105,19 @@ function reuse() {
|
|
|
97
105
|
request(headers, method) {
|
|
98
106
|
const handle = headers.get(exports.MCP_SESSION_HEADER);
|
|
99
107
|
const known = handle === null ? undefined : connections.get(handle);
|
|
100
|
-
// A handle this transport did not issue, or has forgotten: fail closed
|
|
108
|
+
// A handle this transport did not issue, or has forgotten: fail closed,
|
|
109
|
+
// and say what happened — nothing was sent, and nothing answered.
|
|
101
110
|
if (handle !== null && known === undefined)
|
|
102
|
-
|
|
111
|
+
throw new toolSessions_js_1.LocalSessionHandleLostError();
|
|
103
112
|
const connection = known ?? { runtimeId: newId() };
|
|
104
113
|
if (handle !== null) {
|
|
105
|
-
|
|
114
|
+
// Ending the session: the handle is forgotten FIRST, so nothing more is
|
|
115
|
+
// ever sent under it, then the runtime session is stopped.
|
|
116
|
+
if (method === 'DELETE') {
|
|
106
117
|
connections.delete(handle);
|
|
107
|
-
|
|
108
|
-
|
|
118
|
+
return { stop: connection.runtimeId };
|
|
119
|
+
}
|
|
120
|
+
remember(handle, connection);
|
|
109
121
|
}
|
|
110
122
|
// Set, not merged: these are the only session ids this request sends.
|
|
111
123
|
headers.set(exports.AGENTCORE_RUNTIME_SESSION_HEADER, connection.runtimeId);
|
|
@@ -126,8 +138,7 @@ function reuse() {
|
|
|
126
138
|
remember(issued, { ...connection, serverSessionId: returned });
|
|
127
139
|
return withSessionHeader(response, issued);
|
|
128
140
|
}
|
|
129
|
-
|
|
130
|
-
connection.serverSessionId = returned;
|
|
141
|
+
connection.serverSessionId = returned;
|
|
131
142
|
return withSessionHeader(response, handle);
|
|
132
143
|
},
|
|
133
144
|
};
|
|
@@ -165,15 +176,4 @@ function withSessionHeader(response, value) {
|
|
|
165
176
|
headers,
|
|
166
177
|
});
|
|
167
178
|
}
|
|
168
|
-
/**
|
|
169
|
-
* The MCP Streamable HTTP answer to a session the server does not know: 404,
|
|
170
|
-
* after which a client starts a new session with `initialize`.
|
|
171
|
-
*/
|
|
172
|
-
function sessionNotFound() {
|
|
173
|
-
return new Response(JSON.stringify({
|
|
174
|
-
jsonrpc: '2.0',
|
|
175
|
-
id: null,
|
|
176
|
-
error: { code: -32001, message: 'Session not found' },
|
|
177
|
-
}), { status: 404, headers: { 'content-type': 'application/json' } });
|
|
178
|
-
}
|
|
179
179
|
//# sourceMappingURL=session.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/adapters/mcp/agentcoreRuntime/session.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../src/adapters/mcp/agentcoreRuntime/session.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;;;AAEH,oEAA6E;AAE7E,0FAA0F;AAC7E,QAAA,gCAAgC,GAAG,6CAA6C,CAAC;AAE9F,8CAA8C;AACjC,QAAA,kBAAkB,GAAG,gBAAgB,CAAC;AAyBnD,oGAAoG;AACvF,QAAA,eAAe,GAAG,GAAG,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,KAAK,GAAG,GAAW,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;AAE3D;;;;GAIG;AACH,SAAgB,eAAe,CAAC,IAA6B;IAC3D,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,KAAK,EAAE,CAAC;IACrC,IAAI,IAAI,KAAK,UAAU;QAAE,OAAO,OAAO,EAAE,CAAC;IAC1C,MAAM,IAAI,SAAS,CACjB,gFAAgF;QAC9E,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,oEAAoE;QAC3F,mFAAmF,CACtF,CAAC;AACJ,CAAC;AARD,0CAQC;AAQD,SAAS,KAAK;IACZ,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IAClD,MAAM,QAAQ,GAAG,CAAC,MAAc,EAAE,UAAsB,EAAQ,EAAE;QAChE,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3B,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,0BAA0B;QAC/D,OAAO,WAAW,CAAC,IAAI,GAAG,uBAAe,EAAE,CAAC;Y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C;IACjD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,MAAM,CAAC,0BAAkB,CAAC,CAAC;;QACvD,OAAO,CAAC,GAAG,CAAC,0BAAkB,EAAE,KAAK,CAAC,CAAC;IAC5C,OAAO,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE;QACjC,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,OAAO;KACR,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -63,6 +63,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
63
63
|
exports.agentCoreRuntimeUrl = exports.agentCoreRuntimeMcpTransport = exports.SESSION_BUSY_RETRY_DEFAULTS = void 0;
|
|
64
64
|
const gatewayTransport_js_1 = require("../../../mcp/gatewayTransport.js");
|
|
65
65
|
const throttleRetry_js_1 = require("../../../mcp/throttleRetry.js");
|
|
66
|
+
const requestGuard_js_1 = require("../../../mcp/requestGuard.js");
|
|
66
67
|
const invoke_js_1 = require("./invoke.js");
|
|
67
68
|
const safeAnswer_js_1 = require("./safeAnswer.js");
|
|
68
69
|
const session_js_1 = require("./session.js");
|
|
@@ -108,10 +109,46 @@ function agentCoreRuntimeMcpTransport(options) {
|
|
|
108
109
|
return {
|
|
109
110
|
transport: 'http',
|
|
110
111
|
url,
|
|
111
|
-
fetch: sessionedFetch(session, send, { rules: busy === undefined ? [] : [busy] }),
|
|
112
|
+
fetch: sessionedFetch(session, send, { rules: busy === undefined ? [] : [busy] }, stopUrl(options)),
|
|
113
|
+
settings: settingsOf(options),
|
|
112
114
|
};
|
|
113
115
|
}
|
|
114
116
|
exports.agentCoreRuntimeMcpTransport = agentCoreRuntimeMcpTransport;
|
|
117
|
+
/**
|
|
118
|
+
* What this transport keeps inside its `fetch`, stated as data
|
|
119
|
+
* (`McpHttpTransport.settings`): its auth strategy and session strategy, and on
|
|
120
|
+
* the bearer path the service, scopes, mode and credential provider id a token
|
|
121
|
+
* is vended for. Names and modes only — never a credential.
|
|
122
|
+
*/
|
|
123
|
+
function settingsOf(options) {
|
|
124
|
+
const auth = options.auth ?? 'sigv4';
|
|
125
|
+
const session = options.session ?? 'per-call';
|
|
126
|
+
if (auth === 'sigv4')
|
|
127
|
+
return { auth: 'sigv4', session };
|
|
128
|
+
return {
|
|
129
|
+
auth: 'bearer',
|
|
130
|
+
session,
|
|
131
|
+
service: auth.service ?? DEFAULT_BEARER_SERVICE,
|
|
132
|
+
...(auth.scopes !== undefined && { scopes: [...auth.scopes] }),
|
|
133
|
+
mode: auth.mode ?? 'machine',
|
|
134
|
+
credentials: auth.bearer.id,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Where `StopRuntimeSession` goes over HTTPS:
|
|
139
|
+
* `POST https://bedrock-agentcore.{region}.amazonaws.com/runtimes/{url-encoded ARN}/stopruntimesession`,
|
|
140
|
+
* with `qualifier` as a query parameter when given — the operation's request
|
|
141
|
+
* line. The SigV4 path sends the AWS SDK's command instead, and ignores it.
|
|
142
|
+
*/
|
|
143
|
+
function stopUrl(options) {
|
|
144
|
+
const query = new URLSearchParams();
|
|
145
|
+
if (options.qualifier)
|
|
146
|
+
query.set('qualifier', options.qualifier);
|
|
147
|
+
const base = `https://bedrock-agentcore.${options.region}.amazonaws.com/runtimes/` +
|
|
148
|
+
`${encodeURIComponent(options.agentRuntimeArn)}/stopruntimesession`;
|
|
149
|
+
const search = query.toString();
|
|
150
|
+
return search === '' ? base : `${base}?${search}`;
|
|
151
|
+
}
|
|
115
152
|
/**
|
|
116
153
|
* The transport's fetch: the session around ONE retry series around the auth.
|
|
117
154
|
*
|
|
@@ -122,19 +159,56 @@ exports.agentCoreRuntimeMcpTransport = agentCoreRuntimeMcpTransport;
|
|
|
122
159
|
* rebuilt into this same series, inside the session and the rewrite — never
|
|
123
160
|
* wrapped around them as a second loop — and so is the client's request ledger.
|
|
124
161
|
*/
|
|
125
|
-
function sessionedFetch(session, send, spec) {
|
|
162
|
+
function sessionedFetch(session, send, spec, stopAt) {
|
|
126
163
|
const retried = (0, throttleRetry_js_1.retryingFetchFor)(send, spec);
|
|
127
164
|
const sessioned = async (input, init) => {
|
|
128
165
|
const headers = new Headers(init?.headers);
|
|
166
|
+
// A handle this transport does not hold throws here, before anything is
|
|
167
|
+
// sent (`session.ts` · `LocalSessionHandleLostError`).
|
|
129
168
|
const step = session.request(headers, (init?.method ?? 'GET').toUpperCase());
|
|
130
169
|
if ('answer' in step)
|
|
131
170
|
return step.answer;
|
|
171
|
+
if ('stop' in step)
|
|
172
|
+
return stopSession(retried, stopAt, step.stop, init);
|
|
132
173
|
const response = await retried(input, { ...init, headers });
|
|
133
174
|
// What the MCP client may read of a failure is rewritten from safe parts —
|
|
134
175
|
// ONE rule for both auth paths, after the retry has read the original.
|
|
135
176
|
return step.settle(await (0, safeAnswer_js_1.safeAnswer)(response));
|
|
136
177
|
};
|
|
137
|
-
return (0, throttleRetry_js_1.joinableRetry)(sessioned, (join) => sessionedFetch(session, send, (0, throttleRetry_js_1.joinedSpec)(spec, join)));
|
|
178
|
+
return (0, throttleRetry_js_1.joinableRetry)(sessioned, (join) => sessionedFetch(session, send, (0, throttleRetry_js_1.joinedSpec)(spec, join), stopAt));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* A `'reuse'` connection's `DELETE`, as `StopRuntimeSession` for its runtime
|
|
182
|
+
* session — sent through the SAME series as every other request, so the
|
|
183
|
+
* platform's 409 while it starts or stops the session is retried like the
|
|
184
|
+
* session-busy refusal, signed (or vended) afresh each attempt. Answered as a
|
|
185
|
+
* server answers the `DELETE`: 204 once stopped; 404 when the platform no longer
|
|
186
|
+
* holds the session ("not found or already terminated"); otherwise the safe
|
|
187
|
+
* failure (`safeAnswer.ts`), its status kept.
|
|
188
|
+
*
|
|
189
|
+
* Carries the `DELETE`'s signal and, for a pooled client, its send gate
|
|
190
|
+
* (`mcp/requestGuard.ts`), so a deadline or a stale binding sends nothing.
|
|
191
|
+
*/
|
|
192
|
+
async function stopSession(retried, stopAt, runtimeSessionId, init) {
|
|
193
|
+
const stop = {
|
|
194
|
+
method: 'POST',
|
|
195
|
+
headers: {
|
|
196
|
+
'content-type': 'application/json',
|
|
197
|
+
[session_js_1.AGENTCORE_RUNTIME_SESSION_HEADER]: runtimeSessionId,
|
|
198
|
+
},
|
|
199
|
+
// The operation's idempotency token: one per stop, so an attempt the
|
|
200
|
+
// series repeats is the same stop.
|
|
201
|
+
body: JSON.stringify({ clientToken: globalThis.crypto.randomUUID() }),
|
|
202
|
+
...(init?.signal !== undefined && init.signal !== null && { signal: init.signal }),
|
|
203
|
+
[invoke_js_1.STOP_RUNTIME_SESSION]: runtimeSessionId,
|
|
204
|
+
};
|
|
205
|
+
const guard = (0, requestGuard_js_1.guardOf)(init);
|
|
206
|
+
const response = await retried(stopAt, guard === undefined ? stop : (0, requestGuard_js_1.withGuard)(stop, guard));
|
|
207
|
+
if (response.ok) {
|
|
208
|
+
await response.body?.cancel().catch(() => undefined);
|
|
209
|
+
return new Response(null, { status: 204, statusText: 'No Content' });
|
|
210
|
+
}
|
|
211
|
+
return (0, safeAnswer_js_1.safeAnswer)(response);
|
|
138
212
|
}
|
|
139
213
|
/**
|
|
140
214
|
* The HTTPS endpoint of a runtime's MCP server:
|
|
@@ -173,7 +247,7 @@ function authStrategy(options, url) {
|
|
|
173
247
|
const auth = options.auth ?? 'sigv4';
|
|
174
248
|
const sdk = injectedSdk(options);
|
|
175
249
|
if (auth === 'sigv4') {
|
|
176
|
-
const { client, InvokeAgentRuntimeCommand } = (0, invoke_js_1.invokeSdk)({
|
|
250
|
+
const { client, InvokeAgentRuntimeCommand, StopRuntimeSessionCommand } = (0, invoke_js_1.invokeSdk)({
|
|
177
251
|
region: options.region,
|
|
178
252
|
...(options.client !== undefined && { client: options.client }),
|
|
179
253
|
...(sdk !== undefined && { sdk }),
|
|
@@ -182,7 +256,7 @@ function authStrategy(options, url) {
|
|
|
182
256
|
agentRuntimeArn: options.agentRuntimeArn,
|
|
183
257
|
...(options.qualifier !== undefined && { qualifier: options.qualifier }),
|
|
184
258
|
...(options.accountId !== undefined && { accountId: options.accountId }),
|
|
185
|
-
}, client, InvokeAgentRuntimeCommand);
|
|
259
|
+
}, client, InvokeAgentRuntimeCommand, StopRuntimeSessionCommand);
|
|
186
260
|
}
|
|
187
261
|
if (auth !== null && typeof auth === 'object' && auth.bearer !== undefined) {
|
|
188
262
|
if (typeof auth.bearer.getCredential !== 'function') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../../src/adapters/mcp/agentcoreRuntime/transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;;;AAEH,0EAI0C;AAC1C,oEASuC;
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../../src/adapters/mcp/agentcoreRuntime/transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;;;AAEH,0EAI0C;AAC1C,oEASuC;AAEvC,kEAAkE;AAElE,2CAMqB;AACrB,mDAA6C;AAC7C,6CAKsB;AACtB,qDAAqE;AAkIrE;;;;;;;;GAQG;AACU,QAAA,2BAA2B,GAAkB,MAAM,CAAC,MAAM,CAAC;IACtE,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,QAAQ;IACtB,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,CAAC;IACb,MAAM,EAAE,OAAO;IACf,UAAU,EAAE,QAAQ;CACrB,CAAC,CAAC;AAEH,kFAAkF;AAClF,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEzC,iFA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CAAC;IACD,MAAM,IAAI,SAAS,CACjB,6FAA6F;QAC3F,SAAS,QAAQ,CAAC,IAAI,CAAC,+DAA+D;QACtF,uDAAuD,CAC1D,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,SAAS,WAAW,CAClB,OAA4C;IAE5C,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACtC,IAAI,GAAG,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CACjB,qFAAqF;YACnF,yDAAyD,CAC5D,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,IAAI,MAAM,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,eAAe,KAAK,CAAC,MAAM,aAAa,CAAC;IAC/E,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,wBAAwB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAC/F,OAAO,OAAO,KAAK,CAAC;AACtB,CAAC"}
|
package/dist/core/Agent.js
CHANGED
|
@@ -4779,6 +4779,12 @@ class Agent extends RunnerBase_js_1.RunnerBase {
|
|
|
4779
4779
|
integrityLedger: this.integrityLedgerHolder,
|
|
4780
4780
|
...(this.externalToolProvider && { toolProvider: this.externalToolProvider }),
|
|
4781
4781
|
...(this.externalToolProvider && { providerToolCache }),
|
|
4782
|
+
// The caller of THIS run, for `ToolDispatchContext.callerIdentity`: the
|
|
4783
|
+
// instance's caller on its own run, the member's run on a mount — never a
|
|
4784
|
+
// derived identity (the `hiddenSkillIdsNow` precedent).
|
|
4785
|
+
...(this.externalToolProvider && {
|
|
4786
|
+
callerIdentity: (scope) => this.ownScopes.has(scope) ? this.lastRunIdentity : (0, memberRun_js_1.memberIdentityIn)(scope),
|
|
4787
|
+
}),
|
|
4782
4788
|
toolClaimants,
|
|
4783
4789
|
servedTools,
|
|
4784
4790
|
...(readSkillFor && { readSkillFor }),
|