@atbash/sdk 0.10.10-dev.0 → 0.10.12-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/README.md CHANGED
@@ -111,8 +111,8 @@ Read-only methods that read from the Chromia blockchain and dashboard.
111
111
  | `getToolCallCount()` | Total number of tool calls on-chain |
112
112
  | `getToolCallFull(toolCallId)` | Full details of a single tool call |
113
113
  | `getOrgTierInfo(orgName)` | Check an org's tier and whether verdicts are enabled |
114
- | `getAgentDetail(pubkey)` | Get agent metadata (org, status, creation date) |
115
- | `getAgentPolicy(pubkey)` | Check the agent's policy pack and jail status |
114
+ | `getAgentDetail(pubkey, options?)` | Get agent metadata (org, status, creation date) |
115
+ | `getAgentPolicy(pubkey, options?)` | Check the agent's policy pack and jail status |
116
116
  | `getPendingHeldActions(orgName, maxCount)` | List actions waiting for operator approval |
117
117
  | `getHeldActionReviews(orgName, maxCount)` | List completed operator reviews |
118
118
  | `getSafetyStats()` | Chain-wide safety statistics |
@@ -148,6 +148,16 @@ const atbash = Atbash.fromConfig(); // reads env + config file
148
148
 
149
149
  Persistent config helpers: `saveUserConfig(config)`, `loadUserConfig()`, `resolve(key, flagValue?)`, `getConfigPath()`.
150
150
 
151
+ Agent policy and detail reads can resolve the organization's active network, or
152
+ accept an explicit network override:
153
+
154
+ ```ts
155
+ await atbash.getAgentPolicy(atbash.pubkey, { orgName: "acme" });
156
+ await atbash.getAgentDetail(atbash.pubkey, {
157
+ chainOpts: { network: "private" },
158
+ });
159
+ ```
160
+
151
161
  ## Error handling
152
162
 
153
163
  The SDK throws standard `Error` objects. Known failure modes are enriched with a pointer to the dashboard page that fixes them:
@@ -274,6 +274,13 @@ interface AgentPolicy {
274
274
  isCustom: boolean;
275
275
  defaultPolicy: string;
276
276
  }
277
+ /** Options for agent metadata and policy lookups. */
278
+ interface AgentLookupOptions {
279
+ /** Resolve the agent's network from this organization's active network. */
280
+ orgName?: string;
281
+ /** Explicit per-call chain override. `network` selects the dashboard chain. */
282
+ chainOpts?: ChainOpts;
283
+ }
277
284
  /** Optional structured logger. */
278
285
  interface AtbashLogger {
279
286
  info?(...args: unknown[]): void;
@@ -521,8 +528,8 @@ declare class Atbash {
521
528
  getOrgTierInfo(orgName: string): Promise<TierInfo | null>;
522
529
  getPendingHeldActions(orgName: string, maxCount: number): Promise<HeldAction[]>;
523
530
  getHeldActionReviews(orgName: string, maxCount: number): Promise<HeldActionReview[]>;
524
- getAgentDetail(agentPubkey: string): Promise<Record<string, unknown>>;
525
- getAgentPolicy(agentPubkey: string): Promise<AgentPolicy>;
531
+ getAgentDetail(agentPubkey: string, options?: AgentLookupOptions): Promise<Record<string, unknown>>;
532
+ getAgentPolicy(agentPubkey: string, options?: AgentLookupOptions): Promise<AgentPolicy>;
526
533
  getSafetyStats(): Promise<Record<string, unknown>>;
527
534
  /**
528
535
  * Org's subscription on a specific chain. The `network` arg selects
@@ -573,6 +580,14 @@ declare class Atbash {
573
580
  * chains; otherwise the client's default.
574
581
  */
575
582
  private bridFromChainOpts;
583
+ /**
584
+ * Resolve the dashboard chain used by agent metadata/policy reads.
585
+ * Explicit per-call network overrides win; otherwise use the supplied org
586
+ * or the client's configured default org. A custom BRID is intentionally
587
+ * left untouched because it cannot be represented by the dashboard's
588
+ * public/private query selector.
589
+ */
590
+ private resolveAgentLookupNetwork;
576
591
  /**
577
592
  * Get-or-create a Bearer token for dashboard reads. The token is a
578
593
  * signed `log_tool_call` op (locally signed, never submitted) — the
@@ -1211,13 +1226,17 @@ declare function createMemoryGuardManager(opts: MemoryGuardManagerOptions): Memo
1211
1226
  /**
1212
1227
  * Atbash SDK Telemetry — OpenTelemetry metrics for usage tracking.
1213
1228
  *
1214
- * Tracks: function call counts, latency, source (CLI/plugin/SDK),
1215
- * and agent identity. ON by default.
1229
+ * Metrics are POSTed to the Atbash-owned `/api/telemetry` proxy, which
1230
+ * verifies the bearer, injects the Honeycomb ingest key server-side, and
1231
+ * forwards to Honeycomb. The ingest credential never enters the SDK.
1232
+ *
1233
+ * Environment opt-out (recommended for air-gapped deployments):
1234
+ * ATBASH_TELEMETRY_DISABLED=1
1216
1235
  *
1217
1236
  * Opt-out: create ~/.config/atbash/telemetry.json with { "enabled": false }
1218
1237
  * The file must be readable by the SDK process. If missing, corrupted, or
1219
- * unreadable → telemetry stays ON. Environment variables cannot disable
1220
- * telemetry (prevents agent bypass via env-var injection).
1238
+ * unreadable, telemetry remains eligible to start unless the environment
1239
+ * opt-out is set.
1221
1240
  */
1222
1241
  type ClientSource = "cli" | "sdk" | "plugin:openclaw" | "plugin:langchain" | "plugin:langgraph" | "plugin:hermes" | "plugin:eliza" | "plugin:crewai" | "plugin:mcp" | "plugin:autogen" | "plugin:jeenai" | (string & {});
1223
1242
  interface TelemetryConfig {
@@ -1227,6 +1246,13 @@ interface TelemetryConfig {
1227
1246
  source?: ClientSource;
1228
1247
  /** Flush interval in ms. Default: 60000 */
1229
1248
  exportIntervalMs?: number;
1249
+ /** Atbash endpoint that hosts /api/telemetry. Required to actually export. */
1250
+ endpoint?: string;
1251
+ /**
1252
+ * Called on every export to obtain fresh auth headers (typically
1253
+ * `{ Authorization: "Bearer <hex>" }`). Required to actually export.
1254
+ */
1255
+ getAuthHeaders?: () => Record<string, string>;
1230
1256
  }
1231
1257
  declare function setupTelemetry(config: TelemetryConfig): void;
1232
1258
  /**
@@ -1346,4 +1372,4 @@ declare function containsSecret(text: string): boolean;
1346
1372
  declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
1347
1373
  declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
1348
1374
 
1349
- 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 };
1375
+ 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 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
@@ -43452,9 +43452,6 @@ var native = {
43452
43452
  DEFAULT_BLOCKCHAIN_RID: ATBASH_BLOCKCHAIN_RID,
43453
43453
  DEFAULT_PRIVATE_BLOCKCHAIN_RID: ATBASH_PRIVATE_BLOCKCHAIN_RID,
43454
43454
  DEFAULT_ENDPOINT: ATBASH_ENDPOINT,
43455
- // Browser has no NAPI channel to Rust's HONEYCOMB_KEY — telemetry
43456
- // silently no-ops. `HONEYCOMB_API_KEY` env var still overrides at runtime.
43457
- HONEYCOMB_KEY: "",
43458
43455
  defaultChromiaNodeUrls: () => [...DEFAULT_CHROMIA_NODE_URLS_ARR],
43459
43456
  defaultPrivateNodeUrls: () => [...DEFAULT_PRIVATE_NODE_URLS_ARR],
43460
43457
  // Server-only surfaces — throw at runtime, keep types satisfied.
@@ -44678,6 +44675,16 @@ var Atbash = class _Atbash {
44678
44675
  verifying: this.verifyPubKey ? "with response-signature pubkey configured" : "without signature verification"
44679
44676
  });
44680
44677
  }
44678
+ try {
44679
+ setupTelemetry({
44680
+ enabled: true,
44681
+ source: "sdk",
44682
+ endpoint: this.endpoint,
44683
+ getAuthHeaders: () => this.authHeaders()
44684
+ });
44685
+ } catch (err) {
44686
+ this.logger.warn?.("[atbash] telemetry setup failed \u2014 continuing without metrics", { error: String(err) });
44687
+ }
44681
44688
  }
44682
44689
  /**
44683
44690
  * Say which environment this build talks to, once per process.
@@ -45191,19 +45198,25 @@ var Atbash = class _Atbash {
45191
45198
  });
45192
45199
  }
45193
45200
  /* ── risk-engine batched (action-dispatched POST) ──────────────────────── */
45194
- getAgentDetail(agentPubkey) {
45195
- return this.track(
45196
- "getAgentDetail",
45197
- agentPubkey,
45198
- () => this.riskEnginePost({ action: "agent-detail-batch", agent: agentPubkey })
45199
- );
45201
+ async getAgentDetail(agentPubkey, options = {}) {
45202
+ return this.track("getAgentDetail", agentPubkey, async () => {
45203
+ const network = await this.resolveAgentLookupNetwork(options);
45204
+ return this.riskEnginePost(
45205
+ { action: "agent-detail-batch", agent: agentPubkey },
45206
+ network
45207
+ );
45208
+ });
45200
45209
  }
45201
- async getAgentPolicy(agentPubkey) {
45210
+ async getAgentPolicy(agentPubkey, options = {}) {
45202
45211
  return this.track("getAgentPolicy", agentPubkey, async () => {
45203
- const raw2 = await this.riskEnginePost({
45204
- action: "agent-policy-batch",
45205
- agent: agentPubkey
45206
- });
45212
+ const network = await this.resolveAgentLookupNetwork(options);
45213
+ const raw2 = await this.riskEnginePost(
45214
+ {
45215
+ action: "agent-policy-batch",
45216
+ agent: agentPubkey
45217
+ },
45218
+ network
45219
+ );
45207
45220
  return {
45208
45221
  policy: String(raw2.policy ?? ""),
45209
45222
  isJailed: Boolean(raw2.is_jailed),
@@ -45360,6 +45373,20 @@ var Atbash = class _Atbash {
45360
45373
  if (chainOpts?.network === "public") return PUBLIC_CHAIN.blockchainRid;
45361
45374
  return this.blockchainRid;
45362
45375
  }
45376
+ /**
45377
+ * Resolve the dashboard chain used by agent metadata/policy reads.
45378
+ * Explicit per-call network overrides win; otherwise use the supplied org
45379
+ * or the client's configured default org. A custom BRID is intentionally
45380
+ * left untouched because it cannot be represented by the dashboard's
45381
+ * public/private query selector.
45382
+ */
45383
+ async resolveAgentLookupNetwork(options) {
45384
+ if (options.chainOpts?.network) return options.chainOpts.network;
45385
+ if (options.chainOpts?.blockchainRid) return void 0;
45386
+ const orgName = options.orgName ?? this.orgName;
45387
+ if (!orgName) return void 0;
45388
+ return (await this.resolveChainForOrg(orgName)).network;
45389
+ }
45363
45390
  /**
45364
45391
  * Get-or-create a Bearer token for dashboard reads. The token is a
45365
45392
  * signed `log_tool_call` op (locally signed, never submitted) — the
@@ -45402,10 +45429,11 @@ var Atbash = class _Atbash {
45402
45429
  if (resp.status !== 200) throw await this.httpError(resp);
45403
45430
  return this.json(resp);
45404
45431
  }
45405
- async riskEnginePost(body) {
45432
+ async riskEnginePost(body, network) {
45406
45433
  let resp;
45407
45434
  try {
45408
- resp = await this.http.post("/api/risk-engine", body, this.authHeaders());
45435
+ const path4 = network ? `/api/risk-engine?network=${encodeURIComponent(network)}` : "/api/risk-engine";
45436
+ resp = await this.http.post(path4, body, this.authHeaders());
45409
45437
  } catch (err) {
45410
45438
  throw this.transportError(err);
45411
45439
  }