@atbash/sdk 0.10.5-dev.0 → 0.10.7-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/dist/browser.d.mts +74 -1
- package/dist/browser.mjs +266 -30
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +74 -1
- package/dist/index.d.ts +74 -1
- package/dist/index.js +156 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +155 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -5
package/dist/browser.mjs
CHANGED
|
@@ -10,6 +10,9 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
10
10
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
11
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
12
|
});
|
|
13
|
+
var __esm = (fn, res) => function __init() {
|
|
14
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
15
|
+
};
|
|
13
16
|
var __commonJS = (cb, mod2) => function __require2() {
|
|
14
17
|
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
|
|
15
18
|
};
|
|
@@ -30,10 +33,28 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
|
|
|
30
33
|
mod2
|
|
31
34
|
));
|
|
32
35
|
|
|
36
|
+
// <define:__ATBASH_CHROMIA_NODE_URLS__>
|
|
37
|
+
var define_ATBASH_CHROMIA_NODE_URLS_default;
|
|
38
|
+
var init_define_ATBASH_CHROMIA_NODE_URLS = __esm({
|
|
39
|
+
"<define:__ATBASH_CHROMIA_NODE_URLS__>"() {
|
|
40
|
+
define_ATBASH_CHROMIA_NODE_URLS_default = ["https://node0.testnet.chromia.com:7740", "https://node1.testnet.chromia.com:7740", "https://node3.testnet.chromia.com:7740"];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// <define:__ATBASH_PRIVATE_NODE_URLS__>
|
|
45
|
+
var define_ATBASH_PRIVATE_NODE_URLS_default;
|
|
46
|
+
var init_define_ATBASH_PRIVATE_NODE_URLS = __esm({
|
|
47
|
+
"<define:__ATBASH_PRIVATE_NODE_URLS__>"() {
|
|
48
|
+
define_ATBASH_PRIVATE_NODE_URLS_default = ["https://node0-pvn-testnet.dynamic.chromia.dev"];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
33
52
|
// (disabled):node_modules/buffer/index.js
|
|
34
53
|
var require_buffer = __commonJS({
|
|
35
54
|
"(disabled):node_modules/buffer/index.js"() {
|
|
36
55
|
"use strict";
|
|
56
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
57
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
37
58
|
}
|
|
38
59
|
});
|
|
39
60
|
|
|
@@ -41,6 +62,8 @@ var require_buffer = __commonJS({
|
|
|
41
62
|
var require_bn = __commonJS({
|
|
42
63
|
"node_modules/bn.js/lib/bn.js"(exports, module) {
|
|
43
64
|
"use strict";
|
|
65
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
66
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44
67
|
(function(module2, exports2) {
|
|
45
68
|
"use strict";
|
|
46
69
|
function assert2(val, msg) {
|
|
@@ -2858,7 +2881,29 @@ var require_bn = __commonJS({
|
|
|
2858
2881
|
}
|
|
2859
2882
|
});
|
|
2860
2883
|
|
|
2884
|
+
// src-ts/index.ts
|
|
2885
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
2886
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2887
|
+
|
|
2888
|
+
// src-ts/browser/native.ts
|
|
2889
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
2890
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2891
|
+
|
|
2892
|
+
// node_modules/@noble/curves/secp256k1.js
|
|
2893
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
2894
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2895
|
+
|
|
2896
|
+
// node_modules/@noble/hashes/sha2.js
|
|
2897
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
2898
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2899
|
+
|
|
2900
|
+
// node_modules/@noble/hashes/_md.js
|
|
2901
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
2902
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2903
|
+
|
|
2861
2904
|
// node_modules/@noble/hashes/utils.js
|
|
2905
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
2906
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
2862
2907
|
function isBytes(a) {
|
|
2863
2908
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
2864
2909
|
}
|
|
@@ -3279,7 +3324,13 @@ var sha256 = /* @__PURE__ */ createHasher(
|
|
|
3279
3324
|
/* @__PURE__ */ oidNist(1)
|
|
3280
3325
|
);
|
|
3281
3326
|
|
|
3327
|
+
// node_modules/@noble/curves/abstract/curve.js
|
|
3328
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
3329
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
3330
|
+
|
|
3282
3331
|
// node_modules/@noble/curves/utils.js
|
|
3332
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
3333
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
3283
3334
|
var abytes2 = (value, length, title) => abytes(value, length, title);
|
|
3284
3335
|
var anumber2 = anumber;
|
|
3285
3336
|
var bytesToHex2 = bytesToHex;
|
|
@@ -3432,6 +3483,8 @@ function validateObject(object, fields = {}, optFields = {}) {
|
|
|
3432
3483
|
}
|
|
3433
3484
|
|
|
3434
3485
|
// node_modules/@noble/curves/abstract/modular.js
|
|
3486
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
3487
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
3435
3488
|
var _0n2 = /* @__PURE__ */ BigInt(0);
|
|
3436
3489
|
var _1n2 = /* @__PURE__ */ BigInt(1);
|
|
3437
3490
|
var _2n = /* @__PURE__ */ BigInt(2);
|
|
@@ -4079,7 +4132,13 @@ function createKeygen(randomSecretKey, getPublicKey) {
|
|
|
4079
4132
|
};
|
|
4080
4133
|
}
|
|
4081
4134
|
|
|
4135
|
+
// node_modules/@noble/curves/abstract/weierstrass.js
|
|
4136
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
4137
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
4138
|
+
|
|
4082
4139
|
// node_modules/@noble/hashes/hmac.js
|
|
4140
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
4141
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
4083
4142
|
var _HMAC = class {
|
|
4084
4143
|
oHash;
|
|
4085
4144
|
iHash;
|
|
@@ -5111,6 +5170,8 @@ var Pointk1 = /* @__PURE__ */ weierstrass(secp256k1_CURVE, {
|
|
|
5111
5170
|
var secp256k1 = /* @__PURE__ */ ecdsa(Pointk1, sha256);
|
|
5112
5171
|
|
|
5113
5172
|
// node_modules/postchain-client/built/esm/index.js
|
|
5173
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
5174
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
5114
5175
|
var import_bn = __toESM(require_bn(), 1);
|
|
5115
5176
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
5116
5177
|
function getDefaultExportFromCjs(x) {
|
|
@@ -12065,7 +12126,7 @@ function requireBuffer_list() {
|
|
|
12065
12126
|
}
|
|
12066
12127
|
}, {
|
|
12067
12128
|
key: "join",
|
|
12068
|
-
value: function
|
|
12129
|
+
value: function join3(s2) {
|
|
12069
12130
|
if (this.length === 0) return "";
|
|
12070
12131
|
var p = this.head;
|
|
12071
12132
|
var ret = "" + p.data;
|
|
@@ -16147,7 +16208,7 @@ function requireBufferList() {
|
|
|
16147
16208
|
this.head = this.tail = null;
|
|
16148
16209
|
this.length = 0;
|
|
16149
16210
|
};
|
|
16150
|
-
BufferList2.prototype.join = function
|
|
16211
|
+
BufferList2.prototype.join = function join3(s2) {
|
|
16151
16212
|
if (this.length === 0) return "";
|
|
16152
16213
|
var p = this.head;
|
|
16153
16214
|
var ret = "" + p.data;
|
|
@@ -30311,7 +30372,7 @@ function requireBuffer() {
|
|
|
30311
30372
|
}
|
|
30312
30373
|
}
|
|
30313
30374
|
buffer.EncoderBuffer = EncoderBuffer2;
|
|
30314
|
-
EncoderBuffer2.prototype.join = function
|
|
30375
|
+
EncoderBuffer2.prototype.join = function join3(out, offset) {
|
|
30315
30376
|
if (!out)
|
|
30316
30377
|
out = new Buffer5(this.length);
|
|
30317
30378
|
if (!offset)
|
|
@@ -43233,17 +43294,11 @@ var index = /* @__PURE__ */ getDefaultExportFromCjs(builtExports);
|
|
|
43233
43294
|
|
|
43234
43295
|
// src-ts/browser/native.ts
|
|
43235
43296
|
var { Buffer: Buffer3, gtx: pcgtx } = index;
|
|
43236
|
-
var
|
|
43237
|
-
var
|
|
43238
|
-
var
|
|
43239
|
-
var DEFAULT_CHROMIA_NODE_URLS_ARR =
|
|
43240
|
-
|
|
43241
|
-
"https://node1.testnet.chromia.com:7740",
|
|
43242
|
-
"https://node3.testnet.chromia.com:7740"
|
|
43243
|
-
];
|
|
43244
|
-
var DEFAULT_PRIVATE_NODE_URLS_ARR = [
|
|
43245
|
-
"https://node0-pvn-testnet.dynamic.chromia.dev"
|
|
43246
|
-
];
|
|
43297
|
+
var ATBASH_ENDPOINT = "https://chromia-verified-ai-dev-two.vercel.app";
|
|
43298
|
+
var ATBASH_BLOCKCHAIN_RID = "02668C5218871F69A93CC0F7032DCFFE06EF0D35EF2F0B07A92A3D83A3F23A7D";
|
|
43299
|
+
var ATBASH_PRIVATE_BLOCKCHAIN_RID = "2603569AE8DC3F254323F719C8D4347BBA964E874E781291F8474236BE8B6493";
|
|
43300
|
+
var DEFAULT_CHROMIA_NODE_URLS_ARR = define_ATBASH_CHROMIA_NODE_URLS_default;
|
|
43301
|
+
var DEFAULT_PRIVATE_NODE_URLS_ARR = define_ATBASH_PRIVATE_NODE_URLS_default;
|
|
43247
43302
|
var MERKLE_HASH_VERSION = 2;
|
|
43248
43303
|
function stripHex(s2) {
|
|
43249
43304
|
return s2.trim().replace(/^0x/i, "").toLowerCase();
|
|
@@ -43394,9 +43449,9 @@ var native = {
|
|
|
43394
43449
|
deriveMemoryKey,
|
|
43395
43450
|
encryptMemoryContent,
|
|
43396
43451
|
decryptMemoryContent,
|
|
43397
|
-
DEFAULT_BLOCKCHAIN_RID:
|
|
43398
|
-
DEFAULT_PRIVATE_BLOCKCHAIN_RID:
|
|
43399
|
-
DEFAULT_ENDPOINT:
|
|
43452
|
+
DEFAULT_BLOCKCHAIN_RID: ATBASH_BLOCKCHAIN_RID,
|
|
43453
|
+
DEFAULT_PRIVATE_BLOCKCHAIN_RID: ATBASH_PRIVATE_BLOCKCHAIN_RID,
|
|
43454
|
+
DEFAULT_ENDPOINT: ATBASH_ENDPOINT,
|
|
43400
43455
|
// Browser has no NAPI channel to Rust's HONEYCOMB_KEY — telemetry
|
|
43401
43456
|
// silently no-ops. `HONEYCOMB_API_KEY` env var still overrides at runtime.
|
|
43402
43457
|
HONEYCOMB_KEY: "",
|
|
@@ -43456,7 +43511,13 @@ var native = {
|
|
|
43456
43511
|
ARG_ID: "id"
|
|
43457
43512
|
};
|
|
43458
43513
|
|
|
43514
|
+
// src-ts/client.ts
|
|
43515
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43516
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43517
|
+
|
|
43459
43518
|
// src-ts/random.ts
|
|
43519
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43520
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43460
43521
|
function randomBytes4(size) {
|
|
43461
43522
|
const buf = new Uint8Array(size);
|
|
43462
43523
|
globalThis.crypto.getRandomValues(buf);
|
|
@@ -43471,7 +43532,13 @@ function randomHex(size) {
|
|
|
43471
43532
|
return hex;
|
|
43472
43533
|
}
|
|
43473
43534
|
|
|
43535
|
+
// src-ts/chain-config.ts
|
|
43536
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43537
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43538
|
+
|
|
43474
43539
|
// src-ts/constants.ts
|
|
43540
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43541
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43475
43542
|
var DEFAULT_ENDPOINT = native.DEFAULT_ENDPOINT;
|
|
43476
43543
|
var DEFAULT_CHROMIA_NODE_URLS = Object.freeze(
|
|
43477
43544
|
native.defaultChromiaNodeUrls()
|
|
@@ -43494,7 +43561,17 @@ var PRIVATE_CHAIN = {
|
|
|
43494
43561
|
nodeUrls: DEFAULT_PRIVATE_NODE_URLS
|
|
43495
43562
|
};
|
|
43496
43563
|
|
|
43564
|
+
// src-ts/browser/encrypted-toolcall.ts
|
|
43565
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43566
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43567
|
+
|
|
43568
|
+
// src-ts/browser/crypto-ecies.ts
|
|
43569
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43570
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43571
|
+
|
|
43497
43572
|
// node_modules/@noble/hashes/hkdf.js
|
|
43573
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43574
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43498
43575
|
function extract(hash3, ikm, salt) {
|
|
43499
43576
|
ahash(hash3);
|
|
43500
43577
|
if (salt === void 0)
|
|
@@ -43534,7 +43611,17 @@ function expand2(hash3, prk, info2, length = 32) {
|
|
|
43534
43611
|
}
|
|
43535
43612
|
var hkdf = (hash3, ikm, salt, info2, length) => expand2(hash3, extract(hash3, ikm, salt), info2, length);
|
|
43536
43613
|
|
|
43614
|
+
// node_modules/@noble/ciphers/aes.js
|
|
43615
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43616
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43617
|
+
|
|
43618
|
+
// node_modules/@noble/ciphers/_polyval.js
|
|
43619
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43620
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43621
|
+
|
|
43537
43622
|
// node_modules/@noble/ciphers/utils.js
|
|
43623
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
43624
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
43538
43625
|
function isBytes3(a) {
|
|
43539
43626
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
43540
43627
|
}
|
|
@@ -44127,6 +44214,8 @@ function encryptedLength(plaintextByteLength) {
|
|
|
44127
44214
|
}
|
|
44128
44215
|
|
|
44129
44216
|
// src-ts/crypto/envelope.ts
|
|
44217
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44218
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44130
44219
|
var PREFIX = "atb1";
|
|
44131
44220
|
var SEPARATOR = ".";
|
|
44132
44221
|
function toBase64(bytes) {
|
|
@@ -44259,6 +44348,8 @@ function signEncryptedToolCall(toolCallId, action, context, toolName, toolArgsJs
|
|
|
44259
44348
|
}
|
|
44260
44349
|
|
|
44261
44350
|
// src-ts/endpoint.ts
|
|
44351
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44352
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44262
44353
|
function buildAllowedJudgeHosts() {
|
|
44263
44354
|
return /* @__PURE__ */ new Set([
|
|
44264
44355
|
"atbash.ai",
|
|
@@ -44309,6 +44400,8 @@ function validateJudgeEndpoint(judge) {
|
|
|
44309
44400
|
}
|
|
44310
44401
|
|
|
44311
44402
|
// src-ts/errors.ts
|
|
44403
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44404
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44312
44405
|
var AtbashAPIError = class extends Error {
|
|
44313
44406
|
/** HTTP status code (or 0 if the request never completed). */
|
|
44314
44407
|
status;
|
|
@@ -44351,6 +44444,8 @@ function enrich(status, body, statusText, endpoint) {
|
|
|
44351
44444
|
}
|
|
44352
44445
|
|
|
44353
44446
|
// src-ts/http/client.ts
|
|
44447
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44448
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44354
44449
|
var HttpClient = class {
|
|
44355
44450
|
baseUrl;
|
|
44356
44451
|
timeoutMs;
|
|
@@ -44388,6 +44483,8 @@ var HttpClient = class {
|
|
|
44388
44483
|
};
|
|
44389
44484
|
|
|
44390
44485
|
// src-ts/browser/keyLoader.ts
|
|
44486
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44487
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44391
44488
|
var NOT_AVAILABLE = "keyLoader is not available in the browser bundle \u2014 pass `agentKey` explicitly to Atbash.fromConfig or use `new Atbash(privkey, opts)`.";
|
|
44392
44489
|
function resolveKeyPath(_input) {
|
|
44393
44490
|
throw new Error(NOT_AVAILABLE);
|
|
@@ -44397,6 +44494,8 @@ function loadAgentFromFile(_keyPath) {
|
|
|
44397
44494
|
}
|
|
44398
44495
|
|
|
44399
44496
|
// src-ts/normalize.ts
|
|
44497
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44498
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44400
44499
|
function normalizeVerdict(raw2) {
|
|
44401
44500
|
if (raw2 === null || raw2 === void 0) return "No verdict";
|
|
44402
44501
|
const v = String(raw2).toUpperCase();
|
|
@@ -44422,6 +44521,8 @@ function pubkeyToHex(val) {
|
|
|
44422
44521
|
}
|
|
44423
44522
|
|
|
44424
44523
|
// src-ts/browser/opentel/telemetry.ts
|
|
44524
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44525
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44425
44526
|
function setupTelemetry(_config) {
|
|
44426
44527
|
}
|
|
44427
44528
|
function recordCall(_functionName, _source, _agentPubkey) {
|
|
@@ -44434,6 +44535,8 @@ async function shutdownTelemetry() {
|
|
|
44434
44535
|
}
|
|
44435
44536
|
|
|
44436
44537
|
// src-ts/browser/userConfig.ts
|
|
44538
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44539
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44437
44540
|
var NOT_AVAILABLE2 = "userConfig file I/O is not available in the browser bundle.";
|
|
44438
44541
|
function getConfigDir() {
|
|
44439
44542
|
throw new Error(NOT_AVAILABLE2);
|
|
@@ -44470,6 +44573,7 @@ var Atbash = class _Atbash {
|
|
|
44470
44573
|
failClosed;
|
|
44471
44574
|
/** Org key learned from the last agent-exists check, for this agent only. */
|
|
44472
44575
|
_orgKeyFromChain = null;
|
|
44576
|
+
debug;
|
|
44473
44577
|
logger;
|
|
44474
44578
|
http;
|
|
44475
44579
|
/**
|
|
@@ -44483,6 +44587,8 @@ var Atbash = class _Atbash {
|
|
|
44483
44587
|
* server-side replay protection windows never expire it mid-session.
|
|
44484
44588
|
*/
|
|
44485
44589
|
_authBearer = null;
|
|
44590
|
+
/** Guards `logEnvironmentOnce` — hosts construct several clients. */
|
|
44591
|
+
static environmentLogged = false;
|
|
44486
44592
|
constructor(privkey, options = {}) {
|
|
44487
44593
|
this.auth = native.loadAgent(privkey);
|
|
44488
44594
|
this.endpoint = (options.endpoint ?? DEFAULT_ENDPOINT).replace(/\/+$/, "") || DEFAULT_ENDPOINT;
|
|
@@ -44492,8 +44598,10 @@ var Atbash = class _Atbash {
|
|
|
44492
44598
|
this.verifyPubKey = options.verifyPubKey;
|
|
44493
44599
|
this.orgEncryptionPubKey = options.orgEncryptionPubKey;
|
|
44494
44600
|
this.failClosed = options.failClosed !== false;
|
|
44601
|
+
this.debug = options.debug === true;
|
|
44495
44602
|
this.logger = options.logger ?? {};
|
|
44496
44603
|
this.http = new HttpClient(this.endpoint, options.timeoutMs ?? 3e4);
|
|
44604
|
+
this.logEnvironmentOnce();
|
|
44497
44605
|
if (this.endpoint !== DEFAULT_ENDPOINT) {
|
|
44498
44606
|
this.logger.warn?.("[atbash] running on non-default judge endpoint", {
|
|
44499
44607
|
endpoint: this.endpoint,
|
|
@@ -44501,6 +44609,31 @@ var Atbash = class _Atbash {
|
|
|
44501
44609
|
});
|
|
44502
44610
|
}
|
|
44503
44611
|
}
|
|
44612
|
+
/**
|
|
44613
|
+
* Say which environment this build talks to, once per process.
|
|
44614
|
+
*
|
|
44615
|
+
* The endpoint and both chain RIDs are compiled in, chosen by the npm tag,
|
|
44616
|
+
* and no configuration repoints a released build. So installing the build
|
|
44617
|
+
* for the wrong environment is invisible: the plugin loads, the hook fires,
|
|
44618
|
+
* and every judge call fails because the agent does not exist on the chain
|
|
44619
|
+
* this build targets. Organisation names are not unique across environments
|
|
44620
|
+
* either, so an org resolving is not evidence the build is right.
|
|
44621
|
+
*/
|
|
44622
|
+
logEnvironmentOnce() {
|
|
44623
|
+
if (_Atbash.environmentLogged) return;
|
|
44624
|
+
_Atbash.environmentLogged = true;
|
|
44625
|
+
const brief = (rid) => rid ? `${rid.slice(0, 8)}\u2026` : "(unset)";
|
|
44626
|
+
this.logger.info?.(
|
|
44627
|
+
`[atbash] environment \u2014 judge=${this.endpoint} publicChain=${brief(native.DEFAULT_BLOCKCHAIN_RID)} privateChain=${brief(native.DEFAULT_PRIVATE_BLOCKCHAIN_RID)} activeChain=${brief(this.blockchainRid)} responseSignatureCheck=${this.verifyPubKey ? "on" : "off"}`,
|
|
44628
|
+
{
|
|
44629
|
+
judgeEndpoint: this.endpoint,
|
|
44630
|
+
publicBlockchainRid: native.DEFAULT_BLOCKCHAIN_RID,
|
|
44631
|
+
privateBlockchainRid: native.DEFAULT_PRIVATE_BLOCKCHAIN_RID,
|
|
44632
|
+
activeBlockchainRid: this.blockchainRid,
|
|
44633
|
+
responseSignatureCheck: Boolean(this.verifyPubKey)
|
|
44634
|
+
}
|
|
44635
|
+
);
|
|
44636
|
+
}
|
|
44504
44637
|
/**
|
|
44505
44638
|
* Construct from resolved config: explicit overrides → env vars → the
|
|
44506
44639
|
* `~/.config/atbash/config.json` file (see userConfig.resolve). The private
|
|
@@ -44524,6 +44657,9 @@ var Atbash = class _Atbash {
|
|
|
44524
44657
|
orgName: options.orgName,
|
|
44525
44658
|
verifyPubKey: validated.verifyPubKey ?? void 0,
|
|
44526
44659
|
failClosed: options.failClosed,
|
|
44660
|
+
// ATBASH_DEBUG lets an operator turn diagnostics on without editing a
|
|
44661
|
+
// host's plugin config, which is usually the harder half.
|
|
44662
|
+
debug: options.debug ?? /^(1|true|yes)$/i.test(resolve("debug")),
|
|
44527
44663
|
logger: options.logger
|
|
44528
44664
|
});
|
|
44529
44665
|
}
|
|
@@ -44623,11 +44759,15 @@ var Atbash = class _Atbash {
|
|
|
44623
44759
|
* response bytes via the Rust core's `verifySignature`.
|
|
44624
44760
|
*/
|
|
44625
44761
|
async judgeAction(action, context = "", options = {}) {
|
|
44626
|
-
return this.track(
|
|
44627
|
-
|
|
44628
|
-
|
|
44629
|
-
|
|
44630
|
-
|
|
44762
|
+
return this.track("judgeAction", this.auth.pubkey, async () => {
|
|
44763
|
+
try {
|
|
44764
|
+
return await this._judgeAction(action, context, options);
|
|
44765
|
+
} catch (err) {
|
|
44766
|
+
if (!isEncryptionStateMismatch(err)) throw err;
|
|
44767
|
+
this._orgKeyFromChain = null;
|
|
44768
|
+
return await this._judgeAction(action, context, options);
|
|
44769
|
+
}
|
|
44770
|
+
});
|
|
44631
44771
|
}
|
|
44632
44772
|
async _judgeAction(action, context, options) {
|
|
44633
44773
|
if (!action?.trim()) {
|
|
@@ -44765,8 +44905,9 @@ var Atbash = class _Atbash {
|
|
|
44765
44905
|
});
|
|
44766
44906
|
if (result.verdict === "No verdict") {
|
|
44767
44907
|
if (result.status !== "logged") {
|
|
44768
|
-
return this.
|
|
44908
|
+
return this.failJudge(
|
|
44769
44909
|
`judge returned no verdict without an audit-tier marker (status: ${result.status || "absent"})`,
|
|
44910
|
+
void 0,
|
|
44770
44911
|
result.toolCallId
|
|
44771
44912
|
);
|
|
44772
44913
|
}
|
|
@@ -44818,16 +44959,38 @@ var Atbash = class _Atbash {
|
|
|
44818
44959
|
toolCallId: result.toolCallId
|
|
44819
44960
|
};
|
|
44820
44961
|
}
|
|
44821
|
-
return this.
|
|
44962
|
+
return this.failJudge(
|
|
44822
44963
|
"unrecognized action_type from judge",
|
|
44964
|
+
void 0,
|
|
44823
44965
|
result.toolCallId
|
|
44824
44966
|
);
|
|
44825
44967
|
} catch (err) {
|
|
44826
|
-
|
|
44827
|
-
this.logger.warn?.("[atbash] judge API failed", { reason: message });
|
|
44828
|
-
return this.fail(message);
|
|
44968
|
+
return this.failJudge(errorMessage(err), err);
|
|
44829
44969
|
}
|
|
44830
44970
|
}
|
|
44971
|
+
/**
|
|
44972
|
+
* One exit for every judge failure.
|
|
44973
|
+
*
|
|
44974
|
+
* Status and reason go in the *message*, not only in the meta object: hosts
|
|
44975
|
+
* print the message and drop the meta, which is why this read as a bare
|
|
44976
|
+
* "judge API failed" while the judge was answering with a precise reason.
|
|
44977
|
+
* The response body follows only under `debug`, since it can echo the action.
|
|
44978
|
+
*/
|
|
44979
|
+
failJudge(reason, cause, toolCallId) {
|
|
44980
|
+
const api2 = cause instanceof AtbashAPIError ? cause : null;
|
|
44981
|
+
const status = api2 ? ` status=${api2.status || "no-response"}` : "";
|
|
44982
|
+
const body = this.debug && api2?.body ? ` body=${truncate(api2.body, 500)}` : "";
|
|
44983
|
+
this.logger.warn?.(
|
|
44984
|
+
`[atbash] judge API failed \u2014${status} reason=${truncate(reason, 300)}${body}`,
|
|
44985
|
+
{
|
|
44986
|
+
reason,
|
|
44987
|
+
...api2 ? { status: api2.status, body: api2.body } : {},
|
|
44988
|
+
endpoint: this.endpoint,
|
|
44989
|
+
...toolCallId ? { toolCallId } : {}
|
|
44990
|
+
}
|
|
44991
|
+
);
|
|
44992
|
+
return this.fail(reason, toolCallId);
|
|
44993
|
+
}
|
|
44831
44994
|
fail(reason, toolCallId) {
|
|
44832
44995
|
return { allow: !this.failClosed, verdict: "ERROR", reason, toolCallId };
|
|
44833
44996
|
}
|
|
@@ -45301,6 +45464,10 @@ async function safeText(resp) {
|
|
|
45301
45464
|
function errorMessage(err) {
|
|
45302
45465
|
return err instanceof Error ? err.message : String(err);
|
|
45303
45466
|
}
|
|
45467
|
+
function isEncryptionStateMismatch(err) {
|
|
45468
|
+
const msg = errorMessage(err);
|
|
45469
|
+
return msg.includes("must be a valid encryption envelope") || msg.includes("must be plaintext");
|
|
45470
|
+
}
|
|
45304
45471
|
function stringifyArgs(args) {
|
|
45305
45472
|
if (args === null || args === void 0) return "";
|
|
45306
45473
|
if (typeof args === "string") return args;
|
|
@@ -45311,12 +45478,37 @@ function stringifyArgs(args) {
|
|
|
45311
45478
|
}
|
|
45312
45479
|
}
|
|
45313
45480
|
var MAX_ACTION_LEN = 4e3;
|
|
45314
|
-
function truncate(text) {
|
|
45315
|
-
if (text.length <=
|
|
45316
|
-
return text.slice(0,
|
|
45481
|
+
function truncate(text, limit = MAX_ACTION_LEN) {
|
|
45482
|
+
if (text.length <= limit) return text;
|
|
45483
|
+
return text.slice(0, limit) + "\u2026";
|
|
45484
|
+
}
|
|
45485
|
+
|
|
45486
|
+
// src-ts/key-path.ts
|
|
45487
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45488
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45489
|
+
import { homedir } from "os";
|
|
45490
|
+
import { join as join2 } from "path";
|
|
45491
|
+
var KEY_DIR_REL = ".config/atbash";
|
|
45492
|
+
var KEY_FILENAMES = ["guard-client-key", "atbash-client-key"];
|
|
45493
|
+
function home() {
|
|
45494
|
+
return process.env.HOME || homedir() || "";
|
|
45495
|
+
}
|
|
45496
|
+
function expandHome(p) {
|
|
45497
|
+
if (!p.startsWith("~/")) return p;
|
|
45498
|
+
return join2(home(), p.slice(2));
|
|
45499
|
+
}
|
|
45500
|
+
function keyPathCandidates() {
|
|
45501
|
+
return KEY_FILENAMES.map((name2) => join2(home(), KEY_DIR_REL, name2));
|
|
45502
|
+
}
|
|
45503
|
+
function chooseKeyPath(input, exists) {
|
|
45504
|
+
if (input) return expandHome(input);
|
|
45505
|
+
const candidates = keyPathCandidates();
|
|
45506
|
+
return candidates.find(exists) ?? candidates[0];
|
|
45317
45507
|
}
|
|
45318
45508
|
|
|
45319
45509
|
// src-ts/redact.ts
|
|
45510
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45511
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45320
45512
|
function redactJsonStrings(value) {
|
|
45321
45513
|
if (typeof value === "string") {
|
|
45322
45514
|
return native.redactSecrets(value).redacted;
|
|
@@ -45335,6 +45527,8 @@ function redactJsonStrings(value) {
|
|
|
45335
45527
|
}
|
|
45336
45528
|
|
|
45337
45529
|
// src-ts/signature.ts
|
|
45530
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45531
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45338
45532
|
function verifyJudgeResponseSignature(bodyBytes, signatureHex, pubKeyHex) {
|
|
45339
45533
|
if (!signatureHex) {
|
|
45340
45534
|
return { ok: false, reason: "missing X-Atbash-Signature header" };
|
|
@@ -45356,7 +45550,26 @@ function verifyJudgeResponseSignature(bodyBytes, signatureHex, pubKeyHex) {
|
|
|
45356
45550
|
};
|
|
45357
45551
|
}
|
|
45358
45552
|
|
|
45553
|
+
// src-ts/memory/boot-sync-message.ts
|
|
45554
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45555
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45556
|
+
var BOOT_SYNC_HINT = "check the chain endpoint and orgName if the cause above does not explain it";
|
|
45557
|
+
function bootSyncFailureLine(cause) {
|
|
45558
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
45559
|
+
const trimmed = reason.trim();
|
|
45560
|
+
return trimmed ? `[atbash] boot memory sync failed: ${trimmed}` : (
|
|
45561
|
+
// No cause to show: fall back to the advice rather than a bare colon.
|
|
45562
|
+
`[atbash] boot memory sync failed \u2014 ${BOOT_SYNC_HINT}`
|
|
45563
|
+
);
|
|
45564
|
+
}
|
|
45565
|
+
|
|
45566
|
+
// src-ts/memory/index.ts
|
|
45567
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45568
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45569
|
+
|
|
45359
45570
|
// src-ts/browser/memory-crypto.ts
|
|
45571
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45572
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45360
45573
|
var { Buffer: Buffer4 } = index;
|
|
45361
45574
|
var HKDF_INFO = new TextEncoder().encode("atbash:memory-encryption");
|
|
45362
45575
|
var KEY_LEN = 32;
|
|
@@ -45431,6 +45644,8 @@ async function decryptMemoryContent2(ciphertext, nonce, key3) {
|
|
|
45431
45644
|
}
|
|
45432
45645
|
|
|
45433
45646
|
// src-ts/browser/memory-scan.ts
|
|
45647
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45648
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45434
45649
|
var STUB_MSG2 = "not available in @atbash/sdk browser bundle \u2014 scan memory server-side";
|
|
45435
45650
|
async function scanMemory(_entry, _auth, _opts) {
|
|
45436
45651
|
throw new Error(`scanMemory ${STUB_MSG2}`);
|
|
@@ -45440,6 +45655,8 @@ async function scanMemoryBatch(_entries, _auth, _opts) {
|
|
|
45440
45655
|
}
|
|
45441
45656
|
|
|
45442
45657
|
// src-ts/browser/memory-chain.ts
|
|
45658
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45659
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45443
45660
|
var STUB_MSG3 = "not available in @atbash/sdk browser bundle \u2014 commit/rollback memory server-side";
|
|
45444
45661
|
async function commitMemoryVersion(_plaintext, _auth, _opts) {
|
|
45445
45662
|
throw new Error(`commitMemoryVersion ${STUB_MSG3}`);
|
|
@@ -45467,6 +45684,8 @@ async function rollbackMemory(_toId, _reason, _auth, _opts) {
|
|
|
45467
45684
|
}
|
|
45468
45685
|
|
|
45469
45686
|
// src-ts/browser/memory-classifier.ts
|
|
45687
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45688
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45470
45689
|
var STUB_MSG4 = "not available in @atbash/sdk browser bundle \u2014 classify memory writes server-side";
|
|
45471
45690
|
var DEFAULT_MEMORY_WRITE_TOOL_NAMES = [
|
|
45472
45691
|
"write",
|
|
@@ -45489,6 +45708,8 @@ function classifyMemoryWrite(_event, _ctx, _opts = {}) {
|
|
|
45489
45708
|
}
|
|
45490
45709
|
|
|
45491
45710
|
// src-ts/memory/guard.ts
|
|
45711
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45712
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45492
45713
|
function emitDebugProbe(event, ctx, memEntry, logger2) {
|
|
45493
45714
|
if (!logger2?.info) return;
|
|
45494
45715
|
const ev = event ?? {};
|
|
@@ -45585,6 +45806,8 @@ async function guardMemoryWrite(input) {
|
|
|
45585
45806
|
}
|
|
45586
45807
|
|
|
45587
45808
|
// src-ts/memory/sync.ts
|
|
45809
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45810
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45588
45811
|
var MemoryIntegrityError = class extends Error {
|
|
45589
45812
|
constructor(id, reason) {
|
|
45590
45813
|
super(`memory integrity check failed on id ${id}: ${reason}`);
|
|
@@ -45617,6 +45840,8 @@ async function syncLocalMemory(auth, pointer, opts = {}) {
|
|
|
45617
45840
|
}
|
|
45618
45841
|
|
|
45619
45842
|
// src-ts/browser/memory-pointer-store.ts
|
|
45843
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45844
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45620
45845
|
var unavailable = (name2) => {
|
|
45621
45846
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
45622
45847
|
};
|
|
@@ -45635,6 +45860,8 @@ function defaultPointerPath(_workspaceDir) {
|
|
|
45635
45860
|
}
|
|
45636
45861
|
|
|
45637
45862
|
// src-ts/browser/memory-file-logger.ts
|
|
45863
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45864
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45638
45865
|
var unavailable2 = (name2) => {
|
|
45639
45866
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
45640
45867
|
};
|
|
@@ -45646,6 +45873,8 @@ function defaultPluginLogPath(_workspaceDir) {
|
|
|
45646
45873
|
}
|
|
45647
45874
|
|
|
45648
45875
|
// src-ts/browser/memory-read-classifier.ts
|
|
45876
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45877
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45649
45878
|
var STUB_MSG5 = "not available in @atbash/sdk browser bundle \u2014 classify memory reads server-side";
|
|
45650
45879
|
var DEFAULT_MEMORY_READ_TOOL_NAMES = [
|
|
45651
45880
|
"memory_search",
|
|
@@ -45656,6 +45885,8 @@ function classifyMemoryRead(_event, _ctx, _opts = {}) {
|
|
|
45656
45885
|
}
|
|
45657
45886
|
|
|
45658
45887
|
// src-ts/browser/memory-guard-manager.ts
|
|
45888
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
45889
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
45659
45890
|
var unavailable3 = (name2) => {
|
|
45660
45891
|
throw new Error(`${name2} is not available in the browser bundle`);
|
|
45661
45892
|
};
|
|
@@ -45737,6 +45968,7 @@ function diffMemorySnapshots2(before, after) {
|
|
|
45737
45968
|
export {
|
|
45738
45969
|
Atbash,
|
|
45739
45970
|
AtbashAPIError,
|
|
45971
|
+
BOOT_SYNC_HINT,
|
|
45740
45972
|
DEFAULT_BLOCKCHAIN_RID,
|
|
45741
45973
|
DEFAULT_CHROMIA_NODE_URLS,
|
|
45742
45974
|
DEFAULT_ENDPOINT,
|
|
@@ -45744,11 +45976,14 @@ export {
|
|
|
45744
45976
|
DEFAULT_MEMORY_READ_TOOL_NAMES,
|
|
45745
45977
|
DEFAULT_MEMORY_WRITE_TOOL_NAMES,
|
|
45746
45978
|
EciesDomain,
|
|
45979
|
+
KEY_FILENAMES,
|
|
45747
45980
|
MemoryGuardManager,
|
|
45748
45981
|
MemoryIntegrityError,
|
|
45749
45982
|
PointerStore,
|
|
45750
45983
|
SignatureVerificationError,
|
|
45984
|
+
bootSyncFailureLine,
|
|
45751
45985
|
buildAllowedJudgeHosts,
|
|
45986
|
+
chooseKeyPath,
|
|
45752
45987
|
claimHashHex,
|
|
45753
45988
|
classifyMemoryRead,
|
|
45754
45989
|
classifyMemoryWrite,
|
|
@@ -45783,6 +46018,7 @@ export {
|
|
|
45783
46018
|
isEnvelope,
|
|
45784
46019
|
isValidPrivateKey2 as isValidPrivateKey,
|
|
45785
46020
|
keyFingerprintOf,
|
|
46021
|
+
keyPathCandidates,
|
|
45786
46022
|
loadAgent2 as loadAgent,
|
|
45787
46023
|
loadAgentFromFile,
|
|
45788
46024
|
loadUserConfig,
|