@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.
Files changed (87) hide show
  1. package/README.md +1 -0
  2. package/dist/analysis/accepted.d.ts +26 -0
  3. package/dist/analysis/accepted.js +61 -0
  4. package/dist/analysis/detectors.js +12 -9
  5. package/dist/analysis/faults.js +71 -0
  6. package/dist/analysis/grounding.js +5 -9
  7. package/dist/analysis/guard.d.ts +72 -0
  8. package/dist/analysis/guard.js +240 -0
  9. package/dist/analysis/hallucination.js +2 -2
  10. package/dist/analysis/index.d.ts +21 -1
  11. package/dist/analysis/index.js +101 -19
  12. package/dist/analysis/injection.d.ts +2 -1
  13. package/dist/analysis/injection.js +16 -16
  14. package/dist/analysis/landing.js +60 -14
  15. package/dist/analysis/plan-checks.d.ts +55 -0
  16. package/dist/analysis/plan-checks.js +748 -0
  17. package/dist/analysis/taxonomy.js +1 -0
  18. package/dist/analysis/waste.js +2 -3
  19. package/dist/approvals/index.d.ts +12 -3
  20. package/dist/approvals/index.js +36 -10
  21. package/dist/authority/index.js +3 -3
  22. package/dist/aviation/index.d.ts +422 -0
  23. package/dist/aviation/index.js +1014 -0
  24. package/dist/aviation/qrh.d.ts +4 -0
  25. package/dist/aviation/qrh.js +171 -0
  26. package/dist/budgets/index.d.ts +63 -0
  27. package/dist/budgets/index.js +161 -0
  28. package/dist/cli.js +172 -24
  29. package/dist/compliance/index.d.ts +2 -0
  30. package/dist/compliance/index.js +26 -2
  31. package/dist/cost/batch.d.ts +26 -0
  32. package/dist/cost/batch.js +173 -0
  33. package/dist/cost/index.d.ts +21 -0
  34. package/dist/cost/index.js +115 -30
  35. package/dist/cv/index.js +1 -1
  36. package/dist/duty/index.js +2 -1
  37. package/dist/evals/index.d.ts +233 -0
  38. package/dist/evals/index.js +488 -0
  39. package/dist/federation/index.d.ts +9 -0
  40. package/dist/federation/index.js +8 -1
  41. package/dist/finance/index.js +3 -4
  42. package/dist/fleet/index.d.ts +25 -0
  43. package/dist/fleet/index.js +57 -17
  44. package/dist/fleet/insights.js +4 -1
  45. package/dist/health/index.js +2 -2
  46. package/dist/hooks/ai-sdk.d.ts +17 -19
  47. package/dist/hooks/ai-sdk.js +13 -7
  48. package/dist/hooks/index.d.ts +1 -0
  49. package/dist/hooks/index.js +1 -0
  50. package/dist/hooks/mastra.d.ts +26 -0
  51. package/dist/hooks/mastra.js +63 -0
  52. package/dist/index.d.ts +22 -9
  53. package/dist/index.js +23 -9
  54. package/dist/mcp-requests/index.d.ts +26 -0
  55. package/dist/mcp-requests/index.js +154 -0
  56. package/dist/mcp-server/index.d.ts +12 -0
  57. package/dist/mcp-server/index.js +84 -2
  58. package/dist/mcp-wrap/index.js +8 -4
  59. package/dist/otlp/index.d.ts +155 -0
  60. package/dist/otlp/index.js +468 -0
  61. package/dist/otlp/protobuf.d.ts +7 -0
  62. package/dist/otlp/protobuf.js +314 -0
  63. package/dist/packs/index.d.ts +2 -0
  64. package/dist/packs/index.js +5 -1
  65. package/dist/pdf/arabic.d.ts +45 -0
  66. package/dist/pdf/arabic.js +373 -0
  67. package/dist/pdf/index.d.ts +77 -0
  68. package/dist/pdf/index.js +673 -0
  69. package/dist/policy/index.d.ts +0 -4
  70. package/dist/policy/index.js +13 -5
  71. package/dist/realtime/index.d.ts +33 -0
  72. package/dist/realtime/index.js +204 -0
  73. package/dist/reconcile/record.d.ts +12 -0
  74. package/dist/reconcile/record.js +114 -65
  75. package/dist/session/index.d.ts +43 -0
  76. package/dist/session/index.js +83 -0
  77. package/dist/undo/index.js +3 -3
  78. package/dist/verify/anchor.d.ts +5 -1
  79. package/dist/verify/anchor.js +13 -4
  80. package/dist/verify/envelope.d.ts +1 -1
  81. package/dist/verify/envelope.js +5 -0
  82. package/dist/version.d.ts +1 -1
  83. package/dist/version.js +1 -1
  84. package/dist/walls/index.js +2 -2
  85. package/dist/warehouse/index.d.ts +62 -0
  86. package/dist/warehouse/index.js +142 -0
  87. package/package.json +6 -3
@@ -165,3 +165,317 @@ export function otlpFromProtobuf(buf) {
165
165
  }),
166
166
  };
167
167
  }
168
+ const KV = "KeyValue[]";
169
+ const SCHEMAS = {
170
+ AnyValue: [
171
+ [1, "stringValue", "string"],
172
+ [2, "boolValue", "bool"],
173
+ [3, "intValue", "int64"],
174
+ [4, "doubleValue", "double"],
175
+ [5, "arrayValue", "ArrayValue"],
176
+ [6, "kvlistValue", "KeyValueList"],
177
+ [7, "bytesValue", "bytes"],
178
+ ],
179
+ ArrayValue: [[1, "values", "AnyValue[]"]],
180
+ KeyValueList: [[1, "values", KV]],
181
+ KeyValue: [
182
+ [1, "key", "string"],
183
+ [2, "value", "AnyValue"],
184
+ ],
185
+ Resource: [
186
+ [1, "attributes", KV],
187
+ [2, "droppedAttributesCount", "uint32"],
188
+ ],
189
+ Scope: [
190
+ [1, "name", "string"],
191
+ [2, "version", "string"],
192
+ [3, "attributes", KV],
193
+ [4, "droppedAttributesCount", "uint32"],
194
+ ],
195
+ traces: [[1, "resourceSpans", "ResourceSpans[]"]],
196
+ ResourceSpans: [
197
+ [1, "resource", "Resource"],
198
+ [2, "scopeSpans", "ScopeSpans[]"],
199
+ [3, "schemaUrl", "string"],
200
+ ],
201
+ ScopeSpans: [
202
+ [1, "scope", "Scope"],
203
+ [2, "spans", "Span[]"],
204
+ [3, "schemaUrl", "string"],
205
+ ],
206
+ Span: [
207
+ [1, "traceId", "id"],
208
+ [2, "spanId", "id"],
209
+ [3, "traceState", "string"],
210
+ [4, "parentSpanId", "id"],
211
+ [5, "name", "string"],
212
+ [6, "kind", "enum"],
213
+ [7, "startTimeUnixNano", "fixed64"],
214
+ [8, "endTimeUnixNano", "fixed64"],
215
+ [9, "attributes", KV],
216
+ [10, "droppedAttributesCount", "uint32"],
217
+ [11, "events", "SpanEvent[]"],
218
+ [12, "droppedEventsCount", "uint32"],
219
+ [13, "links", "Link[]"],
220
+ [14, "droppedLinksCount", "uint32"],
221
+ [15, "status", "Status"],
222
+ [16, "flags", "fixed32"],
223
+ ],
224
+ SpanEvent: [
225
+ [1, "timeUnixNano", "fixed64"],
226
+ [2, "name", "string"],
227
+ [3, "attributes", KV],
228
+ [4, "droppedAttributesCount", "uint32"],
229
+ ],
230
+ Link: [
231
+ [1, "traceId", "id"],
232
+ [2, "spanId", "id"],
233
+ [3, "traceState", "string"],
234
+ [4, "attributes", KV],
235
+ [5, "droppedAttributesCount", "uint32"],
236
+ [6, "flags", "fixed32"],
237
+ ],
238
+ Status: [
239
+ [2, "message", "string"],
240
+ [3, "code", "enum"],
241
+ ],
242
+ metrics: [[1, "resourceMetrics", "ResourceMetrics[]"]],
243
+ ResourceMetrics: [
244
+ [1, "resource", "Resource"],
245
+ [2, "scopeMetrics", "ScopeMetrics[]"],
246
+ [3, "schemaUrl", "string"],
247
+ ],
248
+ ScopeMetrics: [
249
+ [1, "scope", "Scope"],
250
+ [2, "metrics", "Metric[]"],
251
+ [3, "schemaUrl", "string"],
252
+ ],
253
+ Metric: [
254
+ [1, "name", "string"],
255
+ [2, "description", "string"],
256
+ [3, "unit", "string"],
257
+ [5, "gauge", "Gauge"],
258
+ [7, "sum", "Sum"],
259
+ [9, "histogram", "Histogram"],
260
+ [10, "exponentialHistogram", "ExponentialHistogram"],
261
+ [11, "summary", "Summary"],
262
+ ],
263
+ Gauge: [[1, "dataPoints", "NumberDataPoint[]"]],
264
+ Sum: [
265
+ [1, "dataPoints", "NumberDataPoint[]"],
266
+ [2, "aggregationTemporality", "enum"],
267
+ [3, "isMonotonic", "bool"],
268
+ ],
269
+ Histogram: [
270
+ [1, "dataPoints", "HistogramDataPoint[]"],
271
+ [2, "aggregationTemporality", "enum"],
272
+ ],
273
+ ExponentialHistogram: [
274
+ [1, "dataPoints", "ExponentialHistogramDataPoint[]"],
275
+ [2, "aggregationTemporality", "enum"],
276
+ ],
277
+ Summary: [[1, "dataPoints", "SummaryDataPoint[]"]],
278
+ NumberDataPoint: [
279
+ [2, "startTimeUnixNano", "fixed64"],
280
+ [3, "timeUnixNano", "fixed64"],
281
+ [4, "asDouble", "double"],
282
+ [6, "asInt", "sfixed64"],
283
+ [7, "attributes", KV],
284
+ [8, "flags", "uint32"],
285
+ ],
286
+ HistogramDataPoint: [
287
+ [2, "startTimeUnixNano", "fixed64"],
288
+ [3, "timeUnixNano", "fixed64"],
289
+ [4, "count", "fixed64"],
290
+ [5, "sum", "double"],
291
+ [6, "bucketCounts", "fixed64[]"],
292
+ [7, "explicitBounds", "double[]"],
293
+ [9, "attributes", KV],
294
+ [10, "flags", "uint32"],
295
+ [11, "min", "double"],
296
+ [12, "max", "double"],
297
+ ],
298
+ // ponytail: an exponential histogram's buckets and a summary's quantiles aren't read
299
+ ExponentialHistogramDataPoint: [
300
+ [1, "attributes", KV],
301
+ [2, "startTimeUnixNano", "fixed64"],
302
+ [3, "timeUnixNano", "fixed64"],
303
+ [4, "count", "fixed64"],
304
+ [5, "sum", "double"],
305
+ [6, "scale", "sint32"],
306
+ [7, "zeroCount", "fixed64"],
307
+ [10, "flags", "uint32"],
308
+ [12, "min", "double"],
309
+ [13, "max", "double"],
310
+ ],
311
+ SummaryDataPoint: [
312
+ [2, "startTimeUnixNano", "fixed64"],
313
+ [3, "timeUnixNano", "fixed64"],
314
+ [4, "count", "fixed64"],
315
+ [5, "sum", "double"],
316
+ [7, "attributes", KV],
317
+ [8, "flags", "uint32"],
318
+ ],
319
+ logs: [[1, "resourceLogs", "ResourceLogs[]"]],
320
+ ResourceLogs: [
321
+ [1, "resource", "Resource"],
322
+ [2, "scopeLogs", "ScopeLogs[]"],
323
+ [3, "schemaUrl", "string"],
324
+ ],
325
+ ScopeLogs: [
326
+ [1, "scope", "Scope"],
327
+ [2, "logRecords", "LogRecord[]"],
328
+ [3, "schemaUrl", "string"],
329
+ ],
330
+ LogRecord: [
331
+ [1, "timeUnixNano", "fixed64"],
332
+ [2, "severityNumber", "enum"],
333
+ [3, "severityText", "string"],
334
+ [5, "body", "AnyValue"],
335
+ [6, "attributes", KV],
336
+ [7, "droppedAttributesCount", "uint32"],
337
+ [8, "flags", "fixed32"],
338
+ [9, "traceId", "id"],
339
+ [10, "spanId", "id"],
340
+ [11, "observedTimeUnixNano", "fixed64"],
341
+ [12, "eventName", "string"],
342
+ ],
343
+ };
344
+ const VARINT = new Set(["bool", "enum", "uint32", "int64", "sint32"]);
345
+ const FIXED64 = new Set(["fixed64", "sfixed64", "double"]);
346
+ const wireOf = (t) => (VARINT.has(t) ? 0 : FIXED64.has(t) ? 1 : t === "fixed32" ? 5 : 2);
347
+ function scalarOf(t, v) {
348
+ if (v instanceof Uint8Array)
349
+ return t === "id" ? hex(v) : t === "bytes" ? Buffer.from(v).toString("base64") : text(v);
350
+ if (t === "bool")
351
+ return v !== 0n;
352
+ if (t === "double")
353
+ return float64(v);
354
+ if (t === "int64" || t === "sfixed64")
355
+ return BigInt.asIntN(64, v).toString();
356
+ if (t === "fixed64")
357
+ return v.toString();
358
+ if (t === "sint32")
359
+ return Number((v >> 1n) ^ -(v & 1n));
360
+ return Number(v); // enum, uint32, fixed32
361
+ }
362
+ function decode(b, name) {
363
+ const schema = SCHEMAS[name];
364
+ const out = {};
365
+ for (const f of fields(b)) {
366
+ const spec = schema.find((s) => s[0] === f.n);
367
+ if (!spec)
368
+ continue;
369
+ const [, key, type] = spec;
370
+ const repeated = type.endsWith("[]");
371
+ const t = repeated ? type.slice(0, -2) : type;
372
+ let values;
373
+ if (SCHEMAS[t]) {
374
+ if (f.wire !== 2)
375
+ throw new Error(`protobuf: ${name}.${key} isn't a message`);
376
+ values = [decode(bytes(f), t)];
377
+ }
378
+ else if (repeated && f.wire === 2 && wireOf(t) !== 2) {
379
+ // a packed run of fixed64s or doubles
380
+ const raw = bytes(f);
381
+ if (raw.length % 8)
382
+ throw new Error(`protobuf: ${name}.${key} isn't packed 64-bit values`);
383
+ values = [];
384
+ for (let k = 0; k < raw.length; k += 8) {
385
+ let v = 0n;
386
+ for (let j = 7; j >= 0; j--)
387
+ v = (v << 8n) | BigInt(raw[k + j]);
388
+ values.push(scalarOf(t, v));
389
+ }
390
+ }
391
+ else {
392
+ if (f.wire !== wireOf(t))
393
+ throw new Error(`protobuf: ${name}.${key} has the wrong wire type`);
394
+ values = [scalarOf(t, f.v)];
395
+ }
396
+ if (repeated)
397
+ out[key] = [...(out[key] ?? []), ...values];
398
+ else
399
+ out[key] = values[0];
400
+ }
401
+ return out;
402
+ }
403
+ /** spec/otlp.md §6: an Export{Trace,Metrics,Logs}ServiceRequest's bytes as OTLP/JSON, every field
404
+ * read (64-bit integers as strings, ids as hex). Throws on bad bytes. */
405
+ export function otlpDecode(buf, signal) {
406
+ return decode(buf, signal);
407
+ }
408
+ const varintBytes = (n) => {
409
+ const out = [];
410
+ let v = BigInt.asUintN(64, n);
411
+ while (v > 0x7fn) {
412
+ out.push(Number(v & 0x7fn) | 0x80);
413
+ v >>= 7n;
414
+ }
415
+ out.push(Number(v));
416
+ return out;
417
+ };
418
+ const fixedBytes = (v, size) => {
419
+ const out = [];
420
+ let x = BigInt.asUintN(size * 8, v);
421
+ for (let k = 0; k < size; k++) {
422
+ out.push(Number(x & 0xffn));
423
+ x >>= 8n;
424
+ }
425
+ return out;
426
+ };
427
+ const doubleBits = (x) => {
428
+ const view = new DataView(new ArrayBuffer(8));
429
+ view.setFloat64(0, x, true);
430
+ return view.getBigUint64(0, true);
431
+ };
432
+ const integer = (v) => BigInt(typeof v === "number" ? Math.trunc(v) : String(v));
433
+ function scalarBytes(t, v) {
434
+ if (t === "string")
435
+ return [...new TextEncoder().encode(String(v))];
436
+ if (t === "id")
437
+ return [...Buffer.from(String(v), "hex")];
438
+ if (t === "bytes")
439
+ return [...Buffer.from(String(v), "base64")];
440
+ if (t === "bool")
441
+ return varintBytes(v ? 1n : 0n);
442
+ if (t === "sint32") {
443
+ const n = integer(v);
444
+ return varintBytes(n < 0n ? -2n * n - 1n : 2n * n);
445
+ }
446
+ if (VARINT.has(t))
447
+ return varintBytes(integer(v));
448
+ if (t === "double")
449
+ return fixedBytes(doubleBits(Number(v)), 8);
450
+ if (t === "fixed32")
451
+ return fixedBytes(integer(v), 4);
452
+ return fixedBytes(integer(v), 8); // fixed64, sfixed64
453
+ }
454
+ function encode(o, name) {
455
+ const out = [];
456
+ for (const [n, key, type] of SCHEMAS[name]) {
457
+ const v = o[key];
458
+ if (v === undefined || v === null)
459
+ continue;
460
+ const repeated = type.endsWith("[]");
461
+ const t = repeated ? type.slice(0, -2) : type;
462
+ const wire = SCHEMAS[t] ? 2 : wireOf(t);
463
+ const tag = varintBytes(BigInt((n << 3) | (repeated ? 2 : wire)));
464
+ if (repeated && wire !== 2) {
465
+ // packed: one length-delimited run
466
+ const run = v.flatMap((x) => scalarBytes(t, x));
467
+ out.push(...tag, ...varintBytes(BigInt(run.length)), ...run);
468
+ continue;
469
+ }
470
+ for (const x of repeated ? v : [v]) {
471
+ const body = SCHEMAS[t] ? encode(x, t) : scalarBytes(t, x);
472
+ out.push(...tag, ...(wire === 2 ? varintBytes(BigInt(body.length)) : []), ...body);
473
+ }
474
+ }
475
+ return out;
476
+ }
477
+ /** spec/otlp.md §6: OTLP/JSON as the Export{Trace,Metrics,Logs}ServiceRequest's protobuf bytes,
478
+ * the fields in number order, so both SDKs give the same bytes (spec/vectors/otlp-protobuf-out.json). */
479
+ export function otlpEncode(doc, signal) {
480
+ return Uint8Array.from(encode(doc, signal));
481
+ }
@@ -20,6 +20,7 @@ export declare function packData(packs: readonly unknown[]): DataRules;
20
20
  /** spec/packs.md §2: the core pack, from the built-in frameworks files. */
21
21
  export declare function corePack(compliance: {
22
22
  notes: string;
23
+ notes_ar?: string;
23
24
  frameworks: Obj;
24
25
  }, occurrence: {
25
26
  notes: string;
@@ -32,6 +33,7 @@ export declare function corePack(compliance: {
32
33
  status: string;
33
34
  compliance: {
34
35
  notes: string;
36
+ notes_ar?: string;
35
37
  frameworks: Obj;
36
38
  };
37
39
  occurrence: {
@@ -337,7 +337,11 @@ export function corePack(compliance, occurrence) {
337
337
  id: "core",
338
338
  title: "Core (built in)",
339
339
  status: "draft",
340
- compliance: { notes: compliance.notes, frameworks: compliance.frameworks },
340
+ compliance: {
341
+ notes: compliance.notes,
342
+ ...(compliance.notes_ar ? { notes_ar: compliance.notes_ar } : {}),
343
+ frameworks: compliance.frameworks,
344
+ },
341
345
  occurrence: {
342
346
  notes: occurrence.notes,
343
347
  ...(occurrence.notes_ar ? { notes_ar: occurrence.notes_ar } : {}),
@@ -0,0 +1,45 @@
1
+ /** spec/pdf/unicode-arabic.json */
2
+ export interface UnicodeTables {
3
+ unicode: string;
4
+ bidi: Array<[number, string]>;
5
+ joining: Array<[number, number, string]>;
6
+ forms: number[][];
7
+ lam_alef: number[][];
8
+ mirror: number[][];
9
+ brackets: Array<[number, number, string]>;
10
+ }
11
+ /** The tables as lookups (built once per document). */
12
+ export interface Prepared {
13
+ cls: (cp: number) => string;
14
+ jt: (cp: number) => string;
15
+ forms: Map<number, number[]>;
16
+ lamAlef: Map<number, number[]>;
17
+ mirror: Map<number, number>;
18
+ brackets: Map<number, [number, string]>;
19
+ }
20
+ /** One base character (or a ligature) with the marks on it, in logical order. */
21
+ export interface Cluster {
22
+ /** The code points to draw: the shaped base, then its marks. Empty for a control. */
23
+ cps: number[];
24
+ /** The logical text it stands for ("" for a control). */
25
+ src: string;
26
+ /** The Bidi_Class of its first character. */
27
+ cls: string;
28
+ }
29
+ export declare function prepare(u: UnicodeTables): Prepared;
30
+ /** §6.1: the text as clusters, letters in their joining forms, lam-alef as one ligature. */
31
+ export declare function shapeClusters(text: string, P: Prepared): Cluster[];
32
+ /** §6.1: the shaped text (presentation forms, logical order). */
33
+ export declare function shapeArabic(text: string, tables: UnicodeTables): string;
34
+ /** §6.2: the embedding level of each cluster in a paragraph of level `p` (0 or 1). */
35
+ export declare function bidiLevels(clusters: Cluster[], p: number, P: Prepared): number[];
36
+ /** L1-L2 and L4 for one line (`line`: cluster indices in logical order): the indices in visual
37
+ * order, controls left out, each cluster's code points with mirroring applied, and whether its
38
+ * level is odd (right to left). */
39
+ export declare function reorderLine(line: number[], clusters: Cluster[], levels: number[], p: number, P: Prepared): Array<{
40
+ index: number;
41
+ cps: number[];
42
+ odd: boolean;
43
+ }>;
44
+ /** §6.2: one line of text, shaped and in visual (left to right) order, in a paragraph of level `p`. */
45
+ export declare function visualLine(text: string, p: number, tables: UnicodeTables): string;