stitchkit 0.91.1 → 0.92.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 (87) hide show
  1. package/CHANGELOG.md +104 -0
  2. package/dist/agent-runtime-coding-tools.js +3 -3
  3. package/dist/agent-runtime-harness.js +6 -6
  4. package/dist/agent-runtime-sandbox.js +3 -3
  5. package/dist/agent-runtime.js +9 -9
  6. package/dist/cli.d.ts +6 -3
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +371 -50
  9. package/dist/contract/define.d.ts +84 -2
  10. package/dist/contract/define.d.ts.map +1 -1
  11. package/dist/contract/index.d.ts +1 -1
  12. package/dist/contract/index.d.ts.map +1 -1
  13. package/dist/{index-qrbdq8jk.js → index-2c2bjw3s.js} +3 -3
  14. package/dist/{index-ya611vx3.js → index-7n145nbe.js} +183 -109
  15. package/dist/{index-bh70rk41.js → index-bx75zwt7.js} +3 -3
  16. package/dist/{index-709nh7z7.js → index-cxqhvq21.js} +2 -1
  17. package/dist/{index-13cjtmrw.js → index-e0znv5gn.js} +31 -8
  18. package/dist/{index-f4p4b8f6.js → index-e42wzzz5.js} +3 -3
  19. package/dist/{index-13e1k7v9.js → index-f477k430.js} +1 -1
  20. package/dist/{index-qjeyx5t2.js → index-fq77yfzc.js} +1 -1
  21. package/dist/{index-fenaekmk.js → index-h9etkkyk.js} +37 -27
  22. package/dist/{index-1qvdwnp2.js → index-mzvgxp0n.js} +2 -2
  23. package/dist/{index-zsqy3xfn.js → index-n0f51dfn.js} +4 -4
  24. package/dist/{index-bv7mytab.js → index-sr93cwf9.js} +1 -1
  25. package/dist/{index-vsbzgd7b.js → index-tmwcrptx.js} +1 -0
  26. package/dist/{index-b971qjes.js → index-v5573g1k.js} +1 -1
  27. package/dist/{index-8z9we758.js → index-vjpvjqpn.js} +1 -1
  28. package/dist/{index-bx6yq2m4.js → index-vk3kq9sb.js} +1 -1
  29. package/dist/{index-137jjs4v.js → index-yewwh1w4.js} +1 -1
  30. package/dist/{index-mqhjmadk.js → index-yn8remb1.js} +61 -57
  31. package/dist/index.js +4 -4
  32. package/dist/internal/atomic-file.d.ts +21 -0
  33. package/dist/internal/atomic-file.d.ts.map +1 -0
  34. package/dist/internal/errors.d.ts +10 -0
  35. package/dist/internal/errors.d.ts.map +1 -1
  36. package/dist/node.js +5 -5
  37. package/dist/observability/audit.d.ts +5 -1
  38. package/dist/observability/audit.d.ts.map +1 -1
  39. package/dist/observability/changes.d.ts.map +1 -1
  40. package/dist/observability/context.d.ts +27 -6
  41. package/dist/observability/context.d.ts.map +1 -1
  42. package/dist/observability/event.d.ts +34 -6
  43. package/dist/observability/event.d.ts.map +1 -1
  44. package/dist/observability/index.d.ts +2 -1
  45. package/dist/observability/index.d.ts.map +1 -1
  46. package/dist/observability/index.js +51 -7
  47. package/dist/observability/work.d.ts +55 -0
  48. package/dist/observability/work.d.ts.map +1 -0
  49. package/dist/remote.js +3 -3
  50. package/dist/server/context-contribution.d.ts.map +1 -1
  51. package/dist/server/index.js +7 -7
  52. package/dist/server/types.d.ts +20 -6
  53. package/dist/server/types.d.ts.map +1 -1
  54. package/dist/testing/surface-manifest.d.ts.map +1 -1
  55. package/dist/testing.js +9 -7
  56. package/dist/tool-invoker.js +6 -6
  57. package/dist/tools/cli-checkpoint.d.ts +24 -0
  58. package/dist/tools/cli-checkpoint.d.ts.map +1 -0
  59. package/dist/tools/cli-format.d.ts +10 -0
  60. package/dist/tools/cli-format.d.ts.map +1 -1
  61. package/dist/tools/cli-invoke.d.ts +118 -0
  62. package/dist/tools/cli-invoke.d.ts.map +1 -0
  63. package/dist/tools/cli-manifest.d.ts +6 -9
  64. package/dist/tools/cli-manifest.d.ts.map +1 -1
  65. package/dist/tools/cli-signature.d.ts +81 -0
  66. package/dist/tools/cli-signature.d.ts.map +1 -0
  67. package/dist/tools/cli-stream.d.ts +93 -0
  68. package/dist/tools/cli-stream.d.ts.map +1 -0
  69. package/dist/tools/cli-update.d.ts +62 -0
  70. package/dist/tools/cli-update.d.ts.map +1 -1
  71. package/dist/tools/cli.d.ts +4 -13
  72. package/dist/tools/cli.d.ts.map +1 -1
  73. package/dist/tools/connections/index.js +2 -2
  74. package/dist/tools/execute.d.ts +21 -0
  75. package/dist/tools/execute.d.ts.map +1 -1
  76. package/dist/tools/mcp-progress.d.ts +46 -0
  77. package/dist/tools/mcp-progress.d.ts.map +1 -0
  78. package/dist/tools/mcp-round-policy.d.ts +25 -1
  79. package/dist/tools/mcp-round-policy.d.ts.map +1 -1
  80. package/dist/tools/mcp-round.d.ts +20 -1
  81. package/dist/tools/mcp-round.d.ts.map +1 -1
  82. package/dist/tools/mcp-trace.d.ts +9 -1
  83. package/dist/tools/mcp-trace.d.ts.map +1 -1
  84. package/dist/tools/mount-wait.d.ts.map +1 -1
  85. package/dist/tools.js +160 -51
  86. package/llms-full.txt +358 -8
  87. package/package.json +1 -1
@@ -56,6 +56,11 @@ export declare const CliBuildManifestSchema: z.ZodObject<{
56
56
  size: z.ZodInt;
57
57
  sha256: z.ZodString;
58
58
  }, z.core.$strip>>;
59
+ signature: z.ZodOptional<z.ZodObject<{
60
+ algorithm: z.ZodLiteral<"ed25519">;
61
+ keyId: z.ZodString;
62
+ signature: z.ZodString;
63
+ }, z.core.$strip>>;
59
64
  }, z.core.$strip>;
60
65
  export type CliBuildManifest = z.infer<typeof CliBuildManifestSchema>;
61
66
  /** The stamp a build carries inside itself, so the tool can say what it is. */
@@ -71,13 +76,5 @@ export declare function formatCliBuildStamp(stamp: CliBuildStamp, name?: string)
71
76
  export declare function currentCliBuildTarget(): CliBuildTarget;
72
77
  /** The asset for one target, or `undefined` when this build was not published. */
73
78
  export declare function selectCliBuildAsset(manifest: CliBuildManifest, target?: CliBuildTarget): CliBuildAsset | undefined;
74
- /**
75
- * Refuse republishing a version from a different commit.
76
- *
77
- * A version is a promise about contents. Publishing `1.4.2` twice from two trees
78
- * means everyone who already installed `1.4.2` is told they are current and
79
- * never receives the fix — and nothing about their machine looks wrong. The
80
- * check is one comparison and belongs in the publisher, before the upload.
81
- */
82
- export declare function assertCliPublishable(previous: CliBuildManifest | undefined, next: CliBuildManifest): void;
79
+ export declare function assertCliPublishable(previous: CliBuildManifest | readonly CliBuildManifest[] | undefined, next: CliBuildManifest): void;
83
80
  //# sourceMappingURL=cli-manifest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli-manifest.d.ts","sourceRoot":"","sources":["../../src/tools/cli-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kFAAkF;AAClF,eAAO,MAAM,oBAAoB;;;iBAG/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;iBAK9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;iBAMjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAG/E;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,IAAI,cAAc,CAEtD;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,GAAE,cAAwC,GA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AE,gBAAgB,GAAG,SAAS,gBAAgB,EAAE,GAAG,SAAS,EACpE,IAAI,EAAE,gBAAgB,GACrB,IAAI,CAkBN"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Who built the binary — which the asset digest cannot answer.
3
+ *
4
+ * The digest proves the bytes that arrived are the bytes the manifest named. It
5
+ * proves nothing about who named them: the manifest and the assets come from
6
+ * one origin, and whoever can replace one can replace the other. Authorship
7
+ * needs a key the build carries and the server never holds.
8
+ *
9
+ * So the signature covers the manifest's identity AND every asset's digest —
10
+ * `{name, version, commit, builtAt, assets[]}` — and the chain closes on the
11
+ * file that will execute rather than on the document describing it. Signing the
12
+ * document alone would leave an attacker free to swap an asset URL's contents
13
+ * and keep a valid signature over an unchanged document.
14
+ *
15
+ * Ed25519 over `node:crypto`; no dependency is added for this.
16
+ */
17
+ import { z } from 'zod';
18
+ import type { CliBuildManifest } from './cli-manifest.js';
19
+ /** The detached signature a published manifest carries beside its own fields. */
20
+ export declare const CliBuildSignatureSchema: z.ZodObject<{
21
+ algorithm: z.ZodLiteral<"ed25519">;
22
+ keyId: z.ZodString;
23
+ signature: z.ZodString;
24
+ }, z.core.$strip>;
25
+ export type CliBuildSignature = z.infer<typeof CliBuildSignatureSchema>;
26
+ /**
27
+ * What a verification concluded. Five answers, and `unenforced` is the one that
28
+ * earns its keep: a build with no pinned key must keep updating, and the fact
29
+ * that nothing was checked has to be VISIBLE rather than assumed. A silent
30
+ * "fine" from a check that never ran is the failure mode this whole file exists
31
+ * to remove.
32
+ */
33
+ export type CliSignatureVerdict = 'valid' | 'unenforced' | 'missing' | 'unknown-key' | 'invalid';
34
+ /** The keys a build trusts, by id. A build with none enforces nothing. */
35
+ export interface CliTrustRoot {
36
+ /**
37
+ * `keyId` → public key, as SPKI PEM or base64 of the raw 32-byte Ed25519 key.
38
+ * Compiled into the binary: a trust root fetched at runtime from the same
39
+ * origin as the manifest proves nothing.
40
+ */
41
+ keys: Readonly<Record<string, string>>;
42
+ }
43
+ /**
44
+ * The exact bytes a signature covers.
45
+ *
46
+ * Canonical JSON, so two producers that agree on the content agree on the
47
+ * bytes — key order and whitespace are not allowed to decide whether a
48
+ * signature verifies. Every asset contributes its target, its compression, its
49
+ * size and its digest; `url` does not, because where a file is served from is
50
+ * the publisher's business and moving it must not invalidate the proof of what
51
+ * it contains. Everything that decides what happens to the bytes BEFORE the
52
+ * digest can be checked is signed; only the address is free.
53
+ */
54
+ export declare function cliManifestSigningPayload(manifest: CliBuildManifest): string;
55
+ /**
56
+ * A private key as it comes out of a file or a secret store: PEM text, or DER
57
+ * bytes.
58
+ *
59
+ * Deliberately not `KeyObject`. That type belongs to `node:crypto`, and naming
60
+ * it in a published signature puts `import("node:crypto")` into the declaration
61
+ * files of a package whose browser-safe entries a consumer resolves without
62
+ * Node types at all — the whole surface stops typechecking for them over a
63
+ * function they never call.
64
+ */
65
+ export type CliSigningKey = string | Uint8Array;
66
+ /** Sign a manifest — for the publisher, which is the only side that holds a key. */
67
+ export declare function signCliManifest(manifest: CliBuildManifest, options: {
68
+ keyId: string;
69
+ privateKey: CliSigningKey;
70
+ }): CliBuildSignature;
71
+ /**
72
+ * Verify a manifest against the build's own trust root.
73
+ *
74
+ * Never throws: a verdict is the answer, including for a malformed key or a
75
+ * signature that is not base64 at all. A caller deciding whether to download
76
+ * something wants a decision, not an exception to translate into one.
77
+ */
78
+ export declare function verifyCliManifest(manifest: CliBuildManifest, signature: CliBuildSignature | undefined, trust?: CliTrustRoot): CliSignatureVerdict;
79
+ /** Whether a verdict permits installing the build it describes. */
80
+ export declare function cliSignatureAccepted(verdict: CliSignatureVerdict): boolean;
81
+ //# sourceMappingURL=cli-signature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-signature.d.ts","sourceRoot":"","sources":["../../src/tools/cli-signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,iFAAiF;AACjF,eAAO,MAAM,uBAAuB;;;;iBAMlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP,YAAY,GACZ,SAAS,GACT,aAAa,GACb,SAAS,CAAC;AAEd,0EAA0E;AAC1E,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACxC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAkB5E;AAgBD;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,CAAC;AAEhD,oFAAoF;AACpF,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,aAAa,CAAA;CAAE,GACpD,iBAAiB,CAenB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,iBAAiB,GAAG,SAAS,EACxC,KAAK,CAAC,EAAE,YAAY,GACnB,mBAAmB,CAiBrB;AAED,mEAAmE;AACnE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAE1E"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * One operation per line, and a batch that can be resumed.
3
+ *
4
+ * Every agent-facing CLI grows the same two commands, and the mechanics contain
5
+ * nothing about any product: read a line, run the operation, answer with the
6
+ * same id, do not let one bad line stop the stream — and for a batch, do not
7
+ * run again what already ran.
8
+ *
9
+ * They are factories rather than framework-owned command names. Reserving
10
+ * `jsonl` and `batch` would take two names out of a namespace that belongs to
11
+ * the consumer: an application that already has a `batch` command would either
12
+ * fail at startup or find its own command silently shadowed. So the consumer
13
+ * mounts these under whatever it calls them, exactly like its own commands.
14
+ */
15
+ import { z } from 'zod';
16
+ import type { CliInvocationResult, CliInvoker } from './cli-invoke.js';
17
+ /** One line's answer: the id it came with, plus what running it produced. */
18
+ export interface CliStreamAnswer extends CliInvocationResult {
19
+ /** Correlation id, echoed from the line. */
20
+ id: string;
21
+ /** Present when this answer was replayed from a checkpoint rather than run. */
22
+ replayed?: true;
23
+ }
24
+ export interface CliStreamCommandConfig {
25
+ /** Command name — the consumer's namespace, not the framework's. */
26
+ name?: string;
27
+ description?: string;
28
+ /** The compiled surface to run against. */
29
+ invoker: CliInvoker | (() => Promise<CliInvoker>);
30
+ /**
31
+ * Where the lines come from. Default: `process.stdin`, **as they arrive**.
32
+ *
33
+ * This is the difference between a pipe and a conversation. The framework's
34
+ * ordinary stdin routing accumulates the whole stream and hands the command a
35
+ * string, which is right for `--prompt "$(cat file)"` and fatally wrong here:
36
+ * an agent that writes one line and waits for its answer would wait for its
37
+ * own EOF, which never comes. So the stream owns its input and answers each
38
+ * line as it is read.
39
+ */
40
+ readLines?: () => AsyncIterable<string>;
41
+ }
42
+ /**
43
+ * Lines from a byte stream, delivered as they arrive.
44
+ *
45
+ * Split on `\n` with a trailing `\r` dropped, so a producer on Windows is not a
46
+ * silent parse failure on every line. A final line with no newline is delivered
47
+ * at end of stream rather than discarded.
48
+ */
49
+ export declare function readStdinLines(source?: AsyncIterable<Uint8Array | string>): AsyncIterable<string>;
50
+ /**
51
+ * Run each line as it arrives, answering before reading the next.
52
+ *
53
+ * Sequential on purpose: the answers carry ids, so a consumer could correlate
54
+ * out-of-order ones — but a stream that runs ahead of its answers removes the
55
+ * one form of backpressure an agent has, which is not answering yet.
56
+ */
57
+ export declare function runCliStream(invoker: CliInvoker, lines: AsyncIterable<string>, onAnswer: (answer: CliStreamAnswer) => void, hooks?: CliStreamHooks): Promise<void>;
58
+ /** What a caller decides per line, without owning the loop that reads them. */
59
+ export interface CliStreamHooks {
60
+ /** Answer this line without running it — a replay, or a refusal. */
61
+ before?: (id: string, line: {
62
+ command: string;
63
+ args: Record<string, unknown>;
64
+ }) => CliStreamAnswer | undefined;
65
+ /** Observe what running it produced, before the answer is written. */
66
+ after?: (id: string, line: {
67
+ command: string;
68
+ args: Record<string, unknown>;
69
+ }, outcome: CliInvocationResult) => void;
70
+ }
71
+ /**
72
+ * A stream command the consumer mounts under its own name.
73
+ *
74
+ * Answers go to stdout one JSON object per line; nothing else does, so a script
75
+ * can read stdout as data while diagnostics stay on stderr.
76
+ */
77
+ export declare function defineCliStreamCommand(config: CliStreamCommandConfig): import("./cli-command.js").CliCommandDefinitionWithoutOutput<z.ZodObject<{}, z.core.$strip>>;
78
+ export interface CliBatchCommandConfig extends CliStreamCommandConfig {
79
+ /** Where the checkpoint lives. Relative paths resolve against the process cwd. */
80
+ checkpointPath?: string;
81
+ }
82
+ /**
83
+ * A resumable batch.
84
+ *
85
+ * The checkpoint records, per line id, the digest of the line that produced the
86
+ * recorded answer. A re-run replays what already ran; a line whose CONTENT
87
+ * changed under the same id is refused rather than quietly re-run or quietly
88
+ * replayed, because both of those answer a question nobody asked.
89
+ */
90
+ export declare function defineCliBatchCommand(config: CliBatchCommandConfig): import("./cli-command.js").CliCommandDefinitionWithoutOutput<z.ZodObject<{
91
+ checkpoint: z.ZodOptional<z.ZodString>;
92
+ }, z.core.$strip>>;
93
+ //# sourceMappingURL=cli-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-stream.d.ts","sourceRoot":"","sources":["../../src/tools/cli-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEpE,6EAA6E;AA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,KACzB,IAAI,CAAC;CACX;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,6FAcpE;AAED,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB;IACnE,kFAAkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB;;mBA+DlE"}
@@ -1,4 +1,5 @@
1
1
  import { type CliBuildAsset, type CliBuildManifest, type CliBuildTarget } from './cli-manifest.js';
2
+ import { type CliSignatureVerdict, type CliTrustRoot } from './cli-signature.js';
2
3
  export interface CliUpdateCheckConfig {
3
4
  manifestUrl: string;
4
5
  currentVersion: string;
@@ -11,6 +12,11 @@ export interface CliUpdateCheckConfig {
11
12
  timeoutMs?: number;
12
13
  target?: CliBuildTarget;
13
14
  allowPrivateHosts?: boolean;
15
+ /**
16
+ * Keys this build trusts. With none, nothing is enforced and the verdict says
17
+ * so out loud (`unenforced`) rather than leaving "checked" to be assumed.
18
+ */
19
+ trust?: CliTrustRoot;
14
20
  }
15
21
  /**
16
22
  * Four answers, never three. "Could not ask" is not "up to date": collapsing
@@ -22,11 +28,14 @@ export type CliUpdateCheck = {
22
28
  } | {
23
29
  status: 'current';
24
30
  version: string;
31
+ signature?: CliSignatureVerdict;
25
32
  } | {
26
33
  status: 'outdated';
27
34
  version: string;
28
35
  manifest: CliBuildManifest;
29
36
  asset?: CliBuildAsset;
37
+ /** What the signature check concluded — always present once it ran. */
38
+ signature?: CliSignatureVerdict;
30
39
  } | {
31
40
  status: 'unknown';
32
41
  reason: string;
@@ -46,11 +55,36 @@ export interface CliUpdateApplyConfig {
46
55
  timeoutMs?: number;
47
56
  maxBytes?: number;
48
57
  allowPrivateHosts?: boolean;
58
+ /**
59
+ * The document the asset came from, so authorship can be checked here too.
60
+ *
61
+ * `CliBuildAsset` cannot carry the proof: the signature covers the manifest's
62
+ * identity and every asset's digest together, which is what closes the chain
63
+ * on the file that executes. Passing both is what lets this refuse **before**
64
+ * it downloads anything.
65
+ */
66
+ manifest?: CliBuildManifest;
67
+ /** Keys this build trusts. With `manifest`, the pair is checked before the fetch. */
68
+ trust?: CliTrustRoot;
69
+ /**
70
+ * Keep the bytes being replaced, here, so there is something to go back to.
71
+ *
72
+ * Written after the new bytes are verified and before the target is replaced:
73
+ * a backup taken earlier could preserve a binary that was about to be
74
+ * replaced by a download that then failed its digest, and a backup taken
75
+ * later has nothing left to copy. The target's own mode is carried over — the
76
+ * point of a backup is to be runnable.
77
+ */
78
+ backupPath?: string;
49
79
  }
50
80
  export interface AppliedCliUpdate {
51
81
  path: string;
52
82
  bytes: number;
53
83
  sha256: string;
84
+ /** Where the replaced bytes were kept, when a backup was asked for and there was one. */
85
+ backupPath?: string;
86
+ /** Digest of the replaced bytes — what `rollbackCliUpdate` expects to find. */
87
+ backupSha256?: string;
54
88
  }
55
89
  /**
56
90
  * Download, verify and replace the binary.
@@ -61,4 +95,32 @@ export interface AppliedCliUpdate {
61
95
  * a partial write.
62
96
  */
63
97
  export declare function applyCliUpdate(config: CliUpdateApplyConfig): Promise<AppliedCliUpdate>;
98
+ export interface CliRollbackConfig {
99
+ /** The file to restore onto; defaults to the running executable. */
100
+ targetPath?: string;
101
+ /** The copy kept by a previous `applyCliUpdate({ backupPath })`. */
102
+ backupPath: string;
103
+ /**
104
+ * The digest the backup must have — `backupSha256` from that update.
105
+ *
106
+ * Required, not optional. A rollback that installs whatever happens to be at
107
+ * the backup path is a second install of an unverified binary, and the moment
108
+ * it is used is the moment nobody is in a position to check.
109
+ */
110
+ expectedSha256: string;
111
+ }
112
+ export interface RolledBackCliUpdate {
113
+ path: string;
114
+ bytes: number;
115
+ sha256: string;
116
+ }
117
+ /**
118
+ * Put the previous build back.
119
+ *
120
+ * Rolling back is a property of updating, not of the application: the same
121
+ * attention to atomicity and file mode the replacement gets, applied in the
122
+ * other direction. The digest is checked first, so a corrupted or swapped
123
+ * backup is a refusal rather than an unbootable tool.
124
+ */
125
+ export declare function rollbackCliUpdate(config: CliRollbackConfig): RolledBackCliUpdate;
64
126
  //# sourceMappingURL=cli-update.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli-update.d.ts","sourceRoot":"","sources":["../../src/tools/cli-update.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAErB,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AASxB,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAC;IAAC,KAAK,CAAC,EAAE,aAAa,CAAA;CAAE,GAC1F;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAe1C;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAalF;AAED,6EAA6E;AAC7E,wBAAsB,cAAc,CAAC,MAAM,EAAE,oBAAoB,G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B;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqE5F;AAkBD,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,mBAAmB,CAchF"}
@@ -1,21 +1,14 @@
1
1
  import type { ZodObject, z } from 'zod';
2
- import type { ServiceDef, StitchLogger } from '../server/types.js';
3
2
  import { type CliCommandDefinition } from './cli-command.js';
4
3
  import { type ExitCodeMap } from './cli-format.js';
5
- import { type CliPresentationPolicyConfig } from './cli-policy.js';
4
+ import { type CliInvocationResult, type CliInvoker, type CliInvokerCommand, type CliInvokerConfig, type CliSurfaceSource, cliInvocationResult, createCliInvoker } from './cli-invoke.js';
6
5
  import { type CliWaitConfig } from './cli-wait.js';
7
6
  import { type ErrorHintFn, type ToolCallHooks, type ToolLifecycle } from './execute.js';
8
- import type { RuntimeToolDefinition } from './runtime-tool.js';
9
- export type CliSurfaceSource<TAuth, TValue> = readonly TValue[] | ((auth: Awaited<TAuth> | undefined) => readonly TValue[]);
10
- export interface CliConfig<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown>, TGlobals extends ZodObject = ZodObject> extends CliPresentationPolicyConfig {
11
- /** Program name — shown in help and unknown-command messages. */
12
- name: string;
7
+ export type { CliInvocationResult, CliInvoker, CliInvokerCommand, CliInvokerConfig, CliSurfaceSource, };
8
+ export { cliInvocationResult, createCliInvoker };
9
+ export interface CliConfig<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown>, TGlobals extends ZodObject = ZodObject> extends CliInvokerConfig<TAuth, TContext, TGlobals> {
13
10
  /** Program version — printed by `--version`. */
14
11
  version: string;
15
- /** Contract services exposed as commands — may depend on the resolved identity. */
16
- services?: CliSurfaceSource<TAuth, ServiceDef>;
17
- /** Pathless managed operations. CLI exposure always requires `transports: ['CLI']`. */
18
- runtimeTools?: CliSurfaceSource<TAuth, RuntimeToolDefinition>;
19
12
  /** CLI-only executable commands, dispatched before auth and managed surface factories. */
20
13
  commands?: readonly CliCommandDefinition[];
21
14
  /**
@@ -56,8 +49,6 @@ export interface CliConfig<TAuth = unknown, TContext extends Record<string, unkn
56
49
  * a scoped command bypasses the gate.
57
50
  */
58
51
  lifecycle?: ToolLifecycle;
59
- /** Logger for diagnostics — defaults to stderr-safe `console.error`. */
60
- logger?: StitchLogger;
61
52
  /** Coerce JSON-stringified arrays/objects in arguments. Default: true. */
62
53
  coerceJsonArgs?: boolean;
63
54
  /** Global error hint appended to every failed command's error. */
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/tools/cli.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAUhE,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAsB,KAAK,WAAW,EAAc,MAAM,cAAc,CAAC;AAChF,OAAO,EAIL,KAAK,2BAA2B,EACjC,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAInB,MAAM,WAAW,CAAC;AAKnB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAA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IAC7E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,oEAAoE;IACpE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,oEAAoE;IACpE,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,gEAAgE;IAChE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACtC;AAiZD,8EAA8E;AAC9E,wBAAsB,SAAS,CAC7B,KAAK,GAAG,OAAO,EACf,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,QAAQ,SAAS,SAAS,GAAG,SAAS,EACtC,MAAM,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAid7D"}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  defineRuntimeTool
3
- } from "../../index-8z9we758.js";
3
+ } from "../../index-vjpvjqpn.js";
4
4
  import {
5
5
  declaresDraft07,
6
6
  withDefsDialect
7
- } from "../../index-fenaekmk.js";
7
+ } from "../../index-h9etkkyk.js";
8
8
  import"../../index-cby4ar3v.js";
9
9
  import {
10
10
  AppError
@@ -184,6 +184,27 @@ export interface ToolArgumentExtension {
184
184
  * `AppError` becomes a tool error. Shared by `executeToolMethod` and both
185
185
  * transport mounts so every tool error has one shape.
186
186
  */
187
+ /** What one tool call's arguments parse to — or why they did not. */
188
+ export type ParsedToolCallArguments = {
189
+ ok: true;
190
+ params: unknown;
191
+ input: unknown;
192
+ } | {
193
+ ok: false;
194
+ message: string;
195
+ thrown?: unknown;
196
+ };
197
+ /**
198
+ * Split and validate a flat tool-argument object exactly as a call does.
199
+ *
200
+ * Exported so the ONE thing that needs the parsed value without running the
201
+ * call — an elicitation resolver choosing this call's questions — gets the same
202
+ * value the handler will get, rather than a second parse written beside this
203
+ * one that drifts on the next coercion change. It is pure: no lifecycle, no
204
+ * hooks, no audit row, so asking what the arguments mean costs nothing that a
205
+ * gate would charge for.
206
+ */
207
+ export declare function parseToolCallArguments(method: ToolOperation, callArgs: Record<string, unknown>, coerceJson: boolean): ParsedToolCallArguments;
187
208
  export declare function toolResultFromError(err: unknown): ToolFailure;
188
209
  /** Recover the normalized AppError behind one canonical failed tool result. */
189
210
  export declare function toolErrorFromResult(result: ToolFailure): AppError;
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/tools/execute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,EACL,QAAQ,EAGR,KAAK,cAAc,EACnB,KAAK,cAAc,EAEnB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAKrB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAIzD,MAAM,MAAM,UAAU,GAClB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAC3B;IACE,EAAE,EAAE,KAAK,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEN,KAAK,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAEtD,MAAM,MAAM,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Aa,EACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,eAAe,EACxB,KAAK,CAAC,EAAE,aAAa,EACrB,SAAS,CAAC,EAAE,aAAa,EACzB,UAAU,UAAQ,EAClB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,EACzC,SAAS,CAAC,EAAE,qBAAqB,EACjC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAC7D,OAAO,CAAC,UAAU,CAAC,CA0BrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,IAAI,EAAE;IACJ,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,EACD,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Progress for a call that is still running.
3
+ *
4
+ * A tool that takes ten minutes tells a text host nothing today: the call is
5
+ * made, and the next thing the host sees is the answer. The protocol has the
6
+ * channel for this — the host sends a `progressToken` in the request's `_meta`
7
+ * and the server relates `notifications/progress` to that request — and the
8
+ * framework simply never read the token.
9
+ *
10
+ * Both places that can report live here, so there is one implementation of
11
+ * "what a progress update is": the contract-tool path (`mcp-round.ts`, which
12
+ * hands `reportProgress` to the handler) and the native wait tool
13
+ * (`mount-wait.ts`, which reports its own poll ticks).
14
+ */
15
+ import type { ServerContext } from '@modelcontextprotocol/server';
16
+ import type { McpReportProgress } from '../contract/index.js';
17
+ /**
18
+ * The host's progress token, or `undefined` when it asked for none.
19
+ *
20
+ * It rides in the request's own `_meta`, beside the trace keys, and survives
21
+ * the SDK's envelope lift because it is not an envelope key. `_meta` itself can
22
+ * be absent entirely — the SDK drops it when the lift empties it — so "no
23
+ * `_meta`" and "`_meta` without a token" have to mean the same thing here.
24
+ */
25
+ export declare function mcpProgressToken(context: ServerContext): string | number | undefined;
26
+ /**
27
+ * Build the reporter for one call.
28
+ *
29
+ * Without a token it is a no-op, so nothing upstream has to ask whether the
30
+ * host is listening. With one, every update is a `notifications/progress`
31
+ * related to this request.
32
+ *
33
+ * `progress` is required by the protocol and is often the one thing a handler
34
+ * does not know — it has a stage to name and no scale to name it on. An
35
+ * omitted one becomes the ordinal of this update, which is a fact about what
36
+ * happened; a synthesised percentage would be a claim nobody measured. `total`
37
+ * stays absent in that case, so a host renders an unbounded counter rather
38
+ * than a bar stuck at 3%.
39
+ *
40
+ * Nothing here can fail the call. A transport that refuses the notification
41
+ * leaves the host without progress, which is exactly the state of every host
42
+ * that never asked for it — and a message about work must not be able to kill
43
+ * the work it describes.
44
+ */
45
+ export declare function createMcpProgressReporter(context: ServerContext): McpReportProgress;
46
+ //# sourceMappingURL=mcp-progress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-progress.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-progress.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAqB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAExE;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAGpF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,aAAa,GAAG,iBAAiB,CA4BnF"}
@@ -1,4 +1,13 @@
1
- import type { EndpointMcpPolicy } from '../contract/index.js';
1
+ import type { EndpointMcpInputRequired, EndpointMcpPolicy } from '../contract/index.js';
2
+ /**
3
+ * The declared rounds, when the declaration is a fixed list.
4
+ *
5
+ * A resolver has nothing to read at declaration time — that is the whole point
6
+ * of it — so everything that inspects a policy statically (surface projection,
7
+ * the surface fingerprint, mount-time validation) asks this first and treats
8
+ * `undefined` as "known only per call".
9
+ */
10
+ export declare function staticInputRounds(policy: EndpointMcpPolicy): readonly EndpointMcpInputRequired[] | undefined;
2
11
  /** Validate declarative multi-round policy without importing the optional MCP SDK. */
3
12
  export declare function validateMcpRoundPolicy(tool: {
4
13
  name: string;
@@ -6,4 +15,19 @@ export declare function validateMcpRoundPolicy(tool: {
6
15
  stateConfigured: boolean;
7
16
  maxRounds: number;
8
17
  }): void;
18
+ /**
19
+ * Validate what a resolver actually returned, on the call that returned it.
20
+ *
21
+ * The same two rules the static list is held to — unique keys, no more rounds
22
+ * than the runtime allows — because a resolver can break both, and a policy
23
+ * that is only checked when it happens to be written down is not checked.
24
+ *
25
+ * An empty list is legal here and only here: for a resolver it means "this call
26
+ * needs nothing", which is the answer the feature exists to allow. Declaring
27
+ * zero rounds statically still means the author wrote a policy that can never
28
+ * ask anything, and that stays an error.
29
+ */
30
+ export declare function validateResolvedInputRounds(tool: {
31
+ name: string;
32
+ }, resolved: readonly EndpointMcpInputRequired[], maxRounds: number): void;
9
33
  //# sourceMappingURL=mcp-round-policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-round-policy.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-round-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,sFAAsF;AACtF,wBAAgB,sBAAsB,CACpC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACtB,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE;IAAE,eAAe,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACxD,IAAI,CA6BN"}
1
+ {"version":3,"file":"mcp-round-policy.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-round-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,iBAAiB,GACxB,SAAS,wBAAwB,EAAE,GAAG,SAAS,CAEjD;AAED,sFAAsF;AACtF,wBAAgB,sBAAsB,CACpC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACtB,MAAM,EAAE,iBAAiB,EACzB,OAAO,CAAC,EAAE;IAAE,eAAe,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACxD,IAAI,CAqBN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EACtB,QAAQ,EAAE,SAAS,wBAAwB,EAAE,EAC7C,SAAS,EAAE,MAAM,GAChB,IAAI,CAEN"}
@@ -1,6 +1,6 @@
1
1
  import { type CallToolResult, type InputRequiredResult, type RequestStateCodec, type ServerContext } from '@modelcontextprotocol/server';
2
2
  import { type EndpointMcpPolicy } from '../contract/index.js';
3
- import type { ToolResult } from './execute.js';
3
+ import { type ToolResult } from './execute.js';
4
4
  import type { MountableTool } from './mount.js';
5
5
  interface RoundOperationIdentity {
6
6
  toolName: string;
@@ -15,6 +15,23 @@ export interface McpRoundState {
15
15
  argumentsDigest: string;
16
16
  round: number;
17
17
  accepted: Record<string, unknown>;
18
+ /**
19
+ * Fingerprint of the question plan this conversation started with.
20
+ *
21
+ * `argumentsDigest` proves the ARGUMENTS did not change; it says nothing
22
+ * about the questions, and those are now allowed to be computed. Between two
23
+ * rounds there is a full round trip to the host, and a resolver that reads
24
+ * anything outside its arguments — which is exactly the case this feature
25
+ * exists for — can answer differently the second time. Every other check
26
+ * would still pass: same principal, same operation, same digest, `round`
27
+ * still in range. Round 2's question would be asked under round 1's key, the
28
+ * answer would be accepted if the schemas happened to be compatible, and the
29
+ * handler would receive an answer to a question nobody asked.
30
+ *
31
+ * So the plan is fingerprinted when it is minted and re-checked on every
32
+ * round. A plan that moved is a refusal, not a different question.
33
+ */
34
+ planDigest: string;
18
35
  }
19
36
  export interface McpRoundRuntime {
20
37
  codec: RequestStateCodec<McpRoundState>;
@@ -37,6 +54,8 @@ export declare function resolveMcpRound(options: {
37
54
  runtime?: McpRoundRuntime;
38
55
  runTool: ToolRunner;
39
56
  formatFailure: (result: ToolResult) => CallToolResult;
57
+ /** The mount's JSON-coercion setting, so the resolver parses as the call does. */
58
+ coerceJsonArgs?: boolean;
40
59
  }): Promise<McpRoundResolution>;
41
60
  export {};
42
61
  //# sourceMappingURL=mcp-round.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-round.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-round.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EAIxB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EACnB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAEL,KAAK,iBAAiB,EAGvB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,sBAAsB,CAAC;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;A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MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,UAAU,CAAC;IACpB,aAAa,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,cAAc,CAAC;IACtD,kFAAkF;IAClF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAuO9B"}
@@ -1,4 +1,12 @@
1
1
  import { type ServerContext } from '@modelcontextprotocol/server';
2
- /** Run one SDK-dispatched MCP request inside an isolated propagation context. */
2
+ /**
3
+ * Run one SDK-dispatched MCP request inside an isolated propagation context.
4
+ *
5
+ * `method: 'MCP'` and `path: '/mcp/<tool>'` are written here deliberately, and
6
+ * they are NOT the fabricated transport fields that `kind: 'job'` exists to
7
+ * replace. An MCP tool call arrives as a request, over a transport, naming an
8
+ * operation — it has a verb-shaped thing to say and a path-shaped thing to say.
9
+ * Background work has neither, which is why it now records their absence.
10
+ */
3
11
  export declare function runInMcpRequestContext<T>(context: ServerContext, toolName: string, body: () => Promise<T>): Promise<T>;
4
12
  //# sourceMappingURL=mcp-trace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-trace.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-trace.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,8BAA8B,CAAC;AAQtC,iFAAiF;AACjF,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,OAAO,EAAE,aAAa,EACtB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CA0BZ"}
1
+ {"version":3,"file":"mcp-trace.d.ts","sourceRoot":"","sources":["../../src/tools/mcp-trace.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAGnB,MAAM,8BAA8B,CAAC;AAQtC;;;;;;;;GAQG;AACH,wBAAgB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