saktum 0.12.0 → 0.13.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 +12 -1
  2. package/package.json +1 -1
  3. package/saktum.mjs +137 -17
package/README.md CHANGED
@@ -11,6 +11,17 @@ npx saktum check https://your-server.example/mcp # a remote server (sign-in
11
11
 
12
12
  Runs on your machine. Nothing is uploaded. Your own environment variables are never passed to the server.
13
13
 
14
+ ## Close the nine gaps (v0.13)
15
+
16
+ Saktum now addresses all nine common agent security gaps at the tool layer: **task-scoped, short-lived agent
17
+ credentials** (`identity issue --minutes 30 --tools search,pay`) whose scope can only narrow down the chain, with a
18
+ **delegation-depth limit**; a **secret guard** that refuses calls carrying keys or tokens (never recording them); a
19
+ **result guard** that flags instructions aimed at the agent in tool results, or withholds them with
20
+ `--quarantine-results`; and **output digests** in every receipt. The evidence crosswalk adds **ISO/IEC 27001** and
21
+ Canada's **OSFI E-23** (and lists California SB 53 as not applicable). New story: `npx saktum demo --story support`.
22
+ Boundaries: issuing third-party API tokens belongs to the gateway; Saktum guards what passes through tools, not the
23
+ model's context.
24
+
14
25
  ## Trust you can verify (v0.12)
15
26
 
16
27
  Saktum holds itself to the standard it asks of others. Revocations are signed and stick (receipt chain, optional remote
@@ -245,7 +256,7 @@ servers not on your allowlist, and the weakest grades. Configured secrets are ne
245
256
 
246
257
  ```yaml
247
258
  - uses: actions/checkout@v4
248
- - uses: soodhere/saktum-check@v0.12.0
259
+ - uses: soodhere/saktum-check@v0.13.0
249
260
  with:
250
261
  target: "-- node build/index.js" # or an https URL
251
262
  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.12.0",
3
+ "version": "0.13.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.12.0 (private beta). Licensed Apache-2.0; bundled dependencies keep their own licences.
2
+ // Saktum Check 0.13.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;
@@ -34057,7 +34057,7 @@ var init_dist3 = __esm({
34057
34057
  init_stdio2();
34058
34058
  init_streamableHttp();
34059
34059
  init_types2();
34060
- USER_AGENT = "saktum-check/0.12.0 (+https://saktum.dev/check)";
34060
+ USER_AGENT = "saktum-check/0.13.0 (+https://saktum.dev/check)";
34061
34061
  LIMITS = { requestTimeoutMs: 1e4, connectTimeoutMs: 6e4, maxResponseChars: 5e6 };
34062
34062
  LimitError = class extends Error {
34063
34063
  };
@@ -34095,7 +34095,7 @@ var init_dist3 = __esm({
34095
34095
  jsonrpc: "2.0",
34096
34096
  id: 1,
34097
34097
  method: "initialize",
34098
- params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.12.0" } }
34098
+ params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.13.0" } }
34099
34099
  });
34100
34100
  }
34101
34101
  });
@@ -35467,7 +35467,7 @@ var init_engine = __esm({
35467
35467
  init_runner();
35468
35468
  init_safe();
35469
35469
  init_scoring();
35470
- ENGINE_VERSION = "0.12.0";
35470
+ ENGINE_VERSION = "0.13.0";
35471
35471
  UNKNOWN_TOOL = "saktum_trust_check_no_such_tool";
35472
35472
  INVALID_TOKEN = "saktum-check-deliberately-invalid-token";
35473
35473
  baseOf = (pack, check) => ({
@@ -36111,6 +36111,10 @@ var init_vocab = __esm({
36111
36111
  { path: "code.repository", type: "string", description: "The code repository" },
36112
36112
  { path: "code.environment", type: "string", description: "The deployment environment (for example staging, production)" }
36113
36113
  ] };
36114
+ VOCABULARIES.support = { version: "0.1", fields: [
36115
+ { path: "support.customer_id", type: "string", description: "The customer a support case is about" },
36116
+ { path: "support.amount", type: "number", description: "A refund or credit amount" }
36117
+ ] };
36114
36118
  KNOWN_FIELDS = new Set(Object.values(VOCABULARIES).flatMap((v) => v.fields.map((f) => f.path)));
36115
36119
  NAME_RULES = [
36116
36120
  [/(^|[_-])(search|find|list|get|lookup|deals|browse)([_-]|$)/i, "search"],
@@ -36764,8 +36768,17 @@ function issueCredential(issuerCred, issuerKey, s) {
36764
36768
  throw new Error("The signing key does not belong to the issuer's credential.");
36765
36769
  if (issuerCred.type === "agent")
36766
36770
  throw new Error("Agents cannot issue credentials.");
36771
+ const parentTools = issuerCred.scope?.tools;
36772
+ if (parentTools && s.tools?.some((t) => !parentTools.includes(t)))
36773
+ throw new Error(`The issuer may only grant tools it holds: ${parentTools.join(", ")}.`);
36774
+ if (s.expires > issuerCred.expires)
36775
+ throw new Error(`A credential cannot outlive its issuer's (${issuerCred.expires}).`);
36776
+ if (issuerCred.maxDepth !== void 0 && issuerCred.maxDepth < 1)
36777
+ throw new Error("The issuer's credential does not allow further delegation.");
36778
+ const tools = s.tools ?? parentTools;
36779
+ const maxDepth2 = issuerCred.maxDepth !== void 0 ? Math.min(s.maxDepth ?? issuerCred.maxDepth - 1, issuerCred.maxDepth - 1) : s.maxDepth;
36767
36780
  const chain = [...issuerCred.chain ?? [], { ...issuerCred, chain: void 0 }].map((c2) => JSON.parse(JSON.stringify(c2)));
36768
- const c = { credentialFormat: "0.1", type: s.type, subject: { id: s.id, name: s.name, ...s.role ? { role: s.role } : {} }, issuer: { id: issuerKey.kid, name: issuerCred.subject.name, ...issuerCred.issuer.domain ? { domain: issuerCred.issuer.domain } : {} }, issuedAt: nowIso(), expires: s.expires };
36781
+ const c = { credentialFormat: "0.1", type: s.type, ...tools ? { scope: { tools } } : {}, ...maxDepth2 !== void 0 ? { maxDepth: maxDepth2 } : {}, subject: { id: s.id, name: s.name, ...s.role ? { role: s.role } : {} }, issuer: { id: issuerKey.kid, name: issuerCred.subject.name, ...issuerCred.issuer.domain ? { domain: issuerCred.issuer.domain } : {} }, issuedAt: nowIso(), expires: s.expires };
36769
36782
  return { ...signDocument({ ...c, id: short("cred_", c) }, issuerKey), chain };
36770
36783
  }
36771
36784
  function verifyChain(c, o = {}) {
@@ -36787,9 +36800,18 @@ function verifyChain(c, o = {}) {
36787
36800
  return { valid: false, path, reason: "the chain does not start at an organisation" };
36788
36801
  if (i > 0 && l.issuer.id !== links[i - 1].subject.id)
36789
36802
  return { valid: false, path, reason: `${l.subject.name}'s issuer is not the previous link in the chain` };
36803
+ if (i > 0) {
36804
+ const p = links[i - 1];
36805
+ if (p.scope?.tools && (!l.scope?.tools || l.scope.tools.some((t) => !p.scope.tools.includes(t))))
36806
+ return { valid: false, path, reason: `${l.subject.name}'s credential grants more than its issuer holds` };
36807
+ if (l.expires > p.expires)
36808
+ return { valid: false, path, reason: `${l.subject.name}'s credential outlives its issuer's` };
36809
+ }
36810
+ if (l.maxDepth !== void 0 && links.length - 1 - i > l.maxDepth)
36811
+ return { valid: false, path, reason: `the chain delegates deeper than ${l.subject.name}'s credential allows (${l.maxDepth})` };
36790
36812
  path.push(`${l.subject.name}${l.subject.role ? ` (${l.subject.role})` : ""}`);
36791
36813
  }
36792
- return { valid: true, path, organisation: links[0].subject.name + (links[0].issuer.domain ? ` (${links[0].issuer.domain})` : "") };
36814
+ return { valid: true, path, organisation: links[0].subject.name + (links[0].issuer.domain ? ` (${links[0].issuer.domain})` : ""), ...links[links.length - 1].scope?.tools ? { tools: links[links.length - 1].scope.tools } : {} };
36793
36815
  }
36794
36816
  function findOrphans(creds, o = {}) {
36795
36817
  return creds.filter((c) => c.type === "agent").map((c) => ({ agent: c.subject.name, id: c.subject.id, ...verifyChain(c, o) })).filter((x) => !x.valid);
@@ -37047,6 +37069,25 @@ var init_crosswalk = __esm({
37047
37069
  I("9.2", "Internal audit", "partial", "Independently verifiable ledger, receipts and passports for auditors", ["saktum ledger verify", "saktum receipts verify"]),
37048
37070
  I("A.10", "Third-party and customer relationships", "covered", "Passports, manifests, signed agreements, Verifiable Credentials", ["saktum attest --vc", "saktum agreement verify"])
37049
37071
  ] },
37072
+ { id: "iso-27001", name: "ISO/IEC 27001 (Annex A, 2022)", note: "Information security management; certification is by accredited bodies.", items: [
37073
+ I("A.5.15", "Access control", "covered", "Least-privilege mandates and task-scoped, short-lived agent credentials", ["saktum agent create --intent", "saktum identity issue --minutes --tools"]),
37074
+ I("A.5.19\u2013A.5.22", "Information security in supplier relationships", "covered", "Passports, attestations, monitoring and signed agreements for third-party MCP servers", ["saktum passport", "saktum watch", "saktum agreement verify"]),
37075
+ I("A.8.2", "Privileged access rights", "partial", "Approvals for risky actions, autonomy levels and revocation (agents; not human administrators)", ["saktum agent approve", "saktum agent revoke"]),
37076
+ I("A.8.15", "Logging", "covered", "Signed, chained receipts with input and output digests; checkpoints detect deletion", ["saktum receipts verify", "saktum receipts checkpoint"]),
37077
+ I("A.8.16", "Monitoring activities", "covered", "Daily monitoring of approved servers, result flags, OpenTelemetry export", ["saktum watch", "saktum receipts export --otel"]),
37078
+ I("A.8.24", "Use of cryptography", "partial", "Ed25519 signatures, keys in OS keychains or external key services (confidentiality at rest is the customer's storage)", ["saktum self-verify"])
37079
+ ] },
37080
+ { id: "osfi-e23", name: "OSFI E-23 (Canada)", note: "Model risk management for federally regulated financial institutions, including AI; applicability and dates per OSFI.", items: [
37081
+ I("Inventory", "Model inventory", "covered", "Agent and MCP server inventories across the organisation", ["saktum agents scan", "saktum fleet"]),
37082
+ I("Risk rating", "Risk-based model classification", "covered", "Risk tiers R0\u2013R4 for servers and agents; policy ceilings", ["saktum check", "saktum fleet --policy"]),
37083
+ I("Governance", "Accountability and roles", "covered", "Identity chains to accountable people and organisations; operator countersignatures", ["saktum identity verify", "saktum agent cosign"]),
37084
+ I("Monitoring", "Ongoing monitoring across the lifecycle", "covered", "Track records, maturity levels, daily monitoring, receipts", ["saktum passport --agent", "saktum watch"]),
37085
+ I("Explainability", "Explainability and transparency", "partial", "Every decision carries a reason and rationale (actions, not model internals)", ["saktum receipts summary"]),
37086
+ I("Third parties", "Third-party and vendor models", "partial", "Passports and attestations for third-party tools (the models themselves are out of scope)", ["saktum passport", "saktum attest --vc"])
37087
+ ] },
37088
+ { id: "ca-sb53", name: "California SB 53", note: "Applies to frontier AI model developers, not to organisations running agents; listed so readers see it was considered.", items: [
37089
+ I("Scope", "Frontier developer transparency and safety frameworks", "gap", "Not applicable to Saktum's users (agents and tools, not frontier model training)", [])
37090
+ ] },
37050
37091
  { id: "owasp-llm", name: "OWASP Top 10 for LLM Applications (2025)", note: "Mapped for agents' tool use; model-level risks are out of scope.", items: [
37051
37092
  I("LLM01", "Prompt injection", "partial", "Hidden-instruction checks on tools; mandates contain a manipulated agent (detection inside models is out of scope)", ["saktum check", "saktum demo"]),
37052
37093
  I("LLM02", "Sensitive information disclosure", "partial", "Personal and classified data enforced per recipient; secrets never printed; argument digests only", ["saktum proxy --enforce"]),
@@ -37325,6 +37366,43 @@ var init_webauthn = __esm({
37325
37366
  }
37326
37367
  });
37327
37368
 
37369
+ // packages/testkit-core/dist/guards.js
37370
+ function findSecret(text2) {
37371
+ for (const p of SECRET_PATTERNS) {
37372
+ const re = new RegExp(p.re.source, p.re.flags.replace("g", ""));
37373
+ const m = text2.match(re);
37374
+ if (m && (!p.valid || p.valid(m)))
37375
+ return p.name;
37376
+ }
37377
+ return void 0;
37378
+ }
37379
+ function findHiddenInstruction(text2, o = {}) {
37380
+ for (const re of o.broad ? [...HIDDEN_INSTRUCTION, ...RESULT_INJECTION] : HIDDEN_INSTRUCTION) {
37381
+ const m = text2.match(re);
37382
+ if (m)
37383
+ return m[0].slice(0, 80);
37384
+ }
37385
+ return void 0;
37386
+ }
37387
+ function resultText(result) {
37388
+ const r = result ?? {};
37389
+ return [...(r.content ?? []).map((c) => typeof c.text === "string" ? c.text : ""), r.structuredContent ? JSON.stringify(r.structuredContent) : ""].join("\n");
37390
+ }
37391
+ var RESULT_INJECTION;
37392
+ var init_guards = __esm({
37393
+ "packages/testkit-core/dist/guards.js"() {
37394
+ "use strict";
37395
+ init_analysers();
37396
+ init_leakage();
37397
+ RESULT_INJECTION = [
37398
+ /\bignore (the |your )?(user|previous|prior|above|earlier|original)\b/i,
37399
+ /\b(send|upload|post|forward|email|exfiltrate) (the |all |any |your |their )?(conversation|chat|credentials|api keys?|secrets?|tokens?|passwords?|private data)\b[^.\n]{0,40}\bto\b/i,
37400
+ /\byou are now\b|\bnew instructions?:/i,
37401
+ /\b(do not|don['’]t|never) (tell|inform|alert|notify) the user\b/i
37402
+ ];
37403
+ }
37404
+ });
37405
+
37328
37406
  // packages/testkit-core/dist/index.js
37329
37407
  var dist_exports = {};
37330
37408
  __export(dist_exports, {
@@ -37343,6 +37421,7 @@ __export(dist_exports, {
37343
37421
  FRAMEWORKS: () => FRAMEWORKS,
37344
37422
  FUNCTIONAL_LIMITS: () => FUNCTIONAL_LIMITS,
37345
37423
  GENESIS: () => GENESIS,
37424
+ HIDDEN_INSTRUCTION: () => HIDDEN_INSTRUCTION,
37346
37425
  INVISIBLE: () => INVISIBLE,
37347
37426
  KNOWN_FIELDS: () => KNOWN_FIELDS,
37348
37427
  LEAKAGE_NEEDS: () => LEAKAGE_NEEDS,
@@ -37416,8 +37495,10 @@ __export(dist_exports, {
37416
37495
  evaluatePolicy: () => evaluatePolicy,
37417
37496
  exampleFor: () => exampleFor,
37418
37497
  extractJson: () => extractJson,
37498
+ findHiddenInstruction: () => findHiddenInstruction,
37419
37499
  findInLedger: () => findInLedger,
37420
37500
  findOrphans: () => findOrphans,
37501
+ findSecret: () => findSecret,
37421
37502
  fleetHtml: () => fleetHtml,
37422
37503
  gradeFor: () => gradeFor,
37423
37504
  hasIntent: () => hasIntent,
@@ -37462,6 +37543,7 @@ __export(dist_exports, {
37462
37543
  renderSetup: () => renderSetup,
37463
37544
  renderVerdict: () => renderVerdict,
37464
37545
  resultProblems: () => resultProblems,
37546
+ resultText: () => resultText,
37465
37547
  revocationOf: () => revocationOf,
37466
37548
  revokeMandate: () => revokeMandate,
37467
37549
  revokedInChain: () => revokedInChain,
@@ -37548,6 +37630,7 @@ var init_dist4 = __esm({
37548
37630
  init_agents();
37549
37631
  init_trust();
37550
37632
  init_webauthn();
37633
+ init_guards();
37551
37634
  }
37552
37635
  });
37553
37636
 
@@ -38308,7 +38391,7 @@ async function runProxy(o) {
38308
38391
  let metering;
38309
38392
  try {
38310
38393
  const rev = o.mandate ? revocationOf(o.mandate, o.revocationsPath) : void 0;
38311
- d = rev ? { allow: false, code: "revoked", reason: `the mandate was revoked on ${rev.at.slice(0, 10)}${rev.reason ? ` (${rev.reason})` : ""}` } : o.mandate && (remoteRevoked || revokedInChain(history)) ? { allow: false, code: "revoked", reason: "the mandate was revoked (recorded in the ledger or in this receipt chain)" } : toolsChanged ? { allow: false, code: "tools-changed", reason: "the server's tools differ from the pinned, approved fingerprint" } : o.mandate ? decideCall(o.mandate, { tool, server: service, args, annotations: ann, isMoney, usage: usage() }) : { allow: true, code: "ok", reason: "no mandate: observed" };
38394
+ d = rev ? { allow: false, code: "revoked", reason: `the mandate was revoked on ${rev.at.slice(0, 10)}${rev.reason ? ` (${rev.reason})` : ""}` } : o.mandate && (remoteRevoked || revokedInChain(history)) ? { allow: false, code: "revoked", reason: "the mandate was revoked (recorded in the ledger or in this receipt chain)" } : findSecret(JSON.stringify(args ?? {})) ? { allow: false, code: "secret-in-arguments", reason: `the arguments contain what looks like a secret (${findSecret(JSON.stringify(args ?? {}))}); it was not sent and is not recorded` } : toolsChanged ? { allow: false, code: "tools-changed", reason: "the server's tools differ from the pinned, approved fingerprint" } : o.mandate ? decideCall(o.mandate, { tool, server: service, args, annotations: ann, isMoney, usage: usage() }) : { allow: true, code: "ok", reason: "no mandate: observed" };
38312
38395
  if (d.allow && o.mandate && hasIntent(o.mandate)) {
38313
38396
  const di = decideIntent(o.mandate, def ?? { name: tool }, args, { server: service });
38314
38397
  rationale = di.rationale;
@@ -38344,6 +38427,8 @@ async function runProxy(o) {
38344
38427
  const root = [...o.credential.chain ?? [], o.credential][0].subject.id;
38345
38428
  if (!vc.valid)
38346
38429
  d = { allow: false, code: "identity-chain", reason: `the agent's accountability chain is broken: ${vc.reason}` };
38430
+ else if (vc.tools && !vc.tools.includes(tool))
38431
+ d = { allow: false, code: "outside-credential-scope", reason: `the agent's credential covers only ${vc.tools.join(", ")}` };
38347
38432
  else if (o.agreement && root !== o.agreement.invoker.id)
38348
38433
  d = { allow: false, code: "identity-chain", reason: "the agent's organisation is not the party to the agreement" };
38349
38434
  }
@@ -38368,7 +38453,7 @@ async function runProxy(o) {
38368
38453
  if (!d.allow && (o.enforce || d.code === "error-fail-closed")) {
38369
38454
  const hint = d.code === "revoked" ? " The agent's owner stopped it; do not retry." : d.code === "approval-needed" ? " Ask your user to approve it (saktum agent approve with the request id), then retry the same action once." : d.code === "notify-only" ? " Tell your user what you found instead." : " Ask the agent's owner to change the mandate if this action is needed.";
38370
38455
  process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: msg.id, result: { isError: true, content: [{ type: "text", text: `Blocked by Saktum (${d.code}): ${d.reason}.${hint}` }] } }) + "\n");
38371
- record2(tool, argsHash, "deny", d.reason, { status: "blocked", destructive: isDestructive(ann), code: d.code, values, ...rationale ? { rationale } : {} });
38456
+ record2(tool, argsHash, "deny", d.reason, { status: "blocked", destructive: isDestructive(ann), code: d.code, values: d.code === "secret-in-arguments" ? void 0 : values, ...rationale ? { rationale } : {} });
38372
38457
  o.log?.(`denied ${tool} (${d.code}): ${d.reason}`);
38373
38458
  return;
38374
38459
  }
@@ -38423,7 +38508,16 @@ async function runProxy(o) {
38423
38508
  if (c) {
38424
38509
  calls.delete(k);
38425
38510
  const status = msg.error ? "protocol-error" : msg.result?.isError ? "tool-error" : "ok";
38426
- record2(c.tool, c.argsHash, msg.error ? "error" : "allow", c.reason, { status, latencyMs: Date.now() - c.start, destructive: c.destructive, code: c.code, values: c.values, ...c.rationale ? { rationale: c.rationale } : {}, ...c.metering ? { metering: c.metering } : {} });
38511
+ const text2 = msg.result ? resultText(msg.result) : "";
38512
+ const hidden = text2 ? findHiddenInstruction(text2, { broad: true }) : void 0, secret = text2 ? findSecret(text2) : void 0;
38513
+ const flags = [...hidden ? ["hidden-instruction-in-result"] : [], ...secret ? [`secret-in-result:${secret}`] : []];
38514
+ if (flags.length)
38515
+ o.log?.(`${c.tool}: result flagged (${flags.join(", ")})`);
38516
+ if (flags.length && o.quarantineResults) {
38517
+ msg.result = { content: [{ type: "text", text: `Withheld by Saktum: this tool's result contained ${hidden ? "instructions aimed at the agent" : "what looks like a secret"}. Ask the user before continuing.` }], isError: true };
38518
+ line = JSON.stringify(msg);
38519
+ }
38520
+ record2(c.tool, c.argsHash, msg.error ? "error" : "allow", c.reason + (flags.length ? ` [result ${o.quarantineResults ? "withheld" : "flagged"}: ${flags.join(", ")}]` : ""), { status, latencyMs: Date.now() - c.start, destructive: c.destructive, code: c.code, values: c.values, outputDigest: digest(msg.result ?? msg.error ?? null), ...flags.length ? { flags } : {}, ...c.rationale ? { rationale: c.rationale } : {}, ...c.metering ? { metering: c.metering } : {} });
38427
38521
  }
38428
38522
  process.stdout.write(line + "\n");
38429
38523
  });
@@ -39197,7 +39291,7 @@ __export(demo_exports, {
39197
39291
  import { mkdirSync as mkdirSync5, readFileSync as readFileSync8, writeFileSync as writeFileSync4, existsSync as existsSync6, rmSync } from "node:fs";
39198
39292
  import { join as join6 } from "node:path";
39199
39293
  async function startDemoServer(story = "autonomy") {
39200
- const tools = story === "grocery" ? GROCERY_TOOLS : story === "travel" ? TRAVEL_TOOLS : story === "finance" ? FINANCE_TOOLS : story === "coding" ? CODING_TOOLS : DEMO_TOOLS;
39294
+ const tools = story === "grocery" ? GROCERY_TOOLS : story === "travel" ? TRAVEL_TOOLS : story === "finance" ? FINANCE_TOOLS : story === "coding" ? CODING_TOOLS : story === "support" ? SUPPORT_TOOLS : DEMO_TOOLS;
39201
39295
  const server = new Server({ name: story === "travel" ? "demo-travel" : story === "finance" ? "demo-finance" : "demo-grocer", version: "1.0.0" }, { capabilities: { tools: {} } });
39202
39296
  const cart = [];
39203
39297
  server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools }));
@@ -39230,6 +39324,10 @@ async function startDemoServer(story = "autonomy") {
39230
39324
  return text2(`Sent "${a.report}" to ${a.recipient}.`);
39231
39325
  case "pay_invoice":
39232
39326
  return text2(`Paid $${a.amount} to ${a.vendor}.`);
39327
+ case "lookup_customer":
39328
+ return text2(`${a.customer_id}: 3 orders; latest arrived damaged.`);
39329
+ case "issue_refund":
39330
+ return text2(`Refunded $${a.amount} to ${a.customer_id}.`);
39233
39331
  case "run_tests":
39234
39332
  return text2(`${a.repository}: 412 tests passed.`);
39235
39333
  case "open_pull_request":
@@ -39461,7 +39559,7 @@ async function runDemo(dir, log, story = "all") {
39461
39559
  const owner = loadOrCreateKey(join6(dir, "owner-key.json"));
39462
39560
  log("Saktum demo: agents acting on real instructions (rules, preferences, substitutions, upsells), every decision explained and signed.\n");
39463
39561
  const files = [];
39464
- for (const st of story === "travel" ? [TRAVEL] : story === "grocery" ? [GROCERY] : story === "finance" ? [FINANCE] : story === "coding" ? [CODING] : [GROCERY, TRAVEL, FINANCE, CODING])
39562
+ for (const st of story === "travel" ? [TRAVEL] : story === "grocery" ? [GROCERY] : story === "finance" ? [FINANCE] : story === "coding" ? [CODING] : story === "support" ? [SUPPORT] : [GROCERY, TRAVEL, FINANCE, CODING, SUPPORT])
39465
39563
  files.push(await runStory(dir, st, owner, log));
39466
39564
  if (story === "all")
39467
39565
  files.push(await runMarketplace(dir, log));
@@ -39538,7 +39636,7 @@ async function runAutonomyDemo(dir, log) {
39538
39636
  log("What you just saw: the same agent and the same shop. Only the mandate changed what it was allowed to do, and every\ndecision, allowed or blocked, has a signed receipt. Open the passports to see each agent's permissions and path.");
39539
39637
  return { files };
39540
39638
  }
39541
- var PRODUCTS, DEMO_TOOLS, B, GROCERY_TOOLS, TRAVEL_TOOLS, FINANCE_TOOLS, CODING_TOOLS, SCRIPT, EXTRA, GROCERY, TRAVEL, FINANCE, CODING;
39639
+ var PRODUCTS, DEMO_TOOLS, B, GROCERY_TOOLS, TRAVEL_TOOLS, FINANCE_TOOLS, CODING_TOOLS, SUPPORT_TOOLS, SCRIPT, EXTRA, GROCERY, TRAVEL, FINANCE, CODING, SUPPORT;
39542
39640
  var init_demo = __esm({
39543
39641
  "packages/cli/dist/demo.js"() {
39544
39642
  "use strict";
@@ -39598,6 +39696,10 @@ var init_demo = __esm({
39598
39696
  { name: "deploy_to_staging", description: "Deploy a build to the staging environment.", inputSchema: { type: "object", properties: { repository: { type: "string" }, build: { type: "string" } }, required: ["repository", "build"] }, annotations: { readOnlyHint: false, destructiveHint: false }, _meta: B({ repository: "code.repository" }, "change") },
39599
39697
  { name: "deploy_to_production", description: "Release a build to production.", inputSchema: { type: "object", properties: { repository: { type: "string" }, build: { type: "string" } }, required: ["repository", "build"] }, annotations: { readOnlyHint: false, destructiveHint: true }, _meta: B({ repository: "code.repository" }, "deploy") }
39600
39698
  ];
39699
+ SUPPORT_TOOLS = [
39700
+ { name: "lookup_customer", description: "Look up a customer's account and recent orders.", inputSchema: { type: "object", properties: { customer_id: { type: "string" } }, required: ["customer_id"] }, annotations: { readOnlyHint: true }, _meta: B({ customer_id: "support.customer_id" }, "search") },
39701
+ { name: "issue_refund", description: "Refund an amount to the customer's original payment method.", inputSchema: { type: "object", properties: { customer_id: { type: "string" }, amount: { type: "number" } }, required: ["customer_id", "amount"] }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, _meta: B({ customer_id: "support.customer_id", amount: "support.amount" }, "pay") }
39702
+ ];
39601
39703
  SCRIPT = [
39602
39704
  { tool: "get_deals", args: {}, say: "checks this week's deals" },
39603
39705
  { tool: "search_products", args: { query: "coffee" }, say: "searches for coffee" },
@@ -39688,6 +39790,21 @@ var init_demo = __esm({
39688
39790
  { tool: "", args: {}, say: "in the morning, you approve exactly that release (saktum agent approve)", approveLast: true },
39689
39791
  { tool: "deploy_to_production", args: { repository: "payments-service", build: "build-2291" }, say: "retries the same release" }
39690
39792
  ] };
39793
+ SUPPORT = { id: "support", title: `Support agent: "resolve this customer's case; refunds over $100 need a person"`, server: "support", tools: SUPPORT_TOOLS.map((t) => t.name), m: {
39794
+ autonomy: "act",
39795
+ purpose: "Resolve support case 7731 for customer C-1042",
39796
+ actions: [{ cls: "search", autonomy: "act" }, { cls: "pay", autonomy: "act" }],
39797
+ rules: [{ field: "support.customer_id", op: "in", value: ["C-1042"], label: "only this case's customer" }],
39798
+ approveAbove: { arg: "amount", value: 100 },
39799
+ disclosures: { operator: "Acme support", incentives: "None", dataUse: "This case's customer only" }
39800
+ }, steps: [
39801
+ { tool: "lookup_customer", args: { customer_id: "C-1042" }, say: "looks up the customer on the case" },
39802
+ { tool: "issue_refund", args: { customer_id: "C-1042", amount: 40 }, say: "refunds $40 for the damaged item" },
39803
+ { tool: "lookup_customer", args: { customer_id: "C-2077" }, say: "tries to look up a different customer" },
39804
+ { tool: "issue_refund", args: { customer_id: "C-1042", amount: 250 }, say: "tries to refund $250 (goodwill)" },
39805
+ { tool: "", args: {}, say: "a support lead approves exactly that refund (saktum agent approve)", approveLast: true },
39806
+ { tool: "issue_refund", args: { customer_id: "C-1042", amount: 250 }, say: "retries the same refund" }
39807
+ ] };
39691
39808
  }
39692
39809
  });
39693
39810
 
@@ -40608,7 +40725,7 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
40608
40725
  process.stdout.write(`Revoked the mandate for ${sanitizeText(m.agent.name, 80)} at ${r.at}. Its calls are now refused (code: revoked).
40609
40726
  `);
40610
40727
  });
40611
- program2.command("proxy").description("Put Saktum between an agent and a local MCP server: signed receipts for every tool call, and the agent's mandate observed or enforced (preview)").argument("<command...>", "the server command, after --").option("--mandate <file>", "the agent's mandate (from saktum agent create)").option("--agent-key <file>", "the agent's key, which signs receipts", "agent-key.json").option("--enforce", "block calls outside the mandate (default: observe and record only)", false).option("--receipts <file>", "receipt log (append-only, hash-chained)").option("--revocations <file>", "revocation list to honour (default ~/.saktum/revocations.json)").option("--approvals <file>", "signed approvals to honour (default ~/.saktum/approvals.json)").option("--credential <file>", "the agent's credential: its accountability chain is verified on every call").option("--revoked-credentials <file>", "JSON list of revoked credential ids").option("--agreement <file>", "the signed agreement with the provider: calls outside it are refused and every call is metered").option("--wallet <file>", "prepaid token wallet charged per call under the agreement").option("--approval-webhook <url>", "post approval requests to this webhook (Slack, Teams or an email relay)").option("--approval-url <url>", "base link of saktum approvals serve, included in approval requests").option("--bindings <file>", "bindings override: JSON { tool: { action, bindings: { arg: field } } } for tools that declare nothing").option("--revocations-url <url>", "a remote revocation list (for example in the ledger) the agent cannot edit").option("--digest-key <spec>", "keyed digests of arguments in receipts: env:VAR (recommended)").option("--pin <fingerprint>", "refuse calls if the server's tools differ from this approved fingerprint (sha256:...)").option("--checkpoint-every <n>", "write a signed checkpoint every n receipts").option("--checkpoint-file <file>", "where checkpoints go (keep it off the agent's machine or ship it)").option("--approval-secret <spec>", "secret shared with approvals serve for single-use, per-request links: env:VAR").action(async (parts, o) => {
40728
+ program2.command("proxy").description("Put Saktum between an agent and a local MCP server: signed receipts for every tool call, and the agent's mandate observed or enforced (preview)").argument("<command...>", "the server command, after --").option("--mandate <file>", "the agent's mandate (from saktum agent create)").option("--agent-key <file>", "the agent's key, which signs receipts", "agent-key.json").option("--enforce", "block calls outside the mandate (default: observe and record only)", false).option("--receipts <file>", "receipt log (append-only, hash-chained)").option("--revocations <file>", "revocation list to honour (default ~/.saktum/revocations.json)").option("--approvals <file>", "signed approvals to honour (default ~/.saktum/approvals.json)").option("--credential <file>", "the agent's credential: its accountability chain is verified on every call").option("--revoked-credentials <file>", "JSON list of revoked credential ids").option("--agreement <file>", "the signed agreement with the provider: calls outside it are refused and every call is metered").option("--wallet <file>", "prepaid token wallet charged per call under the agreement").option("--approval-webhook <url>", "post approval requests to this webhook (Slack, Teams or an email relay)").option("--approval-url <url>", "base link of saktum approvals serve, included in approval requests").option("--bindings <file>", "bindings override: JSON { tool: { action, bindings: { arg: field } } } for tools that declare nothing").option("--revocations-url <url>", "a remote revocation list (for example in the ledger) the agent cannot edit").option("--digest-key <spec>", "keyed digests of arguments in receipts: env:VAR (recommended)").option("--pin <fingerprint>", "refuse calls if the server's tools differ from this approved fingerprint (sha256:...)").option("--checkpoint-every <n>", "write a signed checkpoint every n receipts").option("--checkpoint-file <file>", "where checkpoints go (keep it off the agent's machine or ship it)").option("--approval-secret <spec>", "secret shared with approvals serve for single-use, per-request links: env:VAR").option("--quarantine-results", "withhold tool results that contain instructions aimed at the agent or secrets (default: flag them in receipts)", false).action(async (parts, o) => {
40612
40729
  const { homedir: homedir2 } = await import("node:os");
40613
40730
  const { join: join7 } = await import("node:path");
40614
40731
  let mandate;
@@ -40643,6 +40760,7 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
40643
40760
  ...o.pin ? { pin: o.pin } : {},
40644
40761
  ...o.checkpointEvery && o.checkpointFile ? { checkpointEvery: Number(o.checkpointEvery), checkpointFile: o.checkpointFile } : {},
40645
40762
  ...o.approvalSecret ? { approvalSecret: secretFrom(o.approvalSecret) } : {},
40763
+ ...o.quarantineResults ? { quarantineResults: true } : {},
40646
40764
  log: (m) => process.stderr.write(`saktum: ${m}
40647
40765
  `)
40648
40766
  });
@@ -40852,11 +40970,13 @@ To declare them, add to each tool's definition (MCP tools accept _meta):
40852
40970
  `);
40853
40971
  });
40854
40972
  const identity = program2.command("identity").description("Identity chains: organisation -> people -> agents");
40855
- identity.command("issue").description("Issue a credential to a person or an agent, from your own credential").requiredOption("--from <credential>", "your credential (the organisation's, or one it issued to you)").requiredOption("--key <path>", "your signing key").requiredOption("--type <type>", "member or agent").requiredOption("--name <name>", "the subject's name").option("--subject-key <path>", "the subject's key file (its id is used)").option("--subject <did>", "the subject's did:key").option("--role <role>", "role, for a member").option("--expires <date>", "YYYY-MM-DD", new Date(Date.now() + 180 * 864e5).toISOString().slice(0, 10)).option("--out <file>", "credential file", "credential.json").action((o) => {
40973
+ identity.command("issue").description("Issue a credential to a person or an agent, from your own credential").requiredOption("--from <credential>", "your credential (the organisation's, or one it issued to you)").requiredOption("--key <path>", "your signing key").requiredOption("--type <type>", "member or agent").requiredOption("--name <name>", "the subject's name").option("--subject-key <path>", "the subject's key file (its id is used)").option("--subject <did>", "the subject's did:key").option("--role <role>", "role, for a member").option("--expires <date>", "YYYY-MM-DD", new Date(Date.now() + 180 * 864e5).toISOString().slice(0, 10)).option("--out <file>", "credential file", "credential.json").option("--minutes <n>", "short-lived: expire this many minutes from now (overrides --expires)").option("--tools <list>", "comma-separated tools this credential covers (can only narrow down the chain)").option("--max-depth <n>", "how many credentials may follow this one in a chain (0 = no further delegation)").action((o) => {
40974
+ if (o.minutes)
40975
+ o.expires = new Date(Date.now() + Number(o.minutes) * 6e4).toISOString();
40856
40976
  const subject = o.subject ?? (o.subjectKey ? loadOrCreateKey(o.subjectKey).kid : void 0);
40857
40977
  if (!subject)
40858
40978
  throw new Error("Give --subject <did:key> or --subject-key <file>.");
40859
- const c = issueCredential(JSON.parse(readFileSync10(o.from, "utf8")), loadOrCreateKey(o.key), { type: o.type, id: subject, name: o.name, role: o.role, expires: o.expires });
40979
+ const c = issueCredential(JSON.parse(readFileSync10(o.from, "utf8")), loadOrCreateKey(o.key), { type: o.type, id: subject, name: o.name, role: o.role, expires: o.expires, ...o.tools ? { tools: o.tools.split(",").map((t) => t.trim()).filter(Boolean) } : {}, ...o.maxDepth !== void 0 ? { maxDepth: Number(o.maxDepth) } : {} });
40860
40980
  writeFileSync5(o.out, JSON.stringify(c, null, 2) + "\n");
40861
40981
  process.stdout.write(`Issued ${c.id} to ${sanitizeText(o.name, 80)} (${o.type}). Chain: ${verifyChain(c).path.join(" -> ")}
40862
40982
  `);
@@ -41229,11 +41349,11 @@ ${published ? published === mine ? "\u2713 Matches the published release.\n" : "
41229
41349
  npm provenance: npm audit signatures
41230
41350
  `);
41231
41351
  });
41232
- program2.command("demo").description("See permissions, autonomy, risk and receipts in 60 seconds: one shopping agent under three mandates").option("--out <dir>", "folder for the demo's mandates, receipts and passports", "saktum-demo").option("--story <name>", "grocery, travel, finance, coding, marketplace, autonomy, or all (grocery, travel, finance, coding and marketplace)", "all").action(async (o) => {
41352
+ program2.command("demo").description("See permissions, autonomy, risk and receipts in 60 seconds: one shopping agent under three mandates").option("--out <dir>", "folder for the demo's mandates, receipts and passports", "saktum-demo").option("--story <name>", "grocery, travel, finance, coding, support, marketplace, autonomy, or all (grocery, travel, finance, coding, support and marketplace)", "all").action(async (o) => {
41233
41353
  const { runDemo: runDemo2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
41234
41354
  await runDemo2(o.out, (l) => process.stdout.write(l + "\n"), o.story);
41235
41355
  });
41236
- program2.command("demo-server", { hidden: true }).description("The demo MCP servers (used by saktum demo)").option("--story <name>", "grocery, travel, finance, coding or autonomy", "autonomy").action(async (o) => {
41356
+ program2.command("demo-server", { hidden: true }).description("The demo MCP servers (used by saktum demo)").option("--story <name>", "grocery, travel, finance, coding, support or autonomy", "autonomy").action(async (o) => {
41237
41357
  const { startDemoServer: startDemoServer2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
41238
41358
  await startDemoServer2(o.story);
41239
41359
  });