saktum 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/saktum.mjs +46 -12
package/README.md
CHANGED
|
@@ -209,7 +209,7 @@ servers not on your allowlist, and the weakest grades. Configured secrets are ne
|
|
|
209
209
|
|
|
210
210
|
```yaml
|
|
211
211
|
- uses: actions/checkout@v4
|
|
212
|
-
- uses: soodhere/saktum-check@v0.8.
|
|
212
|
+
- uses: soodhere/saktum-check@v0.8.1
|
|
213
213
|
with:
|
|
214
214
|
target: "-- node build/index.js" # or an https URL
|
|
215
215
|
args: "--active --tests saktum.tests.yaml" # optional; --active only for your own server
|
package/package.json
CHANGED
package/saktum.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Saktum Check 0.8.
|
|
2
|
+
// Saktum Check 0.8.1 (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;
|
|
@@ -33996,7 +33996,7 @@ var init_dist3 = __esm({
|
|
|
33996
33996
|
init_stdio2();
|
|
33997
33997
|
init_streamableHttp();
|
|
33998
33998
|
init_types2();
|
|
33999
|
-
USER_AGENT = "saktum-check/0.8.
|
|
33999
|
+
USER_AGENT = "saktum-check/0.8.1 (+https://saktum.dev/check)";
|
|
34000
34000
|
LIMITS = { requestTimeoutMs: 1e4, connectTimeoutMs: 6e4, maxResponseChars: 5e6 };
|
|
34001
34001
|
LimitError = class extends Error {
|
|
34002
34002
|
};
|
|
@@ -34034,7 +34034,7 @@ var init_dist3 = __esm({
|
|
|
34034
34034
|
jsonrpc: "2.0",
|
|
34035
34035
|
id: 1,
|
|
34036
34036
|
method: "initialize",
|
|
34037
|
-
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.8.
|
|
34037
|
+
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.8.1" } }
|
|
34038
34038
|
});
|
|
34039
34039
|
}
|
|
34040
34040
|
});
|
|
@@ -35406,7 +35406,7 @@ var init_engine = __esm({
|
|
|
35406
35406
|
init_runner();
|
|
35407
35407
|
init_safe();
|
|
35408
35408
|
init_scoring();
|
|
35409
|
-
ENGINE_VERSION = "0.8.
|
|
35409
|
+
ENGINE_VERSION = "0.8.1";
|
|
35410
35410
|
UNKNOWN_TOOL = "saktum_trust_check_no_such_tool";
|
|
35411
35411
|
INVALID_TOKEN = "saktum-check-deliberately-invalid-token";
|
|
35412
35412
|
baseOf = (pack, check) => ({
|
|
@@ -36413,6 +36413,29 @@ function consumeApproval(m, requestId, path = DEFAULT_APPROVALS()) {
|
|
|
36413
36413
|
}
|
|
36414
36414
|
return { ok: false };
|
|
36415
36415
|
}
|
|
36416
|
+
function agentMaturity(m, o = {}) {
|
|
36417
|
+
const op = checkOperator(m);
|
|
36418
|
+
const tier = agentRiskTier(m).tier;
|
|
36419
|
+
const bounded = Boolean(m.allow.tools?.length || m.actions?.length) && m.delegation !== true && (!(tier === "R3" || tier === "R4") || Boolean(m.constraints?.length || m.approveAbove || m.rules?.length || m.approvalTriggers?.length || m.autonomy === "propose" || m.autonomy === "notify"));
|
|
36420
|
+
const entries = o.entries ?? [];
|
|
36421
|
+
const actions = entries.filter((e) => e.receipt.outcome === "allow" && e.result.status === "ok").length;
|
|
36422
|
+
const outside = entries.filter((e) => String(e.result.code ?? "").startsWith("observed-")).length;
|
|
36423
|
+
const explained = entries.length > 0 && o.verified === true && entries.every((e) => Boolean(e.result.code));
|
|
36424
|
+
const steps = [
|
|
36425
|
+
{ level: 1, name: "Identified", met: checkMandate(m).ok, why: "its own identity and a valid mandate signed by its owner" },
|
|
36426
|
+
{ level: 2, name: "Accountable", met: op.present && op.valid || o.chainValid === true, why: "an operator countersignature or an identity chain to an organisation" },
|
|
36427
|
+
{ level: 3, name: "Bounded", met: bounded, why: "explicit tools or action classes, no sub-delegation, and caps or approvals when it can act irreversibly or spend" },
|
|
36428
|
+
{ level: 4, name: "Explained", met: explained, why: "signed, verified receipts with a reason for every decision" },
|
|
36429
|
+
{ level: 5, name: "Proven", met: actions >= 10 && outside === 0 && !o.revoked && explained, why: `a track record of at least 10 actions, none outside its mandate (${actions} so far)` }
|
|
36430
|
+
];
|
|
36431
|
+
let level = 0;
|
|
36432
|
+
for (const st of steps) {
|
|
36433
|
+
if (!st.met)
|
|
36434
|
+
break;
|
|
36435
|
+
level = st.level;
|
|
36436
|
+
}
|
|
36437
|
+
return { level, label: level ? `A${level} ${steps[level - 1].name}` : "Not yet identified", steps };
|
|
36438
|
+
}
|
|
36416
36439
|
var FIELD_LABEL, ruleText, DEFAULT_REVOCATIONS, readRevocations, DEFAULT_APPROVALS, readApprovals;
|
|
36417
36440
|
var init_agentid = __esm({
|
|
36418
36441
|
"packages/testkit-core/dist/agentid.js"() {
|
|
@@ -36866,6 +36889,7 @@ __export(dist_exports, {
|
|
|
36866
36889
|
VOCABULARIES: () => VOCABULARIES,
|
|
36867
36890
|
acceptAgreement: () => acceptAgreement,
|
|
36868
36891
|
actionClass: () => actionClass,
|
|
36892
|
+
agentMaturity: () => agentMaturity,
|
|
36869
36893
|
agentRiskTier: () => agentRiskTier,
|
|
36870
36894
|
allowlistFromLedger: () => allowlistFromLedger,
|
|
36871
36895
|
analyseSetup: () => analyseSetup,
|
|
@@ -37071,7 +37095,9 @@ function renderAgentPassport(m, valid, receipts, tier, plain, extra = {}) {
|
|
|
37071
37095
|
const steps = (receipts?.timeline ?? []).slice(0, 80).map((t) => `<span class="step ${t.outcome === "deny" ? "deny" : t.status === "ok" ? "ok" : "err"}${t.repeated ? " rep" : ""}" title="${esc2(t.outcome)} \xB7 ${esc2(t.status)}">${t.outcome === "deny" ? "\u26D4" : t.status === "ok" ? "\u2713" : "!"} ${esc2(t.tool)}</span>`).join('<span class="muted">\u2192</span>');
|
|
37072
37096
|
const body2 = `<div class="card"><div class="top"><div class="seal" style="background:${valid.ok ? "#5a3fc0" : "#c62828"}">AI</div>
|
|
37073
37097
|
<div><small>AGENT PASSPORT</small><h1>${esc2(m.agent.name)}</h1><div class="muted">acts for ${esc2(m.owner.name ?? m.owner.id)}${m.purpose ? ` \xB7 ${esc2(m.purpose)}` : ""}</div></div></div>
|
|
37074
|
-
<div class="chips">${chip("Mandate", valid.ok ? "valid" : "not valid", valid.ok ? "#2e7d32" : "#c62828")}${chip("Expires", m.expires)}${chip("Destructive actions", m.allow.destructive ? "allowed" : "not allowed")}${tier ? chip("Risk", `${tier.tier}`, tier.tier === "R4" ? "#b7791f" : void 0) : ""}${s ? chip("Receipts", receipts.verified ? "verified" : "DO NOT verify", receipts.verified ? "#2e7d32" : "#c62828") : ""}</div>${valid.ok ? "" : `<p><b>${esc2(valid.reason)}</b></p>`}</div>
|
|
37098
|
+
<div class="chips">${chip("Mandate", valid.ok ? "valid" : "not valid", valid.ok ? "#2e7d32" : "#c62828")}${chip("Expires", m.expires)}${chip("Destructive actions", m.allow.destructive ? "allowed" : "not allowed")}${extra.maturity ? chip("Maturity", extra.maturity.label, "#5a3fc0") : ""}${tier ? chip("Risk", `${tier.tier}`, tier.tier === "R4" ? "#b7791f" : void 0) : ""}${s ? chip("Receipts", receipts.verified ? "verified" : "DO NOT verify", receipts.verified ? "#2e7d32" : "#c62828") : ""}</div>${valid.ok ? "" : `<p><b>${esc2(valid.reason)}</b></p>`}</div>
|
|
37099
|
+
${extra.maturity ? `<div class="card"><h2>Maturity</h2><div class="levels">${[1, 2, 3, 4, 5].map((l) => `<div class="lv${l <= extra.maturity.level ? " on" : ""}">A${l}</div>`).join("")}</div><small>${esc2(extra.maturity.label)} \xB7 earned from evidence, never a score</small>
|
|
37100
|
+
<div class="wrap" style="margin-top:8px"><table>${extra.maturity.steps.map((st) => `<tr><td>${st.met ? "\u2713" : "\u2013"} <b>A${st.level} ${esc2(st.name)}</b></td><td>${esc2(st.why)}</td></tr>`).join("")}</table></div></div>` : ""}
|
|
37075
37101
|
${extra.track?.length ? `<div class="card"><h2>Track record</h2>${extra.track.map((l) => `<p style="margin:4px 0">${esc2(l)}</p>`).join("")}<p class="muted">A statement from its signed receipts, not a score.</p></div>` : ""}
|
|
37076
37102
|
${plain?.length ? `<div class="card"><h2>Its instructions, in plain words</h2>${plain.map((l) => `<p style="margin:4px 0">${esc2(l)}</p>`).join("")}</div>` : ""}
|
|
37077
37103
|
<div class="card"><h2>Permissions</h2><div class="wrap"><table>${perms}</table></div>${tier ? `<p class="muted">Risk tier ${esc2(tier.tier)}: ${esc2(tier.note)}.</p>` : ""}</div>
|
|
@@ -38656,10 +38682,14 @@ async function runStory(dir, st, owner, log) {
|
|
|
38656
38682
|
verified: verifyReceiptLog(entries).ok,
|
|
38657
38683
|
summary: summariseReceipts(entries),
|
|
38658
38684
|
timeline: entries.map((e) => ({ tool: e.receipt.envelope.tool, outcome: e.receipt.outcome, status: e.result.status, repeated: false, why: [e.receipt.reason ?? "", ...e.result.rationale?.preferences ?? [], ...e.result.rationale?.flags ?? []].filter(Boolean).join(" \xB7 ") }))
|
|
38659
|
-
}, agentRiskTier(m), describeMandate(m), {
|
|
38660
|
-
|
|
38661
|
-
|
|
38662
|
-
|
|
38685
|
+
}, agentRiskTier(m), describeMandate(m), {
|
|
38686
|
+
operator: (() => {
|
|
38687
|
+
const op = checkOperator(cm);
|
|
38688
|
+
return op.present && op.valid ? `${op.name} (${op.id})` : void 0;
|
|
38689
|
+
})(),
|
|
38690
|
+
track: ts.lines,
|
|
38691
|
+
maturity: agentMaturity(cm, { entries, verified: verifyReceiptLog(entries).ok })
|
|
38692
|
+
}));
|
|
38663
38693
|
log(` ${entries.length} signed receipts \xB7 ${verifyReceiptLog(entries).ok ? "verified" : "NOT verified"} \xB7 passport: ${html}
|
|
38664
38694
|
`);
|
|
38665
38695
|
return html;
|
|
@@ -38700,7 +38730,7 @@ async function runMarketplace(dir, log) {
|
|
|
38700
38730
|
const wf = join5(dir, "market-wallet.json");
|
|
38701
38731
|
topUp(wf, acme.kid, 12);
|
|
38702
38732
|
log(` \u2713 Acme tops up 12 prepaid tokens (bought outside Saktum; no money is handled here)`);
|
|
38703
|
-
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" }, priya), acme, "Acme Corp");
|
|
38733
|
+
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");
|
|
38704
38734
|
const mf = w("market-mandate.json", m), rf = join5(dir, "market-receipts.jsonl"), revf = join5(dir, "market-revoked-credentials.json");
|
|
38705
38735
|
writeFileSync4(revf, "[]");
|
|
38706
38736
|
const open2 = () => connect({ kind: "stdio", command: process.execPath, args: [
|
|
@@ -38767,7 +38797,7 @@ async function runMarketplace(dir, log) {
|
|
|
38767
38797
|
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`);
|
|
38768
38798
|
const html = join5(dir, "marketplace-passport.html");
|
|
38769
38799
|
const ts = trustStatement(all, verifyReceiptLog(all).ok);
|
|
38770
|
-
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 }));
|
|
38800
|
+
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 }) }));
|
|
38771
38801
|
log(` ${all.length} signed receipts \xB7 ${verifyReceiptLog(all).ok ? "verified" : "NOT verified"} \xB7 passport: ${html}
|
|
38772
38802
|
`);
|
|
38773
38803
|
return html;
|
|
@@ -39993,7 +40023,11 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
39993
40023
|
}
|
|
39994
40024
|
const rev = revocationOf(m), op = checkOperator(m);
|
|
39995
40025
|
const ts = o.receipts ? trustStatement(parseReceiptLog(readFileSync9(o.receipts, "utf8")), receipts2?.verified ?? false) : void 0;
|
|
39996
|
-
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), {
|
|
40026
|
+
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
|
+
operator: op.present && op.valid ? `${op.name} (${op.id})` : void 0,
|
|
40028
|
+
track: ts?.lines,
|
|
40029
|
+
maturity: agentMaturity(m, { entries: o.receipts ? parseReceiptLog(readFileSync9(o.receipts, "utf8")) : [], verified: receipts2?.verified, revoked: Boolean(rev) })
|
|
40030
|
+
}));
|
|
39997
40031
|
process.stdout.write(`Wrote the Agent Passport for ${sanitizeText(m.agent.name, 80)} to ${sanitizeText(o.out)}. Open it in a browser.
|
|
39998
40032
|
`);
|
|
39999
40033
|
return;
|