@atbash/sdk 0.10.5-dev.0 → 0.10.7-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.
@@ -310,6 +310,12 @@ interface AtbashOptions {
310
310
  orgEncryptionPubKey?: string;
311
311
  /** When true (default), `auditToolCall` denies on any error. */
312
312
  failClosed?: boolean;
313
+ /**
314
+ * Verbose diagnostics. Off by default. When on, a failed judge call also
315
+ * logs the response body, which is the difference between "judge API failed"
316
+ * and knowing why it failed. Opt-in because that body can echo the action.
317
+ */
318
+ debug?: boolean;
313
319
  logger?: AtbashLogger;
314
320
  }
315
321
  /** Canonical decision returned by `auditToolCall`. */
@@ -350,6 +356,8 @@ interface FromConfigOptions {
350
356
  /** Default org name — see {@link AtbashOptions.orgName}. */
351
357
  orgName?: string;
352
358
  failClosed?: boolean;
359
+ /** See {@link AtbashOptions.debug}. */
360
+ debug?: boolean;
353
361
  logger?: AtbashLogger;
354
362
  }
355
363
  /** Options accepted by `judgeAction`. */
@@ -414,6 +422,7 @@ declare class Atbash {
414
422
  readonly failClosed: boolean;
415
423
  /** Org key learned from the last agent-exists check, for this agent only. */
416
424
  private _orgKeyFromChain;
425
+ private readonly debug;
417
426
  private readonly logger;
418
427
  private readonly http;
419
428
  /**
@@ -427,7 +436,20 @@ declare class Atbash {
427
436
  * server-side replay protection windows never expire it mid-session.
428
437
  */
429
438
  private _authBearer;
439
+ /** Guards `logEnvironmentOnce` — hosts construct several clients. */
440
+ private static environmentLogged;
430
441
  constructor(privkey: string, options?: AtbashOptions);
442
+ /**
443
+ * Say which environment this build talks to, once per process.
444
+ *
445
+ * The endpoint and both chain RIDs are compiled in, chosen by the npm tag,
446
+ * and no configuration repoints a released build. So installing the build
447
+ * for the wrong environment is invisible: the plugin loads, the hook fires,
448
+ * and every judge call fails because the agent does not exist on the chain
449
+ * this build targets. Organisation names are not unique across environments
450
+ * either, so an org resolving is not evidence the build is right.
451
+ */
452
+ private logEnvironmentOnce;
431
453
  /**
432
454
  * Construct from resolved config: explicit overrides → env vars → the
433
455
  * `~/.config/atbash/config.json` file (see userConfig.resolve). The private
@@ -470,6 +492,15 @@ declare class Atbash {
470
492
  * explicitly false.
471
493
  */
472
494
  auditToolCall(input: ToolCallInput): Promise<Decision>;
495
+ /**
496
+ * One exit for every judge failure.
497
+ *
498
+ * Status and reason go in the *message*, not only in the meta object: hosts
499
+ * print the message and drop the meta, which is why this read as a bare
500
+ * "judge API failed" while the judge was answering with a precise reason.
501
+ * The response body follows only under `debug`, since it can echo the action.
502
+ */
503
+ private failJudge;
473
504
  private fail;
474
505
  getJudgmentStatus(judgmentId: string, agentPubkey?: string): Promise<JudgmentStatus>;
475
506
  getToolCalls(maxCount: number): Promise<ToolCallRecord[]>;
@@ -585,6 +616,8 @@ interface AtbashUserConfig {
585
616
  blockchainRid?: string;
586
617
  provider?: string;
587
618
  providerModel?: string;
619
+ /** "1" / "true" turns on verbose diagnostics. See AtbashOptions.debug. */
620
+ debug?: string;
588
621
  }
589
622
  declare function getConfigDir(): string;
590
623
  declare function getConfigPath(): string;
@@ -595,6 +628,26 @@ declare function resolve(key: keyof AtbashUserConfig, flagValue?: string): strin
595
628
  declare function resolveKeyPath(input?: string): string;
596
629
  declare function loadAgentFromFile(keyPath?: string): AgentAuth;
597
630
 
631
+ /**
632
+ * Accepted key filenames, in precedence order.
633
+ *
634
+ * `guard-client-key` stays first: it is the name every existing install
635
+ * already has, and changing which file wins would silently switch agent
636
+ * identity for anyone holding both. `atbash-client-key` is accepted because
637
+ * it is the name people actually create — the old one carries retired
638
+ * branding — and hitting ENOENT on a key you just wrote, from a plugin that
639
+ * still reports itself installed, is a miserable first run.
640
+ */
641
+ declare const KEY_FILENAMES: readonly ["guard-client-key", "atbash-client-key"];
642
+ /** Every path checked when no explicit key path is given, in order. */
643
+ declare function keyPathCandidates(): string[];
644
+ /**
645
+ * Pick the key path: an explicit input wins untouched; otherwise the first
646
+ * accepted filename that exists, falling back to the preferred name so the
647
+ * error names something recognisable when nothing is there.
648
+ */
649
+ declare function chooseKeyPath(input: string | undefined, exists: (p: string) => boolean): string;
650
+
598
651
  /**
599
652
  * Canonical secret kinds reported by the Rust core in `SecretMatch.kind`.
600
653
  * Wire is permissive (modelled as a free string in {@link SecretMatch})
@@ -613,6 +666,26 @@ declare function verifyJudgeResponseSignature(bodyBytes: Uint8Array, signatureHe
613
666
  reason?: string;
614
667
  };
615
668
 
669
+ /**
670
+ * The boot memory-sync failure line.
671
+ *
672
+ * Split out of `guard-manager.ts` so it can be asserted without constructing a
673
+ * guard manager, which needs the native addon. The message is the whole point
674
+ * of AT-304: hosts print the message and drop the structured meta, so a cause
675
+ * that lives only in meta never reaches the operator.
676
+ */
677
+ /** Advice, not a diagnosis — appended only when the cause is unhelpful. */
678
+ declare const BOOT_SYNC_HINT = "check the chain endpoint and orgName if the cause above does not explain it";
679
+ /**
680
+ * Lead with the real cause.
681
+ *
682
+ * The previous wording named the chain endpoint and orgName as the things to
683
+ * check, which sent operators to verify configuration that was already correct
684
+ * while the actual cause (a node answering `404 Can't find blockchain with
685
+ * blockchainRID: …` for a chain it does not host) stayed hidden.
686
+ */
687
+ declare function bootSyncFailureLine(cause: unknown): string;
688
+
616
689
  /** Derive the 32-byte AES key from an agent's secp256k1 privkey (hex). Deterministic — same privkey always yields the same key. */
617
690
  declare function deriveMemoryKey(privkey: string): Promise<Buffer>;
618
691
  /** Encrypt UTF-8 plaintext. `ciphertext` has the 16-byte GCM auth tag appended, matching the SDK's on-chain byte layout. */
@@ -1164,4 +1237,4 @@ declare function containsSecret(text: string): boolean;
1164
1237
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1165
1238
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1166
1239
 
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 };
1240
+ export { type ActionType, type AgentAuth, 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, 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, getActiveMemory, getActiveMemoryId, getAllAgentMemory, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, 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 };