@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.
@@ -216,8 +216,9 @@ var HIGH_CONFIDENCE_CREDENTIAL_PATTERNS = [
216
216
  /\beyJ[a-zA-Z0-9_-]{8,}\.[a-zA-Z0-9_-]{8,}\.[a-zA-Z0-9_-]{8,}\b/,
217
217
  /\b(?:sk-(?:proj-)?[a-zA-Z0-9_-]{16,}|sk-ant-[a-zA-Z0-9_-]{16,}|AIza[0-9A-Za-z_-]{20,})\b/,
218
218
  // Stripe secret / restricted keys use underscores (not sk-). Keep in sync with
219
- // packages/redact/src/index.ts + packages/core/src/checks DEFAULT_SECRET_PATTERNS (#520).
220
- /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/,
219
+ // packages/redact/src/index.ts + packages/core/src/checks DEFAULT_SECRET_PATTERNS (#520/#528).
220
+ // Use non-alnum lookarounds so underscore-adjacent forms (acct_sk_live_…, …_eu) match.
221
+ /(?<![A-Za-z0-9])(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}(?![A-Za-z0-9])/,
221
222
  /\bxox[abposr]-[A-Za-z0-9-]{10,}\b/,
222
223
  /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{20,}\b/,
223
224
  /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,
@@ -3415,10 +3416,11 @@ var SAFE_USAGE_LEAF_KEYS = /* @__PURE__ */ new Set([
3415
3416
  var DEFAULT_SECRET_PATTERNS = [
3416
3417
  { id: "bearer-token", pattern: /Bearer\s+[A-Za-z0-9._~+/-]{12,}=*/ },
3417
3418
  { id: "openai-key", pattern: /sk-[A-Za-z0-9_-]{16,}/ },
3418
- // Stripe + Slack: keep in sync with packages/redact + credential-value-patterns (#520).
3419
+ // Stripe + Slack: keep in sync with packages/redact + credential-value-patterns (#520/#528).
3420
+ // Non-alnum lookarounds so underscore-adjacent forms (acct_sk_live_…, …_eu) match.
3419
3421
  {
3420
3422
  id: "stripe-key",
3421
- pattern: /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/
3423
+ pattern: /(?<![A-Za-z0-9])(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}(?![A-Za-z0-9])/
3422
3424
  },
3423
3425
  { id: "slack-token", pattern: /\bxox[abposr]-[A-Za-z0-9-]{10,}\b/ },
3424
3426
  { id: "aws-access-key", pattern: /AKIA[0-9A-Z]{16}/ },
@@ -3592,11 +3594,27 @@ function eventTimestamp(finding, eventById) {
3592
3594
  const eventId = finding.evidence[0]?.eventId;
3593
3595
  return eventId ? eventById.get(eventId)?.timestamp ?? "" : "";
3594
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
+ }
3595
3607
  function compareFindings(eventById) {
3596
3608
  return (a, b) => {
3597
3609
  if (SEVERITY_RANK[a.severity] !== SEVERITY_RANK[b.severity]) {
3598
3610
  return SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity];
3599
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;
3600
3618
  const byRule = a.ruleId.localeCompare(b.ruleId);
3601
3619
  if (byRule !== 0) return byRule;
3602
3620
  if (STATUS_RANK[a.status] !== STATUS_RANK[b.status]) {
@@ -3690,20 +3708,43 @@ function failFinding(ruleId, message, evidence, expected, actual, meta) {
3690
3708
  ...meta?.action !== void 0 ? { action: meta.action } : {}
3691
3709
  };
3692
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
+ }
3693
3722
  function formatToolNameForMessage(name) {
3723
+ let hasAsciiLetter = false;
3724
+ let hasNonAscii = false;
3725
+ let hasRisky = false;
3694
3726
  const details = [];
3695
3727
  for (let index = 0; index < name.length; ) {
3696
3728
  const codePoint = name.codePointAt(index);
3697
3729
  const width = codePoint > 65535 ? 2 : 1;
3730
+ if (isAsciiLetterCodePoint(codePoint)) hasAsciiLetter = true;
3731
+ const risky = isRiskyToolNameCodePoint(codePoint);
3732
+ if (risky) hasRisky = true;
3698
3733
  if (codePoint > 127) {
3699
- details.push(
3700
- `U+${codePoint.toString(16).toUpperCase().padStart(4, "0")} at index ${index}`
3701
- );
3734
+ hasNonAscii = true;
3735
+ details.push(formatCodePointDetail(codePoint, index));
3736
+ } else if (risky) {
3737
+ details.push(formatCodePointDetail(codePoint, index));
3702
3738
  }
3703
3739
  index += width;
3704
3740
  }
3705
- if (details.length === 0) return name;
3706
- 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})`;
3707
3748
  }
3708
3749
  function describeRunningEvent(event) {
3709
3750
  if (event.kind === "TOOL") {
@@ -7565,11 +7606,25 @@ function attemptIdOf(event) {
7565
7606
  }
7566
7607
  return void 0;
7567
7608
  }
7609
+ function operationIdOf(event) {
7610
+ const direct = event.attributes?.operationId;
7611
+ if (typeof direct === "string" && direct.trim() !== "") return direct;
7612
+ const meta = event.attributes?.metadata;
7613
+ if (meta && typeof meta === "object" && !Array.isArray(meta)) {
7614
+ const nested = meta.operationId;
7615
+ if (typeof nested === "string" && nested.trim() !== "") return nested;
7616
+ }
7617
+ return void 0;
7618
+ }
7568
7619
  function lifecycleKey(event) {
7569
7620
  if (event.kind === "RUN") return `run:${event.runId}`;
7570
7621
  const stepId = stepIdOf2(event);
7571
- if (stepId !== void 0) return `step:${stepId}`;
7572
- return `event:${event.eventId}`;
7622
+ if (stepId === void 0) return `event:${event.eventId}`;
7623
+ const attemptId = attemptIdOf(event);
7624
+ if (attemptId !== void 0) return `step:${stepId}:attempt:${attemptId}`;
7625
+ const operationId = operationIdOf(event);
7626
+ if (operationId !== void 0) return `step:${stepId}:op:${operationId}`;
7627
+ return `step:${stepId}`;
7573
7628
  }
7574
7629
  function isTerminal(status) {
7575
7630
  return status === "ok" || status === "error";
@@ -7620,6 +7675,12 @@ function joinSiblingGroup(group) {
7620
7675
  const others = group.filter(
7621
7676
  (n) => !isTerminal(n.event.status) && n.event.status !== "running"
7622
7677
  );
7678
+ const operationIds = new Set(
7679
+ group.map((n) => operationIdOf(n.event)).filter((id) => id !== void 0)
7680
+ );
7681
+ if (operationIds.size > 1) {
7682
+ return group;
7683
+ }
7623
7684
  const terminalStatuses = new Set(terminals.map((n) => n.event.status));
7624
7685
  if (terminalStatuses.size > 1) {
7625
7686
  return group;
@@ -7631,19 +7692,22 @@ function joinSiblingGroup(group) {
7631
7692
  const out = [];
7632
7693
  for (const terminal of terminals) {
7633
7694
  const terminalAttempt = attemptIdOf(terminal.event);
7695
+ const terminalOp = operationIdOf(terminal.event);
7634
7696
  const terminalTs = eventTime(terminal.event);
7635
- const candidate = runnings.find((r) => {
7697
+ const candidates = runnings.filter((r) => {
7636
7698
  if (usedRunning.has(r.event.eventId)) return false;
7637
7699
  if (eventTime(r.event) > terminalTs) return false;
7700
+ const runningOp = operationIdOf(r.event);
7701
+ if (terminalOp !== void 0 && runningOp !== void 0 && terminalOp !== runningOp) {
7702
+ return false;
7703
+ }
7638
7704
  const runningAttempt = attemptIdOf(r.event);
7639
7705
  if (terminalAttempt !== void 0) {
7640
7706
  return runningAttempt === terminalAttempt;
7641
7707
  }
7642
- if (runningAttempt !== void 0) {
7643
- return true;
7644
- }
7645
- return true;
7708
+ return runningAttempt === void 0;
7646
7709
  });
7710
+ const candidate = candidates.length === 1 ? candidates[0] : void 0;
7647
7711
  if (candidate) {
7648
7712
  usedRunning.add(candidate.event.eventId);
7649
7713
  out.push(joinOnePair(candidate, terminal));
@@ -8816,10 +8880,11 @@ var credentialDetectors = [
8816
8880
  severity: "error"
8817
8881
  }),
8818
8882
  // Stripe secret/restricted keys (underscore form). Keep in sync with
8819
- // packages/core/src/safety/credential-value-patterns.ts + checks DEFAULT_SECRET_PATTERNS (#520).
8883
+ // packages/core/src/safety/credential-value-patterns.ts + checks DEFAULT_SECRET_PATTERNS (#520/#528).
8884
+ // Non-alnum lookarounds so underscore-adjacent forms (acct_sk_live_…, …_eu) match.
8820
8885
  patternDetector({
8821
8886
  id: "value.stripeSecretKey",
8822
- pattern: /\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b/,
8887
+ pattern: /(?<![A-Za-z0-9])(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,}(?![A-Za-z0-9])/,
8823
8888
  severity: "error"
8824
8889
  }),
8825
8890
  patternDetector({
@@ -10039,5 +10104,5 @@ async function runReadOnlyMcpServer(options = {}) {
10039
10104
  }
10040
10105
 
10041
10106
  export { MCP_MAX_REQUEST_BYTES, MCP_PROTOCOL_VERSION, MCP_SERVER_INSTRUCTIONS, READ_ONLY_TOOLS, TRACE_DATA_UNTRUSTED_WARNING, callReadOnlyTool, createMcpServerContext, handleMcpProtocolLine, runReadOnlyMcpServer };
10042
- //# sourceMappingURL=chunk-B7FCFNLA.mjs.map
10043
- //# sourceMappingURL=chunk-B7FCFNLA.mjs.map
10107
+ //# sourceMappingURL=chunk-4U73PORF.mjs.map
10108
+ //# sourceMappingURL=chunk-4U73PORF.mjs.map