@atbash/sdk 0.10.13-dev.0 → 0.12.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/README.md +5 -0
- package/dist/browser.d.mts +32 -12
- package/dist/browser.mjs +105 -77
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +32 -12
- package/dist/index.d.ts +32 -12
- package/dist/index.js +144 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -94
- package/dist/index.mjs.map +1 -1
- package/index.d.ts +18 -10
- package/index.js +85 -196
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -142,12 +142,17 @@ const atbash = Atbash.fromConfig(); // reads env + config file
|
|
|
142
142
|
| `agentKey` | `ATBASH_AGENT_KEY` |
|
|
143
143
|
| `orgName` | `ATBASH_ORG_NAME` |
|
|
144
144
|
| `judgeEndpoint` | `ATBASH_ENDPOINT` |
|
|
145
|
+
| `judgeVerifyPubKey` | `ATBASH_JUDGE_VERIFY_PUBKEY` (self-hosted judge response-signing key; selects the self-hosted policy) |
|
|
145
146
|
| `blockchainRid` | `ATBASH_BLOCKCHAIN_RID` |
|
|
146
147
|
| `provider` | `ATBASH_PROVIDER` |
|
|
147
148
|
| `providerModel` | `ATBASH_PROVIDER_MODEL` |
|
|
148
149
|
|
|
149
150
|
Persistent config helpers: `saveUserConfig(config)`, `loadUserConfig()`, `resolve(key, flagValue?)`, `getConfigPath()`.
|
|
150
151
|
|
|
152
|
+
### Judge endpoint policy
|
|
153
|
+
|
|
154
|
+
Both `Atbash.fromConfig()` and the direct constructor validate the judge endpoint before any request is made. `new Atbash(privkey, { endpoint })` accepts only an `https://` allowlisted judge host, or a self-hosted judge when `verifyPubKey` is also given (the 66-hex response-signing key, which then verifies every judge response). Plaintext `http://` is accepted only for loopback (`localhost`, `127.0.0.1`, `::1`) local development. Anything else throws at construction, so a misconfigured or injected endpoint can no longer receive the agent's signed actions or return unsigned verdicts. `validateJudgeEndpoint(...)` exposes the same check.
|
|
155
|
+
|
|
151
156
|
Agent policy and detail reads can resolve the organization's active network, or
|
|
152
157
|
accept an explicit network override:
|
|
153
158
|
|
package/dist/browser.d.mts
CHANGED
|
@@ -689,6 +689,12 @@ interface AtbashUserConfig {
|
|
|
689
689
|
agentKey?: string;
|
|
690
690
|
orgName?: string;
|
|
691
691
|
judgeEndpoint?: string;
|
|
692
|
+
/**
|
|
693
|
+
* Response-signing pubkey of a self-hosted judge (66 hex). Setting it makes
|
|
694
|
+
* `fromConfig` use the self-hosted policy for `judgeEndpoint`, which is the
|
|
695
|
+
* only way a non-allowlisted judge host is accepted.
|
|
696
|
+
*/
|
|
697
|
+
judgeVerifyPubKey?: string;
|
|
692
698
|
blockchainRid?: string;
|
|
693
699
|
provider?: string;
|
|
694
700
|
providerModel?: string;
|
|
@@ -791,15 +797,26 @@ declare function scanMemoryBatch(entries: MemoryEntry[], auth: AgentAuth, opts?:
|
|
|
791
797
|
interface CommitMemoryOptions {
|
|
792
798
|
/** Score in [1, 10]. Defaults to 5 (matches the Rell entity default). */
|
|
793
799
|
score?: number;
|
|
800
|
+
/**
|
|
801
|
+
* Which memory file this commit targets. Defaults to `""` — the
|
|
802
|
+
* un-pathed slot, matching Rell's `file_path: text = ""` default.
|
|
803
|
+
* Pass an explicit filename (e.g. `"AGENTS.md"`) to keep files
|
|
804
|
+
* versioned independently on chain.
|
|
805
|
+
*/
|
|
806
|
+
filePath?: string;
|
|
794
807
|
/** Org name — when set, the SDK resolves which chain the agent lives on. */
|
|
795
808
|
orgName?: string;
|
|
796
809
|
/** Atbash service endpoint for org→chain lookup. */
|
|
797
810
|
endpoint?: string;
|
|
811
|
+
/** Self-hosted judge response-signing pubkey; required with a non-allowlisted `endpoint`. */
|
|
812
|
+
verifyPubKey?: string;
|
|
798
813
|
chainOpts?: ChainOpts;
|
|
799
814
|
}
|
|
800
815
|
interface RollbackMemoryOptions {
|
|
801
816
|
orgName?: string;
|
|
802
817
|
endpoint?: string;
|
|
818
|
+
/** Self-hosted judge response-signing pubkey; required with a non-allowlisted `endpoint`. */
|
|
819
|
+
verifyPubKey?: string;
|
|
803
820
|
chainOpts?: ChainOpts;
|
|
804
821
|
}
|
|
805
822
|
/**
|
|
@@ -821,6 +838,7 @@ declare function commitMemoryVersion(plaintext: string, auth: AgentAuth, opts?:
|
|
|
821
838
|
*/
|
|
822
839
|
interface AgentMemoryEntry {
|
|
823
840
|
id: number;
|
|
841
|
+
filePath: string;
|
|
824
842
|
content: string;
|
|
825
843
|
decryptError?: string;
|
|
826
844
|
score: number;
|
|
@@ -832,6 +850,7 @@ interface AgentMemoryEntry {
|
|
|
832
850
|
interface MemoryRollbackEvent {
|
|
833
851
|
fromId: number;
|
|
834
852
|
toId: number;
|
|
853
|
+
filePath: string;
|
|
835
854
|
reason: string;
|
|
836
855
|
signer: string;
|
|
837
856
|
createdAt: number;
|
|
@@ -842,36 +861,39 @@ interface MemoryRollbackEvent {
|
|
|
842
861
|
* response is a single integer, so this is safe to call on every
|
|
843
862
|
* memory-read hot path.
|
|
844
863
|
*/
|
|
845
|
-
declare function getActiveMemoryId(auth: AgentAuth, chainOpts?: ChainOpts): Promise<number | null>;
|
|
864
|
+
declare function getActiveMemoryId(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null): Promise<number | null>;
|
|
846
865
|
/**
|
|
847
866
|
* Recent active memory entries — subset of active versions filtered
|
|
848
867
|
* by the chain's `MEMORY_RECENT_WINDOW_MS`. For a time-unbounded view
|
|
849
|
-
* of every currently active version, use `
|
|
868
|
+
* of every currently active version, use `getActiveAgentMemory`.
|
|
850
869
|
*/
|
|
851
|
-
declare function
|
|
870
|
+
declare function getRecentAgentMemory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null): Promise<AgentMemoryEntry[]>;
|
|
852
871
|
/**
|
|
853
872
|
* All currently-active memory entries with no time cutoff. Use this
|
|
854
873
|
* when you need every active version regardless of age.
|
|
855
874
|
*/
|
|
856
|
-
declare function
|
|
875
|
+
declare function getActiveAgentMemory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null): Promise<AgentMemoryEntry[]>;
|
|
857
876
|
/**
|
|
858
877
|
* Full version history — active + inactive, most recent first. Used
|
|
859
878
|
* by rollback UX to choose a target version.
|
|
860
879
|
*/
|
|
861
|
-
declare function getMemoryHistory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry[]>;
|
|
880
|
+
declare function getMemoryHistory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null): Promise<AgentMemoryEntry[]>;
|
|
862
881
|
/**
|
|
863
882
|
* Fetch a single memory entry by version id, including its current
|
|
864
|
-
* `is_active` state.
|
|
883
|
+
* `is_active` state. Version ids are agent-unique on chain (not
|
|
884
|
+
* per-file), so `id` alone resolves the target row.
|
|
865
885
|
*/
|
|
866
886
|
declare function getMemoryById(id: number, auth: AgentAuth, chainOpts?: ChainOpts): Promise<AgentMemoryEntry>;
|
|
867
887
|
/**
|
|
868
888
|
* Audit trail of rollback events for this agent, most recent first.
|
|
889
|
+
* Scope by file with `filePath`; omit for a cross-file view.
|
|
869
890
|
*/
|
|
870
|
-
declare function getRollbackHistory(auth: AgentAuth, chainOpts?: ChainOpts): Promise<MemoryRollbackEvent[]>;
|
|
891
|
+
declare function getRollbackHistory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null): Promise<MemoryRollbackEvent[]>;
|
|
871
892
|
/**
|
|
872
893
|
* Roll back to a previously-committed memory version. The target
|
|
873
|
-
* `toId` must exist and be currently inactive.
|
|
874
|
-
*
|
|
894
|
+
* `toId` must exist and be currently inactive. The chain resolves the
|
|
895
|
+
* target row's `file_path` from `toId` — no file path is passed in.
|
|
896
|
+
* `reason` is required and is recorded on-chain in `memory_rollback_log`.
|
|
875
897
|
*/
|
|
876
898
|
declare function rollbackMemory(toId: number, reason: string, auth: AgentAuth, opts?: RollbackMemoryOptions): Promise<void>;
|
|
877
899
|
|
|
@@ -956,8 +978,6 @@ interface GuardMemoryWriteInput extends ClassifyMemoryWriteOptions {
|
|
|
956
978
|
debug?: boolean;
|
|
957
979
|
/** Optional logger for debug probe + persist-failure warnings. */
|
|
958
980
|
logger?: GuardLogger;
|
|
959
|
-
/** Absolute path of the agent's managed memory file. Required for chain commits — omitted skips them. */
|
|
960
|
-
memoryFilePath?: string;
|
|
961
981
|
}
|
|
962
982
|
/** Plugin-facing decision. Shape mirrors what plugins return from `before_tool_call`. */
|
|
963
983
|
interface GuardMemoryDecision {
|
|
@@ -1378,4 +1398,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1378
1398
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1379
1399
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1380
1400
|
|
|
1381
|
-
export { type ActionType, type AgentAuth, type AgentLookupOptions, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, BOOT_SYNC_HINT, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, DEFAULT_MEMORY_PATH_PATTERNS, DEFAULT_MEMORY_READ_TOOL_NAMES, DEFAULT_MEMORY_WRITE_TOOL_NAMES, type Decision, type DecisionVerdict, EciesDomain, type EncryptedMemory, type Envelope, type FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, HttpClient, HttpTransportError, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, KEY_FILENAMES, type KeyPair, type LogToolCallOptions, type LogToolCallResult, type MemoryAnomaly, type MemoryDiffResult, type MemoryEntry, MemoryGuardManager, type MemoryGuardManagerOptions, MemoryIntegrityError, type MemoryPointer, type MemoryRollbackEvent, type MemoryScanOptions, type MemoryScanResult, type MemoryScanVerdict, type MemorySnapshot, type ModifiedEntry, type Network, type OrgSubscription, PointerStore, type Provider, type PubkeyValue, type RedactResult, type RollbackMemoryOptions, type SecretKind, type SecretMatch, SignatureVerificationError, type Subscription, type SyncMemoryOptions, type SyncMemoryResult, type TelemetryConfig, type TierInfo, type ToolCallFull, type ToolCallInput, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, bootSyncFailureLine, buildAllowedJudgeHosts, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair,
|
|
1401
|
+
export { type ActionType, type AgentAuth, type AgentLookupOptions, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, BOOT_SYNC_HINT, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions, DEFAULT_BLOCKCHAIN_RID, DEFAULT_CHROMIA_NODE_URLS, DEFAULT_ENDPOINT, DEFAULT_MEMORY_PATH_PATTERNS, DEFAULT_MEMORY_READ_TOOL_NAMES, DEFAULT_MEMORY_WRITE_TOOL_NAMES, type Decision, type DecisionVerdict, EciesDomain, type EncryptedMemory, type Envelope, type FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, HttpClient, HttpTransportError, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, KEY_FILENAMES, type KeyPair, type LogToolCallOptions, type LogToolCallResult, type MemoryAnomaly, type MemoryDiffResult, type MemoryEntry, MemoryGuardManager, type MemoryGuardManagerOptions, MemoryIntegrityError, type MemoryPointer, type MemoryRollbackEvent, type MemoryScanOptions, type MemoryScanResult, type MemoryScanVerdict, type MemorySnapshot, type ModifiedEntry, type Network, type OrgSubscription, PointerStore, type Provider, type PubkeyValue, type RedactResult, type RollbackMemoryOptions, type SecretKind, type SecretMatch, SignatureVerificationError, type Subscription, type SyncMemoryOptions, type SyncMemoryResult, type TelemetryConfig, type TierInfo, type ToolCallFull, type ToolCallInput, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, bootSyncFailureLine, buildAllowedJudgeHosts, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
|
package/dist/browser.mjs
CHANGED
|
@@ -37,7 +37,7 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
|
|
|
37
37
|
var define_ATBASH_CHROMIA_NODE_URLS_default;
|
|
38
38
|
var init_define_ATBASH_CHROMIA_NODE_URLS = __esm({
|
|
39
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"
|
|
40
|
+
define_ATBASH_CHROMIA_NODE_URLS_default = ["https://node0.testnet.chromia.com:7740", "https://node1.testnet.chromia.com:7740"];
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ var init_define_ATBASH_CHROMIA_NODE_URLS = __esm({
|
|
|
45
45
|
var define_ATBASH_PRIVATE_NODE_URLS_default;
|
|
46
46
|
var init_define_ATBASH_PRIVATE_NODE_URLS = __esm({
|
|
47
47
|
"<define:__ATBASH_PRIVATE_NODE_URLS__>"() {
|
|
48
|
-
define_ATBASH_PRIVATE_NODE_URLS_default = ["https://node0-pvn-testnet.dynamic.chromia.dev"];
|
|
48
|
+
define_ATBASH_PRIVATE_NODE_URLS_default = ["https://node0-pvn-testnet.dynamic.chromia.dev:7740", "https://node1-pvn-testnet.dynamic.chromia.dev:7740", "https://node2-pvn-testnet.dynamic.chromia.dev:7740"];
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -43478,9 +43478,10 @@ var native = {
|
|
|
43478
43478
|
validateMemoryId: stub("validateMemoryId"),
|
|
43479
43479
|
validateRollbackReason: stub("validateRollbackReason"),
|
|
43480
43480
|
validateMemoryNonce: stub("validateMemoryNonce"),
|
|
43481
|
+
validateFilePath: stub("validateFilePath"),
|
|
43481
43482
|
buildGetActiveMemoryIdQuery: stub("buildGetActiveMemoryIdQuery"),
|
|
43482
|
-
|
|
43483
|
-
|
|
43483
|
+
buildGetRecentAgentMemoryQuery: stub("buildGetRecentAgentMemoryQuery"),
|
|
43484
|
+
buildGetActiveAgentMemoryQuery: stub("buildGetActiveAgentMemoryQuery"),
|
|
43484
43485
|
buildGetAgentMemoryHistoryQuery: stub("buildGetAgentMemoryHistoryQuery"),
|
|
43485
43486
|
buildGetAgentMemoryRollbackHistoryQuery: stub("buildGetAgentMemoryRollbackHistoryQuery"),
|
|
43486
43487
|
buildGetAgentMemoryByIdQuery: stub("buildGetAgentMemoryByIdQuery"),
|
|
@@ -43499,13 +43500,14 @@ var native = {
|
|
|
43499
43500
|
OP_ROLLBACK_AGENT_MEMORY: "rollback_agent_memory",
|
|
43500
43501
|
OP_LOG_ENCRYPTED_TOOL_CALL: "log_encrypted_tool_call",
|
|
43501
43502
|
QUERY_GET_ACTIVE_MEMORY_ID: "get_active_memory_id",
|
|
43502
|
-
|
|
43503
|
-
|
|
43503
|
+
QUERY_GET_RECENT_AGENT_MEMORY: "get_recent_agent_memory",
|
|
43504
|
+
QUERY_GET_ACTIVE_AGENT_MEMORY: "get_active_agent_memory",
|
|
43504
43505
|
QUERY_GET_AGENT_MEMORY_HISTORY: "get_agent_memory_history",
|
|
43505
43506
|
QUERY_GET_AGENT_MEMORY_BY_ID: "get_agent_memory_by_id",
|
|
43506
43507
|
QUERY_GET_AGENT_MEMORY_ROLLBACK_HISTORY: "get_agent_memory_rollback_history",
|
|
43507
43508
|
ARG_AGENT_PUBKEY: "agent_pubkey",
|
|
43508
|
-
ARG_ID: "id"
|
|
43509
|
+
ARG_ID: "id",
|
|
43510
|
+
ARG_FILE_PATH: "file_path"
|
|
43509
43511
|
};
|
|
43510
43512
|
|
|
43511
43513
|
// src-ts/client.ts
|
|
@@ -44662,11 +44664,18 @@ var Atbash = class _Atbash {
|
|
|
44662
44664
|
static environmentLogged = false;
|
|
44663
44665
|
constructor(privkey, options = {}) {
|
|
44664
44666
|
this.auth = native.loadAgent(privkey);
|
|
44665
|
-
|
|
44667
|
+
const validated = validateJudgeEndpoint(
|
|
44668
|
+
options.verifyPubKey ? {
|
|
44669
|
+
policy: "self-hosted",
|
|
44670
|
+
endpoint: options.endpoint ?? DEFAULT_ENDPOINT,
|
|
44671
|
+
verifyPubKey: options.verifyPubKey
|
|
44672
|
+
} : { endpoint: options.endpoint }
|
|
44673
|
+
);
|
|
44674
|
+
this.endpoint = validated.url;
|
|
44666
44675
|
this.nodeUrls = options.nodeUrls ? [...options.nodeUrls] : DEFAULT_CHROMIA_NODE_URLS;
|
|
44667
44676
|
this.blockchainRid = options.blockchainRid ?? native.DEFAULT_BLOCKCHAIN_RID;
|
|
44668
44677
|
this.orgName = options.orgName;
|
|
44669
|
-
this.verifyPubKey =
|
|
44678
|
+
this.verifyPubKey = validated.verifyPubKey ?? void 0;
|
|
44670
44679
|
this.orgEncryptionPubKey = options.orgEncryptionPubKey;
|
|
44671
44680
|
this.failClosed = options.failClosed !== false;
|
|
44672
44681
|
this.debug = options.debug === true;
|
|
@@ -44724,8 +44733,19 @@ var Atbash = class _Atbash {
|
|
|
44724
44733
|
* self-hosted endpoint's `verifyPubKey` becomes the client default.
|
|
44725
44734
|
*/
|
|
44726
44735
|
static fromConfig(options = {}) {
|
|
44736
|
+
const configuredEndpoint = resolve("judgeEndpoint") || void 0;
|
|
44737
|
+
const configuredVerifyPubKey = resolve("judgeVerifyPubKey") || void 0;
|
|
44738
|
+
if (!options.judge && configuredVerifyPubKey && !configuredEndpoint) {
|
|
44739
|
+
throw new Error(
|
|
44740
|
+
"judgeVerifyPubKey / ATBASH_JUDGE_VERIFY_PUBKEY is set but no judge endpoint is configured: set judgeEndpoint / ATBASH_ENDPOINT to the self-hosted judge"
|
|
44741
|
+
);
|
|
44742
|
+
}
|
|
44727
44743
|
const validated = validateJudgeEndpoint(
|
|
44728
|
-
options.judge ??
|
|
44744
|
+
options.judge ?? (configuredVerifyPubKey && configuredEndpoint ? {
|
|
44745
|
+
policy: "self-hosted",
|
|
44746
|
+
endpoint: configuredEndpoint,
|
|
44747
|
+
verifyPubKey: configuredVerifyPubKey
|
|
44748
|
+
} : { endpoint: configuredEndpoint })
|
|
44729
44749
|
);
|
|
44730
44750
|
const agentKey = resolve("agentKey", options.agentKey);
|
|
44731
44751
|
const auth = agentKey ? native.loadAgent(agentKey) : loadAgentFromFile(options.keyPath);
|
|
@@ -45281,21 +45301,22 @@ var Atbash = class _Atbash {
|
|
|
45281
45301
|
* entry (caller falls back to per-chain subscription resolution).
|
|
45282
45302
|
*/
|
|
45283
45303
|
async getActiveNetworkForOrg(orgName) {
|
|
45304
|
+
let resp;
|
|
45284
45305
|
try {
|
|
45285
|
-
|
|
45306
|
+
resp = await this.http.get(
|
|
45286
45307
|
"/api/org-network",
|
|
45287
|
-
{ org: orgName },
|
|
45308
|
+
{ org: orgName.trim() },
|
|
45288
45309
|
this.authHeaders()
|
|
45289
45310
|
);
|
|
45290
|
-
|
|
45291
|
-
|
|
45292
|
-
|
|
45293
|
-
|
|
45294
|
-
|
|
45295
|
-
|
|
45296
|
-
|
|
45297
|
-
return null;
|
|
45311
|
+
} catch (err) {
|
|
45312
|
+
throw this.transportError(err);
|
|
45313
|
+
}
|
|
45314
|
+
if (resp.status !== 200) throw await this.httpError(resp);
|
|
45315
|
+
const data = await this.json(resp);
|
|
45316
|
+
if (data?.network === "public" || data?.network === "private") {
|
|
45317
|
+
return data.network;
|
|
45298
45318
|
}
|
|
45319
|
+
return null;
|
|
45299
45320
|
}
|
|
45300
45321
|
/**
|
|
45301
45322
|
* Resolve which chain an org's actions should run against. Cached
|
|
@@ -45307,10 +45328,11 @@ var Atbash = class _Atbash {
|
|
|
45307
45328
|
* Defaults to the public chain when nothing else resolves.
|
|
45308
45329
|
*/
|
|
45309
45330
|
async resolveChainForOrg(orgName) {
|
|
45310
|
-
const
|
|
45331
|
+
const name2 = orgName.trim();
|
|
45332
|
+
const cached = this._chainCache.get(name2);
|
|
45311
45333
|
if (cached) return cached;
|
|
45312
|
-
const mapNetwork = await this.getActiveNetworkForOrg(
|
|
45313
|
-
return this.resolveChainFromMap(
|
|
45334
|
+
const mapNetwork = await this.getActiveNetworkForOrg(name2);
|
|
45335
|
+
return this.resolveChainFromMap(name2, mapNetwork);
|
|
45314
45336
|
}
|
|
45315
45337
|
/**
|
|
45316
45338
|
* Resolve a chain given an already-fetched `org_networks` map result.
|
|
@@ -45326,29 +45348,38 @@ var Atbash = class _Atbash {
|
|
|
45326
45348
|
this._chainCache.set(orgName, chain);
|
|
45327
45349
|
return chain;
|
|
45328
45350
|
}
|
|
45329
|
-
|
|
45330
|
-
|
|
45331
|
-
|
|
45332
|
-
|
|
45333
|
-
|
|
45334
|
-
|
|
45335
|
-
|
|
45336
|
-
|
|
45337
|
-
|
|
45338
|
-
|
|
45339
|
-
|
|
45340
|
-
|
|
45341
|
-
|
|
45342
|
-
|
|
45343
|
-
|
|
45344
|
-
|
|
45345
|
-
|
|
45346
|
-
|
|
45347
|
-
|
|
45348
|
-
|
|
45349
|
-
|
|
45350
|
-
|
|
45351
|
-
|
|
45351
|
+
const [pubRes, privRes] = await Promise.allSettled([
|
|
45352
|
+
this.getOrgSubscription(orgName, "public"),
|
|
45353
|
+
this.getOrgSubscription(orgName, "private")
|
|
45354
|
+
]);
|
|
45355
|
+
const pubSub = pubRes.status === "fulfilled" ? pubRes.value : null;
|
|
45356
|
+
const privSub = privRes.status === "fulfilled" ? privRes.value : null;
|
|
45357
|
+
const failure = pubRes.status === "rejected" ? pubRes.reason : privRes.status === "rejected" ? privRes.reason : null;
|
|
45358
|
+
if (pubSub?.is_private_blockchain) {
|
|
45359
|
+
this._chainCache.set(orgName, PRIVATE_CHAIN);
|
|
45360
|
+
return PRIVATE_CHAIN;
|
|
45361
|
+
}
|
|
45362
|
+
if (pubSub && privSub) {
|
|
45363
|
+
const chain = privSub.assigned_at > pubSub.assigned_at ? PRIVATE_CHAIN : PUBLIC_CHAIN;
|
|
45364
|
+
this._chainCache.set(orgName, chain);
|
|
45365
|
+
return chain;
|
|
45366
|
+
}
|
|
45367
|
+
if (pubSub) {
|
|
45368
|
+
this._chainCache.set(orgName, PUBLIC_CHAIN);
|
|
45369
|
+
return PUBLIC_CHAIN;
|
|
45370
|
+
}
|
|
45371
|
+
if (privSub?.is_private_blockchain) {
|
|
45372
|
+
this._chainCache.set(orgName, PRIVATE_CHAIN);
|
|
45373
|
+
return PRIVATE_CHAIN;
|
|
45374
|
+
}
|
|
45375
|
+
if (failure) {
|
|
45376
|
+
const detail = failure instanceof Error ? failure.message : String(failure);
|
|
45377
|
+
throw new AtbashAPIError(
|
|
45378
|
+
failure instanceof AtbashAPIError ? failure.status : 0,
|
|
45379
|
+
`could not resolve the chain for org "${orgName}": ${detail}`,
|
|
45380
|
+
"",
|
|
45381
|
+
this.endpoint
|
|
45382
|
+
);
|
|
45352
45383
|
}
|
|
45353
45384
|
this._chainCache.set(orgName, PUBLIC_CHAIN);
|
|
45354
45385
|
return PUBLIC_CHAIN;
|
|
@@ -45842,11 +45873,11 @@ async function commitMemoryVersion(_plaintext, _auth, _opts) {
|
|
|
45842
45873
|
async function getActiveMemoryId(_auth, _chainOpts) {
|
|
45843
45874
|
throw new Error(`getActiveMemoryId ${STUB_MSG3}`);
|
|
45844
45875
|
}
|
|
45845
|
-
async function
|
|
45846
|
-
throw new Error(`
|
|
45876
|
+
async function getRecentAgentMemory(_auth, _chainOpts) {
|
|
45877
|
+
throw new Error(`getRecentAgentMemory ${STUB_MSG3}`);
|
|
45847
45878
|
}
|
|
45848
|
-
async function
|
|
45849
|
-
throw new Error(`
|
|
45879
|
+
async function getActiveAgentMemory(_auth, _chainOpts) {
|
|
45880
|
+
throw new Error(`getActiveAgentMemory ${STUB_MSG3}`);
|
|
45850
45881
|
}
|
|
45851
45882
|
async function getMemoryHistory(_auth, _chainOpts) {
|
|
45852
45883
|
throw new Error(`getMemoryHistory ${STUB_MSG3}`);
|
|
@@ -45925,8 +45956,7 @@ async function guardMemoryWrite(input) {
|
|
|
45925
45956
|
toolNames,
|
|
45926
45957
|
enforce = true,
|
|
45927
45958
|
debug: debug2 = false,
|
|
45928
|
-
logger: logger2
|
|
45929
|
-
memoryFilePath
|
|
45959
|
+
logger: logger2
|
|
45930
45960
|
} = input;
|
|
45931
45961
|
const memEntry = classifyMemoryWrite(event, ctx, { patterns, toolNames });
|
|
45932
45962
|
if (debug2) emitDebugProbe(event, ctx, memEntry, logger2);
|
|
@@ -45962,37 +45992,35 @@ async function guardMemoryWrite(input) {
|
|
|
45962
45992
|
committed: false
|
|
45963
45993
|
};
|
|
45964
45994
|
}
|
|
45965
|
-
const
|
|
45966
|
-
|
|
45967
|
-
|
|
45968
|
-
|
|
45969
|
-
|
|
45970
|
-
|
|
45971
|
-
|
|
45972
|
-
|
|
45973
|
-
|
|
45974
|
-
|
|
45975
|
-
|
|
45976
|
-
|
|
45995
|
+
const filePath = path3.basename(memEntry.key);
|
|
45996
|
+
commitMemoryVersion(memEntry.value, auth, {
|
|
45997
|
+
score: scanResult.score,
|
|
45998
|
+
filePath,
|
|
45999
|
+
orgName,
|
|
46000
|
+
endpoint,
|
|
46001
|
+
verifyPubKey
|
|
46002
|
+
}).catch((err) => {
|
|
46003
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
46004
|
+
logger2?.warn?.("[atbash] memory commit to chain failed", {
|
|
46005
|
+
path: memEntry.key,
|
|
46006
|
+
filePath,
|
|
46007
|
+
reason
|
|
45977
46008
|
});
|
|
45978
|
-
}
|
|
45979
|
-
logger2?.info?.(
|
|
45980
|
-
"[atbash] scanned but not committed \u2014 not the managed memory file",
|
|
45981
|
-
{
|
|
45982
|
-
path: memEntry.key,
|
|
45983
|
-
memoryFilePath: memoryFilePath ?? "(not configured)"
|
|
45984
|
-
}
|
|
45985
|
-
);
|
|
45986
|
-
}
|
|
46009
|
+
});
|
|
45987
46010
|
logger2?.info?.(
|
|
45988
46011
|
scanResult.verdict === "yellow" ? "[atbash] memory HOLD" : "[atbash] memory ALLOW",
|
|
45989
|
-
{
|
|
46012
|
+
{
|
|
46013
|
+
path: memEntry.key,
|
|
46014
|
+
filePath,
|
|
46015
|
+
score: scanResult.score,
|
|
46016
|
+
reason: scanResult.reason
|
|
46017
|
+
}
|
|
45990
46018
|
);
|
|
45991
46019
|
return {
|
|
45992
46020
|
handled: true,
|
|
45993
46021
|
decision: { allow: true },
|
|
45994
46022
|
scanResult,
|
|
45995
|
-
committed:
|
|
46023
|
+
committed: true
|
|
45996
46024
|
};
|
|
45997
46025
|
}
|
|
45998
46026
|
|
|
@@ -46199,13 +46227,13 @@ export {
|
|
|
46199
46227
|
encryptedLength,
|
|
46200
46228
|
flushTelemetry,
|
|
46201
46229
|
generateKeypair2 as generateKeypair,
|
|
46202
|
-
|
|
46230
|
+
getActiveAgentMemory,
|
|
46203
46231
|
getActiveMemoryId,
|
|
46204
|
-
getAllAgentMemory,
|
|
46205
46232
|
getConfigDir,
|
|
46206
46233
|
getConfigPath,
|
|
46207
46234
|
getMemoryById,
|
|
46208
46235
|
getMemoryHistory,
|
|
46236
|
+
getRecentAgentMemory,
|
|
46209
46237
|
getRollbackHistory,
|
|
46210
46238
|
guardMemoryWrite,
|
|
46211
46239
|
isEnvelope,
|