@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/index.d.mts CHANGED
@@ -38,8 +38,12 @@ interface ChainConfig {
38
38
  readonly blockchainRid: string;
39
39
  readonly nodeUrls: readonly string[];
40
40
  }
41
- declare const PUBLIC_CHAIN: ChainConfig;
42
41
  declare const PRIVATE_CHAIN: ChainConfig;
42
+ /**
43
+ * The chain a network name selects. Only `"private"` exists; any other value,
44
+ * including `"public"` from an untyped caller, is refused with the same
45
+ * message the config switch gives, never routed to private in silence.
46
+ */
43
47
  declare function chainForNetwork(network: Network): ChainConfig;
44
48
 
45
49
  /**
@@ -130,13 +134,11 @@ interface MemoryScanOptions {
130
134
  toolArgsJson?: string;
131
135
  }
132
136
  /**
133
- * Which Atbash chain an action runs against. `public` is the shared
134
- * testnet (Free plan); `private` is reserved for Private / Swarm /
135
- * Enterprise tier subscribers. The SDK resolves which one to use from
136
- * the org's subscription via `orgName` — callers normally don't need
137
- * to pass this manually.
137
+ * Chain selector. Only `"private"` exists: the public testnet chains are
138
+ * retired. The SDK resolves an org's chain through the Dashboard via
139
+ * `orgName` — callers normally don't need to pass this manually.
138
140
  */
139
- type Network = "public" | "private";
141
+ type Network = "private";
140
142
  /**
141
143
  * Per-call chain overrides. Pass exactly what you need to override —
142
144
  * `network` selects between the SDK's known chains, `blockchainRid` pins a
@@ -340,7 +342,7 @@ interface AtbashOptions {
340
342
  */
341
343
  chain?: ChainConfig;
342
344
  /**
343
- * Preset chain selector — `"public"` or `"private"`. Resolves to the
345
+ * Preset chain selector — `"private"` is the only value. Resolves to the
344
346
  * matching `ChainConfig` via `chainForNetwork()`. Overridden by `chain`,
345
347
  * overrides env `ATBASH_DEFAULT_CHAIN_NETWORK` and the config file.
346
348
  */
@@ -748,12 +750,9 @@ declare class Atbash {
748
750
  * Resolve which chain an org's actions should run against. Cached
749
751
  * per-client by orgName. Resolution order:
750
752
  * 1. `org_networks` map (authoritative).
751
- * 2. Per-chain subscription fallback — public + private records
752
- * are fetched in parallel, with `is_private_blockchain` and
753
- * `assigned_at` reconciling mixed states.
754
- * A lookup that names exactly one chain wins outright. Where it names
755
- * neither (a brand-new org) or cannot choose between them, the client's
756
- * configured default decides.
753
+ * 2. Subscription fallback — the org's subscription row on the chain.
754
+ * A lookup that finds the org wins outright. Where it finds nothing (a
755
+ * brand-new org), the client's configured default decides.
757
756
  */
758
757
  resolveChainForOrg(orgName: string): Promise<ChainConfig>;
759
758
  /**
@@ -870,8 +869,6 @@ declare function releaseJailHolds(): void;
870
869
  declare function configureJailHold(next: Partial<typeof DEFAULTS>): void;
871
870
 
872
871
  declare const DEFAULT_ENDPOINT: string;
873
- declare const DEFAULT_CHROMIA_NODE_URLS: readonly string[];
874
- declare const DEFAULT_BLOCKCHAIN_RID: string;
875
872
 
876
873
  declare class AtbashAPIError extends Error {
877
874
  /** HTTP status code (or 0 if the request never completed). */
@@ -1157,11 +1154,18 @@ declare function getRecentAgentMemory(auth: AgentAuth, chainOpts?: ChainOpts, fi
1157
1154
  * when you need every active version regardless of age.
1158
1155
  */
1159
1156
  declare function getActiveAgentMemory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null): Promise<AgentMemoryEntry[]>;
1157
+ interface MemoryHistoryPage {
1158
+ /** Most versions to return, at most 200. Omit for the full history. */
1159
+ maxCount?: number;
1160
+ /** Return only versions with a lower id: the last id of the previous page. */
1161
+ beforeId?: number;
1162
+ }
1160
1163
  /**
1161
1164
  * Full version history — active + inactive, most recent first. Used
1162
- * by rollback UX to choose a target version.
1165
+ * by rollback UX to choose a target version. Pass `page` to read it in
1166
+ * pages; this needs a Dashboard and chain that support paging.
1163
1167
  */
1164
- declare function getMemoryHistory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null): Promise<AgentMemoryEntry[]>;
1168
+ declare function getMemoryHistory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null, page?: MemoryHistoryPage): Promise<AgentMemoryEntry[]>;
1165
1169
  /**
1166
1170
  * Fetch a single memory entry by version id, including its current
1167
1171
  * `is_active` state. Version ids are agent-unique on chain (not
@@ -1991,4 +1995,4 @@ declare function containsSecret(text: string): boolean;
1991
1995
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1992
1996
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1993
1997
 
1994
- 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 ChainConfig, 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, JudgeRefusalError, 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 OperationEvent, type OrgSubscription, PRIVATE_CHAIN, PUBLIC_CHAIN, 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, canonicalAllow, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, configureEvents, configureJailHold, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, eventsAreOn, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isJailHeld, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, memorySlotOf, normalizeActionForHash, normalizeActionType, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, recordEvent, redactJsonStrings, redactSecrets, releaseJailHolds, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
1998
+ 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 ChainConfig, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions, 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, JudgeRefusalError, type JudgeResult, type JudgmentState, type JudgmentStatus, KEY_FILENAMES, type KeyPair, type LogToolCallOptions, type LogToolCallResult, type MemoryAnomaly, type MemoryDiffResult, type MemoryEntry, MemoryGuardManager, type MemoryGuardManagerOptions, type MemoryHistoryPage, MemoryIntegrityError, type MemoryPointer, type MemoryRollbackEvent, type MemoryScanOptions, type MemoryScanResult, type MemoryScanVerdict, type MemorySnapshot, type ModifiedEntry, type Network, type OperationEvent, type OrgSubscription, PRIVATE_CHAIN, 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, canonicalAllow, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, configureEvents, configureJailHold, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, eventsAreOn, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isJailHeld, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, memorySlotOf, normalizeActionForHash, normalizeActionType, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, recordEvent, redactJsonStrings, redactSecrets, releaseJailHolds, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
package/dist/index.d.ts CHANGED
@@ -38,8 +38,12 @@ interface ChainConfig {
38
38
  readonly blockchainRid: string;
39
39
  readonly nodeUrls: readonly string[];
40
40
  }
41
- declare const PUBLIC_CHAIN: ChainConfig;
42
41
  declare const PRIVATE_CHAIN: ChainConfig;
42
+ /**
43
+ * The chain a network name selects. Only `"private"` exists; any other value,
44
+ * including `"public"` from an untyped caller, is refused with the same
45
+ * message the config switch gives, never routed to private in silence.
46
+ */
43
47
  declare function chainForNetwork(network: Network): ChainConfig;
44
48
 
45
49
  /**
@@ -130,13 +134,11 @@ interface MemoryScanOptions {
130
134
  toolArgsJson?: string;
131
135
  }
132
136
  /**
133
- * Which Atbash chain an action runs against. `public` is the shared
134
- * testnet (Free plan); `private` is reserved for Private / Swarm /
135
- * Enterprise tier subscribers. The SDK resolves which one to use from
136
- * the org's subscription via `orgName` — callers normally don't need
137
- * to pass this manually.
137
+ * Chain selector. Only `"private"` exists: the public testnet chains are
138
+ * retired. The SDK resolves an org's chain through the Dashboard via
139
+ * `orgName` — callers normally don't need to pass this manually.
138
140
  */
139
- type Network = "public" | "private";
141
+ type Network = "private";
140
142
  /**
141
143
  * Per-call chain overrides. Pass exactly what you need to override —
142
144
  * `network` selects between the SDK's known chains, `blockchainRid` pins a
@@ -340,7 +342,7 @@ interface AtbashOptions {
340
342
  */
341
343
  chain?: ChainConfig;
342
344
  /**
343
- * Preset chain selector — `"public"` or `"private"`. Resolves to the
345
+ * Preset chain selector — `"private"` is the only value. Resolves to the
344
346
  * matching `ChainConfig` via `chainForNetwork()`. Overridden by `chain`,
345
347
  * overrides env `ATBASH_DEFAULT_CHAIN_NETWORK` and the config file.
346
348
  */
@@ -748,12 +750,9 @@ declare class Atbash {
748
750
  * Resolve which chain an org's actions should run against. Cached
749
751
  * per-client by orgName. Resolution order:
750
752
  * 1. `org_networks` map (authoritative).
751
- * 2. Per-chain subscription fallback — public + private records
752
- * are fetched in parallel, with `is_private_blockchain` and
753
- * `assigned_at` reconciling mixed states.
754
- * A lookup that names exactly one chain wins outright. Where it names
755
- * neither (a brand-new org) or cannot choose between them, the client's
756
- * configured default decides.
753
+ * 2. Subscription fallback — the org's subscription row on the chain.
754
+ * A lookup that finds the org wins outright. Where it finds nothing (a
755
+ * brand-new org), the client's configured default decides.
757
756
  */
758
757
  resolveChainForOrg(orgName: string): Promise<ChainConfig>;
759
758
  /**
@@ -870,8 +869,6 @@ declare function releaseJailHolds(): void;
870
869
  declare function configureJailHold(next: Partial<typeof DEFAULTS>): void;
871
870
 
872
871
  declare const DEFAULT_ENDPOINT: string;
873
- declare const DEFAULT_CHROMIA_NODE_URLS: readonly string[];
874
- declare const DEFAULT_BLOCKCHAIN_RID: string;
875
872
 
876
873
  declare class AtbashAPIError extends Error {
877
874
  /** HTTP status code (or 0 if the request never completed). */
@@ -1157,11 +1154,18 @@ declare function getRecentAgentMemory(auth: AgentAuth, chainOpts?: ChainOpts, fi
1157
1154
  * when you need every active version regardless of age.
1158
1155
  */
1159
1156
  declare function getActiveAgentMemory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null): Promise<AgentMemoryEntry[]>;
1157
+ interface MemoryHistoryPage {
1158
+ /** Most versions to return, at most 200. Omit for the full history. */
1159
+ maxCount?: number;
1160
+ /** Return only versions with a lower id: the last id of the previous page. */
1161
+ beforeId?: number;
1162
+ }
1160
1163
  /**
1161
1164
  * Full version history — active + inactive, most recent first. Used
1162
- * by rollback UX to choose a target version.
1165
+ * by rollback UX to choose a target version. Pass `page` to read it in
1166
+ * pages; this needs a Dashboard and chain that support paging.
1163
1167
  */
1164
- declare function getMemoryHistory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null): Promise<AgentMemoryEntry[]>;
1168
+ declare function getMemoryHistory(auth: AgentAuth, chainOpts?: ChainOpts, filePath?: string | null, page?: MemoryHistoryPage): Promise<AgentMemoryEntry[]>;
1165
1169
  /**
1166
1170
  * Fetch a single memory entry by version id, including its current
1167
1171
  * `is_active` state. Version ids are agent-unique on chain (not
@@ -1991,4 +1995,4 @@ declare function containsSecret(text: string): boolean;
1991
1995
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1992
1996
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1993
1997
 
1994
- 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 ChainConfig, 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, JudgeRefusalError, 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 OperationEvent, type OrgSubscription, PRIVATE_CHAIN, PUBLIC_CHAIN, 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, canonicalAllow, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, configureEvents, configureJailHold, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, eventsAreOn, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isJailHeld, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, memorySlotOf, normalizeActionForHash, normalizeActionType, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, recordEvent, redactJsonStrings, redactSecrets, releaseJailHolds, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
1998
+ 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 ChainConfig, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions, 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, JudgeRefusalError, type JudgeResult, type JudgmentState, type JudgmentStatus, KEY_FILENAMES, type KeyPair, type LogToolCallOptions, type LogToolCallResult, type MemoryAnomaly, type MemoryDiffResult, type MemoryEntry, MemoryGuardManager, type MemoryGuardManagerOptions, type MemoryHistoryPage, MemoryIntegrityError, type MemoryPointer, type MemoryRollbackEvent, type MemoryScanOptions, type MemoryScanResult, type MemoryScanVerdict, type MemorySnapshot, type ModifiedEntry, type Network, type OperationEvent, type OrgSubscription, PRIVATE_CHAIN, 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, canonicalAllow, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, configureEvents, configureJailHold, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, eventsAreOn, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isJailHeld, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, memorySlotOf, normalizeActionForHash, normalizeActionType, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, recordEvent, redactJsonStrings, redactSecrets, releaseJailHolds, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
package/dist/index.js CHANGED
@@ -33,8 +33,6 @@ __export(src_ts_exports, {
33
33
  Atbash: () => Atbash,
34
34
  AtbashAPIError: () => AtbashAPIError,
35
35
  BOOT_SYNC_HINT: () => BOOT_SYNC_HINT,
36
- DEFAULT_BLOCKCHAIN_RID: () => DEFAULT_BLOCKCHAIN_RID,
37
- DEFAULT_CHROMIA_NODE_URLS: () => DEFAULT_CHROMIA_NODE_URLS,
38
36
  DEFAULT_ENDPOINT: () => DEFAULT_ENDPOINT,
39
37
  DEFAULT_MEMORY_PATH_PATTERNS: () => DEFAULT_MEMORY_PATH_PATTERNS,
40
38
  DEFAULT_MEMORY_READ_TOOL_NAMES: () => DEFAULT_MEMORY_READ_TOOL_NAMES,
@@ -47,7 +45,6 @@ __export(src_ts_exports, {
47
45
  MemoryGuardManager: () => MemoryGuardManager,
48
46
  MemoryIntegrityError: () => MemoryIntegrityError,
49
47
  PRIVATE_CHAIN: () => PRIVATE_CHAIN,
50
- PUBLIC_CHAIN: () => PUBLIC_CHAIN,
51
48
  PointerStore: () => PointerStore,
52
49
  SignatureVerificationError: () => SignatureVerificationError,
53
50
  bootSyncFailureLine: () => bootSyncFailureLine,
@@ -175,32 +172,28 @@ function agentAuthHeaders(auth, blockchainRid) {
175
172
  return { Authorization: `Bearer ${agentAuthBearer(auth, blockchainRid)}` };
176
173
  }
177
174
 
178
- // src-ts/constants.ts
179
- var DEFAULT_ENDPOINT = native.DEFAULT_ENDPOINT;
180
- var DEFAULT_CHROMIA_NODE_URLS = Object.freeze(
181
- native.defaultChromiaNodeUrls()
182
- );
183
- var DEFAULT_BLOCKCHAIN_RID = native.DEFAULT_BLOCKCHAIN_RID;
184
-
185
175
  // src-ts/chain-config.ts
186
176
  var DEFAULT_PRIVATE_NODE_URLS = Object.freeze(
187
177
  native.defaultPrivateNodeUrls()
188
178
  );
189
179
  var DEFAULT_PRIVATE_BLOCKCHAIN_RID = native.DEFAULT_PRIVATE_BLOCKCHAIN_RID;
190
- var PUBLIC_CHAIN = {
191
- network: "public",
192
- blockchainRid: DEFAULT_BLOCKCHAIN_RID,
193
- nodeUrls: DEFAULT_CHROMIA_NODE_URLS
194
- };
195
180
  var PRIVATE_CHAIN = {
196
181
  network: "private",
197
182
  blockchainRid: DEFAULT_PRIVATE_BLOCKCHAIN_RID,
198
183
  nodeUrls: DEFAULT_PRIVATE_NODE_URLS
199
184
  };
200
185
  function chainForNetwork(network) {
201
- return network === "private" ? PRIVATE_CHAIN : PUBLIC_CHAIN;
186
+ if (network !== "private") {
187
+ throw new Error(
188
+ `network must be "private" (the public chain is retired), got ${JSON.stringify(network)}`
189
+ );
190
+ }
191
+ return PRIVATE_CHAIN;
202
192
  }
203
193
 
194
+ // src-ts/constants.ts
195
+ var DEFAULT_ENDPOINT = native.DEFAULT_ENDPOINT;
196
+
204
197
  // src-ts/encrypted-toolcall.ts
205
198
  function columnAad(toolCallId, column) {
206
199
  return `${toolCallId}:${column}`;
@@ -743,7 +736,7 @@ var import_sdk_metrics = require("@opentelemetry/sdk-metrics");
743
736
  var import_exporter_logs_otlp_http = require("@opentelemetry/exporter-logs-otlp-http");
744
737
  var import_sdk_logs = require("@opentelemetry/sdk-logs");
745
738
  var import_node_crypto = require("crypto");
746
- var SDK_VERSION = true ? "0.20.0-dev.0" : "";
739
+ var SDK_VERSION = true ? "0.22.0-dev.0" : "";
747
740
  var SDK_LANGUAGE = "node";
748
741
  function sdkResourceAttributes() {
749
742
  const attrs = {
@@ -998,9 +991,9 @@ function resolve(key, flagValue) {
998
991
  function forcedChainNetwork(flagValue) {
999
992
  const raw = resolve("defaultChainNetwork", flagValue);
1000
993
  if (!raw) return void 0;
1001
- if (raw !== "public" && raw !== "private") {
994
+ if (raw !== "private") {
1002
995
  throw new Error(
1003
- `ATBASH_DEFAULT_CHAIN_NETWORK / defaultChainNetwork must be "public" or "private", got ${JSON.stringify(raw)} \u2014 unset it to let each org's chain decide.`
996
+ `ATBASH_DEFAULT_CHAIN_NETWORK / defaultChainNetwork must be "private" (the public chain is retired), got ${JSON.stringify(raw)} \u2014 unset it to let each org's chain decide.`
1004
997
  );
1005
998
  }
1006
999
  return raw;
@@ -1017,15 +1010,13 @@ function resolveConstructorChain(options) {
1017
1010
  const hasBrid = options.blockchainRid !== void 0;
1018
1011
  if (hasNodeUrls !== hasBrid) {
1019
1012
  throw new Error(
1020
- '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"`.'
1013
+ 'nodeUrls and blockchainRid must be provided together \u2014 passing one without the other 404s every chain request. Prefer `chain: PRIVATE_CHAIN` or `network: "private"`.'
1021
1014
  );
1022
1015
  }
1023
1016
  if (hasNodeUrls && hasBrid) {
1024
- const brid = options.blockchainRid;
1025
- const derivedNetwork = options.network ?? (brid === PUBLIC_CHAIN.blockchainRid ? "public" : brid === PRIVATE_CHAIN.blockchainRid ? "private" : "private");
1026
1017
  return {
1027
- network: derivedNetwork,
1028
- blockchainRid: brid,
1018
+ network: "private",
1019
+ blockchainRid: options.blockchainRid,
1029
1020
  nodeUrls: options.nodeUrls
1030
1021
  };
1031
1022
  }
@@ -1165,10 +1156,9 @@ var Atbash = class _Atbash {
1165
1156
  _Atbash.environmentLogged = true;
1166
1157
  const brief = (rid) => rid ? `${rid.slice(0, 8)}\u2026` : "(unset)";
1167
1158
  this.logger.info?.(
1168
- `[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"}`,
1159
+ `[atbash] environment \u2014 judge=${this.endpoint} privateChain=${brief(native.DEFAULT_PRIVATE_BLOCKCHAIN_RID)} activeChain=${brief(this.blockchainRid)} responseSignatureCheck=${this.verifyPubKey ? "on" : "off"}`,
1169
1160
  {
1170
1161
  judgeEndpoint: this.endpoint,
1171
- publicBlockchainRid: native.DEFAULT_BLOCKCHAIN_RID,
1172
1162
  privateBlockchainRid: native.DEFAULT_PRIVATE_BLOCKCHAIN_RID,
1173
1163
  activeBlockchainRid: this.blockchainRid,
1174
1164
  responseSignatureCheck: Boolean(this.verifyPubKey)
@@ -1441,7 +1431,9 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
1441
1431
  const startedAt = Date.now();
1442
1432
  let chainOpts = options.chainOpts;
1443
1433
  if (options.orgName && this._explicitChain) {
1444
- chainOpts = options.chainOpts ?? { network: this._defaultChain.network };
1434
+ chainOpts = options.chainOpts ?? {
1435
+ blockchainRid: this._defaultChain.blockchainRid
1436
+ };
1445
1437
  } else if (options.orgName && this.forcedNetwork()) {
1446
1438
  chainOpts = { network: this.forcedNetwork() };
1447
1439
  } else if (options.orgName) {
@@ -1451,8 +1443,7 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
1451
1443
  } else {
1452
1444
  const mapNetwork = await this.getActiveNetworkForOrg(options.orgName);
1453
1445
  if (mapNetwork) {
1454
- const chain = mapNetwork === "private" ? PRIVATE_CHAIN : PUBLIC_CHAIN;
1455
- this._chainCache.set(options.orgName, chain);
1446
+ this._chainCache.set(options.orgName, chainForNetwork(mapNetwork));
1456
1447
  chainOpts = { network: mapNetwork };
1457
1448
  } else if (!chainOpts?.blockchainRid) {
1458
1449
  const resolved = await this.resolveChainFromMap(
@@ -1798,15 +1789,19 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
1798
1789
  }
1799
1790
  const parsed = tryParseJson(bytes.toString("utf-8"));
1800
1791
  const data = isRecord2(parsed) ? parsed : {};
1792
+ const rawId = data.tool_call_id ?? data.judgmentId;
1793
+ const statedId = wireText(rawId);
1794
+ const sameCall = rawId === void 0 || rawId === null || statedId === judgmentId;
1801
1795
  return {
1802
1796
  status: normalizeStatus(data.status),
1803
1797
  verdict: normalizeVerdict(data.verdict),
1804
- allow: this.executable(data),
1798
+ allow: sameCall && this.executable(data),
1805
1799
  reason: wireText(data.reason),
1806
- judgmentId: wireText(data.judgmentId, judgmentId),
1800
+ judgmentId: statedId || judgmentId,
1807
1801
  onChain: optBool(data.onChain),
1808
1802
  cached: optBool(data.cached),
1809
- responseTimeMs: optNumber(data.responseTimeMs)
1803
+ // The Dashboard sends response_time_ms; responseTimeMs is the spec name.
1804
+ responseTimeMs: optNumber(data.responseTimeMs ?? data.response_time_ms)
1810
1805
  };
1811
1806
  });
1812
1807
  }
@@ -1990,21 +1985,16 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
1990
1985
  }
1991
1986
  if (resp.status !== 200) throw await this.httpError(resp);
1992
1987
  const data = await this.json(resp);
1993
- if (data?.network === "public" || data?.network === "private") {
1994
- return data.network;
1995
- }
1988
+ if (data?.network === "private") return data.network;
1996
1989
  return null;
1997
1990
  }
1998
1991
  /**
1999
1992
  * Resolve which chain an org's actions should run against. Cached
2000
1993
  * per-client by orgName. Resolution order:
2001
1994
  * 1. `org_networks` map (authoritative).
2002
- * 2. Per-chain subscription fallback — public + private records
2003
- * are fetched in parallel, with `is_private_blockchain` and
2004
- * `assigned_at` reconciling mixed states.
2005
- * A lookup that names exactly one chain wins outright. Where it names
2006
- * neither (a brand-new org) or cannot choose between them, the client's
2007
- * configured default decides.
1995
+ * 2. Subscription fallback — the org's subscription row on the chain.
1996
+ * A lookup that finds the org wins outright. Where it finds nothing (a
1997
+ * brand-new org), the client's configured default decides.
2008
1998
  */
2009
1999
  async resolveChainForOrg(orgName) {
2010
2000
  const name = orgName.trim();
@@ -2026,35 +2016,14 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
2026
2016
  const cached = this._chainCache.get(orgName);
2027
2017
  if (cached) return cached;
2028
2018
  if (mapNetwork) {
2029
- const chain = mapNetwork === "private" ? PRIVATE_CHAIN : PUBLIC_CHAIN;
2030
- this._chainCache.set(orgName, chain);
2031
- return chain;
2032
- }
2033
- const [pubRes, privRes] = await Promise.allSettled([
2034
- this.getOrgSubscription(orgName, "public"),
2035
- this.getOrgSubscription(orgName, "private")
2036
- ]);
2037
- const pubSub = pubRes.status === "fulfilled" ? pubRes.value : null;
2038
- const privSub = privRes.status === "fulfilled" ? privRes.value : null;
2039
- const failure2 = pubRes.status === "rejected" ? pubRes.reason : privRes.status === "rejected" ? privRes.reason : null;
2040
- if (pubSub?.is_private_blockchain) {
2041
- this._chainCache.set(orgName, PRIVATE_CHAIN);
2042
- return PRIVATE_CHAIN;
2043
- }
2044
- if (pubSub && privSub) {
2045
- const chain = privSub.assigned_at === pubSub.assigned_at ? this._defaultChain : privSub.assigned_at > pubSub.assigned_at ? PRIVATE_CHAIN : PUBLIC_CHAIN;
2019
+ const chain = chainForNetwork(mapNetwork);
2046
2020
  this._chainCache.set(orgName, chain);
2047
2021
  return chain;
2048
2022
  }
2049
- if (pubSub) {
2050
- this._chainCache.set(orgName, PUBLIC_CHAIN);
2051
- return PUBLIC_CHAIN;
2052
- }
2053
- if (privSub?.is_private_blockchain) {
2054
- this._chainCache.set(orgName, PRIVATE_CHAIN);
2055
- return PRIVATE_CHAIN;
2056
- }
2057
- if (failure2) {
2023
+ let privSub;
2024
+ try {
2025
+ privSub = await this.getOrgSubscription(orgName, "private");
2026
+ } catch (failure2) {
2058
2027
  const detail = failure2 instanceof Error ? failure2.message : String(failure2);
2059
2028
  throw new AtbashAPIError(
2060
2029
  failure2 instanceof AtbashAPIError ? failure2.status : 0,
@@ -2063,6 +2032,10 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
2063
2032
  this.endpoint
2064
2033
  );
2065
2034
  }
2035
+ if (privSub) {
2036
+ this._chainCache.set(orgName, PRIVATE_CHAIN);
2037
+ return PRIVATE_CHAIN;
2038
+ }
2066
2039
  this._chainCache.set(orgName, this._defaultChain);
2067
2040
  return this._defaultChain;
2068
2041
  }
@@ -2119,8 +2092,7 @@ config.json still holds an "agentKey" (${identity}), but a settings file no long
2119
2092
  */
2120
2093
  bridFromChainOpts(chainOpts) {
2121
2094
  if (chainOpts?.blockchainRid) return chainOpts.blockchainRid;
2122
- if (chainOpts?.network === "private") return PRIVATE_CHAIN.blockchainRid;
2123
- if (chainOpts?.network === "public") return PUBLIC_CHAIN.blockchainRid;
2095
+ if (chainOpts?.network) return chainForNetwork(chainOpts.network).blockchainRid;
2124
2096
  return this.blockchainRid;
2125
2097
  }
2126
2098
  /**
@@ -2717,7 +2689,7 @@ function resolveBlockchainRid(chainOpts) {
2717
2689
  if (chainOpts?.blockchainRid !== void 0) return chainOpts.blockchainRid;
2718
2690
  if (chainOpts?.nodeUrls !== void 0) {
2719
2691
  throw new Error(
2720
- 'chainOpts.nodeUrls no longer selects a chain on its own \u2014 memory reaches the chain through the Atbash service, not a node. Set `blockchainRid`, or `network: "public" | "private"`.'
2692
+ 'chainOpts.nodeUrls no longer selects a chain on its own \u2014 memory reaches the chain through the Atbash service, not a node. Set `blockchainRid`, or `network: "private"`.'
2721
2693
  );
2722
2694
  }
2723
2695
  const config2 = chainForNetwork(
@@ -2765,14 +2737,15 @@ async function decryptRow(row, key) {
2765
2737
  updatedAt: parsed.updated_at
2766
2738
  };
2767
2739
  }
2768
- async function readRows(action, auth, chainOpts, filePath) {
2740
+ async function readRows(action, auth, chainOpts, filePath, extra = {}) {
2769
2741
  const key = await deriveMemoryKey(auth.privkey);
2770
2742
  const rows = await memoryQuery(
2771
2743
  action,
2772
2744
  auth,
2773
2745
  resolveBlockchainRid(chainOpts),
2774
2746
  chainOpts,
2775
- filePath
2747
+ filePath,
2748
+ extra
2776
2749
  );
2777
2750
  return Promise.all((rows ?? []).map((row) => decryptRow(row, key)));
2778
2751
  }
@@ -2792,8 +2765,29 @@ function getRecentAgentMemory(auth, chainOpts, filePath) {
2792
2765
  function getActiveAgentMemory(auth, chainOpts, filePath) {
2793
2766
  return readRows("memory-active", auth, chainOpts, filePath ?? null);
2794
2767
  }
2795
- function getMemoryHistory(auth, chainOpts, filePath) {
2796
- return readRows("memory-history", auth, chainOpts, filePath ?? null);
2768
+ var MEMORY_HISTORY_MAX_COUNT = 200;
2769
+ function memoryHistoryPageArgs(page) {
2770
+ const extra = {};
2771
+ for (const [name, value] of [
2772
+ ["max_count", page?.maxCount],
2773
+ ["before_id", page?.beforeId]
2774
+ ]) {
2775
+ if (value === void 0) continue;
2776
+ if (!Number.isSafeInteger(value) || value < 1) {
2777
+ throw new Error(`getMemoryHistory: ${name} must be a positive integer`);
2778
+ }
2779
+ if (name === "max_count" && value > MEMORY_HISTORY_MAX_COUNT) {
2780
+ throw new Error(`getMemoryHistory: max_count must be at most ${MEMORY_HISTORY_MAX_COUNT}`);
2781
+ }
2782
+ extra[name] = value;
2783
+ }
2784
+ return extra;
2785
+ }
2786
+ async function getMemoryHistory(auth, chainOpts, filePath, page) {
2787
+ const rows = await readRows("memory-history", auth, chainOpts, filePath ?? null, memoryHistoryPageArgs(page));
2788
+ const beforeId = page?.beforeId;
2789
+ const older = beforeId === void 0 ? rows : rows.filter((row) => row.id < beforeId);
2790
+ return page?.maxCount === void 0 ? older : older.slice(0, page.maxCount);
2797
2791
  }
2798
2792
  async function getMemoryById(id, auth, chainOpts) {
2799
2793
  native.validateMemoryId(id);
@@ -4036,8 +4030,6 @@ function diffMemorySnapshots(before, after) {
4036
4030
  Atbash,
4037
4031
  AtbashAPIError,
4038
4032
  BOOT_SYNC_HINT,
4039
- DEFAULT_BLOCKCHAIN_RID,
4040
- DEFAULT_CHROMIA_NODE_URLS,
4041
4033
  DEFAULT_ENDPOINT,
4042
4034
  DEFAULT_MEMORY_PATH_PATTERNS,
4043
4035
  DEFAULT_MEMORY_READ_TOOL_NAMES,
@@ -4050,7 +4042,6 @@ function diffMemorySnapshots(before, after) {
4050
4042
  MemoryGuardManager,
4051
4043
  MemoryIntegrityError,
4052
4044
  PRIVATE_CHAIN,
4053
- PUBLIC_CHAIN,
4054
4045
  PointerStore,
4055
4046
  SignatureVerificationError,
4056
4047
  bootSyncFailureLine,