@atbash/sdk 0.22.0-dev.0 → 0.24.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/README.md +6 -1
- package/dist/browser.d.mts +147 -10
- package/dist/browser.mjs +356 -59
- package/dist/index.d.mts +147 -10
- package/dist/index.d.ts +147 -10
- package/dist/index.js +227 -60
- package/dist/index.mjs +225 -60
- package/dist/testing.d.mts +15 -0
- package/dist/testing.d.ts +15 -0
- package/dist/testing.js +33 -0
- package/dist/testing.mjs +8 -0
- package/index.d.ts +3 -0
- package/index.js +55 -54
- package/package.json +15 -7
package/dist/index.d.mts
CHANGED
|
@@ -31,6 +31,31 @@ interface ValidatedEndpoint {
|
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
33
|
declare function buildAllowedJudgeHosts(): ReadonlySet<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Pin keys for a loopback judge, so tests can drive the pinned-host path
|
|
36
|
+
* against a local server.
|
|
37
|
+
*
|
|
38
|
+
* Only loopback hosts read this, and their traffic never leaves the machine,
|
|
39
|
+
* so it cannot loosen the check on a real Atbash host.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
* @param keys - Compressed pubkeys to pin; `[]` clears them.
|
|
43
|
+
*/
|
|
44
|
+
declare function setLoopbackJudgePinsForTests(keys: readonly string[]): void;
|
|
45
|
+
/**
|
|
46
|
+
* The keys a judge reply must be signed by, for one endpoint.
|
|
47
|
+
*
|
|
48
|
+
* An Atbash host's pinned keys always decide: a configured `verifyPubKey` on
|
|
49
|
+
* such a host must be one of them, or the client refuses to start, because a
|
|
50
|
+
* key that only had to come from config could be anyone's. A host with no pins
|
|
51
|
+
* uses the configured key, or none.
|
|
52
|
+
*
|
|
53
|
+
* @param endpoint - The validated judge endpoint URL.
|
|
54
|
+
* @param configuredKey - The `verifyPubKey` the caller configured, if any.
|
|
55
|
+
* @returns The accepted keys, current first; empty means replies are not checked.
|
|
56
|
+
* @throws When `configuredKey` is not one of the host's pinned keys.
|
|
57
|
+
*/
|
|
58
|
+
declare function judgeVerifyKeys(endpoint: string, configuredKey?: string): readonly string[];
|
|
34
59
|
declare function validateJudgeEndpoint(judge?: JudgeEndpointConfig): ValidatedEndpoint;
|
|
35
60
|
|
|
36
61
|
interface ChainConfig {
|
|
@@ -195,7 +220,15 @@ interface JudgeResult {
|
|
|
195
220
|
provider: string;
|
|
196
221
|
latencyMs: number;
|
|
197
222
|
toolCallId: string;
|
|
223
|
+
/**
|
|
224
|
+
* The id the judge recorded this verdict under, when it differs from
|
|
225
|
+
* `toolCallId` (the on-chain judge path). Poll `getJudgmentStatus` with
|
|
226
|
+
* `judgmentId || toolCallId`. Absent when the reply names none.
|
|
227
|
+
*/
|
|
228
|
+
judgmentId?: string;
|
|
198
229
|
onChain: boolean;
|
|
230
|
+
/** What the reply stated about the chain; see {@link VerdictRecord}. */
|
|
231
|
+
record?: VerdictRecord;
|
|
199
232
|
/** Severity 1 (poisonous) → 10 (benign). Present on memory-scan responses; absent for regular tool-call judgments. */
|
|
200
233
|
score?: number;
|
|
201
234
|
/**
|
|
@@ -231,6 +264,12 @@ interface JudgmentStatus {
|
|
|
231
264
|
onChain?: boolean;
|
|
232
265
|
cached?: boolean;
|
|
233
266
|
responseTimeMs?: number;
|
|
267
|
+
/**
|
|
268
|
+
* The verdict the judge reached (`"BLOCK"` or `"HOLD"`) when the
|
|
269
|
+
* organisation's signed mode (`shadow`, `monitor`, `off`) let the action run
|
|
270
|
+
* anyway, as {@link Decision.wouldVerdict}. Absent when the status is the verdict.
|
|
271
|
+
*/
|
|
272
|
+
wouldVerdict?: "BLOCK" | "HOLD";
|
|
234
273
|
}
|
|
235
274
|
interface TierInfo {
|
|
236
275
|
orgName: string;
|
|
@@ -398,6 +437,14 @@ interface AtbashOptions {
|
|
|
398
437
|
* off).
|
|
399
438
|
*/
|
|
400
439
|
requireEnforcement?: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* When true, `auditToolCall` enforces the judge's verdict whatever
|
|
442
|
+
* enforcement mode the organisation is in. Default false: on a judge host
|
|
443
|
+
* whose replies are signature-checked, a signed `shadow`, `monitor` or `off`
|
|
444
|
+
* mode lets a BLOCK or HOLD run, reported in `Decision.wouldVerdict`. This
|
|
445
|
+
* can only make the client stricter.
|
|
446
|
+
*/
|
|
447
|
+
enforceLocally?: boolean;
|
|
401
448
|
/**
|
|
402
449
|
* Verbose diagnostics. Off by default. When on, a failed judge call also
|
|
403
450
|
* logs the response body, which is the difference between "judge API failed"
|
|
@@ -406,6 +453,44 @@ interface AtbashOptions {
|
|
|
406
453
|
debug?: boolean;
|
|
407
454
|
logger?: AtbashLogger;
|
|
408
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* What the judge stated about recording this verdict. A host that must not run
|
|
458
|
+
* an unrecorded action gates on `verdictRecorded`. `onChain` is the judge's
|
|
459
|
+
* statement: the SDK does not read the chain.
|
|
460
|
+
*/
|
|
461
|
+
interface VerdictRecord {
|
|
462
|
+
/** The judge's `on_chain`: the verdict is recorded on chain. */
|
|
463
|
+
onChain: boolean;
|
|
464
|
+
/** The judge's `on_chain_status`, such as `pending` or `skipped`; absent when not stated. */
|
|
465
|
+
status?: string;
|
|
466
|
+
/**
|
|
467
|
+
* The reply names the ids this call generated. False when it names another
|
|
468
|
+
* call, or none: `toolCallId` then falls back to this client's own id, which
|
|
469
|
+
* proves nothing about what the judge recorded.
|
|
470
|
+
*/
|
|
471
|
+
boundToCall: boolean;
|
|
472
|
+
/**
|
|
473
|
+
* This reply's signature was checked against a judge key before it was read.
|
|
474
|
+
* False means nothing proves who wrote the reply: it can echo this call's ids
|
|
475
|
+
* and still read as bound, because the ids travel in the request.
|
|
476
|
+
*/
|
|
477
|
+
signatureChecked: boolean;
|
|
478
|
+
/**
|
|
479
|
+
* The judge's own `status`, absent when not stated. `shadow_recorded` is a
|
|
480
|
+
* shadow ack: the call was stored and has no verdict yet, which is what
|
|
481
|
+
* separates it from an ALLOW whose `status` here is `pending`. Read it with
|
|
482
|
+
* `boundToCall` and `signatureChecked`: unsigned, it is only a claim.
|
|
483
|
+
*/
|
|
484
|
+
judgeStatus?: string;
|
|
485
|
+
/**
|
|
486
|
+
* The judge answered this call with a verdict it states is recorded on chain,
|
|
487
|
+
* in a signature-checked reply: `onChain`, `boundToCall` and `signatureChecked`
|
|
488
|
+
* all true, and no `judgeStatus`, which only a reply without a verdict carries
|
|
489
|
+
* (a shadow ack, or an answer that was only logged). Still the judge's word:
|
|
490
|
+
* the SDK does not read the chain.
|
|
491
|
+
*/
|
|
492
|
+
verdictRecorded: boolean;
|
|
493
|
+
}
|
|
409
494
|
/** Canonical decision returned by `auditToolCall`. */
|
|
410
495
|
type DecisionVerdict = "ALLOW" | "HOLD" | "BLOCK" | "ERROR";
|
|
411
496
|
interface Decision {
|
|
@@ -422,6 +507,25 @@ interface Decision {
|
|
|
422
507
|
enforced?: boolean;
|
|
423
508
|
/** Server-reported protection mode (`off`, `monitor`, `enforce`); absent when unknown. */
|
|
424
509
|
enforcementMode?: string;
|
|
510
|
+
/**
|
|
511
|
+
* The verdict the judge reached when the organisation's signed mode
|
|
512
|
+
* (`shadow`, `monitor`, `off`) let the action run anyway: what would have
|
|
513
|
+
* happened under enforcement. Absent when the decision is the verdict.
|
|
514
|
+
*/
|
|
515
|
+
wouldVerdict?: "BLOCK" | "HOLD";
|
|
516
|
+
/**
|
|
517
|
+
* The id the judge recorded this verdict under, when it differs from
|
|
518
|
+
* `toolCallId` (the on-chain judge path), as {@link JudgeResult.judgmentId}.
|
|
519
|
+
* Poll `getJudgmentStatus` with `judgmentId || toolCallId`.
|
|
520
|
+
*/
|
|
521
|
+
judgmentId?: string;
|
|
522
|
+
/**
|
|
523
|
+
* What the judge stated about recording this verdict. Absent means unknown:
|
|
524
|
+
* a transport error, a local jail hold, or a reply that did not state
|
|
525
|
+
* `on_chain`. Treat absent as not recorded. Informational only; `allow`
|
|
526
|
+
* remains the gate.
|
|
527
|
+
*/
|
|
528
|
+
record?: VerdictRecord;
|
|
425
529
|
}
|
|
426
530
|
/** Input to `auditToolCall`. */
|
|
427
531
|
interface ToolCallInput {
|
|
@@ -459,6 +563,8 @@ interface FromConfigOptions {
|
|
|
459
563
|
failClosed?: boolean;
|
|
460
564
|
/** See {@link AtbashOptions.requireEnforcement}. Default true. */
|
|
461
565
|
requireEnforcement?: boolean;
|
|
566
|
+
/** See {@link AtbashOptions.enforceLocally}. Default false. */
|
|
567
|
+
enforceLocally?: boolean;
|
|
462
568
|
/** See {@link AtbashOptions.decisionTimeoutMs}. Default 60 000 ms. */
|
|
463
569
|
decisionTimeoutMs?: number;
|
|
464
570
|
/** See {@link AtbashOptions.debug}. */
|
|
@@ -513,12 +619,21 @@ declare class Atbash {
|
|
|
513
619
|
readonly orgName?: string;
|
|
514
620
|
/** Default judge response-signing pubkey, if configured (see fromConfig). */
|
|
515
621
|
readonly verifyPubKey?: string;
|
|
622
|
+
/**
|
|
623
|
+
* The keys every judge reply must be signed by: the host's pinned keys, or
|
|
624
|
+
* the configured `verifyPubKey` on a host with none. Empty means unchecked.
|
|
625
|
+
*/
|
|
626
|
+
private readonly verifyKeys;
|
|
516
627
|
/** Default org encryption key — see {@link AtbashOptions.orgEncryptionPubKey}. */
|
|
517
628
|
readonly orgEncryptionPubKey?: string;
|
|
518
629
|
/** When true (default), `auditToolCall` denies on any error. */
|
|
519
630
|
readonly failClosed: boolean;
|
|
520
631
|
/** When true (default), an unenforced (audit-tier) answer is refused. */
|
|
521
632
|
readonly requireEnforcement: boolean;
|
|
633
|
+
/** When true, a signed non-enforcing mode never relaxes a verdict. */
|
|
634
|
+
readonly enforceLocally: boolean;
|
|
635
|
+
/** Results whose enforcement mode came signed and bound to their call. */
|
|
636
|
+
private readonly modeTrusted;
|
|
522
637
|
/** Overall deadline for one auditToolCall decision, in ms. */
|
|
523
638
|
readonly decisionTimeoutMs: number;
|
|
524
639
|
/** Org key learned from the last agent-exists check, for this agent only. */
|
|
@@ -659,12 +774,25 @@ declare class Atbash {
|
|
|
659
774
|
* response bytes via the Rust core's `verifySignature`.
|
|
660
775
|
*/
|
|
661
776
|
judgeAction(action: string, context?: string, options?: JudgeOptions): Promise<JudgeResult>;
|
|
777
|
+
/**
|
|
778
|
+
* judgeAction, optionally asking the judge for the true verdict and the
|
|
779
|
+
* organisation's enforcement mode so this client applies the mode itself.
|
|
780
|
+
*
|
|
781
|
+
* Only auditToolCall opts in: judgeAction's callers keep the server-side
|
|
782
|
+
* downgrade they gate on today.
|
|
783
|
+
*
|
|
784
|
+
* @param clientEnforces - Send `X-Atbash-Client-Enforcement` when the reply can be trusted.
|
|
785
|
+
*/
|
|
786
|
+
private judgeTracked;
|
|
662
787
|
private _judgeAction;
|
|
663
788
|
/**
|
|
664
|
-
* Start a local hold on an enforced
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
789
|
+
* Start a local hold on an enforced BLOCK that jails: one already on chain,
|
|
790
|
+
* or one the judge answered before its chain write landed
|
|
791
|
+
* (`on_chain_status: "pending"`), which jails once it lands. Refuse any other
|
|
792
|
+
* result that lands while the agent is held, or whose request was already in
|
|
793
|
+
* flight when the block arrived: the server judged it on pre-jail state.
|
|
794
|
+
*
|
|
795
|
+
* @param onChainStatus - The reply's `on_chain_status`; empty when absent.
|
|
668
796
|
*/
|
|
669
797
|
private applyJailHold;
|
|
670
798
|
/** The server's jailed refusal, produced locally while the agent is held. */
|
|
@@ -677,12 +805,12 @@ declare class Atbash {
|
|
|
677
805
|
*/
|
|
678
806
|
auditToolCall(input: ToolCallInput): Promise<Decision>;
|
|
679
807
|
/**
|
|
680
|
-
* The verify
|
|
681
|
-
* may only narrow what the client accepts: on a client pinned to
|
|
682
|
-
*
|
|
683
|
-
*
|
|
808
|
+
* The verify keys for one call (R4, governor tier-2 review). A per-call key
|
|
809
|
+
* may only narrow what the client accepts: on a client pinned to judge keys
|
|
810
|
+
* it must be one of them, never a replacement; on an unpinned client it
|
|
811
|
+
* adds the check.
|
|
684
812
|
*/
|
|
685
|
-
private
|
|
813
|
+
private effectiveVerifyKeys;
|
|
686
814
|
/**
|
|
687
815
|
* Collapse a judge result into a {@link Decision}. The most restrictive
|
|
688
816
|
* signal wins (security review 2026-09-30, H1): `action_type`, `verdict`
|
|
@@ -693,6 +821,15 @@ declare class Atbash {
|
|
|
693
821
|
* never overrides a refusal.
|
|
694
822
|
*/
|
|
695
823
|
private decide;
|
|
824
|
+
/**
|
|
825
|
+
* Apply the organisation's enforcement mode to the judge's true verdict.
|
|
826
|
+
*
|
|
827
|
+
* Only a mode that arrived signed and bound to this call counts; a missing,
|
|
828
|
+
* unsigned or unknown mode, or enforceLocally, means enforce. Under
|
|
829
|
+
* `shadow`, `monitor` or `off` a BLOCK or HOLD runs, reported in
|
|
830
|
+
* `wouldVerdict`. An ERROR stays an error: it is not a verdict.
|
|
831
|
+
*/
|
|
832
|
+
private applyMode;
|
|
696
833
|
private decideInner;
|
|
697
834
|
/**
|
|
698
835
|
* One exit for every judge failure.
|
|
@@ -1995,4 +2132,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1995
2132
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1996
2133
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1997
2134
|
|
|
1998
|
-
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, type MemoryHistoryPage, 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 };
|
|
2135
|
+
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, type MemoryHistoryPage, 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 VerdictRecord, 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, judgeVerifyKeys, 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, setLoopbackJudgePinsForTests, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,31 @@ interface ValidatedEndpoint {
|
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
33
|
declare function buildAllowedJudgeHosts(): ReadonlySet<string>;
|
|
34
|
+
/**
|
|
35
|
+
* Pin keys for a loopback judge, so tests can drive the pinned-host path
|
|
36
|
+
* against a local server.
|
|
37
|
+
*
|
|
38
|
+
* Only loopback hosts read this, and their traffic never leaves the machine,
|
|
39
|
+
* so it cannot loosen the check on a real Atbash host.
|
|
40
|
+
*
|
|
41
|
+
* @internal
|
|
42
|
+
* @param keys - Compressed pubkeys to pin; `[]` clears them.
|
|
43
|
+
*/
|
|
44
|
+
declare function setLoopbackJudgePinsForTests(keys: readonly string[]): void;
|
|
45
|
+
/**
|
|
46
|
+
* The keys a judge reply must be signed by, for one endpoint.
|
|
47
|
+
*
|
|
48
|
+
* An Atbash host's pinned keys always decide: a configured `verifyPubKey` on
|
|
49
|
+
* such a host must be one of them, or the client refuses to start, because a
|
|
50
|
+
* key that only had to come from config could be anyone's. A host with no pins
|
|
51
|
+
* uses the configured key, or none.
|
|
52
|
+
*
|
|
53
|
+
* @param endpoint - The validated judge endpoint URL.
|
|
54
|
+
* @param configuredKey - The `verifyPubKey` the caller configured, if any.
|
|
55
|
+
* @returns The accepted keys, current first; empty means replies are not checked.
|
|
56
|
+
* @throws When `configuredKey` is not one of the host's pinned keys.
|
|
57
|
+
*/
|
|
58
|
+
declare function judgeVerifyKeys(endpoint: string, configuredKey?: string): readonly string[];
|
|
34
59
|
declare function validateJudgeEndpoint(judge?: JudgeEndpointConfig): ValidatedEndpoint;
|
|
35
60
|
|
|
36
61
|
interface ChainConfig {
|
|
@@ -195,7 +220,15 @@ interface JudgeResult {
|
|
|
195
220
|
provider: string;
|
|
196
221
|
latencyMs: number;
|
|
197
222
|
toolCallId: string;
|
|
223
|
+
/**
|
|
224
|
+
* The id the judge recorded this verdict under, when it differs from
|
|
225
|
+
* `toolCallId` (the on-chain judge path). Poll `getJudgmentStatus` with
|
|
226
|
+
* `judgmentId || toolCallId`. Absent when the reply names none.
|
|
227
|
+
*/
|
|
228
|
+
judgmentId?: string;
|
|
198
229
|
onChain: boolean;
|
|
230
|
+
/** What the reply stated about the chain; see {@link VerdictRecord}. */
|
|
231
|
+
record?: VerdictRecord;
|
|
199
232
|
/** Severity 1 (poisonous) → 10 (benign). Present on memory-scan responses; absent for regular tool-call judgments. */
|
|
200
233
|
score?: number;
|
|
201
234
|
/**
|
|
@@ -231,6 +264,12 @@ interface JudgmentStatus {
|
|
|
231
264
|
onChain?: boolean;
|
|
232
265
|
cached?: boolean;
|
|
233
266
|
responseTimeMs?: number;
|
|
267
|
+
/**
|
|
268
|
+
* The verdict the judge reached (`"BLOCK"` or `"HOLD"`) when the
|
|
269
|
+
* organisation's signed mode (`shadow`, `monitor`, `off`) let the action run
|
|
270
|
+
* anyway, as {@link Decision.wouldVerdict}. Absent when the status is the verdict.
|
|
271
|
+
*/
|
|
272
|
+
wouldVerdict?: "BLOCK" | "HOLD";
|
|
234
273
|
}
|
|
235
274
|
interface TierInfo {
|
|
236
275
|
orgName: string;
|
|
@@ -398,6 +437,14 @@ interface AtbashOptions {
|
|
|
398
437
|
* off).
|
|
399
438
|
*/
|
|
400
439
|
requireEnforcement?: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* When true, `auditToolCall` enforces the judge's verdict whatever
|
|
442
|
+
* enforcement mode the organisation is in. Default false: on a judge host
|
|
443
|
+
* whose replies are signature-checked, a signed `shadow`, `monitor` or `off`
|
|
444
|
+
* mode lets a BLOCK or HOLD run, reported in `Decision.wouldVerdict`. This
|
|
445
|
+
* can only make the client stricter.
|
|
446
|
+
*/
|
|
447
|
+
enforceLocally?: boolean;
|
|
401
448
|
/**
|
|
402
449
|
* Verbose diagnostics. Off by default. When on, a failed judge call also
|
|
403
450
|
* logs the response body, which is the difference between "judge API failed"
|
|
@@ -406,6 +453,44 @@ interface AtbashOptions {
|
|
|
406
453
|
debug?: boolean;
|
|
407
454
|
logger?: AtbashLogger;
|
|
408
455
|
}
|
|
456
|
+
/**
|
|
457
|
+
* What the judge stated about recording this verdict. A host that must not run
|
|
458
|
+
* an unrecorded action gates on `verdictRecorded`. `onChain` is the judge's
|
|
459
|
+
* statement: the SDK does not read the chain.
|
|
460
|
+
*/
|
|
461
|
+
interface VerdictRecord {
|
|
462
|
+
/** The judge's `on_chain`: the verdict is recorded on chain. */
|
|
463
|
+
onChain: boolean;
|
|
464
|
+
/** The judge's `on_chain_status`, such as `pending` or `skipped`; absent when not stated. */
|
|
465
|
+
status?: string;
|
|
466
|
+
/**
|
|
467
|
+
* The reply names the ids this call generated. False when it names another
|
|
468
|
+
* call, or none: `toolCallId` then falls back to this client's own id, which
|
|
469
|
+
* proves nothing about what the judge recorded.
|
|
470
|
+
*/
|
|
471
|
+
boundToCall: boolean;
|
|
472
|
+
/**
|
|
473
|
+
* This reply's signature was checked against a judge key before it was read.
|
|
474
|
+
* False means nothing proves who wrote the reply: it can echo this call's ids
|
|
475
|
+
* and still read as bound, because the ids travel in the request.
|
|
476
|
+
*/
|
|
477
|
+
signatureChecked: boolean;
|
|
478
|
+
/**
|
|
479
|
+
* The judge's own `status`, absent when not stated. `shadow_recorded` is a
|
|
480
|
+
* shadow ack: the call was stored and has no verdict yet, which is what
|
|
481
|
+
* separates it from an ALLOW whose `status` here is `pending`. Read it with
|
|
482
|
+
* `boundToCall` and `signatureChecked`: unsigned, it is only a claim.
|
|
483
|
+
*/
|
|
484
|
+
judgeStatus?: string;
|
|
485
|
+
/**
|
|
486
|
+
* The judge answered this call with a verdict it states is recorded on chain,
|
|
487
|
+
* in a signature-checked reply: `onChain`, `boundToCall` and `signatureChecked`
|
|
488
|
+
* all true, and no `judgeStatus`, which only a reply without a verdict carries
|
|
489
|
+
* (a shadow ack, or an answer that was only logged). Still the judge's word:
|
|
490
|
+
* the SDK does not read the chain.
|
|
491
|
+
*/
|
|
492
|
+
verdictRecorded: boolean;
|
|
493
|
+
}
|
|
409
494
|
/** Canonical decision returned by `auditToolCall`. */
|
|
410
495
|
type DecisionVerdict = "ALLOW" | "HOLD" | "BLOCK" | "ERROR";
|
|
411
496
|
interface Decision {
|
|
@@ -422,6 +507,25 @@ interface Decision {
|
|
|
422
507
|
enforced?: boolean;
|
|
423
508
|
/** Server-reported protection mode (`off`, `monitor`, `enforce`); absent when unknown. */
|
|
424
509
|
enforcementMode?: string;
|
|
510
|
+
/**
|
|
511
|
+
* The verdict the judge reached when the organisation's signed mode
|
|
512
|
+
* (`shadow`, `monitor`, `off`) let the action run anyway: what would have
|
|
513
|
+
* happened under enforcement. Absent when the decision is the verdict.
|
|
514
|
+
*/
|
|
515
|
+
wouldVerdict?: "BLOCK" | "HOLD";
|
|
516
|
+
/**
|
|
517
|
+
* The id the judge recorded this verdict under, when it differs from
|
|
518
|
+
* `toolCallId` (the on-chain judge path), as {@link JudgeResult.judgmentId}.
|
|
519
|
+
* Poll `getJudgmentStatus` with `judgmentId || toolCallId`.
|
|
520
|
+
*/
|
|
521
|
+
judgmentId?: string;
|
|
522
|
+
/**
|
|
523
|
+
* What the judge stated about recording this verdict. Absent means unknown:
|
|
524
|
+
* a transport error, a local jail hold, or a reply that did not state
|
|
525
|
+
* `on_chain`. Treat absent as not recorded. Informational only; `allow`
|
|
526
|
+
* remains the gate.
|
|
527
|
+
*/
|
|
528
|
+
record?: VerdictRecord;
|
|
425
529
|
}
|
|
426
530
|
/** Input to `auditToolCall`. */
|
|
427
531
|
interface ToolCallInput {
|
|
@@ -459,6 +563,8 @@ interface FromConfigOptions {
|
|
|
459
563
|
failClosed?: boolean;
|
|
460
564
|
/** See {@link AtbashOptions.requireEnforcement}. Default true. */
|
|
461
565
|
requireEnforcement?: boolean;
|
|
566
|
+
/** See {@link AtbashOptions.enforceLocally}. Default false. */
|
|
567
|
+
enforceLocally?: boolean;
|
|
462
568
|
/** See {@link AtbashOptions.decisionTimeoutMs}. Default 60 000 ms. */
|
|
463
569
|
decisionTimeoutMs?: number;
|
|
464
570
|
/** See {@link AtbashOptions.debug}. */
|
|
@@ -513,12 +619,21 @@ declare class Atbash {
|
|
|
513
619
|
readonly orgName?: string;
|
|
514
620
|
/** Default judge response-signing pubkey, if configured (see fromConfig). */
|
|
515
621
|
readonly verifyPubKey?: string;
|
|
622
|
+
/**
|
|
623
|
+
* The keys every judge reply must be signed by: the host's pinned keys, or
|
|
624
|
+
* the configured `verifyPubKey` on a host with none. Empty means unchecked.
|
|
625
|
+
*/
|
|
626
|
+
private readonly verifyKeys;
|
|
516
627
|
/** Default org encryption key — see {@link AtbashOptions.orgEncryptionPubKey}. */
|
|
517
628
|
readonly orgEncryptionPubKey?: string;
|
|
518
629
|
/** When true (default), `auditToolCall` denies on any error. */
|
|
519
630
|
readonly failClosed: boolean;
|
|
520
631
|
/** When true (default), an unenforced (audit-tier) answer is refused. */
|
|
521
632
|
readonly requireEnforcement: boolean;
|
|
633
|
+
/** When true, a signed non-enforcing mode never relaxes a verdict. */
|
|
634
|
+
readonly enforceLocally: boolean;
|
|
635
|
+
/** Results whose enforcement mode came signed and bound to their call. */
|
|
636
|
+
private readonly modeTrusted;
|
|
522
637
|
/** Overall deadline for one auditToolCall decision, in ms. */
|
|
523
638
|
readonly decisionTimeoutMs: number;
|
|
524
639
|
/** Org key learned from the last agent-exists check, for this agent only. */
|
|
@@ -659,12 +774,25 @@ declare class Atbash {
|
|
|
659
774
|
* response bytes via the Rust core's `verifySignature`.
|
|
660
775
|
*/
|
|
661
776
|
judgeAction(action: string, context?: string, options?: JudgeOptions): Promise<JudgeResult>;
|
|
777
|
+
/**
|
|
778
|
+
* judgeAction, optionally asking the judge for the true verdict and the
|
|
779
|
+
* organisation's enforcement mode so this client applies the mode itself.
|
|
780
|
+
*
|
|
781
|
+
* Only auditToolCall opts in: judgeAction's callers keep the server-side
|
|
782
|
+
* downgrade they gate on today.
|
|
783
|
+
*
|
|
784
|
+
* @param clientEnforces - Send `X-Atbash-Client-Enforcement` when the reply can be trusted.
|
|
785
|
+
*/
|
|
786
|
+
private judgeTracked;
|
|
662
787
|
private _judgeAction;
|
|
663
788
|
/**
|
|
664
|
-
* Start a local hold on an enforced
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
789
|
+
* Start a local hold on an enforced BLOCK that jails: one already on chain,
|
|
790
|
+
* or one the judge answered before its chain write landed
|
|
791
|
+
* (`on_chain_status: "pending"`), which jails once it lands. Refuse any other
|
|
792
|
+
* result that lands while the agent is held, or whose request was already in
|
|
793
|
+
* flight when the block arrived: the server judged it on pre-jail state.
|
|
794
|
+
*
|
|
795
|
+
* @param onChainStatus - The reply's `on_chain_status`; empty when absent.
|
|
668
796
|
*/
|
|
669
797
|
private applyJailHold;
|
|
670
798
|
/** The server's jailed refusal, produced locally while the agent is held. */
|
|
@@ -677,12 +805,12 @@ declare class Atbash {
|
|
|
677
805
|
*/
|
|
678
806
|
auditToolCall(input: ToolCallInput): Promise<Decision>;
|
|
679
807
|
/**
|
|
680
|
-
* The verify
|
|
681
|
-
* may only narrow what the client accepts: on a client pinned to
|
|
682
|
-
*
|
|
683
|
-
*
|
|
808
|
+
* The verify keys for one call (R4, governor tier-2 review). A per-call key
|
|
809
|
+
* may only narrow what the client accepts: on a client pinned to judge keys
|
|
810
|
+
* it must be one of them, never a replacement; on an unpinned client it
|
|
811
|
+
* adds the check.
|
|
684
812
|
*/
|
|
685
|
-
private
|
|
813
|
+
private effectiveVerifyKeys;
|
|
686
814
|
/**
|
|
687
815
|
* Collapse a judge result into a {@link Decision}. The most restrictive
|
|
688
816
|
* signal wins (security review 2026-09-30, H1): `action_type`, `verdict`
|
|
@@ -693,6 +821,15 @@ declare class Atbash {
|
|
|
693
821
|
* never overrides a refusal.
|
|
694
822
|
*/
|
|
695
823
|
private decide;
|
|
824
|
+
/**
|
|
825
|
+
* Apply the organisation's enforcement mode to the judge's true verdict.
|
|
826
|
+
*
|
|
827
|
+
* Only a mode that arrived signed and bound to this call counts; a missing,
|
|
828
|
+
* unsigned or unknown mode, or enforceLocally, means enforce. Under
|
|
829
|
+
* `shadow`, `monitor` or `off` a BLOCK or HOLD runs, reported in
|
|
830
|
+
* `wouldVerdict`. An ERROR stays an error: it is not a verdict.
|
|
831
|
+
*/
|
|
832
|
+
private applyMode;
|
|
696
833
|
private decideInner;
|
|
697
834
|
/**
|
|
698
835
|
* One exit for every judge failure.
|
|
@@ -1995,4 +2132,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1995
2132
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1996
2133
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1997
2134
|
|
|
1998
|
-
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, type MemoryHistoryPage, 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 };
|
|
2135
|
+
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, type MemoryHistoryPage, 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 VerdictRecord, 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, judgeVerifyKeys, 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, setLoopbackJudgePinsForTests, setupTelemetry, shutdownTelemetry, signEncryptedToolCall, signJudgeAction, signLogToolCall, syncLocalMemory, validateJudgeEndpoint, verifyJudgeResponseSignature, verifySignature };
|