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,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* callChecks — a listing never makes a callable tool lose its checks.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: the SDK's three per-tool call checks, carried by every tool the
|
|
5
|
+
* library hands out, plus one typed refusal.
|
|
6
|
+
* Role: The MCP SDK's `Client` runs three checks inside `callTool`, and it
|
|
7
|
+
* keeps them only for the tools of its most recent `tools/list`
|
|
8
|
+
* answer (1.32: `cacheToolMetadata` replaces them on every answer):
|
|
9
|
+
*
|
|
10
|
+
* 1. a tool with `execution.taskSupport: 'required'` is refused before a
|
|
11
|
+
* plain `tools/call` is sent;
|
|
12
|
+
* 2. a tool with an `outputSchema` must answer with `structuredContent`,
|
|
13
|
+
* unless the answer is an error;
|
|
14
|
+
* 3. that `structuredContent` must match the schema.
|
|
15
|
+
*
|
|
16
|
+
* So a tool that declares any of them carries them itself, as the listing it
|
|
17
|
+
* came from declared them. The library leaves them to the SDK only for a tool
|
|
18
|
+
* of a ONE-page list whose answer is still the latest, with no list request
|
|
19
|
+
* out (`listingGenerations.ts`), both when the call starts and when its answer
|
|
20
|
+
* comes in: the one-page normal case, which runs exactly as it always did.
|
|
21
|
+
* Every other call runs the tool's own checks, at the SDK's moments — the first
|
|
22
|
+
* before sending, the other two once the answer is in, before anything reads it
|
|
23
|
+
* — and raises the SDK's error: its own `McpError` where this arm loaded the
|
|
24
|
+
* SDK, otherwise an error with the same name, code and message. Those calls
|
|
25
|
+
* are to a tool of a paged list, a tool whose list a later answer replaced (a
|
|
26
|
+
* refresh that failed or succeeded; a reference held across it), and any call
|
|
27
|
+
* made while a list is being read.
|
|
28
|
+
*
|
|
29
|
+
* All of this covers the lists the library reads (`tools()`, `refresh()`); a
|
|
30
|
+
* listing it does not send — the SDK client's own automatic refresh, a
|
|
31
|
+
* `listTools` call of the caller's — is not seen (`listingGenerations.ts`).
|
|
32
|
+
*
|
|
33
|
+
* The output checks need a JSON Schema validator equal to the client's: the
|
|
34
|
+
* SDK's default (`AjvJsonSchemaValidator`, loaded with the SDK on the Node
|
|
35
|
+
* loader arm), or the caller's `jsonSchemaValidator`. Where neither exists — an
|
|
36
|
+
* `sdk` or `connection` arm given none — an answer under these rules is never
|
|
37
|
+
* returned unchecked (`McpOutputUncheckedError`):
|
|
38
|
+
*
|
|
39
|
+
* - a call under the tool's own checks from the start, to a tool that
|
|
40
|
+
* declares an `outputSchema`, is refused before it is sent (`sent: false`);
|
|
41
|
+
* - a call that started under the SDK's checks is refused once its answer is
|
|
42
|
+
* in, unread, when the library sent a `tools/list` request while the call
|
|
43
|
+
* was out (`sent: true`): the SDK may have checked it against another list.
|
|
44
|
+
*
|
|
45
|
+
* A schema is compiled when a tool's own checks first need it, never before:
|
|
46
|
+
* the one-page normal case compiles nothing twice.
|
|
47
|
+
*/
|
|
48
|
+
import type { McpCallToolResult, McpJsonSchemaValidator, McpListedTool } from './types.js';
|
|
49
|
+
import type { ListingGenerations } from './listingGenerations.js';
|
|
50
|
+
/** The SDK's `McpError` constructor, as `@modelcontextprotocol/sdk/types.js` exports it. */
|
|
51
|
+
export type McpErrorClass = new (code: number, message: string, data?: unknown) => Error;
|
|
52
|
+
/** A compiled output check, as the SDK's validator returns one. */
|
|
53
|
+
type Validate = (input: unknown) => {
|
|
54
|
+
readonly valid: boolean;
|
|
55
|
+
readonly errorMessage?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* What one connection checks its tools' calls with: a validator equal to its
|
|
59
|
+
* client's, the SDK's own error class where the library loaded the SDK, and
|
|
60
|
+
* which `tools/list` answer the SDK holds its checks for.
|
|
61
|
+
*/
|
|
62
|
+
export interface CallCheckKit {
|
|
63
|
+
/** The client's name, as its refusals name it. */
|
|
64
|
+
readonly server: string;
|
|
65
|
+
/** The validator; created on first use. `undefined` when none is reachable. */
|
|
66
|
+
validator(): McpJsonSchemaValidator | undefined;
|
|
67
|
+
/** The SDK's own `McpError`, when this arm loaded the SDK. */
|
|
68
|
+
readonly McpError?: McpErrorClass;
|
|
69
|
+
/** This connection's list requests, counted (`listingGenerations.ts` · `listingsOf`). */
|
|
70
|
+
readonly listings: ListingGenerations;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The kit for one connection, named `server`, whose list requests `listings`
|
|
74
|
+
* counts (`listingsOf(connection)`, shared by every client over it). `given` is
|
|
75
|
+
* the caller's `jsonSchemaValidator`; `loaded` holds what the library loaded
|
|
76
|
+
* with the SDK on the Node loader arm — the SDK's default validator class and
|
|
77
|
+
* its `McpError` — each `undefined` where it is not a constructor (another arm,
|
|
78
|
+
* or an SDK without it).
|
|
79
|
+
*/
|
|
80
|
+
export declare function callCheckKit(server: string, listings: ListingGenerations, given: McpJsonSchemaValidator | undefined, loaded?: {
|
|
81
|
+
readonly Validator?: unknown;
|
|
82
|
+
readonly McpError?: unknown;
|
|
83
|
+
}): CallCheckKit;
|
|
84
|
+
/**
|
|
85
|
+
* `value` as a validator, or `undefined` when it was not given. Refused by name
|
|
86
|
+
* when it is something else, before anything connects.
|
|
87
|
+
*/
|
|
88
|
+
export declare function validatorOption(value: unknown, at: string): McpJsonSchemaValidator | undefined;
|
|
89
|
+
/** The checks one listed tool carries, as the listing it came from declared them. */
|
|
90
|
+
export interface CallChecks {
|
|
91
|
+
readonly server: string;
|
|
92
|
+
readonly tool: string;
|
|
93
|
+
/** `execution.taskSupport: 'required'`: only ever run as a task. */
|
|
94
|
+
readonly taskRequired: boolean;
|
|
95
|
+
/** The tool declares an `outputSchema`. */
|
|
96
|
+
readonly outputDeclared: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* True while the SDK's `Client` holds this tool's checks: the tool came from
|
|
99
|
+
* a one-page list whose answer is still the latest, and no list request is
|
|
100
|
+
* out. Then the SDK checks the call, and nothing here runs.
|
|
101
|
+
*/
|
|
102
|
+
heldBySdk(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* The compiled output check, compiled from the declared schema on first use.
|
|
105
|
+
* `undefined` when no output is declared or no validator is reachable.
|
|
106
|
+
*/
|
|
107
|
+
validate(): Validate | undefined;
|
|
108
|
+
/** Raise an SDK error, as this arm can: the SDK's class, or its exact shape. */
|
|
109
|
+
fail(code: number, message: string): Error;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The checks `listed` carries — `undefined` when it declares none. `generation`
|
|
113
|
+
* is the one answer its list was read in, when it was read in one
|
|
114
|
+
* (`toolList.ts` · `ToolListing`); a paged list's tools have none, so the SDK
|
|
115
|
+
* never holds all of them.
|
|
116
|
+
*/
|
|
117
|
+
export declare function checksFor(listed: McpListedTool, kit: CallCheckKit, generation: number | undefined): CallChecks | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* True when this call's output cannot be checked here: it runs under the
|
|
120
|
+
* tool's own checks, the tool declares an `outputSchema`, no validator is
|
|
121
|
+
* reachable, and it is not refused as a required task anyway (that refusal is
|
|
122
|
+
* the SDK's, and comes first). The call is then refused before it is sent.
|
|
123
|
+
*/
|
|
124
|
+
export declare function outputUnchecked(checks: CallChecks): boolean;
|
|
125
|
+
/** The SDK's task refusal, word for word, before anything is sent. */
|
|
126
|
+
export declare function refuseRequiredTask(checks: CallChecks): void;
|
|
127
|
+
/**
|
|
128
|
+
* The SDK's two output checks, in its order and with its sentences, once the
|
|
129
|
+
* answer is in and before anything reads it. An answer no validator here can
|
|
130
|
+
* check is never returned: it is refused, unread, as sent.
|
|
131
|
+
*/
|
|
132
|
+
export declare function checkOutput(checks: CallChecks, result: McpCallToolResult): void;
|
|
133
|
+
/**
|
|
134
|
+
* A tool call whose output this connection cannot check, refused. The tool
|
|
135
|
+
* declares an `outputSchema`, the MCP SDK no longer holds the checks of the
|
|
136
|
+
* tool list it came from, and this connection has no JSON Schema validator to
|
|
137
|
+
* check it with — so its answer is never returned:
|
|
138
|
+
*
|
|
139
|
+
* - `sent: false` — refused before it was sent: nothing reached the server.
|
|
140
|
+
* The tool came from a paged list, from a list a later answer replaced, or
|
|
141
|
+
* the call was made while a list was being read.
|
|
142
|
+
* - `sent: true` — the call was sent, and a `tools/list` request went out
|
|
143
|
+
* before its answer came in: the SDK may have checked that answer against
|
|
144
|
+
* the other list, so it is refused unread. The tool may have run.
|
|
145
|
+
*
|
|
146
|
+
* Pass `jsonSchemaValidator` — the validator your client uses — to `mcpClient`.
|
|
147
|
+
* Names the server and the tool, never an argument or an answer.
|
|
148
|
+
*/
|
|
149
|
+
export declare class McpOutputUncheckedError extends Error {
|
|
150
|
+
readonly server: string;
|
|
151
|
+
readonly tool: string;
|
|
152
|
+
/** Whether the request left the client: `false` when the refusal came before it. */
|
|
153
|
+
readonly sent: boolean;
|
|
154
|
+
readonly code: "ERR_MCP_OUTPUT_UNCHECKED";
|
|
155
|
+
readonly reason: "output-unchecked";
|
|
156
|
+
constructor(server: string, tool: string,
|
|
157
|
+
/** Whether the request left the client: `false` when the refusal came before it. */
|
|
158
|
+
sent: boolean);
|
|
159
|
+
}
|
|
160
|
+
export {};
|
|
161
|
+
//# sourceMappingURL=callChecks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callChecks.d.ts","sourceRoot":"","sources":["../../../src/mcp/callChecks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAElE,4FAA4F;AAC5F,MAAM,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,KAAK,CAAC;AAMzF,mEAAmE;AACnE,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;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AE,aAAa,EACrB,GAAG,EAAE,YAAY,EACjB,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,UAAU,GAAG,SAAS,CAoBxB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAE3D;AAED,sEAAsE;AACtE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAO3D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI,CA2B/E;AA+BD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAK9C,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,OAAO;IAPxB,QAAQ,CAAC,IAAI,6BAAuC;IACpD,QAAQ,CAAC,MAAM,qBAA+B;gBAGnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;IACrB,oFAAoF;IAC3E,IAAI,EAAE,OAAO;CASzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callLifetime.d.ts","sourceRoot":"","sources":["../../../src/mcp/callLifetime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;
|
|
1
|
+
{"version":3,"file":"callLifetime.d.ts","sourceRoot":"","sources":["../../../src/mcp/callLifetime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAQH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,oBAAoB,CAAC;AAEvE,mHAAmH;AACnH,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACjD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;IACtD;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvC,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,WAAW,GAAG,SAAS,EACrC,MAAM,EAAE,aAAa,GAAG,SAAS,EACjC,MAAM,EAAE,MAAM,GACb,QAAQ,CAAC,CAAC,CAAC,CA4Cb"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clientPort — what the MCP client pool asks of a client it opens, and what the
|
|
3
|
+
* client hands back beside the ordinary `McpClient`.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: an internal seam, never on a door.
|
|
6
|
+
* Role: The pool's clients are ordinary `mcpClient`s (`mcpClient.ts`): their
|
|
7
|
+
* discovery, their per-tool checks (`callChecks.ts`, counted per
|
|
8
|
+
* client object by `listingGenerations.ts`), their retry series and
|
|
9
|
+
* their request ledger are the library's, unchanged. A pool needs
|
|
10
|
+
* four things more, and only a pool does, so they cross here:
|
|
11
|
+
*
|
|
12
|
+
* - a CONNECT signal apart from the client's lifetime signal: one open runs
|
|
13
|
+
* under the pool's own signal and open deadline, never a caller's;
|
|
14
|
+
* - the request guard of whatever the pool is doing on the client
|
|
15
|
+
* (`requestGuard.ts`), so every request is checked and counted;
|
|
16
|
+
* - the server's tools-changed notice, heard through the SDK's
|
|
17
|
+
* `listChanged.tools` with its automatic refresh OFF — a notice can only
|
|
18
|
+
* make the pool list again, through `listing`, which `mcpClient` counts;
|
|
19
|
+
* - a port back: a listing under the pool's own signal, a callable tool for a
|
|
20
|
+
* definition this client did not list (a shared one), and an ending whose
|
|
21
|
+
* settlement is reported apart from its answer.
|
|
22
|
+
*/
|
|
23
|
+
import type { Tool } from '../tools/tools.js';
|
|
24
|
+
import type { RequestGuard } from './requestGuard.js';
|
|
25
|
+
import type { Ending } from './terminate.js';
|
|
26
|
+
import type { McpListedTool } from './types.js';
|
|
27
|
+
import type { ThrottleFetch } from './throttleRetry.js';
|
|
28
|
+
/** @internal What a pool passes when it opens a client. */
|
|
29
|
+
export interface PooledClientSeam {
|
|
30
|
+
/** Bounds the connect (`initialize`) only: the pool's signal and its open deadline. */
|
|
31
|
+
readonly connectSignal: AbortSignal;
|
|
32
|
+
/**
|
|
33
|
+
* Wrap the transport's outermost `fetch`. `claim` finds the guard of the
|
|
34
|
+
* pooled tool call a request body belongs to (its ledger), `undefined` for
|
|
35
|
+
* any other request.
|
|
36
|
+
*/
|
|
37
|
+
readonly wrapFetch: (inner: ThrottleFetch, claim: (body: unknown) => RequestGuard | undefined) => ThrottleFetch;
|
|
38
|
+
/** The guard for a message that is not a pooled tool call — asked at the watched `send`. */
|
|
39
|
+
readonly guardFor: (message: unknown) => RequestGuard | undefined;
|
|
40
|
+
/** The server said its tool list changed. Called by the SDK; must not throw. */
|
|
41
|
+
readonly onToolsChanged: () => void;
|
|
42
|
+
}
|
|
43
|
+
/** @internal One listing, through the client's own discovery. */
|
|
44
|
+
export interface ClientListing {
|
|
45
|
+
/** The tools as `mcpClient` wraps them: each carries the checks of this listing. */
|
|
46
|
+
readonly tools: readonly Tool[];
|
|
47
|
+
/** The definitions as the server listed them, in the same order. */
|
|
48
|
+
readonly listed: readonly McpListedTool[];
|
|
49
|
+
}
|
|
50
|
+
/** @internal What a pooled client hands the pool. */
|
|
51
|
+
export interface ClientPort {
|
|
52
|
+
/** List every page through the client's own discovery, under `signal`. Replaces its cache. */
|
|
53
|
+
listing(signal: AbortSignal | undefined): Promise<ClientListing>;
|
|
54
|
+
/**
|
|
55
|
+
* A callable tool for `listed` on this connection that carries its OWN
|
|
56
|
+
* checks — for a definition this client did not list itself, so the SDK on
|
|
57
|
+
* this connection holds none for it.
|
|
58
|
+
*/
|
|
59
|
+
bind(listed: McpListedTool): Tool;
|
|
60
|
+
/** End the remote session and close: the answer by its deadline, the settlement apart. */
|
|
61
|
+
end(): Ending;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* @internal What a pooled open that FAILED leaves behind: the server may have
|
|
65
|
+
* opened a session all the same (its `initialize` answer can land after the
|
|
66
|
+
* open was aborted), so the pool can still end it — once the open's work has
|
|
67
|
+
* settled, it asks `hasSession` and, if so, ends it under the ending rule.
|
|
68
|
+
*/
|
|
69
|
+
export interface HalfOpen {
|
|
70
|
+
/** Does the transport hold a session id the server issued — read when asked. */
|
|
71
|
+
hasSession(): boolean;
|
|
72
|
+
/** End that session, then close locally. */
|
|
73
|
+
end(): Ending;
|
|
74
|
+
}
|
|
75
|
+
/** @internal Remember what `error` (a failed pooled open's) left behind. */
|
|
76
|
+
export declare function rememberHalfOpen(error: unknown, halfOpen: HalfOpen): void;
|
|
77
|
+
/** @internal What a failed pooled open left behind, if anything. */
|
|
78
|
+
export declare function halfOpenOf(error: unknown): HalfOpen | undefined;
|
|
79
|
+
//# sourceMappingURL=clientPort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientPort.d.ts","sourceRoot":"","sources":["../../../src/mcp/clientPort.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM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,OAAO,GAAG,QAAQ,GAAG,SAAS,CAE/D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gatewayTransport.d.ts","sourceRoot":"","sources":["../../../src/mcp/gatewayTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"gatewayTransport.d.ts","sourceRoot":"","sources":["../../../src/mcp/gatewayTransport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAsB,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAGnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,4CAA4C;AAC5C,MAAM,WAAW,uBAAuB;IACtC,4BAA4B;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;IACzC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,mFAAmF;IACnF,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkDG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;CAC5B;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,mBAAmB,CAatF;AAED;;;;;;GAMG;AACH,qBAAa,iCAAkC,SAAQ,KAAK;IAC1D,QAAQ,CAAC,IAAI,uCAAiD;IAC9D,sCAAsC;IACtC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;gBAEtB,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;CAUtD;AAgBD,0FAA0F;AAC1F,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEjG;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,mBAAmB,EAC9B,SAAS,GAAE,SAA6C,GACvD,SAAS,CA+CX"}
|
|
@@ -13,5 +13,15 @@ export { retryingFetch } from './throttleRetry.js';
|
|
|
13
13
|
export type { RetryOnThrottle, ThrottleFetch, ThrottleRetryInfo, ThrottleRetryOptions, } from './throttleRetry.js';
|
|
14
14
|
export type { McpReplayDeduplication, McpReplayKind, McpReplayOptions, McpReplayPolicy, McpReplayTool, } from './replay.js';
|
|
15
15
|
export { McpReplayUnavailableError, type McpReplayUnavailableReason } from './replayUnavailable.js';
|
|
16
|
-
export
|
|
16
|
+
export { McpToolListIncompleteError, type McpToolListIncompleteReason } from './toolList.js';
|
|
17
|
+
export { McpOutputUncheckedError } from './callChecks.js';
|
|
18
|
+
export { canTerminate, type TerminableMcpClient } from './terminate.js';
|
|
19
|
+
export { mcpClientPool, type McpClientPool, type McpPoolScope } from './pool/mcpClientPool.js';
|
|
20
|
+
export { MCP_POOL_DEFAULTS, MAX_DEFINITION_ENTRIES, MAX_SHARED_TOOLS, type McpClientPoolOptions, type McpPoolDefinitionSharing, type McpPoolIdentity, type McpPoolShareContext, } from './pool/options.js';
|
|
21
|
+
export { McpPoolRefusedError, PoolFullError, type McpPoolLimit, type McpPoolRefusal, } from './pool/errors.js';
|
|
22
|
+
export type { McpPoolLease } from './pool/lease.js';
|
|
23
|
+
export type { McpPoolReport } from './pool/record.js';
|
|
24
|
+
export type { McpPoolStats } from './pool/pool.js';
|
|
25
|
+
export type { EndReason as McpPoolEndReason } from './pool/pooledClient.js';
|
|
26
|
+
export type { McpCallToolResult, McpClient, McpClientOptions, McpConnection, McpConnectionOptions, McpJsonSchemaValidator, McpSdk, McpGatewayTransport, McpHttpTransport, McpStdioTransport, McpTerminateOutcome, McpTransport, McpTransportSettings, McpSdkClient, McpServeOptions, McpServeHandle, McpServeTransport, McpHttpServeTransport, McpStdioServeTransport, McpSdkServer, } from './types.js';
|
|
17
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,EACL,gBAAgB,EAChB,iCAAiC,EACjC,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EACV,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1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,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,YAAY,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,YAAY,EACV,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,MAAM,EACN,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,GACb,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* listingGenerations — which `tools/list` answer the MCP SDK's `Client` holds
|
|
3
|
+
* its per-tool call checks for, as far as one connection can tell.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: a count of the list requests one connection sent and settled.
|
|
6
|
+
* Role: The SDK's `Client` keeps its per-tool call checks (`callChecks.ts`)
|
|
7
|
+
* for the tools of the last `tools/list` answer it received: every
|
|
8
|
+
* answer replaces them. A request that FAILED can replace them too: the
|
|
9
|
+
* SDK caches an answer before it returns it, and caching can throw after
|
|
10
|
+
* the old checks are cleared (1.32: an `outputSchema` its validator
|
|
11
|
+
* cannot compile). The library cannot see inside the SDK, but it sends
|
|
12
|
+
* every list request it makes. So it counts them:
|
|
13
|
+
*
|
|
14
|
+
* - a request is OUT from the moment it is sent until it settles, because the
|
|
15
|
+
* SDK replaces its checks before the library sees the answer;
|
|
16
|
+
* - each request that settles, answered or failed, starts a new GENERATION.
|
|
17
|
+
*
|
|
18
|
+
* The SDK holds the checks of a listing's one answer only while the generation
|
|
19
|
+
* that answer settled at is the latest and no request is out. The SDK keeps one
|
|
20
|
+
* set of checks per client, so there is one count per connection object: every
|
|
21
|
+
* `mcpClient` over the same client shares it (`listingsOf`). A `tools/list`
|
|
22
|
+
* request the library did not send — your own code calling `listTools` on a
|
|
23
|
+
* client passed as `connection`, or that client's own automatic refresh
|
|
24
|
+
* (`listChanged.tools` with `autoRefresh`) — is not counted: the library cannot
|
|
25
|
+
* see it, and a tool it handed out goes on leaving its checks to an SDK that no
|
|
26
|
+
* longer holds them. That limit is documented, and pinned by
|
|
27
|
+
* `test/mcp/listingKeepsChecks.limits.test.ts`.
|
|
28
|
+
*/
|
|
29
|
+
/** One settled `tools/list` request's answer, and the generation it settled at. */
|
|
30
|
+
export interface SettledListing<T> {
|
|
31
|
+
readonly answer: T;
|
|
32
|
+
readonly generation: number;
|
|
33
|
+
}
|
|
34
|
+
/** The `tools/list` requests one connection has out, and the generations they settled at. */
|
|
35
|
+
export declare class ListingGenerations {
|
|
36
|
+
private settled;
|
|
37
|
+
private out;
|
|
38
|
+
/**
|
|
39
|
+
* Send one `tools/list` request with `send`, counted as out from the moment it
|
|
40
|
+
* is sent until it settles. Settling starts a new generation, answered or not.
|
|
41
|
+
*
|
|
42
|
+
* @throws whatever `send` rejects with, as it rejected
|
|
43
|
+
*/
|
|
44
|
+
ask<T>(send: () => Promise<T>): Promise<SettledListing<T>>;
|
|
45
|
+
/** True while `generation` is the latest settled one and no request is out. */
|
|
46
|
+
isLatest(generation: number): boolean;
|
|
47
|
+
private settle;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The count for `connection`: the same one for every `mcpClient` that adapts
|
|
51
|
+
* the same client, because the SDK keeps one set of checks per client and a
|
|
52
|
+
* listing by any of them replaces it.
|
|
53
|
+
*/
|
|
54
|
+
export declare function listingsOf(connection: object): ListingGenerations;
|
|
55
|
+
//# sourceMappingURL=listingGenerations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listingGenerations.d.ts","sourceRoot":"","sources":["../../../src/mcp/listingGenerations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,mFAAmF;AACnF,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,6FAA6F;AAC7F,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,GAAG,CAAK;IAEhB;;;;;OAKG;IACG,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IAWhE,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIrC,OAAO,CAAC,MAAM;CAKf;AAKD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAOjE"}
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
* loads only when a consumer actually constructs a client. Tests
|
|
43
43
|
* inject `_client` and skip the import path entirely.
|
|
44
44
|
*/
|
|
45
|
-
import type {
|
|
45
|
+
import type { Tool } from '../tools/tools.js';
|
|
46
|
+
import type { McpClient, McpClientOptions, McpConnectionOptions, McpListedTool } from './types.js';
|
|
47
|
+
import { type ClientPort, type PooledClientSeam } from './clientPort.js';
|
|
46
48
|
/**
|
|
47
49
|
* Connect to an MCP server. Returns an `McpClient` that exposes the
|
|
48
50
|
* server's tools as agentfootprint `Tool[]` and a `close()` to tear
|
|
@@ -66,4 +68,19 @@ import type { McpClient, McpClientOptions, McpConnectionOptions } from './types.
|
|
|
66
68
|
* transport fails to connect.
|
|
67
69
|
*/
|
|
68
70
|
export declare function mcpClient(opts: McpClientOptions | McpConnectionOptions): Promise<McpClient>;
|
|
71
|
+
/**
|
|
72
|
+
* @internal The MCP client pool's way to open a client (`mcp/pool/`): an
|
|
73
|
+
* ordinary `mcpClient` — the same discovery, checks, ledger and retry series —
|
|
74
|
+
* plus what only a pool asks for (`clientPort.ts`), and the port back.
|
|
75
|
+
*/
|
|
76
|
+
export declare function openPooledClient(opts: McpClientOptions, seam: PooledClientSeam): Promise<{
|
|
77
|
+
readonly client: McpClient;
|
|
78
|
+
readonly port: ClientPort;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* @internal What a listed MCP tool looks like as a `Tool`, less its `execute`:
|
|
82
|
+
* its schema, its provenance and the declarations its `_meta` carries. The ONE
|
|
83
|
+
* shape both an `mcpClient` tool and an MCP client pool's bound tool take.
|
|
84
|
+
*/
|
|
85
|
+
export declare function mcpToolShape(serverName: string, mcp: McpListedTool): Omit<Tool, 'execute'>;
|
|
69
86
|
//# sourceMappingURL=mcpClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;
|
|
1
|
+
{"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAEV,SAAS,EACT,gBAAgB,EAEhB,oBAAoB,EAEpB,aAAa,EAId,MAAM,YAAY,CAAC;AAqCpB,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AAkBzB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CAEjG;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAEpE;AAsnBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAuB1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockMcpClient.d.ts","sourceRoot":"","sources":["../../../src/mcp/mockMcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mockMcpClient.d.ts","sourceRoot":"","sources":["../../../src/mcp/mockMcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAIH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,YAAY,CAAC;AAIpB,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACxD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD;;;;;;;;OAQG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,OAAO,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KAAE,KAC5D,OAAO,CAAC,MAAM,GAAG,iBAAiB,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,oBAAoB;IACnC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;IACvC;mFAC+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACtD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS,CAgDtE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* boundTool — a tool bound to its conversation, the list it came from and that
|
|
3
|
+
* list's generation, re-checked after every wait and at the send gate.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: the shape every MCP tool takes (`mcpClient.ts` · `mcpToolShape`) +
|
|
6
|
+
* one `execute` that runs the five steps of § 6.3.
|
|
7
|
+
* Role: A bound tool carries its BINDING: the key it was listed for; the
|
|
8
|
+
* context it was listed in (per client, the configuration; shared, the
|
|
9
|
+
* entry's context); the list it came from (per client, the client
|
|
10
|
+
* incarnation; shared, the entry); and that list's generation. Its
|
|
11
|
+
* `execute`:
|
|
12
|
+
*
|
|
13
|
+
* 1. checks that the calling run's caller identity encodes to its key —
|
|
14
|
+
* otherwise `identity-mismatch`, nothing sent;
|
|
15
|
+
* 2. checks its binding is current — otherwise `stale-tools`, nothing sent;
|
|
16
|
+
* 3. is admitted against `maxOperations` and takes a lease on its key's
|
|
17
|
+
* client, opening one from a plan resolved now when the key has none. A
|
|
18
|
+
* client whose plan's context differs from the binding's refuses with
|
|
19
|
+
* `binding-changed` (the client stays for the next list). A client that is
|
|
20
|
+
* not the incarnation the tool was listed from is checked against its OWN
|
|
21
|
+
* fresh list — the call goes on only if that list holds the same
|
|
22
|
+
* definition, compared as canonical JSON; otherwise `stale-tools`. Under
|
|
23
|
+
* the app's sharing contract, a replacement whose context matches uses the
|
|
24
|
+
* shared entry as it stands;
|
|
25
|
+
* 4. after every wait, checks step 2 again — and asks the app's `share`
|
|
26
|
+
* again, so a changed authorization name refuses it (`binding-changed`);
|
|
27
|
+
* 5. sends through the send gate (`mcp/requestGuard.ts`), asked at every
|
|
28
|
+
* boundary the request crosses — before every attempt, after a credential
|
|
29
|
+
* arrives, after signing — classifies the outcome (a server's 404 for the
|
|
30
|
+
* session is `SessionExpiredError`; a handle this process lost is
|
|
31
|
+
* `LocalSessionHandleLostError`; neither is repeated), files its use, and
|
|
32
|
+
* releases its lease once the request's own work has settled.
|
|
33
|
+
*
|
|
34
|
+
* Never another conversation's connection: the binding is to the KEY, and a
|
|
35
|
+
* client of any other key never serves it.
|
|
36
|
+
*/
|
|
37
|
+
import type { Tool } from '../../tools/tools.js';
|
|
38
|
+
import type { Definition } from './definitions.js';
|
|
39
|
+
import { type PoolKey } from './identityKey.js';
|
|
40
|
+
import type { Pool } from './pool.js';
|
|
41
|
+
import { UseFacts } from './record.js';
|
|
42
|
+
/** What a bound tool was listed under. */
|
|
43
|
+
export interface Binding {
|
|
44
|
+
readonly key: PoolKey;
|
|
45
|
+
/** The definitions context: `pc:<configHash>` per client, `sh:<context>` shared. */
|
|
46
|
+
readonly context: string;
|
|
47
|
+
readonly shared: boolean;
|
|
48
|
+
/** The list it came from: an incarnation's own, or a shared entry's. */
|
|
49
|
+
readonly listId: string;
|
|
50
|
+
readonly generation: number;
|
|
51
|
+
/** Per client: the incarnation it was listed from. */
|
|
52
|
+
readonly clientId?: string;
|
|
53
|
+
readonly definition: Definition;
|
|
54
|
+
}
|
|
55
|
+
/** A callable tool for `binding`, shaped as every MCP tool is. */
|
|
56
|
+
export declare function boundTool(pool: Pool, binding: Binding): Tool;
|
|
57
|
+
/** A refusal's word on the record. */
|
|
58
|
+
export declare function noteRefusal(facts: UseFacts, error: unknown): void;
|
|
59
|
+
//# sourceMappingURL=boundTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundTool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/pool/boundTool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAwB,MAAM,sBAAsB,CAAC;AAMvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,0CAA0C;AAC1C,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACjC;AAED,kEAAkE;AAClE,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAK5D;AAuKD,sCAAsC;AACtC,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAUjE"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* clientSet — which clients the pool holds, and in which of its two sets.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: two sets and their indexes, mutated only together.
|
|
5
|
+
* Role: § 5.3 of the design. The OPEN set holds every client that counts
|
|
6
|
+
* toward `maxClients` — opening, busy, idle, deferred, or an abandoned
|
|
7
|
+
* open that has not settled. The ENDING set holds every client from the
|
|
8
|
+
* decision to end it until that ending's work has settled, and counts
|
|
9
|
+
* toward `maxEnding`. A client leaves the open set only into the ending
|
|
10
|
+
* set — a lost handle too: its ending is its local close — or, when its
|
|
11
|
+
* open failed and left nothing to end, by being dropped. So the pool
|
|
12
|
+
* holds at most `maxClients + maxEnding` client objects.
|
|
13
|
+
*
|
|
14
|
+
* Each key has at most one CURRENT client — the one new leases go to. A client
|
|
15
|
+
* named by `terminate`, or whose session expired, stops being current at once
|
|
16
|
+
* while it stays in the open set, counted, until it can end.
|
|
17
|
+
*
|
|
18
|
+
* What the pool remembers of a key after its client left — the incarnation
|
|
19
|
+
* count and why the last one left — is bounded (`KEY_MEMORY`), least recently
|
|
20
|
+
* used forgotten first: after that a key's count starts again at 1. The record
|
|
21
|
+
* reads it; no binding depends on it.
|
|
22
|
+
*/
|
|
23
|
+
import type { EndReason, PooledClient } from './pooledClient.js';
|
|
24
|
+
/** How many keys' incarnation counts the pool remembers. */
|
|
25
|
+
export declare const KEY_MEMORY = 4096;
|
|
26
|
+
/** Why a key's previous client left, as the record names it. */
|
|
27
|
+
export type PreviousEnd = 'idle' | 'evicted' | 'expired' | 'handle-lost' | 'terminated';
|
|
28
|
+
export declare class ClientSet {
|
|
29
|
+
private readonly open;
|
|
30
|
+
private readonly ending;
|
|
31
|
+
private readonly current;
|
|
32
|
+
private readonly perPrincipal;
|
|
33
|
+
private readonly memory;
|
|
34
|
+
/** Clients in the open set. */
|
|
35
|
+
get openCount(): number;
|
|
36
|
+
/** Clients in the ending set. */
|
|
37
|
+
get endingCount(): number;
|
|
38
|
+
/** Every client in the open set. */
|
|
39
|
+
openClients(): readonly PooledClient[];
|
|
40
|
+
/** Clients of the open set that count for `principal`. */
|
|
41
|
+
principalCount(principal: string): number;
|
|
42
|
+
/** The key's current client — opening or open, taking new leases — if it has one. */
|
|
43
|
+
currentFor(key: string): PooledClient | undefined;
|
|
44
|
+
/** The next incarnation number for `key`, and why its previous client left. */
|
|
45
|
+
nextIncarnation(key: string): {
|
|
46
|
+
readonly generation: number;
|
|
47
|
+
readonly previous?: PreviousEnd;
|
|
48
|
+
};
|
|
49
|
+
/** A new client joins the open set as its key's current client. */
|
|
50
|
+
admit(client: PooledClient): void;
|
|
51
|
+
/**
|
|
52
|
+
* The client stops taking new leases: its key has no current client until the
|
|
53
|
+
* next open, and that open's record says `why`. A client that is no longer
|
|
54
|
+
* its key's current one has already left it, so nothing is recorded again —
|
|
55
|
+
* a later client of the key keeps its own reason.
|
|
56
|
+
*/
|
|
57
|
+
retire(client: PooledClient, why: PreviousEnd): void;
|
|
58
|
+
/** The client moves from the open set into the ending set. */
|
|
59
|
+
moveToEnding(client: PooledClient, why: PreviousEnd | undefined): void;
|
|
60
|
+
/** The client's ending settled: it leaves the ending set. */
|
|
61
|
+
ended(client: PooledClient): void;
|
|
62
|
+
/** The client leaves the open set without ending — a failed open, a lost handle. */
|
|
63
|
+
drop(client: PooledClient, why?: PreviousEnd): void;
|
|
64
|
+
/**
|
|
65
|
+
* The least recently used idle client of the open set — among those `pick`
|
|
66
|
+
* accepts — or `undefined` when every one is busy.
|
|
67
|
+
*/
|
|
68
|
+
leastRecentlyUsedIdle(pick: (client: PooledClient) => boolean): PooledClient | undefined;
|
|
69
|
+
private leaveOpen;
|
|
70
|
+
private remember;
|
|
71
|
+
}
|
|
72
|
+
/** The record's `previous` for an end reason, when it names one. */
|
|
73
|
+
export declare function previousOf(reason: EndReason): PreviousEnd | undef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