@zanii/blackbox 0.4.0 → 0.5.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/index.d.ts +1 -1
- package/dist/session/index.d.ts +17 -0
- package/dist/session/index.js +20 -0
- 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.5.0
|
|
87
|
+
|
|
88
|
+
- Held streams: open a session with `holdStreams: true` (or set `BLACKBOX_HOLD_STREAMS=all` on the gateway) and a risky streamed answer waits for a person, as a non-streamed one does. The client gets keep-alives, then the whole stream, or one error in the provider's own format.
|
|
89
|
+
- `session.checkAnswer(seq?)`: what in an answer would hold it (`{seq, risks, hold}`), for an app that streams by itself.
|
|
90
|
+
|
|
86
91
|
## New in 0.4.0
|
|
87
92
|
|
|
88
93
|
- Hallucination controls: the checks above, reference packs, answer credentials (`answerClaims`, `answerCredential`, `verifyAnswerCredential`), `session.retrieved()`, accuracy from people's labels (`detectorAccuracy`, Wilson bounds), the grounding and judge contracts, `answerRisk` for held answers.
|
package/dist/index.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export { cassette, requestKey, type Take } from "./replay/index.ts";
|
|
|
61
61
|
export { ORPHAN_TEXT, repairToolCalls } from "./replay/repair.ts";
|
|
62
62
|
export { checkSearch, type SearchMatch, type SearchQuery, searchEvents } from "./search/index.ts";
|
|
63
63
|
export { type DrainResult, drainSpools } from "./session/drain.ts";
|
|
64
|
-
export { BlackboxSession, checkEgress, type EgressCheck, type FlightPlan, type LlmCallIds, type SessionError, type SessionOptions, type SessionState, type SessionStats, session, stableEventId, } from "./session/index.ts";
|
|
64
|
+
export { type AnswerCheck, BlackboxSession, checkEgress, type EgressCheck, type FlightPlan, type LlmCallIds, type SessionError, type SessionOptions, type SessionState, type SessionStats, session, stableEventId, } from "./session/index.ts";
|
|
65
65
|
export { assembleSla, assessCompliance, buildSlaBody, signSla, slaHash, verifySla, } from "./sla/index.ts";
|
|
66
66
|
export { assembleSuccession, buildSuccessionBody, type Succession, type SuccessionBody, type SuccessionReason, signSuccession, successionHash, verifyLineage, verifySuccession, } from "./succession/index.ts";
|
|
67
67
|
export { type TimestampReport, timestampRequest, verifyTimestamp, } from "./timestamp/index.ts";
|
package/dist/session/index.d.ts
CHANGED
|
@@ -36,6 +36,9 @@ export interface SessionOptions {
|
|
|
36
36
|
authority?: "agent" | "supervised";
|
|
37
37
|
/** spec/api.md: where it runs (`production`, `staging`, …); policy rules can match it. */
|
|
38
38
|
environment?: string;
|
|
39
|
+
/** spec/findings.md §13.1: hold this session's streamed answers until they're checked (`true`),
|
|
40
|
+
* or never (`false`); unset follows the server's BLACKBOX_HOLD_STREAMS. */
|
|
41
|
+
holdStreams?: boolean;
|
|
39
42
|
/** spec/preflight.md: the equipment the run needs. A no-go returns a disabled session (and
|
|
40
43
|
* `stats.lastError` says why); optional items that are down show in `state().degraded`. */
|
|
41
44
|
preflight?: {
|
|
@@ -98,6 +101,16 @@ export interface LandingResult {
|
|
|
98
101
|
/** How many more tries `maxAttempts` allows; at 0, stop and report. */
|
|
99
102
|
attemptsLeft: number;
|
|
100
103
|
}
|
|
104
|
+
/** spec/findings.md §13.1: what would hold an answer, from `checkAnswer()`. */
|
|
105
|
+
export interface AnswerCheck {
|
|
106
|
+
seq: number;
|
|
107
|
+
risks: Array<{
|
|
108
|
+
index: number;
|
|
109
|
+
kind: string;
|
|
110
|
+
status: "contradicted" | "ungrounded";
|
|
111
|
+
}>;
|
|
112
|
+
hold: boolean;
|
|
113
|
+
}
|
|
101
114
|
export interface SessionState {
|
|
102
115
|
session_id: string;
|
|
103
116
|
closed: boolean;
|
|
@@ -333,6 +346,10 @@ export declare class BlackboxSession {
|
|
|
333
346
|
/** Audit S17: the gateway's view of this session (blocked? findings?), or null if it can't be
|
|
334
347
|
* read. Lets an agent react to its own block before its next model call. Never throws. */
|
|
335
348
|
state(): Promise<SessionState | null>;
|
|
349
|
+
/** spec/findings.md §13.1: what in an answer (the latest, or the one at `seq`) would hold it,
|
|
350
|
+
* for an app that streams the answer by itself: `{seq, risks, hold}`. `hold` says whether the
|
|
351
|
+
* server would hold it. `null` when there's no answer yet or the gateway can't be asked. */
|
|
352
|
+
checkAnswer(seq?: number): Promise<AnswerCheck | null>;
|
|
336
353
|
/** spec/approvals.md §2: asks a second person before running one of the agent's own risky tools,
|
|
337
354
|
* and waits (polling) for the answer. Never throws. Only `"approved"` means go ahead; anything
|
|
338
355
|
* else (`rejected`, `timeout`, or `error` when the gateway can't be asked) means don't. */
|
package/dist/session/index.js
CHANGED
|
@@ -84,6 +84,7 @@ export async function session(options) {
|
|
|
84
84
|
...(o.tenant ? { tenant: o.tenant } : {}),
|
|
85
85
|
...(o.authority ? { authority: o.authority } : {}),
|
|
86
86
|
...(o.environment ? { environment: o.environment } : {}),
|
|
87
|
+
...(o.holdStreams !== undefined ? { hold_streams: o.holdStreams } : {}),
|
|
87
88
|
...(o.preflight ? { preflight: await withEgress(o.preflight) } : {}),
|
|
88
89
|
...(o.drill ? { drill: o.drill } : {}),
|
|
89
90
|
sdk: true, // this SDK will report the session's model calls (L2.3.2)
|
|
@@ -521,6 +522,25 @@ export class BlackboxSession {
|
|
|
521
522
|
}
|
|
522
523
|
return null;
|
|
523
524
|
}
|
|
525
|
+
/** spec/findings.md §13.1: what in an answer (the latest, or the one at `seq`) would hold it,
|
|
526
|
+
* for an app that streams the answer by itself: `{seq, risks, hold}`. `hold` says whether the
|
|
527
|
+
* server would hold it. `null` when there's no answer yet or the gateway can't be asked. */
|
|
528
|
+
async checkAnswer(seq) {
|
|
529
|
+
if (!this.enabled)
|
|
530
|
+
return null;
|
|
531
|
+
const at = seq === undefined ? "latest" : String(seq);
|
|
532
|
+
try {
|
|
533
|
+
const r = await send("GET", this.options.url, `/v1/sessions/${this.id}/answers/${at}/risk`, this.token);
|
|
534
|
+
if (r.status === 200)
|
|
535
|
+
return r.json;
|
|
536
|
+
if (r.status !== 404)
|
|
537
|
+
this.fail("rejected", `checking the answer: the gateway answered ${r.status}`);
|
|
538
|
+
}
|
|
539
|
+
catch (error) {
|
|
540
|
+
this.fail("network", `checking the answer: ${message(error)}`);
|
|
541
|
+
}
|
|
542
|
+
return null;
|
|
543
|
+
}
|
|
524
544
|
/** spec/approvals.md §2: asks a second person before running one of the agent's own risky tools,
|
|
525
545
|
* and waits (polling) for the answer. Never throws. Only `"approved"` means go ahead; anything
|
|
526
546
|
* else (`rejected`, `timeout`, or `error` when the gateway can't be asked) means don't. */
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.5.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.5.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.5.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",
|