@atbash/sdk 0.20.0-dev.0 → 0.22.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/dist/browser.mjs CHANGED
@@ -33,14 +33,6 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
33
33
  mod2
34
34
  ));
35
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"];
41
- }
42
- });
43
-
44
36
  // <define:__ATBASH_PRIVATE_NODE_URLS__>
45
37
  var define_ATBASH_PRIVATE_NODE_URLS_default;
46
38
  var init_define_ATBASH_PRIVATE_NODE_URLS = __esm({
@@ -53,7 +45,6 @@ var init_define_ATBASH_PRIVATE_NODE_URLS = __esm({
53
45
  var require_buffer = __commonJS({
54
46
  "(disabled):node_modules/buffer/index.js"() {
55
47
  "use strict";
56
- init_define_ATBASH_CHROMIA_NODE_URLS();
57
48
  init_define_ATBASH_PRIVATE_NODE_URLS();
58
49
  }
59
50
  });
@@ -62,7 +53,6 @@ var require_buffer = __commonJS({
62
53
  var require_bn = __commonJS({
63
54
  "node_modules/bn.js/lib/bn.js"(exports, module) {
64
55
  "use strict";
65
- init_define_ATBASH_CHROMIA_NODE_URLS();
66
56
  init_define_ATBASH_PRIVATE_NODE_URLS();
67
57
  (function(module2, exports2) {
68
58
  "use strict";
@@ -2882,27 +2872,21 @@ var require_bn = __commonJS({
2882
2872
  });
2883
2873
 
2884
2874
  // src-ts/index.ts
2885
- init_define_ATBASH_CHROMIA_NODE_URLS();
2886
2875
  init_define_ATBASH_PRIVATE_NODE_URLS();
2887
2876
 
2888
2877
  // src-ts/browser/native.ts
2889
- init_define_ATBASH_CHROMIA_NODE_URLS();
2890
2878
  init_define_ATBASH_PRIVATE_NODE_URLS();
2891
2879
 
2892
2880
  // node_modules/@noble/curves/secp256k1.js
2893
- init_define_ATBASH_CHROMIA_NODE_URLS();
2894
2881
  init_define_ATBASH_PRIVATE_NODE_URLS();
2895
2882
 
2896
2883
  // node_modules/@noble/hashes/sha2.js
2897
- init_define_ATBASH_CHROMIA_NODE_URLS();
2898
2884
  init_define_ATBASH_PRIVATE_NODE_URLS();
2899
2885
 
2900
2886
  // node_modules/@noble/hashes/_md.js
2901
- init_define_ATBASH_CHROMIA_NODE_URLS();
2902
2887
  init_define_ATBASH_PRIVATE_NODE_URLS();
2903
2888
 
2904
2889
  // node_modules/@noble/hashes/utils.js
2905
- init_define_ATBASH_CHROMIA_NODE_URLS();
2906
2890
  init_define_ATBASH_PRIVATE_NODE_URLS();
2907
2891
  function isBytes(a) {
2908
2892
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
@@ -3325,11 +3309,9 @@ var sha256 = /* @__PURE__ */ createHasher(
3325
3309
  );
3326
3310
 
3327
3311
  // node_modules/@noble/curves/abstract/curve.js
3328
- init_define_ATBASH_CHROMIA_NODE_URLS();
3329
3312
  init_define_ATBASH_PRIVATE_NODE_URLS();
3330
3313
 
3331
3314
  // node_modules/@noble/curves/utils.js
3332
- init_define_ATBASH_CHROMIA_NODE_URLS();
3333
3315
  init_define_ATBASH_PRIVATE_NODE_URLS();
3334
3316
  var abytes2 = (value, length, title) => abytes(value, length, title);
3335
3317
  var anumber2 = anumber;
@@ -3483,7 +3465,6 @@ function validateObject(object, fields = {}, optFields = {}) {
3483
3465
  }
3484
3466
 
3485
3467
  // node_modules/@noble/curves/abstract/modular.js
3486
- init_define_ATBASH_CHROMIA_NODE_URLS();
3487
3468
  init_define_ATBASH_PRIVATE_NODE_URLS();
3488
3469
  var _0n2 = /* @__PURE__ */ BigInt(0);
3489
3470
  var _1n2 = /* @__PURE__ */ BigInt(1);
@@ -4133,11 +4114,9 @@ function createKeygen(randomSecretKey, getPublicKey) {
4133
4114
  }
4134
4115
 
4135
4116
  // node_modules/@noble/curves/abstract/weierstrass.js
4136
- init_define_ATBASH_CHROMIA_NODE_URLS();
4137
4117
  init_define_ATBASH_PRIVATE_NODE_URLS();
4138
4118
 
4139
4119
  // node_modules/@noble/hashes/hmac.js
4140
- init_define_ATBASH_CHROMIA_NODE_URLS();
4141
4120
  init_define_ATBASH_PRIVATE_NODE_URLS();
4142
4121
  var _HMAC = class {
4143
4122
  oHash;
@@ -5170,7 +5149,6 @@ var Pointk1 = /* @__PURE__ */ weierstrass(secp256k1_CURVE, {
5170
5149
  var secp256k1 = /* @__PURE__ */ ecdsa(Pointk1, sha256);
5171
5150
 
5172
5151
  // node_modules/postchain-client/built/esm/index.js
5173
- init_define_ATBASH_CHROMIA_NODE_URLS();
5174
5152
  init_define_ATBASH_PRIVATE_NODE_URLS();
5175
5153
  var import_bn = __toESM(require_bn(), 1);
5176
5154
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -43295,9 +43273,7 @@ var index = /* @__PURE__ */ getDefaultExportFromCjs(builtExports);
43295
43273
  // src-ts/browser/native.ts
43296
43274
  var { Buffer: Buffer3, gtx: pcgtx } = index;
43297
43275
  var ATBASH_ENDPOINT = "https://chromia-verified-ai-dev-two.vercel.app";
43298
- var ATBASH_BLOCKCHAIN_RID = "02668C5218871F69A93CC0F7032DCFFE06EF0D35EF2F0B07A92A3D83A3F23A7D";
43299
43276
  var ATBASH_PRIVATE_BLOCKCHAIN_RID = "2603569AE8DC3F254323F719C8D4347BBA964E874E781291F8474236BE8B6493";
43300
- var DEFAULT_CHROMIA_NODE_URLS_ARR = define_ATBASH_CHROMIA_NODE_URLS_default;
43301
43277
  var DEFAULT_PRIVATE_NODE_URLS_ARR = define_ATBASH_PRIVATE_NODE_URLS_default;
43302
43278
  var MERKLE_HASH_VERSION = 2;
43303
43279
  function stripHex(s2) {
@@ -43449,10 +43425,8 @@ var native = {
43449
43425
  deriveMemoryKey,
43450
43426
  encryptMemoryContent,
43451
43427
  decryptMemoryContent,
43452
- DEFAULT_BLOCKCHAIN_RID: ATBASH_BLOCKCHAIN_RID,
43453
43428
  DEFAULT_PRIVATE_BLOCKCHAIN_RID: ATBASH_PRIVATE_BLOCKCHAIN_RID,
43454
43429
  DEFAULT_ENDPOINT: ATBASH_ENDPOINT,
43455
- defaultChromiaNodeUrls: () => [...DEFAULT_CHROMIA_NODE_URLS_ARR],
43456
43430
  defaultPrivateNodeUrls: () => [...DEFAULT_PRIVATE_NODE_URLS_ARR],
43457
43431
  // Server-only surfaces — throw at runtime, keep types satisfied.
43458
43432
  // The memory signers are here and not with the other signing shims because
@@ -43522,11 +43496,9 @@ var native = {
43522
43496
  };
43523
43497
 
43524
43498
  // src-ts/client.ts
43525
- init_define_ATBASH_CHROMIA_NODE_URLS();
43526
43499
  init_define_ATBASH_PRIVATE_NODE_URLS();
43527
43500
 
43528
43501
  // src-ts/random.ts
43529
- init_define_ATBASH_CHROMIA_NODE_URLS();
43530
43502
  init_define_ATBASH_PRIVATE_NODE_URLS();
43531
43503
  function randomBytes4(size) {
43532
43504
  const buf = new Uint8Array(size);
@@ -43543,7 +43515,6 @@ function randomHex(size) {
43543
43515
  }
43544
43516
 
43545
43517
  // src-ts/auth-bearer.ts
43546
- init_define_ATBASH_CHROMIA_NODE_URLS();
43547
43518
  init_define_ATBASH_PRIVATE_NODE_URLS();
43548
43519
  var BEARER_TTL_MS = 4 * 60 * 1e3;
43549
43520
  var bearers = /* @__PURE__ */ new Map();
@@ -43569,47 +43540,36 @@ function agentAuthHeaders(auth, blockchainRid) {
43569
43540
  }
43570
43541
 
43571
43542
  // src-ts/chain-config.ts
43572
- init_define_ATBASH_CHROMIA_NODE_URLS();
43573
43543
  init_define_ATBASH_PRIVATE_NODE_URLS();
43574
-
43575
- // src-ts/constants.ts
43576
- init_define_ATBASH_CHROMIA_NODE_URLS();
43577
- init_define_ATBASH_PRIVATE_NODE_URLS();
43578
- var DEFAULT_ENDPOINT = native.DEFAULT_ENDPOINT;
43579
- var DEFAULT_CHROMIA_NODE_URLS = Object.freeze(
43580
- native.defaultChromiaNodeUrls()
43581
- );
43582
- var DEFAULT_BLOCKCHAIN_RID = native.DEFAULT_BLOCKCHAIN_RID;
43583
-
43584
- // src-ts/chain-config.ts
43585
43544
  var DEFAULT_PRIVATE_NODE_URLS = Object.freeze(
43586
43545
  native.defaultPrivateNodeUrls()
43587
43546
  );
43588
43547
  var DEFAULT_PRIVATE_BLOCKCHAIN_RID = native.DEFAULT_PRIVATE_BLOCKCHAIN_RID;
43589
- var PUBLIC_CHAIN = {
43590
- network: "public",
43591
- blockchainRid: DEFAULT_BLOCKCHAIN_RID,
43592
- nodeUrls: DEFAULT_CHROMIA_NODE_URLS
43593
- };
43594
43548
  var PRIVATE_CHAIN = {
43595
43549
  network: "private",
43596
43550
  blockchainRid: DEFAULT_PRIVATE_BLOCKCHAIN_RID,
43597
43551
  nodeUrls: DEFAULT_PRIVATE_NODE_URLS
43598
43552
  };
43599
43553
  function chainForNetwork(network) {
43600
- return network === "private" ? PRIVATE_CHAIN : PUBLIC_CHAIN;
43554
+ if (network !== "private") {
43555
+ throw new Error(
43556
+ `network must be "private" (the public chain is retired), got ${JSON.stringify(network)}`
43557
+ );
43558
+ }
43559
+ return PRIVATE_CHAIN;
43601
43560
  }
43602
43561
 
43562
+ // src-ts/constants.ts
43563
+ init_define_ATBASH_PRIVATE_NODE_URLS();
43564
+ var DEFAULT_ENDPOINT = native.DEFAULT_ENDPOINT;
43565
+
43603
43566
  // src-ts/browser/encrypted-toolcall.ts
43604
- init_define_ATBASH_CHROMIA_NODE_URLS();
43605
43567
  init_define_ATBASH_PRIVATE_NODE_URLS();
43606
43568
 
43607
43569
  // src-ts/browser/crypto-ecies.ts
43608
- init_define_ATBASH_CHROMIA_NODE_URLS();
43609
43570
  init_define_ATBASH_PRIVATE_NODE_URLS();
43610
43571
 
43611
43572
  // node_modules/@noble/hashes/hkdf.js
43612
- init_define_ATBASH_CHROMIA_NODE_URLS();
43613
43573
  init_define_ATBASH_PRIVATE_NODE_URLS();
43614
43574
  function extract(hash3, ikm, salt) {
43615
43575
  ahash(hash3);
@@ -43651,15 +43611,12 @@ function expand2(hash3, prk, info2, length = 32) {
43651
43611
  var hkdf = (hash3, ikm, salt, info2, length) => expand2(hash3, extract(hash3, ikm, salt), info2, length);
43652
43612
 
43653
43613
  // node_modules/@noble/ciphers/aes.js
43654
- init_define_ATBASH_CHROMIA_NODE_URLS();
43655
43614
  init_define_ATBASH_PRIVATE_NODE_URLS();
43656
43615
 
43657
43616
  // node_modules/@noble/ciphers/_polyval.js
43658
- init_define_ATBASH_CHROMIA_NODE_URLS();
43659
43617
  init_define_ATBASH_PRIVATE_NODE_URLS();
43660
43618
 
43661
43619
  // node_modules/@noble/ciphers/utils.js
43662
- init_define_ATBASH_CHROMIA_NODE_URLS();
43663
43620
  init_define_ATBASH_PRIVATE_NODE_URLS();
43664
43621
  function isBytes3(a) {
43665
43622
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
@@ -44253,7 +44210,6 @@ function encryptedLength(plaintextByteLength) {
44253
44210
  }
44254
44211
 
44255
44212
  // src-ts/crypto/envelope.ts
44256
- init_define_ATBASH_CHROMIA_NODE_URLS();
44257
44213
  init_define_ATBASH_PRIVATE_NODE_URLS();
44258
44214
  var PREFIX = "atb1";
44259
44215
  var SEPARATOR = ".";
@@ -44387,7 +44343,6 @@ function signEncryptedToolCall(toolCallId, action, context, toolName, toolArgsJs
44387
44343
  }
44388
44344
 
44389
44345
  // src-ts/endpoint.ts
44390
- init_define_ATBASH_CHROMIA_NODE_URLS();
44391
44346
  init_define_ATBASH_PRIVATE_NODE_URLS();
44392
44347
  function buildAllowedJudgeHosts() {
44393
44348
  return /* @__PURE__ */ new Set([
@@ -44446,7 +44401,6 @@ function validateJudgeEndpoint(judge) {
44446
44401
  }
44447
44402
 
44448
44403
  // src-ts/errors.ts
44449
- init_define_ATBASH_CHROMIA_NODE_URLS();
44450
44404
  init_define_ATBASH_PRIVATE_NODE_URLS();
44451
44405
  var AtbashAPIError = class extends Error {
44452
44406
  /** HTTP status code (or 0 if the request never completed). */
@@ -44511,7 +44465,6 @@ function enrich(status, body, statusText, endpoint, path3) {
44511
44465
  }
44512
44466
 
44513
44467
  // src-ts/jail-hold.ts
44514
- init_define_ATBASH_CHROMIA_NODE_URLS();
44515
44468
  init_define_ATBASH_PRIVATE_NODE_URLS();
44516
44469
  var DEFAULTS = { ceilingMs: 3e4, pollMs: 1e3 };
44517
44470
  var holds = /* @__PURE__ */ new Map();
@@ -44568,7 +44521,6 @@ function configureJailHold(next) {
44568
44521
  }
44569
44522
 
44570
44523
  // src-ts/http/client.ts
44571
- init_define_ATBASH_CHROMIA_NODE_URLS();
44572
44524
  init_define_ATBASH_PRIVATE_NODE_URLS();
44573
44525
  var HttpClient = class {
44574
44526
  baseUrl;
@@ -44674,7 +44626,6 @@ function classifyTransportError(err, url, method, timeoutMs) {
44674
44626
  }
44675
44627
 
44676
44628
  // src-ts/browser/keyLoader.ts
44677
- init_define_ATBASH_CHROMIA_NODE_URLS();
44678
44629
  init_define_ATBASH_PRIVATE_NODE_URLS();
44679
44630
  var NOT_AVAILABLE = "keyLoader is not available in the browser bundle \u2014 pass `agentKey` explicitly to Atbash.fromConfig or use `new Atbash(privkey, opts)`.";
44680
44631
  function resolveKeyPath(_input) {
@@ -44685,11 +44636,9 @@ function loadAgentFromFile(_keyPath) {
44685
44636
  }
44686
44637
 
44687
44638
  // src-ts/decision.ts
44688
- init_define_ATBASH_CHROMIA_NODE_URLS();
44689
44639
  init_define_ATBASH_PRIVATE_NODE_URLS();
44690
44640
 
44691
44641
  // src-ts/normalize.ts
44692
- init_define_ATBASH_CHROMIA_NODE_URLS();
44693
44642
  init_define_ATBASH_PRIVATE_NODE_URLS();
44694
44643
  function wireText(raw2, fallback = "") {
44695
44644
  if (raw2 === null || raw2 === void 0) return fallback;
@@ -44801,7 +44750,6 @@ function canonicalAllow(data) {
44801
44750
  }
44802
44751
 
44803
44752
  // src-ts/opentel/events.ts
44804
- init_define_ATBASH_CHROMIA_NODE_URLS();
44805
44753
  init_define_ATBASH_PRIVATE_NODE_URLS();
44806
44754
  var SLOW_MS = 1500;
44807
44755
  var SUCCESS_SAMPLE_RATE = 10;
@@ -44857,7 +44805,6 @@ function recordEvent(e) {
44857
44805
  }
44858
44806
 
44859
44807
  // src-ts/browser/opentel/telemetry.ts
44860
- init_define_ATBASH_CHROMIA_NODE_URLS();
44861
44808
  init_define_ATBASH_PRIVATE_NODE_URLS();
44862
44809
  function setupTelemetry(_config) {
44863
44810
  }
@@ -44871,7 +44818,6 @@ async function shutdownTelemetry() {
44871
44818
  }
44872
44819
 
44873
44820
  // src-ts/browser/userConfig.ts
44874
- init_define_ATBASH_CHROMIA_NODE_URLS();
44875
44821
  init_define_ATBASH_PRIVATE_NODE_URLS();
44876
44822
  var NOT_AVAILABLE2 = "userConfig file I/O is not available in the browser bundle.";
44877
44823
  function getConfigDir() {
@@ -44890,7 +44836,7 @@ function resolve(_key, flagValue) {
44890
44836
  return flagValue ?? "";
44891
44837
  }
44892
44838
  function forcedChainNetwork(flagValue) {
44893
- return flagValue === "public" || flagValue === "private" ? flagValue : void 0;
44839
+ return flagValue === "private" ? flagValue : void 0;
44894
44840
  }
44895
44841
  function agentKeyFromEnv() {
44896
44842
  return "";
@@ -44910,15 +44856,13 @@ function resolveConstructorChain(options) {
44910
44856
  const hasBrid = options.blockchainRid !== void 0;
44911
44857
  if (hasNodeUrls !== hasBrid) {
44912
44858
  throw new Error(
44913
- 'nodeUrls and blockchainRid must be provided together \u2014 passing one without the other 404s every chain request. Prefer `chain: PUBLIC_CHAIN | PRIVATE_CHAIN` or `network: "public" | "private"`.'
44859
+ 'nodeUrls and blockchainRid must be provided together \u2014 passing one without the other 404s every chain request. Prefer `chain: PRIVATE_CHAIN` or `network: "private"`.'
44914
44860
  );
44915
44861
  }
44916
44862
  if (hasNodeUrls && hasBrid) {
44917
- const brid = options.blockchainRid;
44918
- const derivedNetwork = options.network ?? (brid === PUBLIC_CHAIN.blockchainRid ? "public" : brid === PRIVATE_CHAIN.blockchainRid ? "private" : "private");
44919
44863
  return {
44920
- network: derivedNetwork,
44921
- blockchainRid: brid,
44864
+ network: "private",
44865
+ blockchainRid: options.blockchainRid,
44922
44866
  nodeUrls: options.nodeUrls
44923
44867
  };
44924
44868
  }
@@ -45058,10 +45002,9 @@ var Atbash = class _Atbash {
45058
45002
  _Atbash.environmentLogged = true;
45059
45003
  const brief = (rid) => rid ? `${rid.slice(0, 8)}\u2026` : "(unset)";
45060
45004
  this.logger.info?.(
45061
- `[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"}`,
45005
+ `[atbash] environment \u2014 judge=${this.endpoint} privateChain=${brief(native.DEFAULT_PRIVATE_BLOCKCHAIN_RID)} activeChain=${brief(this.blockchainRid)} responseSignatureCheck=${this.verifyPubKey ? "on" : "off"}`,
45062
45006
  {
45063
45007
  judgeEndpoint: this.endpoint,
45064
- publicBlockchainRid: native.DEFAULT_BLOCKCHAIN_RID,
45065
45008
  privateBlockchainRid: native.DEFAULT_PRIVATE_BLOCKCHAIN_RID,
45066
45009
  activeBlockchainRid: this.blockchainRid,
45067
45010
  responseSignatureCheck: Boolean(this.verifyPubKey)
@@ -45334,7 +45277,9 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45334
45277
  const startedAt = Date.now();
45335
45278
  let chainOpts = options.chainOpts;
45336
45279
  if (options.orgName && this._explicitChain) {
45337
- chainOpts = options.chainOpts ?? { network: this._defaultChain.network };
45280
+ chainOpts = options.chainOpts ?? {
45281
+ blockchainRid: this._defaultChain.blockchainRid
45282
+ };
45338
45283
  } else if (options.orgName && this.forcedNetwork()) {
45339
45284
  chainOpts = { network: this.forcedNetwork() };
45340
45285
  } else if (options.orgName) {
@@ -45344,8 +45289,7 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45344
45289
  } else {
45345
45290
  const mapNetwork = await this.getActiveNetworkForOrg(options.orgName);
45346
45291
  if (mapNetwork) {
45347
- const chain = mapNetwork === "private" ? PRIVATE_CHAIN : PUBLIC_CHAIN;
45348
- this._chainCache.set(options.orgName, chain);
45292
+ this._chainCache.set(options.orgName, chainForNetwork(mapNetwork));
45349
45293
  chainOpts = { network: mapNetwork };
45350
45294
  } else if (!chainOpts?.blockchainRid) {
45351
45295
  const resolved = await this.resolveChainFromMap(
@@ -45691,15 +45635,19 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45691
45635
  }
45692
45636
  const parsed = tryParseJson(bytes.toString("utf-8"));
45693
45637
  const data = isRecord2(parsed) ? parsed : {};
45638
+ const rawId = data.tool_call_id ?? data.judgmentId;
45639
+ const statedId = wireText(rawId);
45640
+ const sameCall = rawId === void 0 || rawId === null || statedId === judgmentId;
45694
45641
  return {
45695
45642
  status: normalizeStatus(data.status),
45696
45643
  verdict: normalizeVerdict(data.verdict),
45697
- allow: this.executable(data),
45644
+ allow: sameCall && this.executable(data),
45698
45645
  reason: wireText(data.reason),
45699
- judgmentId: wireText(data.judgmentId, judgmentId),
45646
+ judgmentId: statedId || judgmentId,
45700
45647
  onChain: optBool(data.onChain),
45701
45648
  cached: optBool(data.cached),
45702
- responseTimeMs: optNumber(data.responseTimeMs)
45649
+ // The Dashboard sends response_time_ms; responseTimeMs is the spec name.
45650
+ responseTimeMs: optNumber(data.responseTimeMs ?? data.response_time_ms)
45703
45651
  };
45704
45652
  });
45705
45653
  }
@@ -45883,21 +45831,16 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45883
45831
  }
45884
45832
  if (resp.status !== 200) throw await this.httpError(resp);
45885
45833
  const data = await this.json(resp);
45886
- if (data?.network === "public" || data?.network === "private") {
45887
- return data.network;
45888
- }
45834
+ if (data?.network === "private") return data.network;
45889
45835
  return null;
45890
45836
  }
45891
45837
  /**
45892
45838
  * Resolve which chain an org's actions should run against. Cached
45893
45839
  * per-client by orgName. Resolution order:
45894
45840
  * 1. `org_networks` map (authoritative).
45895
- * 2. Per-chain subscription fallback — public + private records
45896
- * are fetched in parallel, with `is_private_blockchain` and
45897
- * `assigned_at` reconciling mixed states.
45898
- * A lookup that names exactly one chain wins outright. Where it names
45899
- * neither (a brand-new org) or cannot choose between them, the client's
45900
- * configured default decides.
45841
+ * 2. Subscription fallback — the org's subscription row on the chain.
45842
+ * A lookup that finds the org wins outright. Where it finds nothing (a
45843
+ * brand-new org), the client's configured default decides.
45901
45844
  */
45902
45845
  async resolveChainForOrg(orgName) {
45903
45846
  const name2 = orgName.trim();
@@ -45919,35 +45862,14 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45919
45862
  const cached = this._chainCache.get(orgName);
45920
45863
  if (cached) return cached;
45921
45864
  if (mapNetwork) {
45922
- const chain = mapNetwork === "private" ? PRIVATE_CHAIN : PUBLIC_CHAIN;
45923
- this._chainCache.set(orgName, chain);
45924
- return chain;
45925
- }
45926
- const [pubRes, privRes] = await Promise.allSettled([
45927
- this.getOrgSubscription(orgName, "public"),
45928
- this.getOrgSubscription(orgName, "private")
45929
- ]);
45930
- const pubSub = pubRes.status === "fulfilled" ? pubRes.value : null;
45931
- const privSub = privRes.status === "fulfilled" ? privRes.value : null;
45932
- const failure = pubRes.status === "rejected" ? pubRes.reason : privRes.status === "rejected" ? privRes.reason : null;
45933
- if (pubSub?.is_private_blockchain) {
45934
- this._chainCache.set(orgName, PRIVATE_CHAIN);
45935
- return PRIVATE_CHAIN;
45936
- }
45937
- if (pubSub && privSub) {
45938
- const chain = privSub.assigned_at === pubSub.assigned_at ? this._defaultChain : privSub.assigned_at > pubSub.assigned_at ? PRIVATE_CHAIN : PUBLIC_CHAIN;
45865
+ const chain = chainForNetwork(mapNetwork);
45939
45866
  this._chainCache.set(orgName, chain);
45940
45867
  return chain;
45941
45868
  }
45942
- if (pubSub) {
45943
- this._chainCache.set(orgName, PUBLIC_CHAIN);
45944
- return PUBLIC_CHAIN;
45945
- }
45946
- if (privSub?.is_private_blockchain) {
45947
- this._chainCache.set(orgName, PRIVATE_CHAIN);
45948
- return PRIVATE_CHAIN;
45949
- }
45950
- if (failure) {
45869
+ let privSub;
45870
+ try {
45871
+ privSub = await this.getOrgSubscription(orgName, "private");
45872
+ } catch (failure) {
45951
45873
  const detail = failure instanceof Error ? failure.message : String(failure);
45952
45874
  throw new AtbashAPIError(
45953
45875
  failure instanceof AtbashAPIError ? failure.status : 0,
@@ -45956,6 +45878,10 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
45956
45878
  this.endpoint
45957
45879
  );
45958
45880
  }
45881
+ if (privSub) {
45882
+ this._chainCache.set(orgName, PRIVATE_CHAIN);
45883
+ return PRIVATE_CHAIN;
45884
+ }
45959
45885
  this._chainCache.set(orgName, this._defaultChain);
45960
45886
  return this._defaultChain;
45961
45887
  }
@@ -46012,8 +45938,7 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
46012
45938
  */
46013
45939
  bridFromChainOpts(chainOpts) {
46014
45940
  if (chainOpts?.blockchainRid) return chainOpts.blockchainRid;
46015
- if (chainOpts?.network === "private") return PRIVATE_CHAIN.blockchainRid;
46016
- if (chainOpts?.network === "public") return PUBLIC_CHAIN.blockchainRid;
45941
+ if (chainOpts?.network) return chainForNetwork(chainOpts.network).blockchainRid;
46017
45942
  return this.blockchainRid;
46018
45943
  }
46019
45944
  /**
@@ -46373,7 +46298,6 @@ function truncate(text, limit = MAX_ACTION_LEN) {
46373
46298
  }
46374
46299
 
46375
46300
  // src-ts/browser/key-path.ts
46376
- init_define_ATBASH_CHROMIA_NODE_URLS();
46377
46301
  init_define_ATBASH_PRIVATE_NODE_URLS();
46378
46302
  var KEY_FILENAMES = ["guard-client-key", "atbash-client-key"];
46379
46303
  var unavailable = (name2) => {
@@ -46387,7 +46311,6 @@ function chooseKeyPath(_input, _exists) {
46387
46311
  }
46388
46312
 
46389
46313
  // src-ts/redact.ts
46390
- init_define_ATBASH_CHROMIA_NODE_URLS();
46391
46314
  init_define_ATBASH_PRIVATE_NODE_URLS();
46392
46315
  function redactJsonStrings(value) {
46393
46316
  if (typeof value === "string") {
@@ -46407,7 +46330,6 @@ function redactJsonStrings(value) {
46407
46330
  }
46408
46331
 
46409
46332
  // src-ts/signature.ts
46410
- init_define_ATBASH_CHROMIA_NODE_URLS();
46411
46333
  init_define_ATBASH_PRIVATE_NODE_URLS();
46412
46334
  function verifyJudgeResponseSignature(bodyBytes, signatureHex, pubKeyHex) {
46413
46335
  if (!signatureHex) {
@@ -46431,7 +46353,6 @@ function verifyJudgeResponseSignature(bodyBytes, signatureHex, pubKeyHex) {
46431
46353
  }
46432
46354
 
46433
46355
  // src-ts/memory/boot-sync-message.ts
46434
- init_define_ATBASH_CHROMIA_NODE_URLS();
46435
46356
  init_define_ATBASH_PRIVATE_NODE_URLS();
46436
46357
  var BOOT_SYNC_HINT = "check the chain endpoint and orgName if the cause above does not explain it";
46437
46358
  function bootSyncFailureLine(cause) {
@@ -46444,11 +46365,9 @@ function bootSyncFailureLine(cause) {
46444
46365
  }
46445
46366
 
46446
46367
  // src-ts/memory/index.ts
46447
- init_define_ATBASH_CHROMIA_NODE_URLS();
46448
46368
  init_define_ATBASH_PRIVATE_NODE_URLS();
46449
46369
 
46450
46370
  // src-ts/browser/memory-crypto.ts
46451
- init_define_ATBASH_CHROMIA_NODE_URLS();
46452
46371
  init_define_ATBASH_PRIVATE_NODE_URLS();
46453
46372
  var { Buffer: Buffer4 } = index;
46454
46373
  var HKDF_INFO = new TextEncoder().encode("atbash:memory-encryption");
@@ -46524,7 +46443,6 @@ async function decryptMemoryContent2(ciphertext, nonce, key3) {
46524
46443
  }
46525
46444
 
46526
46445
  // src-ts/browser/memory-scan.ts
46527
- init_define_ATBASH_CHROMIA_NODE_URLS();
46528
46446
  init_define_ATBASH_PRIVATE_NODE_URLS();
46529
46447
  var STUB_MSG2 = "not available in @atbash/sdk browser bundle \u2014 scan memory server-side";
46530
46448
  async function scanMemory(_entry, _auth, _opts) {
@@ -46535,7 +46453,6 @@ async function scanMemoryBatch(_entries, _auth, _opts) {
46535
46453
  }
46536
46454
 
46537
46455
  // src-ts/browser/memory-chain.ts
46538
- init_define_ATBASH_CHROMIA_NODE_URLS();
46539
46456
  init_define_ATBASH_PRIVATE_NODE_URLS();
46540
46457
  var STUB_MSG3 = "not available in @atbash/sdk browser bundle \u2014 commit/rollback memory server-side";
46541
46458
  async function commitMemoryVersion(_plaintext, _auth, _opts) {
@@ -46550,7 +46467,7 @@ async function getRecentAgentMemory(_auth, _chainOpts) {
46550
46467
  async function getActiveAgentMemory(_auth, _chainOpts) {
46551
46468
  throw new Error(`getActiveAgentMemory ${STUB_MSG3}`);
46552
46469
  }
46553
- async function getMemoryHistory(_auth, _chainOpts) {
46470
+ async function getMemoryHistory(_auth, _chainOpts, _filePath, _page) {
46554
46471
  throw new Error(`getMemoryHistory ${STUB_MSG3}`);
46555
46472
  }
46556
46473
  async function getMemoryById(_id, _auth, _chainOpts) {
@@ -46564,7 +46481,6 @@ async function rollbackMemory(_toId, _reason, _auth, _opts) {
46564
46481
  }
46565
46482
 
46566
46483
  // src-ts/browser/memory-classifier.ts
46567
- init_define_ATBASH_CHROMIA_NODE_URLS();
46568
46484
  init_define_ATBASH_PRIVATE_NODE_URLS();
46569
46485
  var STUB_MSG4 = "not available in @atbash/sdk browser bundle \u2014 classify memory writes server-side";
46570
46486
  var DEFAULT_MEMORY_WRITE_TOOL_NAMES = [
@@ -46588,7 +46504,6 @@ function classifyMemoryWrite(_event, _ctx, _opts = {}) {
46588
46504
  }
46589
46505
 
46590
46506
  // src-ts/browser/memory-guard.ts
46591
- init_define_ATBASH_CHROMIA_NODE_URLS();
46592
46507
  init_define_ATBASH_PRIVATE_NODE_URLS();
46593
46508
  var STUB_MSG5 = "not available in @atbash/sdk browser bundle \u2014 guard memory writes agent-side";
46594
46509
  async function guardMemoryWrite(_input) {
@@ -46596,7 +46511,6 @@ async function guardMemoryWrite(_input) {
46596
46511
  }
46597
46512
 
46598
46513
  // src-ts/browser/memory-slot.ts
46599
- init_define_ATBASH_CHROMIA_NODE_URLS();
46600
46514
  init_define_ATBASH_PRIVATE_NODE_URLS();
46601
46515
  var unavailable2 = (name2) => {
46602
46516
  throw new Error(`${name2} is not available in the browser bundle`);
@@ -46606,7 +46520,6 @@ function memorySlotOf(_target, _home, _root2, _extraHomes, _p) {
46606
46520
  }
46607
46521
 
46608
46522
  // src-ts/memory/sync.ts
46609
- init_define_ATBASH_CHROMIA_NODE_URLS();
46610
46523
  init_define_ATBASH_PRIVATE_NODE_URLS();
46611
46524
  var MemoryIntegrityError = class extends Error {
46612
46525
  constructor(id, reason) {
@@ -46640,7 +46553,6 @@ async function syncLocalMemory(auth, pointer, opts = {}) {
46640
46553
  }
46641
46554
 
46642
46555
  // src-ts/browser/memory-pointer-store.ts
46643
- init_define_ATBASH_CHROMIA_NODE_URLS();
46644
46556
  init_define_ATBASH_PRIVATE_NODE_URLS();
46645
46557
  var unavailable3 = (name2) => {
46646
46558
  throw new Error(`${name2} is not available in the browser bundle`);
@@ -46660,7 +46572,6 @@ function defaultPointerPath(_workspaceDir) {
46660
46572
  }
46661
46573
 
46662
46574
  // src-ts/browser/memory-file-logger.ts
46663
- init_define_ATBASH_CHROMIA_NODE_URLS();
46664
46575
  init_define_ATBASH_PRIVATE_NODE_URLS();
46665
46576
  var unavailable4 = (name2) => {
46666
46577
  throw new Error(`${name2} is not available in the browser bundle`);
@@ -46673,7 +46584,6 @@ function defaultPluginLogPath(_workspaceDir) {
46673
46584
  }
46674
46585
 
46675
46586
  // src-ts/browser/memory-read-classifier.ts
46676
- init_define_ATBASH_CHROMIA_NODE_URLS();
46677
46587
  init_define_ATBASH_PRIVATE_NODE_URLS();
46678
46588
  var STUB_MSG6 = "not available in @atbash/sdk browser bundle \u2014 classify memory reads server-side";
46679
46589
  var DEFAULT_MEMORY_READ_TOOL_NAMES = [
@@ -46685,7 +46595,6 @@ function classifyMemoryRead(_event, _ctx, _opts = {}) {
46685
46595
  }
46686
46596
 
46687
46597
  // src-ts/browser/memory-guard-manager.ts
46688
- init_define_ATBASH_CHROMIA_NODE_URLS();
46689
46598
  init_define_ATBASH_PRIVATE_NODE_URLS();
46690
46599
  var unavailable5 = (name2) => {
46691
46600
  throw new Error(`${name2} is not available in the browser bundle`);
@@ -46769,8 +46678,6 @@ export {
46769
46678
  Atbash,
46770
46679
  AtbashAPIError,
46771
46680
  BOOT_SYNC_HINT,
46772
- DEFAULT_BLOCKCHAIN_RID,
46773
- DEFAULT_CHROMIA_NODE_URLS,
46774
46681
  DEFAULT_ENDPOINT,
46775
46682
  DEFAULT_MEMORY_PATH_PATTERNS,
46776
46683
  DEFAULT_MEMORY_READ_TOOL_NAMES,
@@ -46783,7 +46690,6 @@ export {
46783
46690
  MemoryGuardManager,
46784
46691
  MemoryIntegrityError,
46785
46692
  PRIVATE_CHAIN,
46786
- PUBLIC_CHAIN,
46787
46693
  PointerStore,
46788
46694
  SignatureVerificationError,
46789
46695
  bootSyncFailureLine,