@zanii/blackbox 0.3.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 +31 -1
- package/dist/a2a/index.d.ts +27 -0
- package/dist/a2a/index.js +104 -1
- package/dist/agents/index.d.ts +8 -0
- package/dist/analysis/accuracy.d.ts +24 -0
- package/dist/analysis/accuracy.js +45 -0
- package/dist/analysis/credential.d.ts +101 -0
- package/dist/analysis/credential.js +142 -0
- package/dist/analysis/faults.js +115 -0
- package/dist/analysis/grounding.d.ts +122 -0
- package/dist/analysis/grounding.js +445 -0
- package/dist/analysis/hallucination.d.ts +32 -0
- package/dist/analysis/hallucination.js +357 -0
- package/dist/analysis/index.d.ts +23 -0
- package/dist/analysis/index.js +93 -0
- package/dist/analysis/memory.d.ts +8 -0
- package/dist/analysis/memory.js +35 -8
- package/dist/analysis/reference.d.ts +49 -0
- package/dist/analysis/reference.js +164 -0
- package/dist/analysis/taxonomy.js +1 -0
- package/dist/approvals/index.d.ts +23 -0
- package/dist/approvals/index.js +48 -0
- package/dist/archive/parquet.d.ts +2 -0
- package/dist/archive/parquet.js +185 -0
- package/dist/badge/index.d.ts +16 -0
- package/dist/badge/index.js +48 -0
- package/dist/bom/index.js +20 -0
- package/dist/cli.js +114 -10
- package/dist/compliance/art12.js +36 -9
- package/dist/compliance/index.d.ts +36 -2
- package/dist/compliance/index.js +78 -11
- package/dist/compliance/zanii.d.ts +29 -0
- package/dist/compliance/zanii.js +84 -0
- package/dist/constitution/index.d.ts +57 -0
- package/dist/constitution/index.js +131 -0
- package/dist/cv/index.d.ts +39 -0
- package/dist/cv/index.js +108 -0
- package/dist/disclosure/index.d.ts +31 -0
- package/dist/disclosure/index.js +113 -0
- package/dist/encryption/index.d.ts +9 -0
- package/dist/encryption/index.js +31 -0
- package/dist/evidence/index.d.ts +60 -0
- package/dist/evidence/index.js +151 -0
- package/dist/federation/index.d.ts +35 -0
- package/dist/federation/index.js +102 -0
- package/dist/finance/index.d.ts +126 -0
- package/dist/finance/index.js +320 -0
- package/dist/fleet/index.js +9 -0
- package/dist/gov/index.d.ts +108 -0
- package/dist/gov/index.js +225 -0
- package/dist/health/index.d.ts +120 -0
- package/dist/health/index.js +233 -0
- package/dist/index.d.ts +29 -7
- package/dist/index.js +28 -6
- package/dist/memory/index.d.ts +36 -0
- package/dist/memory/index.js +85 -0
- package/dist/occurrence/index.d.ts +11 -0
- package/dist/occurrence/index.js +18 -0
- package/dist/otlp/index.js +28 -1
- package/dist/packs/index.js +44 -4
- package/dist/policy/delta.js +7 -1
- package/dist/policy/index.d.ts +23 -6
- package/dist/policy/index.js +151 -8
- package/dist/policy/zanii.d.ts +31 -0
- package/dist/policy/zanii.js +87 -0
- package/dist/pq/index.d.ts +23 -0
- package/dist/pq/index.js +104 -0
- package/dist/search/index.d.ts +23 -0
- package/dist/search/index.js +69 -0
- package/dist/session/index.d.ts +106 -1
- package/dist/session/index.js +163 -11
- package/dist/sla/index.d.ts +61 -0
- package/dist/sla/index.js +197 -0
- package/dist/succession/index.d.ts +50 -0
- package/dist/succession/index.js +123 -0
- package/dist/tokens/index.d.ts +6 -0
- package/dist/tokens/index.js +46 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/walls/index.d.ts +31 -0
- package/dist/walls/index.js +119 -0
- package/package.json +1 -1
package/dist/analysis/faults.js
CHANGED
|
@@ -28,6 +28,26 @@ export const FAULTS = {
|
|
|
28
28
|
en: "File change outside any tool call",
|
|
29
29
|
ar: "تغيير في الملفات خارج أي استدعاء أداة",
|
|
30
30
|
},
|
|
31
|
+
INTEGRITY_FAILED: {
|
|
32
|
+
fault: "BBX-1107",
|
|
33
|
+
en: "A stored record failed the self-check",
|
|
34
|
+
ar: "فشل سجل محفوظ في الفحص الذاتي",
|
|
35
|
+
},
|
|
36
|
+
ANCHOR_STALE: {
|
|
37
|
+
fault: "BBX-1108",
|
|
38
|
+
en: "Anchoring has stalled",
|
|
39
|
+
ar: "توقّف تثبيت السجلات",
|
|
40
|
+
},
|
|
41
|
+
LEDGER_VIOLATION: {
|
|
42
|
+
fault: "BBX-1109",
|
|
43
|
+
en: "The ledger's log was rewritten",
|
|
44
|
+
ar: "أُعيدت كتابة سجل دفتر الأستاذ",
|
|
45
|
+
},
|
|
46
|
+
ANCHOR_REJECTED: {
|
|
47
|
+
fault: "BBX-1110",
|
|
48
|
+
en: "The ledger rejected an anchor",
|
|
49
|
+
ar: "رفض دفتر الأستاذ تثبيتًا",
|
|
50
|
+
},
|
|
31
51
|
SDK_SILENT: {
|
|
32
52
|
fault: "BBX-1201",
|
|
33
53
|
en: "The SDK stopped reporting",
|
|
@@ -102,6 +122,46 @@ export const FAULTS = {
|
|
|
102
122
|
en: "A check that passed now fails",
|
|
103
123
|
ar: "فحص نجح سابقًا ثم فشل",
|
|
104
124
|
},
|
|
125
|
+
UNKNOWN_TOOL: {
|
|
126
|
+
fault: "BBX-4301",
|
|
127
|
+
en: "A call to a tool that doesn't exist",
|
|
128
|
+
ar: "استدعاء أداة غير موجودة",
|
|
129
|
+
},
|
|
130
|
+
TOOL_ARGS_INVALID: {
|
|
131
|
+
fault: "BBX-4302",
|
|
132
|
+
en: "Tool arguments its schema refuses",
|
|
133
|
+
ar: "وسائط أداة يرفضها مخططها",
|
|
134
|
+
},
|
|
135
|
+
FABRICATED_VALUE: {
|
|
136
|
+
fault: "BBX-4303",
|
|
137
|
+
en: "A value the agent never saw",
|
|
138
|
+
ar: "قيمة لم يطّلع عليها الوكيل",
|
|
139
|
+
},
|
|
140
|
+
SUCCESS_AFTER_ERROR: {
|
|
141
|
+
fault: "BBX-4304",
|
|
142
|
+
en: "Success claimed right after an error",
|
|
143
|
+
ar: "نجاح مُعلن بعد خطأ مباشرة",
|
|
144
|
+
},
|
|
145
|
+
PHANTOM_RESULT: {
|
|
146
|
+
fault: "BBX-4305",
|
|
147
|
+
en: "A result quoted from a tool never called",
|
|
148
|
+
ar: "نتيجة منسوبة إلى أداة لم تُستدعَ",
|
|
149
|
+
},
|
|
150
|
+
UNGROUNDED_CLAIM: {
|
|
151
|
+
fault: "BBX-4401",
|
|
152
|
+
en: "A fact in an answer nothing supports",
|
|
153
|
+
ar: "معلومة في إجابة لا يدعمها شيء",
|
|
154
|
+
},
|
|
155
|
+
CONTRADICTED_CLAIM: {
|
|
156
|
+
fault: "BBX-4402",
|
|
157
|
+
en: "A fact in an answer the evidence contradicts",
|
|
158
|
+
ar: "معلومة في إجابة يناقضها الدليل",
|
|
159
|
+
},
|
|
160
|
+
JUDGE_FAILED: {
|
|
161
|
+
fault: "BBX-4501",
|
|
162
|
+
en: "A judge's rubric step failed",
|
|
163
|
+
ar: "خطوة من معايير الحكم لم تتحقق",
|
|
164
|
+
},
|
|
105
165
|
CLAIM_UNVERIFIED: {
|
|
106
166
|
fault: "BBX-4202",
|
|
107
167
|
en: "Completion claim can't be verified",
|
|
@@ -117,6 +177,41 @@ export const FAULTS = {
|
|
|
117
177
|
en: "Tool use against policy",
|
|
118
178
|
ar: "استخدام أداة مخالف للسياسة",
|
|
119
179
|
},
|
|
180
|
+
WALL_CROSSED: {
|
|
181
|
+
fault: "BBX-5104",
|
|
182
|
+
en: "An answer crossed a regulator's wall",
|
|
183
|
+
ar: "تجاوزت إجابة حدود جهة رقابية",
|
|
184
|
+
},
|
|
185
|
+
UNSCREENED_COUNTERPARTY: {
|
|
186
|
+
fault: "BBX-9401",
|
|
187
|
+
en: "A payment to an unscreened counterparty",
|
|
188
|
+
ar: "دفعة إلى طرف لم يُفحص",
|
|
189
|
+
},
|
|
190
|
+
SCREENING_HIT_PAID: {
|
|
191
|
+
fault: "BBX-9402",
|
|
192
|
+
en: "A flagged counterparty was paid",
|
|
193
|
+
ar: "دُفع لطرف عليه إنذار في الفحص",
|
|
194
|
+
},
|
|
195
|
+
FTA_NO_HANDOFF: {
|
|
196
|
+
fault: "BBX-9403",
|
|
197
|
+
en: "A tax filing never reached a Tax Agent",
|
|
198
|
+
ar: "لم يصل إقرار ضريبي إلى وكيل ضريبي",
|
|
199
|
+
},
|
|
200
|
+
BREAK_GLASS: {
|
|
201
|
+
fault: "BBX-9501",
|
|
202
|
+
en: "Emergency access to a record (break-glass)",
|
|
203
|
+
ar: "وصول طارئ إلى سجل (كسر الزجاج)",
|
|
204
|
+
},
|
|
205
|
+
HEALTH_SIGNATURE_INVALID: {
|
|
206
|
+
fault: "BBX-9502",
|
|
207
|
+
en: "A clinician signature doesn't check",
|
|
208
|
+
ar: "توقيع طبيب لا يصح",
|
|
209
|
+
},
|
|
210
|
+
UNCONFIRMED_RECOMMENDATION: {
|
|
211
|
+
fault: "BBX-9503",
|
|
212
|
+
en: "No clinician confirmed a recommendation",
|
|
213
|
+
ar: "لم يؤكد أي طبيب توصية",
|
|
214
|
+
},
|
|
120
215
|
POLICY_AUDIT: {
|
|
121
216
|
fault: "BBX-5103",
|
|
122
217
|
en: "An audit-only policy rule would have acted",
|
|
@@ -132,11 +227,21 @@ export const FAULTS = {
|
|
|
132
227
|
en: "The session token was sent onward",
|
|
133
228
|
ar: "أُرسل رمز الجلسة إلى جهة أخرى",
|
|
134
229
|
},
|
|
230
|
+
TOOL_CHANGED: {
|
|
231
|
+
fault: "BBX-7402",
|
|
232
|
+
en: "A tool's definition changed mid-session",
|
|
233
|
+
ar: "تغيّر تعريف أداة أثناء الجلسة",
|
|
234
|
+
},
|
|
135
235
|
REVOKED_MEMORY_READ: {
|
|
136
236
|
fault: "BBX-7101",
|
|
137
237
|
en: "A revoked memory was used",
|
|
138
238
|
ar: "استُخدمت ذاكرة ملغاة",
|
|
139
239
|
},
|
|
240
|
+
MEMORY_CHAIN_BROKEN: {
|
|
241
|
+
fault: "BBX-7102",
|
|
242
|
+
en: "A memory entry was changed or is out of order",
|
|
243
|
+
ar: "عُدّل إدخال ذاكرة أو جاء خارج الترتيب",
|
|
244
|
+
},
|
|
140
245
|
TOOL_OUTPUT_MISMATCH: {
|
|
141
246
|
fault: "BBX-7201",
|
|
142
247
|
en: "Tool output doesn't match a re-run",
|
|
@@ -188,6 +293,11 @@ export const FAULTS = {
|
|
|
188
293
|
en: "An action waits for a second person",
|
|
189
294
|
ar: "إجراء بانتظار شخص ثانٍ",
|
|
190
295
|
},
|
|
296
|
+
APPROVAL_ARGS_CHANGED: {
|
|
297
|
+
fault: "BBX-8404",
|
|
298
|
+
en: "An approved tool ran with other arguments",
|
|
299
|
+
ar: "شُغّلت أداة معتمدة بمعطيات أخرى",
|
|
300
|
+
},
|
|
191
301
|
PREFLIGHT_DEGRADED: {
|
|
192
302
|
fault: "BBX-8501",
|
|
193
303
|
en: "Started with equipment missing",
|
|
@@ -238,6 +348,11 @@ export const FAULTS = {
|
|
|
238
348
|
en: "A tool's signature doesn't verify",
|
|
239
349
|
ar: "توقيع الأداة غير صالح",
|
|
240
350
|
},
|
|
351
|
+
UNPROVEN_SIDE_EFFECT: {
|
|
352
|
+
fault: "BBX-9203",
|
|
353
|
+
en: "A change the tool didn't prove",
|
|
354
|
+
ar: "تغيير لم تُثبته الأداة",
|
|
355
|
+
},
|
|
241
356
|
EGRESS_OPEN: {
|
|
242
357
|
fault: "BBX-9301",
|
|
243
358
|
en: "The agent can reach the internet around the gateway",
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { type Bodies, type Call } from "../reconcile/record.ts";
|
|
2
|
+
import { canonicalNumber } from "./hallucination.ts";
|
|
3
|
+
import { type ReferencePack } from "./reference.ts";
|
|
4
|
+
export { canonicalNumber };
|
|
5
|
+
import type { Finding } from "./index.ts";
|
|
6
|
+
export interface Fact {
|
|
7
|
+
kind: "money" | "percent" | "quantity" | "date" | string;
|
|
8
|
+
/** Canonical: a decimal (`1250.5`) for money and percentages, normalised text otherwise. */
|
|
9
|
+
value: string;
|
|
10
|
+
at: number;
|
|
11
|
+
end: number;
|
|
12
|
+
currency?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The facts an answer states: money, percentages, quantities, ISO dates, then identifiers (as H1's). */
|
|
15
|
+
export declare function factsIn(text: string): Fact[];
|
|
16
|
+
/** What the agent was given, to check facts against: the record lines it came from (§11 points at
|
|
17
|
+
* them), each normalised, with its numbers. */
|
|
18
|
+
export declare class Evidence {
|
|
19
|
+
/** As given, for a grounding service (§9.1). */
|
|
20
|
+
readonly raw: string;
|
|
21
|
+
readonly numbers: Set<string>;
|
|
22
|
+
private readonly pieces;
|
|
23
|
+
private sums;
|
|
24
|
+
constructor(raw: string, pieces?: ReadonlyArray<{
|
|
25
|
+
seq: number;
|
|
26
|
+
text: string;
|
|
27
|
+
}>);
|
|
28
|
+
/** Whether the evidence holds the fact (§9). */
|
|
29
|
+
holds(f: Fact): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The seqs of the lines that hold a fact, or null. Money, percentages and quantities: the same
|
|
32
|
+
* number, the same in minor units, a percentage as a fraction, or (money) the sum of two of the
|
|
33
|
+
* evidence's numbers. Dates and identifiers: the normalised text.
|
|
34
|
+
*/
|
|
35
|
+
support(f: Fact): number[] | null;
|
|
36
|
+
private pairSums;
|
|
37
|
+
}
|
|
38
|
+
/** The final answers on a record, each with the evidence it should rest on. */
|
|
39
|
+
export declare function answersOf(lines: readonly string[], bodies: Bodies): Array<{
|
|
40
|
+
seq: number;
|
|
41
|
+
text: string;
|
|
42
|
+
evidence: Evidence;
|
|
43
|
+
call: Call;
|
|
44
|
+
}>;
|
|
45
|
+
/** What a grounding service is sent for one answer: the text, the exact tier's facts, and the
|
|
46
|
+
* context it should rest on (the newest 200,000 characters of it). */
|
|
47
|
+
export declare function groundingRequest(sessionId: string, answer: {
|
|
48
|
+
seq: number;
|
|
49
|
+
text: string;
|
|
50
|
+
evidence: Evidence;
|
|
51
|
+
}, packs?: readonly ReferencePack[]): {
|
|
52
|
+
session_id: string;
|
|
53
|
+
answer_seq: number;
|
|
54
|
+
answer: string;
|
|
55
|
+
facts: {
|
|
56
|
+
kind: string;
|
|
57
|
+
value: string;
|
|
58
|
+
}[];
|
|
59
|
+
context: string;
|
|
60
|
+
reference?: {
|
|
61
|
+
pack: string;
|
|
62
|
+
id: string;
|
|
63
|
+
text: string;
|
|
64
|
+
source?: string;
|
|
65
|
+
}[];
|
|
66
|
+
};
|
|
67
|
+
export interface GroundedClaim {
|
|
68
|
+
text: string;
|
|
69
|
+
status: "grounded" | "ungrounded" | "contradicted" | "no_fact";
|
|
70
|
+
score?: number;
|
|
71
|
+
}
|
|
72
|
+
/** A grounding service's answer, checked: `{claims, model?, version?}`, or null (an outage). */
|
|
73
|
+
export declare function parseGroundingAnswer(v: unknown): {
|
|
74
|
+
claims: GroundedClaim[];
|
|
75
|
+
model?: string;
|
|
76
|
+
version?: string;
|
|
77
|
+
} | null;
|
|
78
|
+
/** §9.1: UNGROUNDED_CLAIM and CONTRADICTED_CLAIM from the verdicts a grounding service gave,
|
|
79
|
+
* recorded as `control {action: "grounding", via: "model"}` with the claims as the body. */
|
|
80
|
+
export declare function modelGroundingFindings(lines: readonly string[], bodies: Bodies): Finding[];
|
|
81
|
+
/** spec/findings.md §9-§10: for each fact in a final answer, CONTRADICTED_CLAIM when a reference
|
|
82
|
+
* pack says otherwise, else UNGROUNDED_CLAIM when nothing the agent was given holds it (at most 10
|
|
83
|
+
* per answer); then the grounding service's verdicts (§9.1). */
|
|
84
|
+
export declare function groundingFindings(lines: readonly string[], bodies: Bodies, packs?: readonly ReferencePack[]): Finding[];
|
|
85
|
+
/** What a judge is sent for one answer: the answer and the trajectory before it (its newest 100
|
|
86
|
+
* steps: tools called, whether they failed, earlier answers, the findings so far). */
|
|
87
|
+
export declare function judgeRequest(sessionId: string, answer: {
|
|
88
|
+
seq: number;
|
|
89
|
+
text: string;
|
|
90
|
+
}, lines: readonly string[]): {
|
|
91
|
+
session_id: string;
|
|
92
|
+
answer_seq: number;
|
|
93
|
+
answer: string;
|
|
94
|
+
steps: {
|
|
95
|
+
[key: string]: string | number | boolean;
|
|
96
|
+
}[];
|
|
97
|
+
};
|
|
98
|
+
/** A judge's answer, checked: `{steps: [{rubric, pass, reason?}], model?, version?}`, or null. */
|
|
99
|
+
export declare function parseJudgeAnswer(v: unknown): {
|
|
100
|
+
steps: Array<{
|
|
101
|
+
rubric: string;
|
|
102
|
+
pass: boolean;
|
|
103
|
+
reason?: string;
|
|
104
|
+
}>;
|
|
105
|
+
model?: string;
|
|
106
|
+
version?: string;
|
|
107
|
+
} | null;
|
|
108
|
+
/** §12.1: JUDGE_FAILED for each rubric step a judge failed, from its recorded verdicts. */
|
|
109
|
+
export declare function judgeFindings(lines: readonly string[], bodies: Bodies): Finding[];
|
|
110
|
+
/** spec/findings.md §13: what can hold an answer (BLACKBOX_HOLD_ANSWERS). */
|
|
111
|
+
export declare const HOLD_TRIGGERS: readonly ["contradicted", "money", "ids", "quantity", "percent", "date"];
|
|
112
|
+
/** §13: why an answer should be held before it's delivered: each fact a pack contradicts (with
|
|
113
|
+
* `contradicted`), and each ungrounded fact whose kind is a trigger (`ids` covers the identifiers).
|
|
114
|
+
* Empty: deliver it. */
|
|
115
|
+
export declare function answerRisk(answer: {
|
|
116
|
+
text: string;
|
|
117
|
+
evidence: Evidence;
|
|
118
|
+
}, packs: readonly ReferencePack[], triggers: readonly string[]): Array<{
|
|
119
|
+
index: number;
|
|
120
|
+
kind: string;
|
|
121
|
+
status: "contradicted" | "ungrounded";
|
|
122
|
+
}>;
|