@atbash/sdk 0.14.1-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/dist/browser.d.mts +24 -1
- package/dist/browser.mjs +62 -17
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +61 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
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,
|