@agent-inspect/mcp-server 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.
@@ -3594,11 +3594,27 @@ function eventTimestamp(finding, eventById) {
3594
3594
  const eventId = finding.evidence[0]?.eventId;
3595
3595
  return eventId ? eventById.get(eventId)?.timestamp ?? "" : "";
3596
3596
  }
3597
+ function isObservedToolPolicyFinding(finding) {
3598
+ return finding.ruleId === "tool.usage" && finding.evidence[0]?.eventId !== void 0;
3599
+ }
3600
+ function isMissingToolConsequenceFinding(finding) {
3601
+ if (finding.evidence[0]?.eventId !== void 0) return false;
3602
+ if (finding.ruleId === "tool.usage" && /did not appear/.test(finding.message)) {
3603
+ return true;
3604
+ }
3605
+ return finding.ruleId.startsWith("contract.tool.arguments") && /^No finished tool named /.test(finding.message);
3606
+ }
3597
3607
  function compareFindings(eventById) {
3598
3608
  return (a, b) => {
3599
3609
  if (SEVERITY_RANK[a.severity] !== SEVERITY_RANK[b.severity]) {
3600
3610
  return SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity];
3601
3611
  }
3612
+ const aPolicy = isObservedToolPolicyFinding(a);
3613
+ const bPolicy = isObservedToolPolicyFinding(b);
3614
+ const aMissing = isMissingToolConsequenceFinding(a);
3615
+ const bMissing = isMissingToolConsequenceFinding(b);
3616
+ if (aPolicy && bMissing) return -1;
3617
+ if (bPolicy && aMissing) return 1;
3602
3618
  const byRule = a.ruleId.localeCompare(b.ruleId);
3603
3619
  if (byRule !== 0) return byRule;
3604
3620
  if (STATUS_RANK[a.status] !== STATUS_RANK[b.status]) {
@@ -3692,20 +3708,43 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
3692
3708
  ...meta?.action !== void 0 ? { action: meta.action } : {}
3693
3709
  };
3694
3710
  }
3711
+ var MAX_TOOL_NAME_CODEPOINT_DETAILS = 3;
3712
+ function isAsciiLetterCodePoint(codePoint) {
3713
+ return codePoint >= 65 && codePoint <= 90 || codePoint >= 97 && codePoint <= 122;
3714
+ }
3715
+ function isRiskyToolNameCodePoint(codePoint) {
3716
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) return true;
3717
+ return codePoint === 1564 || codePoint === 8203 || codePoint === 8204 || codePoint === 8205 || codePoint === 8206 || codePoint === 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
3718
+ }
3719
+ function formatCodePointDetail(codePoint, index) {
3720
+ return `U+${codePoint.toString(16).toUpperCase().padStart(4, "0")} at index ${index}`;
3721
+ }
3695
3722
  function formatToolNameForMessage(name) {
3723
+ let hasAsciiLetter = false;
3724
+ let hasNonAscii = false;
3725
+ let hasRisky = false;
3696
3726
  const details = [];
3697
3727
  for (let index = 0; index < name.length; ) {
3698
3728
  const codePoint = name.codePointAt(index);
3699
3729
  const width = codePoint > 65535 ? 2 : 1;
3730
+ if (isAsciiLetterCodePoint(codePoint)) hasAsciiLetter = true;
3731
+ const risky = isRiskyToolNameCodePoint(codePoint);
3732
+ if (risky) hasRisky = true;
3700
3733
  if (codePoint > 127) {
3701
- details.push(
3702
- `U+${codePoint.toString(16).toUpperCase().padStart(4, "0")} at index ${index}`
3703
- );
3734
+ hasNonAscii = true;
3735
+ details.push(formatCodePointDetail(codePoint, index));
3736
+ } else if (risky) {
3737
+ details.push(formatCodePointDetail(codePoint, index));
3704
3738
  }
3705
3739
  index += width;
3706
3740
  }
3707
- if (details.length === 0) return name;
3708
- return `"${name}" (contains ${details.join("; ")})`;
3741
+ if (!hasRisky && !(hasAsciiLetter && hasNonAscii) || details.length === 0) {
3742
+ return name;
3743
+ }
3744
+ const shown = details.slice(0, MAX_TOOL_NAME_CODEPOINT_DETAILS);
3745
+ const remaining = details.length - shown.length;
3746
+ const detailText = remaining > 0 ? `${shown.join("; ")}; and ${remaining} more` : shown.join("; ");
3747
+ return `"${name}" (contains ${detailText})`;
3709
3748
  }
3710
3749
  function describeRunningEvent(event) {
3711
3750
  if (event.kind === "TOOL") {
@@ -10065,5 +10104,5 @@ async function runReadOnlyMcpServer(options = {}) {
10065
10104
  }
10066
10105
 
10067
10106
  export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
10068
- //# sourceMappingURL=chunk-LRBX7VWN.mjs.map
10069
- //# sourceMappingURL=chunk-LRBX7VWN.mjs.map
10107
+ //# sourceMappingURL=chunk-4U73PORF.mjs.map
10108
+ //# sourceMappingURL=chunk-4U73PORF.mjs.map