saktum 0.6.0 → 0.7.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 +38 -1
- package/package.json +1 -1
- package/saktum.mjs +1782 -163
package/saktum.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Saktum Check 0.
|
|
2
|
+
// Saktum Check 0.7.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;
|
|
@@ -3061,6 +3061,19 @@ function sanitizeText(text2, maxLength = 240) {
|
|
|
3061
3061
|
function escapeHtml(text2) {
|
|
3062
3062
|
return text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
3063
3063
|
}
|
|
3064
|
+
function maxDepth(value, limit = 64) {
|
|
3065
|
+
let deepest = 0;
|
|
3066
|
+
const walk = (v, d) => {
|
|
3067
|
+
if (d > limit)
|
|
3068
|
+
throw new Error(`value nested deeper than ${limit} levels`);
|
|
3069
|
+
deepest = Math.max(deepest, d);
|
|
3070
|
+
if (v && typeof v === "object")
|
|
3071
|
+
for (const x of Object.values(v))
|
|
3072
|
+
walk(x, d + 1);
|
|
3073
|
+
};
|
|
3074
|
+
walk(value, 0);
|
|
3075
|
+
return deepest;
|
|
3076
|
+
}
|
|
3064
3077
|
var ANSI_CSI, ANSI_OSC, OTHER_ESC, C0_C1, INVISIBLE;
|
|
3065
3078
|
var init_safe = __esm({
|
|
3066
3079
|
"packages/testkit-core/dist/safe.js"() {
|
|
@@ -19186,19 +19199,389 @@ var init_embedded = __esm({
|
|
|
19186
19199
|
"description": "An agent's identity and what its human owner allows it to do, signed by the owner.",
|
|
19187
19200
|
"type": "object",
|
|
19188
19201
|
"additionalProperties": false,
|
|
19189
|
-
"required": [
|
|
19202
|
+
"required": [
|
|
19203
|
+
"mandateFormat",
|
|
19204
|
+
"agent",
|
|
19205
|
+
"owner",
|
|
19206
|
+
"allow",
|
|
19207
|
+
"issuedAt",
|
|
19208
|
+
"expires",
|
|
19209
|
+
"signature"
|
|
19210
|
+
],
|
|
19190
19211
|
"properties": {
|
|
19191
|
-
"mandateFormat": {
|
|
19192
|
-
|
|
19193
|
-
|
|
19194
|
-
"
|
|
19195
|
-
|
|
19196
|
-
"
|
|
19197
|
-
"
|
|
19198
|
-
|
|
19199
|
-
|
|
19200
|
-
|
|
19201
|
-
|
|
19212
|
+
"mandateFormat": {
|
|
19213
|
+
"const": "0.1"
|
|
19214
|
+
},
|
|
19215
|
+
"agent": {
|
|
19216
|
+
"type": "object",
|
|
19217
|
+
"additionalProperties": false,
|
|
19218
|
+
"required": [
|
|
19219
|
+
"id",
|
|
19220
|
+
"name"
|
|
19221
|
+
],
|
|
19222
|
+
"properties": {
|
|
19223
|
+
"id": {
|
|
19224
|
+
"type": "string",
|
|
19225
|
+
"pattern": "^did:key:"
|
|
19226
|
+
},
|
|
19227
|
+
"name": {
|
|
19228
|
+
"type": "string",
|
|
19229
|
+
"maxLength": 120
|
|
19230
|
+
},
|
|
19231
|
+
"software": {
|
|
19232
|
+
"type": "string",
|
|
19233
|
+
"maxLength": 200
|
|
19234
|
+
}
|
|
19235
|
+
}
|
|
19236
|
+
},
|
|
19237
|
+
"owner": {
|
|
19238
|
+
"type": "object",
|
|
19239
|
+
"additionalProperties": false,
|
|
19240
|
+
"required": [
|
|
19241
|
+
"id"
|
|
19242
|
+
],
|
|
19243
|
+
"properties": {
|
|
19244
|
+
"id": {
|
|
19245
|
+
"type": "string",
|
|
19246
|
+
"pattern": "^did:key:"
|
|
19247
|
+
},
|
|
19248
|
+
"name": {
|
|
19249
|
+
"type": "string",
|
|
19250
|
+
"maxLength": 120
|
|
19251
|
+
}
|
|
19252
|
+
}
|
|
19253
|
+
},
|
|
19254
|
+
"purpose": {
|
|
19255
|
+
"type": "string",
|
|
19256
|
+
"maxLength": 300
|
|
19257
|
+
},
|
|
19258
|
+
"allow": {
|
|
19259
|
+
"type": "object",
|
|
19260
|
+
"additionalProperties": false,
|
|
19261
|
+
"required": [
|
|
19262
|
+
"destructive"
|
|
19263
|
+
],
|
|
19264
|
+
"properties": {
|
|
19265
|
+
"servers": {
|
|
19266
|
+
"type": "array",
|
|
19267
|
+
"items": {
|
|
19268
|
+
"type": "string",
|
|
19269
|
+
"maxLength": 200
|
|
19270
|
+
}
|
|
19271
|
+
},
|
|
19272
|
+
"tools": {
|
|
19273
|
+
"type": "array",
|
|
19274
|
+
"items": {
|
|
19275
|
+
"type": "string",
|
|
19276
|
+
"maxLength": 200
|
|
19277
|
+
}
|
|
19278
|
+
},
|
|
19279
|
+
"destructive": {
|
|
19280
|
+
"type": "boolean"
|
|
19281
|
+
}
|
|
19282
|
+
}
|
|
19283
|
+
},
|
|
19284
|
+
"issuedAt": {
|
|
19285
|
+
"type": "string",
|
|
19286
|
+
"format": "date-time"
|
|
19287
|
+
},
|
|
19288
|
+
"expires": {
|
|
19289
|
+
"type": "string",
|
|
19290
|
+
"format": "date"
|
|
19291
|
+
},
|
|
19292
|
+
"signature": {
|
|
19293
|
+
"type": "object",
|
|
19294
|
+
"required": [
|
|
19295
|
+
"alg",
|
|
19296
|
+
"kid",
|
|
19297
|
+
"jws"
|
|
19298
|
+
],
|
|
19299
|
+
"properties": {
|
|
19300
|
+
"alg": {
|
|
19301
|
+
"const": "EdDSA"
|
|
19302
|
+
},
|
|
19303
|
+
"kid": {
|
|
19304
|
+
"type": "string"
|
|
19305
|
+
},
|
|
19306
|
+
"jws": {
|
|
19307
|
+
"type": "string"
|
|
19308
|
+
}
|
|
19309
|
+
}
|
|
19310
|
+
},
|
|
19311
|
+
"autonomy": {
|
|
19312
|
+
"enum": [
|
|
19313
|
+
"notify",
|
|
19314
|
+
"propose",
|
|
19315
|
+
"act"
|
|
19316
|
+
],
|
|
19317
|
+
"description": "notify: only alert the user; propose: suggest, the user approves; act: act within the limits"
|
|
19318
|
+
},
|
|
19319
|
+
"constraints": {
|
|
19320
|
+
"type": "array",
|
|
19321
|
+
"items": {
|
|
19322
|
+
"type": "object",
|
|
19323
|
+
"additionalProperties": false,
|
|
19324
|
+
"required": [
|
|
19325
|
+
"tool",
|
|
19326
|
+
"arg"
|
|
19327
|
+
],
|
|
19328
|
+
"properties": {
|
|
19329
|
+
"tool": {
|
|
19330
|
+
"type": "string",
|
|
19331
|
+
"maxLength": 200
|
|
19332
|
+
},
|
|
19333
|
+
"arg": {
|
|
19334
|
+
"type": "string",
|
|
19335
|
+
"maxLength": 100
|
|
19336
|
+
},
|
|
19337
|
+
"max": {
|
|
19338
|
+
"type": "number"
|
|
19339
|
+
},
|
|
19340
|
+
"oneOf": {
|
|
19341
|
+
"type": "array",
|
|
19342
|
+
"items": {
|
|
19343
|
+
"type": [
|
|
19344
|
+
"string",
|
|
19345
|
+
"number"
|
|
19346
|
+
]
|
|
19347
|
+
}
|
|
19348
|
+
}
|
|
19349
|
+
}
|
|
19350
|
+
}
|
|
19351
|
+
},
|
|
19352
|
+
"limits": {
|
|
19353
|
+
"type": "object",
|
|
19354
|
+
"additionalProperties": false,
|
|
19355
|
+
"properties": {
|
|
19356
|
+
"callsPerDay": {
|
|
19357
|
+
"type": "integer",
|
|
19358
|
+
"minimum": 0
|
|
19359
|
+
},
|
|
19360
|
+
"totalPerDay": {
|
|
19361
|
+
"type": "object",
|
|
19362
|
+
"additionalProperties": false,
|
|
19363
|
+
"required": [
|
|
19364
|
+
"arg",
|
|
19365
|
+
"max"
|
|
19366
|
+
],
|
|
19367
|
+
"properties": {
|
|
19368
|
+
"arg": {
|
|
19369
|
+
"type": "string",
|
|
19370
|
+
"maxLength": 100
|
|
19371
|
+
},
|
|
19372
|
+
"max": {
|
|
19373
|
+
"type": "number"
|
|
19374
|
+
}
|
|
19375
|
+
}
|
|
19376
|
+
}
|
|
19377
|
+
}
|
|
19378
|
+
},
|
|
19379
|
+
"approveAbove": {
|
|
19380
|
+
"type": "object",
|
|
19381
|
+
"additionalProperties": false,
|
|
19382
|
+
"required": [
|
|
19383
|
+
"arg",
|
|
19384
|
+
"value"
|
|
19385
|
+
],
|
|
19386
|
+
"properties": {
|
|
19387
|
+
"arg": {
|
|
19388
|
+
"type": "string",
|
|
19389
|
+
"maxLength": 100
|
|
19390
|
+
},
|
|
19391
|
+
"value": {
|
|
19392
|
+
"type": "number"
|
|
19393
|
+
}
|
|
19394
|
+
}
|
|
19395
|
+
},
|
|
19396
|
+
"disclosures": {
|
|
19397
|
+
"type": "object",
|
|
19398
|
+
"additionalProperties": false,
|
|
19399
|
+
"properties": {
|
|
19400
|
+
"operator": {
|
|
19401
|
+
"type": "string",
|
|
19402
|
+
"maxLength": 200
|
|
19403
|
+
},
|
|
19404
|
+
"incentives": {
|
|
19405
|
+
"type": "string",
|
|
19406
|
+
"maxLength": 300
|
|
19407
|
+
},
|
|
19408
|
+
"dataUse": {
|
|
19409
|
+
"type": "string",
|
|
19410
|
+
"maxLength": 300
|
|
19411
|
+
}
|
|
19412
|
+
}
|
|
19413
|
+
},
|
|
19414
|
+
"delegation": {
|
|
19415
|
+
"type": "boolean",
|
|
19416
|
+
"description": "May the agent hand work to other agents (default false)"
|
|
19417
|
+
},
|
|
19418
|
+
"actions": {
|
|
19419
|
+
"type": "array",
|
|
19420
|
+
"items": {
|
|
19421
|
+
"type": "object",
|
|
19422
|
+
"additionalProperties": false,
|
|
19423
|
+
"required": [
|
|
19424
|
+
"cls",
|
|
19425
|
+
"autonomy"
|
|
19426
|
+
],
|
|
19427
|
+
"properties": {
|
|
19428
|
+
"cls": {
|
|
19429
|
+
"enum": [
|
|
19430
|
+
"search",
|
|
19431
|
+
"cart",
|
|
19432
|
+
"substitute",
|
|
19433
|
+
"pay",
|
|
19434
|
+
"book",
|
|
19435
|
+
"change",
|
|
19436
|
+
"cancel",
|
|
19437
|
+
"communicate",
|
|
19438
|
+
"other"
|
|
19439
|
+
]
|
|
19440
|
+
},
|
|
19441
|
+
"autonomy": {
|
|
19442
|
+
"enum": [
|
|
19443
|
+
"notify",
|
|
19444
|
+
"propose",
|
|
19445
|
+
"act"
|
|
19446
|
+
]
|
|
19447
|
+
}
|
|
19448
|
+
}
|
|
19449
|
+
}
|
|
19450
|
+
},
|
|
19451
|
+
"rules": {
|
|
19452
|
+
"type": "array",
|
|
19453
|
+
"items": {
|
|
19454
|
+
"type": "object",
|
|
19455
|
+
"additionalProperties": false,
|
|
19456
|
+
"required": [
|
|
19457
|
+
"field",
|
|
19458
|
+
"op",
|
|
19459
|
+
"value"
|
|
19460
|
+
],
|
|
19461
|
+
"properties": {
|
|
19462
|
+
"field": {
|
|
19463
|
+
"type": "string",
|
|
19464
|
+
"pattern": "^[a-z]+(\\\\.[a-z_]+)+$"
|
|
19465
|
+
},
|
|
19466
|
+
"op": {
|
|
19467
|
+
"enum": [
|
|
19468
|
+
"max",
|
|
19469
|
+
"min",
|
|
19470
|
+
"eq",
|
|
19471
|
+
"in",
|
|
19472
|
+
"notIn"
|
|
19473
|
+
]
|
|
19474
|
+
},
|
|
19475
|
+
"value": {},
|
|
19476
|
+
"label": {
|
|
19477
|
+
"type": "string",
|
|
19478
|
+
"maxLength": 200
|
|
19479
|
+
}
|
|
19480
|
+
}
|
|
19481
|
+
}
|
|
19482
|
+
},
|
|
19483
|
+
"preferences": {
|
|
19484
|
+
"type": "array",
|
|
19485
|
+
"items": {
|
|
19486
|
+
"type": "object",
|
|
19487
|
+
"additionalProperties": false,
|
|
19488
|
+
"required": [
|
|
19489
|
+
"field",
|
|
19490
|
+
"prefer"
|
|
19491
|
+
],
|
|
19492
|
+
"properties": {
|
|
19493
|
+
"field": {
|
|
19494
|
+
"type": "string",
|
|
19495
|
+
"pattern": "^[a-z]+(\\\\.[a-z_]+)+$"
|
|
19496
|
+
},
|
|
19497
|
+
"prefer": {
|
|
19498
|
+
"type": [
|
|
19499
|
+
"string",
|
|
19500
|
+
"number",
|
|
19501
|
+
"boolean"
|
|
19502
|
+
]
|
|
19503
|
+
},
|
|
19504
|
+
"label": {
|
|
19505
|
+
"type": "string",
|
|
19506
|
+
"maxLength": 200
|
|
19507
|
+
}
|
|
19508
|
+
}
|
|
19509
|
+
}
|
|
19510
|
+
},
|
|
19511
|
+
"substitution": {
|
|
19512
|
+
"type": "object",
|
|
19513
|
+
"additionalProperties": false,
|
|
19514
|
+
"required": [
|
|
19515
|
+
"allowed"
|
|
19516
|
+
],
|
|
19517
|
+
"properties": {
|
|
19518
|
+
"allowed": {
|
|
19519
|
+
"type": "boolean"
|
|
19520
|
+
},
|
|
19521
|
+
"maxPriceChangePct": {
|
|
19522
|
+
"type": "number",
|
|
19523
|
+
"minimum": 0
|
|
19524
|
+
},
|
|
19525
|
+
"neverFor": {
|
|
19526
|
+
"type": "array",
|
|
19527
|
+
"items": {
|
|
19528
|
+
"type": "string",
|
|
19529
|
+
"maxLength": 100
|
|
19530
|
+
}
|
|
19531
|
+
}
|
|
19532
|
+
}
|
|
19533
|
+
},
|
|
19534
|
+
"upsell": {
|
|
19535
|
+
"enum": [
|
|
19536
|
+
"never",
|
|
19537
|
+
"ask",
|
|
19538
|
+
"allowed"
|
|
19539
|
+
]
|
|
19540
|
+
},
|
|
19541
|
+
"approvalTriggers": {
|
|
19542
|
+
"type": "array",
|
|
19543
|
+
"items": {
|
|
19544
|
+
"enum": [
|
|
19545
|
+
"substitution",
|
|
19546
|
+
"fee",
|
|
19547
|
+
"upsell",
|
|
19548
|
+
"sponsored",
|
|
19549
|
+
"new-counterparty"
|
|
19550
|
+
]
|
|
19551
|
+
}
|
|
19552
|
+
},
|
|
19553
|
+
"counterparties": {
|
|
19554
|
+
"type": "array",
|
|
19555
|
+
"items": {
|
|
19556
|
+
"type": "string",
|
|
19557
|
+
"maxLength": 200
|
|
19558
|
+
}
|
|
19559
|
+
},
|
|
19560
|
+
"dataSharing": {
|
|
19561
|
+
"type": "array",
|
|
19562
|
+
"items": {
|
|
19563
|
+
"type": "object",
|
|
19564
|
+
"additionalProperties": false,
|
|
19565
|
+
"required": [
|
|
19566
|
+
"data",
|
|
19567
|
+
"to"
|
|
19568
|
+
],
|
|
19569
|
+
"properties": {
|
|
19570
|
+
"data": {
|
|
19571
|
+
"type": "string",
|
|
19572
|
+
"maxLength": 100
|
|
19573
|
+
},
|
|
19574
|
+
"to": {
|
|
19575
|
+
"type": "string",
|
|
19576
|
+
"maxLength": 200
|
|
19577
|
+
}
|
|
19578
|
+
}
|
|
19579
|
+
}
|
|
19580
|
+
},
|
|
19581
|
+
"operatorCountersign": {
|
|
19582
|
+
"type": "object",
|
|
19583
|
+
"description": "The operator's signed statement over the mandate digest (role, name, mandate, at, signature)"
|
|
19584
|
+
}
|
|
19202
19585
|
}
|
|
19203
19586
|
}
|
|
19204
19587
|
`, "pack.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/pack/0.1.json",\n "title": "Saktum Trust Check test pack",\n "description": "A versioned set of checks. Packs are data, never code: steps use a closed set of actions, and any logic lives in named, engine-versioned analysers.",\n "type": "object",\n "required": [\n "packFormat",\n "id",\n "version",\n "category",\n "checks"\n ],\n "additionalProperties": false,\n "properties": {\n "packFormat": {\n "const": "0.1"\n },\n "id": {\n "type": "string",\n "pattern": "^[a-z][a-z0-9-]*$"\n },\n "version": {\n "type": "string",\n "pattern": "^\\\\d+\\\\.\\\\d+\\\\.\\\\d+$"\n },\n "category": {\n "enum": [\n "conformance",\n "auth",\n "security",\n "agent-experience",\n "performance",\n "functional"\n ]\n },\n "description": {\n "type": "string"\n },\n "checks": {\n "type": "array",\n "minItems": 1,\n "items": {\n "$ref": "#/$defs/check"\n }\n },\n "signature": {\n "type": "object",\n "required": [\n "alg",\n "kid",\n "jws"\n ],\n "additionalProperties": false,\n "properties": {\n "alg": {\n "const": "EdDSA"\n },\n "kid": {\n "type": "string",\n "pattern": "^did:key:z"\n },\n "jws": {\n "type": "string"\n }\n },\n "description": "Detached JWS over the canonical pack without this member. Required for packs from the feed (v0.2)."\n }\n },\n "$defs": {\n "check": {\n "type": "object",\n "required": [\n "id",\n "title",\n "severity",\n "safety",\n "steps",\n "fix"\n ],\n "additionalProperties": false,\n "properties": {\n "id": {\n "type": "string",\n "pattern": "^[a-z]+(\\\\.[a-z0-9-]+)+$"\n },\n "title": {\n "type": "string"\n },\n "severity": {\n "enum": [\n "critical",\n "high",\n "medium",\n "low",\n "info"\n ]\n },\n "safety": {\n "enum": [\n "passive",\n "active"\n ]\n },\n "scored": {\n "type": "boolean",\n "default": true\n },\n "appliesTo": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "transports": {\n "type": "array",\n "items": {\n "enum": [\n "stdio",\n "streamable-http"\n ]\n }\n },\n "protocol": {\n "type": "string",\n "description": "Minimum protocol revision, e.g. >=2025-03-26"\n }\n }\n },\n "steps": {\n "type": "array",\n "minItems": 1,\n "items": {\n "$ref": "#/$defs/step"\n }\n },\n "fix": {\n "type": "string"\n },\n "references": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "normative": {\n "type": "array",\n "description": "Baseline 4.1: the normative statements this check verifies, for the public traceability matrix.",\n "items": {\n "type": "object",\n "required": [\n "source",\n "level"\n ],\n "additionalProperties": false,\n "properties": {\n "source": {\n "type": "string",\n "description": "e.g. MCP specification, RFC 9728, OWASP MCP Top 10"\n },\n "version": {\n "type": "string",\n "description": "specification revision or date"\n },\n "clause": {\n "type": "string",\n "description": "section or requirement identifier"\n },\n "level": {\n "enum": [\n "MUST",\n "SHOULD",\n "MAY",\n "best-practice"\n ]\n }\n }\n }\n }\n }\n },\n "step": {\n "type": "object",\n "required": [\n "action"\n ],\n "additionalProperties": false,\n "properties": {\n "action": {\n "enum": [\n "mcp.initialize",\n "mcp.listTools",\n "mcp.callTool",\n "analyse"\n ]\n },\n "tool": {\n "type": "string"\n },\n "arguments": {\n "type": "object"\n },\n "analyser": {\n "type": "string"\n },\n "expect": {\n "$ref": "#/$defs/expectation"\n }\n }\n },\n "expectation": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "exists": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "isError": {\n "type": "boolean"\n },\n "errorCodeIn": {\n "type": "array",\n "items": {\n "type": "integer"\n }\n },\n "failed": {\n "type": "boolean",\n "description": "The call must not succeed: either a protocol error or a tool result flagged as an error."\n },\n "anyOf": {\n "type": "array",\n "items": {\n "$ref": "#/$defs/expectation"\n }\n }\n }\n }\n }\n}\n', "policy.schema.json": `{
|
|
@@ -19208,20 +19591,122 @@ var init_embedded = __esm({
|
|
|
19208
19591
|
"description": "An organisation's own rules for which MCP servers its people and agents may use.",
|
|
19209
19592
|
"type": "object",
|
|
19210
19593
|
"additionalProperties": false,
|
|
19211
|
-
"required": [
|
|
19594
|
+
"required": [
|
|
19595
|
+
"policyFormat"
|
|
19596
|
+
],
|
|
19212
19597
|
"properties": {
|
|
19213
|
-
"policyFormat": {
|
|
19214
|
-
|
|
19215
|
-
|
|
19216
|
-
"
|
|
19217
|
-
|
|
19218
|
-
|
|
19219
|
-
|
|
19220
|
-
"
|
|
19221
|
-
|
|
19222
|
-
|
|
19223
|
-
|
|
19224
|
-
|
|
19598
|
+
"policyFormat": {
|
|
19599
|
+
"const": "0.1"
|
|
19600
|
+
},
|
|
19601
|
+
"name": {
|
|
19602
|
+
"type": "string",
|
|
19603
|
+
"maxLength": 120
|
|
19604
|
+
},
|
|
19605
|
+
"minTrust": {
|
|
19606
|
+
"enum": [
|
|
19607
|
+
"A",
|
|
19608
|
+
"B",
|
|
19609
|
+
"C",
|
|
19610
|
+
"D",
|
|
19611
|
+
"F"
|
|
19612
|
+
]
|
|
19613
|
+
},
|
|
19614
|
+
"minReadiness": {
|
|
19615
|
+
"enum": [
|
|
19616
|
+
"A",
|
|
19617
|
+
"B",
|
|
19618
|
+
"C",
|
|
19619
|
+
"D",
|
|
19620
|
+
"F"
|
|
19621
|
+
]
|
|
19622
|
+
},
|
|
19623
|
+
"forbidCapabilities": {
|
|
19624
|
+
"type": "array",
|
|
19625
|
+
"items": {
|
|
19626
|
+
"enum": [
|
|
19627
|
+
"reads-private-data",
|
|
19628
|
+
"untrusted-content",
|
|
19629
|
+
"network",
|
|
19630
|
+
"code-execution",
|
|
19631
|
+
"filesystem",
|
|
19632
|
+
"writes-or-deletes",
|
|
19633
|
+
"sends-messages",
|
|
19634
|
+
"money"
|
|
19635
|
+
]
|
|
19636
|
+
},
|
|
19637
|
+
"uniqueItems": true
|
|
19638
|
+
},
|
|
19639
|
+
"forbidLethalTrifecta": {
|
|
19640
|
+
"type": "boolean"
|
|
19641
|
+
},
|
|
19642
|
+
"maxContextTokens": {
|
|
19643
|
+
"type": "integer",
|
|
19644
|
+
"minimum": 0
|
|
19645
|
+
},
|
|
19646
|
+
"noFailedSeverity": {
|
|
19647
|
+
"enum": [
|
|
19648
|
+
"critical",
|
|
19649
|
+
"high",
|
|
19650
|
+
"medium",
|
|
19651
|
+
"low"
|
|
19652
|
+
],
|
|
19653
|
+
"description": "Any failed check at or above this severity violates the policy"
|
|
19654
|
+
},
|
|
19655
|
+
"requireAllowlist": {
|
|
19656
|
+
"type": "boolean",
|
|
19657
|
+
"description": "Every server must match an entry (by tool fingerprint) in the allowlist file"
|
|
19658
|
+
},
|
|
19659
|
+
"allowlist": {
|
|
19660
|
+
"type": "string",
|
|
19661
|
+
"maxLength": 500,
|
|
19662
|
+
"description": "Path of a saktum allowlist file"
|
|
19663
|
+
},
|
|
19664
|
+
"exceptions": {
|
|
19665
|
+
"type": "array",
|
|
19666
|
+
"items": {
|
|
19667
|
+
"type": "object",
|
|
19668
|
+
"additionalProperties": false,
|
|
19669
|
+
"required": [
|
|
19670
|
+
"server",
|
|
19671
|
+
"reason"
|
|
19672
|
+
],
|
|
19673
|
+
"properties": {
|
|
19674
|
+
"server": {
|
|
19675
|
+
"type": "string",
|
|
19676
|
+
"maxLength": 200
|
|
19677
|
+
},
|
|
19678
|
+
"rules": {
|
|
19679
|
+
"type": "array",
|
|
19680
|
+
"items": {
|
|
19681
|
+
"type": "string"
|
|
19682
|
+
}
|
|
19683
|
+
},
|
|
19684
|
+
"reason": {
|
|
19685
|
+
"type": "string",
|
|
19686
|
+
"minLength": 3,
|
|
19687
|
+
"maxLength": 300
|
|
19688
|
+
},
|
|
19689
|
+
"approvedBy": {
|
|
19690
|
+
"type": "string",
|
|
19691
|
+
"maxLength": 120
|
|
19692
|
+
},
|
|
19693
|
+
"until": {
|
|
19694
|
+
"type": "string",
|
|
19695
|
+
"format": "date"
|
|
19696
|
+
}
|
|
19697
|
+
}
|
|
19698
|
+
}
|
|
19699
|
+
},
|
|
19700
|
+
"maxRiskTier": {
|
|
19701
|
+
"enum": [
|
|
19702
|
+
"R0",
|
|
19703
|
+
"R1",
|
|
19704
|
+
"R2",
|
|
19705
|
+
"R3",
|
|
19706
|
+
"R4"
|
|
19707
|
+
],
|
|
19708
|
+
"description": "Servers above this risk tier violate the policy unless excepted"
|
|
19709
|
+
}
|
|
19225
19710
|
}
|
|
19226
19711
|
}
|
|
19227
19712
|
`, "receipt.schema.json": `{
|
|
@@ -19296,8 +19781,8 @@ var init_embedded = __esm({
|
|
|
19296
19781
|
}
|
|
19297
19782
|
}
|
|
19298
19783
|
}
|
|
19299
|
-
`, "result.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/result/0.1.json",\n "title": "Saktum Trust Check result",\n "description": "The canonical result of one run. Every report format is rendered from this model. Evidence is a hash plus a short, sanitised excerpt; raw payloads never appear.",\n "type": "object",\n "required": [\n "resultFormat",\n "tool",\n "target",\n "packs",\n "findings",\n "scores",\n "metrics",\n "run"\n ],\n "additionalProperties": false,\n "properties": {\n "resultFormat": {\n "const": "0.1"\n },\n "tool": {\n "type": "object",\n "required": [\n "name",\n "version"\n ],\n "additionalProperties": false,\n "properties": {\n "name": {\n "const": "saktum-trust-check"\n },\n "version": {\n "type": "string"\n }\n }\n },\n "target": {\n "type": "object",\n "required": [\n "transport",\n "description"\n ],\n "additionalProperties": false,\n "properties": {\n "transport": {\n "enum": [\n "stdio",\n "streamable-http"\n ]\n },\n "description": {\n "type": "string"\n },\n "protocolVersion": {\n "type": "string"\n },\n "serverInfo": {\n "type": "object"\n },\n "toolsFingerprint": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n }\n }\n },\n "packs": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "id",\n "version",\n "hash"\n ],\n "additionalProperties": false,\n "properties": {\n "id": {\n "type": "string"\n },\n "version": {\n "type": "string"\n },\n "hash": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n }\n }\n }\n },\n "findings": {\n "type": "array",\n "items": {\n "$ref": "#/$defs/finding"\n }\n },\n "scores": {\n "type": "object",\n "required": [\n "overall",\n "capped",\n "categories"\n ],\n "additionalProperties": false,\n "properties": {\n "overall": {\n "type": [\n "integer",\n "null"\n ],\n "minimum": 0,\n "maximum": 100\n },\n "capped": {\n "type": "boolean"\n },\n "categories": {\n "type": "object",\n "additionalProperties": {\n "type": [\n "integer",\n "null"\n ]\n }\n }\n }\n },\n "metrics": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "contextCostTokens": {\n "type": "integer",\n "minimum": 0\n },\n "largestTools": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "tool",\n "tokens"\n ],\n "properties": {\n "tool": {\n "type": "string"\n },\n "tokens": {\n "type": "integer"\n }\n }\n }\n },\n "contextCostPer1kTurnsUsd": {\n "type": "number",\n "minimum": 0,\n "description": "Estimated cost of loading the tool definitions on 1,000 agent turns at pricePerMTokUsd. Reported only."\n },\n "pricePerMTokUsd": {\n "type": "number",\n "minimum": 0\n },\n "performance": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "initMs": {\n "type": "integer",\n "minimum": 0\n },\n "listMs": {\n "type": "integer",\n "minimum": 0\n },\n "listBytes": {\n "type": "integer",\n "minimum": 0\n },\n "rssMb": {\n "type": "number",\n "minimum": 0\n },\n "cpuPct": {\n "type": "number",\n "minimum": 0\n },\n "burst": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "requests": {\n "type": "integer"\n },\n "ok": {\n "type": "integer"\n },\n "rateLimited": {\n "type": "integer"\n },\n "errors": {\n "type": "integer"\n },\n "p95Ms": {\n "type": "integer"\n }\n }\n }\n }\n }\n }\n },\n "run": {\n "type": "object",\n "required": [\n "startedAt",\n "durationMs",\n "mode",\n "runner",\n "sandbox"\n ],\n "additionalProperties": false,\n "properties": {\n "startedAt": {\n "type": "string",\n "format": "date-time"\n },\n "durationMs": {\n "type": "integer",\n "minimum": 0\n },\n "mode": {\n "enum": [\n "passive",\n "active"\n ]\n },\n "runner": {\n "enum": [\n "self",\n "hosted"\n ],\n "description": "self: run and signed by the user, proves integrity not independence. hosted: run and signed by Saktum (later)."\n },\n "sandbox": {\n "enum": [\n "none",\n "docker"\n ],\n "description": "Whether local servers ran inside a container sandbox."\n }\n }\n },\n "signature": {\n "type": "object",\n "required": [\n "alg",\n "kid",\n "jws"\n ],\n "additionalProperties": false,\n "properties": {\n "alg": {\n "const": "EdDSA"\n },\n "kid": {\n "type": "string",\n "pattern": "^did:key:z"\n },\n "jws": {\n "type": "string"\n }\n }\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ],\n "description": "Letter grade from the trust score: A 90-100, B 80-89, C 70-79, D 50-69, F below 50 or any failed critical check."\n },\n "summary": {\n "type": "array",\n "maxItems": 5,\n "items": {\n "type": "string",\n "maxLength": 400\n },\n "description": "Plain-language summary sentences shown first in every report."\n },\n "assuranceLevel": {\n "enum": [\n "L1",\n "L2",\n "L3",\n "L4"\n ],\n "description": "L1 self-tested (Saktum Check); L2 independently tested; L3 certified; L4 continuously certified."\n },\n "readiness": {\n "description": "Agent readiness: a second grade beside trust (annotations, descriptions, context cost), never mixed into the trust score.",\n "oneOf": [\n {\n "type": "null"\n },\n {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "score",\n "grade",\n "toolsAnnotated",\n "toolsDescribed",\n "toolCount",\n "contextTokens"\n ],\n "properties": {\n "score": {\n "type": "integer",\n "minimum": 0,\n "maximum": 100\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ]\n },\n "toolsAnnotated": {\n "type": "integer",\n "minimum": 0\n },\n "toolsDescribed": {\n "type": "integer",\n "minimum": 0\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n },\n "contextTokens": {\n "type": "integer",\n "minimum": 0\n },\n "topImprovement": {\n "type": "string",\n "maxLength": 300\n }\n }\n }\n ]\n },\n "coverage": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "trustChecksRun": {\n "type": "integer",\n "minimum": 0\n }\n }\n },\n "capabilities": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "capabilities",\n "lethalTrifecta",\n "note"\n ],\n "properties": {\n "capabilities": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "capability",\n "label",\n "tools",\n "basis"\n ],\n "properties": {\n "capability": {\n "type": "string"\n },\n "label": {\n "type": "string",\n "maxLength": 400\n },\n "tools": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n },\n "maxItems": 20\n },\n "basis": {\n "enum": [\n "declared",\n "inferred"\n ]\n }\n }\n }\n },\n "lethalTrifecta": {\n "type": "boolean"\n },\n "note": {\n "type": "string",\n "maxLength": 400\n }\n }\n },\n "functional": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "ran",\n "calledTools",\n "notCalled",\n "calls"\n ],\n "properties": {\n "ran": {\n "type": "boolean"\n },\n "reason": {\n "type": "string",\n "maxLength": 400\n },\n "calledTools": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n },\n "survived": {\n "type": "boolean"\n },\n "notCalled": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "tool",\n "why"\n ],\n "properties": {\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "why": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n },\n "calls": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "tool",\n "purpose",\n "outcome",\n "latencyMs",\n "problems"\n ],\n "properties": {\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "purpose": {\n "type": "string",\n "maxLength": 400\n },\n "outcome": {\n "type": "string",\n "maxLength": 400\n },\n "latencyMs": {\n "type": "integer",\n "minimum": 0\n },\n "problems": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n }\n }\n },\n "load": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "operation",\n "latency",\n "levels",\n "verdicts"\n ],\n "properties": {\n "operation": {\n "type": "string",\n "maxLength": 400\n },\n "latency": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "p50": {\n "type": "number"\n },\n "p95": {\n "type": "number"\n },\n "samples": {\n "type": "integer"\n }\n }\n },\n "levels": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "concurrency",\n "requests",\n "ok",\n "rateLimited",\n "errors",\n "p95",\n "throughput"\n ],\n "properties": {\n "concurrency": {\n "type": "number",\n "minimum": 0\n },\n "requests": {\n "type": "number",\n "minimum": 0\n },\n "ok": {\n "type": "number",\n "minimum": 0\n },\n "rateLimited": {\n "type": "number",\n "minimum": 0\n },\n "errors": {\n "type": "number",\n "minimum": 0\n },\n "p95": {\n "type": "number",\n "minimum": 0\n },\n "throughput": {\n "type": "number",\n "minimum": 0\n }\n }\n }\n },\n "memoryGrowthMb": {\n "type": "number"\n },\n "verdicts": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n },\n "tests": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "id",\n "tool",\n "status",\n "problems"\n ],\n "properties": {\n "id": {\n "type": "string",\n "maxLength": 400\n },\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "status": {\n "enum": [\n "pass",\n "fail",\n "skipped"\n ]\n },\n "problems": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n },\n "latencyMs": {\n "type": "integer",\n "minimum": 0\n }\n }\n }\n },\n "suppressions": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "check",\n "reason"\n ],\n "properties": {\n "check": {\n "type": "string",\n "maxLength": 400\n },\n "reason": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n },\n "$defs": {\n "finding": {\n "type": "object",\n "required": [\n "check",\n "pack",\n "status",\n "severity",\n "title"\n ],\n "additionalProperties": false,\n "properties": {\n "check": {\n "type": "string"\n },\n "pack": {\n "type": "string"\n },\n "status": {\n "enum": [\n "pass",\n "fail",\n "skipped",\n "inconclusive",\n "info"\n ]\n },\n "severity": {\n "enum": [\n "critical",\n "high",\n "medium",\n "low",\n "info"\n ]\n },\n "scored": {\n "type": "boolean"\n },\n "title": {\n "type": "string"\n },\n "subject": {\n "type": "string"\n },\n "message": {\n "type": "string"\n },\n "fix": {\n "type": "string"\n },\n "references": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "evidence": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "hash": {\n "type": "string"\n },\n "excerpt": {\n "type": "string",\n "maxLength": 240\n }\n }\n },\n "suppressed": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "reason"\n ],\n "properties": {\n "reason": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n }\n }\n}\n', "test-cases.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/test-cases/0.1.json",\n "title": "Saktum Trust Check functional test cases (saktum.tests.yaml)",\n "type": "object",\n "required": ["testsFormat", "tests"],\n "additionalProperties": false,\n "properties": {\n "testsFormat": { "const": "0.1" },\n "tests": {\n "type": "array",\n "items": {\n "type": "object",\n "required": ["id", "tool", "input", "expect"],\n "additionalProperties": false,\n "properties": {\n "id": { "type": "string" },\n "tool": { "type": "string" },\n "input": { "type": "object" },\n "sideEffects": { "type": "boolean", "default": false, "description": "Tests with side effects run only against owned targets." },\n "expect": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "isError": { "type": "boolean" },\n "textContains": { "type": "string" },\n "structured": { "type": "object" },\n "outputSchema": { "type": "boolean" },\n "latencyMs": { "type": "object", "properties": { "lt": { "type": "integer" } }, "additionalProperties": false }\n }\n }\n }\n }\n }\n }\n}\n' };
|
|
19300
|
-
EMBEDDED_PACKS = { "agent-experience.yaml": 'packFormat: "0.1"\nid: agent-experience\nversion: 0.1.0\ncategory: agent-experience\ndescription: How easily and cheaply agents can use the server. Reported, never part of the trust score.\nchecks:\n - id: ax.context-cost\n title: Context cost of tool definitions\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: context-cost }]\n fix: Shorten long descriptions, split large servers, and drop tools agents rarely need.\n - id: ax.annotations\n title: Tools declare annotations\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: annotations-present }]\n fix: Set readOnlyHint, destructiveHint, idempotentHint and openWorldHint on every tool so clients can warn before risky actions.\n references: ["MCP specification: tool annotations", "OWASP MCP Top 10: MCP02 Privilege Escalation via Scope Creep (undeclared write and destructive tools)"]\n - id: ax.short-descriptions\n title: Tools have usable descriptions\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: short-descriptions }]\n fix: Describe what the tool does, when to use it and when not to, in at least a full sentence.\n - id: ax.client-compat\n title: Fits common client and model-provider constraints\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: client-compat }]\n fix: Use tool names of 1 to 64 letters, digits, underscores and hyphens, keep them short enough for a server prefix, and keep the tool count manageable.\n', "auth.yaml": `packFormat: "0.1"
|
|
19784
|
+
`, "result.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/result/0.1.json",\n "title": "Saktum Trust Check result",\n "description": "The canonical result of one run. Every report format is rendered from this model. Evidence is a hash plus a short, sanitised excerpt; raw payloads never appear.",\n "type": "object",\n "required": [\n "resultFormat",\n "tool",\n "target",\n "packs",\n "findings",\n "scores",\n "metrics",\n "run"\n ],\n "additionalProperties": false,\n "properties": {\n "resultFormat": {\n "const": "0.1"\n },\n "tool": {\n "type": "object",\n "required": [\n "name",\n "version"\n ],\n "additionalProperties": false,\n "properties": {\n "name": {\n "const": "saktum-trust-check"\n },\n "version": {\n "type": "string"\n }\n }\n },\n "target": {\n "type": "object",\n "required": [\n "transport",\n "description"\n ],\n "additionalProperties": false,\n "properties": {\n "transport": {\n "enum": [\n "stdio",\n "streamable-http"\n ]\n },\n "description": {\n "type": "string"\n },\n "protocolVersion": {\n "type": "string"\n },\n "serverInfo": {\n "type": "object"\n },\n "toolsFingerprint": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n }\n }\n },\n "packs": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "id",\n "version",\n "hash"\n ],\n "additionalProperties": false,\n "properties": {\n "id": {\n "type": "string"\n },\n "version": {\n "type": "string"\n },\n "hash": {\n "type": "string",\n "pattern": "^sha256:[0-9a-f]{64}$"\n }\n }\n }\n },\n "findings": {\n "type": "array",\n "items": {\n "$ref": "#/$defs/finding"\n }\n },\n "scores": {\n "type": "object",\n "required": [\n "overall",\n "capped",\n "categories"\n ],\n "additionalProperties": false,\n "properties": {\n "overall": {\n "type": [\n "integer",\n "null"\n ],\n "minimum": 0,\n "maximum": 100\n },\n "capped": {\n "type": "boolean"\n },\n "categories": {\n "type": "object",\n "additionalProperties": {\n "type": [\n "integer",\n "null"\n ]\n }\n }\n }\n },\n "metrics": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "contextCostTokens": {\n "type": "integer",\n "minimum": 0\n },\n "largestTools": {\n "type": "array",\n "items": {\n "type": "object",\n "required": [\n "tool",\n "tokens"\n ],\n "properties": {\n "tool": {\n "type": "string"\n },\n "tokens": {\n "type": "integer"\n }\n }\n }\n },\n "contextCostPer1kTurnsUsd": {\n "type": "number",\n "minimum": 0,\n "description": "Estimated cost of loading the tool definitions on 1,000 agent turns at pricePerMTokUsd. Reported only."\n },\n "pricePerMTokUsd": {\n "type": "number",\n "minimum": 0\n },\n "performance": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "initMs": {\n "type": "integer",\n "minimum": 0\n },\n "listMs": {\n "type": "integer",\n "minimum": 0\n },\n "listBytes": {\n "type": "integer",\n "minimum": 0\n },\n "rssMb": {\n "type": "number",\n "minimum": 0\n },\n "cpuPct": {\n "type": "number",\n "minimum": 0\n },\n "burst": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "requests": {\n "type": "integer"\n },\n "ok": {\n "type": "integer"\n },\n "rateLimited": {\n "type": "integer"\n },\n "errors": {\n "type": "integer"\n },\n "p95Ms": {\n "type": "integer"\n }\n }\n }\n }\n }\n }\n },\n "run": {\n "type": "object",\n "required": [\n "startedAt",\n "durationMs",\n "mode",\n "runner",\n "sandbox"\n ],\n "additionalProperties": false,\n "properties": {\n "startedAt": {\n "type": "string",\n "format": "date-time"\n },\n "durationMs": {\n "type": "integer",\n "minimum": 0\n },\n "mode": {\n "enum": [\n "passive",\n "active"\n ]\n },\n "runner": {\n "enum": [\n "self",\n "hosted"\n ],\n "description": "self: run and signed by the user, proves integrity not independence. hosted: run and signed by Saktum (later)."\n },\n "sandbox": {\n "enum": [\n "none",\n "docker"\n ],\n "description": "Whether local servers ran inside a container sandbox."\n }\n }\n },\n "signature": {\n "type": "object",\n "required": [\n "alg",\n "kid",\n "jws"\n ],\n "additionalProperties": false,\n "properties": {\n "alg": {\n "const": "EdDSA"\n },\n "kid": {\n "type": "string",\n "pattern": "^did:key:z"\n },\n "jws": {\n "type": "string"\n }\n }\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ],\n "description": "Letter grade from the trust score: A 90-100, B 80-89, C 70-79, D 50-69, F below 50 or any failed critical check."\n },\n "summary": {\n "type": "array",\n "maxItems": 5,\n "items": {\n "type": "string",\n "maxLength": 400\n },\n "description": "Plain-language summary sentences shown first in every report."\n },\n "assuranceLevel": {\n "enum": [\n "L1",\n "L2",\n "L3",\n "L4"\n ],\n "description": "L1 self-tested (Saktum Check); L2 independently tested; L3 certified; L4 continuously certified."\n },\n "readiness": {\n "description": "Agent readiness: a second grade beside trust (annotations, descriptions, context cost), never mixed into the trust score.",\n "oneOf": [\n {\n "type": "null"\n },\n {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "score",\n "grade",\n "toolsAnnotated",\n "toolsDescribed",\n "toolCount",\n "contextTokens"\n ],\n "properties": {\n "score": {\n "type": "integer",\n "minimum": 0,\n "maximum": 100\n },\n "grade": {\n "enum": [\n "A",\n "B",\n "C",\n "D",\n "F",\n null\n ]\n },\n "toolsAnnotated": {\n "type": "integer",\n "minimum": 0\n },\n "toolsDescribed": {\n "type": "integer",\n "minimum": 0\n },\n "toolCount": {\n "type": "integer",\n "minimum": 0\n },\n "contextTokens": {\n "type": "integer",\n "minimum": 0\n },\n "topImprovement": {\n "type": "string",\n "maxLength": 300\n }\n }\n }\n ]\n },\n "coverage": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "trustChecksRun": {\n "type": "integer",\n "minimum": 0\n }\n }\n },\n "capabilities": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "capabilities",\n "lethalTrifecta",\n "note"\n ],\n "properties": {\n "capabilities": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "capability",\n "label",\n "tools",\n "basis"\n ],\n "properties": {\n "capability": {\n "type": "string"\n },\n "label": {\n "type": "string",\n "maxLength": 400\n },\n "tools": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n },\n "maxItems": 20\n },\n "basis": {\n "enum": [\n "declared",\n "inferred"\n ]\n }\n }\n }\n },\n "lethalTrifecta": {\n "type": "boolean"\n },\n "note": {\n "type": "string",\n "maxLength": 400\n }\n }\n },\n "functional": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "ran",\n "calledTools",\n "notCalled",\n "calls"\n ],\n "properties": {\n "ran": {\n "type": "boolean"\n },\n "reason": {\n "type": "string",\n "maxLength": 400\n },\n "calledTools": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n },\n "survived": {\n "type": "boolean"\n },\n "notCalled": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "tool",\n "why"\n ],\n "properties": {\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "why": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n },\n "calls": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "tool",\n "purpose",\n "outcome",\n "latencyMs",\n "problems"\n ],\n "properties": {\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "purpose": {\n "type": "string",\n "maxLength": 400\n },\n "outcome": {\n "type": "string",\n "maxLength": 400\n },\n "latencyMs": {\n "type": "integer",\n "minimum": 0\n },\n "problems": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n }\n }\n },\n "load": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "operation",\n "latency",\n "levels",\n "verdicts"\n ],\n "properties": {\n "operation": {\n "type": "string",\n "maxLength": 400\n },\n "latency": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "p50": {\n "type": "number"\n },\n "p95": {\n "type": "number"\n },\n "samples": {\n "type": "integer"\n }\n }\n },\n "levels": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "concurrency",\n "requests",\n "ok",\n "rateLimited",\n "errors",\n "p95",\n "throughput"\n ],\n "properties": {\n "concurrency": {\n "type": "number",\n "minimum": 0\n },\n "requests": {\n "type": "number",\n "minimum": 0\n },\n "ok": {\n "type": "number",\n "minimum": 0\n },\n "rateLimited": {\n "type": "number",\n "minimum": 0\n },\n "errors": {\n "type": "number",\n "minimum": 0\n },\n "p95": {\n "type": "number",\n "minimum": 0\n },\n "throughput": {\n "type": "number",\n "minimum": 0\n }\n }\n }\n },\n "memoryGrowthMb": {\n "type": "number"\n },\n "verdicts": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n },\n "tests": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "id",\n "tool",\n "status",\n "problems"\n ],\n "properties": {\n "id": {\n "type": "string",\n "maxLength": 400\n },\n "tool": {\n "type": "string",\n "maxLength": 400\n },\n "status": {\n "enum": [\n "pass",\n "fail",\n "skipped"\n ]\n },\n "problems": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n },\n "latencyMs": {\n "type": "integer",\n "minimum": 0\n }\n }\n }\n },\n "suppressions": {\n "type": "array",\n "items": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "check",\n "reason"\n ],\n "properties": {\n "check": {\n "type": "string",\n "maxLength": 400\n },\n "reason": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n },\n "riskTier": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "tier",\n "label",\n "reasons",\n "requirement"\n ],\n "properties": {\n "tier": {\n "enum": [\n "R0",\n "R1",\n "R2",\n "R3",\n "R4"\n ]\n },\n "label": {\n "type": "string",\n "maxLength": 200\n },\n "reasons": {\n "type": "array",\n "items": {\n "type": "string",\n "maxLength": 400\n }\n },\n "requirement": {\n "type": "string",\n "maxLength": 300\n }\n }\n }\n },\n "$defs": {\n "finding": {\n "type": "object",\n "required": [\n "check",\n "pack",\n "status",\n "severity",\n "title"\n ],\n "additionalProperties": false,\n "properties": {\n "check": {\n "type": "string"\n },\n "pack": {\n "type": "string"\n },\n "status": {\n "enum": [\n "pass",\n "fail",\n "skipped",\n "inconclusive",\n "info"\n ]\n },\n "severity": {\n "enum": [\n "critical",\n "high",\n "medium",\n "low",\n "info"\n ]\n },\n "scored": {\n "type": "boolean"\n },\n "title": {\n "type": "string"\n },\n "subject": {\n "type": "string"\n },\n "message": {\n "type": "string"\n },\n "fix": {\n "type": "string"\n },\n "references": {\n "type": "array",\n "items": {\n "type": "string"\n }\n },\n "evidence": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "hash": {\n "type": "string"\n },\n "excerpt": {\n "type": "string",\n "maxLength": 240\n }\n }\n },\n "suppressed": {\n "type": "object",\n "additionalProperties": false,\n "required": [\n "reason"\n ],\n "properties": {\n "reason": {\n "type": "string",\n "maxLength": 400\n }\n }\n }\n }\n }\n }\n}\n', "test-cases.schema.json": '{\n "$schema": "https://json-schema.org/draft/2020-12/schema",\n "$id": "https://saktum.dev/schemas/test-cases/0.1.json",\n "title": "Saktum Trust Check functional test cases (saktum.tests.yaml)",\n "type": "object",\n "required": ["testsFormat", "tests"],\n "additionalProperties": false,\n "properties": {\n "testsFormat": { "const": "0.1" },\n "tests": {\n "type": "array",\n "items": {\n "type": "object",\n "required": ["id", "tool", "input", "expect"],\n "additionalProperties": false,\n "properties": {\n "id": { "type": "string" },\n "tool": { "type": "string" },\n "input": { "type": "object" },\n "sideEffects": { "type": "boolean", "default": false, "description": "Tests with side effects run only against owned targets." },\n "expect": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "isError": { "type": "boolean" },\n "textContains": { "type": "string" },\n "structured": { "type": "object" },\n "outputSchema": { "type": "boolean" },\n "latencyMs": { "type": "object", "properties": { "lt": { "type": "integer" } }, "additionalProperties": false }\n }\n }\n }\n }\n }\n }\n}\n' };
|
|
19785
|
+
EMBEDDED_PACKS = { "agent-experience.yaml": 'packFormat: "0.1"\nid: agent-experience\nversion: 0.1.0\ncategory: agent-experience\ndescription: How easily and cheaply agents can use the server. Reported, never part of the trust score.\nchecks:\n - id: ax.context-cost\n title: Context cost of tool definitions\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: context-cost }]\n fix: Shorten long descriptions, split large servers, and drop tools agents rarely need.\n - id: ax.annotations\n title: Tools declare annotations\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: annotations-present }]\n fix: Set readOnlyHint, destructiveHint, idempotentHint and openWorldHint on every tool so clients can warn before risky actions.\n references: ["MCP specification: tool annotations", "OWASP MCP Top 10: MCP02 Privilege Escalation via Scope Creep (undeclared write and destructive tools)"]\n - id: ax.short-descriptions\n title: Tools have usable descriptions\n severity: low\n safety: passive\n steps: [{ action: analyse, analyser: short-descriptions }]\n fix: Describe what the tool does, when to use it and when not to, in at least a full sentence.\n - id: ax.client-compat\n title: Fits common client and model-provider constraints\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: client-compat }]\n fix: Use tool names of 1 to 64 letters, digits, underscores and hyphens, keep them short enough for a server prefix, and keep the tool count manageable.\n - id: ax.payments-idempotent\n title: Tools that move money are idempotent\n severity: info\n safety: passive\n scored: false\n steps: [{ action: analyse, analyser: payments-idempotency }]\n fix: Mark payment tools idempotentHint true and accept an idempotency key, so a retried call can never charge twice.\n', "auth.yaml": `packFormat: "0.1"
|
|
19301
19786
|
id: auth
|
|
19302
19787
|
version: 0.1.0
|
|
19303
19788
|
category: auth
|
|
@@ -33511,7 +33996,7 @@ var init_dist3 = __esm({
|
|
|
33511
33996
|
init_stdio2();
|
|
33512
33997
|
init_streamableHttp();
|
|
33513
33998
|
init_types2();
|
|
33514
|
-
USER_AGENT = "saktum-check/0.
|
|
33999
|
+
USER_AGENT = "saktum-check/0.7.0 (+https://saktum.dev/check)";
|
|
33515
34000
|
LIMITS = { requestTimeoutMs: 1e4, connectTimeoutMs: 6e4, maxResponseChars: 5e6 };
|
|
33516
34001
|
LimitError = class extends Error {
|
|
33517
34002
|
};
|
|
@@ -33549,7 +34034,7 @@ var init_dist3 = __esm({
|
|
|
33549
34034
|
jsonrpc: "2.0",
|
|
33550
34035
|
id: 1,
|
|
33551
34036
|
method: "initialize",
|
|
33552
|
-
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.
|
|
34037
|
+
params: { protocolVersion: "2025-06-18", capabilities: {}, clientInfo: { name: "saktum-trust-check-probe", version: "0.7.0" } }
|
|
33553
34038
|
});
|
|
33554
34039
|
}
|
|
33555
34040
|
});
|
|
@@ -33990,6 +34475,7 @@ var init_analysers = __esm({
|
|
|
33990
34475
|
init_contracts();
|
|
33991
34476
|
init_safe();
|
|
33992
34477
|
init_provider();
|
|
34478
|
+
init_capabilities();
|
|
33993
34479
|
init_auth3();
|
|
33994
34480
|
init_leakage();
|
|
33995
34481
|
init_perf();
|
|
@@ -34018,6 +34504,13 @@ ${JSON.stringify(t.inputSchema ?? {})}`;
|
|
|
34018
34504
|
/(send|upload|post|forward) (the |all |any )?(conversation|chat history|credentials|api keys?|secrets?|tokens?) to/i
|
|
34019
34505
|
];
|
|
34020
34506
|
coreAnalysers = {
|
|
34507
|
+
"payments-idempotency": ({ tools }) => {
|
|
34508
|
+
const money = tools.filter((t) => capabilityProfile([t]).capabilities.some((c) => c.capability === "money"));
|
|
34509
|
+
if (!money.length)
|
|
34510
|
+
return { status: "pass", message: "No tools that move money were found." };
|
|
34511
|
+
const weak = money.filter((t) => t.annotations?.idempotentHint !== true && !Object.keys((t.inputSchema ?? {}).properties ?? {}).some((k) => /idempot|request_?id|client_?reference|dedup/i.test(k)));
|
|
34512
|
+
return weak.length ? { status: "info", message: `${weak.length} tool(s) that move money declare no idempotency (idempotentHint or an idempotency key): ${weak.slice(0, 5).map((t) => t.name).join(", ")}. A retried call could charge twice.` } : { status: "pass", message: `${money.length} tool(s) that move money declare idempotency.` };
|
|
34513
|
+
},
|
|
34021
34514
|
"client-compat": ({ tools }) => {
|
|
34022
34515
|
const issues = clientCompatibility(tools);
|
|
34023
34516
|
return issues.length ? { status: "info", message: issues.join(" ") } : { status: "pass", message: "Tool names and count fit the constraints common to model providers and clients." };
|
|
@@ -34348,6 +34841,56 @@ var init_readiness = __esm({
|
|
|
34348
34841
|
}
|
|
34349
34842
|
});
|
|
34350
34843
|
|
|
34844
|
+
// packages/testkit-core/dist/risk.js
|
|
34845
|
+
function riskTier(tools) {
|
|
34846
|
+
const caps = capabilityProfile(tools).capabilities;
|
|
34847
|
+
const has2 = (c) => caps.find((x) => x.capability === c);
|
|
34848
|
+
const destructive = tools.filter((t) => t.annotations?.destructiveHint === true).map((t) => t.name);
|
|
34849
|
+
const reasons = [];
|
|
34850
|
+
let tier = "R0";
|
|
34851
|
+
const bump = (t, why) => {
|
|
34852
|
+
reasons.push(why);
|
|
34853
|
+
if (t > tier)
|
|
34854
|
+
tier = t;
|
|
34855
|
+
};
|
|
34856
|
+
if (has2("money"))
|
|
34857
|
+
bump("R4", `moves money (${has2("money").tools.slice(0, 3).join(", ")})`);
|
|
34858
|
+
if (has2("code-execution"))
|
|
34859
|
+
bump("R4", `runs code or commands (${has2("code-execution").tools.slice(0, 3).join(", ")})`);
|
|
34860
|
+
if (destructive.length)
|
|
34861
|
+
bump("R3", `declares destructive tools (${destructive.slice(0, 3).join(", ")})`);
|
|
34862
|
+
if (has2("sends-messages"))
|
|
34863
|
+
bump("R3", `sends messages (${has2("sends-messages").tools.slice(0, 3).join(", ")})`);
|
|
34864
|
+
if (has2("writes-or-deletes"))
|
|
34865
|
+
bump("R2", `changes data (${has2("writes-or-deletes").tools.slice(0, 3).join(", ")})`);
|
|
34866
|
+
if (has2("reads-private-data"))
|
|
34867
|
+
bump("R1", "reads private data");
|
|
34868
|
+
if (!reasons.length)
|
|
34869
|
+
reasons.push("only reads; no capability that changes data, moves money or runs code was found");
|
|
34870
|
+
return { tier, label: RISK_LABELS[tier], reasons, requirement: TIER_REQUIREMENT[tier] };
|
|
34871
|
+
}
|
|
34872
|
+
var RISK_LABELS, TIER_REQUIREMENT;
|
|
34873
|
+
var init_risk = __esm({
|
|
34874
|
+
"packages/testkit-core/dist/risk.js"() {
|
|
34875
|
+
"use strict";
|
|
34876
|
+
init_capabilities();
|
|
34877
|
+
RISK_LABELS = {
|
|
34878
|
+
R0: "reads public information",
|
|
34879
|
+
R1: "reads private data",
|
|
34880
|
+
R2: "changes data",
|
|
34881
|
+
R3: "irreversible actions or external messages",
|
|
34882
|
+
R4: "moves money or runs code"
|
|
34883
|
+
};
|
|
34884
|
+
TIER_REQUIREMENT = {
|
|
34885
|
+
R0: "L2 (conformant)",
|
|
34886
|
+
R1: "L3 (safe by default)",
|
|
34887
|
+
R2: "L4 (agent-ready) and a mandate",
|
|
34888
|
+
R3: "L5, a mandate, approval for irreversible actions, receipts",
|
|
34889
|
+
R4: "L5, an enforced mandate with value caps, approvals, receipts and monitoring"
|
|
34890
|
+
};
|
|
34891
|
+
}
|
|
34892
|
+
});
|
|
34893
|
+
|
|
34351
34894
|
// packages/testkit-core/dist/functional.js
|
|
34352
34895
|
function exampleFor(schema, depth = 0) {
|
|
34353
34896
|
const s = obj(schema);
|
|
@@ -34837,7 +35380,7 @@ async function runTrustCheck(target, opts) {
|
|
|
34837
35380
|
}
|
|
34838
35381
|
const noGrade = signInRequired ? { kind: "sign-in" } : listError ? { kind: "list-failed", error: sanitizeText(listError, 160) } : tools.length === 0 ? { kind: "no-tools", toolsCapability: Boolean(session?.capabilities?.tools) } : void 0;
|
|
34839
35382
|
return finish(target, { ...opts, mode }, startedAt, findings, session ? { protocolVersion: session.protocolVersion, serverInfo: session.serverInfo, toolsFingerprint: fingerprint, toolCount: tools.length } : { toolCount: 0 }, metrics, session?.sandbox ?? "none", noGrade, session && !listError ? readinessFor(tools) : null, {
|
|
34840
|
-
...session && !listError && tools.length ? { capabilities: capabilityProfile(tools) } : {},
|
|
35383
|
+
...session && !listError && tools.length ? { capabilities: capabilityProfile(tools), riskTier: riskTier(tools) } : {},
|
|
34841
35384
|
...ctx.functional ? { functional: summariseFunctional(ctx.functional) } : {},
|
|
34842
35385
|
...ctx.load ? { load: ctx.load } : {},
|
|
34843
35386
|
...testResults ? { tests: testResults } : {}
|
|
@@ -34857,12 +35400,13 @@ var init_engine = __esm({
|
|
|
34857
35400
|
init_grade();
|
|
34858
35401
|
init_readiness();
|
|
34859
35402
|
init_capabilities();
|
|
35403
|
+
init_risk();
|
|
34860
35404
|
init_functional();
|
|
34861
35405
|
init_load();
|
|
34862
35406
|
init_runner();
|
|
34863
35407
|
init_safe();
|
|
34864
35408
|
init_scoring();
|
|
34865
|
-
ENGINE_VERSION = "0.
|
|
35409
|
+
ENGINE_VERSION = "0.7.0";
|
|
34866
35410
|
UNKNOWN_TOOL = "saktum_trust_check_no_such_tool";
|
|
34867
35411
|
INVALID_TOKEN = "saktum-check-deliberately-invalid-token";
|
|
34868
35412
|
baseOf = (pack, check) => ({
|
|
@@ -35123,6 +35667,8 @@ function evaluatePolicy(s, p, allowlistFingerprints, today = (/* @__PURE__ */ ne
|
|
|
35123
35667
|
if (bad.length)
|
|
35124
35668
|
v.push({ rule: "noFailedSeverity", message: `${bad.length} failed check(s) at ${p.noFailedSeverity} or above` });
|
|
35125
35669
|
}
|
|
35670
|
+
if (p.maxRiskTier && s.riskTier && s.riskTier > p.maxRiskTier)
|
|
35671
|
+
v.push({ rule: "maxRiskTier", message: `risk tier ${s.riskTier} is above the allowed ${p.maxRiskTier}` });
|
|
35126
35672
|
if (p.requireAllowlist && !(s.toolsFingerprint && allowlistFingerprints?.has(s.toolsFingerprint)))
|
|
35127
35673
|
v.push({ rule: "requireAllowlist", message: "is not on the organisation's allowlist (or its tools changed since it was approved)" });
|
|
35128
35674
|
for (const x of v) {
|
|
@@ -35141,7 +35687,8 @@ function subjectFromResult(r, name) {
|
|
|
35141
35687
|
lethalTrifecta: Boolean(r.capabilities?.lethalTrifecta),
|
|
35142
35688
|
contextTokens: r.readiness?.contextTokens ?? null,
|
|
35143
35689
|
failedSeverities: r.findings.filter((f) => f.status === "fail" && !f.suppressed).map((f) => f.severity),
|
|
35144
|
-
toolsFingerprint: r.target.toolsFingerprint
|
|
35690
|
+
toolsFingerprint: r.target.toolsFingerprint,
|
|
35691
|
+
riskTier: r.riskTier?.tier
|
|
35145
35692
|
};
|
|
35146
35693
|
}
|
|
35147
35694
|
function renderVerdict(v) {
|
|
@@ -35380,44 +35927,116 @@ var init_ledger = __esm({
|
|
|
35380
35927
|
}
|
|
35381
35928
|
});
|
|
35382
35929
|
|
|
35383
|
-
// packages/testkit-core/dist/
|
|
35384
|
-
function
|
|
35385
|
-
const
|
|
35386
|
-
|
|
35387
|
-
|
|
35388
|
-
|
|
35389
|
-
|
|
35390
|
-
|
|
35391
|
-
|
|
35392
|
-
|
|
35393
|
-
|
|
35394
|
-
|
|
35930
|
+
// packages/testkit-core/dist/vocab.js
|
|
35931
|
+
function actionClass(t) {
|
|
35932
|
+
const declared = t._meta?.["io.saktum/action"];
|
|
35933
|
+
if (typeof declared === "string")
|
|
35934
|
+
return { cls: declared, basis: "declared" };
|
|
35935
|
+
for (const [re, c] of NAME_RULES)
|
|
35936
|
+
if (re.test(t.name))
|
|
35937
|
+
return { cls: c, basis: "inferred" };
|
|
35938
|
+
return { cls: "other", basis: "inferred" };
|
|
35939
|
+
}
|
|
35940
|
+
function bindingsFor(t) {
|
|
35941
|
+
const declared = t._meta?.["io.saktum/bindings"];
|
|
35942
|
+
if (declared && typeof declared === "object")
|
|
35943
|
+
return { bindings: Object.fromEntries(Object.entries(declared).filter(([, f]) => KNOWN_FIELDS.has(f))), basis: "declared" };
|
|
35944
|
+
const props = Object.keys((t.inputSchema ?? {}).properties ?? {});
|
|
35945
|
+
const domainHint = /flight|seat|fare|trip|travel|hotel/i.test(`${t.name} ${t.description ?? ""}`) ? "travel" : "commerce";
|
|
35946
|
+
const out = {};
|
|
35947
|
+
for (const p of props)
|
|
35948
|
+
for (const [re, f] of ARG_RULES)
|
|
35949
|
+
if (re.test(p)) {
|
|
35950
|
+
out[p] = domainHint === "travel" && f === "commerce.order.total" ? "travel.fare.total" : domainHint === "travel" && f === "commerce.order.currency" ? "travel.fare.currency" : f;
|
|
35951
|
+
break;
|
|
35952
|
+
}
|
|
35953
|
+
return { bindings: out, basis: "inferred" };
|
|
35395
35954
|
}
|
|
35396
|
-
function
|
|
35397
|
-
const
|
|
35398
|
-
|
|
35399
|
-
return { ok: false, reason: `mandate signature not valid (${v.reason})` };
|
|
35400
|
-
if (v.kid !== m.owner.id)
|
|
35401
|
-
return { ok: false, reason: "mandate is not signed by its stated owner" };
|
|
35402
|
-
if (m.expires < today)
|
|
35403
|
-
return { ok: false, reason: `mandate expired on ${m.expires}` };
|
|
35404
|
-
return { ok: true };
|
|
35955
|
+
function semanticValues(t, args) {
|
|
35956
|
+
const { bindings } = bindingsFor(t);
|
|
35957
|
+
return Object.fromEntries(Object.entries(bindings).filter(([a]) => args[a] !== void 0).map(([a, f]) => [f, args[a]]));
|
|
35405
35958
|
}
|
|
35406
|
-
|
|
35407
|
-
|
|
35408
|
-
|
|
35409
|
-
if (m.allow.tools && !m.allow.tools.includes(tool))
|
|
35410
|
-
return { allow: false, reason: `tool ${tool} is not in the agent's mandate` };
|
|
35411
|
-
const destructive = ann?.destructiveHint === true || ann?.readOnlyHint === false && ann?.destructiveHint !== false;
|
|
35412
|
-
if (destructive && !m.allow.destructive)
|
|
35413
|
-
return { allow: false, reason: `tool ${tool} is declared destructive and the mandate does not allow destructive actions` };
|
|
35414
|
-
return { allow: true, reason: m.allow.tools || m.allow.servers ? "within the agent's mandate" : "mandate allows it" };
|
|
35415
|
-
}
|
|
35416
|
-
var init_agentid = __esm({
|
|
35417
|
-
"packages/testkit-core/dist/agentid.js"() {
|
|
35959
|
+
var VOCABULARIES, KNOWN_FIELDS, NAME_RULES, ARG_RULES;
|
|
35960
|
+
var init_vocab = __esm({
|
|
35961
|
+
"packages/testkit-core/dist/vocab.js"() {
|
|
35418
35962
|
"use strict";
|
|
35419
|
-
|
|
35420
|
-
|
|
35963
|
+
VOCABULARIES = {
|
|
35964
|
+
commerce: { version: "0.1", fields: [
|
|
35965
|
+
{ path: "commerce.order.total", type: "number", description: "Total amount of the order or payment" },
|
|
35966
|
+
{ path: "commerce.order.currency", type: "string", description: "Currency of the order" },
|
|
35967
|
+
{ path: "commerce.item.product", type: "string", description: "Product identifier or name" },
|
|
35968
|
+
{ path: "commerce.item.brand", type: "string", description: "Brand of the item" },
|
|
35969
|
+
{ path: "commerce.item.category", type: "string", description: "Category of the item (for example dairy, baby food, alcohol)" },
|
|
35970
|
+
{ path: "commerce.item.quantity", type: "number", description: "Quantity of the item" },
|
|
35971
|
+
{ path: "commerce.item.unit_price", type: "number", description: "Price of one unit" },
|
|
35972
|
+
{ path: "commerce.item.substitute_for", type: "string", description: "The item this one replaces (a substitution)" },
|
|
35973
|
+
{ path: "commerce.item.reference_price", type: "number", description: "Price of the item being replaced" },
|
|
35974
|
+
{ path: "commerce.item.upgrade", type: "boolean", description: "A larger or premium option than requested (an upsell)" },
|
|
35975
|
+
{ path: "commerce.item.sponsored", type: "boolean", description: "The option was sponsored or promoted" },
|
|
35976
|
+
{ path: "commerce.counterparty", type: "string", description: "The merchant or seller" }
|
|
35977
|
+
] },
|
|
35978
|
+
travel: { version: "0.1", fields: [
|
|
35979
|
+
{ path: "travel.fare.total", type: "number", description: "Total fare" },
|
|
35980
|
+
{ path: "travel.fare.currency", type: "string", description: "Currency of the fare" },
|
|
35981
|
+
{ path: "travel.fare.refundable", type: "boolean", description: "Whether the fare is refundable" },
|
|
35982
|
+
{ path: "travel.itinerary.connections", type: "number", description: "Number of connections (stops)" },
|
|
35983
|
+
{ path: "travel.itinerary.arrive_by", type: "string", description: "Latest arrival time" },
|
|
35984
|
+
{ path: "travel.carrier", type: "string", description: "Airline, rail or other carrier" },
|
|
35985
|
+
{ path: "travel.seat", type: "string", description: "Seat or seat type (aisle, window)" },
|
|
35986
|
+
{ path: "travel.fee", type: "number", description: "Any extra fee (seat, change, baggage)" },
|
|
35987
|
+
{ path: "travel.upgrade", type: "boolean", description: "A paid upgrade (an upsell)" }
|
|
35988
|
+
] }
|
|
35989
|
+
};
|
|
35990
|
+
VOCABULARIES.personal = { version: "0.1", fields: [
|
|
35991
|
+
{ path: "personal.email", type: "string", description: "The principal's email address" },
|
|
35992
|
+
{ path: "personal.phone", type: "string", description: "The principal's phone number" },
|
|
35993
|
+
{ path: "personal.address", type: "string", description: "The principal's postal or delivery address" },
|
|
35994
|
+
{ path: "personal.passport", type: "string", description: "The principal's passport or identity document number" },
|
|
35995
|
+
{ path: "party.recipient", type: "string", description: "Who receives the data or the action" }
|
|
35996
|
+
] };
|
|
35997
|
+
VOCABULARIES.enterprise = { version: "0.1", fields: [
|
|
35998
|
+
{ path: "enterprise.data_class", type: "string", description: "Classification of the data: public, internal, confidential or restricted" },
|
|
35999
|
+
{ path: "enterprise.vendor", type: "string", description: "The supplier or vendor" }
|
|
36000
|
+
] };
|
|
36001
|
+
KNOWN_FIELDS = new Set(Object.values(VOCABULARIES).flatMap((v) => v.fields.map((f) => f.path)));
|
|
36002
|
+
NAME_RULES = [
|
|
36003
|
+
[/(^|[_-])(search|find|list|get|lookup|deals|browse)([_-]|$)/i, "search"],
|
|
36004
|
+
[/(^|[_-])(substitute|replace|swap)([_-]|$)/i, "substitute"],
|
|
36005
|
+
[/(^|[_-])(add_to_cart|cart|basket)([_-]|$)|add_to_cart/i, "cart"],
|
|
36006
|
+
[/(^|[_-])(pay|payment|checkout|purchase|charge)([_-]|$)/i, "pay"],
|
|
36007
|
+
[/(^|[_-])(book|reserve|hold)([_-]|$)/i, "book"],
|
|
36008
|
+
[/(^|[_-])(change|modify|update|seat|upgrade)([_-]|$)/i, "change"],
|
|
36009
|
+
[/(^|[_-])(cancel|refund|void)([_-]|$)/i, "cancel"],
|
|
36010
|
+
[/(^|[_-])(send|email|message|notify|post)([_-]|$)/i, "communicate"]
|
|
36011
|
+
];
|
|
36012
|
+
ARG_RULES = [
|
|
36013
|
+
[/^(amount|total|order_total|price_total|grand_total)$/i, "commerce.order.total"],
|
|
36014
|
+
[/^currency$/i, "commerce.order.currency"],
|
|
36015
|
+
[/^(product|product_id|item|sku)$/i, "commerce.item.product"],
|
|
36016
|
+
[/^brand$/i, "commerce.item.brand"],
|
|
36017
|
+
[/^category$/i, "commerce.item.category"],
|
|
36018
|
+
[/^(quantity|qty|count)$/i, "commerce.item.quantity"],
|
|
36019
|
+
[/^(price|unit_price)$/i, "commerce.item.unit_price"],
|
|
36020
|
+
[/^(substitute_for|replaces|replacement_for)$/i, "commerce.item.substitute_for"],
|
|
36021
|
+
[/^(reference_price|original_price)$/i, "commerce.item.reference_price"],
|
|
36022
|
+
[/^(upgrade|premium|upsell)$/i, "commerce.item.upgrade"],
|
|
36023
|
+
[/^(sponsored|promoted)$/i, "commerce.item.sponsored"],
|
|
36024
|
+
[/^(merchant|seller|store)$/i, "commerce.counterparty"],
|
|
36025
|
+
[/^(fare|fare_total)$/i, "travel.fare.total"],
|
|
36026
|
+
[/^refundable$/i, "travel.fare.refundable"],
|
|
36027
|
+
[/^(stops|connections|max_stops)$/i, "travel.itinerary.connections"],
|
|
36028
|
+
[/^(email|email_address)$/i, "personal.email"],
|
|
36029
|
+
[/^(phone|phone_number|mobile)$/i, "personal.phone"],
|
|
36030
|
+
[/^(address|delivery_address|shipping_address)$/i, "personal.address"],
|
|
36031
|
+
[/^(passport|passport_number|id_number|document_number)$/i, "personal.passport"],
|
|
36032
|
+
[/^(recipient|partner|share_with)$/i, "party.recipient"],
|
|
36033
|
+
[/^(data_class|classification|sensitivity)$/i, "enterprise.data_class"],
|
|
36034
|
+
[/^(vendor|supplier|payee)$/i, "enterprise.vendor"],
|
|
36035
|
+
[/^(arrive_by|arrival)$/i, "travel.itinerary.arrive_by"],
|
|
36036
|
+
[/^(carrier|airline)$/i, "travel.carrier"],
|
|
36037
|
+
[/^seat$/i, "travel.seat"],
|
|
36038
|
+
[/^(fee|seat_fee|change_fee)$/i, "travel.fee"]
|
|
36039
|
+
];
|
|
35421
36040
|
}
|
|
35422
36041
|
});
|
|
35423
36042
|
|
|
@@ -35475,7 +36094,12 @@ function summariseReceipts(entries) {
|
|
|
35475
36094
|
from: entries[0]?.receipt.issuedAt,
|
|
35476
36095
|
to: entries[entries.length - 1]?.receipt.issuedAt,
|
|
35477
36096
|
medianLatencyMs: lat.length ? [...lat].sort((a, b) => a - b)[Math.floor(lat.length / 2)] : void 0,
|
|
35478
|
-
order: entries.slice(0, 50).map((e) => e.receipt.envelope.tool)
|
|
36097
|
+
order: entries.slice(0, 50).map((e) => e.receipt.envelope.tool),
|
|
36098
|
+
byCode: Object.entries(entries.reduce((a, e) => {
|
|
36099
|
+
const k = e.result.code ?? (e.receipt.outcome === "deny" ? "denied" : "ok");
|
|
36100
|
+
a[k] = (a[k] ?? 0) + 1;
|
|
36101
|
+
return a;
|
|
36102
|
+
}, {})).map(([code, count]) => ({ code, count }))
|
|
35479
36103
|
};
|
|
35480
36104
|
}
|
|
35481
36105
|
var RECEIPTS_GENESIS, argumentsHash, entryHashOf;
|
|
@@ -35489,6 +36113,335 @@ var init_receipts = __esm({
|
|
|
35489
36113
|
}
|
|
35490
36114
|
});
|
|
35491
36115
|
|
|
36116
|
+
// packages/testkit-core/dist/agentid.js
|
|
36117
|
+
import { homedir as _home } from "node:os";
|
|
36118
|
+
import { existsSync as _exists, readFileSync as _read, writeFileSync as _write, mkdirSync as _mkdir } from "node:fs";
|
|
36119
|
+
import { dirname as _dirname, join as _join } from "node:path";
|
|
36120
|
+
function createMandate(o, ownerKey) {
|
|
36121
|
+
const body = {
|
|
36122
|
+
mandateFormat: "0.1",
|
|
36123
|
+
agent: { id: o.agentId, name: sanitizeText(o.agentName, 120) },
|
|
36124
|
+
owner: { id: ownerKey.kid, ...o.ownerName ? { name: sanitizeText(o.ownerName, 120) } : {} },
|
|
36125
|
+
...o.purpose ? { purpose: sanitizeText(o.purpose, 300) } : {},
|
|
36126
|
+
allow: { ...o.servers?.length ? { servers: o.servers } : {}, ...o.tools?.length ? { tools: o.tools } : {}, destructive: o.destructive },
|
|
36127
|
+
issuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
36128
|
+
expires: o.expires,
|
|
36129
|
+
...o.autonomy ? { autonomy: o.autonomy } : {},
|
|
36130
|
+
...o.constraints?.length ? { constraints: o.constraints } : {},
|
|
36131
|
+
...o.limits && Object.keys(o.limits).length ? { limits: o.limits } : {},
|
|
36132
|
+
...o.approveAbove ? { approveAbove: o.approveAbove } : {},
|
|
36133
|
+
...o.disclosures && Object.keys(o.disclosures).length ? { disclosures: o.disclosures } : {},
|
|
36134
|
+
delegation: o.delegation === true,
|
|
36135
|
+
...o.actions?.length ? { actions: o.actions } : {},
|
|
36136
|
+
...o.rules?.length ? { rules: o.rules } : {},
|
|
36137
|
+
...o.preferences?.length ? { preferences: o.preferences } : {},
|
|
36138
|
+
...o.substitution ? { substitution: o.substitution } : {},
|
|
36139
|
+
...o.upsell ? { upsell: o.upsell } : {},
|
|
36140
|
+
...o.approvalTriggers?.length ? { approvalTriggers: o.approvalTriggers } : {},
|
|
36141
|
+
...o.counterparties?.length ? { counterparties: o.counterparties } : {},
|
|
36142
|
+
...o.dataSharing?.length ? { dataSharing: o.dataSharing } : {}
|
|
36143
|
+
};
|
|
36144
|
+
return signDocument(body, ownerKey);
|
|
36145
|
+
}
|
|
36146
|
+
function checkMandate(m, today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)) {
|
|
36147
|
+
const { operatorCountersign: _cs, ...principalPart } = m;
|
|
36148
|
+
const v = verifyDocument(principalPart);
|
|
36149
|
+
if (!v.valid)
|
|
36150
|
+
return { ok: false, reason: `mandate signature not valid (${v.reason})` };
|
|
36151
|
+
if (v.kid !== m.owner.id)
|
|
36152
|
+
return { ok: false, reason: "mandate is not signed by its stated owner" };
|
|
36153
|
+
if (m.expires < today)
|
|
36154
|
+
return { ok: false, reason: `mandate expired on ${m.expires}` };
|
|
36155
|
+
return { ok: true };
|
|
36156
|
+
}
|
|
36157
|
+
function mandateDecision(m, server, tool, ann) {
|
|
36158
|
+
if (m.allow.servers && !m.allow.servers.includes(server))
|
|
36159
|
+
return { allow: false, reason: `server ${server} is not in the agent's mandate` };
|
|
36160
|
+
if (m.allow.tools && !m.allow.tools.includes(tool))
|
|
36161
|
+
return { allow: false, reason: `tool ${tool} is not in the agent's mandate` };
|
|
36162
|
+
const destructive = ann?.destructiveHint === true || ann?.readOnlyHint === false && ann?.destructiveHint !== false;
|
|
36163
|
+
if (destructive && !m.allow.destructive)
|
|
36164
|
+
return { allow: false, reason: `tool ${tool} is declared destructive and the mandate does not allow destructive actions` };
|
|
36165
|
+
return { allow: true, reason: m.allow.tools || m.allow.servers ? "within the agent's mandate" : "mandate allows it" };
|
|
36166
|
+
}
|
|
36167
|
+
function decideCall(m, c) {
|
|
36168
|
+
const base = mandateDecision(m, c.server, c.tool, c.annotations);
|
|
36169
|
+
if (!base.allow)
|
|
36170
|
+
return { allow: false, code: base.reason.includes("destructive") ? "destructive" : "not-in-mandate", reason: base.reason };
|
|
36171
|
+
const isRead = c.annotations?.readOnlyHint === true;
|
|
36172
|
+
const autonomy = m.autonomy ?? "act";
|
|
36173
|
+
if (autonomy === "notify" && !isRead)
|
|
36174
|
+
return { allow: false, code: "notify-only", reason: `notify-only mandate: tell your user about ${c.tool} instead of doing it` };
|
|
36175
|
+
const granted = m.allow.tools?.includes(c.tool) || m.constraints?.some((k) => k.tool === c.tool);
|
|
36176
|
+
if (c.isMoney && !granted)
|
|
36177
|
+
return { allow: false, code: "money-not-granted", reason: `${c.tool} moves money and is not explicitly granted in the mandate` };
|
|
36178
|
+
for (const k of (m.constraints ?? []).filter((x) => x.tool === c.tool)) {
|
|
36179
|
+
const v = c.args[k.arg];
|
|
36180
|
+
if (k.max !== void 0 && Number(v) > k.max)
|
|
36181
|
+
return { allow: false, code: "over-cap", reason: `${k.arg} ${v} is above the cap of ${k.max}` };
|
|
36182
|
+
if (k.oneOf && !k.oneOf.map(String).includes(String(v)))
|
|
36183
|
+
return { allow: false, code: "value-not-allowed", reason: `${k.arg} ${String(v)} is not one of ${k.oneOf.join(", ")}` };
|
|
36184
|
+
}
|
|
36185
|
+
if (!isRead && m.limits?.callsPerDay !== void 0 && c.usage.callsToday >= m.limits.callsPerDay)
|
|
36186
|
+
return { allow: false, code: "daily-limit", reason: `daily limit of ${m.limits.callsPerDay} actions reached` };
|
|
36187
|
+
const tot = m.limits?.totalPerDay;
|
|
36188
|
+
if (tot && c.args[tot.arg] !== void 0 && c.usage.totalToday + Number(c.args[tot.arg]) > tot.max)
|
|
36189
|
+
return { allow: false, code: "daily-limit", reason: `daily total for ${tot.arg} would reach ${c.usage.totalToday + Number(c.args[tot.arg])}, above ${tot.max}` };
|
|
36190
|
+
const ap = m.approveAbove;
|
|
36191
|
+
if (ap && c.args[ap.arg] !== void 0 && Number(c.args[ap.arg]) > ap.value)
|
|
36192
|
+
return { allow: false, code: "approval-needed", reason: `${ap.arg} ${c.args[ap.arg]} is above the approval threshold of ${ap.value}: ask your user to approve` };
|
|
36193
|
+
if (autonomy === "propose" && !isRead)
|
|
36194
|
+
return { allow: false, code: "approval-needed", reason: `propose mandate: ask your user to approve ${c.tool} before it runs` };
|
|
36195
|
+
return { allow: true, code: "ok", reason: autonomy === "act" ? "within the mandate's limits" : "read allowed" };
|
|
36196
|
+
}
|
|
36197
|
+
function agentRiskTier(m) {
|
|
36198
|
+
if (!m.allow.tools?.length && !m.constraints?.length)
|
|
36199
|
+
return { tier: m.autonomy === "notify" ? "R1" : "depends on servers", note: "no tool list: the tier follows the servers it connects to" };
|
|
36200
|
+
const names = [.../* @__PURE__ */ new Set([...m.allow.tools ?? [], ...(m.constraints ?? []).map((k) => k.tool)])];
|
|
36201
|
+
const money = names.some((n) => /(^|[_-])(pay|payment|charge|refund|checkout|purchase|buy|order|transfer|invoice)([_-]|$)/i.test(n));
|
|
36202
|
+
const exec = names.some((n) => /(^|[_-])(exec|execute|run_command|shell|bash)([_-]|$)/i.test(n));
|
|
36203
|
+
const writes = names.some((n) => /(^|[_-])(create|update|delete|add|write|send|post|set|remove|cart)([_-]|$)/i.test(n));
|
|
36204
|
+
let tier = money || exec ? "R4" : m.allow.destructive ? "R3" : writes ? "R2" : "R0";
|
|
36205
|
+
let note = money ? "can spend money" : exec ? "can run code" : writes ? "can change data" : "reads only";
|
|
36206
|
+
if (m.autonomy === "notify") {
|
|
36207
|
+
tier = "R0";
|
|
36208
|
+
note += ", but notify-only: it cannot act";
|
|
36209
|
+
} else if (m.autonomy === "propose" && tier > "R1")
|
|
36210
|
+
note += ", but every action needs approval";
|
|
36211
|
+
else if (tier === "R4" && m.constraints?.some((k) => k.max !== void 0))
|
|
36212
|
+
note += `, capped (${m.constraints.filter((k) => k.max !== void 0).map((k) => `${k.arg} \u2264 ${k.max}`).join(", ")})`;
|
|
36213
|
+
return { tier, note };
|
|
36214
|
+
}
|
|
36215
|
+
function hasIntent(m) {
|
|
36216
|
+
return Boolean(m.purpose && (m.actions || m.rules || m.preferences || m.substitution || m.upsell || m.approvalTriggers || m.counterparties));
|
|
36217
|
+
}
|
|
36218
|
+
function decideIntent(m, tool, args, ctx = {}) {
|
|
36219
|
+
const v = semanticValues(tool, args);
|
|
36220
|
+
const r = { evaluated: [], preferences: [], flags: [] };
|
|
36221
|
+
const stop = (code, reason) => ({ allow: false, code, reason, rationale: r, values: v });
|
|
36222
|
+
const cls = actionClass(tool).cls;
|
|
36223
|
+
const auto = m.actions?.find((a) => a.cls === cls)?.autonomy;
|
|
36224
|
+
if (auto === "notify" && cls !== "search")
|
|
36225
|
+
return stop("notify-only", `only alerts for ${cls}: tell your user instead`);
|
|
36226
|
+
for (const rule of m.rules ?? []) {
|
|
36227
|
+
if (!(rule.field in v))
|
|
36228
|
+
continue;
|
|
36229
|
+
const x = v[rule.field];
|
|
36230
|
+
const ok = rule.op === "max" ? Number(x) <= Number(rule.value) : rule.op === "min" ? Number(x) >= Number(rule.value) : rule.op === "eq" ? x === rule.value : rule.op === "in" ? rule.value.map(String).includes(String(x)) : !rule.value.map((s) => String(s).toLowerCase()).includes(String(x).toLowerCase());
|
|
36231
|
+
r.evaluated.push({ rule: ruleText(rule), ok });
|
|
36232
|
+
if (!ok)
|
|
36233
|
+
return stop("rule-violated", `${ruleText(rule)} (got ${String(x)})`);
|
|
36234
|
+
}
|
|
36235
|
+
const cp = v["commerce.counterparty"];
|
|
36236
|
+
if (m.counterparties && cp !== void 0 && !m.counterparties.includes(String(cp))) {
|
|
36237
|
+
if (m.approvalTriggers?.includes("new-counterparty"))
|
|
36238
|
+
return stop("approval-needed", `new counterparty ${String(cp)}: ask your user`);
|
|
36239
|
+
return stop("counterparty-not-allowed", `${String(cp)} is not an allowed counterparty`);
|
|
36240
|
+
}
|
|
36241
|
+
const personal = Object.keys(v).filter((k) => k.startsWith("personal."));
|
|
36242
|
+
const dclass = v["enterprise.data_class"] !== void 0 ? String(v["enterprise.data_class"]).toLowerCase() : void 0;
|
|
36243
|
+
if (dclass && dclass !== "public")
|
|
36244
|
+
personal.push(`class.${dclass}`);
|
|
36245
|
+
if (personal.length) {
|
|
36246
|
+
const recipient = String(v["party.recipient"] ?? v["commerce.counterparty"] ?? v["travel.carrier"] ?? v["enterprise.vendor"] ?? ctx.server ?? "the service");
|
|
36247
|
+
const norm = (x) => x.toLowerCase().replace(/^the /, "").trim();
|
|
36248
|
+
for (const f of personal) {
|
|
36249
|
+
const kind = f.startsWith("class.") ? `${f.slice(6)} data` : f.split(".")[1];
|
|
36250
|
+
const key = kind.replace(/ data$/, "");
|
|
36251
|
+
const ok = (m.dataSharing ?? []).some((d) => norm(d.data).includes(key) && (norm(recipient).includes(norm(d.to)) || norm(d.to).includes(norm(recipient))));
|
|
36252
|
+
if (m.dataSharing) {
|
|
36253
|
+
r.evaluated.push({ rule: `share ${kind} only as permitted (to ${recipient})`, ok });
|
|
36254
|
+
if (!ok)
|
|
36255
|
+
return stop("data-not-permitted", `${kind} may not be shared with ${recipient}`);
|
|
36256
|
+
} else
|
|
36257
|
+
r.flags.push(`personal data shared: ${kind} with ${recipient}`);
|
|
36258
|
+
}
|
|
36259
|
+
}
|
|
36260
|
+
const subFor = v["commerce.item.substitute_for"];
|
|
36261
|
+
if (subFor !== void 0 || cls === "substitute") {
|
|
36262
|
+
const s = m.substitution;
|
|
36263
|
+
if (!s?.allowed)
|
|
36264
|
+
return stop("substitution-not-allowed", "substitutions are not allowed");
|
|
36265
|
+
const cat = String(v["commerce.item.category"] ?? "").toLowerCase();
|
|
36266
|
+
if (s.neverFor?.some((c) => c.toLowerCase() === cat))
|
|
36267
|
+
return stop("substitution-not-allowed", `never substitute ${cat}`);
|
|
36268
|
+
const p = Number(v["commerce.item.unit_price"]), ref = Number(v["commerce.item.reference_price"]);
|
|
36269
|
+
if (s.maxPriceChangePct !== void 0 && p > 0 && ref > 0) {
|
|
36270
|
+
const pct = Math.round((p - ref) / ref * 1e3) / 10;
|
|
36271
|
+
const ok = Math.abs(pct) <= s.maxPriceChangePct;
|
|
36272
|
+
r.evaluated.push({ rule: `substitute within ${s.maxPriceChangePct}% of the price (${pct > 0 ? "+" : ""}${pct}%)`, ok });
|
|
36273
|
+
if (!ok)
|
|
36274
|
+
return stop("substitution-not-allowed", `substitute is ${pct > 0 ? "+" : ""}${pct}% in price, above ${s.maxPriceChangePct}%`);
|
|
36275
|
+
}
|
|
36276
|
+
if (m.approvalTriggers?.includes("substitution"))
|
|
36277
|
+
return stop("approval-needed", `substitution for ${String(subFor)}: ask your user`);
|
|
36278
|
+
r.flags.push(`substitution for ${String(subFor ?? "an item")}, within policy`);
|
|
36279
|
+
}
|
|
36280
|
+
if (v["commerce.item.upgrade"] === true || v["travel.upgrade"] === true) {
|
|
36281
|
+
if (m.upsell === "never")
|
|
36282
|
+
return stop("upsell-not-allowed", "upgrades and upsells are not allowed");
|
|
36283
|
+
if (m.upsell === "ask" || m.approvalTriggers?.includes("upsell"))
|
|
36284
|
+
return stop("approval-needed", "this is an upgrade: ask your user first");
|
|
36285
|
+
r.flags.push("upgrade chosen, allowed by the mandate");
|
|
36286
|
+
}
|
|
36287
|
+
const fee = Number(v["travel.fee"] ?? 0);
|
|
36288
|
+
if (fee > 0 && m.approvalTriggers?.includes("fee"))
|
|
36289
|
+
return stop("approval-needed", `there is a fee of ${fee}: ask your user first`);
|
|
36290
|
+
if (v["commerce.item.sponsored"] === true) {
|
|
36291
|
+
if (m.approvalTriggers?.includes("sponsored"))
|
|
36292
|
+
return stop("approval-needed", "this option is sponsored: ask your user first");
|
|
36293
|
+
r.flags.push("sponsored option chosen");
|
|
36294
|
+
}
|
|
36295
|
+
for (const p of m.preferences ?? [])
|
|
36296
|
+
if (p.field in v) {
|
|
36297
|
+
const matched = String(v[p.field]).toLowerCase() === String(p.prefer).toLowerCase();
|
|
36298
|
+
r.preferences.push(matched ? `matches preference: ${p.label ?? `${FIELD_LABEL(p.field)} ${p.prefer}`}` : `differs from preference: wanted ${p.prefer}, chose ${String(v[p.field])}`);
|
|
36299
|
+
if (!matched)
|
|
36300
|
+
r.flags.push(`differs from the stated preference (${FIELD_LABEL(p.field)})`);
|
|
36301
|
+
}
|
|
36302
|
+
if (auto === "propose" && cls !== "search")
|
|
36303
|
+
return stop("approval-needed", `asks before ${cls}: ask your user to approve`);
|
|
36304
|
+
return { allow: true, code: "ok", reason: r.evaluated.length ? `within the mandate: ${r.evaluated.map((e) => e.rule).join("; ")}` : "within the mandate", rationale: r, values: v };
|
|
36305
|
+
}
|
|
36306
|
+
function describeMandate(m) {
|
|
36307
|
+
const out = [];
|
|
36308
|
+
if (m.purpose)
|
|
36309
|
+
out.push(m.purpose + ".");
|
|
36310
|
+
const verbs = { notify: "only alerts you about", propose: "asks you before", act: "does on its own:" };
|
|
36311
|
+
for (const level of ["act", "propose", "notify"]) {
|
|
36312
|
+
const cl = (m.actions ?? []).filter((a) => a.autonomy === level).map((a) => a.cls);
|
|
36313
|
+
if (cl.length)
|
|
36314
|
+
out.push(`It ${verbs[level]} ${cl.join(", ")}.`);
|
|
36315
|
+
}
|
|
36316
|
+
if (m.rules?.length)
|
|
36317
|
+
out.push(`Always: ${m.rules.map(ruleText).join("; ")}.`);
|
|
36318
|
+
if (m.substitution)
|
|
36319
|
+
out.push(m.substitution.allowed ? `Substitutes${m.substitution.maxPriceChangePct !== void 0 ? ` within ${m.substitution.maxPriceChangePct}% of the price` : ""}${m.substitution.neverFor?.length ? `, never for ${m.substitution.neverFor.join(", ")}` : ""}.` : "Never substitutes.");
|
|
36320
|
+
if (m.upsell)
|
|
36321
|
+
out.push(m.upsell === "never" ? "Never upsells." : m.upsell === "ask" ? "Asks before any upgrade." : "May choose upgrades.");
|
|
36322
|
+
if (m.approvalTriggers?.length)
|
|
36323
|
+
out.push(`Asks you first for: ${m.approvalTriggers.join(", ")}.`);
|
|
36324
|
+
if (m.preferences?.length)
|
|
36325
|
+
out.push(`Prefers: ${m.preferences.map((p) => p.label ?? `${FIELD_LABEL(p.field)} ${p.prefer}`).join("; ")}.`);
|
|
36326
|
+
if (m.counterparties?.length)
|
|
36327
|
+
out.push(`Only with: ${m.counterparties.join(", ")}.`);
|
|
36328
|
+
if (m.dataSharing?.length)
|
|
36329
|
+
out.push(`Shares: ${m.dataSharing.map((d) => `${d.data} with ${d.to} only`).join("; ")}.`);
|
|
36330
|
+
if (m.disclosures?.operator)
|
|
36331
|
+
out.push(`Operated by ${m.disclosures.operator}${m.disclosures.incentives ? ` (incentives: ${m.disclosures.incentives})` : ""}.`);
|
|
36332
|
+
return out;
|
|
36333
|
+
}
|
|
36334
|
+
function mandateDigest(m) {
|
|
36335
|
+
const { operatorCountersign: _x, ...rest } = m;
|
|
36336
|
+
return argumentsHash(JSON.parse(JSON.stringify(rest)));
|
|
36337
|
+
}
|
|
36338
|
+
function cosignMandate(m, key, name) {
|
|
36339
|
+
return { ...m, operatorCountersign: signDocument({ role: "operator", name, mandate: mandateDigest(m), at: (/* @__PURE__ */ new Date()).toISOString() }, key) };
|
|
36340
|
+
}
|
|
36341
|
+
function checkOperator(m) {
|
|
36342
|
+
const cs = m.operatorCountersign;
|
|
36343
|
+
if (!cs)
|
|
36344
|
+
return { present: false };
|
|
36345
|
+
const v = verifyDocument(cs);
|
|
36346
|
+
if (!v.valid)
|
|
36347
|
+
return { present: true, valid: false, reason: "operator signature not valid" };
|
|
36348
|
+
if (cs.mandate !== mandateDigest(m))
|
|
36349
|
+
return { present: true, valid: false, reason: "operator signed a different mandate" };
|
|
36350
|
+
return { present: true, valid: true, id: v.kid, name: cs.name };
|
|
36351
|
+
}
|
|
36352
|
+
function revokeMandate(m, reason, path = DEFAULT_REVOCATIONS()) {
|
|
36353
|
+
const r = readRevocations(path), d = mandateDigest(m);
|
|
36354
|
+
if (!r.revoked.some((x) => x.mandate === d))
|
|
36355
|
+
r.revoked.push({ mandate: d, agent: m.agent.id, at: (/* @__PURE__ */ new Date()).toISOString(), ...reason ? { reason } : {} });
|
|
36356
|
+
_mkdir(_dirname(path), { recursive: true });
|
|
36357
|
+
_write(path, JSON.stringify(r, null, 2) + "\n");
|
|
36358
|
+
return r.revoked.find((x) => x.mandate === d);
|
|
36359
|
+
}
|
|
36360
|
+
function revocationOf(m, path = DEFAULT_REVOCATIONS()) {
|
|
36361
|
+
const d = mandateDigest(m);
|
|
36362
|
+
return readRevocations(path).revoked.find((x) => x.mandate === d);
|
|
36363
|
+
}
|
|
36364
|
+
function trustStatement(entries, verified) {
|
|
36365
|
+
const allowed = entries.filter((e) => e.receipt.outcome === "allow" && e.result.status === "ok").length;
|
|
36366
|
+
const blocked = entries.filter((e) => e.receipt.outcome === "deny");
|
|
36367
|
+
const observed = entries.filter((e) => String(e.result.code ?? "").startsWith("observed-")).length;
|
|
36368
|
+
const prefs = entries.flatMap((e) => e.result.rationale?.preferences ?? []);
|
|
36369
|
+
const matched = prefs.filter((p) => p.startsWith("matches")).length;
|
|
36370
|
+
const flags = entries.flatMap((e) => e.result.rationale?.flags ?? []);
|
|
36371
|
+
const sponsored = flags.filter((f) => /sponsored/.test(f)).length, subs = flags.filter((f) => /^substitution/.test(f)).length, personal = flags.filter((f) => /^personal data/.test(f)).length;
|
|
36372
|
+
const byCode = /* @__PURE__ */ new Map();
|
|
36373
|
+
for (const b of blocked) {
|
|
36374
|
+
const c = b.result.code ?? "denied";
|
|
36375
|
+
byCode.set(c, (byCode.get(c) ?? 0) + 1);
|
|
36376
|
+
}
|
|
36377
|
+
const approved = entries.filter((e) => /^approved by /.test(String(e.receipt.reason ?? "").replace(/^\[[^\]]+\] /, ""))).length;
|
|
36378
|
+
const lines = [
|
|
36379
|
+
`${allowed} action(s) within its instructions${approved ? ` (${approved} after your signed approval)` : ""}${observed ? `; ${observed} outside them (observed, not blocked)` : "; none outside them"}.`,
|
|
36380
|
+
blocked.length ? `${blocked.length} attempt(s) stopped before reaching the service: ${[...byCode].map(([c, n]) => `${n} ${c}`).join(", ")}.` : "No attempts needed stopping.",
|
|
36381
|
+
prefs.length ? `Preferences: matched in ${matched} of ${prefs.length} choice(s).` : "No preference-relevant choices.",
|
|
36382
|
+
sponsored || subs || personal ? `Disclosed: ${[sponsored ? `${sponsored} sponsored option(s)` : "", subs ? `${subs} substitution(s)` : "", personal ? `${personal} personal-data share(s)` : ""].filter(Boolean).join(", ")}.` : "Nothing sponsored, substituted or shared that needed disclosure.",
|
|
36383
|
+
`Receipts: ${entries.length}, ${verified ? "all signed and verified" : "NOT verified"}.`
|
|
36384
|
+
];
|
|
36385
|
+
return { lines, facts: { allowed, approved, blocked: blocked.length, observed, preferences: prefs.length, matched, sponsored, substitutions: subs } };
|
|
36386
|
+
}
|
|
36387
|
+
function approvalRequestId(m, tool, args) {
|
|
36388
|
+
return "apr_" + argumentsHash({ mandate: mandateDigest(m), tool, args: argumentsHash(args) }).replace(/^sha256:/, "").slice(0, 16);
|
|
36389
|
+
}
|
|
36390
|
+
function approveAction(m, requestId, ownerKey, minutes = 60, path = DEFAULT_APPROVALS()) {
|
|
36391
|
+
if (ownerKey.kid !== m.owner.id)
|
|
36392
|
+
throw new Error("Only the mandate's owner can approve its actions.");
|
|
36393
|
+
const a = readApprovals(path);
|
|
36394
|
+
const signed = signDocument({ approval: requestId, mandate: mandateDigest(m), approvedBy: m.owner.name ?? m.owner.id, expires: new Date(Date.now() + minutes * 6e4).toISOString() }, ownerKey);
|
|
36395
|
+
a.approvals.push(signed);
|
|
36396
|
+
_mkdir(_dirname(path), { recursive: true });
|
|
36397
|
+
_write(path, JSON.stringify(a, null, 2) + "\n");
|
|
36398
|
+
return signed;
|
|
36399
|
+
}
|
|
36400
|
+
function consumeApproval(m, requestId, path = DEFAULT_APPROVALS()) {
|
|
36401
|
+
const a = readApprovals(path);
|
|
36402
|
+
if (a.used.includes(requestId))
|
|
36403
|
+
return { ok: false };
|
|
36404
|
+
for (const x of a.approvals) {
|
|
36405
|
+
if (x.approval !== requestId || x.mandate !== mandateDigest(m) || x.expires < (/* @__PURE__ */ new Date()).toISOString())
|
|
36406
|
+
continue;
|
|
36407
|
+
const v = verifyDocument(x);
|
|
36408
|
+
if (!v.valid || v.kid !== m.owner.id)
|
|
36409
|
+
continue;
|
|
36410
|
+
a.used.push(requestId);
|
|
36411
|
+
_write(path, JSON.stringify(a, null, 2) + "\n");
|
|
36412
|
+
return { ok: true, by: x.approvedBy, at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
36413
|
+
}
|
|
36414
|
+
return { ok: false };
|
|
36415
|
+
}
|
|
36416
|
+
var FIELD_LABEL, ruleText, DEFAULT_REVOCATIONS, readRevocations, DEFAULT_APPROVALS, readApprovals;
|
|
36417
|
+
var init_agentid = __esm({
|
|
36418
|
+
"packages/testkit-core/dist/agentid.js"() {
|
|
36419
|
+
"use strict";
|
|
36420
|
+
init_vocab();
|
|
36421
|
+
init_dist();
|
|
36422
|
+
init_safe();
|
|
36423
|
+
init_receipts();
|
|
36424
|
+
FIELD_LABEL = (f) => VOCABULARIES[f.split(".")[0]]?.fields.find((x) => x.path === f)?.description.toLowerCase() ?? f;
|
|
36425
|
+
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)})`);
|
|
36426
|
+
DEFAULT_REVOCATIONS = () => _join(_home(), ".saktum", "revocations.json");
|
|
36427
|
+
readRevocations = (path) => {
|
|
36428
|
+
try {
|
|
36429
|
+
return _exists(path) ? JSON.parse(_read(path, "utf8")) : { revoked: [] };
|
|
36430
|
+
} catch {
|
|
36431
|
+
return { revoked: [] };
|
|
36432
|
+
}
|
|
36433
|
+
};
|
|
36434
|
+
DEFAULT_APPROVALS = () => _join(_home(), ".saktum", "approvals.json");
|
|
36435
|
+
readApprovals = (path) => {
|
|
36436
|
+
try {
|
|
36437
|
+
return _exists(path) ? JSON.parse(_read(path, "utf8")) : { approvals: [], used: [] };
|
|
36438
|
+
} catch {
|
|
36439
|
+
return { approvals: [], used: [] };
|
|
36440
|
+
}
|
|
36441
|
+
};
|
|
36442
|
+
}
|
|
36443
|
+
});
|
|
36444
|
+
|
|
35492
36445
|
// packages/testkit-core/dist/interop.js
|
|
35493
36446
|
import { createHash as createHash2, sign as edSign, verify as edVerify } from "node:crypto";
|
|
35494
36447
|
function receiptsToOtlp(entries, o) {
|
|
@@ -35642,6 +36595,150 @@ var init_watch = __esm({
|
|
|
35642
36595
|
});
|
|
35643
36596
|
|
|
35644
36597
|
// packages/testkit-core/dist/index.js
|
|
36598
|
+
var dist_exports = {};
|
|
36599
|
+
__export(dist_exports, {
|
|
36600
|
+
ANALYSER_NEEDS: () => ANALYSER_NEEDS,
|
|
36601
|
+
AUTH_NEEDS: () => AUTH_NEEDS,
|
|
36602
|
+
CAPABILITY_LABELS: () => CAPABILITY_LABELS,
|
|
36603
|
+
CRITICAL_CAP: () => CRITICAL_CAP,
|
|
36604
|
+
DEFAULT_APPROVALS: () => DEFAULT_APPROVALS,
|
|
36605
|
+
DEFAULT_LEDGER_URL: () => DEFAULT_LEDGER_URL,
|
|
36606
|
+
DEFAULT_REVOCATIONS: () => DEFAULT_REVOCATIONS,
|
|
36607
|
+
EMBEDDED_CONTRACTS: () => EMBEDDED_CONTRACTS,
|
|
36608
|
+
EMBEDDED_PACKS: () => EMBEDDED_PACKS,
|
|
36609
|
+
ENGINE_VERSION: () => ENGINE_VERSION,
|
|
36610
|
+
FUNCTIONAL_LIMITS: () => FUNCTIONAL_LIMITS,
|
|
36611
|
+
GENESIS: () => GENESIS,
|
|
36612
|
+
INVISIBLE: () => INVISIBLE,
|
|
36613
|
+
KNOWN_FIELDS: () => KNOWN_FIELDS,
|
|
36614
|
+
LEAKAGE_NEEDS: () => LEAKAGE_NEEDS,
|
|
36615
|
+
LEAK_PATTERNS: () => LEAK_PATTERNS,
|
|
36616
|
+
LOAD: () => LOAD,
|
|
36617
|
+
MIN_GRADED_CHECKS: () => MIN_GRADED_CHECKS,
|
|
36618
|
+
PERF_NEEDS: () => PERF_NEEDS,
|
|
36619
|
+
PERF_THRESHOLDS: () => PERF_THRESHOLDS,
|
|
36620
|
+
PackError: () => PackError,
|
|
36621
|
+
READINESS: () => READINESS,
|
|
36622
|
+
RECEIPTS_GENESIS: () => RECEIPTS_GENESIS,
|
|
36623
|
+
RISK_LABELS: () => RISK_LABELS,
|
|
36624
|
+
ROI_DEFAULTS: () => ROI_DEFAULTS,
|
|
36625
|
+
SECRET_PATTERNS: () => SECRET_PATTERNS,
|
|
36626
|
+
SEVERITY_WEIGHT: () => SEVERITY_WEIGHT,
|
|
36627
|
+
SIGN_IN_HINT: () => SIGN_IN_HINT,
|
|
36628
|
+
TIER_REQUIREMENT: () => TIER_REQUIREMENT,
|
|
36629
|
+
TRUST_WEIGHTS: () => TRUST_WEIGHTS,
|
|
36630
|
+
UNKNOWN_TOOL: () => UNKNOWN_TOOL,
|
|
36631
|
+
VOCABULARIES: () => VOCABULARIES,
|
|
36632
|
+
actionClass: () => actionClass,
|
|
36633
|
+
agentRiskTier: () => agentRiskTier,
|
|
36634
|
+
allowlistFromLedger: () => allowlistFromLedger,
|
|
36635
|
+
analyseSetup: () => analyseSetup,
|
|
36636
|
+
analysers: () => analysers,
|
|
36637
|
+
appendTestCase: () => appendTestCase,
|
|
36638
|
+
appendToLedger: () => appendToLedger,
|
|
36639
|
+
approvalRequestId: () => approvalRequestId,
|
|
36640
|
+
approveAction: () => approveAction,
|
|
36641
|
+
argumentsHash: () => argumentsHash,
|
|
36642
|
+
attestationToCredential: () => attestationToCredential,
|
|
36643
|
+
authAnalysers: () => authAnalysers,
|
|
36644
|
+
bindingsFor: () => bindingsFor,
|
|
36645
|
+
buildAllowlist: () => buildAllowlist,
|
|
36646
|
+
buildAttestation: () => buildAttestation,
|
|
36647
|
+
buildFleet: () => buildFleet,
|
|
36648
|
+
capabilityProfile: () => capabilityProfile,
|
|
36649
|
+
chainEntry: () => chainEntry,
|
|
36650
|
+
checkAttestation: () => checkAttestation,
|
|
36651
|
+
checkMandate: () => checkMandate,
|
|
36652
|
+
checkNeedsSession: () => checkNeedsSession,
|
|
36653
|
+
checkOperator: () => checkOperator,
|
|
36654
|
+
clientCompatibility: () => clientCompatibility,
|
|
36655
|
+
compileContract: () => compileContract,
|
|
36656
|
+
compileUntrustedSchema: () => compileUntrustedSchema,
|
|
36657
|
+
compileUntrustedSchemaValidator: () => compileUntrustedSchemaValidator,
|
|
36658
|
+
configLocations: () => configLocations,
|
|
36659
|
+
consumeApproval: () => consumeApproval,
|
|
36660
|
+
contextCost: () => contextCost,
|
|
36661
|
+
contractText: () => contractText,
|
|
36662
|
+
contractsDir: () => contractsDir,
|
|
36663
|
+
cosignMandate: () => cosignMandate,
|
|
36664
|
+
createMandate: () => createMandate,
|
|
36665
|
+
decideCall: () => decideCall,
|
|
36666
|
+
decideIntent: () => decideIntent,
|
|
36667
|
+
describeMandate: () => describeMandate,
|
|
36668
|
+
diffLocks: () => diffLocks,
|
|
36669
|
+
docsFor: () => docsFor,
|
|
36670
|
+
escapeHtml: () => escapeHtml,
|
|
36671
|
+
evaluatePolicy: () => evaluatePolicy,
|
|
36672
|
+
exampleFor: () => exampleFor,
|
|
36673
|
+
extractJson: () => extractJson,
|
|
36674
|
+
findInLedger: () => findInLedger,
|
|
36675
|
+
fleetHtml: () => fleetHtml,
|
|
36676
|
+
gradeFor: () => gradeFor,
|
|
36677
|
+
hasIntent: () => hasIntent,
|
|
36678
|
+
invalidArgProblems: () => invalidArgProblems,
|
|
36679
|
+
invalidArgsFor: () => invalidArgsFor,
|
|
36680
|
+
leakageAnalysers: () => leakageAnalysers,
|
|
36681
|
+
lintPaths: () => lintPaths,
|
|
36682
|
+
lintSarif: () => lintSarif,
|
|
36683
|
+
lintSource: () => lintSource,
|
|
36684
|
+
loadEmbeddedPacks: () => loadEmbeddedPacks,
|
|
36685
|
+
loadPack: () => loadPack,
|
|
36686
|
+
loadPackDir: () => loadPackDir,
|
|
36687
|
+
loadPackText: () => loadPackText,
|
|
36688
|
+
mandateDecision: () => mandateDecision,
|
|
36689
|
+
mandateDigest: () => mandateDigest,
|
|
36690
|
+
maxDepth: () => maxDepth,
|
|
36691
|
+
measureLoad: () => measureLoad,
|
|
36692
|
+
needsOf: () => needsOf,
|
|
36693
|
+
outcomeText: () => outcomeText,
|
|
36694
|
+
parseChallenge: () => parseChallenge,
|
|
36695
|
+
parseClientConfig: () => parseClientConfig,
|
|
36696
|
+
parseLedger: () => parseLedger,
|
|
36697
|
+
parsePolicy: () => parsePolicy,
|
|
36698
|
+
parseReceiptLog: () => parseReceiptLog,
|
|
36699
|
+
parseTestCases: () => parseTestCases,
|
|
36700
|
+
percentile: () => percentile,
|
|
36701
|
+
perfAnalysers: () => perfAnalysers,
|
|
36702
|
+
readinessFor: () => readinessFor,
|
|
36703
|
+
receiptsToOtlp: () => receiptsToOtlp,
|
|
36704
|
+
redactCommand: () => redactCommand,
|
|
36705
|
+
redactUrl: () => redactUrl,
|
|
36706
|
+
renderFix: () => renderFix,
|
|
36707
|
+
renderFleet: () => renderFleet,
|
|
36708
|
+
renderSetup: () => renderSetup,
|
|
36709
|
+
renderVerdict: () => renderVerdict,
|
|
36710
|
+
resultProblems: () => resultProblems,
|
|
36711
|
+
revocationOf: () => revocationOf,
|
|
36712
|
+
revokeMandate: () => revokeMandate,
|
|
36713
|
+
riskTier: () => riskTier,
|
|
36714
|
+
roiEstimate: () => roiEstimate,
|
|
36715
|
+
runCheck: () => runCheck,
|
|
36716
|
+
runFunctional: () => runFunctional,
|
|
36717
|
+
runTestCases: () => runTestCases,
|
|
36718
|
+
runTrustCheck: () => runTrustCheck,
|
|
36719
|
+
sanitizeText: () => sanitizeText,
|
|
36720
|
+
schemaDialect: () => schemaDialect,
|
|
36721
|
+
score: () => score,
|
|
36722
|
+
semanticValues: () => semanticValues,
|
|
36723
|
+
signCredentialJwt: () => signCredentialJwt,
|
|
36724
|
+
signReceipt: () => signReceipt,
|
|
36725
|
+
sourceFiles: () => sourceFiles,
|
|
36726
|
+
splitCommand: () => splitCommand,
|
|
36727
|
+
subjectFromResult: () => subjectFromResult,
|
|
36728
|
+
subsetMatch: () => subsetMatch,
|
|
36729
|
+
suggestAnnotations: () => suggestAnnotations,
|
|
36730
|
+
summarise: () => summarise,
|
|
36731
|
+
summariseReceipts: () => summariseReceipts,
|
|
36732
|
+
toolsContextCost: () => contextCost,
|
|
36733
|
+
toolsLock: () => toolsLock,
|
|
36734
|
+
trustStatement: () => trustStatement,
|
|
36735
|
+
verifyCredentialJwt: () => verifyCredentialJwt,
|
|
36736
|
+
verifyLedger: () => verifyLedger,
|
|
36737
|
+
verifyReceipt: () => verifyReceipt,
|
|
36738
|
+
verifyReceiptLog: () => verifyReceiptLog,
|
|
36739
|
+
watchAllowlist: () => watchAllowlist,
|
|
36740
|
+
wellKnownUrls: () => wellKnownUrls
|
|
36741
|
+
});
|
|
35645
36742
|
var init_dist4 = __esm({
|
|
35646
36743
|
"packages/testkit-core/dist/index.js"() {
|
|
35647
36744
|
"use strict";
|
|
@@ -35672,6 +36769,8 @@ var init_dist4 = __esm({
|
|
|
35672
36769
|
init_receipts();
|
|
35673
36770
|
init_interop();
|
|
35674
36771
|
init_watch();
|
|
36772
|
+
init_risk();
|
|
36773
|
+
init_vocab();
|
|
35675
36774
|
}
|
|
35676
36775
|
});
|
|
35677
36776
|
|
|
@@ -35696,24 +36795,41 @@ function renderServerPassport(r, tools, o = {}) {
|
|
|
35696
36795
|
}).join("");
|
|
35697
36796
|
const body = `<div class="card"><div class="top"><div class="seal" style="background:${GRADE_COLOUR[g] ?? "#757575"}">${esc2(g)}</div>
|
|
35698
36797
|
<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>
|
|
35699
|
-
<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`)}${chip("Assurance", r.assuranceLevel ?? "L1")}${o.ledgerEntry ? chip("Ledger entry", `#${o.ledgerEntry}`) : ""}</div></div>
|
|
36798
|
+
<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>
|
|
35700
36799
|
<div class="card"><h2>Maturity</h2>${levelBar(lvl, lvl === 4 ? "L5 also needs supply-chain evidence (provenance, no install scripts)" : void 0)}</div>
|
|
36800
|
+
${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>` : ""}
|
|
35701
36801
|
<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>
|
|
35702
36802
|
<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>
|
|
35703
36803
|
<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 (L1) unless stated otherwise. A passport describes these exact tools at that time; any tool change needs a new one.</p></div>`;
|
|
35704
36804
|
return page(`${name}: MCP Server Passport`, body);
|
|
35705
36805
|
}
|
|
35706
|
-
function renderAgentPassport(m, valid, receipts) {
|
|
36806
|
+
function renderAgentPassport(m, valid, receipts, tier, plain, extra = {}) {
|
|
36807
|
+
const AUTO = { notify: "Notify only: it alerts, never acts", propose: "Propose: it suggests, you approve", act: "Act: within the limits below" };
|
|
36808
|
+
const perms = [
|
|
36809
|
+
["Autonomy", AUTO[m.autonomy ?? "act"] ?? "Act"],
|
|
36810
|
+
...(m.constraints ?? []).map((k) => [`${k.tool}.${k.arg}`, k.max !== void 0 ? `at most ${k.max}` : `only ${(k.oneOf ?? []).join(", ")}`]),
|
|
36811
|
+
...m.approveAbove ? [["Approval", `ask above ${m.approveAbove.arg} ${m.approveAbove.value}`]] : [],
|
|
36812
|
+
...m.limits?.callsPerDay !== void 0 ? [["Daily actions", `at most ${m.limits.callsPerDay}`]] : [],
|
|
36813
|
+
...m.limits?.totalPerDay ? [["Daily total", `${m.limits.totalPerDay.arg} at most ${m.limits.totalPerDay.max}`]] : [],
|
|
36814
|
+
["Delegation", m.delegation ? "may hand work to other agents" : "may not hand work to other agents"],
|
|
36815
|
+
...m.disclosures?.operator ? [["Operated by", m.disclosures.operator]] : [],
|
|
36816
|
+
...m.disclosures?.incentives ? [["Incentives", m.disclosures.incentives]] : [],
|
|
36817
|
+
...m.disclosures?.dataUse ? [["Data use", m.disclosures.dataUse]] : []
|
|
36818
|
+
].map(([k, v]) => `<tr><td><b>${esc2(k)}</b></td><td>${esc2(v)}</td></tr>`).join("");
|
|
35707
36819
|
const s = receipts?.summary;
|
|
35708
36820
|
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>');
|
|
35709
36821
|
const body = `<div class="card"><div class="top"><div class="seal" style="background:${valid.ok ? "#5a3fc0" : "#c62828"}">AI</div>
|
|
35710
36822
|
<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>
|
|
35711
|
-
<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")}${s ? chip("Receipts", receipts.verified ? "verified" : "DO NOT verify", receipts.verified ? "#2e7d32" : "#c62828") : ""}</div>${valid.ok ? "" : `<p><b>${esc2(valid.reason)}</b></p>`}</div>
|
|
36823
|
+
<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>
|
|
36824
|
+
${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>` : ""}
|
|
36825
|
+
${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>` : ""}
|
|
36826
|
+
<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>
|
|
35712
36827
|
<div class="card"><h2>Mandate</h2><div class="grid"><div class="kv"><small>Servers</small><b>${esc2(m.allow.servers?.join(", ") ?? "any")}</b></div><div class="kv"><small>Tools</small><b>${esc2(m.allow.tools?.join(", ") ?? "any")}</b></div><div class="kv"><small>Issued</small><b>${esc2(m.issuedAt.slice(0, 10))}</b></div></div>
|
|
35713
|
-
<p class="muted">Agent identity <code>${esc2(m.agent.id)}</code
|
|
36828
|
+
<p class="muted">Agent identity <code>${esc2(m.agent.id)}</code>${m.agent.software ? ` running ${esc2(m.agent.software)}` : ""}, signed by its owner <code>${esc2(m.owner.id)}</code>${extra.operator ? ` and countersigned by the operator ${esc2(extra.operator)}` : ""}.</p></div>
|
|
35714
36829
|
${s ? `<div class="card"><h2>What it did</h2><div class="grid"><div class="kv"><small>Tool calls</small><b>${s.calls}</b></div><div class="kv"><small>Blocked</small><b>${s.denied}</b></div><div class="kv"><small>Errors</small><b>${s.errors}</b></div><div class="kv"><small>Destructive actions</small><b>${s.destructiveAllowed}</b></div></div>
|
|
35715
36830
|
${s.repeatedIdenticalCalls.length ? `<p><b>Repeated identical calls:</b> ${s.repeatedIdenticalCalls.map((x) => `${esc2(x.call)} \xD7${x.times}`).join(", ")} (possible retry storm; highlighted below).</p>` : ""}
|
|
35716
|
-
<h2 style="margin-top:14px">The path, not the answer</h2><div class="timeline">${steps}</div
|
|
36831
|
+
<h2 style="margin-top:14px">The path, not the answer</h2><div class="timeline">${steps}</div>
|
|
36832
|
+
${(receipts?.timeline ?? []).some((t) => t.why) ? `<h2 style="margin-top:14px">Why, step by step</h2><div class="wrap"><table>${(receipts?.timeline ?? []).map((t, i) => `<tr><td>${i + 1}</td><td><span class="step ${t.outcome === "deny" ? "deny" : t.status === "ok" ? "ok" : "err"}">${esc2(t.tool)}</span></td><td>${esc2(t.why ?? "")}</td></tr>`).join("")}</table></div>` : ""}<p class="muted">${esc2(s.from?.slice(0, 19).replace("T", " ") ?? "")} to ${esc2(s.to?.slice(0, 19).replace("T", " ") ?? "")} \xB7 ${esc2(s.servers.join(", "))}. Each step is a signed, hash-chained receipt; arguments are stored only as digests.</p></div>` : ""}
|
|
35717
36833
|
<div class="card"><h2>Verify</h2><p><code>npx saktum agent verify agent-mandate.json</code> \xB7 <code>npx saktum receipts verify</code></p><p class="muted">Preview: receipts are signed by the agent side; the Saktum gateway adds the server side's signature.</p></div>`;
|
|
35718
36834
|
return page(`${m.agent.name}: Agent Passport`, body);
|
|
35719
36835
|
}
|
|
@@ -35844,6 +36960,8 @@ function trustCard(r) {
|
|
|
35844
36960
|
rows.push({ dimension: "Performance", mark: "-", text: `start-up and tool-list latency only${r.metrics.performance?.listMs !== void 0 ? ` (${r.metrics.performance.listMs} ms)` : ""}; run with --active for latency percentiles and concurrency` });
|
|
35845
36961
|
if (r.readiness)
|
|
35846
36962
|
rows.push({ dimension: "Agent readiness", mark: r.readiness.grade ?? "-", text: r.readiness.topImprovement ? `${r.readiness.topImprovement}` : "annotations, descriptions and context cost all good" });
|
|
36963
|
+
if (r.riskTier)
|
|
36964
|
+
rows.push({ dimension: "Risk tier", mark: r.riskTier.tier, text: `${r.riskTier.label}: ${r.riskTier.reasons.join("; ")}. Needs ${r.riskTier.requirement}.` });
|
|
35847
36965
|
if (r.capabilities) {
|
|
35848
36966
|
const caps = r.capabilities.capabilities.map((c) => c.label);
|
|
35849
36967
|
rows.push({ dimension: "Capabilities", mark: r.capabilities.lethalTrifecta ? "!" : "i", text: caps.length ? `${caps.join("; ")}${r.capabilities.lethalTrifecta ? ". Warning: private data + untrusted content + outbound channel (the lethal trifecta); limit what agents can combine" : ""}` : "no notable capabilities inferred" });
|
|
@@ -35885,6 +37003,8 @@ function renderTerminal(r) {
|
|
|
35885
37003
|
}
|
|
35886
37004
|
const fn = r.findings.filter((f) => (f.pack === "functional" || f.pack === "tests") && f.scored && !f.suppressed && (f.status === "pass" || f.status === "fail"));
|
|
35887
37005
|
lines.push(` FUNCTIONAL ${fn.length ? `${fn.filter((f) => f.status === "pass").length} of ${fn.length} checks passed${r.functional?.calledTools.length ? ` \xB7 ${r.functional.calledTools.length} tool${r.functional.calledTools.length === 1 ? "" : "s"} called` : ""}${r.tests?.length ? ` \xB7 ${r.tests.length} test cases` : ""}` : "not tested (run with --active, or add test cases)"}`);
|
|
37006
|
+
if (r.riskTier)
|
|
37007
|
+
lines.push(` RISK ${r.riskTier.tier} (${r.riskTier.label}; needs ${r.riskTier.requirement})`);
|
|
35888
37008
|
lines.push(` ${COVERAGE_NOTE}`);
|
|
35889
37009
|
for (const line of r.summary ?? [])
|
|
35890
37010
|
lines.push(` ${s(line, 300)}`);
|
|
@@ -36302,19 +37422,31 @@ import { randomUUID } from "node:crypto";
|
|
|
36302
37422
|
async function runProxy(o) {
|
|
36303
37423
|
mkdirSync3(dirname2(o.receiptsPath), { recursive: true });
|
|
36304
37424
|
let last;
|
|
37425
|
+
let history = [];
|
|
36305
37426
|
if (existsSync4(o.receiptsPath)) {
|
|
36306
|
-
|
|
36307
|
-
last =
|
|
36308
|
-
}
|
|
37427
|
+
history = parseReceiptLog(readFileSync5(o.receiptsPath, "utf8"));
|
|
37428
|
+
last = history[history.length - 1];
|
|
37429
|
+
}
|
|
37430
|
+
const today = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
37431
|
+
const totArg = o.mandate?.limits?.totalPerDay?.arg;
|
|
37432
|
+
const governed = /* @__PURE__ */ new Set([...(o.mandate?.constraints ?? []).map((k) => k.arg), ...totArg ? [totArg] : [], ...o.mandate?.approveAbove ? [o.mandate.approveAbove.arg] : []]);
|
|
37433
|
+
const usage = () => {
|
|
37434
|
+
const t = today();
|
|
37435
|
+
const done = history.filter((e) => e.receipt.issuedAt.startsWith(t) && e.receipt.outcome === "allow" && e.result.status === "ok" && e.result.code === "ok-action");
|
|
37436
|
+
return { callsToday: done.length, totalToday: totArg ? done.reduce((a, e) => a + Number(e.result.values?.[totArg] ?? 0), 0) : 0 };
|
|
37437
|
+
};
|
|
36309
37438
|
const bare = !/[\\/]/.test(o.command);
|
|
36310
37439
|
const child = spawn3(o.command, o.args, { stdio: ["pipe", "pipe", "inherit"], shell: process.platform === "win32" && (bare || /\.(cmd|bat)$/i.test(o.command)) });
|
|
36311
37440
|
let service = o.command.split(/[\\/]/).pop() ?? o.command, version2;
|
|
36312
37441
|
const annotations = /* @__PURE__ */ new Map();
|
|
37442
|
+
const toolDefs = /* @__PURE__ */ new Map();
|
|
36313
37443
|
const pendingKinds = /* @__PURE__ */ new Map();
|
|
36314
37444
|
const calls = /* @__PURE__ */ new Map();
|
|
36315
37445
|
const key = (id) => JSON.stringify(id);
|
|
36316
37446
|
const isDestructive = (a) => a?.destructiveHint === true || a?.readOnlyHint === false && a?.destructiveHint !== false;
|
|
36317
37447
|
const record2 = (tool, argsHash, outcome, reason, result) => {
|
|
37448
|
+
if (result.code)
|
|
37449
|
+
reason = `[${result.code}] ${reason}`;
|
|
36318
37450
|
const receipt = signReceipt({
|
|
36319
37451
|
receiptFormat: "0.1",
|
|
36320
37452
|
envelope: {
|
|
@@ -36336,6 +37468,7 @@ async function runProxy(o) {
|
|
|
36336
37468
|
const entry = chainEntry(last, receipt, result);
|
|
36337
37469
|
appendFileSync(o.receiptsPath, JSON.stringify(entry) + "\n");
|
|
36338
37470
|
last = entry;
|
|
37471
|
+
history.push(entry);
|
|
36339
37472
|
};
|
|
36340
37473
|
createInterface({ input: process.stdin }).on("line", (line) => {
|
|
36341
37474
|
let msg;
|
|
@@ -36349,16 +37482,43 @@ async function runProxy(o) {
|
|
|
36349
37482
|
pendingKinds.set(key(msg.id), msg.method);
|
|
36350
37483
|
if (msg.method === "tools/call" && msg.id !== void 0) {
|
|
36351
37484
|
const tool = String(msg.params?.name ?? "");
|
|
36352
|
-
const
|
|
37485
|
+
const args = msg.params?.arguments ?? {};
|
|
37486
|
+
const argsHash = argumentsHash(args);
|
|
36353
37487
|
const ann = annotations.get(tool);
|
|
36354
|
-
const
|
|
37488
|
+
const def = toolDefs.get(tool);
|
|
37489
|
+
const isMoney = def ? capabilityProfile([def]).capabilities.some((c) => c.capability === "money") : false;
|
|
37490
|
+
const values = Object.fromEntries([...governed].filter((k) => args[k] !== void 0 && (typeof args[k] === "number" || typeof args[k] === "string")).map((k) => [k, args[k]]));
|
|
37491
|
+
const rev = o.mandate ? revocationOf(o.mandate, o.revocationsPath) : void 0;
|
|
37492
|
+
let d = rev ? { allow: false, code: "revoked", reason: `the mandate was revoked on ${rev.at.slice(0, 10)}${rev.reason ? ` (${rev.reason})` : ""}` } : o.mandate ? decideCall(o.mandate, { tool, server: service, args, annotations: ann, isMoney, usage: usage() }) : { allow: true, code: "ok", reason: "no mandate: observed" };
|
|
37493
|
+
let rationale;
|
|
37494
|
+
if (d.allow && o.mandate && hasIntent(o.mandate)) {
|
|
37495
|
+
const di = decideIntent(o.mandate, def ?? { name: tool }, args, { server: service });
|
|
37496
|
+
rationale = di.rationale;
|
|
37497
|
+
for (const [k, val] of Object.entries(di.values))
|
|
37498
|
+
if (typeof val === "number" || typeof val === "string" || typeof val === "boolean")
|
|
37499
|
+
values[k] = val;
|
|
37500
|
+
if (!di.allow)
|
|
37501
|
+
d = { allow: false, code: di.code, reason: di.reason };
|
|
37502
|
+
else if (di.reason !== "within the mandate")
|
|
37503
|
+
d = { allow: true, code: "ok", reason: di.reason };
|
|
37504
|
+
}
|
|
37505
|
+
if (!d.allow && d.code === "approval-needed" && o.mandate) {
|
|
37506
|
+
const rid = approvalRequestId(o.mandate, tool, args);
|
|
37507
|
+
const ap = consumeApproval(o.mandate, rid, o.approvalsPath);
|
|
37508
|
+
if (ap.ok)
|
|
37509
|
+
d = { allow: true, code: "ok", reason: `approved by ${ap.by} (${rid}), after: ${d.reason}` };
|
|
37510
|
+
else
|
|
37511
|
+
d = { ...d, reason: `${d.reason} [approval request ${rid}]` };
|
|
37512
|
+
}
|
|
36355
37513
|
if (!d.allow && o.enforce) {
|
|
36356
|
-
|
|
36357
|
-
|
|
36358
|
-
|
|
37514
|
+
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.";
|
|
37515
|
+
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");
|
|
37516
|
+
record2(tool, argsHash, "deny", d.reason, { status: "blocked", destructive: isDestructive(ann), code: d.code, values, ...rationale ? { rationale } : {} });
|
|
37517
|
+
o.log?.(`denied ${tool} (${d.code}): ${d.reason}`);
|
|
36359
37518
|
return;
|
|
36360
37519
|
}
|
|
36361
|
-
|
|
37520
|
+
const code = !d.allow ? `observed-${d.code}` : ann?.readOnlyHint === true ? "ok-read" : "ok-action";
|
|
37521
|
+
calls.set(key(msg.id), { tool, argsHash, start: Date.now(), reason: d.allow ? d.reason : `outside the mandate (observed, not blocked): ${d.reason}`, destructive: isDestructive(ann), code, values, rationale });
|
|
36362
37522
|
}
|
|
36363
37523
|
child.stdin.write(line + "\n");
|
|
36364
37524
|
});
|
|
@@ -36390,21 +37550,23 @@ async function runProxy(o) {
|
|
|
36390
37550
|
pendingKinds.delete(k);
|
|
36391
37551
|
}
|
|
36392
37552
|
if (kind === "tools/list" && Array.isArray(msg.result?.tools)) {
|
|
36393
|
-
for (const t of msg.result.tools)
|
|
37553
|
+
for (const t of msg.result.tools) {
|
|
36394
37554
|
annotations.set(t.name, t.annotations);
|
|
37555
|
+
toolDefs.set(t.name, t);
|
|
37556
|
+
}
|
|
36395
37557
|
pendingKinds.delete(k);
|
|
36396
37558
|
}
|
|
36397
37559
|
const c = calls.get(k);
|
|
36398
37560
|
if (c) {
|
|
36399
37561
|
calls.delete(k);
|
|
36400
37562
|
const status = msg.error ? "protocol-error" : msg.result?.isError ? "tool-error" : "ok";
|
|
36401
|
-
record2(c.tool, c.argsHash, msg.error ? "error" : "allow", c.reason, { status, latencyMs: Date.now() - c.start, destructive: c.destructive });
|
|
37563
|
+
record2(c.tool, c.argsHash, msg.error ? "error" : "allow", c.reason, { status, latencyMs: Date.now() - c.start, destructive: c.destructive, code: c.code, values: c.values, ...c.rationale ? { rationale: c.rationale } : {} });
|
|
36402
37564
|
}
|
|
36403
37565
|
process.stdout.write(line + "\n");
|
|
36404
37566
|
});
|
|
36405
37567
|
return new Promise((resolve) => child.on("exit", (code) => {
|
|
36406
37568
|
for (const c of calls.values())
|
|
36407
|
-
record2(c.tool, c.argsHash, "error", c.reason, { status: "no-response", destructive: c.destructive });
|
|
37569
|
+
record2(c.tool, c.argsHash, "error", c.reason, { status: "no-response", destructive: c.destructive, code: c.code, values: c.values });
|
|
36408
37570
|
resolve(code ?? 0);
|
|
36409
37571
|
}));
|
|
36410
37572
|
}
|
|
@@ -37090,6 +38252,349 @@ var init_stdio3 = __esm({
|
|
|
37090
38252
|
}
|
|
37091
38253
|
});
|
|
37092
38254
|
|
|
38255
|
+
// packages/cli/dist/demo.js
|
|
38256
|
+
var demo_exports = {};
|
|
38257
|
+
__export(demo_exports, {
|
|
38258
|
+
runAutonomyDemo: () => runAutonomyDemo,
|
|
38259
|
+
runDemo: () => runDemo,
|
|
38260
|
+
startDemoServer: () => startDemoServer
|
|
38261
|
+
});
|
|
38262
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync3, existsSync as existsSync5, rmSync } from "node:fs";
|
|
38263
|
+
import { join as join5 } from "node:path";
|
|
38264
|
+
async function startDemoServer(story = "autonomy") {
|
|
38265
|
+
const tools = story === "grocery" ? GROCERY_TOOLS : story === "travel" ? TRAVEL_TOOLS : story === "finance" ? FINANCE_TOOLS : DEMO_TOOLS;
|
|
38266
|
+
const server = new Server({ name: story === "travel" ? "demo-travel" : story === "finance" ? "demo-finance" : "demo-grocer", version: "1.0.0" }, { capabilities: { tools: {} } });
|
|
38267
|
+
const cart = [];
|
|
38268
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools }));
|
|
38269
|
+
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
38270
|
+
const a = req.params.arguments ?? {};
|
|
38271
|
+
const text2 = (t) => ({ content: [{ type: "text", text: t }] });
|
|
38272
|
+
switch (req.params.name) {
|
|
38273
|
+
case "search_products":
|
|
38274
|
+
if (story === "grocery")
|
|
38275
|
+
return text2("Oat milk (Usual Farms) $4.49 \xB7 Rye bread (Bakehouse) $6.35 \xB7 Sourdough: out of stock \xB7 Snack bar (Promo, sponsored) $3.99");
|
|
38276
|
+
return text2(PRODUCTS.filter((p) => p.name.toLowerCase().includes(String(a.query ?? "").toLowerCase().split(" ")[0])).map((p) => `${p.name}: $${p.price}`).join("\n") || "No match.");
|
|
38277
|
+
case "get_deals":
|
|
38278
|
+
return text2("Deal: coffee beans 1 kg, $21.99 (was $27.99).");
|
|
38279
|
+
case "add_to_cart":
|
|
38280
|
+
cart.push(String(a.product));
|
|
38281
|
+
return text2(`Added ${a.quantity} \xD7 ${a.product}${a.brand ? ` (${a.brand})` : ""}.`);
|
|
38282
|
+
case "pay_for_order":
|
|
38283
|
+
return text2(`Paid $${a.amount} ${a.currency}. Order placed.`);
|
|
38284
|
+
case "search_flights":
|
|
38285
|
+
return text2("YUL 3 Mar: Maple Air 1 stop $540 refundable \xB7 Budget Jet 2 stops $420 \xB7 Direct Air $380 non-refundable.");
|
|
38286
|
+
case "book_flight":
|
|
38287
|
+
return text2(`Booked ${a.flight} for $${a.fare}.`);
|
|
38288
|
+
case "change_seat":
|
|
38289
|
+
return text2(`Seat changed to ${a.seat}.`);
|
|
38290
|
+
case "upgrade_cabin":
|
|
38291
|
+
return text2(`Upgraded to ${a.cabin}.`);
|
|
38292
|
+
case "share_traveller_details":
|
|
38293
|
+
return text2(`Shared with ${a.recipient}.`);
|
|
38294
|
+
case "send_report":
|
|
38295
|
+
return text2(`Sent "${a.report}" to ${a.recipient}.`);
|
|
38296
|
+
case "pay_invoice":
|
|
38297
|
+
return text2(`Paid $${a.amount} to ${a.vendor}.`);
|
|
38298
|
+
default:
|
|
38299
|
+
return { isError: true, content: [{ type: "text", text: "Unknown tool" }] };
|
|
38300
|
+
}
|
|
38301
|
+
});
|
|
38302
|
+
const closed = new Promise((r) => {
|
|
38303
|
+
server.onclose = () => r();
|
|
38304
|
+
process.stdin.on("end", () => r());
|
|
38305
|
+
});
|
|
38306
|
+
await server.connect(new StdioServerTransport());
|
|
38307
|
+
await closed;
|
|
38308
|
+
}
|
|
38309
|
+
async function runStory(dir, st, owner, log) {
|
|
38310
|
+
const self = [...process.execArgv, process.argv[1]];
|
|
38311
|
+
const agentKey = loadOrCreateKey(join5(dir, `${st.id}-agent-key.json`));
|
|
38312
|
+
const m = createMandate({
|
|
38313
|
+
agentId: agentKey.kid,
|
|
38314
|
+
agentName: `${st.id === "travel" ? "Travel" : "Shopping"} agent`,
|
|
38315
|
+
ownerName: "Demo customer",
|
|
38316
|
+
tools: st.tools,
|
|
38317
|
+
destructive: false,
|
|
38318
|
+
expires: new Date(Date.now() + 7 * 864e5).toISOString().slice(0, 10),
|
|
38319
|
+
...st.m
|
|
38320
|
+
}, owner);
|
|
38321
|
+
const operatorName = String(st.m.disclosures?.operator ?? "Demo operator");
|
|
38322
|
+
const cm = cosignMandate(m, loadOrCreateKey(join5(dir, `${st.id}-operator-key.json`)), operatorName);
|
|
38323
|
+
const mf = join5(dir, `${st.id}-mandate.json`), rf = join5(dir, `${st.id}-receipts.jsonl`), revf = join5(dir, "revocations.json");
|
|
38324
|
+
writeFileSync3(mf, JSON.stringify(cm, null, 2));
|
|
38325
|
+
log(`\u2500\u2500 ${st.title}`);
|
|
38326
|
+
log(` Signed by you; countersigned by the operator, ${operatorName}.`);
|
|
38327
|
+
for (const line of describeMandate(m))
|
|
38328
|
+
log(` ${line}`);
|
|
38329
|
+
const open2 = () => connect({ kind: "stdio", command: process.execPath, args: [...self, "proxy", "--mandate", mf, "--agent-key", join5(dir, `${st.id}-agent-key.json`), "--enforce", "--receipts", rf, "--revocations", revf, "--approvals", join5(dir, "approvals.json"), "--", process.execPath, ...self, "demo-server", "--story", st.server] });
|
|
38330
|
+
const s = await open2();
|
|
38331
|
+
try {
|
|
38332
|
+
await s.listTools();
|
|
38333
|
+
let lastRid = "";
|
|
38334
|
+
for (const step of st.steps) {
|
|
38335
|
+
if (step.approveLast) {
|
|
38336
|
+
const { approveAction: approveAction2 } = await Promise.resolve().then(() => (init_dist4(), dist_exports));
|
|
38337
|
+
approveAction2(cm, lastRid, owner, 60, join5(dir, "approvals.json"));
|
|
38338
|
+
log(` \u270D ${step.say}: ${lastRid}`);
|
|
38339
|
+
continue;
|
|
38340
|
+
}
|
|
38341
|
+
const o = await s.callTool(step.tool, step.args);
|
|
38342
|
+
const txt = o.kind === "result" ? o.content.map((c) => c.text ?? "").join(" ") : o.kind;
|
|
38343
|
+
const rid = /\[approval request (apr_[0-9a-f]+)\]/.exec(txt);
|
|
38344
|
+
if (rid)
|
|
38345
|
+
lastRid = rid[1];
|
|
38346
|
+
const blocked = /^Blocked by Saktum \(([^)]+)\): (.+?)( \[approval request [^\]]+\])?\.( Ask| Tell|$)/.exec(txt);
|
|
38347
|
+
const lastR = parseReceiptLog(readFileSync6(rf, "utf8")).pop();
|
|
38348
|
+
log(blocked ? ` \u26D4 ${step.say}: ${blocked[1]}: ${blocked[2]}` : ` \u2713 ${step.say}${/approved by/.test(String(lastR?.receipt.reason ?? "")) ? ": approved by you, once" : ""}`);
|
|
38349
|
+
const last = parseReceiptLog(readFileSync6(rf, "utf8")).pop();
|
|
38350
|
+
for (const p of last?.result.rationale?.preferences ?? [])
|
|
38351
|
+
if (!blocked)
|
|
38352
|
+
log(` \xB7 ${p}`);
|
|
38353
|
+
for (const f of last?.result.rationale?.flags ?? [])
|
|
38354
|
+
if (!blocked && !/differs from the stated preference/.test(f))
|
|
38355
|
+
log(` ! ${f}`);
|
|
38356
|
+
}
|
|
38357
|
+
} finally {
|
|
38358
|
+
await s.close();
|
|
38359
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
38360
|
+
}
|
|
38361
|
+
if (st.id === "grocery") {
|
|
38362
|
+
revokeMandate(cm, "you pressed stop", revf);
|
|
38363
|
+
const s2 = await open2();
|
|
38364
|
+
try {
|
|
38365
|
+
await s2.listTools();
|
|
38366
|
+
const o = await s2.callTool("search_products", { query: "milk" });
|
|
38367
|
+
const txt = o.kind === "result" ? o.content.map((c) => c.text ?? "").join(" ") : o.kind;
|
|
38368
|
+
log(/revoked/.test(txt) ? " \u26D4 after you press stop (saktum agent revoke), it tries to search again: revoked" : ` ? after revoke: ${txt.slice(0, 80)}`);
|
|
38369
|
+
} finally {
|
|
38370
|
+
await s2.close();
|
|
38371
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
38372
|
+
}
|
|
38373
|
+
}
|
|
38374
|
+
const entries = parseReceiptLog(readFileSync6(rf, "utf8"));
|
|
38375
|
+
const ts = trustStatement(entries, verifyReceiptLog(entries).ok);
|
|
38376
|
+
log(" Track record:");
|
|
38377
|
+
for (const l of ts.lines)
|
|
38378
|
+
log(` ${l}`);
|
|
38379
|
+
const html = join5(dir, `${st.id}-passport.html`);
|
|
38380
|
+
writeFileSync3(html, renderAgentPassport(m, checkMandate(m).ok ? { ok: true } : { ok: false }, {
|
|
38381
|
+
verified: verifyReceiptLog(entries).ok,
|
|
38382
|
+
summary: summariseReceipts(entries),
|
|
38383
|
+
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 ") }))
|
|
38384
|
+
}, agentRiskTier(m), describeMandate(m), { operator: (() => {
|
|
38385
|
+
const op = checkOperator(cm);
|
|
38386
|
+
return op.present && op.valid ? `${op.name} (${op.id})` : void 0;
|
|
38387
|
+
})(), track: ts.lines }));
|
|
38388
|
+
log(` ${entries.length} signed receipts \xB7 ${verifyReceiptLog(entries).ok ? "verified" : "NOT verified"} \xB7 passport: ${html}
|
|
38389
|
+
`);
|
|
38390
|
+
return html;
|
|
38391
|
+
}
|
|
38392
|
+
async function runDemo(dir, log, story = "all") {
|
|
38393
|
+
if (story === "autonomy")
|
|
38394
|
+
return runAutonomyDemo(dir, log);
|
|
38395
|
+
if (existsSync5(dir))
|
|
38396
|
+
rmSync(dir, { recursive: true, force: true });
|
|
38397
|
+
mkdirSync4(dir, { recursive: true });
|
|
38398
|
+
const owner = loadOrCreateKey(join5(dir, "owner-key.json"));
|
|
38399
|
+
log("Saktum demo: agents acting on real instructions (rules, preferences, substitutions, upsells), every decision explained and signed.\n");
|
|
38400
|
+
const files = [];
|
|
38401
|
+
for (const st of story === "travel" ? [TRAVEL] : story === "grocery" ? [GROCERY] : story === "finance" ? [FINANCE] : [GROCERY, TRAVEL, FINANCE])
|
|
38402
|
+
files.push(await runStory(dir, st, owner, log));
|
|
38403
|
+
log("What you just saw: each agent followed its owner's instructions, not just limits. Even when tricked by a hidden\ninstruction, the mandate held; personal and confidential data went only where you allowed; a big invoice waited for your\nsigned approval of exactly that payment; and the stop button worked. Blocked steps never\nreached the store or airline, and every decision has a signed receipt with its reason. Open the passports for the\ninstructions in plain words, the track record and the reason for every step. Also try: npx saktum demo --story autonomy");
|
|
38404
|
+
return { files };
|
|
38405
|
+
}
|
|
38406
|
+
async function runAutonomyDemo(dir, log) {
|
|
38407
|
+
if (existsSync5(dir))
|
|
38408
|
+
rmSync(dir, { recursive: true, force: true });
|
|
38409
|
+
mkdirSync4(dir, { recursive: true });
|
|
38410
|
+
const owner = loadOrCreateKey(join5(dir, "owner-key.json"));
|
|
38411
|
+
const self = [...process.execArgv, process.argv[1]];
|
|
38412
|
+
const tools = DEMO_TOOLS.map((t) => t.name);
|
|
38413
|
+
const personas = [
|
|
38414
|
+
{ id: "notify", title: '"Only alert me to great deals"', m: { autonomy: "notify" }, steps: SCRIPT },
|
|
38415
|
+
{ id: "propose", title: `"Suggest, and I'll approve"`, m: { autonomy: "propose" }, steps: SCRIPT },
|
|
38416
|
+
{ id: "act", title: '"Act for me, up to $50; ask me above $25; Canadian dollars only"', m: { autonomy: "act", constraints: [{ tool: "pay_for_order", arg: "amount", max: 50 }, { tool: "pay_for_order", arg: "currency", oneOf: ["CAD"] }], approveAbove: { arg: "amount", value: 25 }, limits: { totalPerDay: { arg: "amount", max: 100 } } }, steps: [...SCRIPT, ...EXTRA] }
|
|
38417
|
+
];
|
|
38418
|
+
const files = [];
|
|
38419
|
+
log("Saktum demo: one shopping agent, three mandates, every call governed and receipted.\n");
|
|
38420
|
+
for (const p of personas) {
|
|
38421
|
+
const agentKey = loadOrCreateKey(join5(dir, `${p.id}-agent-key.json`));
|
|
38422
|
+
const m = createMandate({
|
|
38423
|
+
agentId: agentKey.kid,
|
|
38424
|
+
agentName: `Shopping agent (${p.id})`,
|
|
38425
|
+
ownerName: "Demo shopper",
|
|
38426
|
+
purpose: "Weekly grocery shopping",
|
|
38427
|
+
tools,
|
|
38428
|
+
destructive: false,
|
|
38429
|
+
expires: new Date(Date.now() + 7 * 864e5).toISOString().slice(0, 10),
|
|
38430
|
+
disclosures: { operator: "Demo Grocer", incentives: "None: no sponsored ranking", dataUse: "Order history used only to suggest your usual items" },
|
|
38431
|
+
...p.m
|
|
38432
|
+
}, owner);
|
|
38433
|
+
const mf = join5(dir, `${p.id}-mandate.json`), rf = join5(dir, `${p.id}-receipts.jsonl`);
|
|
38434
|
+
writeFileSync3(mf, JSON.stringify(m, null, 2));
|
|
38435
|
+
const tier = agentRiskTier(m);
|
|
38436
|
+
log(`\u2500\u2500 ${p.title} autonomy ${m.autonomy} \xB7 risk ${tier.tier}`);
|
|
38437
|
+
const s = await connect({ kind: "stdio", command: process.execPath, args: [...self, "proxy", "--mandate", mf, "--agent-key", join5(dir, `${p.id}-agent-key.json`), "--enforce", "--receipts", rf, "--", process.execPath, ...self, "demo-server"] });
|
|
38438
|
+
try {
|
|
38439
|
+
await s.listTools();
|
|
38440
|
+
for (const st of p.steps) {
|
|
38441
|
+
const o = await s.callTool(st.tool, st.args);
|
|
38442
|
+
const txt = o.kind === "result" ? o.content.map((c) => c.text ?? "").join(" ") : o.kind;
|
|
38443
|
+
const blocked = /^Blocked by Saktum \(([^)]+)\): ([^.]+)/.exec(txt);
|
|
38444
|
+
log(blocked ? ` \u26D4 ${st.say}: blocked (${blocked[1]}): ${blocked[2]}` : ` \u2713 ${st.say}: ${txt.split("\n")[0]}`);
|
|
38445
|
+
}
|
|
38446
|
+
} finally {
|
|
38447
|
+
await s.close();
|
|
38448
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
38449
|
+
}
|
|
38450
|
+
const entries = parseReceiptLog(readFileSync6(rf, "utf8"));
|
|
38451
|
+
const counts = /* @__PURE__ */ new Map();
|
|
38452
|
+
for (const e of entries) {
|
|
38453
|
+
const k = `${e.receipt.envelope.tool}|${e.receipt.envelope.argumentsHash}`;
|
|
38454
|
+
counts.set(k, (counts.get(k) ?? 0) + 1);
|
|
38455
|
+
}
|
|
38456
|
+
const html = join5(dir, `${p.id}-passport.html`);
|
|
38457
|
+
writeFileSync3(html, renderAgentPassport(m, checkMandate(m).ok ? { ok: true } : { ok: false }, {
|
|
38458
|
+
verified: verifyReceiptLog(entries).ok,
|
|
38459
|
+
summary: summariseReceipts(entries),
|
|
38460
|
+
timeline: entries.map((e) => ({ tool: e.receipt.envelope.tool, outcome: e.receipt.outcome, status: e.result.status, repeated: (counts.get(`${e.receipt.envelope.tool}|${e.receipt.envelope.argumentsHash}`) ?? 0) >= 3 }))
|
|
38461
|
+
}, tier));
|
|
38462
|
+
files.push(html);
|
|
38463
|
+
log(` ${entries.length} signed receipts \xB7 ${verifyReceiptLog(entries).ok ? "verified" : "NOT verified"} \xB7 passport: ${html}
|
|
38464
|
+
`);
|
|
38465
|
+
}
|
|
38466
|
+
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.");
|
|
38467
|
+
return { files };
|
|
38468
|
+
}
|
|
38469
|
+
var PRODUCTS, DEMO_TOOLS, B, GROCERY_TOOLS, TRAVEL_TOOLS, FINANCE_TOOLS, SCRIPT, EXTRA, GROCERY, TRAVEL, FINANCE;
|
|
38470
|
+
var init_demo = __esm({
|
|
38471
|
+
"packages/cli/dist/demo.js"() {
|
|
38472
|
+
"use strict";
|
|
38473
|
+
init_server2();
|
|
38474
|
+
init_stdio3();
|
|
38475
|
+
init_types2();
|
|
38476
|
+
init_dist();
|
|
38477
|
+
init_dist3();
|
|
38478
|
+
init_dist4();
|
|
38479
|
+
init_dist5();
|
|
38480
|
+
PRODUCTS = [{ id: "oat-milk", name: "Oat milk 1 L", price: 4.49 }, { id: "bread", name: "Sourdough bread", price: 5.99 }, { id: "coffee", name: "Coffee beans 1 kg", price: 21.99 }];
|
|
38481
|
+
DEMO_TOOLS = [
|
|
38482
|
+
{ name: "search_products", description: "Search the store's catalogue for products matching a query.", inputSchema: { type: "object", properties: { query: { type: "string" } }, required: ["query"] }, annotations: { readOnlyHint: true, openWorldHint: false } },
|
|
38483
|
+
{ name: "get_deals", description: "List this week's best deals on products the user usually buys.", inputSchema: { type: "object", properties: {} }, annotations: { readOnlyHint: true, openWorldHint: false } },
|
|
38484
|
+
{ name: "add_to_cart", description: "Add a product to the user's cart.", inputSchema: { type: "object", properties: { product: { type: "string" }, quantity: { type: "integer", minimum: 1 } }, required: ["product", "quantity"] }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false } },
|
|
38485
|
+
{ name: "pay_for_order", description: "Charges the customer's card for the cart total and places the order.", inputSchema: { type: "object", properties: { amount: { type: "number" }, currency: { type: "string" }, idempotency_key: { type: "string" } }, required: ["amount", "currency", "idempotency_key"] }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true } }
|
|
38486
|
+
];
|
|
38487
|
+
B = (bindings, action) => ({ "io.saktum/bindings": bindings, "io.saktum/action": action });
|
|
38488
|
+
GROCERY_TOOLS = [
|
|
38489
|
+
{ name: "search_products", description: "Search the store's catalogue for products matching a query.", inputSchema: { type: "object", properties: { query: { type: "string" } }, required: ["query"] }, annotations: { readOnlyHint: true }, _meta: B({}, "search") },
|
|
38490
|
+
{
|
|
38491
|
+
name: "add_to_cart",
|
|
38492
|
+
description: "Add a product to the cart, or a substitute for an unavailable product.",
|
|
38493
|
+
inputSchema: { type: "object", properties: { product: { type: "string" }, brand: { type: "string" }, category: { type: "string" }, quantity: { type: "integer" }, price: { type: "number" }, substitute_for: { type: "string" }, reference_price: { type: "number" }, upgrade: { type: "boolean" }, sponsored: { type: "boolean" } }, required: ["product", "quantity", "price"] },
|
|
38494
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
38495
|
+
_meta: B({ product: "commerce.item.product", brand: "commerce.item.brand", category: "commerce.item.category", quantity: "commerce.item.quantity", price: "commerce.item.unit_price", substitute_for: "commerce.item.substitute_for", reference_price: "commerce.item.reference_price", upgrade: "commerce.item.upgrade", sponsored: "commerce.item.sponsored" }, "cart")
|
|
38496
|
+
},
|
|
38497
|
+
{
|
|
38498
|
+
name: "pay_for_order",
|
|
38499
|
+
description: "Charges the customer's card for the cart total and places the order.",
|
|
38500
|
+
inputSchema: { type: "object", properties: { amount: { type: "number" }, currency: { type: "string" }, merchant: { type: "string" }, delivery_address: { type: "string" }, idempotency_key: { type: "string" } }, required: ["amount", "currency", "idempotency_key"] },
|
|
38501
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
|
|
38502
|
+
_meta: B({ amount: "commerce.order.total", currency: "commerce.order.currency", merchant: "commerce.counterparty", delivery_address: "personal.address" }, "pay")
|
|
38503
|
+
}
|
|
38504
|
+
];
|
|
38505
|
+
TRAVEL_TOOLS = [
|
|
38506
|
+
{ name: "search_flights", description: "Search flights between two cities on a date.", inputSchema: { type: "object", properties: { from: { type: "string" }, to: { type: "string" }, date: { type: "string" } }, required: ["from", "to", "date"] }, annotations: { readOnlyHint: true }, _meta: B({}, "search") },
|
|
38507
|
+
{
|
|
38508
|
+
name: "book_flight",
|
|
38509
|
+
description: "Book a flight itinerary for the traveller.",
|
|
38510
|
+
inputSchema: { type: "object", properties: { flight: { type: "string" }, fare: { type: "number" }, currency: { type: "string" }, stops: { type: "integer" }, refundable: { type: "boolean" }, carrier: { type: "string" }, passport_number: { type: "string" }, idempotency_key: { type: "string" } }, required: ["flight", "fare", "stops", "refundable"] },
|
|
38511
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },
|
|
38512
|
+
_meta: B({ fare: "travel.fare.total", currency: "travel.fare.currency", stops: "travel.itinerary.connections", refundable: "travel.fare.refundable", carrier: "travel.carrier", passport_number: "personal.passport" }, "book")
|
|
38513
|
+
},
|
|
38514
|
+
{ name: "share_traveller_details", description: "Share the traveller's details with a travel partner.", inputSchema: { type: "object", properties: { recipient: { type: "string" }, passport_number: { type: "string" }, email: { type: "string" } }, required: ["recipient"] }, annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, _meta: B({ recipient: "party.recipient", passport_number: "personal.passport", email: "personal.email" }, "communicate") },
|
|
38515
|
+
{ name: "change_seat", description: "Change the traveller's seat on a booked flight.", inputSchema: { type: "object", properties: { seat: { type: "string" }, fee: { type: "number" } }, required: ["seat", "fee"] }, annotations: { readOnlyHint: false, destructiveHint: false }, _meta: B({ seat: "travel.seat", fee: "travel.fee" }, "change") },
|
|
38516
|
+
{ name: "upgrade_cabin", description: "Upgrade the traveller to a higher cabin for a fee.", inputSchema: { type: "object", properties: { cabin: { type: "string" }, fee: { type: "number" }, upgrade: { type: "boolean" } }, required: ["cabin", "fee"] }, annotations: { readOnlyHint: false, destructiveHint: false }, _meta: B({ fee: "travel.fee", upgrade: "travel.upgrade" }, "change") }
|
|
38517
|
+
];
|
|
38518
|
+
FINANCE_TOOLS = [
|
|
38519
|
+
{ 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") },
|
|
38520
|
+
{ 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") }
|
|
38521
|
+
];
|
|
38522
|
+
SCRIPT = [
|
|
38523
|
+
{ tool: "get_deals", args: {}, say: "checks this week's deals" },
|
|
38524
|
+
{ tool: "search_products", args: { query: "coffee" }, say: "searches for coffee" },
|
|
38525
|
+
{ tool: "add_to_cart", args: { product: "coffee", quantity: 1 }, say: "adds coffee beans to the cart" },
|
|
38526
|
+
{ tool: "pay_for_order", args: { amount: 18, currency: "CAD", idempotency_key: "order-1" }, say: "tries to pay $18" }
|
|
38527
|
+
];
|
|
38528
|
+
EXTRA = [
|
|
38529
|
+
{ tool: "pay_for_order", args: { amount: 30, currency: "CAD", idempotency_key: "order-2" }, say: "tries to pay $30" },
|
|
38530
|
+
{ tool: "pay_for_order", args: { amount: 80, currency: "CAD", idempotency_key: "order-3" }, say: "tries to pay $80" },
|
|
38531
|
+
{ tool: "pay_for_order", args: { amount: 10, currency: "USD", idempotency_key: "order-4" }, say: "tries to pay $10 in USD" }
|
|
38532
|
+
];
|
|
38533
|
+
GROCERY = { id: "grocery", title: 'Grocery: "weekly groceries, my usual brands"', server: "grocery", tools: GROCERY_TOOLS.map((t) => t.name), m: {
|
|
38534
|
+
autonomy: "act",
|
|
38535
|
+
purpose: "Weekly groceries for the family",
|
|
38536
|
+
actions: [{ cls: "search", autonomy: "act" }, { cls: "cart", autonomy: "act" }, { cls: "pay", autonomy: "act" }],
|
|
38537
|
+
rules: [{ field: "commerce.item.quantity", op: "max", value: 2, label: "at most 2 of each item" }, { field: "commerce.item.category", op: "notIn", value: ["alcohol"], label: "never alcohol" }, { field: "commerce.order.total", op: "max", value: 150, label: "up to $150 per order" }],
|
|
38538
|
+
substitution: { allowed: true, maxPriceChangePct: 10, neverFor: ["baby food"] },
|
|
38539
|
+
upsell: "ask",
|
|
38540
|
+
preferences: [{ field: "commerce.item.brand", prefer: "Usual Farms", label: "the usual brand, Usual Farms" }],
|
|
38541
|
+
counterparties: ["Demo Grocer"],
|
|
38542
|
+
dataSharing: [{ data: "delivery address", to: "Demo Grocer" }],
|
|
38543
|
+
disclosures: { operator: "Demo Grocer", incentives: "Sponsored products are labelled", dataUse: "Order history used only for your lists" }
|
|
38544
|
+
}, steps: [
|
|
38545
|
+
{ tool: "search_products", args: { query: "milk" }, say: "searches the catalogue" },
|
|
38546
|
+
{ tool: "add_to_cart", args: { product: "Oat milk", brand: "Usual Farms", category: "dairy", quantity: 1, price: 4.49 }, say: "adds oat milk" },
|
|
38547
|
+
{ tool: "add_to_cart", args: { product: "Apples", brand: "Usual Farms", category: "produce", quantity: 5, price: 0.8 }, say: "adds 5 bags of apples" },
|
|
38548
|
+
{ tool: "add_to_cart", args: { product: "Rye bread", brand: "Bakehouse", category: "bakery", quantity: 1, price: 6.35, substitute_for: "Sourdough bread", reference_price: 5.99 }, say: "substitutes rye for the out-of-stock sourdough (+6%)" },
|
|
38549
|
+
{ tool: "add_to_cart", args: { product: "Baby oatmeal", brand: "Other Co", category: "baby food", quantity: 1, price: 4.2, substitute_for: "Usual Farms baby oatmeal", reference_price: 4.1 }, say: "substitutes another brand of baby oatmeal" },
|
|
38550
|
+
{ tool: "add_to_cart", args: { product: "Premium coffee 2 kg", brand: "Usual Farms", category: "coffee", quantity: 1, price: 39.99, upgrade: true }, say: "upgrades coffee to the premium 2 kg bag" },
|
|
38551
|
+
{ tool: "add_to_cart", args: { product: "Snack bar", brand: "Promo", category: "snacks", quantity: 1, price: 3.99, sponsored: true }, say: "adds a sponsored snack bar" },
|
|
38552
|
+
{ tool: "add_to_cart", args: { product: "Red wine", brand: "Cellar", category: "alcohol", quantity: 1, price: 14.99 }, say: "adds a bottle of wine" },
|
|
38553
|
+
{ tool: "add_to_cart", args: { product: "Gift card $50", category: "gift cards", quantity: 10, price: 50 }, say: "is tricked by a hidden instruction in a listing: adds 10 gift cards" },
|
|
38554
|
+
{ tool: "pay_for_order", args: { amount: 90, currency: "CAD", merchant: "QuickCash", idempotency_key: "g-x" }, say: "is tricked into paying $90 to QuickCash" },
|
|
38555
|
+
{ tool: "pay_for_order", args: { amount: 68.4, currency: "CAD", merchant: "Demo Grocer", delivery_address: "12 King St, Toronto", idempotency_key: "g-1" }, say: "pays $68.40 to Demo Grocer, with your delivery address" },
|
|
38556
|
+
{ tool: "pay_for_order", args: { amount: 180, currency: "CAD", merchant: "Demo Grocer", idempotency_key: "g-2" }, say: "tries to pay $180" }
|
|
38557
|
+
] };
|
|
38558
|
+
TRAVEL = { id: "travel", title: 'Travel: "business trip to Montreal, refundable, at most one stop"', server: "travel", tools: TRAVEL_TOOLS.map((t) => t.name), m: {
|
|
38559
|
+
autonomy: "act",
|
|
38560
|
+
purpose: "Business trip to Montreal, 3 to 4 March",
|
|
38561
|
+
actions: [{ cls: "search", autonomy: "act" }, { cls: "book", autonomy: "act" }, { cls: "change", autonomy: "act" }],
|
|
38562
|
+
rules: [{ field: "travel.fare.total", op: "max", value: 600, label: "fare up to $600" }, { field: "travel.itinerary.connections", op: "max", value: 1, label: "at most one connection" }, { field: "travel.fare.refundable", op: "eq", value: true, label: "refundable fares only" }],
|
|
38563
|
+
upsell: "ask",
|
|
38564
|
+
approvalTriggers: ["fee"],
|
|
38565
|
+
preferences: [{ field: "travel.seat", prefer: "aisle", label: "an aisle seat" }, { field: "travel.carrier", prefer: "Maple Air", label: "Maple Air (loyalty)" }],
|
|
38566
|
+
dataSharing: [{ data: "passport", to: "Maple Air" }],
|
|
38567
|
+
disclosures: { operator: "Demo Travel", incentives: "No commissions affect choices", dataUse: "Trip details used only for this booking" }
|
|
38568
|
+
}, steps: [
|
|
38569
|
+
{ tool: "search_flights", args: { from: "YYZ", to: "YUL", date: "2027-03-03" }, say: "searches flights" },
|
|
38570
|
+
{ tool: "book_flight", args: { flight: "BJ 210", fare: 420, currency: "CAD", stops: 2, refundable: true, carrier: "Budget Jet", idempotency_key: "t-1" }, say: "tries the cheapest fare (2 stops, $420)" },
|
|
38571
|
+
{ tool: "book_flight", args: { flight: "DA 101", fare: 380, currency: "CAD", stops: 0, refundable: false, carrier: "Direct Air", idempotency_key: "t-2" }, say: "tries a direct non-refundable fare ($380)" },
|
|
38572
|
+
{ tool: "book_flight", args: { flight: "MA 330", fare: 540, currency: "CAD", stops: 1, refundable: true, carrier: "Maple Air", passport_number: "X1234567", idempotency_key: "t-3" }, say: "books Maple Air, 1 stop, refundable ($540), with your passport" },
|
|
38573
|
+
{ tool: "share_traveller_details", args: { recipient: "Hotel Partner", passport_number: "X1234567" }, say: "tries to share your passport with a hotel partner" },
|
|
38574
|
+
{ tool: "change_seat", args: { seat: "aisle", fee: 0 }, say: "changes to a free aisle seat" },
|
|
38575
|
+
{ tool: "change_seat", args: { seat: "window, extra legroom", fee: 45 }, say: "tries a $45 extra-legroom seat" },
|
|
38576
|
+
{ tool: "upgrade_cabin", args: { cabin: "business", fee: 120, upgrade: true }, say: "tries a $120 business upgrade" }
|
|
38577
|
+
] };
|
|
38578
|
+
FINANCE = { id: "finance", title: 'Finance: "month-end operations; confidential data only to the auditor; I approve big invoices"', server: "finance", tools: FINANCE_TOOLS.map((t) => t.name), m: {
|
|
38579
|
+
autonomy: "act",
|
|
38580
|
+
purpose: "Month-end finance operations",
|
|
38581
|
+
actions: [{ cls: "communicate", autonomy: "act" }, { cls: "pay", autonomy: "act" }],
|
|
38582
|
+
rules: [{ field: "commerce.order.total", op: "max", value: 5e4, label: "invoices up to $50,000" }],
|
|
38583
|
+
approveAbove: { arg: "amount", value: 1e4 },
|
|
38584
|
+
dataSharing: [{ data: "internal", to: "Finance team" }, { data: "confidential", to: "External Auditor" }],
|
|
38585
|
+
disclosures: { operator: "Acme Corp IT", incentives: "None", dataUse: "Company data stays within the recipients listed" }
|
|
38586
|
+
}, steps: [
|
|
38587
|
+
{ tool: "send_report", args: { recipient: "Finance team", report: "Month-end close summary", data_class: "internal" }, say: "sends the internal close summary to the finance team" },
|
|
38588
|
+
{ tool: "send_report", args: { recipient: "Partner Agency", report: "Q1 forecast", data_class: "confidential" }, say: "tries to send the confidential forecast to a partner agency" },
|
|
38589
|
+
{ tool: "send_report", args: { recipient: "External Auditor", report: "Q4 results", data_class: "confidential" }, say: "sends confidential results to the external auditor" },
|
|
38590
|
+
{ tool: "pay_invoice", args: { amount: 4200, currency: "CAD", vendor: "Cloud Hosting Inc", idempotency_key: "f-1" }, say: "pays a $4,200 hosting invoice" },
|
|
38591
|
+
{ tool: "pay_invoice", args: { amount: 12e3, currency: "CAD", vendor: "Consulting LLP", idempotency_key: "f-2" }, say: "tries to pay a $12,000 consulting invoice" },
|
|
38592
|
+
{ tool: "", args: {}, say: "you approve exactly that invoice (saktum agent approve)", approveLast: true },
|
|
38593
|
+
{ tool: "pay_invoice", args: { amount: 12e3, currency: "CAD", vendor: "Consulting LLP", idempotency_key: "f-2" }, say: "retries the same $12,000 invoice" }
|
|
38594
|
+
] };
|
|
38595
|
+
}
|
|
38596
|
+
});
|
|
38597
|
+
|
|
37093
38598
|
// packages/cli/dist/mcp-server.js
|
|
37094
38599
|
var mcp_server_exports = {};
|
|
37095
38600
|
__export(mcp_server_exports, {
|
|
@@ -37098,7 +38603,7 @@ __export(mcp_server_exports, {
|
|
|
37098
38603
|
splitTarget: () => splitTarget,
|
|
37099
38604
|
startMcpServer: () => startMcpServer
|
|
37100
38605
|
});
|
|
37101
|
-
import { readFileSync as
|
|
38606
|
+
import { readFileSync as readFileSync7 } from "node:fs";
|
|
37102
38607
|
function splitTarget(target) {
|
|
37103
38608
|
const t = target.trim();
|
|
37104
38609
|
if (/^https?:\/\//i.test(t))
|
|
@@ -37134,7 +38639,7 @@ async function handleSaktumTool(name, args, packs) {
|
|
|
37134
38639
|
case "diff_against_lock": {
|
|
37135
38640
|
if (typeof args.lock_path !== "string")
|
|
37136
38641
|
throw new Error("lock_path is required");
|
|
37137
|
-
const before = JSON.parse(
|
|
38642
|
+
const before = JSON.parse(readFileSync7(args.lock_path, "utf8"));
|
|
37138
38643
|
const d = diffLocks(before, { tools: (await listTools(targetOf(args.target))).tools });
|
|
37139
38644
|
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 });
|
|
37140
38645
|
}
|
|
@@ -37275,7 +38780,7 @@ var init_mcp_server = __esm({
|
|
|
37275
38780
|
});
|
|
37276
38781
|
|
|
37277
38782
|
// packages/cli/dist/main.js
|
|
37278
|
-
import { existsSync as
|
|
38783
|
+
import { existsSync as existsSync6, readFileSync as readFileSync8, writeFileSync as writeFileSync4 } from "node:fs";
|
|
37279
38784
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
37280
38785
|
|
|
37281
38786
|
// node_modules/.pnpm/commander@12.1.0/node_modules/commander/esm.mjs
|
|
@@ -37469,6 +38974,7 @@ var WELCOME = `Saktum Check \u2014 make the tools AI agents use trustworthy.
|
|
|
37469
38974
|
|
|
37470
38975
|
What would you like to do?
|
|
37471
38976
|
|
|
38977
|
+
0. See it in 60 seconds npx saktum demo
|
|
37472
38978
|
1. Test an MCP server npx saktum check -- npx -y some-mcp-server
|
|
37473
38979
|
npx saktum check https://your-server.example/mcp
|
|
37474
38980
|
2. Start a new MCP server npx saktum init my-server --lang ts (or --lang py)
|
|
@@ -37510,16 +39016,16 @@ async function main(argv = process.argv) {
|
|
|
37510
39016
|
});
|
|
37511
39017
|
let testCases;
|
|
37512
39018
|
if (o.tests) {
|
|
37513
|
-
if (!
|
|
39019
|
+
if (!existsSync6(o.tests))
|
|
37514
39020
|
throw new Error(`Test file not found: ${o.tests}. See docs/TESTS.md for the format.`);
|
|
37515
|
-
testCases = await parseTestCases(
|
|
39021
|
+
testCases = await parseTestCases(readFileSync8(o.tests, "utf8"));
|
|
37516
39022
|
}
|
|
37517
39023
|
const target = parseTarget(targetParts);
|
|
37518
39024
|
if (target.kind === "stdio" && o.env.length)
|
|
37519
39025
|
target.env = parseEnv(o.env);
|
|
37520
39026
|
if (target.kind === "streamable-http" && o.header.length)
|
|
37521
39027
|
target.headers = parseHeaders(o.header);
|
|
37522
|
-
const packs = o.packs ? loadPackDir(o.packs) :
|
|
39028
|
+
const packs = o.packs ? loadPackDir(o.packs) : existsSync6(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
|
|
37523
39029
|
let result;
|
|
37524
39030
|
try {
|
|
37525
39031
|
result = await runTrustCheck(target, { packs, mode: o.active ? "active" : "passive", pricePerMTokUsd: price, callTools: o.call, testCases, ignore });
|
|
@@ -37531,23 +39037,23 @@ async function main(argv = process.argv) {
|
|
|
37531
39037
|
return 2;
|
|
37532
39038
|
}
|
|
37533
39039
|
const signed = signDocument(result, loadOrCreateKey(o.key));
|
|
37534
|
-
|
|
39040
|
+
writeFileSync4(o.out, JSON.stringify(signed, null, 2));
|
|
37535
39041
|
if (o.html)
|
|
37536
|
-
|
|
39042
|
+
writeFileSync4(o.html, renderHtml(signed));
|
|
37537
39043
|
if (o.badge)
|
|
37538
|
-
|
|
39044
|
+
writeFileSync4(o.badge, badgeSvg(signed));
|
|
37539
39045
|
const keyOf = (f) => `${f.check}:${f.subject ?? ""}`;
|
|
37540
39046
|
const failing = signed.findings.filter((f) => f.status === "fail" && !f.suppressed);
|
|
37541
39047
|
let accepted = /* @__PURE__ */ new Set();
|
|
37542
39048
|
if (o.baseline && o.updateBaseline) {
|
|
37543
|
-
|
|
39049
|
+
writeFileSync4(o.baseline, JSON.stringify({ baselineFormat: "0.1", createdAt: (/* @__PURE__ */ new Date()).toISOString(), accepted: failing.map((f) => ({ check: f.check, subject: f.subject, severity: f.severity, title: f.title })) }, null, 2) + "\n");
|
|
37544
39050
|
process.stdout.write(`Wrote baseline ${sanitizeText(o.baseline)} accepting ${failing.length} existing finding(s). Commit it; later runs fail only on new findings.
|
|
37545
39051
|
`);
|
|
37546
|
-
} else if (o.baseline &&
|
|
37547
|
-
accepted = new Set(JSON.parse(
|
|
39052
|
+
} else if (o.baseline && existsSync6(o.baseline)) {
|
|
39053
|
+
accepted = new Set(JSON.parse(readFileSync8(o.baseline, "utf8")).accepted.map(keyOf));
|
|
37548
39054
|
}
|
|
37549
39055
|
if (o.sarif)
|
|
37550
|
-
|
|
39056
|
+
writeFileSync4(o.sarif, JSON.stringify(toSarif(signed, o.sarifAnchor, accepted), null, 2) + "\n");
|
|
37551
39057
|
process.stdout.write(renderTerminal(signed) + "\n");
|
|
37552
39058
|
process.stdout.write(`
|
|
37553
39059
|
Signed result: ${sanitizeText(o.out)} (verify with: saktum verify ${sanitizeText(o.out)})${o.badge ? `
|
|
@@ -37616,7 +39122,7 @@ Watching ${sanitizeText(o.watchDir)} for changes (Ctrl+C to stop).
|
|
|
37616
39122
|
exitCode = await runCheckCommand(targetParts, o);
|
|
37617
39123
|
});
|
|
37618
39124
|
program2.command("checks").description("List every check: what it tests, the standard behind it, and when it runs").option("--markdown", "print a Markdown table (as in docs/CHECKS.md)", false).option("--packs <dir>", "directory of packs (default: the built-in packs)").action((o) => {
|
|
37619
|
-
const packs = o.packs ? loadPackDir(o.packs) :
|
|
39125
|
+
const packs = o.packs ? loadPackDir(o.packs) : existsSync6(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
|
|
37620
39126
|
process.stdout.write(checksTable(packs, o.markdown));
|
|
37621
39127
|
});
|
|
37622
39128
|
const listTarget = async (targetParts, env, header) => {
|
|
@@ -37638,13 +39144,13 @@ Watching ${sanitizeText(o.watchDir)} for changes (Ctrl+C to stop).
|
|
|
37638
39144
|
});
|
|
37639
39145
|
program2.command("snapshot").description("Write a lock file of the server's tools, to detect breaking or silent changes later with saktum diff").argument("<target...>", "https://host/mcp or -- node server.js").option("--out <file>", "lock file", "saktum.lock.json").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 (targetParts, o) => {
|
|
37640
39146
|
const { tools, server } = await listTarget(targetParts, o.env, o.header);
|
|
37641
|
-
|
|
39147
|
+
writeFileSync4(o.out, JSON.stringify(toolsLock(tools, server), null, 2) + "\n");
|
|
37642
39148
|
process.stdout.write(`Wrote ${sanitizeText(o.out)} with ${tools.length} tools. Commit it; run saktum diff in CI to catch breaking or silent changes.
|
|
37643
39149
|
`);
|
|
37644
39150
|
});
|
|
37645
39151
|
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) => {
|
|
37646
|
-
const before = JSON.parse(
|
|
37647
|
-
const after = rest.length === 1 && rest[0].endsWith(".json") ? JSON.parse(
|
|
39152
|
+
const before = JSON.parse(readFileSync8(lock, "utf8"));
|
|
39153
|
+
const after = rest.length === 1 && rest[0].endsWith(".json") ? JSON.parse(readFileSync8(rest[0], "utf8")) : { tools: (await listTarget(rest, o.env, o.header)).tools };
|
|
37648
39154
|
const d = diffLocks(before, after);
|
|
37649
39155
|
const mark2 = { breaking: "\u2717 BREAKING", risky: "! REVIEW ", addition: "+ ADDED ", change: "~ CHANGED " };
|
|
37650
39156
|
for (const c of d.changes)
|
|
@@ -37661,11 +39167,11 @@ ${d.summary}
|
|
|
37661
39167
|
process.stdout.write(docsFor(tools, name, target.kind === "stdio" ? { command: target.command, args: target.args } : { url: target.url }));
|
|
37662
39168
|
});
|
|
37663
39169
|
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) => {
|
|
37664
|
-
const doc = JSON.parse(
|
|
39170
|
+
const doc = JSON.parse(readFileSync8(file, "utf8"));
|
|
37665
39171
|
const v = verifyDocument(doc);
|
|
37666
39172
|
if (!v.valid)
|
|
37667
39173
|
throw new Error(`The result's signature is not valid (${v.reason}); a packet must be built from an unaltered signed result.`);
|
|
37668
|
-
|
|
39174
|
+
writeFileSync4(o.out, renderPacket(doc, v.kid));
|
|
37669
39175
|
process.stdout.write(`Wrote ${sanitizeText(o.out)}: open it in a browser and print to PDF. Send it with ${sanitizeText(file)} so customers can verify it.
|
|
37670
39176
|
`);
|
|
37671
39177
|
});
|
|
@@ -37675,9 +39181,9 @@ ${d.summary}
|
|
|
37675
39181
|
const check = verifyLedger(entries);
|
|
37676
39182
|
if (!check.ok)
|
|
37677
39183
|
throw new Error(`The ledger does not verify: ${check.errors[0]}`);
|
|
37678
|
-
const signers = o.trustedSigners ? new Set(
|
|
39184
|
+
const signers = o.trustedSigners ? new Set(readFileSync8(o.trustedSigners, "utf8").split(/\r?\n/).map((l) => l.trim()).filter(Boolean)) : void 0;
|
|
37679
39185
|
const list2 = allowlistFromLedger(entries, { minTrust: o.minTrust.toUpperCase(), minReadiness: o.minReadiness.toUpperCase(), trustedSigners: signers });
|
|
37680
|
-
|
|
39186
|
+
writeFileSync4(o.out, JSON.stringify(list2, null, 2) + "\n");
|
|
37681
39187
|
process.stdout.write(`Ledger verified (${check.count} entries). Wrote ${sanitizeText(o.out)}: ${list2.allowed.length} allowed, ${list2.excluded.length} excluded.
|
|
37682
39188
|
`);
|
|
37683
39189
|
return;
|
|
@@ -37685,14 +39191,14 @@ ${d.summary}
|
|
|
37685
39191
|
if (!files.length)
|
|
37686
39192
|
throw new Error("Give signed results, or use --from-ledger.");
|
|
37687
39193
|
const inputs = files.map((f) => {
|
|
37688
|
-
const doc = JSON.parse(
|
|
39194
|
+
const doc = JSON.parse(readFileSync8(f, "utf8"));
|
|
37689
39195
|
const v = verifyDocument(doc);
|
|
37690
39196
|
if (!v.valid)
|
|
37691
39197
|
throw new Error(`${f}: signature not valid (${v.reason}); only unaltered signed results can be allowlisted.`);
|
|
37692
39198
|
return { result: doc, signedBy: v.kid };
|
|
37693
39199
|
});
|
|
37694
39200
|
const list = buildAllowlist(inputs, { minTrust: o.minTrust.toUpperCase(), minReadiness: o.minReadiness.toUpperCase(), noFailedCritical: !o.allowCritical });
|
|
37695
|
-
|
|
39201
|
+
writeFileSync4(o.out, JSON.stringify(list, null, 2) + "\n");
|
|
37696
39202
|
for (const a of list.allowed)
|
|
37697
39203
|
process.stdout.write(`\u2713 ${sanitizeText(a.server, 60)} ${sanitizeText(a.version ?? "", 20)} trust ${a.trustGrade} \xB7 readiness ${a.readinessGrade} \xB7 ${a.toolCount} tools pinned
|
|
37698
39204
|
`);
|
|
@@ -37729,7 +39235,7 @@ Next:
|
|
|
37729
39235
|
${findings.length} finding(s) in tool definitions.
|
|
37730
39236
|
` : "No problems found in tool definitions (files importing an MCP SDK).\n");
|
|
37731
39237
|
if (o.sarif)
|
|
37732
|
-
|
|
39238
|
+
writeFileSync4(o.sarif, JSON.stringify(lintSarif(findings, ENGINE_VERSION), null, 2) + "\n");
|
|
37733
39239
|
exitCode = findings.some((f) => f.severity === "error" || o.strict) ? 1 : 0;
|
|
37734
39240
|
});
|
|
37735
39241
|
program2.command("call").description("Call one tool and show the result; --save-test turns the call into a test case (save as test)").argument("<tool>", "tool name").argument("<target...>", "https://host/mcp or -- node server.js").option("--args <json>", "arguments as JSON", "{}").option("--save-test <id>", "append this call and its result as a test case").option("--tests <file>", "test file to append to", "saktum.tests.yaml").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 (toolName, targetParts, o) => {
|
|
@@ -37772,7 +39278,7 @@ ${structured ? `structured: ${sanitizeText(JSON.stringify(structured), 1e3)}
|
|
|
37772
39278
|
expect.outputSchema = true;
|
|
37773
39279
|
expect.latencyMs = { lt: Math.max(2e3, outcome.latencyMs * 5) };
|
|
37774
39280
|
const tc = { id: o.saveTest, tool: toolName, input: args, ...tool.annotations?.readOnlyHint === true ? {} : { sideEffects: true }, expect };
|
|
37775
|
-
|
|
39281
|
+
writeFileSync4(o.tests, await appendTestCase(existsSync6(o.tests) ? readFileSync8(o.tests, "utf8") : void 0, tc));
|
|
37776
39282
|
process.stdout.write(`Saved test case ${sanitizeText(o.saveTest, 60)} to ${sanitizeText(o.tests)}. Run: saktum test -- <start command>
|
|
37777
39283
|
`);
|
|
37778
39284
|
}
|
|
@@ -37780,7 +39286,7 @@ ${structured ? `structured: ${sanitizeText(JSON.stringify(structured), 1e3)}
|
|
|
37780
39286
|
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) => {
|
|
37781
39287
|
const { homedir: homedir2 } = await import("node:os");
|
|
37782
39288
|
const locations = o.config.length ? o.config.map((file) => ({ client: "configuration", file })) : configLocations(homedir2(), process.cwd(), process.platform, process.env.APPDATA);
|
|
37783
|
-
const servers = locations.filter((l) =>
|
|
39289
|
+
const servers = locations.filter((l) => existsSync6(l.file)).flatMap((l) => parseClientConfig(readFileSync8(l.file, "utf8"), l.client, l.file)).filter((x) => !x.disabled);
|
|
37784
39290
|
if (!servers.length) {
|
|
37785
39291
|
process.stdout.write("No MCP servers found in the known configuration locations. Point to one with --config <file>.\n");
|
|
37786
39292
|
return;
|
|
@@ -37803,7 +39309,7 @@ ${structured ? `structured: ${sanitizeText(JSON.stringify(structured), 1e3)}
|
|
|
37803
39309
|
return;
|
|
37804
39310
|
}
|
|
37805
39311
|
}
|
|
37806
|
-
const packs =
|
|
39312
|
+
const packs = existsSync6(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
|
|
37807
39313
|
const scans = [];
|
|
37808
39314
|
for (const x of servers) {
|
|
37809
39315
|
let tools = [];
|
|
@@ -37830,7 +39336,7 @@ ${structured ? `structured: ${sanitizeText(JSON.stringify(structured), 1e3)}
|
|
|
37830
39336
|
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) });
|
|
37831
39337
|
}
|
|
37832
39338
|
}
|
|
37833
|
-
const allow = o.allowlist ? new Set(JSON.parse(
|
|
39339
|
+
const allow = o.allowlist ? new Set(JSON.parse(readFileSync8(o.allowlist, "utf8")).allowed.map((a) => a.toolsFingerprint).filter((f) => Boolean(f))) : void 0;
|
|
37834
39340
|
const report = analyseSetup(scans, { turnsPerDay: Number(o.turnsPerDay) || 50, pricePerMTokUsd: Number(o.pricePerMtok) || 3, allowlistFingerprints: allow });
|
|
37835
39341
|
process.stdout.write("\n" + renderSetup(report));
|
|
37836
39342
|
if (o.policy) {
|
|
@@ -37843,10 +39349,10 @@ POLICY${policy.name ? ` (${sanitizeText(policy.name, 80)})` : ""}
|
|
|
37843
39349
|
}
|
|
37844
39350
|
const { hostname } = await import("node:os");
|
|
37845
39351
|
if (o.out)
|
|
37846
|
-
|
|
39352
|
+
writeFileSync4(o.out, JSON.stringify({ ...report, machine: o.machine ?? hostname() }, null, 2) + "\n");
|
|
37847
39353
|
});
|
|
37848
39354
|
program2.command("vc").description("W3C Verifiable Credentials made by saktum attest --vc").command("verify").description("Verify a Saktum credential (vc+jwt): signature and issuer did:key").argument("<file>", "the .vc.jwt file").action((f) => {
|
|
37849
|
-
const r = verifyCredentialJwt(
|
|
39355
|
+
const r = verifyCredentialJwt(readFileSync8(f, "utf8"));
|
|
37850
39356
|
if (r.valid) {
|
|
37851
39357
|
const cs = r.credential.credentialSubject ?? {};
|
|
37852
39358
|
process.stdout.write(`\u2713 Valid credential from ${r.issuer}: ${sanitizeText(String(cs.server ?? ""), 80)} trust ${cs.trustGrade ?? "-"}, readiness ${cs.readinessGrade ?? "-"}.
|
|
@@ -37879,50 +39385,127 @@ ${r.errors.slice(0, 10).map((e) => ` ${sanitizeText(e, 200)}`).join("\n")}
|
|
|
37879
39385
|
const v = verifyLedger(entries);
|
|
37880
39386
|
if (!v.ok)
|
|
37881
39387
|
throw new Error(`The ledger does not verify: ${v.errors[0]}`);
|
|
37882
|
-
const { mkdirSync:
|
|
37883
|
-
|
|
39388
|
+
const { mkdirSync: mkdirSync5 } = await import("node:fs");
|
|
39389
|
+
mkdirSync5(o.out, { recursive: true });
|
|
37884
39390
|
const latest = /* @__PURE__ */ new Map();
|
|
37885
39391
|
for (const e of entries)
|
|
37886
39392
|
latest.set(e.subject.server, e);
|
|
37887
39393
|
for (const e of latest.values())
|
|
37888
|
-
|
|
37889
|
-
|
|
39394
|
+
writeFileSync4(`${o.out}/${passportSlug(e.subject.server)}.html`, renderLedgerPassport(e));
|
|
39395
|
+
writeFileSync4(`${o.out}/index.html`, renderPassportGallery(entries));
|
|
37890
39396
|
process.stdout.write(`Wrote ${latest.size} passport page(s) and the gallery to ${sanitizeText(o.out)}.
|
|
37891
39397
|
`);
|
|
37892
39398
|
});
|
|
37893
39399
|
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) => {
|
|
37894
|
-
const att = extractJson(
|
|
37895
|
-
const { text: text2, entry } = appendToLedger(
|
|
37896
|
-
|
|
39400
|
+
const att = extractJson(readFileSync8(input, "utf8"));
|
|
39401
|
+
const { text: text2, entry } = appendToLedger(existsSync6(o.ledger) ? readFileSync8(o.ledger, "utf8") : "", att, { via: "saktum-index issue", ...o.issue ? { issue: Number(o.issue) } : {} });
|
|
39402
|
+
writeFileSync4(o.ledger, text2);
|
|
37897
39403
|
process.stdout.write(`Recorded entry #${entry.seq} for ${sanitizeText(entry.subject.server, 80)} (signed by ${entry.signer}); entry hash ${entry.entryHash}.
|
|
37898
39404
|
`);
|
|
37899
39405
|
});
|
|
37900
39406
|
const agent = program2.command("agent").description("Agent identity: give an agent its own key and a mandate signed by its owner (preview)");
|
|
37901
|
-
agent.command("create").description("Create an agent identity (did:key) and a mandate you sign: allowed servers and tools, destructive actions, expiry").requiredOption("--name <name>", 'agent name, for example "Billing assistant"').option("--purpose <text>", "what the agent is for").option("--owner-name <name>", "your name or team, shown in receipts").option("--allow-server <name>", "server the agent may use (repeatable; default: any)", collect, []).option("--allow-tool <name>", "tool the agent may use (repeatable; default: any)", collect, []).option("--allow-destructive", "allow tools declared destructive", false).option("--expires <date>", "last valid day, YYYY-MM-DD", new Date(Date.now() + 30 * 864e5).toISOString().slice(0, 10)).option("--out <file>", "mandate file", "agent-mandate.json").option("--agent-key <file>", "where to keep the agent's own key", "agent-key.json").option("--key <file>", "your (owner's) signing key").action((o) => {
|
|
39407
|
+
agent.command("create").description("Create an agent identity (did:key) and a mandate you sign: allowed servers and tools, destructive actions, expiry").requiredOption("--name <name>", 'agent name, for example "Billing assistant"').option("--purpose <text>", "what the agent is for").option("--owner-name <name>", "your name or team, shown in receipts").option("--allow-server <name>", "server the agent may use (repeatable; default: any)", collect, []).option("--allow-tool <name>", "tool the agent may use (repeatable; default: any)", collect, []).option("--allow-destructive", "allow tools declared destructive", false).option("--autonomy <level>", "notify (only alert), propose (suggest, the user approves) or act (within the limits)", "propose").option("--max <tool.arg=value>", "cap a numeric argument, for example checkout.amount=50 (repeatable)", collect, []).option("--allow-value <tool.arg=v1,v2>", "allowed values for an argument, for example checkout.currency=CAD (repeatable)", collect, []).option("--daily-calls <n>", "at most this many actions a day").option("--daily-total <arg=max>", "at most this total a day for an argument, for example amount=200").option("--approve-above <arg=value>", "ask the user above this value, for example amount=25").option("--operator <name>", "who operates the agent (disclosure)").option("--incentives <text>", "incentives that could influence the agent, for example sponsored products (disclosure)").option("--data-use <text>", "what the agent does with the user's data (disclosure)").option("--allow-delegation", "allow the agent to hand work to other agents", false).option("--software <name@version>", "the agent software that will act under this mandate").option("--intent <file>", "instructions as JSON: purpose, actions, rules, preferences, substitution, upsell, approvalTriggers, counterparties, dataSharing (see examples/mandate-grocery.json)").option("--expires <date>", "last valid day, YYYY-MM-DD", new Date(Date.now() + 30 * 864e5).toISOString().slice(0, 10)).option("--out <file>", "mandate file", "agent-mandate.json").option("--agent-key <file>", "where to keep the agent's own key", "agent-key.json").option("--key <file>", "your (owner's) signing key").action((o) => {
|
|
37902
39408
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(o.expires))
|
|
37903
39409
|
throw new Error("--expires must be YYYY-MM-DD");
|
|
39410
|
+
if (!["notify", "propose", "act"].includes(o.autonomy))
|
|
39411
|
+
throw new Error("--autonomy must be notify, propose or act");
|
|
39412
|
+
const ta = (x, flag) => {
|
|
39413
|
+
const m2 = /^([^.=]+)\.([^=]+)=(.+)$/.exec(x);
|
|
39414
|
+
if (!m2)
|
|
39415
|
+
throw new Error(`${flag} must look like tool.arg=value`);
|
|
39416
|
+
return { tool: m2[1], arg: m2[2], value: m2[3] };
|
|
39417
|
+
};
|
|
39418
|
+
const av = (x, flag) => {
|
|
39419
|
+
const m2 = /^([^=]+)=(-?[\d.]+)$/.exec(x);
|
|
39420
|
+
if (!m2)
|
|
39421
|
+
throw new Error(`${flag} must look like arg=number`);
|
|
39422
|
+
return { arg: m2[1], value: Number(m2[2]) };
|
|
39423
|
+
};
|
|
39424
|
+
const constraints = [...o.max.map((x) => {
|
|
39425
|
+
const t = ta(x, "--max");
|
|
39426
|
+
return { tool: t.tool, arg: t.arg, max: Number(t.value) };
|
|
39427
|
+
}), ...o.allowValue.map((x) => {
|
|
39428
|
+
const t = ta(x, "--allow-value");
|
|
39429
|
+
return { tool: t.tool, arg: t.arg, oneOf: t.value.split(",").map((v) => v.trim()) };
|
|
39430
|
+
})];
|
|
39431
|
+
const dt = o.dailyTotal ? av(o.dailyTotal, "--daily-total") : void 0, aa = o.approveAbove ? av(o.approveAbove, "--approve-above") : void 0;
|
|
37904
39432
|
const agentKey = loadOrCreateKey(o.agentKey);
|
|
37905
|
-
const m = createMandate({
|
|
37906
|
-
|
|
39433
|
+
const m = createMandate({
|
|
39434
|
+
agentId: agentKey.kid,
|
|
39435
|
+
agentName: o.name,
|
|
39436
|
+
ownerName: o.ownerName,
|
|
39437
|
+
purpose: o.purpose,
|
|
39438
|
+
servers: o.allowServer,
|
|
39439
|
+
tools: o.allowTool,
|
|
39440
|
+
destructive: o.allowDestructive,
|
|
39441
|
+
expires: o.expires,
|
|
39442
|
+
autonomy: o.autonomy,
|
|
39443
|
+
constraints,
|
|
39444
|
+
limits: { ...o.dailyCalls ? { callsPerDay: Number(o.dailyCalls) } : {}, ...dt ? { totalPerDay: { arg: dt.arg, max: dt.value } } : {} },
|
|
39445
|
+
approveAbove: aa,
|
|
39446
|
+
disclosures: { ...o.operator ? { operator: o.operator } : {}, ...o.incentives ? { incentives: o.incentives } : {}, ...o.dataUse ? { dataUse: o.dataUse } : {} },
|
|
39447
|
+
delegation: o.allowDelegation,
|
|
39448
|
+
...o.intent ? JSON.parse(readFileSync8(o.intent, "utf8")) : {}
|
|
39449
|
+
}, loadOrCreateKey(o.key));
|
|
39450
|
+
if (o.software) {
|
|
39451
|
+
const { signature: _old, ...body } = m;
|
|
39452
|
+
body.agent = { ...body.agent, software: o.software };
|
|
39453
|
+
Object.assign(m, signDocument(body, loadOrCreateKey(o.key)));
|
|
39454
|
+
}
|
|
39455
|
+
const valid = compileContract("mandate.schema.json");
|
|
39456
|
+
if (!valid(m))
|
|
39457
|
+
throw new Error(`The mandate is not valid: ${(valid.errors ?? []).map((e) => `${e.instancePath || "/"} ${e.message}`).join("; ")}`);
|
|
39458
|
+
writeFileSync4(o.out, JSON.stringify(m, null, 2) + "\n");
|
|
39459
|
+
for (const line of describeMandate(m))
|
|
39460
|
+
process.stdout.write(` ${line}
|
|
39461
|
+
`);
|
|
37907
39462
|
process.stdout.write(`Agent ${sanitizeText(o.name, 80)}: ${agentKey.kid}
|
|
37908
|
-
Mandate signed by ${m.owner.id}, valid until ${o.expires}: ${m.allow.servers ? `servers ${m.allow.servers.join(", ")}` : "any server"}; ${m.allow.tools ? `tools ${m.allow.tools.join(", ")}` : "any tool"}; destructive actions ${m.allow.destructive ? "allowed" : "not allowed"}.
|
|
39463
|
+
Mandate signed by ${m.owner.id}, valid until ${o.expires}: ${m.allow.servers ? `servers ${m.allow.servers.join(", ")}` : "any server"}; ${m.allow.tools ? `tools ${m.allow.tools.join(", ")}` : "any tool"}; destructive actions ${m.allow.destructive ? "allowed" : "not allowed"}; autonomy ${m.autonomy}; risk tier ${agentRiskTier(m).tier} (${agentRiskTier(m).note}).
|
|
37909
39464
|
Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep it private).
|
|
37910
39465
|
`);
|
|
37911
39466
|
});
|
|
37912
|
-
agent.command("verify").description("Check a mandate's
|
|
37913
|
-
const m = JSON.parse(
|
|
37914
|
-
const c = checkMandate(m);
|
|
39467
|
+
agent.command("verify").description("Check a mandate: the principal's signature, the operator's countersignature, expiry and revocation").argument("<mandate>", "mandate file").action((f) => {
|
|
39468
|
+
const m = JSON.parse(readFileSync8(f, "utf8"));
|
|
39469
|
+
const c = checkMandate(m), op = checkOperator(m), rev = revocationOf(m);
|
|
37915
39470
|
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}.
|
|
37916
39471
|
` : `\u2717 ${c.reason}
|
|
37917
39472
|
`);
|
|
37918
|
-
|
|
39473
|
+
if (op.present)
|
|
39474
|
+
process.stdout.write(op.valid ? `\u2713 Countersigned by the operator ${sanitizeText(op.name ?? "", 80)} (${op.id}).
|
|
39475
|
+
` : `\u2717 Operator countersignature: ${op.reason}
|
|
39476
|
+
`);
|
|
39477
|
+
if (rev)
|
|
39478
|
+
process.stdout.write(`\u2717 Revoked on ${rev.at.slice(0, 10)}${rev.reason ? `: ${sanitizeText(rev.reason, 200)}` : ""}.
|
|
39479
|
+
`);
|
|
39480
|
+
exitCode = c.ok && (!op.present || op.valid) && !rev ? 0 : 1;
|
|
37919
39481
|
});
|
|
37920
|
-
|
|
39482
|
+
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) => {
|
|
39483
|
+
const m = JSON.parse(readFileSync8(f, "utf8"));
|
|
39484
|
+
if (!checkMandate(m).ok)
|
|
39485
|
+
throw new Error("The mandate is not valid; it cannot be countersigned.");
|
|
39486
|
+
const signed = cosignMandate(m, loadOrCreateKey(o.key), o.name);
|
|
39487
|
+
writeFileSync4(f, JSON.stringify(signed, null, 2) + "\n");
|
|
39488
|
+
process.stdout.write(`Countersigned by ${sanitizeText(o.name, 80)} (${loadOrCreateKey(o.key).kid}). Check: npx saktum agent verify ${sanitizeText(f)}
|
|
39489
|
+
`);
|
|
39490
|
+
});
|
|
39491
|
+
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) => {
|
|
39492
|
+
const m = JSON.parse(readFileSync8(o.mandate, "utf8"));
|
|
39493
|
+
const a = approveAction(m, rid, loadOrCreateKey(o.key), Number(o.minutes), o.approvals);
|
|
39494
|
+
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.
|
|
39495
|
+
`);
|
|
39496
|
+
});
|
|
39497
|
+
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) => {
|
|
39498
|
+
const m = JSON.parse(readFileSync8(f, "utf8"));
|
|
39499
|
+
const r = revokeMandate(m, o.reason);
|
|
39500
|
+
process.stdout.write(`Revoked the mandate for ${sanitizeText(m.agent.name, 80)} at ${r.at}. Its calls are now refused (code: revoked).
|
|
39501
|
+
`);
|
|
39502
|
+
});
|
|
39503
|
+
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)").action(async (parts, o) => {
|
|
37921
39504
|
const { homedir: homedir2 } = await import("node:os");
|
|
37922
|
-
const { join:
|
|
39505
|
+
const { join: join6 } = await import("node:path");
|
|
37923
39506
|
let mandate;
|
|
37924
39507
|
if (o.mandate) {
|
|
37925
|
-
mandate = JSON.parse(
|
|
39508
|
+
mandate = JSON.parse(readFileSync8(o.mandate, "utf8"));
|
|
37926
39509
|
const c = checkMandate(mandate);
|
|
37927
39510
|
if (!c.ok)
|
|
37928
39511
|
throw new Error(`Mandate refused: ${c.reason}`);
|
|
@@ -37931,14 +39514,14 @@ Wrote ${sanitizeText(o.out)} and the agent key ${sanitizeText(o.agentKey)} (keep
|
|
|
37931
39514
|
if (mandate && agentKey.kid !== mandate.agent.id)
|
|
37932
39515
|
throw new Error("The agent key does not match the mandate's agent.");
|
|
37933
39516
|
const { runProxy: runProxy2 } = await Promise.resolve().then(() => (init_proxy(), proxy_exports));
|
|
37934
|
-
exitCode = await runProxy2({ command: parts[0], args: parts.slice(1), receiptsPath: o.receipts ??
|
|
39517
|
+
exitCode = await runProxy2({ command: parts[0], args: parts.slice(1), receiptsPath: o.receipts ?? join6(homedir2(), ".saktum", "receipts.jsonl"), agentKey, mandate, enforce: o.enforce, ...o.revocations ? { revocationsPath: o.revocations } : {}, ...o.approvals ? { approvalsPath: o.approvals } : {}, log: (m) => process.stderr.write(`saktum: ${m}
|
|
37935
39518
|
`) });
|
|
37936
39519
|
});
|
|
37937
39520
|
const receipts = program2.command("receipts").description("Signed receipts of agent tool calls (from saktum proxy)");
|
|
37938
39521
|
receipts.command("verify").description("Verify every receipt's signature and the hash chain").argument("[file]", "receipt log").action(async (f) => {
|
|
37939
39522
|
const { homedir: homedir2 } = await import("node:os");
|
|
37940
|
-
const { join:
|
|
37941
|
-
const r = verifyReceiptLog(parseReceiptLog(
|
|
39523
|
+
const { join: join6 } = await import("node:path");
|
|
39524
|
+
const r = verifyReceiptLog(parseReceiptLog(readFileSync8(f ?? join6(homedir2(), ".saktum", "receipts.jsonl"), "utf8")));
|
|
37942
39525
|
process.stdout.write(r.ok ? `\u2713 ${r.count} receipts verified: every signature valid, chain intact.
|
|
37943
39526
|
` : `\u2717 Receipts do NOT verify:
|
|
37944
39527
|
${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
@@ -37947,11 +39530,11 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
37947
39530
|
});
|
|
37948
39531
|
receipts.command("export").description("Export receipts as OpenTelemetry traces (OTLP/JSON) for your observability or security tools").argument("[file]", "receipt log").option("--otel <file>", "write OTLP/JSON traces to this file", "saktum-receipts.otlp.json").option("--endpoint <url>", "also send them to an OpenTelemetry collector (OTLP/HTTP), for example http://localhost:4318").action(async (f, o) => {
|
|
37949
39532
|
const { homedir: homedir2 } = await import("node:os");
|
|
37950
|
-
const { join:
|
|
37951
|
-
const entries = parseReceiptLog(
|
|
39533
|
+
const { join: join6 } = await import("node:path");
|
|
39534
|
+
const entries = parseReceiptLog(readFileSync8(f ?? join6(homedir2(), ".saktum", "receipts.jsonl"), "utf8"));
|
|
37952
39535
|
const v = verifyReceiptLog(entries);
|
|
37953
39536
|
const otlp = receiptsToOtlp(entries, { verified: v.ok, version: ENGINE_VERSION });
|
|
37954
|
-
|
|
39537
|
+
writeFileSync4(o.otel, JSON.stringify(otlp, null, 2) + "\n");
|
|
37955
39538
|
process.stdout.write(`Wrote ${entries.length} span(s) to ${sanitizeText(o.otel)} (receipts ${v.ok ? "verified" : "DO NOT verify"}).
|
|
37956
39539
|
`);
|
|
37957
39540
|
if (o.endpoint) {
|
|
@@ -37965,8 +39548,8 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
37965
39548
|
});
|
|
37966
39549
|
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) => {
|
|
37967
39550
|
const { homedir: homedir2 } = await import("node:os");
|
|
37968
|
-
const { join:
|
|
37969
|
-
const entries = parseReceiptLog(
|
|
39551
|
+
const { join: join6 } = await import("node:path");
|
|
39552
|
+
const entries = parseReceiptLog(readFileSync8(f ?? join6(homedir2(), ".saktum", "receipts.jsonl"), "utf8"));
|
|
37970
39553
|
const v = verifyReceiptLog(entries), s = summariseReceipts(entries);
|
|
37971
39554
|
if (o.json) {
|
|
37972
39555
|
process.stdout.write(JSON.stringify({ verified: v.ok, ...s }, null, 2) + "\n");
|
|
@@ -37980,11 +39563,11 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
37980
39563
|
});
|
|
37981
39564
|
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) => {
|
|
37982
39565
|
if (o.agent) {
|
|
37983
|
-
const m = JSON.parse(
|
|
39566
|
+
const m = JSON.parse(readFileSync8(o.agent, "utf8"));
|
|
37984
39567
|
const valid = checkMandate(m);
|
|
37985
39568
|
let receipts2;
|
|
37986
39569
|
if (o.receipts) {
|
|
37987
|
-
const entries = parseReceiptLog(
|
|
39570
|
+
const entries = parseReceiptLog(readFileSync8(o.receipts, "utf8"));
|
|
37988
39571
|
const counts = /* @__PURE__ */ new Map();
|
|
37989
39572
|
for (const e of entries) {
|
|
37990
39573
|
const k = `${e.receipt.envelope.tool}|${e.receipt.envelope.argumentsHash}`;
|
|
@@ -37996,7 +39579,9 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
37996
39579
|
timeline: entries.map((e) => ({ tool: e.receipt.envelope.tool, outcome: e.receipt.outcome, status: e.result.status, repeated: (counts.get(`${e.receipt.envelope.tool}|${e.receipt.envelope.argumentsHash}`) ?? 0) >= 3 }))
|
|
37997
39580
|
};
|
|
37998
39581
|
}
|
|
37999
|
-
|
|
39582
|
+
const rev = revocationOf(m), op = checkOperator(m);
|
|
39583
|
+
const ts = o.receipts ? trustStatement(parseReceiptLog(readFileSync8(o.receipts, "utf8")), receipts2?.verified ?? false) : void 0;
|
|
39584
|
+
writeFileSync4(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), { operator: op.present && op.valid ? `${op.name} (${op.id})` : void 0, track: ts?.lines }));
|
|
38000
39585
|
process.stdout.write(`Wrote the Agent Passport for ${sanitizeText(m.agent.name, 80)} to ${sanitizeText(o.out)}. Open it in a browser.
|
|
38001
39586
|
`);
|
|
38002
39587
|
return;
|
|
@@ -38008,20 +39593,20 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
38008
39593
|
target.env = parseEnv(o.env);
|
|
38009
39594
|
if (target.kind === "streamable-http" && o.header.length)
|
|
38010
39595
|
target.headers = parseHeaders(o.header);
|
|
38011
|
-
const packs =
|
|
39596
|
+
const packs = existsSync6(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
|
|
38012
39597
|
let tools = [];
|
|
38013
39598
|
const r = await runTrustCheck(target, { packs, onTools: (t) => {
|
|
38014
39599
|
tools = t;
|
|
38015
39600
|
} });
|
|
38016
39601
|
const signed = signDocument(r, loadOrCreateKey(o.key));
|
|
38017
|
-
|
|
38018
|
-
|
|
39602
|
+
writeFileSync4(o.out, renderServerPassport(signed, tools));
|
|
39603
|
+
writeFileSync4(o.out.replace(/\.html?$/i, "") + ".json", JSON.stringify(signed, null, 2));
|
|
38019
39604
|
process.stdout.write(`Wrote the MCP Server Passport for ${sanitizeText(String(r.target.serverInfo?.["name"] ?? "server"), 80)} to ${sanitizeText(o.out)} (trust ${r.grade ?? "-"}, readiness ${r.readiness?.grade ?? "-"}), and its signed result beside it.
|
|
38020
39605
|
`);
|
|
38021
39606
|
});
|
|
38022
39607
|
program2.command("watch").description("Continuous monitoring: re-check every server on an allowlist and alert on changed tools, grade drops or unreachable servers").argument("<allowlist>", "saktum-allowlist.json (from saktum allowlist)").option("--out <file>", "write the results as JSON").option("--webhook <url>", "POST a summary to this URL when something changed (for example a chat or incident webhook)").action(async (file, o) => {
|
|
38023
|
-
const list = JSON.parse(
|
|
38024
|
-
const packs =
|
|
39608
|
+
const list = JSON.parse(readFileSync8(file, "utf8"));
|
|
39609
|
+
const packs = existsSync6(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
|
|
38025
39610
|
const r = await watchAllowlist(list.allowed ?? [], packs);
|
|
38026
39611
|
const mark2 = { unchanged: "\u2713", changed: "\u2717", degraded: "!", unreachable: "?" };
|
|
38027
39612
|
for (const f of r.findings)
|
|
@@ -38031,7 +39616,7 @@ ${r.errors.slice(0, 10).map((e) => ` ${e}`).join("\n")}
|
|
|
38031
39616
|
${r.findings.length} server(s) checked; ${r.alerts} need attention.
|
|
38032
39617
|
`);
|
|
38033
39618
|
if (o.out)
|
|
38034
|
-
|
|
39619
|
+
writeFileSync4(o.out, JSON.stringify(r, null, 2) + "\n");
|
|
38035
39620
|
if (o.webhook && r.alerts) {
|
|
38036
39621
|
const text2 = `Saktum watch: ${r.alerts} MCP server(s) need attention. ${r.findings.filter((f) => f.status !== "unchanged").map((f) => `${f.server}: ${f.details.join("; ")}`).join(" | ")}`.slice(0, 3e3);
|
|
38037
39622
|
try {
|
|
@@ -38056,43 +39641,77 @@ Assumptions: ${r.assumptions}.
|
|
|
38056
39641
|
`);
|
|
38057
39642
|
});
|
|
38058
39643
|
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) => {
|
|
38059
|
-
const fleet = JSON.parse(
|
|
39644
|
+
const fleet = JSON.parse(readFileSync8(o.fleet, "utf8"));
|
|
38060
39645
|
const rec = o.receipts.map((f) => {
|
|
38061
|
-
const e = parseReceiptLog(
|
|
39646
|
+
const e = parseReceiptLog(readFileSync8(f, "utf8"));
|
|
38062
39647
|
return { agent: e[0]?.receipt.envelope.caller.agent?.slice(0, 32) ?? f, summary: summariseReceipts(e), verified: verifyReceiptLog(e).ok };
|
|
38063
39648
|
});
|
|
38064
39649
|
const distinctTokens = (fleet.servers ?? []).reduce((a, x) => a + (x.tokens ?? 0), 0);
|
|
38065
39650
|
const roi = roiEstimate({ ...ROI_DEFAULTS, tokensPerTurn: distinctTokens, agents: Number(o.agents), turnsPerDay: Number(o.turnsPerDay), pricePerMTok: Number(o.pricePerMtok), vendorReviews: Number(o.vendorReviews) });
|
|
38066
|
-
|
|
39651
|
+
writeFileSync4(o.out, renderAssessment(o.org, fleet, rec, roi));
|
|
38067
39652
|
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.
|
|
38068
39653
|
`);
|
|
38069
39654
|
});
|
|
38070
39655
|
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) => {
|
|
38071
39656
|
const setups = files.map((f) => {
|
|
38072
|
-
const j = JSON.parse(
|
|
39657
|
+
const j = JSON.parse(readFileSync8(f, "utf8"));
|
|
38073
39658
|
return { machine: j.machine ?? f, servers: j.servers ?? [] };
|
|
38074
39659
|
});
|
|
38075
39660
|
const pol = o.policy ? await loadPolicy(o.policy) : void 0;
|
|
38076
39661
|
const fleet = buildFleet(setups, pol?.policy, pol?.allow);
|
|
38077
39662
|
process.stdout.write(renderFleet(fleet));
|
|
38078
39663
|
if (o.out)
|
|
38079
|
-
|
|
39664
|
+
writeFileSync4(o.out, JSON.stringify(fleet, null, 2) + "\n");
|
|
38080
39665
|
if (o.html)
|
|
38081
|
-
|
|
39666
|
+
writeFileSync4(o.html, fleetHtml(fleet));
|
|
38082
39667
|
exitCode = fleet.nonCompliant ? 1 : 0;
|
|
38083
39668
|
});
|
|
39669
|
+
program2.command("bindings").description("How Saktum reads a server's tools (action class, what each argument means), and the _meta block to declare them").argument("<target...>", "https://host/mcp or -- node server.js").option("--env <KEY=VALUE>", "environment variable for a local server (repeatable)", collect, []).action(async (parts, o) => {
|
|
39670
|
+
const target = parseTarget(parts);
|
|
39671
|
+
if (target.kind === "stdio" && o.env.length)
|
|
39672
|
+
target.env = parseEnv(o.env);
|
|
39673
|
+
const s2 = await connect(target);
|
|
39674
|
+
let tools = [];
|
|
39675
|
+
try {
|
|
39676
|
+
tools = await s2.listTools();
|
|
39677
|
+
} finally {
|
|
39678
|
+
await s2.close();
|
|
39679
|
+
}
|
|
39680
|
+
for (const t of tools) {
|
|
39681
|
+
const a = actionClass(t), b = bindingsFor(t);
|
|
39682
|
+
process.stdout.write(`${sanitizeText(t.name, 60).padEnd(28)} ${a.cls.padEnd(12)} ${b.basis === "declared" ? "declared" : "inferred"}: ${Object.entries(b.bindings).map(([k, f]) => `${k} \u2192 ${f}`).join(", ") || "(no domain arguments)"}
|
|
39683
|
+
`);
|
|
39684
|
+
}
|
|
39685
|
+
const undeclared = tools.filter((t) => !t._meta?.["io.saktum/bindings"]);
|
|
39686
|
+
if (undeclared.length) {
|
|
39687
|
+
process.stdout.write(`
|
|
39688
|
+
To declare them, add to each tool's definition (MCP tools accept _meta):
|
|
39689
|
+
`);
|
|
39690
|
+
for (const t of undeclared.slice(0, 5))
|
|
39691
|
+
process.stdout.write(` ${t.name}: _meta: ${JSON.stringify({ "io.saktum/action": actionClass(t).cls, "io.saktum/bindings": bindingsFor(t).bindings })}
|
|
39692
|
+
`);
|
|
39693
|
+
}
|
|
39694
|
+
});
|
|
39695
|
+
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, autonomy, or all (grocery, travel and finance)", "all").action(async (o) => {
|
|
39696
|
+
const { runDemo: runDemo2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
|
|
39697
|
+
await runDemo2(o.out, (l) => process.stdout.write(l + "\n"), o.story);
|
|
39698
|
+
});
|
|
39699
|
+
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) => {
|
|
39700
|
+
const { startDemoServer: startDemoServer2 } = await Promise.resolve().then(() => (init_demo(), demo_exports));
|
|
39701
|
+
await startDemoServer2(o.story);
|
|
39702
|
+
});
|
|
38084
39703
|
program2.command("mcp").description("Run Saktum Check as an MCP server (stdio), so coding agents can test, fix, diff and document MCP servers").option("--packs <dir>", "directory of packs (default: the built-in packs)").action(async (o) => {
|
|
38085
|
-
const packs = o.packs ? loadPackDir(o.packs) :
|
|
39704
|
+
const packs = o.packs ? loadPackDir(o.packs) : existsSync6(bundledPacks) ? loadPackDir(bundledPacks) : loadEmbeddedPacks();
|
|
38086
39705
|
const { startMcpServer: startMcpServer2 } = await Promise.resolve().then(() => (init_mcp_server(), mcp_server_exports));
|
|
38087
39706
|
await startMcpServer2(packs);
|
|
38088
39707
|
});
|
|
38089
39708
|
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) => {
|
|
38090
|
-
const doc = JSON.parse(
|
|
39709
|
+
const doc = JSON.parse(readFileSync8(file, "utf8"));
|
|
38091
39710
|
const v = verifyDocument(doc);
|
|
38092
39711
|
if (!v.valid)
|
|
38093
39712
|
throw new Error(`The result's signature is not valid (${v.reason}); attestations are built only from unaltered signed results.`);
|
|
38094
39713
|
const att = signDocument(buildAttestation(doc), loadOrCreateKey(o.key));
|
|
38095
|
-
|
|
39714
|
+
writeFileSync4(o.out, JSON.stringify(att, null, 2) + "\n");
|
|
38096
39715
|
const c = att.claims, colour = (g) => ({ A: "2e7d32", B: "558b2f", C: "f9a825", D: "ef6c00", F: "c62828" })[g ?? ""] ?? "757575";
|
|
38097
39716
|
process.stdout.write(`Wrote ${sanitizeText(o.out)} (trust ${c.trustGrade ?? "-"}, agent readiness ${c.readinessGrade ?? "-"}; evidence: ${Object.entries(c.evidence).filter(([, x]) => x).map(([k]) => k).join(", ") || "none"}).
|
|
38098
39717
|
Anyone can check it: npx saktum verify ${sanitizeText(o.out)}
|
|
@@ -38104,8 +39723,8 @@ README badge:
|
|
|
38104
39723
|
const key = loadOrCreateKey(o.key);
|
|
38105
39724
|
const cred = attestationToCredential(att, key.kid);
|
|
38106
39725
|
const base = o.out.replace(/\.json$/i, "");
|
|
38107
|
-
|
|
38108
|
-
|
|
39726
|
+
writeFileSync4(`${base}.vc.jwt`, signCredentialJwt(cred, key) + "\n");
|
|
39727
|
+
writeFileSync4(`${base}.vc.json`, JSON.stringify(cred, null, 2) + "\n");
|
|
38109
39728
|
process.stdout.write(`
|
|
38110
39729
|
W3C Verifiable Credential: ${sanitizeText(base)}.vc.jwt (check it: npx saktum vc verify ${sanitizeText(base)}.vc.jwt)
|
|
38111
39730
|
`);
|
|
@@ -38130,7 +39749,7 @@ ${url2}
|
|
|
38130
39749
|
exitCode = r.code;
|
|
38131
39750
|
});
|
|
38132
39751
|
program2.command("verify").description("Verify a signed Saktum Check result").argument("<file>").action((file) => {
|
|
38133
|
-
const doc = JSON.parse(
|
|
39752
|
+
const doc = JSON.parse(readFileSync8(file, "utf8"));
|
|
38134
39753
|
const validate2 = compileContract("result.schema.json");
|
|
38135
39754
|
if (!validate2(doc)) {
|
|
38136
39755
|
process.stdout.write(`Invalid result format: ${JSON.stringify(validate2.errors?.slice(0, 2))}
|