@zanii/blackbox 0.7.0 → 0.8.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 +5 -0
- package/dist/cli.js +4 -2
- package/dist/session/drain.d.ts +4 -0
- package/dist/session/drain.js +11 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,11 @@ verifyAnswerCredential(credential, lines, bodies, packs); // { ok, problems }: t
|
|
|
83
83
|
|
|
84
84
|
The same checks run offline as pure functions: `toolHallucinations`, `groundingFindings`, `factsIn`, `loadReferencePacks`, `answerRisk`, `detectorAccuracy`.
|
|
85
85
|
|
|
86
|
+
## New in 0.8.0
|
|
87
|
+
|
|
88
|
+
- `blackbox drain --close` (and `drainSpools({close: true})` / `drain_spools(close=True)`): after shipping what a stopped agent left behind, each session is closed as `abandoned`.
|
|
89
|
+
- Works with gateway v0.10: alerts signed as Standard Webhooks, tenant keys that expire, more identity-provider algorithms (PS256, ES384, EdDSA).
|
|
90
|
+
|
|
86
91
|
## New in 0.7.0
|
|
87
92
|
|
|
88
93
|
- Any number of serverless functions or workers can write one session at the same moment: a joined session sends its events unnumbered, each with an id, and a v0.9+ gateway numbers them in arrival order (a resend adds nothing).
|
package/dist/cli.js
CHANGED
|
@@ -33,7 +33,8 @@ const USAGE = `usage (spec/cli.md):
|
|
|
33
33
|
blackbox erase <session_id>
|
|
34
34
|
blackbox approvals <session_id>
|
|
35
35
|
blackbox decide <session_id> <approval_id> approve|reject [--note <text>]
|
|
36
|
-
blackbox drain [--spool-dir <dir>] (ships what a stopped agent left in its spool
|
|
36
|
+
blackbox drain [--spool-dir <dir>] [--close] (ships what a stopped agent left in its spool;
|
|
37
|
+
--close then closes each session as abandoned)
|
|
37
38
|
blackbox analyze <bundle.json> [--bodies <dir>] [--prices <file>]
|
|
38
39
|
blackbox verify-certificate <certificate.json> [--did <did:key:…>]
|
|
39
40
|
blackbox investigate <bundle.json> [--bodies <dir>] [--directives <file>] [--identity <file>] [--proofs] [--out <prefix>]
|
|
@@ -1102,7 +1103,7 @@ async function tailCommand(rest) {
|
|
|
1102
1103
|
}
|
|
1103
1104
|
/** Audit K5: ships what stopped agents left in the spool (BLACKBOX_URL; no key: the kept tokens). */
|
|
1104
1105
|
async function drainCommand(rest) {
|
|
1105
|
-
const { flags, positional } = parse(rest, []);
|
|
1106
|
+
const { flags, positional } = parse(rest, ["--close"]);
|
|
1106
1107
|
const url = process.env.BLACKBOX_URL;
|
|
1107
1108
|
if (positional.length || !url)
|
|
1108
1109
|
return usage();
|
|
@@ -1110,6 +1111,7 @@ async function drainCommand(rest) {
|
|
|
1110
1111
|
const results = await drainSpools({
|
|
1111
1112
|
url,
|
|
1112
1113
|
...(flags["spool-dir"] ? { spoolDir: flags["spool-dir"] } : {}),
|
|
1114
|
+
...(flags.close ? { close: true } : {}),
|
|
1113
1115
|
});
|
|
1114
1116
|
process.stdout.write(`${JSON.stringify({ ok: results.every((r) => r.shipped), sessions: results })}\n`);
|
|
1115
1117
|
return results.every((r) => r.shipped) ? 0 : 2;
|
package/dist/session/drain.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export interface DrainResult {
|
|
|
3
3
|
shipped: boolean;
|
|
4
4
|
/** Events the gateway still doesn't have (0 when shipped). */
|
|
5
5
|
left: number;
|
|
6
|
+
/** With `close`: whether the session was closed. */
|
|
7
|
+
closed?: boolean;
|
|
6
8
|
}
|
|
7
9
|
/** Only for agents that have stopped: a running agent ships its own spool. Never throws. */
|
|
8
10
|
export declare function drainSpools(options: {
|
|
@@ -10,4 +12,6 @@ export declare function drainSpools(options: {
|
|
|
10
12
|
spoolDir?: string;
|
|
11
13
|
timeoutMs?: number;
|
|
12
14
|
logger?: (message: string) => void;
|
|
15
|
+
/** LA.5: close each session once shipped, as `abandoned`. */
|
|
16
|
+
close?: boolean;
|
|
13
17
|
}): Promise<DrainResult[]>;
|
package/dist/session/drain.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Audit K5: ships the events a stopped agent left in its spool. The SDK keeps the token of a session
|
|
2
2
|
// it opened itself next to the spool (`<id>.token`, mode 0600), since only it knew the token; this
|
|
3
|
-
// reads each one and ships what the gateway hasn't acknowledged.
|
|
4
|
-
//
|
|
3
|
+
// reads each one and ships what the gateway hasn't acknowledged. With `close` (LA.5) each shipped
|
|
4
|
+
// session is then closed as `abandoned`, with its own token; without it an operator closes it.
|
|
5
5
|
import { existsSync, readdirSync, readFileSync, rmSync } from "node:fs";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
import { join } from "node:path";
|
|
@@ -26,10 +26,18 @@ export async function drainSpools(options) {
|
|
|
26
26
|
}, id, token);
|
|
27
27
|
const shipped = await s.flush({ timeoutMs: options.timeoutMs ?? 30_000 });
|
|
28
28
|
const left = s.stats.recorded - s.stats.acked;
|
|
29
|
+
const closed = shipped && options.close
|
|
30
|
+
? await s.close("abandoned", "the agent stopped; its spool was drained")
|
|
31
|
+
: undefined;
|
|
29
32
|
s.stop();
|
|
30
33
|
if (shipped)
|
|
31
34
|
rmSync(join(dir, file), { force: true });
|
|
32
|
-
out.push({
|
|
35
|
+
out.push({
|
|
36
|
+
session_id: id,
|
|
37
|
+
shipped,
|
|
38
|
+
left: shipped ? 0 : Math.max(0, left),
|
|
39
|
+
...(closed === undefined ? {} : { closed }),
|
|
40
|
+
});
|
|
33
41
|
}
|
|
34
42
|
return out;
|
|
35
43
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.8.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// The SDK version, on its own so the CLI can print it without loading the whole SDK.
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.8.0";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zanii/blackbox",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"description": "The flight recorder for AI agents: sessions, a zero-loss spool, framework hooks, approvals, and offline verification of the gateway's hash-chained record.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ai-agents",
|