@atbash/sdk 0.9.1 → 0.9.2

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
@@ -10054,8 +10054,8 @@ Reporter$3.prototype.wrapResult = function wrapResult(result) {
10054
10054
  errors: state2.errors
10055
10055
  };
10056
10056
  };
10057
- function ReporterError$1(path4, msg) {
10058
- this.path = path4;
10057
+ function ReporterError$1(path3, msg) {
10058
+ this.path = path3;
10059
10059
  this.rethrow(msg);
10060
10060
  }
10061
10061
  inherits$v(ReporterError$1, Error);
@@ -12126,7 +12126,7 @@ function requireBuffer_list() {
12126
12126
  }
12127
12127
  }, {
12128
12128
  key: "join",
12129
- value: function join3(s2) {
12129
+ value: function join2(s2) {
12130
12130
  if (this.length === 0) return "";
12131
12131
  var p = this.head;
12132
12132
  var ret = "" + p.data;
@@ -16208,7 +16208,7 @@ function requireBufferList() {
16208
16208
  this.head = this.tail = null;
16209
16209
  this.length = 0;
16210
16210
  };
16211
- BufferList2.prototype.join = function join3(s2) {
16211
+ BufferList2.prototype.join = function join2(s2) {
16212
16212
  if (this.length === 0) return "";
16213
16213
  var p = this.head;
16214
16214
  var ret = "" + p.data;
@@ -30276,8 +30276,8 @@ Reporter.prototype.wrapResult = function wrapResult2(result) {
30276
30276
  errors: state2.errors
30277
30277
  };
30278
30278
  };
30279
- function ReporterError(path4, msg) {
30280
- this.path = path4;
30279
+ function ReporterError(path3, msg) {
30280
+ this.path = path3;
30281
30281
  this.rethrow(msg);
30282
30282
  }
30283
30283
  inherits(ReporterError, Error);
@@ -30372,7 +30372,7 @@ function requireBuffer() {
30372
30372
  }
30373
30373
  }
30374
30374
  buffer.EncoderBuffer = EncoderBuffer2;
30375
- EncoderBuffer2.prototype.join = function join3(out, offset) {
30375
+ EncoderBuffer2.prototype.join = function join2(out, offset) {
30376
30376
  if (!out)
30377
30377
  out = new Buffer5(this.length);
30378
30378
  if (!offset)
@@ -33307,8 +33307,8 @@ var parseUtil = {};
33307
33307
  const errors_js_12 = errors$3;
33308
33308
  const en_js_12 = __importDefault2(en);
33309
33309
  const makeIssue = (params) => {
33310
- const { data, path: path4, errorMaps, issueData } = params;
33311
- const fullPath = [...path4, ...issueData.path || []];
33310
+ const { data, path: path3, errorMaps, issueData } = params;
33311
+ const fullPath = [...path3, ...issueData.path || []];
33312
33312
  const fullIssue = {
33313
33313
  ...issueData,
33314
33314
  path: fullPath
@@ -33445,11 +33445,11 @@ var errorUtil_js_1 = errorUtil$1;
33445
33445
  var parseUtil_js_1 = parseUtil;
33446
33446
  var util_js_1 = util;
33447
33447
  var ParseInputLazyPath = class {
33448
- constructor(parent, value, path4, key3) {
33448
+ constructor(parent, value, path3, key3) {
33449
33449
  this._cachedPath = [];
33450
33450
  this.parent = parent;
33451
33451
  this.data = value;
33452
- this._path = path4;
33452
+ this._path = path3;
33453
33453
  this._key = key3;
33454
33454
  }
33455
33455
  get path() {
@@ -40355,21 +40355,21 @@ function createTimeoutController(timeout) {
40355
40355
  const timeoutId = setTimeout(() => controller.abort(timeoutError), timeout);
40356
40356
  return { controller, timeoutId };
40357
40357
  }
40358
- function handleRequest(method, path4, endpoint, timeout, postObject) {
40358
+ function handleRequest(method, path3, endpoint, timeout, postObject) {
40359
40359
  return __awaiter$2(this, void 0, void 0, function* () {
40360
40360
  if (method == enums_1$2.Method.GET) {
40361
- return yield get(path4, endpoint, timeout);
40361
+ return yield get(path3, endpoint, timeout);
40362
40362
  } else {
40363
- return yield post(path4, endpoint, timeout, postObject);
40363
+ return yield post(path3, endpoint, timeout, postObject);
40364
40364
  }
40365
40365
  });
40366
40366
  }
40367
- function get(path4, endpoint, timeout) {
40367
+ function get(path3, endpoint, timeout) {
40368
40368
  return __awaiter$2(this, void 0, void 0, function* () {
40369
- logger.debug(`GET URL ${new URL(path4, endpoint).href}`);
40369
+ logger.debug(`GET URL ${new URL(path3, endpoint).href}`);
40370
40370
  try {
40371
40371
  const { controller, timeoutId } = createTimeoutController(timeout);
40372
- const response = yield fetch(new URL(path4, endpoint).href, {
40372
+ const response = yield fetch(new URL(path3, endpoint).href, {
40373
40373
  signal: controller === null || controller === void 0 ? void 0 : controller.signal
40374
40374
  });
40375
40375
  if (timeoutId)
@@ -40407,9 +40407,9 @@ function constructBufferResponseBody(response) {
40407
40407
  return responseText ? responseText : response.statusText;
40408
40408
  });
40409
40409
  }
40410
- function post(path4, endpoint, timeout, requestBody) {
40410
+ function post(path3, endpoint, timeout, requestBody) {
40411
40411
  return __awaiter$2(this, void 0, void 0, function* () {
40412
- logger.debug(`POST URL ${new URL(path4, endpoint).href}`);
40412
+ logger.debug(`POST URL ${new URL(path3, endpoint).href}`);
40413
40413
  logger.debug(`POST body ${JSON.stringify(requestBody)}`);
40414
40414
  if (buffer_1.Buffer.isBuffer(requestBody)) {
40415
40415
  try {
@@ -40423,7 +40423,7 @@ function post(path4, endpoint, timeout, requestBody) {
40423
40423
  },
40424
40424
  signal: controller === null || controller === void 0 ? void 0 : controller.signal
40425
40425
  };
40426
- const response = yield fetch(new URL(path4, endpoint).href, requestOptions);
40426
+ const response = yield fetch(new URL(path3, endpoint).href, requestOptions);
40427
40427
  if (timeoutId)
40428
40428
  clearTimeout(timeoutId);
40429
40429
  const transactionTimestamp = response.headers.get("X-Transaction-Timestamp");
@@ -40434,7 +40434,7 @@ function post(path4, endpoint, timeout, requestBody) {
40434
40434
  } else {
40435
40435
  try {
40436
40436
  const { controller, timeoutId } = createTimeoutController(timeout);
40437
- const response = yield fetch(new URL(path4, endpoint).href, {
40437
+ const response = yield fetch(new URL(path3, endpoint).href, {
40438
40438
  method: "post",
40439
40439
  body: JSON.stringify(requestBody),
40440
40440
  headers: {
@@ -40614,10 +40614,10 @@ function requireFailoverStrategies() {
40614
40614
  }
40615
40615
  }
40616
40616
  function abortOnError(_a2) {
40617
- return __awaiter2(this, arguments, void 0, function* ({ method, path: path4, config: config2, postObject, timeoutOverride }) {
40617
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
40618
40618
  return yield retryRequest({
40619
40619
  method,
40620
- path: path4,
40620
+ path: path3,
40621
40621
  config: config2,
40622
40622
  postObject,
40623
40623
  timeoutOverride,
@@ -40628,10 +40628,10 @@ function requireFailoverStrategies() {
40628
40628
  });
40629
40629
  }
40630
40630
  function tryNextOnError(_a2) {
40631
- return __awaiter2(this, arguments, void 0, function* ({ method, path: path4, config: config2, postObject, timeoutOverride }) {
40631
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
40632
40632
  return yield retryRequest({
40633
40633
  method,
40634
- path: path4,
40634
+ path: path3,
40635
40635
  config: config2,
40636
40636
  postObject,
40637
40637
  timeoutOverride,
@@ -40647,7 +40647,7 @@ function requireFailoverStrategies() {
40647
40647
  return endpointPoolLength - (endpointPoolLength - 1) / 3;
40648
40648
  }
40649
40649
  function queryMajority(_a2) {
40650
- return __awaiter2(this, arguments, void 0, function* ({ method, path: path4, config: config2, postObject, timeoutOverride }) {
40650
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
40651
40651
  var _b;
40652
40652
  const bftMajorityThreshold = calculateBftMajorityThreshold(config2.endpointPool.length);
40653
40653
  const failureThreshold = config2.endpointPool.length - bftMajorityThreshold + 1;
@@ -40658,7 +40658,7 @@ function requireFailoverStrategies() {
40658
40658
  const promises = availableNodes.map((node2) => __awaiter2(this, void 0, void 0, function* () {
40659
40659
  try {
40660
40660
  const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config2.responseTimeout;
40661
- const response = yield (0, httpUtil_1.handleRequest)(method, path4, node2.url, requestTimeout, postObject);
40661
+ const response = yield (0, httpUtil_1.handleRequest)(method, path3, node2.url, requestTimeout, postObject);
40662
40662
  const { statusCode } = response;
40663
40663
  if (statusCode && (0, http_utils_1.isSuccessfulStatusCode)(statusCode)) {
40664
40664
  outcomes.push({ type: "SUCCESS", result: response });
@@ -40705,7 +40705,7 @@ function requireFailoverStrategies() {
40705
40705
  });
40706
40706
  }
40707
40707
  function singleEndpoint(_a2) {
40708
- return __awaiter2(this, arguments, void 0, function* ({ method, path: path4, config: config2, postObject, timeoutOverride }) {
40708
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, timeoutOverride }) {
40709
40709
  let statusCode = null;
40710
40710
  let rspBody = null;
40711
40711
  let error4 = null;
@@ -40716,7 +40716,7 @@ function requireFailoverStrategies() {
40716
40716
  }
40717
40717
  for (let attempt = 0; attempt < config2.attemptsPerEndpoint; attempt++) {
40718
40718
  const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config2.responseTimeout;
40719
- const response = yield (0, httpUtil_1.handleRequest)(method, path4, endpoint.url, requestTimeout, postObject);
40719
+ const response = yield (0, httpUtil_1.handleRequest)(method, path3, endpoint.url, requestTimeout, postObject);
40720
40720
  if (response) {
40721
40721
  ({ error: error4, statusCode, rspBody, transactionTimestamp } = response);
40722
40722
  }
@@ -40731,7 +40731,7 @@ function requireFailoverStrategies() {
40731
40731
  });
40732
40732
  }
40733
40733
  function retryRequest(_a2) {
40734
- return __awaiter2(this, arguments, void 0, function* ({ method, path: path4, config: config2, postObject, useNextNodeOnError, recoveryThreshold, timeoutOverride }) {
40734
+ return __awaiter2(this, arguments, void 0, function* ({ method, path: path3, config: config2, postObject, useNextNodeOnError, recoveryThreshold, timeoutOverride }) {
40735
40735
  var _b, _c, _d;
40736
40736
  let statusCode = null;
40737
40737
  let rspBody = null;
@@ -40742,7 +40742,7 @@ function requireFailoverStrategies() {
40742
40742
  for (const node2 of availableNodes) {
40743
40743
  for (let attempt = 0; attempt < config2.attemptsPerEndpoint; attempt++) {
40744
40744
  const requestTimeout = timeoutOverride !== null && timeoutOverride !== void 0 ? timeoutOverride : config2.responseTimeout;
40745
- const response = yield (0, httpUtil_1.handleRequest)(method, path4, node2.url, requestTimeout, postObject);
40745
+ const response = yield (0, httpUtil_1.handleRequest)(method, path3, node2.url, requestTimeout, postObject);
40746
40746
  error4 = (_b = response === null || response === void 0 ? void 0 : response.error) !== null && _b !== void 0 ? _b : null;
40747
40747
  statusCode = (_c = response === null || response === void 0 ? void 0 : response.statusCode) !== null && _c !== void 0 ? _c : null;
40748
40748
  rspBody = (_d = response === null || response === void 0 ? void 0 : response.rspBody) !== null && _d !== void 0 ? _d : null;
@@ -40885,19 +40885,19 @@ function requireRequestWithFailoverStrategy() {
40885
40885
  const enums_12 = enums;
40886
40886
  const failoverStrategies_1 = requireFailoverStrategies();
40887
40887
  function requestWithFailoverStrategy$1(method_1, path_1, config_1, postObject_1) {
40888
- return __awaiter2(this, arguments, void 0, function* (method, path4, config2, postObject, forceSingleEndpoint = false, timeoutOverride) {
40888
+ return __awaiter2(this, arguments, void 0, function* (method, path3, config2, postObject, forceSingleEndpoint = false, timeoutOverride) {
40889
40889
  switch (config2.failoverStrategy) {
40890
40890
  case enums_12.FailoverStrategy.AbortOnError:
40891
- return yield (0, failoverStrategies_1.abortOnError)({ method, path: path4, config: config2, postObject, timeoutOverride });
40891
+ return yield (0, failoverStrategies_1.abortOnError)({ method, path: path3, config: config2, postObject, timeoutOverride });
40892
40892
  case enums_12.FailoverStrategy.TryNextOnError:
40893
- return yield (0, failoverStrategies_1.tryNextOnError)({ method, path: path4, config: config2, postObject, timeoutOverride });
40893
+ return yield (0, failoverStrategies_1.tryNextOnError)({ method, path: path3, config: config2, postObject, timeoutOverride });
40894
40894
  case enums_12.FailoverStrategy.SingleEndpoint:
40895
- return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path4, config: config2, postObject, timeoutOverride });
40895
+ return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path3, config: config2, postObject, timeoutOverride });
40896
40896
  case enums_12.FailoverStrategy.QueryMajority:
40897
40897
  if (forceSingleEndpoint) {
40898
- return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path4, config: config2, postObject, timeoutOverride });
40898
+ return yield (0, failoverStrategies_1.singleEndpoint)({ method, path: path3, config: config2, postObject, timeoutOverride });
40899
40899
  }
40900
- return yield (0, failoverStrategies_1.queryMajority)({ method, path: path4, config: config2, postObject, timeoutOverride });
40900
+ return yield (0, failoverStrategies_1.queryMajority)({ method, path: path3, config: config2, postObject, timeoutOverride });
40901
40901
  default:
40902
40902
  throw new Error(`Unsupported failover strategy: ${config2.failoverStrategy}`);
40903
40903
  }
@@ -42096,7 +42096,7 @@ var networkSettings = {};
42096
42096
  const restNetworkSettingsValidationContext = RestNetworkSettingsSchema.safeParse(networkSettings2);
42097
42097
  if ("error" in restNetworkSettingsValidationContext) {
42098
42098
  const { error: { issues } = {} } = restNetworkSettingsValidationContext;
42099
- const errorMessage2 = issues === null || issues === void 0 ? void 0 : issues.map(({ message, path: path4 }) => `${path4[0]}: ${message}`).join(", ");
42099
+ const errorMessage2 = issues === null || issues === void 0 ? void 0 : issues.map(({ message, path: path3 }) => `${path3[0]}: ${message}`).join(", ");
42100
42100
  if (throwOnError) {
42101
42101
  throw new Error(errorMessage2);
42102
42102
  }
@@ -44360,6 +44360,13 @@ function buildAllowedJudgeHosts() {
44360
44360
  ]);
44361
44361
  }
44362
44362
  var ALLOWED_JUDGE_HOSTS = buildAllowedJudgeHosts();
44363
+ function isAllowlistedJudgeHost(endpoint) {
44364
+ try {
44365
+ return ALLOWED_JUDGE_HOSTS.has(new URL(endpoint).hostname.toLowerCase());
44366
+ } catch {
44367
+ return false;
44368
+ }
44369
+ }
44363
44370
  function validateJudgeEndpoint(judge) {
44364
44371
  const policy = judge?.policy === "self-hosted" ? "self-hosted" : "default";
44365
44372
  const candidate = judge?.endpoint?.trim() || DEFAULT_ENDPOINT;
@@ -44420,12 +44427,12 @@ var AtbashAPIError = class extends Error {
44420
44427
  * ran does not carry. The path is the fact that settles it.
44421
44428
  */
44422
44429
  path;
44423
- constructor(status, body, statusText = "", endpoint = DEFAULT_ENDPOINT, path4) {
44424
- super(enrich(status, body, statusText, endpoint, path4));
44430
+ constructor(status, body, statusText = "", endpoint = DEFAULT_ENDPOINT, path3) {
44431
+ super(enrich(status, body, statusText, endpoint, path3));
44425
44432
  this.name = "AtbashAPIError";
44426
44433
  this.status = status;
44427
44434
  this.body = body;
44428
- this.path = path4;
44435
+ this.path = path3;
44429
44436
  }
44430
44437
  };
44431
44438
  var SignatureVerificationError = class extends Error {
@@ -44434,9 +44441,9 @@ var SignatureVerificationError = class extends Error {
44434
44441
  this.name = "SignatureVerificationError";
44435
44442
  }
44436
44443
  };
44437
- function enrich(status, body, statusText, endpoint, path4) {
44444
+ function enrich(status, body, statusText, endpoint, path3) {
44438
44445
  const dashboard = endpoint.replace(/\/+$/, "") || DEFAULT_ENDPOINT;
44439
- let msg = `API error ${status}${path4 ? ` from ${path4}` : ""}: ${body || statusText}`;
44446
+ let msg = `API error ${status}${path3 ? ` from ${path3}` : ""}: ${body || statusText}`;
44440
44447
  const lowered = body.toLowerCase();
44441
44448
  if (lowered.includes("agent not registered")) {
44442
44449
  msg += `
@@ -44467,8 +44474,8 @@ var HttpClient = class {
44467
44474
  this.baseUrl = baseUrl.replace(/\/+$/, "");
44468
44475
  this.timeoutMs = timeoutMs;
44469
44476
  }
44470
- buildUrl(path4, query) {
44471
- const url = new URL(this.baseUrl + path4);
44477
+ buildUrl(path3, query) {
44478
+ const url = new URL(this.baseUrl + path3);
44472
44479
  if (query) {
44473
44480
  for (const [k, v] of Object.entries(query)) {
44474
44481
  if (v !== void 0 && v !== null && v !== "") {
@@ -44478,14 +44485,14 @@ var HttpClient = class {
44478
44485
  }
44479
44486
  return url.toString();
44480
44487
  }
44481
- async get(path4, query, headers) {
44482
- return this.fetch(this.buildUrl(path4, query), {
44488
+ async get(path3, query, headers) {
44489
+ return this.fetch(this.buildUrl(path3, query), {
44483
44490
  method: "GET",
44484
44491
  ...headers && { headers }
44485
44492
  });
44486
44493
  }
44487
- async post(path4, body, headers) {
44488
- return this.fetch(this.buildUrl(path4), {
44494
+ async post(path3, body, headers) {
44495
+ return this.fetch(this.buildUrl(path3), {
44489
44496
  method: "POST",
44490
44497
  headers: { "Content-Type": "application/json", ...headers },
44491
44498
  body: JSON.stringify(body)
@@ -44796,16 +44803,23 @@ var Atbash = class _Atbash {
44796
44803
  verifying: this.verifyPubKey ? "with response-signature pubkey configured" : "without signature verification"
44797
44804
  });
44798
44805
  }
44799
- try {
44800
- setupTelemetry({
44801
- enabled: true,
44802
- endpoint: this.endpoint,
44803
- getAuthHeaders: () => this.authHeaders()
44804
- });
44805
- } catch (err) {
44806
- this.logger.warn?.(
44807
- "[atbash] telemetry setup failed \u2014 continuing without metrics",
44808
- { error: String(err) }
44806
+ if (isAllowlistedJudgeHost(this.endpoint)) {
44807
+ try {
44808
+ setupTelemetry({
44809
+ enabled: true,
44810
+ endpoint: this.endpoint,
44811
+ getAuthHeaders: () => this.authHeaders()
44812
+ });
44813
+ } catch (err) {
44814
+ this.logger.warn?.(
44815
+ "[atbash] telemetry setup failed \u2014 continuing without metrics",
44816
+ { error: String(err) }
44817
+ );
44818
+ }
44819
+ } else {
44820
+ this.logger.info?.(
44821
+ "[atbash] telemetry disabled \u2014 the agent bearer is only sent to hosts that already receive it, and this judge endpoint is not one",
44822
+ { endpoint: this.endpoint }
44809
44823
  );
44810
44824
  }
44811
44825
  }
@@ -45625,8 +45639,8 @@ var Atbash = class _Atbash {
45625
45639
  async riskEnginePost(body, network, brid) {
45626
45640
  let resp;
45627
45641
  try {
45628
- const path4 = network ? `/api/risk-engine?network=${encodeURIComponent(network)}` : "/api/risk-engine";
45629
- resp = await this.http.post(path4, body, this.authHeaders(brid));
45642
+ const path3 = network ? `/api/risk-engine?network=${encodeURIComponent(network)}` : "/api/risk-engine";
45643
+ resp = await this.http.post(path3, body, this.authHeaders(brid));
45630
45644
  } catch (err) {
45631
45645
  throw this.transportError(err);
45632
45646
  }
@@ -45866,27 +45880,18 @@ function truncate(text, limit = MAX_ACTION_LEN) {
45866
45880
  return text.slice(0, limit) + "\u2026";
45867
45881
  }
45868
45882
 
45869
- // src-ts/key-path.ts
45883
+ // src-ts/browser/key-path.ts
45870
45884
  init_define_ATBASH_CHROMIA_NODE_URLS();
45871
45885
  init_define_ATBASH_PRIVATE_NODE_URLS();
45872
- import { homedir } from "os";
45873
- import { join as join2 } from "path";
45874
- var KEY_DIR_REL = ".config/atbash";
45875
45886
  var KEY_FILENAMES = ["guard-client-key", "atbash-client-key"];
45876
- function home() {
45877
- return process.env.HOME || homedir() || "";
45878
- }
45879
- function expandHome(p) {
45880
- if (!p.startsWith("~/")) return p;
45881
- return join2(home(), p.slice(2));
45882
- }
45887
+ var unavailable = (name2) => {
45888
+ throw new Error(`${name2} is not available in the browser bundle`);
45889
+ };
45883
45890
  function keyPathCandidates() {
45884
- return KEY_FILENAMES.map((name2) => join2(home(), KEY_DIR_REL, name2));
45891
+ return unavailable("keyPathCandidates");
45885
45892
  }
45886
- function chooseKeyPath(input, exists) {
45887
- if (input) return expandHome(input);
45888
- const candidates = keyPathCandidates();
45889
- return candidates.find(exists) ?? candidates[0];
45893
+ function chooseKeyPath(_input, _exists) {
45894
+ return unavailable("chooseKeyPath");
45890
45895
  }
45891
45896
 
45892
45897
  // src-ts/redact.ts
@@ -46106,127 +46111,12 @@ function classifyMemoryWrite(_event, _ctx, _opts = {}) {
46106
46111
  throw new Error(`classifyMemoryWrite ${STUB_MSG4}`);
46107
46112
  }
46108
46113
 
46109
- // src-ts/memory/guard.ts
46114
+ // src-ts/browser/memory-guard.ts
46110
46115
  init_define_ATBASH_CHROMIA_NODE_URLS();
46111
46116
  init_define_ATBASH_PRIVATE_NODE_URLS();
46112
- import path3 from "path";
46113
- function emitDebugProbe(event, ctx, memEntry, logger2) {
46114
- if (!logger2?.info) return;
46115
- const ev = event ?? {};
46116
- const c = ctx ?? {};
46117
- const argsCandidate = ev.params ?? c.params ?? ev.args ?? c.args ?? ev.arguments ?? c.arguments;
46118
- const argsObj = argsCandidate && typeof argsCandidate === "object" ? argsCandidate : {};
46119
- const argsKeys = Object.keys(argsObj).slice(0, 20);
46120
- const pickedPath = typeof argsObj.file_path === "string" && argsObj.file_path || typeof argsObj.path === "string" && argsObj.path || typeof argsObj.filename === "string" && argsObj.filename || null;
46121
- const editsArr = Array.isArray(argsObj.edits) ? argsObj.edits : null;
46122
- const firstEditKeys = editsArr && editsArr[0] && typeof editsArr[0] === "object" ? Object.keys(editsArr[0]).slice(0, 10) : null;
46123
- const tool = ev.toolName ?? c.tool?.name ?? c.toolName ?? c.name ?? "(none)";
46124
- logger2.info("[atbash][probe] before_tool_call", {
46125
- toolName: tool,
46126
- eventKeys: Object.keys(ev).slice(0, 20),
46127
- ctxKeys: Object.keys(c).slice(0, 20),
46128
- argsKeys,
46129
- pickedPath,
46130
- firstEditKeys,
46131
- editsCount: editsArr?.length,
46132
- memoryWrite: !!memEntry,
46133
- memoryPath: memEntry?.key
46134
- });
46135
- }
46136
- async function guardMemoryWrite(input) {
46137
- const {
46138
- event,
46139
- ctx,
46140
- auth,
46141
- endpoint,
46142
- verifyPubKey,
46143
- orgName,
46144
- threshold,
46145
- patterns,
46146
- toolNames,
46147
- enforce = true,
46148
- debug: debug2 = false,
46149
- logger: logger2
46150
- } = input;
46151
- let memEntry;
46152
- try {
46153
- memEntry = classifyMemoryWrite(event, ctx, { patterns, toolNames });
46154
- } catch (err) {
46155
- const why = err instanceof Error ? err.message : String(err);
46156
- logger2?.warn?.("[atbash] memory classifier refused this tool call's input", { reason: why });
46157
- if (!enforce) return { handled: false };
46158
- return {
46159
- handled: true,
46160
- decision: {
46161
- allow: false,
46162
- block: true,
46163
- reason: `Memory protection could not read this tool call (${why}); blocked because it could not be checked.`
46164
- }
46165
- };
46166
- }
46167
- if (debug2) emitDebugProbe(event, ctx, memEntry, logger2);
46168
- if (!memEntry) return { handled: false };
46169
- let scanResult;
46170
- try {
46171
- scanResult = await scanMemory(memEntry, auth, {
46172
- endpoint,
46173
- verifyPubKey,
46174
- orgName,
46175
- threshold
46176
- });
46177
- } catch (err) {
46178
- const reason = err instanceof Error ? err.message : String(err);
46179
- logger2?.warn?.("[atbash] memory scan failed", {
46180
- path: memEntry.key,
46181
- reason
46182
- });
46183
- return {
46184
- handled: true,
46185
- decision: enforce ? { allow: false, block: true, reason } : { allow: true }
46186
- };
46187
- }
46188
- if (scanResult.verdict === "red") {
46189
- logger2?.warn?.("[atbash] memory BLOCK", {
46190
- path: memEntry.key,
46191
- reason: scanResult.reason
46192
- });
46193
- return {
46194
- handled: true,
46195
- decision: enforce ? { allow: false, block: true, reason: scanResult.reason } : { allow: true },
46196
- scanResult,
46197
- committed: false
46198
- };
46199
- }
46200
- const filePath = path3.basename(memEntry.key);
46201
- commitMemoryVersion(memEntry.value, auth, {
46202
- score: scanResult.score,
46203
- filePath,
46204
- orgName,
46205
- endpoint,
46206
- verifyPubKey
46207
- }).catch((err) => {
46208
- const reason = err instanceof Error ? err.message : String(err);
46209
- logger2?.warn?.("[atbash] memory commit to chain failed", {
46210
- path: memEntry.key,
46211
- filePath,
46212
- reason
46213
- });
46214
- });
46215
- logger2?.info?.(
46216
- scanResult.verdict === "yellow" ? "[atbash] memory HOLD" : "[atbash] memory ALLOW",
46217
- {
46218
- path: memEntry.key,
46219
- filePath,
46220
- score: scanResult.score,
46221
- reason: scanResult.reason
46222
- }
46223
- );
46224
- return {
46225
- handled: true,
46226
- decision: { allow: true },
46227
- scanResult,
46228
- committed: true
46229
- };
46117
+ var STUB_MSG5 = "not available in @atbash/sdk browser bundle \u2014 guard memory writes agent-side";
46118
+ async function guardMemoryWrite(_input) {
46119
+ throw new Error(`guardMemoryWrite ${STUB_MSG5}`);
46230
46120
  }
46231
46121
 
46232
46122
  // src-ts/memory/sync.ts
@@ -46248,7 +46138,7 @@ async function syncLocalMemory(auth, pointer, opts = {}) {
46248
46138
  if (withinTtl) {
46249
46139
  return { drifted: false, checked: false, pointer };
46250
46140
  }
46251
- const currentId = await getActiveMemoryId(auth, opts.chainOpts);
46141
+ const currentId = await getActiveMemoryId(auth, opts.chainOpts, opts.filePath);
46252
46142
  const nextPointer = { activeId: currentId, checkedAt: now };
46253
46143
  if (currentId === pointer.activeId) {
46254
46144
  return { drifted: false, checked: true, pointer: nextPointer };
@@ -46266,7 +46156,7 @@ async function syncLocalMemory(auth, pointer, opts = {}) {
46266
46156
  // src-ts/browser/memory-pointer-store.ts
46267
46157
  init_define_ATBASH_CHROMIA_NODE_URLS();
46268
46158
  init_define_ATBASH_PRIVATE_NODE_URLS();
46269
- var unavailable = (name2) => {
46159
+ var unavailable2 = (name2) => {
46270
46160
  throw new Error(`${name2} is not available in the browser bundle`);
46271
46161
  };
46272
46162
  var PointerStore = class {
@@ -46280,38 +46170,38 @@ var PointerStore = class {
46280
46170
  }
46281
46171
  };
46282
46172
  function defaultPointerPath(_workspaceDir) {
46283
- return unavailable("defaultPointerPath");
46173
+ return unavailable2("defaultPointerPath");
46284
46174
  }
46285
46175
 
46286
46176
  // src-ts/browser/memory-file-logger.ts
46287
46177
  init_define_ATBASH_CHROMIA_NODE_URLS();
46288
46178
  init_define_ATBASH_PRIVATE_NODE_URLS();
46289
- var unavailable2 = (name2) => {
46179
+ var unavailable3 = (name2) => {
46290
46180
  throw new Error(`${name2} is not available in the browser bundle`);
46291
46181
  };
46292
46182
  function createFileLogger(_logFilePath, _hostLogger) {
46293
- return unavailable2("createFileLogger");
46183
+ return unavailable3("createFileLogger");
46294
46184
  }
46295
46185
  function defaultPluginLogPath(_workspaceDir) {
46296
- return unavailable2("defaultPluginLogPath");
46186
+ return unavailable3("defaultPluginLogPath");
46297
46187
  }
46298
46188
 
46299
46189
  // src-ts/browser/memory-read-classifier.ts
46300
46190
  init_define_ATBASH_CHROMIA_NODE_URLS();
46301
46191
  init_define_ATBASH_PRIVATE_NODE_URLS();
46302
- var STUB_MSG5 = "not available in @atbash/sdk browser bundle \u2014 classify memory reads server-side";
46192
+ var STUB_MSG6 = "not available in @atbash/sdk browser bundle \u2014 classify memory reads server-side";
46303
46193
  var DEFAULT_MEMORY_READ_TOOL_NAMES = [
46304
46194
  "memory_search",
46305
46195
  "memory_get"
46306
46196
  ];
46307
46197
  function classifyMemoryRead(_event, _ctx, _opts = {}) {
46308
- throw new Error(`classifyMemoryRead ${STUB_MSG5}`);
46198
+ throw new Error(`classifyMemoryRead ${STUB_MSG6}`);
46309
46199
  }
46310
46200
 
46311
46201
  // src-ts/browser/memory-guard-manager.ts
46312
46202
  init_define_ATBASH_CHROMIA_NODE_URLS();
46313
46203
  init_define_ATBASH_PRIVATE_NODE_URLS();
46314
- var unavailable3 = (name2) => {
46204
+ var unavailable4 = (name2) => {
46315
46205
  throw new Error(`${name2} is not available in the browser bundle`);
46316
46206
  };
46317
46207
  var MemoryGuardManager = class {
@@ -46331,7 +46221,7 @@ var MemoryGuardManager = class {
46331
46221
  }
46332
46222
  };
46333
46223
  function createMemoryGuardManager(_opts) {
46334
- return unavailable3("createMemoryGuardManager");
46224
+ return unavailable4("createMemoryGuardManager");
46335
46225
  }
46336
46226
 
46337
46227
  // src-ts/index.ts