agentfootprint 11.4.0 → 12.0.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 (198) hide show
  1. package/CAPABILITIES.md +3 -1
  2. package/dist/adapters/code/agentcore.js +295 -214
  3. package/dist/adapters/code/agentcore.js.map +1 -1
  4. package/dist/adapters/code/agentcoreClient.js +178 -0
  5. package/dist/adapters/code/agentcoreClient.js.map +1 -0
  6. package/dist/adapters/code/agentcoreWire.js +348 -0
  7. package/dist/adapters/code/agentcoreWire.js.map +1 -0
  8. package/dist/adapters/code/fileName.js +100 -0
  9. package/dist/adapters/code/fileName.js.map +1 -0
  10. package/dist/adapters/code/local.js +529 -183
  11. package/dist/adapters/code/local.js.map +1 -1
  12. package/dist/adapters/code/output.js +140 -0
  13. package/dist/adapters/code/output.js.map +1 -0
  14. package/dist/adapters/mcp/agentcoreRuntime/invoke.js +7 -6
  15. package/dist/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
  16. package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js +36 -2
  17. package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -1
  18. package/dist/adapters/mcp/agentcoreRuntime/transport.js +3 -1
  19. package/dist/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
  20. package/dist/core/codeRunnerTool.js +52 -7
  21. package/dist/core/codeRunnerTool.js.map +1 -1
  22. package/dist/doors/providers.js.map +1 -1
  23. package/dist/esm/adapters/code/agentcore.d.ts +65 -68
  24. package/dist/esm/adapters/code/agentcore.js +293 -212
  25. package/dist/esm/adapters/code/agentcore.js.map +1 -1
  26. package/dist/esm/adapters/code/agentcoreClient.d.ts +193 -0
  27. package/dist/esm/adapters/code/agentcoreClient.js +173 -0
  28. package/dist/esm/adapters/code/agentcoreClient.js.map +1 -0
  29. package/dist/esm/adapters/code/agentcoreWire.d.ts +119 -0
  30. package/dist/esm/adapters/code/agentcoreWire.js +334 -0
  31. package/dist/esm/adapters/code/agentcoreWire.js.map +1 -0
  32. package/dist/esm/adapters/code/fileName.d.ts +43 -0
  33. package/dist/esm/adapters/code/fileName.js +96 -0
  34. package/dist/esm/adapters/code/fileName.js.map +1 -0
  35. package/dist/esm/adapters/code/local.d.ts +91 -12
  36. package/dist/esm/adapters/code/local.js +528 -182
  37. package/dist/esm/adapters/code/local.js.map +1 -1
  38. package/dist/esm/adapters/code/output.d.ts +70 -0
  39. package/dist/esm/adapters/code/output.js +129 -0
  40. package/dist/esm/adapters/code/output.js.map +1 -0
  41. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
  42. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +7 -6
  43. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
  44. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
  45. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js +35 -1
  46. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -1
  47. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +4 -2
  48. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
  49. package/dist/esm/core/codeRunnerTool.d.ts +15 -3
  50. package/dist/esm/core/codeRunnerTool.js +52 -7
  51. package/dist/esm/core/codeRunnerTool.js.map +1 -1
  52. package/dist/esm/doors/providers.d.ts +1 -1
  53. package/dist/esm/doors/providers.js.map +1 -1
  54. package/dist/esm/events/payloads.d.ts +144 -29
  55. package/dist/esm/index.d.ts +2 -0
  56. package/dist/esm/index.js +5 -0
  57. package/dist/esm/index.js.map +1 -1
  58. package/dist/esm/mcp/callLifetime.d.ts +57 -14
  59. package/dist/esm/mcp/callLifetime.js +67 -19
  60. package/dist/esm/mcp/callLifetime.js.map +1 -1
  61. package/dist/esm/mcp/callMarker.d.ts +43 -0
  62. package/dist/esm/mcp/callMarker.js +69 -0
  63. package/dist/esm/mcp/callMarker.js.map +1 -0
  64. package/dist/esm/mcp/connectionRefusals.js +7 -0
  65. package/dist/esm/mcp/connectionRefusals.js.map +1 -1
  66. package/dist/esm/mcp/index.d.ts +2 -0
  67. package/dist/esm/mcp/index.js +3 -0
  68. package/dist/esm/mcp/index.js.map +1 -1
  69. package/dist/esm/mcp/mcpClient.js +93 -26
  70. package/dist/esm/mcp/mcpClient.js.map +1 -1
  71. package/dist/esm/mcp/replay.d.ts +291 -0
  72. package/dist/esm/mcp/replay.js +405 -0
  73. package/dist/esm/mcp/replay.js.map +1 -0
  74. package/dist/esm/mcp/replayUnavailable.d.ts +68 -0
  75. package/dist/esm/mcp/replayUnavailable.js +87 -0
  76. package/dist/esm/mcp/replayUnavailable.js.map +1 -0
  77. package/dist/esm/mcp/requestLedger.d.ts +115 -32
  78. package/dist/esm/mcp/requestLedger.js +193 -52
  79. package/dist/esm/mcp/requestLedger.js.map +1 -1
  80. package/dist/esm/mcp/seriesEvidence.d.ts +73 -15
  81. package/dist/esm/mcp/seriesEvidence.js +114 -21
  82. package/dist/esm/mcp/seriesEvidence.js.map +1 -1
  83. package/dist/esm/mcp/throttleRetry.d.ts +86 -42
  84. package/dist/esm/mcp/throttleRetry.js +158 -50
  85. package/dist/esm/mcp/throttleRetry.js.map +1 -1
  86. package/dist/esm/mcp/toolResult.d.ts +6 -0
  87. package/dist/esm/mcp/toolResult.js +15 -0
  88. package/dist/esm/mcp/toolResult.js.map +1 -1
  89. package/dist/esm/mcp/types.d.ts +73 -8
  90. package/dist/esm/provider-contract/codeSandbox.d.ts +89 -0
  91. package/dist/esm/provider-contract/codeSandbox.js +119 -0
  92. package/dist/esm/provider-contract/codeSandbox.js.map +1 -0
  93. package/dist/esm/provider-contract/sessionExpired.d.ts +31 -0
  94. package/dist/esm/provider-contract/sessionExpired.js +40 -0
  95. package/dist/esm/provider-contract/sessionExpired.js.map +1 -0
  96. package/dist/esm/provider-contract/types.d.ts +166 -17
  97. package/dist/esm/provider-contract/types.js +9 -0
  98. package/dist/esm/provider-contract/types.js.map +1 -1
  99. package/dist/esm/redaction/knownStrings.js +16 -0
  100. package/dist/esm/redaction/knownStrings.js.map +1 -1
  101. package/dist/esm/tool-providers/index.d.ts +2 -2
  102. package/dist/esm/tool-providers/index.js +4 -0
  103. package/dist/esm/tool-providers/index.js.map +1 -1
  104. package/dist/esm/tools/requestEvidence.js +60 -0
  105. package/dist/esm/tools/requestEvidence.js.map +1 -1
  106. package/dist/index.js +12 -4
  107. package/dist/index.js.map +1 -1
  108. package/dist/mcp/callLifetime.js +66 -18
  109. package/dist/mcp/callLifetime.js.map +1 -1
  110. package/dist/mcp/callMarker.js +74 -0
  111. package/dist/mcp/callMarker.js.map +1 -0
  112. package/dist/mcp/connectionRefusals.js +7 -0
  113. package/dist/mcp/connectionRefusals.js.map +1 -1
  114. package/dist/mcp/index.js +5 -1
  115. package/dist/mcp/index.js.map +1 -1
  116. package/dist/mcp/mcpClient.js +91 -24
  117. package/dist/mcp/mcpClient.js.map +1 -1
  118. package/dist/mcp/replay.js +415 -0
  119. package/dist/mcp/replay.js.map +1 -0
  120. package/dist/mcp/replayUnavailable.js +92 -0
  121. package/dist/mcp/replayUnavailable.js.map +1 -0
  122. package/dist/mcp/requestLedger.js +193 -52
  123. package/dist/mcp/requestLedger.js.map +1 -1
  124. package/dist/mcp/seriesEvidence.js +116 -22
  125. package/dist/mcp/seriesEvidence.js.map +1 -1
  126. package/dist/mcp/throttleRetry.js +160 -51
  127. package/dist/mcp/throttleRetry.js.map +1 -1
  128. package/dist/mcp/toolResult.js +17 -1
  129. package/dist/mcp/toolResult.js.map +1 -1
  130. package/dist/provider-contract/codeSandbox.js +125 -0
  131. package/dist/provider-contract/codeSandbox.js.map +1 -0
  132. package/dist/provider-contract/sessionExpired.js +44 -0
  133. package/dist/provider-contract/sessionExpired.js.map +1 -0
  134. package/dist/provider-contract/types.js +12 -1
  135. package/dist/provider-contract/types.js.map +1 -1
  136. package/dist/redaction/knownStrings.js +16 -0
  137. package/dist/redaction/knownStrings.js.map +1 -1
  138. package/dist/tool-providers/index.js +5 -1
  139. package/dist/tool-providers/index.js.map +1 -1
  140. package/dist/tools/requestEvidence.js +60 -0
  141. package/dist/tools/requestEvidence.js.map +1 -1
  142. package/dist/types/adapters/code/agentcore.d.ts +65 -68
  143. package/dist/types/adapters/code/agentcore.d.ts.map +1 -1
  144. package/dist/types/adapters/code/agentcoreClient.d.ts +194 -0
  145. package/dist/types/adapters/code/agentcoreClient.d.ts.map +1 -0
  146. package/dist/types/adapters/code/agentcoreWire.d.ts +120 -0
  147. package/dist/types/adapters/code/agentcoreWire.d.ts.map +1 -0
  148. package/dist/types/adapters/code/fileName.d.ts +44 -0
  149. package/dist/types/adapters/code/fileName.d.ts.map +1 -0
  150. package/dist/types/adapters/code/local.d.ts +91 -12
  151. package/dist/types/adapters/code/local.d.ts.map +1 -1
  152. package/dist/types/adapters/code/output.d.ts +71 -0
  153. package/dist/types/adapters/code/output.d.ts.map +1 -0
  154. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
  155. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -1
  156. package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
  157. package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts.map +1 -1
  158. package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -1
  159. package/dist/types/core/codeRunnerTool.d.ts +15 -3
  160. package/dist/types/core/codeRunnerTool.d.ts.map +1 -1
  161. package/dist/types/doors/providers.d.ts +1 -1
  162. package/dist/types/doors/providers.d.ts.map +1 -1
  163. package/dist/types/events/payloads.d.ts +144 -29
  164. package/dist/types/events/payloads.d.ts.map +1 -1
  165. package/dist/types/index.d.ts +2 -0
  166. package/dist/types/index.d.ts.map +1 -1
  167. package/dist/types/mcp/callLifetime.d.ts +57 -14
  168. package/dist/types/mcp/callLifetime.d.ts.map +1 -1
  169. package/dist/types/mcp/callMarker.d.ts +44 -0
  170. package/dist/types/mcp/callMarker.d.ts.map +1 -0
  171. package/dist/types/mcp/index.d.ts +2 -0
  172. package/dist/types/mcp/index.d.ts.map +1 -1
  173. package/dist/types/mcp/mcpClient.d.ts.map +1 -1
  174. package/dist/types/mcp/replay.d.ts +292 -0
  175. package/dist/types/mcp/replay.d.ts.map +1 -0
  176. package/dist/types/mcp/replayUnavailable.d.ts +69 -0
  177. package/dist/types/mcp/replayUnavailable.d.ts.map +1 -0
  178. package/dist/types/mcp/requestLedger.d.ts +115 -32
  179. package/dist/types/mcp/requestLedger.d.ts.map +1 -1
  180. package/dist/types/mcp/seriesEvidence.d.ts +73 -15
  181. package/dist/types/mcp/seriesEvidence.d.ts.map +1 -1
  182. package/dist/types/mcp/throttleRetry.d.ts +86 -42
  183. package/dist/types/mcp/throttleRetry.d.ts.map +1 -1
  184. package/dist/types/mcp/toolResult.d.ts +6 -0
  185. package/dist/types/mcp/toolResult.d.ts.map +1 -1
  186. package/dist/types/mcp/types.d.ts +73 -8
  187. package/dist/types/mcp/types.d.ts.map +1 -1
  188. package/dist/types/provider-contract/codeSandbox.d.ts +90 -0
  189. package/dist/types/provider-contract/codeSandbox.d.ts.map +1 -0
  190. package/dist/types/provider-contract/sessionExpired.d.ts +32 -0
  191. package/dist/types/provider-contract/sessionExpired.d.ts.map +1 -0
  192. package/dist/types/provider-contract/types.d.ts +166 -17
  193. package/dist/types/provider-contract/types.d.ts.map +1 -1
  194. package/dist/types/redaction/knownStrings.d.ts.map +1 -1
  195. package/dist/types/tool-providers/index.d.ts +2 -2
  196. package/dist/types/tool-providers/index.d.ts.map +1 -1
  197. package/dist/types/tools/requestEvidence.d.ts.map +1 -1
  198. package/package.json +1 -1
@@ -0,0 +1,291 @@
1
+ /**
2
+ * replay — who may send an MCP tool call again, and what is known of what each
3
+ * attempt did: two facts, decided apart and recorded apart.
4
+ *
5
+ * Pattern: a declaration read once + one permission rule + one accumulator.
6
+ * Role: Layer-3 tool transport. `mcpClient({ replay })` reads the app's
7
+ * declaration (`replayDeclarationOf`) when the client is built. The
8
+ * call's retry series (`throttleRetry.ts` · `Series`) asks `permit`
9
+ * before every repeat and records the answer beside the attempt;
10
+ * `SeriesKnowledge` carries what is known of the series' effect from
11
+ * one attempt to the next.
12
+ *
13
+ * ── THE LAW ──────────────────────────────────────────────────────────────────
14
+ * PERMISSION to repeat comes only from the app: the (server, tool) pairs it
15
+ * declares — the server is the client the declaration is given to — and the
16
+ * failure kinds each tool may be repeated on. Never from the model, a tool's
17
+ * description or a server's annotations (`readOnlyHint`): nothing here reads
18
+ * them. It is configuration, read once when the client is built — never a
19
+ * per-call question.
20
+ *
21
+ * KNOWLEDGE of whether an attempt ran comes only from the record and from an
22
+ * established service guarantee. No reply this library reads is one. A 429 is
23
+ * not: RFC 6585 §4 defines it as rate limiting, and `Retry-After` says when to
24
+ * ask again, not that asking is safe. AgentCore Runtime's session-busy body is
25
+ * not either: AWS documents a retryable conflict while a session starts or
26
+ * stops, and the body is matched by its code and words, which a server behind
27
+ * the runtime can send after it ran the call. So every attempt that was sent
28
+ * and did not complete is `unknown`; `none` is only a request never sent. A
29
+ * vendor's own SDK may retry its own 429s because the vendor documents its own
30
+ * service; a generic MCP client cannot assume that of an arbitrary server.
31
+ *
32
+ * Neither is read from the other: a permission never makes an effect known,
33
+ * and an effect never grants a permission.
34
+ *
35
+ * ── WHAT A REPEAT IS ─────────────────────────────────────────────────────────
36
+ * The same validated, authorized request sent again: the same body — the same
37
+ * arguments — to the same server, in the same session, as the same identity.
38
+ * Nothing is re-planned. A credential the library vends, or a signature, is
39
+ * made afresh for each attempt (signatures expire), for that same identity.
40
+ *
41
+ * ── THE POLICIES ─────────────────────────────────────────────────────────────
42
+ * 'compatibility' — the default, kept in 12.0: today's behaviour by name. A
43
+ * 429 is repeated for every tool, on the ASSUMPTION that the server
44
+ * refused it before running it. Each such repeat records that
45
+ * assumption; the attempt's effect stays `unknown`, and the caller sees
46
+ * the error it always did. It gains none of the strict policy's
47
+ * guarantees: it never establishes that answers are seen or that
48
+ * requests are matched to their calls.
49
+ * 'app-authorized' — opt-in, by name only: a 429 or a network failure is
50
+ * repeated only when the app's entry for the tool names it. What the
51
+ * caller sees follows footprintjs's law
52
+ * (`RequestReplay` · `uncertain`, `callLifetime.ts`): a received refusal
53
+ * or error keeps the server's error as it came, its effect still
54
+ * `unknown`; a call that genuinely lacked an answer somewhere — an
55
+ * attempt with no response, or a request accepted over HTTP whose
56
+ * JSON-RPC answer never came — and then fails, fails with
57
+ * `UnknownEffectError`, its final error the cause. That needs each
58
+ * request matched to its call and each answer seen; a connection that
59
+ * cannot give both refuses the tool call before its request is sent
60
+ * (`replayUnavailable.ts`), so the contract never silently weakens. It
61
+ * never falls back to 'compatibility', and nothing chooses it from the
62
+ * transport.
63
+ *
64
+ * Under both, the adapter the app chose retries its own refusal within the
65
+ * budget — AgentCore's session-busy reply — as the ADAPTER's policy, on an
66
+ * assumption it records the same way (`permission: { by: 'adapter', assumes }`),
67
+ * never as evidence. And THE SIDE-EFFECT GUARD holds: a tool the app declares
68
+ * as making changes is never repeated automatically unless the server is
69
+ * declared to deduplicate by an idempotency key the call carries —
70
+ * footprintjs's law, a retry of an effect without a key can apply it twice. A
71
+ * key protects only when the server uses it; the library cannot check that.
72
+ *
73
+ * The protocol's own requests (`initialize`, `tools/list`, notifications) run
74
+ * no tool. The declaration does not govern them, and a 429 on one is asked
75
+ * again under both policies, as it always was. They file no record.
76
+ */
77
+ import type { ToolRequestEffect, ToolRequestPermission, ToolRequestReason, ToolRequestReplayKind } from '../events/payloads.js';
78
+ /**
79
+ * Which rule decides whether a tool call is sent again after a refusal or a
80
+ * failure. `'compatibility'` is the default, kept in 12.0: it keeps its stated
81
+ * retry assumption and gains none of the strict guarantees. `'app-authorized'`
82
+ * applies only when written, and never falls back to `'compatibility'`.
83
+ */
84
+ export type McpReplayPolicy = 'app-authorized' | 'compatibility';
85
+ /**
86
+ * A failure kind the app may declare a tool repeatable on: HTTP 429
87
+ * (`'throttle'`), or a request that failed in transport without an answer
88
+ * (`'network'`, footprintjs's category: a dropped or refused connection, or a
89
+ * timeout raised below the retry series). Either may have run on the server, so
90
+ * a repeat after it leaves the call's effect `unknown`.
91
+ */
92
+ export type McpReplayKind = ToolRequestReplayKind;
93
+ /** One tool's entry in {@link McpReplayOptions.tools}. */
94
+ export interface McpReplayTool {
95
+ /**
96
+ * The failure kinds this tool may be sent again on. Default: none. Under
97
+ * `'compatibility'` a 429 is repeated without it, recorded as an assumption;
98
+ * under `'app-authorized'` only what is named here is repeated.
99
+ */
100
+ readonly on?: readonly McpReplayKind[];
101
+ /**
102
+ * `true` — this tool makes changes. It is then never sent again
103
+ * automatically, under either policy, unless the server is declared to
104
+ * deduplicate (`deduplicates`) and the call carries the key.
105
+ */
106
+ readonly changes?: boolean;
107
+ }
108
+ /**
109
+ * How the server deduplicates a tool call: by an idempotency key the call
110
+ * carries in the named argument. Declare it only when the server does; a key
111
+ * protects only when the server uses it.
112
+ */
113
+ export interface McpReplayDeduplication {
114
+ /**
115
+ * The argument that carries the key — present as a non-empty string in the
116
+ * call for a repeat to be allowed. Set it in your code (a `toolMiddleware`
117
+ * that writes it from the call), never from what the model wrote: a key the
118
+ * model reuses for a different operation makes the server drop that one.
119
+ */
120
+ readonly argument: string;
121
+ }
122
+ /**
123
+ * The app's replay declaration for one MCP server — its client. Read once when
124
+ * the client is built; a field it does not know is refused there, so a
125
+ * misspelled `changes` cannot quietly switch the side-effect guard off.
126
+ */
127
+ export interface McpReplayOptions {
128
+ /**
129
+ * Default `'compatibility'`, in 12.0 as in 11.x. An explicit
130
+ * `'app-authorized'` never falls back to it.
131
+ */
132
+ readonly policy?: McpReplayPolicy;
133
+ /** The tools of this server, by the name the server lists them under. */
134
+ readonly tools?: Readonly<Record<string, McpReplayTool>>;
135
+ /** The server deduplicates by an idempotency key the call carries. */
136
+ readonly deduplicates?: McpReplayDeduplication;
137
+ }
138
+ interface ToolEntry {
139
+ readonly on: ReadonlySet<McpReplayKind>;
140
+ readonly changes: boolean;
141
+ }
142
+ /** @internal A declaration, read and checked once. */
143
+ export interface ReplayDeclaration {
144
+ readonly policy: McpReplayPolicy;
145
+ readonly tools: ReadonlyMap<string, ToolEntry>;
146
+ /** The argument the server deduplicates by, when it is declared to. */
147
+ readonly keyArgument?: string;
148
+ }
149
+ /** @internal No declaration: the compatibility policy, no tool named. */
150
+ export declare const COMPATIBILITY: ReplayDeclaration;
151
+ /**
152
+ * @internal `options` read as a declaration — `undefined` is the compatibility
153
+ * policy with nothing named.
154
+ *
155
+ * @throws TypeError naming the field, never echoing a value, for anything the
156
+ * rule cannot mean: an unknown field, a policy or kind it does not know, an
157
+ * argument name that is not one.
158
+ */
159
+ export declare function replayDeclarationOf(options: unknown, where: string): ReplayDeclaration;
160
+ /**
161
+ * @internal Whether the declaration needs a retry series even with the 429
162
+ * rule off (`retryOnThrottle: false`): a tool declared repeatable on
163
+ * `'network'`, or the `'app-authorized'` policy — its record and its "may have
164
+ * run" rest on the series.
165
+ */
166
+ export declare function needsSeries(declaration: ReplayDeclaration): boolean;
167
+ /**
168
+ * @internal One request, as the permission rule needs it: the protocol's own,
169
+ * or a `tools/call` — its tool when the body names one, and whether its
170
+ * arguments carry the key the server deduplicates by.
171
+ */
172
+ export type ReplayTarget = {
173
+ readonly kind: 'protocol';
174
+ } | {
175
+ readonly kind: 'tool';
176
+ readonly name?: string;
177
+ readonly keyCarried: boolean;
178
+ };
179
+ /**
180
+ * @internal `body` — the request exactly as it will be sent — read as a
181
+ * target. A declaration that names nothing under `'compatibility'` decides the
182
+ * same for every request, so its bodies are never parsed.
183
+ */
184
+ export declare function replayTargetOf(body: unknown, declaration: ReplayDeclaration): ReplayTarget;
185
+ /** @internal A failure the series met, as the permission rule reads it. */
186
+ export interface MetFailure {
187
+ /** A refusal a rule recognised (`throttle`, `session-busy`), or a request that failed in transport. */
188
+ readonly kind: 'throttle' | 'session-busy' | 'network';
189
+ /**
190
+ * What the adapter that recognised this refusal assumes in retrying it, as
191
+ * its own policy — set on its rule. Never evidence of the attempt's effect.
192
+ */
193
+ readonly assumes?: 'refused-before-execution';
194
+ }
195
+ /** @internal Why the series did not ask again, by the rule. */
196
+ export type ReplayDeclined = Extract<ToolRequestReason, 'not-retryable' | 'not-permitted' | 'changes-without-key'>;
197
+ /**
198
+ * @internal The rule's answer: ask again, with what allowed it — absent for a
199
+ * protocol request, which has no record — or not, and why.
200
+ */
201
+ export type ReplayDecision = {
202
+ readonly repeat: true;
203
+ readonly permission?: ToolRequestPermission;
204
+ } | {
205
+ readonly repeat: false;
206
+ readonly declined: ReplayDeclined;
207
+ };
208
+ /** @internal A thrown failure the rule can read: footprintjs's `network` category, or nothing. */
209
+ export declare function thrownFailure(error: unknown): MetFailure | undefined;
210
+ /**
211
+ * @internal THE rule: may the series send `target` again after `failure`?
212
+ * Asked before every repeat; the budget is asked after it.
213
+ */
214
+ export declare function permit(declaration: ReplayDeclaration, target: ReplayTarget, failure: MetFailure): ReplayDecision;
215
+ /**
216
+ * @internal What is known of a whole series' effect, one attempt at a time.
217
+ * Uncertainty survives: once any attempt is `unknown`, the series is, whatever
218
+ * later attempts show — a proven refusal does not resolve it, and a success
219
+ * does not prove the operation happened only once. Evidence that something ran
220
+ * (`applied`) is never erased by a later failure.
221
+ */
222
+ export declare class SeriesKnowledge {
223
+ private unknown;
224
+ private applied;
225
+ note(effect: ToolRequestEffect): void;
226
+ get effect(): ToolRequestEffect;
227
+ }
228
+ /** @internal How `callTool` settled, as the call reads it. */
229
+ export type CallVerdict = 'completed' | 'tool-error' | 'failed';
230
+ /**
231
+ * @internal One `tools/call` request's replay facts, shared by the series that
232
+ * sends it, the ledger that watches its answer, and the call that waits for it
233
+ * — the ledger hands all three the same object (`requestLedger.ts`).
234
+ *
235
+ * TWO LAYERS, KEPT APART. The series sees HTTP: whether an attempt got a
236
+ * response at all, and the status of the one it delivered. A response is not
237
+ * the MCP call's answer — a 202, or a stream, can be accepted and never carry
238
+ * it — so the ledger watches the connection's incoming messages for the
239
+ * JSON-RPC response to THIS request's id. And "its effect is unknown" is not
240
+ * "it lacked an answer": a received 429 or error is an answer whose effect is
241
+ * unknown.
242
+ *
243
+ * Each fact is written once, by its owner: the series (what it sent, whether an
244
+ * attempt lacked any response, what it delivered, the policy), the ledger (the
245
+ * logical answer), the call (how it settled).
246
+ */
247
+ export declare class RequestReplay {
248
+ readonly id: string | number;
249
+ private requests;
250
+ private appAuthorized;
251
+ private attemptUnanswered;
252
+ private delivered;
253
+ private logical;
254
+ private settled;
255
+ private failedAsMayHaveRun;
256
+ /**
257
+ * @param id the request's JSON-RPC id, how its answer is found.
258
+ * @param watched whether the connection's incoming messages are observed —
259
+ * without that, the logical layer is unknown and never decides anything.
260
+ */
261
+ constructor(id: string | number, watched: boolean);
262
+ /** The series sent the request once more. */
263
+ sentOne(): void;
264
+ /** The series runs under the `'app-authorized'` policy. */
265
+ appAuthorizedPolicy(): void;
266
+ /**
267
+ * The series: an attempt genuinely lacked an answer — no response arrived
268
+ * (a lost connection, a timeout, a cut). A received refusal is never this.
269
+ */
270
+ noAnswer(): void;
271
+ /** The series handed the MCP SDK a response with this status. */
272
+ deliveredStatus(status: number): void;
273
+ /** The ledger: the JSON-RPC response to this request's id arrived. */
274
+ answered(): void;
275
+ /** The call settled; `mayHaveRun` when it failed as "may have run". The first word stands. */
276
+ settle(verdict: CallVerdict, mayHaveRun: boolean): void;
277
+ get sent(): number;
278
+ /**
279
+ * Under `'app-authorized'`, a call that does not complete fails as "may have
280
+ * run" when the call genuinely lacked an answer somewhere: an attempt got no
281
+ * response, or the HTTP layer accepted the request (a 2xx) and the JSON-RPC
282
+ * response never came. A chain of received refusals and errors is an answer
283
+ * throughout: it keeps the server's error.
284
+ */
285
+ get uncertain(): boolean;
286
+ /** The HTTP layer took the request (2xx), and the logical answer never arrived. */
287
+ private get acceptedWithoutAnswer();
288
+ get verdict(): CallVerdict | undefined;
289
+ get mayHaveRun(): boolean;
290
+ }
291
+ export {};