agent-inspect 6.17.0 → 6.17.2

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, resolveBundleRunIds, getTraceFilePath, openTrace, sha256Hex, collectTraceSchemaVersions, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceHtmlShell, buildEvidenceProvenanceViewHtml, EVIDENCE_FORMAT_VERSION, inferEvidenceFileRole, buildEvidenceSafetyViewHtml, buildEvidenceDiffViewHtml, buildEvidenceCircuitViewHtml, buildEvidenceOutcomesViewHtml, buildEvidenceContractsViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceCausalFailureViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceTreeViewHtml, buildEvidenceManifest, serializeEvidenceManifest, buildZipArchive, assertBundlePathContained, enrichSessionRunRecord, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, runTraceChecks, assertEvidenceRelativePath, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, TraceReadError, resolveRedactionProfile, applyProfileMetadataCaps, Redactor, flattenTree, escapeHtml, safeString, compactAttributes, stableJson, escapeMarkdown, truncateStringForProfile, extractMetadata, filterTraces, truncateName, buildRunSummary, formatDuration, formatTimestamp, isAgentInspectTrace, filterMetasBySessionScope, aggregateSessionCheckResults, createBaselineRegressionRule, summarizeSemanticParity, buildEvidenceCiPackage, verifyEvidenceDirectory, diffTraceEvents, renderRunDiff, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, formatStepLabel, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, renderErrorLine, getIndent, TreeBuilder, zeroKinds, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, diffRuns, manualTraceEventsToComparableRun } from './chunk-LFSBMUCD.mjs';
2
+ import { createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, resolveBundleRunIds, getTraceFilePath, openTrace, sha256Hex, collectTraceSchemaVersions, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, EVIDENCE_HTML_FILENAME, EVIDENCE_MANIFEST_FILENAME, buildBundleMetadata, buildBundleSummaryMarkdown, buildEvidenceHtmlShell, buildEvidenceProvenanceViewHtml, EVIDENCE_FORMAT_VERSION, inferEvidenceFileRole, buildEvidenceSafetyViewHtml, buildEvidenceDiffViewHtml, buildEvidenceCircuitViewHtml, buildEvidenceOutcomesViewHtml, buildEvidenceContractsViewHtml, buildEvidenceToolsLlmViewHtml, buildEvidenceCausalFailureViewHtml, buildEvidenceTimelineViewHtml, buildEvidenceTreeViewHtml, buildEvidenceManifest, serializeEvidenceManifest, buildZipArchive, assertBundlePathContained, enrichSessionRunRecord, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, runTraceChecks, assertEvidenceRelativePath, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, TraceReadError, resolveRedactionProfile, applyProfileMetadataCaps, Redactor, flattenTree, escapeHtml, safeString, compactAttributes, stableJson, escapeMarkdown, truncateStringForProfile, extractMetadata, filterTraces, truncateName, buildRunSummary, formatDuration, formatTimestamp, isAgentInspectTrace, filterMetasBySessionScope, aggregateSessionCheckResults, createBaselineRegressionRule, summarizeSemanticParity, buildEvidenceCiPackage, verifyEvidenceDirectory, diffTraceEvents, renderRunDiff, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, formatStepLabel, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, renderErrorLine, getIndent, TreeBuilder, zeroKinds, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, diffRuns, manualTraceEventsToComparableRun } from './chunk-FXGWXSFV.mjs';
3
3
  import { realpathSync, constants as constants$1, existsSync, readFileSync } from 'fs';
4
4
  import path18 from 'path';
5
5
  import { fileURLToPath, pathToFileURL } from 'url';
@@ -12,7 +12,7 @@ import { spawn } from 'child_process';
12
12
  import { createRequire } from 'module';
13
13
 
14
14
  // package.json
15
- var version = "6.17.0";
15
+ var version = "6.17.2";
16
16
 
17
17
  // packages/cli/src/trace-dir-scale.ts
18
18
  var TRACE_COUNT_WARN = 1e3;
@@ -3347,7 +3347,7 @@ async function newestTraceMtimeMs(traceDir) {
3347
3347
  }
3348
3348
  async function loadSessionRuns(traceDir) {
3349
3349
  try {
3350
- const mod = await import('./src-5J2HPOJ3.mjs');
3350
+ const mod = await import('./src-EW7KW2BK.mjs');
3351
3351
  const dbPath = mod.resolveIndexDbPath(traceDir);
3352
3352
  const status = mod.indexStatus(dbPath);
3353
3353
  if (!status.healthy) {
@@ -5771,6 +5771,58 @@ function mergeSafetyExtensions(result, read, options) {
5771
5771
  }
5772
5772
 
5773
5773
  // packages/cli/src/check.ts
5774
+ var DEFAULT_SELECT = ["run.status"];
5775
+ function uniqueSelectIds(ids) {
5776
+ const seen = /* @__PURE__ */ new Set();
5777
+ const out = [];
5778
+ for (const id of ids) {
5779
+ const trimmed = id.trim();
5780
+ if (trimmed === "" || seen.has(trimmed)) continue;
5781
+ seen.add(trimmed);
5782
+ out.push(trimmed);
5783
+ }
5784
+ return out;
5785
+ }
5786
+ function cliShorthandSelectIds(options) {
5787
+ const ids = [];
5788
+ if (options.failOnObservation !== void 0 && options.failOnObservation.trim() !== "") {
5789
+ ids.push("outcome.status");
5790
+ }
5791
+ if ((options.requiredTool?.length ?? 0) > 0 || (options.forbiddenTool?.length ?? 0) > 0) {
5792
+ ids.push("tool.usage");
5793
+ }
5794
+ if ((options.allowedModel?.length ?? 0) > 0 || options.maxTotalTokens !== void 0) {
5795
+ ids.push("llm.usage");
5796
+ }
5797
+ if (options.maxDurationMs !== void 0) {
5798
+ ids.push("run.duration");
5799
+ }
5800
+ if (options.maxStepDuration !== void 0) {
5801
+ ids.push("run.maxStepDuration");
5802
+ }
5803
+ if (options.detectStalls === true) {
5804
+ ids.push("run.stall");
5805
+ }
5806
+ return ids;
5807
+ }
5808
+ function unionCheckSelect(input3) {
5809
+ const explicit = uniqueSelectIds([
5810
+ ...input3.presetSelect ?? [],
5811
+ ...input3.explicitRules ?? [],
5812
+ ...input3.configSelect ?? []
5813
+ ]);
5814
+ if (explicit.length === 0) {
5815
+ return uniqueSelectIds([
5816
+ ...DEFAULT_SELECT,
5817
+ ...(input3.constructedRuleIds ?? []).filter((id) => id !== "run.status")
5818
+ ]);
5819
+ }
5820
+ const constructed = new Set(input3.constructedRuleIds ?? []);
5821
+ const shorthand = (input3.shorthandIds ?? []).filter(
5822
+ (id) => constructed.size === 0 || constructed.has(id)
5823
+ );
5824
+ return uniqueSelectIds([...explicit, ...shorthand]);
5825
+ }
5774
5826
  function resolvePreset(preset, context = {}) {
5775
5827
  if (preset === void 0 || preset.trim() === "") return void 0;
5776
5828
  const name = preset.trim().toLowerCase();
@@ -5819,7 +5871,6 @@ function resolvePreset(preset, context = {}) {
5819
5871
  select
5820
5872
  };
5821
5873
  }
5822
- var DEFAULT_SELECT = ["run.status"];
5823
5874
  var CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([".json", ".js", ".mjs", ".cjs"]);
5824
5875
  var TS_CONFIG_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".mts", ".cts"]);
5825
5876
  function diagnostic(code, message, severity = "error") {
@@ -5911,12 +5962,11 @@ function applyResolvedPreset(config, options, resolved) {
5911
5962
  config: { checks: checks2 },
5912
5963
  options: {
5913
5964
  ...options,
5914
- ...resolved.requireCompleted ? { requireCompleted: true } : {},
5915
- rule: [...resolved.select, ...options.rule ?? []]
5965
+ ...resolved.requireCompleted ? { requireCompleted: true } : {}
5916
5966
  }
5917
5967
  };
5918
5968
  }
5919
- function buildRules(config, options) {
5969
+ function buildRules(config, options, presetSelect = []) {
5920
5970
  const diagnostics = [];
5921
5971
  const checks2 = normalizeConfig(config);
5922
5972
  const run = checks2.run ?? {};
@@ -6006,21 +6056,15 @@ function buildRules(config, options) {
6006
6056
  if (safety.maxStringLength !== void 0 || safety.maxArrayLength !== void 0 || safety.maxObjectKeys !== void 0 || safety.maxSerializedBytes !== void 0) {
6007
6057
  rules.push(createSafetyOversizedAttributeRule(safety));
6008
6058
  }
6009
- const select = [
6010
- ...asStringArray(checks2.select) ?? [],
6011
- ...options.rule ?? []
6012
- ];
6013
- if (select.length === 0) {
6014
- const auto = new Set(DEFAULT_SELECT);
6015
- for (const rule of rules) {
6016
- if (rule.id !== "run.status") auto.add(rule.id);
6017
- }
6018
- return {
6019
- rules,
6020
- select: [...auto],
6021
- diagnostics
6022
- };
6023
- }
6059
+ const constructedRuleIds = rules.map((rule) => rule.id);
6060
+ const shorthandIds = cliShorthandSelectIds(options);
6061
+ const select = unionCheckSelect({
6062
+ presetSelect,
6063
+ explicitRules: options.rule ?? [],
6064
+ configSelect: asStringArray(checks2.select) ?? [],
6065
+ shorthandIds,
6066
+ constructedRuleIds
6067
+ });
6024
6068
  return {
6025
6069
  rules,
6026
6070
  select,
@@ -6149,7 +6193,7 @@ async function checkCommand(target, options = {}, stdin = process.stdin) {
6149
6193
  config = applied.config;
6150
6194
  effectiveOptions = applied.options;
6151
6195
  }
6152
- const built = buildRules(config, effectiveOptions);
6196
+ const built = buildRules(config, effectiveOptions, resolved?.select ?? []);
6153
6197
  if (built.diagnostics.some((item) => item.severity === "error")) {
6154
6198
  result = errorResult("AI_CHECK_INVALID_CONFIG", "Invalid check configuration.");
6155
6199
  result.diagnostics = [...built.diagnostics];
@@ -11211,7 +11255,7 @@ function isModuleNotFound4(e) {
11211
11255
  }
11212
11256
  async function loadIndexSqlite() {
11213
11257
  try {
11214
- return await import('./src-5J2HPOJ3.mjs');
11258
+ return await import('./src-EW7KW2BK.mjs');
11215
11259
  } catch (e) {
11216
11260
  if (isModuleNotFound4(e)) {
11217
11261
  console.error(
@@ -12225,11 +12269,17 @@ function createCliProgram() {
12225
12269
  });
12226
12270
  bundleCmd.command("verify").description("Verify Evidence v2 integrity (manifest, hashes, presence)").argument("<path>", "evidence/bundle directory containing evidence.json").addOption(
12227
12271
  new Option("--unexpected <mode>", "policy for files not listed in the manifest").choices(["fail", "warn", "ignore"]).default("fail")
12228
- ).option("--json", "print deterministic JSON verify result").action((targetPath, opts) => {
12229
- runCommand(() => bundleVerifyCommand(targetPath, opts));
12272
+ ).option("--json", "print deterministic JSON verify result").action((targetPath, opts, command) => {
12273
+ const merged = {
12274
+ ...opts,
12275
+ ...command.optsWithGlobals?.() ?? {}
12276
+ };
12277
+ const json = opts.json === true || merged.json === true || process.argv.includes("--json");
12278
+ runCommand(() => bundleVerifyCommand(targetPath, { ...opts, json }));
12230
12279
  });
12231
12280
  bundleCmd.command("open").description("Verify then open local Evidence HTML in the platform browser (no network)").argument("<path>", "evidence/bundle directory or evidence.html path").option("--skip-verify", "skip integrity verify before open (not recommended)").option("--json", "print deterministic JSON open result").action((targetPath, opts) => {
12232
- runCommand(() => bundleOpenCommand(targetPath, opts));
12281
+ const json = opts.json === true || process.argv.includes("--json");
12282
+ runCommand(() => bundleOpenCommand(targetPath, { ...opts, json }));
12233
12283
  });
12234
12284
  program.command("ci-summary").description("Summarize local reporter artifact manifests for CI").argument("<manifest...>", "reporter artifact manifest JSON files").option("-o, --output <path>", "write Markdown summary to a local file").option("--github-summary <path>", "append Markdown summary to this local file, e.g. GITHUB_STEP_SUMMARY").option("--json", "print deterministic JSON summary").action((manifest, opts) => {
12235
12285
  runCommand(() => ciSummaryCommand(manifest, opts));