agent-inspect 5.3.0 → 6.0.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,5 +1,5 @@
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, buildPlaceholderArtifact, buildBundleMetadata, buildBundleSummaryMarkdown, buildRunTimeline, renderTimeline, buildTraceStats, renderTraceStats, parseDurationFilter, searchTraces, buildActivitySummary, renderActivitySummaryHuman, buildRunWhatSummary, renderRunWhat, buildLocalExplanation, 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, defaultBundleOutputPath, 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-4LKKB4Z5.mjs';
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, 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, defaultBundleOutputPath, 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-YS2I722C.mjs';
3
3
  import { realpathSync, constants as constants$1 } from 'fs';
4
4
  import path14 from 'path';
5
5
  import { fileURLToPath, pathToFileURL } from 'url';
@@ -11,7 +11,7 @@ import { createServer } from 'http';
11
11
  import { createRequire } from 'module';
12
12
 
13
13
  // package.json
14
- var version = "5.3.0";
14
+ var version = "6.0.0";
15
15
 
16
16
  // packages/cli/src/trace-dir-scale.ts
17
17
  var TRACE_COUNT_WARN = 1e3;
@@ -3782,7 +3782,7 @@ async function newestTraceMtimeMs(traceDir) {
3782
3782
  }
3783
3783
  async function loadSessionRuns(traceDir) {
3784
3784
  try {
3785
- const mod = await import('./src-4SGS3Q2D.mjs');
3785
+ const mod = await import('./src-FVNE44UA.mjs');
3786
3786
  const dbPath = mod.resolveIndexDbPath(traceDir);
3787
3787
  const status = mod.indexStatus(dbPath);
3788
3788
  if (!status.healthy) {
@@ -7075,6 +7075,63 @@ async function serveCommand(options = {}) {
7075
7075
  });
7076
7076
  }
7077
7077
 
7078
+ // packages/cli/src/studio-cmd.ts
7079
+ var PACKAGE = "@agent-inspect/studio";
7080
+ function isModuleNotFound3(e) {
7081
+ return e !== null && typeof e === "object" && "code" in e && (e.code === "ERR_MODULE_NOT_FOUND" || e.code === "MODULE_NOT_FOUND");
7082
+ }
7083
+ async function loadStudio() {
7084
+ try {
7085
+ return await import('@agent-inspect/studio');
7086
+ } catch (e) {
7087
+ if (isModuleNotFound3(e)) {
7088
+ console.error(
7089
+ `The optional Studio analyzer is not installed. Run: npm install ${PACKAGE}`
7090
+ );
7091
+ process.exitCode = 1;
7092
+ return null;
7093
+ }
7094
+ const msg = e instanceof Error ? e.message : String(e);
7095
+ console.error(`[AgentInspect] failed to load ${PACKAGE}: ${msg}`);
7096
+ process.exitCode = 1;
7097
+ return null;
7098
+ }
7099
+ }
7100
+ function parsePort2(value) {
7101
+ if (value === void 0) return void 0;
7102
+ const parsed = Number(value);
7103
+ if (!Number.isInteger(parsed) || parsed <= 0 || parsed > 65535) {
7104
+ throw new Error("--port must be an integer between 1 and 65535.");
7105
+ }
7106
+ return parsed;
7107
+ }
7108
+ async function studioCommand(options = {}) {
7109
+ const mod = await loadStudio();
7110
+ if (!mod) return;
7111
+ const port = parsePort2(options.port);
7112
+ const host = options.host?.trim();
7113
+ const info = await mod.startStudioServer({
7114
+ ...host !== void 0 && host.length > 0 ? { host } : {},
7115
+ ...port !== void 0 ? { port } : {},
7116
+ ...options.workspace !== void 0 ? { workspacePath: options.workspace } : {},
7117
+ ...options.db !== void 0 ? { dbPath: options.db } : {},
7118
+ ...options.server === true ? { server: true } : {},
7119
+ ...options.cwd !== void 0 ? { cwd: options.cwd } : {},
7120
+ ...options.auth === "basic" ? { auth: "basic" } : {},
7121
+ ...options.passwordEnv !== void 0 ? { passwordEnv: options.passwordEnv } : {}
7122
+ });
7123
+ console.log(`AgentInspect studio (read-only): ${info.url}`);
7124
+ if (options.open === true && info.host !== "127.0.0.1" && info.host !== "localhost") {
7125
+ console.warn("Skipping browser open for non-local host binding.");
7126
+ } else if (options.open === true) {
7127
+ const openMod = await import('child_process');
7128
+ openMod.exec(`open ${info.url}`, () => {
7129
+ });
7130
+ }
7131
+ await new Promise(() => {
7132
+ });
7133
+ }
7134
+
7078
7135
  // packages/eval/src/index.ts
7079
7136
  function isTraceReadResult(value) {
7080
7137
  return value !== null && typeof value === "object" && "runs" in value && "events" in value && "format" in value;
@@ -9869,23 +9926,23 @@ async function indexCleanCommand(options = {}) {
9869
9926
  process.exitCode = 1;
9870
9927
  }
9871
9928
  }
9872
- var PACKAGE = "@agent-inspect/index-sqlite";
9873
- function isModuleNotFound3(e) {
9929
+ var PACKAGE2 = "@agent-inspect/index-sqlite";
9930
+ function isModuleNotFound4(e) {
9874
9931
  return e !== null && typeof e === "object" && "code" in e && (e.code === "ERR_MODULE_NOT_FOUND" || e.code === "MODULE_NOT_FOUND");
9875
9932
  }
9876
9933
  async function loadIndexSqlite() {
9877
9934
  try {
9878
- return await import('./src-4SGS3Q2D.mjs');
9935
+ return await import('./src-FVNE44UA.mjs');
9879
9936
  } catch (e) {
9880
- if (isModuleNotFound3(e)) {
9937
+ if (isModuleNotFound4(e)) {
9881
9938
  console.error(
9882
- `The optional SQLite index is not installed. Run: npm install ${PACKAGE}`
9939
+ `The optional SQLite index is not installed. Run: npm install ${PACKAGE2}`
9883
9940
  );
9884
9941
  process.exitCode = 1;
9885
9942
  return null;
9886
9943
  }
9887
9944
  const msg = e instanceof Error ? e.message : String(e);
9888
- console.error(`[AgentInspect] failed to load ${PACKAGE}: ${msg}`);
9945
+ console.error(`[AgentInspect] failed to load ${PACKAGE2}: ${msg}`);
9889
9946
  process.exitCode = 1;
9890
9947
  return null;
9891
9948
  }
@@ -10162,30 +10219,39 @@ function resolveCwd(options) {
10162
10219
  async function suiteInitCommand(options = {}) {
10163
10220
  const cwd = resolveCwd(options);
10164
10221
  const configPath = path14.join(cwd, DEFAULT_CONFIG_FILENAME);
10165
- const template = defaultSuiteConfigTemplate();
10222
+ const template = options.template?.trim();
10223
+ const suiteConfig = template !== void 0 && template !== "" ? resolveSuiteTemplate(template) : defaultSuiteConfigTemplate();
10166
10224
  if (options.dryRun) {
10167
10225
  if (options.json) {
10168
10226
  printJson5({
10169
10227
  ok: true,
10170
10228
  dryRun: true,
10171
10229
  wouldWrite: [DEFAULT_CONFIG_FILENAME],
10172
- config: template
10230
+ config: suiteConfig,
10231
+ ...template ? { template } : {}
10173
10232
  });
10174
10233
  return;
10175
10234
  }
10176
10235
  console.log("Dry run \u2014 would create:");
10177
10236
  console.log(`- ${DEFAULT_CONFIG_FILENAME}`);
10237
+ if (template) console.log(` template: ${template}`);
10178
10238
  return;
10179
10239
  }
10180
10240
  try {
10181
- await writeFile(configPath, `${JSON.stringify(template, null, 2)}
10241
+ await writeFile(configPath, `${JSON.stringify(suiteConfig, null, 2)}
10182
10242
  `, "utf-8");
10183
10243
  if (options.json) {
10184
- printJson5({ ok: true, created: [DEFAULT_CONFIG_FILENAME], configPath });
10244
+ printJson5({
10245
+ ok: true,
10246
+ created: [DEFAULT_CONFIG_FILENAME],
10247
+ configPath,
10248
+ ...template ? { template } : {}
10249
+ });
10185
10250
  return;
10186
10251
  }
10187
10252
  console.log("Created suite config:");
10188
10253
  console.log(`- ${DEFAULT_CONFIG_FILENAME}`);
10254
+ if (template) console.log(` template: ${template}`);
10189
10255
  console.log("\nNext:");
10190
10256
  console.log(" npx agent-inspect suite validate");
10191
10257
  console.log(" npx agent-inspect suite run --json");
@@ -10715,6 +10781,11 @@ function createCliProgram() {
10715
10781
  program.command("viewer").description("Start localhost read-only viewer (traces, suite, or workspace) (v5.3+)").option("--dir <path>", "trace directory (trace mode)").option("--suite", "suite evidence mode").option("--workspace", "workspace mode").option("--config <path>", "suite config path (suite mode)").option("--host <host>", "bind host (default 127.0.0.1)", "127.0.0.1").option("--port <number>", "bind port (default 7337)", "7337").option("--open", "open browser locally when host is localhost").action((opts) => {
10716
10782
  runCommand(() => serveCommand(opts));
10717
10783
  });
10784
+ program.command("studio").description(
10785
+ "Start self-hosted read-only Studio analyzer (requires @agent-inspect/studio) (v6.0+)"
10786
+ ).option("--workspace <path>", "studio registry manifest path").option("--db <path>", "studio database path (sqlite file or postgres URL)").option("--host <host>", "bind host (default 127.0.0.1)", "127.0.0.1").option("--port <number>", "bind port (default 7340)", "7340").option("--server", "bind for network access (0.0.0.0; requires explicit opt-in)").option("--auth <mode>", "auth mode: none or basic", "none").option("--password-env <name>", "env var for basic-auth password").option("--open", "open browser locally when host is localhost").action((opts) => {
10787
+ runCommand(() => studioCommand(opts));
10788
+ });
10718
10789
  program.command("eval").description("Run deterministic local evals against a trace").argument("<trace-path-or-run-id>", "trace file, directory, stdin -, or run id").option("--dir <path>", "trace directory for run-id lookup").addOption(
10719
10790
  new Option("--format <format>", "trace input format").choices([
10720
10791
  "agent-inspect-jsonl",
@@ -10986,7 +11057,7 @@ function createCliProgram() {
10986
11057
  runCommand(() => workspacePathCommand(opts));
10987
11058
  });
10988
11059
  const suiteCmd = program.command("suite").description("Define and run local trace suites for CI (v5.0+)");
10989
- suiteCmd.command("init").description("Create a starter agent-inspect.suite.json").option("--dry-run", "show planned files without writing").option("--json", "print deterministic JSON result").action((opts) => {
11060
+ suiteCmd.command("init").description("Create a starter agent-inspect.suite.json").option("--template <name>", "PM/QA template id (v5.4+)").option("--dry-run", "show planned files without writing").option("--json", "print deterministic JSON result").action((opts) => {
10990
11061
  runCommand(() => suiteInitCommand(opts));
10991
11062
  });
10992
11063
  suiteCmd.command("validate").description("Validate suite config shape and trace paths").option("--config <path>", "suite config path").option("--json", "print deterministic JSON result").action((opts) => {