@agent-inspect/viewer 6.31.34 → 6.31.35
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/index.cjs +44 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +44 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2216,11 +2216,27 @@ function eventTimestamp(finding, eventById) {
|
|
|
2216
2216
|
const eventId = finding.evidence[0]?.eventId;
|
|
2217
2217
|
return eventId ? eventById.get(eventId)?.timestamp ?? "" : "";
|
|
2218
2218
|
}
|
|
2219
|
+
function isObservedToolPolicyFinding(finding) {
|
|
2220
|
+
return finding.ruleId === "tool.usage" && finding.evidence[0]?.eventId !== void 0;
|
|
2221
|
+
}
|
|
2222
|
+
function isMissingToolConsequenceFinding(finding) {
|
|
2223
|
+
if (finding.evidence[0]?.eventId !== void 0) return false;
|
|
2224
|
+
if (finding.ruleId === "tool.usage" && /did not appear/.test(finding.message)) {
|
|
2225
|
+
return true;
|
|
2226
|
+
}
|
|
2227
|
+
return finding.ruleId.startsWith("contract.tool.arguments") && /^No finished tool named /.test(finding.message);
|
|
2228
|
+
}
|
|
2219
2229
|
function compareFindings(eventById) {
|
|
2220
2230
|
return (a, b) => {
|
|
2221
2231
|
if (SEVERITY_RANK[a.severity] !== SEVERITY_RANK[b.severity]) {
|
|
2222
2232
|
return SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity];
|
|
2223
2233
|
}
|
|
2234
|
+
const aPolicy = isObservedToolPolicyFinding(a);
|
|
2235
|
+
const bPolicy = isObservedToolPolicyFinding(b);
|
|
2236
|
+
const aMissing = isMissingToolConsequenceFinding(a);
|
|
2237
|
+
const bMissing = isMissingToolConsequenceFinding(b);
|
|
2238
|
+
if (aPolicy && bMissing) return -1;
|
|
2239
|
+
if (bPolicy && aMissing) return 1;
|
|
2224
2240
|
const byRule = a.ruleId.localeCompare(b.ruleId);
|
|
2225
2241
|
if (byRule !== 0) return byRule;
|
|
2226
2242
|
if (STATUS_RANK[a.status] !== STATUS_RANK[b.status]) {
|
|
@@ -2349,20 +2365,43 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
|
|
|
2349
2365
|
function toolName(event) {
|
|
2350
2366
|
return resolveCanonicalToolName(event);
|
|
2351
2367
|
}
|
|
2368
|
+
var MAX_TOOL_NAME_CODEPOINT_DETAILS = 3;
|
|
2369
|
+
function isAsciiLetterCodePoint(codePoint) {
|
|
2370
|
+
return codePoint >= 65 && codePoint <= 90 || codePoint >= 97 && codePoint <= 122;
|
|
2371
|
+
}
|
|
2372
|
+
function isRiskyToolNameCodePoint(codePoint) {
|
|
2373
|
+
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) return true;
|
|
2374
|
+
return codePoint === 1564 || codePoint === 8203 || codePoint === 8204 || codePoint === 8205 || codePoint === 8206 || codePoint === 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
|
|
2375
|
+
}
|
|
2376
|
+
function formatCodePointDetail(codePoint, index) {
|
|
2377
|
+
return `U+${codePoint.toString(16).toUpperCase().padStart(4, "0")} at index ${index}`;
|
|
2378
|
+
}
|
|
2352
2379
|
function formatToolNameForMessage(name) {
|
|
2380
|
+
let hasAsciiLetter = false;
|
|
2381
|
+
let hasNonAscii = false;
|
|
2382
|
+
let hasRisky = false;
|
|
2353
2383
|
const details = [];
|
|
2354
2384
|
for (let index = 0; index < name.length; ) {
|
|
2355
2385
|
const codePoint = name.codePointAt(index);
|
|
2356
2386
|
const width = codePoint > 65535 ? 2 : 1;
|
|
2387
|
+
if (isAsciiLetterCodePoint(codePoint)) hasAsciiLetter = true;
|
|
2388
|
+
const risky = isRiskyToolNameCodePoint(codePoint);
|
|
2389
|
+
if (risky) hasRisky = true;
|
|
2357
2390
|
if (codePoint > 127) {
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2391
|
+
hasNonAscii = true;
|
|
2392
|
+
details.push(formatCodePointDetail(codePoint, index));
|
|
2393
|
+
} else if (risky) {
|
|
2394
|
+
details.push(formatCodePointDetail(codePoint, index));
|
|
2361
2395
|
}
|
|
2362
2396
|
index += width;
|
|
2363
2397
|
}
|
|
2364
|
-
if (details.length === 0)
|
|
2365
|
-
|
|
2398
|
+
if (!hasRisky && !(hasAsciiLetter && hasNonAscii) || details.length === 0) {
|
|
2399
|
+
return name;
|
|
2400
|
+
}
|
|
2401
|
+
const shown = details.slice(0, MAX_TOOL_NAME_CODEPOINT_DETAILS);
|
|
2402
|
+
const remaining = details.length - shown.length;
|
|
2403
|
+
const detailText = remaining > 0 ? `${shown.join("; ")}; and ${remaining} more` : shown.join("; ");
|
|
2404
|
+
return `"${name}" (contains ${detailText})`;
|
|
2366
2405
|
}
|
|
2367
2406
|
function describeRunningEvent(event) {
|
|
2368
2407
|
if (event.kind === "TOOL") {
|