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
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* work — an admitted operation's charge, and the work under it until that work
|
|
3
|
+
* has settled.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: one object per unit of work that is at once the request guard
|
|
6
|
+
* (`mcp/requestGuard.ts`) and the count of what is still running.
|
|
7
|
+
* Role: The pool's third budget (`docs/design/2026-10-mcp-client-pool.md`
|
|
8
|
+
* § 5.3). The accounting unit is the admitted LOGICAL operation: a
|
|
9
|
+
* `tools/call`, a listing (one `list(ctx)` for one conversation), an
|
|
10
|
+
* `acquire` and an ending each take one slot at admission. Setup an
|
|
11
|
+
* operation performs for itself — the open of its key's client, the
|
|
12
|
+
* revalidating `tools/list` of a replacement — runs inside that slot.
|
|
13
|
+
*
|
|
14
|
+
* AN ABORT IS NOT SETTLEMENT. A slot is released only when the operation's
|
|
15
|
+
* logical request has its answer AND every piece of work under it has settled:
|
|
16
|
+
* the `send()` it made, a credential vend, an attempt's `fetch`, an AWS `send`,
|
|
17
|
+
* the open it owns. A caller's timeout answers the caller; it frees nothing.
|
|
18
|
+
* Work that never settles keeps its charge — `stats().unsettled` reports it,
|
|
19
|
+
* and the budget refuses new work rather than admit it against room that does
|
|
20
|
+
* not exist. There is no release that returns capacity sooner.
|
|
21
|
+
*/
|
|
22
|
+
import type { RequestGuard } from '../requestGuard.js';
|
|
23
|
+
/** What a unit of work is doing now — what `stats().unsettled` counts it under. */
|
|
24
|
+
export type WorkKind = 'open' | 'listing' | 'call' | 'ending';
|
|
25
|
+
/** What an operation is, as the budget admits it. */
|
|
26
|
+
export type OperationKind = 'listing' | 'call' | 'acquire' | 'ending';
|
|
27
|
+
/** What a request's answer proved, as the pool's fetch read it (`pool.ts`). */
|
|
28
|
+
export type WorkEvidence = 'server-404' | 'handle-lost';
|
|
29
|
+
/**
|
|
30
|
+
* One unit of pooled work: its requests are checked against it at every
|
|
31
|
+
* boundary (`check`), and every promise started for it is counted until it
|
|
32
|
+
* settles (`track`). It is SETTLED once its logical part has finished and the
|
|
33
|
+
* count is zero.
|
|
34
|
+
*/
|
|
35
|
+
export declare class Work implements RequestGuard {
|
|
36
|
+
/** What it is doing now. */
|
|
37
|
+
phase: WorkKind;
|
|
38
|
+
private readonly link;
|
|
39
|
+
private pending;
|
|
40
|
+
private finished;
|
|
41
|
+
private done;
|
|
42
|
+
/** Still running underneath when the caller was answered: it lingered. */
|
|
43
|
+
private lingered;
|
|
44
|
+
private readonly listeners;
|
|
45
|
+
/** What `check` asks besides the abort — a call's binding. */
|
|
46
|
+
private extra;
|
|
47
|
+
/** What the latest answered request proved, if anything. */
|
|
48
|
+
evidence: WorkEvidence | undefined;
|
|
49
|
+
constructor(
|
|
50
|
+
/** What it is doing now. */
|
|
51
|
+
phase: WorkKind, sources: readonly (AbortSignal | undefined)[]);
|
|
52
|
+
/** What aborts its own work: its sources, its deadline, its caller detaching. */
|
|
53
|
+
get signal(): AbortSignal;
|
|
54
|
+
/** True once its logical part finished and everything under it settled. */
|
|
55
|
+
get settled(): boolean;
|
|
56
|
+
/** Its caller was answered while work under it still ran. */
|
|
57
|
+
get unsettledPastAnswer(): boolean;
|
|
58
|
+
/** Abort its work with `reason` (a deadline, a detached caller). Idempotent. */
|
|
59
|
+
abort(reason: unknown): void;
|
|
60
|
+
/** Ask `gate` too, each time a request is checked. */
|
|
61
|
+
guardWith(gate: () => void): void;
|
|
62
|
+
/**
|
|
63
|
+
* The send gate: refused once its caller was answered (nothing more is sent
|
|
64
|
+
* for an answered operation), once aborted, or when the extra gate refuses.
|
|
65
|
+
*/
|
|
66
|
+
check(): void;
|
|
67
|
+
/** Count `work` until it settles. Never throws; never surfaces its rejection. */
|
|
68
|
+
track(work: PromiseLike<unknown>): void;
|
|
69
|
+
/** Record what a request's answer proved. */
|
|
70
|
+
note(evidence: WorkEvidence): void;
|
|
71
|
+
/**
|
|
72
|
+
* Its logical part is over: the caller has its answer. It settles now, or —
|
|
73
|
+
* when work under it still runs — when that work does.
|
|
74
|
+
*/
|
|
75
|
+
finish(): void;
|
|
76
|
+
/** Did it linger — answered while work under it ran? Read once it settled. */
|
|
77
|
+
get settledLate(): boolean;
|
|
78
|
+
/** Call `listener` once it has settled (at once when it already has). */
|
|
79
|
+
onSettled(listener: () => void): void;
|
|
80
|
+
/** A promise that resolves once it has settled. */
|
|
81
|
+
whenSettled(): Promise<void>;
|
|
82
|
+
private settleIfDone;
|
|
83
|
+
}
|
|
84
|
+
/** An admitted operation: a unit of work that holds one slot of the budget. */
|
|
85
|
+
export declare class Operation extends Work {
|
|
86
|
+
readonly kind: OperationKind;
|
|
87
|
+
/** When it was admitted, on the pool's clock. */
|
|
88
|
+
readonly admittedAt: number;
|
|
89
|
+
constructor(kind: OperationKind, phase: WorkKind, sources: readonly (AbortSignal | undefined)[],
|
|
90
|
+
/** When it was admitted, on the pool's clock. */
|
|
91
|
+
admittedAt: number);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The pool-wide operation budget: at most `max` operations charged, each from
|
|
95
|
+
* its admission until it has SETTLED (see the module note). Admission is the
|
|
96
|
+
* only way in; settlement the only way out.
|
|
97
|
+
*/
|
|
98
|
+
export declare class OperationBudget {
|
|
99
|
+
readonly max: number;
|
|
100
|
+
private readonly charged;
|
|
101
|
+
private readonly onRelease;
|
|
102
|
+
constructor(max: number);
|
|
103
|
+
/** Operations charged now. */
|
|
104
|
+
get count(): number;
|
|
105
|
+
/** Is there a free slot? */
|
|
106
|
+
get hasRoom(): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Admit one operation, or `undefined` when the budget is full. The slot is
|
|
109
|
+
* charged from here until the operation settles.
|
|
110
|
+
*/
|
|
111
|
+
admit(kind: OperationKind, phase: WorkKind, sources: readonly (AbortSignal | undefined)[], now: number): Operation | undefined;
|
|
112
|
+
/** Call `listener` each time an operation settles and frees its slot. Returns the unsubscribe. */
|
|
113
|
+
whenReleased(listener: (operation: Operation) => void): () => void;
|
|
114
|
+
/** Charged work whose caller was already answered and which has not settled, by what it is doing. */
|
|
115
|
+
unsettled(): Record<WorkKind, number>;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=work.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work.d.ts","sourceRoot":"","sources":["../../../../src/mcp/pool/work.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,mFAAmF;AACnF,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE9D,qDAAqD;AACrD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtE,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,aAAa,CAAC;AAExD;;;;;GAKG;AACH,qBAAa,IAAK,YAAW,YAAY;IAcrC,4BAA4B;IACrB,KAAK,EAAE,QAAQ;IAdxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAsC;IAC3D,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,IAAI,CAAS;IACrB,0EAA0E;IAC1E,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IACnD,8DAA8D;IAC9D,OAAO,CAAC,KAAK,CAA2B;IACxC,4DAA4D;IAC5D,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;;IAGjC,4BAA4B;IACrB,KAAK,EAAE,QAAQ,EACtB,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,SAAS,CAAC,EAAE;IAK/C,iFAAiF;IACjF,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,2EAA2E;IAC3E,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,6DAA6D;IA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Aa,EACnB,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,SAAS,CAAC,EAAE,EAC7C,GAAG,EAAE,MAAM,GACV,SAAS,GAAG,SAAS;IAWxB,kGAAkG;IAClG,YAAY,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,GAAG,MAAM,IAAI;IAQlE,qGAAqG;IACrG,SAAS,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;CAOtC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* requestGuard — the last check a pooled operation's request meets at every
|
|
3
|
+
* boundary the library controls, and the count of the work under it until
|
|
4
|
+
* that work has settled.
|
|
5
|
+
*
|
|
6
|
+
* Pattern: one object per operation, carried on the request's `init` under a
|
|
7
|
+
* library-private symbol.
|
|
8
|
+
* Role: The send gate of the MCP client pool (`mcp/pool/`). The MCP SDK and
|
|
9
|
+
* the transport wait between a tool call and the network — `send()`
|
|
10
|
+
* awaits its own headers, a gateway vends a credential inside `fetch`,
|
|
11
|
+
* the AWS SDK signs inside `send` — so the last check cannot live in
|
|
12
|
+
* the tool. Each place that waits asks the request's guard after its
|
|
13
|
+
* wait and before it hands the request on:
|
|
14
|
+
*
|
|
15
|
+
* - the watched `send` (`requestLedger.ts`) — the last boundary on stdio,
|
|
16
|
+
* whose `send` writes without waiting;
|
|
17
|
+
* - the pool's own fetch, before the request enters the transport;
|
|
18
|
+
* - the retry series, before every attempt (`throttleRetry.ts`);
|
|
19
|
+
* - the vending fetch, once the credential has arrived (`gatewayTransport.ts`);
|
|
20
|
+
* - the AWS SDK command, after it is signed and before its request handler
|
|
21
|
+
* sends it (`adapters/mcp/agentcoreRuntime/invoke.ts`).
|
|
22
|
+
*
|
|
23
|
+
* A refusal there sends nothing. What no guard can recall is a request already
|
|
24
|
+
* handed on: to the network, or to an app's own `fetch`.
|
|
25
|
+
*
|
|
26
|
+
* The same object COUNTS the work under the request: every promise a boundary
|
|
27
|
+
* starts for it — an attempt's `fetch`, a credential vend, an AWS `send` — is
|
|
28
|
+
* tracked until it settles, whatever the caller was told. An abort is a
|
|
29
|
+
* signal, not proof that the work stopped, so the pool keeps an operation
|
|
30
|
+
* charged until this count says it has.
|
|
31
|
+
*
|
|
32
|
+
* The guard rides `init` under a symbol, so a layer that rebuilds `init` with
|
|
33
|
+
* a spread (`{ ...init, headers }`) carries it on, and nothing reaches the
|
|
34
|
+
* wire: `fetch` reads only the fields it knows. A request with no guard — every
|
|
35
|
+
* request of a client the pool did not build — is exactly what it always was.
|
|
36
|
+
*/
|
|
37
|
+
/** @internal The `init` key a pooled request's guard rides under. */
|
|
38
|
+
export declare const REQUEST_GUARD: unique symbol;
|
|
39
|
+
/** What one pooled operation's requests are checked against, and counted by. */
|
|
40
|
+
export interface RequestGuard {
|
|
41
|
+
/**
|
|
42
|
+
* Throw the refusal when the request may not be handed on now — its binding
|
|
43
|
+
* went stale, or its operation was aborted or ran out of time. Synchronous:
|
|
44
|
+
* nothing waits between this check and the hand-off it guards.
|
|
45
|
+
*/
|
|
46
|
+
check(): void;
|
|
47
|
+
/** Count `work` as work under this request until it settles. Never throws. */
|
|
48
|
+
track(work: PromiseLike<unknown>): void;
|
|
49
|
+
/** What aborts the operation's own work — linked into each request it makes. */
|
|
50
|
+
readonly signal?: AbortSignal;
|
|
51
|
+
}
|
|
52
|
+
/** The guard `init` carries, or `undefined` — a request no pool sent. Never throws. */
|
|
53
|
+
export declare function guardOf(init: RequestInit | undefined): RequestGuard | undefined;
|
|
54
|
+
/** `init` carrying `guard`: a new object, every other field in place. */
|
|
55
|
+
export declare function withGuard(init: RequestInit | undefined, guard: RequestGuard): RequestInit;
|
|
56
|
+
/**
|
|
57
|
+
* Track `work` under `init`'s guard, when it has one, and hand `work` back
|
|
58
|
+
* unchanged. The one line every boundary uses.
|
|
59
|
+
*/
|
|
60
|
+
export declare function trackedBy<T extends PromiseLike<unknown>>(init: RequestInit | undefined, work: T): T;
|
|
61
|
+
/**
|
|
62
|
+
* @internal The call-context key a pooled tool hands its guard down under, to
|
|
63
|
+
* the MCP tool it runs (`callLifetime.ts` · `openCall` issues the call with
|
|
64
|
+
* it). Enumerable, so a wrapper that copies the context keeps it.
|
|
65
|
+
*/
|
|
66
|
+
export declare const CALL_GUARD: unique symbol;
|
|
67
|
+
/** `ctx` carrying `guard` for the MCP tool it is handed to. */
|
|
68
|
+
export declare function withCallGuard<C extends object>(ctx: C, guard: RequestGuard): C;
|
|
69
|
+
/** The guard a call's context carries, or `undefined`. Never throws, whatever `ctx` is. */
|
|
70
|
+
export declare function callGuardOf(ctx: unknown): RequestGuard | undefined;
|
|
71
|
+
//# sourceMappingURL=requestGuard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requestGuard.d.ts","sourceRoot":"","sources":["../../../src/mcp/requestGuard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,qEAAqE;AACrE,eAAO,MAAM,aAAa,EAAE,OAAO,MAAmD,CAAC;AAEvF,gFAAgF;AAChF,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAAC;IACd,8EAA8E;IAC9E,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;IACxC,gFAAgF;IAChF,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAKD,uFAAuF;AACvF,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAa/E;AAED,yEAAyE;AACzE,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,WAAW,CAEzF;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,CAAC,OAAO,CAAC,EACtD,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,IAAI,EAAE,CAAC,GACN,CAAC,CAGH;AAID;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,OAAO,MAAgD,CAAC;AAEjF,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,GAAG,CAAC,CAE9E;AAED,2FAA2F;AAC3F,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAalE"}
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
* has stopped waiting for them.
|
|
68
68
|
*/
|
|
69
69
|
import type { RequestEvidenceSink } from '../tools/requestEvidence.js';
|
|
70
|
+
import type { RequestGuard } from './requestGuard.js';
|
|
70
71
|
import { RequestReplay } from './replay.js';
|
|
71
72
|
/** One call's claim on the request it sends. */
|
|
72
73
|
export interface RequestTicket {
|
|
@@ -83,6 +84,11 @@ export interface ClaimedRequest {
|
|
|
83
84
|
readonly cancelled: AbortSignal;
|
|
84
85
|
/** What this request's series and its call share (`replay.ts` · `RequestReplay`). */
|
|
85
86
|
readonly replay: RequestReplay;
|
|
87
|
+
/**
|
|
88
|
+
* The send gate of the pooled call this request belongs to (`requestGuard.ts`)
|
|
89
|
+
* — absent for a call no pool made.
|
|
90
|
+
*/
|
|
91
|
+
readonly guard?: RequestGuard;
|
|
86
92
|
}
|
|
87
93
|
/** How a connection's ledger is set up. */
|
|
88
94
|
export interface RequestLedgerOptions {
|
|
@@ -90,6 +96,16 @@ export interface RequestLedgerOptions {
|
|
|
90
96
|
readonly server: string;
|
|
91
97
|
/** The `'app-authorized'` policy is in force: see the module note. */
|
|
92
98
|
readonly strict: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* A pooled client's guard for every message that does not carry its own — its
|
|
101
|
+
* open, its listing, its ending (`mcp/pool/`) — and for a `tools/call` that
|
|
102
|
+
* reached `send` without a call carrying a guard: the pool answers that one
|
|
103
|
+
* with a guard that refuses it, so a pooled request is never sent unchecked,
|
|
104
|
+
* under either replay policy. A request it guards is checked before it is
|
|
105
|
+
* sent, and every message's send is counted under it. Absent for a client no
|
|
106
|
+
* pool built.
|
|
107
|
+
*/
|
|
108
|
+
readonly guardFor?: (message: unknown) => RequestGuard | undefined;
|
|
93
109
|
}
|
|
94
110
|
type JsonRpcId = string | number;
|
|
95
111
|
/** The request a call's marker was matched to. */
|
|
@@ -105,6 +121,8 @@ export interface MatchedRequest {
|
|
|
105
121
|
export interface IssuedCall {
|
|
106
122
|
readonly marker: string;
|
|
107
123
|
readonly ticket?: RequestTicket;
|
|
124
|
+
/** The pooled call's send gate, when a pool made the call (`requestGuard.ts`). */
|
|
125
|
+
readonly guard?: RequestGuard;
|
|
108
126
|
/** Set once, by the watched `send`: a marker matches ONE request. */
|
|
109
127
|
readonly request?: MatchedRequest;
|
|
110
128
|
}
|
|
@@ -117,6 +135,12 @@ export declare class RequestLedger {
|
|
|
117
135
|
private readonly sending;
|
|
118
136
|
/** Matched requests whose JSON-RPC answer is awaited (`strict` only) — by id. */
|
|
119
137
|
private readonly awaiting;
|
|
138
|
+
/**
|
|
139
|
+
* A pooled call's guard by its request's id, until the call settles: the SDK's
|
|
140
|
+
* `notifications/cancelled` for that request is work started for the call, and
|
|
141
|
+
* is counted under it (`requestGuard.ts`).
|
|
142
|
+
*/
|
|
143
|
+
private readonly guards;
|
|
120
144
|
private initializeId;
|
|
121
145
|
private initializeAnswered;
|
|
122
146
|
private markers;
|
|
@@ -129,7 +153,7 @@ export declare class RequestLedger {
|
|
|
129
153
|
* is where its attempts are filed, when the call carries the run's evidence
|
|
130
154
|
* port.
|
|
131
155
|
*/
|
|
132
|
-
issue(ticket?: RequestTicket): IssuedCall;
|
|
156
|
+
issue(ticket?: RequestTicket, guard?: RequestGuard): IssuedCall;
|
|
133
157
|
/** `call` settled: forget it, and stop awaiting its request's answer. */
|
|
134
158
|
settle(call: IssuedCall): void;
|
|
135
159
|
/** The connection closed: nothing it sent is awaited, and no call is pending, any more. */
|
|
@@ -172,6 +196,16 @@ export declare class RequestLedger {
|
|
|
172
196
|
claim(body: unknown): ClaimedRequest | undefined;
|
|
173
197
|
/** One message through the watched transport. */
|
|
174
198
|
private send;
|
|
199
|
+
/**
|
|
200
|
+
* Any message but a `tools/call`: sent as it always was — unless a pool
|
|
201
|
+
* guards it (`guardFor`), and then a REQUEST is checked first and refused
|
|
202
|
+
* unsent, and every message's send is counted under the guard.
|
|
203
|
+
* Notifications are never refused: a `notifications/cancelled` is the
|
|
204
|
+
* courtesy that tells the server to stop.
|
|
205
|
+
*/
|
|
206
|
+
private sendOther;
|
|
207
|
+
/** The guard of the pooled call a `notifications/cancelled` names, if any. */
|
|
208
|
+
private cancelledGuard;
|
|
175
209
|
/** The `initialize` request: its answer is the one that proves the observer is in place. */
|
|
176
210
|
private noteInitialize;
|
|
177
211
|
/** The SDK gave a request up: stop the series still sending it, and stop awaiting its answer. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestLedger.d.ts","sourceRoot":"","sources":["../../../src/mcp/requestLedger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,gDAAgD;AAChD,MAAM,WAAW,aAAa;IAC5B,8CAA8C;IAC9C,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,kEAAkE;AAClE,MAAM,WAAW,cAAc;IAC7B,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,+EAA+E;IAC/E,QAAQ,C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,MAAM,CAErB;IAED,8GAA8G;IAC9G,YAAY,IAAI,OAAO;IAMvB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAyBpD,4FAA4F;IAC5F,OAAO,CAAC,aAAa;IAcrB,0FAA0F;IAC1F,OAAO,CAAC,OAAO;IAUf;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS;IAmBhD,iDAAiD;IACjD,OAAO,CAAC,IAAI;IAyDZ;;;;;;OAMG;IACH,OAAO,CAAC,SAAS;IAiBjB,8EAA8E;IAC9E,OAAO,CAAC,cAAc;IAStB,4FAA4F;IAC5F,OAAO,CAAC,cAAc;IAQtB,iGAAiG;IACjG,OAAO,CAAC,aAAa;CAStB"}
|
|
@@ -119,11 +119,13 @@ export declare class SeriesEvidence {
|
|
|
119
119
|
/**
|
|
120
120
|
* The series delivered a response. It is the last attempt's — an answer, or a
|
|
121
121
|
* refusal it will not ask again after. A refusal it MEANT to ask again after
|
|
122
|
-
* is delivered when the
|
|
123
|
-
*
|
|
124
|
-
*
|
|
122
|
+
* is delivered when the series stopped inside the wait: the deadline landed
|
|
123
|
+
* there (`no-time-left`), or a pooled call's send gate refused the next
|
|
124
|
+
* attempt before it was sent (`stoppedBy`, `not-permitted`). The end says
|
|
125
|
+
* which, during the `wait`; the attempt that was never sent has no row.
|
|
126
|
+
* Filed when the call has read it.
|
|
125
127
|
*/
|
|
126
|
-
delivered(): void;
|
|
128
|
+
delivered(stoppedBy?: DeclineReason): void;
|
|
127
129
|
/**
|
|
128
130
|
* The series threw. The end is the last attempt's when that attempt ended it
|
|
129
131
|
* (a failure, a timed-out request). The rest is defensive — footprintjs 10.6's
|
|
@@ -131,9 +133,11 @@ export declare class SeriesEvidence {
|
|
|
131
133
|
* as one: a deadline that had passed before the first request (`timed-out`,
|
|
132
134
|
* no `during`, nothing sent) or one a future runner reports from inside a wait
|
|
133
135
|
* (`during: 'wait'`); anything else is filed as a failure the record cannot
|
|
134
|
-
* account for, so a request is never left unfiled.
|
|
136
|
+
* account for, so a request is never left unfiled. A pooled call's send gate
|
|
137
|
+
* that refused the next attempt before it was sent ends it as `stoppedBy`,
|
|
138
|
+
* during the `wait`. Filed when the call settles.
|
|
135
139
|
*/
|
|
136
|
-
threw(outOfTime: boolean): void;
|
|
140
|
+
threw(outOfTime: boolean, stoppedBy?: DeclineReason): void;
|
|
137
141
|
private add;
|
|
138
142
|
/**
|
|
139
143
|
* File `end` once the call has settled — its verdict is what says whether an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seriesEvidence.d.ts","sourceRoot":"","sources":["../../../src/mcp/seriesEvidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAGjB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAElE,0FAA0F;AAC1F,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,QAAQ,CAAC,CAAC;AAExE,wEAAwE;AACxE,MAAM,WAAW,WAAW;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,CAAC;QAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACnG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;IACH,OAAO,CAAC,YAAY;CAQrB;AAcD,wEAAwE;AACxE,wBAAgB,KAAK,CACnB,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,QAAQ,CAAC,EAAE,aAAa,GACvB,kBAAkB,CAqBpB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,kBAAkB,EACvB,KAAK,EAAE,YAAY,GAAG,SAAS,GAC9B,kBAAkB,CASpB"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* terminate — ending a client's remote session, and saying what the remote side
|
|
3
|
+
* answered.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: a pass-through `fetch` that reads one status + one bounded procedure.
|
|
6
|
+
* Role: `McpClient.terminate()` (`mcpClient.ts`). The MCP SDK's
|
|
7
|
+
* `StreamableHTTPClientTransport.close()` only aborts the requests in
|
|
8
|
+
* flight; `terminateSession()` is the one method that sends the
|
|
9
|
+
* Streamable HTTP `DELETE` carrying `Mcp-Session-Id`. It treats a 405
|
|
10
|
+
* as success, so the status is read here, by a pass-through `fetch`
|
|
11
|
+
* the library installs on every transport it builds — it changes no
|
|
12
|
+
* request and reads only a `DELETE`'s answer.
|
|
13
|
+
*
|
|
14
|
+
* The procedure, at most once per client:
|
|
15
|
+
*
|
|
16
|
+
* 1. no session id was ever issued → `'no-session'`, nothing is sent;
|
|
17
|
+
* 2. otherwise the transport's own `terminateSession()`, bounded by
|
|
18
|
+
* `TOOL_TEARDOWN_TIMEOUT_MS` (the tool-session tier's `withTimeout`, shared):
|
|
19
|
+
* at the deadline the request is aborted and the outcome is `'timed-out'`;
|
|
20
|
+
* 3. a local close, whatever happened.
|
|
21
|
+
*
|
|
22
|
+
* ONE DEADLINE ANSWERS THE CALLER: the remote answer and the local close are
|
|
23
|
+
* waited for together for at most `TOOL_TEARDOWN_TIMEOUT_MS` of ELAPSED time,
|
|
24
|
+
* measured by timers started together at the start — never by reading the wall
|
|
25
|
+
* clock, so a clock stepped back cannot stretch it. A close that finishes in
|
|
26
|
+
* time is finished before the caller hears; one that hangs does not hold the
|
|
27
|
+
* answer. The work's own settlement — the `DELETE`, a `fetch` that ignores its
|
|
28
|
+
* abort, the close — may come later, and is returned apart (`settled`): the MCP
|
|
29
|
+
* client pool keeps an ending charged until then. The clock (`now`) only
|
|
30
|
+
* measures `durationMs`.
|
|
31
|
+
*
|
|
32
|
+
* Never vendor-aware: the one port is the Streamable HTTP `DELETE`. A transport
|
|
33
|
+
* that turns it into something else (AgentCore Runtime's `StopRuntimeSession`)
|
|
34
|
+
* answers it like a server would.
|
|
35
|
+
*/
|
|
36
|
+
import type { McpClient, McpTerminateOutcome } from './types.js';
|
|
37
|
+
/** An `McpClient` that can end its remote session. */
|
|
38
|
+
export type TerminableMcpClient = McpClient & {
|
|
39
|
+
terminate(): Promise<McpTerminateOutcome>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Can `client` end its remote session? Reads the member, never assumes it —
|
|
43
|
+
* the feature-detection law (`provider-contract/types.ts` · `canStageCodeInputs`).
|
|
44
|
+
* True for `mcpClient()` and `mockMcpClient()`; false for a hand-written client
|
|
45
|
+
* without `terminate`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function canTerminate(client: unknown): client is TerminableMcpClient;
|
|
48
|
+
/** What ending one client came to: the caller's answer, and when the work under it settled. */
|
|
49
|
+
export interface Ending {
|
|
50
|
+
/** Answers by `TOOL_TEARDOWN_TIMEOUT_MS`. Never rejects. */
|
|
51
|
+
readonly outcome: Promise<McpTerminateOutcome>;
|
|
52
|
+
/** Resolves once every piece of work the ending started has settled. Never rejects. */
|
|
53
|
+
readonly settled: Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/** The slice of the SDK's Streamable HTTP transport the procedure uses. */
|
|
56
|
+
export interface TerminableTransport {
|
|
57
|
+
readonly sessionId?: string;
|
|
58
|
+
terminateSession(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* What the pass-through `fetch` saw of a transport's `DELETE` requests: the
|
|
62
|
+
* status of the latest answer, and the signal it links into each one while an
|
|
63
|
+
* ending is under way.
|
|
64
|
+
*/
|
|
65
|
+
export declare class DeleteWatch {
|
|
66
|
+
private status;
|
|
67
|
+
private cut;
|
|
68
|
+
/** Arm for one ending: forget the last status, link `cut` into its `DELETE`. */
|
|
69
|
+
arm(cut: AbortSignal): void;
|
|
70
|
+
/** The status the latest `DELETE` was answered with, if one was. */
|
|
71
|
+
get answered(): number | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* `inner` (the global `fetch` when `undefined`, looked up at call time),
|
|
74
|
+
* passed through untouched except that a `DELETE`'s answer status is read and
|
|
75
|
+
* an armed ending's signal is linked into it.
|
|
76
|
+
*/
|
|
77
|
+
fetch(inner: ((input: string | URL, init?: RequestInit) => Promise<Response>) | undefined): (input: string | URL, init?: RequestInit) => Promise<Response>;
|
|
78
|
+
}
|
|
79
|
+
/** The outcome for an ending that sent nothing. */
|
|
80
|
+
export declare function outcomeWithout(remote: 'no-session' | 'unavailable', durationMs?: number): McpTerminateOutcome;
|
|
81
|
+
/**
|
|
82
|
+
* An ending that sends nothing — `remote` says why — only the local close:
|
|
83
|
+
* the caller is answered when the close finishes or at `timeoutMs`, whichever
|
|
84
|
+
* comes first; `settled` waits for the close itself.
|
|
85
|
+
*/
|
|
86
|
+
export declare function endLocally(remote: 'no-session' | 'unavailable', close: () => Promise<void>, now?: () => number, timeoutMs?: number): Ending;
|
|
87
|
+
/**
|
|
88
|
+
* End `transport`'s session, then close locally with `close` — the procedure
|
|
89
|
+
* in the module note. `watch` is the `DeleteWatch` installed on the transport's
|
|
90
|
+
* fetch. `now` is the clock the duration is measured with.
|
|
91
|
+
*/
|
|
92
|
+
export declare function endSession(transport: TerminableTransport, watch: DeleteWatch, close: () => Promise<void>, now?: () => number, timeoutMs?: number): Ending;
|
|
93
|
+
/** A failure's class name, never its message. */
|
|
94
|
+
export declare function classOf(error: unknown): string;
|
|
95
|
+
//# sourceMappingURL=terminate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminate.d.ts","sourceRoot":"","sources":["../../../src/mcp/terminate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AASH,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjE,sDAAsD;AACtD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG;IAC5C,SAAS,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,mBAAmB,CAO3E;AAED,+FAA+F;AAC/F,MAAM,WAAW,MAAM;IACrB,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC/C,uFAAuF;IACvF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC;AAED,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,GAAG,CAA0B;IAErC,gFAAgF;IAChF,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;IAK3B,oEAAoE;IACpE,IAAI,QAAQ,IAAI,MAAM,GAAG,SAAS,CAEjC;IAED;;;;OAIG;IACH,KAAK,CACH,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GAClF,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC;CAWlE;AAED,mDAAmD;AACnD,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,GAAG,aAAa,EACpC,UAAU,SAAI,GACb,mBAAmB,CAErB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,YAAY,GAAG,aAAa,EACpC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC1B,GAAG,GAAE,MAAM,MAAiB,EAC5B,SAAS,GAAE,MAAiC,GAC3C,MAAM,CASR;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CACxB,SAAS,EAAE,mBAAmB,EAC9B,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC1B,GAAG,GAAE,MAAM,MAAiB,EAC5B,SAAS,GAAE,MAAiC,GAC3C,MAAM,CA2BR;AAgED,iDAAiD;AACjD,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAO9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttleRetry.d.ts","sourceRoot":"","sources":["../../../src/mcp/throttleRetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsGG;AAaH,OAAO,EAOL,KAAK,iBAAiB,EAEvB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"throttleRetry.d.ts","sourceRoot":"","sources":["../../../src/mcp/throttleRetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,GAAG,SAAS,GAAG,aAAa,CAYrF;AAKD;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAE5E,0CAA0C;AAC1C,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,UAAU,CAOzE;AASD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,aAAa,GAC3C,aAAa,CAGf;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,aAAa,EACrB,MAAM,CAAC,EAAE,iBAAiB,GACzB,aAAa,GAAG,SAAS,CAE3B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,UAAU,GAAG,aAAa,CAStF;AA2iBD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAOpF"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* toolList — every page of a server's `tools/list` answer, or a typed refusal
|
|
3
|
+
* that says the list is incomplete.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: one bounded loop + one typed refusal.
|
|
6
|
+
* Role: MCP pages a tool list: a page carries `nextCursor` while the server
|
|
7
|
+
* has more, and the next page is asked for with `{ cursor }`. Reading
|
|
8
|
+
* only the first page cut a paginating server's catalogue short in
|
|
9
|
+
* silence — the agent saw part of it and nothing said so. This reads
|
|
10
|
+
* until the server sends no cursor, within a bound, and when it cannot
|
|
11
|
+
* finish the list it says why:
|
|
12
|
+
*
|
|
13
|
+
* - `'page-limit'` — the list did not end within {@link MAX_TOOL_LIST_PAGES}
|
|
14
|
+
* pages;
|
|
15
|
+
* - `'cursor-repeated'` — a page named a cursor this listing already sent, so
|
|
16
|
+
* following it would loop.
|
|
17
|
+
*
|
|
18
|
+
* The first page is asked exactly as before pagination was followed: no params
|
|
19
|
+
* (and, with no signal, no arguments at all). The client's signal rides every
|
|
20
|
+
* page in the SDK's trailing options, and it is checked immediately before each
|
|
21
|
+
* page is asked for and again when each answer arrives (`lib/abort.ts`): once
|
|
22
|
+
* it has fired, nothing more is asked for and no page is accepted, the last one
|
|
23
|
+
* included. An abort is the caller's word, so it wins over an incomplete list.
|
|
24
|
+
* What it cannot do is settle a page a connection that ignores the signal is
|
|
25
|
+
* still holding: that promise settles when the connection says.
|
|
26
|
+
*
|
|
27
|
+
* Every page request is counted from the moment it is sent until it settles
|
|
28
|
+
* (`listingGenerations.ts`): the MCP SDK's `Client` replaces its per-tool call
|
|
29
|
+
* checks with each answer, so a tool's checks depend on which answer is the
|
|
30
|
+
* latest (`callChecks.ts`).
|
|
31
|
+
*/
|
|
32
|
+
import type { Tool } from '../tools/tools.js';
|
|
33
|
+
import type { ListingGenerations } from './listingGenerations.js';
|
|
34
|
+
import type { McpConnection, McpListedTool } from './types.js';
|
|
35
|
+
/**
|
|
36
|
+
* The most `tools/list` requests one listing sends. A bound on REQUESTS, not on
|
|
37
|
+
* the catalogue's size: a page may hold any number of tools. A server that
|
|
38
|
+
* keeps paging past it is reported as incomplete rather than read without end.
|
|
39
|
+
*/
|
|
40
|
+
export declare const MAX_TOOL_LIST_PAGES = 100;
|
|
41
|
+
/** Why a server's tool list could not be read to its end. */
|
|
42
|
+
export type McpToolListIncompleteReason = 'page-limit' | 'cursor-repeated';
|
|
43
|
+
/** What a listing read: every tool its pages held, how many pages, and whether it ended. */
|
|
44
|
+
export interface ToolListing {
|
|
45
|
+
readonly tools: readonly McpListedTool[];
|
|
46
|
+
readonly pages: number;
|
|
47
|
+
/**
|
|
48
|
+
* For a list read in ONE answer, the generation that answer settled at: the
|
|
49
|
+
* MCP SDK's `Client` holds its tools' checks while it stays the latest
|
|
50
|
+
* (`listingGenerations.ts`). Absent for a paged list: no one answer holds all
|
|
51
|
+
* of its tools.
|
|
52
|
+
*/
|
|
53
|
+
readonly generation?: number;
|
|
54
|
+
/** Absent when the server's list ended: the last page carried no cursor. */
|
|
55
|
+
readonly incomplete?: McpToolListIncompleteReason;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Read the server's tool list, page by page, until a page carries no cursor —
|
|
59
|
+
* or until it cannot be finished, which the result says (`incomplete`).
|
|
60
|
+
*
|
|
61
|
+
* @param listings the connection's count of list requests, which every page
|
|
62
|
+
* request joins (`listingGenerations.ts`)
|
|
63
|
+
* @throws the abort, when `signal` has fired before a page is asked for or by
|
|
64
|
+
* the time its answer arrives; and whatever the connection rejects a page
|
|
65
|
+
* with, as it always did
|
|
66
|
+
*/
|
|
67
|
+
export declare function listEveryPage(connection: McpConnection, signal: AbortSignal | undefined, listings: ListingGenerations): Promise<ToolListing>;
|
|
68
|
+
/**
|
|
69
|
+
* A server's tool list that could not be read to its end. `tools()` and
|
|
70
|
+
* `refresh()` reject with it rather than return a list cut short: an agent
|
|
71
|
+
* handed part of a catalogue cannot know what it was not offered.
|
|
72
|
+
*
|
|
73
|
+
* `tools` holds what WAS listed — wrapped and callable, exactly as `tools()`
|
|
74
|
+
* would have returned them — for a caller that decides to use an incomplete
|
|
75
|
+
* list knowingly. Names the server, the reason and the count, never a cursor.
|
|
76
|
+
*/
|
|
77
|
+
export declare class McpToolListIncompleteError extends Error {
|
|
78
|
+
readonly reason: McpToolListIncompleteReason;
|
|
79
|
+
readonly server: string;
|
|
80
|
+
/** The pages read before the listing stopped. */
|
|
81
|
+
readonly pages: number;
|
|
82
|
+
/** The tools those pages listed, in page order. */
|
|
83
|
+
readonly tools: readonly Tool[];
|
|
84
|
+
readonly code: "ERR_MCP_TOOL_LIST_INCOMPLETE";
|
|
85
|
+
constructor(reason: McpToolListIncompleteReason, server: string,
|
|
86
|
+
/** The pages read before the listing stopped. */
|
|
87
|
+
pages: number,
|
|
88
|
+
/** The tools those pages listed, in page order. */
|
|
89
|
+
tools: readonly Tool[]);
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=toolList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolList.d.ts","sourceRoot":"","sources":["../../../src/mcp/toolList.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,6DAA6D;AAC7D,MAAM,MAAM,2BAA2B,GAAG,YAAY,GAAG,iBAAiB,CAAC;AAE3E,4FAA4F;AAC5F,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,UAAU,CAAC,EAAE,2BAA2B,CAAC;CACnD;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,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