@agent-inspect/mcp-server 6.17.4 → 6.17.5

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { runReadOnlyMcpServer } from './chunk-PPA3VJQG.mjs';
1
+ import { runReadOnlyMcpServer } from './chunk-GMXH2CU3.mjs';
2
2
  import { readFileSync } from 'fs';
3
3
  import path from 'path';
4
4
  import { fileURLToPath } from 'url';
package/dist/index.cjs CHANGED
@@ -3183,10 +3183,11 @@ function emptySummary() {
3183
3183
  passed: 0,
3184
3184
  failed: 0,
3185
3185
  warnings: 0,
3186
- errors: 0
3186
+ errors: 0,
3187
+ rulesEvaluated: 0
3187
3188
  };
3188
3189
  }
3189
- function errorResult(input, diagnostics, selectedRun) {
3190
+ function errorResult(input, diagnostics, selectedRun, ruleExecutions = []) {
3190
3191
  return {
3191
3192
  ok: false,
3192
3193
  status: "error",
@@ -3194,10 +3195,12 @@ function errorResult(input, diagnostics, selectedRun) {
3194
3195
  ...selectedRun ? { runId: selectedRun.runId } : {},
3195
3196
  summary: {
3196
3197
  ...emptySummary(),
3197
- errors: diagnostics.filter((item) => item.severity === "error").length
3198
+ errors: diagnostics.filter((item) => item.severity === "error").length,
3199
+ rulesEvaluated: ruleExecutions.length
3198
3200
  },
3199
3201
  findings: [],
3200
- diagnostics: [...diagnostics]
3202
+ diagnostics: [...diagnostics],
3203
+ ruleExecutions: [...ruleExecutions]
3201
3204
  };
3202
3205
  }
3203
3206
  function flattenNodes(nodes) {
@@ -3353,7 +3356,7 @@ function normalizeFinding(rule, finding) {
3353
3356
  ...finding.action !== void 0 ? { action: finding.action } : {}
3354
3357
  };
3355
3358
  }
3356
- function summarize(findings, diagnostics) {
3359
+ function summarize(findings, diagnostics, rulesEvaluated) {
3357
3360
  return {
3358
3361
  passed: findings.filter((finding) => finding.status === "pass").length,
3359
3362
  failed: findings.filter(
@@ -3362,9 +3365,21 @@ function summarize(findings, diagnostics) {
3362
3365
  warnings: findings.filter(
3363
3366
  (finding) => finding.status === "warning" || finding.severity === "warning"
3364
3367
  ).length,
3365
- errors: diagnostics.filter((item) => item.severity === "error").length
3368
+ errors: diagnostics.filter((item) => item.severity === "error").length,
3369
+ rulesEvaluated
3366
3370
  };
3367
3371
  }
3372
+ function classifyRuleExecution(findings, threw) {
3373
+ if (findings.some((finding) => finding.status === "fail" && finding.severity === "error")) {
3374
+ return "fail";
3375
+ }
3376
+ if (findings.some(
3377
+ (finding) => finding.status === "warning" || finding.severity === "warning"
3378
+ )) {
3379
+ return "warning";
3380
+ }
3381
+ return "pass";
3382
+ }
3368
3383
  function eventEvidence(event, path16) {
3369
3384
  return {
3370
3385
  runId: event.runId,
@@ -3730,6 +3745,18 @@ function runTraceChecks(input, options = {}) {
3730
3745
  if (rules.diagnostics.length > 0) {
3731
3746
  return errorResult(input, rules.diagnostics, selected.run);
3732
3747
  }
3748
+ if (rules.rules.length === 0) {
3749
+ return errorResult(
3750
+ input,
3751
+ [
3752
+ diagnostic(
3753
+ "AI_CHECK_NO_RULES_EVALUATED",
3754
+ "No trace check rules were evaluated. Configure at least one rule, contract, or CLI check option."
3755
+ )
3756
+ ],
3757
+ selected.run
3758
+ );
3759
+ }
3733
3760
  const facts = buildFacts(input, selected.run);
3734
3761
  const context = {
3735
3762
  ...facts,
@@ -3738,22 +3765,38 @@ function runTraceChecks(input, options = {}) {
3738
3765
  };
3739
3766
  const diagnostics = [];
3740
3767
  const findings = [];
3768
+ const ruleExecutions = [];
3741
3769
  for (const rule of rules.rules) {
3742
3770
  try {
3743
- findings.push(...rule.evaluate(context).map((finding) => normalizeFinding(rule, finding)));
3771
+ const ruleFindings = rule.evaluate(context).map((finding) => normalizeFinding(rule, finding));
3772
+ findings.push(...ruleFindings);
3773
+ ruleExecutions.push({
3774
+ ruleId: rule.id,
3775
+ category: rule.category,
3776
+ status: classifyRuleExecution(ruleFindings, false),
3777
+ findingCount: ruleFindings.length,
3778
+ ...selected.run ? { runId: selected.run.runId } : {}
3779
+ });
3744
3780
  } catch (error) {
3745
3781
  const message = error instanceof Error ? error.message : String(error);
3746
3782
  diagnostics.push(
3747
3783
  diagnostic("AI_CHECK_INTERNAL_ERROR", `Rule ${rule.id} failed: ${message}`, rule.id)
3748
3784
  );
3785
+ ruleExecutions.push({
3786
+ ruleId: rule.id,
3787
+ category: rule.category,
3788
+ status: "error",
3789
+ findingCount: 0,
3790
+ ...selected.run ? { runId: selected.run.runId } : {}
3791
+ });
3749
3792
  }
3750
3793
  }
3751
3794
  if (diagnostics.length > 0) {
3752
- return errorResult(input, diagnostics, selected.run);
3795
+ return errorResult(input, diagnostics, selected.run, ruleExecutions);
3753
3796
  }
3754
3797
  const eventById = new Map(input.read.events.map((event) => [event.eventId, event]));
3755
3798
  const sortedFindings = findings.sort(compareFindings(eventById));
3756
- const summary = summarize(sortedFindings, diagnostics);
3799
+ const summary = summarize(sortedFindings, diagnostics, ruleExecutions.length);
3757
3800
  const status = summary.failed > 0 ? "fail" : "pass";
3758
3801
  return {
3759
3802
  ok: status === "pass",
@@ -3762,7 +3805,8 @@ function runTraceChecks(input, options = {}) {
3762
3805
  ...selected.run ? { runId: selected.run.runId } : {},
3763
3806
  summary,
3764
3807
  findings: sortedFindings,
3765
- diagnostics
3808
+ diagnostics,
3809
+ ruleExecutions
3766
3810
  };
3767
3811
  }
3768
3812