@zanii/blackbox 0.17.0 → 0.18.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/dist/analysis/faults.js +10 -0
- package/dist/analysis/index.d.ts +8 -0
- package/dist/analysis/index.js +65 -0
- package/dist/analysis/taxonomy.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/analysis/faults.js
CHANGED
|
@@ -232,6 +232,16 @@ export const FAULTS = {
|
|
|
232
232
|
en: "A tool's definition changed mid-session",
|
|
233
233
|
ar: "تغيّر تعريف أداة أثناء الجلسة",
|
|
234
234
|
},
|
|
235
|
+
USER_DOWNVOTE: {
|
|
236
|
+
fault: "BBX-4601",
|
|
237
|
+
en: "The person served said an answer was wrong",
|
|
238
|
+
ar: "قال الشخص المخدوم إن الإجابة خاطئة",
|
|
239
|
+
},
|
|
240
|
+
SECRET_SENT: {
|
|
241
|
+
fault: "BBX-9106",
|
|
242
|
+
en: "A credential was sent to a model or tool",
|
|
243
|
+
ar: "أُرسلت بيانات اعتماد إلى نموذج أو أداة",
|
|
244
|
+
},
|
|
235
245
|
PROMPT_INJECTION: {
|
|
236
246
|
fault: "BBX-7403",
|
|
237
247
|
squawk: "HIJACK",
|
package/dist/analysis/index.d.ts
CHANGED
|
@@ -88,6 +88,14 @@ export declare function toolChanged(events: Ev[]): Finding[];
|
|
|
88
88
|
* (`meta.tool_defs_prev`); a tool listed with another hash is a finding, once per server and tool.
|
|
89
89
|
*/
|
|
90
90
|
export declare function toolDrifted(events: Ev[]): Finding[];
|
|
91
|
+
/**
|
|
92
|
+
* spec/data.md §6a: a credential left for a model or a tool. The record's own redaction counted it
|
|
93
|
+
* (`meta.redacted.secrets`); what the model was sent had fewer masked (`meta.outbound_redacted`), or
|
|
94
|
+
* the call went to an MCP tool. A request refused for it (`outbound_blocked`) sent nothing.
|
|
95
|
+
*/
|
|
96
|
+
export declare function secretSent(events: Ev[]): Finding[];
|
|
97
|
+
/** spec/findings.md §12b: a person the agent served said an answer was wrong (👎), once per answer. */
|
|
98
|
+
export declare function userDownvotes(events: Ev[]): Finding[];
|
|
91
99
|
/** N6 (idea S3): the gateway refused a request that carried the session's own token. */
|
|
92
100
|
export declare function tokenMisuse(events: Ev[]): Finding[];
|
|
93
101
|
/** Stage 2 R3: a `verify` check that passed, then failed later in the run. */
|
package/dist/analysis/index.js
CHANGED
|
@@ -58,6 +58,8 @@ export function analyze(lines, options) {
|
|
|
58
58
|
...tokenMisuse(events),
|
|
59
59
|
...toolChanged(events),
|
|
60
60
|
...toolDrifted(events),
|
|
61
|
+
...secretSent(events),
|
|
62
|
+
...userDownvotes(events),
|
|
61
63
|
...injectionFindings(lines, options.bodies),
|
|
62
64
|
...verifyRegression(events),
|
|
63
65
|
...falseSuccess(events, now),
|
|
@@ -440,6 +442,69 @@ export function toolDrifted(events) {
|
|
|
440
442
|
}
|
|
441
443
|
return out;
|
|
442
444
|
}
|
|
445
|
+
/**
|
|
446
|
+
* spec/data.md §6a: a credential left for a model or a tool. The record's own redaction counted it
|
|
447
|
+
* (`meta.redacted.secrets`); what the model was sent had fewer masked (`meta.outbound_redacted`), or
|
|
448
|
+
* the call went to an MCP tool. A request refused for it (`outbound_blocked`) sent nothing.
|
|
449
|
+
*/
|
|
450
|
+
export function secretSent(events) {
|
|
451
|
+
const blocked = new Set();
|
|
452
|
+
for (const e of events)
|
|
453
|
+
if (e.kind === "llm.incomplete" &&
|
|
454
|
+
e.meta.reason === "outbound_blocked" &&
|
|
455
|
+
typeof e.meta.request_seq === "number")
|
|
456
|
+
blocked.add(e.meta.request_seq);
|
|
457
|
+
const count = (v) => {
|
|
458
|
+
const n = v?.secrets;
|
|
459
|
+
return typeof n === "number" && Number.isSafeInteger(n) && n > 0 ? n : 0;
|
|
460
|
+
};
|
|
461
|
+
const out = [];
|
|
462
|
+
for (const e of events) {
|
|
463
|
+
let to = null;
|
|
464
|
+
let n = 0;
|
|
465
|
+
if (e.kind === "llm.request" && !blocked.has(e.seq)) {
|
|
466
|
+
n = count(e.meta.redacted) - count(e.meta.outbound_redacted);
|
|
467
|
+
to = "model";
|
|
468
|
+
}
|
|
469
|
+
else if (e.kind === "tool.call" && typeof e.meta.tool === "string") {
|
|
470
|
+
n = count(e.meta.redacted);
|
|
471
|
+
to = "tool";
|
|
472
|
+
}
|
|
473
|
+
if (!to || n <= 0)
|
|
474
|
+
continue;
|
|
475
|
+
out.push({
|
|
476
|
+
code: "SECRET_SENT",
|
|
477
|
+
source: "detectors",
|
|
478
|
+
severity: "warning",
|
|
479
|
+
ref: { seq: e.seq, to, count: n, ...(to === "tool" ? { tool: e.meta.tool } : {}) },
|
|
480
|
+
detail: to === "model"
|
|
481
|
+
? "A credential (a key, a token, a password) went to the model provider in the request."
|
|
482
|
+
: "A credential (a key, a token, a password) went to a tool in its arguments; the gateway's credential broker keeps them out of the agent's hands.",
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
return out;
|
|
486
|
+
}
|
|
487
|
+
/** spec/findings.md §12b: a person the agent served said an answer was wrong (👎), once per answer. */
|
|
488
|
+
export function userDownvotes(events) {
|
|
489
|
+
const out = [];
|
|
490
|
+
const seen = new Set();
|
|
491
|
+
for (const e of events) {
|
|
492
|
+
const about = e.meta.about_seq;
|
|
493
|
+
if (e.kind !== "control" || e.meta.action !== "feedback" || e.meta.rating !== "down")
|
|
494
|
+
continue;
|
|
495
|
+
if (typeof about !== "number" || seen.has(about))
|
|
496
|
+
continue;
|
|
497
|
+
seen.add(about);
|
|
498
|
+
out.push({
|
|
499
|
+
code: "USER_DOWNVOTE",
|
|
500
|
+
source: "detectors",
|
|
501
|
+
severity: "advisory",
|
|
502
|
+
ref: { seq: about, feedback_seq: e.seq },
|
|
503
|
+
detail: "The person this answer was for said it was wrong.",
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
return out;
|
|
507
|
+
}
|
|
443
508
|
/** N6 (idea S3): the gateway refused a request that carried the session's own token. */
|
|
444
509
|
export function tokenMisuse(events) {
|
|
445
510
|
return events
|
|
@@ -56,6 +56,7 @@ export const TAXONOMY = {
|
|
|
56
56
|
TOOL_CHANGED: { owasp: ["ASI04"], atlas: ["AML.T0110.002"] },
|
|
57
57
|
TOOL_DRIFTED: { owasp: ["ASI04"], atlas: ["AML.T0110.002"] },
|
|
58
58
|
PROMPT_INJECTION: { owasp: ["ASI01"], atlas: ["AML.T0051"] },
|
|
59
|
+
SECRET_SENT: { owasp: ["ASI03"], atlas: ["AML.T0057"] },
|
|
59
60
|
TOOL_OUTPUT_MISMATCH: { owasp: ["ASI04", "ASI06"], atlas: ["AML.T0110.002", "AML.T0099"] },
|
|
60
61
|
TOOL_WITNESS_INVALID: { owasp: ["ASI04"], atlas: ["AML.T0110.002"] },
|
|
61
62
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { A2A_STREAMING, type AgentCardReport, a2aMethod, a2aRequestMeta, a2aResp
|
|
|
2
2
|
export { causality, memoryXray } from "./agents/index.ts";
|
|
3
3
|
export { type DetectorOptions, detectors, fingerprint } from "./analysis/detectors.ts";
|
|
4
4
|
export { FAULTS, type Fault, faultOf } from "./analysis/faults.ts";
|
|
5
|
-
export { type Accuracy, type AnalyzeOptions, type AnswerClaims, analyze, answerClaims, answerCredential, answerRisk, answersOf, answerText, type ClaimEntry, type ClaimVerdict, type CriterionResult, canonicalNumber, checkAgainstPacks, checkFlightPlan, checkpointReplay, detectorAccuracy, dualWitness, Evidence, eventsOf, type Fact, type Finding as AnalysisFinding, factsIn, findingKey, type GroundedClaim, groundingFindings, groundingRequest, HOLD_TRIGGERS, identifiersIn, judgeFindings, judgeRequest, type Label as AccuracyLabel, type Landing, landing, loadReferencePacks, modelGroundingFindings, normaliseValue, OUTCOMES, type Outcome, type OutcomeRollup, packsFor, parseGroundingAnswer, parseJudgeAnswer, type ReferenceFact, type ReferencePack, type ReferenceVerdict, referenceContext, rollup, type Severity, schemaProblem, toolDrifted, toolHallucinations, verifyAnswerCredential, type WasteReason, type WasteReport, waste, wilsonLow, } from "./analysis/index.ts";
|
|
5
|
+
export { type Accuracy, type AnalyzeOptions, type AnswerClaims, analyze, answerClaims, answerCredential, answerRisk, answersOf, answerText, type ClaimEntry, type ClaimVerdict, type CriterionResult, canonicalNumber, checkAgainstPacks, checkFlightPlan, checkpointReplay, detectorAccuracy, dualWitness, Evidence, eventsOf, type Fact, type Finding as AnalysisFinding, factsIn, findingKey, type GroundedClaim, groundingFindings, groundingRequest, HOLD_TRIGGERS, identifiersIn, judgeFindings, judgeRequest, type Label as AccuracyLabel, type Landing, landing, loadReferencePacks, modelGroundingFindings, normaliseValue, OUTCOMES, type Outcome, type OutcomeRollup, packsFor, parseGroundingAnswer, parseJudgeAnswer, type ReferenceFact, type ReferencePack, type ReferenceVerdict, referenceContext, rollup, type Severity, schemaProblem, secretSent, toolDrifted, toolHallucinations, userDownvotes, verifyAnswerCredential, type WasteReason, type WasteReport, waste, wilsonLow, } from "./analysis/index.ts";
|
|
6
6
|
export { injectionFindings, injectionRule } from "./analysis/injection.ts";
|
|
7
7
|
export { MITRE_ATLAS, OWASP_ASI, TAXONOMY, type Taxonomy, taxonomyOf, } from "./analysis/taxonomy.ts";
|
|
8
8
|
export { type ApprovalFinding, approvalConfirmation, approvalFindings, argsHash, verifyConfirmation, } from "./approvals/index.ts";
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { A2A_STREAMING, a2aMethod, a2aRequestMeta, a2aResponseMeta, a2aRestMetho
|
|
|
4
4
|
export { causality, memoryXray } from "./agents/index.js";
|
|
5
5
|
export { detectors, fingerprint } from "./analysis/detectors.js";
|
|
6
6
|
export { FAULTS, faultOf } from "./analysis/faults.js";
|
|
7
|
-
export { analyze, answerClaims, answerCredential, answerRisk, answersOf, answerText, canonicalNumber, checkAgainstPacks, checkFlightPlan, checkpointReplay, detectorAccuracy, dualWitness, Evidence, eventsOf, factsIn, findingKey, groundingFindings, groundingRequest, HOLD_TRIGGERS, identifiersIn, judgeFindings, judgeRequest, landing, loadReferencePacks, modelGroundingFindings, normaliseValue, OUTCOMES, packsFor, parseGroundingAnswer, parseJudgeAnswer, referenceContext, rollup, schemaProblem, toolDrifted, toolHallucinations, verifyAnswerCredential, waste, wilsonLow, } from "./analysis/index.js";
|
|
7
|
+
export { analyze, answerClaims, answerCredential, answerRisk, answersOf, answerText, canonicalNumber, checkAgainstPacks, checkFlightPlan, checkpointReplay, detectorAccuracy, dualWitness, Evidence, eventsOf, factsIn, findingKey, groundingFindings, groundingRequest, HOLD_TRIGGERS, identifiersIn, judgeFindings, judgeRequest, landing, loadReferencePacks, modelGroundingFindings, normaliseValue, OUTCOMES, packsFor, parseGroundingAnswer, parseJudgeAnswer, referenceContext, rollup, schemaProblem, secretSent, toolDrifted, toolHallucinations, userDownvotes, verifyAnswerCredential, waste, wilsonLow, } from "./analysis/index.js";
|
|
8
8
|
export { injectionFindings, injectionRule } from "./analysis/injection.js";
|
|
9
9
|
export { MITRE_ATLAS, OWASP_ASI, TAXONOMY, taxonomyOf, } from "./analysis/taxonomy.js";
|
|
10
10
|
export { approvalConfirmation, approvalFindings, argsHash, verifyConfirmation, } from "./approvals/index.js";
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.18.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.18.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.18.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",
|