agentfootprint 12.1.0 → 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.
Files changed (275) hide show
  1. package/AGENTS.md +1 -1
  2. package/CAPABILITIES.md +3 -1
  3. package/ai-instructions/claude-code/SKILL.md +1 -1
  4. package/dist/adapters/mcp/agentcoreRuntime/invoke.js +113 -7
  5. package/dist/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
  6. package/dist/adapters/mcp/agentcoreRuntime/session.js +21 -21
  7. package/dist/adapters/mcp/agentcoreRuntime/session.js.map +1 -1
  8. package/dist/adapters/mcp/agentcoreRuntime/transport.js +79 -5
  9. package/dist/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
  10. package/dist/core/Agent.js +6 -0
  11. package/dist/core/Agent.js.map +1 -1
  12. package/dist/core/agent/stages/toolCalls.js +4 -0
  13. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  14. package/dist/core/slots/buildToolsSlot.js +8 -0
  15. package/dist/core/slots/buildToolsSlot.js.map +1 -1
  16. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +23 -4
  17. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +112 -6
  18. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
  19. package/dist/esm/adapters/mcp/agentcoreRuntime/session.d.ts +20 -6
  20. package/dist/esm/adapters/mcp/agentcoreRuntime/session.js +21 -21
  21. package/dist/esm/adapters/mcp/agentcoreRuntime/session.js.map +1 -1
  22. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +81 -7
  23. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
  24. package/dist/esm/core/Agent.js +6 -0
  25. package/dist/esm/core/Agent.js.map +1 -1
  26. package/dist/esm/core/agent/stages/toolCalls.js +4 -0
  27. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  28. package/dist/esm/core/slots/buildToolsSlot.d.ts +12 -0
  29. package/dist/esm/core/slots/buildToolsSlot.js +8 -0
  30. package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
  31. package/dist/esm/events/payloads.d.ts +41 -0
  32. package/dist/esm/events/registry.d.ts +3 -1
  33. package/dist/esm/events/registry.js +2 -0
  34. package/dist/esm/events/registry.js.map +1 -1
  35. package/dist/esm/identity/types.d.ts +7 -3
  36. package/dist/esm/identity/types.js.map +1 -1
  37. package/dist/esm/index.d.ts +1 -1
  38. package/dist/esm/index.js +4 -1
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/lib/boundedJson.d.ts +14 -7
  41. package/dist/esm/lib/boundedJson.js +14 -7
  42. package/dist/esm/lib/boundedJson.js.map +1 -1
  43. package/dist/esm/mcp/callLifetime.js +5 -2
  44. package/dist/esm/mcp/callLifetime.js.map +1 -1
  45. package/dist/esm/mcp/clientPort.d.ts +78 -0
  46. package/dist/esm/mcp/clientPort.js +33 -0
  47. package/dist/esm/mcp/clientPort.js.map +1 -0
  48. package/dist/esm/mcp/gatewayTransport.js +13 -3
  49. package/dist/esm/mcp/gatewayTransport.js.map +1 -1
  50. package/dist/esm/mcp/index.d.ts +9 -1
  51. package/dist/esm/mcp/index.js +8 -0
  52. package/dist/esm/mcp/index.js.map +1 -1
  53. package/dist/esm/mcp/mcpClient.d.ts +18 -1
  54. package/dist/esm/mcp/mcpClient.js +203 -43
  55. package/dist/esm/mcp/mcpClient.js.map +1 -1
  56. package/dist/esm/mcp/mockMcpClient.js +13 -0
  57. package/dist/esm/mcp/mockMcpClient.js.map +1 -1
  58. package/dist/esm/mcp/pool/boundTool.d.ts +58 -0
  59. package/dist/esm/mcp/pool/boundTool.js +218 -0
  60. package/dist/esm/mcp/pool/boundTool.js.map +1 -0
  61. package/dist/esm/mcp/pool/clientSet.d.ts +73 -0
  62. package/dist/esm/mcp/pool/clientSet.js +152 -0
  63. package/dist/esm/mcp/pool/clientSet.js.map +1 -0
  64. package/dist/esm/mcp/pool/definitions.d.ts +103 -0
  65. package/dist/esm/mcp/pool/definitions.js +168 -0
  66. package/dist/esm/mcp/pool/definitions.js.map +1 -0
  67. package/dist/esm/mcp/pool/errors.d.ts +76 -0
  68. package/dist/esm/mcp/pool/errors.js +91 -0
  69. package/dist/esm/mcp/pool/errors.js.map +1 -0
  70. package/dist/esm/mcp/pool/identityKey.d.ts +57 -0
  71. package/dist/esm/mcp/pool/identityKey.js +94 -0
  72. package/dist/esm/mcp/pool/identityKey.js.map +1 -0
  73. package/dist/esm/mcp/pool/lease.d.ts +36 -0
  74. package/dist/esm/mcp/pool/lease.js +51 -0
  75. package/dist/esm/mcp/pool/lease.js.map +1 -0
  76. package/dist/esm/mcp/pool/listTools.d.ts +33 -0
  77. package/dist/esm/mcp/pool/listTools.js +146 -0
  78. package/dist/esm/mcp/pool/listTools.js.map +1 -0
  79. package/dist/esm/mcp/pool/mcpClientPool.d.ts +121 -0
  80. package/dist/esm/mcp/pool/mcpClientPool.js +151 -0
  81. package/dist/esm/mcp/pool/mcpClientPool.js.map +1 -0
  82. package/dist/esm/mcp/pool/options.d.ts +183 -0
  83. package/dist/esm/mcp/pool/options.js +119 -0
  84. package/dist/esm/mcp/pool/options.js.map +1 -0
  85. package/dist/esm/mcp/pool/plan.d.ts +77 -0
  86. package/dist/esm/mcp/pool/plan.js +134 -0
  87. package/dist/esm/mcp/pool/plan.js.map +1 -0
  88. package/dist/esm/mcp/pool/pool.d.ts +307 -0
  89. package/dist/esm/mcp/pool/pool.js +1071 -0
  90. package/dist/esm/mcp/pool/pool.js.map +1 -0
  91. package/dist/esm/mcp/pool/pooledClient.d.ts +93 -0
  92. package/dist/esm/mcp/pool/pooledClient.js +90 -0
  93. package/dist/esm/mcp/pool/pooledClient.js.map +1 -0
  94. package/dist/esm/mcp/pool/record.d.ts +80 -0
  95. package/dist/esm/mcp/pool/record.js +75 -0
  96. package/dist/esm/mcp/pool/record.js.map +1 -0
  97. package/dist/esm/mcp/pool/sessionEnded.d.ts +24 -0
  98. package/dist/esm/mcp/pool/sessionEnded.js +31 -0
  99. package/dist/esm/mcp/pool/sessionEnded.js.map +1 -0
  100. package/dist/esm/mcp/pool/work.d.ts +116 -0
  101. package/dist/esm/mcp/pool/work.js +213 -0
  102. package/dist/esm/mcp/pool/work.js.map +1 -0
  103. package/dist/esm/mcp/requestGuard.d.ts +70 -0
  104. package/dist/esm/mcp/requestGuard.js +98 -0
  105. package/dist/esm/mcp/requestGuard.js.map +1 -0
  106. package/dist/esm/mcp/requestLedger.d.ts +35 -1
  107. package/dist/esm/mcp/requestLedger.js +76 -3
  108. package/dist/esm/mcp/requestLedger.js.map +1 -1
  109. package/dist/esm/mcp/seriesEvidence.d.ts +10 -6
  110. package/dist/esm/mcp/seriesEvidence.js +16 -7
  111. package/dist/esm/mcp/seriesEvidence.js.map +1 -1
  112. package/dist/esm/mcp/terminate.d.ts +94 -0
  113. package/dist/esm/mcp/terminate.js +184 -0
  114. package/dist/esm/mcp/terminate.js.map +1 -0
  115. package/dist/esm/mcp/throttleRetry.js +71 -7
  116. package/dist/esm/mcp/throttleRetry.js.map +1 -1
  117. package/dist/esm/mcp/types.d.ts +85 -7
  118. package/dist/esm/redaction/knownStrings.js +34 -0
  119. package/dist/esm/redaction/knownStrings.js.map +1 -1
  120. package/dist/esm/tool-providers/index.d.ts +2 -2
  121. package/dist/esm/tool-providers/index.js +7 -1
  122. package/dist/esm/tool-providers/index.js.map +1 -1
  123. package/dist/esm/tools/mcpClientUse.d.ts +59 -0
  124. package/dist/esm/tools/mcpClientUse.js +216 -0
  125. package/dist/esm/tools/mcpClientUse.js.map +1 -0
  126. package/dist/esm/tools/toolProvider.d.ts +16 -0
  127. package/dist/esm/tools/toolSessions.d.ts +41 -0
  128. package/dist/esm/tools/toolSessions.js +41 -1
  129. package/dist/esm/tools/toolSessions.js.map +1 -1
  130. package/dist/events/registry.js +2 -0
  131. package/dist/events/registry.js.map +1 -1
  132. package/dist/identity/types.js.map +1 -1
  133. package/dist/index.js +6 -3
  134. package/dist/index.js.map +1 -1
  135. package/dist/lib/boundedJson.js +14 -7
  136. package/dist/lib/boundedJson.js.map +1 -1
  137. package/dist/mcp/callLifetime.js +5 -2
  138. package/dist/mcp/callLifetime.js.map +1 -1
  139. package/dist/mcp/clientPort.js +38 -0
  140. package/dist/mcp/clientPort.js.map +1 -0
  141. package/dist/mcp/gatewayTransport.js +13 -3
  142. package/dist/mcp/gatewayTransport.js.map +1 -1
  143. package/dist/mcp/index.js +16 -1
  144. package/dist/mcp/index.js.map +1 -1
  145. package/dist/mcp/mcpClient.js +207 -45
  146. package/dist/mcp/mcpClient.js.map +1 -1
  147. package/dist/mcp/mockMcpClient.js +13 -0
  148. package/dist/mcp/mockMcpClient.js.map +1 -1
  149. package/dist/mcp/pool/boundTool.js +223 -0
  150. package/dist/mcp/pool/boundTool.js.map +1 -0
  151. package/dist/mcp/pool/clientSet.js +157 -0
  152. package/dist/mcp/pool/clientSet.js.map +1 -0
  153. package/dist/mcp/pool/definitions.js +174 -0
  154. package/dist/mcp/pool/definitions.js.map +1 -0
  155. package/dist/mcp/pool/errors.js +96 -0
  156. package/dist/mcp/pool/errors.js.map +1 -0
  157. package/dist/mcp/pool/identityKey.js +99 -0
  158. package/dist/mcp/pool/identityKey.js.map +1 -0
  159. package/dist/mcp/pool/lease.js +55 -0
  160. package/dist/mcp/pool/lease.js.map +1 -0
  161. package/dist/mcp/pool/listTools.js +150 -0
  162. package/dist/mcp/pool/listTools.js.map +1 -0
  163. package/dist/mcp/pool/mcpClientPool.js +155 -0
  164. package/dist/mcp/pool/mcpClientPool.js.map +1 -0
  165. package/dist/mcp/pool/options.js +123 -0
  166. package/dist/mcp/pool/options.js.map +1 -0
  167. package/dist/mcp/pool/plan.js +140 -0
  168. package/dist/mcp/pool/plan.js.map +1 -0
  169. package/dist/mcp/pool/pool.js +1075 -0
  170. package/dist/mcp/pool/pool.js.map +1 -0
  171. package/dist/mcp/pool/pooledClient.js +94 -0
  172. package/dist/mcp/pool/pooledClient.js.map +1 -0
  173. package/dist/mcp/pool/record.js +80 -0
  174. package/dist/mcp/pool/record.js.map +1 -0
  175. package/dist/mcp/pool/sessionEnded.js +35 -0
  176. package/dist/mcp/pool/sessionEnded.js.map +1 -0
  177. package/dist/mcp/pool/work.js +219 -0
  178. package/dist/mcp/pool/work.js.map +1 -0
  179. package/dist/mcp/requestGuard.js +106 -0
  180. package/dist/mcp/requestGuard.js.map +1 -0
  181. package/dist/mcp/requestLedger.js +76 -3
  182. package/dist/mcp/requestLedger.js.map +1 -1
  183. package/dist/mcp/seriesEvidence.js +16 -7
  184. package/dist/mcp/seriesEvidence.js.map +1 -1
  185. package/dist/mcp/terminate.js +193 -0
  186. package/dist/mcp/terminate.js.map +1 -0
  187. package/dist/mcp/throttleRetry.js +71 -7
  188. package/dist/mcp/throttleRetry.js.map +1 -1
  189. package/dist/redaction/knownStrings.js +34 -0
  190. package/dist/redaction/knownStrings.js.map +1 -1
  191. package/dist/tool-providers/index.js +12 -1
  192. package/dist/tool-providers/index.js.map +1 -1
  193. package/dist/tools/mcpClientUse.js +225 -0
  194. package/dist/tools/mcpClientUse.js.map +1 -0
  195. package/dist/tools/toolSessions.js +44 -1
  196. package/dist/tools/toolSessions.js.map +1 -1
  197. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +23 -4
  198. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -1
  199. package/dist/types/adapters/mcp/agentcoreRuntime/session.d.ts +20 -6
  200. package/dist/types/adapters/mcp/agentcoreRuntime/session.d.ts.map +1 -1
  201. package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -1
  202. package/dist/types/core/Agent.d.ts.map +1 -1
  203. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  204. package/dist/types/core/slots/buildToolsSlot.d.ts +12 -0
  205. package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
  206. package/dist/types/events/payloads.d.ts +41 -0
  207. package/dist/types/events/payloads.d.ts.map +1 -1
  208. package/dist/types/events/registry.d.ts +3 -1
  209. package/dist/types/events/registry.d.ts.map +1 -1
  210. package/dist/types/identity/types.d.ts +7 -3
  211. package/dist/types/identity/types.d.ts.map +1 -1
  212. package/dist/types/index.d.ts +1 -1
  213. package/dist/types/index.d.ts.map +1 -1
  214. package/dist/types/lib/boundedJson.d.ts +14 -7
  215. package/dist/types/lib/boundedJson.d.ts.map +1 -1
  216. package/dist/types/mcp/callLifetime.d.ts.map +1 -1
  217. package/dist/types/mcp/clientPort.d.ts +79 -0
  218. package/dist/types/mcp/clientPort.d.ts.map +1 -0
  219. package/dist/types/mcp/gatewayTransport.d.ts.map +1 -1
  220. package/dist/types/mcp/index.d.ts +9 -1
  221. package/dist/types/mcp/index.d.ts.map +1 -1
  222. package/dist/types/mcp/mcpClient.d.ts +18 -1
  223. package/dist/types/mcp/mcpClient.d.ts.map +1 -1
  224. package/dist/types/mcp/mockMcpClient.d.ts.map +1 -1
  225. package/dist/types/mcp/pool/boundTool.d.ts +59 -0
  226. package/dist/types/mcp/pool/boundTool.d.ts.map +1 -0
  227. package/dist/types/mcp/pool/clientSet.d.ts +74 -0
  228. package/dist/types/mcp/pool/clientSet.d.ts.map +1 -0
  229. package/dist/types/mcp/pool/definitions.d.ts +104 -0
  230. package/dist/types/mcp/pool/definitions.d.ts.map +1 -0
  231. package/dist/types/mcp/pool/errors.d.ts +77 -0
  232. package/dist/types/mcp/pool/errors.d.ts.map +1 -0
  233. package/dist/types/mcp/pool/identityKey.d.ts +58 -0
  234. package/dist/types/mcp/pool/identityKey.d.ts.map +1 -0
  235. package/dist/types/mcp/pool/lease.d.ts +37 -0
  236. package/dist/types/mcp/pool/lease.d.ts.map +1 -0
  237. package/dist/types/mcp/pool/listTools.d.ts +34 -0
  238. package/dist/types/mcp/pool/listTools.d.ts.map +1 -0
  239. package/dist/types/mcp/pool/mcpClientPool.d.ts +122 -0
  240. package/dist/types/mcp/pool/mcpClientPool.d.ts.map +1 -0
  241. package/dist/types/mcp/pool/options.d.ts +184 -0
  242. package/dist/types/mcp/pool/options.d.ts.map +1 -0
  243. package/dist/types/mcp/pool/plan.d.ts +78 -0
  244. package/dist/types/mcp/pool/plan.d.ts.map +1 -0
  245. package/dist/types/mcp/pool/pool.d.ts +308 -0
  246. package/dist/types/mcp/pool/pool.d.ts.map +1 -0
  247. package/dist/types/mcp/pool/pooledClient.d.ts +94 -0
  248. package/dist/types/mcp/pool/pooledClient.d.ts.map +1 -0
  249. package/dist/types/mcp/pool/record.d.ts +81 -0
  250. package/dist/types/mcp/pool/record.d.ts.map +1 -0
  251. package/dist/types/mcp/pool/sessionEnded.d.ts +25 -0
  252. package/dist/types/mcp/pool/sessionEnded.d.ts.map +1 -0
  253. package/dist/types/mcp/pool/work.d.ts +117 -0
  254. package/dist/types/mcp/pool/work.d.ts.map +1 -0
  255. package/dist/types/mcp/requestGuard.d.ts +71 -0
  256. package/dist/types/mcp/requestGuard.d.ts.map +1 -0
  257. package/dist/types/mcp/requestLedger.d.ts +35 -1
  258. package/dist/types/mcp/requestLedger.d.ts.map +1 -1
  259. package/dist/types/mcp/seriesEvidence.d.ts +10 -6
  260. package/dist/types/mcp/seriesEvidence.d.ts.map +1 -1
  261. package/dist/types/mcp/terminate.d.ts +95 -0
  262. package/dist/types/mcp/terminate.d.ts.map +1 -0
  263. package/dist/types/mcp/throttleRetry.d.ts.map +1 -1
  264. package/dist/types/mcp/types.d.ts +85 -7
  265. package/dist/types/mcp/types.d.ts.map +1 -1
  266. package/dist/types/redaction/knownStrings.d.ts.map +1 -1
  267. package/dist/types/tool-providers/index.d.ts +2 -2
  268. package/dist/types/tool-providers/index.d.ts.map +1 -1
  269. package/dist/types/tools/mcpClientUse.d.ts +60 -0
  270. package/dist/types/tools/mcpClientUse.d.ts.map +1 -0
  271. package/dist/types/tools/toolProvider.d.ts +16 -0
  272. package/dist/types/tools/toolProvider.d.ts.map +1 -1
  273. package/dist/types/tools/toolSessions.d.ts +41 -0
  274. package/dist/types/tools/toolSessions.d.ts.map +1 -1
  275. package/package.json +3 -3
@@ -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;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AAC,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"}
@@ -15,5 +15,13 @@ export type { McpReplayDeduplication, McpReplayKind, McpReplayOptions, McpReplay
15
15
  export { McpReplayUnavailableError, type McpReplayUnavailableReason } from './replayUnavailable.js';
16
16
  export { McpToolListIncompleteError, type McpToolListIncompleteReason } from './toolList.js';
17
17
  export { McpOutputUncheckedError } from './callChecks.js';
18
- export type { McpCallToolResult, McpClient, McpClientOptions, McpConnection, McpConnectionOptions, McpJsonSchemaValidator, McpSdk, McpGatewayTransport, McpHttpTransport, McpStdioTransport, McpTransport, McpSdkClient, McpServeOptions, McpServeHandle, McpServeTransport, McpHttpServeTransport, McpStdioServeTransport, McpSdkServer, } from './types.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';
19
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,K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A2B,EAAE,MAAM,eAAe,CAAC;AAI7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,mBAAmB,EACnB,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"}
@@ -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 { McpClient, McpClientOptions, McpConnectionOptions } from './types.js';
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;AAKH,OAAO,KAAK,EAEV,SAAS,EACT,gBAAgB,EAEhB,oBAAoB,EAMrB,MAAM,YAAY,CAAC;AA8CpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CAoFjG"}
1
+ {"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;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AQ,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 | undefined;
74
+ //# sourceMappingURL=clientSet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientSet.d.ts","sourceRoot":"","sources":["../../../../src/mcp/pool/clientSet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjE,4DAA4D;AAC5D,eAAO,MAAM,UAAU,OAAO,CAAC;AAE/B,gEAAgE;AAChE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,GAAG,YAAY,CAAC;AAQxF,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2B;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAC3D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAC1D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IAEvD,+BAA+B;IAC/B,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,iCAAiC;IACjC,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,oCAAoC;IACpC,WAAW,IAAI,SAAS,YAAY,EAAE;IAItC,0DAA0D;IAC1D,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAIzC,qFAAqF;IACrF,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIjD,+EAA+E;IAC/E,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAA;KAAE;IAQ9F,mEAAmE;IACnE,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAMjC;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,GAAG,IAAI;IAMpD,8DAA8D;IAC9D,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI;IAOtE,6DAA6D;IAC7D,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;IAIjC,oFAAoF;IACpF,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,CAAC,EAAE,WAAW,GAAG,IAAI;IAMnD;;;OAGG;IACH,qBAAqB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,GAAG,YAAY,GAAG,SAAS;IASxF,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,QAAQ;CAYjB;AAED,oEAAoE;AACpE,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,CAarE"}
@@ -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;;;;;;;;;;;;;;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iE;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/err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AC,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"}