saktum 0.12.0 → 0.14.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 +22 -1
- package/package.json +1 -1
- package/saktum.mjs +312 -39
package/README.md
CHANGED
|
@@ -11,6 +11,27 @@ npx saktum check https://your-server.example/mcp # a remote server (sign-in
|
|
|
11
11
|
|
|
12
12
|
Runs on your machine. Nothing is uploaded. Your own environment variables are never passed to the server.
|
|
13
13
|
|
|
14
|
+
## Industry-ready governance (v0.14)
|
|
15
|
+
|
|
16
|
+
- **Resource-scoped credentials:** `identity issue --where legal.case_id=C-7731` limits an agent to the cases (or
|
|
17
|
+
accounts, patients, tickets) it is assigned; scope can only narrow down the chain, and the proxy enforces it.
|
|
18
|
+
- **Required fields per action class:** a rule such as `{ "field": "legal.citation", "op": "present", "actions":
|
|
19
|
+
["communicate"] }` refuses client messages that cite no source.
|
|
20
|
+
- **Supervised autonomy:** `"review": { "sample": 0.2, "actions": ["change"] }` lets an agent act while a share of its
|
|
21
|
+
actions is queued for human review (`saktum receipts review receipts.jsonl`).
|
|
22
|
+
- **Legal vocabulary** and `npx saktum demo --story legal`; see the legal-tech industry demo on the website.
|
|
23
|
+
|
|
24
|
+
## Close the nine gaps (v0.13)
|
|
25
|
+
|
|
26
|
+
Saktum now addresses all nine common agent security gaps at the tool layer: **task-scoped, short-lived agent
|
|
27
|
+
credentials** (`identity issue --minutes 30 --tools search,pay`) whose scope can only narrow down the chain, with a
|
|
28
|
+
**delegation-depth limit**; a **secret guard** that refuses calls carrying keys or tokens (never recording them); a
|
|
29
|
+
**result guard** that flags instructions aimed at the agent in tool results, or withholds them with
|
|
30
|
+
`--quarantine-results`; and **output digests** in every receipt. The evidence crosswalk adds **ISO/IEC 27001** and
|
|
31
|
+
Canada's **OSFI E-23** (and lists California SB 53 as not applicable). New story: `npx saktum demo --story support`.
|
|
32
|
+
Boundaries: issuing third-party API tokens belongs to the gateway; Saktum guards what passes through tools, not the
|
|
33
|
+
model's context.
|
|
34
|
+
|
|
14
35
|
## Trust you can verify (v0.12)
|
|
15
36
|
|
|
16
37
|
Saktum holds itself to the standard it asks of others. Revocations are signed and stick (receipt chain, optional remote
|
|
@@ -245,7 +266,7 @@ servers not on your allowlist, and the weakest grades. Configured secrets are ne
|
|
|
245
266
|
|
|
246
267
|
```yaml
|
|
247
268
|
- uses: actions/checkout@v4
|
|
248
|
-
- uses: soodhere/saktum-check@v0.
|
|
269
|
+
- uses: soodhere/saktum-check@v0.14.0
|
|
249
270
|
with:
|
|
250
271
|
target: "-- node build/index.js" # or an https URL
|
|
251
272
|
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.
|
|
2
|
+
// Saktum Check 0.14.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;
|
|
@@ -19516,8 +19516,7 @@ var init_embedded = __esm({
|
|
|
19516
19516
|
"additionalProperties": false,
|
|
19517
19517
|
"required": [
|
|
19518
19518
|
"field",
|
|
19519
|
-
"op"
|
|
19520
|
-
"value"
|
|
19519
|
+
"op"
|
|
19521
19520
|
],
|
|
19522
19521
|
"properties": {
|
|
19523
19522
|
"field": {
|
|
@@ -19526,17 +19525,24 @@ var init_embedded = __esm({
|
|
|
19526
19525
|
},
|
|
19527
19526
|
"op": {
|
|
19528
19527
|
"enum": [
|
|
19529
|
-
"max",
|
|
19530
|
-
"min",
|
|
19531
19528
|
"eq",
|
|
19532
19529
|
"in",
|
|
19533
|
-
"
|
|
19530
|
+
"max",
|
|
19531
|
+
"min",
|
|
19532
|
+
"notIn",
|
|
19533
|
+
"present"
|
|
19534
19534
|
]
|
|
19535
19535
|
},
|
|
19536
19536
|
"value": {},
|
|
19537
19537
|
"label": {
|
|
19538
19538
|
"type": "string",
|
|
19539
19539
|
"maxLength": 200
|
|
19540
|
+
},
|
|
19541
|
+
"actions": {
|
|
19542
|
+
"type": "array",
|
|
19543
|
+
"items": {
|
|
19544
|
+
"type": "string"
|
|
19545
|
+
}
|
|
19540
19546
|
}
|
|
19541
19547
|
}
|
|
19542
19548
|
}
|
|
@@ -19642,6 +19648,26 @@ var init_embedded = __esm({
|
|
|
19642
19648
|
"operatorCountersign": {
|
|
19643
19649
|
"type": "object",
|
|
19644
19650
|
"description": "The operator's signed statement over the mandate digest (role, name, mandate, at, signature)"
|
|
19651
|
+
},
|
|
19652
|
+
"review": {
|
|
19653
|
+
"type": "object",
|
|
19654
|
+
"properties": {
|
|
19655
|
+
"sample": {
|
|
19656
|
+
"type": "number",
|
|
19657
|
+
"minimum": 0,
|
|
19658
|
+
"maximum": 1
|
|
19659
|
+
},
|
|
19660
|
+
"actions": {
|
|
19661
|
+
"type": "array",
|
|
19662
|
+
"items": {
|
|
19663
|
+
"type": "string"
|
|
19664
|
+
}
|
|
19665
|
+
}
|
|
19666
|
+
},
|
|
19667
|
+
"required": [
|
|
19668
|
+
"sample"
|
|
19669
|
+
],
|
|
19670
|
+
"additionalProperties": false
|
|
19645
19671
|
}
|
|
19646
19672
|
}
|
|
19647
19673
|
}
|
|
@@ -34057,7 +34083,7 @@ var init_dist3 = __esm({
|
|
|
34057
34083
|
init_stdio2();
|
|
34058
34084
|
init_streamableHttp();
|
|
34059
34085
|
init_types2();
|
|
34060
|
-
USER_AGENT = "saktum-check/0.
|
|
34086
|
+
USER_AGENT = "saktum-check/0.14.0 (+https://saktum.dev/check)";
|
|
34061
34087
|
LIMITS = { requestTimeoutMs: 1e4, connectTimeoutMs: 6e4, maxResponseChars: 5e6 };
|
|
34062
34088
|
LimitError = class extends Error {
|
|
34063
34089
|
};
|
|
@@ -34095,7 +34121,7 @@ var init_dist3 = __esm({
|
|
|
34095
34121
|
jsonrpc: "2.0",
|
|
34096
34122
|
id: 1,
|
|
34097
34123
|
method: "initialize",
|
|
34098
|
-
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.
|
|
34124
|
+
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.14.0" } }
|
|
34099
34125
|
});
|
|
34100
34126
|
}
|
|
34101
34127
|
});
|
|
@@ -35467,7 +35493,7 @@ var init_engine = __esm({
|
|
|
35467
35493
|
init_runner();
|
|
35468
35494
|
init_safe();
|
|
35469
35495
|
init_scoring();
|
|
35470
|
-
ENGINE_VERSION = "0.
|
|
35496
|
+
ENGINE_VERSION = "0.14.0";
|
|
35471
35497
|
UNKNOWN_TOOL = "saktum_trust_check_no_such_tool";
|
|
35472
35498
|
INVALID_TOKEN = "saktum-check-deliberately-invalid-token";
|
|
35473
35499
|
baseOf = (pack, check) => ({
|
|
@@ -36111,6 +36137,18 @@ var init_vocab = __esm({
|
|
|
36111
36137
|
{ path: "code.repository", type: "string", description: "The code repository" },
|
|
36112
36138
|
{ path: "code.environment", type: "string", description: "The deployment environment (for example staging, production)" }
|
|
36113
36139
|
] };
|
|
36140
|
+
VOCABULARIES.support = { version: "0.1", fields: [
|
|
36141
|
+
{ path: "support.customer_id", type: "string", description: "The customer a support case is about" },
|
|
36142
|
+
{ path: "support.amount", type: "number", description: "A refund or credit amount" }
|
|
36143
|
+
] };
|
|
36144
|
+
VOCABULARIES.legal = { version: "0.1", fields: [
|
|
36145
|
+
{ path: "legal.case_id", type: "string", description: "The legal matter (case) an action concerns" },
|
|
36146
|
+
{ path: "legal.client_id", type: "string", description: "The client the matter is for" },
|
|
36147
|
+
{ path: "legal.practice_area", type: "string", description: "Practice area, e.g. economic immigration, family sponsorship" },
|
|
36148
|
+
{ path: "legal.document_type", type: "string", description: "Type of document, e.g. passport, language test, reference letter" },
|
|
36149
|
+
{ path: "legal.citation", type: "string", description: "Source cited for a statement: rule version, official page or case evidence" },
|
|
36150
|
+
{ path: "legal.rule_version", type: "string", description: "Version of the rule pack used for a score or eligibility result" }
|
|
36151
|
+
] };
|
|
36114
36152
|
KNOWN_FIELDS = new Set(Object.values(VOCABULARIES).flatMap((v) => v.fields.map((f) => f.path)));
|
|
36115
36153
|
NAME_RULES = [
|
|
36116
36154
|
[/(^|[_-])(search|find|list|get|lookup|deals|browse)([_-]|$)/i, "search"],
|
|
@@ -36253,7 +36291,8 @@ function createMandate(o, ownerKey) {
|
|
|
36253
36291
|
...o.upsell ? { upsell: o.upsell } : {},
|
|
36254
36292
|
...o.approvalTriggers?.length ? { approvalTriggers: o.approvalTriggers } : {},
|
|
36255
36293
|
...o.counterparties?.length ? { counterparties: o.counterparties } : {},
|
|
36256
|
-
...o.dataSharing?.length ? { dataSharing: o.dataSharing } : {}
|
|
36294
|
+
...o.dataSharing?.length ? { dataSharing: o.dataSharing } : {},
|
|
36295
|
+
...o.review && o.review.sample > 0 ? { review: { sample: Math.min(1, o.review.sample), ...o.review.actions?.length ? { actions: o.review.actions } : {} } } : {}
|
|
36257
36296
|
};
|
|
36258
36297
|
return signDocument(body2, ownerKey);
|
|
36259
36298
|
}
|
|
@@ -36338,6 +36377,15 @@ function decideIntent(m, tool, args, ctx = {}) {
|
|
|
36338
36377
|
if (auto === "notify" && cls !== "search")
|
|
36339
36378
|
return stop("notify-only", `only alerts for ${cls}: tell your user instead`);
|
|
36340
36379
|
for (const rule of m.rules ?? []) {
|
|
36380
|
+
if (rule.actions && !rule.actions.includes(cls))
|
|
36381
|
+
continue;
|
|
36382
|
+
if (rule.op === "present") {
|
|
36383
|
+
const ok2 = rule.field in v && String(v[rule.field] ?? "").trim() !== "";
|
|
36384
|
+
r.evaluated.push({ rule: ruleText(rule), ok: ok2 });
|
|
36385
|
+
if (!ok2)
|
|
36386
|
+
return stop("rule-violated", ruleText(rule));
|
|
36387
|
+
continue;
|
|
36388
|
+
}
|
|
36341
36389
|
if (!(rule.field in v))
|
|
36342
36390
|
continue;
|
|
36343
36391
|
const x = v[rule.field];
|
|
@@ -36580,7 +36628,7 @@ var init_agentid = __esm({
|
|
|
36580
36628
|
init_safe();
|
|
36581
36629
|
init_receipts();
|
|
36582
36630
|
FIELD_LABEL = (f) => VOCABULARIES[f.split(".")[0]]?.fields.find((x) => x.path === f)?.description.toLowerCase() ?? f;
|
|
36583
|
-
ruleText = (r) => r.label ?? (r.op === "max" ? `${FIELD_LABEL(r.field)} at most ${r.value}` : r.op === "min" ? `${FIELD_LABEL(r.field)} at least ${r.value}` : r.op === "eq" ? `${FIELD_LABEL(r.field)}: ${r.value === true ? "yes" : r.value === false ? "no" : String(r.value)}` : r.op === "in" ? `${FIELD_LABEL(r.field)} only ${r.value.join(", ")}` : `never ${r.value.join(", ")} (${FIELD_LABEL(r.field)})`);
|
|
36631
|
+
ruleText = (r) => r.label ?? (r.op === "present" ? `${FIELD_LABEL(r.field)} must be given` : r.op === "max" ? `${FIELD_LABEL(r.field)} at most ${r.value}` : r.op === "min" ? `${FIELD_LABEL(r.field)} at least ${r.value}` : r.op === "eq" ? `${FIELD_LABEL(r.field)}: ${r.value === true ? "yes" : r.value === false ? "no" : String(r.value)}` : r.op === "in" ? `${FIELD_LABEL(r.field)} only ${r.value.join(", ")}` : `never ${r.value.join(", ")} (${FIELD_LABEL(r.field)})`);
|
|
36584
36632
|
DEFAULT_REVOCATIONS = () => _join(_home(), ".saktum", "revocations.json");
|
|
36585
36633
|
readRevocations = (path) => {
|
|
36586
36634
|
try {
|
|
@@ -36764,8 +36812,24 @@ function issueCredential(issuerCred, issuerKey, s) {
|
|
|
36764
36812
|
throw new Error("The signing key does not belong to the issuer's credential.");
|
|
36765
36813
|
if (issuerCred.type === "agent")
|
|
36766
36814
|
throw new Error("Agents cannot issue credentials.");
|
|
36815
|
+
const parentTools = issuerCred.scope?.tools;
|
|
36816
|
+
if (parentTools && s.tools?.some((t) => !parentTools.includes(t)))
|
|
36817
|
+
throw new Error(`The issuer may only grant tools it holds: ${parentTools.join(", ")}.`);
|
|
36818
|
+
if (s.expires > issuerCred.expires)
|
|
36819
|
+
throw new Error(`A credential cannot outlive its issuer's (${issuerCred.expires}).`);
|
|
36820
|
+
if (issuerCred.maxDepth !== void 0 && issuerCred.maxDepth < 1)
|
|
36821
|
+
throw new Error("The issuer's credential does not allow further delegation.");
|
|
36822
|
+
const tools = s.tools ?? parentTools;
|
|
36823
|
+
const pw = issuerCred.scope?.where;
|
|
36824
|
+
if (pw) {
|
|
36825
|
+
for (const [f, vals] of Object.entries(pw))
|
|
36826
|
+
if (s.where && s.where[f] && s.where[f].some((x) => !vals.includes(x)))
|
|
36827
|
+
throw new Error(`The issuer may only grant ${f} within ${vals.join(", ")}.`);
|
|
36828
|
+
}
|
|
36829
|
+
const where = s.where || pw ? { ...pw ?? {}, ...s.where ?? {} } : void 0;
|
|
36830
|
+
const maxDepth2 = issuerCred.maxDepth !== void 0 ? Math.min(s.maxDepth ?? issuerCred.maxDepth - 1, issuerCred.maxDepth - 1) : s.maxDepth;
|
|
36767
36831
|
const chain = [...issuerCred.chain ?? [], { ...issuerCred, chain: void 0 }].map((c2) => JSON.parse(JSON.stringify(c2)));
|
|
36768
|
-
const c = { credentialFormat: "0.1", type: s.type, subject: { id: s.id, name: s.name, ...s.role ? { role: s.role } : {} }, issuer: { id: issuerKey.kid, name: issuerCred.subject.name, ...issuerCred.issuer.domain ? { domain: issuerCred.issuer.domain } : {} }, issuedAt: nowIso(), expires: s.expires };
|
|
36832
|
+
const c = { credentialFormat: "0.1", type: s.type, ...tools || where ? { scope: { ...tools ? { tools } : {}, ...where ? { where } : {} } } : {}, ...maxDepth2 !== void 0 ? { maxDepth: maxDepth2 } : {}, subject: { id: s.id, name: s.name, ...s.role ? { role: s.role } : {} }, issuer: { id: issuerKey.kid, name: issuerCred.subject.name, ...issuerCred.issuer.domain ? { domain: issuerCred.issuer.domain } : {} }, issuedAt: nowIso(), expires: s.expires };
|
|
36769
36833
|
return { ...signDocument({ ...c, id: short("cred_", c) }, issuerKey), chain };
|
|
36770
36834
|
}
|
|
36771
36835
|
function verifyChain(c, o = {}) {
|
|
@@ -36787,9 +36851,21 @@ function verifyChain(c, o = {}) {
|
|
|
36787
36851
|
return { valid: false, path, reason: "the chain does not start at an organisation" };
|
|
36788
36852
|
if (i > 0 && l.issuer.id !== links[i - 1].subject.id)
|
|
36789
36853
|
return { valid: false, path, reason: `${l.subject.name}'s issuer is not the previous link in the chain` };
|
|
36854
|
+
if (i > 0) {
|
|
36855
|
+
const p = links[i - 1];
|
|
36856
|
+
if (p.scope?.tools && (!l.scope?.tools || l.scope.tools.some((t) => !p.scope.tools.includes(t))))
|
|
36857
|
+
return { valid: false, path, reason: `${l.subject.name}'s credential grants more than its issuer holds` };
|
|
36858
|
+
if (l.expires > p.expires)
|
|
36859
|
+
return { valid: false, path, reason: `${l.subject.name}'s credential outlives its issuer's` };
|
|
36860
|
+
for (const [f, vals] of Object.entries(p.scope?.where ?? {}))
|
|
36861
|
+
if (!l.scope?.where?.[f] || l.scope.where[f].some((x) => !vals.includes(x)))
|
|
36862
|
+
return { valid: false, path, reason: `${l.subject.name}'s credential reaches beyond its issuer's ${f}` };
|
|
36863
|
+
}
|
|
36864
|
+
if (l.maxDepth !== void 0 && links.length - 1 - i > l.maxDepth)
|
|
36865
|
+
return { valid: false, path, reason: `the chain delegates deeper than ${l.subject.name}'s credential allows (${l.maxDepth})` };
|
|
36790
36866
|
path.push(`${l.subject.name}${l.subject.role ? ` (${l.subject.role})` : ""}`);
|
|
36791
36867
|
}
|
|
36792
|
-
return { valid: true, path, organisation: links[0].subject.name + (links[0].issuer.domain ? ` (${links[0].issuer.domain})` : "") };
|
|
36868
|
+
return { valid: true, path, organisation: links[0].subject.name + (links[0].issuer.domain ? ` (${links[0].issuer.domain})` : ""), ...links[links.length - 1].scope?.tools ? { tools: links[links.length - 1].scope.tools } : {}, ...links[links.length - 1].scope?.where ? { where: links[links.length - 1].scope.where } : {} };
|
|
36793
36869
|
}
|
|
36794
36870
|
function findOrphans(creds, o = {}) {
|
|
36795
36871
|
return creds.filter((c) => c.type === "agent").map((c) => ({ agent: c.subject.name, id: c.subject.id, ...verifyChain(c, o) })).filter((x) => !x.valid);
|
|
@@ -37047,6 +37123,25 @@ var init_crosswalk = __esm({
|
|
|
37047
37123
|
I("9.2", "Internal audit", "partial", "Independently verifiable ledger, receipts and passports for auditors", ["saktum ledger verify", "saktum receipts verify"]),
|
|
37048
37124
|
I("A.10", "Third-party and customer relationships", "covered", "Passports, manifests, signed agreements, Verifiable Credentials", ["saktum attest --vc", "saktum agreement verify"])
|
|
37049
37125
|
] },
|
|
37126
|
+
{ id: "iso-27001", name: "ISO/IEC 27001 (Annex A, 2022)", note: "Information security management; certification is by accredited bodies.", items: [
|
|
37127
|
+
I("A.5.15", "Access control", "covered", "Least-privilege mandates and task-scoped, short-lived agent credentials", ["saktum agent create --intent", "saktum identity issue --minutes --tools"]),
|
|
37128
|
+
I("A.5.19\u2013A.5.22", "Information security in supplier relationships", "covered", "Passports, attestations, monitoring and signed agreements for third-party MCP servers", ["saktum passport", "saktum watch", "saktum agreement verify"]),
|
|
37129
|
+
I("A.8.2", "Privileged access rights", "partial", "Approvals for risky actions, autonomy levels and revocation (agents; not human administrators)", ["saktum agent approve", "saktum agent revoke"]),
|
|
37130
|
+
I("A.8.15", "Logging", "covered", "Signed, chained receipts with input and output digests; checkpoints detect deletion", ["saktum receipts verify", "saktum receipts checkpoint"]),
|
|
37131
|
+
I("A.8.16", "Monitoring activities", "covered", "Daily monitoring of approved servers, result flags, OpenTelemetry export", ["saktum watch", "saktum receipts export --otel"]),
|
|
37132
|
+
I("A.8.24", "Use of cryptography", "partial", "Ed25519 signatures, keys in OS keychains or external key services (confidentiality at rest is the customer's storage)", ["saktum self-verify"])
|
|
37133
|
+
] },
|
|
37134
|
+
{ id: "osfi-e23", name: "OSFI E-23 (Canada)", note: "Model risk management for federally regulated financial institutions, including AI; applicability and dates per OSFI.", items: [
|
|
37135
|
+
I("Inventory", "Model inventory", "covered", "Agent and MCP server inventories across the organisation", ["saktum agents scan", "saktum fleet"]),
|
|
37136
|
+
I("Risk rating", "Risk-based model classification", "covered", "Risk tiers R0\u2013R4 for servers and agents; policy ceilings", ["saktum check", "saktum fleet --policy"]),
|
|
37137
|
+
I("Governance", "Accountability and roles", "covered", "Identity chains to accountable people and organisations; operator countersignatures", ["saktum identity verify", "saktum agent cosign"]),
|
|
37138
|
+
I("Monitoring", "Ongoing monitoring across the lifecycle", "covered", "Track records, maturity levels, daily monitoring, receipts", ["saktum passport --agent", "saktum watch"]),
|
|
37139
|
+
I("Explainability", "Explainability and transparency", "partial", "Every decision carries a reason and rationale (actions, not model internals)", ["saktum receipts summary"]),
|
|
37140
|
+
I("Third parties", "Third-party and vendor models", "partial", "Passports and attestations for third-party tools (the models themselves are out of scope)", ["saktum passport", "saktum attest --vc"])
|
|
37141
|
+
] },
|
|
37142
|
+
{ id: "ca-sb53", name: "California SB 53", note: "Applies to frontier AI model developers, not to organisations running agents; listed so readers see it was considered.", items: [
|
|
37143
|
+
I("Scope", "Frontier developer transparency and safety frameworks", "gap", "Not applicable to Saktum's users (agents and tools, not frontier model training)", [])
|
|
37144
|
+
] },
|
|
37050
37145
|
{ id: "owasp-llm", name: "OWASP Top 10 for LLM Applications (2025)", note: "Mapped for agents' tool use; model-level risks are out of scope.", items: [
|
|
37051
37146
|
I("LLM01", "Prompt injection", "partial", "Hidden-instruction checks on tools; mandates contain a manipulated agent (detection inside models is out of scope)", ["saktum check", "saktum demo"]),
|
|
37052
37147
|
I("LLM02", "Sensitive information disclosure", "partial", "Personal and classified data enforced per recipient; secrets never printed; argument digests only", ["saktum proxy --enforce"]),
|
|
@@ -37325,6 +37420,43 @@ var init_webauthn = __esm({
|
|
|
37325
37420
|
}
|
|
37326
37421
|
});
|
|
37327
37422
|
|
|
37423
|
+
// packages/testkit-core/dist/guards.js
|
|
37424
|
+
function findSecret(text2) {
|
|
37425
|
+
for (const p of SECRET_PATTERNS) {
|
|
37426
|
+
const re = new RegExp(p.re.source, p.re.flags.replace("g", ""));
|
|
37427
|
+
const m = text2.match(re);
|
|
37428
|
+
if (m && (!p.valid || p.valid(m)))
|
|
37429
|
+
return p.name;
|
|
37430
|
+
}
|
|
37431
|
+
return void 0;
|
|
37432
|
+
}
|
|
37433
|
+
function findHiddenInstruction(text2, o = {}) {
|
|
37434
|
+
for (const re of o.broad ? [...HIDDEN_INSTRUCTION, ...RESULT_INJECTION] : HIDDEN_INSTRUCTION) {
|
|
37435
|
+
const m = text2.match(re);
|
|
37436
|
+
if (m)
|
|
37437
|
+
return m[0].slice(0, 80);
|
|
37438
|
+
}
|
|
37439
|
+
return void 0;
|
|
37440
|
+
}
|
|
37441
|
+
function resultText(result) {
|
|
37442
|
+
const r = result ?? {};
|
|
37443
|
+
return [...(r.content ?? []).map((c) => typeof c.text === "string" ? c.text : ""), r.structuredContent ? JSON.stringify(r.structuredContent) : ""].join("\n");
|
|
37444
|
+
}
|
|
37445
|
+
var RESULT_INJECTION;
|
|
37446
|
+
var init_guards = __esm({
|
|
37447
|
+
"packages/testkit-core/dist/guards.js"() {
|
|
37448
|
+
"use strict";
|
|
37449
|
+
init_analysers();
|
|
37450
|
+
init_leakage();
|
|
37451
|
+
RESULT_INJECTION = [
|
|
37452
|
+
/\bignore (the |your )?(user|previous|prior|above|earlier|original)\b/i,
|
|
37453
|
+
/\b(send|upload|post|forward|email|exfiltrate) (the |all |any |your |their )?(conversation|chat|credentials|api keys?|secrets?|tokens?|passwords?|private data)\b[^.\n]{0,40}\bto\b/i,
|
|
37454
|
+
/\byou are now\b|\bnew instructions?:/i,
|
|
37455
|
+
/\b(do not|don['’]t|never) (tell|inform|alert|notify) the user\b/i
|
|
37456
|
+
];
|
|
37457
|
+
}
|
|
37458
|
+
});
|
|
37459
|
+
|
|
37328
37460
|
// packages/testkit-core/dist/index.js
|
|
37329
37461
|
var dist_exports = {};
|
|
37330
37462
|
__export(dist_exports, {
|
|
@@ -37343,6 +37475,7 @@ __export(dist_exports, {
|
|
|
37343
37475
|
FRAMEWORKS: () => FRAMEWORKS,
|
|
37344
37476
|
FUNCTIONAL_LIMITS: () => FUNCTIONAL_LIMITS,
|
|
37345
37477
|
GENESIS: () => GENESIS,
|
|
37478
|
+
HIDDEN_INSTRUCTION: () => HIDDEN_INSTRUCTION,
|
|
37346
37479
|
INVISIBLE: () => INVISIBLE,
|
|
37347
37480
|
KNOWN_FIELDS: () => KNOWN_FIELDS,
|
|
37348
37481
|
LEAKAGE_NEEDS: () => LEAKAGE_NEEDS,
|
|
@@ -37416,8 +37549,10 @@ __export(dist_exports, {
|
|
|
37416
37549
|
evaluatePolicy: () => evaluatePolicy,
|
|
37417
37550
|
exampleFor: () => exampleFor,
|
|
37418
37551
|
extractJson: () => extractJson,
|
|
37552
|
+
findHiddenInstruction: () => findHiddenInstruction,
|
|
37419
37553
|
findInLedger: () => findInLedger,
|
|
37420
37554
|
findOrphans: () => findOrphans,
|
|
37555
|
+
findSecret: () => findSecret,
|
|
37421
37556
|
fleetHtml: () => fleetHtml,
|
|
37422
37557
|
gradeFor: () => gradeFor,
|
|
37423
37558
|
hasIntent: () => hasIntent,
|
|
@@ -37462,6 +37597,7 @@ __export(dist_exports, {
|
|
|
37462
37597
|
renderSetup: () => renderSetup,
|
|
37463
37598
|
renderVerdict: () => renderVerdict,
|
|
37464
37599
|
resultProblems: () => resultProblems,
|
|
37600
|
+
resultText: () => resultText,
|
|
37465
37601
|
revocationOf: () => revocationOf,
|
|
37466
37602
|
revokeMandate: () => revokeMandate,
|
|
37467
37603
|
revokedInChain: () => revokedInChain,
|
|
@@ -37548,6 +37684,7 @@ var init_dist4 = __esm({
|
|
|
37548
37684
|
init_agents();
|
|
37549
37685
|
init_trust();
|
|
37550
37686
|
init_webauthn();
|
|
37687
|
+
init_guards();
|
|
37551
37688
|
}
|
|
37552
37689
|
});
|
|
37553
37690
|
|
|
@@ -38308,7 +38445,7 @@ async function runProxy(o) {
|
|
|
38308
38445
|
let metering;
|
|
38309
38446
|
try {
|
|
38310
38447
|
const rev = o.mandate ? revocationOf(o.mandate, o.revocationsPath) : void 0;
|
|
38311
|
-
d = rev ? { allow: false, code: "revoked", reason: `the mandate was revoked on ${rev.at.slice(0, 10)}${rev.reason ? ` (${rev.reason})` : ""}` } : o.mandate && (remoteRevoked || revokedInChain(history)) ? { allow: false, code: "revoked", reason: "the mandate was revoked (recorded in the ledger or in this receipt chain)" } : toolsChanged ? { allow: false, code: "tools-changed", reason: "the server's tools differ from the pinned, approved fingerprint" } : o.mandate ? decideCall(o.mandate, { tool, server: service, args, annotations: ann, isMoney, usage: usage() }) : { allow: true, code: "ok", reason: "no mandate: observed" };
|
|
38448
|
+
d = rev ? { allow: false, code: "revoked", reason: `the mandate was revoked on ${rev.at.slice(0, 10)}${rev.reason ? ` (${rev.reason})` : ""}` } : o.mandate && (remoteRevoked || revokedInChain(history)) ? { allow: false, code: "revoked", reason: "the mandate was revoked (recorded in the ledger or in this receipt chain)" } : findSecret(JSON.stringify(args ?? {})) ? { allow: false, code: "secret-in-arguments", reason: `the arguments contain what looks like a secret (${findSecret(JSON.stringify(args ?? {}))}); it was not sent and is not recorded` } : toolsChanged ? { allow: false, code: "tools-changed", reason: "the server's tools differ from the pinned, approved fingerprint" } : o.mandate ? decideCall(o.mandate, { tool, server: service, args, annotations: ann, isMoney, usage: usage() }) : { allow: true, code: "ok", reason: "no mandate: observed" };
|
|
38312
38449
|
if (d.allow && o.mandate && hasIntent(o.mandate)) {
|
|
38313
38450
|
const di = decideIntent(o.mandate, def ?? { name: tool }, args, { server: service });
|
|
38314
38451
|
rationale = di.rationale;
|
|
@@ -38344,7 +38481,19 @@ async function runProxy(o) {
|
|
|
38344
38481
|
const root = [...o.credential.chain ?? [], o.credential][0].subject.id;
|
|
38345
38482
|
if (!vc.valid)
|
|
38346
38483
|
d = { allow: false, code: "identity-chain", reason: `the agent's accountability chain is broken: ${vc.reason}` };
|
|
38347
|
-
else if (
|
|
38484
|
+
else if (vc.tools && !vc.tools.includes(tool))
|
|
38485
|
+
d = { allow: false, code: "outside-credential-scope", reason: `the agent's credential covers only ${vc.tools.join(", ")}` };
|
|
38486
|
+
else if (vc.where) {
|
|
38487
|
+
const b = bindingsFor(toolDefs.get(tool) ?? { name: tool }).bindings;
|
|
38488
|
+
for (const [arg, field] of Object.entries(b)) {
|
|
38489
|
+
const allowed = vc.where[field];
|
|
38490
|
+
const val = args[arg];
|
|
38491
|
+
if (allowed && val !== void 0 && !allowed.includes(String(val))) {
|
|
38492
|
+
d = { allow: false, code: "outside-credential-scope", reason: `the agent's credential covers ${field} ${allowed.join(", ")} only (got ${String(val)})` };
|
|
38493
|
+
break;
|
|
38494
|
+
}
|
|
38495
|
+
}
|
|
38496
|
+
} else if (o.agreement && root !== o.agreement.invoker.id)
|
|
38348
38497
|
d = { allow: false, code: "identity-chain", reason: "the agent's organisation is not the party to the agreement" };
|
|
38349
38498
|
}
|
|
38350
38499
|
if (d.allow && o.agreement) {
|
|
@@ -38368,7 +38517,7 @@ async function runProxy(o) {
|
|
|
38368
38517
|
if (!d.allow && (o.enforce || d.code === "error-fail-closed")) {
|
|
38369
38518
|
const hint = d.code === "revoked" ? " The agent's owner stopped it; do not retry." : d.code === "approval-needed" ? " Ask your user to approve it (saktum agent approve with the request id), then retry the same action once." : d.code === "notify-only" ? " Tell your user what you found instead." : " Ask the agent's owner to change the mandate if this action is needed.";
|
|
38370
38519
|
process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: msg.id, result: { isError: true, content: [{ type: "text", text: `Blocked by Saktum (${d.code}): ${d.reason}.${hint}` }] } }) + "\n");
|
|
38371
|
-
record2(tool, argsHash, "deny", d.reason, { status: "blocked", destructive: isDestructive(ann), code: d.code, values, ...rationale ? { rationale } : {} });
|
|
38520
|
+
record2(tool, argsHash, "deny", d.reason, { status: "blocked", destructive: isDestructive(ann), code: d.code, values: d.code === "secret-in-arguments" ? void 0 : values, ...rationale ? { rationale } : {} });
|
|
38372
38521
|
o.log?.(`denied ${tool} (${d.code}): ${d.reason}`);
|
|
38373
38522
|
return;
|
|
38374
38523
|
}
|
|
@@ -38423,7 +38572,18 @@ async function runProxy(o) {
|
|
|
38423
38572
|
if (c) {
|
|
38424
38573
|
calls.delete(k);
|
|
38425
38574
|
const status = msg.error ? "protocol-error" : msg.result?.isError ? "tool-error" : "ok";
|
|
38426
|
-
|
|
38575
|
+
const text2 = msg.result ? resultText(msg.result) : "";
|
|
38576
|
+
const hidden = text2 ? findHiddenInstruction(text2, { broad: true }) : void 0, secret = text2 ? findSecret(text2) : void 0;
|
|
38577
|
+
const rv = o.mandate?.review;
|
|
38578
|
+
const sampled = Boolean(rv && !msg.error && (!rv.actions || rv.actions.includes(actionClass(toolDefs.get(c.tool) ?? { name: c.tool }).cls)) && parseInt(sha256Tag(c.argsHash + c.start).slice(7, 15), 16) / 4294967295 < rv.sample);
|
|
38579
|
+
const flags = [...hidden ? ["hidden-instruction-in-result"] : [], ...secret ? [`secret-in-result:${secret}`] : [], ...sampled ? ["review-sampled"] : []];
|
|
38580
|
+
if (flags.length)
|
|
38581
|
+
o.log?.(`${c.tool}: result flagged (${flags.join(", ")})`);
|
|
38582
|
+
if ((hidden || secret) && o.quarantineResults) {
|
|
38583
|
+
msg.result = { content: [{ type: "text", text: `Withheld by Saktum: this tool's result contained ${hidden ? "instructions aimed at the agent" : "what looks like a secret"}. Ask the user before continuing.` }], isError: true };
|
|
38584
|
+
line = JSON.stringify(msg);
|
|
38585
|
+
}
|
|
38586
|
+
record2(c.tool, c.argsHash, msg.error ? "error" : "allow", c.reason + (hidden || secret ? ` [result ${o.quarantineResults ? "withheld" : "flagged"}: ${flags.filter((f) => f !== "review-sampled").join(", ")}]` : "") + (sampled ? " [sampled for human review]" : ""), { status, latencyMs: Date.now() - c.start, destructive: c.destructive, code: c.code, values: c.values, outputDigest: digest(msg.result ?? msg.error ?? null), ...flags.length ? { flags } : {}, ...c.rationale ? { rationale: c.rationale } : {}, ...c.metering ? { metering: c.metering } : {} });
|
|
38427
38587
|
}
|
|
38428
38588
|
process.stdout.write(line + "\n");
|
|
38429
38589
|
});
|
|
@@ -39197,7 +39357,7 @@ __export(demo_exports, {
|
|
|
39197
39357
|
import { mkdirSync as mkdirSync5, readFileSync as readFileSync8, writeFileSync as writeFileSync4, existsSync as existsSync6, rmSync } from "node:fs";
|
|
39198
39358
|
import { join as join6 } from "node:path";
|
|
39199
39359
|
async function startDemoServer(story = "autonomy") {
|
|
39200
|
-
const tools = story === "grocery" ? GROCERY_TOOLS : story === "travel" ? TRAVEL_TOOLS : story === "finance" ? FINANCE_TOOLS : story === "coding" ? CODING_TOOLS : DEMO_TOOLS;
|
|
39360
|
+
const tools = story === "grocery" ? GROCERY_TOOLS : story === "travel" ? TRAVEL_TOOLS : story === "finance" ? FINANCE_TOOLS : story === "coding" ? CODING_TOOLS : story === "support" ? SUPPORT_TOOLS : story === "legal" ? LEGAL_TOOLS : DEMO_TOOLS;
|
|
39201
39361
|
const server = new Server({ name: story === "travel" ? "demo-travel" : story === "finance" ? "demo-finance" : "demo-grocer", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
39202
39362
|
const cart = [];
|
|
39203
39363
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools }));
|
|
@@ -39230,6 +39390,16 @@ async function startDemoServer(story = "autonomy") {
|
|
|
39230
39390
|
return text2(`Sent "${a.report}" to ${a.recipient}.`);
|
|
39231
39391
|
case "pay_invoice":
|
|
39232
39392
|
return text2(`Paid $${a.amount} to ${a.vendor}.`);
|
|
39393
|
+
case "read_case_document":
|
|
39394
|
+
return text2(`${a.case_id}: ${a.document_type} read (expires 2031-04-30).`);
|
|
39395
|
+
case "update_profile_field":
|
|
39396
|
+
return text2(`${a.case_id}: ${a.field} set from source document.`);
|
|
39397
|
+
case "send_client_message":
|
|
39398
|
+
return text2(`Message sent on ${a.case_id}.`);
|
|
39399
|
+
case "lookup_customer":
|
|
39400
|
+
return text2(`${a.customer_id}: 3 orders; latest arrived damaged.`);
|
|
39401
|
+
case "issue_refund":
|
|
39402
|
+
return text2(`Refunded $${a.amount} to ${a.customer_id}.`);
|
|
39233
39403
|
case "run_tests":
|
|
39234
39404
|
return text2(`${a.repository}: 412 tests passed.`);
|
|
39235
39405
|
case "open_pull_request":
|
|
@@ -39251,6 +39421,47 @@ async function startDemoServer(story = "autonomy") {
|
|
|
39251
39421
|
await server.connect(new StdioServerTransport());
|
|
39252
39422
|
await closed;
|
|
39253
39423
|
}
|
|
39424
|
+
async function governedSession(open2) {
|
|
39425
|
+
const start = async () => {
|
|
39426
|
+
try {
|
|
39427
|
+
const x = await open2();
|
|
39428
|
+
await x.listTools();
|
|
39429
|
+
return x;
|
|
39430
|
+
} catch {
|
|
39431
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
39432
|
+
const x = await open2();
|
|
39433
|
+
await x.listTools();
|
|
39434
|
+
return x;
|
|
39435
|
+
}
|
|
39436
|
+
};
|
|
39437
|
+
let s = await start();
|
|
39438
|
+
return {
|
|
39439
|
+
call: async (tool, args) => {
|
|
39440
|
+
try {
|
|
39441
|
+
return await s.callTool(tool, args);
|
|
39442
|
+
} catch (e) {
|
|
39443
|
+
try {
|
|
39444
|
+
await s.close();
|
|
39445
|
+
} catch {
|
|
39446
|
+
}
|
|
39447
|
+
try {
|
|
39448
|
+
s = await start();
|
|
39449
|
+
return await s.callTool(tool, args);
|
|
39450
|
+
} catch (e2) {
|
|
39451
|
+
process.stderr.write(`demo step ${tool} failed: ${String(e2.message ?? e2)} (first attempt: ${String(e.message ?? e)})
|
|
39452
|
+
`);
|
|
39453
|
+
return { kind: "error", message: String(e2.message ?? e2) };
|
|
39454
|
+
}
|
|
39455
|
+
}
|
|
39456
|
+
},
|
|
39457
|
+
close: async () => {
|
|
39458
|
+
try {
|
|
39459
|
+
await s.close();
|
|
39460
|
+
} catch {
|
|
39461
|
+
}
|
|
39462
|
+
}
|
|
39463
|
+
};
|
|
39464
|
+
}
|
|
39254
39465
|
async function runStory(dir, st, owner, log) {
|
|
39255
39466
|
const self = [...process.execArgv, process.argv[1]];
|
|
39256
39467
|
const agentKey = loadOrCreateKey(join6(dir, `${st.id}-agent-key.json`));
|
|
@@ -39272,9 +39483,9 @@ async function runStory(dir, st, owner, log) {
|
|
|
39272
39483
|
for (const line of describeMandate(m))
|
|
39273
39484
|
log(` ${line}`);
|
|
39274
39485
|
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] });
|
|
39275
|
-
const
|
|
39486
|
+
const gs = await governedSession(open2);
|
|
39487
|
+
const call = gs.call;
|
|
39276
39488
|
try {
|
|
39277
|
-
await s.listTools();
|
|
39278
39489
|
let lastRid = "";
|
|
39279
39490
|
for (const step of st.steps) {
|
|
39280
39491
|
if (step.approveLast) {
|
|
@@ -39283,7 +39494,11 @@ async function runStory(dir, st, owner, log) {
|
|
|
39283
39494
|
log(` \u270D ${step.say}: ${lastRid}`);
|
|
39284
39495
|
continue;
|
|
39285
39496
|
}
|
|
39286
|
-
const o = await
|
|
39497
|
+
const o = await call(step.tool, step.args);
|
|
39498
|
+
if (o.kind === "error" && "message" in o) {
|
|
39499
|
+
log(` ! ${step.say}: could not complete on this machine (${o.message}); continuing`);
|
|
39500
|
+
continue;
|
|
39501
|
+
}
|
|
39287
39502
|
const txt = o.kind === "result" ? o.content.map((c) => c.text ?? "").join(" ") : o.kind;
|
|
39288
39503
|
const rid = /\[approval request (apr_[0-9a-f]+)\]/.exec(txt);
|
|
39289
39504
|
if (rid)
|
|
@@ -39300,15 +39515,14 @@ async function runStory(dir, st, owner, log) {
|
|
|
39300
39515
|
log(` ! ${f}`);
|
|
39301
39516
|
}
|
|
39302
39517
|
} finally {
|
|
39303
|
-
await
|
|
39518
|
+
await gs.close();
|
|
39304
39519
|
await new Promise((r) => setTimeout(r, 300));
|
|
39305
39520
|
}
|
|
39306
39521
|
if (st.id === "grocery") {
|
|
39307
39522
|
revokeMandate(cm, "you pressed stop", revf);
|
|
39308
|
-
const s2 = await open2
|
|
39523
|
+
const s2 = await governedSession(open2);
|
|
39309
39524
|
try {
|
|
39310
|
-
await s2.
|
|
39311
|
-
const o = await s2.callTool("search_products", { query: "milk" });
|
|
39525
|
+
const o = await s2.call("search_products", { query: "milk" });
|
|
39312
39526
|
const txt = o.kind === "result" ? o.content.map((c) => c.text ?? "").join(" ") : o.kind;
|
|
39313
39527
|
log(/revoked/.test(txt) ? " \u26D4 after you press stop (saktum agent revoke), it tries to search again: revoked" : ` ? after revoke: ${txt.slice(0, 80)}`);
|
|
39314
39528
|
} finally {
|
|
@@ -39411,11 +39625,10 @@ async function runMarketplace(dir, log) {
|
|
|
39411
39625
|
{ tool: "search_products", args: { query: "fruit" }, say: "searches again" }
|
|
39412
39626
|
];
|
|
39413
39627
|
const run = async (st2) => {
|
|
39414
|
-
const s2 = await open2
|
|
39628
|
+
const s2 = await governedSession(open2);
|
|
39415
39629
|
try {
|
|
39416
|
-
await s2.listTools();
|
|
39417
39630
|
for (const st1 of st2) {
|
|
39418
|
-
const o = await s2.
|
|
39631
|
+
const o = await s2.call(st1.tool, st1.args);
|
|
39419
39632
|
const txt = o.kind === "result" ? o.content.map((c) => c.text ?? "").join(" ") : o.kind;
|
|
39420
39633
|
const blocked = /^Blocked by Saktum \(([^)]+)\): (.+?)\.( Ask| Tell|$)/.exec(txt);
|
|
39421
39634
|
const last = parseReceiptLog(readFileSync8(rf, "utf8")).pop();
|
|
@@ -39461,7 +39674,7 @@ async function runDemo(dir, log, story = "all") {
|
|
|
39461
39674
|
const owner = loadOrCreateKey(join6(dir, "owner-key.json"));
|
|
39462
39675
|
log("Saktum demo: agents acting on real instructions (rules, preferences, substitutions, upsells), every decision explained and signed.\n");
|
|
39463
39676
|
const files = [];
|
|
39464
|
-
for (const st of story === "travel" ? [TRAVEL] : story === "grocery" ? [GROCERY] : story === "finance" ? [FINANCE] : story === "coding" ? [CODING] : [GROCERY, TRAVEL, FINANCE, CODING])
|
|
39677
|
+
for (const st of story === "travel" ? [TRAVEL] : story === "grocery" ? [GROCERY] : story === "finance" ? [FINANCE] : story === "coding" ? [CODING] : story === "support" ? [SUPPORT] : story === "legal" ? [LEGAL] : [GROCERY, TRAVEL, FINANCE, CODING, SUPPORT, LEGAL])
|
|
39465
39678
|
files.push(await runStory(dir, st, owner, log));
|
|
39466
39679
|
if (story === "all")
|
|
39467
39680
|
files.push(await runMarketplace(dir, log));
|
|
@@ -39506,17 +39719,21 @@ async function runAutonomyDemo(dir, log) {
|
|
|
39506
39719
|
writeFileSync4(mf, JSON.stringify(m, null, 2));
|
|
39507
39720
|
const tier = agentRiskTier(m);
|
|
39508
39721
|
log(`\u2500\u2500 ${p.title} autonomy ${m.autonomy} \xB7 risk ${tier.tier}`);
|
|
39509
|
-
const
|
|
39722
|
+
const open2 = () => 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"] });
|
|
39723
|
+
const gs = await governedSession(open2);
|
|
39510
39724
|
try {
|
|
39511
|
-
await s.listTools();
|
|
39512
39725
|
for (const st of p.steps) {
|
|
39513
|
-
const o = await
|
|
39726
|
+
const o = await gs.call(st.tool, st.args);
|
|
39727
|
+
if (o.kind === "error" && "message" in o) {
|
|
39728
|
+
log(` ! ${st.say}: could not complete on this machine (${o.message}); continuing`);
|
|
39729
|
+
continue;
|
|
39730
|
+
}
|
|
39514
39731
|
const txt = o.kind === "result" ? o.content.map((c) => c.text ?? "").join(" ") : o.kind;
|
|
39515
39732
|
const blocked = /^Blocked by Saktum \(([^)]+)\): ([^.]+)/.exec(txt);
|
|
39516
39733
|
log(blocked ? ` \u26D4 ${st.say}: blocked (${blocked[1]}): ${blocked[2]}` : ` \u2713 ${st.say}: ${txt.split("\n")[0]}`);
|
|
39517
39734
|
}
|
|
39518
39735
|
} finally {
|
|
39519
|
-
await
|
|
39736
|
+
await gs.close();
|
|
39520
39737
|
await new Promise((r) => setTimeout(r, 300));
|
|
39521
39738
|
}
|
|
39522
39739
|
const entries = parseReceiptLog(readFileSync8(rf, "utf8"));
|
|
@@ -39538,7 +39755,7 @@ async function runAutonomyDemo(dir, log) {
|
|
|
39538
39755
|
log("What you just saw: the same agent and the same shop. Only the mandate changed what it was allowed to do, and every\ndecision, allowed or blocked, has a signed receipt. Open the passports to see each agent's permissions and path.");
|
|
39539
39756
|
return { files };
|
|
39540
39757
|
}
|
|
39541
|
-
var PRODUCTS, DEMO_TOOLS, B, GROCERY_TOOLS, TRAVEL_TOOLS, FINANCE_TOOLS, CODING_TOOLS, SCRIPT, EXTRA, GROCERY, TRAVEL, FINANCE, CODING;
|
|
39758
|
+
var PRODUCTS, DEMO_TOOLS, B, GROCERY_TOOLS, TRAVEL_TOOLS, FINANCE_TOOLS, CODING_TOOLS, SUPPORT_TOOLS, LEGAL_TOOLS, SCRIPT, EXTRA, GROCERY, TRAVEL, FINANCE, CODING, SUPPORT, LEGAL;
|
|
39542
39759
|
var init_demo = __esm({
|
|
39543
39760
|
"packages/cli/dist/demo.js"() {
|
|
39544
39761
|
"use strict";
|
|
@@ -39598,6 +39815,15 @@ var init_demo = __esm({
|
|
|
39598
39815
|
{ name: "deploy_to_staging", description: "Deploy a build to the staging environment.", inputSchema: { type: "object", properties: { repository: { type: "string" }, build: { type: "string" } }, required: ["repository", "build"] }, annotations: { readOnlyHint: false, destructiveHint: false }, _meta: B({ repository: "code.repository" }, "change") },
|
|
39599
39816
|
{ name: "deploy_to_production", description: "Release a build to production.", inputSchema: { type: "object", properties: { repository: { type: "string" }, build: { type: "string" } }, required: ["repository", "build"] }, annotations: { readOnlyHint: false, destructiveHint: true }, _meta: B({ repository: "code.repository" }, "deploy") }
|
|
39600
39817
|
];
|
|
39818
|
+
SUPPORT_TOOLS = [
|
|
39819
|
+
{ name: "lookup_customer", description: "Look up a customer's account and recent orders.", inputSchema: { type: "object", properties: { customer_id: { type: "string" } }, required: ["customer_id"] }, annotations: { readOnlyHint: true }, _meta: B({ customer_id: "support.customer_id" }, "search") },
|
|
39820
|
+
{ name: "issue_refund", description: "Refund an amount to the customer's original payment method.", inputSchema: { type: "object", properties: { customer_id: { type: "string" }, amount: { type: "number" } }, required: ["customer_id", "amount"] }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false }, _meta: B({ customer_id: "support.customer_id", amount: "support.amount" }, "pay") }
|
|
39821
|
+
];
|
|
39822
|
+
LEGAL_TOOLS = [
|
|
39823
|
+
{ name: "read_case_document", description: "Read a document from a case file.", inputSchema: { type: "object", properties: { case_id: { type: "string" }, document_type: { type: "string" } }, required: ["case_id", "document_type"] }, annotations: { readOnlyHint: true }, _meta: B({ case_id: "legal.case_id", document_type: "legal.document_type" }, "search") },
|
|
39824
|
+
{ name: "update_profile_field", description: "Set a field in the case profile from a source document.", inputSchema: { type: "object", properties: { case_id: { type: "string" }, field: { type: "string" }, value: { type: "string" } }, required: ["case_id", "field", "value"] }, annotations: { readOnlyHint: false, destructiveHint: false }, _meta: B({ case_id: "legal.case_id" }, "change") },
|
|
39825
|
+
{ name: "send_client_message", description: "Send a message to the client on a case.", inputSchema: { type: "object", properties: { case_id: { type: "string" }, body: { type: "string" }, citation: { type: "string" } }, required: ["case_id", "body"] }, annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, _meta: B({ case_id: "legal.case_id", citation: "legal.citation" }, "communicate") }
|
|
39826
|
+
];
|
|
39601
39827
|
SCRIPT = [
|
|
39602
39828
|
{ tool: "get_deals", args: {}, say: "checks this week's deals" },
|
|
39603
39829
|
{ tool: "search_products", args: { query: "coffee" }, say: "searches for coffee" },
|
|
@@ -39688,6 +39914,37 @@ var init_demo = __esm({
|
|
|
39688
39914
|
{ tool: "", args: {}, say: "in the morning, you approve exactly that release (saktum agent approve)", approveLast: true },
|
|
39689
39915
|
{ tool: "deploy_to_production", args: { repository: "payments-service", build: "build-2291" }, say: "retries the same release" }
|
|
39690
39916
|
] };
|
|
39917
|
+
SUPPORT = { id: "support", title: `Support agent: "resolve this customer's case; refunds over $100 need a person"`, server: "support", tools: SUPPORT_TOOLS.map((t) => t.name), m: {
|
|
39918
|
+
autonomy: "act",
|
|
39919
|
+
purpose: "Resolve support case 7731 for customer C-1042",
|
|
39920
|
+
actions: [{ cls: "search", autonomy: "act" }, { cls: "pay", autonomy: "act" }],
|
|
39921
|
+
rules: [{ field: "support.customer_id", op: "in", value: ["C-1042"], label: "only this case's customer" }],
|
|
39922
|
+
approveAbove: { arg: "amount", value: 100 },
|
|
39923
|
+
disclosures: { operator: "Acme support", incentives: "None", dataUse: "This case's customer only" }
|
|
39924
|
+
}, steps: [
|
|
39925
|
+
{ tool: "lookup_customer", args: { customer_id: "C-1042" }, say: "looks up the customer on the case" },
|
|
39926
|
+
{ tool: "issue_refund", args: { customer_id: "C-1042", amount: 40 }, say: "refunds $40 for the damaged item" },
|
|
39927
|
+
{ tool: "lookup_customer", args: { customer_id: "C-2077" }, say: "tries to look up a different customer" },
|
|
39928
|
+
{ tool: "issue_refund", args: { customer_id: "C-1042", amount: 250 }, say: "tries to refund $250 (goodwill)" },
|
|
39929
|
+
{ tool: "", args: {}, say: "a support lead approves exactly that refund (saktum agent approve)", approveLast: true },
|
|
39930
|
+
{ tool: "issue_refund", args: { customer_id: "C-1042", amount: 250 }, say: "retries the same refund" }
|
|
39931
|
+
] };
|
|
39932
|
+
LEGAL = { id: "legal", title: 'Legal document agent: "prepare case 7731; every client message cites its source; a lawyer approves what leaves"', server: "legal", tools: LEGAL_TOOLS.map((t) => t.name), m: {
|
|
39933
|
+
autonomy: "act",
|
|
39934
|
+
purpose: "Prepare the Express Entry file for case C-7731",
|
|
39935
|
+
actions: [{ cls: "search", autonomy: "act" }, { cls: "change", autonomy: "act" }, { cls: "communicate", autonomy: "propose" }],
|
|
39936
|
+
rules: [{ field: "legal.case_id", op: "in", value: ["C-7731"], label: "only its assigned case" }, { field: "legal.citation", op: "present", actions: ["communicate"], label: "every client message cites its source" }],
|
|
39937
|
+
review: { sample: 1, actions: ["change"] },
|
|
39938
|
+
disclosures: { operator: "Maple Path Immigration Law", incentives: "None", dataUse: "Case C-7731 only; passport data to the IRCC package and the supervising lawyer" }
|
|
39939
|
+
}, steps: [
|
|
39940
|
+
{ tool: "read_case_document", args: { case_id: "C-7731", document_type: "passport" }, say: "reads the passport on its case" },
|
|
39941
|
+
{ tool: "read_case_document", args: { case_id: "C-9120", document_type: "passport" }, say: "tries to read a passport from another case" },
|
|
39942
|
+
{ tool: "update_profile_field", args: { case_id: "C-7731", field: "passport_expiry", value: "2031-04-30" }, say: "fills the profile from the passport (sampled for lawyer review)" },
|
|
39943
|
+
{ tool: "send_client_message", args: { case_id: "C-7731", body: "Your language test is still valid." }, say: "tries to message the client without citing a source" },
|
|
39944
|
+
{ tool: "send_client_message", args: { case_id: "C-7731", body: "Your language test is valid for two years from the test date.", citation: "IRCC language test validity, rule pack ee-2026.11" }, say: "drafts the message with its citation" },
|
|
39945
|
+
{ tool: "", args: {}, say: "the supervising lawyer approves exactly that message (saktum agent approve)", approveLast: true },
|
|
39946
|
+
{ tool: "send_client_message", args: { case_id: "C-7731", body: "Your language test is valid for two years from the test date.", citation: "IRCC language test validity, rule pack ee-2026.11" }, say: "sends the approved message" }
|
|
39947
|
+
] };
|
|
39691
39948
|
}
|
|
39692
39949
|
});
|
|
39693
39950
|
|
|
@@ -40608,7 +40865,7 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
|
|
|
40608
40865
|
process.stdout.write(`Revoked the mandate for ${sanitizeText(m.agent.name, 80)} at ${r.at}. Its calls are now refused (code: revoked).
|
|
40609
40866
|
`);
|
|
40610
40867
|
});
|
|
40611
|
-
program2.command("proxy").description("Put Saktum between an agent and a local MCP server: signed receipts for every tool call, and the agent's mandate observed or enforced (preview)").argument("<command...>", "the server command, after --").option("--mandate <file>", "the agent's mandate (from saktum agent create)").option("--agent-key <file>", "the agent's key, which signs receipts", "agent-key.json").option("--enforce", "block calls outside the mandate (default: observe and record only)", false).option("--receipts <file>", "receipt log (append-only, hash-chained)").option("--revocations <file>", "revocation list to honour (default ~/.saktum/revocations.json)").option("--approvals <file>", "signed approvals to honour (default ~/.saktum/approvals.json)").option("--credential <file>", "the agent's credential: its accountability chain is verified on every call").option("--revoked-credentials <file>", "JSON list of revoked credential ids").option("--agreement <file>", "the signed agreement with the provider: calls outside it are refused and every call is metered").option("--wallet <file>", "prepaid token wallet charged per call under the agreement").option("--approval-webhook <url>", "post approval requests to this webhook (Slack, Teams or an email relay)").option("--approval-url <url>", "base link of saktum approvals serve, included in approval requests").option("--bindings <file>", "bindings override: JSON { tool: { action, bindings: { arg: field } } } for tools that declare nothing").option("--revocations-url <url>", "a remote revocation list (for example in the ledger) the agent cannot edit").option("--digest-key <spec>", "keyed digests of arguments in receipts: env:VAR (recommended)").option("--pin <fingerprint>", "refuse calls if the server's tools differ from this approved fingerprint (sha256:...)").option("--checkpoint-every <n>", "write a signed checkpoint every n receipts").option("--checkpoint-file <file>", "where checkpoints go (keep it off the agent's machine or ship it)").option("--approval-secret <spec>", "secret shared with approvals serve for single-use, per-request links: env:VAR").action(async (parts, o) => {
|
|
40868
|
+
program2.command("proxy").description("Put Saktum between an agent and a local MCP server: signed receipts for every tool call, and the agent's mandate observed or enforced (preview)").argument("<command...>", "the server command, after --").option("--mandate <file>", "the agent's mandate (from saktum agent create)").option("--agent-key <file>", "the agent's key, which signs receipts", "agent-key.json").option("--enforce", "block calls outside the mandate (default: observe and record only)", false).option("--receipts <file>", "receipt log (append-only, hash-chained)").option("--revocations <file>", "revocation list to honour (default ~/.saktum/revocations.json)").option("--approvals <file>", "signed approvals to honour (default ~/.saktum/approvals.json)").option("--credential <file>", "the agent's credential: its accountability chain is verified on every call").option("--revoked-credentials <file>", "JSON list of revoked credential ids").option("--agreement <file>", "the signed agreement with the provider: calls outside it are refused and every call is metered").option("--wallet <file>", "prepaid token wallet charged per call under the agreement").option("--approval-webhook <url>", "post approval requests to this webhook (Slack, Teams or an email relay)").option("--approval-url <url>", "base link of saktum approvals serve, included in approval requests").option("--bindings <file>", "bindings override: JSON { tool: { action, bindings: { arg: field } } } for tools that declare nothing").option("--revocations-url <url>", "a remote revocation list (for example in the ledger) the agent cannot edit").option("--digest-key <spec>", "keyed digests of arguments in receipts: env:VAR (recommended)").option("--pin <fingerprint>", "refuse calls if the server's tools differ from this approved fingerprint (sha256:...)").option("--checkpoint-every <n>", "write a signed checkpoint every n receipts").option("--checkpoint-file <file>", "where checkpoints go (keep it off the agent's machine or ship it)").option("--approval-secret <spec>", "secret shared with approvals serve for single-use, per-request links: env:VAR").option("--quarantine-results", "withhold tool results that contain instructions aimed at the agent or secrets (default: flag them in receipts)", false).action(async (parts, o) => {
|
|
40612
40869
|
const { homedir: homedir2 } = await import("node:os");
|
|
40613
40870
|
const { join: join7 } = await import("node:path");
|
|
40614
40871
|
let mandate;
|
|
@@ -40643,6 +40900,7 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
|
|
|
40643
40900
|
...o.pin ? { pin: o.pin } : {},
|
|
40644
40901
|
...o.checkpointEvery && o.checkpointFile ? { checkpointEvery: Number(o.checkpointEvery), checkpointFile: o.checkpointFile } : {},
|
|
40645
40902
|
...o.approvalSecret ? { approvalSecret: secretFrom(o.approvalSecret) } : {},
|
|
40903
|
+
...o.quarantineResults ? { quarantineResults: true } : {},
|
|
40646
40904
|
log: (m) => process.stderr.write(`saktum: ${m}
|
|
40647
40905
|
`)
|
|
40648
40906
|
});
|
|
@@ -40686,6 +40944,14 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
40686
40944
|
`);
|
|
40687
40945
|
exitCode = logs.every((l) => l.verified) ? 0 : 1;
|
|
40688
40946
|
});
|
|
40947
|
+
receipts.command("review").description("The human-review queue: allowed actions sampled for review under supervised autonomy").argument("<file>", "receipt log").action((f) => {
|
|
40948
|
+
const e = parseReceiptLog(readFileSync10(f, "utf8")).filter((x) => x.result.flags?.includes("review-sampled"));
|
|
40949
|
+
for (const x of e)
|
|
40950
|
+
process.stdout.write(`#${x.seq} ${x.receipt.issuedAt.slice(0, 16).replace("T", " ")} ${sanitizeText(x.receipt.envelope.tool, 40)} ${sanitizeText(String(x.receipt.reason ?? ""), 120)}
|
|
40951
|
+
`);
|
|
40952
|
+
process.stdout.write(`${e.length} action(s) sampled for review.
|
|
40953
|
+
`);
|
|
40954
|
+
});
|
|
40689
40955
|
receipts.command("checkpoint").description("Write a signed checkpoint of a receipt log (keep it elsewhere, so deletions are detectable)").argument("[file]", "receipt log").option("--key <spec>", "signing key").option("--out <file>", "checkpoint file", "saktum-checkpoint.json").action(async (f, o) => {
|
|
40690
40956
|
const { homedir: homedir2 } = await import("node:os");
|
|
40691
40957
|
const { join: join7 } = await import("node:path");
|
|
@@ -40852,11 +41118,18 @@ To declare them, add to each tool's definition (MCP tools accept _meta):
|
|
|
40852
41118
|
`);
|
|
40853
41119
|
});
|
|
40854
41120
|
const identity = program2.command("identity").description("Identity chains: organisation -> people -> agents");
|
|
40855
|
-
identity.command("issue").description("Issue a credential to a person or an agent, from your own credential").requiredOption("--from <credential>", "your credential (the organisation's, or one it issued to you)").requiredOption("--key <path>", "your signing key").requiredOption("--type <type>", "member or agent").requiredOption("--name <name>", "the subject's name").option("--subject-key <path>", "the subject's key file (its id is used)").option("--subject <did>", "the subject's did:key").option("--role <role>", "role, for a member").option("--expires <date>", "YYYY-MM-DD", new Date(Date.now() + 180 * 864e5).toISOString().slice(0, 10)).option("--out <file>", "credential file", "credential.json").action((o) => {
|
|
41121
|
+
identity.command("issue").description("Issue a credential to a person or an agent, from your own credential").requiredOption("--from <credential>", "your credential (the organisation's, or one it issued to you)").requiredOption("--key <path>", "your signing key").requiredOption("--type <type>", "member or agent").requiredOption("--name <name>", "the subject's name").option("--subject-key <path>", "the subject's key file (its id is used)").option("--subject <did>", "the subject's did:key").option("--role <role>", "role, for a member").option("--expires <date>", "YYYY-MM-DD", new Date(Date.now() + 180 * 864e5).toISOString().slice(0, 10)).option("--out <file>", "credential file", "credential.json").option("--minutes <n>", "short-lived: expire this many minutes from now (overrides --expires)").option("--tools <list>", "comma-separated tools this credential covers (can only narrow down the chain)").option("--max-depth <n>", "how many credentials may follow this one in a chain (0 = no further delegation)").option("--where <field=values>", "resource scope, e.g. legal.case_id=C-7731 (repeatable; values comma-separated; can only narrow)", collect, []).action((o) => {
|
|
41122
|
+
if (o.minutes)
|
|
41123
|
+
o.expires = new Date(Date.now() + Number(o.minutes) * 6e4).toISOString();
|
|
40856
41124
|
const subject = o.subject ?? (o.subjectKey ? loadOrCreateKey(o.subjectKey).kid : void 0);
|
|
40857
41125
|
if (!subject)
|
|
40858
41126
|
throw new Error("Give --subject <did:key> or --subject-key <file>.");
|
|
40859
|
-
const c = issueCredential(JSON.parse(readFileSync10(o.from, "utf8")), loadOrCreateKey(o.key), { type: o.type, id: subject, name: o.name, role: o.role, expires: o.expires })
|
|
41127
|
+
const c = issueCredential(JSON.parse(readFileSync10(o.from, "utf8")), loadOrCreateKey(o.key), { type: o.type, id: subject, name: o.name, role: o.role, expires: o.expires, ...o.tools ? { tools: o.tools.split(",").map((t) => t.trim()).filter(Boolean) } : {}, ...o.maxDepth !== void 0 ? { maxDepth: Number(o.maxDepth) } : {}, ...o.where?.length ? { where: Object.fromEntries(o.where.map((w) => {
|
|
41128
|
+
const i = w.indexOf("=");
|
|
41129
|
+
if (i < 1)
|
|
41130
|
+
throw new Error(`--where ${w}: use field=value1,value2`);
|
|
41131
|
+
return [w.slice(0, i), w.slice(i + 1).split(",").map((x) => x.trim()).filter(Boolean)];
|
|
41132
|
+
})) } : {} });
|
|
40860
41133
|
writeFileSync5(o.out, JSON.stringify(c, null, 2) + "\n");
|
|
40861
41134
|
process.stdout.write(`Issued ${c.id} to ${sanitizeText(o.name, 80)} (${o.type}). Chain: ${verifyChain(c).path.join(" -> ")}
|
|
40862
41135
|
`);
|
|
@@ -41229,11 +41502,11 @@ ${published ? published === mine ? "\u2713 Matches the published release.\n" : "
|
|
|
41229
41502
|
npm provenance: npm audit signatures
|
|
41230
41503
|
`);
|
|
41231
41504
|
});
|
|
41232
|
-
program2.command("demo").description("See permissions, autonomy, risk and receipts in 60 seconds: one shopping agent under three mandates").option("--out <dir>", "folder for the demo's mandates, receipts and passports", "saktum-demo").option("--story <name>", "grocery, travel, finance, coding, marketplace, autonomy, or all (grocery, travel, finance, coding and marketplace)", "all").action(async (o) => {
|
|
41505
|
+
program2.command("demo").description("See permissions, autonomy, risk and receipts in 60 seconds: one shopping agent under three mandates").option("--out <dir>", "folder for the demo's mandates, receipts and passports", "saktum-demo").option("--story <name>", "grocery, travel, finance, coding, support, legal, marketplace, autonomy, or all (grocery, travel, finance, coding, support, legal and marketplace)", "all").action(async (o) => {
|
|
41233
41506
|
const { runDemo: runDemo2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
|
|
41234
41507
|
await runDemo2(o.out, (l) => process.stdout.write(l + "\n"), o.story);
|
|
41235
41508
|
});
|
|
41236
|
-
program2.command("demo-server", { hidden: true }).description("The demo MCP servers (used by saktum demo)").option("--story <name>", "grocery, travel, finance, coding or autonomy", "autonomy").action(async (o) => {
|
|
41509
|
+
program2.command("demo-server", { hidden: true }).description("The demo MCP servers (used by saktum demo)").option("--story <name>", "grocery, travel, finance, coding, support, legal or autonomy", "autonomy").action(async (o) => {
|
|
41237
41510
|
const { startDemoServer: startDemoServer2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
|
|
41238
41511
|
await startDemoServer2(o.story);
|
|
41239
41512
|
});
|