@atbash/sdk 0.19.2-dev.0 → 0.21.0-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/browser.d.mts +118 -24
- package/dist/browser.mjs +314 -251
- package/dist/index.d.mts +118 -24
- package/dist/index.d.ts +118 -24
- package/dist/index.js +271 -130
- package/dist/index.mjs +280 -141
- package/index.d.ts +0 -4
- package/index.js +58 -56
- package/package.json +8 -6
package/dist/browser.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import nodePath from 'node:path';
|
|
1
2
|
import { Logger } from '@opentelemetry/api-logs';
|
|
2
3
|
|
|
3
4
|
type JudgeEndpointConfig = {
|
|
@@ -37,8 +38,12 @@ interface ChainConfig {
|
|
|
37
38
|
readonly blockchainRid: string;
|
|
38
39
|
readonly nodeUrls: readonly string[];
|
|
39
40
|
}
|
|
40
|
-
declare const PUBLIC_CHAIN: ChainConfig;
|
|
41
41
|
declare const PRIVATE_CHAIN: ChainConfig;
|
|
42
|
+
/**
|
|
43
|
+
* The chain a network name selects. Only `"private"` exists; any other value,
|
|
44
|
+
* including `"public"` from an untyped caller, is refused with the same
|
|
45
|
+
* message the config switch gives, never routed to private in silence.
|
|
46
|
+
*/
|
|
42
47
|
declare function chainForNetwork(network: Network): ChainConfig;
|
|
43
48
|
|
|
44
49
|
/**
|
|
@@ -129,13 +134,11 @@ interface MemoryScanOptions {
|
|
|
129
134
|
toolArgsJson?: string;
|
|
130
135
|
}
|
|
131
136
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* the org's subscription via `orgName` — callers normally don't need
|
|
136
|
-
* to pass this manually.
|
|
137
|
+
* Chain selector. Only `"private"` exists: the public testnet chains are
|
|
138
|
+
* retired. The SDK resolves an org's chain through the Dashboard via
|
|
139
|
+
* `orgName` — callers normally don't need to pass this manually.
|
|
137
140
|
*/
|
|
138
|
-
type Network = "
|
|
141
|
+
type Network = "private";
|
|
139
142
|
/**
|
|
140
143
|
* Per-call chain overrides. Pass exactly what you need to override —
|
|
141
144
|
* `network` selects between the SDK's known chains, `blockchainRid` pins a
|
|
@@ -199,6 +202,8 @@ interface JudgeResult {
|
|
|
199
202
|
* Whether the org's protection mode actually acts on a HOLD/BLOCK verdict.
|
|
200
203
|
* `false` in Monitor mode (verdict is logged for observation, agent is NOT
|
|
201
204
|
* jailed and the action is not held); `true` in Enforce mode.
|
|
205
|
+
* A plain boolean: an omitted field reads as `false`. `Decision.enforced`
|
|
206
|
+
* keeps "unknown" apart; gate on that, not on this.
|
|
202
207
|
*/
|
|
203
208
|
enforced: boolean;
|
|
204
209
|
/** Server-reported protection mode: `off`, `monitor`, or `enforce`. */
|
|
@@ -337,7 +342,7 @@ interface AtbashOptions {
|
|
|
337
342
|
*/
|
|
338
343
|
chain?: ChainConfig;
|
|
339
344
|
/**
|
|
340
|
-
* Preset chain selector — `"
|
|
345
|
+
* Preset chain selector — `"private"` is the only value. Resolves to the
|
|
341
346
|
* matching `ChainConfig` via `chainForNetwork()`. Overridden by `chain`,
|
|
342
347
|
* overrides env `ATBASH_DEFAULT_CHAIN_NETWORK` and the config file.
|
|
343
348
|
*/
|
|
@@ -372,7 +377,16 @@ interface AtbashOptions {
|
|
|
372
377
|
* `orgEncryptionPubKey` overrides this, same as `verifyPubKey`.
|
|
373
378
|
*/
|
|
374
379
|
orgEncryptionPubKey?: string;
|
|
375
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* When true (default), `auditToolCall` denies on any error. When false, it
|
|
382
|
+
* allows only when Atbash could not be reached or could not answer: a
|
|
383
|
+
* transport failure, a timeout, a 5xx or a 408 (and a readable reply that
|
|
384
|
+
* neither grants nor refuses). Atbash's own refusals still deny: an
|
|
385
|
+
* unregistered agent, any other 4xx (no policy, billing suspended, quota
|
|
386
|
+
* exhausted or rate limited, unauthorized), and a 2xx reply that is not a
|
|
387
|
+
* JSON object. Direct `judgeAction` callers get a `JudgeRefusalError` for
|
|
388
|
+
* an unregistered agent or an unreadable reply.
|
|
389
|
+
*/
|
|
376
390
|
failClosed?: boolean;
|
|
377
391
|
/**
|
|
378
392
|
* When true (the default), an answer that carries no enforcement decision
|
|
@@ -399,6 +413,15 @@ interface Decision {
|
|
|
399
413
|
verdict: DecisionVerdict;
|
|
400
414
|
reason?: string;
|
|
401
415
|
toolCallId?: string;
|
|
416
|
+
/**
|
|
417
|
+
* Whether the organisation acts on a HOLD/BLOCK verdict; false under Monitor mode and per-agent Shadow Mode. Absent means unknown: a
|
|
418
|
+
* transport error, or a judge that stated no mode. Test `=== false`, never
|
|
419
|
+
* `!decision.enforced`, or every outage counts as a would-block.
|
|
420
|
+
* Informational only; `allow` remains the gate.
|
|
421
|
+
*/
|
|
422
|
+
enforced?: boolean;
|
|
423
|
+
/** Server-reported protection mode (`off`, `monitor`, `enforce`); absent when unknown. */
|
|
424
|
+
enforcementMode?: string;
|
|
402
425
|
}
|
|
403
426
|
/** Input to `auditToolCall`. */
|
|
404
427
|
interface ToolCallInput {
|
|
@@ -622,6 +645,13 @@ declare class Atbash {
|
|
|
622
645
|
* return the signed tx hex. The server broadcasts to chain.
|
|
623
646
|
*/
|
|
624
647
|
logToolCall(action: string, context?: string, options?: LogToolCallOptions): Promise<LogToolCallResult>;
|
|
648
|
+
/**
|
|
649
|
+
* `raisePreflightErrors` (the judge path, like Python's
|
|
650
|
+
* `raise_preflight_errors`): a failed registration check throws instead of
|
|
651
|
+
* becoming `{ success: false }`, so the caller can tell Atbash's "no"
|
|
652
|
+
* (not registered, or a 4xx) from an outage.
|
|
653
|
+
*/
|
|
654
|
+
private _logToolCall;
|
|
625
655
|
/**
|
|
626
656
|
* Sign log_tool_call + optionally judge_action, POST /api/v1/judge.
|
|
627
657
|
*
|
|
@@ -630,6 +660,15 @@ declare class Atbash {
|
|
|
630
660
|
*/
|
|
631
661
|
judgeAction(action: string, context?: string, options?: JudgeOptions): Promise<JudgeResult>;
|
|
632
662
|
private _judgeAction;
|
|
663
|
+
/**
|
|
664
|
+
* Start a local hold on an enforced, on-chain BLOCK (the verdict that jails).
|
|
665
|
+
* Refuse any other result that lands while the agent is held, or whose
|
|
666
|
+
* request was already in flight when the block arrived: the server judged it
|
|
667
|
+
* on pre-jail state.
|
|
668
|
+
*/
|
|
669
|
+
private applyJailHold;
|
|
670
|
+
/** The server's jailed refusal, produced locally while the agent is held. */
|
|
671
|
+
private localJailBlock;
|
|
633
672
|
/**
|
|
634
673
|
* High-level guard: redact secrets, submit for judgement, and collapse the
|
|
635
674
|
* result into an allow/deny `Decision`. Fails closed by default — any error
|
|
@@ -654,6 +693,7 @@ declare class Atbash {
|
|
|
654
693
|
* never overrides a refusal.
|
|
655
694
|
*/
|
|
656
695
|
private decide;
|
|
696
|
+
private decideInner;
|
|
657
697
|
/**
|
|
658
698
|
* One exit for every judge failure.
|
|
659
699
|
*
|
|
@@ -673,12 +713,12 @@ declare class Atbash {
|
|
|
673
713
|
/**
|
|
674
714
|
* Return the current status of a previously submitted judgment.
|
|
675
715
|
*
|
|
676
|
-
* `chainOpts` names which chain the judgment was signed against
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
716
|
+
* `chainOpts` names which chain the judgment was signed against; the SDK
|
|
717
|
+
* sends it as the `brid` query param the server routes by. Without it the
|
|
718
|
+
* read uses the same chain `judgeAction` signs for (see `callBrid`): the
|
|
719
|
+
* client's org chain when it has an `orgName`, else the client default.
|
|
720
|
+
* A judgment signed with an explicit per-call `chainOpts` (or a per-call
|
|
721
|
+
* `orgName` on another chain) must be polled with that same `chainOpts`.
|
|
682
722
|
*/
|
|
683
723
|
getJudgmentStatus(judgmentId: string, agentPubkey?: string, chainOpts?: ChainOpts): Promise<JudgmentStatus>;
|
|
684
724
|
getToolCalls(maxCount: number): Promise<ToolCallRecord[]>;
|
|
@@ -710,12 +750,9 @@ declare class Atbash {
|
|
|
710
750
|
* Resolve which chain an org's actions should run against. Cached
|
|
711
751
|
* per-client by orgName. Resolution order:
|
|
712
752
|
* 1. `org_networks` map (authoritative).
|
|
713
|
-
* 2.
|
|
714
|
-
*
|
|
715
|
-
*
|
|
716
|
-
* A lookup that names exactly one chain wins outright. Where it names
|
|
717
|
-
* neither (a brand-new org) or cannot choose between them, the client's
|
|
718
|
-
* configured default decides.
|
|
753
|
+
* 2. Subscription fallback — the org's subscription row on the chain.
|
|
754
|
+
* A lookup that finds the org wins outright. Where it finds nothing (a
|
|
755
|
+
* brand-new org), the client's configured default decides.
|
|
719
756
|
*/
|
|
720
757
|
resolveChainForOrg(orgName: string): Promise<ChainConfig>;
|
|
721
758
|
/**
|
|
@@ -743,6 +780,13 @@ declare class Atbash {
|
|
|
743
780
|
* chains; otherwise the client's default.
|
|
744
781
|
*/
|
|
745
782
|
private bridFromChainOpts;
|
|
783
|
+
/**
|
|
784
|
+
* The chain one call's transactions are signed for: the per-call override
|
|
785
|
+
* when given, otherwise the client's org, otherwise the client default.
|
|
786
|
+
* log_tool_call, judge_action and the judgment-status read all use this, so
|
|
787
|
+
* a request never pairs transactions signed for two different chains.
|
|
788
|
+
*/
|
|
789
|
+
private callBrid;
|
|
746
790
|
/**
|
|
747
791
|
* Resolve the dashboard chain used by agent metadata/policy reads.
|
|
748
792
|
* Explicit per-call network overrides win; otherwise use the supplied org
|
|
@@ -813,9 +857,18 @@ declare class Atbash {
|
|
|
813
857
|
static containsEvasionCharacters(text: string): boolean;
|
|
814
858
|
}
|
|
815
859
|
|
|
860
|
+
declare const DEFAULTS: {
|
|
861
|
+
ceilingMs: number;
|
|
862
|
+
pollMs: number;
|
|
863
|
+
};
|
|
864
|
+
/** Whether `pubkey` is currently held. */
|
|
865
|
+
declare function isJailHeld(pubkey: string): boolean;
|
|
866
|
+
/** Forget every hold and stop its poll; tests and hosts that reset state. */
|
|
867
|
+
declare function releaseJailHolds(): void;
|
|
868
|
+
/** Override the ceiling or poll interval; an empty object restores defaults. */
|
|
869
|
+
declare function configureJailHold(next: Partial<typeof DEFAULTS>): void;
|
|
870
|
+
|
|
816
871
|
declare const DEFAULT_ENDPOINT: string;
|
|
817
|
-
declare const DEFAULT_CHROMIA_NODE_URLS: readonly string[];
|
|
818
|
-
declare const DEFAULT_BLOCKCHAIN_RID: string;
|
|
819
872
|
|
|
820
873
|
declare class AtbashAPIError extends Error {
|
|
821
874
|
/** HTTP status code (or 0 if the request never completed). */
|
|
@@ -838,6 +891,14 @@ declare class AtbashAPIError extends Error {
|
|
|
838
891
|
declare class SignatureVerificationError extends Error {
|
|
839
892
|
constructor(message: string);
|
|
840
893
|
}
|
|
894
|
+
/**
|
|
895
|
+
* Atbash answered, and the answer was not a grant: the agent is not
|
|
896
|
+
* registered, or the reply could not be read. Unlike an unreachable judge this
|
|
897
|
+
* always denies, whatever `failClosed` says.
|
|
898
|
+
*/
|
|
899
|
+
declare class JudgeRefusalError extends Error {
|
|
900
|
+
constructor(message: string);
|
|
901
|
+
}
|
|
841
902
|
|
|
842
903
|
/**
|
|
843
904
|
* Thin typed fetch wrapper.
|
|
@@ -1250,6 +1311,39 @@ interface GuardMemoryWriteResult {
|
|
|
1250
1311
|
*/
|
|
1251
1312
|
declare function guardMemoryWrite(input: GuardMemoryWriteInput): Promise<GuardMemoryWriteResult>;
|
|
1252
1313
|
|
|
1314
|
+
/**
|
|
1315
|
+
* The chain slot of a memory file, computed the same way everywhere.
|
|
1316
|
+
*
|
|
1317
|
+
* The Rust core finds the slot by stripping the agent's home from the file's
|
|
1318
|
+
* path, as an exact string prefix. The file path arrives resolved
|
|
1319
|
+
* (`path.resolve`), but the home did not: on Windows `HOME=/home/agent`
|
|
1320
|
+
* resolves the file to `C:\home\agent\...` and never matches, and a host that
|
|
1321
|
+
* spells the drive or the user folder differently (`c:\users\me` against
|
|
1322
|
+
* `C:\Users\Me`, both the same folder) did not match either. A file with no
|
|
1323
|
+
* slot is scanned but never recorded on chain, silently, so the on-chain
|
|
1324
|
+
* version record and its rollback/read checks were skipped for it.
|
|
1325
|
+
*
|
|
1326
|
+
* Here the home (and the memory root) is resolved like the file, and on a
|
|
1327
|
+
* case-insensitive file system it is passed to the core spelled the way the
|
|
1328
|
+
* file path spells it. The slot itself, the part below the agent home, keeps
|
|
1329
|
+
* the file's own spelling, so slots recorded before this change still match.
|
|
1330
|
+
*
|
|
1331
|
+
* Known limit: a folder with NTFS per-directory case sensitivity enabled
|
|
1332
|
+
* (`fsutil file setCaseSensitiveInfo`, or one created from WSL) can hold both
|
|
1333
|
+
* `Me` and `me`; there ASCII case does separate folders, and a sibling spelled
|
|
1334
|
+
* in another case would share the home's slots. Creating one needs write
|
|
1335
|
+
* access to the home's parent. A follow-up can confirm the same folder on disk
|
|
1336
|
+
* when the spellings differ.
|
|
1337
|
+
*/
|
|
1338
|
+
|
|
1339
|
+
/** Path semantics: `node:path` here, `path.win32` / `path.posix` in tests. */
|
|
1340
|
+
type PathImpl = typeof nodePath;
|
|
1341
|
+
/**
|
|
1342
|
+
* The chain slot for `target`, or null when it gets no chain record. `p`
|
|
1343
|
+
* selects path semantics (tests pass `path.win32` to check Windows anywhere).
|
|
1344
|
+
*/
|
|
1345
|
+
declare function memorySlotOf(target: string, home: string, root?: string, extraHomes?: string[], p?: PathImpl): string | null;
|
|
1346
|
+
|
|
1253
1347
|
/**
|
|
1254
1348
|
* Aligns a local `MemoryPointer` with chain's active memory version
|
|
1255
1349
|
* via a TTL-cached pointer check. Inside the TTL window: no-op.
|
|
@@ -1894,4 +1988,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1894
1988
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1895
1989
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1896
1990
|
|
|
1897
|
-
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 ChainConfig, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions,
|
|
1991
|
+
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 ChainConfig, type ChainOpts, type ClassifierToolContext, type ClassifierToolEvent, type ClassifyMemoryReadOptions, type ClassifyMemoryWriteOptions, type ClientSource, type CommitMemoryOptions, 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, JudgeRefusalError, 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 OperationEvent, type OrgSubscription, PRIVATE_CHAIN, 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, canonicalAllow, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, configureEvents, configureJailHold, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, eventsAreOn, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isJailHeld, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, memorySlotOf, normalizeActionForHash, normalizeActionType, normalizeForMatching, normalizeStatus, normalizeVerdict, packEnvelope, parseEnvelope, pubkeyToHex, recordCall, recordDuration, recordEvent, redactJsonStrings, redactSecrets, releaseJailHolds, resolve, resolveKeyPath, rollbackMemory, saveUserConfig, scanMemory, scanMemoryBatch, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
|