@atbash/sdk 0.10.1-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.
@@ -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
  /**
@@ -1145,4 +1164,4 @@ declare function containsSecret(text: string): boolean;
1145
1164
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1146
1165
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1147
1166
 
1148
- 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, 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 };
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/browser.mjs CHANGED
@@ -43233,9 +43233,9 @@ var index = /* @__PURE__ */ getDefaultExportFromCjs(builtExports);
43233
43233
 
43234
43234
  // src-ts/browser/native.ts
43235
43235
  var { Buffer: Buffer3, gtx: pcgtx } = index;
43236
- var DEV_ENDPOINT = "https://chromia-verified-ai-dev-two.vercel.app";
43237
- var DEV_BLOCKCHAIN_RID = "02668C5218871F69A93CC0F7032DCFFE06EF0D35EF2F0B07A92A3D83A3F23A7D";
43238
- var DEV_PRIVATE_BLOCKCHAIN_RID = "2603569AE8DC3F254323F719C8D4347BBA964E874E781291F8474236BE8B6493";
43236
+ var PROD_ENDPOINT = "https://atbash.ai";
43237
+ var PROD_BLOCKCHAIN_RID = "0163241D9AF137638E63E48EFCDE15510F38C2426F7AD5DC726AF60351BF4DFE";
43238
+ var PROD_PRIVATE_BLOCKCHAIN_RID = "39FFD3557D0296CB2C57FDC6A3B8C024E95639CF4964DA08141AC20C6344D408";
43239
43239
  var DEFAULT_CHROMIA_NODE_URLS_ARR = [
43240
43240
  "https://node0.testnet.chromia.com:7740",
43241
43241
  "https://node1.testnet.chromia.com:7740",
@@ -43394,9 +43394,9 @@ var native = {
43394
43394
  deriveMemoryKey,
43395
43395
  encryptMemoryContent,
43396
43396
  decryptMemoryContent,
43397
- DEFAULT_BLOCKCHAIN_RID: DEV_BLOCKCHAIN_RID,
43398
- DEFAULT_PRIVATE_BLOCKCHAIN_RID: DEV_PRIVATE_BLOCKCHAIN_RID,
43399
- DEFAULT_ENDPOINT: DEV_ENDPOINT,
43397
+ DEFAULT_BLOCKCHAIN_RID: PROD_BLOCKCHAIN_RID,
43398
+ DEFAULT_PRIVATE_BLOCKCHAIN_RID: PROD_PRIVATE_BLOCKCHAIN_RID,
43399
+ DEFAULT_ENDPOINT: PROD_ENDPOINT,
43400
43400
  // Browser has no NAPI channel to Rust's HONEYCOMB_KEY — telemetry
43401
43401
  // silently no-ops. `HONEYCOMB_API_KEY` env var still overrides at runtime.
43402
43402
  HONEYCOMB_KEY: "",
@@ -44259,11 +44259,14 @@ function signEncryptedToolCall(toolCallId, action, context, toolName, toolArgsJs
44259
44259
  }
44260
44260
 
44261
44261
  // src-ts/endpoint.ts
44262
- var ALLOWED_JUDGE_HOSTS = /* @__PURE__ */ new Set([
44263
- "atbash.ai",
44264
- "www.atbash.ai",
44265
- "chromia-verified-ai-dev-two.vercel.app"
44266
- ]);
44262
+ function buildAllowedJudgeHosts() {
44263
+ return /* @__PURE__ */ new Set([
44264
+ "atbash.ai",
44265
+ "www.atbash.ai",
44266
+ new URL(DEFAULT_ENDPOINT).hostname.toLowerCase()
44267
+ ]);
44268
+ }
44269
+ var ALLOWED_JUDGE_HOSTS = buildAllowedJudgeHosts();
44267
44270
  function validateJudgeEndpoint(judge) {
44268
44271
  const policy = judge?.policy === "self-hosted" ? "self-hosted" : "default";
44269
44272
  const candidate = judge?.endpoint?.trim() || DEFAULT_ENDPOINT;
@@ -44465,6 +44468,8 @@ var Atbash = class _Atbash {
44465
44468
  orgEncryptionPubKey;
44466
44469
  /** When true (default), `auditToolCall` denies on any error. */
44467
44470
  failClosed;
44471
+ /** Org key learned from the last agent-exists check, for this agent only. */
44472
+ _orgKeyFromChain = null;
44468
44473
  logger;
44469
44474
  http;
44470
44475
  /**
@@ -44549,6 +44554,10 @@ var Atbash = class _Atbash {
44549
44554
  );
44550
44555
  await this.raiseIfError(resp);
44551
44556
  const data = await this.json(resp);
44557
+ if (pk === this.auth.pubkey) {
44558
+ const key3 = data?.org_encryption_pubkey;
44559
+ this._orgKeyFromChain = typeof key3 === "string" && key3 ? key3 : null;
44560
+ }
44552
44561
  return Boolean(data?.registered);
44553
44562
  });
44554
44563
  }
@@ -44579,7 +44588,7 @@ var Atbash = class _Atbash {
44579
44588
  }
44580
44589
  const toolCallId = generateToolCallId();
44581
44590
  const brid = this.bridFromChainOpts(options.chainOpts);
44582
- const orgKey = options.orgEncryptionPubKey ?? this.orgEncryptionPubKey;
44591
+ const orgKey = options.orgEncryptionPubKey ?? this.orgEncryptionPubKey ?? this._orgKeyFromChain;
44583
44592
  try {
44584
44593
  const signedHex = orgKey ? signEncryptedToolCall(
44585
44594
  toolCallId,
@@ -45738,6 +45747,7 @@ export {
45738
45747
  MemoryIntegrityError,
45739
45748
  PointerStore,
45740
45749
  SignatureVerificationError,
45750
+ buildAllowedJudgeHosts,
45741
45751
  claimHashHex,
45742
45752
  classifyMemoryRead,
45743
45753
  classifyMemoryWrite,