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,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* definitions — the tool lists a pool serves, and when each stops being served.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: one list type, two owners — a client incarnation, or a shared entry.
|
|
5
|
+
* Role: § 6 of the design. A definition is what one `tools/list` entry says:
|
|
6
|
+
* name, description, input schema, and the declarations its `_meta`
|
|
7
|
+
* carries. The executable half (the connection) is never shared.
|
|
8
|
+
*
|
|
9
|
+
* - PER CLIENT (the default): a conversation's list is its own client's, and
|
|
10
|
+
* it belongs to that client INCARNATION alone — a replacement client, even
|
|
11
|
+
* one opened from the same plan, is a new session whose list may differ,
|
|
12
|
+
* so it lists again.
|
|
13
|
+
* - SHARED, only under the app's declared contract: one entry per context
|
|
14
|
+
* (`plan.ts`), listed on the client of whichever conversation needs it,
|
|
15
|
+
* bounded at `MAX_DEFINITION_ENTRIES` entries; a list longer than
|
|
16
|
+
* `MAX_SHARED_TOOLS` is used by its own client and not shared.
|
|
17
|
+
*
|
|
18
|
+
* A list stops being served in four ways, plus a time limit: the configuration
|
|
19
|
+
* (a new context is a new list), the server's tools-changed notice, the app's
|
|
20
|
+
* `permissionsChanged`, and `toolsChanged`. Invalidation moves the list's
|
|
21
|
+
* GENERATION at once — every tool bound to an older one is refused — and marks
|
|
22
|
+
* it to be listed again. A lapsed time limit lists again at the next list, and
|
|
23
|
+
* moves the generation only if the new list differs. A generation counts within
|
|
24
|
+
* one list: a replacement client and a new entry start counts of their own, and
|
|
25
|
+
* a binding names the list it came from, so no number of an old list can match
|
|
26
|
+
* a new one. A listing still in flight when its list's generation moved is
|
|
27
|
+
* discarded, never written.
|
|
28
|
+
*
|
|
29
|
+
* Every list is a frozen plain-data copy (`mcp/plainData.ts` · `copyJsonObject`),
|
|
30
|
+
* written once per generation, by one listing at a time.
|
|
31
|
+
*/
|
|
32
|
+
import type { Tool } from '../../tools/tools.js';
|
|
33
|
+
import type { McpListedTool } from '../types.js';
|
|
34
|
+
/** One definition, frozen, and its canonical JSON — what "the same definition" compares. */
|
|
35
|
+
export interface Definition {
|
|
36
|
+
readonly listed: McpListedTool;
|
|
37
|
+
readonly canonical: string;
|
|
38
|
+
}
|
|
39
|
+
/** A frozen copy of `listed`, or `undefined` when it is not plain JSON data. */
|
|
40
|
+
export declare function definitionOf(listed: McpListedTool): Definition | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* One list: an incarnation's own or a shared entry. Its `id` is stable for its
|
|
43
|
+
* life; its `generation` moves on invalidation, and on a time-limit relisting
|
|
44
|
+
* that changed it.
|
|
45
|
+
*/
|
|
46
|
+
export declare class DefinitionList {
|
|
47
|
+
readonly id: string;
|
|
48
|
+
private current;
|
|
49
|
+
private tools;
|
|
50
|
+
/** Has any listing been written? */
|
|
51
|
+
private written;
|
|
52
|
+
/** 0 until the first listing is written. */
|
|
53
|
+
generation: number;
|
|
54
|
+
/** Invalidated: listed again before it is served. */
|
|
55
|
+
stale: boolean;
|
|
56
|
+
/** When it was last written, on the pool's clock. */
|
|
57
|
+
listedAt: number;
|
|
58
|
+
/** The listing in flight, joined by anyone who needs the same list. */
|
|
59
|
+
listing: Promise<void> | undefined;
|
|
60
|
+
/** Can it be served at `now`, as it stands? */
|
|
61
|
+
servable(now: number, ttlMs: number): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Invalidate: every older binding is refused, the next list lists again, and
|
|
64
|
+
* a listing in flight is discarded — even a first one, before anything was
|
|
65
|
+
* written. Generations only ever increase.
|
|
66
|
+
*/
|
|
67
|
+
invalidate(): void;
|
|
68
|
+
/** The definition named `name`, at the current generation. */
|
|
69
|
+
definition(name: string): Definition | undefined;
|
|
70
|
+
/** The client's own wrapped tool named `name` (per-client lists only). */
|
|
71
|
+
tool(name: string): Tool | undefined;
|
|
72
|
+
/** Every definition, in listing order. */
|
|
73
|
+
all(): readonly Definition[];
|
|
74
|
+
/**
|
|
75
|
+
* Write a listing that began at generation `began`. Refused — `false`, nothing
|
|
76
|
+
* written — when the generation moved while it ran. A first write moves the
|
|
77
|
+
* generation to a number no binding has seen; a write after invalidation keeps
|
|
78
|
+
* the moved one; a time-limit rewrite moves it only when the list differs.
|
|
79
|
+
*/
|
|
80
|
+
write(began: number, definitions: readonly Definition[], tools: readonly Tool[] | undefined, now: number): boolean;
|
|
81
|
+
}
|
|
82
|
+
/** A shared entry: a list and the tenant its context carries. */
|
|
83
|
+
export interface SharedEntry {
|
|
84
|
+
readonly list: DefinitionList;
|
|
85
|
+
readonly tenant: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The shared definition entries, by context — bounded at
|
|
89
|
+
* `MAX_DEFINITION_ENTRIES`, the least recently used dropped first. A dropped
|
|
90
|
+
* entry's bindings are refused as stale: the entry they name is gone.
|
|
91
|
+
*/
|
|
92
|
+
export declare class SharedDefinitions {
|
|
93
|
+
private readonly maxEntries;
|
|
94
|
+
private readonly entries;
|
|
95
|
+
constructor(maxEntries?: number);
|
|
96
|
+
get size(): number;
|
|
97
|
+
/** The entry for `context`, created empty when there is none; most recently used. */
|
|
98
|
+
entryFor(context: string, tenant: string): SharedEntry;
|
|
99
|
+
/** The entry for `context` if it still exists — never created. */
|
|
100
|
+
peek(context: string): SharedEntry | undefined;
|
|
101
|
+
/** Invalidate every entry `matches` selects. */
|
|
102
|
+
invalidate(matches: (entry: SharedEntry) => boolean): void;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../../src/mcp/pool/definitions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,4FAA4F;AAC5F,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,gFAAgF;AAChF,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,UAAU,GAAG,SAAS,CAI1E;AAaD;;;;GAIG;AACH,qBAAa,cAAc;IACzB,QAAQ,CAAC,EAAE,SAAqB;IAChC,OAAO,CAAC,OAAO,CAA8C;IAC7D,OAAO,CAAC,KAAK,CAAwC;IACrD,oCAAoC;IACpC,OAAO,CAAC,OAAO,CAAS;IACxB,4CAA4C;IAC5C,UAAU,SAAK;IACf,qDAAqD;IACrD,KAAK,UAAS;IACd,qDAAqD;IACrD,QAAQ,SAAK;IACb,uEAAuE;IACvE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IAEnC,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAI7C;;;;OAIG;IACH,UAAU,IAAI,IAAI;IAKlB,8DAA8D;IAC9D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIhD,0EAA0E;IAC1E,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIpC,0CAA0C;IAC1C,GAAG,IAAI,SAAS,UAAU,EAAE;IAI5B;;;;;OAKG;IACH,KAAK,CACH,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,SAAS,EAClC,GAAG,EAAE,MAAM,GACV,OAAO;CAYX;AAUD,iEAAiE;AACjE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;IAGhB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;gBAE7B,UAAU,GAAE,MAA+B;IAExE,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW;IAatD,kEAAkE;IAClE,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI9C,gDAAgD;IAChD,UAAU,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,GAAG,IAAI;CAG3D"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* errors — the pool's two refusals, each one fixed sentence.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: typed errors whose message reaches the model and whose fields reach
|
|
5
|
+
* the app.
|
|
6
|
+
* Role: A refusal comes before the `tools/call` is sent, and says so
|
|
7
|
+
* (`sent: false`) for the record of what that attempt did. Control
|
|
8
|
+
* requests made on the way — the `initialize` of a replacement client,
|
|
9
|
+
* a revalidating `tools/list` — may already have reached the server;
|
|
10
|
+
* `sent` describes the `tools/call` only.
|
|
11
|
+
*
|
|
12
|
+
* A message is a fixed sentence per reason. It names no identity, no key, no
|
|
13
|
+
* session and no count: the counts ride typed fields the app reads, and the
|
|
14
|
+
* original error of a failed open rides `cause`, for the app, never composed
|
|
15
|
+
* into the message.
|
|
16
|
+
*/
|
|
17
|
+
/** Why a pool refused, by name. */
|
|
18
|
+
export type McpPoolRefusal = 'no-identity' | 'incomplete-identity' | 'identity-mismatch' | 'init-timeout' | 'init-failed' | 'stale-tools' | 'binding-changed' | 'request-unmatched' | 'lease-expired' | 'closed';
|
|
19
|
+
/** The sentence each refusal reaches the model as. */
|
|
20
|
+
export declare const MCP_POOL_REFUSAL_SENTENCES: Readonly<Record<McpPoolRefusal, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* The pool refused before the `tools/call` was sent — by `reason`.
|
|
23
|
+
*
|
|
24
|
+
* `init-failed` keeps the open's own error as `cause`, for the app; its text is
|
|
25
|
+
* never in the message.
|
|
26
|
+
*/
|
|
27
|
+
export declare class McpPoolRefusedError extends Error {
|
|
28
|
+
readonly reason: McpPoolRefusal;
|
|
29
|
+
/** The pool's name: the server. */
|
|
30
|
+
readonly server: string;
|
|
31
|
+
readonly code: "ERR_MCP_POOL_REFUSED";
|
|
32
|
+
/** The `tools/call` was not sent. Control requests on the way may have been. */
|
|
33
|
+
readonly sent: false;
|
|
34
|
+
constructor(reason: McpPoolRefusal,
|
|
35
|
+
/** The pool's name: the server. */
|
|
36
|
+
server: string, options?: {
|
|
37
|
+
readonly cause?: unknown;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/** Which budget was full. */
|
|
41
|
+
export type McpPoolLimit = 'pool' | 'principal' | 'ending' | 'operations';
|
|
42
|
+
/** The one sentence a full pool reaches the model as. */
|
|
43
|
+
export declare const POOL_FULL_SENTENCE = "The connection pool for this server was full, so the tool call was not sent.";
|
|
44
|
+
/**
|
|
45
|
+
* A budget was full, so the work was refused at once — there is no queue. Its
|
|
46
|
+
* scope is the `tools/call`, as with `sent: false`. The counts ride typed fields.
|
|
47
|
+
*/
|
|
48
|
+
export declare class PoolFullError extends Error {
|
|
49
|
+
/** The pool's name: the server. */
|
|
50
|
+
readonly server: string;
|
|
51
|
+
/** Which budget was full. */
|
|
52
|
+
readonly limit: McpPoolLimit;
|
|
53
|
+
/** That budget's size. */
|
|
54
|
+
readonly max: number;
|
|
55
|
+
/** Busy clients when it was refused. */
|
|
56
|
+
readonly busy: number;
|
|
57
|
+
/** Clients being ended when it was refused. */
|
|
58
|
+
readonly ending: number;
|
|
59
|
+
/** Operations charged when it was refused. */
|
|
60
|
+
readonly operations: number;
|
|
61
|
+
readonly code: "ERR_MCP_POOL_FULL";
|
|
62
|
+
readonly sent: false;
|
|
63
|
+
constructor(
|
|
64
|
+
/** The pool's name: the server. */
|
|
65
|
+
server: string,
|
|
66
|
+
/** Which budget was full. */
|
|
67
|
+
limit: McpPoolLimit,
|
|
68
|
+
/** That budget's size. */
|
|
69
|
+
max: number,
|
|
70
|
+
/** Busy clients when it was refused. */
|
|
71
|
+
busy: number,
|
|
72
|
+
/** Clients being ended when it was refused. */
|
|
73
|
+
ending: number,
|
|
74
|
+
/** Operations charged when it was refused. */
|
|
75
|
+
operations: number);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/mcp/pool/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,mCAAmC;AACnC,MAAM,MAAM,cAAc,GACtB,aAAa,GACb,qBAAqB,GACrB,mBAAmB,GACnB,cAAc,GACd,aAAa,GACb,aAAa,GACb,iBAAiB,GACjB,mBAAmB,GACnB,eAAe,GACf,QAAQ,CAAC;AAEb,sDAAsD;AACtD,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,CAmB9E,CAAC;AAEH;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAM1C,QAAQ,CAAC,MAAM,EAAE,cAAc;IAC/B,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAPzB,QAAQ,CAAC,IAAI,yBAAmC;IAChD,gFAAgF;IAChF,QAAQ,CAAC,IAAI,QAAkB;gBAGpB,MAAM,EAAE,cAAc;IAC/B,mCAAmC;IAC1B,MAAM,EAAE,MAAM,EACvB,OAAO,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;CAO7C;AAED,6BAA6B;AAC7B,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE1E,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,iFACiD,CAAC;AAEjF;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAKpC,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,EAAE,YAAY;IAC5B,0BAA0B;IAC1B,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM;IAf7B,QAAQ,CAAC,IAAI,sBAAgC;IAC7C,QAAQ,CAAC,IAAI,QAAkB;;IAG7B,mCAAmC;IAC1B,MAAM,EAAE,MAAM;IACvB,6BAA6B;IACpB,KAAK,EAAE,YAAY;IAC5B,0BAA0B;IACjB,GAAG,EAAE,MAAM;IACpB,wCAAwC;IAC/B,IAAI,EAAE,MAAM;IACrB,+CAA+C;IACtC,MAAM,EAAE,MAAM;IACvB,8CAA8C;IACrC,UAAU,EAAE,MAAM;CAK9B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* identityKey — the conversation a pooled client belongs to, as one key.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: the library's one identity encoding, never a second.
|
|
5
|
+
* Role: The client key is `identityNamespace` of the identity the CALLER
|
|
6
|
+
* named — each field through `encodeIdentityField`, the encoding the
|
|
7
|
+
* memory layer calls the tenant boundary. It is injective: tenant
|
|
8
|
+
* `acme/hr` with principal `alice` and tenant `acme` with principal
|
|
9
|
+
* `hr/alice` are two keys, and an absent field and a field named `_`
|
|
10
|
+
* are two keys. A pool is one server, so the key needs no server
|
|
11
|
+
* segment, and two pools never share a client.
|
|
12
|
+
*
|
|
13
|
+
* Two doors only: the run's caller identity (`ToolDispatchContext.callerIdentity`,
|
|
14
|
+
* `ToolExecutionContext.identity`) and the identity app code passes to `acquire`
|
|
15
|
+
* and `terminate`. Never tool arguments, model output, a message, a request
|
|
16
|
+
* body, or a `sessionId` alone. No identity value is ever written to an error,
|
|
17
|
+
* an event or a report: the wire carries `keyHash`, the tool-session digest.
|
|
18
|
+
*/
|
|
19
|
+
import type { McpPoolIdentity } from './options.js';
|
|
20
|
+
/** One conversation's key, and the coarser keys its budgets count by. */
|
|
21
|
+
export interface PoolKey {
|
|
22
|
+
/** `identityNamespace` of the identity — the client key. */
|
|
23
|
+
readonly key: string;
|
|
24
|
+
/** The tenant and principal segments — what `maxClientsPerPrincipal` counts by. */
|
|
25
|
+
readonly principal: string;
|
|
26
|
+
/** The tenant segment — always part of a shared definitions context. */
|
|
27
|
+
readonly tenant: string;
|
|
28
|
+
/** The digest the record carries in the key's place. */
|
|
29
|
+
readonly keyHash: string;
|
|
30
|
+
/** The identity itself, as a frozen copy — what the transport factory and `share` are asked with. */
|
|
31
|
+
readonly identity: McpPoolIdentity;
|
|
32
|
+
}
|
|
33
|
+
/** What an identity must carry. */
|
|
34
|
+
export interface IdentityRules {
|
|
35
|
+
readonly requirePrincipal: boolean;
|
|
36
|
+
readonly requireTenant: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The key for `identity`, or why there is none: `'no-identity'` when nothing was
|
|
40
|
+
* named (a derived identity counts as none), `'incomplete-identity'` when it
|
|
41
|
+
* lacks a `conversationId`, a required `principal` or a required `tenant`, or a
|
|
42
|
+
* field is not a string.
|
|
43
|
+
*/
|
|
44
|
+
export declare function poolKeyOf(identity: unknown, rules: IdentityRules): PoolKey | 'no-identity' | 'incomplete-identity';
|
|
45
|
+
/**
|
|
46
|
+
* Which keys a scope names. The tenant is matched exactly, always — an absent
|
|
47
|
+
* tenant is the absent segment, never a wildcard, because the tenant is the
|
|
48
|
+
* boundary. A scope that names a `conversationId` names exactly that one
|
|
49
|
+
* conversation (an absent principal is then the absent segment, as in the key).
|
|
50
|
+
* A scope without one names every conversation of its principal, and a scope
|
|
51
|
+
* without a principal either names every conversation of its tenant.
|
|
52
|
+
*/
|
|
53
|
+
export declare function scopeMatcher(scope: {
|
|
54
|
+
readonly tenant?: string;
|
|
55
|
+
readonly principal?: string;
|
|
56
|
+
readonly conversationId?: string;
|
|
57
|
+
}): (key: PoolKey) => boolean;
|
|
58
|
+
//# sourceMappingURL=identityKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identityKey.d.ts","sourceRoot":"","sources":["../../../../src/mcp/pool/identityKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,yEAAyE;AACzE,MAAM,WAAW,OAAO;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mFAAmF;IACnF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,qGAAqG;IACrG,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;CACpC;AAED,mCAAmC;AACnC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,aAAa,GACnB,OAAO,GAAG,aAAa,GAAG,qBAAqB,CAiCjD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAe5B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lease — the app's explicit, bounded hold on one conversation's client.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: a handle that releases at most once, by hand or by `await using`.
|
|
5
|
+
* Role: § 3.3 and § 5.2 of the design. `acquire` is for code that drives a
|
|
6
|
+
* sequence itself, or a host that must keep a conversation's client
|
|
7
|
+
* from eviction for a whole turn (it holds one around `agent.run()`, and
|
|
8
|
+
* the provider then finds the same client). It is the only way to
|
|
9
|
+
* protect a client between calls: there is no hidden grace period.
|
|
10
|
+
*
|
|
11
|
+
* The `acquire` that opened it was the operation; the held lease is not one. It
|
|
12
|
+
* is bounded by `maxLeaseMs`: past it, it is revoked at the next pool
|
|
13
|
+
* interaction and reported, and its next use throws `lease-expired`. Calls
|
|
14
|
+
* already in flight keep their own leases until they settle.
|
|
15
|
+
*/
|
|
16
|
+
import type { Tool } from '../../tools/tools.js';
|
|
17
|
+
import type { PoolKey } from './identityKey.js';
|
|
18
|
+
import type { HeldLease, Pool } from './pool.js';
|
|
19
|
+
/** The app's hold on one conversation's client. Release it — or `await using` it. */
|
|
20
|
+
export interface McpPoolLease extends AsyncDisposable {
|
|
21
|
+
/**
|
|
22
|
+
* This conversation's tools, bound to it. A call through one needs the
|
|
23
|
+
* conversation's identity on its context (`ToolExecutionContext.identity`);
|
|
24
|
+
* the agent puts it there for a run that named one.
|
|
25
|
+
*
|
|
26
|
+
* @throws `McpPoolRefusedError` (`lease-expired`) once the lease was revoked
|
|
27
|
+
* or released; what a listing throws otherwise
|
|
28
|
+
*/
|
|
29
|
+
tools(options?: {
|
|
30
|
+
readonly signal?: AbortSignal;
|
|
31
|
+
}): Promise<readonly Tool[]>;
|
|
32
|
+
/** Release the hold. Idempotent. */
|
|
33
|
+
release(): void;
|
|
34
|
+
}
|
|
35
|
+
/** The lease handle for `held`, on `key`'s client. */
|
|
36
|
+
export declare function leaseHandle(pool: Pool, key: PoolKey, held: HeldLease): McpPoolLease;
|
|
37
|
+
//# sourceMappingURL=lease.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lease.d.ts","sourceRoot":"","sources":["../../../../src/mcp/pool/lease.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjD,qFAAqF;AACrF,MAAM,WAAW,YAAa,SAAQ,eAAe;IACnD;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IAC7E,oCAAoC;IACpC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,sDAAsD;AACtD,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,YAAY,CA0BnF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* listTools — one conversation's tools, bound to it: one listing operation.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: one admitted operation per call, the provider's and the lease's alike.
|
|
5
|
+
* Role: § 3.2 and § 6 of the design. A listing is one `list(ctx)` for one
|
|
6
|
+
* conversation, admitted against `maxOperations`. Its setup — the open
|
|
7
|
+
* of the key's client, the `tools/list` — runs inside its slot.
|
|
8
|
+
*
|
|
9
|
+
* - PER CLIENT: the conversation's own client is opened (or reused) and its own
|
|
10
|
+
* list served, listed again when it cannot be served as it stands.
|
|
11
|
+
* - SHARED, under the app's contract: the plan is resolved and the context
|
|
12
|
+
* computed WITHOUT opening anything; a current entry is served touching no
|
|
13
|
+
* client (`client: 'not-needed'`); a listing already under way for it is
|
|
14
|
+
* joined; otherwise the listing runs on THIS conversation's own client —
|
|
15
|
+
* never in another conversation's session.
|
|
16
|
+
* - THE CALLER'S CONTEXT AFTER EVERY WAIT: the app's names are asked again
|
|
17
|
+
* after a joined listing and after this one's own (`Pool.ensureListed`); a
|
|
18
|
+
* list is served only under the context the caller has at that moment, and
|
|
19
|
+
* a moved context is resolved again — at most three rounds, then refused
|
|
20
|
+
* (`binding-changed`).
|
|
21
|
+
*
|
|
22
|
+
* A refused listing never reaches the model as a tool result: it fails that
|
|
23
|
+
* iteration's tool discovery (`agentfootprint.tools.discovery_failed`), as any
|
|
24
|
+
* failing `ToolProvider` does. A list that cannot be read to its end
|
|
25
|
+
* (`McpToolListIncompleteError`, from the client's own discovery) is never
|
|
26
|
+
* served cut short.
|
|
27
|
+
*/
|
|
28
|
+
import type { Tool } from '../../tools/tools.js';
|
|
29
|
+
import type { PoolKey } from './identityKey.js';
|
|
30
|
+
import type { Pool } from './pool.js';
|
|
31
|
+
import type { UseFacts } from './record.js';
|
|
32
|
+
/** List `key`'s conversation's tools, bound to it, under one admitted operation. */
|
|
33
|
+
export declare function listTools(pool: Pool, key: PoolKey, signal: AbortSignal | undefined, facts: UseFacts): Promise<readonly Tool[]>;
|
|
34
|
+
//# sourceMappingURL=listTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listTools.d.ts","sourceRoot":"","sources":["../../../../src/mcp/pool/listTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,WAAW,CAAC;AAElD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,oFAAoF;AACpF,wBAAsB,SAAS,CAC7B,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,KAAK,EAAE,QAAQ,GACd,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAgD1B"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mcpClientPool — a client per conversation, for one MCP server.
|
|
3
|
+
*
|
|
4
|
+
* const orders = mcpClientPool({
|
|
5
|
+
* name: 'orders',
|
|
6
|
+
* transport: () =>
|
|
7
|
+
* agentCoreRuntimeMcpTransport({ agentRuntimeArn, region, session: 'reuse', client: aws }),
|
|
8
|
+
* });
|
|
9
|
+
* const agent = Agent.create({ provider, model }).toolProvider(orders.toolProvider()).build();
|
|
10
|
+
* await agent.run({ message, identity: { tenant, principal, conversationId } });
|
|
11
|
+
*
|
|
12
|
+
* Pattern: Facade over one state machine (`pool.ts`), its accounting (`work.ts`),
|
|
13
|
+
* its definitions (`definitions.ts`) and its bound tools (`boundTool.ts`).
|
|
14
|
+
* Role: `docs/design/2026-10-mcp-client-pool.md`. A `'reuse'` session costs a
|
|
15
|
+
* cold start once per conversation instead of once per call — but only
|
|
16
|
+
* if each conversation has a client of its own, opened once, bounded,
|
|
17
|
+
* never closed while in use, ended remotely and said to be. This is
|
|
18
|
+
* the one place that does all of it:
|
|
19
|
+
*
|
|
20
|
+
* - one client per authenticated conversation, keyed by the library's
|
|
21
|
+
* identity encoding of the identity the CALLER named;
|
|
22
|
+
* - one open per key, under the pool's own signal and `initTimeoutMs`;
|
|
23
|
+
* - three budgets — open clients, endings, outstanding operations — each
|
|
24
|
+
* charged until the work under it has SETTLED, and `PoolFullError` at once
|
|
25
|
+
* when one is full: there is no queue;
|
|
26
|
+
* - tool definitions per client incarnation by default, shared only under the
|
|
27
|
+
* app's declared contract, every tool re-checked after each wait and at the
|
|
28
|
+
* send gate;
|
|
29
|
+
* - every ending through `terminate()`, with the remote outcome reported, and
|
|
30
|
+
* `close()` still only local.
|
|
31
|
+
*
|
|
32
|
+
* What it does not do: repeat a call, share anything across processes, bound a
|
|
33
|
+
* remote session it could not end, or make a server enforce per-user
|
|
34
|
+
* permissions.
|
|
35
|
+
*/
|
|
36
|
+
import type { ToolProvider } from '../../tools/toolProvider.js';
|
|
37
|
+
import type { McpTerminateOutcome } from '../types.js';
|
|
38
|
+
import { type McpPoolLease } from './lease.js';
|
|
39
|
+
import { type McpClientPoolOptions, type McpPoolIdentity } from './options.js';
|
|
40
|
+
import { type McpPoolStats } from './pool.js';
|
|
41
|
+
/** The scope `terminate` and `permissionsChanged` name. */
|
|
42
|
+
export interface McpPoolScope {
|
|
43
|
+
/** Matched exactly, always: an absent tenant is "no tenant", never "every tenant". */
|
|
44
|
+
readonly tenant?: string;
|
|
45
|
+
/** Absent: every principal of the tenant (`permissionsChanged` only). */
|
|
46
|
+
readonly principal?: string;
|
|
47
|
+
/** Absent: every conversation of the principal. */
|
|
48
|
+
readonly conversationId?: string;
|
|
49
|
+
}
|
|
50
|
+
/** One pool per MCP server: a client per conversation. */
|
|
51
|
+
export interface McpClientPool {
|
|
52
|
+
/** The pool's name: the server. */
|
|
53
|
+
readonly name: string;
|
|
54
|
+
/**
|
|
55
|
+
* The agent path: a `ToolProvider` (id `mcp-pool:<name>`) whose `list(ctx)`
|
|
56
|
+
* takes the run's caller identity (`ToolDispatchContext.callerIdentity`) and
|
|
57
|
+
* returns that conversation's tools, bound to it. A bound tool's `execute`
|
|
58
|
+
* takes a lease on the key's client for one call, opening the client first
|
|
59
|
+
* when the key has none; nothing is held between calls. A run with no caller
|
|
60
|
+
* identity is refused (`no-identity`) — a derived one counts as none.
|
|
61
|
+
*/
|
|
62
|
+
toolProvider(): ToolProvider;
|
|
63
|
+
/**
|
|
64
|
+
* Hold `identity`'s conversation client — opened or reused — until
|
|
65
|
+
* `release()`, at most `maxLeaseMs`. The only way to protect a client between
|
|
66
|
+
* calls (a host holds one around `agent.run()`).
|
|
67
|
+
*
|
|
68
|
+
* @throws `McpPoolRefusedError` (`no-identity`, `incomplete-identity`,
|
|
69
|
+
* `init-timeout`, `init-failed`, `closed`) or `PoolFullError`
|
|
70
|
+
*/
|
|
71
|
+
acquire(identity: McpPoolIdentity, options?: {
|
|
72
|
+
readonly signal?: AbortSignal;
|
|
73
|
+
}): Promise<McpPoolLease>;
|
|
74
|
+
/**
|
|
75
|
+
* End the conversations `scope` names — one (`{ tenant, principal,
|
|
76
|
+
* conversationId }`) or every one of a principal (`{ tenant, principal }`).
|
|
77
|
+
* New leases stop at once; the next acquire for a key opens a new client.
|
|
78
|
+
* In-flight work is waited for up to 5 s; then each client is ended through
|
|
79
|
+
* `terminate()` once an ending slot and an operation slot are reserved. A
|
|
80
|
+
* client still leased, or whose slots cannot be reserved yet, is reported
|
|
81
|
+
* deferred (`onEvent`), never as ended, and is ended when it can be.
|
|
82
|
+
*
|
|
83
|
+
* @returns one `McpTerminateOutcome` per client it ended
|
|
84
|
+
*/
|
|
85
|
+
terminate(scope: McpPoolScope): Promise<readonly McpTerminateOutcome[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Shut down: refuse new work, revoke app leases, abort in-flight calls
|
|
88
|
+
* through the pool's own signal, then end every client as slots can be
|
|
89
|
+
* reserved, at most `maxEnding` at a time. Resolves after a bounded wait;
|
|
90
|
+
* the clients it could not end yet are reported deferred and the work still
|
|
91
|
+
* unsettled stays charged until it settles (`stats()`). Idempotent.
|
|
92
|
+
*
|
|
93
|
+
* @returns one `McpTerminateOutcome` per client it ended
|
|
94
|
+
*/
|
|
95
|
+
close(): Promise<readonly McpTerminateOutcome[]>;
|
|
96
|
+
/** Resolves once every charged operation and every ending has settled. */
|
|
97
|
+
settled(): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* The app's permission signal: every tool list in the scope stops being
|
|
100
|
+
* served, and every tool bound to one is refused (`stale-tools`) before it is
|
|
101
|
+
* sent. Per process: a fleet sends it to every process, or versions its
|
|
102
|
+
* `authorization` names.
|
|
103
|
+
*/
|
|
104
|
+
permissionsChanged(scope: {
|
|
105
|
+
readonly tenant?: string;
|
|
106
|
+
readonly principal?: string;
|
|
107
|
+
}): void;
|
|
108
|
+
/** The server changed (a deploy hook): every tool list stops being served. */
|
|
109
|
+
toolsChanged(): void;
|
|
110
|
+
/** Run the lazy sweep now: revoked leases, idle ends, deferred ends. No timer is ever installed. */
|
|
111
|
+
sweep(): void;
|
|
112
|
+
/** Counts only — never keys. They report; the budgets enforce. */
|
|
113
|
+
stats(): McpPoolStats;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Build a pool for one MCP server.
|
|
117
|
+
*
|
|
118
|
+
* @throws TypeError when an option is missing, mistyped or out of range, or when
|
|
119
|
+
* `connection` is given — here, when the pool is built
|
|
120
|
+
*/
|
|
121
|
+
export declare function mcpClientPool(options: McpClientPoolOptions): McpClientPool;
|
|
122
|
+
//# sourceMappingURL=mcpClientPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpClientPool.d.ts","sourceRoot":"","sources":["../../../../src/mcp/pool/mcpClientPool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAAmB,KAAK,oBAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAQ,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAGpD,2DAA2D;AAC3D,MAAM,WAAW,YAAY;IAC3B,sFAAsF;IACtF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,yEAAyE;IACzE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,mDAAmD;IACnD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,YAAY,IAAI,YAAY,CAAC;IAC7B;;;;;;;OAOG;IACH,OAAO,CACL,QAAQ,EAAE,eAAe,EACzB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAC1C,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB;;;;;;;;;;OAUG;IACH,SAAS,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC,CAAC;IACxE;;;;;;;;OAQG;IACH,KAAK,IAAI,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC,CAAC;IACjD,0EAA0E;IAC1E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB;;;;;OAKG;IACH,kBAAkB,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC3F,8EAA8E;IAC9E,YAAY,IAAI,IAAI,CAAC;IACrB,oGAAoG;IACpG,KAAK,IAAI,IAAI,CAAC;IACd,kEAAkE;IAClE,KAAK,IAAI,YAAY,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CAqE1E"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* options — what `mcpClientPool` is built from, read and checked once.
|
|
3
|
+
*
|
|
4
|
+
* Pattern: one options type + one reader that refuses by name.
|
|
5
|
+
* Role: The pool's budgets and clocks (`docs/design/2026-10-mcp-client-pool.md`
|
|
6
|
+
* § 3.1). Every number is checked when the pool is built, never at the
|
|
7
|
+
* first call. The pool takes the `mcpClient` options that shape one
|
|
8
|
+
* connection and hands them to every client it opens; it never takes
|
|
9
|
+
* `connection`, because it must build the transport itself — to end
|
|
10
|
+
* the session, to hear the tools-changed notice, and to place the send
|
|
11
|
+
* gate.
|
|
12
|
+
*/
|
|
13
|
+
import type { MemoryIdentity } from '../../memory/identity/types.js';
|
|
14
|
+
import { type McpReplayOptions } from '../replay.js';
|
|
15
|
+
import type { RetryOnThrottle } from '../throttleRetry.js';
|
|
16
|
+
import type { McpJsonSchemaValidator, McpSdk, McpTransport } from '../types.js';
|
|
17
|
+
import type { McpPoolReport } from './record.js';
|
|
18
|
+
import type { PoolClientOpener } from './plan.js';
|
|
19
|
+
/** The identity a pool keys a client by: `{ tenant?, principal?, conversationId }`. */
|
|
20
|
+
export type McpPoolIdentity = MemoryIdentity;
|
|
21
|
+
/** What a conversation's tool list may be shared under: two names the app vouches for. */
|
|
22
|
+
export interface McpPoolShareContext {
|
|
23
|
+
/**
|
|
24
|
+
* What the transport hides in its code — a signer's role, the credentials of
|
|
25
|
+
* an AWS client, a custom `fetch`. Hashed into the context, never recorded.
|
|
26
|
+
*/
|
|
27
|
+
readonly configuration: string;
|
|
28
|
+
/**
|
|
29
|
+
* What the server's tool visibility depends on — a role and a policy version
|
|
30
|
+
* (`'analyst@policy-7'`). A version in the name reaches a new entry without
|
|
31
|
+
* `permissionsChanged`, for conversations that already have a client too:
|
|
32
|
+
* their tools are listed again under the new name, and a tool bound under the
|
|
33
|
+
* old one is refused before it is sent. Hashed into the context, never
|
|
34
|
+
* recorded.
|
|
35
|
+
*/
|
|
36
|
+
readonly authorization: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Share tool definitions between conversations — declared by the app, checked by
|
|
40
|
+
* the pool. `share` is asked for every conversation before anything opens, and
|
|
41
|
+
* again at every listing, every call and every send gate after that, so a
|
|
42
|
+
* changed answer takes effect at the next one; it must be synchronous and
|
|
43
|
+
* cheap. A listing's answer is kept only if the names still give the context it
|
|
44
|
+
* was listed for when it arrives — otherwise it is dropped and listed again. Return both names, or `undefined` to keep that conversation's list to
|
|
45
|
+
* itself. Conversations share a list only when the transport's comparable
|
|
46
|
+
* data, both names and the tenant are all equal. A `share` that throws refuses
|
|
47
|
+
* the open (`init-failed`) or, for a conversation that already has a client,
|
|
48
|
+
* that listing or call (`binding-changed`) — its error as `cause`. Never share
|
|
49
|
+
* a server whose list follows the session (one that unlocks tools as a
|
|
50
|
+
* conversation goes on).
|
|
51
|
+
*/
|
|
52
|
+
export interface McpPoolDefinitionSharing {
|
|
53
|
+
readonly share: (identity: McpPoolIdentity) => McpPoolShareContext | undefined;
|
|
54
|
+
}
|
|
55
|
+
/** Options for {@link mcpClientPool}. */
|
|
56
|
+
export interface McpClientPoolOptions {
|
|
57
|
+
/** The server's name: every tool's `source`, the provider's id, and the record. */
|
|
58
|
+
readonly name: string;
|
|
59
|
+
/**
|
|
60
|
+
* The transport each client is opened over. A FUNCTION of the identity is
|
|
61
|
+
* preferred: it is called before each client opens (and again for every
|
|
62
|
+
* replacement) with the identity the client is for, so each client gets a
|
|
63
|
+
* transport — and a session map — of its own, and a provider can vend THAT
|
|
64
|
+
* user's credential. One shared object serves every client; a shared
|
|
65
|
+
* `'reuse'` runtime transport then needs `maxClients + maxEnding` at or below
|
|
66
|
+
* its 256 remembered connections.
|
|
67
|
+
*/
|
|
68
|
+
readonly transport: McpTransport | ((identity: McpPoolIdentity) => McpTransport);
|
|
69
|
+
/** Open clients — opening, busy or idle. Default 64. */
|
|
70
|
+
readonly maxClients?: number;
|
|
71
|
+
/** Open clients for one principal (one tenant's principal). Default 8. */
|
|
72
|
+
readonly maxClientsPerPrincipal?: number;
|
|
73
|
+
/** Clients being ended at once, until each ending's work has settled. Default 8. */
|
|
74
|
+
readonly maxEnding?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Opens, listings, calls and endings outstanding on any client, each from
|
|
77
|
+
* its admission until its work has settled — not merely until its caller was
|
|
78
|
+
* answered. Default 256. Size it above `maxEnding`.
|
|
79
|
+
*/
|
|
80
|
+
readonly maxOperations?: number;
|
|
81
|
+
/** One open per conversation, under this ceiling. Default 30 000 ms. */
|
|
82
|
+
readonly initTimeoutMs?: number;
|
|
83
|
+
/**
|
|
84
|
+
* End a client idle this long, at the next pool interaction (no timer is
|
|
85
|
+
* installed). Default 600 000 ms — below AgentCore Runtime's 900 s idle
|
|
86
|
+
* timeout; set it lower for a runtime configured lower.
|
|
87
|
+
*/
|
|
88
|
+
readonly idleMs?: number;
|
|
89
|
+
/** An app lease (`acquire`) is revoked past this. Default 900 000 ms (15 minutes). */
|
|
90
|
+
readonly maxLeaseMs?: number;
|
|
91
|
+
/** A tool list is listed again after this, at the next list. Default 600 000 ms. */
|
|
92
|
+
readonly definitionTtlMs?: number;
|
|
93
|
+
/** `'per-client'` (the default), or the app's declared sharing contract. */
|
|
94
|
+
readonly definitions?: 'per-client' | McpPoolDefinitionSharing;
|
|
95
|
+
/** Refuse an identity without a `principal`. Default `true`. */
|
|
96
|
+
readonly requirePrincipal?: boolean;
|
|
97
|
+
/** Refuse an identity without a `tenant` — for multitenant hosts. Default `false`. */
|
|
98
|
+
readonly requireTenant?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* What happens outside a run — endings, deferred endings, revoked leases,
|
|
101
|
+
* work that settled after its deadline. Ids and outcomes only. A throwing
|
|
102
|
+
* handler is swallowed and changes nothing.
|
|
103
|
+
*/
|
|
104
|
+
readonly onEvent?: (report: McpPoolReport) => void;
|
|
105
|
+
/** Passed to every client: how a tool's result is decoded (`McpClientOptions.resultMode`). */
|
|
106
|
+
readonly resultMode?: 'text' | 'structured' | 'structured-or-json';
|
|
107
|
+
/** Passed to every client: the `initialize` identity. */
|
|
108
|
+
readonly clientInfo?: {
|
|
109
|
+
readonly name: string;
|
|
110
|
+
readonly version: string;
|
|
111
|
+
};
|
|
112
|
+
/** Passed to every client: the 429 retry (`McpClientOptions.retryOnThrottle`). */
|
|
113
|
+
readonly retryOnThrottle?: RetryOnThrottle;
|
|
114
|
+
/**
|
|
115
|
+
* Passed to every client: who may send a tool call again
|
|
116
|
+
* (`McpClientOptions.replay`). Read and checked when the pool is built. The
|
|
117
|
+
* default stays `'compatibility'`. Whatever the policy, the pool's own send
|
|
118
|
+
* gate refuses a pooled request it cannot check (`request-unmatched`).
|
|
119
|
+
*/
|
|
120
|
+
readonly replay?: McpReplayOptions;
|
|
121
|
+
/** Passed to every client: the two SDK modules, imported by you (`McpClientOptions.sdk`). */
|
|
122
|
+
readonly sdk?: McpSdk;
|
|
123
|
+
/**
|
|
124
|
+
* Passed to every client: the JSON Schema validator a tool's own output checks
|
|
125
|
+
* use (`McpClientOptions.jsonSchemaValidator`). With `sdk`, give it: a shared
|
|
126
|
+
* definition always runs its own checks, and without a validator a tool that
|
|
127
|
+
* declares an `outputSchema` is refused unsent.
|
|
128
|
+
*/
|
|
129
|
+
readonly jsonSchemaValidator?: McpJsonSchemaValidator;
|
|
130
|
+
/** Clock seam — tests drive idle, lease and definition ages without waiting. */
|
|
131
|
+
readonly now?: () => number;
|
|
132
|
+
/** @internal Test seam: how a client is opened (the real path is `openPooledClient`). */
|
|
133
|
+
readonly _open?: PoolClientOpener;
|
|
134
|
+
}
|
|
135
|
+
/** The defaults, named so a test and a docstring cannot drift from the code. */
|
|
136
|
+
export declare const MCP_POOL_DEFAULTS: Readonly<{
|
|
137
|
+
maxClients: 64;
|
|
138
|
+
maxClientsPerPrincipal: 8;
|
|
139
|
+
maxEnding: 8;
|
|
140
|
+
maxOperations: 256;
|
|
141
|
+
initTimeoutMs: 30000;
|
|
142
|
+
idleMs: 600000;
|
|
143
|
+
maxLeaseMs: 900000;
|
|
144
|
+
definitionTtlMs: 600000;
|
|
145
|
+
}>;
|
|
146
|
+
/** At most this many shared definition entries are kept; the least recently used goes first. */
|
|
147
|
+
export declare const MAX_DEFINITION_ENTRIES = 256;
|
|
148
|
+
/** A list longer than this is used by its own client and never shared. */
|
|
149
|
+
export declare const MAX_SHARED_TOOLS = 512;
|
|
150
|
+
/** The pool's settings, read once. */
|
|
151
|
+
export interface PoolSettings {
|
|
152
|
+
readonly name: string;
|
|
153
|
+
readonly transport: (identity: McpPoolIdentity) => McpTransport;
|
|
154
|
+
readonly maxClients: number;
|
|
155
|
+
readonly maxClientsPerPrincipal: number;
|
|
156
|
+
readonly maxEnding: number;
|
|
157
|
+
readonly maxOperations: number;
|
|
158
|
+
readonly initTimeoutMs: number;
|
|
159
|
+
readonly idleMs: number;
|
|
160
|
+
readonly maxLeaseMs: number;
|
|
161
|
+
readonly definitionTtlMs: number;
|
|
162
|
+
readonly share: McpPoolDefinitionSharing['share'] | undefined;
|
|
163
|
+
readonly requirePrincipal: boolean;
|
|
164
|
+
readonly requireTenant: boolean;
|
|
165
|
+
readonly onEvent: ((report: McpPoolReport) => void) | undefined;
|
|
166
|
+
readonly client: {
|
|
167
|
+
readonly resultMode?: McpClientPoolOptions['resultMode'];
|
|
168
|
+
readonly clientInfo?: McpClientPoolOptions['clientInfo'];
|
|
169
|
+
readonly retryOnThrottle?: RetryOnThrottle;
|
|
170
|
+
readonly replay?: McpReplayOptions;
|
|
171
|
+
readonly sdk?: McpSdk;
|
|
172
|
+
readonly jsonSchemaValidator?: McpJsonSchemaValidator;
|
|
173
|
+
};
|
|
174
|
+
readonly now: () => number;
|
|
175
|
+
readonly open: PoolClientOpener | undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Read `options` once.
|
|
179
|
+
*
|
|
180
|
+
* @throws TypeError naming the option, when one is missing, mistyped or out of
|
|
181
|
+
* range, or when `connection` is given — here, when the pool is built.
|
|
182
|
+
*/
|
|
183
|
+
export declare function readPoolOptions(options: McpClientPoolOptions): PoolSettings;
|
|
184
|
+
//# sourceMappingURL=options.d.ts.map
|