@atbash/sdk 0.15.0-dev.0 → 0.15.2-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 +22 -0
- package/dist/browser.mjs +0 -1
- package/dist/index.d.mts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +64 -3
- package/dist/index.mjs +64 -3
- package/package.json +6 -6
- package/dist/browser.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/browser.d.mts
CHANGED
|
@@ -1320,7 +1320,29 @@ declare class MemoryGuardManager {
|
|
|
1320
1320
|
private readonly rollbackMinScore;
|
|
1321
1321
|
private readonly enforce;
|
|
1322
1322
|
private readonly agentPubkeyHex;
|
|
1323
|
+
/**
|
|
1324
|
+
* Memoized org→chain resolution. Reads have to hit the SAME chain
|
|
1325
|
+
* writes did, so an org-scoped guard must resolve `orgName` to
|
|
1326
|
+
* network exactly like `commitMemoryVersion` does. Without this
|
|
1327
|
+
* cache the read path would either (a) hit the SDK-default chain
|
|
1328
|
+
* every time — silently returning "no active memory on chain" when
|
|
1329
|
+
* writes landed on the org's actual chain, or (b) hammer
|
|
1330
|
+
* `/api/org-network` on every read. `undefined` means "not yet
|
|
1331
|
+
* resolved"; a resolved `null` means "no org / use raw chainOpts".
|
|
1332
|
+
*/
|
|
1333
|
+
private _resolvedChainOpts;
|
|
1334
|
+
private _resolveChainInflight?;
|
|
1323
1335
|
constructor(opts: MemoryGuardManagerOptions);
|
|
1336
|
+
/**
|
|
1337
|
+
* Resolve `orgName` → chain once, cache forever. `commitMemoryVersion`
|
|
1338
|
+
* already does this for writes; without the same call on the read
|
|
1339
|
+
* path, a client on the SDK's baked default chain reads from the wrong
|
|
1340
|
+
* chain and reports "no active memory" for an agent whose writes did
|
|
1341
|
+
* land — on the org's actual chain. An explicit `chainOpts.blockchainRid`
|
|
1342
|
+
* still wins (caller vouched for it); everything else honors the
|
|
1343
|
+
* dashboard's `org_networks` map.
|
|
1344
|
+
*/
|
|
1345
|
+
private resolveChainOpts;
|
|
1324
1346
|
/**
|
|
1325
1347
|
* One-shot chain probe at plugin registration. Refreshes MEMORY.md
|
|
1326
1348
|
* from chain when drifted and score passes threshold. Fire-and-forget
|
package/dist/browser.mjs
CHANGED
|
@@ -46452,4 +46452,3 @@ postchain-client/built/esm/index.js:
|
|
|
46452
46452
|
@noble/ciphers/utils.js:
|
|
46453
46453
|
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
|
|
46454
46454
|
*/
|
|
46455
|
-
//# sourceMappingURL=browser.mjs.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1320,7 +1320,29 @@ declare class MemoryGuardManager {
|
|
|
1320
1320
|
private readonly rollbackMinScore;
|
|
1321
1321
|
private readonly enforce;
|
|
1322
1322
|
private readonly agentPubkeyHex;
|
|
1323
|
+
/**
|
|
1324
|
+
* Memoized org→chain resolution. Reads have to hit the SAME chain
|
|
1325
|
+
* writes did, so an org-scoped guard must resolve `orgName` to
|
|
1326
|
+
* network exactly like `commitMemoryVersion` does. Without this
|
|
1327
|
+
* cache the read path would either (a) hit the SDK-default chain
|
|
1328
|
+
* every time — silently returning "no active memory on chain" when
|
|
1329
|
+
* writes landed on the org's actual chain, or (b) hammer
|
|
1330
|
+
* `/api/org-network` on every read. `undefined` means "not yet
|
|
1331
|
+
* resolved"; a resolved `null` means "no org / use raw chainOpts".
|
|
1332
|
+
*/
|
|
1333
|
+
private _resolvedChainOpts;
|
|
1334
|
+
private _resolveChainInflight?;
|
|
1323
1335
|
constructor(opts: MemoryGuardManagerOptions);
|
|
1336
|
+
/**
|
|
1337
|
+
* Resolve `orgName` → chain once, cache forever. `commitMemoryVersion`
|
|
1338
|
+
* already does this for writes; without the same call on the read
|
|
1339
|
+
* path, a client on the SDK's baked default chain reads from the wrong
|
|
1340
|
+
* chain and reports "no active memory" for an agent whose writes did
|
|
1341
|
+
* land — on the org's actual chain. An explicit `chainOpts.blockchainRid`
|
|
1342
|
+
* still wins (caller vouched for it); everything else honors the
|
|
1343
|
+
* dashboard's `org_networks` map.
|
|
1344
|
+
*/
|
|
1345
|
+
private resolveChainOpts;
|
|
1324
1346
|
/**
|
|
1325
1347
|
* One-shot chain probe at plugin registration. Refreshes MEMORY.md
|
|
1326
1348
|
* from chain when drifted and score passes threshold. Fire-and-forget
|
package/dist/index.d.ts
CHANGED
|
@@ -1320,7 +1320,29 @@ declare class MemoryGuardManager {
|
|
|
1320
1320
|
private readonly rollbackMinScore;
|
|
1321
1321
|
private readonly enforce;
|
|
1322
1322
|
private readonly agentPubkeyHex;
|
|
1323
|
+
/**
|
|
1324
|
+
* Memoized org→chain resolution. Reads have to hit the SAME chain
|
|
1325
|
+
* writes did, so an org-scoped guard must resolve `orgName` to
|
|
1326
|
+
* network exactly like `commitMemoryVersion` does. Without this
|
|
1327
|
+
* cache the read path would either (a) hit the SDK-default chain
|
|
1328
|
+
* every time — silently returning "no active memory on chain" when
|
|
1329
|
+
* writes landed on the org's actual chain, or (b) hammer
|
|
1330
|
+
* `/api/org-network` on every read. `undefined` means "not yet
|
|
1331
|
+
* resolved"; a resolved `null` means "no org / use raw chainOpts".
|
|
1332
|
+
*/
|
|
1333
|
+
private _resolvedChainOpts;
|
|
1334
|
+
private _resolveChainInflight?;
|
|
1323
1335
|
constructor(opts: MemoryGuardManagerOptions);
|
|
1336
|
+
/**
|
|
1337
|
+
* Resolve `orgName` → chain once, cache forever. `commitMemoryVersion`
|
|
1338
|
+
* already does this for writes; without the same call on the read
|
|
1339
|
+
* path, a client on the SDK's baked default chain reads from the wrong
|
|
1340
|
+
* chain and reports "no active memory" for an agent whose writes did
|
|
1341
|
+
* land — on the org's actual chain. An explicit `chainOpts.blockchainRid`
|
|
1342
|
+
* still wins (caller vouched for it); everything else honors the
|
|
1343
|
+
* dashboard's `org_networks` map.
|
|
1344
|
+
*/
|
|
1345
|
+
private resolveChainOpts;
|
|
1324
1346
|
/**
|
|
1325
1347
|
* One-shot chain probe at plugin registration. Refreshes MEMORY.md
|
|
1326
1348
|
* from chain when drifted and score passes threshold. Fire-and-forget
|
package/dist/index.js
CHANGED
|
@@ -43434,6 +43434,66 @@ var MemoryGuardManager = class {
|
|
|
43434
43434
|
rollbackMinScore;
|
|
43435
43435
|
enforce;
|
|
43436
43436
|
agentPubkeyHex;
|
|
43437
|
+
/**
|
|
43438
|
+
* Memoized org→chain resolution. Reads have to hit the SAME chain
|
|
43439
|
+
* writes did, so an org-scoped guard must resolve `orgName` to
|
|
43440
|
+
* network exactly like `commitMemoryVersion` does. Without this
|
|
43441
|
+
* cache the read path would either (a) hit the SDK-default chain
|
|
43442
|
+
* every time — silently returning "no active memory on chain" when
|
|
43443
|
+
* writes landed on the org's actual chain, or (b) hammer
|
|
43444
|
+
* `/api/org-network` on every read. `undefined` means "not yet
|
|
43445
|
+
* resolved"; a resolved `null` means "no org / use raw chainOpts".
|
|
43446
|
+
*/
|
|
43447
|
+
_resolvedChainOpts = void 0;
|
|
43448
|
+
_resolveChainInflight;
|
|
43449
|
+
/**
|
|
43450
|
+
* Resolve `orgName` → chain once, cache forever. `commitMemoryVersion`
|
|
43451
|
+
* already does this for writes; without the same call on the read
|
|
43452
|
+
* path, a client on the SDK's baked default chain reads from the wrong
|
|
43453
|
+
* chain and reports "no active memory" for an agent whose writes did
|
|
43454
|
+
* land — on the org's actual chain. An explicit `chainOpts.blockchainRid`
|
|
43455
|
+
* still wins (caller vouched for it); everything else honors the
|
|
43456
|
+
* dashboard's `org_networks` map.
|
|
43457
|
+
*/
|
|
43458
|
+
async resolveChainOpts() {
|
|
43459
|
+
if (this._resolvedChainOpts !== void 0) {
|
|
43460
|
+
return this._resolvedChainOpts ?? void 0;
|
|
43461
|
+
}
|
|
43462
|
+
if (this._resolveChainInflight) return this._resolveChainInflight;
|
|
43463
|
+
this._resolveChainInflight = (async () => {
|
|
43464
|
+
if (this.opts.chainOpts?.blockchainRid) {
|
|
43465
|
+
this._resolvedChainOpts = this.opts.chainOpts;
|
|
43466
|
+
return this.opts.chainOpts;
|
|
43467
|
+
}
|
|
43468
|
+
if (!this.opts.orgName) {
|
|
43469
|
+
this._resolvedChainOpts = this.opts.chainOpts ?? null;
|
|
43470
|
+
return this.opts.chainOpts;
|
|
43471
|
+
}
|
|
43472
|
+
try {
|
|
43473
|
+
const atbash = new Atbash(this.opts.auth.privkey, {
|
|
43474
|
+
endpoint: this.opts.judgeEndpoint,
|
|
43475
|
+
verifyPubKey: this.opts.judgeVerifyPubKey,
|
|
43476
|
+
orgName: this.opts.orgName
|
|
43477
|
+
});
|
|
43478
|
+
const resolved = await atbash.resolveChainForOrg(this.opts.orgName);
|
|
43479
|
+
const chainOpts = { ...this.opts.chainOpts, network: resolved.network };
|
|
43480
|
+
this._resolvedChainOpts = chainOpts;
|
|
43481
|
+
this.logger.info(
|
|
43482
|
+
`[atbash] resolved org \u2192 chain \u2014 org=${this.opts.orgName} network=${resolved.network}`
|
|
43483
|
+
);
|
|
43484
|
+
return chainOpts;
|
|
43485
|
+
} catch (err) {
|
|
43486
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
43487
|
+
this.logger.warn(
|
|
43488
|
+
`[atbash] org \u2192 chain resolution failed (falling back to SDK default): ${msg}`
|
|
43489
|
+
);
|
|
43490
|
+
return this.opts.chainOpts;
|
|
43491
|
+
} finally {
|
|
43492
|
+
this._resolveChainInflight = void 0;
|
|
43493
|
+
}
|
|
43494
|
+
})();
|
|
43495
|
+
return this._resolveChainInflight;
|
|
43496
|
+
}
|
|
43437
43497
|
/**
|
|
43438
43498
|
* One-shot chain probe at plugin registration. Refreshes MEMORY.md
|
|
43439
43499
|
* from chain when drifted and score passes threshold. Fire-and-forget
|
|
@@ -43441,11 +43501,12 @@ var MemoryGuardManager = class {
|
|
|
43441
43501
|
*/
|
|
43442
43502
|
async runBootProbe() {
|
|
43443
43503
|
try {
|
|
43504
|
+
const chainOpts = await this.resolveChainOpts();
|
|
43444
43505
|
const seed = { activeId: null, checkedAt: 0 };
|
|
43445
43506
|
const result = await syncLocalMemory(this.opts.auth, seed, {
|
|
43446
43507
|
ttlMs: 0,
|
|
43447
43508
|
force: true,
|
|
43448
|
-
chainOpts
|
|
43509
|
+
chainOpts
|
|
43449
43510
|
});
|
|
43450
43511
|
if (!result.drifted && result.pointer.activeId == null) {
|
|
43451
43512
|
this.logger.info(
|
|
@@ -43584,9 +43645,10 @@ var MemoryGuardManager = class {
|
|
|
43584
43645
|
const pointer = await this.pointerStore.get(this.agentPubkeyHex);
|
|
43585
43646
|
let result;
|
|
43586
43647
|
try {
|
|
43648
|
+
const chainOpts = await this.resolveChainOpts();
|
|
43587
43649
|
result = await syncLocalMemory(this.opts.auth, pointer, {
|
|
43588
43650
|
ttlMs: this.ttlMs,
|
|
43589
|
-
chainOpts
|
|
43651
|
+
chainOpts
|
|
43590
43652
|
});
|
|
43591
43653
|
} catch (err) {
|
|
43592
43654
|
if (err instanceof MemoryIntegrityError) {
|
|
@@ -43868,4 +43930,3 @@ postchain-client/built/esm/index.js:
|
|
|
43868
43930
|
*)
|
|
43869
43931
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
43870
43932
|
*/
|
|
43871
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.mjs
CHANGED
|
@@ -43348,6 +43348,66 @@ var MemoryGuardManager = class {
|
|
|
43348
43348
|
rollbackMinScore;
|
|
43349
43349
|
enforce;
|
|
43350
43350
|
agentPubkeyHex;
|
|
43351
|
+
/**
|
|
43352
|
+
* Memoized org→chain resolution. Reads have to hit the SAME chain
|
|
43353
|
+
* writes did, so an org-scoped guard must resolve `orgName` to
|
|
43354
|
+
* network exactly like `commitMemoryVersion` does. Without this
|
|
43355
|
+
* cache the read path would either (a) hit the SDK-default chain
|
|
43356
|
+
* every time — silently returning "no active memory on chain" when
|
|
43357
|
+
* writes landed on the org's actual chain, or (b) hammer
|
|
43358
|
+
* `/api/org-network` on every read. `undefined` means "not yet
|
|
43359
|
+
* resolved"; a resolved `null` means "no org / use raw chainOpts".
|
|
43360
|
+
*/
|
|
43361
|
+
_resolvedChainOpts = void 0;
|
|
43362
|
+
_resolveChainInflight;
|
|
43363
|
+
/**
|
|
43364
|
+
* Resolve `orgName` → chain once, cache forever. `commitMemoryVersion`
|
|
43365
|
+
* already does this for writes; without the same call on the read
|
|
43366
|
+
* path, a client on the SDK's baked default chain reads from the wrong
|
|
43367
|
+
* chain and reports "no active memory" for an agent whose writes did
|
|
43368
|
+
* land — on the org's actual chain. An explicit `chainOpts.blockchainRid`
|
|
43369
|
+
* still wins (caller vouched for it); everything else honors the
|
|
43370
|
+
* dashboard's `org_networks` map.
|
|
43371
|
+
*/
|
|
43372
|
+
async resolveChainOpts() {
|
|
43373
|
+
if (this._resolvedChainOpts !== void 0) {
|
|
43374
|
+
return this._resolvedChainOpts ?? void 0;
|
|
43375
|
+
}
|
|
43376
|
+
if (this._resolveChainInflight) return this._resolveChainInflight;
|
|
43377
|
+
this._resolveChainInflight = (async () => {
|
|
43378
|
+
if (this.opts.chainOpts?.blockchainRid) {
|
|
43379
|
+
this._resolvedChainOpts = this.opts.chainOpts;
|
|
43380
|
+
return this.opts.chainOpts;
|
|
43381
|
+
}
|
|
43382
|
+
if (!this.opts.orgName) {
|
|
43383
|
+
this._resolvedChainOpts = this.opts.chainOpts ?? null;
|
|
43384
|
+
return this.opts.chainOpts;
|
|
43385
|
+
}
|
|
43386
|
+
try {
|
|
43387
|
+
const atbash = new Atbash(this.opts.auth.privkey, {
|
|
43388
|
+
endpoint: this.opts.judgeEndpoint,
|
|
43389
|
+
verifyPubKey: this.opts.judgeVerifyPubKey,
|
|
43390
|
+
orgName: this.opts.orgName
|
|
43391
|
+
});
|
|
43392
|
+
const resolved = await atbash.resolveChainForOrg(this.opts.orgName);
|
|
43393
|
+
const chainOpts = { ...this.opts.chainOpts, network: resolved.network };
|
|
43394
|
+
this._resolvedChainOpts = chainOpts;
|
|
43395
|
+
this.logger.info(
|
|
43396
|
+
`[atbash] resolved org \u2192 chain \u2014 org=${this.opts.orgName} network=${resolved.network}`
|
|
43397
|
+
);
|
|
43398
|
+
return chainOpts;
|
|
43399
|
+
} catch (err) {
|
|
43400
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
43401
|
+
this.logger.warn(
|
|
43402
|
+
`[atbash] org \u2192 chain resolution failed (falling back to SDK default): ${msg}`
|
|
43403
|
+
);
|
|
43404
|
+
return this.opts.chainOpts;
|
|
43405
|
+
} finally {
|
|
43406
|
+
this._resolveChainInflight = void 0;
|
|
43407
|
+
}
|
|
43408
|
+
})();
|
|
43409
|
+
return this._resolveChainInflight;
|
|
43410
|
+
}
|
|
43351
43411
|
/**
|
|
43352
43412
|
* One-shot chain probe at plugin registration. Refreshes MEMORY.md
|
|
43353
43413
|
* from chain when drifted and score passes threshold. Fire-and-forget
|
|
@@ -43355,11 +43415,12 @@ var MemoryGuardManager = class {
|
|
|
43355
43415
|
*/
|
|
43356
43416
|
async runBootProbe() {
|
|
43357
43417
|
try {
|
|
43418
|
+
const chainOpts = await this.resolveChainOpts();
|
|
43358
43419
|
const seed = { activeId: null, checkedAt: 0 };
|
|
43359
43420
|
const result = await syncLocalMemory(this.opts.auth, seed, {
|
|
43360
43421
|
ttlMs: 0,
|
|
43361
43422
|
force: true,
|
|
43362
|
-
chainOpts
|
|
43423
|
+
chainOpts
|
|
43363
43424
|
});
|
|
43364
43425
|
if (!result.drifted && result.pointer.activeId == null) {
|
|
43365
43426
|
this.logger.info(
|
|
@@ -43498,9 +43559,10 @@ var MemoryGuardManager = class {
|
|
|
43498
43559
|
const pointer = await this.pointerStore.get(this.agentPubkeyHex);
|
|
43499
43560
|
let result;
|
|
43500
43561
|
try {
|
|
43562
|
+
const chainOpts = await this.resolveChainOpts();
|
|
43501
43563
|
result = await syncLocalMemory(this.opts.auth, pointer, {
|
|
43502
43564
|
ttlMs: this.ttlMs,
|
|
43503
|
-
chainOpts
|
|
43565
|
+
chainOpts
|
|
43504
43566
|
});
|
|
43505
43567
|
} catch (err) {
|
|
43506
43568
|
if (err instanceof MemoryIntegrityError) {
|
|
@@ -43781,4 +43843,3 @@ postchain-client/built/esm/index.js:
|
|
|
43781
43843
|
*)
|
|
43782
43844
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
43783
43845
|
*/
|
|
43784
|
-
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atbash/sdk",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2-dev.0",
|
|
4
4
|
"description": "TypeScript SDK for Atbash — the safety layer that evaluates AI agent actions against operator-defined policies before execution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atbash",
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"typescript-eslint": "^8.62.1"
|
|
90
90
|
},
|
|
91
91
|
"optionalDependencies": {
|
|
92
|
-
"@atbash/sdk-linux-x64-gnu": "0.15.
|
|
93
|
-
"@atbash/sdk-linux-arm64-gnu": "0.15.
|
|
94
|
-
"@atbash/sdk-linux-x64-musl": "0.15.
|
|
95
|
-
"@atbash/sdk-darwin-arm64": "0.15.
|
|
96
|
-
"@atbash/sdk-win32-x64-msvc": "0.15.
|
|
92
|
+
"@atbash/sdk-linux-x64-gnu": "0.15.2-dev.0",
|
|
93
|
+
"@atbash/sdk-linux-arm64-gnu": "0.15.2-dev.0",
|
|
94
|
+
"@atbash/sdk-linux-x64-musl": "0.15.2-dev.0",
|
|
95
|
+
"@atbash/sdk-darwin-arm64": "0.15.2-dev.0",
|
|
96
|
+
"@atbash/sdk-win32-x64-msvc": "0.15.2-dev.0"
|
|
97
97
|
}
|
|
98
98
|
}
|