agent-inspect 6.31.34 → 6.31.36
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/docs/API.md +2 -2
- package/docs/CLI.md +1 -0
- package/docs/KNOWN-ISSUES.md +1 -0
- package/docs/LIMITATIONS.md +23 -0
- package/docs/SAFE-TRACE-SHARING.md +1 -1
- package/docs/SCHEMA.md +10 -1
- package/package.json +1 -1
- package/packages/cli/dist/{chunk-6TXW53UR.mjs → chunk-Z3WXP44D.mjs} +64 -7
- package/packages/cli/dist/chunk-Z3WXP44D.mjs.map +1 -0
- package/packages/cli/dist/index.cjs +64 -7
- package/packages/cli/dist/index.cjs.map +1 -1
- package/packages/cli/dist/index.mjs +4 -4
- package/packages/cli/dist/index.mjs.map +1 -1
- package/packages/cli/dist/{src-GCLC4DIC.mjs → src-LCUTRLRQ.mjs} +3 -3
- package/packages/cli/dist/{src-GCLC4DIC.mjs.map → src-LCUTRLRQ.mjs.map} +1 -1
- package/packages/core/dist/advanced.cjs +62 -5
- package/packages/core/dist/advanced.cjs.map +1 -1
- package/packages/core/dist/advanced.mjs +2 -2
- package/packages/core/dist/checks.cjs +62 -5
- package/packages/core/dist/checks.cjs.map +1 -1
- package/packages/core/dist/checks.mjs +1 -1
- package/packages/core/dist/{chunk-CXC7L4PY.mjs → chunk-KQX3Z4DH.mjs} +64 -7
- package/packages/core/dist/chunk-KQX3Z4DH.mjs.map +1 -0
- package/packages/cli/dist/chunk-6TXW53UR.mjs.map +0 -1
- package/packages/core/dist/chunk-CXC7L4PY.mjs.map +0 -1
|
@@ -5729,11 +5729,27 @@ function eventTimestamp(finding, eventById) {
|
|
|
5729
5729
|
const eventId = finding.evidence[0]?.eventId;
|
|
5730
5730
|
return eventId ? eventById.get(eventId)?.timestamp ?? "" : "";
|
|
5731
5731
|
}
|
|
5732
|
+
function isObservedToolPolicyFinding(finding) {
|
|
5733
|
+
return finding.ruleId === "tool.usage" && finding.evidence[0]?.eventId !== void 0;
|
|
5734
|
+
}
|
|
5735
|
+
function isMissingToolConsequenceFinding(finding) {
|
|
5736
|
+
if (finding.evidence[0]?.eventId !== void 0) return false;
|
|
5737
|
+
if (finding.ruleId === "tool.usage" && /did not appear/.test(finding.message)) {
|
|
5738
|
+
return true;
|
|
5739
|
+
}
|
|
5740
|
+
return finding.ruleId.startsWith("contract.tool.arguments") && /^No finished tool named /.test(finding.message);
|
|
5741
|
+
}
|
|
5732
5742
|
function compareFindings(eventById) {
|
|
5733
5743
|
return (a, b) => {
|
|
5734
5744
|
if (SEVERITY_RANK[a.severity] !== SEVERITY_RANK[b.severity]) {
|
|
5735
5745
|
return SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity];
|
|
5736
5746
|
}
|
|
5747
|
+
const aPolicy = isObservedToolPolicyFinding(a);
|
|
5748
|
+
const bPolicy = isObservedToolPolicyFinding(b);
|
|
5749
|
+
const aMissing = isMissingToolConsequenceFinding(a);
|
|
5750
|
+
const bMissing = isMissingToolConsequenceFinding(b);
|
|
5751
|
+
if (aPolicy && bMissing) return -1;
|
|
5752
|
+
if (bPolicy && aMissing) return 1;
|
|
5737
5753
|
const byRule = a.ruleId.localeCompare(b.ruleId);
|
|
5738
5754
|
if (byRule !== 0) return byRule;
|
|
5739
5755
|
if (STATUS_RANK[a.status] !== STATUS_RANK[b.status]) {
|
|
@@ -5869,20 +5885,42 @@ function failFinding(ruleId, message, evidence, expected, actual, meta2) {
|
|
|
5869
5885
|
function toolName(event) {
|
|
5870
5886
|
return resolveCanonicalToolName(event);
|
|
5871
5887
|
}
|
|
5888
|
+
function isAsciiLetterCodePoint(codePoint) {
|
|
5889
|
+
return codePoint >= 65 && codePoint <= 90 || codePoint >= 97 && codePoint <= 122;
|
|
5890
|
+
}
|
|
5891
|
+
function isRiskyToolNameCodePoint(codePoint) {
|
|
5892
|
+
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) return true;
|
|
5893
|
+
return codePoint === 1564 || codePoint === 8203 || codePoint === 8204 || codePoint === 8205 || codePoint === 8206 || codePoint === 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
|
|
5894
|
+
}
|
|
5895
|
+
function formatCodePointDetail(codePoint, index) {
|
|
5896
|
+
return `U+${codePoint.toString(16).toUpperCase().padStart(4, "0")} at index ${index}`;
|
|
5897
|
+
}
|
|
5872
5898
|
function formatToolNameForMessage(name) {
|
|
5899
|
+
let hasAsciiLetter = false;
|
|
5900
|
+
let hasNonAscii = false;
|
|
5901
|
+
let hasRisky = false;
|
|
5873
5902
|
const details = [];
|
|
5874
5903
|
for (let index = 0; index < name.length; ) {
|
|
5875
5904
|
const codePoint = name.codePointAt(index);
|
|
5876
5905
|
const width = codePoint > 65535 ? 2 : 1;
|
|
5906
|
+
if (isAsciiLetterCodePoint(codePoint)) hasAsciiLetter = true;
|
|
5907
|
+
const risky = isRiskyToolNameCodePoint(codePoint);
|
|
5908
|
+
if (risky) hasRisky = true;
|
|
5877
5909
|
if (codePoint > 127) {
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5910
|
+
hasNonAscii = true;
|
|
5911
|
+
details.push(formatCodePointDetail(codePoint, index));
|
|
5912
|
+
} else if (risky) {
|
|
5913
|
+
details.push(formatCodePointDetail(codePoint, index));
|
|
5881
5914
|
}
|
|
5882
5915
|
index += width;
|
|
5883
5916
|
}
|
|
5884
|
-
if (details.length === 0)
|
|
5885
|
-
|
|
5917
|
+
if (!hasRisky && !(hasAsciiLetter && hasNonAscii) || details.length === 0) {
|
|
5918
|
+
return name;
|
|
5919
|
+
}
|
|
5920
|
+
const shown = details.slice(0, MAX_TOOL_NAME_CODEPOINT_DETAILS);
|
|
5921
|
+
const remaining = details.length - shown.length;
|
|
5922
|
+
const detailText = remaining > 0 ? `${shown.join("; ")}; and ${remaining} more` : shown.join("; ");
|
|
5923
|
+
return `"${name}" (contains ${detailText})`;
|
|
5886
5924
|
}
|
|
5887
5925
|
function describeRunningEvent(event) {
|
|
5888
5926
|
if (event.kind === "TOOL") {
|
|
@@ -6827,6 +6865,9 @@ function createToolFailureRule(options) {
|
|
|
6827
6865
|
}
|
|
6828
6866
|
};
|
|
6829
6867
|
}
|
|
6868
|
+
function recordsTokenUsage(event) {
|
|
6869
|
+
return Object.values(event.tokenUsage ?? {}).some((count) => typeof count === "number");
|
|
6870
|
+
}
|
|
6830
6871
|
function createLlmUsageRule(options) {
|
|
6831
6872
|
return {
|
|
6832
6873
|
id: "llm.usage",
|
|
@@ -6884,6 +6925,21 @@ function createLlmUsageRule(options) {
|
|
|
6884
6925
|
["total", options.maxTotalTokens],
|
|
6885
6926
|
["cached", options.maxCachedTokens]
|
|
6886
6927
|
];
|
|
6928
|
+
const hasTokenLimit = tokenLimits.some(([, limit]) => limit !== void 0);
|
|
6929
|
+
const callsWithoutUsage = llms.filter(
|
|
6930
|
+
(event) => event.status !== "error" && !recordsTokenUsage(event)
|
|
6931
|
+
);
|
|
6932
|
+
if (hasTokenLimit && callsWithoutUsage.length > 0) {
|
|
6933
|
+
findings.push(
|
|
6934
|
+
failFinding(
|
|
6935
|
+
"llm.usage",
|
|
6936
|
+
`No token usage was read for ${callsWithoutUsage.length} of ${llms.length} LLM call(s), so the token limit cannot be verified.`,
|
|
6937
|
+
callsWithoutUsage.map((event) => eventEvidence(event, "tokenUsage")),
|
|
6938
|
+
"token usage on every completed LLM call",
|
|
6939
|
+
{ callsWithoutUsage: callsWithoutUsage.length, calls: llms.length }
|
|
6940
|
+
)
|
|
6941
|
+
);
|
|
6942
|
+
}
|
|
6887
6943
|
for (const [key, limit] of tokenLimits) {
|
|
6888
6944
|
if (limit !== void 0 && tokenTotals[key] > limit) {
|
|
6889
6945
|
findings.push(
|
|
@@ -7609,7 +7665,7 @@ function runTraceChecks(input3, options = {}) {
|
|
|
7609
7665
|
ruleExecutions
|
|
7610
7666
|
};
|
|
7611
7667
|
}
|
|
7612
|
-
var SEVERITY_RANK, STATUS_RANK, CONFIDENCE_RANK, DEFAULT_SENSITIVE_KEYS, DEFAULT_RAW_CONTENT_KEYS, DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES, SAFE_USAGE_LEAF_KEYS, DEFAULT_SECRET_PATTERNS;
|
|
7668
|
+
var SEVERITY_RANK, STATUS_RANK, CONFIDENCE_RANK, DEFAULT_SENSITIVE_KEYS, DEFAULT_RAW_CONTENT_KEYS, DEFAULT_SAFE_RAW_CONTENT_PATH_PREFIXES, SAFE_USAGE_LEAF_KEYS, DEFAULT_SECRET_PATTERNS, MAX_TOOL_NAME_CODEPOINT_DETAILS;
|
|
7613
7669
|
var init_checks2 = __esm({
|
|
7614
7670
|
"packages/core/src/checks/index.ts"() {
|
|
7615
7671
|
init_inspect_event();
|
|
@@ -7713,6 +7769,7 @@ var init_checks2 = __esm({
|
|
|
7713
7769
|
pattern: /\b(?:api[_-]?key|internal[_-]?token|access[_-]?token|auth[_-]?token|password|secret|token)=(?!\[(?:REDACTED|HASH:(?:[0-9a-f]{8}|unknown))\](?![^\s"'\\&#?]))([^\s"'\\]{8,})/i
|
|
7714
7770
|
}
|
|
7715
7771
|
];
|
|
7772
|
+
MAX_TOOL_NAME_CODEPOINT_DETAILS = 3;
|
|
7716
7773
|
}
|
|
7717
7774
|
});
|
|
7718
7775
|
|
|
@@ -17479,7 +17536,7 @@ var init_src = __esm({
|
|
|
17479
17536
|
});
|
|
17480
17537
|
|
|
17481
17538
|
// package.json
|
|
17482
|
-
var version = "6.31.
|
|
17539
|
+
var version = "6.31.36";
|
|
17483
17540
|
|
|
17484
17541
|
// packages/cli/src/list.ts
|
|
17485
17542
|
init_advanced();
|