@atbash/sdk 0.22.0-dev.0 → 0.23.0-dev.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 +3 -0
- package/dist/browser.d.mts +100 -10
- package/dist/browser.mjs +334 -58
- package/dist/index.d.mts +100 -10
- package/dist/index.d.ts +100 -10
- package/dist/index.js +205 -59
- package/dist/index.mjs +203 -59
- package/dist/testing.d.mts +15 -0
- package/dist/testing.d.ts +15 -0
- package/dist/testing.js +33 -0
- package/dist/testing.mjs +8 -0
- package/index.d.ts +3 -0
- package/index.js +55 -54
- package/package.json +15 -7
package/dist/browser.mjs
CHANGED
|
@@ -33,6 +33,14 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
|
|
|
33
33
|
mod2
|
|
34
34
|
));
|
|
35
35
|
|
|
36
|
+
// <define:__ATBASH_DEV_JUDGE_PINS__>
|
|
37
|
+
var define_ATBASH_DEV_JUDGE_PINS_default;
|
|
38
|
+
var init_define_ATBASH_DEV_JUDGE_PINS = __esm({
|
|
39
|
+
"<define:__ATBASH_DEV_JUDGE_PINS__>"() {
|
|
40
|
+
define_ATBASH_DEV_JUDGE_PINS_default = ["03f1632c850eb126edf64923484a21713d3b3931a0755258a2cb6090d4a1859d3a"];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
36
44
|
// <define:__ATBASH_PRIVATE_NODE_URLS__>
|
|
37
45
|
var define_ATBASH_PRIVATE_NODE_URLS_default;
|
|
38
46
|
var init_define_ATBASH_PRIVATE_NODE_URLS = __esm({
|
|
@@ -41,11 +49,21 @@ var init_define_ATBASH_PRIVATE_NODE_URLS = __esm({
|
|
|
41
49
|
}
|
|
42
50
|
});
|
|
43
51
|
|
|
52
|
+
// <define:__ATBASH_PROD_JUDGE_PINS__>
|
|
53
|
+
var define_ATBASH_PROD_JUDGE_PINS_default;
|
|
54
|
+
var init_define_ATBASH_PROD_JUDGE_PINS = __esm({
|
|
55
|
+
"<define:__ATBASH_PROD_JUDGE_PINS__>"() {
|
|
56
|
+
define_ATBASH_PROD_JUDGE_PINS_default = [];
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
44
60
|
// (disabled):node_modules/buffer/index.js
|
|
45
61
|
var require_buffer = __commonJS({
|
|
46
62
|
"(disabled):node_modules/buffer/index.js"() {
|
|
47
63
|
"use strict";
|
|
64
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
48
65
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
66
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
49
67
|
}
|
|
50
68
|
});
|
|
51
69
|
|
|
@@ -53,7 +71,9 @@ var require_buffer = __commonJS({
|
|
|
53
71
|
var require_bn = __commonJS({
|
|
54
72
|
"node_modules/bn.js/lib/bn.js"(exports, module) {
|
|
55
73
|
"use strict";
|
|
74
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
56
75
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
76
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
57
77
|
(function(module2, exports2) {
|
|
58
78
|
"use strict";
|
|
59
79
|
function assert2(val, msg) {
|
|
@@ -2872,22 +2892,34 @@ var require_bn = __commonJS({
|
|
|
2872
2892
|
});
|
|
2873
2893
|
|
|
2874
2894
|
// src-ts/index.ts
|
|
2895
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
2875
2896
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2897
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
2876
2898
|
|
|
2877
2899
|
// src-ts/browser/native.ts
|
|
2900
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
2878
2901
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2902
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
2879
2903
|
|
|
2880
2904
|
// node_modules/@noble/curves/secp256k1.js
|
|
2905
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
2881
2906
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2907
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
2882
2908
|
|
|
2883
2909
|
// node_modules/@noble/hashes/sha2.js
|
|
2910
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
2884
2911
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2912
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
2885
2913
|
|
|
2886
2914
|
// node_modules/@noble/hashes/_md.js
|
|
2915
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
2887
2916
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2917
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
2888
2918
|
|
|
2889
2919
|
// node_modules/@noble/hashes/utils.js
|
|
2920
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
2890
2921
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2922
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
2891
2923
|
function isBytes(a) {
|
|
2892
2924
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
2893
2925
|
}
|
|
@@ -3309,10 +3341,14 @@ var sha256 = /* @__PURE__ */ createHasher(
|
|
|
3309
3341
|
);
|
|
3310
3342
|
|
|
3311
3343
|
// node_modules/@noble/curves/abstract/curve.js
|
|
3344
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
3312
3345
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
3346
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
3313
3347
|
|
|
3314
3348
|
// node_modules/@noble/curves/utils.js
|
|
3349
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
3315
3350
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
3351
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
3316
3352
|
var abytes2 = (value, length, title) => abytes(value, length, title);
|
|
3317
3353
|
var anumber2 = anumber;
|
|
3318
3354
|
var bytesToHex2 = bytesToHex;
|
|
@@ -3465,7 +3501,9 @@ function validateObject(object, fields = {}, optFields = {}) {
|
|
|
3465
3501
|
}
|
|
3466
3502
|
|
|
3467
3503
|
// node_modules/@noble/curves/abstract/modular.js
|
|
3504
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
3468
3505
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
3506
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
3469
3507
|
var _0n2 = /* @__PURE__ */ BigInt(0);
|
|
3470
3508
|
var _1n2 = /* @__PURE__ */ BigInt(1);
|
|
3471
3509
|
var _2n = /* @__PURE__ */ BigInt(2);
|
|
@@ -4114,10 +4152,14 @@ function createKeygen(randomSecretKey, getPublicKey) {
|
|
|
4114
4152
|
}
|
|
4115
4153
|
|
|
4116
4154
|
// node_modules/@noble/curves/abstract/weierstrass.js
|
|
4155
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
4117
4156
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
4157
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
4118
4158
|
|
|
4119
4159
|
// node_modules/@noble/hashes/hmac.js
|
|
4160
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
4120
4161
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
4162
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
4121
4163
|
var _HMAC = class {
|
|
4122
4164
|
oHash;
|
|
4123
4165
|
iHash;
|
|
@@ -5149,7 +5191,9 @@ var Pointk1 = /* @__PURE__ */ weierstrass(secp256k1_CURVE, {
|
|
|
5149
5191
|
var secp256k1 = /* @__PURE__ */ ecdsa(Pointk1, sha256);
|
|
5150
5192
|
|
|
5151
5193
|
// node_modules/postchain-client/built/esm/index.js
|
|
5194
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
5152
5195
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
5196
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
5153
5197
|
var import_bn = __toESM(require_bn(), 1);
|
|
5154
5198
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
5155
5199
|
function getDefaultExportFromCjs(x) {
|
|
@@ -43375,6 +43419,17 @@ function verifySignature(body, signatureHex, pubkeyHex) {
|
|
|
43375
43419
|
const sigBytes = hexToBytes2(sigClean);
|
|
43376
43420
|
return secp256k1.verify(sigBytes, digest9, pkBytes, { prehash: false });
|
|
43377
43421
|
}
|
|
43422
|
+
function pinnedJudgeVerifyKeys(host) {
|
|
43423
|
+
const h = host.trim().toLowerCase();
|
|
43424
|
+
if (h === "atbash.ai" || h === "www.atbash.ai") return [...define_ATBASH_PROD_JUDGE_PINS_default];
|
|
43425
|
+
let devHost = "";
|
|
43426
|
+
try {
|
|
43427
|
+
devHost = "https://chromia-verified-ai-dev-two.vercel.app" ? new URL("https://chromia-verified-ai-dev-two.vercel.app").hostname.toLowerCase() : "";
|
|
43428
|
+
} catch {
|
|
43429
|
+
devHost = "";
|
|
43430
|
+
}
|
|
43431
|
+
return devHost !== "" && h === devHost ? [...define_ATBASH_DEV_JUDGE_PINS_default] : [];
|
|
43432
|
+
}
|
|
43378
43433
|
var STUB_MSG = "not available in @atbash/sdk browser bundle \u2014 call from Node or handle server-side";
|
|
43379
43434
|
function redactSecrets(input) {
|
|
43380
43435
|
return { redacted: input, found: [] };
|
|
@@ -43416,6 +43471,7 @@ var native = {
|
|
|
43416
43471
|
signLogToolCall,
|
|
43417
43472
|
signJudgeAction,
|
|
43418
43473
|
verifySignature,
|
|
43474
|
+
pinnedJudgeVerifyKeys,
|
|
43419
43475
|
normalizeForMatching,
|
|
43420
43476
|
containsEvasionCharacters,
|
|
43421
43477
|
redactSecrets,
|
|
@@ -43496,10 +43552,14 @@ var native = {
|
|
|
43496
43552
|
};
|
|
43497
43553
|
|
|
43498
43554
|
// src-ts/client.ts
|
|
43555
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43499
43556
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43557
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43500
43558
|
|
|
43501
43559
|
// src-ts/random.ts
|
|
43560
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43502
43561
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43562
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43503
43563
|
function randomBytes4(size) {
|
|
43504
43564
|
const buf = new Uint8Array(size);
|
|
43505
43565
|
globalThis.crypto.getRandomValues(buf);
|
|
@@ -43515,7 +43575,9 @@ function randomHex(size) {
|
|
|
43515
43575
|
}
|
|
43516
43576
|
|
|
43517
43577
|
// src-ts/auth-bearer.ts
|
|
43578
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43518
43579
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43580
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43519
43581
|
var BEARER_TTL_MS = 4 * 60 * 1e3;
|
|
43520
43582
|
var bearers = /* @__PURE__ */ new Map();
|
|
43521
43583
|
function agentAuthBearer(auth, blockchainRid) {
|
|
@@ -43540,7 +43602,9 @@ function agentAuthHeaders(auth, blockchainRid) {
|
|
|
43540
43602
|
}
|
|
43541
43603
|
|
|
43542
43604
|
// src-ts/chain-config.ts
|
|
43605
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43543
43606
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43607
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43544
43608
|
var DEFAULT_PRIVATE_NODE_URLS = Object.freeze(
|
|
43545
43609
|
native.defaultPrivateNodeUrls()
|
|
43546
43610
|
);
|
|
@@ -43560,17 +43624,25 @@ function chainForNetwork(network) {
|
|
|
43560
43624
|
}
|
|
43561
43625
|
|
|
43562
43626
|
// src-ts/constants.ts
|
|
43627
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43563
43628
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43629
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43564
43630
|
var DEFAULT_ENDPOINT = native.DEFAULT_ENDPOINT;
|
|
43565
43631
|
|
|
43566
43632
|
// src-ts/browser/encrypted-toolcall.ts
|
|
43633
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43567
43634
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43635
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43568
43636
|
|
|
43569
43637
|
// src-ts/browser/crypto-ecies.ts
|
|
43638
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43570
43639
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43640
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43571
43641
|
|
|
43572
43642
|
// node_modules/@noble/hashes/hkdf.js
|
|
43643
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43573
43644
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43645
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43574
43646
|
function extract(hash3, ikm, salt) {
|
|
43575
43647
|
ahash(hash3);
|
|
43576
43648
|
if (salt === void 0)
|
|
@@ -43611,13 +43683,19 @@ function expand2(hash3, prk, info2, length = 32) {
|
|
|
43611
43683
|
var hkdf = (hash3, ikm, salt, info2, length) => expand2(hash3, extract(hash3, ikm, salt), info2, length);
|
|
43612
43684
|
|
|
43613
43685
|
// node_modules/@noble/ciphers/aes.js
|
|
43686
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43614
43687
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43688
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43615
43689
|
|
|
43616
43690
|
// node_modules/@noble/ciphers/_polyval.js
|
|
43691
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43617
43692
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43693
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43618
43694
|
|
|
43619
43695
|
// node_modules/@noble/ciphers/utils.js
|
|
43696
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
43620
43697
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43698
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
43621
43699
|
function isBytes3(a) {
|
|
43622
43700
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
43623
43701
|
}
|
|
@@ -44210,7 +44288,9 @@ function encryptedLength(plaintextByteLength) {
|
|
|
44210
44288
|
}
|
|
44211
44289
|
|
|
44212
44290
|
// src-ts/crypto/envelope.ts
|
|
44291
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44213
44292
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44293
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44214
44294
|
var PREFIX = "atb1";
|
|
44215
44295
|
var SEPARATOR = ".";
|
|
44216
44296
|
function toBase64(bytes) {
|
|
@@ -44343,7 +44423,9 @@ function signEncryptedToolCall(toolCallId, action, context, toolName, toolArgsJs
|
|
|
44343
44423
|
}
|
|
44344
44424
|
|
|
44345
44425
|
// src-ts/endpoint.ts
|
|
44426
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44346
44427
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44428
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44347
44429
|
function buildAllowedJudgeHosts() {
|
|
44348
44430
|
return /* @__PURE__ */ new Set([
|
|
44349
44431
|
"atbash.ai",
|
|
@@ -44359,6 +44441,23 @@ function isAllowlistedJudgeHost(endpoint) {
|
|
|
44359
44441
|
return false;
|
|
44360
44442
|
}
|
|
44361
44443
|
}
|
|
44444
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]", "::1"]);
|
|
44445
|
+
var loopbackJudgePins = [];
|
|
44446
|
+
function setLoopbackJudgePinsForTests(keys2) {
|
|
44447
|
+
loopbackJudgePins = keys2.map((k) => k.trim().toLowerCase());
|
|
44448
|
+
}
|
|
44449
|
+
function judgeVerifyKeys(endpoint, configuredKey) {
|
|
44450
|
+
const host = new URL(endpoint).hostname.toLowerCase();
|
|
44451
|
+
const pins = LOOPBACK_HOSTS.has(host) ? loopbackJudgePins : native.pinnedJudgeVerifyKeys(host);
|
|
44452
|
+
const key3 = configuredKey?.trim().toLowerCase();
|
|
44453
|
+
if (pins.length === 0) return key3 ? [key3] : [];
|
|
44454
|
+
if (key3 && !pins.includes(key3)) {
|
|
44455
|
+
throw new Error(
|
|
44456
|
+
`[atbash] verifyPubKey ${key3} is not the response-signing key pinned for ${host}. Refusing to load \u2014 an Atbash host's replies are checked against the key built into the SDK; remove verifyPubKey, or set it to the pinned key.`
|
|
44457
|
+
);
|
|
44458
|
+
}
|
|
44459
|
+
return pins;
|
|
44460
|
+
}
|
|
44362
44461
|
function validateJudgeEndpoint(judge) {
|
|
44363
44462
|
const policy = judge?.policy === "self-hosted" ? "self-hosted" : "default";
|
|
44364
44463
|
const candidate = judge?.endpoint?.trim() || DEFAULT_ENDPOINT;
|
|
@@ -44401,7 +44500,9 @@ function validateJudgeEndpoint(judge) {
|
|
|
44401
44500
|
}
|
|
44402
44501
|
|
|
44403
44502
|
// src-ts/errors.ts
|
|
44503
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44404
44504
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44505
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44405
44506
|
var AtbashAPIError = class extends Error {
|
|
44406
44507
|
/** HTTP status code (or 0 if the request never completed). */
|
|
44407
44508
|
status;
|
|
@@ -44465,7 +44566,9 @@ function enrich(status, body, statusText, endpoint, path3) {
|
|
|
44465
44566
|
}
|
|
44466
44567
|
|
|
44467
44568
|
// src-ts/jail-hold.ts
|
|
44569
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44468
44570
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44571
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44469
44572
|
var DEFAULTS = { ceilingMs: 3e4, pollMs: 1e3 };
|
|
44470
44573
|
var holds = /* @__PURE__ */ new Map();
|
|
44471
44574
|
var blockedAt = /* @__PURE__ */ new Map();
|
|
@@ -44475,7 +44578,7 @@ function isJailHeld(pubkey) {
|
|
|
44475
44578
|
return holds.has(pubkey);
|
|
44476
44579
|
}
|
|
44477
44580
|
function recordBlock(pubkey) {
|
|
44478
|
-
const now =
|
|
44581
|
+
const now = performance.now();
|
|
44479
44582
|
for (const [key3, at] of blockedAt) if (now - at > BLOCK_MEMORY_MS) blockedAt.delete(key3);
|
|
44480
44583
|
blockedAt.set(pubkey, now);
|
|
44481
44584
|
}
|
|
@@ -44521,7 +44624,9 @@ function configureJailHold(next) {
|
|
|
44521
44624
|
}
|
|
44522
44625
|
|
|
44523
44626
|
// src-ts/http/client.ts
|
|
44627
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44524
44628
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44629
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44525
44630
|
var HttpClient = class {
|
|
44526
44631
|
baseUrl;
|
|
44527
44632
|
timeoutMs;
|
|
@@ -44626,7 +44731,9 @@ function classifyTransportError(err, url, method, timeoutMs) {
|
|
|
44626
44731
|
}
|
|
44627
44732
|
|
|
44628
44733
|
// src-ts/browser/keyLoader.ts
|
|
44734
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44629
44735
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44736
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44630
44737
|
var NOT_AVAILABLE = "keyLoader is not available in the browser bundle \u2014 pass `agentKey` explicitly to Atbash.fromConfig or use `new Atbash(privkey, opts)`.";
|
|
44631
44738
|
function resolveKeyPath(_input) {
|
|
44632
44739
|
throw new Error(NOT_AVAILABLE);
|
|
@@ -44636,10 +44743,14 @@ function loadAgentFromFile(_keyPath) {
|
|
|
44636
44743
|
}
|
|
44637
44744
|
|
|
44638
44745
|
// src-ts/decision.ts
|
|
44746
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44639
44747
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44748
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44640
44749
|
|
|
44641
44750
|
// src-ts/normalize.ts
|
|
44751
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44642
44752
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44753
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44643
44754
|
function wireText(raw2, fallback = "") {
|
|
44644
44755
|
if (raw2 === null || raw2 === void 0) return fallback;
|
|
44645
44756
|
if (typeof raw2 === "object" || typeof raw2 === "function") return fallback;
|
|
@@ -44750,7 +44861,9 @@ function canonicalAllow(data) {
|
|
|
44750
44861
|
}
|
|
44751
44862
|
|
|
44752
44863
|
// src-ts/opentel/events.ts
|
|
44864
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44753
44865
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44866
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44754
44867
|
var SLOW_MS = 1500;
|
|
44755
44868
|
var SUCCESS_SAMPLE_RATE = 10;
|
|
44756
44869
|
var logger2 = null;
|
|
@@ -44805,7 +44918,9 @@ function recordEvent(e) {
|
|
|
44805
44918
|
}
|
|
44806
44919
|
|
|
44807
44920
|
// src-ts/browser/opentel/telemetry.ts
|
|
44921
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44808
44922
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44923
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44809
44924
|
function setupTelemetry(_config) {
|
|
44810
44925
|
}
|
|
44811
44926
|
function recordCall(_functionName, _source, _agentPubkey) {
|
|
@@ -44818,7 +44933,9 @@ async function shutdownTelemetry() {
|
|
|
44818
44933
|
}
|
|
44819
44934
|
|
|
44820
44935
|
// src-ts/browser/userConfig.ts
|
|
44936
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
44821
44937
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44938
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
44822
44939
|
var NOT_AVAILABLE2 = "userConfig file I/O is not available in the browser bundle.";
|
|
44823
44940
|
function getConfigDir() {
|
|
44824
44941
|
throw new Error(NOT_AVAILABLE2);
|
|
@@ -44847,7 +44964,10 @@ function strandedAgentKey() {
|
|
|
44847
44964
|
|
|
44848
44965
|
// src-ts/client.ts
|
|
44849
44966
|
var AGENT_NOT_REGISTERED = "Agent not registered. Onboard the agent at the dashboard before submitting actions.";
|
|
44967
|
+
var TOOL_CALL_IDS_FOR_TESTS = /* @__PURE__ */ Symbol.for("@atbash/sdk.toolCallIdsForTests");
|
|
44850
44968
|
function generateToolCallId() {
|
|
44969
|
+
const fixed = globalThis[TOOL_CALL_IDS_FOR_TESTS];
|
|
44970
|
+
if (fixed && fixed.ids.length > 0) return fixed.ids[fixed.next++ % fixed.ids.length];
|
|
44851
44971
|
return `tc-${Date.now()}-${randomHex(4)}`;
|
|
44852
44972
|
}
|
|
44853
44973
|
function resolveConstructorChain(options) {
|
|
@@ -44884,12 +45004,21 @@ var Atbash = class _Atbash {
|
|
|
44884
45004
|
orgName;
|
|
44885
45005
|
/** Default judge response-signing pubkey, if configured (see fromConfig). */
|
|
44886
45006
|
verifyPubKey;
|
|
45007
|
+
/**
|
|
45008
|
+
* The keys every judge reply must be signed by: the host's pinned keys, or
|
|
45009
|
+
* the configured `verifyPubKey` on a host with none. Empty means unchecked.
|
|
45010
|
+
*/
|
|
45011
|
+
verifyKeys;
|
|
44887
45012
|
/** Default org encryption key — see {@link AtbashOptions.orgEncryptionPubKey}. */
|
|
44888
45013
|
orgEncryptionPubKey;
|
|
44889
45014
|
/** When true (default), `auditToolCall` denies on any error. */
|
|
44890
45015
|
failClosed;
|
|
44891
45016
|
/** When true (default), an unenforced (audit-tier) answer is refused. */
|
|
44892
45017
|
requireEnforcement;
|
|
45018
|
+
/** When true, a signed non-enforcing mode never relaxes a verdict. */
|
|
45019
|
+
enforceLocally;
|
|
45020
|
+
/** Results whose enforcement mode came signed and bound to their call. */
|
|
45021
|
+
modeTrusted = /* @__PURE__ */ new WeakSet();
|
|
44893
45022
|
/** Overall deadline for one auditToolCall decision, in ms. */
|
|
44894
45023
|
decisionTimeoutMs;
|
|
44895
45024
|
/** Org key learned from the last agent-exists check, for this agent only. */
|
|
@@ -44953,9 +45082,11 @@ var Atbash = class _Atbash {
|
|
|
44953
45082
|
this._forcedNetwork = forcedChainNetwork();
|
|
44954
45083
|
this.orgName = options.orgName;
|
|
44955
45084
|
this.verifyPubKey = validated.verifyPubKey ?? void 0;
|
|
45085
|
+
this.verifyKeys = judgeVerifyKeys(this.endpoint, this.verifyPubKey);
|
|
44956
45086
|
this.orgEncryptionPubKey = options.orgEncryptionPubKey;
|
|
44957
45087
|
this.failClosed = options.failClosed !== false;
|
|
44958
45088
|
this.requireEnforcement = options.requireEnforcement !== false;
|
|
45089
|
+
this.enforceLocally = options.enforceLocally === true;
|
|
44959
45090
|
this.decisionTimeoutMs = options.decisionTimeoutMs ?? DEFAULT_DECISION_TIMEOUT_MS;
|
|
44960
45091
|
this.debug = options.debug === true;
|
|
44961
45092
|
this.logger = options.logger ?? {};
|
|
@@ -44964,7 +45095,7 @@ var Atbash = class _Atbash {
|
|
|
44964
45095
|
if (this.endpoint !== DEFAULT_ENDPOINT) {
|
|
44965
45096
|
this.logger.warn?.("[atbash] running on non-default judge endpoint", {
|
|
44966
45097
|
endpoint: this.endpoint,
|
|
44967
|
-
verifying: this.
|
|
45098
|
+
verifying: this.verifyKeys.length > 0 ? "with response-signature pubkey configured" : "without signature verification"
|
|
44968
45099
|
});
|
|
44969
45100
|
}
|
|
44970
45101
|
if (isAllowlistedJudgeHost(this.endpoint)) {
|
|
@@ -45002,12 +45133,12 @@ var Atbash = class _Atbash {
|
|
|
45002
45133
|
_Atbash.environmentLogged = true;
|
|
45003
45134
|
const brief = (rid) => rid ? `${rid.slice(0, 8)}\u2026` : "(unset)";
|
|
45004
45135
|
this.logger.info?.(
|
|
45005
|
-
`[atbash] environment \u2014 judge=${this.endpoint} privateChain=${brief(native.DEFAULT_PRIVATE_BLOCKCHAIN_RID)} activeChain=${brief(this.blockchainRid)} responseSignatureCheck=${this.
|
|
45136
|
+
`[atbash] environment \u2014 judge=${this.endpoint} privateChain=${brief(native.DEFAULT_PRIVATE_BLOCKCHAIN_RID)} activeChain=${brief(this.blockchainRid)} responseSignatureCheck=${this.verifyKeys.length > 0 ? "on" : "off"}`,
|
|
45006
45137
|
{
|
|
45007
45138
|
judgeEndpoint: this.endpoint,
|
|
45008
45139
|
privateBlockchainRid: native.DEFAULT_PRIVATE_BLOCKCHAIN_RID,
|
|
45009
45140
|
activeBlockchainRid: this.blockchainRid,
|
|
45010
|
-
responseSignatureCheck:
|
|
45141
|
+
responseSignatureCheck: this.verifyKeys.length > 0
|
|
45011
45142
|
}
|
|
45012
45143
|
);
|
|
45013
45144
|
}
|
|
@@ -45125,6 +45256,7 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45125
45256
|
verifyPubKey: validated.verifyPubKey ?? void 0,
|
|
45126
45257
|
failClosed: options.failClosed,
|
|
45127
45258
|
requireEnforcement: options.requireEnforcement,
|
|
45259
|
+
enforceLocally: options.enforceLocally,
|
|
45128
45260
|
decisionTimeoutMs: options.decisionTimeoutMs,
|
|
45129
45261
|
// ATBASH_DEBUG lets an operator turn diagnostics on without editing a
|
|
45130
45262
|
// host's plugin config, which is usually the harder half.
|
|
@@ -45259,22 +45391,34 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45259
45391
|
* response bytes via the Rust core's `verifySignature`.
|
|
45260
45392
|
*/
|
|
45261
45393
|
async judgeAction(action, context = "", options = {}) {
|
|
45394
|
+
return this.judgeTracked(action, context, options, false);
|
|
45395
|
+
}
|
|
45396
|
+
/**
|
|
45397
|
+
* judgeAction, optionally asking the judge for the true verdict and the
|
|
45398
|
+
* organisation's enforcement mode so this client applies the mode itself.
|
|
45399
|
+
*
|
|
45400
|
+
* Only auditToolCall opts in: judgeAction's callers keep the server-side
|
|
45401
|
+
* downgrade they gate on today.
|
|
45402
|
+
*
|
|
45403
|
+
* @param clientEnforces - Send `X-Atbash-Client-Enforcement` when the reply can be trusted.
|
|
45404
|
+
*/
|
|
45405
|
+
judgeTracked(action, context, options, clientEnforces) {
|
|
45262
45406
|
return this.track("judgeAction", this.auth.pubkey, async () => {
|
|
45263
45407
|
try {
|
|
45264
|
-
return await this._judgeAction(action, context, options);
|
|
45408
|
+
return await this._judgeAction(action, context, options, clientEnforces);
|
|
45265
45409
|
} catch (err) {
|
|
45266
45410
|
if (!isEncryptionStateMismatch(err)) throw err;
|
|
45267
45411
|
this._orgKeyFromChain = null;
|
|
45268
|
-
return await this._judgeAction(action, context, options);
|
|
45412
|
+
return await this._judgeAction(action, context, options, clientEnforces);
|
|
45269
45413
|
}
|
|
45270
45414
|
});
|
|
45271
45415
|
}
|
|
45272
|
-
async _judgeAction(action, context, options) {
|
|
45416
|
+
async _judgeAction(action, context, options, clientEnforces = false) {
|
|
45273
45417
|
if (!action?.trim()) {
|
|
45274
45418
|
throw new Error("action is required and cannot be empty.");
|
|
45275
45419
|
}
|
|
45276
45420
|
if (isJailHeld(this.auth.pubkey)) return this.localJailBlock();
|
|
45277
|
-
const startedAt =
|
|
45421
|
+
const startedAt = performance.now();
|
|
45278
45422
|
let chainOpts = options.chainOpts;
|
|
45279
45423
|
if (options.orgName && this._explicitChain) {
|
|
45280
45424
|
chainOpts = options.chainOpts ?? {
|
|
@@ -45331,17 +45475,23 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45331
45475
|
if (options.toolArgsJson) body.tool_args_json = options.toolArgsJson;
|
|
45332
45476
|
if (options.resolved) body.resolved = options.resolved;
|
|
45333
45477
|
if (options.mode) body.mode = options.mode;
|
|
45478
|
+
const verifyKeys = this.effectiveVerifyKeys(options.verifyPubKey);
|
|
45479
|
+
const optIn = clientEnforces && (verifyKeys.length > 0 || this.enforceLocally);
|
|
45480
|
+
const optInValue = this.enforceLocally ? "strict" : "1";
|
|
45334
45481
|
let resp;
|
|
45335
45482
|
try {
|
|
45336
|
-
resp = await this.http.post(
|
|
45483
|
+
resp = await this.http.post(
|
|
45484
|
+
"/api/v1/judge",
|
|
45485
|
+
body,
|
|
45486
|
+
optIn ? { "X-Atbash-Client-Enforcement": optInValue } : void 0
|
|
45487
|
+
);
|
|
45337
45488
|
} catch (err) {
|
|
45338
45489
|
throw this.transportError(err);
|
|
45339
45490
|
}
|
|
45340
45491
|
if (!resp.ok) throw await this.httpError(resp);
|
|
45341
45492
|
const bodyBytes = Buffer.from(await resp.arrayBuffer());
|
|
45342
|
-
|
|
45343
|
-
|
|
45344
|
-
verifyResponseSignature(bodyBytes, resp, verifyPubKey);
|
|
45493
|
+
if (verifyKeys.length > 0) {
|
|
45494
|
+
verifyResponseSignature(bodyBytes, resp, verifyKeys);
|
|
45345
45495
|
}
|
|
45346
45496
|
const parsed = tryParseJson(bodyBytes.toString("utf-8"));
|
|
45347
45497
|
if (!isRecord2(parsed)) {
|
|
@@ -45361,6 +45511,7 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45361
45511
|
provider: wireText(data.provider),
|
|
45362
45512
|
latencyMs: wireNumber(data.latency_ms),
|
|
45363
45513
|
toolCallId: wireText(data.tool_call_id, logResult.toolCallId),
|
|
45514
|
+
...wireText(data.judgment_id) ? { judgmentId: wireText(data.judgment_id) } : {},
|
|
45364
45515
|
onChain: Boolean(data.on_chain),
|
|
45365
45516
|
enforced: Boolean(data.enforced),
|
|
45366
45517
|
enforcementMode: wireText(data.enforcement_mode),
|
|
@@ -45368,23 +45519,46 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45368
45519
|
score,
|
|
45369
45520
|
refusal: explicitRefusal(data)
|
|
45370
45521
|
};
|
|
45371
|
-
|
|
45522
|
+
if (optIn) {
|
|
45523
|
+
const echo = data.client_enforcement;
|
|
45524
|
+
if (echo !== void 0 && echo !== optInValue || echo === void 0 && this.enforceLocally) {
|
|
45525
|
+
throw new SignatureVerificationError(
|
|
45526
|
+
"the reply does not confirm the enforcement this client asked for"
|
|
45527
|
+
);
|
|
45528
|
+
}
|
|
45529
|
+
if (verifyKeys.length > 0) {
|
|
45530
|
+
const statedId = wireText(data.tool_call_id);
|
|
45531
|
+
const statedJudgment = wireText(data.judgment_id);
|
|
45532
|
+
if (statedId && statedId !== logResult.toolCallId && statedId !== judgmentId || statedJudgment && statedJudgment !== judgmentId) {
|
|
45533
|
+
throw new SignatureVerificationError(
|
|
45534
|
+
`the signed reply is for call ${statedJudgment || statedId}, not this one`
|
|
45535
|
+
);
|
|
45536
|
+
}
|
|
45537
|
+
if (statedId && echo === optInValue) this.modeTrusted.add(result);
|
|
45538
|
+
}
|
|
45539
|
+
}
|
|
45540
|
+
return this.applyJailHold(result, startedAt, wireText(data.on_chain_status));
|
|
45372
45541
|
}
|
|
45373
45542
|
/**
|
|
45374
|
-
* Start a local hold on an enforced
|
|
45375
|
-
*
|
|
45376
|
-
*
|
|
45377
|
-
*
|
|
45543
|
+
* Start a local hold on an enforced BLOCK that jails: one already on chain,
|
|
45544
|
+
* or one the judge answered before its chain write landed
|
|
45545
|
+
* (`on_chain_status: "pending"`), which jails once it lands. Refuse any other
|
|
45546
|
+
* result that lands while the agent is held, or whose request was already in
|
|
45547
|
+
* flight when the block arrived: the server judged it on pre-jail state.
|
|
45548
|
+
*
|
|
45549
|
+
* @param onChainStatus - The reply's `on_chain_status`; empty when absent.
|
|
45378
45550
|
*/
|
|
45379
|
-
applyJailHold(result, startedAt) {
|
|
45551
|
+
applyJailHold(result, startedAt, onChainStatus = "") {
|
|
45380
45552
|
const pubkey = this.auth.pubkey;
|
|
45381
|
-
if (result.verdict === "BLOCK" && result.enforced
|
|
45553
|
+
if (result.verdict === "BLOCK" && result.enforced) {
|
|
45382
45554
|
recordBlock(pubkey);
|
|
45383
|
-
|
|
45384
|
-
|
|
45385
|
-
|
|
45386
|
-
|
|
45387
|
-
|
|
45555
|
+
if (result.onChain || onChainStatus === "pending") {
|
|
45556
|
+
holdJail(
|
|
45557
|
+
pubkey,
|
|
45558
|
+
() => this.getAgentPolicy(pubkey).then((p) => p.isJailed),
|
|
45559
|
+
() => this.logger.warn?.("[atbash] local jail hold released: the chain did not confirm the jail in time")
|
|
45560
|
+
);
|
|
45561
|
+
}
|
|
45388
45562
|
return result;
|
|
45389
45563
|
}
|
|
45390
45564
|
return isJailHeld(pubkey) || blockedSince(pubkey, startedAt) ? this.localJailBlock(result.toolCallId) : result;
|
|
@@ -45439,13 +45613,18 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45439
45613
|
try {
|
|
45440
45614
|
this.logger.info?.("[atbash] judge API called", { tool: toolName });
|
|
45441
45615
|
const result = await withDeadline(
|
|
45442
|
-
this.
|
|
45443
|
-
|
|
45444
|
-
|
|
45445
|
-
|
|
45446
|
-
|
|
45447
|
-
|
|
45448
|
-
|
|
45616
|
+
this.judgeTracked(
|
|
45617
|
+
actionText,
|
|
45618
|
+
contextText,
|
|
45619
|
+
{
|
|
45620
|
+
toolName,
|
|
45621
|
+
toolArgsJson: argsJson,
|
|
45622
|
+
orgName: this.orgName,
|
|
45623
|
+
// Passed through unredacted — caller vouches for the contents.
|
|
45624
|
+
resolved: input.resolved
|
|
45625
|
+
},
|
|
45626
|
+
true
|
|
45627
|
+
),
|
|
45449
45628
|
this.decisionTimeoutMs
|
|
45450
45629
|
);
|
|
45451
45630
|
return this.decide(result);
|
|
@@ -45455,7 +45634,7 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45455
45634
|
return {
|
|
45456
45635
|
allow: false,
|
|
45457
45636
|
verdict: "ERROR",
|
|
45458
|
-
reason: `The judge's reply
|
|
45637
|
+
reason: `The judge's reply was not trusted (${errorMessage(err)}).`
|
|
45459
45638
|
};
|
|
45460
45639
|
}
|
|
45461
45640
|
if (err instanceof JudgeRefusalError || err instanceof AtbashAPIError && isRefusalStatus(err.status)) {
|
|
@@ -45465,20 +45644,20 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45465
45644
|
}
|
|
45466
45645
|
}
|
|
45467
45646
|
/**
|
|
45468
|
-
* The verify
|
|
45469
|
-
* may only narrow what the client accepts: on a client pinned to
|
|
45470
|
-
*
|
|
45471
|
-
*
|
|
45647
|
+
* The verify keys for one call (R4, governor tier-2 review). A per-call key
|
|
45648
|
+
* may only narrow what the client accepts: on a client pinned to judge keys
|
|
45649
|
+
* it must be one of them, never a replacement; on an unpinned client it
|
|
45650
|
+
* adds the check.
|
|
45472
45651
|
*/
|
|
45473
|
-
|
|
45474
|
-
if (perCall === void 0) return this.
|
|
45652
|
+
effectiveVerifyKeys(perCall) {
|
|
45653
|
+
if (perCall === void 0) return this.verifyKeys;
|
|
45475
45654
|
const key3 = perCall.trim().toLowerCase();
|
|
45476
|
-
if (this.
|
|
45655
|
+
if (this.verifyKeys.length > 0 && !this.verifyKeys.includes(key3)) {
|
|
45477
45656
|
throw new SignatureVerificationError(
|
|
45478
45657
|
"a per-call verifyPubKey cannot replace the judge key this client is pinned to"
|
|
45479
45658
|
);
|
|
45480
45659
|
}
|
|
45481
|
-
return key3;
|
|
45660
|
+
return [key3];
|
|
45482
45661
|
}
|
|
45483
45662
|
/**
|
|
45484
45663
|
* Collapse a judge result into a {@link Decision}. The most restrictive
|
|
@@ -45490,7 +45669,8 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45490
45669
|
* never overrides a refusal.
|
|
45491
45670
|
*/
|
|
45492
45671
|
decide(result) {
|
|
45493
|
-
const
|
|
45672
|
+
const decided = this.applyMode(result);
|
|
45673
|
+
const inner = result.judgmentId ? { ...decided, judgmentId: result.judgmentId } : decided;
|
|
45494
45674
|
if (!result.enforcementMode) return inner;
|
|
45495
45675
|
return {
|
|
45496
45676
|
...inner,
|
|
@@ -45498,6 +45678,50 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45498
45678
|
enforcementMode: result.enforcementMode
|
|
45499
45679
|
};
|
|
45500
45680
|
}
|
|
45681
|
+
/**
|
|
45682
|
+
* Apply the organisation's enforcement mode to the judge's true verdict.
|
|
45683
|
+
*
|
|
45684
|
+
* Only a mode that arrived signed and bound to this call counts; a missing,
|
|
45685
|
+
* unsigned or unknown mode, or enforceLocally, means enforce. Under
|
|
45686
|
+
* `shadow`, `monitor` or `off` a BLOCK or HOLD runs, reported in
|
|
45687
|
+
* `wouldVerdict`. An ERROR stays an error: it is not a verdict.
|
|
45688
|
+
*/
|
|
45689
|
+
applyMode(result) {
|
|
45690
|
+
const mode = result.enforcementMode;
|
|
45691
|
+
const relaxes = this.modeTrusted.has(result) && (mode === "shadow" || mode === "monitor" || mode === "off");
|
|
45692
|
+
if (result.status === "shadow_recorded" && result.verdict === "No verdict") {
|
|
45693
|
+
if (!relaxes || this.enforceLocally) {
|
|
45694
|
+
return {
|
|
45695
|
+
allow: false,
|
|
45696
|
+
verdict: "ERROR",
|
|
45697
|
+
reason: "Atbash recorded this action without judging it (the organisation is not enforcing), and this client requires a verdict.",
|
|
45698
|
+
toolCallId: result.toolCallId
|
|
45699
|
+
};
|
|
45700
|
+
}
|
|
45701
|
+
this.logger.info?.(`[atbash] recorded in ${mode} mode; not judged yet`, {
|
|
45702
|
+
toolCallId: result.toolCallId
|
|
45703
|
+
});
|
|
45704
|
+
return {
|
|
45705
|
+
allow: true,
|
|
45706
|
+
verdict: "ALLOW",
|
|
45707
|
+
reason: `Recorded in ${mode} mode; the verdict appears in the dashboard.`,
|
|
45708
|
+
toolCallId: result.toolCallId
|
|
45709
|
+
};
|
|
45710
|
+
}
|
|
45711
|
+
const inner = this.decideInner(result);
|
|
45712
|
+
if (!relaxes || this.enforceLocally || inner.allow) return inner;
|
|
45713
|
+
if (inner.verdict !== "BLOCK" && inner.verdict !== "HOLD") return inner;
|
|
45714
|
+
this.logger.warn?.(`[atbash] would ${inner.verdict.toLowerCase()} (${mode} mode): ${inner.reason ?? ""}`, {
|
|
45715
|
+
toolCallId: inner.toolCallId
|
|
45716
|
+
});
|
|
45717
|
+
return {
|
|
45718
|
+
allow: true,
|
|
45719
|
+
verdict: "ALLOW",
|
|
45720
|
+
reason: inner.reason,
|
|
45721
|
+
toolCallId: inner.toolCallId,
|
|
45722
|
+
wouldVerdict: inner.verdict
|
|
45723
|
+
};
|
|
45724
|
+
}
|
|
45501
45725
|
decideInner(result) {
|
|
45502
45726
|
const toolCallId = result.toolCallId;
|
|
45503
45727
|
const deny = (verdict, reason) => ({
|
|
@@ -45533,7 +45757,9 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45533
45757
|
return {
|
|
45534
45758
|
allow: false,
|
|
45535
45759
|
verdict: "ERROR",
|
|
45536
|
-
|
|
45760
|
+
// The judge's own reason says why it did not check (the plan, a
|
|
45761
|
+
// deactivated agent); a fixed "audit-tier plan" hid which.
|
|
45762
|
+
reason: result.reason ? `Atbash did not check this action, and this client requires a checked decision. The judge said: ${result.reason}` : "Atbash logged this action but did not check it (audit-tier plan), and this client requires a checked decision. Upgrade the plan, or set requireEnforcement: false for log-only mode.",
|
|
45537
45763
|
toolCallId
|
|
45538
45764
|
};
|
|
45539
45765
|
}
|
|
@@ -45623,32 +45849,52 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
|
|
|
45623
45849
|
const pk = agentPubkey ?? this.auth.pubkey;
|
|
45624
45850
|
return this.track("getJudgmentStatus", pk, async () => {
|
|
45625
45851
|
const brid = await this.callBrid(chainOpts);
|
|
45852
|
+
const optIn = this.verifyKeys.length > 0 || this.enforceLocally;
|
|
45853
|
+
const optInValue = this.enforceLocally ? "strict" : "1";
|
|
45626
45854
|
const resp = await this.http.get(
|
|
45627
45855
|
"/api/v1/judge",
|
|
45628
45856
|
{ tool_call_id: judgmentId, agent_pubkey: pk, brid },
|
|
45629
|
-
|
|
45857
|
+
{
|
|
45858
|
+
...this.authHeaders(brid),
|
|
45859
|
+
...optIn ? { "X-Atbash-Client-Enforcement": optInValue } : {}
|
|
45860
|
+
}
|
|
45630
45861
|
);
|
|
45631
45862
|
await this.raiseIfError(resp);
|
|
45632
45863
|
const bytes = Buffer.from(await resp.arrayBuffer());
|
|
45633
|
-
if (this.
|
|
45634
|
-
verifyResponseSignature(bytes, resp, this.
|
|
45864
|
+
if (this.verifyKeys.length > 0) {
|
|
45865
|
+
verifyResponseSignature(bytes, resp, this.verifyKeys);
|
|
45635
45866
|
}
|
|
45636
45867
|
const parsed = tryParseJson(bytes.toString("utf-8"));
|
|
45637
45868
|
const data = isRecord2(parsed) ? parsed : {};
|
|
45638
|
-
const rawId = data.tool_call_id
|
|
45869
|
+
const rawId = data.tool_call_id;
|
|
45639
45870
|
const statedId = wireText(rawId);
|
|
45640
45871
|
const sameCall = rawId === void 0 || rawId === null || statedId === judgmentId;
|
|
45641
|
-
|
|
45872
|
+
let modeTrusted = false;
|
|
45873
|
+
if (optIn) {
|
|
45874
|
+
const echo = data.client_enforcement;
|
|
45875
|
+
if (echo !== void 0 && echo !== optInValue || echo === void 0 && this.enforceLocally) {
|
|
45876
|
+
throw new SignatureVerificationError(
|
|
45877
|
+
"the status does not confirm the enforcement this client asked for"
|
|
45878
|
+
);
|
|
45879
|
+
}
|
|
45880
|
+
modeTrusted = this.verifyKeys.length > 0 && echo === optInValue && statedId === judgmentId;
|
|
45881
|
+
}
|
|
45882
|
+
const status = {
|
|
45642
45883
|
status: normalizeStatus(data.status),
|
|
45643
45884
|
verdict: normalizeVerdict(data.verdict),
|
|
45644
45885
|
allow: sameCall && this.executable(data),
|
|
45645
45886
|
reason: wireText(data.reason),
|
|
45646
45887
|
judgmentId: statedId || judgmentId,
|
|
45647
|
-
|
|
45648
|
-
cached: optBool(data.cached),
|
|
45649
|
-
// The Dashboard sends response_time_ms; responseTimeMs is the spec name.
|
|
45650
|
-
responseTimeMs: optNumber(data.responseTimeMs ?? data.response_time_ms)
|
|
45888
|
+
responseTimeMs: optNumber(data.response_time_ms)
|
|
45651
45889
|
};
|
|
45890
|
+
const mode = wireText(data.enforcement_mode);
|
|
45891
|
+
if (!modeTrusted || this.enforceLocally || !(mode === "shadow" || mode === "monitor" || mode === "off") || status.verdict !== "BLOCK" && status.verdict !== "HOLD") {
|
|
45892
|
+
return status;
|
|
45893
|
+
}
|
|
45894
|
+
this.logger.warn?.(`[atbash] would ${status.verdict.toLowerCase()} (${mode} mode): ${status.reason}`, {
|
|
45895
|
+
toolCallId: judgmentId
|
|
45896
|
+
});
|
|
45897
|
+
return { ...status, verdict: "ALLOW", allow: true, wouldVerdict: status.verdict };
|
|
45652
45898
|
});
|
|
45653
45899
|
}
|
|
45654
45900
|
/* ── risk-engine queries (action-dispatched GET) ───────────────────────── */
|
|
@@ -46150,14 +46396,14 @@ async function withDeadline(p, ms) {
|
|
|
46150
46396
|
clearTimeout(timer);
|
|
46151
46397
|
}
|
|
46152
46398
|
}
|
|
46153
|
-
function verifyResponseSignature(bodyBytes, resp,
|
|
46399
|
+
function verifyResponseSignature(bodyBytes, resp, verifyKeys) {
|
|
46154
46400
|
const sig = resp.headers.get("X-Atbash-Signature");
|
|
46155
46401
|
if (!sig) {
|
|
46156
46402
|
throw new SignatureVerificationError("missing X-Atbash-Signature header");
|
|
46157
46403
|
}
|
|
46158
|
-
let ok;
|
|
46404
|
+
let ok = false;
|
|
46159
46405
|
try {
|
|
46160
|
-
ok = native.verifySignature(bodyBytes, sig,
|
|
46406
|
+
ok = verifyKeys.some((key3) => native.verifySignature(bodyBytes, sig, key3));
|
|
46161
46407
|
} catch (err) {
|
|
46162
46408
|
throw new SignatureVerificationError(
|
|
46163
46409
|
`signature verification threw: ${errorMessage(err)}`
|
|
@@ -46249,10 +46495,6 @@ function optNumber(v) {
|
|
|
46249
46495
|
const n = Number(v);
|
|
46250
46496
|
return Number.isFinite(n) ? n : void 0;
|
|
46251
46497
|
}
|
|
46252
|
-
function optBool(v) {
|
|
46253
|
-
if (v === null || v === void 0) return void 0;
|
|
46254
|
-
return Boolean(v);
|
|
46255
|
-
}
|
|
46256
46498
|
function tryParseJson(text) {
|
|
46257
46499
|
try {
|
|
46258
46500
|
return JSON.parse(text);
|
|
@@ -46298,7 +46540,9 @@ function truncate(text, limit = MAX_ACTION_LEN) {
|
|
|
46298
46540
|
}
|
|
46299
46541
|
|
|
46300
46542
|
// src-ts/browser/key-path.ts
|
|
46543
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46301
46544
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46545
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46302
46546
|
var KEY_FILENAMES = ["guard-client-key", "atbash-client-key"];
|
|
46303
46547
|
var unavailable = (name2) => {
|
|
46304
46548
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
@@ -46311,7 +46555,9 @@ function chooseKeyPath(_input, _exists) {
|
|
|
46311
46555
|
}
|
|
46312
46556
|
|
|
46313
46557
|
// src-ts/redact.ts
|
|
46558
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46314
46559
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46560
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46315
46561
|
function redactJsonStrings(value) {
|
|
46316
46562
|
if (typeof value === "string") {
|
|
46317
46563
|
return native.redactSecrets(value).redacted;
|
|
@@ -46330,7 +46576,9 @@ function redactJsonStrings(value) {
|
|
|
46330
46576
|
}
|
|
46331
46577
|
|
|
46332
46578
|
// src-ts/signature.ts
|
|
46579
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46333
46580
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46581
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46334
46582
|
function verifyJudgeResponseSignature(bodyBytes, signatureHex, pubKeyHex) {
|
|
46335
46583
|
if (!signatureHex) {
|
|
46336
46584
|
return { ok: false, reason: "missing X-Atbash-Signature header" };
|
|
@@ -46353,7 +46601,9 @@ function verifyJudgeResponseSignature(bodyBytes, signatureHex, pubKeyHex) {
|
|
|
46353
46601
|
}
|
|
46354
46602
|
|
|
46355
46603
|
// src-ts/memory/boot-sync-message.ts
|
|
46604
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46356
46605
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46606
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46357
46607
|
var BOOT_SYNC_HINT = "check the chain endpoint and orgName if the cause above does not explain it";
|
|
46358
46608
|
function bootSyncFailureLine(cause) {
|
|
46359
46609
|
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
@@ -46365,10 +46615,14 @@ function bootSyncFailureLine(cause) {
|
|
|
46365
46615
|
}
|
|
46366
46616
|
|
|
46367
46617
|
// src-ts/memory/index.ts
|
|
46618
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46368
46619
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46620
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46369
46621
|
|
|
46370
46622
|
// src-ts/browser/memory-crypto.ts
|
|
46623
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46371
46624
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46625
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46372
46626
|
var { Buffer: Buffer4 } = index;
|
|
46373
46627
|
var HKDF_INFO = new TextEncoder().encode("atbash:memory-encryption");
|
|
46374
46628
|
var KEY_LEN = 32;
|
|
@@ -46443,7 +46697,9 @@ async function decryptMemoryContent2(ciphertext, nonce, key3) {
|
|
|
46443
46697
|
}
|
|
46444
46698
|
|
|
46445
46699
|
// src-ts/browser/memory-scan.ts
|
|
46700
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46446
46701
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46702
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46447
46703
|
var STUB_MSG2 = "not available in @atbash/sdk browser bundle \u2014 scan memory server-side";
|
|
46448
46704
|
async function scanMemory(_entry, _auth, _opts) {
|
|
46449
46705
|
throw new Error(`scanMemory ${STUB_MSG2}`);
|
|
@@ -46453,7 +46709,9 @@ async function scanMemoryBatch(_entries, _auth, _opts) {
|
|
|
46453
46709
|
}
|
|
46454
46710
|
|
|
46455
46711
|
// src-ts/browser/memory-chain.ts
|
|
46712
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46456
46713
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46714
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46457
46715
|
var STUB_MSG3 = "not available in @atbash/sdk browser bundle \u2014 commit/rollback memory server-side";
|
|
46458
46716
|
async function commitMemoryVersion(_plaintext, _auth, _opts) {
|
|
46459
46717
|
throw new Error(`commitMemoryVersion ${STUB_MSG3}`);
|
|
@@ -46481,7 +46739,9 @@ async function rollbackMemory(_toId, _reason, _auth, _opts) {
|
|
|
46481
46739
|
}
|
|
46482
46740
|
|
|
46483
46741
|
// src-ts/browser/memory-classifier.ts
|
|
46742
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46484
46743
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46744
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46485
46745
|
var STUB_MSG4 = "not available in @atbash/sdk browser bundle \u2014 classify memory writes server-side";
|
|
46486
46746
|
var DEFAULT_MEMORY_WRITE_TOOL_NAMES = [
|
|
46487
46747
|
"write",
|
|
@@ -46504,14 +46764,18 @@ function classifyMemoryWrite(_event, _ctx, _opts = {}) {
|
|
|
46504
46764
|
}
|
|
46505
46765
|
|
|
46506
46766
|
// src-ts/browser/memory-guard.ts
|
|
46767
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46507
46768
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46769
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46508
46770
|
var STUB_MSG5 = "not available in @atbash/sdk browser bundle \u2014 guard memory writes agent-side";
|
|
46509
46771
|
async function guardMemoryWrite(_input) {
|
|
46510
46772
|
throw new Error(`guardMemoryWrite ${STUB_MSG5}`);
|
|
46511
46773
|
}
|
|
46512
46774
|
|
|
46513
46775
|
// src-ts/browser/memory-slot.ts
|
|
46776
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46514
46777
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46778
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46515
46779
|
var unavailable2 = (name2) => {
|
|
46516
46780
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46517
46781
|
};
|
|
@@ -46520,7 +46784,9 @@ function memorySlotOf(_target, _home, _root2, _extraHomes, _p) {
|
|
|
46520
46784
|
}
|
|
46521
46785
|
|
|
46522
46786
|
// src-ts/memory/sync.ts
|
|
46787
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46523
46788
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46789
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46524
46790
|
var MemoryIntegrityError = class extends Error {
|
|
46525
46791
|
constructor(id, reason) {
|
|
46526
46792
|
super(`memory integrity check failed on id ${id}: ${reason}`);
|
|
@@ -46553,7 +46819,9 @@ async function syncLocalMemory(auth, pointer, opts = {}) {
|
|
|
46553
46819
|
}
|
|
46554
46820
|
|
|
46555
46821
|
// src-ts/browser/memory-pointer-store.ts
|
|
46822
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46556
46823
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46824
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46557
46825
|
var unavailable3 = (name2) => {
|
|
46558
46826
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46559
46827
|
};
|
|
@@ -46572,7 +46840,9 @@ function defaultPointerPath(_workspaceDir) {
|
|
|
46572
46840
|
}
|
|
46573
46841
|
|
|
46574
46842
|
// src-ts/browser/memory-file-logger.ts
|
|
46843
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46575
46844
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46845
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46576
46846
|
var unavailable4 = (name2) => {
|
|
46577
46847
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46578
46848
|
};
|
|
@@ -46584,7 +46854,9 @@ function defaultPluginLogPath(_workspaceDir) {
|
|
|
46584
46854
|
}
|
|
46585
46855
|
|
|
46586
46856
|
// src-ts/browser/memory-read-classifier.ts
|
|
46857
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46587
46858
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46859
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46588
46860
|
var STUB_MSG6 = "not available in @atbash/sdk browser bundle \u2014 classify memory reads server-side";
|
|
46589
46861
|
var DEFAULT_MEMORY_READ_TOOL_NAMES = [
|
|
46590
46862
|
"memory_search",
|
|
@@ -46595,7 +46867,9 @@ function classifyMemoryRead(_event, _ctx, _opts = {}) {
|
|
|
46595
46867
|
}
|
|
46596
46868
|
|
|
46597
46869
|
// src-ts/browser/memory-guard-manager.ts
|
|
46870
|
+
init_define_ATBASH_DEV_JUDGE_PINS();
|
|
46598
46871
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
46872
|
+
init_define_ATBASH_PROD_JUDGE_PINS();
|
|
46599
46873
|
var unavailable5 = (name2) => {
|
|
46600
46874
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
46601
46875
|
};
|
|
@@ -46734,6 +47008,7 @@ export {
|
|
|
46734
47008
|
isEnvelope,
|
|
46735
47009
|
isJailHeld,
|
|
46736
47010
|
isValidPrivateKey2 as isValidPrivateKey,
|
|
47011
|
+
judgeVerifyKeys,
|
|
46737
47012
|
keyFingerprintOf,
|
|
46738
47013
|
keyPathCandidates,
|
|
46739
47014
|
loadAgent2 as loadAgent,
|
|
@@ -46760,6 +47035,7 @@ export {
|
|
|
46760
47035
|
saveUserConfig,
|
|
46761
47036
|
scanMemory,
|
|
46762
47037
|
scanMemoryBatch,
|
|
47038
|
+
setLoopbackJudgePinsForTests,
|
|
46763
47039
|
setupTelemetry,
|
|
46764
47040
|
shutdownTelemetry,
|
|
46765
47041
|
signEncryptedToolCall,
|