agent-inspect 6.7.4 → 6.8.0

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,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, enrichSessionRunRecord, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, extractMetadata, filterTraces, truncateName, getTraceFilePath, buildRunSummary, formatDuration, formatTimestamp, isAgentInspectTrace, openTrace, TraceReadError, filterMetasBySessionScope, runTraceChecks, aggregateSessionCheckResults, createBaselineRegressionRule, resolveBundleRunIds, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, buildBundleMetadata, buildBundleSummaryMarkdown, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, renderErrorLine, getIndent, Redactor, TreeBuilder, zeroKinds, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, assertBundlePathContained, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, escapeMarkdown, escapeHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, resolveRedactionProfile, applyProfileMetadataCaps, flattenTree, safeString, compactAttributes, stableJson, truncateStringForProfile } from './chunk-FVEQ7JFF.mjs';
3
- import { realpathSync, constants as constants$1 } from 'fs';
2
+ import { createSafetyRawContentRule, createSafetyRedactionRule, createSafetySecretPatternRule, createSafetyOversizedAttributeRule, resolveTraceDir, parseDuration, buildSessionIndex, enrichSessionRunRecord, TraceDirectory, loadTraceMetadataList, loadSessionRunRecords, extractMetadata, filterTraces, truncateName, getTraceFilePath, buildRunSummary, formatDuration, formatTimestamp, isAgentInspectTrace, openTrace, TraceReadError, filterMetasBySessionScope, runTraceChecks, aggregateSessionCheckResults, createBaselineRegressionRule, resolveBundleRunIds, aggregateBundleSafeStatus, bundleFailsOnSafety, bundleRunAssetRelativePath, buildPlaceholderArtifact, buildBundleMetadata, buildBundleSummaryMarkdown, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, resolveSuiteTemplate, defaultSuiteConfigTemplate, loadSuiteConfig, validateSuiteConfig, runSuite, renderSuiteReport, analyzeCohort, renderCohortReport, gateHasThresholds, runGate, renderGateReport, persistedInspectEventsToTraceEvents, renderStepLine, renderErrorLine, getIndent, Redactor, TreeBuilder, zeroKinds, validateEvent, traceEventToPersistedInspectEvent, isPersistedInspectEvent, createRunStatusRule, createStructureOrphanRule, createStructureCycleRule, createRunDurationRule, createMaxStepDurationRule, createRequireCompletedRule, createStallDetectionRule, createObservedOutcomeRule, createRunDepthRule, createToolUsageRule, createLlmUsageRule, createStructureRelationshipRule, createStructureParallelWidthRule, normalizeBundleOutputPath, sanitizeBundleRunId, defaultBundleOutputPath, assertBundlePathContained, summarizeObservedOutcomes, extractOutcomesFromTraceEvents, renderObservedOutcomesMarkdown, renderObservedOutcomesHtml, escapeMarkdown, escapeHtml, DEFAULT_SUITE_ARTIFACTS_DIR, parseCohortMetricList, COHORT_METRIC_IDS, parseGateList, nanoid, resolveRedactionProfile, applyProfileMetadataCaps, flattenTree, safeString, compactAttributes, stableJson, truncateStringForProfile } from './chunk-TO4VENHV.mjs';
3
+ import { realpathSync, constants as constants$1, existsSync, readFileSync } from 'fs';
4
4
  import path14 from 'path';
5
5
  import { fileURLToPath, pathToFileURL } from 'url';
6
6
  import { Command, Option } from 'commander';
@@ -11,7 +11,7 @@ import { createServer } from 'http';
11
11
  import { createRequire } from 'module';
12
12
 
13
13
  // package.json
14
- var version = "6.7.4";
14
+ var version = "6.8.0";
15
15
 
16
16
  // packages/cli/src/trace-dir-scale.ts
17
17
  var TRACE_COUNT_WARN = 1e3;
@@ -2878,6 +2878,20 @@ ${attrsSection}
2878
2878
  };
2879
2879
  }
2880
2880
 
2881
+ // packages/cli/src/cli-option-aliases.ts
2882
+ function resolveOutputOption(options) {
2883
+ const canonical = options.output?.trim();
2884
+ if (canonical) return canonical;
2885
+ const legacy = options.out?.trim();
2886
+ return legacy || void 0;
2887
+ }
2888
+ function resolveRedactionProfileOption(options) {
2889
+ const canonical = options.redactionProfile?.trim();
2890
+ if (canonical) return canonical;
2891
+ const legacy = options.profile?.trim();
2892
+ return legacy || void 0;
2893
+ }
2894
+
2881
2895
  // packages/cli/src/export.ts
2882
2896
  function parseRedactionProfile(s) {
2883
2897
  const v = (s ?? "local").trim().toLowerCase();
@@ -2908,7 +2922,7 @@ async function exportCommand(runId, options = {}) {
2908
2922
  let redactionProfile;
2909
2923
  try {
2910
2924
  format = parseExportFormat(options.format);
2911
- redactionProfile = parseRedactionProfile(options.redactionProfile);
2925
+ redactionProfile = parseRedactionProfile(resolveRedactionProfileOption(options));
2912
2926
  } catch (e) {
2913
2927
  const msg = e instanceof Error ? e.message : String(e);
2914
2928
  console.error(msg);
@@ -2956,7 +2970,8 @@ Trace directory: ${traceDir}`);
2956
2970
  if (validation !== void 0 && !validation.ok) {
2957
2971
  process.exitCode = 1;
2958
2972
  }
2959
- const outPath = options.output !== void 0 && options.output.trim() !== "" ? path14.resolve(options.output.trim()) : void 0;
2973
+ const resolvedOutput = resolveOutputOption(options);
2974
+ const outPath = resolvedOutput !== void 0 ? path14.resolve(resolvedOutput) : void 0;
2960
2975
  if (outPath !== void 0) {
2961
2976
  await mkdir(path14.dirname(outPath), { recursive: true });
2962
2977
  await writeFile(outPath, result.content, "utf-8");
@@ -3793,7 +3808,7 @@ async function newestTraceMtimeMs(traceDir) {
3793
3808
  }
3794
3809
  async function loadSessionRuns(traceDir) {
3795
3810
  try {
3796
- const mod = await import('./src-I5NA7BLK.mjs');
3811
+ const mod = await import('./src-Z5W27YCW.mjs');
3797
3812
  const dbPath = mod.resolveIndexDbPath(traceDir);
3798
3813
  const status = mod.indexStatus(dbPath);
3799
3814
  if (!status.healthy) {
@@ -4209,7 +4224,7 @@ async function reportCommand(runId, options = {}) {
4209
4224
  let redactionProfile;
4210
4225
  try {
4211
4226
  format = parseReportFormat(options.format);
4212
- redactionProfile = parseRedactionProfile2(options.redactionProfile);
4227
+ redactionProfile = parseRedactionProfile2(resolveRedactionProfileOption(options));
4213
4228
  } catch (e) {
4214
4229
  const msg = e instanceof Error ? e.message : String(e);
4215
4230
  console.error(msg);
@@ -4241,7 +4256,8 @@ async function reportCommand(runId, options = {}) {
4241
4256
  correlation: !options.noCorrelation,
4242
4257
  ...options.section ? { section: options.section } : {}
4243
4258
  });
4244
- const outPath = options.output !== void 0 && options.output.trim() !== "" ? path14.resolve(options.output.trim()) : void 0;
4259
+ const resolvedOutput = resolveOutputOption(options);
4260
+ const outPath = resolvedOutput !== void 0 ? path14.resolve(resolvedOutput) : void 0;
4245
4261
  if (outPath !== void 0) {
4246
4262
  await mkdir(path14.dirname(outPath), { recursive: true });
4247
4263
  await writeFile(outPath, result.content, "utf-8");
@@ -4754,11 +4770,12 @@ function redactTraceContent(content, profile) {
4754
4770
  return redactDocument(content, profile);
4755
4771
  }
4756
4772
  async function redactCommand(target, options = {}, stdin = process.stdin) {
4757
- const profile = parseRedactionProfile3(options.profile);
4773
+ const profile = parseRedactionProfile3(resolveRedactionProfileOption(options));
4758
4774
  const source = await contentFromTarget(target, options, stdin);
4759
4775
  const redacted = redactDocument(source.content, profile);
4760
- if (options.output !== void 0) {
4761
- await writeFile(options.output, redacted.content, "utf-8");
4776
+ const outputPath = resolveOutputOption(options);
4777
+ if (outputPath !== void 0) {
4778
+ await writeFile(outputPath, redacted.content, "utf-8");
4762
4779
  }
4763
4780
  if (options.json) {
4764
4781
  console.log(
@@ -4767,9 +4784,9 @@ async function redactCommand(target, options = {}, stdin = process.stdin) {
4767
4784
  ok: true,
4768
4785
  profile,
4769
4786
  source: source.source,
4770
- output: options.output,
4787
+ output: outputPath,
4771
4788
  findings: redacted.findings,
4772
- content: options.output === void 0 ? redacted.content : void 0
4789
+ content: outputPath === void 0 ? redacted.content : void 0
4773
4790
  }),
4774
4791
  null,
4775
4792
  2
@@ -4777,7 +4794,7 @@ async function redactCommand(target, options = {}, stdin = process.stdin) {
4777
4794
  );
4778
4795
  return;
4779
4796
  }
4780
- if (options.output === void 0) {
4797
+ if (outputPath === void 0) {
4781
4798
  process.stdout.write(redacted.content);
4782
4799
  }
4783
4800
  }
@@ -4854,7 +4871,7 @@ async function explainCommand(target, options = {}, stdin = process.stdin) {
4854
4871
  }
4855
4872
  let redactionProfile;
4856
4873
  try {
4857
- redactionProfile = parseRedactionProfile4(options.redactionProfile);
4874
+ redactionProfile = parseRedactionProfile4(resolveRedactionProfileOption(options));
4858
4875
  } catch (error) {
4859
4876
  process.exitCode = 1;
4860
4877
  console.error(error instanceof Error ? error.message : String(error));
@@ -8794,8 +8811,9 @@ function safetyStatusFromAssess(status) {
8794
8811
  return "UNKNOWN";
8795
8812
  }
8796
8813
  async function resolveOutputDir(options, runIds, cwd) {
8797
- if (options.out !== void 0 && options.out.trim() !== "") {
8798
- const normalized = normalizeBundleOutputPath(options.out);
8814
+ const out = resolveOutputOption(options);
8815
+ if (out !== void 0) {
8816
+ const normalized = normalizeBundleOutputPath(out);
8799
8817
  try {
8800
8818
  const location = resolveWorkspaceLocation(cwd);
8801
8819
  const manifest = await readWorkspaceManifestFile(location);
@@ -8865,7 +8883,7 @@ function extractHtmlBody(content) {
8865
8883
  return match?.[1]?.trim() ?? content;
8866
8884
  }
8867
8885
  async function bundleCommand(runIdArg, options = {}) {
8868
- const profile = parseBundleProfile(options.profile);
8886
+ const profile = parseBundleProfile(resolveRedactionProfileOption(options));
8869
8887
  const traceDir = resolveTraceDir({ dir: options.dir });
8870
8888
  const cwd = process.cwd();
8871
8889
  let resolveResult;
@@ -9750,42 +9768,67 @@ async function traceDirWritable(traceDir) {
9750
9768
  };
9751
9769
  }
9752
9770
  }
9753
- function resolvePackage(cwd, name) {
9771
+ function readPackageVersionNearEntry(entryPath, packageName) {
9772
+ let dir = path14.dirname(path14.resolve(entryPath));
9773
+ const { root } = path14.parse(dir);
9774
+ while (true) {
9775
+ const candidate = path14.join(dir, "package.json");
9776
+ if (existsSync(candidate)) {
9777
+ try {
9778
+ const pkg = JSON.parse(readFileSync(candidate, "utf8"));
9779
+ if (pkg.name === packageName && typeof pkg.version === "string") {
9780
+ return pkg.version;
9781
+ }
9782
+ } catch {
9783
+ }
9784
+ }
9785
+ if (dir === root) break;
9786
+ const parent = path14.dirname(dir);
9787
+ if (parent === dir) break;
9788
+ dir = parent;
9789
+ }
9790
+ return void 0;
9791
+ }
9792
+ function resolveInstalledPackage(cwd, name) {
9754
9793
  const require2 = createRequire(path14.join(cwd, "package.json"));
9755
9794
  try {
9756
- const pkgPath = require2.resolve(`${name}/package.json`);
9757
- const pkg = require2(pkgPath);
9758
- return { ok: true, version: pkg.version };
9795
+ const entry = require2.resolve(name);
9796
+ let version2;
9797
+ try {
9798
+ const pkgPath = require2.resolve(`${name}/package.json`);
9799
+ const pkg = require2(pkgPath);
9800
+ if (typeof pkg.version === "string") version2 = pkg.version;
9801
+ } catch {
9802
+ version2 = readPackageVersionNearEntry(entry, name);
9803
+ }
9804
+ return { ok: true, version: version2, entry };
9759
9805
  } catch {
9760
9806
  return { ok: false };
9761
9807
  }
9762
9808
  }
9763
9809
  function importSmoke(cwd) {
9764
9810
  const results = [];
9765
- const require2 = createRequire(path14.join(cwd, "package.json"));
9766
- try {
9767
- require2.resolve("agent-inspect");
9811
+ const resolved = resolveInstalledPackage(cwd, "agent-inspect");
9812
+ if (resolved.ok) {
9768
9813
  results.push({
9769
9814
  id: "import-agent-inspect",
9770
9815
  status: "pass",
9771
- message: "agent-inspect resolves from the current project."
9816
+ message: "agent-inspect resolves from the current project.",
9817
+ evidence: resolved.entry
9772
9818
  });
9773
- } catch {
9819
+ results.push({
9820
+ id: "import-agent-inspect-cjs",
9821
+ status: "pass",
9822
+ message: "CJS resolution for agent-inspect succeeded.",
9823
+ evidence: resolved.entry
9824
+ });
9825
+ } else {
9774
9826
  results.push({
9775
9827
  id: "import-agent-inspect",
9776
9828
  status: "warn",
9777
9829
  message: "agent-inspect is not installed in the current project.",
9778
9830
  remediation: "Run npm install agent-inspect (or pnpm add agent-inspect)."
9779
9831
  });
9780
- }
9781
- try {
9782
- require2.resolve("agent-inspect/package.json");
9783
- results.push({
9784
- id: "import-agent-inspect-cjs",
9785
- status: "pass",
9786
- message: "CJS resolution for agent-inspect succeeded."
9787
- });
9788
- } catch {
9789
9832
  results.push({
9790
9833
  id: "import-agent-inspect-cjs",
9791
9834
  status: "skipped",
@@ -9803,7 +9846,7 @@ function optionalPackageChecks(cwd, framework) {
9803
9846
  "@agent-inspect/eval"
9804
9847
  ];
9805
9848
  return packages.map((name) => {
9806
- const resolved = resolvePackage(cwd, name);
9849
+ const resolved = resolveInstalledPackage(cwd, name);
9807
9850
  if (!resolved.ok) {
9808
9851
  return {
9809
9852
  id: `optional-package-${name}`,
@@ -9821,7 +9864,7 @@ function optionalPackageChecks(cwd, framework) {
9821
9864
  });
9822
9865
  }
9823
9866
  function versionMismatchCheck(cwd) {
9824
- const root = resolvePackage(cwd, "agent-inspect");
9867
+ const root = resolveInstalledPackage(cwd, "agent-inspect");
9825
9868
  if (!root.ok || root.version === void 0) {
9826
9869
  return {
9827
9870
  id: "version-alignment",
@@ -10380,7 +10423,7 @@ function isModuleNotFound4(e) {
10380
10423
  }
10381
10424
  async function loadIndexSqlite() {
10382
10425
  try {
10383
- return await import('./src-I5NA7BLK.mjs');
10426
+ return await import('./src-Z5W27YCW.mjs');
10384
10427
  } catch (e) {
10385
10428
  if (isModuleNotFound4(e)) {
10386
10429
  console.error(
@@ -11169,11 +11212,17 @@ function createCliProgram() {
11169
11212
  "openinference",
11170
11213
  "otlp-json"
11171
11214
  ])
11172
- ).option("-o, --output <path>", "write export to file (creates parent dirs)").option("--json", "emit JSON wrapper about the export (includes content when writing to stdout)").option("--validate", "validate exported payload shape after generation").option("--include-attributes", "include bounded attributes (review before sharing)").option("--no-metadata", "omit summary / metadata sections").option("--no-errors", "omit error sections").addOption(
11215
+ ).option("-o, --output <path>", "write export to file (creates parent dirs)").option("--out <path>", "alias for --output").option("--json", "emit JSON wrapper about the export (includes content when writing to stdout)").option("--validate", "validate exported payload shape after generation").option("--include-attributes", "include bounded attributes (review before sharing)").option("--no-metadata", "omit summary / metadata sections").option("--no-errors", "omit error sections").addOption(
11173
11216
  new Option(
11174
11217
  "--redaction-profile <profile>",
11175
11218
  "redaction profile for exported copies: local, share, strict (default: local)"
11176
11219
  ).choices(["local", "share", "strict"])
11220
+ ).addOption(
11221
+ new Option("--profile <profile>", "alias for --redaction-profile").choices([
11222
+ "local",
11223
+ "share",
11224
+ "strict"
11225
+ ])
11177
11226
  ).action((runId, opts) => {
11178
11227
  runCommand(() => exportCommand(runId, opts));
11179
11228
  });
@@ -11309,7 +11358,12 @@ function createCliProgram() {
11309
11358
  });
11310
11359
  program.command("bundle").description("Create a share-safe offline trace bundle (local folder)").argument("[run-id]", "run id to bundle (optional with --session or --since)").option("--dir <path>", "trace directory for run/session lookup").option("--session <session-id>", "bundle all runs in a session").option("--since <duration>", "bundle runs with activity since a duration (e.g. 24h)").addOption(
11311
11360
  new Option("--profile <profile>", "redaction profile for exported copies").choices(["local", "share", "strict"]).default("share")
11312
- ).option("--out <path>", "output directory (folder; .zip suffix is stripped)").option("--allow-unsafe", "write bundle even when verify-safe reports UNSAFE").option("--json", "print deterministic JSON manifest").action((runId, opts) => {
11361
+ ).addOption(
11362
+ new Option(
11363
+ "--redaction-profile <profile>",
11364
+ "alias for --profile (canonical spelling)"
11365
+ ).choices(["local", "share", "strict"])
11366
+ ).option("--out <path>", "output directory (folder; .zip suffix is stripped)").option("--output <path>", "alias for --out (canonical spelling)").option("--allow-unsafe", "write bundle even when verify-safe reports UNSAFE").option("--json", "print deterministic JSON manifest").action((runId, opts) => {
11313
11367
  runCommand(() => bundleCommand(runId, opts));
11314
11368
  });
11315
11369
  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) => {
@@ -11402,7 +11456,7 @@ function createCliProgram() {
11402
11456
  "markdown",
11403
11457
  "html"
11404
11458
  ])
11405
- ).option("-o, --output <path>", "write report to file (creates parent dirs)").option("--json", "emit JSON wrapper (includes content when writing to stdout)").option("--include-attributes", "include bounded step attributes in tree section").option("--no-errors", "omit error details from tree section").option("--no-correlation", "omit correlation metadata from what section").addOption(
11459
+ ).option("-o, --output <path>", "write report to file (creates parent dirs)").option("--out <path>", "alias for --output").option("--json", "emit JSON wrapper (includes content when writing to stdout)").option("--include-attributes", "include bounded step attributes in tree section").option("--no-errors", "omit error details from tree section").option("--no-correlation", "omit correlation metadata from what section").addOption(
11406
11460
  new Option("--section <section>", "report section (default: all)").choices([
11407
11461
  "all",
11408
11462
  "observations",
@@ -11415,6 +11469,12 @@ function createCliProgram() {
11415
11469
  "--redaction-profile <profile>",
11416
11470
  "redaction profile for entire report: local, share, strict (default: local)"
11417
11471
  ).choices(["local", "share", "strict"])
11472
+ ).addOption(
11473
+ new Option("--profile <profile>", "alias for --redaction-profile").choices([
11474
+ "local",
11475
+ "share",
11476
+ "strict"
11477
+ ])
11418
11478
  ).action((runId, opts) => {
11419
11479
  runCommand(() => reportCommand(runId, opts));
11420
11480
  });
@@ -11423,7 +11483,12 @@ function createCliProgram() {
11423
11483
  "--profile <profile>",
11424
11484
  "redaction profile: local, share, strict (default: share)"
11425
11485
  ).choices(["local", "share", "strict"])
11426
- ).option("-o, --output <path>", "write redacted content to a file").option("--json", "print deterministic JSON wrapper with findings").action((target, opts) => {
11486
+ ).addOption(
11487
+ new Option(
11488
+ "--redaction-profile <profile>",
11489
+ "alias for --profile (canonical spelling)"
11490
+ ).choices(["local", "share", "strict"])
11491
+ ).option("-o, --output <path>", "write redacted content to a file").option("--out <path>", "alias for --output").option("--json", "print deterministic JSON wrapper with findings").action((target, opts) => {
11427
11492
  runCommand(() => redactCommand(target, opts));
11428
11493
  });
11429
11494
  program.command("explain").description("Explain a local trace with deterministic facts (no provider calls)").argument("<trace-path-or-run-id>", "trace file, directory, stdin -, or run id").option("--dir <path>", "trace directory for run-id lookup").addOption(
@@ -11440,6 +11505,12 @@ function createCliProgram() {
11440
11505
  "--redaction-profile <profile>",
11441
11506
  "redaction profile for explanation payload: local, share, strict (default: local)"
11442
11507
  ).choices(["local", "share", "strict"])
11508
+ ).addOption(
11509
+ new Option("--profile <profile>", "alias for --redaction-profile").choices([
11510
+ "local",
11511
+ "share",
11512
+ "strict"
11513
+ ])
11443
11514
  ).action((target, opts) => {
11444
11515
  runCommand(() => explainCommand(target, opts));
11445
11516
  });