@atbash/sdk 0.13.0-dev.0 → 0.13.3-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/index.mjs CHANGED
@@ -4346,15 +4346,16 @@ var Atbash = class _Atbash {
4346
4346
  }
4347
4347
  /**
4348
4348
  * BRID for an org — one round-trip to the map, honoring the client's chain
4349
- * cache. Returns undefined when the org is unknown, so the caller falls
4350
- * back to the client default (best-effort discovery).
4349
+ * cache. A "brand-new org" (nothing anywhere names its chain) is not an
4350
+ * error — `resolveChainForOrg` returns the client default for that case and
4351
+ * this helper returns its BRID. A transport failure or non-200 from
4352
+ * `/api/org-network` IS an error and propagates: the caller cannot fall
4353
+ * back to the default chain on outage, because with multi-chain live that
4354
+ * silently reads from the wrong chain. Matches the Python binding's
4355
+ * `_brid_for_org` semantics.
4351
4356
  */
4352
4357
  async bridForOrg(orgName) {
4353
- try {
4354
- return (await this.resolveChainForOrg(orgName)).blockchainRid;
4355
- } catch {
4356
- return void 0;
4357
- }
4358
+ return (await this.resolveChainForOrg(orgName)).blockchainRid;
4358
4359
  }
4359
4360
  /**
4360
4361
  * BRID for the client's configured default org, if it has one.
@@ -4648,21 +4649,26 @@ async function scanMemory(entry, auth, opts) {
4648
4649
  }
4649
4650
  const KNOWN_ACTIONS = ["allow", "block", "hold_for_user_confirm"];
4650
4651
  const action = result.actionType.trim().toLowerCase();
4651
- if (result.verdict !== "No verdict" && !KNOWN_ACTIONS.includes(action)) {
4652
+ if (result.verdict !== "No verdict" && action !== "" && !KNOWN_ACTIONS.includes(action)) {
4652
4653
  throw new Error(
4653
- `memory scan: unrecognized action_type from judge (${result.actionType || "absent"})`
4654
+ `memory scan: unrecognized action_type from judge (${result.actionType})`
4654
4655
  );
4655
4656
  }
4656
- const mapped = native.mapVerdict(
4657
- action,
4658
- result.confidence,
4659
- threshold
4660
- );
4661
- let verdict = mapped;
4662
- if (result.verdict === "BLOCK") {
4663
- verdict = "red";
4664
- } else if (result.verdict === "HOLD" && mapped === "green") {
4665
- verdict = "yellow";
4657
+ let verdict;
4658
+ if (action === "") {
4659
+ verdict = result.verdict === "BLOCK" ? "red" : result.verdict === "HOLD" ? "yellow" : "green";
4660
+ } else {
4661
+ const mapped = native.mapVerdict(
4662
+ action,
4663
+ result.confidence,
4664
+ threshold
4665
+ );
4666
+ verdict = mapped;
4667
+ if (result.verdict === "BLOCK") {
4668
+ verdict = "red";
4669
+ } else if (result.verdict === "HOLD" && mapped === "green") {
4670
+ verdict = "yellow";
4671
+ }
4666
4672
  }
4667
4673
  const parsed = native.parseScoreFromReason(result.reason);
4668
4674
  const score = result.score ?? parsed.score ?? native.defaultScoreForVerdict(verdict);
@@ -43004,11 +43010,20 @@ async function rollbackMemory(toId, reason, auth, opts) {
43004
43010
  );
43005
43011
  }
43006
43012
 
43013
+ // src-ts/memory/_json_safe.ts
43014
+ function toJsonSafe(value) {
43015
+ try {
43016
+ return JSON.parse(JSON.stringify(value ?? null));
43017
+ } catch {
43018
+ return null;
43019
+ }
43020
+ }
43021
+
43007
43022
  // src-ts/memory/classifier.ts
43008
43023
  var DEFAULT_MEMORY_WRITE_TOOL_NAMES = native.defaultMemoryWriteToolNames();
43009
43024
  var DEFAULT_MEMORY_PATH_PATTERNS = native.defaultMemoryPathPatterns();
43010
43025
  function classifyMemoryWrite(event, ctx, opts = {}) {
43011
- return native.classifyMemoryWrite(event, ctx, {
43026
+ return native.classifyMemoryWrite(toJsonSafe(event), toJsonSafe(ctx), {
43012
43027
  patterns: opts.patterns ? [...opts.patterns] : void 0,
43013
43028
  toolNames: opts.toolNames ? [...opts.toolNames] : void 0
43014
43029
  });
@@ -43246,7 +43261,7 @@ function defaultPluginLogPath(workspaceDir = process.cwd()) {
43246
43261
  // src-ts/memory/read-classifier.ts
43247
43262
  var DEFAULT_MEMORY_READ_TOOL_NAMES = native.defaultMemoryReadToolNames();
43248
43263
  function classifyMemoryRead(event, ctx, opts = {}) {
43249
- return native.classifyMemoryRead(event, ctx, {
43264
+ return native.classifyMemoryRead(toJsonSafe(event), toJsonSafe(ctx), {
43250
43265
  readToolNames: opts.readToolNames ? [...opts.readToolNames] : void 0,
43251
43266
  patterns: opts.patterns ? [...opts.patterns] : void 0,
43252
43267
  genericReadToolNames: opts.genericReadToolNames ? [...opts.genericReadToolNames] : void 0