@mcp-index/sdk 0.14.0 → 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 +48 -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 +14 -0
- package/dist/src/gate.d.ts.map +1 -1
- package/dist/src/gate.js +159 -16
- 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,17 @@
|
|
|
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
|
+
|
|
8
15
|
## 0.14.0 - 2026-10-02
|
|
9
16
|
|
|
10
17
|
### Changed
|
|
@@ -122,7 +129,7 @@ classifications on the measured corpus.
|
|
|
122
129
|
|
|
123
130
|
New export: `isNumericOnlyDescriptionChange(before, after)`.
|
|
124
131
|
|
|
125
|
-
## 0.10.0
|
|
132
|
+
## 0.10.0 - 2026-08-05
|
|
126
133
|
|
|
127
134
|
**The HOLD text an agent reads is now separate from the one a human reads.** Behaviour
|
|
128
135
|
change on a shipped surface: `PreflightHold.message` (and the proxy's JSON-RPC error
|
|
@@ -130,22 +137,22 @@ change on a shipped surface: `PreflightHold.message` (and the proxy's JSON-RPC e
|
|
|
130
137
|
|
|
131
138
|
Why: on 2026-08-05 a frontier model met a real HOLD, classified the banner as a
|
|
132
139
|
prompt-injection attempt, refused to act on it, retried the held call, and told the user
|
|
133
|
-
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 -
|
|
134
141
|
it could not verify us. The gate diffs the pin against the LIVE contract while the agent
|
|
135
142
|
sees only its own cached tool list, a third view that legitimately disagrees. We were
|
|
136
143
|
asserting a change the reader could not observe and then inviting it to act, which is the
|
|
137
144
|
shape of a manipulation attempt. Refusing was correct behaviour.
|
|
138
145
|
|
|
139
|
-
- **Added** `renderHoldMessage()`
|
|
146
|
+
- **Added** `renderHoldMessage()` - the agent-facing text. Renders the drift as an evidence
|
|
140
147
|
block (tool / change + path / effect / call sent), names the stale-tool-list mismatch
|
|
141
148
|
before the agent trips over it, and states the disposition without inviting any action.
|
|
142
|
-
- **Added** `PreflightHold.presentation`
|
|
149
|
+
- **Added** `PreflightHold.presentation` - the human brand banner, kept off `message`.
|
|
143
150
|
`String(err)` is what a builder is most likely to hand to a model.
|
|
144
|
-
- **Unchanged** `renderHoldBanner()` and `holdBanner()`
|
|
151
|
+
- **Unchanged** `renderHoldBanner()` and `holdBanner()` - same text, same meaning, for
|
|
145
152
|
humans and hosts.
|
|
146
|
-
- **Security:** the agent-facing message may only CONSTRAIN. `[Review
|
|
147
|
-
invited the reader toward `repin()`
|
|
148
|
-
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
|
|
149
156
|
the text an attacker would forge; forging "stop and ask your human" earns them nothing.
|
|
150
157
|
- **Security:** no defence was traded away to get there. `mdText` escaping and
|
|
151
158
|
`redactGreenWords` now run per untrusted value rather than over the whole render, so they
|
|
@@ -153,13 +160,13 @@ shape of a manipulation attempt. Refusing was correct behaviour.
|
|
|
153
160
|
(`VALUE_CHAR_CAP`), closing an unbounded-render vector a security audit measured at 5.2 MB
|
|
154
161
|
from a 1.6 MB hostile tool name.
|
|
155
162
|
- **Fixed** (audit HIGH) `holdBanner()` fell through to the full detail banner when the
|
|
156
|
-
provenance choke refused or on an internal-error verdict
|
|
163
|
+
provenance choke refused or on an internal-error verdict - asserting a specific contract
|
|
157
164
|
change that, in the latter case, never happened. It now returns the generic notice, as
|
|
158
165
|
Python always did.
|
|
159
166
|
- **Fixed** evidence rows sort by codepoint, not `localeCompare`, so the two SDKs cannot
|
|
160
167
|
render different evidence for identical drift.
|
|
161
168
|
|
|
162
|
-
## 0.9.2
|
|
169
|
+
## 0.9.2 - 2026-07-29
|
|
163
170
|
|
|
164
171
|
Copy only, no behaviour change.
|
|
165
172
|
|
|
@@ -170,22 +177,22 @@ Copy only, no behaviour change.
|
|
|
170
177
|
- `package.json` description likewise names mcpindex.ai + the category; added
|
|
171
178
|
`mcpindex` keyword. Lockfile version resynced (was stale at 0.7.0).
|
|
172
179
|
|
|
173
|
-
## 0.9.1
|
|
180
|
+
## 0.9.1 - 2026-07-18
|
|
174
181
|
|
|
175
182
|
### Fixed
|
|
176
|
-
- **`wrap(session)` now works with no options
|
|
183
|
+
- **`wrap(session)` now works with no options - the README quickstart is honest
|
|
177
184
|
again.** `pin` and `serverId` are now OPTIONAL: when omitted, `wrap()` creates an
|
|
178
185
|
ephemeral in-memory `PreflightPin()` under the new `DEFAULT_SERVER_ID` ("mcp") and
|
|
179
186
|
pins each tool trust-on-first-use. Previously `wrap(session)` threw
|
|
180
187
|
`TypeError: Cannot read properties of undefined (reading 'pin')`, and
|
|
181
188
|
`wrap(session, { scanResults: true, onHold })` (no pin/serverId) HELD **every** call
|
|
182
189
|
with the internal-error banner. Security posture is unchanged: a missing pin
|
|
183
|
-
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
|
|
184
191
|
`{ pin, serverId }` for a durable/shared baseline or fleet telemetry.
|
|
185
192
|
- Exported `DEFAULT_SERVER_ID` for callers that want to reference the default pin
|
|
186
193
|
namespace explicitly.
|
|
187
194
|
|
|
188
|
-
## 0.9.0
|
|
195
|
+
## 0.9.0 - 2026-07-14
|
|
189
196
|
|
|
190
197
|
### Added
|
|
191
198
|
- **`mcpindex login` CLI.** New `mcpindex` bin with `login` / `whoami`. `login` opens
|
|
@@ -195,14 +202,14 @@ Copy only, no behaviour change.
|
|
|
195
202
|
callback is bound to a per-session nonce carried in the loopback path (closes
|
|
196
203
|
key-fixation); the key never transits a third party. `MCPINDEX_WEB_BASE` overrides the
|
|
197
204
|
default host. `whoami` reports sign-in state without ever printing the key.
|
|
198
|
-
- **`--provider github|google`** on `mcpindex login` (default `github`)
|
|
205
|
+
- **`--provider github|google`** on `mcpindex login` (default `github`) - selects the
|
|
199
206
|
identity provider; the loopback/nonce handoff is provider-agnostic.
|
|
200
207
|
|
|
201
|
-
## 0.7.0
|
|
208
|
+
## 0.7.0 - 2026-07-12
|
|
202
209
|
|
|
203
210
|
### Added
|
|
204
211
|
- **Result-content scanning (`scanResults`).** New opt-in gate that scans tool
|
|
205
|
-
RESULT content
|
|
212
|
+
RESULT content - text blocks and `structuredContent` - for prompt-injection,
|
|
206
213
|
exfiltration, and credential-path markers, giving TS parity with the Python
|
|
207
214
|
client. **Default OFF** (zero behavior change): a hostile result passes through
|
|
208
215
|
untouched unless enabled. When ON, a tainted result is WITHHELD under `GUARD`/
|
|
@@ -221,12 +228,12 @@ Copy only, no behaviour change.
|
|
|
221
228
|
`resource_link` URI is no longer a false positive; the scan budget is shared
|
|
222
229
|
across `content[]` + structured so a large result can't evade the cap.
|
|
223
230
|
|
|
224
|
-
## 0.6.1
|
|
231
|
+
## 0.6.1 - 2026-06-11
|
|
225
232
|
|
|
226
233
|
### Added
|
|
227
234
|
- **Read-only `lookup` telemetry mode.** `MCPINDEX_DRIFT_TELEMETRY` gains `lookup`
|
|
228
235
|
(vocabulary is now `off | lookup | detection | contribute`). `lookup` RECEIVES fleet
|
|
229
|
-
drift warnings (the salted-fingerprint query) while SENDING nothing
|
|
236
|
+
drift warnings (the salted-fingerprint query) while SENDING nothing - the gate splits the
|
|
230
237
|
former single switch into `readEnabled()` (any non-off mode) and `sendEnabled()`
|
|
231
238
|
(detection/contribute only), with a re-check at the enqueue boundary. Cross-language
|
|
232
239
|
parity with the Python client. Default stays `off` (zero egress).
|
|
@@ -236,7 +243,7 @@ Copy only, no behaviour change.
|
|
|
236
243
|
list) now name the `sdk` tag (`py`/`ts`) that the wire payload already includes, and
|
|
237
244
|
document `lookup` as low-egress (not zero-egress). Kept byte-identical to the Python notice.
|
|
238
245
|
|
|
239
|
-
## 0.6.0
|
|
246
|
+
## 0.6.0 - 2026-06-09
|
|
240
247
|
|
|
241
248
|
### Added
|
|
242
249
|
- **Fleet drift query (M3, "warns you on call 1").** On first pin the gate fire-and-forgets a
|
|
@@ -246,11 +253,11 @@ Copy only, no behaviour change.
|
|
|
246
253
|
fingerprint is the one already emitted), fail-open, AD-6-safe (never moves PROCEED/HOLD;
|
|
247
254
|
redirects hard-off). Exported: `driftQuery`, `FleetAdvisory`; surfaced by `renderVerdict`.
|
|
248
255
|
|
|
249
|
-
## 0.5.0
|
|
256
|
+
## 0.5.0 - 2026-06-09
|
|
250
257
|
|
|
251
258
|
### Added
|
|
252
259
|
- **Drift telemetry (M1, opt-in, OFF by default).** On a tool pin or a contract drift the
|
|
253
|
-
gate can emit one one-way signal
|
|
260
|
+
gate can emit one one-way signal - salted (HMAC) fingerprints of the server/tool id, the
|
|
254
261
|
contract hashes, the change type, a safety flag, an hour-rounded time, and a random install
|
|
255
262
|
id. Never a schema, argument, description, URL, or server/tool name. Enable with
|
|
256
263
|
`MCPINDEX_DRIFT_TELEMETRY=detection`; fail-open (never blocks or changes a tool call). The
|
|
@@ -261,45 +268,45 @@ Copy only, no behaviour change.
|
|
|
261
268
|
classification) shipped in 0.4.0, with the `MCPINDEX_ACTION_CLASSIFICATION_ENABLED=0`
|
|
262
269
|
opt-out. (0.4.0 published before the README caught up.)
|
|
263
270
|
|
|
264
|
-
## 0.4.0
|
|
271
|
+
## 0.4.0 - 2026-06-08
|
|
265
272
|
|
|
266
273
|
### Added
|
|
267
274
|
- **Local Tier-0a action classification (blast radius).** The gate now COMPUTES the
|
|
268
|
-
advisory `actionClassification` block locally from the live tool definition
|
|
269
|
-
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 -
|
|
270
277
|
instead of leaving it `null` until a hosted verdict supplied one. So the blast-radius
|
|
271
278
|
grade is on by default in the SDK, at parity with the Python `mcpindex-gate`
|
|
272
279
|
client. Default-on; opt out with `MCPINDEX_ACTION_CLASSIFICATION_ENABLED=0`. Pure,
|
|
273
280
|
deterministic, total, and a byte-for-byte port of the Python `cse.action_class.classify`
|
|
274
|
-
(12-case cross-language golden parity test). **Advisory only**
|
|
281
|
+
(12-case cross-language golden parity test). **Advisory only** - it rides alongside the
|
|
275
282
|
decision and never moves `PROCEED`/`HOLD` (AD-1). New exports: `classifyAction`,
|
|
276
283
|
`classifyToolDef`, `actionClassificationEnabled`, and the `ActionType` /
|
|
277
284
|
`SideEffectClass` / `Reversibility` / `Egress` / `ScopeHint` / `PatternShape` /
|
|
278
285
|
`AutonomyCeiling` / `NoteClass` / `Severity` / `EvidenceRefType` enums.
|
|
279
286
|
|
|
280
|
-
## 0.3.2
|
|
287
|
+
## 0.3.2 - 2026-06-08
|
|
281
288
|
|
|
282
289
|
### Fixed
|
|
283
|
-
- **Schema-content scanner no longer false-flags benign URLs**
|
|
290
|
+
- **Schema-content scanner no longer false-flags benign URLs** - the exfil tripwire
|
|
284
291
|
(`scanSchemaHasMarker`) had a bare `https?://` rule that flagged any URL in a tool's
|
|
285
292
|
declared schema as a CRITICAL exfil marker. A real crawl tripped it on a benign
|
|
286
293
|
`web_url_reader` whose `url` param carried example URLs. A URL now signals exfil only
|
|
287
|
-
in an exfil-verb context (`forward
|
|
294
|
+
in an exfil-verb context (`forward ... https://...`); example/doc URLs are clean.
|
|
288
295
|
Credential-path and injection detection unchanged. Mirrors the Python `schema_scan` fix.
|
|
289
296
|
|
|
290
|
-
## 0.3.1
|
|
297
|
+
## 0.3.1 - 2026-06-08
|
|
291
298
|
|
|
292
299
|
### Changed
|
|
293
|
-
- **Ambient line reworded `watching`
|
|
300
|
+
- **Ambient line reworded `watching` -> `noted`** - `mcpindex | noted <server>/<tool> - ...`.
|
|
294
301
|
The previous "watching" read like surveillance *of the user*; "noted" frames it as
|
|
295
302
|
mcpindex quietly keeping track on your behalf. Copy-only; behavior identical.
|
|
296
303
|
|
|
297
|
-
## 0.3.0
|
|
304
|
+
## 0.3.0 - 2026-06-08
|
|
298
305
|
|
|
299
306
|
### Added
|
|
300
|
-
- **Ambient presence (default-on).** A subtle, low-frequency `mcpindex
|
|
307
|
+
- **Ambient presence (default-on).** A subtle, low-frequency `mcpindex | watching
|
|
301
308
|
<server>/<tool>` line on the gate's PROCEED path so a user remembers mcpindex is
|
|
302
|
-
working
|
|
309
|
+
working - first-touch per tool (one line per distinct tool, silent on repeats) plus a
|
|
303
310
|
once-per-session summary. New `onInvocation` option on `wrap()` lets an integrator
|
|
304
311
|
render the signal in their own UI. The first line carries `(silence:
|
|
305
312
|
MCPINDEX_AMBIENT_NOTICE=off)` so the off-switch is always discoverable; cadence tunes
|
|
@@ -310,20 +317,20 @@ Copy only, no behaviour change.
|
|
|
310
317
|
decision or a tool call's result (a HOLD emits nothing; a broken notifier is swallowed).
|
|
311
318
|
New `ambient.ts` + 12 tests (incl. a stdout-stays-empty channel-safety assertion).
|
|
312
319
|
|
|
313
|
-
## 0.2.0
|
|
320
|
+
## 0.2.0 - 2026-06-07
|
|
314
321
|
|
|
315
322
|
### Added
|
|
316
|
-
- **`actionClassification` on `PreflightVerdict`**
|
|
323
|
+
- **`actionClassification` on `PreflightVerdict`** - the read-side mirror of the
|
|
317
324
|
server's Tier 0a advisory action-classification block: the *blast radius* of a tool
|
|
318
325
|
call (action type, resource, side-effect, reversibility, egress, and a static
|
|
319
326
|
autonomy ceiling). New exported `ActionClassification` type. Lets TS/JS consumers
|
|
320
327
|
read the block off a verdict.
|
|
321
|
-
- **Advisory only**
|
|
328
|
+
- **Advisory only** - it rides *alongside* the decision and never alters
|
|
322
329
|
`PROCEED`/`HOLD` (`isProceed` reads only `decision`).
|
|
323
|
-
- **Read-side only in this release**
|
|
330
|
+
- **Read-side only in this release** - the SDK does **not** yet *compute* the block
|
|
324
331
|
locally; the field is populated from a server/hosted verdict, else `null`. The
|
|
325
332
|
local `classify()` port lands with the in-process interceptor (deferred).
|
|
326
|
-
- **Backward-compatible**
|
|
333
|
+
- **Backward-compatible** - the field defaults to `null` in `makeVerdict`, so existing
|
|
327
334
|
consumers are unaffected. The nested block uses the snake_case wire keys (the server
|
|
328
335
|
JSON contract); the envelope stays camelCase.
|
|
329
336
|
|
|
@@ -334,6 +341,6 @@ Copy only, no behaviour change.
|
|
|
334
341
|
|
|
335
342
|
## 0.1.0
|
|
336
343
|
|
|
337
|
-
- Initial release: pre-flight MCP tool-contract drift interceptor
|
|
344
|
+
- Initial release: pre-flight MCP tool-contract drift interceptor - `wrap()` over an
|
|
338
345
|
MCP client session that HOLDs a tool call when the contract drifted from your pin.
|
|
339
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,SAAS,GAAG,CAAC,CAAS;IACpB,OAAO,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,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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 {
|
|
@@ -114,6 +115,14 @@ export interface GateOptions {
|
|
|
114
115
|
posture?: Posture;
|
|
115
116
|
errors?: ErrorStore | null;
|
|
116
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
|
+
}
|
|
117
126
|
export declare class Gate {
|
|
118
127
|
private readonly pin;
|
|
119
128
|
private readonly _serverId;
|
|
@@ -140,6 +149,11 @@ export declare class Gate {
|
|
|
140
149
|
* null when the live definition is unavailable or the flag is off. Mirrors the
|
|
141
150
|
* Python wrapper's `build_action_classification`. */
|
|
142
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;
|
|
143
157
|
private decideContract;
|
|
144
158
|
private classifyDrift;
|
|
145
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,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EACL,UAAU,EAIV,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAM9C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAKpD,QAAA,MAAM,iCAAiC,EAAE,WAAW,CAAC,UAAU,CAG7D,CAAC;AASH,oBAAY,OAAO;IACjB,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAID,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,UAAU,CAgBxD,CAAC;AAuCH,eAAO,MAAM,kCAAkC,2GACoD,CAAC;AAE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