agentfootprint 11.4.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 (116) hide show
  1. package/CAPABILITIES.md +2 -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/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
  9. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +7 -6
  10. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
  11. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
  12. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js +35 -1
  13. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -1
  14. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +4 -2
  15. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
  16. package/dist/esm/events/payloads.d.ts +128 -27
  17. package/dist/esm/mcp/callLifetime.d.ts +57 -14
  18. package/dist/esm/mcp/callLifetime.js +67 -19
  19. package/dist/esm/mcp/callLifetime.js.map +1 -1
  20. package/dist/esm/mcp/callMarker.d.ts +43 -0
  21. package/dist/esm/mcp/callMarker.js +69 -0
  22. package/dist/esm/mcp/callMarker.js.map +1 -0
  23. package/dist/esm/mcp/connectionRefusals.js +7 -0
  24. package/dist/esm/mcp/connectionRefusals.js.map +1 -1
  25. package/dist/esm/mcp/index.d.ts +2 -0
  26. package/dist/esm/mcp/index.js +3 -0
  27. package/dist/esm/mcp/index.js.map +1 -1
  28. package/dist/esm/mcp/mcpClient.js +93 -26
  29. package/dist/esm/mcp/mcpClient.js.map +1 -1
  30. package/dist/esm/mcp/replay.d.ts +283 -0
  31. package/dist/esm/mcp/replay.js +401 -0
  32. package/dist/esm/mcp/replay.js.map +1 -0
  33. package/dist/esm/mcp/replayUnavailable.d.ts +55 -0
  34. package/dist/esm/mcp/replayUnavailable.js +74 -0
  35. package/dist/esm/mcp/replayUnavailable.js.map +1 -0
  36. package/dist/esm/mcp/requestLedger.d.ts +115 -32
  37. package/dist/esm/mcp/requestLedger.js +193 -52
  38. package/dist/esm/mcp/requestLedger.js.map +1 -1
  39. package/dist/esm/mcp/seriesEvidence.d.ts +73 -15
  40. package/dist/esm/mcp/seriesEvidence.js +114 -21
  41. package/dist/esm/mcp/seriesEvidence.js.map +1 -1
  42. package/dist/esm/mcp/throttleRetry.d.ts +86 -42
  43. package/dist/esm/mcp/throttleRetry.js +158 -50
  44. package/dist/esm/mcp/throttleRetry.js.map +1 -1
  45. package/dist/esm/mcp/toolResult.d.ts +6 -0
  46. package/dist/esm/mcp/toolResult.js +15 -0
  47. package/dist/esm/mcp/toolResult.js.map +1 -1
  48. package/dist/esm/mcp/types.d.ts +70 -8
  49. package/dist/esm/redaction/knownStrings.js +13 -0
  50. package/dist/esm/redaction/knownStrings.js.map +1 -1
  51. package/dist/esm/tool-providers/index.d.ts +2 -2
  52. package/dist/esm/tool-providers/index.js +4 -0
  53. package/dist/esm/tool-providers/index.js.map +1 -1
  54. package/dist/esm/tools/requestEvidence.js +60 -0
  55. package/dist/esm/tools/requestEvidence.js.map +1 -1
  56. package/dist/mcp/callLifetime.js +66 -18
  57. package/dist/mcp/callLifetime.js.map +1 -1
  58. package/dist/mcp/callMarker.js +74 -0
  59. package/dist/mcp/callMarker.js.map +1 -0
  60. package/dist/mcp/connectionRefusals.js +7 -0
  61. package/dist/mcp/connectionRefusals.js.map +1 -1
  62. package/dist/mcp/index.js +5 -1
  63. package/dist/mcp/index.js.map +1 -1
  64. package/dist/mcp/mcpClient.js +91 -24
  65. package/dist/mcp/mcpClient.js.map +1 -1
  66. package/dist/mcp/replay.js +411 -0
  67. package/dist/mcp/replay.js.map +1 -0
  68. package/dist/mcp/replayUnavailable.js +79 -0
  69. package/dist/mcp/replayUnavailable.js.map +1 -0
  70. package/dist/mcp/requestLedger.js +193 -52
  71. package/dist/mcp/requestLedger.js.map +1 -1
  72. package/dist/mcp/seriesEvidence.js +116 -22
  73. package/dist/mcp/seriesEvidence.js.map +1 -1
  74. package/dist/mcp/throttleRetry.js +160 -51
  75. package/dist/mcp/throttleRetry.js.map +1 -1
  76. package/dist/mcp/toolResult.js +17 -1
  77. package/dist/mcp/toolResult.js.map +1 -1
  78. package/dist/redaction/knownStrings.js +13 -0
  79. package/dist/redaction/knownStrings.js.map +1 -1
  80. package/dist/tool-providers/index.js +5 -1
  81. package/dist/tool-providers/index.js.map +1 -1
  82. package/dist/tools/requestEvidence.js +60 -0
  83. package/dist/tools/requestEvidence.js.map +1 -1
  84. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
  85. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -1
  86. package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
  87. package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts.map +1 -1
  88. package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -1
  89. package/dist/types/events/payloads.d.ts +128 -27
  90. package/dist/types/events/payloads.d.ts.map +1 -1
  91. package/dist/types/mcp/callLifetime.d.ts +57 -14
  92. package/dist/types/mcp/callLifetime.d.ts.map +1 -1
  93. package/dist/types/mcp/callMarker.d.ts +44 -0
  94. package/dist/types/mcp/callMarker.d.ts.map +1 -0
  95. package/dist/types/mcp/index.d.ts +2 -0
  96. package/dist/types/mcp/index.d.ts.map +1 -1
  97. package/dist/types/mcp/mcpClient.d.ts.map +1 -1
  98. package/dist/types/mcp/replay.d.ts +284 -0
  99. package/dist/types/mcp/replay.d.ts.map +1 -0
  100. package/dist/types/mcp/replayUnavailable.d.ts +56 -0
  101. package/dist/types/mcp/replayUnavailable.d.ts.map +1 -0
  102. package/dist/types/mcp/requestLedger.d.ts +115 -32
  103. package/dist/types/mcp/requestLedger.d.ts.map +1 -1
  104. package/dist/types/mcp/seriesEvidence.d.ts +73 -15
  105. package/dist/types/mcp/seriesEvidence.d.ts.map +1 -1
  106. package/dist/types/mcp/throttleRetry.d.ts +86 -42
  107. package/dist/types/mcp/throttleRetry.d.ts.map +1 -1
  108. package/dist/types/mcp/toolResult.d.ts +6 -0
  109. package/dist/types/mcp/toolResult.d.ts.map +1 -1
  110. package/dist/types/mcp/types.d.ts +70 -8
  111. package/dist/types/mcp/types.d.ts.map +1 -1
  112. package/dist/types/redaction/knownStrings.d.ts.map +1 -1
  113. package/dist/types/tool-providers/index.d.ts +2 -2
  114. package/dist/types/tool-providers/index.d.ts.map +1 -1
  115. package/dist/types/tools/requestEvidence.d.ts.map +1 -1
  116. package/package.json +1 -1
@@ -42,12 +42,15 @@
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 { isDevMode } from 'footprintjs';
45
46
  import { callMetaOf, readToolExtras } from './toolExtras.js';
46
- import { readToolResult, resultModeOf } from './toolResult.js';
47
+ import { isToolError, readToolResult, resultModeOf } from './toolResult.js';
47
48
  import { createVendingFetch } from './gatewayTransport.js';
48
- import { ledgeredFetch, retryingFetch } from './throttleRetry.js';
49
+ import { ledgeredFetch, retryingFetch, seriesWithoutThrottle, } from './throttleRetry.js';
49
50
  import { RequestLedger } from './requestLedger.js';
50
51
  import { openCall } from './callLifetime.js';
52
+ import { McpReplayUnavailableError, unavailableBeforeSending } from './replayUnavailable.js';
53
+ import { needsSeries, replayDeclarationOf, } from './replay.js';
51
54
  import { refuseConflictingOptions } from './connectionRefusals.js';
52
55
  import { sdkLoadFailure } from './sdkLoadFailure.js';
53
56
  import { transportUrl } from './transportUrl.js';
@@ -87,7 +90,12 @@ export async function mcpClient(opts) {
87
90
  // Before anything connects: an option that names a behaviour which cannot
88
91
  // happen on the chosen arm is a defect, not a preference.
89
92
  refuseConflictingOptions(opts, name);
90
- const { connection, ledger } = await openConnection(opts);
93
+ // The app's replay declaration — who may send a tool call again — read and
94
+ // checked once, here, before anything connects (`replay.ts`).
95
+ const replay = replayDeclarationOf(opts.replay, `mcpClient[${name}]`);
96
+ const strict = replay.policy === 'app-authorized';
97
+ const { connection, ledger } = await openConnection(opts, replay, name);
98
+ const unlisted = new Set();
91
99
  // Tool cache so consumers calling `.tools()` more than once don't
92
100
  // hammer the server. `.refresh()` invalidates it.
93
101
  let cache = null;
@@ -103,7 +111,8 @@ export async function mcpClient(opts) {
103
111
  const listed = opts.signal
104
112
  ? await connection.listTools(undefined, { signal: opts.signal })
105
113
  : await connection.listTools();
106
- return listed.tools.map((t) => wrapMcpTool(name, connection, t, opts.signal, resultMode, ledger));
114
+ noteUnlisted(replay, listed.tools, name, unlisted);
115
+ return listed.tools.map((t) => wrapMcpTool(name, connection, t, opts.signal, resultMode, ledger, strict));
107
116
  };
108
117
  return {
109
118
  name,
@@ -123,7 +132,13 @@ export async function mcpClient(opts) {
123
132
  return;
124
133
  closed = true;
125
134
  cache = null;
126
- await connection.close();
135
+ try {
136
+ await connection.close();
137
+ }
138
+ finally {
139
+ // Nothing this connection sent is awaited any more, however it closed.
140
+ ledger?.close();
141
+ }
127
142
  },
128
143
  };
129
144
  }
@@ -136,7 +151,7 @@ export async function mcpClient(opts) {
136
151
  * A call with neither `connection` nor `sdk` reaches `resolveClient` with two
137
152
  * `undefined` arguments and takes the identical path it always took.
138
153
  */
139
- async function openConnection(opts) {
154
+ async function openConnection(opts, replay, name) {
140
155
  if (opts.connection !== undefined)
141
156
  return { connection: opts.connection };
142
157
  if (opts._client !== undefined)
@@ -144,17 +159,17 @@ async function openConnection(opts) {
144
159
  // `refuseConflictingOptions` has already refused the case where this is
145
160
  // absent, so the assertion documents that guarantee rather than assuming it.
146
161
  const transport = opts.transport;
147
- return resolveClient(transport, opts.clientInfo, opts.signal, opts.retryOnThrottle, opts.sdk);
162
+ return resolveClient(transport, opts.clientInfo, opts.signal, opts.retryOnThrottle, opts.sdk, replay, name);
148
163
  }
149
164
  // ─── SDK construction (lazy require, unless the caller supplied it) ─
150
- async function resolveClient(transport, clientInfo, signal, retryOnThrottle, sdk) {
165
+ async function resolveClient(transport, clientInfo, signal, retryOnThrottle, sdk, replay, name = 'mcp') {
151
166
  if (sdk !== undefined)
152
167
  assertSdk(sdk, transport.transport);
153
168
  const mod = sdk ?? loadClientModule();
154
169
  const client = new mod.Client(clientInfo ?? DEFAULT_CLIENT_INFO, {
155
170
  capabilities: {},
156
171
  });
157
- const built = await buildTransport(transport, retryOnThrottle, sdk);
172
+ const built = await buildTransport(transport, retryOnThrottle, sdk, replay, name);
158
173
  // Same rule as callTool: options ride beside the transport, never inside it.
159
174
  if (signal)
160
175
  await client.connect(built.transport, { signal });
@@ -204,7 +219,7 @@ function loadClientModule() {
204
219
  }));
205
220
  }
206
221
  }
207
- async function buildTransport(t, retryOnThrottle, sdk) {
222
+ async function buildTransport(t, retryOnThrottle, sdk, replay, name = 'mcp') {
208
223
  if (t.transport === 'stdio') {
209
224
  // Deliberately NOT served by `sdk`: stdio spawns a subprocess, so it can
210
225
  // never run in a browser, and `client/stdio.js` is the SDK's one client
@@ -249,9 +264,23 @@ async function buildTransport(t, retryOnThrottle, sdk) {
249
264
  //
250
265
  // The ledger joins the same series, so each request a dispatched tool call
251
266
  // sends files its attempts into that call's run; the transport's `send` is
252
- // watched to bind each request to its call (`requestLedger.ts`). A fetch that
253
- // runs no series (retry off) gets no ledger: there is nothing to file.
254
- const ledger = new RequestLedger();
267
+ // watched to bind each request to its call (`requestLedger.ts`). The app's
268
+ // replay declaration joins with it: the series asks it before sending a tool
269
+ // call again (`replay.ts`). `retryOnThrottle: false` turns off the 429 rule
270
+ // and nothing else: when the declaration still needs a series — a tool
271
+ // declared repeatable on 'network', or the 'app-authorized' policy — the
272
+ // series stays, with that rule switched off (`seriesWithoutThrottle`).
273
+ // Otherwise a fetch that runs no series gets neither ledger nor declaration:
274
+ // there is nothing to file and nothing is sent again.
275
+ const retried = (inner) => retryOnThrottle === false && replay !== undefined && needsSeries(replay)
276
+ ? seriesWithoutThrottle(inner)
277
+ : retryingFetch(inner, retryOnThrottle);
278
+ // Under 'app-authorized' the ledger refuses a request it cannot match to its
279
+ // call, and awaits each matched request's answer (`requestLedger.ts`).
280
+ const ledger = new RequestLedger({
281
+ server: name,
282
+ strict: replay?.policy === 'app-authorized',
283
+ });
255
284
  if (t.transport === 'gateway') {
256
285
  // The consumer's own `fetch` (9.32.0) goes UNDERNEATH the vending, not
257
286
  // beside it: `createVendingFetch` resolves the credential, applies it to
@@ -260,8 +289,8 @@ async function buildTransport(t, retryOnThrottle, sdk) {
260
289
  // credential is still vended per request. Passing `undefined` is the
261
290
  // default global `fetch`, which is byte-identical to every release before
262
291
  // the seam existed.
263
- const gatewayFetch = retryingFetch(createVendingFetch(t, t.fetch), retryOnThrottle);
264
- const ledgered = gatewayFetch && ledgeredFetch(gatewayFetch, ledger);
292
+ const gatewayFetch = retried(createVendingFetch(t, t.fetch));
293
+ const ledgered = gatewayFetch && ledgeredFetch(gatewayFetch, ledger, replay);
265
294
  return watched(new httpMod.StreamableHTTPClientTransport(transportUrl(t.url, 'mcpClient'), {
266
295
  fetch: ledgered ?? gatewayFetch,
267
296
  }), ledgered && ledger);
@@ -270,8 +299,8 @@ async function buildTransport(t, retryOnThrottle, sdk) {
270
299
  // are given. The SDK folds `requestInit.headers` into the `init.headers` it
271
300
  // hands the custom fetch, so a signer sees the static headers and has the
272
301
  // final word over the bytes — see `McpHttpTransport.fetch`.
273
- const httpFetch = retryingFetch(t.fetch, retryOnThrottle);
274
- const ledgered = httpFetch && ledgeredFetch(httpFetch, ledger);
302
+ const httpFetch = retried(t.fetch);
303
+ const ledgered = httpFetch && ledgeredFetch(httpFetch, ledger, replay);
275
304
  const fetch = ledgered ?? httpFetch;
276
305
  return watched(new httpMod.StreamableHTTPClientTransport(transportUrl(t.url, 'mcpClient'), {
277
306
  ...(t.headers && { requestInit: { headers: { ...t.headers } } }),
@@ -306,8 +335,26 @@ function loadHttpModule(transport) {
306
335
  }));
307
336
  }
308
337
  }
338
+ /**
339
+ * Dev mode, once per client and name: a replay entry for a tool the server does
340
+ * not list applies to nothing — a misspelled name would leave a tool that makes
341
+ * changes outside the side-effect guard, so it is named.
342
+ */
343
+ function noteUnlisted(replay, listed, server, noted) {
344
+ if (replay.tools.size === 0 || !isDevMode())
345
+ return;
346
+ const names = new Set(listed.map((tool) => tool.name));
347
+ for (const tool of replay.tools.keys()) {
348
+ if (names.has(tool) || noted.has(tool))
349
+ continue;
350
+ noted.add(tool);
351
+ // eslint-disable-next-line no-console
352
+ console.warn(`[agentfootprint] mcpClient[${server}]: \`replay.tools\` names ${JSON.stringify(tool)}, ` +
353
+ "which the server does not list, so the entry applies to nothing. Check the name against the server's tool list.");
354
+ }
355
+ }
309
356
  // ─── Tool wrapping ─────────────────────────────────────────────────
310
- function wrapMcpTool(serverName, connection, mcp, signal, resultMode, ledger) {
357
+ function wrapMcpTool(serverName, connection, mcp, signal, resultMode, ledger, strict = false) {
311
358
  const tool = {
312
359
  schema: {
313
360
  name: mcp.name,
@@ -349,20 +396,40 @@ function wrapMcpTool(serverName, connection, mcp, signal, resultMode, ledger) {
349
396
  ...(ctx?.time !== undefined && { _meta: callMetaOf(ctx.time) }),
350
397
  };
351
398
  // The call's lifetime (`callLifetime.ts`): its context's signal and the
352
- // client's cancel the SDK request while it runs; a call the agent
353
- // dispatched issues a ticket keyed by THIS params object — the one the
354
- // SDK hands the transport — so the retry series that sends it files its
355
- // attempts into the call's run; and however the call settles, a series
356
- // still sending is cut, inside the call. Nothing is added to the request.
399
+ // client's cancel the SDK request while it runs; the call puts a private
400
+ // marker in its params' `_meta` (`call.params`), which ties the request
401
+ // the SDK sends to this call — through any copy the SDK makes — so the
402
+ // retry series that sends it files its attempts into the call's run; and
403
+ // however the call settles, a series still sending is cut, inside the
404
+ // call. The transport takes the marker out: the server receives the
405
+ // request it always did.
406
+ //
407
+ // How it settles is its verdict: `completed` when the server answered and
408
+ // not with an error (a result it then cannot decode still completed).
409
+ // Under 'app-authorized', a call that genuinely lacked an answer somewhere
410
+ // and does not complete fails as "may have run"; a received refusal or
411
+ // error is delivered as it came (`callLifetime.ts`). That contract needs
412
+ // each request matched to its call and each answer seen: a connection
413
+ // that cannot establish both refuses the call here, before anything is
414
+ // sent (`replayUnavailable.ts`).
415
+ const unavailable = strict ? unavailableBeforeSending(ledger) : undefined;
416
+ if (unavailable !== undefined) {
417
+ throw new McpReplayUnavailableError(unavailable, serverName, mcp.name);
418
+ }
357
419
  const call = openCall(params, ctx, signal, ledger, serverName);
420
+ let verdict = 'failed';
358
421
  try {
359
422
  const result = call.signal
360
- ? await connection.callTool(params, undefined, { signal: call.signal })
361
- : await connection.callTool(params);
423
+ ? await connection.callTool(call.params, undefined, { signal: call.signal })
424
+ : await connection.callTool(call.params);
425
+ verdict = isToolError(result) ? 'tool-error' : 'completed';
362
426
  return readToolResult(result, mcp.name, serverName, resultMode);
363
427
  }
428
+ catch (error) {
429
+ throw call.failed(error, verdict);
430
+ }
364
431
  finally {
365
- call.close();
432
+ call.close(verdict);
366
433
  }
367
434
  },
368
435
  };
@@ -1 +1 @@
1
- {"version":3,"file":"mcpClient.js","sourceRoot":"","sources":["../../../src/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAaH,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC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AAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;KACF,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,283 @@
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 11.x default, today's behaviour by name: a 429 is
43
+ * repeated for every tool, on the ASSUMPTION that the server refused it
44
+ * before running it. Each such repeat records that assumption; the
45
+ * attempt's effect stays `unknown`, and the caller sees the error it
46
+ * always did.
47
+ * 'app-authorized' — opt-in now, the default in the next major: a 429 or a
48
+ * network failure is repeated only when the app's entry for the tool
49
+ * names it. What the caller sees follows footprintjs's law
50
+ * (`RequestReplay` · `uncertain`, `callLifetime.ts`): a received refusal
51
+ * or error keeps the server's error as it came, its effect still
52
+ * `unknown`; a call that genuinely lacked an answer somewhere — an
53
+ * attempt with no response, or a request accepted over HTTP whose
54
+ * JSON-RPC answer never came — and then fails, fails with
55
+ * `UnknownEffectError`, its final error the cause. That needs each
56
+ * request matched to its call and each answer seen; a connection that
57
+ * cannot give both refuses the call before it is sent
58
+ * (`replayUnavailable.ts`), so the contract never silently weakens.
59
+ *
60
+ * Under both, the adapter the app chose retries its own refusal within the
61
+ * budget — AgentCore's session-busy reply — as the ADAPTER's policy, on an
62
+ * assumption it records the same way (`permission: { by: 'adapter', assumes }`),
63
+ * never as evidence. And THE SIDE-EFFECT GUARD holds: a tool the app declares
64
+ * as making changes is never repeated automatically unless the server is
65
+ * declared to deduplicate by an idempotency key the call carries —
66
+ * footprintjs's law, a retry of an effect without a key can apply it twice. A
67
+ * key protects only when the server uses it; the library cannot check that.
68
+ *
69
+ * The protocol's own requests (`initialize`, `tools/list`, notifications) run
70
+ * no tool. The declaration does not govern them, and a 429 on one is asked
71
+ * again under both policies, as it always was. They file no record.
72
+ */
73
+ import type { ToolRequestEffect, ToolRequestPermission, ToolRequestReason, ToolRequestReplayKind } from '../events/payloads.js';
74
+ /**
75
+ * Which rule decides whether a tool call is sent again after a refusal or a
76
+ * failure. `'compatibility'` is the default in 11.x; `'app-authorized'` becomes
77
+ * the default in the next major.
78
+ */
79
+ export type McpReplayPolicy = 'app-authorized' | 'compatibility';
80
+ /**
81
+ * A failure kind the app may declare a tool repeatable on: HTTP 429
82
+ * (`'throttle'`), or a request that failed in transport without an answer
83
+ * (`'network'`, footprintjs's category: a dropped or refused connection, or a
84
+ * timeout raised below the retry series). Either may have run on the server, so
85
+ * a repeat after it leaves the call's effect `unknown`.
86
+ */
87
+ export type McpReplayKind = ToolRequestReplayKind;
88
+ /** One tool's entry in {@link McpReplayOptions.tools}. */
89
+ export interface McpReplayTool {
90
+ /**
91
+ * The failure kinds this tool may be sent again on. Default: none. Under
92
+ * `'compatibility'` a 429 is repeated without it, recorded as an assumption;
93
+ * under `'app-authorized'` only what is named here is repeated.
94
+ */
95
+ readonly on?: readonly McpReplayKind[];
96
+ /**
97
+ * `true` — this tool makes changes. It is then never sent again
98
+ * automatically, under either policy, unless the server is declared to
99
+ * deduplicate (`deduplicates`) and the call carries the key.
100
+ */
101
+ readonly changes?: boolean;
102
+ }
103
+ /**
104
+ * How the server deduplicates a tool call: by an idempotency key the call
105
+ * carries in the named argument. Declare it only when the server does; a key
106
+ * protects only when the server uses it.
107
+ */
108
+ export interface McpReplayDeduplication {
109
+ /**
110
+ * The argument that carries the key — present as a non-empty string in the
111
+ * call for a repeat to be allowed. Set it in your code (a `toolMiddleware`
112
+ * that writes it from the call), never from what the model wrote: a key the
113
+ * model reuses for a different operation makes the server drop that one.
114
+ */
115
+ readonly argument: string;
116
+ }
117
+ /**
118
+ * The app's replay declaration for one MCP server — its client. Read once when
119
+ * the client is built; a field it does not know is refused there, so a
120
+ * misspelled `changes` cannot quietly switch the side-effect guard off.
121
+ */
122
+ export interface McpReplayOptions {
123
+ /** Default `'compatibility'` in 11.x. */
124
+ readonly policy?: McpReplayPolicy;
125
+ /** The tools of this server, by the name the server lists them under. */
126
+ readonly tools?: Readonly<Record<string, McpReplayTool>>;
127
+ /** The server deduplicates by an idempotency key the call carries. */
128
+ readonly deduplicates?: McpReplayDeduplication;
129
+ }
130
+ interface ToolEntry {
131
+ readonly on: ReadonlySet<McpReplayKind>;
132
+ readonly changes: boolean;
133
+ }
134
+ /** @internal A declaration, read and checked once. */
135
+ export interface ReplayDeclaration {
136
+ readonly policy: McpReplayPolicy;
137
+ readonly tools: ReadonlyMap<string, ToolEntry>;
138
+ /** The argument the server deduplicates by, when it is declared to. */
139
+ readonly keyArgument?: string;
140
+ }
141
+ /** @internal No declaration: the compatibility policy, no tool named. */
142
+ export declare const COMPATIBILITY: ReplayDeclaration;
143
+ /**
144
+ * @internal `options` read as a declaration — `undefined` is the compatibility
145
+ * policy with nothing named.
146
+ *
147
+ * @throws TypeError naming the field, never echoing a value, for anything the
148
+ * rule cannot mean: an unknown field, a policy or kind it does not know, an
149
+ * argument name that is not one.
150
+ */
151
+ export declare function replayDeclarationOf(options: unknown, where: string): ReplayDeclaration;
152
+ /**
153
+ * @internal Whether the declaration needs a retry series even with the 429
154
+ * rule off (`retryOnThrottle: false`): a tool declared repeatable on
155
+ * `'network'`, or the `'app-authorized'` policy — its record and its "may have
156
+ * run" rest on the series.
157
+ */
158
+ export declare function needsSeries(declaration: ReplayDeclaration): boolean;
159
+ /**
160
+ * @internal One request, as the permission rule needs it: the protocol's own,
161
+ * or a `tools/call` — its tool when the body names one, and whether its
162
+ * arguments carry the key the server deduplicates by.
163
+ */
164
+ export type ReplayTarget = {
165
+ readonly kind: 'protocol';
166
+ } | {
167
+ readonly kind: 'tool';
168
+ readonly name?: string;
169
+ readonly keyCarried: boolean;
170
+ };
171
+ /**
172
+ * @internal `body` — the request exactly as it will be sent — read as a
173
+ * target. A declaration that names nothing under `'compatibility'` decides the
174
+ * same for every request, so its bodies are never parsed.
175
+ */
176
+ export declare function replayTargetOf(body: unknown, declaration: ReplayDeclaration): ReplayTarget;
177
+ /** @internal A failure the series met, as the permission rule reads it. */
178
+ export interface MetFailure {
179
+ /** A refusal a rule recognised (`throttle`, `session-busy`), or a request that failed in transport. */
180
+ readonly kind: 'throttle' | 'session-busy' | 'network';
181
+ /**
182
+ * What the adapter that recognised this refusal assumes in retrying it, as
183
+ * its own policy — set on its rule. Never evidence of the attempt's effect.
184
+ */
185
+ readonly assumes?: 'refused-before-execution';
186
+ }
187
+ /** @internal Why the series did not ask again, by the rule. */
188
+ export type ReplayDeclined = Extract<ToolRequestReason, 'not-retryable' | 'not-permitted' | 'changes-without-key'>;
189
+ /**
190
+ * @internal The rule's answer: ask again, with what allowed it — absent for a
191
+ * protocol request, which has no record — or not, and why.
192
+ */
193
+ export type ReplayDecision = {
194
+ readonly repeat: true;
195
+ readonly permission?: ToolRequestPermission;
196
+ } | {
197
+ readonly repeat: false;
198
+ readonly declined: ReplayDeclined;
199
+ };
200
+ /** @internal A thrown failure the rule can read: footprintjs's `network` category, or nothing. */
201
+ export declare function thrownFailure(error: unknown): MetFailure | undefined;
202
+ /**
203
+ * @internal THE rule: may the series send `target` again after `failure`?
204
+ * Asked before every repeat; the budget is asked after it.
205
+ */
206
+ export declare function permit(declaration: ReplayDeclaration, target: ReplayTarget, failure: MetFailure): ReplayDecision;
207
+ /**
208
+ * @internal What is known of a whole series' effect, one attempt at a time.
209
+ * Uncertainty survives: once any attempt is `unknown`, the series is, whatever
210
+ * later attempts show — a proven refusal does not resolve it, and a success
211
+ * does not prove the operation happened only once. Evidence that something ran
212
+ * (`applied`) is never erased by a later failure.
213
+ */
214
+ export declare class SeriesKnowledge {
215
+ private unknown;
216
+ private applied;
217
+ note(effect: ToolRequestEffect): void;
218
+ get effect(): ToolRequestEffect;
219
+ }
220
+ /** @internal How `callTool` settled, as the call reads it. */
221
+ export type CallVerdict = 'completed' | 'tool-error' | 'failed';
222
+ /**
223
+ * @internal One `tools/call` request's replay facts, shared by the series that
224
+ * sends it, the ledger that watches its answer, and the call that waits for it
225
+ * — the ledger hands all three the same object (`requestLedger.ts`).
226
+ *
227
+ * TWO LAYERS, KEPT APART. The series sees HTTP: whether an attempt got a
228
+ * response at all, and the status of the one it delivered. A response is not
229
+ * the MCP call's answer — a 202, or a stream, can be accepted and never carry
230
+ * it — so the ledger watches the connection's incoming messages for the
231
+ * JSON-RPC response to THIS request's id. And "its effect is unknown" is not
232
+ * "it lacked an answer": a received 429 or error is an answer whose effect is
233
+ * unknown.
234
+ *
235
+ * Each fact is written once, by its owner: the series (what it sent, whether an
236
+ * attempt lacked any response, what it delivered, the policy), the ledger (the
237
+ * logical answer), the call (how it settled).
238
+ */
239
+ export declare class RequestReplay {
240
+ readonly id: string | number;
241
+ private requests;
242
+ private appAuthorized;
243
+ private attemptUnanswered;
244
+ private delivered;
245
+ private logical;
246
+ private settled;
247
+ private failedAsMayHaveRun;
248
+ /**
249
+ * @param id the request's JSON-RPC id, how its answer is found.
250
+ * @param watched whether the connection's incoming messages are observed —
251
+ * without that, the logical layer is unknown and never decides anything.
252
+ */
253
+ constructor(id: string | number, watched: boolean);
254
+ /** The series sent the request once more. */
255
+ sentOne(): void;
256
+ /** The series runs under the `'app-authorized'` policy. */
257
+ appAuthorizedPolicy(): void;
258
+ /**
259
+ * The series: an attempt genuinely lacked an answer — no response arrived
260
+ * (a lost connection, a timeout, a cut). A received refusal is never this.
261
+ */
262
+ noAnswer(): void;
263
+ /** The series handed the MCP SDK a response with this status. */
264
+ deliveredStatus(status: number): void;
265
+ /** The ledger: the JSON-RPC response to this request's id arrived. */
266
+ answered(): void;
267
+ /** The call settled; `mayHaveRun` when it failed as "may have run". The first word stands. */
268
+ settle(verdict: CallVerdict, mayHaveRun: boolean): void;
269
+ get sent(): number;
270
+ /**
271
+ * Under `'app-authorized'`, a call that does not complete fails as "may have
272
+ * run" when the call genuinely lacked an answer somewhere: an attempt got no
273
+ * response, or the HTTP layer accepted the request (a 2xx) and the JSON-RPC
274
+ * response never came. A chain of received refusals and errors is an answer
275
+ * throughout: it keeps the server's error.
276
+ */
277
+ get uncertain(): boolean;
278
+ /** The HTTP layer took the request (2xx), and the logical answer never arrived. */
279
+ private get acceptedWithoutAnswer();
280
+ get verdict(): CallVerdict | undefined;
281
+ get mayHaveRun(): boolean;
282
+ }
283
+ export {};