@agent-inspect/mcp-server 6.31.33 → 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/cli.cjs CHANGED
@@ -226,8 +226,9 @@ var HIGH_CONFIDENCE_CREDENTIAL_PATTERNS = [
226
226
  /\beyJ[a-zA-Z0-9_-]{8,}\.[a-zA-Z0-9_-]{8,}\.[a-zA-Z0-9_-]{8,}\b/,
227
227
  /\b(?:sk-(?:proj-)?[a-zA-Z0-9_-]{16,}|sk-ant-[a-zA-Z0-9_-]{16,}|AIza[0-9A-Za-z_-]{20,})\b/,
228
228
  // Stripe secret / restricted keys use underscores (not sk-). Keep in sync with
229
- // packages/redact/src/index.ts + packages/core/src/checks DEFAULT_SECRET_PATTERNS (#520).
230
- /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/,
229
+ // packages/redact/src/index.ts + packages/core/src/checks DEFAULT_SECRET_PATTERNS (#520/#528).
230
+ // Use non-alnum lookarounds so underscore-adjacent forms (acct_sk_live_…, …_eu) match.
231
+ /(?<![A-Za-z0-9])(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}(?![A-Za-z0-9])/,
231
232
  /\bxox[abposr]-[A-Za-z0-9-]{10,}\b/,
232
233
  /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{20,}\b/,
233
234
  /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,
@@ -3425,10 +3426,11 @@ var SAFE_USAGE_LEAF_KEYS = /* @__PURE__ */ new Set([
3425
3426
  var DEFAULT_SECRET_PATTERNS = [
3426
3427
  { id: "bearer-token", pattern: /Bearer\s+[A-Za-z0-9._~+/-]{12,}=*/ },
3427
3428
  { id: "openai-key", pattern: /sk-[A-Za-z0-9_-]{16,}/ },
3428
- // Stripe + Slack: keep in sync with packages/redact + credential-value-patterns (#520).
3429
+ // Stripe + Slack: keep in sync with packages/redact + credential-value-patterns (#520/#528).
3430
+ // Non-alnum lookarounds so underscore-adjacent forms (acct_sk_live_…, …_eu) match.
3429
3431
  {
3430
3432
  id: "stripe-key",
3431
- pattern: /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/
3433
+ pattern: /(?<![A-Za-z0-9])(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}(?![A-Za-z0-9])/
3432
3434
  },
3433
3435
  { id: "slack-token", pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}\b/ },
3434
3436
  { id: "aws-access-key", pattern: /AKIA[0-9A-Z]{16}/ },
@@ -3602,11 +3604,27 @@ function eventTimestamp(finding, eventById) {
3602
3604
  const eventId = finding.evidence[0]?.eventId;
3603
3605
  return eventId ? eventById.get(eventId)?.timestamp ?? "" : "";
3604
3606
  }
3607
+ function isObservedToolPolicyFinding(finding) {
3608
+ return finding.ruleId === "tool.usage" && finding.evidence[0]?.eventId !== void 0;
3609
+ }
3610
+ function isMissingToolConsequenceFinding(finding) {
3611
+ if (finding.evidence[0]?.eventId !== void 0) return false;
3612
+ if (finding.ruleId === "tool.usage" && /did not appear/.test(finding.message)) {
3613
+ return true;
3614
+ }
3615
+ return finding.ruleId.startsWith("contract.tool.arguments") && /^No finished tool named /.test(finding.message);
3616
+ }
3605
3617
  function compareFindings(eventById) {
3606
3618
  return (a, b) => {
3607
3619
  if (SEVERITY_RANK[a.severity] !== SEVERITY_RANK[b.severity]) {
3608
3620
  return SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity];
3609
3621
  }
3622
+ const aPolicy = isObservedToolPolicyFinding(a);
3623
+ const bPolicy = isObservedToolPolicyFinding(b);
3624
+ const aMissing = isMissingToolConsequenceFinding(a);
3625
+ const bMissing = isMissingToolConsequenceFinding(b);
3626
+ if (aPolicy && bMissing) return -1;
3627
+ if (bPolicy && aMissing) return 1;
3610
3628
  const byRule = a.ruleId.localeCompare(b.ruleId);
3611
3629
  if (byRule !== 0) return byRule;
3612
3630
  if (STATUS_RANK[a.status] !== STATUS_RANK[b.status]) {
@@ -3700,20 +3718,43 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
3700
3718
  ...meta?.action !== void 0 ? { action: meta.action } : {}
3701
3719
  };
3702
3720
  }
3721
+ var MAX_TOOL_NAME_CODEPOINT_DETAILS = 3;
3722
+ function isAsciiLetterCodePoint(codePoint) {
3723
+ return codePoint >= 65 && codePoint <= 90 || codePoint >= 97 && codePoint <= 122;
3724
+ }
3725
+ function isRiskyToolNameCodePoint(codePoint) {
3726
+ if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) return true;
3727
+ return codePoint === 1564 || codePoint === 8203 || codePoint === 8204 || codePoint === 8205 || codePoint === 8206 || codePoint === 8207 || codePoint >= 8234 && codePoint <= 8238 || codePoint >= 8294 && codePoint <= 8297 || codePoint === 65279;
3728
+ }
3729
+ function formatCodePointDetail(codePoint, index) {
3730
+ return `U+${codePoint.toString(16).toUpperCase().padStart(4, "0")} at index ${index}`;
3731
+ }
3703
3732
  function formatToolNameForMessage(name) {
3733
+ let hasAsciiLetter = false;
3734
+ let hasNonAscii = false;
3735
+ let hasRisky = false;
3704
3736
  const details = [];
3705
3737
  for (let index = 0; index < name.length; ) {
3706
3738
  const codePoint = name.codePointAt(index);
3707
3739
  const width = codePoint > 65535 ? 2 : 1;
3740
+ if (isAsciiLetterCodePoint(codePoint)) hasAsciiLetter = true;
3741
+ const risky = isRiskyToolNameCodePoint(codePoint);
3742
+ if (risky) hasRisky = true;
3708
3743
  if (codePoint > 127) {
3709
- details.push(
3710
- `U+${codePoint.toString(16).toUpperCase().padStart(4, "0")} at index ${index}`
3711
- );
3744
+ hasNonAscii = true;
3745
+ details.push(formatCodePointDetail(codePoint, index));
3746
+ } else if (risky) {
3747
+ details.push(formatCodePointDetail(codePoint, index));
3712
3748
  }
3713
3749
  index += width;
3714
3750
  }
3715
- if (details.length === 0) return name;
3716
- return `"${name}" (contains ${details.join("; ")})`;
3751
+ if (!hasRisky && !(hasAsciiLetter && hasNonAscii) || details.length === 0) {
3752
+ return name;
3753
+ }
3754
+ const shown = details.slice(0, MAX_TOOL_NAME_CODEPOINT_DETAILS);
3755
+ const remaining = details.length - shown.length;
3756
+ const detailText = remaining > 0 ? `${shown.join("; ")}; and ${remaining} more` : shown.join("; ");
3757
+ return `"${name}" (contains ${detailText})`;
3717
3758
  }
3718
3759
  function describeRunningEvent(event) {
3719
3760
  if (event.kind === "TOOL") {
@@ -7575,11 +7616,25 @@ function attemptIdOf(event) {
7575
7616
  }
7576
7617
  return void 0;
7577
7618
  }
7619
+ function operationIdOf(event) {
7620
+ const direct = event.attributes?.operationId;
7621
+ if (typeof direct === "string" && direct.trim() !== "") return direct;
7622
+ const meta = event.attributes?.metadata;
7623
+ if (meta && typeof meta === "object" && !Array.isArray(meta)) {
7624
+ const nested = meta.operationId;
7625
+ if (typeof nested === "string" && nested.trim() !== "") return nested;
7626
+ }
7627
+ return void 0;
7628
+ }
7578
7629
  function lifecycleKey(event) {
7579
7630
  if (event.kind === "RUN") return `run:${event.runId}`;
7580
7631
  const stepId = stepIdOf2(event);
7581
- if (stepId !== void 0) return `step:${stepId}`;
7582
- return `event:${event.eventId}`;
7632
+ if (stepId === void 0) return `event:${event.eventId}`;
7633
+ const attemptId = attemptIdOf(event);
7634
+ if (attemptId !== void 0) return `step:${stepId}:attempt:${attemptId}`;
7635
+ const operationId = operationIdOf(event);
7636
+ if (operationId !== void 0) return `step:${stepId}:op:${operationId}`;
7637
+ return `step:${stepId}`;
7583
7638
  }
7584
7639
  function isTerminal(status) {
7585
7640
  return status === "ok" || status === "error";
@@ -7630,6 +7685,12 @@ function joinSiblingGroup(group) {
7630
7685
  const others = group.filter(
7631
7686
  (n) => !isTerminal(n.event.status) && n.event.status !== "running"
7632
7687
  );
7688
+ const operationIds = new Set(
7689
+ group.map((n) => operationIdOf(n.event)).filter((id) => id !== void 0)
7690
+ );
7691
+ if (operationIds.size > 1) {
7692
+ return group;
7693
+ }
7633
7694
  const terminalStatuses = new Set(terminals.map((n) => n.event.status));
7634
7695
  if (terminalStatuses.size > 1) {
7635
7696
  return group;
@@ -7641,19 +7702,22 @@ function joinSiblingGroup(group) {
7641
7702
  const out = [];
7642
7703
  for (const terminal of terminals) {
7643
7704
  const terminalAttempt = attemptIdOf(terminal.event);
7705
+ const terminalOp = operationIdOf(terminal.event);
7644
7706
  const terminalTs = eventTime(terminal.event);
7645
- const candidate = runnings.find((r) => {
7707
+ const candidates = runnings.filter((r) => {
7646
7708
  if (usedRunning.has(r.event.eventId)) return false;
7647
7709
  if (eventTime(r.event) > terminalTs) return false;
7710
+ const runningOp = operationIdOf(r.event);
7711
+ if (terminalOp !== void 0 && runningOp !== void 0 && terminalOp !== runningOp) {
7712
+ return false;
7713
+ }
7648
7714
  const runningAttempt = attemptIdOf(r.event);
7649
7715
  if (terminalAttempt !== void 0) {
7650
7716
  return runningAttempt === terminalAttempt;
7651
7717
  }
7652
- if (runningAttempt !== void 0) {
7653
- return true;
7654
- }
7655
- return true;
7718
+ return runningAttempt === void 0;
7656
7719
  });
7720
+ const candidate = candidates.length === 1 ? candidates[0] : void 0;
7657
7721
  if (candidate) {
7658
7722
  usedRunning.add(candidate.event.eventId);
7659
7723
  out.push(joinOnePair(candidate, terminal));
@@ -8826,10 +8890,11 @@ var credentialDetectors = [
8826
8890
  severity: "error"
8827
8891
  }),
8828
8892
  // Stripe secret/restricted keys (underscore form). Keep in sync with
8829
- // packages/core/src/safety/credential-value-patterns.ts + checks DEFAULT_SECRET_PATTERNS (#520).
8893
+ // packages/core/src/safety/credential-value-patterns.ts + checks DEFAULT_SECRET_PATTERNS (#520/#528).
8894
+ // Non-alnum lookarounds so underscore-adjacent forms (acct_sk_live_…, …_eu) match.
8830
8895
  patternDetector({
8831
8896
  id: "value.stripeSecretKey",
8832
- pattern: /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/,
8897
+ pattern: /(?<![A-Za-z0-9])(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}(?![A-Za-z0-9])/,
8833
8898
  severity: "error"
8834
8899
  }),
8835
8900
  patternDetector({