@atbash/sdk 0.13.3-dev.0 → 0.15.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 +2 -2
- package/dist/browser.d.mts +35 -2
- package/dist/browser.mjs +76 -20
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +35 -2
- package/dist/index.d.ts +35 -2
- package/dist/index.js +75 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -169,6 +169,11 @@ interface LogToolCallResult {
|
|
|
169
169
|
}
|
|
170
170
|
interface JudgeResult {
|
|
171
171
|
verdict: Verdict;
|
|
172
|
+
/**
|
|
173
|
+
* Canonical executable permission, computed by `canonicalAllow` — see that
|
|
174
|
+
* function for the rule. Never more permissive than `auditToolCall`.
|
|
175
|
+
*/
|
|
176
|
+
allow: boolean;
|
|
172
177
|
actionType: string;
|
|
173
178
|
reason: string;
|
|
174
179
|
confidence: number;
|
|
@@ -197,6 +202,8 @@ interface JudgeResult {
|
|
|
197
202
|
interface JudgmentStatus {
|
|
198
203
|
status: JudgmentState;
|
|
199
204
|
verdict: Verdict;
|
|
205
|
+
/** Same canonical executable permission as {@link JudgeResult.allow}. */
|
|
206
|
+
allow: boolean;
|
|
200
207
|
reason: string;
|
|
201
208
|
judgmentId: string;
|
|
202
209
|
onChain?: boolean;
|
|
@@ -564,7 +571,17 @@ declare class Atbash {
|
|
|
564
571
|
*/
|
|
565
572
|
private failJudge;
|
|
566
573
|
private fail;
|
|
567
|
-
|
|
574
|
+
/**
|
|
575
|
+
* Return the current status of a previously submitted judgment.
|
|
576
|
+
*
|
|
577
|
+
* `chainOpts` names which chain the judgment was signed against. The
|
|
578
|
+
* server's GET /api/v1/judge routes to that chain when the SDK sends
|
|
579
|
+
* a `brid` query param; without it, the server falls back to public.
|
|
580
|
+
* Callers on the private chain must pass a `chainOpts` (or configure
|
|
581
|
+
* the client on the private chain) — otherwise polling a POSTed
|
|
582
|
+
* judgment on the private chain 404s at the server.
|
|
583
|
+
*/
|
|
584
|
+
getJudgmentStatus(judgmentId: string, agentPubkey?: string, chainOpts?: ChainOpts): Promise<JudgmentStatus>;
|
|
568
585
|
getToolCalls(maxCount: number): Promise<ToolCallRecord[]>;
|
|
569
586
|
getOrgToolCalls(orgName: string, maxCount: number): Promise<ToolCallRecord[]>;
|
|
570
587
|
getAgentToolCalls(agentPubkey: string, maxCount: number): Promise<ToolCallRecord[]>;
|
|
@@ -749,9 +766,25 @@ declare class HttpTransportError extends Error {
|
|
|
749
766
|
});
|
|
750
767
|
}
|
|
751
768
|
|
|
769
|
+
declare function canonicalAllow(data: Record<string, unknown>): boolean;
|
|
770
|
+
|
|
752
771
|
/** Normalize wire shapes (verdict casing, status, pubkey) to canonical forms. */
|
|
753
772
|
|
|
754
773
|
declare function normalizeVerdict(raw: unknown): Verdict;
|
|
774
|
+
/**
|
|
775
|
+
* Canonicalize `action_type` at the wire boundary, the way
|
|
776
|
+
* {@link normalizeVerdict} already canonicalizes `verdict`.
|
|
777
|
+
*
|
|
778
|
+
* `verdict` has been normalized here since the beginning and has never
|
|
779
|
+
* drifted between consumers. `action_type` was passed through raw, so every
|
|
780
|
+
* reader invented its own folding policy — `auditToolCall` compared exactly
|
|
781
|
+
* while `memory/scan.ts` trimmed and case-folded, and the same `" ALLOW "`
|
|
782
|
+
* was therefore an error on one path and permission on the other.
|
|
783
|
+
*
|
|
784
|
+
* Trim and case-fold only. Zero-width and homoglyph variants survive
|
|
785
|
+
* untouched, stay outside the known set, and still fail closed.
|
|
786
|
+
*/
|
|
787
|
+
declare function normalizeActionType(raw: unknown): string;
|
|
755
788
|
declare function normalizeStatus(raw: unknown): JudgmentState;
|
|
756
789
|
/** Wire pubkey may be a hex string, a Buffer/Uint8Array, or `{ data: [...] }`. */
|
|
757
790
|
declare function pubkeyToHex(val: unknown): string;
|
|
@@ -1476,4 +1509,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1476
1509
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1477
1510
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1478
1511
|
|
|
1479
|
-
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_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, PRIVATE_CHAIN, PUBLIC_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, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, 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 };
|
|
1512
|
+
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_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, PRIVATE_CHAIN, PUBLIC_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, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeActionType, 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/index.d.ts
CHANGED
|
@@ -169,6 +169,11 @@ interface LogToolCallResult {
|
|
|
169
169
|
}
|
|
170
170
|
interface JudgeResult {
|
|
171
171
|
verdict: Verdict;
|
|
172
|
+
/**
|
|
173
|
+
* Canonical executable permission, computed by `canonicalAllow` — see that
|
|
174
|
+
* function for the rule. Never more permissive than `auditToolCall`.
|
|
175
|
+
*/
|
|
176
|
+
allow: boolean;
|
|
172
177
|
actionType: string;
|
|
173
178
|
reason: string;
|
|
174
179
|
confidence: number;
|
|
@@ -197,6 +202,8 @@ interface JudgeResult {
|
|
|
197
202
|
interface JudgmentStatus {
|
|
198
203
|
status: JudgmentState;
|
|
199
204
|
verdict: Verdict;
|
|
205
|
+
/** Same canonical executable permission as {@link JudgeResult.allow}. */
|
|
206
|
+
allow: boolean;
|
|
200
207
|
reason: string;
|
|
201
208
|
judgmentId: string;
|
|
202
209
|
onChain?: boolean;
|
|
@@ -564,7 +571,17 @@ declare class Atbash {
|
|
|
564
571
|
*/
|
|
565
572
|
private failJudge;
|
|
566
573
|
private fail;
|
|
567
|
-
|
|
574
|
+
/**
|
|
575
|
+
* Return the current status of a previously submitted judgment.
|
|
576
|
+
*
|
|
577
|
+
* `chainOpts` names which chain the judgment was signed against. The
|
|
578
|
+
* server's GET /api/v1/judge routes to that chain when the SDK sends
|
|
579
|
+
* a `brid` query param; without it, the server falls back to public.
|
|
580
|
+
* Callers on the private chain must pass a `chainOpts` (or configure
|
|
581
|
+
* the client on the private chain) — otherwise polling a POSTed
|
|
582
|
+
* judgment on the private chain 404s at the server.
|
|
583
|
+
*/
|
|
584
|
+
getJudgmentStatus(judgmentId: string, agentPubkey?: string, chainOpts?: ChainOpts): Promise<JudgmentStatus>;
|
|
568
585
|
getToolCalls(maxCount: number): Promise<ToolCallRecord[]>;
|
|
569
586
|
getOrgToolCalls(orgName: string, maxCount: number): Promise<ToolCallRecord[]>;
|
|
570
587
|
getAgentToolCalls(agentPubkey: string, maxCount: number): Promise<ToolCallRecord[]>;
|
|
@@ -749,9 +766,25 @@ declare class HttpTransportError extends Error {
|
|
|
749
766
|
});
|
|
750
767
|
}
|
|
751
768
|
|
|
769
|
+
declare function canonicalAllow(data: Record<string, unknown>): boolean;
|
|
770
|
+
|
|
752
771
|
/** Normalize wire shapes (verdict casing, status, pubkey) to canonical forms. */
|
|
753
772
|
|
|
754
773
|
declare function normalizeVerdict(raw: unknown): Verdict;
|
|
774
|
+
/**
|
|
775
|
+
* Canonicalize `action_type` at the wire boundary, the way
|
|
776
|
+
* {@link normalizeVerdict} already canonicalizes `verdict`.
|
|
777
|
+
*
|
|
778
|
+
* `verdict` has been normalized here since the beginning and has never
|
|
779
|
+
* drifted between consumers. `action_type` was passed through raw, so every
|
|
780
|
+
* reader invented its own folding policy — `auditToolCall` compared exactly
|
|
781
|
+
* while `memory/scan.ts` trimmed and case-folded, and the same `" ALLOW "`
|
|
782
|
+
* was therefore an error on one path and permission on the other.
|
|
783
|
+
*
|
|
784
|
+
* Trim and case-fold only. Zero-width and homoglyph variants survive
|
|
785
|
+
* untouched, stay outside the known set, and still fail closed.
|
|
786
|
+
*/
|
|
787
|
+
declare function normalizeActionType(raw: unknown): string;
|
|
755
788
|
declare function normalizeStatus(raw: unknown): JudgmentState;
|
|
756
789
|
/** Wire pubkey may be a hex string, a Buffer/Uint8Array, or `{ data: [...] }`. */
|
|
757
790
|
declare function pubkeyToHex(val: unknown): string;
|
|
@@ -1476,4 +1509,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1476
1509
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1477
1510
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1478
1511
|
|
|
1479
|
-
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_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, PRIVATE_CHAIN, PUBLIC_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, chainForNetwork, chooseKeyPath, claimHashHex, classifyMemoryRead, classifyMemoryWrite, columnAad, commitMemoryVersion, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, 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 };
|
|
1512
|
+
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_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, PRIVATE_CHAIN, PUBLIC_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, containsEvasionCharacters, containsSecret, createFileLogger, createMemoryGuardManager, createMemorySnapshot, decryptForOrg, decryptMemoryContent, defaultPluginLogPath, defaultPointerPath, deriveMemoryKey, derivePublicKey, diffMemorySnapshots, encryptForOrg, encryptMemoryContent, encryptedLength, flushTelemetry, generateKeypair, getActiveAgentMemory, getActiveMemoryId, getConfigDir, getConfigPath, getMemoryById, getMemoryHistory, getRecentAgentMemory, getRollbackHistory, guardMemoryWrite, isEnvelope, isValidPrivateKey, keyFingerprintOf, keyPathCandidates, loadAgent, loadAgentFromFile, loadUserConfig, normalizeActionForHash, normalizeActionType, 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/index.js
CHANGED
|
@@ -2875,6 +2875,7 @@ __export(src_ts_exports, {
|
|
|
2875
2875
|
SignatureVerificationError: () => SignatureVerificationError,
|
|
2876
2876
|
bootSyncFailureLine: () => bootSyncFailureLine,
|
|
2877
2877
|
buildAllowedJudgeHosts: () => buildAllowedJudgeHosts,
|
|
2878
|
+
canonicalAllow: () => canonicalAllow,
|
|
2878
2879
|
chainForNetwork: () => chainForNetwork,
|
|
2879
2880
|
chooseKeyPath: () => chooseKeyPath,
|
|
2880
2881
|
claimHashHex: () => claimHashHex,
|
|
@@ -2916,6 +2917,7 @@ __export(src_ts_exports, {
|
|
|
2916
2917
|
loadAgentFromFile: () => loadAgentFromFile,
|
|
2917
2918
|
loadUserConfig: () => loadUserConfig,
|
|
2918
2919
|
normalizeActionForHash: () => normalizeActionForHash,
|
|
2920
|
+
normalizeActionType: () => normalizeActionType,
|
|
2919
2921
|
normalizeForMatching: () => normalizeForMatching,
|
|
2920
2922
|
normalizeStatus: () => normalizeStatus,
|
|
2921
2923
|
normalizeVerdict: () => normalizeVerdict,
|
|
@@ -3278,6 +3280,9 @@ function normalizeVerdict(raw2) {
|
|
|
3278
3280
|
if (v === "BLOCK" || v === "RED") return "BLOCK";
|
|
3279
3281
|
return "HOLD";
|
|
3280
3282
|
}
|
|
3283
|
+
function normalizeActionType(raw2) {
|
|
3284
|
+
return typeof raw2 === "string" ? raw2.trim().toLowerCase() : "";
|
|
3285
|
+
}
|
|
3281
3286
|
function normalizeStatus(raw2) {
|
|
3282
3287
|
const s2 = String(raw2 ?? "").toLowerCase();
|
|
3283
3288
|
if (s2 === "pending" || s2 === "answered" || s2 === "error") return s2;
|
|
@@ -3294,6 +3299,37 @@ function pubkeyToHex(val) {
|
|
|
3294
3299
|
return "";
|
|
3295
3300
|
}
|
|
3296
3301
|
|
|
3302
|
+
// src-ts/decision.ts
|
|
3303
|
+
function isRecord(value) {
|
|
3304
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3305
|
+
}
|
|
3306
|
+
function allowSignalsPermit(data) {
|
|
3307
|
+
const signals = [];
|
|
3308
|
+
if (Object.hasOwn(data, "allow")) signals.push(data.allow);
|
|
3309
|
+
if (isRecord(data.decision) && Object.hasOwn(data.decision, "allow")) {
|
|
3310
|
+
signals.push(data.decision.allow);
|
|
3311
|
+
}
|
|
3312
|
+
return signals.length === 0 || signals.every((value) => value === true);
|
|
3313
|
+
}
|
|
3314
|
+
function wireActionType(data) {
|
|
3315
|
+
if (data.action_type !== void 0)
|
|
3316
|
+
return normalizeActionType(data.action_type);
|
|
3317
|
+
return normalizeActionType(data.actionType);
|
|
3318
|
+
}
|
|
3319
|
+
function isAuditTier(data) {
|
|
3320
|
+
const absentVerdict = data.verdict === null || data.verdict === void 0;
|
|
3321
|
+
return absentVerdict && data.status === "logged";
|
|
3322
|
+
}
|
|
3323
|
+
function canonicalAllow(data) {
|
|
3324
|
+
if (!allowSignalsPermit(data)) return false;
|
|
3325
|
+
const actionType = wireActionType(data);
|
|
3326
|
+
if (actionType && actionType !== "allow") return false;
|
|
3327
|
+
if (isAuditTier(data)) return true;
|
|
3328
|
+
if (typeof data.verdict !== "string") return false;
|
|
3329
|
+
const verdict = data.verdict.trim().toUpperCase();
|
|
3330
|
+
return verdict === "ALLOW" || verdict === "GREEN";
|
|
3331
|
+
}
|
|
3332
|
+
|
|
3297
3333
|
// src-ts/opentel/telemetry.ts
|
|
3298
3334
|
var import_node_fs2 = require("fs");
|
|
3299
3335
|
var import_node_os2 = require("os");
|
|
@@ -3606,7 +3642,10 @@ var Atbash = class _Atbash {
|
|
|
3606
3642
|
getAuthHeaders: () => this.authHeaders()
|
|
3607
3643
|
});
|
|
3608
3644
|
} catch (err) {
|
|
3609
|
-
this.logger.warn?.(
|
|
3645
|
+
this.logger.warn?.(
|
|
3646
|
+
"[atbash] telemetry setup failed \u2014 continuing without metrics",
|
|
3647
|
+
{ error: String(err) }
|
|
3648
|
+
);
|
|
3610
3649
|
}
|
|
3611
3650
|
}
|
|
3612
3651
|
/**
|
|
@@ -3821,7 +3860,10 @@ var Atbash = class _Atbash {
|
|
|
3821
3860
|
this._chainCache.set(options.orgName, chain);
|
|
3822
3861
|
chainOpts = { network: mapNetwork };
|
|
3823
3862
|
} else if (!chainOpts?.blockchainRid) {
|
|
3824
|
-
const resolved = await this.resolveChainFromMap(
|
|
3863
|
+
const resolved = await this.resolveChainFromMap(
|
|
3864
|
+
options.orgName,
|
|
3865
|
+
null
|
|
3866
|
+
);
|
|
3825
3867
|
chainOpts = { ...chainOpts, network: resolved.network };
|
|
3826
3868
|
}
|
|
3827
3869
|
}
|
|
@@ -3896,7 +3938,8 @@ var Atbash = class _Atbash {
|
|
|
3896
3938
|
const score = typeof rawScore === "number" && Number.isInteger(rawScore) && rawScore >= 1 && rawScore <= 10 ? rawScore : void 0;
|
|
3897
3939
|
return {
|
|
3898
3940
|
verdict: normalizeVerdict(data.verdict),
|
|
3899
|
-
|
|
3941
|
+
allow: canonicalAllow(data),
|
|
3942
|
+
actionType: normalizeActionType(data.action_type),
|
|
3900
3943
|
reason: String(data.reason ?? ""),
|
|
3901
3944
|
confidence: Number(data.confidence ?? 0),
|
|
3902
3945
|
provider: String(data.provider ?? ""),
|
|
@@ -4038,19 +4081,31 @@ var Atbash = class _Atbash {
|
|
|
4038
4081
|
return { allow: !this.failClosed, verdict: "ERROR", reason, toolCallId };
|
|
4039
4082
|
}
|
|
4040
4083
|
/* ── judgment status ───────────────────────────────────────────────────── */
|
|
4041
|
-
|
|
4084
|
+
/**
|
|
4085
|
+
* Return the current status of a previously submitted judgment.
|
|
4086
|
+
*
|
|
4087
|
+
* `chainOpts` names which chain the judgment was signed against. The
|
|
4088
|
+
* server's GET /api/v1/judge routes to that chain when the SDK sends
|
|
4089
|
+
* a `brid` query param; without it, the server falls back to public.
|
|
4090
|
+
* Callers on the private chain must pass a `chainOpts` (or configure
|
|
4091
|
+
* the client on the private chain) — otherwise polling a POSTed
|
|
4092
|
+
* judgment on the private chain 404s at the server.
|
|
4093
|
+
*/
|
|
4094
|
+
async getJudgmentStatus(judgmentId, agentPubkey, chainOpts) {
|
|
4042
4095
|
const pk = agentPubkey ?? this.auth.pubkey;
|
|
4096
|
+
const brid = this.bridFromChainOpts(chainOpts);
|
|
4043
4097
|
return this.track("getJudgmentStatus", pk, async () => {
|
|
4044
4098
|
const resp = await this.http.get(
|
|
4045
4099
|
"/api/v1/judge",
|
|
4046
|
-
{ tool_call_id: judgmentId, agent_pubkey: pk },
|
|
4047
|
-
this.authHeaders(
|
|
4100
|
+
{ tool_call_id: judgmentId, agent_pubkey: pk, brid },
|
|
4101
|
+
this.authHeaders(brid)
|
|
4048
4102
|
);
|
|
4049
4103
|
await this.raiseIfError(resp);
|
|
4050
4104
|
const data = await this.json(resp) ?? {};
|
|
4051
4105
|
return {
|
|
4052
4106
|
status: normalizeStatus(data.status),
|
|
4053
4107
|
verdict: normalizeVerdict(data.verdict),
|
|
4108
|
+
allow: canonicalAllow(data),
|
|
4054
4109
|
reason: String(data.reason ?? ""),
|
|
4055
4110
|
judgmentId: String(data.judgmentId ?? judgmentId),
|
|
4056
4111
|
onChain: optBool(data.onChain),
|
|
@@ -4110,7 +4165,7 @@ var Atbash = class _Atbash {
|
|
|
4110
4165
|
{ tool_call_id: toolCallId },
|
|
4111
4166
|
await this.defaultOrgBrid()
|
|
4112
4167
|
);
|
|
4113
|
-
if (!
|
|
4168
|
+
if (!isRecord2(raw2)) return null;
|
|
4114
4169
|
return toToolCallFull(raw2);
|
|
4115
4170
|
});
|
|
4116
4171
|
}
|
|
@@ -4122,7 +4177,7 @@ var Atbash = class _Atbash {
|
|
|
4122
4177
|
{ org: orgName },
|
|
4123
4178
|
brid
|
|
4124
4179
|
);
|
|
4125
|
-
if (!
|
|
4180
|
+
if (!isRecord2(raw2)) return null;
|
|
4126
4181
|
return {
|
|
4127
4182
|
orgName: String(raw2.org_name ?? ""),
|
|
4128
4183
|
tier: String(raw2.tier ?? ""),
|
|
@@ -4199,7 +4254,7 @@ var Atbash = class _Atbash {
|
|
|
4199
4254
|
);
|
|
4200
4255
|
await this.raiseIfError(resp);
|
|
4201
4256
|
const data = await this.json(resp) ?? {};
|
|
4202
|
-
if (
|
|
4257
|
+
if (isRecord2(data.data)) return data.data;
|
|
4203
4258
|
return data;
|
|
4204
4259
|
});
|
|
4205
4260
|
}
|
|
@@ -4215,7 +4270,7 @@ var Atbash = class _Atbash {
|
|
|
4215
4270
|
if (network) params.network = network;
|
|
4216
4271
|
const brid = network ? this.bridFromChainOpts({ network }) : void 0;
|
|
4217
4272
|
const raw2 = await this.riskEngineGet("org-subscription", params, brid);
|
|
4218
|
-
if (!
|
|
4273
|
+
if (!isRecord2(raw2)) return null;
|
|
4219
4274
|
return coerceOrgSubscription(raw2, orgName);
|
|
4220
4275
|
});
|
|
4221
4276
|
}
|
|
@@ -4421,7 +4476,7 @@ var Atbash = class _Atbash {
|
|
|
4421
4476
|
}
|
|
4422
4477
|
if (resp.status !== 200) throw await this.httpError(resp);
|
|
4423
4478
|
const data = await this.json(resp);
|
|
4424
|
-
return
|
|
4479
|
+
return isRecord2(data) ? data : {};
|
|
4425
4480
|
}
|
|
4426
4481
|
async riskEngineRecords(action, params, brid) {
|
|
4427
4482
|
const raw2 = await this.riskEngineGet(action, params, brid);
|
|
@@ -4488,14 +4543,11 @@ var Atbash = class _Atbash {
|
|
|
4488
4543
|
transportError(err) {
|
|
4489
4544
|
if (err instanceof HttpTransportError) {
|
|
4490
4545
|
if (this.debug) {
|
|
4491
|
-
this.logger.warn?.(
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
endpoint: this.endpoint
|
|
4497
|
-
}
|
|
4498
|
-
);
|
|
4546
|
+
this.logger.warn?.(`[atbash] transport failed \u2014 kind=${err.kind}`, {
|
|
4547
|
+
kind: err.kind,
|
|
4548
|
+
cause: err.cause instanceof Error ? err.cause.message : String(err.cause ?? ""),
|
|
4549
|
+
endpoint: this.endpoint
|
|
4550
|
+
});
|
|
4499
4551
|
}
|
|
4500
4552
|
return new AtbashAPIError(0, err.message, "", this.endpoint);
|
|
4501
4553
|
}
|
|
@@ -4593,7 +4645,7 @@ function coerceOrgSubscription(raw2, orgName) {
|
|
|
4593
4645
|
is_active: Boolean(raw2.is_active)
|
|
4594
4646
|
};
|
|
4595
4647
|
}
|
|
4596
|
-
function
|
|
4648
|
+
function isRecord2(v) {
|
|
4597
4649
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4598
4650
|
}
|
|
4599
4651
|
function optString(v) {
|
|
@@ -4732,7 +4784,7 @@ async function scanMemory(entry, auth, opts) {
|
|
|
4732
4784
|
);
|
|
4733
4785
|
}
|
|
4734
4786
|
const KNOWN_ACTIONS = ["allow", "block", "hold_for_user_confirm"];
|
|
4735
|
-
const action = result.actionType
|
|
4787
|
+
const action = result.actionType;
|
|
4736
4788
|
if (result.verdict !== "No verdict" && action !== "" && !KNOWN_ACTIONS.includes(action)) {
|
|
4737
4789
|
throw new Error(
|
|
4738
4790
|
`memory scan: unrecognized action_type from judge (${result.actionType})`
|
|
@@ -43735,6 +43787,7 @@ function diffMemorySnapshots(before, after) {
|
|
|
43735
43787
|
SignatureVerificationError,
|
|
43736
43788
|
bootSyncFailureLine,
|
|
43737
43789
|
buildAllowedJudgeHosts,
|
|
43790
|
+
canonicalAllow,
|
|
43738
43791
|
chainForNetwork,
|
|
43739
43792
|
chooseKeyPath,
|
|
43740
43793
|
claimHashHex,
|
|
@@ -43776,6 +43829,7 @@ function diffMemorySnapshots(before, after) {
|
|
|
43776
43829
|
loadAgentFromFile,
|
|
43777
43830
|
loadUserConfig,
|
|
43778
43831
|
normalizeActionForHash,
|
|
43832
|
+
normalizeActionType,
|
|
43779
43833
|
normalizeForMatching,
|
|
43780
43834
|
normalizeStatus,
|
|
43781
43835
|
normalizeVerdict,
|