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.
- package/CAPABILITIES.md +3 -1
- package/dist/adapters/code/agentcore.js +295 -214
- package/dist/adapters/code/agentcore.js.map +1 -1
- package/dist/adapters/code/agentcoreClient.js +178 -0
- package/dist/adapters/code/agentcoreClient.js.map +1 -0
- package/dist/adapters/code/agentcoreWire.js +348 -0
- package/dist/adapters/code/agentcoreWire.js.map +1 -0
- package/dist/adapters/code/fileName.js +100 -0
- package/dist/adapters/code/fileName.js.map +1 -0
- package/dist/adapters/code/local.js +529 -183
- package/dist/adapters/code/local.js.map +1 -1
- package/dist/adapters/code/output.js +140 -0
- package/dist/adapters/code/output.js.map +1 -0
- package/dist/adapters/mcp/agentcoreRuntime/invoke.js +7 -6
- package/dist/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
- package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js +36 -2
- package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -1
- package/dist/adapters/mcp/agentcoreRuntime/transport.js +3 -1
- package/dist/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
- package/dist/core/codeRunnerTool.js +52 -7
- package/dist/core/codeRunnerTool.js.map +1 -1
- package/dist/doors/providers.js.map +1 -1
- package/dist/esm/adapters/code/agentcore.d.ts +65 -68
- package/dist/esm/adapters/code/agentcore.js +293 -212
- package/dist/esm/adapters/code/agentcore.js.map +1 -1
- package/dist/esm/adapters/code/agentcoreClient.d.ts +193 -0
- package/dist/esm/adapters/code/agentcoreClient.js +173 -0
- package/dist/esm/adapters/code/agentcoreClient.js.map +1 -0
- package/dist/esm/adapters/code/agentcoreWire.d.ts +119 -0
- package/dist/esm/adapters/code/agentcoreWire.js +334 -0
- package/dist/esm/adapters/code/agentcoreWire.js.map +1 -0
- package/dist/esm/adapters/code/fileName.d.ts +43 -0
- package/dist/esm/adapters/code/fileName.js +96 -0
- package/dist/esm/adapters/code/fileName.js.map +1 -0
- package/dist/esm/adapters/code/local.d.ts +91 -12
- package/dist/esm/adapters/code/local.js +528 -182
- package/dist/esm/adapters/code/local.js.map +1 -1
- package/dist/esm/adapters/code/output.d.ts +70 -0
- package/dist/esm/adapters/code/output.js +129 -0
- package/dist/esm/adapters/code/output.js.map +1 -0
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +7 -6
- package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js +35 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -1
- package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +4 -2
- package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -1
- package/dist/esm/core/codeRunnerTool.d.ts +15 -3
- package/dist/esm/core/codeRunnerTool.js +52 -7
- package/dist/esm/core/codeRunnerTool.js.map +1 -1
- package/dist/esm/doors/providers.d.ts +1 -1
- package/dist/esm/doors/providers.js.map +1 -1
- package/dist/esm/events/payloads.d.ts +144 -29
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mcp/callLifetime.d.ts +57 -14
- package/dist/esm/mcp/callLifetime.js +67 -19
- package/dist/esm/mcp/callLifetime.js.map +1 -1
- package/dist/esm/mcp/callMarker.d.ts +43 -0
- package/dist/esm/mcp/callMarker.js +69 -0
- package/dist/esm/mcp/callMarker.js.map +1 -0
- package/dist/esm/mcp/connectionRefusals.js +7 -0
- package/dist/esm/mcp/connectionRefusals.js.map +1 -1
- package/dist/esm/mcp/index.d.ts +2 -0
- package/dist/esm/mcp/index.js +3 -0
- package/dist/esm/mcp/index.js.map +1 -1
- package/dist/esm/mcp/mcpClient.js +93 -26
- package/dist/esm/mcp/mcpClient.js.map +1 -1
- package/dist/esm/mcp/replay.d.ts +291 -0
- package/dist/esm/mcp/replay.js +405 -0
- package/dist/esm/mcp/replay.js.map +1 -0
- package/dist/esm/mcp/replayUnavailable.d.ts +68 -0
- package/dist/esm/mcp/replayUnavailable.js +87 -0
- package/dist/esm/mcp/replayUnavailable.js.map +1 -0
- package/dist/esm/mcp/requestLedger.d.ts +115 -32
- package/dist/esm/mcp/requestLedger.js +193 -52
- package/dist/esm/mcp/requestLedger.js.map +1 -1
- package/dist/esm/mcp/seriesEvidence.d.ts +73 -15
- package/dist/esm/mcp/seriesEvidence.js +114 -21
- package/dist/esm/mcp/seriesEvidence.js.map +1 -1
- package/dist/esm/mcp/throttleRetry.d.ts +86 -42
- package/dist/esm/mcp/throttleRetry.js +158 -50
- package/dist/esm/mcp/throttleRetry.js.map +1 -1
- package/dist/esm/mcp/toolResult.d.ts +6 -0
- package/dist/esm/mcp/toolResult.js +15 -0
- package/dist/esm/mcp/toolResult.js.map +1 -1
- package/dist/esm/mcp/types.d.ts +73 -8
- package/dist/esm/provider-contract/codeSandbox.d.ts +89 -0
- package/dist/esm/provider-contract/codeSandbox.js +119 -0
- package/dist/esm/provider-contract/codeSandbox.js.map +1 -0
- package/dist/esm/provider-contract/sessionExpired.d.ts +31 -0
- package/dist/esm/provider-contract/sessionExpired.js +40 -0
- package/dist/esm/provider-contract/sessionExpired.js.map +1 -0
- package/dist/esm/provider-contract/types.d.ts +166 -17
- package/dist/esm/provider-contract/types.js +9 -0
- package/dist/esm/provider-contract/types.js.map +1 -1
- package/dist/esm/redaction/knownStrings.js +16 -0
- package/dist/esm/redaction/knownStrings.js.map +1 -1
- package/dist/esm/tool-providers/index.d.ts +2 -2
- package/dist/esm/tool-providers/index.js +4 -0
- package/dist/esm/tool-providers/index.js.map +1 -1
- package/dist/esm/tools/requestEvidence.js +60 -0
- package/dist/esm/tools/requestEvidence.js.map +1 -1
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/mcp/callLifetime.js +66 -18
- package/dist/mcp/callLifetime.js.map +1 -1
- package/dist/mcp/callMarker.js +74 -0
- package/dist/mcp/callMarker.js.map +1 -0
- package/dist/mcp/connectionRefusals.js +7 -0
- package/dist/mcp/connectionRefusals.js.map +1 -1
- package/dist/mcp/index.js +5 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mcpClient.js +91 -24
- package/dist/mcp/mcpClient.js.map +1 -1
- package/dist/mcp/replay.js +415 -0
- package/dist/mcp/replay.js.map +1 -0
- package/dist/mcp/replayUnavailable.js +92 -0
- package/dist/mcp/replayUnavailable.js.map +1 -0
- package/dist/mcp/requestLedger.js +193 -52
- package/dist/mcp/requestLedger.js.map +1 -1
- package/dist/mcp/seriesEvidence.js +116 -22
- package/dist/mcp/seriesEvidence.js.map +1 -1
- package/dist/mcp/throttleRetry.js +160 -51
- package/dist/mcp/throttleRetry.js.map +1 -1
- package/dist/mcp/toolResult.js +17 -1
- package/dist/mcp/toolResult.js.map +1 -1
- package/dist/provider-contract/codeSandbox.js +125 -0
- package/dist/provider-contract/codeSandbox.js.map +1 -0
- package/dist/provider-contract/sessionExpired.js +44 -0
- package/dist/provider-contract/sessionExpired.js.map +1 -0
- package/dist/provider-contract/types.js +12 -1
- package/dist/provider-contract/types.js.map +1 -1
- package/dist/redaction/knownStrings.js +16 -0
- package/dist/redaction/knownStrings.js.map +1 -1
- package/dist/tool-providers/index.js +5 -1
- package/dist/tool-providers/index.js.map +1 -1
- package/dist/tools/requestEvidence.js +60 -0
- package/dist/tools/requestEvidence.js.map +1 -1
- package/dist/types/adapters/code/agentcore.d.ts +65 -68
- package/dist/types/adapters/code/agentcore.d.ts.map +1 -1
- package/dist/types/adapters/code/agentcoreClient.d.ts +194 -0
- package/dist/types/adapters/code/agentcoreClient.d.ts.map +1 -0
- package/dist/types/adapters/code/agentcoreWire.d.ts +120 -0
- package/dist/types/adapters/code/agentcoreWire.d.ts.map +1 -0
- package/dist/types/adapters/code/fileName.d.ts +44 -0
- package/dist/types/adapters/code/fileName.d.ts.map +1 -0
- package/dist/types/adapters/code/local.d.ts +91 -12
- package/dist/types/adapters/code/local.d.ts.map +1 -1
- package/dist/types/adapters/code/output.d.ts +71 -0
- package/dist/types/adapters/code/output.d.ts.map +1 -0
- package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +7 -6
- package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +32 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts.map +1 -1
- package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -1
- package/dist/types/core/codeRunnerTool.d.ts +15 -3
- package/dist/types/core/codeRunnerTool.d.ts.map +1 -1
- package/dist/types/doors/providers.d.ts +1 -1
- package/dist/types/doors/providers.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +144 -29
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mcp/callLifetime.d.ts +57 -14
- package/dist/types/mcp/callLifetime.d.ts.map +1 -1
- package/dist/types/mcp/callMarker.d.ts +44 -0
- package/dist/types/mcp/callMarker.d.ts.map +1 -0
- package/dist/types/mcp/index.d.ts +2 -0
- package/dist/types/mcp/index.d.ts.map +1 -1
- package/dist/types/mcp/mcpClient.d.ts.map +1 -1
- package/dist/types/mcp/replay.d.ts +292 -0
- package/dist/types/mcp/replay.d.ts.map +1 -0
- package/dist/types/mcp/replayUnavailable.d.ts +69 -0
- package/dist/types/mcp/replayUnavailable.d.ts.map +1 -0
- package/dist/types/mcp/requestLedger.d.ts +115 -32
- package/dist/types/mcp/requestLedger.d.ts.map +1 -1
- package/dist/types/mcp/seriesEvidence.d.ts +73 -15
- package/dist/types/mcp/seriesEvidence.d.ts.map +1 -1
- package/dist/types/mcp/throttleRetry.d.ts +86 -42
- package/dist/types/mcp/throttleRetry.d.ts.map +1 -1
- package/dist/types/mcp/toolResult.d.ts +6 -0
- package/dist/types/mcp/toolResult.d.ts.map +1 -1
- package/dist/types/mcp/types.d.ts +73 -8
- package/dist/types/mcp/types.d.ts.map +1 -1
- package/dist/types/provider-contract/codeSandbox.d.ts +90 -0
- package/dist/types/provider-contract/codeSandbox.d.ts.map +1 -0
- package/dist/types/provider-contract/sessionExpired.d.ts +32 -0
- package/dist/types/provider-contract/sessionExpired.d.ts.map +1 -0
- package/dist/types/provider-contract/types.d.ts +166 -17
- package/dist/types/provider-contract/types.d.ts.map +1 -1
- package/dist/types/redaction/knownStrings.d.ts.map +1 -1
- package/dist/types/tool-providers/index.d.ts +2 -2
- package/dist/types/tool-providers/index.d.ts.map +1 -1
- package/dist/types/tools/requestEvidence.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -15,36 +15,79 @@
|
|
|
15
15
|
* the call. The link is undone when the call settles: the SDK keeps its
|
|
16
16
|
* abort listener on the signal it was given, and a link that outlived the
|
|
17
17
|
* call would cancel a request that had already finished.
|
|
18
|
-
* 2. ITS
|
|
19
|
-
* the
|
|
18
|
+
* 2. ITS MARKER is issued when the connection has a ledger, with its ticket
|
|
19
|
+
* when the call carries the run's evidence port: a library-private string
|
|
20
|
+
* in the request's `_meta` (`callMarker.ts`), which ties the request to
|
|
21
|
+
* the call even when the SDK copies the params, and which the transport
|
|
22
|
+
* takes out before anything is sent.
|
|
20
23
|
* 3. ITS SETTLING ENDS ITS SERIES. However `callTool` settles — answered,
|
|
21
24
|
* failed, or given up by the SDK (its own timeout) — a retry series still
|
|
22
25
|
* sending the request is cut there and then, inside the call: it files
|
|
23
26
|
* `cancelled` before the call's result is read, and sends nothing more.
|
|
27
|
+
* 4. ITS VERDICT REACHES ITS RECORD. A series that has ended waits for the
|
|
28
|
+
* call to settle before it files, because only the call can say whether
|
|
29
|
+
* the answer completed — a 200 can carry a tool error. The call leaves its
|
|
30
|
+
* verdict in the request's shared replay facts (`replay.ts` ·
|
|
31
|
+
* `RequestReplay`) before it settles the series' wait.
|
|
32
|
+
* 5. "MAY HAVE RUN" IS RAISED HERE — footprintjs's law, under the
|
|
33
|
+
* `'app-authorized'` policy (`replay.ts` · `RequestReplay`, its
|
|
34
|
+
* `uncertain`). A received refusal or error is preserved: a 429, a 503,
|
|
35
|
+
* a JSON-RPC or tool error — or a chain in which every attempt received
|
|
36
|
+
* one — keeps the server's error as it came, its effect still `unknown`.
|
|
37
|
+
* A call that genuinely lacked an answer somewhere — an attempt with no
|
|
38
|
+
* response at all, or a request the HTTP layer accepted whose JSON-RPC
|
|
39
|
+
* answer never came — and then fails, fails with footprintjs's
|
|
40
|
+
* `UnknownEffectError`, its final error (a later refusal's, or the
|
|
41
|
+
* timeout) as the `cause`: that error alone would read as "failed, try
|
|
42
|
+
* again". A call that completes returns normally. Under `'compatibility'`
|
|
43
|
+
* the caller sees the error it always did; the record still says the
|
|
44
|
+
* effect is unknown. A cancellation never raises it: a call its caller
|
|
45
|
+
* cancelled ends with the caller's reason, as it always did.
|
|
24
46
|
*
|
|
25
|
-
* In dev mode, a ticket that no request was
|
|
26
|
-
* settled, when a `tools/call` request DID go out, is named once per
|
|
27
|
-
* the params, so the call's
|
|
28
|
-
*
|
|
29
|
-
* `notifications/cancelled`).
|
|
47
|
+
* In dev mode, a ticket that no request was matched to by the time the call
|
|
48
|
+
* settled, when a `tools/call` request DID go out, is named once per
|
|
49
|
+
* connection: the SDK rebuilt the params without the marker, so the call's
|
|
50
|
+
* attempts could not be matched to it. Its cancellation still reached the
|
|
51
|
+
* request (1, and the ledger's own watch on `notifications/cancelled`). Under
|
|
52
|
+
* `'app-authorized'` such a request is never sent at all
|
|
53
|
+
* (`replayUnavailable.ts`).
|
|
30
54
|
*/
|
|
55
|
+
import type { CallVerdict } from './replay.js';
|
|
31
56
|
import type { RequestLedger } from './requestLedger.js';
|
|
32
|
-
/** A call that has been opened: the signal its SDK request runs under, and how to close it. */
|
|
33
|
-
export interface OpenCall {
|
|
57
|
+
/** A call that has been opened: the params to send, the signal its SDK request runs under, and how to close it. */
|
|
58
|
+
export interface OpenCall<P extends object = object> {
|
|
59
|
+
/**
|
|
60
|
+
* What to hand the SDK: the call's params, with its private marker in
|
|
61
|
+
* `_meta` when a ledger watches the connection (`callMarker.ts`). The
|
|
62
|
+
* transport takes the marker out again: the server never sees it.
|
|
63
|
+
*/
|
|
64
|
+
readonly params: P;
|
|
34
65
|
/** What cancels the SDK request — absent when nothing can. */
|
|
35
66
|
readonly signal?: AbortSignal;
|
|
36
|
-
/**
|
|
37
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The call failed with `error` (`verdict` says how far it got): the error it
|
|
69
|
+
* fails with — `error` itself, or, under `'app-authorized'`, footprintjs's
|
|
70
|
+
* `UnknownEffectError` with `error` as its `cause` when the call genuinely
|
|
71
|
+
* lacked an answer somewhere (see 5 above).
|
|
72
|
+
*/
|
|
73
|
+
failed(error: unknown, verdict: CallVerdict): unknown;
|
|
74
|
+
/**
|
|
75
|
+
* The call settled with `verdict`: leave it for the record, settle it in the
|
|
76
|
+
* ledger (its answer is no longer awaited), undo the link, cut a series
|
|
77
|
+
* still sending, check its request was matched.
|
|
78
|
+
*/
|
|
79
|
+
close(verdict: CallVerdict): void;
|
|
38
80
|
}
|
|
39
81
|
/**
|
|
40
82
|
* Open one call.
|
|
41
83
|
*
|
|
42
|
-
* @param params the request's params
|
|
43
|
-
* the
|
|
84
|
+
* @param params the request's params. The call sends them marked
|
|
85
|
+
* (`OpenCall.params`): the marker, not the object, is how the ledger knows
|
|
86
|
+
* the request is this call's — it survives an SDK that copies the params.
|
|
44
87
|
* @param ctx the call's context: its signal, and the run's evidence port if any.
|
|
45
88
|
* @param clientSignal the client's own `signal` (`McpClientOptions.signal`).
|
|
46
89
|
* @param ledger the connection's ledger, when the library built its transport.
|
|
47
90
|
* @param server the client's name, for the dev-mode note.
|
|
48
91
|
*/
|
|
49
|
-
export declare function openCall(params:
|
|
92
|
+
export declare function openCall<P extends object>(params: P, ctx: unknown, clientSignal: AbortSignal | undefined, ledger: RequestLedger | undefined, server: string): OpenCall<P>;
|
|
50
93
|
//# sourceMappingURL=callLifetime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callLifetime.d.ts","sourceRoot":"","sources":["../../../src/mcp/callLifetime.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"callLifetime.d.ts","sourceRoot":"","sources":["../../../src/mcp/callLifetime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,oBAAoB,CAAC;AAEvE,mHAAmH;AACnH,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACjD;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;IACtD;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvC,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,OAAO,EACZ,YAAY,EAAE,WAAW,GAAG,SAAS,EACrC,MAAM,EAAE,aAAa,GAAG,SAAS,EACjC,MAAM,EAAE,MAAM,GACb,QAAQ,CAAC,CAAC,CAAC,CA0Cb"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* callMarker — a library-private marker that ties one MCP tool call to the one
|
|
3
|
+
* request the SDK sends for it, whatever the SDK copies on the way.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: mark at the call, take at the transport.
|
|
6
|
+
* Role: The correlation hop of the request ledger (`requestLedger.ts`). The
|
|
7
|
+
* call puts its marker in the request's own `_meta` bag
|
|
8
|
+
* (`markParams`); the MCP SDK carries `_meta` through to the
|
|
9
|
+
* transport — the very object, or a copy of it (`structuredClone`, a
|
|
10
|
+
* spread) — and the ledger's watched `send` takes the marker out again
|
|
11
|
+
* (`takeMarker`) before the transport serializes the request. The
|
|
12
|
+
* server receives the bytes it always did: the marker never leaves the
|
|
13
|
+
* client.
|
|
14
|
+
*
|
|
15
|
+
* An object's identity does not survive a copy; a string inside it does. So an
|
|
16
|
+
* SDK that copies the params still delivers the marker, and the request is
|
|
17
|
+
* matched to its call by the call's own word, never by guessing from content
|
|
18
|
+
* (two calls with the same arguments are the case content matching gets wrong).
|
|
19
|
+
* An SDK that rebuilds the params and drops `_meta` delivers nothing: the
|
|
20
|
+
* request then matches no call, and the ledger says so (`requestLedger.ts`).
|
|
21
|
+
*/
|
|
22
|
+
/** The `_meta` key the marker rides under. Never sent: `takeMarker` removes it. */
|
|
23
|
+
export declare const CALL_MARKER_KEY = "agentfootprint/call-ref";
|
|
24
|
+
/**
|
|
25
|
+
* `params` with `marker` added to its `_meta` bag: a new object, with every
|
|
26
|
+
* other key in its place; `params` itself is not changed. A `_meta` that was
|
|
27
|
+
* absent is added, after the other keys, so `takeMarker` can remove it whole.
|
|
28
|
+
*/
|
|
29
|
+
export declare function markParams<P extends object>(params: P, marker: string): P;
|
|
30
|
+
/** What `takeMarker` found: the marker, when the message carried one, and the message to send. */
|
|
31
|
+
export interface TakenMarker {
|
|
32
|
+
readonly marker?: string;
|
|
33
|
+
/** The message without the marker, or the message itself when it carried none. */
|
|
34
|
+
readonly message: unknown;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The marker a JSON-RPC message carries in `params._meta`, and the message
|
|
38
|
+
* without it. The message is never changed in place: the SDK's object stays
|
|
39
|
+
* the SDK's. Without the marker, the params are what they were before
|
|
40
|
+
* `markParams`: a `_meta` the marker alone filled is removed, and any other
|
|
41
|
+
* entry, the SDK's own included, keeps its place.
|
|
42
|
+
*/
|
|
43
|
+
export declare function takeMarker(message: unknown): TakenMarker;
|
|
44
|
+
//# sourceMappingURL=callMarker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callMarker.d.ts","sourceRoot":"","sources":["../../../src/mcp/callMarker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,mFAAmF;AACnF,eAAO,MAAM,eAAe,4BAA4B,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAGzE;AAED,kGAAkG;AAClG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAsBxD"}
|
|
@@ -11,5 +11,7 @@ export { mockMcpClient, type MockMcpClientOptions, type MockMcpTool } from './mo
|
|
|
11
11
|
export { gatewayTransport, GatewayAuthorizationRequiredError, type GatewayTransportOptions, } from './gatewayTransport.js';
|
|
12
12
|
export { retryingFetch } from './throttleRetry.js';
|
|
13
13
|
export type { RetryOnThrottle, ThrottleFetch, ThrottleRetryInfo, ThrottleRetryOptions, } from './throttleRetry.js';
|
|
14
|
+
export type { McpReplayDeduplication, McpReplayKind, McpReplayOptions, McpReplayPolicy, McpReplayTool, } from './replay.js';
|
|
15
|
+
export { McpReplayUnavailableError, type McpReplayUnavailableReason } from './replayUnavailable.js';
|
|
14
16
|
export type { McpCallToolResult, McpClient, McpClientOptions, McpConnection, McpConnectionOptions, McpSdk, McpGatewayTransport, McpHttpTransport, McpStdioTransport, McpTransport, McpSdkClient, McpServeOptions, McpServeHandle, McpServeTransport, McpHttpServeTransport, McpStdioServeTransport, McpSdkServer, } from './types.js';
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,EACL,gBAAgB,EAChB,iCAAiC,EACjC,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EACV,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,mBAAmB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChG,OAAO,EACL,gBAAgB,EAChB,iCAAiC,EACjC,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC;AAI/B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EACV,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAG5B,YAAY,EACV,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpG,YAAY,EACV,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACpB,MAAM,EACN,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,GACb,MAAM,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;
|
|
1
|
+
{"version":3,"file":"mcpClient.d.ts","sourceRoot":"","sources":["../../../src/mcp/mcpClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAKH,OAAO,KAAK,EACV,SAAS,EACT,gBAAgB,EAEhB,oBAAoB,EAKrB,MAAM,YAAY,CAAC;AAiCpB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,gBAAgB,GAAG,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CA8DjG"}
|
|
@@ -0,0 +1,292 @@
|
|
|
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 {};
|
|
292
|
+
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../../src/mcp/replay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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OAAO,KAAK,qBAAqB,GAGhC;IAED,IAAI,OAAO,IAAI,WAAW,GAAG,SAAS,CAErC;IAED,IAAI,UAAU,IAAI,OAAO,CAExB;CACF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* replayUnavailable — when a connection cannot keep the `'app-authorized'`
|
|
3
|
+
* contract, a tool call under it is refused BEFORE its request is sent, and the
|
|
4
|
+
* error says why.
|
|
5
|
+
*
|
|
6
|
+
* Pattern: a readiness rule + one typed refusal.
|
|
7
|
+
* Role: Under `'app-authorized'`, a call that genuinely lacked an answer and
|
|
8
|
+
* then fails is raised as "may have run" (`callLifetime.ts`). That
|
|
9
|
+
* rests on two things the library must ESTABLISH for every call,
|
|
10
|
+
* never assume:
|
|
11
|
+
*
|
|
12
|
+
* 1. ITS REQUEST IS MATCHED to the call, by the call's private marker, taken
|
|
13
|
+
* at the transport's `send` (`callMarker.ts`, `requestLedger.ts`).
|
|
14
|
+
* - `'requests-unwatched'`: the library cannot watch this transport's
|
|
15
|
+
* `send` at all (stdio, or a transport that refuses the wrap).
|
|
16
|
+
* - `'request-unmatched'`: a request reached `send` without its call's
|
|
17
|
+
* marker (an SDK that rebuilt the params and dropped `_meta`), so it
|
|
18
|
+
* cannot be tied to any call. Checked on every `tools/call`, so a match
|
|
19
|
+
* lost after the connection initialized is refused too.
|
|
20
|
+
* 2. ITS ANSWER IS SEEN: the JSON-RPC response to the request's id, read as
|
|
21
|
+
* it arrives. This is checked once the connection is initialized: the
|
|
22
|
+
* `initialize` answer must have passed the library's observer.
|
|
23
|
+
* - `'answers-unobserved'`: it did not. An MCP SDK whose `connect`
|
|
24
|
+
* REPLACES the transport's `onmessage` handler instead of keeping it
|
|
25
|
+
* leaves the observer out. SDK 1.10's `Protocol.connect` does, when
|
|
26
|
+
* run; reading the source finds the same through 1.13. The rule tests
|
|
27
|
+
* the behaviour, never a version number.
|
|
28
|
+
*
|
|
29
|
+
* Without either, a request the server accepted and never answered would reach
|
|
30
|
+
* the caller as a plain timeout: the strict contract, silently weakened. So the
|
|
31
|
+
* tool call is refused instead, and its request is not sent. Only tool
|
|
32
|
+
* invocations (`tools/call`) are refused: connecting (`initialize`) and listing
|
|
33
|
+
* tools ran before them and may already have reached the server (on `stdio`,
|
|
34
|
+
* the server process has started). The policy never falls back to
|
|
35
|
+
* `'compatibility'`, and a refused request is never sent again to recover its
|
|
36
|
+
* match. `'compatibility'` asks none of this and keeps its behaviour.
|
|
37
|
+
*/
|
|
38
|
+
/** Why a call under `'app-authorized'` was refused before it was sent. */
|
|
39
|
+
export type McpReplayUnavailableReason = 'requests-unwatched' | 'answers-unobserved' | 'request-unmatched';
|
|
40
|
+
/**
|
|
41
|
+
* A tool call refused before its request was sent, because this connection
|
|
42
|
+
* cannot keep the `'app-authorized'` replay contract (`reason`). The tool
|
|
43
|
+
* request never reached the server; connecting and listing tools may have.
|
|
44
|
+
* Names the server and the tool, never an argument.
|
|
45
|
+
*/
|
|
46
|
+
export declare class McpReplayUnavailableError extends Error {
|
|
47
|
+
readonly reason: McpReplayUnavailableReason;
|
|
48
|
+
readonly server: string;
|
|
49
|
+
readonly tool: string;
|
|
50
|
+
readonly code: "ERR_MCP_REPLAY_UNAVAILABLE";
|
|
51
|
+
/**
|
|
52
|
+
* This tool request was not sent: the refusal came before it left the
|
|
53
|
+
* client. It says nothing of the connection: `initialize` and `tools/list`
|
|
54
|
+
* ran before it, and on `stdio` the server process was started.
|
|
55
|
+
*/
|
|
56
|
+
readonly sent: false;
|
|
57
|
+
constructor(reason: McpReplayUnavailableReason, server: string, tool: string);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Why a connection cannot take a call under `'app-authorized'` before anything
|
|
61
|
+
* is sent — `undefined` when it can. `ledger` is the connection's request
|
|
62
|
+
* ledger: absent when the library could not watch the transport's requests.
|
|
63
|
+
* A request that reaches the transport without its marker is refused there, by
|
|
64
|
+
* the ledger (`'request-unmatched'`).
|
|
65
|
+
*/
|
|
66
|
+
export declare function unavailableBeforeSending(ledger: {
|
|
67
|
+
readonly answersObserved: boolean;
|
|
68
|
+
} | undefined): McpReplayUnavailableReason | undefined;
|
|
69
|
+
//# sourceMappingURL=replayUnavailable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replayUnavailable.d.ts","sourceRoot":"","sources":["../../../src/mcp/replayUnavailable.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,0BAA0B,GAClC,oBAAoB,GACpB,oBAAoB,GACpB,mBAAmB,CAAC;AAcxB;;;;;GAKG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAUhD,QAAQ,CAAC,MAAM,EAAE,0BAA0B;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAXvB,QAAQ,CAAC,IAAI,+BAAyC;IACtD;;;;OAIG;IACH,QAAQ,CAAC,IAAI,QAAkB;gBAGpB,MAAM,EAAE,0BAA0B,EAClC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;CASxB;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE;IAAE,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,GACxD,0BAA0B,GAAG,SAAS,CAIxC"}
|