@mcp-index/sdk 0.13.1 → 0.14.1
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/CHANGELOG.md +54 -41
- package/dist/src/canonical.d.ts +4 -0
- package/dist/src/canonical.d.ts.map +1 -1
- package/dist/src/canonical.js +54 -17
- package/dist/src/canonical.js.map +1 -1
- package/dist/src/gate.d.ts +15 -0
- package/dist/src/gate.d.ts.map +1 -1
- package/dist/src/gate.js +165 -17
- package/dist/src/gate.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/schemaDiff.d.ts +5 -0
- package/dist/src/schemaDiff.d.ts.map +1 -1
- package/dist/src/schemaDiff.js +66 -16
- package/dist/src/schemaDiff.js.map +1 -1
- package/dist/src/wrap.d.ts.map +1 -1
- package/dist/src/wrap.js +3 -2
- package/dist/src/wrap.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
# Changelog
|
|
1
|
+
# Changelog - @mcp-index/sdk
|
|
2
2
|
|
|
3
3
|
All notable changes to the TypeScript SDK. Versioning is semver (0.x: minor =
|
|
4
4
|
additive feature, patch = fix). Backward-compatible additions only in 0.2.0.
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## 0.14.1 - 2026-10-04
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Some changes that used to auto-accept now hold for review.
|
|
13
|
+
- Tool hashes for existing pins are unchanged.
|
|
14
|
+
|
|
15
|
+
## 0.14.0 - 2026-10-02
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Guard now holds a newly header-mirrored parameter, and users who want the old behaviour can run monitor.
|
|
20
|
+
|
|
8
21
|
## 0.13.1 - 2026-10-01
|
|
9
22
|
|
|
10
23
|
### Changed
|
|
@@ -116,7 +129,7 @@ classifications on the measured corpus.
|
|
|
116
129
|
|
|
117
130
|
New export: `isNumericOnlyDescriptionChange(before, after)`.
|
|
118
131
|
|
|
119
|
-
## 0.10.0
|
|
132
|
+
## 0.10.0 - 2026-08-05
|
|
120
133
|
|
|
121
134
|
**The HOLD text an agent reads is now separate from the one a human reads.** Behaviour
|
|
122
135
|
change on a shipped surface: `PreflightHold.message` (and the proxy's JSON-RPC error
|
|
@@ -124,22 +137,22 @@ change on a shipped surface: `PreflightHold.message` (and the proxy's JSON-RPC e
|
|
|
124
137
|
|
|
125
138
|
Why: on 2026-08-05 a frontier model met a real HOLD, classified the banner as a
|
|
126
139
|
prompt-injection attempt, refused to act on it, retried the held call, and told the user
|
|
127
|
-
something suspicious was intercepting its tools. Its load-bearing objection was not tone
|
|
140
|
+
something suspicious was intercepting its tools. Its load-bearing objection was not tone -
|
|
128
141
|
it could not verify us. The gate diffs the pin against the LIVE contract while the agent
|
|
129
142
|
sees only its own cached tool list, a third view that legitimately disagrees. We were
|
|
130
143
|
asserting a change the reader could not observe and then inviting it to act, which is the
|
|
131
144
|
shape of a manipulation attempt. Refusing was correct behaviour.
|
|
132
145
|
|
|
133
|
-
- **Added** `renderHoldMessage()`
|
|
146
|
+
- **Added** `renderHoldMessage()` - the agent-facing text. Renders the drift as an evidence
|
|
134
147
|
block (tool / change + path / effect / call sent), names the stale-tool-list mismatch
|
|
135
148
|
before the agent trips over it, and states the disposition without inviting any action.
|
|
136
|
-
- **Added** `PreflightHold.presentation`
|
|
149
|
+
- **Added** `PreflightHold.presentation` - the human brand banner, kept off `message`.
|
|
137
150
|
`String(err)` is what a builder is most likely to hand to a model.
|
|
138
|
-
- **Unchanged** `renderHoldBanner()` and `holdBanner()`
|
|
151
|
+
- **Unchanged** `renderHoldBanner()` and `holdBanner()` - same text, same meaning, for
|
|
139
152
|
humans and hosts.
|
|
140
|
-
- **Security:** the agent-facing message may only CONSTRAIN. `[Review
|
|
141
|
-
invited the reader toward `repin()`
|
|
142
|
-
new trusted baseline
|
|
153
|
+
- **Security:** the agent-facing message may only CONSTRAIN. `[Review | Re-pin | Validate]`
|
|
154
|
+
invited the reader toward `repin()` - the one action that makes a changed contract the
|
|
155
|
+
new trusted baseline - on a channel the agent must treat as attacker-controlled. That is
|
|
143
156
|
the text an attacker would forge; forging "stop and ask your human" earns them nothing.
|
|
144
157
|
- **Security:** no defence was traded away to get there. `mdText` escaping and
|
|
145
158
|
`redactGreenWords` now run per untrusted value rather than over the whole render, so they
|
|
@@ -147,13 +160,13 @@ shape of a manipulation attempt. Refusing was correct behaviour.
|
|
|
147
160
|
(`VALUE_CHAR_CAP`), closing an unbounded-render vector a security audit measured at 5.2 MB
|
|
148
161
|
from a 1.6 MB hostile tool name.
|
|
149
162
|
- **Fixed** (audit HIGH) `holdBanner()` fell through to the full detail banner when the
|
|
150
|
-
provenance choke refused or on an internal-error verdict
|
|
163
|
+
provenance choke refused or on an internal-error verdict - asserting a specific contract
|
|
151
164
|
change that, in the latter case, never happened. It now returns the generic notice, as
|
|
152
165
|
Python always did.
|
|
153
166
|
- **Fixed** evidence rows sort by codepoint, not `localeCompare`, so the two SDKs cannot
|
|
154
167
|
render different evidence for identical drift.
|
|
155
168
|
|
|
156
|
-
## 0.9.2
|
|
169
|
+
## 0.9.2 - 2026-07-29
|
|
157
170
|
|
|
158
171
|
Copy only, no behaviour change.
|
|
159
172
|
|
|
@@ -164,22 +177,22 @@ Copy only, no behaviour change.
|
|
|
164
177
|
- `package.json` description likewise names mcpindex.ai + the category; added
|
|
165
178
|
`mcpindex` keyword. Lockfile version resynced (was stale at 0.7.0).
|
|
166
179
|
|
|
167
|
-
## 0.9.1
|
|
180
|
+
## 0.9.1 - 2026-07-18
|
|
168
181
|
|
|
169
182
|
### Fixed
|
|
170
|
-
- **`wrap(session)` now works with no options
|
|
183
|
+
- **`wrap(session)` now works with no options - the README quickstart is honest
|
|
171
184
|
again.** `pin` and `serverId` are now OPTIONAL: when omitted, `wrap()` creates an
|
|
172
185
|
ephemeral in-memory `PreflightPin()` under the new `DEFAULT_SERVER_ID` ("mcp") and
|
|
173
186
|
pins each tool trust-on-first-use. Previously `wrap(session)` threw
|
|
174
187
|
`TypeError: Cannot read properties of undefined (reading 'pin')`, and
|
|
175
188
|
`wrap(session, { scanResults: true, onHold })` (no pin/serverId) HELD **every** call
|
|
176
189
|
with the internal-error banner. Security posture is unchanged: a missing pin
|
|
177
|
-
pins-on-first-use (TOFU) and HOLDs on drift
|
|
190
|
+
pins-on-first-use (TOFU) and HOLDs on drift - it never fails open. Pass an explicit
|
|
178
191
|
`{ pin, serverId }` for a durable/shared baseline or fleet telemetry.
|
|
179
192
|
- Exported `DEFAULT_SERVER_ID` for callers that want to reference the default pin
|
|
180
193
|
namespace explicitly.
|
|
181
194
|
|
|
182
|
-
## 0.9.0
|
|
195
|
+
## 0.9.0 - 2026-07-14
|
|
183
196
|
|
|
184
197
|
### Added
|
|
185
198
|
- **`mcpindex login` CLI.** New `mcpindex` bin with `login` / `whoami`. `login` opens
|
|
@@ -189,14 +202,14 @@ Copy only, no behaviour change.
|
|
|
189
202
|
callback is bound to a per-session nonce carried in the loopback path (closes
|
|
190
203
|
key-fixation); the key never transits a third party. `MCPINDEX_WEB_BASE` overrides the
|
|
191
204
|
default host. `whoami` reports sign-in state without ever printing the key.
|
|
192
|
-
- **`--provider github|google`** on `mcpindex login` (default `github`)
|
|
205
|
+
- **`--provider github|google`** on `mcpindex login` (default `github`) - selects the
|
|
193
206
|
identity provider; the loopback/nonce handoff is provider-agnostic.
|
|
194
207
|
|
|
195
|
-
## 0.7.0
|
|
208
|
+
## 0.7.0 - 2026-07-12
|
|
196
209
|
|
|
197
210
|
### Added
|
|
198
211
|
- **Result-content scanning (`scanResults`).** New opt-in gate that scans tool
|
|
199
|
-
RESULT content
|
|
212
|
+
RESULT content - text blocks and `structuredContent` - for prompt-injection,
|
|
200
213
|
exfiltration, and credential-path markers, giving TS parity with the Python
|
|
201
214
|
client. **Default OFF** (zero behavior change): a hostile result passes through
|
|
202
215
|
untouched unless enabled. When ON, a tainted result is WITHHELD under `GUARD`/
|
|
@@ -215,12 +228,12 @@ Copy only, no behaviour change.
|
|
|
215
228
|
`resource_link` URI is no longer a false positive; the scan budget is shared
|
|
216
229
|
across `content[]` + structured so a large result can't evade the cap.
|
|
217
230
|
|
|
218
|
-
## 0.6.1
|
|
231
|
+
## 0.6.1 - 2026-06-11
|
|
219
232
|
|
|
220
233
|
### Added
|
|
221
234
|
- **Read-only `lookup` telemetry mode.** `MCPINDEX_DRIFT_TELEMETRY` gains `lookup`
|
|
222
235
|
(vocabulary is now `off | lookup | detection | contribute`). `lookup` RECEIVES fleet
|
|
223
|
-
drift warnings (the salted-fingerprint query) while SENDING nothing
|
|
236
|
+
drift warnings (the salted-fingerprint query) while SENDING nothing - the gate splits the
|
|
224
237
|
former single switch into `readEnabled()` (any non-off mode) and `sendEnabled()`
|
|
225
238
|
(detection/contribute only), with a re-check at the enqueue boundary. Cross-language
|
|
226
239
|
parity with the Python client. Default stays `off` (zero egress).
|
|
@@ -230,7 +243,7 @@ Copy only, no behaviour change.
|
|
|
230
243
|
list) now name the `sdk` tag (`py`/`ts`) that the wire payload already includes, and
|
|
231
244
|
document `lookup` as low-egress (not zero-egress). Kept byte-identical to the Python notice.
|
|
232
245
|
|
|
233
|
-
## 0.6.0
|
|
246
|
+
## 0.6.0 - 2026-06-09
|
|
234
247
|
|
|
235
248
|
### Added
|
|
236
249
|
- **Fleet drift query (M3, "warns you on call 1").** On first pin the gate fire-and-forgets a
|
|
@@ -240,11 +253,11 @@ Copy only, no behaviour change.
|
|
|
240
253
|
fingerprint is the one already emitted), fail-open, AD-6-safe (never moves PROCEED/HOLD;
|
|
241
254
|
redirects hard-off). Exported: `driftQuery`, `FleetAdvisory`; surfaced by `renderVerdict`.
|
|
242
255
|
|
|
243
|
-
## 0.5.0
|
|
256
|
+
## 0.5.0 - 2026-06-09
|
|
244
257
|
|
|
245
258
|
### Added
|
|
246
259
|
- **Drift telemetry (M1, opt-in, OFF by default).** On a tool pin or a contract drift the
|
|
247
|
-
gate can emit one one-way signal
|
|
260
|
+
gate can emit one one-way signal - salted (HMAC) fingerprints of the server/tool id, the
|
|
248
261
|
contract hashes, the change type, a safety flag, an hour-rounded time, and a random install
|
|
249
262
|
id. Never a schema, argument, description, URL, or server/tool name. Enable with
|
|
250
263
|
`MCPINDEX_DRIFT_TELEMETRY=detection`; fail-open (never blocks or changes a tool call). The
|
|
@@ -255,45 +268,45 @@ Copy only, no behaviour change.
|
|
|
255
268
|
classification) shipped in 0.4.0, with the `MCPINDEX_ACTION_CLASSIFICATION_ENABLED=0`
|
|
256
269
|
opt-out. (0.4.0 published before the README caught up.)
|
|
257
270
|
|
|
258
|
-
## 0.4.0
|
|
271
|
+
## 0.4.0 - 2026-06-08
|
|
259
272
|
|
|
260
273
|
### Added
|
|
261
274
|
- **Local Tier-0a action classification (blast radius).** The gate now COMPUTES the
|
|
262
|
-
advisory `actionClassification` block locally from the live tool definition
|
|
263
|
-
type, resource, side-effect, reversibility, egress, and a static autonomy ceiling
|
|
275
|
+
advisory `actionClassification` block locally from the live tool definition - action
|
|
276
|
+
type, resource, side-effect, reversibility, egress, and a static autonomy ceiling -
|
|
264
277
|
instead of leaving it `null` until a hosted verdict supplied one. So the blast-radius
|
|
265
278
|
grade is on by default in the SDK, at parity with the Python `mcpindex-gate`
|
|
266
279
|
client. Default-on; opt out with `MCPINDEX_ACTION_CLASSIFICATION_ENABLED=0`. Pure,
|
|
267
280
|
deterministic, total, and a byte-for-byte port of the Python `cse.action_class.classify`
|
|
268
|
-
(12-case cross-language golden parity test). **Advisory only**
|
|
281
|
+
(12-case cross-language golden parity test). **Advisory only** - it rides alongside the
|
|
269
282
|
decision and never moves `PROCEED`/`HOLD` (AD-1). New exports: `classifyAction`,
|
|
270
283
|
`classifyToolDef`, `actionClassificationEnabled`, and the `ActionType` /
|
|
271
284
|
`SideEffectClass` / `Reversibility` / `Egress` / `ScopeHint` / `PatternShape` /
|
|
272
285
|
`AutonomyCeiling` / `NoteClass` / `Severity` / `EvidenceRefType` enums.
|
|
273
286
|
|
|
274
|
-
## 0.3.2
|
|
287
|
+
## 0.3.2 - 2026-06-08
|
|
275
288
|
|
|
276
289
|
### Fixed
|
|
277
|
-
- **Schema-content scanner no longer false-flags benign URLs**
|
|
290
|
+
- **Schema-content scanner no longer false-flags benign URLs** - the exfil tripwire
|
|
278
291
|
(`scanSchemaHasMarker`) had a bare `https?://` rule that flagged any URL in a tool's
|
|
279
292
|
declared schema as a CRITICAL exfil marker. A real crawl tripped it on a benign
|
|
280
293
|
`web_url_reader` whose `url` param carried example URLs. A URL now signals exfil only
|
|
281
|
-
in an exfil-verb context (`forward
|
|
294
|
+
in an exfil-verb context (`forward ... https://...`); example/doc URLs are clean.
|
|
282
295
|
Credential-path and injection detection unchanged. Mirrors the Python `schema_scan` fix.
|
|
283
296
|
|
|
284
|
-
## 0.3.1
|
|
297
|
+
## 0.3.1 - 2026-06-08
|
|
285
298
|
|
|
286
299
|
### Changed
|
|
287
|
-
- **Ambient line reworded `watching`
|
|
300
|
+
- **Ambient line reworded `watching` -> `noted`** - `mcpindex | noted <server>/<tool> - ...`.
|
|
288
301
|
The previous "watching" read like surveillance *of the user*; "noted" frames it as
|
|
289
302
|
mcpindex quietly keeping track on your behalf. Copy-only; behavior identical.
|
|
290
303
|
|
|
291
|
-
## 0.3.0
|
|
304
|
+
## 0.3.0 - 2026-06-08
|
|
292
305
|
|
|
293
306
|
### Added
|
|
294
|
-
- **Ambient presence (default-on).** A subtle, low-frequency `mcpindex
|
|
307
|
+
- **Ambient presence (default-on).** A subtle, low-frequency `mcpindex | watching
|
|
295
308
|
<server>/<tool>` line on the gate's PROCEED path so a user remembers mcpindex is
|
|
296
|
-
working
|
|
309
|
+
working - first-touch per tool (one line per distinct tool, silent on repeats) plus a
|
|
297
310
|
once-per-session summary. New `onInvocation` option on `wrap()` lets an integrator
|
|
298
311
|
render the signal in their own UI. The first line carries `(silence:
|
|
299
312
|
MCPINDEX_AMBIENT_NOTICE=off)` so the off-switch is always discoverable; cadence tunes
|
|
@@ -304,20 +317,20 @@ Copy only, no behaviour change.
|
|
|
304
317
|
decision or a tool call's result (a HOLD emits nothing; a broken notifier is swallowed).
|
|
305
318
|
New `ambient.ts` + 12 tests (incl. a stdout-stays-empty channel-safety assertion).
|
|
306
319
|
|
|
307
|
-
## 0.2.0
|
|
320
|
+
## 0.2.0 - 2026-06-07
|
|
308
321
|
|
|
309
322
|
### Added
|
|
310
|
-
- **`actionClassification` on `PreflightVerdict`**
|
|
323
|
+
- **`actionClassification` on `PreflightVerdict`** - the read-side mirror of the
|
|
311
324
|
server's Tier 0a advisory action-classification block: the *blast radius* of a tool
|
|
312
325
|
call (action type, resource, side-effect, reversibility, egress, and a static
|
|
313
326
|
autonomy ceiling). New exported `ActionClassification` type. Lets TS/JS consumers
|
|
314
327
|
read the block off a verdict.
|
|
315
|
-
- **Advisory only**
|
|
328
|
+
- **Advisory only** - it rides *alongside* the decision and never alters
|
|
316
329
|
`PROCEED`/`HOLD` (`isProceed` reads only `decision`).
|
|
317
|
-
- **Read-side only in this release**
|
|
330
|
+
- **Read-side only in this release** - the SDK does **not** yet *compute* the block
|
|
318
331
|
locally; the field is populated from a server/hosted verdict, else `null`. The
|
|
319
332
|
local `classify()` port lands with the in-process interceptor (deferred).
|
|
320
|
-
- **Backward-compatible**
|
|
333
|
+
- **Backward-compatible** - the field defaults to `null` in `makeVerdict`, so existing
|
|
321
334
|
consumers are unaffected. The nested block uses the snake_case wire keys (the server
|
|
322
335
|
JSON contract); the envelope stays camelCase.
|
|
323
336
|
|
|
@@ -328,6 +341,6 @@ Copy only, no behaviour change.
|
|
|
328
341
|
|
|
329
342
|
## 0.1.0
|
|
330
343
|
|
|
331
|
-
- Initial release: pre-flight MCP tool-contract drift interceptor
|
|
344
|
+
- Initial release: pre-flight MCP tool-contract drift interceptor - `wrap()` over an
|
|
332
345
|
MCP client session that HOLDs a tool call when the contract drifted from your pin.
|
|
333
346
|
No credential handling.
|
package/dist/src/canonical.d.ts
CHANGED
|
@@ -25,6 +25,10 @@ export type Json = null | boolean | number | string | Json[] | {
|
|
|
25
25
|
/** THE canonical serialization — every hash site MUST use this (port of
|
|
26
26
|
* `contract.canonical_bytes`). */
|
|
27
27
|
export declare function canonicalBytes(obj: unknown): Buffer;
|
|
28
|
+
/** Tool-contract serialization. Same walker as `canonicalBytes`, plus the
|
|
29
|
+
* NFC-collision and float-shaped-string rules. Ordinary inputs match
|
|
30
|
+
* `canonicalBytes`. Objects in this walker are `Object.create(null)`. */
|
|
31
|
+
export declare function contractBytes(obj: unknown): Buffer;
|
|
28
32
|
/** The connector's per-tool hash, byte-identical to Python `_tool_hash`. The
|
|
29
33
|
* preimage is `{name, description, input_schema}` (snake_case schema key). */
|
|
30
34
|
export declare function toolHash(name: string, description: string, inputSchema: Record<string, unknown>): string;
|
|
@@ -1 +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;
|
|
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;AAiM1B;kCACkC;AAClC,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAEnD;AAED;;yEAEyE;AACzE,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAElD;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"}
|
package/dist/src/canonical.js
CHANGED
|
@@ -81,7 +81,14 @@ function pythonFloatRepr(n) {
|
|
|
81
81
|
exp = exp.padStart(2, "0");
|
|
82
82
|
return `${mantissa}e${sign}${exp}`;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
const FLOATISH = /^-?[0-9]\.[0-9]{17}e[+-][0-9]{2,}$/;
|
|
85
|
+
function contractString(s) {
|
|
86
|
+
const n = nfc(s);
|
|
87
|
+
if (n.startsWith("\0") || FLOATISH.test(n))
|
|
88
|
+
return "\0" + n;
|
|
89
|
+
return n;
|
|
90
|
+
}
|
|
91
|
+
function canonicalize(o, depth, contract = false) {
|
|
85
92
|
if (depth > MAX_CANON_DEPTH) {
|
|
86
93
|
throw new Error("canonical depth exceeded");
|
|
87
94
|
}
|
|
@@ -104,23 +111,45 @@ function canonicalize(o, depth) {
|
|
|
104
111
|
return Number(o);
|
|
105
112
|
}
|
|
106
113
|
if (typeof o === "string") {
|
|
107
|
-
return nfc(o);
|
|
114
|
+
return contract ? contractString(o) : nfc(o);
|
|
108
115
|
}
|
|
109
116
|
if (Array.isArray(o)) {
|
|
110
|
-
return o.map((v) => canonicalize(v, depth + 1));
|
|
117
|
+
return o.map((v) => canonicalize(v, depth + 1, contract));
|
|
111
118
|
}
|
|
112
119
|
if (typeof o === "object") {
|
|
113
120
|
const src = o;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
src[k]
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
const keys = Object.keys(src);
|
|
122
|
+
if (!contract) {
|
|
123
|
+
// NFC-normalize keys, then sort by the normalized string (Python sorts by
|
|
124
|
+
// `str(k)`; all our keys are already strings).
|
|
125
|
+
const entries = keys.map((k) => [nfc(k), src[k]]);
|
|
126
|
+
entries.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
|
|
127
|
+
const out = {};
|
|
128
|
+
for (const [k, v] of entries) {
|
|
129
|
+
out[k] = canonicalize(v, depth + 1, false);
|
|
130
|
+
}
|
|
131
|
+
return out;
|
|
132
|
+
}
|
|
133
|
+
const groups = new Map();
|
|
134
|
+
for (const k of keys) {
|
|
135
|
+
const nk = nfc(k);
|
|
136
|
+
const g = groups.get(nk);
|
|
137
|
+
if (g === undefined)
|
|
138
|
+
groups.set(nk, [k]);
|
|
139
|
+
else
|
|
140
|
+
g.push(k);
|
|
141
|
+
}
|
|
142
|
+
const out = Object.create(null);
|
|
143
|
+
for (const [nk, ks] of groups) {
|
|
144
|
+
if (ks.length === 1) {
|
|
145
|
+
const only = ks[0];
|
|
146
|
+
out[nk] = canonicalize(src[only], depth + 1, true);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
for (const k of ks) {
|
|
150
|
+
out[k] = canonicalize(src[k], depth + 1, true);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
124
153
|
}
|
|
125
154
|
return out;
|
|
126
155
|
}
|
|
@@ -143,9 +172,11 @@ function encodeAscii(v) {
|
|
|
143
172
|
if (Array.isArray(v)) {
|
|
144
173
|
return "[" + v.map(encodeAscii).join(",") + "]";
|
|
145
174
|
}
|
|
146
|
-
//
|
|
175
|
+
// sort_keys, matching Python json.dumps. The contract walker inserts in
|
|
176
|
+
// first-seen order; the dump is what makes ordinary objects byte-stable.
|
|
147
177
|
const parts = [];
|
|
148
|
-
|
|
178
|
+
const keys = Object.keys(v).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
179
|
+
for (const k of keys) {
|
|
149
180
|
parts.push(encodeAsciiString(k) + ":" + encodeAscii(v[k]));
|
|
150
181
|
}
|
|
151
182
|
return "{" + parts.join(",") + "}";
|
|
@@ -195,12 +226,18 @@ function encodeAsciiString(s) {
|
|
|
195
226
|
/** THE canonical serialization — every hash site MUST use this (port of
|
|
196
227
|
* `contract.canonical_bytes`). */
|
|
197
228
|
export function canonicalBytes(obj) {
|
|
198
|
-
return Buffer.from(encodeAscii(canonicalize(obj, 0)), "utf-8");
|
|
229
|
+
return Buffer.from(encodeAscii(canonicalize(obj, 0, false)), "utf-8");
|
|
230
|
+
}
|
|
231
|
+
/** Tool-contract serialization. Same walker as `canonicalBytes`, plus the
|
|
232
|
+
* NFC-collision and float-shaped-string rules. Ordinary inputs match
|
|
233
|
+
* `canonicalBytes`. Objects in this walker are `Object.create(null)`. */
|
|
234
|
+
export function contractBytes(obj) {
|
|
235
|
+
return Buffer.from(encodeAscii(canonicalize(obj, 0, true)), "utf-8");
|
|
199
236
|
}
|
|
200
237
|
/** The connector's per-tool hash, byte-identical to Python `_tool_hash`. The
|
|
201
238
|
* preimage is `{name, description, input_schema}` (snake_case schema key). */
|
|
202
239
|
export function toolHash(name, description, inputSchema) {
|
|
203
|
-
const bytes =
|
|
240
|
+
const bytes = contractBytes({
|
|
204
241
|
name,
|
|
205
242
|
description,
|
|
206
243
|
input_schema: inputSchema,
|
|
@@ -1 +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,SAA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AI,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"}
|
package/dist/src/gate.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { PreflightPin } from "./preflight.js";
|
|
10
10
|
import type { PinnedTool, PreflightVerdict, ToolDef } from "./preflight.js";
|
|
11
11
|
import { ChangeKind, isSafetyRelevant } from "./schemaDiff.js";
|
|
12
|
+
import type { Change } from "./schemaDiff.js";
|
|
12
13
|
import { ErrorStore, Operation } from "./errors.js";
|
|
13
14
|
declare const DEFAULT_BEHAVIORAL_MANDATED_KINDS: ReadonlySet<ChangeKind>;
|
|
14
15
|
export declare enum Posture {
|
|
@@ -16,6 +17,7 @@ export declare enum Posture {
|
|
|
16
17
|
GUARD = "guard",
|
|
17
18
|
STRICT = "strict"
|
|
18
19
|
}
|
|
20
|
+
export declare const GUARD_DANGEROUS_KINDS: ReadonlySet<ChangeKind>;
|
|
19
21
|
export declare const HELD_PROVENANCE_UNAVAILABLE_BANNER = "\u2B21 mcpindex \u2014 held a call before your agent ran it (provenance unavailable; no detail shown).";
|
|
20
22
|
/** The AGENT-facing twin of the banner above. Same fact, no brand glyph, no chrome.
|
|
21
23
|
*
|
|
@@ -113,6 +115,14 @@ export interface GateOptions {
|
|
|
113
115
|
posture?: Posture;
|
|
114
116
|
errors?: ErrorStore | null;
|
|
115
117
|
}
|
|
118
|
+
export interface GateEffect {
|
|
119
|
+
kind: "repin" | "drift" | "fleet";
|
|
120
|
+
toolName: string;
|
|
121
|
+
observed?: ToolDef | null;
|
|
122
|
+
oldHash?: string;
|
|
123
|
+
newHash?: string;
|
|
124
|
+
drift?: readonly Change[];
|
|
125
|
+
}
|
|
116
126
|
export declare class Gate {
|
|
117
127
|
private readonly pin;
|
|
118
128
|
private readonly _serverId;
|
|
@@ -139,6 +149,11 @@ export declare class Gate {
|
|
|
139
149
|
* null when the live definition is unavailable or the flag is off. Mirrors the
|
|
140
150
|
* Python wrapper's `build_action_classification`. */
|
|
141
151
|
evaluate(name: string, observed: ToolDef | null): PreflightVerdict;
|
|
152
|
+
/** `(static, effective, effects)` with no pin write, telemetry send, or fleet read. */
|
|
153
|
+
assess(name: string, observed: ToolDef | null): [PreflightVerdict, PreflightVerdict, GateEffect[]];
|
|
154
|
+
/** Run effects, then re-apply posture so the fleet advisory rides as `evaluate` did. */
|
|
155
|
+
commit(stat: PreflightVerdict, effects: readonly GateEffect[]): [PreflightVerdict, PreflightVerdict];
|
|
156
|
+
private collect;
|
|
142
157
|
private decideContract;
|
|
143
158
|
private classifyDrift;
|
|
144
159
|
private mandatedUnhashedDrift;
|
package/dist/src/gate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../src/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAGL,YAAY,EAIb,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EACL,UAAU,
|
|
1
|
+
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../src/gate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAGL,YAAY,EAIb,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAg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