saktum 0.8.1 → 0.10.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.
- package/README.md +26 -1
- package/package.json +1 -1
- package/saktum.mjs +561 -115
package/saktum.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Saktum Check 0.
|
|
2
|
+
// Saktum Check 0.10.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;
|
|
@@ -10417,6 +10417,7 @@ var require_dist = __commonJS({
|
|
|
10417
10417
|
});
|
|
10418
10418
|
|
|
10419
10419
|
// packages/sign/dist/index.js
|
|
10420
|
+
import { execFileSync } from "node:child_process";
|
|
10420
10421
|
import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, sign, verify } from "node:crypto";
|
|
10421
10422
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
10422
10423
|
import { dirname, join } from "node:path";
|
|
@@ -10483,7 +10484,55 @@ function generateSigningKey() {
|
|
|
10483
10484
|
const { privateKey, publicKey } = generateKeyPairSync("ed25519");
|
|
10484
10485
|
return { privateKey, publicKey, kid: didKeyFromPublicKey(publicKey) };
|
|
10485
10486
|
}
|
|
10487
|
+
function keyFromJwk(jwkText) {
|
|
10488
|
+
const privateKey = createPrivateKey({ key: JSON.parse(jwkText), format: "jwk" });
|
|
10489
|
+
const publicKey = createPublicKey(privateKey);
|
|
10490
|
+
return { privateKey, publicKey, kid: didKeyFromPublicKey(publicKey) };
|
|
10491
|
+
}
|
|
10492
|
+
function keychain(name) {
|
|
10493
|
+
if (!/^[A-Za-z0-9._-]{1,64}$/.test(name))
|
|
10494
|
+
throw new Error("Keychain names may use letters, digits, dot, dash and underscore.");
|
|
10495
|
+
const run = (cmd, args, input, env) => execFileSync(cmd, args, { encoding: "utf8", input, env: { ...process.env, ...env ?? {} }, stdio: ["pipe", "pipe", "ignore"] }).trim();
|
|
10496
|
+
const fresh = () => {
|
|
10497
|
+
const k = generateSigningKey();
|
|
10498
|
+
return { k, jwk: JSON.stringify(k.privateKey.export({ format: "jwk" })) };
|
|
10499
|
+
};
|
|
10500
|
+
if (process.platform === "darwin") {
|
|
10501
|
+
try {
|
|
10502
|
+
return keyFromJwk(run("security", ["find-generic-password", "-s", "saktum", "-a", name, "-w"]));
|
|
10503
|
+
} catch {
|
|
10504
|
+
const { k, jwk } = fresh();
|
|
10505
|
+
run("security", ["add-generic-password", "-s", "saktum", "-a", name, "-w", jwk, "-U"]);
|
|
10506
|
+
return k;
|
|
10507
|
+
}
|
|
10508
|
+
}
|
|
10509
|
+
if (process.platform === "win32") {
|
|
10510
|
+
const file = join(homedir(), ".saktum", "keys", `${name}.dpapi`);
|
|
10511
|
+
const ps = (script, env) => run("powershell", ["-NoProfile", "-NonInteractive", "-Command", "Add-Type -AssemblyName System.Security; " + script], void 0, env);
|
|
10512
|
+
if (existsSync(file))
|
|
10513
|
+
return keyFromJwk(ps("[Text.Encoding]::UTF8.GetString([Security.Cryptography.ProtectedData]::Unprotect([Convert]::FromBase64String((Get-Content -Raw $env:SAKTUM_F)), $null, 'CurrentUser'))", { SAKTUM_F: file }));
|
|
10514
|
+
const { k, jwk } = fresh();
|
|
10515
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
10516
|
+
writeFileSync(file, ps("[Convert]::ToBase64String([Security.Cryptography.ProtectedData]::Protect([Text.Encoding]::UTF8.GetBytes($env:SAKTUM_J), $null, 'CurrentUser'))", { SAKTUM_J: jwk }), { mode: 384 });
|
|
10517
|
+
return k;
|
|
10518
|
+
}
|
|
10519
|
+
try {
|
|
10520
|
+
return keyFromJwk(run("secret-tool", ["lookup", "service", "saktum", "account", name]));
|
|
10521
|
+
} catch {
|
|
10522
|
+
const { k, jwk } = fresh();
|
|
10523
|
+
run("secret-tool", ["store", "--label", `Saktum key ${name}`, "service", "saktum", "account", name], jwk);
|
|
10524
|
+
return k;
|
|
10525
|
+
}
|
|
10526
|
+
}
|
|
10486
10527
|
function loadOrCreateKey(path = defaultKeyPath()) {
|
|
10528
|
+
if (path.startsWith("env:")) {
|
|
10529
|
+
const v = process.env[path.slice(4)];
|
|
10530
|
+
if (!v)
|
|
10531
|
+
throw new Error(`Environment variable ${path.slice(4)} is not set.`);
|
|
10532
|
+
return keyFromJwk(v);
|
|
10533
|
+
}
|
|
10534
|
+
if (path.startsWith("keychain:"))
|
|
10535
|
+
return keychain(path.slice(9));
|
|
10487
10536
|
if (existsSync(path)) {
|
|
10488
10537
|
const jwk = JSON.parse(readFileSync(path, "utf8"));
|
|
10489
10538
|
const privateKey = createPrivateKey({ key: jwk, format: "jwk" });
|
|
@@ -19435,6 +19484,7 @@ var init_embedded = __esm({
|
|
|
19435
19484
|
"change",
|
|
19436
19485
|
"cancel",
|
|
19437
19486
|
"communicate",
|
|
19487
|
+
"deploy",
|
|
19438
19488
|
"other"
|
|
19439
19489
|
]
|
|
19440
19490
|
},
|
|
@@ -33996,7 +34046,7 @@ var init_dist3 = __esm({
|
|
|
33996
34046
|
init_stdio2();
|
|
33997
34047
|
init_streamableHttp();
|
|
33998
34048
|
init_types2();
|
|
33999
|
-
USER_AGENT = "saktum-check/0.
|
|
34049
|
+
USER_AGENT = "saktum-check/0.10.0 (+https://saktum.dev/check)";
|
|
34000
34050
|
LIMITS = { requestTimeoutMs: 1e4, connectTimeoutMs: 6e4, maxResponseChars: 5e6 };
|
|
34001
34051
|
LimitError = class extends Error {
|
|
34002
34052
|
};
|
|
@@ -34034,7 +34084,7 @@ var init_dist3 = __esm({
|
|
|
34034
34084
|
jsonrpc: "2.0",
|
|
34035
34085
|
id: 1,
|
|
34036
34086
|
method: "initialize",
|
|
34037
|
-
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.
|
|
34087
|
+
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.10.0" } }
|
|
34038
34088
|
});
|
|
34039
34089
|
}
|
|
34040
34090
|
});
|
|
@@ -35406,7 +35456,7 @@ var init_engine = __esm({
|
|
|
35406
35456
|
init_runner();
|
|
35407
35457
|
init_safe();
|
|
35408
35458
|
init_scoring();
|
|
35409
|
-
ENGINE_VERSION = "0.
|
|
35459
|
+
ENGINE_VERSION = "0.10.0";
|
|
35410
35460
|
UNKNOWN_TOOL = "saktum_trust_check_no_such_tool";
|
|
35411
35461
|
INVALID_TOKEN = "saktum-check-deliberately-invalid-token";
|
|
35412
35462
|
baseOf = (pack, check) => ({
|
|
@@ -35998,6 +36048,10 @@ var init_vocab = __esm({
|
|
|
35998
36048
|
{ path: "enterprise.data_class", type: "string", description: "Classification of the data: public, internal, confidential or restricted" },
|
|
35999
36049
|
{ path: "enterprise.vendor", type: "string", description: "The supplier or vendor" }
|
|
36000
36050
|
] };
|
|
36051
|
+
VOCABULARIES.code = { version: "0.1", fields: [
|
|
36052
|
+
{ path: "code.repository", type: "string", description: "The code repository" },
|
|
36053
|
+
{ path: "code.environment", type: "string", description: "The deployment environment (for example staging, production)" }
|
|
36054
|
+
] };
|
|
36001
36055
|
KNOWN_FIELDS = new Set(Object.values(VOCABULARIES).flatMap((v) => v.fields.map((f) => f.path)));
|
|
36002
36056
|
NAME_RULES = [
|
|
36003
36057
|
[/(^|[_-])(search|find|list|get|lookup|deals|browse)([_-]|$)/i, "search"],
|
|
@@ -36007,6 +36061,7 @@ var init_vocab = __esm({
|
|
|
36007
36061
|
[/(^|[_-])(book|reserve|hold)([_-]|$)/i, "book"],
|
|
36008
36062
|
[/(^|[_-])(change|modify|update|seat|upgrade)([_-]|$)/i, "change"],
|
|
36009
36063
|
[/(^|[_-])(cancel|refund|void)([_-]|$)/i, "cancel"],
|
|
36064
|
+
[/(^|[_-])(deploy|release|publish)([_-]|$)/i, "deploy"],
|
|
36010
36065
|
[/(^|[_-])(send|email|message|notify|post)([_-]|$)/i, "communicate"]
|
|
36011
36066
|
];
|
|
36012
36067
|
ARG_RULES = [
|
|
@@ -36387,6 +36442,17 @@ function trustStatement(entries, verified) {
|
|
|
36387
36442
|
function approvalRequestId(m, tool, args) {
|
|
36388
36443
|
return "apr_" + argumentsHash({ mandate: mandateDigest(m), tool, args: argumentsHash(args) }).replace(/^sha256:/, "").slice(0, 16);
|
|
36389
36444
|
}
|
|
36445
|
+
function recordPending(path, req) {
|
|
36446
|
+
const a = readApprovals(path);
|
|
36447
|
+
a.pending = (a.pending ?? []).filter((p) => p.id !== req.id);
|
|
36448
|
+
a.pending.push({ ...req, at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
36449
|
+
_mkdir(_dirname(path), { recursive: true });
|
|
36450
|
+
_write(path, JSON.stringify(a, null, 2) + "\n");
|
|
36451
|
+
}
|
|
36452
|
+
function listPending(path = DEFAULT_APPROVALS()) {
|
|
36453
|
+
const a = readApprovals(path);
|
|
36454
|
+
return (a.pending ?? []).filter((p) => !a.used.includes(p.id) && !a.approvals.some((x) => x.approval === p.id));
|
|
36455
|
+
}
|
|
36390
36456
|
function approveAction(m, requestId, ownerKey, minutes = 60, path = DEFAULT_APPROVALS()) {
|
|
36391
36457
|
if (ownerKey.kid !== m.owner.id)
|
|
36392
36458
|
throw new Error("Only the mandate's owner can approve its actions.");
|
|
@@ -36850,6 +36916,129 @@ var init_market = __esm({
|
|
|
36850
36916
|
}
|
|
36851
36917
|
});
|
|
36852
36918
|
|
|
36919
|
+
// packages/testkit-core/dist/crosswalk.js
|
|
36920
|
+
function crosswalk(id = "all") {
|
|
36921
|
+
return id === "all" ? FRAMEWORKS : FRAMEWORKS.filter((f) => f.id === id);
|
|
36922
|
+
}
|
|
36923
|
+
function coverageSummary(f) {
|
|
36924
|
+
const n = (c) => f.items.filter((i) => i.coverage === c).length;
|
|
36925
|
+
return { covered: n("covered"), partial: n("partial"), gap: n("gap"), total: f.items.length };
|
|
36926
|
+
}
|
|
36927
|
+
var I, FRAMEWORKS, DISCLAIMER;
|
|
36928
|
+
var init_crosswalk = __esm({
|
|
36929
|
+
"packages/testkit-core/dist/crosswalk.js"() {
|
|
36930
|
+
"use strict";
|
|
36931
|
+
I = (ref, obligation, coverage, evidence, commands) => ({ ref, obligation, coverage, evidence, commands });
|
|
36932
|
+
FRAMEWORKS = [
|
|
36933
|
+
{ id: "eu-ai-act", name: "EU AI Act", note: "Most obligations apply to high-risk AI systems; whether a system is high-risk is the organisation's assessment.", items: [
|
|
36934
|
+
I("Art. 9", "Risk management", "partial", "Risk tiers R0\u2013R4 for servers and agents, policy ceilings, the executive assessment", ["saktum check", "saktum assess"]),
|
|
36935
|
+
I("Art. 12", "Record-keeping (automatic logging)", "covered", "Signed, hash-chained receipts of every agent tool call, with the decision and its reason", ["saktum proxy", "saktum receipts verify"]),
|
|
36936
|
+
I("Art. 13", "Transparency and information to deployers", "partial", "Passports, manifests and plain-language mandates", ["saktum passport", "saktum manifest create"]),
|
|
36937
|
+
I("Art. 14", "Human oversight", "covered", "Autonomy levels, signed approvals of exact actions, revocation (the stop button)", ["saktum agent approve", "saktum agent revoke"]),
|
|
36938
|
+
I("Art. 15", "Accuracy, robustness and cybersecurity", "partial", "Conformance and security checks of tools; containment of manipulated agents by mandates (not model accuracy)", ["saktum check", "saktum demo"]),
|
|
36939
|
+
I("Art. 26", "Obligations of deployers (monitoring, logs)", "covered", "Monitoring of approved tools, receipts retained by the deployer, OpenTelemetry export", ["saktum watch", "saktum receipts export --otel"]),
|
|
36940
|
+
I("Art. 50", "Transparency for certain AI systems", "gap", "Not in scope: disclosure to people interacting with AI is the deployer's interface", [])
|
|
36941
|
+
] },
|
|
36942
|
+
{ id: "nist-ai-rmf", name: "NIST AI RMF 1.0", note: "Voluntary framework; functions Govern, Map, Measure, Manage.", items: [
|
|
36943
|
+
I("GOVERN", "Policies, accountability, third-party risk", "covered", "Policy as code with exceptions; identity chains to accountable people and organisations; operator countersignatures", ["saktum fleet --policy", "saktum identity verify"]),
|
|
36944
|
+
I("MAP", "Context, inventory and risk categorisation", "partial", "Inventory of MCP servers across machines, capability profiles, risk tiers (agent inventory planned)", ["saktum scan-config", "saktum fleet"]),
|
|
36945
|
+
I("MEASURE", "Testing, evaluation and monitoring", "partial", "Conformance, security, functional and readiness checks; track records from receipts (no model evaluation)", ["saktum check", "saktum kpi"]),
|
|
36946
|
+
I("MANAGE", "Risk treatment, response and recovery", "covered", "Mandates, approvals, allowlists, monitoring alerts, revocation", ["saktum allowlist", "saktum watch", "saktum agent revoke"])
|
|
36947
|
+
] },
|
|
36948
|
+
{ id: "iso-42001", name: "ISO/IEC 42001", note: "AI management system standard; certification is by accredited bodies.", items: [
|
|
36949
|
+
I("6.1", "Actions to address risks and opportunities", "partial", "Risk tiers, policy, assessment with recommendations", ["saktum assess"]),
|
|
36950
|
+
I("8", "Operation: planning and control", "covered", "Mandates and agreements enforced before every call", ["saktum proxy --enforce"]),
|
|
36951
|
+
I("9.1", "Monitoring, measurement, analysis and evaluation", "covered", "Receipts, KPIs, usage statements, monitoring", ["saktum kpi", "saktum usage", "saktum watch"]),
|
|
36952
|
+
I("9.2", "Internal audit", "partial", "Independently verifiable ledger, receipts and passports for auditors", ["saktum ledger verify", "saktum receipts verify"]),
|
|
36953
|
+
I("A.10", "Third-party and customer relationships", "covered", "Passports, manifests, signed agreements, Verifiable Credentials", ["saktum attest --vc", "saktum agreement verify"])
|
|
36954
|
+
] },
|
|
36955
|
+
{ 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: [
|
|
36956
|
+
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"]),
|
|
36957
|
+
I("LLM02", "Sensitive information disclosure", "partial", "Personal and classified data enforced per recipient; secrets never printed; argument digests only", ["saktum proxy --enforce"]),
|
|
36958
|
+
I("LLM03", "Supply chain", "covered", "Provenance and install-script checks, maturity levels, SBOMs, the census", ["saktum check", "saktum passport"]),
|
|
36959
|
+
I("LLM06", "Excessive agency", "covered", "Least-privilege mandates, autonomy levels, approvals, revocation", ["saktum agent create --intent", "saktum agent approve"]),
|
|
36960
|
+
I("LLM10", "Unbounded consumption", "covered", "Daily limits, prepaid token metering, context-cost and ROI analysis", ["saktum proxy --wallet", "saktum roi"])
|
|
36961
|
+
] },
|
|
36962
|
+
{ id: "dora-nis2", name: "DORA and NIS2", note: "EU financial-sector (DORA) and critical-sector (NIS2) resilience rules.", items: [
|
|
36963
|
+
I("DORA Art. 28", "ICT third-party risk and the register of information", "partial", "Inventory of AI tools, passports, agreements, monitoring of third-party servers", ["saktum fleet", "saktum watch"]),
|
|
36964
|
+
I("NIS2 Art. 21", "Risk-management measures incl. supply-chain security", "partial", "Supply-chain checks, allowlists pinned to tool fingerprints, incident evidence", ["saktum allowlist", "saktum check"])
|
|
36965
|
+
] },
|
|
36966
|
+
{ id: "gdpr-dpdp", name: "GDPR and India's DPDP Act", note: "Data protection; lawful basis and notices are the controller's responsibility.", items: [
|
|
36967
|
+
I("GDPR Art. 5(1)(b)", "Purpose limitation", "partial", "Mandates state the purpose; personal data goes only to permitted recipients", ["saktum agent create --intent"]),
|
|
36968
|
+
I("GDPR Art. 30", "Records of processing", "partial", "Receipts record which personal-data fields went to whom (digests, not values)", ["saktum receipts summary"]),
|
|
36969
|
+
I("GDPR Art. 32 / DPDP", "Security of processing; reasonable safeguards", "partial", "Enforcement before each call, signed evidence, revocation", ["saktum proxy --enforce"])
|
|
36970
|
+
] }
|
|
36971
|
+
];
|
|
36972
|
+
DISCLAIMER = "Saktum supports evidence for these obligations; it does not establish compliance, which depends on your own assessment and advisers.";
|
|
36973
|
+
}
|
|
36974
|
+
});
|
|
36975
|
+
|
|
36976
|
+
// packages/testkit-core/dist/agents.js
|
|
36977
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync6, statSync as statSync2 } from "node:fs";
|
|
36978
|
+
import { join as join4 } from "node:path";
|
|
36979
|
+
function scanAgents(dirs, o = {}) {
|
|
36980
|
+
const found = [];
|
|
36981
|
+
const walk = (dir, depth) => {
|
|
36982
|
+
let names = [];
|
|
36983
|
+
try {
|
|
36984
|
+
names = readdirSync3(dir);
|
|
36985
|
+
} catch {
|
|
36986
|
+
return;
|
|
36987
|
+
}
|
|
36988
|
+
for (const n of names) {
|
|
36989
|
+
if (n === "node_modules" || n.startsWith(".git"))
|
|
36990
|
+
continue;
|
|
36991
|
+
const p = join4(dir, n);
|
|
36992
|
+
let st;
|
|
36993
|
+
try {
|
|
36994
|
+
st = statSync2(p);
|
|
36995
|
+
} catch {
|
|
36996
|
+
continue;
|
|
36997
|
+
}
|
|
36998
|
+
if (st.isDirectory()) {
|
|
36999
|
+
if (depth > 0)
|
|
37000
|
+
walk(p, depth - 1);
|
|
37001
|
+
continue;
|
|
37002
|
+
}
|
|
37003
|
+
if (!n.endsWith(".json") || st.size > 1e6)
|
|
37004
|
+
continue;
|
|
37005
|
+
let m;
|
|
37006
|
+
try {
|
|
37007
|
+
m = JSON.parse(readFileSync6(p, "utf8"));
|
|
37008
|
+
} catch {
|
|
37009
|
+
continue;
|
|
37010
|
+
}
|
|
37011
|
+
if (!m || typeof m !== "object" || !("mandateFormat" in m) || !m.agent?.id)
|
|
37012
|
+
continue;
|
|
37013
|
+
const op = checkOperator(m);
|
|
37014
|
+
found.push({
|
|
37015
|
+
name: m.agent.name,
|
|
37016
|
+
id: m.agent.id,
|
|
37017
|
+
owner: m.owner?.name ?? m.owner?.id ?? "",
|
|
37018
|
+
operator: op.present ? op.valid ? op.name ?? "" : "invalid countersignature" : "",
|
|
37019
|
+
purpose: m.purpose ?? "",
|
|
37020
|
+
autonomy: m.autonomy ?? "act",
|
|
37021
|
+
tools: m.allow?.tools?.length ?? 0,
|
|
37022
|
+
riskTier: agentRiskTier(m).tier,
|
|
37023
|
+
maturity: agentMaturity(m).label,
|
|
37024
|
+
expires: m.expires,
|
|
37025
|
+
valid: checkMandate(m).ok,
|
|
37026
|
+
revoked: Boolean(revocationOf(m, o.revocationsPath)),
|
|
37027
|
+
file: p
|
|
37028
|
+
});
|
|
37029
|
+
}
|
|
37030
|
+
};
|
|
37031
|
+
for (const d of dirs)
|
|
37032
|
+
walk(d, o.depth ?? 3);
|
|
37033
|
+
return found;
|
|
37034
|
+
}
|
|
37035
|
+
var init_agents = __esm({
|
|
37036
|
+
"packages/testkit-core/dist/agents.js"() {
|
|
37037
|
+
"use strict";
|
|
37038
|
+
init_agentid();
|
|
37039
|
+
}
|
|
37040
|
+
});
|
|
37041
|
+
|
|
36853
37042
|
// packages/testkit-core/dist/index.js
|
|
36854
37043
|
var dist_exports = {};
|
|
36855
37044
|
__export(dist_exports, {
|
|
@@ -36861,9 +37050,11 @@ __export(dist_exports, {
|
|
|
36861
37050
|
DEFAULT_LEDGER_URL: () => DEFAULT_LEDGER_URL,
|
|
36862
37051
|
DEFAULT_REVOCATIONS: () => DEFAULT_REVOCATIONS,
|
|
36863
37052
|
DEFAULT_TERMS: () => DEFAULT_TERMS,
|
|
37053
|
+
DISCLAIMER: () => DISCLAIMER,
|
|
36864
37054
|
EMBEDDED_CONTRACTS: () => EMBEDDED_CONTRACTS,
|
|
36865
37055
|
EMBEDDED_PACKS: () => EMBEDDED_PACKS,
|
|
36866
37056
|
ENGINE_VERSION: () => ENGINE_VERSION,
|
|
37057
|
+
FRAMEWORKS: () => FRAMEWORKS,
|
|
36867
37058
|
FUNCTIONAL_LIMITS: () => FUNCTIONAL_LIMITS,
|
|
36868
37059
|
GENESIS: () => GENESIS,
|
|
36869
37060
|
INVISIBLE: () => INVISIBLE,
|
|
@@ -36923,7 +37114,9 @@ __export(dist_exports, {
|
|
|
36923
37114
|
contractText: () => contractText,
|
|
36924
37115
|
contractsDir: () => contractsDir,
|
|
36925
37116
|
cosignMandate: () => cosignMandate,
|
|
37117
|
+
coverageSummary: () => coverageSummary,
|
|
36926
37118
|
createMandate: () => createMandate,
|
|
37119
|
+
crosswalk: () => crosswalk,
|
|
36927
37120
|
decideCall: () => decideCall,
|
|
36928
37121
|
decideIntent: () => decideIntent,
|
|
36929
37122
|
describeMandate: () => describeMandate,
|
|
@@ -36947,6 +37140,7 @@ __export(dist_exports, {
|
|
|
36947
37140
|
lintPaths: () => lintPaths,
|
|
36948
37141
|
lintSarif: () => lintSarif,
|
|
36949
37142
|
lintSource: () => lintSource,
|
|
37143
|
+
listPending: () => listPending,
|
|
36950
37144
|
loadEmbeddedPacks: () => loadEmbeddedPacks,
|
|
36951
37145
|
loadPack: () => loadPack,
|
|
36952
37146
|
loadPackDir: () => loadPackDir,
|
|
@@ -36968,6 +37162,7 @@ __export(dist_exports, {
|
|
|
36968
37162
|
perfAnalysers: () => perfAnalysers,
|
|
36969
37163
|
readinessFor: () => readinessFor,
|
|
36970
37164
|
receiptsToOtlp: () => receiptsToOtlp,
|
|
37165
|
+
recordPending: () => recordPending,
|
|
36971
37166
|
redactCommand: () => redactCommand,
|
|
36972
37167
|
redactUrl: () => redactUrl,
|
|
36973
37168
|
renderFix: () => renderFix,
|
|
@@ -36984,6 +37179,7 @@ __export(dist_exports, {
|
|
|
36984
37179
|
runTestCases: () => runTestCases,
|
|
36985
37180
|
runTrustCheck: () => runTrustCheck,
|
|
36986
37181
|
sanitizeText: () => sanitizeText,
|
|
37182
|
+
scanAgents: () => scanAgents,
|
|
36987
37183
|
schemaDialect: () => schemaDialect,
|
|
36988
37184
|
score: () => score,
|
|
36989
37185
|
searchCatalogue: () => searchCatalogue,
|
|
@@ -37046,6 +37242,8 @@ var init_dist4 = __esm({
|
|
|
37046
37242
|
init_risk();
|
|
37047
37243
|
init_vocab();
|
|
37048
37244
|
init_market();
|
|
37245
|
+
init_crosswalk();
|
|
37246
|
+
init_agents();
|
|
37049
37247
|
}
|
|
37050
37248
|
});
|
|
37051
37249
|
|
|
@@ -37070,12 +37268,12 @@ function renderServerPassport(r, tools, o = {}) {
|
|
|
37070
37268
|
}).join("");
|
|
37071
37269
|
const body2 = `<div class="card"><div class="top"><div class="seal" style="background:${GRADE_COLOUR[g] ?? "#757575"}">${esc2(g)}</div>
|
|
37072
37270
|
<div><small>MCP SERVER PASSPORT</small><h1>${esc2(name)} ${esc2(version2)}</h1><div class="muted">${esc2(r.target.transport)} \xB7 protocol ${esc2(r.target.protocolVersion ?? "unknown")} \xB7 ${esc2(String(r.target.toolCount ?? tools.length))} tools</div></div></div>
|
|
37073
|
-
<div class="chips">${chip("Trust", r.grade, GRADE_COLOUR[g])}${chip("Agent readiness", r.readiness?.grade, GRADE_COLOUR[r.readiness?.grade ?? ""])}${chip("Context", `${(r.readiness?.contextTokens ?? 0).toLocaleString("en-US")} tokens/turn`)}${r.riskTier ? chip("Risk", `${r.riskTier.tier} \xB7 ${r.riskTier.label}`, r.riskTier.tier >= "R3" ? "#b7791f" : void 0) : ""}${chip("Assurance", r.assuranceLevel ?? "L1")}${o.ledgerEntry ? chip("Ledger entry", `#${o.ledgerEntry}`) : ""}</div></div>
|
|
37271
|
+
<div class="chips">${chip("Trust", r.grade, GRADE_COLOUR[g])}${chip("Agent readiness", r.readiness?.grade, GRADE_COLOUR[r.readiness?.grade ?? ""])}${chip("Context", `${(r.readiness?.contextTokens ?? 0).toLocaleString("en-US")} tokens/turn`)}${r.riskTier ? chip("Risk", `${r.riskTier.tier} \xB7 ${r.riskTier.label}`, r.riskTier.tier >= "R3" ? "#b7791f" : void 0) : ""}${chip("Assurance", { L1: "self-tested", L2: "independently checked", L3: "certified", L4: "continuously certified" }[r.assuranceLevel ?? "L1"] ?? "self-tested")}${o.ledgerEntry ? chip("Ledger entry", `#${o.ledgerEntry}`) : ""}</div></div>
|
|
37074
37272
|
<div class="card"><h2>Maturity</h2>${levelBar(lvl, lvl === 4 ? "L5 also needs supply-chain evidence (provenance, no install scripts)" : void 0)}</div>
|
|
37075
37273
|
${r.riskTier ? `<div class="card"><h2>Risk tier</h2><p><b>${esc2(r.riskTier.tier)}: ${esc2(r.riskTier.label)}.</b> ${esc2(r.riskTier.reasons.join("; "))}.</p><p class="muted">Proportionate requirement: ${esc2(r.riskTier.requirement)}.</p></div>` : ""}
|
|
37076
37274
|
<div class="card"><h2>What it can do</h2>${caps.length ? `<div class="chips">${caps.map((c) => chip(c.basis, c.label)).join("")}</div>` : `<p class="muted">No notable capabilities inferred.</p>`}${r.capabilities?.lethalTrifecta ? `<p><b>Note:</b> combines private data, untrusted content and an outbound channel.</p>` : ""}</div>
|
|
37077
37275
|
<div class="card"><h2>Interface</h2>${tools.length ? `<div class="wrap"><table><tr><th>Tool</th><th>Effect</th><th>Output schema</th><th>Required inputs</th></tr>${rows}</table></div>${tools.length > 60 ? `<p class="muted">First 60 of ${tools.length} tools.</p>` : ""}` : `<p class="muted">Tool list not included.</p>`}</div>
|
|
37078
|
-
<div class="card"><h2>Verify this passport</h2><p>Generated by Saktum Check ${esc2(r.tool.version)} on ${esc2(r.run.startedAt.slice(0, 10))} from a signed result${r.signature?.kid ? ` (signer <code>${esc2(r.signature.kid)}</code>)` : ""}; tool fingerprint <code>${esc2(r.target.toolsFingerprint ?? "-")}</code>. Check it yourself: <code>npx saktum verify saktum-report.json</code>${o.ledgerEntry ? ` and <code>npx saktum ledger find "${esc2(name)}"</code>` : ""}.</p><p class="muted">Self-tested
|
|
37276
|
+
<div class="card"><h2>Verify this passport</h2><p>Generated by Saktum Check ${esc2(r.tool.version)} on ${esc2(r.run.startedAt.slice(0, 10))} from a signed result${r.signature?.kid ? ` (signer <code>${esc2(r.signature.kid)}</code>)` : ""}; tool fingerprint <code>${esc2(r.target.toolsFingerprint ?? "-")}</code>. Check it yourself: <code>npx saktum verify saktum-report.json</code>${o.ledgerEntry ? ` and <code>npx saktum ledger find "${esc2(name)}"</code>` : ""}.</p><p class="muted">Self-tested unless stated otherwise. A passport describes these exact tools at that time; any tool change needs a new one.</p></div>`;
|
|
37079
37277
|
return page(`${name}: MCP Server Passport`, body2);
|
|
37080
37278
|
}
|
|
37081
37279
|
function renderAgentPassport(m, valid, receipts, tier, plain, extra = {}) {
|
|
@@ -37114,9 +37312,9 @@ function renderLedgerPassport(e) {
|
|
|
37114
37312
|
const c = e.attestation.claims, g = c.trustGrade ?? "-";
|
|
37115
37313
|
const body2 = `<div class="card"><div class="top"><div class="seal" style="background:${GRADE_COLOUR[g] ?? "#757575"}">${esc2(g)}</div><div><small>MCP SERVER PASSPORT \xB7 TRUST LEDGER ENTRY #${e.seq}</small><h1>${esc2(e.subject.server)} ${esc2(e.subject.version ?? "")}</h1>
|
|
37116
37314
|
<div class="muted">${esc2(e.attestation.subject.transport)} \xB7 ${esc2(String(e.attestation.subject.toolCount ?? "?"))} tools \xB7 checked ${esc2(e.attestation.checkedAt.slice(0, 10))} with ${esc2(e.attestation.checkedWith)}</div></div></div>
|
|
37117
|
-
<div class="chips">${chip("Trust", c.trustGrade, GRADE_COLOUR[g])}${chip("Agent readiness", c.readinessGrade, GRADE_COLOUR[c.readinessGrade ?? ""])}${chip("Assurance", c.assuranceLevel)}${chip("Recorded", e.recordedAt.slice(0, 10))}</div></div>
|
|
37315
|
+
<div class="chips">${chip("Trust", c.trustGrade, GRADE_COLOUR[g])}${chip("Agent readiness", c.readinessGrade, GRADE_COLOUR[c.readinessGrade ?? ""])}${chip("Assurance", { L1: "self-tested", L2: "independently checked", L3: "certified", L4: "continuously certified" }[c.assuranceLevel] ?? c.assuranceLevel)}${chip("Recorded", e.recordedAt.slice(0, 10))}</div></div>
|
|
37118
37316
|
<div class="card"><h2>Maturity evidence</h2>${levelBar(evidenceLevel(c.evidence))}</div>
|
|
37119
|
-
<div class="card"><h2>Verify</h2><p>Signed by <code>${esc2(e.signer)}</code>; tools fingerprint <code>${esc2(e.subject.toolsFingerprint ?? "-")}</code>.</p><p><code>npx saktum ledger verify</code> \xB7 <code>npx saktum ledger find "${esc2(e.subject.server)}"</code></p><p class="muted">A signed claim by the server's publisher (
|
|
37317
|
+
<div class="card"><h2>Verify</h2><p>Signed by <code>${esc2(e.signer)}</code>; tools fingerprint <code>${esc2(e.subject.toolsFingerprint ?? "-")}</code>.</p><p><code>npx saktum ledger verify</code> \xB7 <code>npx saktum ledger find "${esc2(e.subject.server)}"</code></p><p class="muted">A signed claim by the server's publisher (${esc2({ L1: "self-tested", L2: "independently checked", L3: "certified", L4: "continuously certified" }[c.assuranceLevel] ?? c.assuranceLevel)}). It describes the tools matching the fingerprint at that time.</p></div>
|
|
37120
37318
|
<p class="muted"><a href="index.html">All passports</a> \xB7 <a href="../index.html">State of MCP Trust</a></p>`;
|
|
37121
37319
|
return page(`${e.subject.server}: MCP Server Passport`, body2);
|
|
37122
37320
|
}
|
|
@@ -37130,7 +37328,7 @@ function renderPassportGallery(entries) {
|
|
|
37130
37328
|
}).join("");
|
|
37131
37329
|
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>`}`);
|
|
37132
37330
|
}
|
|
37133
|
-
function renderAssessment(org, f, receipts = [], roi) {
|
|
37331
|
+
function renderAssessment(org, f, receipts = [], roi, frameworks, disclaimer, agents) {
|
|
37134
37332
|
const risky = /* @__PURE__ */ new Set(["code-execution", "money", "sends-messages", "writes-or-deletes", "reads-private-data"]);
|
|
37135
37333
|
const caps = ["code-execution", "money", "sends-messages", "writes-or-deletes", "reads-private-data", "network", "filesystem", "untrusted-content"];
|
|
37136
37334
|
const grades = ["A", "B", "C", "D", "F", "-"];
|
|
@@ -37158,10 +37356,20 @@ function renderAssessment(org, f, receipts = [], roi) {
|
|
|
37158
37356
|
<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>
|
|
37159
37357
|
${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>` : ""}
|
|
37160
37358
|
${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>` : ""}
|
|
37359
|
+
${agents ? `<div class="card"><h2>Agents</h2>${agents.length ? `<div class="wrap"><table><tr><th>Agent</th><th>Owner</th><th>Operator</th><th>Autonomy</th><th>Risk</th><th>Maturity</th><th>Status</th></tr>${agents.map((a) => `<tr><td>${esc2(a.name)}</td><td>${esc2(a.owner)}</td><td>${esc2(a.operator || "none")}</td><td>${esc2(a.autonomy)}</td><td>${esc2(a.riskTier)}</td><td>${esc2(a.maturity)}</td><td>${a.revoked ? "revoked" : !a.valid ? "invalid or expired" : "active until " + esc2(a.expires)}</td></tr>`).join("")}</table></div>` : `<p>No agent mandates found.</p>`}<p class="muted">From <code>npx saktum agents scan</code>. Agents without an operator countersignature, or with broad autonomy on risky tiers, deserve review first.</p></div>` : ""}
|
|
37360
|
+
${frameworks?.length ? `<div class="card"><h2>Evidence for the frameworks you are held to</h2><div class="wrap"><table><tr><th>Framework</th><th>Covered</th><th>Partly</th><th>Not covered</th></tr>${frameworks.map((x) => `<tr><td>${esc2(x.name)}</td><td>${x.summary.covered}</td><td>${x.summary.partial}</td><td>${x.summary.gap}</td></tr>`).join("")}</table></div><p class="muted">${esc2(disclaimer ?? "")} Details: <code>npx saktum evidence --framework all</code>.</p></div>` : ""}
|
|
37161
37361
|
<div class="card"><h2>Recommendations</h2><ol>${rec.map((x) => `<li>${esc2(x)}</li>`).join("")}</ol></div>
|
|
37162
37362
|
<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>`;
|
|
37163
37363
|
return page(`MCP Trust Assessment: ${org}`, body2);
|
|
37164
37364
|
}
|
|
37365
|
+
function renderReceiptsView(logs) {
|
|
37366
|
+
const all = logs.flatMap((l) => l.entries.map((e) => ({ ...e, log: l.name }))).sort((a, b) => a.at.localeCompare(b.at));
|
|
37367
|
+
const sum = logs.map((l) => `<tr><td>${esc2(l.name)}</td><td>${l.entries.length}</td><td>${l.entries.filter((e) => e.outcome === "allow").length}</td><td>${l.entries.filter((e) => e.outcome === "deny").length}</td><td>${l.entries.reduce((n, e) => n + e.tokens, 0)}</td><td>${l.verified ? "\u2713 verified" : "\u2717 NOT verified"}</td></tr>`).join("");
|
|
37368
|
+
const rows = all.slice(-500).map((e) => `<tr><td><code>${esc2(e.at.slice(0, 19).replace("T", " "))}</code></td><td>${esc2(e.agent)}</td><td>${esc2(e.tool)}</td><td><span class="step ${e.outcome === "deny" ? "deny" : "ok"}">${e.outcome === "deny" ? "\u26D4 " + esc2(e.code) : "\u2713"}</span></td><td>${esc2(e.reason)}</td><td>${e.tokens || ""}</td></tr>`).join("");
|
|
37369
|
+
return page("Saktum receipts: combined view", `<div class="card"><small>RECEIPTS \xB7 COMBINED VIEW</small><h1>${all.length} agent calls across ${logs.length} log(s)</h1><p class="muted">Each log verified independently: every signature and every link of its hash chain.</p>
|
|
37370
|
+
<div class="wrap"><table><tr><th>Log</th><th>Calls</th><th>Allowed</th><th>Blocked</th><th>Tokens</th><th>Integrity</th></tr>${sum}</table></div></div>
|
|
37371
|
+
<div class="card"><h2>Timeline</h2><div class="wrap"><table><tr><th>Time (UTC)</th><th>Agent</th><th>Tool</th><th>Decision</th><th>Reason</th><th>Tokens</th></tr>${rows}</table></div>${all.length > 500 ? `<p class="muted">Latest 500 of ${all.length}.</p>` : ""}</div>`);
|
|
37372
|
+
}
|
|
37165
37373
|
var esc2, GRADE_COLOUR, chip, STYLE, page, levelBar, effect, passportSlug, evidenceLevel;
|
|
37166
37374
|
var init_passport = __esm({
|
|
37167
37375
|
"packages/report/dist/passport.js"() {
|
|
@@ -37352,7 +37560,7 @@ function renderTerminal(r) {
|
|
|
37352
37560
|
}
|
|
37353
37561
|
lines.push("");
|
|
37354
37562
|
lines.push(SELF_SIGNED_NOTE);
|
|
37355
|
-
lines.push(
|
|
37563
|
+
lines.push(DISCLAIMER2);
|
|
37356
37564
|
lines.push("");
|
|
37357
37565
|
lines.push(`Feedback shapes the next release (2 minutes): ${FEEDBACK_URL}`);
|
|
37358
37566
|
return lines.join("\n");
|
|
@@ -37375,7 +37583,7 @@ ${(r.summary ?? []).map((l) => `<p>${e(l)}</p>`).join("")}
|
|
|
37375
37583
|
<h2>Findings</h2><table>${rows}</table>
|
|
37376
37584
|
<h2>Scope of this run</h2>${scopeOfRun(r).map((l) => `<p>${e(l)}</p>`).join("")}
|
|
37377
37585
|
<h2>OWASP MCP Top 10 coverage</h2><table>${cov}</table>
|
|
37378
|
-
<p><small>${e(SELF_SIGNED_NOTE)} ${e(
|
|
37586
|
+
<p><small>${e(SELF_SIGNED_NOTE)} ${e(DISCLAIMER2)}</small></p></body></html>`;
|
|
37379
37587
|
}
|
|
37380
37588
|
function badgeSvg(r) {
|
|
37381
37589
|
const colour = (g) => ({ A: "#2e7d32", B: "#558b2f", C: "#f9a825", D: "#ef6c00", F: "#c62828" })[g ?? ""] ?? "#757575";
|
|
@@ -37425,7 +37633,7 @@ ${(r.summary ?? []).map((l) => `<p>${e(l)}</p>`).join("")}
|
|
|
37425
37633
|
<h2>2. Open findings</h2><table><tr><th>Severity</th><th>Check</th><th>Detail</th></tr>${problems}</table>
|
|
37426
37634
|
<h2>3. What the tools can do</h2><ul>${caps}</ul>${r.capabilities?.lethalTrifecta ? "<p><b>Note:</b> the tools combine private data, untrusted content and an outbound channel; customers should limit what an agent can combine.</p>" : ""}
|
|
37427
37635
|
${tests ? `<h2>4. Provider test cases</h2><ul>${tests}</ul>` : ""}
|
|
37428
|
-
<h2>${tests ? 5 : 4}. Scope and limits</h2>${scopeOfRun(r).map((l) => `<p>${e(l)}</p>`).join("")}<p class="muted">${e(COVERAGE_NOTE)} ${e(
|
|
37636
|
+
<h2>${tests ? 5 : 4}. Scope and limits</h2>${scopeOfRun(r).map((l) => `<p>${e(l)}</p>`).join("")}<p class="muted">${e(COVERAGE_NOTE)} ${e(DISCLAIMER2)}</p>
|
|
37429
37637
|
<h2>${tests ? 6 : 5}. Verify this evidence</h2><p>The full signed result accompanies this packet${signedBy ? ` (signed by <code>${e(signedBy)}</code>)` : ""}. Anyone can check it was not altered: <code>npx saktum verify saktum-report.json</code>.</p>
|
|
37430
37638
|
<h2>${tests ? 7 : 6}. Provider statements (completed by the provider; not verified by Saktum)</h2><table>${declare}</table>
|
|
37431
37639
|
</body></html>
|
|
@@ -37460,7 +37668,7 @@ function toSarif(r, anchor2 = "package.json", accepted = /* @__PURE__ */ new Set
|
|
|
37460
37668
|
}]
|
|
37461
37669
|
};
|
|
37462
37670
|
}
|
|
37463
|
-
var SEV_ORDER, rank, SYMBOL, FEEDBACK_URL, COVERAGE_NOTE,
|
|
37671
|
+
var SEV_ORDER, rank, SYMBOL, FEEDBACK_URL, COVERAGE_NOTE, DISCLAIMER2, SELF_SIGNED_NOTE, OWASP_MCP, LATER, PARTIAL, PACK_DIMENSION, dim;
|
|
37464
37672
|
var init_dist5 = __esm({
|
|
37465
37673
|
"packages/report/dist/index.js"() {
|
|
37466
37674
|
"use strict";
|
|
@@ -37471,7 +37679,7 @@ var init_dist5 = __esm({
|
|
|
37471
37679
|
SYMBOL = { fail: "\u2717 FAIL", inconclusive: "! INCONCLUSIVE", pass: "\u2713 PASS", skipped: "- SKIPPED", info: "i INFO" };
|
|
37472
37680
|
FEEDBACK_URL = "https://github.com/soodhere/saktum-check/discussions";
|
|
37473
37681
|
COVERAGE_NOTE = "This version tests conformance, sign-in basics, security hygiene, functional behaviour (with --active or test cases), performance and agent readiness; deeper sign-in, injection and supply-chain checks arrive in later releases.";
|
|
37474
|
-
|
|
37682
|
+
DISCLAIMER2 = "Findings describe this server at the time of the run. They are not a guarantee of security or correctness.";
|
|
37475
37683
|
SELF_SIGNED_NOTE = "Assurance level L1 (self-tested): the signature proves this report was not changed after the run, not that it was run independently.";
|
|
37476
37684
|
OWASP_MCP = [
|
|
37477
37685
|
["MCP01", "Token mismanagement and secret exposure"],
|
|
@@ -37512,9 +37720,9 @@ __export(init_exports, {
|
|
|
37512
37720
|
initProject: () => initProject
|
|
37513
37721
|
});
|
|
37514
37722
|
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
37515
|
-
import { join as
|
|
37723
|
+
import { join as join5 } from "node:path";
|
|
37516
37724
|
function initProject(dir, lang, name) {
|
|
37517
|
-
if (existsSync4(
|
|
37725
|
+
if (existsSync4(join5(dir, "package.json")) || existsSync4(join5(dir, "pyproject.toml")) || existsSync4(join5(dir, "server.py")))
|
|
37518
37726
|
throw new Error(`${dir} already contains a project; choose an empty folder.`);
|
|
37519
37727
|
const id = name.replace(/[^a-z0-9-]/gi, "-").toLowerCase() || "my-mcp-server";
|
|
37520
37728
|
const files = {};
|
|
@@ -37603,8 +37811,8 @@ if __name__ == "__main__":
|
|
|
37603
37811
|
|
|
37604
37812
|
${AGENT_RULES}`;
|
|
37605
37813
|
for (const [p, text2] of Object.entries(files)) {
|
|
37606
|
-
const f =
|
|
37607
|
-
mkdirSync3(
|
|
37814
|
+
const f = join5(dir, p);
|
|
37815
|
+
mkdirSync3(join5(f, ".."), { recursive: true });
|
|
37608
37816
|
writeFileSync3(f, text2);
|
|
37609
37817
|
}
|
|
37610
37818
|
return Object.keys(files);
|
|
@@ -37692,7 +37900,7 @@ __export(proxy_exports, {
|
|
|
37692
37900
|
runProxy: () => runProxy
|
|
37693
37901
|
});
|
|
37694
37902
|
import { spawn as spawn3 } from "node:child_process";
|
|
37695
|
-
import { appendFileSync, existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as
|
|
37903
|
+
import { appendFileSync, existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync7 } from "node:fs";
|
|
37696
37904
|
import { dirname as dirname3 } from "node:path";
|
|
37697
37905
|
import { createInterface } from "node:readline";
|
|
37698
37906
|
import { randomUUID } from "node:crypto";
|
|
@@ -37701,7 +37909,7 @@ async function runProxy(o) {
|
|
|
37701
37909
|
let last;
|
|
37702
37910
|
let history = [];
|
|
37703
37911
|
if (existsSync5(o.receiptsPath)) {
|
|
37704
|
-
history = parseReceiptLog(
|
|
37912
|
+
history = parseReceiptLog(readFileSync7(o.receiptsPath, "utf8"));
|
|
37705
37913
|
last = history[history.length - 1];
|
|
37706
37914
|
}
|
|
37707
37915
|
const today = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
@@ -37784,8 +37992,18 @@ async function runProxy(o) {
|
|
|
37784
37992
|
const ap = consumeApproval(o.mandate, rid, o.approvalsPath);
|
|
37785
37993
|
if (ap.ok)
|
|
37786
37994
|
d = { allow: true, code: "ok", reason: `approved by ${ap.by} (${rid}), after: ${d.reason}` };
|
|
37787
|
-
else
|
|
37995
|
+
else {
|
|
37788
37996
|
d = { ...d, reason: `${d.reason} [approval request ${rid}]` };
|
|
37997
|
+
try {
|
|
37998
|
+
recordPending(o.approvalsPath ?? DEFAULT_APPROVALS(), { id: rid, tool, reason: d.reason, agent: o.mandate.agent.name });
|
|
37999
|
+
} catch {
|
|
38000
|
+
}
|
|
38001
|
+
if (o.approvalWebhook) {
|
|
38002
|
+
const link = o.approvalUrl ? `${o.approvalUrl}${o.approvalUrl.includes("?") ? "&" : "?"}id=${rid}` : "";
|
|
38003
|
+
const text2 = `Approval needed: ${o.mandate.agent.name} wants to run ${tool}. ${d.reason.replace(/ \[approval request [^\]]+\]/, "")}. Request ${rid}. ${link ? `Approve: ${link}` : `Approve with: npx saktum agent approve ${rid} --mandate <mandate>`}`;
|
|
38004
|
+
fetch(o.approvalWebhook, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ text: text2, requestId: rid, tool, agent: o.mandate.agent.name, ...link ? { approveUrl: link } : {} }) }).catch(() => void 0);
|
|
38005
|
+
}
|
|
38006
|
+
}
|
|
37789
38007
|
}
|
|
37790
38008
|
if (d.allow && o.credential) {
|
|
37791
38009
|
const vc = verifyChain(o.credential, { revoked: o.revokedCredentials });
|
|
@@ -37852,8 +38070,10 @@ async function runProxy(o) {
|
|
|
37852
38070
|
}
|
|
37853
38071
|
if (kind === "tools/list" && Array.isArray(msg.result?.tools)) {
|
|
37854
38072
|
for (const t of msg.result.tools) {
|
|
38073
|
+
const ov = o.bindingsOverride?.[t.name];
|
|
38074
|
+
const def = ov ? { ...t, _meta: { ...t._meta ?? {}, ...ov.action ? { "io.saktum/action": ov.action } : {}, ...ov.bindings ? { "io.saktum/bindings": ov.bindings } : {} } } : t;
|
|
37855
38075
|
annotations.set(t.name, t.annotations);
|
|
37856
|
-
toolDefs.set(t.name,
|
|
38076
|
+
toolDefs.set(t.name, def);
|
|
37857
38077
|
}
|
|
37858
38078
|
pendingKinds.delete(k);
|
|
37859
38079
|
}
|
|
@@ -37878,6 +38098,77 @@ var init_proxy = __esm({
|
|
|
37878
38098
|
}
|
|
37879
38099
|
});
|
|
37880
38100
|
|
|
38101
|
+
// packages/cli/dist/bridge.js
|
|
38102
|
+
var bridge_exports = {};
|
|
38103
|
+
__export(bridge_exports, {
|
|
38104
|
+
runBridge: () => runBridge
|
|
38105
|
+
});
|
|
38106
|
+
import { createInterface as createInterface2 } from "node:readline";
|
|
38107
|
+
async function runBridge(url2, headers) {
|
|
38108
|
+
let session;
|
|
38109
|
+
const out = (m) => process.stdout.write(JSON.stringify(m) + "\n");
|
|
38110
|
+
const rl = createInterface2({ input: process.stdin });
|
|
38111
|
+
const pending = [];
|
|
38112
|
+
const forward = async (line) => {
|
|
38113
|
+
let msg = {};
|
|
38114
|
+
try {
|
|
38115
|
+
msg = JSON.parse(line);
|
|
38116
|
+
} catch {
|
|
38117
|
+
return;
|
|
38118
|
+
}
|
|
38119
|
+
try {
|
|
38120
|
+
const res = await fetch(url2, {
|
|
38121
|
+
method: "POST",
|
|
38122
|
+
body: line,
|
|
38123
|
+
headers: { "Content-Type": "application/json", Accept: "application/json, text/event-stream", ...session ? { "Mcp-Session-Id": session } : {}, ...headers }
|
|
38124
|
+
});
|
|
38125
|
+
const sid = res.headers.get("mcp-session-id");
|
|
38126
|
+
if (sid)
|
|
38127
|
+
session = sid;
|
|
38128
|
+
const text2 = await res.text();
|
|
38129
|
+
if (msg.id === void 0 || res.status === 202)
|
|
38130
|
+
return;
|
|
38131
|
+
if (!res.ok && !text2.trim()) {
|
|
38132
|
+
out({ jsonrpc: "2.0", id: msg.id, error: { code: -32e3, message: `upstream HTTP ${res.status}` } });
|
|
38133
|
+
return;
|
|
38134
|
+
}
|
|
38135
|
+
if ((res.headers.get("content-type") ?? "").includes("text/event-stream")) {
|
|
38136
|
+
for (const l of text2.split(/\r?\n/))
|
|
38137
|
+
if (l.startsWith("data:")) {
|
|
38138
|
+
const d = l.slice(5).trim();
|
|
38139
|
+
if (d)
|
|
38140
|
+
process.stdout.write(d + "\n");
|
|
38141
|
+
}
|
|
38142
|
+
} else if (text2.trim()) {
|
|
38143
|
+
const j = JSON.parse(text2);
|
|
38144
|
+
for (const m of Array.isArray(j) ? j : [j])
|
|
38145
|
+
out(m);
|
|
38146
|
+
}
|
|
38147
|
+
} catch (e) {
|
|
38148
|
+
if (msg.id !== void 0)
|
|
38149
|
+
out({ jsonrpc: "2.0", id: msg.id, error: { code: -32e3, message: `upstream unreachable: ${String(e.message).slice(0, 120)}` } });
|
|
38150
|
+
}
|
|
38151
|
+
};
|
|
38152
|
+
rl.on("line", (line) => {
|
|
38153
|
+
if (line.trim())
|
|
38154
|
+
pending.push(forward(line));
|
|
38155
|
+
});
|
|
38156
|
+
await new Promise((r) => rl.on("close", () => r()));
|
|
38157
|
+
await Promise.allSettled(pending);
|
|
38158
|
+
if (session) {
|
|
38159
|
+
try {
|
|
38160
|
+
await fetch(url2, { method: "DELETE", headers: { "Mcp-Session-Id": session, ...headers } });
|
|
38161
|
+
} catch {
|
|
38162
|
+
}
|
|
38163
|
+
}
|
|
38164
|
+
return 0;
|
|
38165
|
+
}
|
|
38166
|
+
var init_bridge = __esm({
|
|
38167
|
+
"packages/cli/dist/bridge.js"() {
|
|
38168
|
+
"use strict";
|
|
38169
|
+
}
|
|
38170
|
+
});
|
|
38171
|
+
|
|
37881
38172
|
// node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_zod@4.6.7/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
37882
38173
|
var ExperimentalServerTasks;
|
|
37883
38174
|
var init_server = __esm({
|
|
@@ -38560,10 +38851,10 @@ __export(demo_exports, {
|
|
|
38560
38851
|
runDemo: () => runDemo,
|
|
38561
38852
|
startDemoServer: () => startDemoServer
|
|
38562
38853
|
});
|
|
38563
|
-
import { mkdirSync as mkdirSync5, readFileSync as
|
|
38564
|
-
import { join as
|
|
38854
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync8, writeFileSync as writeFileSync4, existsSync as existsSync6, rmSync } from "node:fs";
|
|
38855
|
+
import { join as join6 } from "node:path";
|
|
38565
38856
|
async function startDemoServer(story = "autonomy") {
|
|
38566
|
-
const tools = story === "grocery" ? GROCERY_TOOLS : story === "travel" ? TRAVEL_TOOLS : story === "finance" ? FINANCE_TOOLS : DEMO_TOOLS;
|
|
38857
|
+
const tools = story === "grocery" ? GROCERY_TOOLS : story === "travel" ? TRAVEL_TOOLS : story === "finance" ? FINANCE_TOOLS : story === "coding" ? CODING_TOOLS : DEMO_TOOLS;
|
|
38567
38858
|
const server = new Server({ name: story === "travel" ? "demo-travel" : story === "finance" ? "demo-finance" : "demo-grocer", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
38568
38859
|
const cart = [];
|
|
38569
38860
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools }));
|
|
@@ -38596,6 +38887,16 @@ async function startDemoServer(story = "autonomy") {
|
|
|
38596
38887
|
return text2(`Sent "${a.report}" to ${a.recipient}.`);
|
|
38597
38888
|
case "pay_invoice":
|
|
38598
38889
|
return text2(`Paid $${a.amount} to ${a.vendor}.`);
|
|
38890
|
+
case "run_tests":
|
|
38891
|
+
return text2(`${a.repository}: 412 tests passed.`);
|
|
38892
|
+
case "open_pull_request":
|
|
38893
|
+
return text2(`Opened pull request #318 in ${a.repository}: ${a.title}.`);
|
|
38894
|
+
case "read_secret":
|
|
38895
|
+
return text2(`Read ${a.name}.`);
|
|
38896
|
+
case "deploy_to_staging":
|
|
38897
|
+
return text2(`Deployed ${a.build} to staging.`);
|
|
38898
|
+
case "deploy_to_production":
|
|
38899
|
+
return text2(`Released ${a.build} to production.`);
|
|
38599
38900
|
default:
|
|
38600
38901
|
return { isError: true, content: [{ type: "text", text: "Unknown tool" }] };
|
|
38601
38902
|
}
|
|
@@ -38609,7 +38910,7 @@ async function startDemoServer(story = "autonomy") {
|
|
|
38609
38910
|
}
|
|
38610
38911
|
async function runStory(dir, st, owner, log) {
|
|
38611
38912
|
const self = [...process.execArgv, process.argv[1]];
|
|
38612
|
-
const agentKey = loadOrCreateKey(
|
|
38913
|
+
const agentKey = loadOrCreateKey(join6(dir, `${st.id}-agent-key.json`));
|
|
38613
38914
|
const m = createMandate({
|
|
38614
38915
|
agentId: agentKey.kid,
|
|
38615
38916
|
agentName: `${st.id === "travel" ? "Travel" : "Shopping"} agent`,
|
|
@@ -38620,14 +38921,14 @@ async function runStory(dir, st, owner, log) {
|
|
|
38620
38921
|
...st.m
|
|
38621
38922
|
}, owner);
|
|
38622
38923
|
const operatorName = String(st.m.disclosures?.operator ?? "Demo operator");
|
|
38623
|
-
const cm = cosignMandate(m, loadOrCreateKey(
|
|
38624
|
-
const mf =
|
|
38924
|
+
const cm = cosignMandate(m, loadOrCreateKey(join6(dir, `${st.id}-operator-key.json`)), operatorName);
|
|
38925
|
+
const mf = join6(dir, `${st.id}-mandate.json`), rf = join6(dir, `${st.id}-receipts.jsonl`), revf = join6(dir, "revocations.json");
|
|
38625
38926
|
writeFileSync4(mf, JSON.stringify(cm, null, 2));
|
|
38626
38927
|
log(`\u2500\u2500 ${st.title}`);
|
|
38627
38928
|
log(` Signed by you; countersigned by the operator, ${operatorName}.`);
|
|
38628
38929
|
for (const line of describeMandate(m))
|
|
38629
38930
|
log(` ${line}`);
|
|
38630
|
-
const open2 = () => connect({ kind: "stdio", command: process.execPath, args: [...self, "proxy", "--mandate", mf, "--agent-key",
|
|
38931
|
+
const open2 = () => connect({ kind: "stdio", command: process.execPath, args: [...self, "proxy", "--mandate", mf, "--agent-key", join6(dir, `${st.id}-agent-key.json`), "--enforce", "--receipts", rf, "--revocations", revf, "--approvals", join6(dir, "approvals.json"), "--", process.execPath, ...self, "demo-server", "--story", st.server] });
|
|
38631
38932
|
const s = await open2();
|
|
38632
38933
|
try {
|
|
38633
38934
|
await s.listTools();
|
|
@@ -38635,7 +38936,7 @@ async function runStory(dir, st, owner, log) {
|
|
|
38635
38936
|
for (const step of st.steps) {
|
|
38636
38937
|
if (step.approveLast) {
|
|
38637
38938
|
const { approveAction: approveAction2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports));
|
|
38638
|
-
approveAction2(cm, lastRid, owner, 60,
|
|
38939
|
+
approveAction2(cm, lastRid, owner, 60, join6(dir, "approvals.json"));
|
|
38639
38940
|
log(` \u270D ${step.say}: ${lastRid}`);
|
|
38640
38941
|
continue;
|
|
38641
38942
|
}
|
|
@@ -38645,9 +38946,9 @@ async function runStory(dir, st, owner, log) {
|
|
|
38645
38946
|
if (rid)
|
|
38646
38947
|
lastRid = rid[1];
|
|
38647
38948
|
const blocked = /^Blocked by Saktum \(([^)]+)\): (.+?)( \[approval request [^\]]+\])?\.( Ask| Tell|$)/.exec(txt);
|
|
38648
|
-
const lastR = parseReceiptLog(
|
|
38949
|
+
const lastR = parseReceiptLog(readFileSync8(rf, "utf8")).pop();
|
|
38649
38950
|
log(blocked ? ` \u26D4 ${step.say}: ${blocked[1]}: ${blocked[2]}` : ` \u2713 ${step.say}${/approved by/.test(String(lastR?.receipt.reason ?? "")) ? ": approved by you, once" : ""}`);
|
|
38650
|
-
const last = parseReceiptLog(
|
|
38951
|
+
const last = parseReceiptLog(readFileSync8(rf, "utf8")).pop();
|
|
38651
38952
|
for (const p of last?.result.rationale?.preferences ?? [])
|
|
38652
38953
|
if (!blocked)
|
|
38653
38954
|
log(` \xB7 ${p}`);
|
|
@@ -38672,12 +38973,12 @@ async function runStory(dir, st, owner, log) {
|
|
|
38672
38973
|
await new Promise((r) => setTimeout(r, 300));
|
|
38673
38974
|
}
|
|
38674
38975
|
}
|
|
38675
|
-
const entries = parseReceiptLog(
|
|
38976
|
+
const entries = parseReceiptLog(readFileSync8(rf, "utf8"));
|
|
38676
38977
|
const ts = trustStatement(entries, verifyReceiptLog(entries).ok);
|
|
38677
38978
|
log(" Track record:");
|
|
38678
38979
|
for (const l of ts.lines)
|
|
38679
38980
|
log(` ${l}`);
|
|
38680
|
-
const html =
|
|
38981
|
+
const html = join6(dir, `${st.id}-passport.html`);
|
|
38681
38982
|
writeFileSync4(html, renderAgentPassport(m, checkMandate(m).ok ? { ok: true } : { ok: false }, {
|
|
38682
38983
|
verified: verifyReceiptLog(entries).ok,
|
|
38683
38984
|
summary: summariseReceipts(entries),
|
|
@@ -38696,12 +38997,12 @@ async function runStory(dir, st, owner, log) {
|
|
|
38696
38997
|
}
|
|
38697
38998
|
async function runMarketplace(dir, log) {
|
|
38698
38999
|
const self = [...process.execArgv, process.argv[1]];
|
|
38699
|
-
const k = (n) => loadOrCreateKey(
|
|
39000
|
+
const k = (n) => loadOrCreateKey(join6(dir, `market-${n}-key.json`));
|
|
38700
39001
|
const acme = k("acme"), priya = k("priya"), agent = k("agent"), grocer = k("grocer"), travel = k("travel");
|
|
38701
39002
|
const exp = new Date(Date.now() + 180 * 864e5).toISOString().slice(0, 10);
|
|
38702
39003
|
const w = (f, x) => {
|
|
38703
|
-
writeFileSync4(
|
|
38704
|
-
return
|
|
39004
|
+
writeFileSync4(join6(dir, f), JSON.stringify(x, null, 2));
|
|
39005
|
+
return join6(dir, f);
|
|
38705
39006
|
};
|
|
38706
39007
|
log(`\u2500\u2500 Marketplace: "Acme's shopping agent finds a store, agrees terms, and pays per call in prepaid tokens"`);
|
|
38707
39008
|
const root = organisationRoot({ name: "Acme Corp", domain: "acme.example", expires: exp }, acme);
|
|
@@ -38727,11 +39028,11 @@ async function runMarketplace(dir, log) {
|
|
|
38727
39028
|
}, grocer), acme);
|
|
38728
39029
|
const agFile = w("market-agreement.json", ag);
|
|
38729
39030
|
log(` \u2713 agreement ${ag.id}: ${ag.terms.length} default terms + ${ag.specificTerms.length} specific, signed by Demo Grocer and Acme Corp (${verifyAgreement(ag).valid ? "verified" : "NOT valid"})`);
|
|
38730
|
-
const wf =
|
|
39031
|
+
const wf = join6(dir, "market-wallet.json");
|
|
38731
39032
|
topUp(wf, acme.kid, 12);
|
|
38732
39033
|
log(` \u2713 Acme tops up 12 prepaid tokens (bought outside Saktum; no money is handled here)`);
|
|
38733
39034
|
const m = cosignMandate(createMandate({ agentId: agent.kid, agentName: "Acme shopping agent", ownerName: "Priya", purpose: "Weekly office groceries", tools: gm.capabilities.map((c) => c.tool), destructive: false, expires: exp, autonomy: "act", approveAbove: { arg: "amount", value: 50 } }, priya), acme, "Acme Corp");
|
|
38734
|
-
const mf = w("market-mandate.json", m), rf =
|
|
39035
|
+
const mf = w("market-mandate.json", m), rf = join6(dir, "market-receipts.jsonl"), revf = join6(dir, "market-revoked-credentials.json");
|
|
38735
39036
|
writeFileSync4(revf, "[]");
|
|
38736
39037
|
const open2 = () => connect({ kind: "stdio", command: process.execPath, args: [
|
|
38737
39038
|
...self,
|
|
@@ -38739,7 +39040,7 @@ async function runMarketplace(dir, log) {
|
|
|
38739
39040
|
"--mandate",
|
|
38740
39041
|
mf,
|
|
38741
39042
|
"--agent-key",
|
|
38742
|
-
|
|
39043
|
+
join6(dir, "market-agent-key.json"),
|
|
38743
39044
|
"--enforce",
|
|
38744
39045
|
"--receipts",
|
|
38745
39046
|
rf,
|
|
@@ -38774,7 +39075,7 @@ async function runMarketplace(dir, log) {
|
|
|
38774
39075
|
const o = await s2.callTool(st1.tool, st1.args);
|
|
38775
39076
|
const txt = o.kind === "result" ? o.content.map((c) => c.text ?? "").join(" ") : o.kind;
|
|
38776
39077
|
const blocked = /^Blocked by Saktum \(([^)]+)\): (.+?)\.( Ask| Tell|$)/.exec(txt);
|
|
38777
|
-
const last = parseReceiptLog(
|
|
39078
|
+
const last = parseReceiptLog(readFileSync8(rf, "utf8")).pop();
|
|
38778
39079
|
log(blocked ? ` \u26D4 ${st1.say}: ${blocked[1]}: ${blocked[2]}` : ` \u2713 ${st1.say} \xB7 ${last?.result.metering?.tokens ?? 0} token(s), balance ${last?.result.metering?.balance ?? "-"}`);
|
|
38779
39080
|
}
|
|
38780
39081
|
} finally {
|
|
@@ -38783,7 +39084,7 @@ async function runMarketplace(dir, log) {
|
|
|
38783
39084
|
}
|
|
38784
39085
|
};
|
|
38785
39086
|
await run(steps);
|
|
38786
|
-
const entries = parseReceiptLog(
|
|
39087
|
+
const entries = parseReceiptLog(readFileSync8(rf, "utf8"));
|
|
38787
39088
|
const st = usageStatement(entries, ag, grocer);
|
|
38788
39089
|
log(` \u2713 usage statement signed by Demo Grocer: ${st.lines.map((l) => `${l.tool} ${l.calls}\xD7 = ${l.tokens}`).join(", ")}; total ${st.totalTokens} tokens`);
|
|
38789
39090
|
log(` \u2713 wallet (double-entry): Acme ${walletBalance(wf, acme.kid)} tokens, Demo Grocer ${walletBalance(wf, grocer.kid)} tokens`);
|
|
@@ -38792,10 +39093,10 @@ async function runMarketplace(dir, log) {
|
|
|
38792
39093
|
log(` \u26D4 Priya leaves Acme and her credential is revoked: the agent is now an orphan (${orphan?.reason})`);
|
|
38793
39094
|
topUp(wf, acme.kid, 5);
|
|
38794
39095
|
await run([{ tool: "search_products", args: { query: "milk" }, say: "the orphaned agent tries to search" }]);
|
|
38795
|
-
const all = parseReceiptLog(
|
|
39096
|
+
const all = parseReceiptLog(readFileSync8(rf, "utf8"));
|
|
38796
39097
|
const k2 = kpis(all);
|
|
38797
39098
|
log(` KPIs: ${k2.calls} calls \xB7 ${k2.allowed} allowed \xB7 ${k2.blocked} blocked (${k2.byOutcome.filter(([c]) => !c.startsWith("ok")).map(([c, n]) => `${n} ${c}`).join(", ")}) \xB7 ${k2.tokens} tokens`);
|
|
38798
|
-
const html =
|
|
39099
|
+
const html = join6(dir, "marketplace-passport.html");
|
|
38799
39100
|
const ts = trustStatement(all, verifyReceiptLog(all).ok);
|
|
38800
39101
|
writeFileSync4(html, renderAgentPassport(m, { ok: true }, { verified: verifyReceiptLog(all).ok, summary: summariseReceipts(all), timeline: all.map((e) => ({ tool: e.receipt.envelope.tool, outcome: e.receipt.outcome, status: e.result.status, repeated: false, why: [e.receipt.reason ?? "", e.result.metering ? `${e.result.metering.tokens} token(s), balance ${e.result.metering.balance}` : ""].filter(Boolean).join(" \xB7 ") })) }, agentRiskTier(m), [`Weekly office groceries for Acme Corp, under agreement ${ag.id} with Demo Grocer.`, `Accountable: ${verifyChain(agentCred).path.join(" \u2192 ")}.`, "Paid per call in prepaid tokens."], { operator: "Acme Corp", track: ts.lines, maturity: agentMaturity(m, { entries: all, verified: verifyReceiptLog(all).ok, chainValid: verifyChain(agentCred).valid }) }));
|
|
38801
39102
|
log(` ${all.length} signed receipts \xB7 ${verifyReceiptLog(all).ok ? "verified" : "NOT verified"} \xB7 passport: ${html}
|
|
@@ -38814,10 +39115,10 @@ async function runDemo(dir, log, story = "all") {
|
|
|
38814
39115
|
if (existsSync6(dir))
|
|
38815
39116
|
rmSync(dir, { recursive: true, force: true });
|
|
38816
39117
|
mkdirSync5(dir, { recursive: true });
|
|
38817
|
-
const owner = loadOrCreateKey(
|
|
39118
|
+
const owner = loadOrCreateKey(join6(dir, "owner-key.json"));
|
|
38818
39119
|
log("Saktum demo: agents acting on real instructions (rules, preferences, substitutions, upsells), every decision explained and signed.\n");
|
|
38819
39120
|
const files = [];
|
|
38820
|
-
for (const st of story === "travel" ? [TRAVEL] : story === "grocery" ? [GROCERY] : story === "finance" ? [FINANCE] : [GROCERY, TRAVEL, FINANCE])
|
|
39121
|
+
for (const st of story === "travel" ? [TRAVEL] : story === "grocery" ? [GROCERY] : story === "finance" ? [FINANCE] : story === "coding" ? [CODING] : [GROCERY, TRAVEL, FINANCE, CODING])
|
|
38821
39122
|
files.push(await runStory(dir, st, owner, log));
|
|
38822
39123
|
if (story === "all")
|
|
38823
39124
|
files.push(await runMarketplace(dir, log));
|
|
@@ -38835,7 +39136,7 @@ async function runAutonomyDemo(dir, log) {
|
|
|
38835
39136
|
if (existsSync6(dir))
|
|
38836
39137
|
rmSync(dir, { recursive: true, force: true });
|
|
38837
39138
|
mkdirSync5(dir, { recursive: true });
|
|
38838
|
-
const owner = loadOrCreateKey(
|
|
39139
|
+
const owner = loadOrCreateKey(join6(dir, "owner-key.json"));
|
|
38839
39140
|
const self = [...process.execArgv, process.argv[1]];
|
|
38840
39141
|
const tools = DEMO_TOOLS.map((t) => t.name);
|
|
38841
39142
|
const personas = [
|
|
@@ -38846,7 +39147,7 @@ async function runAutonomyDemo(dir, log) {
|
|
|
38846
39147
|
const files = [];
|
|
38847
39148
|
log("Saktum demo: one shopping agent, three mandates, every call governed and receipted.\n");
|
|
38848
39149
|
for (const p of personas) {
|
|
38849
|
-
const agentKey = loadOrCreateKey(
|
|
39150
|
+
const agentKey = loadOrCreateKey(join6(dir, `${p.id}-agent-key.json`));
|
|
38850
39151
|
const m = createMandate({
|
|
38851
39152
|
agentId: agentKey.kid,
|
|
38852
39153
|
agentName: `Shopping agent (${p.id})`,
|
|
@@ -38858,11 +39159,11 @@ async function runAutonomyDemo(dir, log) {
|
|
|
38858
39159
|
disclosures: { operator: "Demo Grocer", incentives: "None: no sponsored ranking", dataUse: "Order history used only to suggest your usual items" },
|
|
38859
39160
|
...p.m
|
|
38860
39161
|
}, owner);
|
|
38861
|
-
const mf =
|
|
39162
|
+
const mf = join6(dir, `${p.id}-mandate.json`), rf = join6(dir, `${p.id}-receipts.jsonl`);
|
|
38862
39163
|
writeFileSync4(mf, JSON.stringify(m, null, 2));
|
|
38863
39164
|
const tier = agentRiskTier(m);
|
|
38864
39165
|
log(`\u2500\u2500 ${p.title} autonomy ${m.autonomy} \xB7 risk ${tier.tier}`);
|
|
38865
|
-
const s = await connect({ kind: "stdio", command: process.execPath, args: [...self, "proxy", "--mandate", mf, "--agent-key",
|
|
39166
|
+
const s = await connect({ kind: "stdio", command: process.execPath, args: [...self, "proxy", "--mandate", mf, "--agent-key", join6(dir, `${p.id}-agent-key.json`), "--enforce", "--receipts", rf, "--", process.execPath, ...self, "demo-server"] });
|
|
38866
39167
|
try {
|
|
38867
39168
|
await s.listTools();
|
|
38868
39169
|
for (const st of p.steps) {
|
|
@@ -38875,13 +39176,13 @@ async function runAutonomyDemo(dir, log) {
|
|
|
38875
39176
|
await s.close();
|
|
38876
39177
|
await new Promise((r) => setTimeout(r, 300));
|
|
38877
39178
|
}
|
|
38878
|
-
const entries = parseReceiptLog(
|
|
39179
|
+
const entries = parseReceiptLog(readFileSync8(rf, "utf8"));
|
|
38879
39180
|
const counts = /* @__PURE__ */ new Map();
|
|
38880
39181
|
for (const e of entries) {
|
|
38881
39182
|
const k = `${e.receipt.envelope.tool}|${e.receipt.envelope.argumentsHash}`;
|
|
38882
39183
|
counts.set(k, (counts.get(k) ?? 0) + 1);
|
|
38883
39184
|
}
|
|
38884
|
-
const html =
|
|
39185
|
+
const html = join6(dir, `${p.id}-passport.html`);
|
|
38885
39186
|
writeFileSync4(html, renderAgentPassport(m, checkMandate(m).ok ? { ok: true } : { ok: false }, {
|
|
38886
39187
|
verified: verifyReceiptLog(entries).ok,
|
|
38887
39188
|
summary: summariseReceipts(entries),
|
|
@@ -38894,7 +39195,7 @@ async function runAutonomyDemo(dir, log) {
|
|
|
38894
39195
|
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.");
|
|
38895
39196
|
return { files };
|
|
38896
39197
|
}
|
|
38897
|
-
var PRODUCTS, DEMO_TOOLS, B, GROCERY_TOOLS, TRAVEL_TOOLS, FINANCE_TOOLS, SCRIPT, EXTRA, GROCERY, TRAVEL, FINANCE;
|
|
39198
|
+
var PRODUCTS, DEMO_TOOLS, B, GROCERY_TOOLS, TRAVEL_TOOLS, FINANCE_TOOLS, CODING_TOOLS, SCRIPT, EXTRA, GROCERY, TRAVEL, FINANCE, CODING;
|
|
38898
39199
|
var init_demo = __esm({
|
|
38899
39200
|
"packages/cli/dist/demo.js"() {
|
|
38900
39201
|
"use strict";
|
|
@@ -38947,6 +39248,13 @@ var init_demo = __esm({
|
|
|
38947
39248
|
{ name: "send_report", description: "Send a report to a recipient.", inputSchema: { type: "object", properties: { recipient: { type: "string" }, report: { type: "string" }, data_class: { type: "string" } }, required: ["recipient", "report", "data_class"] }, annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, _meta: B({ recipient: "party.recipient", data_class: "enterprise.data_class" }, "communicate") },
|
|
38948
39249
|
{ name: "pay_invoice", description: "Pays a vendor invoice from the company account.", inputSchema: { type: "object", properties: { amount: { type: "number" }, currency: { type: "string" }, vendor: { type: "string" }, idempotency_key: { type: "string" } }, required: ["amount", "currency", "vendor", "idempotency_key"] }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true }, _meta: B({ amount: "commerce.order.total", currency: "commerce.order.currency", vendor: "enterprise.vendor" }, "pay") }
|
|
38949
39250
|
];
|
|
39251
|
+
CODING_TOOLS = [
|
|
39252
|
+
{ name: "run_tests", description: "Run the repository's test suite.", inputSchema: { type: "object", properties: { repository: { type: "string" } }, required: ["repository"] }, annotations: { readOnlyHint: true }, _meta: B({ repository: "code.repository" }, "search") },
|
|
39253
|
+
{ name: "open_pull_request", description: "Open a pull request with the agent's changes.", inputSchema: { type: "object", properties: { repository: { type: "string" }, title: { type: "string" } }, required: ["repository", "title"] }, annotations: { readOnlyHint: false, destructiveHint: false }, _meta: B({ repository: "code.repository" }, "change") },
|
|
39254
|
+
{ name: "read_secret", description: "Read a secret from the secrets store.", inputSchema: { type: "object", properties: { repository: { type: "string" }, name: { type: "string" } }, required: ["repository", "name"] }, annotations: { readOnlyHint: true }, _meta: B({ repository: "code.repository" }, "search") },
|
|
39255
|
+
{ 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") },
|
|
39256
|
+
{ 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") }
|
|
39257
|
+
];
|
|
38950
39258
|
SCRIPT = [
|
|
38951
39259
|
{ tool: "get_deals", args: {}, say: "checks this week's deals" },
|
|
38952
39260
|
{ tool: "search_products", args: { query: "coffee" }, say: "searches for coffee" },
|
|
@@ -39020,6 +39328,23 @@ var init_demo = __esm({
|
|
|
39020
39328
|
{ tool: "", args: {}, say: "you approve exactly that invoice (saktum agent approve)", approveLast: true },
|
|
39021
39329
|
{ tool: "pay_invoice", args: { amount: 12e3, currency: "CAD", vendor: "Consulting LLP", idempotency_key: "f-2" }, say: "retries the same $12,000 invoice" }
|
|
39022
39330
|
] };
|
|
39331
|
+
CODING = { id: "coding", title: 'Coding agent: "fix the failing tests; production only with my approval"', server: "coding", tools: CODING_TOOLS.map((t) => t.name), m: {
|
|
39332
|
+
autonomy: "act",
|
|
39333
|
+
destructive: true,
|
|
39334
|
+
purpose: "Fix the failing tests in payments-service overnight",
|
|
39335
|
+
actions: [{ cls: "search", autonomy: "act" }, { cls: "change", autonomy: "act" }, { cls: "deploy", autonomy: "propose" }],
|
|
39336
|
+
rules: [{ field: "code.repository", op: "in", value: ["payments-service"], label: "only the payments-service repository" }],
|
|
39337
|
+
disclosures: { operator: "Acme platform team", incentives: "None", dataUse: "Code and secrets of payments-service only" }
|
|
39338
|
+
}, steps: [
|
|
39339
|
+
{ tool: "run_tests", args: { repository: "payments-service" }, say: "runs the test suite" },
|
|
39340
|
+
{ tool: "open_pull_request", args: { repository: "payments-service", title: "Fix currency rounding in refunds" }, say: "opens a pull request with the fix" },
|
|
39341
|
+
{ tool: "read_secret", args: { repository: "payments-service", name: "STAGING_DB_URL" }, say: "reads its own staging database secret" },
|
|
39342
|
+
{ tool: "read_secret", args: { repository: "billing-core", name: "PROD_SIGNING_KEY" }, say: "tries to read another repository's production key" },
|
|
39343
|
+
{ tool: "deploy_to_staging", args: { repository: "payments-service", build: "build-2291" }, say: "deploys build-2291 to staging" },
|
|
39344
|
+
{ tool: "deploy_to_production", args: { repository: "payments-service", build: "build-2291" }, say: "tries to release build-2291 to production" },
|
|
39345
|
+
{ tool: "", args: {}, say: "in the morning, you approve exactly that release (saktum agent approve)", approveLast: true },
|
|
39346
|
+
{ tool: "deploy_to_production", args: { repository: "payments-service", build: "build-2291" }, say: "retries the same release" }
|
|
39347
|
+
] };
|
|
39023
39348
|
}
|
|
39024
39349
|
});
|
|
39025
39350
|
|
|
@@ -39031,7 +39356,7 @@ __export(mcp_server_exports, {
|
|
|
39031
39356
|
splitTarget: () => splitTarget,
|
|
39032
39357
|
startMcpServer: () => startMcpServer
|
|
39033
39358
|
});
|
|
39034
|
-
import { readFileSync as
|
|
39359
|
+
import { readFileSync as readFileSync9 } from "node:fs";
|
|
39035
39360
|
function splitTarget(target) {
|
|
39036
39361
|
const t = target.trim();
|
|
39037
39362
|
if (/^https?:\/\//i.test(t))
|
|
@@ -39067,7 +39392,7 @@ async function handleSaktumTool(name, args, packs) {
|
|
|
39067
39392
|
case "diff_against_lock": {
|
|
39068
39393
|
if (typeof args.lock_path !== "string")
|
|
39069
39394
|
throw new Error("lock_path is required");
|
|
39070
|
-
const before = JSON.parse(
|
|
39395
|
+
const before = JSON.parse(readFileSync9(args.lock_path, "utf8"));
|
|
39071
39396
|
const d = diffLocks(before, { tools: (await listTools(targetOf(args.target))).tools });
|
|
39072
39397
|
return text([...d.changes.map((c) => `${c.kind}: ${c.tool}: ${c.detail}`), d.summary].join("\n"), { semver: d.semver, summary: d.summary, changes: d.changes });
|
|
39073
39398
|
}
|
|
@@ -39208,7 +39533,7 @@ var init_mcp_server = __esm({
|
|
|
39208
39533
|
});
|
|
39209
39534
|
|
|
39210
39535
|
// packages/cli/dist/main.js
|
|
39211
|
-
import { existsSync as existsSync7, readFileSync as
|
|
39536
|
+
import { existsSync as existsSync7, readFileSync as readFileSync10, writeFileSync as writeFileSync5 } from "node:fs";
|
|
39212
39537
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
39213
39538
|
|
|
39214
39539
|
// node_modules/.pnpm/commander@12.1.0/node_modules/commander/esm.mjs
|
|
@@ -39446,7 +39771,7 @@ async function main(argv = process.argv) {
|
|
|
39446
39771
|
if (o.tests) {
|
|
39447
39772
|
if (!existsSync7(o.tests))
|
|
39448
39773
|
throw new Error(`Test file not found: ${o.tests}. See docs/TESTS.md for the format.`);
|
|
39449
|
-
testCases = await parseTestCases(
|
|
39774
|
+
testCases = await parseTestCases(readFileSync10(o.tests, "utf8"));
|
|
39450
39775
|
}
|
|
39451
39776
|
const target = parseTarget(targetParts);
|
|
39452
39777
|
if (target.kind === "stdio" && o.env.length)
|
|
@@ -39478,7 +39803,7 @@ async function main(argv = process.argv) {
|
|
|
39478
39803
|
process.stdout.write(`Wrote baseline ${sanitizeText(o.baseline)} accepting ${failing.length} existing finding(s). Commit it; later runs fail only on new findings.
|
|
39479
39804
|
`);
|
|
39480
39805
|
} else if (o.baseline && existsSync7(o.baseline)) {
|
|
39481
|
-
accepted = new Set(JSON.parse(
|
|
39806
|
+
accepted = new Set(JSON.parse(readFileSync10(o.baseline, "utf8")).accepted.map(keyOf));
|
|
39482
39807
|
}
|
|
39483
39808
|
if (o.sarif)
|
|
39484
39809
|
writeFileSync5(o.sarif, JSON.stringify(toSarif(signed, o.sarifAnchor, accepted), null, 2) + "\n");
|
|
@@ -39577,8 +39902,8 @@ Watching ${sanitizeText(o.watchDir)} for changes (Ctrl+C to stop).
|
|
|
39577
39902
|
`);
|
|
39578
39903
|
});
|
|
39579
39904
|
program2.command("diff").description("Compare tools with a lock file: breaking changes, risky changes (silent tool changes), additions, and the version bump they need").argument("<lock>", "the lock file written by saktum snapshot").argument("[target...]", "a second lock file, or the server to compare (after --)").option("--allow-breaking", "do not fail on breaking or risky changes", false).option("--env <KEY=VALUE>", "environment variable for a local server (repeatable)", collect, []).option("--header <Name: value>", "HTTP header for a remote server (repeatable)", collect, []).action(async (lock, rest, o) => {
|
|
39580
|
-
const before = JSON.parse(
|
|
39581
|
-
const after = rest.length === 1 && rest[0].endsWith(".json") ? JSON.parse(
|
|
39905
|
+
const before = JSON.parse(readFileSync10(lock, "utf8"));
|
|
39906
|
+
const after = rest.length === 1 && rest[0].endsWith(".json") ? JSON.parse(readFileSync10(rest[0], "utf8")) : { tools: (await listTarget(rest, o.env, o.header)).tools };
|
|
39582
39907
|
const d = diffLocks(before, after);
|
|
39583
39908
|
const mark2 = { breaking: "\u2717 BREAKING", risky: "! REVIEW ", addition: "+ ADDED ", change: "~ CHANGED " };
|
|
39584
39909
|
for (const c of d.changes)
|
|
@@ -39595,7 +39920,7 @@ ${d.summary}
|
|
|
39595
39920
|
process.stdout.write(docsFor(tools, name, target.kind === "stdio" ? { command: target.command, args: target.args } : { url: target.url }));
|
|
39596
39921
|
});
|
|
39597
39922
|
program2.command("packet").description("Turn a signed result into a printable security packet for customers' security reviews").argument("<result>", "a signed result (saktum-report.json)").option("--out <file>", "HTML packet (print to PDF from a browser)", "saktum-security-packet.html").action((file, o) => {
|
|
39598
|
-
const doc = JSON.parse(
|
|
39923
|
+
const doc = JSON.parse(readFileSync10(file, "utf8"));
|
|
39599
39924
|
const v = verifyDocument(doc);
|
|
39600
39925
|
if (!v.valid)
|
|
39601
39926
|
throw new Error(`The result's signature is not valid (${v.reason}); a packet must be built from an unaltered signed result.`);
|
|
@@ -39609,7 +39934,7 @@ ${d.summary}
|
|
|
39609
39934
|
const check = verifyLedger(entries);
|
|
39610
39935
|
if (!check.ok)
|
|
39611
39936
|
throw new Error(`The ledger does not verify: ${check.errors[0]}`);
|
|
39612
|
-
const signers = o.trustedSigners ? new Set(
|
|
39937
|
+
const signers = o.trustedSigners ? new Set(readFileSync10(o.trustedSigners, "utf8").split(/\r?\n/).map((l) => l.trim()).filter(Boolean)) : void 0;
|
|
39613
39938
|
const list2 = allowlistFromLedger(entries, { minTrust: o.minTrust.toUpperCase(), minReadiness: o.minReadiness.toUpperCase(), trustedSigners: signers });
|
|
39614
39939
|
writeFileSync5(o.out, JSON.stringify(list2, null, 2) + "\n");
|
|
39615
39940
|
process.stdout.write(`Ledger verified (${check.count} entries). Wrote ${sanitizeText(o.out)}: ${list2.allowed.length} allowed, ${list2.excluded.length} excluded.
|
|
@@ -39619,7 +39944,7 @@ ${d.summary}
|
|
|
39619
39944
|
if (!files.length)
|
|
39620
39945
|
throw new Error("Give signed results, or use --from-ledger.");
|
|
39621
39946
|
const inputs = files.map((f) => {
|
|
39622
|
-
const doc = JSON.parse(
|
|
39947
|
+
const doc = JSON.parse(readFileSync10(f, "utf8"));
|
|
39623
39948
|
const v = verifyDocument(doc);
|
|
39624
39949
|
if (!v.valid)
|
|
39625
39950
|
throw new Error(`${f}: signature not valid (${v.reason}); only unaltered signed results can be allowlisted.`);
|
|
@@ -39706,7 +40031,7 @@ ${structured ? `structured: ${sanitizeText(JSON.stringify(structured), 1e3)}
|
|
|
39706
40031
|
expect.outputSchema = true;
|
|
39707
40032
|
expect.latencyMs = { lt: Math.max(2e3, outcome.latencyMs * 5) };
|
|
39708
40033
|
const tc = { id: o.saveTest, tool: toolName, input: args, ...tool.annotations?.readOnlyHint === true ? {} : { sideEffects: true }, expect };
|
|
39709
|
-
writeFileSync5(o.tests, await appendTestCase(existsSync7(o.tests) ?
|
|
40034
|
+
writeFileSync5(o.tests, await appendTestCase(existsSync7(o.tests) ? readFileSync10(o.tests, "utf8") : void 0, tc));
|
|
39710
40035
|
process.stdout.write(`Saved test case ${sanitizeText(o.saveTest, 60)} to ${sanitizeText(o.tests)}. Run: saktum test -- <start command>
|
|
39711
40036
|
`);
|
|
39712
40037
|
}
|
|
@@ -39714,7 +40039,7 @@ ${structured ? `structured: ${sanitizeText(JSON.stringify(structured), 1e3)}
|
|
|
39714
40039
|
program2.command("scan-config").description("Check every MCP server your agents load (Claude Desktop, Claude Code, Cursor, VS Code): total context cost, duplicate tools, unvetted servers").option("--config <file>", "a specific configuration file (repeatable); default: the known locations", collect, []).option("--yes", "start the servers without asking (they run with the settings in your configuration)", false).option("--turns-per-day <n>", "agent turns a day, for the monthly cost estimate", "50").option("--price-per-mtok <usd>", "your model's price per million input tokens", "3").option("--allowlist <file>", "saktum-allowlist.json: flag servers that are not on it").option("--out <file>", "also write the analysis as JSON (input for saktum fleet)").option("--policy <file>", "your organisation's policy: show which servers violate it").option("--machine <label>", "label for this machine in fleet reports (default: the host name)").action(async (o) => {
|
|
39715
40040
|
const { homedir: homedir2 } = await import("node:os");
|
|
39716
40041
|
const locations = o.config.length ? o.config.map((file) => ({ client: "configuration", file })) : configLocations(homedir2(), process.cwd(), process.platform, process.env.APPDATA);
|
|
39717
|
-
const servers = locations.filter((l) => existsSync7(l.file)).flatMap((l) => parseClientConfig(
|
|
40042
|
+
const servers = locations.filter((l) => existsSync7(l.file)).flatMap((l) => parseClientConfig(readFileSync10(l.file, "utf8"), l.client, l.file)).filter((x) => !x.disabled);
|
|
39718
40043
|
if (!servers.length) {
|
|
39719
40044
|
process.stdout.write("No MCP servers found in the known configuration locations. Point to one with --config <file>.\n");
|
|
39720
40045
|
return;
|
|
@@ -39764,7 +40089,7 @@ ${structured ? `structured: ${sanitizeText(JSON.stringify(structured), 1e3)}
|
|
|
39764
40089
|
scans.push({ name: x.name, client: x.client, trustGrade: null, readinessGrade: null, tools: [], tokens: 0, target: x.url ? redactUrl(x.url) : redactCommand(x.command, x.args), error: sanitizeText(e.message, 120) });
|
|
39765
40090
|
}
|
|
39766
40091
|
}
|
|
39767
|
-
const allow = o.allowlist ? new Set(JSON.parse(
|
|
40092
|
+
const allow = o.allowlist ? new Set(JSON.parse(readFileSync10(o.allowlist, "utf8")).allowed.map((a) => a.toolsFingerprint).filter((f) => Boolean(f))) : void 0;
|
|
39768
40093
|
const report = analyseSetup(scans, { turnsPerDay: Number(o.turnsPerDay) || 50, pricePerMTokUsd: Number(o.pricePerMtok) || 3, allowlistFingerprints: allow });
|
|
39769
40094
|
process.stdout.write("\n" + renderSetup(report));
|
|
39770
40095
|
if (o.policy) {
|
|
@@ -39780,7 +40105,7 @@ POLICY${policy.name ? ` (${sanitizeText(policy.name, 80)})` : ""}
|
|
|
39780
40105
|
writeFileSync5(o.out, JSON.stringify({ ...report, machine: o.machine ?? hostname() }, null, 2) + "\n");
|
|
39781
40106
|
});
|
|
39782
40107
|
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) => {
|
|
39783
|
-
const r = verifyCredentialJwt(
|
|
40108
|
+
const r = verifyCredentialJwt(readFileSync10(f, "utf8"));
|
|
39784
40109
|
if (r.valid) {
|
|
39785
40110
|
const cs = r.credential.credentialSubject ?? {};
|
|
39786
40111
|
process.stdout.write(`\u2713 Valid credential from ${r.issuer}: ${sanitizeText(String(cs.server ?? ""), 80)} trust ${cs.trustGrade ?? "-"}, readiness ${cs.readinessGrade ?? "-"}.
|
|
@@ -39825,8 +40150,8 @@ ${r.errors.slice(0, 10).map((e) => ` ${sanitizeText(e, 200)}`).join("\n")}
|
|
|
39825
40150
|
`);
|
|
39826
40151
|
});
|
|
39827
40152
|
ledger.command("append").description("Append a signed attestation to a ledger file after verifying it (used by the ledger bot)").argument("<input>", "attestation JSON, or a text file (such as an issue body) containing it").requiredOption("--ledger <file>", "ledger file to append to").option("--issue <n>", "issue number that requested it").action((input, o) => {
|
|
39828
|
-
const att = extractJson(
|
|
39829
|
-
const { text: text2, entry } = appendToLedger(existsSync7(o.ledger) ?
|
|
40153
|
+
const att = extractJson(readFileSync10(input, "utf8"));
|
|
40154
|
+
const { text: text2, entry } = appendToLedger(existsSync7(o.ledger) ? readFileSync10(o.ledger, "utf8") : "", att, { via: "saktum-index issue", ...o.issue ? { issue: Number(o.issue) } : {} });
|
|
39830
40155
|
writeFileSync5(o.ledger, text2);
|
|
39831
40156
|
process.stdout.write(`Recorded entry #${entry.seq} for ${sanitizeText(entry.subject.server, 80)} (signed by ${entry.signer}); entry hash ${entry.entryHash}.
|
|
39832
40157
|
`);
|
|
@@ -39873,7 +40198,7 @@ ${r.errors.slice(0, 10).map((e) => ` ${sanitizeText(e, 200)}`).join("\n")}
|
|
|
39873
40198
|
approveAbove: aa,
|
|
39874
40199
|
disclosures: { ...o.operator ? { operator: o.operator } : {}, ...o.incentives ? { incentives: o.incentives } : {}, ...o.dataUse ? { dataUse: o.dataUse } : {} },
|
|
39875
40200
|
delegation: o.allowDelegation,
|
|
39876
|
-
...o.intent ? JSON.parse(
|
|
40201
|
+
...o.intent ? JSON.parse(readFileSync10(o.intent, "utf8")) : {}
|
|
39877
40202
|
}, loadOrCreateKey(o.key));
|
|
39878
40203
|
if (o.software) {
|
|
39879
40204
|
const { signature: _old, ...body2 } = m;
|
|
@@ -39893,7 +40218,7 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
|
|
|
39893
40218
|
`);
|
|
39894
40219
|
});
|
|
39895
40220
|
agent.command("verify").description("Check a mandate: the principal's signature, the operator's countersignature, expiry and revocation").argument("<mandate>", "mandate file").action((f) => {
|
|
39896
|
-
const m = JSON.parse(
|
|
40221
|
+
const m = JSON.parse(readFileSync10(f, "utf8"));
|
|
39897
40222
|
const c = checkMandate(m), op = checkOperator(m), rev = revocationOf(m);
|
|
39898
40223
|
process.stdout.write(c.ok ? `\u2713 Valid mandate for ${sanitizeText(m.agent.name, 80)} (${m.agent.id}), signed by ${m.owner.name ?? m.owner.id}, until ${m.expires}.
|
|
39899
40224
|
` : `\u2717 ${c.reason}
|
|
@@ -39908,7 +40233,7 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
|
|
|
39908
40233
|
exitCode = c.ok && (!op.present || op.valid) && !rev ? 0 : 1;
|
|
39909
40234
|
});
|
|
39910
40235
|
agent.command("cosign").description("As the operator (who runs the agent and is accountable), countersign a principal's mandate").argument("<mandate>", "mandate file (updated in place)").requiredOption("--name <operator>", "the operator's name").option("--key <path>", "the operator's signing key (created if missing)", "saktum-operator-key.json").action((f, o) => {
|
|
39911
|
-
const m = JSON.parse(
|
|
40236
|
+
const m = JSON.parse(readFileSync10(f, "utf8"));
|
|
39912
40237
|
if (!checkMandate(m).ok)
|
|
39913
40238
|
throw new Error("The mandate is not valid; it cannot be countersigned.");
|
|
39914
40239
|
const signed = cosignMandate(m, loadOrCreateKey(o.key), o.name);
|
|
@@ -39917,23 +40242,23 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
|
|
|
39917
40242
|
`);
|
|
39918
40243
|
});
|
|
39919
40244
|
agent.command("approve").description("As the mandate's owner, approve exactly one pending action (by its request id), for a limited time, once").argument("<request-id>", "the approval request id from the blocked call (apr_...)").requiredOption("--mandate <file>", "the mandate").option("--key <path>", "the owner's signing key (the one that signed the mandate)").option("--minutes <n>", "how long the approval stays valid", "60").option("--approvals <file>", "approvals file the proxy reads (default ~/.saktum/approvals.json)").action((rid, o) => {
|
|
39920
|
-
const m = JSON.parse(
|
|
40245
|
+
const m = JSON.parse(readFileSync10(o.mandate, "utf8"));
|
|
39921
40246
|
const a = approveAction(m, rid, loadOrCreateKey(o.key), Number(o.minutes), o.approvals);
|
|
39922
40247
|
process.stdout.write(`Approved ${sanitizeText(rid, 40)} for ${sanitizeText(m.agent.name, 80)}, valid until ${a.expires}, once. The agent can now retry exactly that action.
|
|
39923
40248
|
`);
|
|
39924
40249
|
});
|
|
39925
40250
|
agent.command("revoke").description("Stop an agent now: every Saktum proxy on this machine refuses calls under this mandate").argument("<mandate>", "mandate file").option("--reason <text>", "why").action((f, o) => {
|
|
39926
|
-
const m = JSON.parse(
|
|
40251
|
+
const m = JSON.parse(readFileSync10(f, "utf8"));
|
|
39927
40252
|
const r = revokeMandate(m, o.reason);
|
|
39928
40253
|
process.stdout.write(`Revoked the mandate for ${sanitizeText(m.agent.name, 80)} at ${r.at}. Its calls are now refused (code: revoked).
|
|
39929
40254
|
`);
|
|
39930
40255
|
});
|
|
39931
|
-
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").action(async (parts, o) => {
|
|
40256
|
+
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").action(async (parts, o) => {
|
|
39932
40257
|
const { homedir: homedir2 } = await import("node:os");
|
|
39933
|
-
const { join:
|
|
40258
|
+
const { join: join7 } = await import("node:path");
|
|
39934
40259
|
let mandate;
|
|
39935
40260
|
if (o.mandate) {
|
|
39936
|
-
mandate = JSON.parse(
|
|
40261
|
+
mandate = JSON.parse(readFileSync10(o.mandate, "utf8"));
|
|
39937
40262
|
const c = checkMandate(mandate);
|
|
39938
40263
|
if (!c.ok)
|
|
39939
40264
|
throw new Error(`Mandate refused: ${c.reason}`);
|
|
@@ -39945,16 +40270,19 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
|
|
|
39945
40270
|
exitCode = await runProxy2({
|
|
39946
40271
|
command: parts[0],
|
|
39947
40272
|
args: parts.slice(1),
|
|
39948
|
-
receiptsPath: o.receipts ??
|
|
40273
|
+
receiptsPath: o.receipts ?? join7(homedir2(), ".saktum", "receipts.jsonl"),
|
|
39949
40274
|
agentKey,
|
|
39950
40275
|
mandate,
|
|
39951
40276
|
enforce: o.enforce,
|
|
39952
40277
|
...o.revocations ? { revocationsPath: o.revocations } : {},
|
|
39953
40278
|
...o.approvals ? { approvalsPath: o.approvals } : {},
|
|
39954
|
-
...o.credential ? { credential: JSON.parse(
|
|
39955
|
-
...o.revokedCredentials ? { revokedCredentials: JSON.parse(
|
|
39956
|
-
...o.agreement ? { agreement: JSON.parse(
|
|
40279
|
+
...o.credential ? { credential: JSON.parse(readFileSync10(o.credential, "utf8")) } : {},
|
|
40280
|
+
...o.revokedCredentials ? { revokedCredentials: JSON.parse(readFileSync10(o.revokedCredentials, "utf8")) } : {},
|
|
40281
|
+
...o.agreement ? { agreement: JSON.parse(readFileSync10(o.agreement, "utf8")) } : {},
|
|
39957
40282
|
...o.wallet ? { walletPath: o.wallet } : {},
|
|
40283
|
+
...o.approvalWebhook ? { approvalWebhook: o.approvalWebhook } : {},
|
|
40284
|
+
...o.approvalUrl ? { approvalUrl: o.approvalUrl } : {},
|
|
40285
|
+
...o.bindings ? { bindingsOverride: JSON.parse(readFileSync10(o.bindings, "utf8")) } : {},
|
|
39958
40286
|
log: (m) => process.stderr.write(`saktum: ${m}
|
|
39959
40287
|
`)
|
|
39960
40288
|
});
|
|
@@ -39962,8 +40290,8 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
|
|
|
39962
40290
|
const receipts = program2.command("receipts").description("Signed receipts of agent tool calls (from saktum proxy)");
|
|
39963
40291
|
receipts.command("verify").description("Verify every receipt's signature and the hash chain").argument("[file]", "receipt log").action(async (f) => {
|
|
39964
40292
|
const { homedir: homedir2 } = await import("node:os");
|
|
39965
|
-
const { join:
|
|
39966
|
-
const r = verifyReceiptLog(parseReceiptLog(
|
|
40293
|
+
const { join: join7 } = await import("node:path");
|
|
40294
|
+
const r = verifyReceiptLog(parseReceiptLog(readFileSync10(f ?? join7(homedir2(), ".saktum", "receipts.jsonl"), "utf8")));
|
|
39967
40295
|
process.stdout.write(r.ok ? `\u2713 ${r.count} receipts verified: every signature valid, chain intact.
|
|
39968
40296
|
` : `\u2717 Receipts do NOT verify:
|
|
39969
40297
|
${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
@@ -39972,8 +40300,8 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
39972
40300
|
});
|
|
39973
40301
|
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) => {
|
|
39974
40302
|
const { homedir: homedir2 } = await import("node:os");
|
|
39975
|
-
const { join:
|
|
39976
|
-
const entries = parseReceiptLog(
|
|
40303
|
+
const { join: join7 } = await import("node:path");
|
|
40304
|
+
const entries = parseReceiptLog(readFileSync10(f ?? join7(homedir2(), ".saktum", "receipts.jsonl"), "utf8"));
|
|
39977
40305
|
const v = verifyReceiptLog(entries);
|
|
39978
40306
|
const otlp = receiptsToOtlp(entries, { verified: v.ok, version: ENGINE_VERSION });
|
|
39979
40307
|
writeFileSync5(o.otel, JSON.stringify(otlp, null, 2) + "\n");
|
|
@@ -39988,10 +40316,20 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
39988
40316
|
exitCode = 1;
|
|
39989
40317
|
}
|
|
39990
40318
|
});
|
|
40319
|
+
receipts.command("view").description("One verified view across many agents' receipt logs (for example collected in a shared folder)").argument("<files...>", "receipt logs").option("--html <file>", "output", "saktum-receipts.html").action((fs3, o) => {
|
|
40320
|
+
const logs = fs3.map((f) => {
|
|
40321
|
+
const e = parseReceiptLog(readFileSync10(f, "utf8"));
|
|
40322
|
+
return { name: f, verified: verifyReceiptLog(e).ok, entries: e.map((x) => ({ at: x.receipt.issuedAt, agent: x.receipt.envelope.caller.agent?.slice(0, 24) ?? "", tool: x.receipt.envelope.tool, outcome: x.receipt.outcome, code: x.result.code ?? "", reason: String(x.receipt.reason ?? ""), tokens: x.result.metering?.tokens ?? 0 })) };
|
|
40323
|
+
});
|
|
40324
|
+
writeFileSync5(o.html, renderReceiptsView(logs));
|
|
40325
|
+
process.stdout.write(`Combined ${logs.reduce((n, l) => n + l.entries.length, 0)} receipts from ${logs.length} log(s) into ${sanitizeText(o.html)}; ${logs.filter((l) => !l.verified).length} log(s) failed verification.
|
|
40326
|
+
`);
|
|
40327
|
+
exitCode = logs.every((l) => l.verified) ? 0 : 1;
|
|
40328
|
+
});
|
|
39991
40329
|
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) => {
|
|
39992
40330
|
const { homedir: homedir2 } = await import("node:os");
|
|
39993
|
-
const { join:
|
|
39994
|
-
const entries = parseReceiptLog(
|
|
40331
|
+
const { join: join7 } = await import("node:path");
|
|
40332
|
+
const entries = parseReceiptLog(readFileSync10(f ?? join7(homedir2(), ".saktum", "receipts.jsonl"), "utf8"));
|
|
39995
40333
|
const v = verifyReceiptLog(entries), s = summariseReceipts(entries);
|
|
39996
40334
|
if (o.json) {
|
|
39997
40335
|
process.stdout.write(JSON.stringify({ verified: v.ok, ...s }, null, 2) + "\n");
|
|
@@ -40005,11 +40343,11 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
40005
40343
|
});
|
|
40006
40344
|
program2.command("passport").description("A visual passport: for an MCP server (checks it first) or, with --agent, for an agent (mandate and receipt timeline)").argument("[target...]", "the server: https URL, or -- <command that starts it>").option("--agent <mandate>", "make an Agent Passport from this mandate instead").option("--receipts <file>", "with --agent: the agent's receipt log, for the timeline").option("--out <file>", "HTML file", "saktum-passport.html").option("--key <path>", "signing key for the server's result").option("--env <KEY=VALUE>", "environment variable for a local server (repeatable)", collect, []).option("--header <Name: value>", "HTTP header for a remote server (repeatable)", collect, []).action(async (parts, o) => {
|
|
40007
40345
|
if (o.agent) {
|
|
40008
|
-
const m = JSON.parse(
|
|
40346
|
+
const m = JSON.parse(readFileSync10(o.agent, "utf8"));
|
|
40009
40347
|
const valid = checkMandate(m);
|
|
40010
40348
|
let receipts2;
|
|
40011
40349
|
if (o.receipts) {
|
|
40012
|
-
const entries = parseReceiptLog(
|
|
40350
|
+
const entries = parseReceiptLog(readFileSync10(o.receipts, "utf8"));
|
|
40013
40351
|
const counts = /* @__PURE__ */ new Map();
|
|
40014
40352
|
for (const e of entries) {
|
|
40015
40353
|
const k = `${e.receipt.envelope.tool}|${e.receipt.envelope.argumentsHash}`;
|
|
@@ -40022,11 +40360,11 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
40022
40360
|
};
|
|
40023
40361
|
}
|
|
40024
40362
|
const rev = revocationOf(m), op = checkOperator(m);
|
|
40025
|
-
const ts = o.receipts ? trustStatement(parseReceiptLog(
|
|
40363
|
+
const ts = o.receipts ? trustStatement(parseReceiptLog(readFileSync10(o.receipts, "utf8")), receipts2?.verified ?? false) : void 0;
|
|
40026
40364
|
writeFileSync5(o.out, renderAgentPassport(m, rev ? { ok: false, reason: `Revoked on ${rev.at.slice(0, 10)}${rev.reason ? `: ${rev.reason}` : ""}` } : valid.ok ? { ok: true } : { ok: false, reason: valid.reason }, receipts2, agentRiskTier(m), describeMandate(m), {
|
|
40027
40365
|
operator: op.present && op.valid ? `${op.name} (${op.id})` : void 0,
|
|
40028
40366
|
track: ts?.lines,
|
|
40029
|
-
maturity: agentMaturity(m, { entries: o.receipts ? parseReceiptLog(
|
|
40367
|
+
maturity: agentMaturity(m, { entries: o.receipts ? parseReceiptLog(readFileSync10(o.receipts, "utf8")) : [], verified: receipts2?.verified, revoked: Boolean(rev) })
|
|
40030
40368
|
}));
|
|
40031
40369
|
process.stdout.write(`Wrote the Agent Passport for ${sanitizeText(m.agent.name, 80)} to ${sanitizeText(o.out)}. Open it in a browser.
|
|
40032
40370
|
`);
|
|
@@ -40051,7 +40389,7 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
40051
40389
|
`);
|
|
40052
40390
|
});
|
|
40053
40391
|
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) => {
|
|
40054
|
-
const list = JSON.parse(
|
|
40392
|
+
const list = JSON.parse(readFileSync10(file, "utf8"));
|
|
40055
40393
|
const packs = existsSync7(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
|
|
40056
40394
|
const r = await watchAllowlist(list.allowed ?? [], packs);
|
|
40057
40395
|
const mark2 = { unchanged: "\u2713", changed: "\u2717", degraded: "!", unreachable: "?" };
|
|
@@ -40086,21 +40424,21 @@ Total: about ${usd(r.totalSavings)} a year.
|
|
|
40086
40424
|
Assumptions: ${r.assumptions}.
|
|
40087
40425
|
`);
|
|
40088
40426
|
});
|
|
40089
|
-
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) => {
|
|
40090
|
-
const fleet = JSON.parse(
|
|
40427
|
+
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").option("--agents-inventory <file>", "agent inventory from saktum agents scan --out").action((o) => {
|
|
40428
|
+
const fleet = JSON.parse(readFileSync10(o.fleet, "utf8"));
|
|
40091
40429
|
const rec = o.receipts.map((f) => {
|
|
40092
|
-
const e = parseReceiptLog(
|
|
40430
|
+
const e = parseReceiptLog(readFileSync10(f, "utf8"));
|
|
40093
40431
|
return { agent: e[0]?.receipt.envelope.caller.agent?.slice(0, 32) ?? f, summary: summariseReceipts(e), verified: verifyReceiptLog(e).ok };
|
|
40094
40432
|
});
|
|
40095
40433
|
const distinctTokens = (fleet.servers ?? []).reduce((a, x) => a + (x.tokens ?? 0), 0);
|
|
40096
40434
|
const roi = roiEstimate({ ...ROI_DEFAULTS, tokensPerTurn: distinctTokens, agents: Number(o.agents), turnsPerDay: Number(o.turnsPerDay), pricePerMTok: Number(o.pricePerMtok), vendorReviews: Number(o.vendorReviews) });
|
|
40097
|
-
writeFileSync5(o.out, renderAssessment(o.org, fleet, rec, roi));
|
|
40435
|
+
writeFileSync5(o.out, renderAssessment(o.org, fleet, rec, roi, crosswalk().map((x) => ({ name: x.name, summary: coverageSummary(x) })), DISCLAIMER, o.agentsInventory ? JSON.parse(readFileSync10(o.agentsInventory, "utf8")) : void 0));
|
|
40098
40436
|
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.
|
|
40099
40437
|
`);
|
|
40100
40438
|
});
|
|
40101
40439
|
program2.command("fleet").description("Merge scan-config results from many machines into one organisation inventory, checked against your policy").argument("<setups...>", "JSON files written by saktum scan-config --out").option("--policy <file>", "your organisation's policy").option("--out <file>", "inventory as JSON").option("--html <file>", "inventory as an HTML page").action(async (files, o) => {
|
|
40102
40440
|
const setups = files.map((f) => {
|
|
40103
|
-
const j = JSON.parse(
|
|
40441
|
+
const j = JSON.parse(readFileSync10(f, "utf8"));
|
|
40104
40442
|
return { machine: j.machine ?? f, servers: j.servers ?? [] };
|
|
40105
40443
|
});
|
|
40106
40444
|
const pol = o.policy ? await loadPolicy(o.policy) : void 0;
|
|
@@ -40150,20 +40488,20 @@ To declare them, add to each tool's definition (MCP tools accept _meta):
|
|
|
40150
40488
|
const subject = o.subject ?? (o.subjectKey ? loadOrCreateKey(o.subjectKey).kid : void 0);
|
|
40151
40489
|
if (!subject)
|
|
40152
40490
|
throw new Error("Give --subject <did:key> or --subject-key <file>.");
|
|
40153
|
-
const c = issueCredential(JSON.parse(
|
|
40491
|
+
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 });
|
|
40154
40492
|
writeFileSync5(o.out, JSON.stringify(c, null, 2) + "\n");
|
|
40155
40493
|
process.stdout.write(`Issued ${c.id} to ${sanitizeText(o.name, 80)} (${o.type}). Chain: ${verifyChain(c).path.join(" -> ")}
|
|
40156
40494
|
`);
|
|
40157
40495
|
});
|
|
40158
40496
|
identity.command("verify").description("Walk a credential's chain to its organisation").argument("<credential>").option("--revoked <file>", "JSON list of revoked credential ids").action((f, o) => {
|
|
40159
|
-
const v = verifyChain(JSON.parse(
|
|
40497
|
+
const v = verifyChain(JSON.parse(readFileSync10(f, "utf8")), { revoked: o.revoked ? JSON.parse(readFileSync10(o.revoked, "utf8")) : [] });
|
|
40160
40498
|
process.stdout.write(v.valid ? `\u2713 ${v.path.join(" -> ")}: accountable organisation ${v.organisation}
|
|
40161
40499
|
` : `\u2717 ${v.reason}
|
|
40162
40500
|
`);
|
|
40163
40501
|
exitCode = v.valid ? 0 : 1;
|
|
40164
40502
|
});
|
|
40165
40503
|
identity.command("orphans").description("Agents whose accountability chain is broken (expired, revoked or invalid)").argument("<credentials...>").option("--revoked <file>", "JSON list of revoked credential ids").action((fs, o) => {
|
|
40166
|
-
const orphans = findOrphans(fs.map((f) => JSON.parse(
|
|
40504
|
+
const orphans = findOrphans(fs.map((f) => JSON.parse(readFileSync10(f, "utf8"))), { revoked: o.revoked ? JSON.parse(readFileSync10(o.revoked, "utf8")) : [] });
|
|
40167
40505
|
for (const x of orphans)
|
|
40168
40506
|
process.stdout.write(`\u2717 ${sanitizeText(x.agent, 80)} (${x.id}): ${x.reason}
|
|
40169
40507
|
`);
|
|
@@ -40196,16 +40534,16 @@ To declare them, add to each tool's definition (MCP tools accept _meta):
|
|
|
40196
40534
|
});
|
|
40197
40535
|
const catalog = program2.command("catalog").description("A catalogue of signed manifests, searchable by intent");
|
|
40198
40536
|
catalog.command("add").argument("<manifest>").option("--catalog <file>", "catalogue file", "saktum-catalog.json").action((f, o) => {
|
|
40199
|
-
const m = JSON.parse(
|
|
40537
|
+
const m = JSON.parse(readFileSync10(f, "utf8"));
|
|
40200
40538
|
if (!verifyDocument(m).valid)
|
|
40201
40539
|
throw new Error("The manifest's signature is not valid.");
|
|
40202
|
-
const c = existsSync7(o.catalog) ? JSON.parse(
|
|
40540
|
+
const c = existsSync7(o.catalog) ? JSON.parse(readFileSync10(o.catalog, "utf8")) : [];
|
|
40203
40541
|
writeFileSync5(o.catalog, JSON.stringify([...c.filter((x) => x.server.name !== m.server.name || x.publisher.id !== m.publisher.id), m], null, 2) + "\n");
|
|
40204
40542
|
process.stdout.write(`Added ${sanitizeText(m.server.name, 80)} by ${sanitizeText(m.publisher.name, 80)} to ${sanitizeText(o.catalog)}.
|
|
40205
40543
|
`);
|
|
40206
40544
|
});
|
|
40207
40545
|
catalog.command("search").argument("<query...>").option("--catalog <file>", "catalogue file", "saktum-catalog.json").option("--max-risk <tier>", "only servers at or below this risk tier").action((q, o) => {
|
|
40208
|
-
const res = searchCatalogue(JSON.parse(
|
|
40546
|
+
const res = searchCatalogue(JSON.parse(readFileSync10(o.catalog, "utf8")), q.join(" "), { maxRisk: o.maxRisk });
|
|
40209
40547
|
for (const r of res.slice(0, 10))
|
|
40210
40548
|
process.stdout.write(`${String(r.score).padStart(3)} ${sanitizeText(r.manifest.server.name, 40).padEnd(24)} ${sanitizeText(r.manifest.publisher.name, 40).padEnd(20)} trust ${r.manifest.quality?.trustGrade ?? "-"} \xB7 risk ${r.manifest.quality?.riskTier ?? "-"} \xB7 ${r.matched.join(", ")}
|
|
40211
40549
|
`);
|
|
@@ -40214,19 +40552,19 @@ To declare them, add to each tool's definition (MCP tools accept _meta):
|
|
|
40214
40552
|
});
|
|
40215
40553
|
const agreement = program2.command("agreement").description("Agreements between providers and invokers (smart contracts as signed documents)");
|
|
40216
40554
|
agreement.command("draft").description("As the provider, draft and sign an agreement from the default template").requiredOption("--manifest <file>").requiredOption("--invoker-name <name>").requiredOption("--invoker <did>", "the invoker organisation's id").requiredOption("--purpose <text>").option("--tools <list>", "comma-separated tools in scope").option("--tokens-per-month <n>").option("--term <text>", "a specific term (repeatable)", collect, []).option("--valid-until <date>", "YYYY-MM-DD", new Date(Date.now() + 365 * 864e5).toISOString().slice(0, 10)).option("--key <path>", "the provider's key", "saktum-publisher-key.json").option("--out <file>", "agreement file", "saktum-agreement.json").action((o) => {
|
|
40217
|
-
const a = draftAgreement({ manifest: JSON.parse(
|
|
40555
|
+
const a = draftAgreement({ manifest: JSON.parse(readFileSync10(o.manifest, "utf8")), invoker: { id: o.invoker, name: o.invokerName }, purpose: o.purpose, tools: o.tools?.split(",").map((x) => x.trim()), tokensPerMonth: o.tokensPerMonth ? Number(o.tokensPerMonth) : void 0, specificTerms: o.term, validUntil: o.validUntil }, loadOrCreateKey(o.key));
|
|
40218
40556
|
writeFileSync5(o.out, JSON.stringify(a, null, 2) + "\n");
|
|
40219
40557
|
process.stdout.write(`Drafted ${a.id} (${a.terms.length} default terms, ${a.specificTerms?.length ?? 0} specific), signed by the provider. The invoker accepts with: npx saktum agreement accept ${sanitizeText(o.out)} --key <invoker-key>
|
|
40220
40558
|
`);
|
|
40221
40559
|
});
|
|
40222
40560
|
agreement.command("accept").argument("<agreement>").requiredOption("--key <path>", "the invoker's key").action((f, o) => {
|
|
40223
|
-
const a = acceptAgreement(JSON.parse(
|
|
40561
|
+
const a = acceptAgreement(JSON.parse(readFileSync10(f, "utf8")), loadOrCreateKey(o.key));
|
|
40224
40562
|
writeFileSync5(f, JSON.stringify(a, null, 2) + "\n");
|
|
40225
40563
|
process.stdout.write(`Accepted ${a.id}: signed by both parties.
|
|
40226
40564
|
`);
|
|
40227
40565
|
});
|
|
40228
40566
|
agreement.command("verify").argument("<agreement>").action((f) => {
|
|
40229
|
-
const a = JSON.parse(
|
|
40567
|
+
const a = JSON.parse(readFileSync10(f, "utf8"));
|
|
40230
40568
|
const v = verifyAgreement(a);
|
|
40231
40569
|
process.stdout.write(v.valid ? `\u2713 ${a.id}: ${sanitizeText(a.provider.name, 80)} and ${sanitizeText(a.invoker.name, 80)}, until ${a.validUntil}.
|
|
40232
40570
|
` : `\u2717 ${v.reason}
|
|
@@ -40244,8 +40582,8 @@ To declare them, add to each tool's definition (MCP tools accept _meta):
|
|
|
40244
40582
|
});
|
|
40245
40583
|
program2.command("usage").description("A usage statement for an agreement, from the receipts (optionally signed)").requiredOption("--agreement <file>").argument("[receipts]").option("--key <path>", "sign the statement with this key").option("--out <file>").action(async (f, o) => {
|
|
40246
40584
|
const { homedir: homedir2 } = await import("node:os");
|
|
40247
|
-
const { join:
|
|
40248
|
-
const st = usageStatement(parseReceiptLog(
|
|
40585
|
+
const { join: join7 } = await import("node:path");
|
|
40586
|
+
const st = usageStatement(parseReceiptLog(readFileSync10(f ?? join7(homedir2(), ".saktum", "receipts.jsonl"), "utf8")), JSON.parse(readFileSync10(o.agreement, "utf8")), o.key ? loadOrCreateKey(o.key) : void 0);
|
|
40249
40587
|
for (const l of st.lines)
|
|
40250
40588
|
process.stdout.write(`${sanitizeText(l.tool, 60).padEnd(24)} ${String(l.calls).padStart(5)} calls ${String(l.tokens).padStart(7)} tokens
|
|
40251
40589
|
`);
|
|
@@ -40256,8 +40594,8 @@ To declare them, add to each tool's definition (MCP tools accept _meta):
|
|
|
40256
40594
|
});
|
|
40257
40595
|
program2.command("kpi").description("KPIs over receipts: calls, outcomes, approvals, tokens, latency, by tool").argument("[receipts]").option("--tool <name>").option("--agent <did>").option("--since <date>").action(async (f, o) => {
|
|
40258
40596
|
const { homedir: homedir2 } = await import("node:os");
|
|
40259
|
-
const { join:
|
|
40260
|
-
const k = kpis(parseReceiptLog(
|
|
40597
|
+
const { join: join7 } = await import("node:path");
|
|
40598
|
+
const k = kpis(parseReceiptLog(readFileSync10(f ?? join7(homedir2(), ".saktum", "receipts.jsonl"), "utf8")), o);
|
|
40261
40599
|
process.stdout.write(`Calls ${k.calls} \xB7 allowed ${k.allowed} \xB7 blocked ${k.blocked} \xB7 approved ${k.approvals} \xB7 tokens ${k.tokens} \xB7 latency p50 ${k.latencyP50 ?? "-"} ms, p95 ${k.latencyP95 ?? "-"} ms
|
|
40262
40600
|
`);
|
|
40263
40601
|
process.stdout.write(`By outcome: ${k.byOutcome.map(([c, n]) => `${c} ${n}`).join(", ")}
|
|
@@ -40265,15 +40603,123 @@ By tool: ${k.byTool.map(([c, n]) => `${c} ${n}`).join(", ")}
|
|
|
40265
40603
|
`);
|
|
40266
40604
|
});
|
|
40267
40605
|
program2.command("bounty").description("Bounties (contract only for now)").command("validate").argument("<file>").action((f) => {
|
|
40268
|
-
const ok = compileContract("bounty.schema.json")(JSON.parse(
|
|
40606
|
+
const ok = compileContract("bounty.schema.json")(JSON.parse(readFileSync10(f, "utf8")));
|
|
40269
40607
|
process.stdout.write(ok ? "\u2713 Valid bounty document.\n" : "\u2717 Not a valid bounty document.\n");
|
|
40270
40608
|
exitCode = ok ? 0 : 1;
|
|
40271
40609
|
});
|
|
40272
|
-
program2.command("
|
|
40610
|
+
program2.command("evidence").description("Saktum's evidence mapped to the frameworks you're held to (supports evidence; never a compliance claim)").option("--framework <id>", "all, eu-ai-act, nist-ai-rmf, iso-42001, owasp-llm, dora-nis2, gdpr-dpdp", "all").option("--markdown", "print as Markdown tables", false).action((o) => {
|
|
40611
|
+
const fs2 = crosswalk(o.framework);
|
|
40612
|
+
if (!fs2.length)
|
|
40613
|
+
throw new Error("Unknown framework. Use all, eu-ai-act, nist-ai-rmf, iso-42001, owasp-llm, dora-nis2 or gdpr-dpdp.");
|
|
40614
|
+
const mark2 = { covered: "\u2713 covered", partial: "\u25D0 partly", gap: "\u2013 not covered" };
|
|
40615
|
+
for (const f of fs2) {
|
|
40616
|
+
const sm = coverageSummary(f);
|
|
40617
|
+
if (o.markdown) {
|
|
40618
|
+
process.stdout.write(`## ${f.name}
|
|
40619
|
+
|
|
40620
|
+
${f.note}
|
|
40621
|
+
|
|
40622
|
+
| Ref | Obligation | Coverage | Saktum evidence | Commands |
|
|
40623
|
+
| --- | --- | --- | --- | --- |
|
|
40624
|
+
`);
|
|
40625
|
+
for (const i of f.items)
|
|
40626
|
+
process.stdout.write(`| ${i.ref} | ${i.obligation} | ${mark2[i.coverage]} | ${i.evidence} | ${i.commands.map((c) => "`" + c + "`").join(", ")} |
|
|
40627
|
+
`);
|
|
40628
|
+
process.stdout.write("\n");
|
|
40629
|
+
} else {
|
|
40630
|
+
process.stdout.write(`
|
|
40631
|
+
${f.name}: ${sm.covered} covered, ${sm.partial} partly, ${sm.gap} not covered
|
|
40632
|
+
${f.note}
|
|
40633
|
+
`);
|
|
40634
|
+
for (const i of f.items)
|
|
40635
|
+
process.stdout.write(` ${mark2[i.coverage].padEnd(15)} ${i.ref.padEnd(18)} ${i.obligation}
|
|
40636
|
+
${" ".repeat(36)}${i.evidence}${i.commands.length ? ` (${i.commands.join("; ")})` : ""}
|
|
40637
|
+
`);
|
|
40638
|
+
}
|
|
40639
|
+
}
|
|
40640
|
+
process.stdout.write(`
|
|
40641
|
+
${DISCLAIMER}
|
|
40642
|
+
`);
|
|
40643
|
+
});
|
|
40644
|
+
program2.command("bridge").description("Present a remote MCP server (Streamable HTTP) as a local one, so saktum proxy can govern it: saktum proxy ... -- saktum bridge https://host/mcp").argument("<url>", "the remote server's URL").option("--header <Name: value>", "HTTP header to send, for example Authorization (repeatable; never logged)", collect, []).action(async (url2, o) => {
|
|
40645
|
+
if (!/^https?:\/\//.test(url2))
|
|
40646
|
+
throw new Error("Give the remote server's http(s) URL.");
|
|
40647
|
+
const { runBridge: runBridge2 } = await Promise.resolve().then(() => (init_bridge(), bridge_exports));
|
|
40648
|
+
exitCode = await runBridge2(url2, parseHeaders(o.header));
|
|
40649
|
+
});
|
|
40650
|
+
const approvals = program2.command("approvals").description("Approvals by link (v0.10)");
|
|
40651
|
+
approvals.command("list").option("--approvals <file>", "approvals file").action((o) => {
|
|
40652
|
+
const p = listPending(o.approvals);
|
|
40653
|
+
for (const x of p)
|
|
40654
|
+
process.stdout.write(`${x.id} ${sanitizeText(x.agent, 40)} ${sanitizeText(x.tool, 40)} ${sanitizeText(x.reason, 160)} (${x.at.slice(0, 16).replace("T", " ")})
|
|
40655
|
+
`);
|
|
40656
|
+
process.stdout.write(`${p.length} waiting.
|
|
40657
|
+
`);
|
|
40658
|
+
});
|
|
40659
|
+
approvals.command("serve").description("A local page where the mandate's owner approves exactly one pending action with their key").requiredOption("--mandate <file>").option("--key <path>", "the owner's key (file, env:VAR or keychain:NAME)").option("--approvals <file>", "approvals file shared with the proxy").option("--port <n>", "port", "8787").option("--host <host>", "interface to listen on", "127.0.0.1").option("--minutes <n>", "approval validity", "60").action(async (o) => {
|
|
40660
|
+
const http = await import("node:http");
|
|
40661
|
+
const { randomBytes } = await import("node:crypto");
|
|
40662
|
+
const m = JSON.parse(readFileSync10(o.mandate, "utf8"));
|
|
40663
|
+
const key = loadOrCreateKey(o.key);
|
|
40664
|
+
const token = randomBytes(16).toString("hex");
|
|
40665
|
+
if (key.kid !== m.owner.id)
|
|
40666
|
+
throw new Error("This key is not the mandate owner's key.");
|
|
40667
|
+
const esc22 = (x) => String(x).replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
40668
|
+
const pageOf = (body2) => `<!doctype html><meta name="viewport" content="width=device-width, initial-scale=1"><title>Saktum approvals</title><body style="font:15px system-ui;max-width:760px;margin:24px auto;padding:0 16px"><h1>Approvals for ${esc22(m.agent.name)}</h1>${body2}</body>`;
|
|
40669
|
+
const server = http.createServer((req, res) => {
|
|
40670
|
+
const u = new URL(req.url ?? "/", `http://${req.headers.host}`);
|
|
40671
|
+
if (u.searchParams.get("token") !== token) {
|
|
40672
|
+
res.writeHead(403);
|
|
40673
|
+
res.end("Forbidden");
|
|
40674
|
+
return;
|
|
40675
|
+
}
|
|
40676
|
+
if (req.method === "POST") {
|
|
40677
|
+
let b = "";
|
|
40678
|
+
req.on("data", (c) => {
|
|
40679
|
+
b += c;
|
|
40680
|
+
if (b.length > 2e3)
|
|
40681
|
+
req.destroy();
|
|
40682
|
+
});
|
|
40683
|
+
req.on("end", () => {
|
|
40684
|
+
const id = new URLSearchParams(b).get("id") ?? "";
|
|
40685
|
+
if (!listPending(o.approvals).some((p2) => p2.id === id)) {
|
|
40686
|
+
res.writeHead(400, { "Content-Type": "text/html" });
|
|
40687
|
+
res.end(pageOf(`<p>No pending request ${esc22(id)}.</p>`));
|
|
40688
|
+
return;
|
|
40689
|
+
}
|
|
40690
|
+
approveAction(m, id, key, Number(o.minutes), o.approvals);
|
|
40691
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
40692
|
+
res.end(pageOf(`<p>\u2713 Approved <code>${esc22(id)}</code>, once, for ${esc22(o.minutes)} minutes. The agent can retry exactly that action.</p><p><a href="/?token=${token}">Back</a></p>`));
|
|
40693
|
+
});
|
|
40694
|
+
return;
|
|
40695
|
+
}
|
|
40696
|
+
const only = u.searchParams.get("id");
|
|
40697
|
+
const p = listPending(o.approvals).filter((x) => !only || x.id === only);
|
|
40698
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
40699
|
+
res.end(pageOf(p.length ? p.map((x) => `<form method="post" action="/?token=${token}" style="border:1px solid #ddd;border-radius:12px;padding:12px;margin:10px 0"><b>${esc22(x.tool)}</b> <code>${esc22(x.id)}</code><p>${esc22(x.reason)}</p><small>${esc22(x.at)}</small><input type="hidden" name="id" value="${esc22(x.id)}"><p><button type="submit">Approve exactly this action, once</button></p></form>`).join("") : "<p>Nothing is waiting for approval.</p>"));
|
|
40700
|
+
});
|
|
40701
|
+
server.listen(Number(o.port), o.host, () => process.stdout.write(`Approvals page: http://${o.host}:${o.port}/?token=${token}
|
|
40702
|
+
Give the proxy --approval-url "http://${o.host}:${o.port}/?token=${token}" so requests carry a one-click link. Ctrl+C to stop.
|
|
40703
|
+
`));
|
|
40704
|
+
await new Promise(() => void 0);
|
|
40705
|
+
});
|
|
40706
|
+
program2.command("agents").description("Agent inventory (v0.10)").command("scan").argument("[dirs...]", "folders to search for agent mandates (default: this folder and ~/.saktum)").option("--out <file>", "write the inventory as JSON (for saktum assess --agents)").action(async (dirs, o) => {
|
|
40707
|
+
const { homedir: homedir2 } = await import("node:os");
|
|
40708
|
+
const { join: join7 } = await import("node:path");
|
|
40709
|
+
const a = scanAgents(dirs.length ? dirs : [".", join7(homedir2(), ".saktum")]);
|
|
40710
|
+
for (const x of a)
|
|
40711
|
+
process.stdout.write(`${x.revoked ? "\u26D4" : x.valid ? "\u2713" : "\u2717"} ${sanitizeText(x.name, 40).padEnd(26)} owner ${sanitizeText(x.owner, 30).padEnd(16)} ${x.operator ? "operator " + sanitizeText(x.operator, 30) : "no operator"} \xB7 ${x.autonomy} \xB7 ${x.riskTier} \xB7 ${x.maturity}
|
|
40712
|
+
`);
|
|
40713
|
+
process.stdout.write(`${a.length} agent(s); ${a.filter((x) => !x.operator).length} without an operator countersignature; ${a.filter((x) => x.revoked).length} revoked.
|
|
40714
|
+
`);
|
|
40715
|
+
if (o.out)
|
|
40716
|
+
writeFileSync5(o.out, JSON.stringify(a, null, 2) + "\n");
|
|
40717
|
+
});
|
|
40718
|
+
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) => {
|
|
40273
40719
|
const { runDemo: runDemo2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
|
|
40274
40720
|
await runDemo2(o.out, (l) => process.stdout.write(l + "\n"), o.story);
|
|
40275
40721
|
});
|
|
40276
|
-
program2.command("demo-server", { hidden: true }).description("The demo MCP servers (used by saktum demo)").option("--story <name>", "grocery, travel, finance or autonomy", "autonomy").action(async (o) => {
|
|
40722
|
+
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) => {
|
|
40277
40723
|
const { startDemoServer: startDemoServer2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
|
|
40278
40724
|
await startDemoServer2(o.story);
|
|
40279
40725
|
});
|
|
@@ -40283,7 +40729,7 @@ By tool: ${k.byTool.map(([c, n]) => `${c} ${n}`).join(", ")}
|
|
|
40283
40729
|
await startMcpServer2(packs);
|
|
40284
40730
|
});
|
|
40285
40731
|
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) => {
|
|
40286
|
-
const doc = JSON.parse(
|
|
40732
|
+
const doc = JSON.parse(readFileSync10(file, "utf8"));
|
|
40287
40733
|
const v = verifyDocument(doc);
|
|
40288
40734
|
if (!v.valid)
|
|
40289
40735
|
throw new Error(`The result's signature is not valid (${v.reason}); attestations are built only from unaltered signed results.`);
|
|
@@ -40326,7 +40772,7 @@ ${url2}
|
|
|
40326
40772
|
exitCode = r.code;
|
|
40327
40773
|
});
|
|
40328
40774
|
program2.command("verify").description("Verify a signed Saktum Check result").argument("<file>").action((file) => {
|
|
40329
|
-
const doc = JSON.parse(
|
|
40775
|
+
const doc = JSON.parse(readFileSync10(file, "utf8"));
|
|
40330
40776
|
const validate2 = compileContract("result.schema.json");
|
|
40331
40777
|
if (!validate2(doc)) {
|
|
40332
40778
|
process.stdout.write(`Invalid result format: ${JSON.stringify(validate2.errors?.slice(0, 2))}
|