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.
@@ -8263,6 +8263,120 @@ var init_report = __esm({
8263
8263
  }
8264
8264
  });
8265
8265
 
8266
+ // packages/core/src/suite/templates.ts
8267
+ function baseTemplate(name, cases) {
8268
+ return {
8269
+ name,
8270
+ traces: "./.agent-inspect",
8271
+ cases,
8272
+ checks: {
8273
+ select: ["run.status", "outcome.status"],
8274
+ run: { maxDurationMs: 6e4 }
8275
+ },
8276
+ redactionProfile: "local",
8277
+ artifacts: { outputDir: ".agent-inspect/suite-runs" }
8278
+ };
8279
+ }
8280
+ function getSuiteTemplate(id) {
8281
+ if (!SUITE_TEMPLATE_IDS.includes(id)) return void 0;
8282
+ return structuredClone(TEMPLATES[id]);
8283
+ }
8284
+ function resolveSuiteTemplate(id) {
8285
+ const template = getSuiteTemplate(id);
8286
+ if (template === void 0) {
8287
+ throw new Error(
8288
+ `Unknown suite template "${id}". Available: ${SUITE_TEMPLATE_IDS.join(", ")}`
8289
+ );
8290
+ }
8291
+ return template;
8292
+ }
8293
+ var SUITE_TEMPLATE_IDS, TEMPLATES;
8294
+ var init_templates = __esm({
8295
+ "packages/core/src/suite/templates.ts"() {
8296
+ SUITE_TEMPLATE_IDS = [
8297
+ "customer-support-agent",
8298
+ "refund-agent",
8299
+ "sales-assistant",
8300
+ "browser-task-agent",
8301
+ "mcp-tool-agent",
8302
+ "workflow-agent",
8303
+ "rag-answer-agent",
8304
+ "human-approval-agent"
8305
+ ];
8306
+ TEMPLATES = {
8307
+ "customer-support-agent": baseTemplate("customer-support-agent", [
8308
+ {
8309
+ id: "support-ticket",
8310
+ runId: "support-ticket",
8311
+ requireTools: ["searchDocs"],
8312
+ forbidTools: ["deleteAccount"],
8313
+ expectedObservations: ["answerReady"],
8314
+ maxDurationMs: 45e3
8315
+ }
8316
+ ]),
8317
+ "refund-agent": baseTemplate("refund-agent", [
8318
+ {
8319
+ id: "refund-flow",
8320
+ runId: "refund-flow",
8321
+ requireTools: ["searchDocs"],
8322
+ forbidTools: ["deleteAccount"],
8323
+ expectedObservations: ["policyShown"],
8324
+ maxDurationMs: 3e4
8325
+ }
8326
+ ]),
8327
+ "sales-assistant": baseTemplate("sales-assistant", [
8328
+ {
8329
+ id: "quote-request",
8330
+ runId: "quote-request",
8331
+ requireTools: ["lookupPricing"],
8332
+ maxDurationMs: 3e4
8333
+ }
8334
+ ]),
8335
+ "browser-task-agent": baseTemplate("browser-task-agent", [
8336
+ {
8337
+ id: "browser-nav",
8338
+ runId: "browser-nav",
8339
+ requireTools: ["browserNavigate"],
8340
+ maxDurationMs: 12e4
8341
+ }
8342
+ ]),
8343
+ "mcp-tool-agent": baseTemplate("mcp-tool-agent", [
8344
+ {
8345
+ id: "mcp-call",
8346
+ runId: "mcp-call",
8347
+ requireTools: ["mcp:tools/list"],
8348
+ maxDurationMs: 3e4
8349
+ }
8350
+ ]),
8351
+ "workflow-agent": baseTemplate("workflow-agent", [
8352
+ {
8353
+ id: "workflow-handoff",
8354
+ runId: "workflow-handoff",
8355
+ requireTools: ["handoff"],
8356
+ maxDurationMs: 6e4
8357
+ }
8358
+ ]),
8359
+ "rag-answer-agent": baseTemplate("rag-answer-agent", [
8360
+ {
8361
+ id: "rag-answer",
8362
+ runId: "rag-answer",
8363
+ requireTools: ["retrieve", "answer"],
8364
+ expectedObservations: ["citationShown"],
8365
+ maxDurationMs: 45e3
8366
+ }
8367
+ ]),
8368
+ "human-approval-agent": baseTemplate("human-approval-agent", [
8369
+ {
8370
+ id: "approval-gate",
8371
+ runId: "approval-gate",
8372
+ expectedObservations: ["approvalRequested", "approvalGranted"],
8373
+ maxDurationMs: 6e4
8374
+ }
8375
+ ])
8376
+ };
8377
+ }
8378
+ });
8379
+
8266
8380
  // packages/core/src/suite/index.ts
8267
8381
  var init_suite = __esm({
8268
8382
  "packages/core/src/suite/index.ts"() {
@@ -8272,6 +8386,7 @@ var init_suite = __esm({
8272
8386
  init_resolve2();
8273
8387
  init_run();
8274
8388
  init_report();
8389
+ init_templates();
8275
8390
  }
8276
8391
  });
8277
8392
 
@@ -9416,6 +9531,7 @@ var init_advanced = __esm({
9416
9531
  init_duration();
9417
9532
  init_bundle();
9418
9533
  init_suite();
9534
+ init_templates();
9419
9535
  init_extract();
9420
9536
  init_cohort2();
9421
9537
  init_gate();
@@ -10613,7 +10729,7 @@ var init_src = __esm({
10613
10729
  });
10614
10730
 
10615
10731
  // package.json
10616
- var version = "5.3.0";
10732
+ var version = "6.0.0";
10617
10733
 
10618
10734
  // packages/cli/src/list.ts
10619
10735
  init_advanced();
@@ -17783,6 +17899,63 @@ async function serveCommand(options = {}) {
17783
17899
  });
17784
17900
  }
17785
17901
 
17902
+ // packages/cli/src/studio-cmd.ts
17903
+ var PACKAGE = "@agent-inspect/studio";
17904
+ function isModuleNotFound3(e) {
17905
+ return e !== null && typeof e === "object" && "code" in e && (e.code === "ERR_MODULE_NOT_FOUND" || e.code === "MODULE_NOT_FOUND");
17906
+ }
17907
+ async function loadStudio() {
17908
+ try {
17909
+ return await import('@agent-inspect/studio');
17910
+ } catch (e) {
17911
+ if (isModuleNotFound3(e)) {
17912
+ console.error(
17913
+ `The optional Studio analyzer is not installed. Run: npm install ${PACKAGE}`
17914
+ );
17915
+ process.exitCode = 1;
17916
+ return null;
17917
+ }
17918
+ const msg = e instanceof Error ? e.message : String(e);
17919
+ console.error(`[AgentInspect] failed to load ${PACKAGE}: ${msg}`);
17920
+ process.exitCode = 1;
17921
+ return null;
17922
+ }
17923
+ }
17924
+ function parsePort2(value) {
17925
+ if (value === void 0) return void 0;
17926
+ const parsed = Number(value);
17927
+ if (!Number.isInteger(parsed) || parsed <= 0 || parsed > 65535) {
17928
+ throw new Error("--port must be an integer between 1 and 65535.");
17929
+ }
17930
+ return parsed;
17931
+ }
17932
+ async function studioCommand(options = {}) {
17933
+ const mod = await loadStudio();
17934
+ if (!mod) return;
17935
+ const port = parsePort2(options.port);
17936
+ const host = options.host?.trim();
17937
+ const info = await mod.startStudioServer({
17938
+ ...host !== void 0 && host.length > 0 ? { host } : {},
17939
+ ...port !== void 0 ? { port } : {},
17940
+ ...options.workspace !== void 0 ? { workspacePath: options.workspace } : {},
17941
+ ...options.db !== void 0 ? { dbPath: options.db } : {},
17942
+ ...options.server === true ? { server: true } : {},
17943
+ ...options.cwd !== void 0 ? { cwd: options.cwd } : {},
17944
+ ...options.auth === "basic" ? { auth: "basic" } : {},
17945
+ ...options.passwordEnv !== void 0 ? { passwordEnv: options.passwordEnv } : {}
17946
+ });
17947
+ console.log(`AgentInspect studio (read-only): ${info.url}`);
17948
+ if (options.open === true && info.host !== "127.0.0.1" && info.host !== "localhost") {
17949
+ console.warn("Skipping browser open for non-local host binding.");
17950
+ } else if (options.open === true) {
17951
+ const openMod = await import('child_process');
17952
+ openMod.exec(`open ${info.url}`, () => {
17953
+ });
17954
+ }
17955
+ await new Promise(() => {
17956
+ });
17957
+ }
17958
+
17786
17959
  // packages/eval/src/index.ts
17787
17960
  function isTraceReadResult(value) {
17788
17961
  return value !== null && typeof value === "object" && "runs" in value && "events" in value && "format" in value;
@@ -20585,23 +20758,23 @@ async function indexCleanCommand(options = {}) {
20585
20758
 
20586
20759
  // packages/cli/src/index-sqlite-cmd.ts
20587
20760
  init_advanced();
20588
- var PACKAGE = "@agent-inspect/index-sqlite";
20589
- function isModuleNotFound3(e) {
20761
+ var PACKAGE2 = "@agent-inspect/index-sqlite";
20762
+ function isModuleNotFound4(e) {
20590
20763
  return e !== null && typeof e === "object" && "code" in e && (e.code === "ERR_MODULE_NOT_FOUND" || e.code === "MODULE_NOT_FOUND");
20591
20764
  }
20592
20765
  async function loadIndexSqlite() {
20593
20766
  try {
20594
20767
  return await Promise.resolve().then(() => (init_src(), src_exports));
20595
20768
  } catch (e) {
20596
- if (isModuleNotFound3(e)) {
20769
+ if (isModuleNotFound4(e)) {
20597
20770
  console.error(
20598
- `The optional SQLite index is not installed. Run: npm install ${PACKAGE}`
20771
+ `The optional SQLite index is not installed. Run: npm install ${PACKAGE2}`
20599
20772
  );
20600
20773
  process.exitCode = 1;
20601
20774
  return null;
20602
20775
  }
20603
20776
  const msg = e instanceof Error ? e.message : String(e);
20604
- console.error(`[AgentInspect] failed to load ${PACKAGE}: ${msg}`);
20777
+ console.error(`[AgentInspect] failed to load ${PACKAGE2}: ${msg}`);
20605
20778
  process.exitCode = 1;
20606
20779
  return null;
20607
20780
  }
@@ -20881,30 +21054,39 @@ function resolveCwd(options) {
20881
21054
  async function suiteInitCommand(options = {}) {
20882
21055
  const cwd = resolveCwd(options);
20883
21056
  const configPath = path26__default.default.join(cwd, DEFAULT_CONFIG_FILENAME);
20884
- const template = defaultSuiteConfigTemplate();
21057
+ const template = options.template?.trim();
21058
+ const suiteConfig = template !== void 0 && template !== "" ? resolveSuiteTemplate(template) : defaultSuiteConfigTemplate();
20885
21059
  if (options.dryRun) {
20886
21060
  if (options.json) {
20887
21061
  printJson5({
20888
21062
  ok: true,
20889
21063
  dryRun: true,
20890
21064
  wouldWrite: [DEFAULT_CONFIG_FILENAME],
20891
- config: template
21065
+ config: suiteConfig,
21066
+ ...template ? { template } : {}
20892
21067
  });
20893
21068
  return;
20894
21069
  }
20895
21070
  console.log("Dry run \u2014 would create:");
20896
21071
  console.log(`- ${DEFAULT_CONFIG_FILENAME}`);
21072
+ if (template) console.log(` template: ${template}`);
20897
21073
  return;
20898
21074
  }
20899
21075
  try {
20900
- await promises.writeFile(configPath, `${JSON.stringify(template, null, 2)}
21076
+ await promises.writeFile(configPath, `${JSON.stringify(suiteConfig, null, 2)}
20901
21077
  `, "utf-8");
20902
21078
  if (options.json) {
20903
- printJson5({ ok: true, created: [DEFAULT_CONFIG_FILENAME], configPath });
21079
+ printJson5({
21080
+ ok: true,
21081
+ created: [DEFAULT_CONFIG_FILENAME],
21082
+ configPath,
21083
+ ...template ? { template } : {}
21084
+ });
20904
21085
  return;
20905
21086
  }
20906
21087
  console.log("Created suite config:");
20907
21088
  console.log(`- ${DEFAULT_CONFIG_FILENAME}`);
21089
+ if (template) console.log(` template: ${template}`);
20908
21090
  console.log("\nNext:");
20909
21091
  console.log(" npx agent-inspect suite validate");
20910
21092
  console.log(" npx agent-inspect suite run --json");
@@ -21440,6 +21622,11 @@ function createCliProgram() {
21440
21622
  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) => {
21441
21623
  runCommand(() => serveCommand(opts));
21442
21624
  });
21625
+ program.command("studio").description(
21626
+ "Start self-hosted read-only Studio analyzer (requires @agent-inspect/studio) (v6.0+)"
21627
+ ).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) => {
21628
+ runCommand(() => studioCommand(opts));
21629
+ });
21443
21630
  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(
21444
21631
  new commander.Option("--format <format>", "trace input format").choices([
21445
21632
  "agent-inspect-jsonl",
@@ -21711,7 +21898,7 @@ function createCliProgram() {
21711
21898
  runCommand(() => workspacePathCommand(opts));
21712
21899
  });
21713
21900
  const suiteCmd = program.command("suite").description("Define and run local trace suites for CI (v5.0+)");
21714
- 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) => {
21901
+ 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) => {
21715
21902
  runCommand(() => suiteInitCommand(opts));
21716
21903
  });
21717
21904
  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) => {