@atbash/sdk 0.10.0-dev.0 → 0.10.4-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
@@ -11,6 +11,23 @@ interface ValidatedEndpoint {
11
11
  policy: "default" | "self-hosted";
12
12
  verifyPubKey: string | null;
13
13
  }
14
+ /**
15
+ * Builds the trusted judge host set.
16
+ *
17
+ * The compiled-in default is always trusted: a `prod` build resolves it to
18
+ * atbash.ai, a dev build to whatever DEV_ENDPOINT was set at build time. No
19
+ * dev host is spelled out in source, and dev builds still validate their own
20
+ * default.
21
+ *
22
+ * Exported for tests only. The set is a build-time value and is deliberately
23
+ * never read from the process environment — an env var would let anyone widen
24
+ * the allowlist of an already-shipped artifact, which is the silent-redirection
25
+ * attack the allowlist exists to prevent (F-003). Asserting that requires
26
+ * calling this with the environment set, so it cannot stay module-private.
27
+ *
28
+ * @internal
29
+ */
30
+ declare function buildAllowedJudgeHosts(): ReadonlySet<string>;
14
31
  declare function validateJudgeEndpoint(judge?: JudgeEndpointConfig): ValidatedEndpoint;
15
32
 
16
33
  /**
@@ -395,6 +412,8 @@ declare class Atbash {
395
412
  readonly orgEncryptionPubKey?: string;
396
413
  /** When true (default), `auditToolCall` denies on any error. */
397
414
  readonly failClosed: boolean;
415
+ /** Org key learned from the last agent-exists check, for this agent only. */
416
+ private _orgKeyFromChain;
398
417
  private readonly logger;
399
418
  private readonly http;
400
419
  /**
@@ -1049,35 +1068,16 @@ declare function flushTelemetry(): Promise<void>;
1049
1068
  declare function shutdownTelemetry(): Promise<void>;
1050
1069
 
1051
1070
  /**
1052
- * Signs `log_encrypted_tool_call` the ciphertext-only counterpart of
1053
- * `log_tool_call`. Rust core owns the encrypt + hash + GTX sign flow;
1054
- * this module is a thin wrapper. Browser callers get the pure-TS shim
1055
- * at `src-ts/browser/encrypted-toolcall.ts` (NAPI can't run in-browser).
1056
- */
1057
- /** Plaintext fields of a tool call, sealed into a single ECIES payload. */
1058
- interface ToolCallPlaintext {
1059
- tool_name: string;
1060
- action: string;
1061
- context: string;
1062
- tool_args_json: string;
1063
- }
1064
- /**
1065
- * Canonical form of an action for the retry-cache hash. Byte-identical to
1066
- * the dashboard's `normalizeActionForHash` — diverging silently breaks
1067
- * YELLOW-hold retry resolution.
1071
+ * Rust core does the work; `browser/encrypted-toolcall.ts` mirrors it for the
1072
+ * browser and must produce the same columns.
1068
1073
  */
1074
+ /** Must match `column_aad` in the core — the label binds a ciphertext to its column. */
1075
+ declare function columnAad(toolCallId: string, column: string): string;
1076
+ /** Byte-identical to the dashboard's copy — diverging breaks hold-retry resolution. */
1069
1077
  declare function normalizeActionForHash(action: string): string;
1070
- /**
1071
- * Signed commitment to the plaintext claims the caller sends alongside the
1072
- * ciphertext. The judge reads plaintext from the request body but holds no
1073
- * org key; this hash lets it verify body-vs-ciphertext without decrypting.
1074
- * Byte-identical to the dashboard's `claimHashHex`.
1075
- */
1078
+ /** Lets the judge check the request body against the ciphertext without an org key. */
1076
1079
  declare function claimHashHex(toolName: string, action: string, context: string, toolArgsJson: string): string;
1077
- /**
1078
- * Build + sign a `log_encrypted_tool_call` transaction. Returns hex-encoded
1079
- * signed tx, ready to POST as `signed_log_tool_call`.
1080
- */
1080
+ /** @returns hex-encoded signed tx, ready to POST as `signed_log_tool_call`. */
1081
1081
  declare function signEncryptedToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, orgEncryptionPubKey: string, privkeyHex: string, blockchainRidHex: string): string;
1082
1082
 
1083
1083
  /**
@@ -1126,6 +1126,29 @@ declare function decryptForOrg(payload: Uint8Array, orgPrivKeyHex: string, aad:
1126
1126
  */
1127
1127
  declare function encryptedLength(plaintextByteLength: number): number;
1128
1128
 
1129
+ /**
1130
+ * atb1.<key-fingerprint>.<claim-hash>.<base64 ciphertext>
1131
+ *
1132
+ * Normative spec: `core/src/crypto_envelope.rs`. This mirrors it for the browser.
1133
+ */
1134
+ interface Envelope {
1135
+ /** First 8 bytes of the recipient public key, hex. May be empty. */
1136
+ keyFingerprint: string;
1137
+ /** Commitment to the accompanying plaintext claims. May be empty. */
1138
+ claimHash: string;
1139
+ /** Raw ECIES payload. */
1140
+ payload: Uint8Array;
1141
+ }
1142
+ declare function packEnvelope(payload: Uint8Array, keyFingerprint?: string, claimHash?: string): string;
1143
+ /**
1144
+ * Stays true for a truncated envelope that `parseEnvelope` rejects — a severed
1145
+ * ciphertext is not plaintext, so callers must show a placeholder.
1146
+ */
1147
+ declare function isEnvelope(value: string): boolean;
1148
+ /** Null, not a throw — pre-encryption records are plaintext. */
1149
+ declare function parseEnvelope(value: string): Envelope | null;
1150
+ declare function keyFingerprintOf(pubKeyHex: string): string;
1151
+
1129
1152
  declare function isValidPrivateKey(hex: string): boolean;
1130
1153
  declare function derivePublicKey(privkey: string): string;
1131
1154
  declare function generateKeypair(): KeyPair;
@@ -1141,4 +1164,4 @@ declare function containsSecret(text: string): boolean;
1141
1164
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1142
1165
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1143
1166
 
1144
- export { type ActionType, type AgentAuth, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, 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 FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, 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 ToolCallPlaintext, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, claimHashHex, classifyMemoryRead, classifyMemoryWrite, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRollbackHistory, guardMemoryWrite, isValidPrivateKey, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeForMatching, normalizeStatus, normalizeVerdict, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
1167
+ export { type ActionType, type AgentAuth, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, 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, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, 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, buildAllowedJudgeHosts, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRollbackHistory, guardMemoryWrite, isEnvelope, isValidPrivateKey, keyFingerprintOf, 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/index.d.ts CHANGED
@@ -11,6 +11,23 @@ interface ValidatedEndpoint {
11
11
  policy: "default" | "self-hosted";
12
12
  verifyPubKey: string | null;
13
13
  }
14
+ /**
15
+ * Builds the trusted judge host set.
16
+ *
17
+ * The compiled-in default is always trusted: a `prod` build resolves it to
18
+ * atbash.ai, a dev build to whatever DEV_ENDPOINT was set at build time. No
19
+ * dev host is spelled out in source, and dev builds still validate their own
20
+ * default.
21
+ *
22
+ * Exported for tests only. The set is a build-time value and is deliberately
23
+ * never read from the process environment — an env var would let anyone widen
24
+ * the allowlist of an already-shipped artifact, which is the silent-redirection
25
+ * attack the allowlist exists to prevent (F-003). Asserting that requires
26
+ * calling this with the environment set, so it cannot stay module-private.
27
+ *
28
+ * @internal
29
+ */
30
+ declare function buildAllowedJudgeHosts(): ReadonlySet<string>;
14
31
  declare function validateJudgeEndpoint(judge?: JudgeEndpointConfig): ValidatedEndpoint;
15
32
 
16
33
  /**
@@ -395,6 +412,8 @@ declare class Atbash {
395
412
  readonly orgEncryptionPubKey?: string;
396
413
  /** When true (default), `auditToolCall` denies on any error. */
397
414
  readonly failClosed: boolean;
415
+ /** Org key learned from the last agent-exists check, for this agent only. */
416
+ private _orgKeyFromChain;
398
417
  private readonly logger;
399
418
  private readonly http;
400
419
  /**
@@ -1049,35 +1068,16 @@ declare function flushTelemetry(): Promise<void>;
1049
1068
  declare function shutdownTelemetry(): Promise<void>;
1050
1069
 
1051
1070
  /**
1052
- * Signs `log_encrypted_tool_call` the ciphertext-only counterpart of
1053
- * `log_tool_call`. Rust core owns the encrypt + hash + GTX sign flow;
1054
- * this module is a thin wrapper. Browser callers get the pure-TS shim
1055
- * at `src-ts/browser/encrypted-toolcall.ts` (NAPI can't run in-browser).
1056
- */
1057
- /** Plaintext fields of a tool call, sealed into a single ECIES payload. */
1058
- interface ToolCallPlaintext {
1059
- tool_name: string;
1060
- action: string;
1061
- context: string;
1062
- tool_args_json: string;
1063
- }
1064
- /**
1065
- * Canonical form of an action for the retry-cache hash. Byte-identical to
1066
- * the dashboard's `normalizeActionForHash` — diverging silently breaks
1067
- * YELLOW-hold retry resolution.
1071
+ * Rust core does the work; `browser/encrypted-toolcall.ts` mirrors it for the
1072
+ * browser and must produce the same columns.
1068
1073
  */
1074
+ /** Must match `column_aad` in the core — the label binds a ciphertext to its column. */
1075
+ declare function columnAad(toolCallId: string, column: string): string;
1076
+ /** Byte-identical to the dashboard's copy — diverging breaks hold-retry resolution. */
1069
1077
  declare function normalizeActionForHash(action: string): string;
1070
- /**
1071
- * Signed commitment to the plaintext claims the caller sends alongside the
1072
- * ciphertext. The judge reads plaintext from the request body but holds no
1073
- * org key; this hash lets it verify body-vs-ciphertext without decrypting.
1074
- * Byte-identical to the dashboard's `claimHashHex`.
1075
- */
1078
+ /** Lets the judge check the request body against the ciphertext without an org key. */
1076
1079
  declare function claimHashHex(toolName: string, action: string, context: string, toolArgsJson: string): string;
1077
- /**
1078
- * Build + sign a `log_encrypted_tool_call` transaction. Returns hex-encoded
1079
- * signed tx, ready to POST as `signed_log_tool_call`.
1080
- */
1080
+ /** @returns hex-encoded signed tx, ready to POST as `signed_log_tool_call`. */
1081
1081
  declare function signEncryptedToolCall(toolCallId: string, action: string, context: string, toolName: string, toolArgsJson: string, orgEncryptionPubKey: string, privkeyHex: string, blockchainRidHex: string): string;
1082
1082
 
1083
1083
  /**
@@ -1126,6 +1126,29 @@ declare function decryptForOrg(payload: Uint8Array, orgPrivKeyHex: string, aad:
1126
1126
  */
1127
1127
  declare function encryptedLength(plaintextByteLength: number): number;
1128
1128
 
1129
+ /**
1130
+ * atb1.<key-fingerprint>.<claim-hash>.<base64 ciphertext>
1131
+ *
1132
+ * Normative spec: `core/src/crypto_envelope.rs`. This mirrors it for the browser.
1133
+ */
1134
+ interface Envelope {
1135
+ /** First 8 bytes of the recipient public key, hex. May be empty. */
1136
+ keyFingerprint: string;
1137
+ /** Commitment to the accompanying plaintext claims. May be empty. */
1138
+ claimHash: string;
1139
+ /** Raw ECIES payload. */
1140
+ payload: Uint8Array;
1141
+ }
1142
+ declare function packEnvelope(payload: Uint8Array, keyFingerprint?: string, claimHash?: string): string;
1143
+ /**
1144
+ * Stays true for a truncated envelope that `parseEnvelope` rejects — a severed
1145
+ * ciphertext is not plaintext, so callers must show a placeholder.
1146
+ */
1147
+ declare function isEnvelope(value: string): boolean;
1148
+ /** Null, not a throw — pre-encryption records are plaintext. */
1149
+ declare function parseEnvelope(value: string): Envelope | null;
1150
+ declare function keyFingerprintOf(pubKeyHex: string): string;
1151
+
1129
1152
  declare function isValidPrivateKey(hex: string): boolean;
1130
1153
  declare function derivePublicKey(privkey: string): string;
1131
1154
  declare function generateKeypair(): KeyPair;
@@ -1141,4 +1164,4 @@ declare function containsSecret(text: string): boolean;
1141
1164
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1142
1165
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1143
1166
 
1144
- export { type ActionType, type AgentAuth, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, 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 FromConfigOptions, type GuardLogger, type GuardMemoryDecision, type GuardMemoryWriteInput, type GuardMemoryWriteResult, type HeldAction, type HeldActionReview, type HookDecision, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, 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 ToolCallPlaintext, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, claimHashHex, classifyMemoryRead, classifyMemoryWrite, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRollbackHistory, guardMemoryWrite, isValidPrivateKey, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeForMatching, normalizeStatus, normalizeVerdict, pubkeyToHex, recordCall, recordDuration, redactJsonStrings, redactSecrets, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
1167
+ export { type ActionType, type AgentAuth, type AgentMemoryEntry, type AgentPolicy, type AnomalySeverity, type AnomalyType, Atbash, AtbashAPIError, type AtbashLogger, type AtbashOptions, type AtbashUserConfig, 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, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, 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, buildAllowedJudgeHosts, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRollbackHistory, guardMemoryWrite, isEnvelope, isValidPrivateKey, keyFingerprintOf, 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/index.js CHANGED
@@ -2867,9 +2867,11 @@ __export(src_ts_exports, {
2867
2867
  MemoryIntegrityError: () => MemoryIntegrityError,
2868
2868
  PointerStore: () => PointerStore,
2869
2869
  SignatureVerificationError: () => SignatureVerificationError,
2870
+ buildAllowedJudgeHosts: () => buildAllowedJudgeHosts,
2870
2871
  claimHashHex: () => claimHashHex,
2871
2872
  classifyMemoryRead: () => classifyMemoryRead,
2872
2873
  classifyMemoryWrite: () => classifyMemoryWrite,
2874
+ columnAad: () => columnAad,
2873
2875
  commitMemoryVersion: () => commitMemoryVersion,
2874
2876
  containsEvasionCharacters: () => containsEvasionCharacters,
2875
2877
  containsSecret: () => containsSecret,
@@ -2897,7 +2899,9 @@ __export(src_ts_exports, {
2897
2899
  getMemoryHistory: () => getMemoryHistory,
2898
2900
  getRollbackHistory: () => getRollbackHistory,
2899
2901
  guardMemoryWrite: () => guardMemoryWrite,
2902
+ isEnvelope: () => isEnvelope,
2900
2903
  isValidPrivateKey: () => isValidPrivateKey,
2904
+ keyFingerprintOf: () => keyFingerprintOf,
2901
2905
  loadAgent: () => loadAgent,
2902
2906
  loadAgentFromFile: () => loadAgentFromFile,
2903
2907
  loadUserConfig: () => loadUserConfig,
@@ -2905,6 +2909,8 @@ __export(src_ts_exports, {
2905
2909
  normalizeForMatching: () => normalizeForMatching,
2906
2910
  normalizeStatus: () => normalizeStatus,
2907
2911
  normalizeVerdict: () => normalizeVerdict,
2912
+ packEnvelope: () => packEnvelope,
2913
+ parseEnvelope: () => parseEnvelope,
2908
2914
  pubkeyToHex: () => pubkeyToHex,
2909
2915
  recordCall: () => recordCall,
2910
2916
  recordDuration: () => recordDuration,
@@ -2976,6 +2982,9 @@ function chainForNetwork(network) {
2976
2982
  }
2977
2983
 
2978
2984
  // src-ts/encrypted-toolcall.ts
2985
+ function columnAad(toolCallId, column) {
2986
+ return `${toolCallId}:${column}`;
2987
+ }
2979
2988
  function normalizeActionForHash(action) {
2980
2989
  return native.normalizeActionForHash(action);
2981
2990
  }
@@ -2996,11 +3005,14 @@ function signEncryptedToolCall(toolCallId, action, context, toolName, toolArgsJs
2996
3005
  }
2997
3006
 
2998
3007
  // src-ts/endpoint.ts
2999
- var ALLOWED_JUDGE_HOSTS = /* @__PURE__ */ new Set([
3000
- "atbash.ai",
3001
- "www.atbash.ai",
3002
- "chromia-verified-ai-dev-two.vercel.app"
3003
- ]);
3008
+ function buildAllowedJudgeHosts() {
3009
+ return /* @__PURE__ */ new Set([
3010
+ "atbash.ai",
3011
+ "www.atbash.ai",
3012
+ new URL(DEFAULT_ENDPOINT).hostname.toLowerCase()
3013
+ ]);
3014
+ }
3015
+ var ALLOWED_JUDGE_HOSTS = buildAllowedJudgeHosts();
3004
3016
  function validateJudgeEndpoint(judge) {
3005
3017
  const policy = judge?.policy === "self-hosted" ? "self-hosted" : "default";
3006
3018
  const candidate = judge?.endpoint?.trim() || DEFAULT_ENDPOINT;
@@ -3353,6 +3365,8 @@ var Atbash = class _Atbash {
3353
3365
  orgEncryptionPubKey;
3354
3366
  /** When true (default), `auditToolCall` denies on any error. */
3355
3367
  failClosed;
3368
+ /** Org key learned from the last agent-exists check, for this agent only. */
3369
+ _orgKeyFromChain = null;
3356
3370
  logger;
3357
3371
  http;
3358
3372
  /**
@@ -3437,6 +3451,10 @@ var Atbash = class _Atbash {
3437
3451
  );
3438
3452
  await this.raiseIfError(resp);
3439
3453
  const data = await this.json(resp);
3454
+ if (pk === this.auth.pubkey) {
3455
+ const key3 = data?.org_encryption_pubkey;
3456
+ this._orgKeyFromChain = typeof key3 === "string" && key3 ? key3 : null;
3457
+ }
3440
3458
  return Boolean(data?.registered);
3441
3459
  });
3442
3460
  }
@@ -3467,7 +3485,7 @@ var Atbash = class _Atbash {
3467
3485
  }
3468
3486
  const toolCallId = generateToolCallId();
3469
3487
  const brid = this.bridFromChainOpts(options.chainOpts);
3470
- const orgKey = options.orgEncryptionPubKey ?? this.orgEncryptionPubKey;
3488
+ const orgKey = options.orgEncryptionPubKey ?? this.orgEncryptionPubKey ?? this._orgKeyFromChain;
3471
3489
  try {
3472
3490
  const signedHex = orgKey ? signEncryptedToolCall(
3473
3491
  toolCallId,
@@ -43008,6 +43026,44 @@ function encryptedLength(plaintextByteLength) {
43008
43026
  return native.encryptedLength(plaintextByteLength);
43009
43027
  }
43010
43028
 
43029
+ // src-ts/crypto/envelope.ts
43030
+ var PREFIX = "atb1";
43031
+ var SEPARATOR = ".";
43032
+ function toBase64(bytes) {
43033
+ let binary = "";
43034
+ for (const b of bytes) binary += String.fromCharCode(b);
43035
+ return btoa(binary);
43036
+ }
43037
+ function fromBase64(text) {
43038
+ const binary = atob(text);
43039
+ const out = new Uint8Array(binary.length);
43040
+ for (let i = 0; i < binary.length; i++) out[i] = binary.charCodeAt(i);
43041
+ return out;
43042
+ }
43043
+ function packEnvelope(payload, keyFingerprint = "", claimHash = "") {
43044
+ return [PREFIX, keyFingerprint, claimHash, toBase64(payload)].join(SEPARATOR);
43045
+ }
43046
+ function fieldWidthOk(value, hexChars) {
43047
+ return value.length === 0 ? true : value.length === hexChars && /^[0-9a-f]+$/.test(value);
43048
+ }
43049
+ function isEnvelope(value) {
43050
+ if (typeof value !== "string" || !value.startsWith(PREFIX + SEPARATOR)) return false;
43051
+ const parts = value.split(SEPARATOR);
43052
+ return parts.length >= 4 && fieldWidthOk(parts[1], 16) && fieldWidthOk(parts[2], 64);
43053
+ }
43054
+ function parseEnvelope(value) {
43055
+ if (!isEnvelope(value)) return null;
43056
+ const [, keyFingerprint, claimHash, ...rest] = value.split(SEPARATOR);
43057
+ try {
43058
+ return { keyFingerprint, claimHash, payload: fromBase64(rest.join(SEPARATOR)) };
43059
+ } catch {
43060
+ return null;
43061
+ }
43062
+ }
43063
+ function keyFingerprintOf(pubKeyHex) {
43064
+ return pubKeyHex.trim().replace(/^0x/i, "").toLowerCase().slice(0, 16);
43065
+ }
43066
+
43011
43067
  // src-ts/index.ts
43012
43068
  function isValidPrivateKey(hex) {
43013
43069
  return native.isValidPrivateKey(hex);
@@ -43078,9 +43134,11 @@ function diffMemorySnapshots(before, after) {
43078
43134
  MemoryIntegrityError,
43079
43135
  PointerStore,
43080
43136
  SignatureVerificationError,
43137
+ buildAllowedJudgeHosts,
43081
43138
  claimHashHex,
43082
43139
  classifyMemoryRead,
43083
43140
  classifyMemoryWrite,
43141
+ columnAad,
43084
43142
  commitMemoryVersion,
43085
43143
  containsEvasionCharacters,
43086
43144
  containsSecret,
@@ -43108,7 +43166,9 @@ function diffMemorySnapshots(before, after) {
43108
43166
  getMemoryHistory,
43109
43167
  getRollbackHistory,
43110
43168
  guardMemoryWrite,
43169
+ isEnvelope,
43111
43170
  isValidPrivateKey,
43171
+ keyFingerprintOf,
43112
43172
  loadAgent,
43113
43173
  loadAgentFromFile,
43114
43174
  loadUserConfig,
@@ -43116,6 +43176,8 @@ function diffMemorySnapshots(before, after) {
43116
43176
  normalizeForMatching,
43117
43177
  normalizeStatus,
43118
43178
  normalizeVerdict,
43179
+ packEnvelope,
43180
+ parseEnvelope,
43119
43181
  pubkeyToHex,
43120
43182
  recordCall,
43121
43183
  recordDuration,