saktum 0.5.0 → 0.6.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 (3) hide show
  1. package/README.md +10 -1
  2. package/package.json +1 -1
  3. package/saktum.mjs +279 -34
package/README.md CHANGED
@@ -82,6 +82,15 @@ with an honest error to the agent. Receipts follow Saktum's receipt contract and
82
82
  Preview limits: local (stdio) servers; receipts are signed by the agent side (bilateral receipts, co-signed by the
83
83
  server side, come with the Saktum gateway).
84
84
 
85
+ ## Plugs into what you run, and pays for itself (v0.6)
86
+
87
+ | Command | What it does |
88
+ | --- | --- |
89
+ | `saktum watch saktum-allowlist.json` | Continuous monitoring: re-checks approved servers and alerts on changed tools, grade drops or unreachable servers (daily GitHub workflow: `examples/saktum-watch.yml`) |
90
+ | `saktum receipts export --otel receipts.otlp.json [--endpoint http://collector:4318]` | Agent receipts as OpenTelemetry traces, into your observability and security tools |
91
+ | `saktum attest saktum-report.json --vc` · `saktum vc verify file.vc.jwt` | Attestations as W3C Verifiable Credentials, issued by your did:key |
92
+ | `saktum roi --tokens-per-turn 32833 --agents 10` | What tool definitions cost a year and what fixes and passports save (assumptions shown); `assess` includes the business case |
93
+
85
94
  ## Passports: trust you can see
86
95
 
87
96
  ```
@@ -155,7 +164,7 @@ servers not on your allowlist, and the weakest grades. Configured secrets are ne
155
164
 
156
165
  ```yaml
157
166
  - uses: actions/checkout@v4
158
- - uses: soodhere/saktum-check@v0.5.0
167
+ - uses: soodhere/saktum-check@v0.6.0
159
168
  with:
160
169
  target: "-- node build/index.js" # or an https URL
161
170
  args: "--active --tests saktum.tests.yaml" # optional; --active only for your own server
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saktum",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Test MCP servers in one command: conformance, sign-in, security (OWASP MCP Top 10), agent experience, context cost and performance.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/saktum.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- // Saktum Check 0.5.0 (private beta). Licensed Apache-2.0; bundled dependencies keep their own licences.
2
+ // Saktum Check 0.6.0 (private beta). Licensed Apache-2.0; bundled dependencies keep their own licences.
3
3
  import { createRequire as __saktumCreateRequire } from "node:module";
4
4
  const require = __saktumCreateRequire(import.meta.url);
5
5
  var __create = Object.create;
@@ -10448,11 +10448,11 @@ function base58decode(s) {
10448
10448
  throw new Error("invalid base58");
10449
10449
  n = n * 58n + BigInt(i);
10450
10450
  }
10451
- let hex = n.toString(16);
10452
- if (hex.length % 2)
10453
- hex = "0" + hex;
10451
+ let hex2 = n.toString(16);
10452
+ if (hex2.length % 2)
10453
+ hex2 = "0" + hex2;
10454
10454
  const lead = s.match(/^1*/)?.[0].length ?? 0;
10455
- return Uint8Array.from([...new Array(lead).fill(0), ...Buffer.from(n === 0n ? "" : hex, "hex")]);
10455
+ return Uint8Array.from([...new Array(lead).fill(0), ...Buffer.from(n === 0n ? "" : hex2, "hex")]);
10456
10456
  }
10457
10457
  function didKeyFromPublicKey(publicKey) {
10458
10458
  const raw = Buffer.from(publicKey.export({ format: "jwk" }).x, "base64url");
@@ -13882,9 +13882,9 @@ var require_utils = __commonJS({
13882
13882
  let output = "";
13883
13883
  for (let i = 0; i < input.length; i++) {
13884
13884
  if (input[i] === "%" && i + 2 < input.length) {
13885
- const hex = input.slice(i + 1, i + 3);
13886
- if (isHexPair(hex)) {
13887
- const normalizedHex = hex.toUpperCase();
13885
+ const hex2 = input.slice(i + 1, i + 3);
13886
+ if (isHexPair(hex2)) {
13887
+ const normalizedHex = hex2.toUpperCase();
13888
13888
  const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
13889
13889
  if (decodeUnreserved && isUnreserved(decoded)) {
13890
13890
  output += decoded;
@@ -13904,9 +13904,9 @@ var require_utils = __commonJS({
13904
13904
  for (let i = 0; i < input.length; i++) {
13905
13905
  const ch = input[i];
13906
13906
  if (ch === "%" && i + 2 < input.length) {
13907
- const hex = input.slice(i + 1, i + 3);
13908
- if (isHexPair(hex)) {
13909
- const normalizedHex = hex.toUpperCase();
13907
+ const hex2 = input.slice(i + 1, i + 3);
13908
+ if (isHexPair(hex2)) {
13909
+ const normalizedHex = hex2.toUpperCase();
13910
13910
  const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
13911
13911
  if (decoded !== "." && isUnreserved(decoded)) {
13912
13912
  output += decoded;
@@ -13946,9 +13946,9 @@ var require_utils = __commonJS({
13946
13946
  for (let i = 0; i < input.length; i++) {
13947
13947
  const ch = input[i];
13948
13948
  if (ch === "%" && i + 2 < input.length) {
13949
- const hex = input.slice(i + 1, i + 3);
13950
- if (isHexPair(hex)) {
13951
- output += "%" + hex.toUpperCase();
13949
+ const hex2 = input.slice(i + 1, i + 3);
13950
+ if (isHexPair(hex2)) {
13951
+ output += "%" + hex2.toUpperCase();
13952
13952
  i += 2;
13953
13953
  continue;
13954
13954
  }
@@ -13984,9 +13984,9 @@ var require_utils = __commonJS({
13984
13984
  for (let i = 0; i < input.length; i++) {
13985
13985
  const ch = input[i];
13986
13986
  if (ch === "%" && i + 2 < input.length) {
13987
- const hex = input.slice(i + 1, i + 3);
13988
- if (isHexPair(hex)) {
13989
- output += "%" + hex.toUpperCase();
13987
+ const hex2 = input.slice(i + 1, i + 3);
13988
+ if (isHexPair(hex2)) {
13989
+ output += "%" + hex2.toUpperCase();
13990
13990
  i += 2;
13991
13991
  continue;
13992
13992
  }
@@ -14031,9 +14031,9 @@ var require_utils = __commonJS({
14031
14031
  for (let i = 0; i < input.length; i++) {
14032
14032
  const ch = input[i];
14033
14033
  if (ch === "%" && i + 2 < input.length) {
14034
- const hex = input.slice(i + 1, i + 3);
14035
- if (isHexPair(hex)) {
14036
- const normalizedHex = hex.toUpperCase();
14034
+ const hex2 = input.slice(i + 1, i + 3);
14035
+ if (isHexPair(hex2)) {
14036
+ const normalizedHex = hex2.toUpperCase();
14037
14037
  const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
14038
14038
  if (isUnreserved(decoded)) {
14039
14039
  output += decoded;
@@ -14071,9 +14071,9 @@ var require_utils = __commonJS({
14071
14071
  let output = "";
14072
14072
  for (let i = 0; i < input.length; i++) {
14073
14073
  if (input[i] === "%" && i + 2 < input.length) {
14074
- const hex = input.slice(i + 1, i + 3);
14075
- if (isHexPair(hex)) {
14076
- output += "%" + hex.toUpperCase();
14074
+ const hex2 = input.slice(i + 1, i + 3);
14075
+ if (isHexPair(hex2)) {
14076
+ output += "%" + hex2.toUpperCase();
14077
14077
  i += 2;
14078
14078
  continue;
14079
14079
  }
@@ -20608,8 +20608,8 @@ function base64urlToUint8Array(base64url2) {
20608
20608
  function uint8ArrayToBase64url(bytes) {
20609
20609
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
20610
20610
  }
20611
- function hexToUint8Array(hex) {
20612
- const cleanHex = hex.replace(/^0x/, "");
20611
+ function hexToUint8Array(hex2) {
20612
+ const cleanHex = hex2.replace(/^0x/, "");
20613
20613
  if (cleanHex.length % 2 !== 0) {
20614
20614
  throw new Error("Invalid hex string length");
20615
20615
  }
@@ -33511,7 +33511,7 @@ var init_dist3 = __esm({
33511
33511
  init_stdio2();
33512
33512
  init_streamableHttp();
33513
33513
  init_types2();
33514
- USER_AGENT = "saktum-check/0.5.0 (+https://saktum.dev/check)";
33514
+ USER_AGENT = "saktum-check/0.6.0 (+https://saktum.dev/check)";
33515
33515
  LIMITS = { requestTimeoutMs: 1e4, connectTimeoutMs: 6e4, maxResponseChars: 5e6 };
33516
33516
  LimitError = class extends Error {
33517
33517
  };
@@ -33549,7 +33549,7 @@ var init_dist3 = __esm({
33549
33549
  jsonrpc: "2.0",
33550
33550
  id: 1,
33551
33551
  method: "initialize",
33552
- params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.5.0" } }
33552
+ params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.6.0" } }
33553
33553
  });
33554
33554
  }
33555
33555
  });
@@ -34862,7 +34862,7 @@ var init_engine = __esm({
34862
34862
  init_runner();
34863
34863
  init_safe();
34864
34864
  init_scoring();
34865
- ENGINE_VERSION = "0.5.0";
34865
+ ENGINE_VERSION = "0.6.0";
34866
34866
  UNKNOWN_TOOL = "saktum_trust_check_no_such_tool";
34867
34867
  INVALID_TOKEN = "saktum-check-deliberately-invalid-token";
34868
34868
  baseOf = (pack, check) => ({
@@ -34962,7 +34962,8 @@ function analyseSetup(scans, o) {
34962
34962
  }
34963
34963
  function renderSetup(r) {
34964
34964
  const L = ["Saktum scan-config: your agent set-up as a whole", ""];
34965
- L.push(` ${r.servers.length} servers \xB7 ${r.totalTokens.toLocaleString("en-US")} tokens of tool definitions every turn \xB7 about $${r.monthlyCostUsd.toLocaleString("en-US")} a month at ${r.assumptions.turnsPerDay} turns a day and $${r.assumptions.pricePerMTokUsd} per million input tokens`, "");
34965
+ const yearly = Math.round(r.monthlyCostUsd * 12);
34966
+ L.push(` ${r.servers.length} servers \xB7 ${r.totalTokens.toLocaleString("en-US")} tokens of tool definitions every turn \xB7 about $${r.monthlyCostUsd.toLocaleString("en-US")} a month at ${r.assumptions.turnsPerDay} turns a day and $${r.assumptions.pricePerMTokUsd} per million input tokens (about $${yearly.toLocaleString("en-US")} a year; npx saktum roi for the full business case)`, "");
34966
34967
  for (const s of r.servers)
34967
34968
  L.push(` ${s.name.padEnd(28)} ${s.client.padEnd(22)} ${s.error ? `could not check: ${s.error}` : `trust ${s.trustGrade ?? "-"} \xB7 readiness ${s.readinessGrade ?? "-"} \xB7 ${s.toolCount} tools \xB7 ${s.tokens.toLocaleString("en-US")} tokens${s.onAllowlist === false ? " \xB7 not on allowlist" : ""}`}`);
34968
34969
  if (r.duplicates.length) {
@@ -35488,6 +35489,158 @@ var init_receipts = __esm({
35488
35489
  }
35489
35490
  });
35490
35491
 
35492
+ // packages/testkit-core/dist/interop.js
35493
+ import { createHash as createHash2, sign as edSign, verify as edVerify } from "node:crypto";
35494
+ function receiptsToOtlp(entries, o) {
35495
+ const traceId = hex(`saktum-trace:${entries[0]?.receipt.envelope.caller.agent ?? ""}:${entries[0]?.receipt.envelope.id ?? ""}`, 32);
35496
+ const spans = entries.map((e) => {
35497
+ const env = e.receipt.envelope, end = e.receipt.issuedAt, lat = e.result.latencyMs ?? 0;
35498
+ const error2 = e.receipt.outcome !== "allow" || e.result.status !== "ok";
35499
+ return {
35500
+ traceId,
35501
+ spanId: hex(`span:${env.id}`, 16),
35502
+ name: `execute_tool ${env.tool}`,
35503
+ kind: 3,
35504
+ startTimeUnixNano: nanos(end, lat),
35505
+ endTimeUnixNano: nanos(end),
35506
+ attributes: [
35507
+ attr("gen_ai.operation.name", "execute_tool"),
35508
+ attr("gen_ai.tool.name", env.tool),
35509
+ attr("mcp.method.name", "tools/call"),
35510
+ attr("server.address", env.target.service),
35511
+ attr("saktum.server.version", env.target.version),
35512
+ attr("saktum.agent.id", env.caller.agent),
35513
+ attr("saktum.on_behalf_of", env.caller.onBehalfOf),
35514
+ attr("saktum.outcome", e.receipt.outcome),
35515
+ attr("saktum.reason", e.receipt.reason),
35516
+ attr("saktum.result.status", e.result.status),
35517
+ attr("saktum.destructive", e.result.destructive),
35518
+ attr("saktum.arguments.hash", env.argumentsHash),
35519
+ attr("saktum.receipt.seq", e.seq),
35520
+ attr("saktum.receipt.entry_hash", e.entryHash),
35521
+ attr("saktum.receipts.verified", o.verified)
35522
+ ].filter(Boolean),
35523
+ status: error2 ? { code: 2, message: e.receipt.outcome === "deny" ? `blocked: ${e.receipt.reason ?? ""}` : e.result.status } : { code: 1 }
35524
+ };
35525
+ });
35526
+ return { resourceSpans: [{
35527
+ resource: { attributes: [attr("service.name", o.serviceName ?? "saktum-proxy"), attr("service.version", o.version)].filter(Boolean) },
35528
+ scopeSpans: [{ scope: { name: "saktum", version: o.version }, spans }]
35529
+ }] };
35530
+ }
35531
+ function attestationToCredential(a, issuer) {
35532
+ return {
35533
+ "@context": ["https://www.w3.org/ns/credentials/v2"],
35534
+ type: ["VerifiableCredential", "SaktumMcpServerAttestation"],
35535
+ issuer,
35536
+ validFrom: a.checkedAt,
35537
+ credentialSubject: {
35538
+ id: `urn:saktum:mcp-server:${(a.subject.toolsFingerprint ?? "unknown").replace(/^sha256:/, "")}`,
35539
+ server: a.subject.server,
35540
+ version: a.subject.version,
35541
+ transport: a.subject.transport,
35542
+ toolsFingerprint: a.subject.toolsFingerprint,
35543
+ trustGrade: a.claims.trustGrade,
35544
+ readinessGrade: a.claims.readinessGrade,
35545
+ maturityEvidence: a.claims.evidence,
35546
+ assuranceLevel: a.claims.assuranceLevel,
35547
+ checkedWith: a.checkedWith,
35548
+ resultDigest: a.resultDigest
35549
+ }
35550
+ };
35551
+ }
35552
+ function signCredentialJwt(vc, key) {
35553
+ const header = { alg: "EdDSA", typ: "vc+jwt", cty: "vc", kid: `${key.kid}#${key.kid.slice("did:key:".length)}` };
35554
+ const input = `${b64u2(JSON.stringify(header))}.${b64u2(JSON.stringify(vc))}`;
35555
+ return `${input}.${b64u2(edSign(null, Buffer.from(input), key.privateKey))}`;
35556
+ }
35557
+ function verifyCredentialJwt(jwt) {
35558
+ try {
35559
+ const [h, p, s] = jwt.trim().split(".");
35560
+ if (!h || !p || !s)
35561
+ return { valid: false, reason: "not a compact JWS" };
35562
+ const header = JSON.parse(Buffer.from(h, "base64url").toString("utf8"));
35563
+ const vc = JSON.parse(Buffer.from(p, "base64url").toString("utf8"));
35564
+ if (header.alg !== "EdDSA" || header.typ !== "vc+jwt")
35565
+ return { valid: false, reason: "unexpected header (expected EdDSA, vc+jwt)" };
35566
+ const did = String(header.kid ?? "").split("#")[0];
35567
+ if (!did.startsWith("did:key:"))
35568
+ return { valid: false, reason: "issuer key is not a did:key" };
35569
+ if (vc.issuer !== did)
35570
+ return { valid: false, reason: "the credential's issuer does not match the signing key" };
35571
+ const ok = edVerify(null, Buffer.from(`${h}.${p}`), publicKeyFromDidKey(did), Buffer.from(s, "base64url"));
35572
+ return ok ? { valid: true, credential: vc, issuer: did } : { valid: false, reason: "signature does not match" };
35573
+ } catch (e) {
35574
+ return { valid: false, reason: e.message };
35575
+ }
35576
+ }
35577
+ function roiEstimate(i) {
35578
+ const annualToolCost = i.tokensPerTurn * i.turnsPerDay * 365 * i.agents * i.pricePerMTok / 1e6;
35579
+ const tokenSavings = annualToolCost * i.wasteShare;
35580
+ const reviewSavings = i.vendorReviews * i.hoursPerReview * i.hourlyCost * i.reviewTimeSaved;
35581
+ const r = (x) => Math.round(x);
35582
+ return {
35583
+ annualToolCost: r(annualToolCost),
35584
+ tokenSavings: r(tokenSavings),
35585
+ reviewSavings: r(reviewSavings),
35586
+ totalSavings: r(tokenSavings + reviewSavings),
35587
+ assumptions: `${i.tokensPerTurn.toLocaleString("en-US")} tokens of tool definitions per turn, ${i.turnsPerDay.toLocaleString("en-US")} turns a day, ${i.agents} agent(s), $${i.pricePerMTok} per million input tokens, ${Math.round(i.wasteShare * 100)}% removable (duplicates, unused servers, oversized definitions)${i.vendorReviews ? `; ${i.vendorReviews} vendor reviews a year at ${i.hoursPerReview} hours and $${i.hourlyCost} an hour, ${Math.round(i.reviewTimeSaved * 100)}% of the effort replaced by passports` : ""}`
35588
+ };
35589
+ }
35590
+ var hex, nanos, attr, b64u2, ROI_DEFAULTS;
35591
+ var init_interop = __esm({
35592
+ "packages/testkit-core/dist/interop.js"() {
35593
+ "use strict";
35594
+ init_dist();
35595
+ hex = (s, n) => createHash2("sha256").update(s).digest("hex").slice(0, n);
35596
+ nanos = (iso, minusMs = 0) => String(BigInt(Date.parse(iso) - minusMs) * 1000000n);
35597
+ attr = (key, v) => v === void 0 ? void 0 : { key, value: typeof v === "number" ? Number.isInteger(v) ? { intValue: String(v) } : { doubleValue: v } : typeof v === "boolean" ? { boolValue: v } : { stringValue: v } };
35598
+ b64u2 = (b) => Buffer.from(b).toString("base64url");
35599
+ ROI_DEFAULTS = { turnsPerDay: 1e3, agents: 1, pricePerMTok: 3, wasteShare: 0.3, vendorReviews: 0, hoursPerReview: 20, hourlyCost: 100, reviewTimeSaved: 0.6 };
35600
+ }
35601
+ });
35602
+
35603
+ // packages/testkit-core/dist/watch.js
35604
+ function splitCommand(s) {
35605
+ const out = [];
35606
+ const re = /"([^"]*)"|'([^']*)'|(\S+)/g;
35607
+ let m;
35608
+ while (m = re.exec(s))
35609
+ out.push(m[1] ?? m[2] ?? m[3]);
35610
+ return out;
35611
+ }
35612
+ async function watchAllowlist(entries, packs) {
35613
+ const findings = [];
35614
+ for (const e of entries) {
35615
+ try {
35616
+ const parts = splitCommand(e.target);
35617
+ const target = e.transport === "streamable-http" ? { kind: "streamable-http", url: e.target } : { kind: "stdio", command: parts[0], args: parts.slice(1) };
35618
+ const r = await runTrustCheck(target, { packs });
35619
+ const d = [];
35620
+ if (e.toolsFingerprint && r.target.toolsFingerprint !== e.toolsFingerprint)
35621
+ d.push("tools changed since approval (fingerprint differs): re-review before agents keep using it");
35622
+ if (worse(r.grade, e.trustGrade))
35623
+ d.push(`trust grade dropped from ${e.trustGrade} to ${r.grade ?? "not graded"}`);
35624
+ if (worse(r.readiness?.grade, e.readinessGrade))
35625
+ d.push(`agent readiness dropped from ${e.readinessGrade} to ${r.readiness?.grade ?? "not graded"}`);
35626
+ const status = d.some((x) => x.startsWith("tools changed")) ? "changed" : d.length ? "degraded" : "unchanged";
35627
+ findings.push({ server: e.server, status, details: d, trustGrade: r.grade ?? null, readinessGrade: r.readiness?.grade ?? null, toolsFingerprint: r.target.toolsFingerprint });
35628
+ } catch (err) {
35629
+ findings.push({ server: e.server, status: "unreachable", details: [`could not connect: ${String(err.message).slice(0, 160)}`] });
35630
+ }
35631
+ }
35632
+ return { checkedAt: (/* @__PURE__ */ new Date()).toISOString(), findings, alerts: findings.filter((f) => f.status !== "unchanged").length };
35633
+ }
35634
+ var GRADES4, worse;
35635
+ var init_watch = __esm({
35636
+ "packages/testkit-core/dist/watch.js"() {
35637
+ "use strict";
35638
+ init_engine();
35639
+ GRADES4 = ["A", "B", "C", "D", "F"];
35640
+ worse = (now, then) => then != null && (now == null || GRADES4.indexOf(now) > GRADES4.indexOf(then));
35641
+ }
35642
+ });
35643
+
35491
35644
  // packages/testkit-core/dist/index.js
35492
35645
  var init_dist4 = __esm({
35493
35646
  "packages/testkit-core/dist/index.js"() {
@@ -35517,6 +35670,8 @@ var init_dist4 = __esm({
35517
35670
  init_ledger();
35518
35671
  init_agentid();
35519
35672
  init_receipts();
35673
+ init_interop();
35674
+ init_watch();
35520
35675
  }
35521
35676
  });
35522
35677
 
@@ -35582,7 +35737,7 @@ function renderPassportGallery(entries) {
35582
35737
  }).join("");
35583
35738
  return page("MCP Server Passports: the Saktum trust ledger", `<div class="card"><small>SAKTUM TRUST LEDGER</small><h1>MCP Server Passports</h1><p class="muted">Servers whose publishers recorded a signed Saktum attestation in the public, append-only ledger. Anyone can verify every entry: <code>npx saktum ledger verify</code>. Add yours: <code>npx saktum attest saktum-report.json --publish</code>.</p></div>${cards || `<p class="muted">No entries yet.</p>`}`);
35584
35739
  }
35585
- function renderAssessment(org, f, receipts = []) {
35740
+ function renderAssessment(org, f, receipts = [], roi) {
35586
35741
  const risky = /* @__PURE__ */ new Set(["code-execution", "money", "sends-messages", "writes-or-deletes", "reads-private-data"]);
35587
35742
  const caps = ["code-execution", "money", "sends-messages", "writes-or-deletes", "reads-private-data", "network", "filesystem", "untrusted-content"];
35588
35743
  const grades = ["A", "B", "C", "D", "F", "-"];
@@ -35609,6 +35764,7 @@ function renderAssessment(org, f, receipts = []) {
35609
35764
  <div class="card"><h2>Risk heat map: capability by trust grade</h2><div class="wrap"><table><tr><th>Capability</th>${grades.map((g) => `<th style="text-align:center">${g === "-" ? "n/a" : g}</th>`).join("")}</tr>${heat}</table></div><small>Red cells: risky capabilities on servers graded C or below, or not assessed.</small></div>
35610
35765
  <div class="card"><h2>Servers needing attention</h2>${top ? `<div class="wrap"><table><tr><th>Server</th><th>Machines</th><th>Trust / readiness</th><th>Why</th></tr>${top}</table></div>` : `<p>None: every assessed server meets the policy.</p>`}</div>
35611
35766
  ${rc ? `<div class="card"><h2>Agent receipts</h2><div class="wrap"><table><tr><th>Agent</th><th>Calls</th><th>Blocked</th><th>Destructive</th><th>Repeated calls</th><th>Receipts</th></tr>${rc}</table></div></div>` : ""}
35767
+ ${roi ? `<div class="card"><h2>Business case</h2><div class="grid"><div class="kv"><small>Tool definitions cost a year</small><b>$${roi.annualToolCost.toLocaleString("en-US")}</b></div><div class="kv"><small>Savings from fixes</small><b>$${roi.tokenSavings.toLocaleString("en-US")}</b></div><div class="kv"><small>Review effort replaced by passports</small><b>$${roi.reviewSavings.toLocaleString("en-US")}</b></div><div class="kv"><small>Total a year</small><b>$${roi.totalSavings.toLocaleString("en-US")}</b></div></div><p class="muted">Estimate. Assumptions: ${esc2(roi.assumptions)}. Replace them with your own figures.</p></div>` : ""}
35612
35768
  <div class="card"><h2>Recommendations</h2><ol>${rec.map((x) => `<li>${esc2(x)}</li>`).join("")}</ol></div>
35613
35769
  <div class="card"><h2>Next steps</h2><p>1. Agree the policy and exceptions with security. 2. Enforce it in CI on MCP repositories. 3. Deploy the allowlist to the MCP firewall or gateway. 4. Extend agent mandates and receipts to production agent workflows with the Saktum gateway (design partnership).</p><p class="muted">Findings describe the servers and agents at the time of assessment and are not a guarantee of security.</p></div>`;
35614
35770
  return page(`MCP Trust Assessment: ${org}`, body);
@@ -36206,7 +36362,18 @@ async function runProxy(o) {
36206
36362
  }
36207
36363
  child.stdin.write(line + "\n");
36208
36364
  });
36209
- process.stdin.on("end", () => child.stdin.end());
36365
+ process.stdin.on("end", () => {
36366
+ child.stdin.end();
36367
+ setTimeout(() => {
36368
+ if (child.exitCode === null)
36369
+ child.kill("SIGTERM");
36370
+ }, 2e3).unref();
36371
+ });
36372
+ for (const sig of ["SIGINT", "SIGTERM"])
36373
+ process.once(sig, () => {
36374
+ if (child.exitCode === null)
36375
+ child.kill("SIGTERM");
36376
+ });
36210
36377
  createInterface({ input: child.stdout }).on("line", (line) => {
36211
36378
  let msg;
36212
36379
  try {
@@ -37678,6 +37845,18 @@ POLICY${policy.name ? ` (${sanitizeText(policy.name, 80)})` : ""}
37678
37845
  if (o.out)
37679
37846
  writeFileSync3(o.out, JSON.stringify({ ...report, machine: o.machine ?? hostname() }, null, 2) + "\n");
37680
37847
  });
37848
+ program2.command("vc").description("W3C Verifiable Credentials made by saktum attest --vc").command("verify").description("Verify a Saktum credential (vc+jwt): signature and issuer did:key").argument("<file>", "the .vc.jwt file").action((f) => {
37849
+ const r = verifyCredentialJwt(readFileSync7(f, "utf8"));
37850
+ if (r.valid) {
37851
+ const cs = r.credential.credentialSubject ?? {};
37852
+ process.stdout.write(`\u2713 Valid credential from ${r.issuer}: ${sanitizeText(String(cs.server ?? ""), 80)} trust ${cs.trustGrade ?? "-"}, readiness ${cs.readinessGrade ?? "-"}.
37853
+ `);
37854
+ } else {
37855
+ process.stdout.write(`\u2717 Not valid: ${r.reason}
37856
+ `);
37857
+ exitCode = 1;
37858
+ }
37859
+ });
37681
37860
  const ledger = program2.command("ledger").description("The public Saktum trust ledger: signed attestations in an append-only, hash-chained log");
37682
37861
  ledger.command("verify").description("Verify every signature and the hash chain of a ledger (default: the public ledger)").argument("[source]", "ledger file or https URL", DEFAULT_LEDGER_URL).action(async (src) => {
37683
37862
  const r = verifyLedger(parseLedger(await readLedgerText(src)));
@@ -37766,6 +37945,24 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
37766
37945
  `);
37767
37946
  exitCode = r.ok ? 0 : 1;
37768
37947
  });
37948
+ receipts.command("export").description("Export receipts as OpenTelemetry traces (OTLP/JSON) for your observability or security tools").argument("[file]", "receipt log").option("--otel <file>", "write OTLP/JSON traces to this file", "saktum-receipts.otlp.json").option("--endpoint <url>", "also send them to an OpenTelemetry collector (OTLP/HTTP), for example http://localhost:4318").action(async (f, o) => {
37949
+ const { homedir: homedir2 } = await import("node:os");
37950
+ const { join: join5 } = await import("node:path");
37951
+ const entries = parseReceiptLog(readFileSync7(f ?? join5(homedir2(), ".saktum", "receipts.jsonl"), "utf8"));
37952
+ const v = verifyReceiptLog(entries);
37953
+ const otlp = receiptsToOtlp(entries, { verified: v.ok, version: ENGINE_VERSION });
37954
+ writeFileSync3(o.otel, JSON.stringify(otlp, null, 2) + "\n");
37955
+ process.stdout.write(`Wrote ${entries.length} span(s) to ${sanitizeText(o.otel)} (receipts ${v.ok ? "verified" : "DO NOT verify"}).
37956
+ `);
37957
+ if (o.endpoint) {
37958
+ const url2 = o.endpoint.replace(/\/+$/, "") + "/v1/traces";
37959
+ const res = await fetch(url2, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(otlp) });
37960
+ process.stdout.write(`Sent to ${sanitizeText(url2)}: HTTP ${res.status}
37961
+ `);
37962
+ if (!res.ok)
37963
+ exitCode = 1;
37964
+ }
37965
+ });
37769
37966
  receipts.command("summary").description("The path, not the answer: which tools were called, how often, in what order, retries, denials, destructive actions").argument("[file]", "receipt log").option("--json", "print JSON", false).action(async (f, o) => {
37770
37967
  const { homedir: homedir2 } = await import("node:os");
37771
37968
  const { join: join5 } = await import("node:path");
@@ -37822,13 +38019,51 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
37822
38019
  process.stdout.write(`Wrote the MCP Server Passport for ${sanitizeText(String(r.target.serverInfo?.["name"] ?? "server"), 80)} to ${sanitizeText(o.out)} (trust ${r.grade ?? "-"}, readiness ${r.readiness?.grade ?? "-"}), and its signed result beside it.
37823
38020
  `);
37824
38021
  });
37825
- program2.command("assess").description("An executive MCP Trust Assessment for an organisation, from a fleet inventory and agent receipts (pilot deliverable)").requiredOption("--fleet <file>", "inventory JSON from saktum fleet --out").option("--org <name>", "organisation name", "Your organisation").option("--receipts <file>", "an agent's receipt log (repeatable)", collect, []).option("--out <file>", "HTML report (print to PDF from a browser)", "saktum-assessment.html").action((o) => {
38022
+ program2.command("watch").description("Continuous monitoring: re-check every server on an allowlist and alert on changed tools, grade drops or unreachable servers").argument("<allowlist>", "saktum-allowlist.json (from saktum allowlist)").option("--out <file>", "write the results as JSON").option("--webhook <url>", "POST a summary to this URL when something changed (for example a chat or incident webhook)").action(async (file, o) => {
38023
+ const list = JSON.parse(readFileSync7(file, "utf8"));
38024
+ const packs = existsSync5(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
38025
+ const r = await watchAllowlist(list.allowed ?? [], packs);
38026
+ const mark2 = { unchanged: "\u2713", changed: "\u2717", degraded: "!", unreachable: "?" };
38027
+ for (const f of r.findings)
38028
+ process.stdout.write(`${mark2[f.status]} ${sanitizeText(f.server, 60).padEnd(32)} ${f.status}${f.details.length ? `: ${sanitizeText(f.details.join("; "), 300)}` : ""}
38029
+ `);
38030
+ process.stdout.write(`
38031
+ ${r.findings.length} server(s) checked; ${r.alerts} need attention.
38032
+ `);
38033
+ if (o.out)
38034
+ writeFileSync3(o.out, JSON.stringify(r, null, 2) + "\n");
38035
+ if (o.webhook && r.alerts) {
38036
+ const text2 = `Saktum watch: ${r.alerts} MCP server(s) need attention. ${r.findings.filter((f) => f.status !== "unchanged").map((f) => `${f.server}: ${f.details.join("; ")}`).join(" | ")}`.slice(0, 3e3);
38037
+ try {
38038
+ const res = await fetch(o.webhook, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: text2, findings: r.findings }) });
38039
+ process.stdout.write(`Webhook: HTTP ${res.status}
38040
+ `);
38041
+ } catch (e) {
38042
+ process.stderr.write(`Webhook failed: ${sanitizeText(e.message, 200)}
38043
+ `);
38044
+ }
38045
+ }
38046
+ exitCode = r.alerts ? 1 : 0;
38047
+ });
38048
+ program2.command("roi").description("What tool definitions cost your agents a year, and what Saktum's fixes and passports can save (assumptions shown)").option("--tokens-per-turn <n>", "tokens of tool definitions per turn (from saktum check or scan-config)", "5047").option("--turns-per-day <n>", "agent turns a day, per agent", String(ROI_DEFAULTS.turnsPerDay)).option("--agents <n>", "number of agents", String(ROI_DEFAULTS.agents)).option("--price-per-mtok <usd>", "price per million input tokens", String(ROI_DEFAULTS.pricePerMTok)).option("--waste <share>", "share removable by fixes (0 to 1)", String(ROI_DEFAULTS.wasteShare)).option("--vendor-reviews <n>", "AI vendor or tool security reviews a year", "0").option("--hours-per-review <n>", "hours per review", String(ROI_DEFAULTS.hoursPerReview)).option("--hourly-cost <usd>", "loaded cost per hour", String(ROI_DEFAULTS.hourlyCost)).action((o) => {
38049
+ const n = (k) => Number(o[k]);
38050
+ const r = roiEstimate({ tokensPerTurn: n("tokensPerTurn"), turnsPerDay: n("turnsPerDay"), agents: n("agents"), pricePerMTok: n("pricePerMtok"), wasteShare: n("waste"), vendorReviews: n("vendorReviews"), hoursPerReview: n("hoursPerReview"), hourlyCost: n("hourlyCost"), reviewTimeSaved: ROI_DEFAULTS.reviewTimeSaved });
38051
+ const usd = (x) => `$${x.toLocaleString("en-US")}`;
38052
+ process.stdout.write(`Tool definitions cost about ${usd(r.annualToolCost)} a year.
38053
+ Fixes could save about ${usd(r.tokenSavings)} a year${r.reviewSavings ? `; passports could save about ${usd(r.reviewSavings)} of review effort` : ""}.
38054
+ Total: about ${usd(r.totalSavings)} a year.
38055
+ Assumptions: ${r.assumptions}.
38056
+ `);
38057
+ });
38058
+ program2.command("assess").description("An executive MCP Trust Assessment for an organisation, from a fleet inventory and agent receipts (pilot deliverable)").requiredOption("--fleet <file>", "inventory JSON from saktum fleet --out").option("--org <name>", "organisation name", "Your organisation").option("--receipts <file>", "an agent's receipt log (repeatable)", collect, []).option("--out <file>", "HTML report (print to PDF from a browser)", "saktum-assessment.html").option("--agents <n>", "agents in production, for the business case", "10").option("--turns-per-day <n>", "turns a day per agent", "1000").option("--price-per-mtok <usd>", "price per million input tokens", "3").option("--vendor-reviews <n>", "AI vendor or tool security reviews a year", "20").action((o) => {
37826
38059
  const fleet = JSON.parse(readFileSync7(o.fleet, "utf8"));
37827
38060
  const rec = o.receipts.map((f) => {
37828
38061
  const e = parseReceiptLog(readFileSync7(f, "utf8"));
37829
38062
  return { agent: e[0]?.receipt.envelope.caller.agent?.slice(0, 32) ?? f, summary: summariseReceipts(e), verified: verifyReceiptLog(e).ok };
37830
38063
  });
37831
- writeFileSync3(o.out, renderAssessment(o.org, fleet, rec));
38064
+ const distinctTokens = (fleet.servers ?? []).reduce((a, x) => a + (x.tokens ?? 0), 0);
38065
+ const roi = roiEstimate({ ...ROI_DEFAULTS, tokensPerTurn: distinctTokens, agents: Number(o.agents), turnsPerDay: Number(o.turnsPerDay), pricePerMTok: Number(o.pricePerMtok), vendorReviews: Number(o.vendorReviews) });
38066
+ writeFileSync3(o.out, renderAssessment(o.org, fleet, rec, roi));
37832
38067
  process.stdout.write(`Wrote the MCP Trust Assessment for ${sanitizeText(o.org, 80)} to ${sanitizeText(o.out)}: ${fleet.servers?.length ?? 0} servers, ${fleet.nonCompliant ?? 0} violating policy. Open it in a browser and print to PDF.
37833
38068
  `);
37834
38069
  });
@@ -37851,7 +38086,7 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
37851
38086
  const { startMcpServer: startMcpServer2 } = await Promise.resolve().then(() => (init_mcp_server(), mcp_server_exports));
37852
38087
  await startMcpServer2(packs);
37853
38088
  });
37854
- program2.command("attest").description("Turn a signed result into a compact signed attestation for your README or registry listing").argument("<result>", "a signed result (saktum-report.json)").option("--out <file>", "attestation file", "saktum-attestation.json").option("--key <path>", "signing key file").option("--publish", "also print a link that publishes it to the public Saktum trust ledger (a pre-filled GitHub issue)", false).action((file, o) => {
38089
+ program2.command("attest").description("Turn a signed result into a compact signed attestation for your README or registry listing").argument("<result>", "a signed result (saktum-report.json)").option("--out <file>", "attestation file", "saktum-attestation.json").option("--key <path>", "signing key file").option("--publish", "also print a link that publishes it to the public Saktum trust ledger (a pre-filled GitHub issue)", false).option("--vc", "also write it as a W3C Verifiable Credential (vc+jwt, issued by your did:key)", false).action((file, o) => {
37855
38090
  const doc = JSON.parse(readFileSync7(file, "utf8"));
37856
38091
  const v = verifyDocument(doc);
37857
38092
  if (!v.valid)
@@ -37865,6 +38100,16 @@ Anyone can check it: npx saktum verify ${sanitizeText(o.out)}
37865
38100
  README badge:
37866
38101
  [![Saktum trust ${c.trustGrade ?? "-"}](https://img.shields.io/badge/Saktum-trust%20${c.trustGrade ?? "-"}%20%C2%B7%20readiness%20${c.readinessGrade ?? "-"}-${colour(c.trustGrade)})](${sanitizeText(o.out)})
37867
38102
  `);
38103
+ if (o.vc) {
38104
+ const key = loadOrCreateKey(o.key);
38105
+ const cred = attestationToCredential(att, key.kid);
38106
+ const base = o.out.replace(/\.json$/i, "");
38107
+ writeFileSync3(`${base}.vc.jwt`, signCredentialJwt(cred, key) + "\n");
38108
+ writeFileSync3(`${base}.vc.json`, JSON.stringify(cred, null, 2) + "\n");
38109
+ process.stdout.write(`
38110
+ W3C Verifiable Credential: ${sanitizeText(base)}.vc.jwt (check it: npx saktum vc verify ${sanitizeText(base)}.vc.jwt)
38111
+ `);
38112
+ }
37868
38113
  if (o.publish) {
37869
38114
  const body = `Publishing a signed Saktum attestation to the public trust ledger. The bot verifies the signature and appends it.
37870
38115