@atbash/sdk 0.10.7-dev.0 → 0.10.9-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.
@@ -576,7 +576,13 @@ declare class Atbash {
576
576
  private raiseIfError;
577
577
  /** Wrap a failed HTTP *response* (non-2xx / non-200) as an AtbashAPIError. */
578
578
  private httpError;
579
- /** Wrap a *transport* failure (fetch threw, no response) as an AtbashAPIError. */
579
+ /**
580
+ * Wrap a transport failure (fetch threw, no response) as an AtbashAPIError.
581
+ *
582
+ * `HttpTransportError.kind` names the cause; the message is already
583
+ * human-readable. `debug` echoes the original exception so operators can
584
+ * cross-reference with node / undici logs when a class doesn't match.
585
+ */
580
586
  private transportError;
581
587
  private json;
582
588
  static generateKeypair(): KeyPair;
@@ -602,6 +608,43 @@ declare class SignatureVerificationError extends Error {
602
608
  constructor(message: string);
603
609
  }
604
610
 
611
+ /**
612
+ * Thin typed fetch wrapper.
613
+ *
614
+ * openapi-typescript emits types only (no runtime client), so this is the
615
+ * single hand-written transport — generic `get`/`post` over global `fetch`
616
+ * with a per-request timeout. The endpoint-specific request/response *shapes*
617
+ * are pulled from the generated `schema.ts` at the call sites in client.ts, so
618
+ * the wire contract still lives in spec/openapi.yaml. Methods return the raw
619
+ * `Response` so the caller can read the exact bytes the server signed before
620
+ * any decode (judge signature verification) — mirroring the Python surface's
621
+ * use of raw httpx (DECISIONS 2026-05-22).
622
+ */
623
+ type QueryValue = string | number | boolean | undefined | null;
624
+ declare class HttpClient {
625
+ readonly baseUrl: string;
626
+ readonly timeoutMs: number;
627
+ constructor(baseUrl: string, timeoutMs: number);
628
+ buildUrl(path: string, query?: Record<string, QueryValue>): string;
629
+ get(path: string, query?: Record<string, QueryValue>, headers?: Record<string, string>): Promise<Response>;
630
+ post(path: string, body: unknown, headers?: Record<string, string>): Promise<Response>;
631
+ private fetch;
632
+ }
633
+ /**
634
+ * A transport failure the SDK can act on. Every real cause the platform surfaces
635
+ * lands as one of these — the message names the cause in plain language so a
636
+ * plugin can show it to a user without decoding httpx / fetch internals.
637
+ *
638
+ * `cause` preserves the original error for debug logging; consumers that want
639
+ * the raw exception (e.g. tests) read it there.
640
+ */
641
+ declare class HttpTransportError extends Error {
642
+ readonly kind: "timeout" | "aborted" | "dns" | "connect_refused" | "connection_reset" | "unknown";
643
+ constructor(kind: HttpTransportError["kind"], message: string, options?: {
644
+ cause?: unknown;
645
+ });
646
+ }
647
+
605
648
  /** Normalize wire shapes (verdict casing, status, pubkey) to canonical forms. */
606
649
 
607
650
  declare function normalizeVerdict(raw: unknown): Verdict;
@@ -1237,4 +1280,4 @@ declare function containsSecret(text: string): boolean;
1237
1280
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1238
1281
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1239
1282
 
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 };
1283
+ 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, HttpClient, HttpTransportError, type JudgeEndpointConfig, type JudgeOptions, type JudgeResult, type JudgmentState, type JudgmentStatus, KEY_FILENAMES, type KeyPair, type LogToolCallOptions, type LogToolCallResult, type MemoryAnomaly, type MemoryDiffResult, type MemoryEntry, MemoryGuardManager, type MemoryGuardManagerOptions, MemoryIntegrityError, type MemoryPointer, type MemoryRollbackEvent, type MemoryScanOptions, type MemoryScanResult, type MemoryScanVerdict, type MemorySnapshot, type ModifiedEntry, type Network, type OrgSubscription, PointerStore, type Provider, type PubkeyValue, type RedactResult, type RollbackMemoryOptions, type SecretKind, type SecretMatch, SignatureVerificationError, type Subscription, type SyncMemoryOptions, type SyncMemoryResult, type TelemetryConfig, type TierInfo, type ToolCallFull, type ToolCallInput, type ToolCallRecord, type ValidatedEndpoint, type Verdict, type WrappedLogger, bootSyncFailureLine, buildAllowedJudgeHosts, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, 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 };
package/dist/browser.mjs CHANGED
@@ -44478,9 +44478,69 @@ var HttpClient = class {
44478
44478
  });
44479
44479
  }
44480
44480
  async fetch(url, init4) {
44481
- return fetch(url, { ...init4, signal: AbortSignal.timeout(this.timeoutMs) });
44481
+ try {
44482
+ return await fetch(url, {
44483
+ ...init4,
44484
+ signal: AbortSignal.timeout(this.timeoutMs)
44485
+ });
44486
+ } catch (err) {
44487
+ throw classifyTransportError(err, url, init4.method ?? "GET", this.timeoutMs);
44488
+ }
44482
44489
  }
44483
44490
  };
44491
+ var HttpTransportError = class extends Error {
44492
+ kind;
44493
+ constructor(kind, message, options) {
44494
+ super(message, options);
44495
+ this.name = "HttpTransportError";
44496
+ this.kind = kind;
44497
+ }
44498
+ };
44499
+ function classifyTransportError(err, url, method, timeoutMs) {
44500
+ const name2 = err instanceof Error ? err.name : "";
44501
+ const cause = err instanceof Error ? err.cause : void 0;
44502
+ const code2 = cause && typeof cause === "object" && "code" in cause ? String(cause.code) : "";
44503
+ if (name2 === "TimeoutError") {
44504
+ return new HttpTransportError(
44505
+ "timeout",
44506
+ `${method} ${url} did not respond within ${timeoutMs} ms \u2014 the judge may be slow to boot or the LLM is under load; retry in a moment`,
44507
+ { cause: err }
44508
+ );
44509
+ }
44510
+ if (name2 === "AbortError") {
44511
+ return new HttpTransportError(
44512
+ "aborted",
44513
+ `${method} ${url} was cancelled by the caller`,
44514
+ { cause: err }
44515
+ );
44516
+ }
44517
+ if (code2 === "ENOTFOUND" || code2 === "EAI_AGAIN") {
44518
+ return new HttpTransportError(
44519
+ "dns",
44520
+ `could not resolve the judge hostname (${url}) \u2014 check the endpoint and DNS`,
44521
+ { cause: err }
44522
+ );
44523
+ }
44524
+ if (code2 === "ECONNREFUSED") {
44525
+ return new HttpTransportError(
44526
+ "connect_refused",
44527
+ `judge refused the connection (${url}) \u2014 the service may be down or restarting`,
44528
+ { cause: err }
44529
+ );
44530
+ }
44531
+ if (code2 === "ECONNRESET" || code2 === "EPIPE") {
44532
+ return new HttpTransportError(
44533
+ "connection_reset",
44534
+ `judge dropped the connection mid-request (${url}) \u2014 retry once`,
44535
+ { cause: err }
44536
+ );
44537
+ }
44538
+ return new HttpTransportError(
44539
+ "unknown",
44540
+ `${method} ${url} failed: ${err instanceof Error ? err.message : String(err)}`,
44541
+ { cause: err }
44542
+ );
44543
+ }
44484
44544
 
44485
44545
  // src-ts/browser/keyLoader.ts
44486
44546
  init_define_ATBASH_CHROMIA_NODE_URLS();
@@ -44600,7 +44660,7 @@ var Atbash = class _Atbash {
44600
44660
  this.failClosed = options.failClosed !== false;
44601
44661
  this.debug = options.debug === true;
44602
44662
  this.logger = options.logger ?? {};
44603
- this.http = new HttpClient(this.endpoint, options.timeoutMs ?? 3e4);
44663
+ this.http = new HttpClient(this.endpoint, options.timeoutMs ?? 6e4);
44604
44664
  this.logEnvironmentOnce();
44605
44665
  if (this.endpoint !== DEFAULT_ENDPOINT) {
44606
44666
  this.logger.warn?.("[atbash] running on non-default judge endpoint", {
@@ -45331,8 +45391,27 @@ var Atbash = class _Atbash {
45331
45391
  this.endpoint
45332
45392
  );
45333
45393
  }
45334
- /** Wrap a *transport* failure (fetch threw, no response) as an AtbashAPIError. */
45394
+ /**
45395
+ * Wrap a transport failure (fetch threw, no response) as an AtbashAPIError.
45396
+ *
45397
+ * `HttpTransportError.kind` names the cause; the message is already
45398
+ * human-readable. `debug` echoes the original exception so operators can
45399
+ * cross-reference with node / undici logs when a class doesn't match.
45400
+ */
45335
45401
  transportError(err) {
45402
+ if (err instanceof HttpTransportError) {
45403
+ if (this.debug) {
45404
+ this.logger.warn?.(
45405
+ `[atbash] transport failed \u2014 kind=${err.kind}`,
45406
+ {
45407
+ kind: err.kind,
45408
+ cause: err.cause instanceof Error ? err.cause.message : String(err.cause ?? ""),
45409
+ endpoint: this.endpoint
45410
+ }
45411
+ );
45412
+ }
45413
+ return new AtbashAPIError(0, err.message, "", this.endpoint);
45414
+ }
45336
45415
  return new AtbashAPIError(0, errorMessage(err), "", this.endpoint);
45337
45416
  }
45338
45417
  async json(resp) {
@@ -45976,6 +46055,8 @@ export {
45976
46055
  DEFAULT_MEMORY_READ_TOOL_NAMES,
45977
46056
  DEFAULT_MEMORY_WRITE_TOOL_NAMES,
45978
46057
  EciesDomain,
46058
+ HttpClient,
46059
+ HttpTransportError,
45979
46060
  KEY_FILENAMES,
45980
46061
  MemoryGuardManager,
45981
46062
  MemoryIntegrityError,