@nulladrift/core 0.7.1 → 0.8.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 (36) hide show
  1. package/dist/{chunk-TBVL7XVR.js → chunk-5OCXDAFS.js} +18 -5
  2. package/dist/chunk-5OCXDAFS.js.map +1 -0
  3. package/dist/{chunk-DF52BV5H.js → chunk-FVT77BL4.js} +22 -2
  4. package/dist/chunk-FVT77BL4.js.map +1 -0
  5. package/dist/{chunk-2TZBS4SQ.js → chunk-OJCQ2CU3.js} +1 -1
  6. package/dist/chunk-OJCQ2CU3.js.map +1 -0
  7. package/dist/{chunk-2BZR6CAV.js → chunk-TRNJNLQQ.js} +2 -2
  8. package/dist/{chunk-6WXMFDJM.js → chunk-XUKSVMFX.js} +100 -19
  9. package/dist/chunk-XUKSVMFX.js.map +1 -0
  10. package/dist/{chunk-WEU7FBSB.js → chunk-ZD2C4FMT.js} +18 -4
  11. package/dist/chunk-ZD2C4FMT.js.map +1 -0
  12. package/dist/diff/index.d.ts +1 -1
  13. package/dist/diff/index.js +5 -5
  14. package/dist/diff/schema.d.ts +1 -1
  15. package/dist/diff/schema.js +2 -2
  16. package/dist/index.d.ts +15 -4
  17. package/dist/index.js +17 -11
  18. package/dist/index.js.map +1 -1
  19. package/dist/lock/canonical.d.ts +1 -1
  20. package/dist/lock/credentials.d.ts +3 -1
  21. package/dist/lock/credentials.js +1 -1
  22. package/dist/lock/jsonschema.d.ts +7 -2
  23. package/dist/lock/jsonschema.js +3 -1
  24. package/dist/lock/normalize.d.ts +7 -8
  25. package/dist/lock/normalize.js +3 -3
  26. package/dist/lock/reseal.d.ts +1 -1
  27. package/dist/lock/types.d.ts +1 -1
  28. package/dist/lock/types.js +1 -1
  29. package/dist/{types-Tbdp5tnv.d.ts → types-B4YmIRoy.d.ts} +34 -1
  30. package/package.json +1 -1
  31. package/dist/chunk-2TZBS4SQ.js.map +0 -1
  32. package/dist/chunk-6WXMFDJM.js.map +0 -1
  33. package/dist/chunk-DF52BV5H.js.map +0 -1
  34. package/dist/chunk-TBVL7XVR.js.map +0 -1
  35. package/dist/chunk-WEU7FBSB.js.map +0 -1
  36. /package/dist/{chunk-2BZR6CAV.js.map → chunk-TRNJNLQQ.js.map} +0 -0
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  redactPath
3
- } from "./chunk-WEU7FBSB.js";
3
+ } from "./chunk-ZD2C4FMT.js";
4
4
  import {
5
5
  MAX_VISIT_DEPTH,
6
6
  alternatives,
7
7
  asObject,
8
8
  effectiveSchema
9
- } from "./chunk-DF52BV5H.js";
9
+ } from "./chunk-FVT77BL4.js";
10
10
 
11
11
  // src/lock/normalize.ts
12
12
  function resolveBehavior(annotations) {
@@ -21,16 +21,29 @@ function resolveBehavior(annotations) {
21
21
  function isEscalation(previous, next) {
22
22
  return previous.readOnly && !next.readOnly || !previous.destructive && next.destructive || previous.idempotent && !next.idempotent || !previous.openWorld && next.openWorld;
23
23
  }
24
+ var DATA_KEYWORDS = /* @__PURE__ */ new Set(["const", "default", "enum", "examples", "example"]);
25
+ var NAMED_SCHEMAS = /* @__PURE__ */ new Set(["properties", "patternProperties", "$defs", "definitions", "dependentSchemas"]);
24
26
  function normalizeSchema(value) {
25
- if (Array.isArray(value)) return value.map(normalizeSchema);
27
+ return normalizeNode(value, false);
28
+ }
29
+ function normalizeNode(value, namesOnly) {
30
+ if (Array.isArray(value)) return value.map((member) => normalizeNode(member, false));
26
31
  if (value === null || typeof value !== "object") return value;
27
32
  const out = /* @__PURE__ */ Object.create(null);
28
33
  for (const [key, member] of Object.entries(value)) {
34
+ if (namesOnly) {
35
+ out[key] = normalizeNode(member, false);
36
+ continue;
37
+ }
29
38
  if (key === "required" && Array.isArray(member) && member.every((entry) => typeof entry === "string")) {
30
39
  out[key] = [...member].sort();
31
40
  continue;
32
41
  }
33
- out[key] = normalizeSchema(member);
42
+ if (DATA_KEYWORDS.has(key)) {
43
+ out[key] = member;
44
+ continue;
45
+ }
46
+ out[key] = normalizeNode(member, NAMED_SCHEMAS.has(key));
34
47
  }
35
48
  return out;
36
49
  }
@@ -106,4 +119,4 @@ export {
106
119
  stripIgnoredMeta,
107
120
  sanitizeUrl
108
121
  };
109
- //# sourceMappingURL=chunk-TBVL7XVR.js.map
122
+ //# sourceMappingURL=chunk-5OCXDAFS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lock/normalize.ts"],"sourcesContent":["/** Turning what a server sent into the stable, reviewable form the lock stores. */\nimport { redactPath } from \"./credentials\";\nimport { alternatives, asObject, effectiveSchema, MAX_VISIT_DEPTH } from \"./jsonschema\";\nimport type { JsonObject, JsonValue, LockedAnnotations, LockedBehavior } from \"./types\";\n\n/**\n * Resolves the four behavioural annotations against the spec's defaults, which are not neutral:\n * an absent `readOnlyHint` means \"may modify\" and an absent `destructiveHint` means \"may\n * destroy\". A server deleting an annotation is therefore an escalation, and the lock has to be\n * able to show it as a changed value rather than a removed line. See docs/lockfile.md §4.\n *\n * `destructiveHint` and `idempotentHint` are defined to be meaningful only when `readOnlyHint`\n * is false, so a read-only tool resolves to non-destructive and idempotent regardless of what\n * it claims: a tool that changes nothing cannot destroy anything, and repeating it has no\n * additional effect.\n */\nexport function resolveBehavior(annotations: LockedAnnotations | undefined): LockedBehavior {\n const readOnly = annotations?.readOnlyHint ?? false;\n return {\n readOnly,\n destructive: readOnly ? false : (annotations?.destructiveHint ?? true),\n idempotent: readOnly ? true : (annotations?.idempotentHint ?? false),\n openWorld: annotations?.openWorldHint ?? true,\n };\n}\n\n/** True when `next` claims any power `previous` did not. */\nexport function isEscalation(previous: LockedBehavior, next: LockedBehavior): boolean {\n return (\n (previous.readOnly && !next.readOnly) ||\n (!previous.destructive && next.destructive) ||\n (previous.idempotent && !next.idempotent) ||\n (!previous.openWorld && next.openWorld)\n );\n}\n\n/*\n * Keywords whose value is data rather than a schema. A `required` array inside a `const` or a\n * `default` is part of a value the model is shown, and its order is the server's to choose:\n * sorting it there made `[\"backup\", \"delete\"]` and `[\"delete\", \"backup\"]` compare as the same.\n */\nconst DATA_KEYWORDS = new Set([\"const\", \"default\", \"enum\", \"examples\", \"example\"]);\n/** Keywords whose value maps names to schemas: the keys are names, never keywords. */\nconst NAMED_SCHEMAS = new Set([\"properties\", \"patternProperties\", \"$defs\", \"definitions\", \"dependentSchemas\"]);\n\n/**\n * Sorts the `required` keyword's array. Member order there is semantically insignificant and is\n * the most common source of diffs that mean nothing. Every other array keeps server order,\n * because order *is* significant in `prefixItems`, `allOf` and `icons`, and we only reorder where\n * we can show it is safe.\n *\n * Only where `required` is a keyword: not inside a value (`const`, `default`, `enum`,\n * `examples`), and not as the name of a property, which is a schema of its own.\n */\nexport function normalizeSchema(value: JsonValue): JsonValue {\n return normalizeNode(value, false);\n}\n\nfunction normalizeNode(value: JsonValue, namesOnly: boolean): JsonValue {\n if (Array.isArray(value)) return value.map((member) => normalizeNode(member, false));\n if (value === null || typeof value !== \"object\") return value;\n\n // No prototype, so a member named `__proto__` is kept (see toJson in canonical.ts).\n const out = Object.create(null) as JsonObject;\n for (const [key, member] of Object.entries(value)) {\n if (namesOnly) {\n out[key] = normalizeNode(member, false);\n continue;\n }\n if (key === \"required\" && Array.isArray(member) && member.every((entry) => typeof entry === \"string\")) {\n out[key] = [...(member as string[])].sort();\n continue;\n }\n if (DATA_KEYWORDS.has(key)) {\n out[key] = member;\n continue;\n }\n out[key] = normalizeNode(member, NAMED_SCHEMAS.has(key));\n }\n return out;\n}\n\n/**\n * Finds input properties carrying an `x-mcp-header` annotation, which mirrors the argument's\n * value into an `Mcp-Param-*` HTTP header on Streamable HTTP, where proxies and WAFs can read\n * it. A server adding this to an existing parameter redirects that argument's data with no\n * visible change to the tool's signature, so it gets its own line in the lock.\n *\n * `$ref` and `allOf` are resolved first. Schema generators put properties behind `$defs` as a\n * matter of course, and a scan that only read literal nodes found nothing in those -- which is\n * the worst outcome for a field whose entire purpose is to move data somewhere new.\n */\nexport function extractHeaderParams(schema: JsonValue): string[] {\n const found: string[] = [];\n /*\n * Bounded twice. A `$ref` already on the way down is not followed again: a definition whose\n * properties point back at it was walked once per property per level, P^12 calls, so a\n * 200-byte schema held `check` for minutes on a blocked event loop that no timeout could\n * interrupt. Headers inside a recursion are the ones its first pass already found. And a hard\n * ceiling on visits, which leaves a marker in the lock rather than an incomplete list that\n * looks complete.\n */\n let budget = MAX_HEADER_VISITS;\n\n const walk = (node: JsonValue, path: string[], depth: number, refsOnPath: ReadonlySet<string>): void => {\n if (depth > MAX_VISIT_DEPTH) return;\n if (budget <= 0) return;\n budget -= 1;\n const object = effectiveSchema(node, schema);\n if (!object) return;\n\n const properties = asObject(object[\"properties\"]);\n if (properties) {\n for (const [name, child] of Object.entries(properties)) {\n const resolved = effectiveSchema(child, schema);\n if (!resolved) continue;\n const header = resolved[\"x-mcp-header\"];\n if (typeof header === \"string\" && header.length > 0) found.push(`${[...path, name].join(\".\")} -> ${header}`);\n const ref = asObject(child)?.[\"$ref\"];\n if (typeof ref === \"string\" && refsOnPath.has(ref)) continue;\n walk(child, [...path, name], depth + 1, typeof ref === \"string\" ? new Set([...refsOnPath, ref]) : refsOnPath);\n }\n }\n\n // A parameter reachable only through one branch of an `anyOf` is still reachable.\n for (const branch of alternatives(object)) {\n const ref = asObject(branch.schema)?.[\"$ref\"];\n if (typeof ref === \"string\" && refsOnPath.has(ref)) continue;\n walk(branch.schema, path, depth + 1, typeof ref === \"string\" ? new Set([...refsOnPath, ref]) : refsOnPath);\n }\n };\n\n const rootRef = asObject(schema)?.[\"$ref\"];\n walk(schema, [], 0, new Set(typeof rootRef === \"string\" ? [rootRef] : []));\n if (budget <= 0) found.push(`(schema too large to scan for headers past ${MAX_HEADER_VISITS} nodes)`);\n return [...new Set(found)].sort();\n}\n\n/** How many schema nodes the header scan visits before it stops and says so. */\nexport const MAX_HEADER_VISITS = 20_000;\n\n/** Drops `_meta` keys under any ignored prefix. Returns undefined when nothing is left to pin. */\nexport function stripIgnoredMeta(meta: JsonValue | undefined, ignoredPrefixes: readonly string[]): JsonObject | undefined {\n if (meta === null || meta === undefined || typeof meta !== \"object\" || Array.isArray(meta)) return undefined;\n const out = Object.create(null) as JsonObject;\n for (const [key, value] of Object.entries(meta)) {\n if (ignoredPrefixes.some((prefix) => key.startsWith(prefix))) continue;\n out[key] = value;\n }\n return Object.keys(out).length > 0 ? out : undefined;\n}\n\n/** Strips the query string: query strings routinely carry tokens, and the lock is committed. */\nexport function sanitizeUrl(raw: string): string {\n /*\n * A placeholder (`${HOST}`, `${PORT}`) is kept exactly as written. Parsing first lowercased a\n * placeholder in the host, so the lock named a variable the config never used, and failed on one\n * in the port, which wrote the address raw, query string and all.\n */\n if (raw.includes(\"${\")) return sanitizeText(raw);\n try {\n const url = new URL(raw);\n url.search = \"\";\n url.hash = \"\";\n /*\n * `https://alice:s3cr3t@host/mcp` survived this untouched, because `toString()` keeps\n * userinfo. The query string was stripped on the grounds that credentials usually sit there;\n * userinfo is the one place a credential sits by definition.\n */\n url.username = \"\";\n url.password = \"\";\n // A hosted server whose address embeds the key keeps it in the path, past both of the above.\n url.pathname = redactPath(url.pathname);\n return url.toString();\n } catch {\n return sanitizeText(raw);\n }\n}\n\n/** The same, as text, for an address a URL parser cannot or should not normalize. */\nfunction sanitizeText(raw: string): string {\n const withoutUser = raw.replace(/^([a-z][a-z0-9+.-]*:\\/\\/)[^/@]*@/i, \"$1\");\n const base = withoutUser.split(/[?#]/)[0] ?? withoutUser;\n const parts = /^([a-z][a-z0-9+.-]*:\\/\\/[^/]*)(\\/.*)?$/i.exec(base);\n return parts ? `${parts[1]}${parts[2] ? redactPath(parts[2]) : \"\"}` : base;\n}\n"],"mappings":";;;;;;;;;;;AAgBO,SAAS,gBAAgB,aAA4D;AAC1F,QAAM,WAAW,aAAa,gBAAgB;AAC9C,SAAO;AAAA,IACL;AAAA,IACA,aAAa,WAAW,QAAS,aAAa,mBAAmB;AAAA,IACjE,YAAY,WAAW,OAAQ,aAAa,kBAAkB;AAAA,IAC9D,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__PURE__ */ new WeakMap();
7
+ function stateOf(root) {
8
+ if (root === null || typeof root !== "object") return { refs: /* @__PURE__ */ new Map(), spent: 0 };
9
+ let state = states.get(root);
10
+ if (!state) {
11
+ state = { refs: /* @__PURE__ */ new Map(), spent: 0 };
12
+ states.set(root, state);
13
+ }
14
+ return state;
15
+ }
5
16
  function asObject(value) {
6
17
  return value !== null && value !== void 0 && typeof value === "object" && !Array.isArray(value) ? value : void 0;
7
18
  }
@@ -29,6 +40,9 @@ function effectiveSchema(node, root, seenRefs = /* @__PURE__ */ new Set(), depth
29
40
  const object = asObject(node);
30
41
  if (object === void 0) return void 0;
31
42
  if (depth > MAX_REF_DEPTH) return object;
43
+ const state = stateOf(root);
44
+ if (depth === 0) state.spent = 0;
45
+ if (++state.spent > MAX_RESOLUTIONS) return object;
32
46
  const out = /* @__PURE__ */ Object.create(null);
33
47
  const merge = (source) => {
34
48
  for (const [key, value] of Object.entries(source)) {
@@ -50,7 +64,12 @@ function effectiveSchema(node, root, seenRefs = /* @__PURE__ */ new Set(), depth
50
64
  merge(object);
51
65
  const ref = object["$ref"];
52
66
  if (typeof ref === "string" && !seenRefs.has(ref)) {
53
- const resolved = effectiveSchema(resolvePointer(root, ref), root, /* @__PURE__ */ new Set([...seenRefs, ref]), depth + 1);
67
+ let resolved;
68
+ if (state.refs.has(ref)) resolved = state.refs.get(ref);
69
+ else {
70
+ resolved = effectiveSchema(resolvePointer(root, ref), root, /* @__PURE__ */ new Set([...seenRefs, ref]), depth + 1);
71
+ state.refs.set(ref, resolved);
72
+ }
54
73
  if (resolved) merge(resolved);
55
74
  }
56
75
  const allOf = object["allOf"];
@@ -79,9 +98,10 @@ export {
79
98
  MAX_REF_DEPTH,
80
99
  MAX_VISIT_DEPTH,
81
100
  MAX_FACTS,
101
+ MAX_RESOLUTIONS,
82
102
  asObject,
83
103
  resolvePointer,
84
104
  effectiveSchema,
85
105
  alternatives
86
106
  };
87
- //# sourceMappingURL=chunk-DF52BV5H.js.map
107
+ //# sourceMappingURL=chunk-FVT77BL4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lock/jsonschema.ts"],"sourcesContent":["/**\n * Just enough JSON Schema to see through the indirection servers actually use.\n *\n * Two parts of this tool have to look inside a tool's `inputSchema`: the widening heuristic and\n * the `x-mcp-header` scan. Both used to read only the literal node in front of them, so a schema\n * that put its properties behind `$ref` or `allOf` -- which the generators for Pydantic, Zod and\n * most OpenAPI toolchains do by default -- looked empty to both. A widened parameter went out as\n * a bare `.changed`, and a parameter newly mirrored into an HTTP header was missed entirely.\n *\n * This is not a validator. It resolves local `$ref`, flattens `allOf`, and leaves the\n * alternation keywords for the caller to branch on. Remote `$ref` is never fetched: an audit\n * that reaches out to a URL named by the thing it is auditing is not an audit.\n */\nimport type { JsonObject, JsonValue } from \"./types\";\n\n/** Depth caps. A hostile or merely recursive schema must not be able to hang the run. */\nexport const MAX_REF_DEPTH = 32;\nexport const MAX_VISIT_DEPTH = 12;\nexport const MAX_FACTS = 5_000;\n/**\n * Nodes one call may merge. A ceiling on total work, where the depth caps only bound how far down\n * one path goes; see `effectiveSchema`.\n */\nexport const MAX_RESOLUTIONS = 100_000;\n\n/*\n * What each `$ref` resolves to, per schema root. Without it, `allOf: [{$ref: next} x4]` at each of\n * sixteen levels resolved `next` once per path to it: 4^16 resolutions for an 1.8 KB schema,\n * synchronously, after the server had answered, so no timeout could stop it. A definition means\n * the same thing wherever it is referenced from, so it is resolved once.\n */\ninterface ResolutionState {\n refs: Map<string, JsonObject | undefined>;\n spent: number;\n}\nconst states = new WeakMap<object, ResolutionState>();\n\nfunction stateOf(root: JsonValue): ResolutionState {\n if (root === null || typeof root !== \"object\") return { refs: new Map(), spent: 0 };\n let state = states.get(root);\n if (!state) {\n state = { refs: new Map(), spent: 0 };\n states.set(root, state);\n }\n return state;\n}\n\nexport function asObject(value: JsonValue | undefined): JsonObject | undefined {\n return value !== null && value !== undefined && typeof value === \"object\" && !Array.isArray(value) ? (value as JsonObject) : undefined;\n}\n\n/** RFC 6901 token decoding: `~1` is `/` and `~0` is `~`, in that order. */\nfunction decodeToken(token: string): string {\n let decoded = token;\n try {\n decoded = decodeURIComponent(token);\n } catch {\n // A malformed escape is a literal, not a reason to abandon the schema.\n }\n return decoded.replace(/~1/g, \"/\").replace(/~0/g, \"~\");\n}\n\n/** Resolves a local JSON pointer. Anything with a non-empty URI part is left unresolved. */\nexport function resolvePointer(root: JsonValue, ref: string): JsonValue | undefined {\n if (!ref.startsWith(\"#\")) return undefined;\n const pointer = ref.slice(1);\n if (pointer !== \"\" && !pointer.startsWith(\"/\")) return undefined; // `#anchor`, which needs an anchor index.\n\n let node: JsonValue | undefined = root;\n for (const token of pointer.split(\"/\").slice(1)) {\n const object = asObject(node);\n if (object === undefined) return undefined;\n node = object[decodeToken(token)];\n }\n return node;\n}\n\n/**\n * The keywords in effect at a node, with `$ref` followed and `allOf` folded in.\n *\n * The node's own keywords win over anything it inherits, `properties` are unioned, and\n * `required` is the union of every contributor -- which is what `allOf` means. Alternation\n * (`anyOf` / `oneOf` / `then` / `else`) is deliberately left in place: a caller that wants to\n * treat branches as separate possibilities can, and one that does not is no worse off.\n */\nexport function effectiveSchema(node: JsonValue | undefined, root: JsonValue, seenRefs: ReadonlySet<string> = new Set(), depth = 0): JsonObject | undefined {\n const object = asObject(node);\n if (object === undefined) return undefined;\n if (depth > MAX_REF_DEPTH) return object;\n const state = stateOf(root);\n if (depth === 0) state.spent = 0;\n // Past the budget, a node is taken as written. Less precise, and never unbounded.\n if (++state.spent > MAX_RESOLUTIONS) return object;\n\n /*\n * No prototype, and own-property checks rather than `in`. `name in merged` on a plain object is\n * true for `constructor`, `toString` and `__proto__`, so a property with one of those names was\n * skipped as already merged, and `merged[\"__proto__\"] = ...` set the prototype instead.\n */\n const out = Object.create(null) as JsonObject;\n const merge = (source: JsonObject): void => {\n for (const [key, value] of Object.entries(source)) {\n if (key === \"$ref\" || key === \"allOf\") continue;\n if (key === \"properties\") {\n // First contributor wins on a conflict, and keeps its position: the merged object reads\n // in the order a person wrote it, not inside-out from the inheritance chain.\n const merged = Object.assign(Object.create(null) as JsonObject, asObject(out[\"properties\"]) ?? {});\n for (const [name, schema] of Object.entries(asObject(value) ?? {})) {\n if (!Object.hasOwn(merged, name)) Object.defineProperty(merged, name, { value: schema, enumerable: true, writable: true, configurable: true });\n }\n out[\"properties\"] = merged;\n } else if (key === \"required\" && Array.isArray(value)) {\n const already = Array.isArray(out[\"required\"]) ? (out[\"required\"] as JsonValue[]) : [];\n out[\"required\"] = [...new Set([...already, ...value].filter((entry): entry is string => typeof entry === \"string\"))];\n } else if (!Object.hasOwn(out, key)) {\n out[key] = value;\n }\n }\n };\n\n // The node itself first, so its own keywords take precedence over what it inherits.\n merge(object);\n\n const ref = object[\"$ref\"];\n if (typeof ref === \"string\" && !seenRefs.has(ref)) {\n let resolved: JsonObject | undefined;\n if (state.refs.has(ref)) resolved = state.refs.get(ref);\n else {\n resolved = effectiveSchema(resolvePointer(root, ref), root, new Set([...seenRefs, ref]), depth + 1);\n state.refs.set(ref, resolved);\n }\n if (resolved) merge(resolved);\n }\n\n const allOf = object[\"allOf\"];\n if (Array.isArray(allOf)) {\n for (const branch of allOf) {\n const resolved = effectiveSchema(branch, root, seenRefs, depth + 1);\n if (resolved) merge(resolved);\n }\n }\n\n return out;\n}\n\n/** The alternation branches at a node, labelled so a caller can key facts by them. */\nexport function alternatives(object: JsonObject): Array<{ label: string; schema: JsonValue }> {\n const branches: Array<{ label: string; schema: JsonValue }> = [];\n for (const keyword of [\"anyOf\", \"oneOf\"] as const) {\n const value = object[keyword];\n if (!Array.isArray(value)) continue;\n value.forEach((schema, index) => branches.push({ label: `${keyword}[${index}]`, schema }));\n }\n for (const keyword of [\"then\", \"else\", \"not\"] as const) {\n if (object[keyword] !== undefined) branches.push({ label: keyword, schema: object[keyword] as JsonValue });\n }\n return branches;\n}\n"],"mappings":";AAgBO,IAAM,gBAAgB;AACtB,IAAM,kBAAkB;AACxB,IAA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IAAI,GAAG;AAAA,SACjD;AACH,iBAAW,gBAAgB,eAAe,MAAM,GAAG,GAAG,MAAM,oBAAI,IAAI,CAAC,GAAG,UAAU,GAAG,CAAC,GAAG,QAAQ,CAAC;AAClG,YAAM,KAAK,IAAI,KAAK,QAAQ;AAAA,IAC9B;AACA,QAAI,SAAU,OAAM,QAAQ;AAAA,EAC9B;AAEA,QAAM,QAAQ,OAAO,OAAO;AAC5B,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAW,UAAU,OAAO;AAC1B,YAAM,WAAW,gBAAgB,QAAQ,MAAM,UAAU,QAAQ,CAAC;AAClE,UAAI,SAAU,OAAM,QAAQ;AAAA,IAC9B;AAAA,EACF;AAEA,SAAO;AACT;AAGO,SAAS,aAAa,QAAiE;AAC5F,QAAM,WAAwD,CAAC;AAC/D,aAAW,WAAW,CAAC,SAAS,OAAO,GAAY;AACjD,UAAM,QAAQ,OAAO,OAAO;AAC5B,QAAI,CAAC,MAAM,QAAQ,KAAK,EAAG;AAC3B,UAAM,QAAQ,CAAC,QAAQ,UAAU,SAAS,KAAK,EAAE,OAAO,GAAG,OAAO,IAAI,KAAK,KAAK,OAAO,CAAC,CAAC;AAAA,EAC3F;AACA,aAAW,WAAW,CAAC,QAAQ,QAAQ,KAAK,GAAY;AACtD,QAAI,OAAO,OAAO,MAAM,OAAW,UAAS,KAAK,EAAE,OAAO,SAAS,QAAQ,OAAO,OAAO,EAAe,CAAC;AAAA,EAC3G;AACA,SAAO;AACT;","names":[]}
@@ -6,4 +6,4 @@ export {
6
6
  LOCKFILE_VERSION,
7
7
  SUBJECT_KINDS
8
8
  };
9
- //# sourceMappingURL=chunk-2TZBS4SQ.js.map
9
+ //# sourceMappingURL=chunk-OJCQ2CU3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lock/types.ts"],"sourcesContent":["/** The shape of `mcp.lock`. Mirrors schema/mcp.lock.schema.json, which is the published contract. */\n\n/**\n * Bumped to 2 when the root stopped naming a protocol.\n *\n * Version 1 keyed everything under `servers`, which made the format MCP's rather than the\n * product's: an agent's grants, an OpenAPI surface or a token's scopes had nowhere to live\n * without a second root key and a second diff path. Version 2 keys them all under `subjects`,\n * each tagged with what it is.\n *\n * A version 1 file is upgraded on read rather than refused, and the upgrade is lossless:\n * `kind` is not part of any digest (see `reseal.ts`, which covers an explicit field list), so\n * an upgraded lock reseals to exactly the digests it arrived with and nobody sees drift that\n * is really a format change.\n */\nexport const LOCKFILE_VERSION = 2;\n\nimport type { CapabilityKind } from \"../risk/capability\";\n\nexport type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\nexport type JsonObject = { [key: string]: JsonValue };\n\nexport interface Lockfile {\n lockfileVersion: number;\n generatedBy?: string;\n policy?: LockPolicy;\n /**\n * Everything this project has pinned, keyed by identity. One map rather than a key per kind,\n * so adding a kind is a new member of `LockedSubject` and not a new branch in every consumer.\n */\n subjects: Record<string, LockedSubject>;\n /**\n * Servers the project knowingly leaves unaudited, by how they are reached: a server that only\n * runs on developers' machines, or needs a credential CI does not hold. Written by\n * `init --allow-unreachable` and by accepting the server in `review`.\n *\n * Under `--allow-unreachable`, a configured server that could not be audited passes only if it\n * is listed here with the same transport. Without the list, a pull request that added a server\n * which refused the auditor -- one that exits when the client says it is nulladrift -- passed\n * with it in the configuration and nothing in the report. Outside the digest and the diff: it\n * pins nothing, it only records what was agreed to go unpinned.\n */\n unaudited?: Record<string, LockedUnaudited>;\n}\n\nexport interface LockedUnaudited {\n /** Absent for a definition this tool cannot read at all (an unsupported transport). */\n transport?: LockedTransport;\n}\n\n/**\n * What a pinned thing is.\n *\n * The list is short because only one reader exists. The point of naming it at all is that the\n * diff engine, the policy evaluator and the audit log already do not care which one they are\n * looking at, so the cost of the second is a reader and a vocabulary rather than a redesign.\n */\nexport const SUBJECT_KINDS = [\"mcp-server\"] as const;\nexport type SubjectKind = (typeof SUBJECT_KINDS)[number];\n\nexport interface LockPolicy {\n /** Reverse-DNS `_meta` key prefixes to leave out, for servers that put build ids there. */\n ignoreMetaPrefixes?: string[];\n allowUnreachable?: boolean;\n /**\n * Capabilities no server in this project may have. Checked against the surface itself rather\n * than against the diff, so accepting drift cannot make one allowed and a repository that never\n * changes is still covered.\n *\n * There is deliberately no steering equivalent: a capability is a fact about schema shape, and\n * a steering signal is a regular expression over prose that legitimate servers trip.\n */\n deniedCapabilities?: CapabilityKind[];\n}\n\nexport type ClientKind =\n | \"claude-code\"\n | \"claude-desktop\"\n | \"vscode\"\n | \"cursor\"\n | \"copilot\"\n | \"windsurf\"\n | \"generic\"\n | \"manual\";\n\nexport interface LockedSource {\n client: ClientKind;\n /** Repo-relative where possible, else with the home directory written as `~`. Never an absolute machine path. */\n file: string;\n scope?: \"project\" | \"user\" | \"local\";\n}\n\nexport interface LockedStdioTransport {\n type: \"stdio\";\n command: string;\n args?: string[];\n /** Names only. The lock is committed; the values are credentials. */\n envKeys?: string[];\n cwd?: string;\n}\n\nexport interface LockedHttpTransport {\n type: \"http\" | \"sse\";\n /** Query string removed: query strings routinely carry tokens. */\n url: string;\n headerKeys?: string[];\n}\n\nexport type LockedTransport = LockedStdioTransport | LockedHttpTransport;\n\nexport interface LockedProtocol {\n era: \"modern\" | \"legacy\";\n version: string;\n supportedVersions?: string[];\n}\n\n/**\n * What a stdio invocation actually ran: the artifact behind the command, by content address.\n *\n * Everything else in a locked server describes what the server *says* -- its tools, its\n * instructions, even `serverInfo.version`, which is self-reported over the wire. None of it says\n * what code is answering. A release that keeps every tool name, description and schema byte for\n * byte while changing what the tools do is invisible to all of it, and that is the supply-chain\n * attack this category exists to catch.\n *\n * Deliberately outside the server digest. A lock written before this existed, or a run that\n * could not reach a registry, has no provenance; folding it into the digest would turn every\n * upgrade of this tool and every offline run into drift against servers nobody touched. It is\n * compared on its own instead -- before the digest short-circuit, since the case it exists for\n * is the one where the digest has not moved.\n */\nexport interface LockedProvenance {\n ecosystem: \"npm\" | \"pypi\" | \"oci\" | \"file\";\n /** The package, image or path, as its registry names it. */\n name: string;\n /** The exact version that ran: never a range, a dist-tag or `latest`. Absent for a file. */\n version?: string;\n /**\n * A content address for exactly those bytes: npm's `dist.integrity`, a PyPI distribution's\n * sha256, an OCI manifest digest, or the sha256 of the file. Absent when it could not be\n * established, which is a gap in the record rather than a claim about the artifact.\n */\n integrity?: string;\n /**\n * How the invocation asked for it -- `@1.2.3`, `^1`, or nothing at all. Kept because it is the\n * actionable half: a server that floats will move on its own, and the fix is in the config.\n */\n requested?: string;\n /**\n * Every file published for this release, by name, with its sha256. PyPI only.\n *\n * `integrity` covers one file -- the sdist, or the first universal wheel -- and that is rarely\n * the one an installer runs: uv and pip take the best wheel for the platform. PyPI also lets a\n * maintainer add a file to a release after it is published. So a platform wheel added to a\n * pinned version, or the pinned file removed so another is chosen, changed what ran and left\n * `integrity` where it was. The release is pinned as the set of its files.\n */\n files?: Record<string, string>;\n}\n\nexport interface LockedServerInfo {\n name?: string;\n title?: string;\n version?: string;\n description?: string;\n websiteUrl?: string;\n /** Recorded since a security review: a server could point its icon at any URL and compare clean. */\n icons?: LockedIcon[];\n}\n\nexport interface LockedAnnotations {\n title?: string;\n readOnlyHint?: boolean;\n destructiveHint?: boolean;\n idempotentHint?: boolean;\n openWorldHint?: boolean;\n}\n\n/** Annotations resolved against the spec's defaults. See docs/lockfile.md §4. */\nexport interface LockedBehavior {\n readOnly: boolean;\n destructive: boolean;\n idempotent: boolean;\n openWorld: boolean;\n}\n\nexport interface LockedIcon {\n src: string;\n mimeType?: string;\n sizes?: string[];\n theme?: \"light\" | \"dark\";\n}\n\nexport interface LockedTool {\n name: string;\n title?: string;\n description?: string;\n inputSchema: JsonObject;\n outputSchema?: JsonObject;\n annotations?: LockedAnnotations;\n behavior: LockedBehavior;\n /** `propertyPath -> HeaderName`, sorted. Derived from `x-mcp-header`. */\n headerParams?: string[];\n icons?: LockedIcon[];\n /**\n * How the tool may be run (`taskSupport`: forbidden, optional, required). A tool that started\n * requiring to be run as a task behaves differently for every client, and was not recorded.\n */\n execution?: JsonObject;\n meta?: JsonObject;\n digest: string;\n}\n\nexport interface LockedResource {\n uri: string;\n name: string;\n title?: string;\n description?: string;\n mimeType?: string;\n annotations?: JsonObject;\n icons?: LockedIcon[];\n meta?: JsonObject;\n digest: string;\n}\n\nexport interface LockedResourceTemplate {\n uriTemplate: string;\n name: string;\n title?: string;\n description?: string;\n mimeType?: string;\n annotations?: JsonObject;\n icons?: LockedIcon[];\n meta?: JsonObject;\n digest: string;\n}\n\nexport interface LockedPromptArgument {\n name: string;\n title?: string;\n description?: string;\n required?: boolean;\n}\n\nexport interface LockedPrompt {\n name: string;\n title?: string;\n description?: string;\n arguments?: LockedPromptArgument[];\n icons?: LockedIcon[];\n meta?: JsonObject;\n digest: string;\n}\n\n/** What every pinned thing carries, whatever it is. */\nexport interface LockedSubjectBase {\n kind: SubjectKind;\n source: LockedSource;\n digest: string;\n}\n\n/** An MCP server's declared capability surface. The first subject kind, and so far the only one. */\nexport interface LockedMcpServer extends LockedSubjectBase {\n kind: \"mcp-server\";\n transport: LockedTransport;\n /** What the command resolved to. Stdio only, and only when it could be established. */\n provenance?: LockedProvenance;\n protocol: LockedProtocol;\n serverInfo?: LockedServerInfo;\n capabilities?: JsonObject;\n instructions?: string;\n tools?: LockedTool[];\n resources?: LockedResource[];\n resourceTemplates?: LockedResourceTemplate[];\n prompts?: LockedPrompt[];\n}\n\n/**\n * A union of one, deliberately. An agent's grants or an OpenAPI surface joins here, and every\n * consumer that switches on `kind` gets a compiler error pointing at the branch it is missing.\n */\nexport type LockedSubject = LockedMcpServer;\n\n/** Anything in the lock that carries its own digest and is matched by a stable key. */\nexport type LockedMember = LockedTool | LockedResource | LockedResourceTemplate | LockedPrompt;\n"],"mappings":";AAeO,IAAM,mBAAmB;AA0CzB,IAAM,gBAAgB,CAAC,YAAY;","names":[]}
@@ -8,7 +8,7 @@ import {
8
8
  alternatives,
9
9
  asObject,
10
10
  effectiveSchema
11
- } from "./chunk-DF52BV5H.js";
11
+ } from "./chunk-FVT77BL4.js";
12
12
 
13
13
  // src/diff/schema.ts
14
14
  function numberAt(node, key) {
@@ -124,4 +124,4 @@ function classifySchemaChange(before, after) {
124
124
  export {
125
125
  classifySchemaChange
126
126
  };
127
- //# sourceMappingURL=chunk-2BZR6CAV.js.map
127
+ //# sourceMappingURL=chunk-TRNJNLQQ.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  isEscalation
3
- } from "./chunk-TBVL7XVR.js";
3
+ } from "./chunk-5OCXDAFS.js";
4
4
  import {
5
5
  classifySchemaChange
6
- } from "./chunk-2BZR6CAV.js";
6
+ } from "./chunk-TRNJNLQQ.js";
7
7
  import {
8
8
  SEVERITY,
9
9
  sortChanges
@@ -138,8 +138,15 @@ function change(kind, server, summary, extra) {
138
138
  function same(a, b) {
139
139
  return stableKey(a ?? null) === stableKey(b ?? null);
140
140
  }
141
- function indexBy(members, key) {
142
- return new Map((members ?? []).map((member) => [key(member), member]));
141
+ function groupBy(members, key) {
142
+ const groups = /* @__PURE__ */ new Map();
143
+ for (const member of members ?? []) {
144
+ const k = key(member);
145
+ const group = groups.get(k);
146
+ if (group) group.push(member);
147
+ else groups.set(k, [member]);
148
+ }
149
+ return groups;
143
150
  }
144
151
  function declaredNames(capabilities) {
145
152
  const names = [];
@@ -173,12 +180,12 @@ var CAPABILITY_SEVERITY = {
173
180
  low: "low"
174
181
  };
175
182
  function compareToolCapabilities(server, before, after) {
176
- const previous = indexBy(before, (tool) => tool.name);
183
+ const previous = groupBy(before, (tool) => tool.name);
177
184
  const changes = [];
178
185
  for (const tool of after ?? []) {
179
186
  const existing = previous.get(tool.name);
180
187
  if (!existing) continue;
181
- const had = new Set(toolCapabilities(existing).map((capability) => capability.kind));
188
+ const had = new Set(existing.flatMap((copy) => toolCapabilities(copy).map((capability) => capability.kind)));
182
189
  for (const capability of toolCapabilities(tool)) {
183
190
  if (had.has(capability.kind)) continue;
184
191
  changes.push(
@@ -230,10 +237,20 @@ function compareTool(name, before, after) {
230
237
  );
231
238
  }
232
239
  if (changes.length === 0) {
233
- changes.push(change("tool.changed", name, "tool definition changed (title, icons or _meta)", { ...at, before, after }));
240
+ const moved = [
241
+ !same(before.title, after.title) ? "title" : "",
242
+ !same(before.icons, after.icons) ? "icons" : "",
243
+ !same(before.execution, after.execution) ? `how it may be run (${describeExecution(before.execution)} \u2192 ${describeExecution(after.execution)})` : "",
244
+ !same(before.meta, after.meta) ? "_meta" : ""
245
+ ].filter(Boolean);
246
+ changes.push(change("tool.changed", name, `tool definition changed: ${moved.length > 0 ? moved.join(", ") : "a field this report has no finding for"}`, { ...at, before, after }));
234
247
  }
235
248
  return changes;
236
249
  }
250
+ function describeExecution(execution) {
251
+ const support = execution?.["taskSupport"];
252
+ return typeof support === "string" ? `task support ${support}` : "unstated";
253
+ }
237
254
  function describeEscalation(before, after) {
238
255
  const gained = [];
239
256
  if (before.behavior.readOnly && !after.behavior.readOnly) gained.push("may now modify");
@@ -244,25 +261,61 @@ function describeEscalation(before, after) {
244
261
  }
245
262
  function compareMembers(name, before, after, spec, deep) {
246
263
  const changes = [];
247
- const previous = indexBy(before, spec.key);
248
- const next = indexBy(after, spec.key);
249
- for (const [key, member] of next) {
264
+ const previous = groupBy(before, spec.key);
265
+ const next = groupBy(after, spec.key);
266
+ for (const [key, members] of next) {
250
267
  const existing = previous.get(key);
251
268
  if (!existing) {
252
- const extra = spec.arriving?.(member);
269
+ for (const member of members) {
270
+ const extra = spec.arriving?.(member);
271
+ changes.push(
272
+ change(spec.added, name, `new ${spec.noun} ${spec.label(member)}${extra ? ` \xB7 ${extra}` : ""}`, { member: spec.label(member), after: member })
273
+ );
274
+ }
275
+ continue;
276
+ }
277
+ const unpairedBefore = [...existing];
278
+ const unpairedAfter = [];
279
+ for (const member of members) {
280
+ const twin = unpairedBefore.findIndex((candidate) => candidate.digest === member.digest);
281
+ if (twin === -1) unpairedAfter.push(member);
282
+ else unpairedBefore.splice(twin, 1);
283
+ }
284
+ for (const [index, member] of unpairedAfter.entries()) {
285
+ const counterpart = unpairedBefore[index] ?? existing[0];
286
+ if (counterpart.digest === member.digest) {
287
+ changes.push(
288
+ change(spec.changed, name, `${spec.noun} ${spec.label(member)} is now declared ${members.length} times`, { member: spec.label(member), before: existing, after: members })
289
+ );
290
+ continue;
291
+ }
253
292
  changes.push(
254
- change(spec.added, name, `new ${spec.noun} ${spec.label(member)}${extra ? ` \xB7 ${extra}` : ""}`, { member: spec.label(member), after: member })
293
+ ...deep ? deep(key, counterpart, member) : [change(spec.changed, name, `${spec.noun} ${spec.label(member)} changed`, { member: spec.label(member), before: counterpart, after: member })]
255
294
  );
256
- continue;
257
295
  }
258
- if (existing.digest === member.digest) continue;
259
- changes.push(...deep ? deep(key, existing, member) : [change(spec.changed, name, `${spec.noun} ${spec.label(member)} changed`, { member: spec.label(member), before: existing, after: member })]);
296
+ for (const member of unpairedBefore.slice(unpairedAfter.length)) {
297
+ changes.push(change(spec.removed, name, `one of the ${spec.noun}s declared as ${spec.label(member)} is gone`, { member: spec.label(member), before: member }));
298
+ }
260
299
  }
261
- for (const [key, member] of previous) {
262
- if (!next.has(key)) changes.push(change(spec.removed, name, `${spec.noun} ${spec.label(member)} is gone`, { member: spec.label(member), before: member }));
300
+ for (const [key, members] of previous) {
301
+ if (next.has(key)) continue;
302
+ for (const member of members) changes.push(change(spec.removed, name, `${spec.noun} ${spec.label(member)} is gone`, { member: spec.label(member), before: member }));
263
303
  }
264
304
  return changes;
265
305
  }
306
+ function filesMoved(was, now) {
307
+ if (was === void 0 || now === void 0) return void 0;
308
+ const added = Object.keys(now).filter((file) => !Object.hasOwn(was, file));
309
+ const removed = Object.keys(was).filter((file) => !Object.hasOwn(now, file));
310
+ const changed = Object.keys(now).filter((file) => Object.hasOwn(was, file) && was[file] !== now[file]);
311
+ if (added.length + removed.length + changed.length === 0) return void 0;
312
+ const list = (files) => `${files.slice(0, 3).join(", ")}${files.length > 3 ? ` +${files.length - 3}` : ""}`;
313
+ return [
314
+ added.length > 0 ? `added ${list(added)}` : "",
315
+ removed.length > 0 ? `removed ${list(removed)}` : "",
316
+ changed.length > 0 ? `different contents for ${list(changed)}` : ""
317
+ ].filter(Boolean).join("; ");
318
+ }
266
319
  function compareProvenance(name, before, after) {
267
320
  const was = before.provenance;
268
321
  const now = after.provenance;
@@ -272,7 +325,16 @@ function compareProvenance(name, before, after) {
272
325
  const unexplained = surfaceHeld ? ", and the declared surface did not change: nothing else in this report describes what the new code does" : "";
273
326
  const integrityMoved = was.integrity !== void 0 && now.integrity !== void 0 && was.integrity !== now.integrity;
274
327
  if (was.version !== void 0 && was.version === now.version) {
275
- if (!integrityMoved) return [];
328
+ if (!integrityMoved) {
329
+ const files = filesMoved(was.files, now.files);
330
+ if (files) {
331
+ return [change("server.artifact.changed", name, `the files published for ${was.name}@${was.version} are not the ones that were pinned (${files})${unexplained}`, { before: was, after: now })];
332
+ }
333
+ if (was.integrity !== void 0 && now.integrity === void 0) {
334
+ return [change("server.artifact.changed", name, `the file pinned for ${was.name}@${was.version} is no longer published, so something else is installed in its place${unexplained}`, { before: was, after: now })];
335
+ }
336
+ return [];
337
+ }
276
338
  if (was.ecosystem === "npm") {
277
339
  return [
278
340
  change(
@@ -293,6 +355,17 @@ function compareProvenance(name, before, after) {
293
355
  const what = was.ecosystem === "oci" ? `the image ${was.name}:${was.requested ?? "latest"} now resolves to a different digest` : "the file this server runs from has different contents than when it was pinned";
294
356
  return [change("server.artifact.changed", name, `${what}${unexplained}`, { before: was, after: now })];
295
357
  }
358
+ function orderless(entry) {
359
+ const { kind: _kind, source: _source, digest: _digest, provenance: _provenance, tools, resources, resourceTemplates, prompts, ...rest } = entry;
360
+ const digests = (members) => (members ?? []).map((member) => member.digest).sort();
361
+ return stableKey({
362
+ ...rest,
363
+ tools: digests(tools),
364
+ resources: digests(resources),
365
+ resourceTemplates: digests(resourceTemplates),
366
+ prompts: digests(prompts)
367
+ });
368
+ }
296
369
  function compareServer(name, before, after) {
297
370
  const provenance = compareProvenance(name, before, after);
298
371
  if (before.digest === after.digest) return provenance;
@@ -375,6 +448,14 @@ function compareServer(name, before, after) {
375
448
  noun: "prompt"
376
449
  })
377
450
  );
451
+ if (changes.length === 0 && orderless(before) !== orderless(after)) {
452
+ changes.push(
453
+ change("server.capabilities.changed", name, "the server's pinned definition changed in a way no other finding describes; compare the lock entries", {
454
+ before: before.digest,
455
+ after: after.digest
456
+ })
457
+ );
458
+ }
378
459
  return changes;
379
460
  }
380
461
  function detectRenames(before, after, removed, added) {
@@ -432,4 +513,4 @@ export {
432
513
  surfaceCapabilities,
433
514
  diffLockfiles
434
515
  };
435
- //# sourceMappingURL=chunk-6WXMFDJM.js.map
516
+ //# sourceMappingURL=chunk-XUKSVMFX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/risk/untrusted.ts","../src/risk/capability.ts","../src/diff/index.ts"],"sourcesContent":["/**\n * Coercion for values that arrived from somewhere else.\n *\n * Everything in `risk/` reads a declaration a server sent, or a reading a collector posted. The\n * types say `{ name?: string }[]`, and a type is a claim about a value this code never checked:\n * `tools` is whatever was in the JSON, so it can be absent, a string, or an array with a `null`\n * in it. `tool.name` on that `null` throws a TypeError.\n *\n * In the CLI that aborts one audit, which is survivable. In the control plane the same call sits\n * inside ingest, where one malformed element in one tool of one server would fail the whole\n * request -- every other server in that reading included. A classifier is a security control, and\n * a security control that can be switched off by sending it a `null` is one an attacker turns off\n * rather than evades.\n *\n * So the guard belongs here, at the point the value is first believed, rather than at each of the\n * places that go on to read it.\n */\n\n/** The members of `value` that are objects, or an empty list if it is not a list at all. */\nexport function objectsIn(value: unknown): Array<Record<string, unknown>> {\n if (!Array.isArray(value)) return [];\n return value.filter((member): member is Record<string, unknown> => typeof member === \"object\" && member !== null);\n}\n\n/** `value` if it is a non-null object, otherwise an empty one, so a property read is always safe. */\nexport function objectOr(value: unknown): Record<string, unknown> {\n return typeof value === \"object\" && value !== null ? (value as Record<string, unknown>) : {};\n}\n\n/** `value` if it is a string, otherwise undefined: a `name` that is a number is not a name. */\nexport function stringOr(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n","/**\n * What a server could do to you, derived from what it declares.\n *\n * This answers one question and refuses another. It answers *what could this tool do if the\n * model decides to use it*, from the tool's name, its argument names and its schema shape. It\n * does not answer *is this tool malicious*, which is a judgement, needs a corpus, and would make\n * a verdict depend on something other than the bytes on the wire.\n *\n * The distinction matters because it is the same one the severity table already makes: rank by\n * shape, never by intent. A tool named `run_command` taking a `command` argument is arbitrary\n * execution whatever its description claims, and that is a fact about the declaration rather\n * than an opinion about the author.\n *\n * Nothing here is stored in the lockfile. Capabilities are derived from the schemas that *are*\n * stored, so sharpening a pattern re-reads existing locks instead of showing every user a wave\n * of drift that no server caused.\n */\n\n/** Ordered worst-first; the order is the comparison. */\nimport { objectOr, objectsIn, stringOr } from \"./untrusted\";\n\nexport const CAPABILITY_SEVERITIES = [\"critical\", \"high\", \"medium\", \"low\"] as const;\nexport type CapabilitySeverity = (typeof CAPABILITY_SEVERITIES)[number];\n\nexport const CAPABILITY_KINDS = [\n \"process-exec\",\n \"code-eval\",\n \"credential-access\",\n \"file-write\",\n \"network-egress\",\n \"database\",\n \"privilege\",\n \"agent-control\",\n \"env-access\",\n \"file-read\",\n] as const;\nexport type CapabilityKind = (typeof CAPABILITY_KINDS)[number];\n\nexport interface Capability {\n kind: CapabilityKind;\n severity: CapabilitySeverity;\n /** Where it was seen: `name`, or `arg:<argument>`. Shown so a finding can be checked. */\n evidence: string;\n}\n\ninterface Rule {\n kind: CapabilityKind;\n severity: CapabilitySeverity;\n /** Matched against the tool name, with separators normalised to `_`. */\n name?: RegExp;\n /** Matched against each top-level argument name, normalised the same way. */\n arg?: RegExp;\n}\n\n/*\n * Deliberately narrow. A pattern that fires on `get_user` because it contains \"user\" teaches\n * people to ignore the output, and an ignored signal is worse than none: it spends the attention\n * the real findings need.\n */\nconst RULES: Rule[] = [\n { kind: \"process-exec\", severity: \"critical\", name: /(^|_)(exec|execute|spawn|shell|bash|sh|cmd|command|run_command|terminal|subprocess)(_|$)/, arg: /(^|_)(command|cmd|argv|shell|exec|script)(_|$)/ },\n // `source` is deliberately absent: in `copy_file(source, destination)` it is a path, and\n // labelling a file copy as arbitrary code execution at CRITICAL is the false positive that\n // teaches people to stop reading the line. `code` has to be the whole argument name for the\n // same reason -- a crawl of 468 published tools flagged `location_code` as arbitrary code\n // execution, and `country_code`, `status_code` and `zip_code` are all waiting behind it.\n { kind: \"code-eval\", severity: \"critical\", name: /(^|_)(eval|evaluate|run_code|exec_code|interpret|compile)(_|$)/, arg: /^code$|(^|_)(source_code|code_to_run|js_code|python_code|expression|program|snippet)(_|$)/ },\n { kind: \"credential-access\", severity: \"critical\", name: /(^|_)(secret|secrets|credential|credentials|token|keychain|vault|password)(_|$)/, arg: /(^|_)(secret|credential|password|private_key|api_key|access_token)(_|$)/ },\n { kind: \"file-write\", severity: \"high\", name: /(^|_)(write|create_file|put_file|save|delete|remove|unlink|rename|move|copy|chmod|mkdir|rmdir|edit)(_|$)/, arg: /(^|_)(contents|content|data|destination|dest_path|target_path)(_|$)/ },\n { kind: \"network-egress\", severity: \"high\", name: /(^|_)(fetch|request|http|curl|download|upload|post|webhook|navigate|browse|send)(_|$)/, arg: /(^|_)(url|uri|endpoint|host|hostname|webhook|callback)(_|$)/ },\n // Narrowed to things that are actually SQL-shaped. `query`, `select` and `update` on their\n // own matched `simulate-research-query`, `browser_select_option` and `trigger-resource-update`,\n // none of which is a database.\n { kind: \"database\", severity: \"high\", name: /(^|_)(sql|execute_sql|run_sql|query_db|db_query|migrate)(_|$)/, arg: /(^|_)(sql|statement|dsn|connection_string)(_|$)/ },\n { kind: \"privilege\", severity: \"high\", name: /(^|_)(sudo|root|admin|grant|revoke|permission|permissions|acl|policy)(_|$)/, arg: /(^|_)(role|scope|scopes|permission|permissions|privilege)(_|$)/ },\n { kind: \"agent-control\", severity: \"high\", name: /(^|_)(prompt|system_prompt|instruction|instructions|memory|context|persona)(_|$)/, arg: /(^|_)(system_prompt|instruction|instructions|persona)(_|$)/ },\n { kind: \"env-access\", severity: \"medium\", name: /(^|_)(env|environment|getenv|setenv|config|settings)(_|$)/, arg: /(^|_)(env|environment|env_var)(_|$)/ },\n { kind: \"file-read\", severity: \"low\", name: /(^|_)(read|read_file|cat|open|load|list_directory|ls|glob|search_files)(_|$)/, arg: /(^|_)(path|file|filename|filepath|directory|dir)(_|$)/ },\n];\n\n/*\n * Cyrillic and Greek letters that are drawn like Latin ones. `run_comm\\u0430nd` reads as\n * `run_command` to a person and matched nothing at all, so a single substituted character\n * bought a tool complete invisibility to a classifier whose whole job is reading names.\n * Folding them is the difference between a check and a formality.\n */\nconst CONFUSABLES: Record<string, string> = {\n \"\\u0430\": \"a\", \"\\u0435\": \"e\", \"\\u043E\": \"o\", \"\\u0441\": \"c\", \"\\u0440\": \"p\", \"\\u0445\": \"x\",\n \"\\u0443\": \"y\", \"\\u0456\": \"i\", \"\\u0458\": \"j\", \"\\u04BB\": \"h\", \"\\u0501\": \"d\", \"\\u051B\": \"q\",\n \"\\u03BF\": \"o\", \"\\u03B1\": \"a\", \"\\u03B5\": \"e\", \"\\u03BD\": \"v\", \"\\u03C1\": \"p\", \"\\u03C5\": \"u\",\n \"\\u0131\": \"i\", \"\\u1E9E\": \"s\",\n};\n\n/** Built from the map above, so the pattern and the replacements cannot drift apart. */\nconst CONFUSABLE_PATTERN = new RegExp(`[${Object.keys(CONFUSABLES).join(\"\")}]`, \"g\");\n\n/** `browser.take-screenshot` and `browser_take_screenshot` are the same shape. */\nfunction normalize(identifier: string): string {\n return identifier\n .toLowerCase()\n .replace(CONFUSABLE_PATTERN, (character) => CONFUSABLES[character] ?? character)\n .replace(/[-.\\s/]+/g, \"_\");\n}\n\n/*\n * Nested properties count. `tool({ opts: { command } })` is the same capability as\n * `tool({ command })`, and only the top level was examined, so one wrapping object hid it.\n * Depth is bounded because a schema is attacker-supplied and need not terminate.\n */\nfunction argumentNames(inputSchema: unknown, depth = 0): string[] {\n if (depth > 6 || typeof inputSchema !== \"object\" || inputSchema === null) return [];\n const node = inputSchema as { properties?: unknown; items?: unknown };\n const names: string[] = [];\n const properties = node.properties;\n if (typeof properties === \"object\" && properties !== null) {\n for (const [name, child] of Object.entries(properties as Record<string, unknown>)) {\n names.push(name);\n names.push(...argumentNames(child, depth + 1));\n }\n }\n if (node.items !== undefined) names.push(...argumentNames(node.items, depth + 1));\n return names;\n}\n\n/**\n * The capabilities one tool declares. Worst first, one entry per kind: a tool matching\n * `process-exec` by both its name and an argument is not twice as dangerous.\n */\nexport function toolCapabilities(tool: { name?: string; inputSchema?: unknown } | null | undefined): Capability[] {\n // The argument is whatever was in the JSON; see risk/untrusted.\n const subject = objectOr(tool);\n const name = normalize(stringOr(subject.name) ?? \"\");\n const args = argumentNames(subject.inputSchema).map((argument) => [argument, normalize(argument)] as const);\n const found = new Map<CapabilityKind, Capability>();\n\n for (const rule of RULES) {\n if (found.has(rule.kind)) continue;\n if (rule.name?.test(name)) {\n found.set(rule.kind, { kind: rule.kind, severity: rule.severity, evidence: \"name\" });\n continue;\n }\n const hit = rule.arg ? args.find(([, normalized]) => rule.arg?.test(normalized)) : undefined;\n if (hit) found.set(rule.kind, { kind: rule.kind, severity: rule.severity, evidence: `arg:${hit[0]}` });\n }\n\n return [...found.values()].sort(\n (a, b) => CAPABILITY_SEVERITIES.indexOf(a.severity) - CAPABILITY_SEVERITIES.indexOf(b.severity) || a.kind.localeCompare(b.kind),\n );\n}\n\n/** Every capability a set of tools declares between them, with the tools that declare each. */\nexport function surfaceCapabilities(\n tools: ReadonlyArray<{ name?: string; inputSchema?: unknown }> | null | undefined,\n): Array<Capability & { tools: string[] }> {\n const byKind = new Map<CapabilityKind, Capability & { tools: string[] }>();\n for (const tool of objectsIn(tools)) {\n const label = stringOr(tool.name) ?? \"?\";\n for (const capability of toolCapabilities(tool)) {\n const existing = byKind.get(capability.kind);\n if (existing) existing.tools.push(label);\n else byKind.set(capability.kind, { ...capability, tools: [label] });\n }\n }\n return [...byKind.values()].sort(\n (a, b) => CAPABILITY_SEVERITIES.indexOf(a.severity) - CAPABILITY_SEVERITIES.indexOf(b.severity) || a.kind.localeCompare(b.kind),\n );\n}\n","/** Comparing a freshly captured lock against the committed one. */\nimport { stableKey } from \"../lock/canonical\";\nimport { isEscalation } from \"../lock/normalize\";\nimport type {\n LockedPrompt,\n LockedResource,\n LockedResourceTemplate,\n LockedMcpServer,\n LockedTool,\n Lockfile,\n} from \"../lock/types\";\nimport { toolCapabilities, type CapabilitySeverity } from \"../risk/capability\";\nimport { classifySchemaChange } from \"./schema\";\nimport type { Change, ChangeKind, Severity } from \"./types\";\nimport { SEVERITY, sortChanges } from \"./types\";\n\nfunction change(kind: ChangeKind, server: string, summary: string, extra?: Partial<Change>): Change {\n return { kind, severity: SEVERITY[kind], server, summary, ...extra };\n}\n\nfunction same(a: unknown, b: unknown): boolean {\n return stableKey(a ?? null) === stableKey(b ?? null);\n}\n\n/**\n * Members grouped by their key, every copy kept.\n *\n * A Map from key to member kept the last of two tools with the same name and dropped the first\n * without a word. A server that listed a poisoned `read_file` ahead of the approved one compared\n * clean: the approved copy was the one compared, and the poisoned one was never looked at. Which\n * copy a client uses is the client's business, so every copy is compared.\n */\nfunction groupBy<T>(members: T[] | undefined, key: (member: T) => string): Map<string, T[]> {\n const groups = new Map<string, T[]>();\n for (const member of members ?? []) {\n const k = key(member);\n const group = groups.get(k);\n if (group) group.push(member);\n else groups.set(k, [member]);\n }\n return groups;\n}\n\n/**\n * What a server declares, flattened so that an extension is one of the names.\n *\n * `capabilities` is a handful of top-level keys, and one of them, `extensions`, is a map of\n * reverse-DNS ids: that is the mechanism the specification uses to ship capability outside the\n * core. Comparing only the top level means a server that gains an extension still has\n * `extensions` before and after, so nothing reads as gained and the finding lands on the generic\n * \"declared capabilities changed\" with the detail left inside a JSON blob for a reviewer to go\n * and read. As more of what a server can do arrives as an extension, \"what did this one just\n * gain\" becomes an extension question, and it deserves an answer in words.\n *\n * The `extensions` key itself is not a name. Reporting both it and the id it contains would say\n * the same thing twice on the reading where a server declares its first extension.\n */\nfunction declaredNames(capabilities: LockedMcpServer[\"capabilities\"]): string[] {\n const names: string[] = [];\n for (const [key, value] of Object.entries(capabilities ?? {})) {\n if (key === \"extensions\" && value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n for (const id of Object.keys(value)) names.push(`extensions/${id}`);\n continue;\n }\n names.push(key);\n }\n return names;\n}\n\n/** Describes the delta between two capability maps in the direction that matters. */\nfunction compareCapabilities(before: LockedMcpServer, after: LockedMcpServer, name: string): Change[] {\n if (same(before.capabilities, after.capabilities)) return [];\n const previous = declaredNames(before.capabilities);\n const next = declaredNames(after.capabilities);\n const gained = next.filter((key) => !previous.includes(key));\n const lost = previous.filter((key) => !next.includes(key));\n\n if (gained.length > 0 && lost.length === 0) {\n return [change(\"server.capabilities.widened\", name, `server now declares ${gained.join(\", \")}`, { before: before.capabilities, after: after.capabilities })];\n }\n if (lost.length > 0 && gained.length === 0) {\n return [change(\"server.capabilities.narrowed\", name, `server no longer declares ${lost.join(\", \")}`, { before: before.capabilities, after: after.capabilities })];\n }\n return [change(\"server.capabilities.changed\", name, \"declared capabilities changed\", { before: before.capabilities, after: after.capabilities })];\n}\n\n\n/*\n * What a tool can do, compared across a reading.\n *\n * The schema diff says a tool \"accepts input it did not before\", which is the same sentence\n * whether the new argument is `nickname` or `command`. The classifier already knows the\n * difference and says so at pin time; the diff did not ask, so the finding a reviewer approved\n * described arbitrary command execution in the words of an optional string.\n *\n * A tool that is new is compared against nothing, so everything it can do is gained. That is the\n * honest reading: a server that adds a tool taking `command` has gained command execution just as\n * surely as one that adds the argument to a tool already there.\n */\nconst CAPABILITY_SEVERITY: Record<CapabilitySeverity, Severity> = {\n critical: \"high\",\n high: \"high\",\n medium: \"medium\",\n low: \"low\",\n};\n\nfunction compareToolCapabilities(server: string, before: LockedTool[] | undefined, after: LockedTool[] | undefined): Change[] {\n const previous = groupBy(before, (tool) => tool.name);\n const changes: Change[] = [];\n\n for (const tool of after ?? []) {\n /*\n * Only tools that were already here. A tool that is new is reported once, by `tool.added`,\n * which names what it can do: raising a second finding for the same fact makes a reviewer\n * read the arrival of one tool twice.\n */\n const existing = previous.get(tool.name);\n if (!existing) continue;\n // Against every copy that was pinned under this name: what any of them could do was approved.\n const had = new Set(existing.flatMap((copy) => toolCapabilities(copy).map((capability) => capability.kind)));\n for (const capability of toolCapabilities(tool)) {\n if (had.has(capability.kind)) continue;\n changes.push(\n change(\"tool.capability.gained\", server, `can now ${capability.kind} (${capability.evidence})`, {\n member: tool.name,\n severity: CAPABILITY_SEVERITY[capability.severity],\n after: { kind: capability.kind, severity: capability.severity, evidence: capability.evidence },\n }),\n );\n }\n }\n return changes;\n}\n\nfunction compareTool(name: string, before: LockedTool, after: LockedTool): Change[] {\n if (before.digest === after.digest) return [];\n const changes: Change[] = [];\n const at = { member: before.name };\n\n if (!same(before.description, after.description)) {\n changes.push(\n change(\"tool.description.changed\", name, `description changed (${before.description?.length ?? 0} → ${after.description?.length ?? 0} characters)`, {\n ...at,\n before: before.description,\n after: after.description,\n }),\n );\n }\n\n const inputVerdict = classifySchemaChange(before.inputSchema, after.inputSchema);\n if (inputVerdict !== \"same\") {\n const kind = (`tool.input_schema.${inputVerdict}` satisfies ChangeKind) as ChangeKind;\n const wording = inputVerdict === \"widened\" ? \"accepts input it did not before\" : inputVerdict === \"narrowed\" ? \"accepts less input than before\" : \"input schema changed\";\n changes.push(change(kind, name, wording, { ...at, before: before.inputSchema, after: after.inputSchema }));\n }\n\n if (!same(before.outputSchema, after.outputSchema)) {\n changes.push(change(\"tool.output_schema.changed\", name, \"output schema changed\", { ...at, before: before.outputSchema, after: after.outputSchema }));\n }\n\n if (!same(before.behavior, after.behavior)) {\n const escalated = isEscalation(before.behavior, after.behavior);\n changes.push(\n change(escalated ? \"tool.behavior.escalated\" : \"tool.behavior.relaxed\", name, escalated ? describeEscalation(before, after) : \"declares fewer powers than before\", {\n ...at,\n before: before.behavior,\n after: after.behavior,\n }),\n );\n }\n\n if (!same(before.headerParams, after.headerParams)) {\n changes.push(\n change(\"tool.header_params.changed\", name, \"arguments mirrored into HTTP headers changed\", { ...at, before: before.headerParams ?? [], after: after.headerParams ?? [] }),\n );\n }\n\n /*\n * The digest covers more than the fields called out above -- title, icons, `_meta`. If none of\n * them fired, something in that remainder moved, and silence would be worse than a vague\n * finding.\n */\n if (changes.length === 0) {\n const moved = [\n !same(before.title, after.title) ? \"title\" : \"\",\n !same(before.icons, after.icons) ? \"icons\" : \"\",\n !same(before.execution, after.execution) ? `how it may be run (${describeExecution(before.execution)} → ${describeExecution(after.execution)})` : \"\",\n !same(before.meta, after.meta) ? \"_meta\" : \"\",\n ].filter(Boolean);\n changes.push(change(\"tool.changed\", name, `tool definition changed: ${moved.length > 0 ? moved.join(\", \") : \"a field this report has no finding for\"}`, { ...at, before, after }));\n }\n return changes;\n}\n\nfunction describeExecution(execution: LockedTool[\"execution\"]): string {\n const support = execution?.[\"taskSupport\"];\n return typeof support === \"string\" ? `task support ${support}` : \"unstated\";\n}\n\nfunction describeEscalation(before: LockedTool, after: LockedTool): string {\n const gained: string[] = [];\n if (before.behavior.readOnly && !after.behavior.readOnly) gained.push(\"may now modify\");\n if (!before.behavior.destructive && after.behavior.destructive) gained.push(\"may now destroy\");\n if (before.behavior.idempotent && !after.behavior.idempotent) gained.push(\"repeat calls now compound\");\n if (!before.behavior.openWorld && after.behavior.openWorld) gained.push(\"may now reach external systems\");\n return gained.join(\"; \");\n}\n\ninterface MemberSpec<T> {\n key: (member: T) => string;\n label: (member: T) => string;\n added: ChangeKind;\n removed: ChangeKind;\n changed: ChangeKind;\n noun: string;\n /** Extra wording for a member that is new, where arriving is itself the finding. */\n arriving?: (member: T) => string;\n}\n\nfunction compareMembers<T extends { digest: string }>(\n name: string,\n before: T[] | undefined,\n after: T[] | undefined,\n spec: MemberSpec<T>,\n deep?: (key: string, a: T, b: T) => Change[],\n): Change[] {\n const changes: Change[] = [];\n const previous = groupBy(before, spec.key);\n const next = groupBy(after, spec.key);\n\n for (const [key, members] of next) {\n const existing = previous.get(key);\n if (!existing) {\n for (const member of members) {\n const extra = spec.arriving?.(member);\n changes.push(\n change(spec.added, name, `new ${spec.noun} ${spec.label(member)}${extra ? ` \\u00b7 ${extra}` : \"\"}`, { member: spec.label(member), after: member }),\n );\n }\n continue;\n }\n\n /*\n * Identical copies pair off first, so a server that reorders its list compares clean. What is\n * left on the new side is compared against what is left on the old one, or, where a copy was\n * added beside the approved one, against the approved one: a second `read_file` is described\n * by how it differs from the first, which is the finding a reviewer needs.\n */\n const unpairedBefore = [...existing];\n const unpairedAfter: T[] = [];\n for (const member of members) {\n const twin = unpairedBefore.findIndex((candidate) => candidate.digest === member.digest);\n if (twin === -1) unpairedAfter.push(member);\n else unpairedBefore.splice(twin, 1);\n }\n for (const [index, member] of unpairedAfter.entries()) {\n const counterpart = unpairedBefore[index] ?? existing[0]!;\n if (counterpart.digest === member.digest) {\n changes.push(\n change(spec.changed, name, `${spec.noun} ${spec.label(member)} is now declared ${members.length} times`, { member: spec.label(member), before: existing, after: members }),\n );\n continue;\n }\n changes.push(\n ...(deep\n ? deep(key, counterpart, member)\n : [change(spec.changed, name, `${spec.noun} ${spec.label(member)} changed`, { member: spec.label(member), before: counterpart, after: member })]),\n );\n }\n for (const member of unpairedBefore.slice(unpairedAfter.length)) {\n changes.push(change(spec.removed, name, `one of the ${spec.noun}s declared as ${spec.label(member)} is gone`, { member: spec.label(member), before: member }));\n }\n }\n for (const [key, members] of previous) {\n if (next.has(key)) continue;\n for (const member of members) changes.push(change(spec.removed, name, `${spec.noun} ${spec.label(member)} is gone`, { member: spec.label(member), before: member }));\n }\n return changes;\n}\n\n/**\n * Whether the code behind the server is the code that was pinned.\n *\n * Absence on either side says nothing. A lock written before provenance existed, or a run that\n * could not reach a registry, has none, and reporting that would turn every upgrade of this tool\n * and every offline run into drift against servers nobody touched. Neither does a change of\n * package name: that only happens when the command or its arguments changed, which\n * `server.transport.changed` already reports, and saying it twice is how a reviewer learns to\n * skim.\n */\n/** What differs between two lists of a release's files, said briefly, or nothing when they match. */\nfunction filesMoved(was: Record<string, string> | undefined, now: Record<string, string> | undefined): string | undefined {\n if (was === undefined || now === undefined) return undefined;\n const added = Object.keys(now).filter((file) => !Object.hasOwn(was, file));\n const removed = Object.keys(was).filter((file) => !Object.hasOwn(now, file));\n const changed = Object.keys(now).filter((file) => Object.hasOwn(was, file) && was[file] !== now[file]);\n if (added.length + removed.length + changed.length === 0) return undefined;\n const list = (files: string[]) => `${files.slice(0, 3).join(\", \")}${files.length > 3 ? ` +${files.length - 3}` : \"\"}`;\n return [\n added.length > 0 ? `added ${list(added)}` : \"\",\n removed.length > 0 ? `removed ${list(removed)}` : \"\",\n changed.length > 0 ? `different contents for ${list(changed)}` : \"\",\n ]\n .filter(Boolean)\n .join(\"; \");\n}\n\nfunction compareProvenance(name: string, before: LockedMcpServer, after: LockedMcpServer): Change[] {\n const was = before.provenance;\n const now = after.provenance;\n if (!was || !now) return [];\n if (was.ecosystem !== now.ecosystem || was.name !== now.name) return [];\n\n const surfaceHeld = before.digest === after.digest;\n\n /*\n * Said out loud when the surface held still, because that is the case nothing else in the\n * report covers. A release that changed its tools is described by the tool changes; one that\n * changed only its code is described by this line and nothing else.\n */\n const unexplained = surfaceHeld ? \", and the declared surface did not change: nothing else in this report describes what the new code does\" : \"\";\n const integrityMoved = was.integrity !== undefined && now.integrity !== undefined && was.integrity !== now.integrity;\n\n if (was.version !== undefined && was.version === now.version) {\n if (!integrityMoved) {\n /*\n * The pinned file is one of a release's files, and an installer picks among all of them.\n * A wheel added to the release, or the pinned file taken away, changes what runs without\n * moving `integrity`; when both sides list the release's files, that is compared too.\n */\n const files = filesMoved(was.files, now.files);\n if (files) {\n return [change(\"server.artifact.changed\", name, `the files published for ${was.name}@${was.version} are not the ones that were pinned (${files})${unexplained}`, { before: was, after: now })];\n }\n if (was.integrity !== undefined && now.integrity === undefined) {\n return [change(\"server.artifact.changed\", name, `the file pinned for ${was.name}@${was.version} is no longer published, so something else is installed in its place${unexplained}`, { before: was, after: now })];\n }\n return [];\n }\n /*\n * Substitution is claimed only where the registry guarantees one artifact per version. npm\n * refuses to republish a version, so different bytes under the same one means something\n * between here and the registry served them. PyPI lets a maintainer add files to a release\n * after the fact, so the same version with a different recorded file has an ordinary\n * explanation, and it is reported as the milder kind.\n */\n if (was.ecosystem === \"npm\") {\n return [\n change(\n \"server.artifact.substituted\",\n name,\n `${was.name}@${was.version} now has different contents than when it was pinned: the same version, different bytes`,\n { before: was, after: now },\n ),\n ];\n }\n return [change(\"server.artifact.changed\", name, `the files published for ${was.name}@${was.version} are not the ones that were pinned${unexplained}`, { before: was, after: now })];\n }\n\n if (was.version !== now.version) {\n const moved = `the package behind this server moved from ${was.version ?? \"an unknown version\"} to ${now.version ?? \"an unknown version\"}`;\n return [change(\"server.artifact.changed\", name, `${moved}${unexplained}`, { before: was, after: now })];\n }\n\n /*\n * No version on either side: a file, or an image, whose tag is a pointer rather than a release.\n * A moved tag and a rebuilt binary are both ordinary, so both are the medium kind.\n */\n if (!integrityMoved) return [];\n const what =\n was.ecosystem === \"oci\"\n ? `the image ${was.name}:${was.requested ?? \"latest\"} now resolves to a different digest`\n : \"the file this server runs from has different contents than when it was pinned\";\n return [change(\"server.artifact.changed\", name, `${what}${unexplained}`, { before: was, after: now })];\n}\n\n/**\n * What the server digest covers, with each member list taken as a set.\n *\n * Members are stored sorted by name, so copies that share a name keep the order the server sent\n * them in, and a server that swaps two of them moves its digest without changing anything. The\n * member comparison already reads that as clean; this is what lets the fallback below agree.\n *\n * Everything but the fields the digest leaves out is taken as it is, rather than listed, so a\n * field the format gains later is covered here on the day it is added.\n */\nfunction orderless(entry: LockedMcpServer): string {\n const { kind: _kind, source: _source, digest: _digest, provenance: _provenance, tools, resources, resourceTemplates, prompts, ...rest } = entry;\n const digests = (members: Array<{ digest: string }> | undefined) => (members ?? []).map((member) => member.digest).sort();\n return stableKey({\n ...rest,\n tools: digests(tools),\n resources: digests(resources),\n resourceTemplates: digests(resourceTemplates),\n prompts: digests(prompts),\n });\n}\n\nfunction compareServer(name: string, before: LockedMcpServer, after: LockedMcpServer): Change[] {\n /*\n * Provenance first, and outside the short-circuit: the attack it exists for is new code behind\n * an unchanged surface, which is exactly the case where the digests match.\n */\n const provenance = compareProvenance(name, before, after);\n if (before.digest === after.digest) return provenance;\n const changes: Change[] = [...provenance];\n\n if (!same(before.transport, after.transport)) {\n changes.push(change(\"server.transport.changed\", name, \"the server is reached differently than when it was pinned\", { before: before.transport, after: after.transport }));\n }\n if (!same(before.serverInfo, after.serverInfo)) {\n const from = before.serverInfo?.version ?? \"unknown\";\n const to = after.serverInfo?.version ?? \"unknown\";\n changes.push(change(\"server.identity.changed\", name, `server identity changed (version ${from} → ${to})`, { before: before.serverInfo, after: after.serverInfo }));\n }\n if (!same(before.protocol, after.protocol)) {\n changes.push(\n change(\"server.protocol.changed\", name, `protocol changed (${before.protocol.era}/${before.protocol.version} → ${after.protocol.era}/${after.protocol.version})`, {\n before: before.protocol,\n after: after.protocol,\n }),\n );\n }\n if (!same(before.instructions, after.instructions)) {\n changes.push(\n change(\"server.instructions.changed\", name, \"server instructions changed: this text goes into the model's system prompt\", {\n before: before.instructions,\n after: after.instructions,\n }),\n );\n }\n changes.push(...compareCapabilities(before, after, name));\n\n changes.push(\n ...compareMembers<LockedTool>(name, before.tools, after.tools, {\n key: (t) => t.name,\n label: (t) => t.name,\n added: \"tool.added\",\n removed: \"tool.removed\",\n changed: \"tool.changed\",\n noun: \"tool\",\n arriving: (t) => {\n const can = toolCapabilities(t);\n return can.length > 0 ? `can ${can.map((capability) => capability.kind).join(\", \")}` : \"\";\n },\n }, (_key, a, b) =>\n compareTool(name, a, b),\n ),\n );\n changes.push(...compareToolCapabilities(name, before.tools, after.tools));\n changes.push(\n ...compareMembers<LockedResource>(name, before.resources, after.resources, {\n key: (r) => r.uri,\n label: (r) => `${r.name} (${r.uri})`,\n added: \"resource.added\",\n removed: \"resource.removed\",\n changed: \"resource.changed\",\n noun: \"resource\",\n }),\n );\n changes.push(\n ...compareMembers<LockedResourceTemplate>(name, before.resourceTemplates, after.resourceTemplates, {\n key: (t) => t.uriTemplate,\n // The template itself is the capability -- widening it from file:///project/{path} to\n // file:///{path} is the whole finding -- so it belongs in the label, not just the body.\n label: (t) => `${t.name} (${t.uriTemplate})`,\n added: \"resource_template.added\",\n removed: \"resource_template.removed\",\n changed: \"resource_template.changed\",\n noun: \"resource template\",\n }),\n );\n changes.push(\n ...compareMembers<LockedPrompt>(name, before.prompts, after.prompts, {\n key: (p) => p.name,\n label: (p) => p.name,\n added: \"prompt.added\",\n removed: \"prompt.removed\",\n changed: \"prompt.changed\",\n noun: \"prompt\",\n }),\n );\n\n /*\n * The digest moved and nothing above says why. Every field the digest covers is compared above,\n * so this should not happen; when it does, a field was missed, and the honest report is a vague\n * finding rather than a clean one. A false clean is the one failure this engine exists to avoid.\n */\n if (changes.length === 0 && orderless(before) !== orderless(after)) {\n changes.push(\n change(\"server.capabilities.changed\", name, \"the server's pinned definition changed in a way no other finding describes; compare the lock entries\", {\n before: before.digest,\n after: after.digest,\n }),\n );\n }\n\n return changes;\n}\n\n/**\n * A server renamed in config would naively read as a removal plus an addition: two alarming\n * findings for a cosmetic edit. Collapsing requires an identical transport *and* an identical\n * digest, so a rename that also changed capabilities stays a remove and an add -- which is what\n * it is, and hiding a capability change inside a cosmetic one is the failure mode worth avoiding.\n */\nfunction detectRenames(before: Lockfile, after: Lockfile, removed: string[], added: string[]): { changes: Change[]; renamed: Set<string> } {\n const changes: Change[] = [];\n const renamed = new Set<string>();\n const availableAdds = [...added];\n\n for (const oldName of removed) {\n const oldEntry = before.subjects[oldName];\n if (!oldEntry) continue;\n const match = availableAdds.find((newName) => {\n const candidate = after.subjects[newName];\n return candidate !== undefined && candidate.digest === oldEntry.digest && same(candidate.transport, oldEntry.transport);\n });\n if (!match) continue;\n\n availableAdds.splice(availableAdds.indexOf(match), 1);\n renamed.add(oldName);\n renamed.add(match);\n changes.push(change(\"server.renamed\", match, `renamed from \"${oldName}\"; capabilities are unchanged`, { before: oldName, after: match }));\n }\n return { changes, renamed };\n}\n\nexport function diffLockfiles(before: Lockfile, after: Lockfile): Change[] {\n const beforeNames = Object.keys(before.subjects);\n const afterNames = Object.keys(after.subjects);\n const removed = beforeNames.filter((name) => !afterNames.includes(name));\n const added = afterNames.filter((name) => !beforeNames.includes(name));\n\n const { changes: renameChanges, renamed } = detectRenames(before, after, removed, added);\n const changes: Change[] = [...renameChanges];\n\n for (const name of added) {\n if (renamed.has(name)) continue;\n const entry = after.subjects[name];\n const toolCount = entry?.tools?.length ?? 0;\n changes.push(change(\"server.added\", name, `new server with ${toolCount} tool${toolCount === 1 ? \"\" : \"s\"}`, { after: entry }));\n }\n for (const name of removed) {\n if (renamed.has(name)) continue;\n changes.push(change(\"server.removed\", name, \"server is no longer configured\", { before: before.subjects[name] }));\n }\n for (const name of afterNames) {\n const a = before.subjects[name];\n const b = after.subjects[name];\n if (!a || !b) continue;\n changes.push(...compareServer(name, a, b));\n }\n\n return sortChanges(changes);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAmBO,SAAS,UAAU,OAAgD;AACxE,MAAI,CAAC,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC;AACnC,SAAO,MAAM,OAAO,CAAC,WAA8C,OAAO,WAAW,YAAY,WAAW,IAAI;AAClH;AAGO,SAAS,SAAS,OAAyC;AAChE,SAAO,OAAO,UAAU,YAAY,UAAU,OAAQ,QAAoC,CAAC;AAC7F;AAGO,SAAS,SAAS,OAAoC;AAC3D,SAAO,OAAO,UAAU,WAAW,QAAQ;AAC7C;;;ACXO,IAAM,wBAAwB,CAAC,YAAY,QAAQ,UAAU,KAAK;AAGlE,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;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QAAQ,MAAM,SAAS,IAAI;AACjC,UAAM,YAAY,OAAO,OAAO,UAAU;AAC1C,YAAQ,KAAK,OAAO,gBAAgB,MAAM,mBAAmB,SAAS,QAAQ,cAAc,IAAI,KAAK,GAAG,IAAI,EAAE,OAAO,MAAM,CAAC,CAAC;AAAA,EAC/H;AACA,aAAW,QAAQ,SAAS;AAC1B,QAAI,QAAQ,IAAI,IAAI,EAAG;AACvB,YAAQ,KAAK,OAAO,kBAAkB,MAAM,kCAAkC,EAAE,QAAQ,OAAO,SAAS,IAAI,EAAE,CAAC,CAAC;AAAA,EAClH;AACA,aAAW,QAAQ,YAAY;AAC7B,UAAM,IAAI,OAAO,SAAS,IAAI;AAC9B,UAAM,IAAI,MAAM,SAAS,IAAI;AAC7B,QAAI,CAAC,KAAK,CAAC,EAAG;AACd,YAAQ,KAAK,GAAG,cAAc,MAAM,GAAG,CAAC,CAAC;AAAA,EAC3C;AAEA,SAAO,YAAY,OAAO;AAC5B;","names":[]}
@@ -120,6 +120,19 @@ function redactFormats(value) {
120
120
  for (const format of ISSUER_FORMATS) out = out.replace(format, REDACTED);
121
121
  return out;
122
122
  }
123
+ var CODE_HOSTS = /* @__PURE__ */ new Set([
124
+ "github.com",
125
+ "raw.githubusercontent.com",
126
+ "codeload.github.com",
127
+ "gist.github.com",
128
+ "gist.githubusercontent.com",
129
+ "api.github.com",
130
+ "gitlab.com",
131
+ "bitbucket.org",
132
+ "cdn.jsdelivr.net",
133
+ "esm.sh",
134
+ "deno.land"
135
+ ]);
123
136
  function redactUrl(value) {
124
137
  if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(value)) return value;
125
138
  let url;
@@ -139,7 +152,7 @@ function redactUrl(value) {
139
152
  changed = true;
140
153
  }
141
154
  }
142
- const path = redactPath(url.pathname);
155
+ const path = redactPath(url.pathname, { contentAddressed: CODE_HOSTS.has(url.hostname.toLowerCase()) });
143
156
  if (path !== url.pathname) {
144
157
  url.pathname = path;
145
158
  changed = true;
@@ -241,11 +254,12 @@ function redactArgs(args) {
241
254
  function looksLikeAnOperand(value) {
242
255
  return value.startsWith("@") || value.includes("/") || /\.(m?[jt]s|cjs|py|json|ya?ml|toml|sh|exe)$/i.test(value);
243
256
  }
244
- function redactPath(pathname) {
257
+ function redactPath(pathname, options = {}) {
245
258
  return pathname.split("/").map((segment) => {
246
259
  if (segment === "" || PLACEHOLDER.test(decoded(segment))) return segment;
247
260
  if (looksRandom(segment)) return REDACTED;
248
- if (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(segment) || /^[0-9a-f]{32,}$/i.test(segment)) return REDACTED;
261
+ if (!options.contentAddressed && (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(segment) || /^[0-9a-f]{32,}$/i.test(segment)))
262
+ return REDACTED;
249
263
  return redactFormats(segment);
250
264
  }).join("/");
251
265
  }
@@ -261,4 +275,4 @@ export {
261
275
  redactPath,
262
276
  countRedacted
263
277
  };
264
- //# sourceMappingURL=chunk-WEU7FBSB.js.map
278
+ //# sourceMappingURL=chunk-ZD2C4FMT.js.map