@mcp-index/sdk 0.1.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 (55) hide show
  1. package/LICENSE +133 -0
  2. package/README.md +49 -0
  3. package/dist/src/canonical.d.ts +42 -0
  4. package/dist/src/canonical.d.ts.map +1 -0
  5. package/dist/src/canonical.js +231 -0
  6. package/dist/src/canonical.js.map +1 -0
  7. package/dist/src/errors.d.ts +39 -0
  8. package/dist/src/errors.d.ts.map +1 -0
  9. package/dist/src/errors.js +79 -0
  10. package/dist/src/errors.js.map +1 -0
  11. package/dist/src/gate.d.ts +128 -0
  12. package/dist/src/gate.d.ts.map +1 -0
  13. package/dist/src/gate.js +626 -0
  14. package/dist/src/gate.js.map +1 -0
  15. package/dist/src/index.d.ts +26 -0
  16. package/dist/src/index.d.ts.map +1 -0
  17. package/dist/src/index.js +20 -0
  18. package/dist/src/index.js.map +1 -0
  19. package/dist/src/lexicon.d.ts +15 -0
  20. package/dist/src/lexicon.d.ts.map +1 -0
  21. package/dist/src/lexicon.js +70 -0
  22. package/dist/src/lexicon.js.map +1 -0
  23. package/dist/src/outcomes.d.ts +67 -0
  24. package/dist/src/outcomes.d.ts.map +1 -0
  25. package/dist/src/outcomes.js +159 -0
  26. package/dist/src/outcomes.js.map +1 -0
  27. package/dist/src/preflight.d.ts +54 -0
  28. package/dist/src/preflight.d.ts.map +1 -0
  29. package/dist/src/preflight.js +0 -0
  30. package/dist/src/preflight.js.map +1 -0
  31. package/dist/src/provenance.d.ts +95 -0
  32. package/dist/src/provenance.d.ts.map +1 -0
  33. package/dist/src/provenance.js +221 -0
  34. package/dist/src/provenance.js.map +1 -0
  35. package/dist/src/render.d.ts +10 -0
  36. package/dist/src/render.d.ts.map +1 -0
  37. package/dist/src/render.js +38 -0
  38. package/dist/src/render.js.map +1 -0
  39. package/dist/src/risk.d.ts +32 -0
  40. package/dist/src/risk.d.ts.map +1 -0
  41. package/dist/src/risk.js +179 -0
  42. package/dist/src/risk.js.map +1 -0
  43. package/dist/src/scan.d.ts +15 -0
  44. package/dist/src/scan.d.ts.map +1 -0
  45. package/dist/src/scan.js +88 -0
  46. package/dist/src/scan.js.map +1 -0
  47. package/dist/src/schemaDiff.d.ts +36 -0
  48. package/dist/src/schemaDiff.d.ts.map +1 -0
  49. package/dist/src/schemaDiff.js +448 -0
  50. package/dist/src/schemaDiff.js.map +1 -0
  51. package/dist/src/wrap.d.ts +77 -0
  52. package/dist/src/wrap.d.ts.map +1 -0
  53. package/dist/src/wrap.js +554 -0
  54. package/dist/src/wrap.js.map +1 -0
  55. package/package.json +44 -0
package/LICENSE ADDED
@@ -0,0 +1,133 @@
1
+ Required Notice: Copyright Bhartis LLC (https://mcpindex.ai)
2
+
3
+ # PolyForm Noncommercial License 1.0.0
4
+
5
+ <https://polyformproject.org/licenses/noncommercial/1.0.0>
6
+
7
+ ## Acceptance
8
+
9
+ In order to get any license under these terms, you must agree
10
+ to them as both strict obligations and conditions to all
11
+ your licenses.
12
+
13
+ ## Copyright License
14
+
15
+ The licensor grants you a copyright license for the
16
+ software to do everything you might do with the software
17
+ that would otherwise infringe the licensor's copyright
18
+ in it for any permitted purpose. However, you may
19
+ only distribute the software according to [Distribution
20
+ License](#distribution-license) and make changes or new works
21
+ based on the software according to [Changes and New Works
22
+ License](#changes-and-new-works-license).
23
+
24
+ ## Distribution License
25
+
26
+ The licensor grants you an additional copyright license
27
+ to distribute copies of the software. Your license
28
+ to distribute covers distributing the software with
29
+ changes and new works permitted by [Changes and New Works
30
+ License](#changes-and-new-works-license).
31
+
32
+ ## Notices
33
+
34
+ You must ensure that anyone who gets a copy of any part of
35
+ the software from you also gets a copy of these terms or the
36
+ URL for them above, as well as copies of any plain-text lines
37
+ beginning with `Required Notice:` that the licensor provided
38
+ with the software. For example:
39
+
40
+ > Required Notice: Copyright Bhartis LLC (https://mcpindex.ai)
41
+
42
+ ## Changes and New Works License
43
+
44
+ The licensor grants you an additional copyright license to
45
+ make changes and new works based on the software for any
46
+ permitted purpose.
47
+
48
+ ## Patent License
49
+
50
+ The licensor grants you a patent license for the software that
51
+ covers patent claims the licensor can license, or becomes able
52
+ to license, that you would infringe by using the software.
53
+
54
+ ## Noncommercial Purposes
55
+
56
+ Any noncommercial purpose is a permitted purpose.
57
+
58
+ ## Personal Uses
59
+
60
+ Personal use for research, experiment, and testing for
61
+ the benefit of public knowledge, personal study, private
62
+ entertainment, hobby projects, amateur pursuits, or religious
63
+ observance, without any anticipated commercial application,
64
+ is use for a permitted purpose.
65
+
66
+ ## Noncommercial Organizations
67
+
68
+ Use by any charitable organization, educational institution,
69
+ public research organization, public safety or health
70
+ organization, environmental protection organization,
71
+ or government institution is use for a permitted purpose
72
+ regardless of the source of funding or obligations resulting
73
+ from the funding.
74
+
75
+ ## Fair Use
76
+
77
+ You may have "fair use" rights for the software under the
78
+ law. These terms do not limit them.
79
+
80
+ ## No Other Rights
81
+
82
+ These terms do not allow you to sublicense or transfer any of
83
+ your licenses to anyone else, or prevent the licensor from
84
+ granting licenses to anyone else. These terms do not imply
85
+ any other licenses.
86
+
87
+ ## Patent Defense
88
+
89
+ If you make any written claim that the software infringes or
90
+ contributes to infringement of any patent, your patent license
91
+ for the software granted under these terms ends immediately. If
92
+ your company makes such a claim, your patent license ends
93
+ immediately for work on behalf of your company.
94
+
95
+ ## Violations
96
+
97
+ The first time you are notified in writing that you have
98
+ violated any of these terms, or done anything with the software
99
+ not covered by your licenses, your licenses can nonetheless
100
+ continue if you come into full compliance with these terms,
101
+ and take practical steps to correct past violations, within
102
+ 32 days of receiving notice. Otherwise, all your licenses
103
+ end immediately.
104
+
105
+ ## No Liability
106
+
107
+ ***As far as the law allows, the software comes as is, without
108
+ any warranty or condition, and the licensor will not be liable
109
+ to you for any damages arising out of these terms or the use
110
+ or nature of the software, under any kind of legal claim.***
111
+
112
+ ## Definitions
113
+
114
+ The **licensor** is the individual or entity offering these
115
+ terms, and the **software** is the software the licensor makes
116
+ available under these terms.
117
+
118
+ **You** refers to the individual or entity agreeing to these
119
+ terms.
120
+
121
+ **Your company** is any legal entity, sole proprietorship,
122
+ or other kind of organization that you work for, plus all
123
+ organizations that have control over, are under the control of,
124
+ or are under common control with that organization. **Control**
125
+ means ownership of substantially all the assets of an entity,
126
+ or the power to direct its management and policies by vote,
127
+ contract, or otherwise. Control can be direct or indirect.
128
+
129
+ **Your licenses** are all the licenses granted to you for the
130
+ software under these terms.
131
+
132
+ **Use** means anything you do with the software requiring one
133
+ of your licenses.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @mcp-index/sdk
2
+
3
+ Pre-flight MCP tool-contract drift interceptor. One line — `wrap()` an MCP client
4
+ session and the gate **HOLDs a tool call before your agent acts** the moment the
5
+ tool's contract silently changes from what you pinned. In-path, on your host; no
6
+ credentials, no egress.
7
+
8
+ ## Install
9
+
10
+ ```sh
11
+ npm i @mcp-index/sdk
12
+ ```
13
+
14
+ Peer dependency: `@modelcontextprotocol/sdk` >= 1.0.0.
15
+
16
+ ## Use
17
+
18
+ ```ts
19
+ import { wrap } from '@mcp-index/sdk';
20
+
21
+ // wrap an already-connected MCP client session
22
+ const guarded = wrap(session); // pins each tool's contract on first use (TOFU)
23
+
24
+ // use `guarded` exactly like `session`; a drifted contract is HELD before the call
25
+ // fires. A PreflightHold surfaces (Guard/Strict) so you can route the agent to
26
+ // Review / Re-pin / Validate.
27
+ ```
28
+
29
+ ## What it does
30
+
31
+ - Pins each MCP tool's contract trust-on-first-use (TOFU), persisted across restarts.
32
+ - Runs a **deterministic** contract-diff (the ChangeKind taxonomy: added-required-param,
33
+ constraint-narrowed, annotation-flip-to-destructive, output-schema-changed,
34
+ type/enum/removed, …) plus an injection/exfil marker scan over input and output schema.
35
+ - **HOLDs** the call with the ⬡ banner when the contract drifted; **PROCEEDs** silently
36
+ on a benign change (no false alarm).
37
+ - Postures: `Monitor` (notify + proceed) / `Guard` (default; hold dangerous) /
38
+ `Strict` (hold any drift).
39
+
40
+ ## What it is NOT
41
+
42
+ The verdict is a **contract-diff, not a safety oracle** — it tells you the contract
43
+ *changed* versus your pin, not that the new contract is safe. It does not "block attacks"
44
+ or "guarantee safe." You decide what a HOLD means for your agent.
45
+
46
+ ## License
47
+
48
+ PolyForm Noncommercial 1.0.0 — © Bhartis LLC. Free for noncommercial use; commercial use
49
+ requires a separate license. See [`LICENSE`](./LICENSE) and https://mcpindex.ai.
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The canonical serialization + per-tool hash — a BYTE-FOR-BYTE port of the
3
+ * Python `trust.contract.canonical_bytes` / `_canonicalize` and the connector's
4
+ * `_tool_hash`. A TS-pinned hash MUST equal a Python-pinned hash for the SAME
5
+ * contract, or the cross-language pin chain breaks.
6
+ *
7
+ * CONFORMANCE RULES (from contract.py, load-bearing):
8
+ * - Objects: keys NFC-normalized, sorted by their string form, separators
9
+ * `(",",":")`, `ensure_ascii=True` (every non-ASCII char escaped as \uXXXX).
10
+ * - Strings/keys: Unicode NFC.
11
+ * - Floats: Python `%.17e` form (`1.50000000000000000e-01`) — exponent sign
12
+ * ALWAYS present, exponent ALWAYS >= 2 digits zero-padded. JS
13
+ * `toExponential(17)` does NOT zero-pad the exponent, so we re-pad.
14
+ * - Integers stay integers; -0.0 collapses to 0.0; non-finite floats raise.
15
+ * - Depth-capped at 64.
16
+ *
17
+ * NOTE the hash preimage key is `input_schema` (snake_case) — the Python
18
+ * `_hash_tool` maps the public `inputSchema` field onto `input_schema` before
19
+ * hashing. We replicate that exactly.
20
+ */
21
+ /** A JSON-ish value the canonicalizer accepts. */
22
+ export type Json = null | boolean | number | string | Json[] | {
23
+ [k: string]: Json;
24
+ };
25
+ /** THE canonical serialization — every hash site MUST use this (port of
26
+ * `contract.canonical_bytes`). */
27
+ export declare function canonicalBytes(obj: unknown): Buffer;
28
+ /** The connector's per-tool hash, byte-identical to Python `_tool_hash`. The
29
+ * preimage is `{name, description, input_schema}` (snake_case schema key). */
30
+ export declare function toolHash(name: string, description: string, inputSchema: Record<string, unknown>): string;
31
+ /** Hash a PUBLIC tool-definition dict (port of cse `_hash_tool`): coerces
32
+ * name/description to strings, an absent/non-object inputSchema to `{}`.
33
+ *
34
+ * LATENT divergence (audit L2): on a `null` name/description we coerce to `""`,
35
+ * whereas Python `_hash_tool` does `str(None)` -> `"None"`. This is UNREACHABLE
36
+ * via the wrapper: `wrap.toolToDict` already normalizes a null/absent description
37
+ * to `""` before this is ever called (and a tool with a null NAME is dropped), so
38
+ * both languages hash `""`. The divergence only surfaces on a RAW-dict direct call
39
+ * to `hashTool({description: null})` that bypasses the wrapper's normalization —
40
+ * we keep the `""` coercion (it is the wrapper-faithful value) and note the gap. */
41
+ export declare function hashTool(defn: Record<string, unknown>): string;
42
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/canonical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,kDAAkD;AAClD,MAAM,MAAM,IAAI,GACZ,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,IAAI,EAAE,GACN;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAoK1B;kCACkC;AAClC,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAEnD;AAED;8EAC8E;AAC9E,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,MAAM,CAOR;AAED;;;;;;;;;oFASoF;AACpF,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAY9D"}
@@ -0,0 +1,231 @@
1
+ /**
2
+ * The canonical serialization + per-tool hash — a BYTE-FOR-BYTE port of the
3
+ * Python `trust.contract.canonical_bytes` / `_canonicalize` and the connector's
4
+ * `_tool_hash`. A TS-pinned hash MUST equal a Python-pinned hash for the SAME
5
+ * contract, or the cross-language pin chain breaks.
6
+ *
7
+ * CONFORMANCE RULES (from contract.py, load-bearing):
8
+ * - Objects: keys NFC-normalized, sorted by their string form, separators
9
+ * `(",",":")`, `ensure_ascii=True` (every non-ASCII char escaped as \uXXXX).
10
+ * - Strings/keys: Unicode NFC.
11
+ * - Floats: Python `%.17e` form (`1.50000000000000000e-01`) — exponent sign
12
+ * ALWAYS present, exponent ALWAYS >= 2 digits zero-padded. JS
13
+ * `toExponential(17)` does NOT zero-pad the exponent, so we re-pad.
14
+ * - Integers stay integers; -0.0 collapses to 0.0; non-finite floats raise.
15
+ * - Depth-capped at 64.
16
+ *
17
+ * NOTE the hash preimage key is `input_schema` (snake_case) — the Python
18
+ * `_hash_tool` maps the public `inputSchema` field onto `input_schema` before
19
+ * hashing. We replicate that exactly.
20
+ */
21
+ import { createHash } from "node:crypto";
22
+ const FLOAT_DIGITS = 17;
23
+ const MAX_CANON_DEPTH = 64;
24
+ function nfc(s) {
25
+ return s.normalize("NFC");
26
+ }
27
+ /**
28
+ * KNOWN CROSS-LANGUAGE GAP (audit H2) — integral-valued floats.
29
+ *
30
+ * Python's canonicalizer keys off the RUNTIME TYPE: a Python `int` stays an int,
31
+ * a Python `float` becomes the `%.17e` string. Python `json.loads` PRESERVES that
32
+ * distinction off the wire — `0.0` parses to `float`, `0` to `int` — so Python
33
+ * `_hash_tool` gives DIFFERENT hashes for `minimum:0.0` vs `minimum:0`.
34
+ *
35
+ * JS `JSON.parse` does NOT: it collapses `0.0` -> the Number `0`, and the decimal
36
+ * is GONE before `wrap()` (or this canonicalizer) ever sees the Tool object — the
37
+ * SDK parsed it. A bare JS `number` carries no int/float tag, and the wrapper does
38
+ * NOT control the SDK's parse step, so the distinction is UNRECOVERABLE at this layer.
39
+ *
40
+ * We therefore emit INTEGRAL-VALUED numbers (`Number.isInteger(n)` true — includes
41
+ * `0.0`, `1.0`, `-0.0`, `1e300`, `1.5e10`) as integers, matching a Python `int`, and
42
+ * route only genuinely NON-INTEGRAL values through the `%.17e` float path. Consequence:
43
+ * - A schema bound/default authored as an integral-valued FLOAT (e.g. `minimum:0.0`)
44
+ * hashes in TS as if it were the int `0`, DIVERGING from Python's float hash.
45
+ * - This degrades to a tier-1 cross-language definition_hash MISS, which is
46
+ * FAIL-CLOSED-SAFE: the tier-0-INCONCLUSIVE -> tier-1-lookup-by-hash flow MISSES,
47
+ * stays INCONCLUSIVE, and HOLDS on the wire. It NEVER produces a wrong PROCEED —
48
+ * it only loses the cross-language cache/flywheel benefit on that one contract.
49
+ * - The TS client's OWN in-session drift detection is UNAFFECTED: pin and live are
50
+ * BOTH computed with this same TS `hashTool`, so an integral-valued float pins and
51
+ * re-derives identically within TS. The gap is purely cross-LANGUAGE.
52
+ *
53
+ * Genuinely non-integral floats (`0.5`, `0.1`, `3.14`, `1.5`, ...) ARE recoverable
54
+ * (JS keeps them as non-integral numbers) and hash BYTE-IDENTICAL to Python via
55
+ * `pythonFloatRepr` below — pinned in test/parity.test.ts against live-Python refs.
56
+ *
57
+ * True cross-language parity on integral-valued floats would need a VALUE-BASED (not
58
+ * type-based) canonicalization decision ON THE PYTHON SIDE — a corpus-migration /
59
+ * hash-format one-way door, out of this slice's scope. Tracked in tasks/todo-s6-ts.md.
60
+ */
61
+ function isIntegral(n) {
62
+ return Number.isInteger(n);
63
+ }
64
+ function pythonFloatRepr(n) {
65
+ if (Number.isNaN(n) || !Number.isFinite(n)) {
66
+ throw new Error("non-finite float is not canonicalizable");
67
+ }
68
+ let v = n;
69
+ if (v === 0)
70
+ v = 0; // collapse -0.0 -> 0.0
71
+ // toExponential(17): "d.<17 digits>e±X" but the exponent is NOT zero-padded.
72
+ const raw = v.toExponential(FLOAT_DIGITS);
73
+ const m = /^(-?\d\.\d+)e([+-])(\d+)$/.exec(raw);
74
+ if (m === null) {
75
+ throw new Error(`unexpected exponential form: ${raw}`);
76
+ }
77
+ const mantissa = m[1];
78
+ const sign = m[2];
79
+ let exp = m[3];
80
+ if (exp.length < 2)
81
+ exp = exp.padStart(2, "0");
82
+ return `${mantissa}e${sign}${exp}`;
83
+ }
84
+ function canonicalize(o, depth) {
85
+ if (depth > MAX_CANON_DEPTH) {
86
+ throw new Error("canonical depth exceeded");
87
+ }
88
+ if (o === null || o === undefined) {
89
+ return null;
90
+ }
91
+ if (typeof o === "boolean") {
92
+ return o;
93
+ }
94
+ if (typeof o === "number") {
95
+ if (isIntegral(o)) {
96
+ if (!Number.isFinite(o)) {
97
+ throw new Error("non-finite number is not canonicalizable");
98
+ }
99
+ return o; // emitted as an integer, matching a Python int
100
+ }
101
+ return pythonFloatRepr(o);
102
+ }
103
+ if (typeof o === "bigint") {
104
+ return Number(o);
105
+ }
106
+ if (typeof o === "string") {
107
+ return nfc(o);
108
+ }
109
+ if (Array.isArray(o)) {
110
+ return o.map((v) => canonicalize(v, depth + 1));
111
+ }
112
+ if (typeof o === "object") {
113
+ const src = o;
114
+ // NFC-normalize keys, then sort by the normalized string (Python sorts by
115
+ // `str(k)`; all our keys are already strings).
116
+ const entries = Object.keys(src).map((k) => [
117
+ nfc(k),
118
+ src[k],
119
+ ]);
120
+ entries.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
121
+ const out = {};
122
+ for (const [k, v] of entries) {
123
+ out[k] = canonicalize(v, depth + 1);
124
+ }
125
+ return out;
126
+ }
127
+ throw new Error(`non-canonicalizable type ${typeof o}`);
128
+ }
129
+ /** ensure_ascii=True JSON encoder with `(",",":")` separators over an already-
130
+ * canonicalized (key-sorted) value. We escape every non-ASCII char as \uXXXX to
131
+ * match Python's `json.dumps(ensure_ascii=True)`. */
132
+ function encodeAscii(v) {
133
+ if (v === null)
134
+ return "null";
135
+ if (typeof v === "boolean")
136
+ return v ? "true" : "false";
137
+ if (typeof v === "number") {
138
+ // Only integers reach here as numbers (floats are pre-stringified).
139
+ return String(v);
140
+ }
141
+ if (typeof v === "string")
142
+ return encodeAsciiString(v);
143
+ if (Array.isArray(v)) {
144
+ return "[" + v.map(encodeAscii).join(",") + "]";
145
+ }
146
+ // object: keys already canonical-sorted; preserve insertion order.
147
+ const parts = [];
148
+ for (const k of Object.keys(v)) {
149
+ parts.push(encodeAsciiString(k) + ":" + encodeAscii(v[k]));
150
+ }
151
+ return "{" + parts.join(",") + "}";
152
+ }
153
+ function encodeAsciiString(s) {
154
+ let out = '"';
155
+ for (const ch of s) {
156
+ const cp = ch.codePointAt(0);
157
+ if (ch === '"')
158
+ out += '\\"';
159
+ else if (ch === "\\")
160
+ out += "\\\\";
161
+ else if (ch === "\b")
162
+ out += "\\b";
163
+ else if (ch === "\f")
164
+ out += "\\f";
165
+ else if (ch === "\n")
166
+ out += "\\n";
167
+ else if (ch === "\r")
168
+ out += "\\r";
169
+ else if (ch === "\t")
170
+ out += "\\t";
171
+ else if (cp < 0x20)
172
+ out += "\\u" + cp.toString(16).padStart(4, "0");
173
+ else if (cp < 0x7f)
174
+ out += ch;
175
+ else {
176
+ // ensure_ascii: emit \uXXXX (surrogate pair for astral planes), matching
177
+ // Python's json encoder.
178
+ if (cp > 0xffff) {
179
+ const c = cp - 0x10000;
180
+ const hi = 0xd800 + (c >> 10);
181
+ const lo = 0xdc00 + (c & 0x3ff);
182
+ out +=
183
+ "\\u" +
184
+ hi.toString(16).padStart(4, "0") +
185
+ "\\u" +
186
+ lo.toString(16).padStart(4, "0");
187
+ }
188
+ else {
189
+ out += "\\u" + cp.toString(16).padStart(4, "0");
190
+ }
191
+ }
192
+ }
193
+ return out + '"';
194
+ }
195
+ /** THE canonical serialization — every hash site MUST use this (port of
196
+ * `contract.canonical_bytes`). */
197
+ export function canonicalBytes(obj) {
198
+ return Buffer.from(encodeAscii(canonicalize(obj, 0)), "utf-8");
199
+ }
200
+ /** The connector's per-tool hash, byte-identical to Python `_tool_hash`. The
201
+ * preimage is `{name, description, input_schema}` (snake_case schema key). */
202
+ export function toolHash(name, description, inputSchema) {
203
+ const bytes = canonicalBytes({
204
+ name,
205
+ description,
206
+ input_schema: inputSchema,
207
+ });
208
+ return "sha256:" + createHash("sha256").update(bytes).digest("hex");
209
+ }
210
+ /** Hash a PUBLIC tool-definition dict (port of cse `_hash_tool`): coerces
211
+ * name/description to strings, an absent/non-object inputSchema to `{}`.
212
+ *
213
+ * LATENT divergence (audit L2): on a `null` name/description we coerce to `""`,
214
+ * whereas Python `_hash_tool` does `str(None)` -> `"None"`. This is UNREACHABLE
215
+ * via the wrapper: `wrap.toolToDict` already normalizes a null/absent description
216
+ * to `""` before this is ever called (and a tool with a null NAME is dropped), so
217
+ * both languages hash `""`. The divergence only surfaces on a RAW-dict direct call
218
+ * to `hashTool({description: null})` that bypasses the wrapper's normalization —
219
+ * we keep the `""` coercion (it is the wrapper-faithful value) and note the gap. */
220
+ export function hashTool(defn) {
221
+ const name = defn.name === undefined || defn.name === null ? "" : String(defn.name);
222
+ const desc = defn.description === undefined || defn.description === null
223
+ ? ""
224
+ : String(defn.description);
225
+ const schema = defn.inputSchema;
226
+ const inSch = schema !== null && typeof schema === "object" && !Array.isArray(schema)
227
+ ? schema
228
+ : {};
229
+ return toolHash(name, desc, inSch);
230
+ }
231
+ //# sourceMappingURL=canonical.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.js","sourceRoot":"","sources":["../../src/canonical.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,eAAe,GAAG,EAAE,CAAC;AAW3B,SAAS,GAAG,CAAC,CAAS;IACpB,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC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AAC;IACpF,MAAM,IAAI,GACR,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI;QACzD,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;IAChC,MAAM,KAAK,GACT,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QACrE,CAAC,CAAE,MAAkC;QACrC,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The LOCAL breadcrumb store for OUR-OWN code failures (graceful-fail capture) —
3
+ * a port of Python `tooling/cse/errors.py`. A bug in our gate/wrapper must NEVER
4
+ * crash the agent's call: the entry points catch it, fail closed to a generic
5
+ * internal-error HOLD, and record a SCRUBBED breadcrumb here. A record carries
6
+ * ONLY the exception CLASS NAME, a closed `Operation`, our-authored location, the
7
+ * client version, and a dedup fingerprint — NEVER user data.
8
+ */
9
+ export declare const CLIENT_VERSION = "0.1.0";
10
+ export declare const ERROR_RECORD_KEYS: ReadonlySet<string>;
11
+ export declare enum Operation {
12
+ CALL_TOOL = "call_tool",
13
+ SEND_REQUEST = "send_request",
14
+ LIST_TOOLS = "list_tools",
15
+ GATE_DECISION = "gate_decision",
16
+ PROXY_GATE = "proxy_gate",
17
+ PROXY_RELAY = "proxy_relay"
18
+ }
19
+ export interface ErrorRecord {
20
+ readonly at: string;
21
+ readonly errorClass: string;
22
+ readonly operation: Operation;
23
+ readonly ourCodeLocation: string;
24
+ readonly clientVersion: string;
25
+ readonly fingerprint: string;
26
+ }
27
+ /** The SCRUBBED projection — only the `ERROR_RECORD_KEYS` allowlist. */
28
+ export declare function asRecord(r: ErrorRecord): Record<string, string>;
29
+ /** On-device append-only breadcrumb store; ZERO egress. */
30
+ export declare class ErrorStore {
31
+ private readonly now;
32
+ private readonly records;
33
+ constructor(now?: () => string);
34
+ capture(excClassName: string, operation: Operation, ourCodeLocation: string, clientVersion?: string): ErrorRecord;
35
+ snapshot(): ErrorRecord[];
36
+ scrubbedRecords(): Array<Record<string, string>>;
37
+ fingerprintCounts(): Record<string, number>;
38
+ }
39
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAMhD,CAAC;AAEH,oBAAY,SAAS;IACnB,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,UAAU,eAAe;IACzB,WAAW,gBAAgB;CAC5B;AAOD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,wEAAwE;AACxE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ/D;AAID,2DAA2D;AAC3D,qBAAa,UAAU;IAGT,OAAO,CAAC,QAAQ,CAAC,GAAG;IAFhC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;gBAEhB,GAAG,GAAE,MAAM,MAAkB;IAE1D,OAAO,CACL,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,SAAS,EACpB,eAAe,EAAE,MAAM,EACvB,aAAa,GAAE,MAAuB,GACrC,WAAW;IAgBd,QAAQ,IAAI,WAAW,EAAE;IAIzB,eAAe,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAIhD,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAO5C"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * The LOCAL breadcrumb store for OUR-OWN code failures (graceful-fail capture) —
3
+ * a port of Python `tooling/cse/errors.py`. A bug in our gate/wrapper must NEVER
4
+ * crash the agent's call: the entry points catch it, fail closed to a generic
5
+ * internal-error HOLD, and record a SCRUBBED breadcrumb here. A record carries
6
+ * ONLY the exception CLASS NAME, a closed `Operation`, our-authored location, the
7
+ * client version, and a dedup fingerprint — NEVER user data.
8
+ */
9
+ import { createHash } from "node:crypto";
10
+ import { utcNowIso } from "./preflight.js";
11
+ export const CLIENT_VERSION = "0.1.0";
12
+ export const ERROR_RECORD_KEYS = new Set([
13
+ "error_class",
14
+ "operation",
15
+ "our_code_location",
16
+ "client_version",
17
+ "fingerprint",
18
+ ]);
19
+ export var Operation;
20
+ (function (Operation) {
21
+ Operation["CALL_TOOL"] = "call_tool";
22
+ Operation["SEND_REQUEST"] = "send_request";
23
+ Operation["LIST_TOOLS"] = "list_tools";
24
+ Operation["GATE_DECISION"] = "gate_decision";
25
+ Operation["PROXY_GATE"] = "proxy_gate";
26
+ Operation["PROXY_RELAY"] = "proxy_relay";
27
+ })(Operation || (Operation = {}));
28
+ function fingerprint(errorClass, ourCodeLocation) {
29
+ const pre = `${errorClass}|${ourCodeLocation}`;
30
+ return createHash("sha256").update(pre, "utf-8").digest("hex").slice(0, 16);
31
+ }
32
+ /** The SCRUBBED projection — only the `ERROR_RECORD_KEYS` allowlist. */
33
+ export function asRecord(r) {
34
+ return {
35
+ error_class: r.errorClass,
36
+ operation: r.operation,
37
+ our_code_location: r.ourCodeLocation,
38
+ client_version: r.clientVersion,
39
+ fingerprint: r.fingerprint,
40
+ };
41
+ }
42
+ const MAX_RECORDS = 10_000;
43
+ /** On-device append-only breadcrumb store; ZERO egress. */
44
+ export class ErrorStore {
45
+ now;
46
+ records = [];
47
+ constructor(now = utcNowIso) {
48
+ this.now = now;
49
+ }
50
+ capture(excClassName, operation, ourCodeLocation, clientVersion = CLIENT_VERSION) {
51
+ const rec = {
52
+ at: this.now(),
53
+ errorClass: excClassName,
54
+ operation,
55
+ ourCodeLocation,
56
+ clientVersion,
57
+ fingerprint: fingerprint(excClassName, ourCodeLocation),
58
+ };
59
+ this.records.push(rec);
60
+ if (this.records.length > MAX_RECORDS) {
61
+ this.records.splice(0, this.records.length - MAX_RECORDS);
62
+ }
63
+ return rec;
64
+ }
65
+ snapshot() {
66
+ return [...this.records];
67
+ }
68
+ scrubbedRecords() {
69
+ return this.records.map(asRecord);
70
+ }
71
+ fingerprintCounts() {
72
+ const counts = {};
73
+ for (const r of this.records) {
74
+ counts[r.fingerprint] = (counts[r.fingerprint] ?? 0) + 1;
75
+ }
76
+ return counts;
77
+ }
78
+ }
79
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,MAAM,CAAC,MAAM,iBAAiB,GAAwB,IAAI,GAAG,CAAC;IAC5D,aAAa;IACb,WAAW;IACX,mBAAmB;IACnB,gBAAgB;IAChB,aAAa;CACd,CAAC,CAAC;AAEH,MAAM,CAAN,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,oCAAuB,CAAA;IACvB,0CAA6B,CAAA;IAC7B,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