@atbash/sdk 0.14.1-dev.0 → 0.15.1-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 +24 -1
- package/dist/browser.mjs +62 -18
- package/dist/index.d.mts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +61 -19
- package/dist/index.mjs +59 -19
- package/package.json +6 -6
- package/dist/browser.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/browser.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;
|
|
@@ -759,9 +766,25 @@ declare class HttpTransportError extends Error {
|
|
|
759
766
|
});
|
|
760
767
|
}
|
|
761
768
|
|
|
769
|
+
declare function canonicalAllow(data: Record<string, unknown>): boolean;
|
|
770
|
+
|
|
762
771
|
/** Normalize wire shapes (verdict casing, status, pubkey) to canonical forms. */
|
|
763
772
|
|
|
764
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;
|
|
765
788
|
declare function normalizeStatus(raw: unknown): JudgmentState;
|
|
766
789
|
/** Wire pubkey may be a hex string, a Buffer/Uint8Array, or `{ data: [...] }`. */
|
|
767
790
|
declare function pubkeyToHex(val: unknown): string;
|
|
@@ -1486,4 +1509,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1486
1509
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1487
1510
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1488
1511
|
|
|
1489
|
-
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/browser.mjs
CHANGED
|
@@ -44555,6 +44555,10 @@ function loadAgentFromFile(_keyPath) {
|
|
|
44555
44555
|
throw new Error(NOT_AVAILABLE);
|
|
44556
44556
|
}
|
|
44557
44557
|
|
|
44558
|
+
// src-ts/decision.ts
|
|
44559
|
+
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44560
|
+
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
44561
|
+
|
|
44558
44562
|
// src-ts/normalize.ts
|
|
44559
44563
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44560
44564
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
@@ -44566,6 +44570,9 @@ function normalizeVerdict(raw2) {
|
|
|
44566
44570
|
if (v === "BLOCK" || v === "RED") return "BLOCK";
|
|
44567
44571
|
return "HOLD";
|
|
44568
44572
|
}
|
|
44573
|
+
function normalizeActionType(raw2) {
|
|
44574
|
+
return typeof raw2 === "string" ? raw2.trim().toLowerCase() : "";
|
|
44575
|
+
}
|
|
44569
44576
|
function normalizeStatus(raw2) {
|
|
44570
44577
|
const s2 = String(raw2 ?? "").toLowerCase();
|
|
44571
44578
|
if (s2 === "pending" || s2 === "answered" || s2 === "error") return s2;
|
|
@@ -44582,6 +44589,37 @@ function pubkeyToHex(val) {
|
|
|
44582
44589
|
return "";
|
|
44583
44590
|
}
|
|
44584
44591
|
|
|
44592
|
+
// src-ts/decision.ts
|
|
44593
|
+
function isRecord(value) {
|
|
44594
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44595
|
+
}
|
|
44596
|
+
function allowSignalsPermit(data) {
|
|
44597
|
+
const signals = [];
|
|
44598
|
+
if (Object.hasOwn(data, "allow")) signals.push(data.allow);
|
|
44599
|
+
if (isRecord(data.decision) && Object.hasOwn(data.decision, "allow")) {
|
|
44600
|
+
signals.push(data.decision.allow);
|
|
44601
|
+
}
|
|
44602
|
+
return signals.length === 0 || signals.every((value) => value === true);
|
|
44603
|
+
}
|
|
44604
|
+
function wireActionType(data) {
|
|
44605
|
+
if (data.action_type !== void 0)
|
|
44606
|
+
return normalizeActionType(data.action_type);
|
|
44607
|
+
return normalizeActionType(data.actionType);
|
|
44608
|
+
}
|
|
44609
|
+
function isAuditTier(data) {
|
|
44610
|
+
const absentVerdict = data.verdict === null || data.verdict === void 0;
|
|
44611
|
+
return absentVerdict && data.status === "logged";
|
|
44612
|
+
}
|
|
44613
|
+
function canonicalAllow(data) {
|
|
44614
|
+
if (!allowSignalsPermit(data)) return false;
|
|
44615
|
+
const actionType = wireActionType(data);
|
|
44616
|
+
if (actionType && actionType !== "allow") return false;
|
|
44617
|
+
if (isAuditTier(data)) return true;
|
|
44618
|
+
if (typeof data.verdict !== "string") return false;
|
|
44619
|
+
const verdict = data.verdict.trim().toUpperCase();
|
|
44620
|
+
return verdict === "ALLOW" || verdict === "GREEN";
|
|
44621
|
+
}
|
|
44622
|
+
|
|
44585
44623
|
// src-ts/browser/opentel/telemetry.ts
|
|
44586
44624
|
init_define_ATBASH_CHROMIA_NODE_URLS();
|
|
44587
44625
|
init_define_ATBASH_PRIVATE_NODE_URLS();
|
|
@@ -44750,7 +44788,10 @@ var Atbash = class _Atbash {
|
|
|
44750
44788
|
getAuthHeaders: () => this.authHeaders()
|
|
44751
44789
|
});
|
|
44752
44790
|
} catch (err) {
|
|
44753
|
-
this.logger.warn?.(
|
|
44791
|
+
this.logger.warn?.(
|
|
44792
|
+
"[atbash] telemetry setup failed \u2014 continuing without metrics",
|
|
44793
|
+
{ error: String(err) }
|
|
44794
|
+
);
|
|
44754
44795
|
}
|
|
44755
44796
|
}
|
|
44756
44797
|
/**
|
|
@@ -44965,7 +45006,10 @@ var Atbash = class _Atbash {
|
|
|
44965
45006
|
this._chainCache.set(options.orgName, chain);
|
|
44966
45007
|
chainOpts = { network: mapNetwork };
|
|
44967
45008
|
} else if (!chainOpts?.blockchainRid) {
|
|
44968
|
-
const resolved = await this.resolveChainFromMap(
|
|
45009
|
+
const resolved = await this.resolveChainFromMap(
|
|
45010
|
+
options.orgName,
|
|
45011
|
+
null
|
|
45012
|
+
);
|
|
44969
45013
|
chainOpts = { ...chainOpts, network: resolved.network };
|
|
44970
45014
|
}
|
|
44971
45015
|
}
|
|
@@ -45040,7 +45084,8 @@ var Atbash = class _Atbash {
|
|
|
45040
45084
|
const score = typeof rawScore === "number" && Number.isInteger(rawScore) && rawScore >= 1 && rawScore <= 10 ? rawScore : void 0;
|
|
45041
45085
|
return {
|
|
45042
45086
|
verdict: normalizeVerdict(data.verdict),
|
|
45043
|
-
|
|
45087
|
+
allow: canonicalAllow(data),
|
|
45088
|
+
actionType: normalizeActionType(data.action_type),
|
|
45044
45089
|
reason: String(data.reason ?? ""),
|
|
45045
45090
|
confidence: Number(data.confidence ?? 0),
|
|
45046
45091
|
provider: String(data.provider ?? ""),
|
|
@@ -45206,6 +45251,7 @@ var Atbash = class _Atbash {
|
|
|
45206
45251
|
return {
|
|
45207
45252
|
status: normalizeStatus(data.status),
|
|
45208
45253
|
verdict: normalizeVerdict(data.verdict),
|
|
45254
|
+
allow: canonicalAllow(data),
|
|
45209
45255
|
reason: String(data.reason ?? ""),
|
|
45210
45256
|
judgmentId: String(data.judgmentId ?? judgmentId),
|
|
45211
45257
|
onChain: optBool(data.onChain),
|
|
@@ -45265,7 +45311,7 @@ var Atbash = class _Atbash {
|
|
|
45265
45311
|
{ tool_call_id: toolCallId },
|
|
45266
45312
|
await this.defaultOrgBrid()
|
|
45267
45313
|
);
|
|
45268
|
-
if (!
|
|
45314
|
+
if (!isRecord2(raw2)) return null;
|
|
45269
45315
|
return toToolCallFull(raw2);
|
|
45270
45316
|
});
|
|
45271
45317
|
}
|
|
@@ -45277,7 +45323,7 @@ var Atbash = class _Atbash {
|
|
|
45277
45323
|
{ org: orgName },
|
|
45278
45324
|
brid
|
|
45279
45325
|
);
|
|
45280
|
-
if (!
|
|
45326
|
+
if (!isRecord2(raw2)) return null;
|
|
45281
45327
|
return {
|
|
45282
45328
|
orgName: String(raw2.org_name ?? ""),
|
|
45283
45329
|
tier: String(raw2.tier ?? ""),
|
|
@@ -45354,7 +45400,7 @@ var Atbash = class _Atbash {
|
|
|
45354
45400
|
);
|
|
45355
45401
|
await this.raiseIfError(resp);
|
|
45356
45402
|
const data = await this.json(resp) ?? {};
|
|
45357
|
-
if (
|
|
45403
|
+
if (isRecord2(data.data)) return data.data;
|
|
45358
45404
|
return data;
|
|
45359
45405
|
});
|
|
45360
45406
|
}
|
|
@@ -45370,7 +45416,7 @@ var Atbash = class _Atbash {
|
|
|
45370
45416
|
if (network) params.network = network;
|
|
45371
45417
|
const brid = network ? this.bridFromChainOpts({ network }) : void 0;
|
|
45372
45418
|
const raw2 = await this.riskEngineGet("org-subscription", params, brid);
|
|
45373
|
-
if (!
|
|
45419
|
+
if (!isRecord2(raw2)) return null;
|
|
45374
45420
|
return coerceOrgSubscription(raw2, orgName);
|
|
45375
45421
|
});
|
|
45376
45422
|
}
|
|
@@ -45576,7 +45622,7 @@ var Atbash = class _Atbash {
|
|
|
45576
45622
|
}
|
|
45577
45623
|
if (resp.status !== 200) throw await this.httpError(resp);
|
|
45578
45624
|
const data = await this.json(resp);
|
|
45579
|
-
return
|
|
45625
|
+
return isRecord2(data) ? data : {};
|
|
45580
45626
|
}
|
|
45581
45627
|
async riskEngineRecords(action, params, brid) {
|
|
45582
45628
|
const raw2 = await this.riskEngineGet(action, params, brid);
|
|
@@ -45643,14 +45689,11 @@ var Atbash = class _Atbash {
|
|
|
45643
45689
|
transportError(err) {
|
|
45644
45690
|
if (err instanceof HttpTransportError) {
|
|
45645
45691
|
if (this.debug) {
|
|
45646
|
-
this.logger.warn?.(
|
|
45647
|
-
|
|
45648
|
-
|
|
45649
|
-
|
|
45650
|
-
|
|
45651
|
-
endpoint: this.endpoint
|
|
45652
|
-
}
|
|
45653
|
-
);
|
|
45692
|
+
this.logger.warn?.(`[atbash] transport failed \u2014 kind=${err.kind}`, {
|
|
45693
|
+
kind: err.kind,
|
|
45694
|
+
cause: err.cause instanceof Error ? err.cause.message : String(err.cause ?? ""),
|
|
45695
|
+
endpoint: this.endpoint
|
|
45696
|
+
});
|
|
45654
45697
|
}
|
|
45655
45698
|
return new AtbashAPIError(0, err.message, "", this.endpoint);
|
|
45656
45699
|
}
|
|
@@ -45748,7 +45791,7 @@ function coerceOrgSubscription(raw2, orgName) {
|
|
|
45748
45791
|
is_active: Boolean(raw2.is_active)
|
|
45749
45792
|
};
|
|
45750
45793
|
}
|
|
45751
|
-
function
|
|
45794
|
+
function isRecord2(v) {
|
|
45752
45795
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
45753
45796
|
}
|
|
45754
45797
|
function optString(v) {
|
|
@@ -46318,6 +46361,7 @@ export {
|
|
|
46318
46361
|
SignatureVerificationError,
|
|
46319
46362
|
bootSyncFailureLine,
|
|
46320
46363
|
buildAllowedJudgeHosts,
|
|
46364
|
+
canonicalAllow,
|
|
46321
46365
|
chainForNetwork,
|
|
46322
46366
|
chooseKeyPath,
|
|
46323
46367
|
claimHashHex,
|
|
@@ -46359,6 +46403,7 @@ export {
|
|
|
46359
46403
|
loadAgentFromFile,
|
|
46360
46404
|
loadUserConfig,
|
|
46361
46405
|
normalizeActionForHash,
|
|
46406
|
+
normalizeActionType,
|
|
46362
46407
|
normalizeForMatching2 as normalizeForMatching,
|
|
46363
46408
|
normalizeStatus,
|
|
46364
46409
|
normalizeVerdict,
|
|
@@ -46407,4 +46452,3 @@ postchain-client/built/esm/index.js:
|
|
|
46407
46452
|
@noble/ciphers/utils.js:
|
|
46408
46453
|
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
|
|
46409
46454
|
*/
|
|
46410
|
-
//# sourceMappingURL=browser.mjs.map
|
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;
|
|
@@ -759,9 +766,25 @@ declare class HttpTransportError extends Error {
|
|
|
759
766
|
});
|
|
760
767
|
}
|
|
761
768
|
|
|
769
|
+
declare function canonicalAllow(data: Record<string, unknown>): boolean;
|
|
770
|
+
|
|
762
771
|
/** Normalize wire shapes (verdict casing, status, pubkey) to canonical forms. */
|
|
763
772
|
|
|
764
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;
|
|
765
788
|
declare function normalizeStatus(raw: unknown): JudgmentState;
|
|
766
789
|
/** Wire pubkey may be a hex string, a Buffer/Uint8Array, or `{ data: [...] }`. */
|
|
767
790
|
declare function pubkeyToHex(val: unknown): string;
|
|
@@ -1486,4 +1509,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1486
1509
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1487
1510
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1488
1511
|
|
|
1489
|
-
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;
|
|
@@ -759,9 +766,25 @@ declare class HttpTransportError extends Error {
|
|
|
759
766
|
});
|
|
760
767
|
}
|
|
761
768
|
|
|
769
|
+
declare function canonicalAllow(data: Record<string, unknown>): boolean;
|
|
770
|
+
|
|
762
771
|
/** Normalize wire shapes (verdict casing, status, pubkey) to canonical forms. */
|
|
763
772
|
|
|
764
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;
|
|
765
788
|
declare function normalizeStatus(raw: unknown): JudgmentState;
|
|
766
789
|
/** Wire pubkey may be a hex string, a Buffer/Uint8Array, or `{ data: [...] }`. */
|
|
767
790
|
declare function pubkeyToHex(val: unknown): string;
|
|
@@ -1486,4 +1509,4 @@ declare function containsSecret(text: string): boolean;
|
|
|
1486
1509
|
declare function createMemorySnapshot(entries: MemoryEntry[], takenAt: number): MemorySnapshot;
|
|
1487
1510
|
declare function diffMemorySnapshots(before: MemorySnapshot, after: MemorySnapshot): MemoryDiffResult;
|
|
1488
1511
|
|
|
1489
|
-
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 ?? ""),
|
|
@@ -4062,6 +4105,7 @@ var Atbash = class _Atbash {
|
|
|
4062
4105
|
return {
|
|
4063
4106
|
status: normalizeStatus(data.status),
|
|
4064
4107
|
verdict: normalizeVerdict(data.verdict),
|
|
4108
|
+
allow: canonicalAllow(data),
|
|
4065
4109
|
reason: String(data.reason ?? ""),
|
|
4066
4110
|
judgmentId: String(data.judgmentId ?? judgmentId),
|
|
4067
4111
|
onChain: optBool(data.onChain),
|
|
@@ -4121,7 +4165,7 @@ var Atbash = class _Atbash {
|
|
|
4121
4165
|
{ tool_call_id: toolCallId },
|
|
4122
4166
|
await this.defaultOrgBrid()
|
|
4123
4167
|
);
|
|
4124
|
-
if (!
|
|
4168
|
+
if (!isRecord2(raw2)) return null;
|
|
4125
4169
|
return toToolCallFull(raw2);
|
|
4126
4170
|
});
|
|
4127
4171
|
}
|
|
@@ -4133,7 +4177,7 @@ var Atbash = class _Atbash {
|
|
|
4133
4177
|
{ org: orgName },
|
|
4134
4178
|
brid
|
|
4135
4179
|
);
|
|
4136
|
-
if (!
|
|
4180
|
+
if (!isRecord2(raw2)) return null;
|
|
4137
4181
|
return {
|
|
4138
4182
|
orgName: String(raw2.org_name ?? ""),
|
|
4139
4183
|
tier: String(raw2.tier ?? ""),
|
|
@@ -4210,7 +4254,7 @@ var Atbash = class _Atbash {
|
|
|
4210
4254
|
);
|
|
4211
4255
|
await this.raiseIfError(resp);
|
|
4212
4256
|
const data = await this.json(resp) ?? {};
|
|
4213
|
-
if (
|
|
4257
|
+
if (isRecord2(data.data)) return data.data;
|
|
4214
4258
|
return data;
|
|
4215
4259
|
});
|
|
4216
4260
|
}
|
|
@@ -4226,7 +4270,7 @@ var Atbash = class _Atbash {
|
|
|
4226
4270
|
if (network) params.network = network;
|
|
4227
4271
|
const brid = network ? this.bridFromChainOpts({ network }) : void 0;
|
|
4228
4272
|
const raw2 = await this.riskEngineGet("org-subscription", params, brid);
|
|
4229
|
-
if (!
|
|
4273
|
+
if (!isRecord2(raw2)) return null;
|
|
4230
4274
|
return coerceOrgSubscription(raw2, orgName);
|
|
4231
4275
|
});
|
|
4232
4276
|
}
|
|
@@ -4432,7 +4476,7 @@ var Atbash = class _Atbash {
|
|
|
4432
4476
|
}
|
|
4433
4477
|
if (resp.status !== 200) throw await this.httpError(resp);
|
|
4434
4478
|
const data = await this.json(resp);
|
|
4435
|
-
return
|
|
4479
|
+
return isRecord2(data) ? data : {};
|
|
4436
4480
|
}
|
|
4437
4481
|
async riskEngineRecords(action, params, brid) {
|
|
4438
4482
|
const raw2 = await this.riskEngineGet(action, params, brid);
|
|
@@ -4499,14 +4543,11 @@ var Atbash = class _Atbash {
|
|
|
4499
4543
|
transportError(err) {
|
|
4500
4544
|
if (err instanceof HttpTransportError) {
|
|
4501
4545
|
if (this.debug) {
|
|
4502
|
-
this.logger.warn?.(
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
endpoint: this.endpoint
|
|
4508
|
-
}
|
|
4509
|
-
);
|
|
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
|
+
});
|
|
4510
4551
|
}
|
|
4511
4552
|
return new AtbashAPIError(0, err.message, "", this.endpoint);
|
|
4512
4553
|
}
|
|
@@ -4604,7 +4645,7 @@ function coerceOrgSubscription(raw2, orgName) {
|
|
|
4604
4645
|
is_active: Boolean(raw2.is_active)
|
|
4605
4646
|
};
|
|
4606
4647
|
}
|
|
4607
|
-
function
|
|
4648
|
+
function isRecord2(v) {
|
|
4608
4649
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4609
4650
|
}
|
|
4610
4651
|
function optString(v) {
|
|
@@ -4743,7 +4784,7 @@ async function scanMemory(entry, auth, opts) {
|
|
|
4743
4784
|
);
|
|
4744
4785
|
}
|
|
4745
4786
|
const KNOWN_ACTIONS = ["allow", "block", "hold_for_user_confirm"];
|
|
4746
|
-
const action = result.actionType
|
|
4787
|
+
const action = result.actionType;
|
|
4747
4788
|
if (result.verdict !== "No verdict" && action !== "" && !KNOWN_ACTIONS.includes(action)) {
|
|
4748
4789
|
throw new Error(
|
|
4749
4790
|
`memory scan: unrecognized action_type from judge (${result.actionType})`
|
|
@@ -43746,6 +43787,7 @@ function diffMemorySnapshots(before, after) {
|
|
|
43746
43787
|
SignatureVerificationError,
|
|
43747
43788
|
bootSyncFailureLine,
|
|
43748
43789
|
buildAllowedJudgeHosts,
|
|
43790
|
+
canonicalAllow,
|
|
43749
43791
|
chainForNetwork,
|
|
43750
43792
|
chooseKeyPath,
|
|
43751
43793
|
claimHashHex,
|
|
@@ -43787,6 +43829,7 @@ function diffMemorySnapshots(before, after) {
|
|
|
43787
43829
|
loadAgentFromFile,
|
|
43788
43830
|
loadUserConfig,
|
|
43789
43831
|
normalizeActionForHash,
|
|
43832
|
+
normalizeActionType,
|
|
43790
43833
|
normalizeForMatching,
|
|
43791
43834
|
normalizeStatus,
|
|
43792
43835
|
normalizeVerdict,
|
|
@@ -43825,4 +43868,3 @@ postchain-client/built/esm/index.js:
|
|
|
43825
43868
|
*)
|
|
43826
43869
|
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
43827
43870
|
*/
|
|
43828
|
-
//# sourceMappingURL=index.js.map
|