agentfootprint 11.3.0 → 11.5.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 (227) hide show
  1. package/CAPABILITIES.md +4 -1
  2. package/dist/adapters/mcp/agentcoreRuntime/invoke.js +7 -6
  3. package/dist/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
  4. package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js +36 -2
  5. package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -1
  6. package/dist/adapters/mcp/agentcoreRuntime/transport.js +3 -1
  7. package/dist/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
  8. package/dist/answer-account/account.js +15 -3
  9. package/dist/answer-account/account.js.map +1 -1
  10. package/dist/answer-account/facts/howSure.js +10 -22
  11. package/dist/answer-account/facts/howSure.js.map +1 -1
  12. package/dist/core/Agent.js +26 -3
  13. package/dist/core/Agent.js.map +1 -1
  14. package/dist/core/agent/AgentBuilder.js +69 -12
  15. package/dist/core/agent/AgentBuilder.js.map +1 -1
  16. package/dist/core/agent/assessment/assess.js +15 -4
  17. package/dist/core/agent/assessment/assess.js.map +1 -1
  18. package/dist/core/agent/assessment/compose.js +153 -15
  19. package/dist/core/agent/assessment/compose.js.map +1 -1
  20. package/dist/core/agent/assessment/reasons.js +35 -1
  21. package/dist/core/agent/assessment/reasons.js.map +1 -1
  22. package/dist/core/agent/assessment/sources.js +205 -0
  23. package/dist/core/agent/assessment/sources.js.map +1 -0
  24. package/dist/core/agent/assessment/stage.js +15 -4
  25. package/dist/core/agent/assessment/stage.js.map +1 -1
  26. package/dist/core/agent/buildAgentChart.js.map +1 -1
  27. package/dist/core/agent/buildToolRegistry.js +3 -0
  28. package/dist/core/agent/buildToolRegistry.js.map +1 -1
  29. package/dist/core/agent/evidence/numberPrecision.js.map +1 -1
  30. package/dist/core/agent/honesty/mounts.js.map +1 -1
  31. package/dist/core/agent/stages/prepareFinal.js +33 -17
  32. package/dist/core/agent/stages/prepareFinal.js.map +1 -1
  33. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
  34. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +7 -6
  35. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
  36. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
  37. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js +35 -1
  38. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -1
  39. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +4 -2
  40. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
  41. package/dist/esm/answer-account/account.js +16 -4
  42. package/dist/esm/answer-account/account.js.map +1 -1
  43. package/dist/esm/answer-account/facts/howSure.js +10 -22
  44. package/dist/esm/answer-account/facts/howSure.js.map +1 -1
  45. package/dist/esm/core/Agent.d.ts +2 -1
  46. package/dist/esm/core/Agent.js +26 -3
  47. package/dist/esm/core/Agent.js.map +1 -1
  48. package/dist/esm/core/agent/AgentBuilder.d.ts +22 -1
  49. package/dist/esm/core/agent/AgentBuilder.js +69 -12
  50. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  51. package/dist/esm/core/agent/assessment/assess.js +15 -4
  52. package/dist/esm/core/agent/assessment/assess.js.map +1 -1
  53. package/dist/esm/core/agent/assessment/compose.d.ts +82 -5
  54. package/dist/esm/core/agent/assessment/compose.js +148 -14
  55. package/dist/esm/core/agent/assessment/compose.js.map +1 -1
  56. package/dist/esm/core/agent/assessment/reasons.d.ts +17 -1
  57. package/dist/esm/core/agent/assessment/reasons.js +35 -1
  58. package/dist/esm/core/agent/assessment/reasons.js.map +1 -1
  59. package/dist/esm/core/agent/assessment/sources.d.ts +66 -0
  60. package/dist/esm/core/agent/assessment/sources.js +201 -0
  61. package/dist/esm/core/agent/assessment/sources.js.map +1 -0
  62. package/dist/esm/core/agent/assessment/stage.d.ts +17 -4
  63. package/dist/esm/core/agent/assessment/stage.js +16 -5
  64. package/dist/esm/core/agent/assessment/stage.js.map +1 -1
  65. package/dist/esm/core/agent/assessment/types.d.ts +37 -0
  66. package/dist/esm/core/agent/buildAgentChart.d.ts +8 -0
  67. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  68. package/dist/esm/core/agent/buildToolRegistry.js +4 -1
  69. package/dist/esm/core/agent/buildToolRegistry.js.map +1 -1
  70. package/dist/esm/core/agent/evidence/numberPrecision.d.ts +3 -2
  71. package/dist/esm/core/agent/evidence/numberPrecision.js.map +1 -1
  72. package/dist/esm/core/agent/honesty/mounts.d.ts +11 -2
  73. package/dist/esm/core/agent/honesty/mounts.js.map +1 -1
  74. package/dist/esm/core/agent/stages/prepareFinal.d.ts +19 -3
  75. package/dist/esm/core/agent/stages/prepareFinal.js +33 -17
  76. package/dist/esm/core/agent/stages/prepareFinal.js.map +1 -1
  77. package/dist/esm/core/agent/types.d.ts +16 -2
  78. package/dist/esm/events/payloads.d.ts +137 -27
  79. package/dist/esm/lib/displayName.d.ts +81 -0
  80. package/dist/esm/lib/displayName.js +119 -0
  81. package/dist/esm/lib/displayName.js.map +1 -0
  82. package/dist/esm/mcp/callLifetime.d.ts +57 -14
  83. package/dist/esm/mcp/callLifetime.js +67 -19
  84. package/dist/esm/mcp/callLifetime.js.map +1 -1
  85. package/dist/esm/mcp/callMarker.d.ts +43 -0
  86. package/dist/esm/mcp/callMarker.js +69 -0
  87. package/dist/esm/mcp/callMarker.js.map +1 -0
  88. package/dist/esm/mcp/connectionRefusals.js +7 -0
  89. package/dist/esm/mcp/connectionRefusals.js.map +1 -1
  90. package/dist/esm/mcp/index.d.ts +2 -0
  91. package/dist/esm/mcp/index.js +3 -0
  92. package/dist/esm/mcp/index.js.map +1 -1
  93. package/dist/esm/mcp/mcpClient.js +93 -26
  94. package/dist/esm/mcp/mcpClient.js.map +1 -1
  95. package/dist/esm/mcp/replay.d.ts +283 -0
  96. package/dist/esm/mcp/replay.js +401 -0
  97. package/dist/esm/mcp/replay.js.map +1 -0
  98. package/dist/esm/mcp/replayUnavailable.d.ts +55 -0
  99. package/dist/esm/mcp/replayUnavailable.js +74 -0
  100. package/dist/esm/mcp/replayUnavailable.js.map +1 -0
  101. package/dist/esm/mcp/requestLedger.d.ts +115 -32
  102. package/dist/esm/mcp/requestLedger.js +193 -52
  103. package/dist/esm/mcp/requestLedger.js.map +1 -1
  104. package/dist/esm/mcp/seriesEvidence.d.ts +73 -15
  105. package/dist/esm/mcp/seriesEvidence.js +114 -21
  106. package/dist/esm/mcp/seriesEvidence.js.map +1 -1
  107. package/dist/esm/mcp/throttleRetry.d.ts +86 -42
  108. package/dist/esm/mcp/throttleRetry.js +158 -50
  109. package/dist/esm/mcp/throttleRetry.js.map +1 -1
  110. package/dist/esm/mcp/toolResult.d.ts +6 -0
  111. package/dist/esm/mcp/toolResult.js +15 -0
  112. package/dist/esm/mcp/toolResult.js.map +1 -1
  113. package/dist/esm/mcp/types.d.ts +70 -8
  114. package/dist/esm/redaction/knownStrings.js +14 -0
  115. package/dist/esm/redaction/knownStrings.js.map +1 -1
  116. package/dist/esm/semantics/coverage/answer.d.ts +9 -1
  117. package/dist/esm/semantics/coverage/answer.js +50 -10
  118. package/dist/esm/semantics/coverage/answer.js.map +1 -1
  119. package/dist/esm/tool-providers/index.d.ts +2 -2
  120. package/dist/esm/tool-providers/index.js +4 -0
  121. package/dist/esm/tool-providers/index.js.map +1 -1
  122. package/dist/esm/tools/requestEvidence.js +60 -0
  123. package/dist/esm/tools/requestEvidence.js.map +1 -1
  124. package/dist/esm/tools/tools.d.ts +30 -0
  125. package/dist/esm/tools/tools.js +16 -0
  126. package/dist/esm/tools/tools.js.map +1 -1
  127. package/dist/lib/displayName.js +125 -0
  128. package/dist/lib/displayName.js.map +1 -0
  129. package/dist/mcp/callLifetime.js +66 -18
  130. package/dist/mcp/callLifetime.js.map +1 -1
  131. package/dist/mcp/callMarker.js +74 -0
  132. package/dist/mcp/callMarker.js.map +1 -0
  133. package/dist/mcp/connectionRefusals.js +7 -0
  134. package/dist/mcp/connectionRefusals.js.map +1 -1
  135. package/dist/mcp/index.js +5 -1
  136. package/dist/mcp/index.js.map +1 -1
  137. package/dist/mcp/mcpClient.js +91 -24
  138. package/dist/mcp/mcpClient.js.map +1 -1
  139. package/dist/mcp/replay.js +411 -0
  140. package/dist/mcp/replay.js.map +1 -0
  141. package/dist/mcp/replayUnavailable.js +79 -0
  142. package/dist/mcp/replayUnavailable.js.map +1 -0
  143. package/dist/mcp/requestLedger.js +193 -52
  144. package/dist/mcp/requestLedger.js.map +1 -1
  145. package/dist/mcp/seriesEvidence.js +116 -22
  146. package/dist/mcp/seriesEvidence.js.map +1 -1
  147. package/dist/mcp/throttleRetry.js +160 -51
  148. package/dist/mcp/throttleRetry.js.map +1 -1
  149. package/dist/mcp/toolResult.js +17 -1
  150. package/dist/mcp/toolResult.js.map +1 -1
  151. package/dist/redaction/knownStrings.js +14 -0
  152. package/dist/redaction/knownStrings.js.map +1 -1
  153. package/dist/semantics/coverage/answer.js +49 -9
  154. package/dist/semantics/coverage/answer.js.map +1 -1
  155. package/dist/tool-providers/index.js +5 -1
  156. package/dist/tool-providers/index.js.map +1 -1
  157. package/dist/tools/requestEvidence.js +60 -0
  158. package/dist/tools/requestEvidence.js.map +1 -1
  159. package/dist/tools/tools.js +18 -1
  160. package/dist/tools/tools.js.map +1 -1
  161. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
  162. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -1
  163. package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
  164. package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts.map +1 -1
  165. package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -1
  166. package/dist/types/answer-account/account.d.ts.map +1 -1
  167. package/dist/types/answer-account/facts/howSure.d.ts.map +1 -1
  168. package/dist/types/core/Agent.d.ts +2 -1
  169. package/dist/types/core/Agent.d.ts.map +1 -1
  170. package/dist/types/core/agent/AgentBuilder.d.ts +22 -1
  171. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  172. package/dist/types/core/agent/assessment/assess.d.ts.map +1 -1
  173. package/dist/types/core/agent/assessment/compose.d.ts +82 -5
  174. package/dist/types/core/agent/assessment/compose.d.ts.map +1 -1
  175. package/dist/types/core/agent/assessment/reasons.d.ts +17 -1
  176. package/dist/types/core/agent/assessment/reasons.d.ts.map +1 -1
  177. package/dist/types/core/agent/assessment/sources.d.ts +67 -0
  178. package/dist/types/core/agent/assessment/sources.d.ts.map +1 -0
  179. package/dist/types/core/agent/assessment/stage.d.ts +17 -4
  180. package/dist/types/core/agent/assessment/stage.d.ts.map +1 -1
  181. package/dist/types/core/agent/assessment/types.d.ts +37 -0
  182. package/dist/types/core/agent/assessment/types.d.ts.map +1 -1
  183. package/dist/types/core/agent/buildAgentChart.d.ts +8 -0
  184. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  185. package/dist/types/core/agent/buildToolRegistry.d.ts.map +1 -1
  186. package/dist/types/core/agent/evidence/numberPrecision.d.ts +3 -2
  187. package/dist/types/core/agent/evidence/numberPrecision.d.ts.map +1 -1
  188. package/dist/types/core/agent/honesty/mounts.d.ts +11 -2
  189. package/dist/types/core/agent/honesty/mounts.d.ts.map +1 -1
  190. package/dist/types/core/agent/stages/prepareFinal.d.ts +19 -3
  191. package/dist/types/core/agent/stages/prepareFinal.d.ts.map +1 -1
  192. package/dist/types/core/agent/types.d.ts +16 -2
  193. package/dist/types/core/agent/types.d.ts.map +1 -1
  194. package/dist/types/events/payloads.d.ts +137 -27
  195. package/dist/types/events/payloads.d.ts.map +1 -1
  196. package/dist/types/lib/displayName.d.ts +82 -0
  197. package/dist/types/lib/displayName.d.ts.map +1 -0
  198. package/dist/types/mcp/callLifetime.d.ts +57 -14
  199. package/dist/types/mcp/callLifetime.d.ts.map +1 -1
  200. package/dist/types/mcp/callMarker.d.ts +44 -0
  201. package/dist/types/mcp/callMarker.d.ts.map +1 -0
  202. package/dist/types/mcp/index.d.ts +2 -0
  203. package/dist/types/mcp/index.d.ts.map +1 -1
  204. package/dist/types/mcp/mcpClient.d.ts.map +1 -1
  205. package/dist/types/mcp/replay.d.ts +284 -0
  206. package/dist/types/mcp/replay.d.ts.map +1 -0
  207. package/dist/types/mcp/replayUnavailable.d.ts +56 -0
  208. package/dist/types/mcp/replayUnavailable.d.ts.map +1 -0
  209. package/dist/types/mcp/requestLedger.d.ts +115 -32
  210. package/dist/types/mcp/requestLedger.d.ts.map +1 -1
  211. package/dist/types/mcp/seriesEvidence.d.ts +73 -15
  212. package/dist/types/mcp/seriesEvidence.d.ts.map +1 -1
  213. package/dist/types/mcp/throttleRetry.d.ts +86 -42
  214. package/dist/types/mcp/throttleRetry.d.ts.map +1 -1
  215. package/dist/types/mcp/toolResult.d.ts +6 -0
  216. package/dist/types/mcp/toolResult.d.ts.map +1 -1
  217. package/dist/types/mcp/types.d.ts +70 -8
  218. package/dist/types/mcp/types.d.ts.map +1 -1
  219. package/dist/types/redaction/knownStrings.d.ts.map +1 -1
  220. package/dist/types/semantics/coverage/answer.d.ts +9 -1
  221. package/dist/types/semantics/coverage/answer.d.ts.map +1 -1
  222. package/dist/types/tool-providers/index.d.ts +2 -2
  223. package/dist/types/tool-providers/index.d.ts.map +1 -1
  224. package/dist/types/tools/requestEvidence.d.ts.map +1 -1
  225. package/dist/types/tools/tools.d.ts +30 -0
  226. package/dist/types/tools/tools.d.ts.map +1 -1
  227. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.js","sourceRoot":"","sources":["../../../src/mcp/replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,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,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,gEAAgE;AAChE,SAAS,UAAU,CAAC,IAAY;IAC9B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * replayUnavailable — when a connection cannot keep the `'app-authorized'`
3
+ * contract, a call under it is refused BEFORE it is sent, and the error says why.
4
+ *
5
+ * Pattern: a readiness rule + one typed refusal.
6
+ * Role: Under `'app-authorized'`, a call that genuinely lacked an answer and
7
+ * then fails is raised as "may have run" (`callLifetime.ts`). That
8
+ * rests on two things the library must ESTABLISH for every call,
9
+ * never assume:
10
+ *
11
+ * 1. ITS REQUEST IS MATCHED to the call, by the call's private marker, taken
12
+ * at the transport's `send` (`callMarker.ts`, `requestLedger.ts`).
13
+ * - `'requests-unwatched'`: the library cannot watch this transport's
14
+ * `send` at all (stdio, or a transport that refuses the wrap).
15
+ * - `'request-unmatched'`: a request reached `send` without its call's
16
+ * marker (an SDK that rebuilt the params and dropped `_meta`), so it
17
+ * cannot be tied to any call.
18
+ * 2. ITS ANSWER IS SEEN: the JSON-RPC response to the request's id, read as
19
+ * it arrives. This is checked once the connection is initialized: the
20
+ * `initialize` answer must have passed the library's observer.
21
+ * - `'answers-unobserved'`: it did not. An MCP SDK whose `connect`
22
+ * REPLACES the transport's `onmessage` handler instead of keeping it
23
+ * (SDK 1.10's `Protocol.connect` does) leaves the observer out.
24
+ *
25
+ * Without either, a request the server accepted and never answered would reach
26
+ * the caller as a plain timeout: the strict contract, silently weakened. So the
27
+ * call is refused instead, and nothing is sent. `'compatibility'` asks none of
28
+ * this and keeps its behaviour.
29
+ */
30
+ /** Why a call under `'app-authorized'` was refused before it was sent. */
31
+ export type McpReplayUnavailableReason = 'requests-unwatched' | 'answers-unobserved' | 'request-unmatched';
32
+ /**
33
+ * A tool call refused before it was sent, because this connection cannot keep
34
+ * the `'app-authorized'` replay contract (`reason`). Nothing reached the server.
35
+ * Names the server and the tool, never an argument.
36
+ */
37
+ export declare class McpReplayUnavailableError extends Error {
38
+ readonly reason: McpReplayUnavailableReason;
39
+ readonly server: string;
40
+ readonly tool: string;
41
+ readonly code: "ERR_MCP_REPLAY_UNAVAILABLE";
42
+ /** Nothing was sent: the refusal came before the request left the client. */
43
+ readonly sent: false;
44
+ constructor(reason: McpReplayUnavailableReason, server: string, tool: string);
45
+ }
46
+ /**
47
+ * Why a connection cannot take a call under `'app-authorized'` before anything
48
+ * is sent — `undefined` when it can. `ledger` is the connection's request
49
+ * ledger: absent when the library could not watch the transport's requests.
50
+ * A request that reaches the transport without its marker is refused there, by
51
+ * the ledger (`'request-unmatched'`).
52
+ */
53
+ export declare function unavailableBeforeSending(ledger: {
54
+ readonly answersObserved: boolean;
55
+ } | undefined): McpReplayUnavailableReason | undefined;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * replayUnavailable — when a connection cannot keep the `'app-authorized'`
3
+ * contract, a call under it is refused BEFORE it is sent, and the error says why.
4
+ *
5
+ * Pattern: a readiness rule + one typed refusal.
6
+ * Role: Under `'app-authorized'`, a call that genuinely lacked an answer and
7
+ * then fails is raised as "may have run" (`callLifetime.ts`). That
8
+ * rests on two things the library must ESTABLISH for every call,
9
+ * never assume:
10
+ *
11
+ * 1. ITS REQUEST IS MATCHED to the call, by the call's private marker, taken
12
+ * at the transport's `send` (`callMarker.ts`, `requestLedger.ts`).
13
+ * - `'requests-unwatched'`: the library cannot watch this transport's
14
+ * `send` at all (stdio, or a transport that refuses the wrap).
15
+ * - `'request-unmatched'`: a request reached `send` without its call's
16
+ * marker (an SDK that rebuilt the params and dropped `_meta`), so it
17
+ * cannot be tied to any call.
18
+ * 2. ITS ANSWER IS SEEN: the JSON-RPC response to the request's id, read as
19
+ * it arrives. This is checked once the connection is initialized: the
20
+ * `initialize` answer must have passed the library's observer.
21
+ * - `'answers-unobserved'`: it did not. An MCP SDK whose `connect`
22
+ * REPLACES the transport's `onmessage` handler instead of keeping it
23
+ * (SDK 1.10's `Protocol.connect` does) leaves the observer out.
24
+ *
25
+ * Without either, a request the server accepted and never answered would reach
26
+ * the caller as a plain timeout: the strict contract, silently weakened. So the
27
+ * call is refused instead, and nothing is sent. `'compatibility'` asks none of
28
+ * this and keeps its behaviour.
29
+ */
30
+ /** The fixed sentence each reason reads as. Never an argument, a header or an answer. */
31
+ const BECAUSE = {
32
+ 'requests-unwatched': "the library cannot watch this transport's requests, so it cannot match a request to its call",
33
+ 'answers-unobserved': "this connection's answers do not pass the library's observer: the MCP SDK replaced the " +
34
+ "transport's message handler when it connected",
35
+ 'request-unmatched': "the request reached the transport without its call's marker: the MCP SDK rebuilt the " +
36
+ "request's params",
37
+ };
38
+ /**
39
+ * A tool call refused before it was sent, because this connection cannot keep
40
+ * the `'app-authorized'` replay contract (`reason`). Nothing reached the server.
41
+ * Names the server and the tool, never an argument.
42
+ */
43
+ export class McpReplayUnavailableError extends Error {
44
+ reason;
45
+ server;
46
+ tool;
47
+ code = 'ERR_MCP_REPLAY_UNAVAILABLE';
48
+ /** Nothing was sent: the refusal came before the request left the client. */
49
+ sent = false;
50
+ constructor(reason, server, tool) {
51
+ super(`mcpClient[${server}]: the call to '${tool}' was not sent. The 'app-authorized' replay ` +
52
+ `policy needs each request matched to its call and each answer seen, and ` +
53
+ `${BECAUSE[reason]}.`);
54
+ this.reason = reason;
55
+ this.server = server;
56
+ this.tool = tool;
57
+ this.name = 'McpReplayUnavailableError';
58
+ }
59
+ }
60
+ /**
61
+ * Why a connection cannot take a call under `'app-authorized'` before anything
62
+ * is sent — `undefined` when it can. `ledger` is the connection's request
63
+ * ledger: absent when the library could not watch the transport's requests.
64
+ * A request that reaches the transport without its marker is refused there, by
65
+ * the ledger (`'request-unmatched'`).
66
+ */
67
+ export function unavailableBeforeSending(ledger) {
68
+ if (ledger === undefined)
69
+ return 'requests-unwatched';
70
+ if (!ledger.answersObserved)
71
+ return 'answers-unobserved';
72
+ return undefined;
73
+ }
74
+ //# sourceMappingURL=replayUnavailable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replayUnavailable.js","sourceRoot":"","sources":["../../../src/mcp/replayUnavailable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAQH,yFAAyF;AACzF,MAAM,OAAO,GAAyD;IACpE,oBAAoB,EAClB,8FAA8F;IAChG,oBAAoB,EAClB,yFAAyF;QACzF,+CAA+C;IACjD,mBAAmB,EACjB,uFAAuF;QACvF,kBAAkB;CACrB,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAMvC;IACA;IACA;IAPF,IAAI,GAAG,4BAAqC,CAAC;IACtD,6EAA6E;IACpE,IAAI,GAAG,KAAc,CAAC;IAE/B,YACW,MAAkC,EAClC,MAAc,EACd,IAAY;QAErB,KAAK,CACH,aAAa,MAAM,mBAAmB,IAAI,8CAA8C;YACtF,0EAA0E;YAC1E,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CACxB,CAAC;QARO,WAAM,GAAN,MAAM,CAA4B;QAClC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAOrB,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,MAAyD;IAEzD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,oBAAoB,CAAC;IACtD,IAAI,CAAC,MAAM,CAAC,eAAe;QAAE,OAAO,oBAAoB,CAAC;IACzD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,48 +1,73 @@
1
1
  /**
2
2
  * requestLedger — which dispatched tool call an MCP request belongs to, so the
3
- * retry series that sends it files its attempts into THAT call's run; and when
4
- * the MCP SDK cancels a request, so the series sending it stops.
3
+ * retry series that sends it files its attempts into THAT call's run; when the
4
+ * MCP SDK cancels a request, so the series sending it stops; and whether the
5
+ * request's JSON-RPC answer arrived.
5
6
  *
6
7
  * Pattern: a per-connection ledger + the SDK transport's `send`, watched in place.
7
8
  * Role: The middle of the evidence seam (`tools/requestEvidence.ts` is its
8
9
  * door). The retry series runs inside the transport's `fetch`, which
9
10
  * the MCP SDK calls with a serialized body and nothing else — no tool
10
- * call, no run. Three hops carry the call down to it, each by an
11
- * identity the hop already holds:
11
+ * call, no run. Three hops carry the call down to it:
12
12
  *
13
- * 1. call → params `issue`: the MCP tool keys its ticket by the request's
14
- * params OBJECT. The SDK puts that very object into the
15
- * JSON-RPC message it hands the transport.
16
- * 2. params → id the watched `send` finds the ticket by `message.params`
17
- * and keys it by the JSON-RPC `id` the SDK assigned, until
18
- * that send settles.
13
+ * 1. call → marker `issue`: the MCP tool gets a library-private marker and
14
+ * puts it in its request's `_meta` (`callMarker.ts`). It
15
+ * survives an SDK that copies the params.
16
+ * 2. marker → id the watched `send` takes the marker out of the message
17
+ * — the server receives the bytes it always did — and
18
+ * keys the call by the JSON-RPC `id` the SDK assigned.
19
19
  * 3. id → series `claim`: the series reads the `id` back out of the body
20
20
  * it is about to send.
21
21
  *
22
22
  * CANCELLATION DOES NOT WAIT ON ATTRIBUTION. Every `tools/call` in flight gets
23
- * an entry, ticket or not, and the SDK says when it gives a request up: it sends
24
- * `notifications/cancelled` naming the request's id — on its own timeout, or
25
- * when the call's signal fires — through this same `send`. The ledger aborts
26
- * that request's series there and then, so a request nobody waits for is never
27
- * asked again, even when its params could not be matched to a call.
23
+ * an entry, matched or not, and the SDK says when it gives a request up: it
24
+ * sends `notifications/cancelled` naming the request's id — on its own
25
+ * timeout, or when the call's signal fires — through this same `send`. The
26
+ * ledger aborts that request's series there and then, so a request nobody waits
27
+ * for is never asked again, even when it could not be matched to a call.
28
28
  *
29
- * Nothing is added to the wire: the request the server receives is
30
- * byte-identical, and the SDK's own options keep their meanings. Ids are the
31
- * client's, one ledger per connection, so concurrent calls — and concurrent
32
- * runs sharing one client — can never claim each other's request. A request
33
- * that is not a `tools/call` (a `tools/list`, a notification, a response)
34
- * claims nothing.
29
+ * Under `'app-authorized'` (`strict`), two more things hold:
30
+ * - A `tools/call` that reaches `send` without a marker this ledger issued
31
+ * and has not used is REFUSED there (`replayUnavailable.ts`,
32
+ * `'request-unmatched'`): its answer could not be tied to any call, so it
33
+ * is never sent rather than guessed at.
34
+ * - Each matched request's answer is AWAITED, by its id: the connection's
35
+ * incoming messages are observed for the JSON-RPC response to it. A 202, or
36
+ * a stream, is not that answer. The watch ends when the answer arrives,
37
+ * when the SDK cancels the request, when the call settles (found by its
38
+ * marker, never by its params object) or when the connection closes —
39
+ * never when only the HTTP send finished, since a 202 or a stream can still
40
+ * carry the answer later.
41
+ *
42
+ * Whether the answers are observed at all is established once, at
43
+ * initialization: the `initialize` answer must pass the observer
44
+ * (`answersObserved`). An SDK whose `connect` replaces the transport's
45
+ * `onmessage` instead of keeping it leaves the observer out, and a call under
46
+ * `'app-authorized'` is then refused before it is sent (`replayUnavailable.ts`).
47
+ *
48
+ * Ids are the client's, one ledger per connection, so concurrent calls — and
49
+ * concurrent runs sharing one client — can never claim each other's request. A
50
+ * request that is not a `tools/call` (a `tools/list`, a notification, a
51
+ * response) claims nothing.
35
52
  *
36
53
  * `send` is installed as an OWN property of the transport instance — the same
37
54
  * object, its own `send` bound to it, so a transport class with `#private`
38
55
  * fields works as it always did. Assigning `send` again afterwards THROWS: a
39
56
  * send that bypassed the ledger would quietly lose every call's attempts.
40
57
  *
58
+ * Each matched `tools/call` also gets ONE `RequestReplay` (`replay.ts`), the
59
+ * facts its series, this ledger and its call share: the series' claim hands it
60
+ * over by the request's id, the call reads it from the entry it was issued
61
+ * (`IssuedCall`), which outlives the connection's close. The
62
+ * series writes what HTTP showed; this ledger writes whether the JSON-RPC
63
+ * answer arrived; the call writes how it settled.
64
+ *
41
65
  * What it does NOT do: retry, wait, or decide anything. The series is the one
42
66
  * retry owner; this only tells it whose attempts it is making, and when the SDK
43
67
  * has stopped waiting for them.
44
68
  */
45
69
  import type { RequestEvidenceSink } from '../tools/requestEvidence.js';
70
+ import { RequestReplay } from './replay.js';
46
71
  /** One call's claim on the request it sends. */
47
72
  export interface RequestTicket {
48
73
  /** Where the request's attempts are filed. */
@@ -56,23 +81,71 @@ export interface ClaimedRequest {
56
81
  readonly ticket?: RequestTicket;
57
82
  /** Fires when the MCP SDK cancels this request (`notifications/cancelled`). */
58
83
  readonly cancelled: AbortSignal;
84
+ /** What this request's series and its call share (`replay.ts` · `RequestReplay`). */
85
+ readonly replay: RequestReplay;
86
+ }
87
+ /** How a connection's ledger is set up. */
88
+ export interface RequestLedgerOptions {
89
+ /** The client's name, which a refusal names. */
90
+ readonly server: string;
91
+ /** The `'app-authorized'` policy is in force: see the module note. */
92
+ readonly strict: boolean;
59
93
  }
60
- /** Per connection: the tickets issued and not yet sent, and the requests being sent. */
94
+ type JsonRpcId = string | number;
95
+ /** The request a call's marker was matched to. */
96
+ export interface MatchedRequest {
97
+ readonly id: JsonRpcId;
98
+ readonly replay: RequestReplay;
99
+ }
100
+ /**
101
+ * One call, from `issue` until it settles: the marker it sends, and the
102
+ * request matched to it once one was. The call holds this entry itself, so
103
+ * what it reads does not depend on the ledger still holding it.
104
+ */
105
+ export interface IssuedCall {
106
+ readonly marker: string;
107
+ readonly ticket?: RequestTicket;
108
+ /** Set once, by the watched `send`: a marker matches ONE request. */
109
+ readonly request?: MatchedRequest;
110
+ }
111
+ /** Per connection: the calls issued and not yet settled, the requests being sent, the answers awaited. */
61
112
  export declare class RequestLedger {
62
- /** Issued, not yet sent — keyed by the request's params object. Collected with it. */
113
+ private readonly options;
114
+ /** Every call issued and not yet settled — keyed by its marker. */
63
115
  private readonly issued;
64
- /** Tickets a request was bound to. */
65
- private readonly bound;
66
116
  /** Every `tools/call` sent and not yet settled — keyed by its JSON-RPC id. */
67
117
  private readonly sending;
118
+ /** Matched requests whose JSON-RPC answer is awaited (`strict` only) — by id. */
119
+ private readonly awaiting;
120
+ private initializeId;
121
+ private initializeAnswered;
122
+ private markers;
68
123
  private calls;
69
124
  private unboundNamed;
70
- /** The call about to send `params` files its attempts through `ticket`. */
71
- issue(params: object, ticket: RequestTicket): void;
72
- /** Whether a request the transport sent was bound to `ticket`. */
73
- wasBound(ticket: RequestTicket): boolean;
125
+ constructor(options?: RequestLedgerOptions);
126
+ /**
127
+ * A call is about to send its request: its entry, whose `marker` the call
128
+ * puts in the request's `_meta` (`callMarker.ts` · `markParams`). `ticket`
129
+ * is where its attempts are filed, when the call carries the run's evidence
130
+ * port.
131
+ */
132
+ issue(ticket?: RequestTicket): IssuedCall;
133
+ /** `call` settled: forget it, and stop awaiting its request's answer. */
134
+ settle(call: IssuedCall): void;
135
+ /** The connection closed: nothing it sent is awaited, and no call is pending, any more. */
136
+ close(): void;
137
+ /**
138
+ * Whether this connection's answers pass the observer: the `initialize`
139
+ * answer did. Read once the connection is initialized.
140
+ */
141
+ get answersObserved(): boolean;
74
142
  /** How many `tools/call` requests the watched transport has sent — matched to a call or not. */
75
143
  get toolCallsSent(): number;
144
+ /**
145
+ * @internal How many entries the ledger holds: calls issued and not settled,
146
+ * requests being sent, answers awaited. Zero once every call settled.
147
+ */
148
+ get retained(): number;
76
149
  /** `true` the first time it is asked, then never again: an unmatched request is named once per connection. */
77
150
  firstUnbound(): boolean;
78
151
  /**
@@ -80,8 +153,17 @@ export declare class RequestLedger {
80
153
  * original bound to the instance itself. Returns the SAME object — or
81
154
  * `undefined` when it has no `send` to watch or refuses the property, and
82
155
  * then nothing is watched and no call should expect its attempts filed.
156
+ *
157
+ * Its incoming messages are watched too: an `onmessage` set before the
158
+ * client connects, which the current MCP SDK's `Protocol.connect` keeps and
159
+ * calls before its own dispatch. Whether it was kept is known once the
160
+ * `initialize` answer has, or has not, passed it (`answersObserved`).
83
161
  */
84
162
  watch<T extends object>(transport: T): T | undefined;
163
+ /** Observe incoming messages before whatever handled them already — never instead of it. */
164
+ private watchMessages;
165
+ /** One incoming message: the `initialize` answer, or the answer to an awaited request. */
166
+ private observe;
85
167
  /**
86
168
  * The `tools/call` request `body` carries, while its send runs — its ticket
87
169
  * when a call issued one, and the signal its cancellation fires. `undefined`
@@ -90,8 +172,9 @@ export declare class RequestLedger {
90
172
  claim(body: unknown): ClaimedRequest | undefined;
91
173
  /** One message through the watched transport. */
92
174
  private send;
93
- /** Register a `tools/call` in flight, with the ticket its params were issued — if any. */
94
- private bind;
95
- /** The SDK gave a request up: stop the series still sending it. */
175
+ /** The `initialize` request: its answer is the one that proves the observer is in place. */
176
+ private noteInitialize;
177
+ /** The SDK gave a request up: stop the series still sending it, and stop awaiting its answer. */
96
178
  private cancelIfAsked;
97
179
  }
180
+ export {};