@zanii/blackbox 0.22.0 → 0.23.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 +1 -0
- package/dist/analysis/accepted.d.ts +26 -0
- package/dist/analysis/accepted.js +61 -0
- package/dist/analysis/detectors.js +12 -9
- package/dist/analysis/faults.js +71 -0
- package/dist/analysis/grounding.js +5 -9
- package/dist/analysis/guard.d.ts +72 -0
- package/dist/analysis/guard.js +240 -0
- package/dist/analysis/hallucination.js +2 -2
- package/dist/analysis/index.d.ts +21 -1
- package/dist/analysis/index.js +101 -19
- package/dist/analysis/injection.d.ts +2 -1
- package/dist/analysis/injection.js +16 -16
- package/dist/analysis/landing.js +60 -14
- package/dist/analysis/plan-checks.d.ts +55 -0
- package/dist/analysis/plan-checks.js +748 -0
- package/dist/analysis/taxonomy.js +1 -0
- package/dist/analysis/waste.js +2 -3
- package/dist/approvals/index.d.ts +12 -3
- package/dist/approvals/index.js +36 -10
- package/dist/authority/index.js +3 -3
- package/dist/aviation/index.d.ts +422 -0
- package/dist/aviation/index.js +1014 -0
- package/dist/aviation/qrh.d.ts +4 -0
- package/dist/aviation/qrh.js +171 -0
- package/dist/budgets/index.d.ts +63 -0
- package/dist/budgets/index.js +161 -0
- package/dist/cli.js +172 -24
- package/dist/compliance/index.d.ts +2 -0
- package/dist/compliance/index.js +26 -2
- package/dist/cost/batch.d.ts +26 -0
- package/dist/cost/batch.js +173 -0
- package/dist/cost/index.d.ts +21 -0
- package/dist/cost/index.js +115 -30
- package/dist/cv/index.js +1 -1
- package/dist/duty/index.js +2 -1
- package/dist/evals/index.d.ts +233 -0
- package/dist/evals/index.js +488 -0
- package/dist/federation/index.d.ts +9 -0
- package/dist/federation/index.js +8 -1
- package/dist/finance/index.js +3 -4
- package/dist/fleet/index.d.ts +25 -0
- package/dist/fleet/index.js +57 -17
- package/dist/fleet/insights.js +4 -1
- package/dist/health/index.js +2 -2
- package/dist/hooks/ai-sdk.d.ts +17 -19
- package/dist/hooks/ai-sdk.js +13 -7
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/mastra.d.ts +26 -0
- package/dist/hooks/mastra.js +63 -0
- package/dist/index.d.ts +22 -9
- package/dist/index.js +23 -9
- package/dist/mcp-requests/index.d.ts +26 -0
- package/dist/mcp-requests/index.js +154 -0
- package/dist/mcp-server/index.d.ts +12 -0
- package/dist/mcp-server/index.js +84 -2
- package/dist/mcp-wrap/index.js +8 -4
- package/dist/otlp/index.d.ts +155 -0
- package/dist/otlp/index.js +468 -0
- package/dist/otlp/protobuf.d.ts +7 -0
- package/dist/otlp/protobuf.js +314 -0
- package/dist/packs/index.d.ts +2 -0
- package/dist/packs/index.js +5 -1
- package/dist/pdf/arabic.d.ts +45 -0
- package/dist/pdf/arabic.js +373 -0
- package/dist/pdf/index.d.ts +77 -0
- package/dist/pdf/index.js +673 -0
- package/dist/policy/index.d.ts +0 -4
- package/dist/policy/index.js +13 -5
- package/dist/realtime/index.d.ts +33 -0
- package/dist/realtime/index.js +204 -0
- package/dist/reconcile/record.d.ts +12 -0
- package/dist/reconcile/record.js +114 -65
- package/dist/session/index.d.ts +43 -0
- package/dist/session/index.js +83 -0
- package/dist/undo/index.js +3 -3
- package/dist/verify/anchor.d.ts +5 -1
- package/dist/verify/anchor.js +13 -4
- package/dist/verify/envelope.d.ts +1 -1
- package/dist/verify/envelope.js +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/walls/index.js +2 -2
- package/dist/warehouse/index.d.ts +62 -0
- package/dist/warehouse/index.js +142 -0
- package/package.json +6 -3
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import type { Summary } from "../fleet/index.ts";
|
|
2
|
+
type Obj = {
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
};
|
|
5
|
+
export declare const SCORERS: readonly ["exact", "contains", "regex", "json_schema", "numeric", "tool_called", "tool_not_called", "findings_absent", "judge"];
|
|
6
|
+
export type ScorerKind = (typeof SCORERS)[number];
|
|
7
|
+
export interface Scorer {
|
|
8
|
+
kind: ScorerKind;
|
|
9
|
+
pattern?: string;
|
|
10
|
+
schema?: Obj;
|
|
11
|
+
tolerance_milli?: number;
|
|
12
|
+
tool?: string;
|
|
13
|
+
codes?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface EvalCase {
|
|
16
|
+
id: string;
|
|
17
|
+
input: unknown;
|
|
18
|
+
expected?: string | number;
|
|
19
|
+
rubric?: string;
|
|
20
|
+
tags: string[];
|
|
21
|
+
scorer: Scorer;
|
|
22
|
+
}
|
|
23
|
+
export declare const CASE_ID: RegExp;
|
|
24
|
+
/** §2: a scorer, checked: the normalised scorer, or what's wrong with it. */
|
|
25
|
+
export declare function checkScorer(v: unknown, at?: string): Scorer | string;
|
|
26
|
+
/**
|
|
27
|
+
* §1: a dataset, checked: `{name, cases}` with every case normalised (an id, tags, its scorer or
|
|
28
|
+
* the dataset's), or the first problem. Numbers must be integers: decimals are written as strings.
|
|
29
|
+
*/
|
|
30
|
+
export declare function checkDataset(v: unknown): {
|
|
31
|
+
name: string;
|
|
32
|
+
cases: EvalCase[];
|
|
33
|
+
} | string;
|
|
34
|
+
/** §1: what names a dataset's content exactly: `sha256:` over the canonical JSON of {name, cases}. */
|
|
35
|
+
export declare function datasetHash(d: {
|
|
36
|
+
name: string;
|
|
37
|
+
cases: readonly EvalCase[];
|
|
38
|
+
}): string;
|
|
39
|
+
/** §1: a JSON Lines file of cases: one object per non-empty line, or the first line that isn't. */
|
|
40
|
+
export declare function parseCasesJsonl(text: string): unknown[] | string;
|
|
41
|
+
/** §1: one case per saved scenario (spec/replay.md §3): a fork of the incident, passing when none
|
|
42
|
+
* of its findings comes back. */
|
|
43
|
+
export declare function casesFromScenarios(scenarios: readonly unknown[]): Obj[] | string;
|
|
44
|
+
/** §1: one case per recorded session: a fork of it, expected to answer what it answered then. */
|
|
45
|
+
export declare function casesFromSessions(items: ReadonlyArray<{
|
|
46
|
+
session_id: string;
|
|
47
|
+
answer: string;
|
|
48
|
+
}>): Obj[];
|
|
49
|
+
/** What one run of the agent left, read from its record: the final answer, the tools it called,
|
|
50
|
+
* its findings, and the judge's verdict (undefined: not asked; null: an outage). */
|
|
51
|
+
export interface Observation {
|
|
52
|
+
answer: string | null;
|
|
53
|
+
tools: {
|
|
54
|
+
[tool: string]: number;
|
|
55
|
+
};
|
|
56
|
+
finding_codes: {
|
|
57
|
+
[code: string]: number;
|
|
58
|
+
};
|
|
59
|
+
judge?: {
|
|
60
|
+
steps: Array<{
|
|
61
|
+
rubric: string;
|
|
62
|
+
pass: boolean;
|
|
63
|
+
reason?: string;
|
|
64
|
+
}>;
|
|
65
|
+
} | null;
|
|
66
|
+
}
|
|
67
|
+
export interface CaseScore {
|
|
68
|
+
pass: boolean;
|
|
69
|
+
reason: string;
|
|
70
|
+
outage?: true;
|
|
71
|
+
}
|
|
72
|
+
/** A decimal as integer milli-units, the digits past the third decimal dropped. */
|
|
73
|
+
export declare function toMilli(s: string): bigint;
|
|
74
|
+
/** §2: one case scored against what its run left. An outage of the judge is never a pass. */
|
|
75
|
+
export declare function scoreCase(c: EvalCase, o: Observation): CaseScore;
|
|
76
|
+
export interface RunSummary {
|
|
77
|
+
total: number;
|
|
78
|
+
passed: number;
|
|
79
|
+
failed: number;
|
|
80
|
+
outages: number;
|
|
81
|
+
pass_ppm: number;
|
|
82
|
+
pass_low_ppm: number;
|
|
83
|
+
pass_high_ppm: number;
|
|
84
|
+
cost_micro_usd: number;
|
|
85
|
+
cost_per_case_micro_usd: number;
|
|
86
|
+
tags: {
|
|
87
|
+
[tag: string]: {
|
|
88
|
+
total: number;
|
|
89
|
+
passed: number;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** §3: a run's totals: passes with the 95% range, outages, cost, and per tag. */
|
|
94
|
+
export declare function runSummary(results: ReadonlyArray<{
|
|
95
|
+
pass: boolean;
|
|
96
|
+
outage?: boolean;
|
|
97
|
+
cost_micro_usd: number;
|
|
98
|
+
tags?: readonly string[];
|
|
99
|
+
}>): RunSummary;
|
|
100
|
+
type Verdict = "better" | "worse" | "unclear";
|
|
101
|
+
interface RunDoc {
|
|
102
|
+
id: string;
|
|
103
|
+
dataset: {
|
|
104
|
+
id: string;
|
|
105
|
+
hash: string;
|
|
106
|
+
};
|
|
107
|
+
results: ReadonlyArray<{
|
|
108
|
+
case: string;
|
|
109
|
+
pass: boolean;
|
|
110
|
+
}>;
|
|
111
|
+
summary: RunSummary;
|
|
112
|
+
}
|
|
113
|
+
/** §3: run `b` against run `a`: better, worse or unclear, and the cases each fixed or broke. */
|
|
114
|
+
export declare function compareRuns(a: RunDoc, b: RunDoc): {
|
|
115
|
+
a: string;
|
|
116
|
+
b: string;
|
|
117
|
+
same_dataset: boolean;
|
|
118
|
+
verdict: Verdict;
|
|
119
|
+
pass_ppm: {
|
|
120
|
+
a: number;
|
|
121
|
+
b: number;
|
|
122
|
+
};
|
|
123
|
+
pass_range_ppm: {
|
|
124
|
+
a: number[];
|
|
125
|
+
b: number[];
|
|
126
|
+
};
|
|
127
|
+
fixed: string[];
|
|
128
|
+
broken: string[];
|
|
129
|
+
cost_per_case_delta_micro_usd: number;
|
|
130
|
+
};
|
|
131
|
+
export declare const PROMPT_NAME: RegExp;
|
|
132
|
+
/** §4: a prompt text's version hash: the gateway's `system_sha256` of a request whose system
|
|
133
|
+
* prompt is this text (an Anthropic `system` string, or a Chat Completions system message). */
|
|
134
|
+
export declare function promptSha256(text: string): string;
|
|
135
|
+
/** §5: the arm a session falls in: the first 8 hex of sha256(`<experiment>:<session>`) mod 1000,
|
|
136
|
+
* walked through the arms' per-mille shares in order. The same session always gets the same arm. */
|
|
137
|
+
export declare function assignArm(experimentId: string, sessionId: string, arms: ReadonlyArray<{
|
|
138
|
+
name: string;
|
|
139
|
+
share_permille: number;
|
|
140
|
+
}>): string;
|
|
141
|
+
export interface Arm {
|
|
142
|
+
name: string;
|
|
143
|
+
version: number;
|
|
144
|
+
share_permille: number;
|
|
145
|
+
}
|
|
146
|
+
/** §5: an experiment, checked against its prompt's versions: `{name, prompt, arms}`, or why not. */
|
|
147
|
+
export declare function checkExperiment(v: unknown, versions: readonly number[]): {
|
|
148
|
+
name: string;
|
|
149
|
+
prompt: string;
|
|
150
|
+
arms: Arm[];
|
|
151
|
+
} | string;
|
|
152
|
+
/** §4: how a group of runs did: success with the 95% range, spend per run, findings. */
|
|
153
|
+
export declare function armStats(runs: readonly Summary[]): {
|
|
154
|
+
sessions: number;
|
|
155
|
+
success: number;
|
|
156
|
+
success_ppm: number;
|
|
157
|
+
success_low_ppm: number;
|
|
158
|
+
success_high_ppm: number;
|
|
159
|
+
spend_per_run_micro_usd: number;
|
|
160
|
+
findings: {
|
|
161
|
+
advisory: number;
|
|
162
|
+
caution: number;
|
|
163
|
+
warning: number;
|
|
164
|
+
};
|
|
165
|
+
finding_codes: {
|
|
166
|
+
[k: string]: number;
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* §4: each version of a prompt, from closed sessions' summaries: the runs that declared it (an
|
|
171
|
+
* experiment's arm or the SDK's `promptVersion`), and the runs that declared none whose first
|
|
172
|
+
* request's system prompt hash is the version's. Oldest version first, each against the one before.
|
|
173
|
+
*/
|
|
174
|
+
export declare function promptResults(summaries: readonly Summary[], prompt: {
|
|
175
|
+
name: string;
|
|
176
|
+
versions: ReadonlyArray<{
|
|
177
|
+
version: number;
|
|
178
|
+
sha256: string;
|
|
179
|
+
}>;
|
|
180
|
+
}): {
|
|
181
|
+
name: string;
|
|
182
|
+
sessions: number;
|
|
183
|
+
versions: {
|
|
184
|
+
sessions: number;
|
|
185
|
+
success: number;
|
|
186
|
+
success_ppm: number;
|
|
187
|
+
success_low_ppm: number;
|
|
188
|
+
success_high_ppm: number;
|
|
189
|
+
spend_per_run_micro_usd: number;
|
|
190
|
+
findings: {
|
|
191
|
+
advisory: number;
|
|
192
|
+
caution: number;
|
|
193
|
+
warning: number;
|
|
194
|
+
};
|
|
195
|
+
finding_codes: {
|
|
196
|
+
[k: string]: number;
|
|
197
|
+
};
|
|
198
|
+
version: number;
|
|
199
|
+
sha256: string;
|
|
200
|
+
declared: number;
|
|
201
|
+
detected: number;
|
|
202
|
+
vs_previous: Verdict | null;
|
|
203
|
+
}[];
|
|
204
|
+
};
|
|
205
|
+
/** §5: each arm of an experiment, from the closed sessions it assigned, against the first arm. */
|
|
206
|
+
export declare function experimentResults(summaries: readonly Summary[], experiment: {
|
|
207
|
+
id: string;
|
|
208
|
+
arms: readonly Arm[];
|
|
209
|
+
}): {
|
|
210
|
+
id: string;
|
|
211
|
+
sessions: number;
|
|
212
|
+
arms: {
|
|
213
|
+
sessions: number;
|
|
214
|
+
success: number;
|
|
215
|
+
success_ppm: number;
|
|
216
|
+
success_low_ppm: number;
|
|
217
|
+
success_high_ppm: number;
|
|
218
|
+
spend_per_run_micro_usd: number;
|
|
219
|
+
findings: {
|
|
220
|
+
advisory: number;
|
|
221
|
+
caution: number;
|
|
222
|
+
warning: number;
|
|
223
|
+
};
|
|
224
|
+
finding_codes: {
|
|
225
|
+
[k: string]: number;
|
|
226
|
+
};
|
|
227
|
+
name: string;
|
|
228
|
+
version: number;
|
|
229
|
+
share_permille: number;
|
|
230
|
+
vs_control: Verdict | null;
|
|
231
|
+
}[];
|
|
232
|
+
};
|
|
233
|
+
export {};
|