@atbash/sdk 0.9.0 → 0.9.2
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 +49 -14
- package/dist/browser.mjs +124 -192
- package/dist/index.d.mts +49 -14
- package/dist/index.d.ts +49 -14
- package/dist/index.js +338 -92
- package/dist/index.mjs +342 -93
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -721,7 +721,18 @@ declare class AtbashAPIError extends Error {
|
|
|
721
721
|
readonly status: number;
|
|
722
722
|
/** Raw response body text (may be empty). */
|
|
723
723
|
readonly body: string;
|
|
724
|
-
|
|
724
|
+
/**
|
|
725
|
+
* Request path this status came from, e.g. `/api/v1/judge` — absent when the
|
|
726
|
+
* request never reached a response (transport failures carry status 0).
|
|
727
|
+
*
|
|
728
|
+
* A status alone does not say what failed. Several routes answer one call, and
|
|
729
|
+
* more than one of them can 404: a caller reading only `404` cannot tell "this
|
|
730
|
+
* agent is not registered" from "the chain-routing lookup did not resolve", and
|
|
731
|
+
* has to guess from the body's prose — which a 404 raised before any handler
|
|
732
|
+
* ran does not carry. The path is the fact that settles it.
|
|
733
|
+
*/
|
|
734
|
+
readonly path?: string;
|
|
735
|
+
constructor(status: number, body: string, statusText?: string, endpoint?: string, path?: string);
|
|
725
736
|
}
|
|
726
737
|
declare class SignatureVerificationError extends Error {
|
|
727
738
|
constructor(message: string);
|
|
@@ -1068,6 +1079,13 @@ interface ClassifyMemoryWriteOptions {
|
|
|
1068
1079
|
*
|
|
1069
1080
|
* Empty-content writes return `null`: they can't carry a poisoning
|
|
1070
1081
|
* payload, and the regular audit path still sees them.
|
|
1082
|
+
*
|
|
1083
|
+
* THROWS on host input it cannot read without side effects: a proxy, an accessor where a data
|
|
1084
|
+
* property is expected, a value with no safe projection, or one past the size bounds. Refusing is
|
|
1085
|
+
* deliberate - a silent `null` would report "not a memory write" for a call nobody could classify,
|
|
1086
|
+
* and memory protection would be skipped exactly where the input was strange. Callers that sit in a
|
|
1087
|
+
* host hook MUST catch it and turn it into a decision; `guardMemoryWrite` and
|
|
1088
|
+
* `MemoryGuardManager.handleBeforeToolCall` already do.
|
|
1071
1089
|
*/
|
|
1072
1090
|
declare function classifyMemoryWrite(event: unknown, ctx: unknown, opts?: ClassifyMemoryWriteOptions): MemoryEntry | null;
|
|
1073
1091
|
|
|
@@ -1093,6 +1111,8 @@ interface GuardMemoryWriteInput extends ClassifyMemoryWriteOptions {
|
|
|
1093
1111
|
verifyPubKey?: string;
|
|
1094
1112
|
/** Org name for chain resolution (public vs org-private chain). */
|
|
1095
1113
|
orgName?: string;
|
|
1114
|
+
/** Explicit chain target when the host already resolved and verified it. */
|
|
1115
|
+
chainOpts?: ChainOpts;
|
|
1096
1116
|
/** LLM confidence threshold for yellow escalation. Default 0.6. */
|
|
1097
1117
|
threshold?: number;
|
|
1098
1118
|
/** When false, red verdicts log but don't block. Default true. */
|
|
@@ -1115,7 +1135,7 @@ interface GuardMemoryWriteResult {
|
|
|
1115
1135
|
decision?: GuardMemoryDecision;
|
|
1116
1136
|
/** Present when handled and scan ran. Absent when scan threw. */
|
|
1117
1137
|
scanResult?: MemoryScanResult;
|
|
1118
|
-
/** Present when handled. True
|
|
1138
|
+
/** Present when handled. True only after the chain transaction confirms. */
|
|
1119
1139
|
committed?: boolean;
|
|
1120
1140
|
}
|
|
1121
1141
|
/**
|
|
@@ -1125,12 +1145,13 @@ interface GuardMemoryWriteResult {
|
|
|
1125
1145
|
*
|
|
1126
1146
|
* Verdict handling:
|
|
1127
1147
|
* - `red` → not persisted to chain; decision blocks (unless `enforce: false`)
|
|
1128
|
-
* - `yellow` → persisted with LLM score; decision allows
|
|
1129
|
-
* - `green` → persisted with LLM score; decision allows
|
|
1148
|
+
* - `yellow` → persisted with its LLM score; decision allows once the chain confirms
|
|
1149
|
+
* - `green` → persisted with its LLM score; decision allows once the chain confirms
|
|
1150
|
+
* - anything else → not persisted; decision blocks (unless `enforce: false`)
|
|
1130
1151
|
*
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
1152
|
+
* A write is acknowledged only after the chain transaction confirms, for
|
|
1153
|
+
* yellow exactly as for green. An unconfirmed write blocks in enforce mode
|
|
1154
|
+
* and remains unaudited in observe mode.
|
|
1134
1155
|
*/
|
|
1135
1156
|
declare function guardMemoryWrite(input: GuardMemoryWriteInput): Promise<GuardMemoryWriteResult>;
|
|
1136
1157
|
|
|
@@ -1160,6 +1181,8 @@ interface SyncMemoryOptions {
|
|
|
1160
1181
|
/** Skip the TTL gate and force a chain check this call. Default false. */
|
|
1161
1182
|
force?: boolean;
|
|
1162
1183
|
chainOpts?: ChainOpts;
|
|
1184
|
+
/** Exact chain slot for the managed file; omission keeps the cross-file API behavior. */
|
|
1185
|
+
filePath?: string;
|
|
1163
1186
|
}
|
|
1164
1187
|
/**
|
|
1165
1188
|
* `drifted: false` — pointer is still valid; caller can keep serving the local copy.
|
|
@@ -1208,6 +1231,8 @@ declare function defaultPointerPath(workspaceDir?: string): string;
|
|
|
1208
1231
|
interface WrappedLogger {
|
|
1209
1232
|
info(message: string, meta?: Record<string, unknown>): void;
|
|
1210
1233
|
warn(message: string, meta?: Record<string, unknown>): void;
|
|
1234
|
+
/** Wait for queued writes and surface any lost log entry. */
|
|
1235
|
+
flush(): Promise<void>;
|
|
1211
1236
|
}
|
|
1212
1237
|
interface UpstreamLogger {
|
|
1213
1238
|
info: (...args: unknown[]) => void;
|
|
@@ -1236,6 +1261,13 @@ interface ClassifyMemoryReadOptions {
|
|
|
1236
1261
|
* Caller-supplied `patterns` are MERGED with the defaults (matches
|
|
1237
1262
|
* Node's original behavior — extending in one plugin doesn't disable
|
|
1238
1263
|
* standard coverage).
|
|
1264
|
+
*
|
|
1265
|
+
* THROWS on host input it cannot read without side effects: a proxy, an accessor where a data
|
|
1266
|
+
* property is expected, a value with no safe projection, or one past the size bounds. Refusing is
|
|
1267
|
+
* deliberate - a silent `null` would report "not a memory write" for a call nobody could classify,
|
|
1268
|
+
* and memory protection would be skipped exactly where the input was strange. Callers that sit in a
|
|
1269
|
+
* host hook MUST catch it and turn it into a decision; `guardMemoryWrite` and
|
|
1270
|
+
* `MemoryGuardManager.handleBeforeToolCall` already do.
|
|
1239
1271
|
*/
|
|
1240
1272
|
declare function classifyMemoryRead(event: unknown, ctx: unknown, opts?: ClassifyMemoryReadOptions): boolean;
|
|
1241
1273
|
|
|
@@ -1260,10 +1292,10 @@ interface HookDecision {
|
|
|
1260
1292
|
* failure, a rolled-back version), and a host must never re-judge its way past
|
|
1261
1293
|
* one.
|
|
1262
1294
|
*
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1295
|
+
* Absent or false means the guard reached no decision — for example, the scan
|
|
1296
|
+
* never ran or this manager does not own the requested file. In enforce mode,
|
|
1297
|
+
* failed chain verification of the managed file is a block, never an unaudited
|
|
1298
|
+
* allow. In observe mode unverified calls remain unaudited.
|
|
1267
1299
|
*
|
|
1268
1300
|
* So the host rule is:
|
|
1269
1301
|
* `if (d.block) deny; else if (d.audited) allow; else judge it yourself;`
|
|
@@ -1363,9 +1395,9 @@ declare class MemoryGuardManager {
|
|
|
1363
1395
|
runBootProbe(): Promise<void>;
|
|
1364
1396
|
/**
|
|
1365
1397
|
* Returns a `HookDecision` when the guard reached a decision about this event.
|
|
1366
|
-
* Returns `null`
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1398
|
+
* Returns `null` for non-memory events, other files this manager does not
|
|
1399
|
+
* own, or unverified observe-mode reads. An enforced read of the managed
|
|
1400
|
+
* file blocks when verification cannot complete.
|
|
1369
1401
|
*
|
|
1370
1402
|
* A returned decision carries `audited` (see `HookDecision`). Only
|
|
1371
1403
|
* `{ allow: true, audited: true }` means "checked and cleared"; anything else
|
|
@@ -1390,6 +1422,9 @@ declare class MemoryGuardManager {
|
|
|
1390
1422
|
*/
|
|
1391
1423
|
private vouchesForTarget;
|
|
1392
1424
|
private handleMemoryRead;
|
|
1425
|
+
/** Complete queued audit-log writes before a host shuts down or removes its workspace. */
|
|
1426
|
+
flushLogs(): Promise<void>;
|
|
1427
|
+
private unverifiedRead;
|
|
1393
1428
|
private writeMemoryAtomic;
|
|
1394
1429
|
}
|
|
1395
1430
|
declare function createMemoryGuardManager(opts: MemoryGuardManagerOptions): MemoryGuardManager;
|
package/dist/index.d.ts
CHANGED
|
@@ -721,7 +721,18 @@ declare class AtbashAPIError extends Error {
|
|
|
721
721
|
readonly status: number;
|
|
722
722
|
/** Raw response body text (may be empty). */
|
|
723
723
|
readonly body: string;
|
|
724
|
-
|
|
724
|
+
/**
|
|
725
|
+
* Request path this status came from, e.g. `/api/v1/judge` — absent when the
|
|
726
|
+
* request never reached a response (transport failures carry status 0).
|
|
727
|
+
*
|
|
728
|
+
* A status alone does not say what failed. Several routes answer one call, and
|
|
729
|
+
* more than one of them can 404: a caller reading only `404` cannot tell "this
|
|
730
|
+
* agent is not registered" from "the chain-routing lookup did not resolve", and
|
|
731
|
+
* has to guess from the body's prose — which a 404 raised before any handler
|
|
732
|
+
* ran does not carry. The path is the fact that settles it.
|
|
733
|
+
*/
|
|
734
|
+
readonly path?: string;
|
|
735
|
+
constructor(status: number, body: string, statusText?: string, endpoint?: string, path?: string);
|
|
725
736
|
}
|
|
726
737
|
declare class SignatureVerificationError extends Error {
|
|
727
738
|
constructor(message: string);
|
|
@@ -1068,6 +1079,13 @@ interface ClassifyMemoryWriteOptions {
|
|
|
1068
1079
|
*
|
|
1069
1080
|
* Empty-content writes return `null`: they can't carry a poisoning
|
|
1070
1081
|
* payload, and the regular audit path still sees them.
|
|
1082
|
+
*
|
|
1083
|
+
* THROWS on host input it cannot read without side effects: a proxy, an accessor where a data
|
|
1084
|
+
* property is expected, a value with no safe projection, or one past the size bounds. Refusing is
|
|
1085
|
+
* deliberate - a silent `null` would report "not a memory write" for a call nobody could classify,
|
|
1086
|
+
* and memory protection would be skipped exactly where the input was strange. Callers that sit in a
|
|
1087
|
+
* host hook MUST catch it and turn it into a decision; `guardMemoryWrite` and
|
|
1088
|
+
* `MemoryGuardManager.handleBeforeToolCall` already do.
|
|
1071
1089
|
*/
|
|
1072
1090
|
declare function classifyMemoryWrite(event: unknown, ctx: unknown, opts?: ClassifyMemoryWriteOptions): MemoryEntry | null;
|
|
1073
1091
|
|
|
@@ -1093,6 +1111,8 @@ interface GuardMemoryWriteInput extends ClassifyMemoryWriteOptions {
|
|
|
1093
1111
|
verifyPubKey?: string;
|
|
1094
1112
|
/** Org name for chain resolution (public vs org-private chain). */
|
|
1095
1113
|
orgName?: string;
|
|
1114
|
+
/** Explicit chain target when the host already resolved and verified it. */
|
|
1115
|
+
chainOpts?: ChainOpts;
|
|
1096
1116
|
/** LLM confidence threshold for yellow escalation. Default 0.6. */
|
|
1097
1117
|
threshold?: number;
|
|
1098
1118
|
/** When false, red verdicts log but don't block. Default true. */
|
|
@@ -1115,7 +1135,7 @@ interface GuardMemoryWriteResult {
|
|
|
1115
1135
|
decision?: GuardMemoryDecision;
|
|
1116
1136
|
/** Present when handled and scan ran. Absent when scan threw. */
|
|
1117
1137
|
scanResult?: MemoryScanResult;
|
|
1118
|
-
/** Present when handled. True
|
|
1138
|
+
/** Present when handled. True only after the chain transaction confirms. */
|
|
1119
1139
|
committed?: boolean;
|
|
1120
1140
|
}
|
|
1121
1141
|
/**
|
|
@@ -1125,12 +1145,13 @@ interface GuardMemoryWriteResult {
|
|
|
1125
1145
|
*
|
|
1126
1146
|
* Verdict handling:
|
|
1127
1147
|
* - `red` → not persisted to chain; decision blocks (unless `enforce: false`)
|
|
1128
|
-
* - `yellow` → persisted with LLM score; decision allows
|
|
1129
|
-
* - `green` → persisted with LLM score; decision allows
|
|
1148
|
+
* - `yellow` → persisted with its LLM score; decision allows once the chain confirms
|
|
1149
|
+
* - `green` → persisted with its LLM score; decision allows once the chain confirms
|
|
1150
|
+
* - anything else → not persisted; decision blocks (unless `enforce: false`)
|
|
1130
1151
|
*
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1133
|
-
*
|
|
1152
|
+
* A write is acknowledged only after the chain transaction confirms, for
|
|
1153
|
+
* yellow exactly as for green. An unconfirmed write blocks in enforce mode
|
|
1154
|
+
* and remains unaudited in observe mode.
|
|
1134
1155
|
*/
|
|
1135
1156
|
declare function guardMemoryWrite(input: GuardMemoryWriteInput): Promise<GuardMemoryWriteResult>;
|
|
1136
1157
|
|
|
@@ -1160,6 +1181,8 @@ interface SyncMemoryOptions {
|
|
|
1160
1181
|
/** Skip the TTL gate and force a chain check this call. Default false. */
|
|
1161
1182
|
force?: boolean;
|
|
1162
1183
|
chainOpts?: ChainOpts;
|
|
1184
|
+
/** Exact chain slot for the managed file; omission keeps the cross-file API behavior. */
|
|
1185
|
+
filePath?: string;
|
|
1163
1186
|
}
|
|
1164
1187
|
/**
|
|
1165
1188
|
* `drifted: false` — pointer is still valid; caller can keep serving the local copy.
|
|
@@ -1208,6 +1231,8 @@ declare function defaultPointerPath(workspaceDir?: string): string;
|
|
|
1208
1231
|
interface WrappedLogger {
|
|
1209
1232
|
info(message: string, meta?: Record<string, unknown>): void;
|
|
1210
1233
|
warn(message: string, meta?: Record<string, unknown>): void;
|
|
1234
|
+
/** Wait for queued writes and surface any lost log entry. */
|
|
1235
|
+
flush(): Promise<void>;
|
|
1211
1236
|
}
|
|
1212
1237
|
interface UpstreamLogger {
|
|
1213
1238
|
info: (...args: unknown[]) => void;
|
|
@@ -1236,6 +1261,13 @@ interface ClassifyMemoryReadOptions {
|
|
|
1236
1261
|
* Caller-supplied `patterns` are MERGED with the defaults (matches
|
|
1237
1262
|
* Node's original behavior — extending in one plugin doesn't disable
|
|
1238
1263
|
* standard coverage).
|
|
1264
|
+
*
|
|
1265
|
+
* THROWS on host input it cannot read without side effects: a proxy, an accessor where a data
|
|
1266
|
+
* property is expected, a value with no safe projection, or one past the size bounds. Refusing is
|
|
1267
|
+
* deliberate - a silent `null` would report "not a memory write" for a call nobody could classify,
|
|
1268
|
+
* and memory protection would be skipped exactly where the input was strange. Callers that sit in a
|
|
1269
|
+
* host hook MUST catch it and turn it into a decision; `guardMemoryWrite` and
|
|
1270
|
+
* `MemoryGuardManager.handleBeforeToolCall` already do.
|
|
1239
1271
|
*/
|
|
1240
1272
|
declare function classifyMemoryRead(event: unknown, ctx: unknown, opts?: ClassifyMemoryReadOptions): boolean;
|
|
1241
1273
|
|
|
@@ -1260,10 +1292,10 @@ interface HookDecision {
|
|
|
1260
1292
|
* failure, a rolled-back version), and a host must never re-judge its way past
|
|
1261
1293
|
* one.
|
|
1262
1294
|
*
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1295
|
+
* Absent or false means the guard reached no decision — for example, the scan
|
|
1296
|
+
* never ran or this manager does not own the requested file. In enforce mode,
|
|
1297
|
+
* failed chain verification of the managed file is a block, never an unaudited
|
|
1298
|
+
* allow. In observe mode unverified calls remain unaudited.
|
|
1267
1299
|
*
|
|
1268
1300
|
* So the host rule is:
|
|
1269
1301
|
* `if (d.block) deny; else if (d.audited) allow; else judge it yourself;`
|
|
@@ -1363,9 +1395,9 @@ declare class MemoryGuardManager {
|
|
|
1363
1395
|
runBootProbe(): Promise<void>;
|
|
1364
1396
|
/**
|
|
1365
1397
|
* Returns a `HookDecision` when the guard reached a decision about this event.
|
|
1366
|
-
* Returns `null`
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1398
|
+
* Returns `null` for non-memory events, other files this manager does not
|
|
1399
|
+
* own, or unverified observe-mode reads. An enforced read of the managed
|
|
1400
|
+
* file blocks when verification cannot complete.
|
|
1369
1401
|
*
|
|
1370
1402
|
* A returned decision carries `audited` (see `HookDecision`). Only
|
|
1371
1403
|
* `{ allow: true, audited: true }` means "checked and cleared"; anything else
|
|
@@ -1390,6 +1422,9 @@ declare class MemoryGuardManager {
|
|
|
1390
1422
|
*/
|
|
1391
1423
|
private vouchesForTarget;
|
|
1392
1424
|
private handleMemoryRead;
|
|
1425
|
+
/** Complete queued audit-log writes before a host shuts down or removes its workspace. */
|
|
1426
|
+
flushLogs(): Promise<void>;
|
|
1427
|
+
private unverifiedRead;
|
|
1393
1428
|
private writeMemoryAtomic;
|
|
1394
1429
|
}
|
|
1395
1430
|
declare function createMemoryGuardManager(opts: MemoryGuardManagerOptions): MemoryGuardManager;
|