@mcpjam/cli 3.10.1 → 3.11.1

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/index.js CHANGED
@@ -9,7 +9,7 @@ import { randomUUID } from 'crypto';
9
9
  import { spawn } from 'child_process';
10
10
  import { createRequire } from 'module';
11
11
  import os, { homedir } from 'os';
12
- import { listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, listEvalCasesOperation, getEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createHostOperation, updateHostOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation } from '@mcpjam/sdk/platform';
12
+ import { cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createHostOperation, updateHostOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation } from '@mcpjam/sdk/platform';
13
13
  import { HOST_TEMPLATES as HOST_TEMPLATES$1 } from '@mcpjam/sdk/host-config/templates';
14
14
  import { StdioServerTransport, McpServer } from '@modelcontextprotocol/server';
15
15
  import { z } from 'zod';
@@ -21,7 +21,7 @@ import { WebSocket } from 'ws';
21
21
 
22
22
  // package.json
23
23
  var package_default = {
24
- version: "3.10.1"};
24
+ version: "3.11.1"};
25
25
 
26
26
  // src/lib/output.ts
27
27
  var DEFAULT_OUTPUT_FORMAT = "json";
@@ -3400,25 +3400,51 @@ function extractRenderedScreenshots(result) {
3400
3400
  const root = asRecord(result);
3401
3401
  if (!root) return [];
3402
3402
  const trace = asRecord(root.trace) ?? root;
3403
- const observations = trace.widgetRenderObservations;
3404
- if (!Array.isArray(observations)) return [];
3405
3403
  const screenshots = [];
3406
- for (const entry of observations) {
3407
- const obs = asRecord(entry);
3408
- if (!obs) continue;
3409
- const status = asString(obs.status);
3410
- const screenshotUrl = asString(obs.screenshotUrl);
3411
- if (status !== "rendered" || !screenshotUrl) continue;
3412
- screenshots.push({
3413
- status,
3414
- screenshotUrl,
3415
- toolName: asString(obs.toolName),
3416
- toolCallId: asString(obs.toolCallId),
3417
- promptIndex: typeof obs.promptIndex === "number" ? obs.promptIndex : void 0
3418
- });
3404
+ const observations = trace.widgetRenderObservations;
3405
+ if (Array.isArray(observations)) {
3406
+ for (const entry of observations) {
3407
+ const obs = asRecord(entry);
3408
+ if (!obs) continue;
3409
+ const status = asString(obs.status);
3410
+ const screenshotUrl = asString(obs.screenshotUrl);
3411
+ if (status !== "rendered" || !screenshotUrl) continue;
3412
+ screenshots.push({
3413
+ status,
3414
+ screenshotUrl,
3415
+ toolName: asString(obs.toolName),
3416
+ toolCallId: asString(obs.toolCallId),
3417
+ promptIndex: typeof obs.promptIndex === "number" ? obs.promptIndex : void 0
3418
+ });
3419
+ }
3420
+ }
3421
+ const interactions = trace.browserInteractionSteps;
3422
+ if (Array.isArray(interactions)) {
3423
+ for (const entry of interactions) {
3424
+ const step = asRecord(entry);
3425
+ if (!step) continue;
3426
+ const screenshotUrl = asString(step.screenshotUrl);
3427
+ if (!screenshotUrl) continue;
3428
+ const assertion = asRecord(step.assertion);
3429
+ const status = assertion ? assertion.passed === true ? "assert:passed" : "assert:failed" : asString(step.action) ?? "interaction";
3430
+ const label = asString(step.locatorLabel) ?? asString(step.action) ?? "interaction";
3431
+ screenshots.push({
3432
+ status,
3433
+ screenshotUrl,
3434
+ toolName: label,
3435
+ toolCallId: asString(step.toolCallId),
3436
+ promptIndex: typeof step.promptIndex === "number" ? step.promptIndex : void 0
3437
+ });
3438
+ }
3419
3439
  }
3420
3440
  return screenshots;
3421
3441
  }
3442
+ function extractIterationVideoUrl(result) {
3443
+ const root = asRecord(result);
3444
+ if (!root) return void 0;
3445
+ const trace = asRecord(root.trace) ?? root;
3446
+ return asString(trace.videoUrl);
3447
+ }
3422
3448
  function screenshotFilename(shot, index) {
3423
3449
  const tool = (shot.toolName ?? "widget").replace(/[^a-zA-Z0-9_-]+/g, "-");
3424
3450
  const suffix = shot.toolCallId ? shot.toolCallId.replace(/[^a-zA-Z0-9_-]+/g, "-") : String(index + 1);
@@ -3647,7 +3673,7 @@ function buildCaseInput(options, opts) {
3647
3673
  if (options.title !== void 0) input.title = options.title;
3648
3674
  return input;
3649
3675
  }
3650
- async function fetchScreenshotBytes(url, timeoutMs) {
3676
+ async function fetchArtifactBytes(url, timeoutMs, kind = "screenshot") {
3651
3677
  const controller = new AbortController();
3652
3678
  const handle = setTimeout(() => controller.abort(), timeoutMs);
3653
3679
  handle.unref?.();
@@ -3655,7 +3681,7 @@ async function fetchScreenshotBytes(url, timeoutMs) {
3655
3681
  const response = await fetch(url, { signal: controller.signal });
3656
3682
  if (!response.ok) {
3657
3683
  throw operationalError(
3658
- `Failed to download screenshot (HTTP ${response.status}).`,
3684
+ `Failed to download ${kind} (HTTP ${response.status}).`,
3659
3685
  { url }
3660
3686
  );
3661
3687
  }
@@ -3663,7 +3689,7 @@ async function fetchScreenshotBytes(url, timeoutMs) {
3663
3689
  } catch (error) {
3664
3690
  if (error instanceof Error && error.name === "AbortError") {
3665
3691
  throw operationalError(
3666
- `Timed out downloading screenshot after ${timeoutMs}ms.`,
3692
+ `Timed out downloading ${kind} after ${timeoutMs}ms.`,
3667
3693
  { url }
3668
3694
  );
3669
3695
  }
@@ -3672,6 +3698,9 @@ async function fetchScreenshotBytes(url, timeoutMs) {
3672
3698
  clearTimeout(handle);
3673
3699
  }
3674
3700
  }
3701
+ function fetchScreenshotBytes(url, timeoutMs) {
3702
+ return fetchArtifactBytes(url, timeoutMs, "screenshot");
3703
+ }
3675
3704
  function resolveScreenshotPath(out, shot, index, total) {
3676
3705
  const looksLikeDir = out.endsWith("/") || existsSync(out) && statSync(out).isDirectory();
3677
3706
  if (looksLikeDir) {
@@ -3777,6 +3806,20 @@ function registerEvalCommands(program) {
3777
3806
  writeResult(result, globalOptions.format);
3778
3807
  }
3779
3808
  );
3809
+ addPlatformOptions(
3810
+ evals.command("cancel").description(
3811
+ "Cancel an in-flight eval run (no-op if already cancelled; errors if it already finished)"
3812
+ ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption("--project <id-or-name>", "Project name or ID")
3813
+ ).action(
3814
+ async (options, command) => {
3815
+ await executeOp(
3816
+ cancelEvalRunOperation,
3817
+ { project: options.project, runId: options.run },
3818
+ options,
3819
+ command
3820
+ );
3821
+ }
3822
+ );
3780
3823
  const PROJECT_OPT = "Project name or ID (defaults to most recently updated)";
3781
3824
  addPlatformOptions(
3782
3825
  evals.command("iterations").description(
@@ -3820,6 +3863,30 @@ function registerEvalCommands(program) {
3820
3863
  );
3821
3864
  }
3822
3865
  );
3866
+ addPlatformOptions(
3867
+ evals.command("steps").description(
3868
+ "Per-authored-step results for one eval iteration: status (ok/fail/skipped/pending), reason, and evidence (screenshot/video URLs). The fastest way to see WHICH step failed and why."
3869
+ ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
3870
+ "--iteration <id>",
3871
+ "Iteration ID (from `eval iterations`)"
3872
+ ).requiredOption(
3873
+ "--project <id-or-name>",
3874
+ "Project the run belongs to (name or ID)"
3875
+ )
3876
+ ).action(
3877
+ async (options, command) => {
3878
+ await executeOp(
3879
+ getEvalRunStepsOperation,
3880
+ {
3881
+ project: options.project,
3882
+ runId: options.run,
3883
+ iterationId: options.iteration
3884
+ },
3885
+ options,
3886
+ command
3887
+ );
3888
+ }
3889
+ );
3823
3890
  addPlatformOptions(
3824
3891
  evals.command("screenshot").description(
3825
3892
  "Show the widget screenshot(s) an eval iteration rendered \u2014 inline when the terminal supports it, otherwise the image URL"
@@ -3928,6 +3995,70 @@ function registerEvalCommands(program) {
3928
3995
  }
3929
3996
  }
3930
3997
  );
3998
+ addPlatformOptions(
3999
+ evals.command("video").description(
4000
+ "Get the Playwright replay video (.webm) an eval iteration recorded \u2014 prints the URL, or downloads it with --out"
4001
+ ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
4002
+ "--iteration <id>",
4003
+ "Iteration ID (from `eval iterations`)"
4004
+ ).requiredOption(
4005
+ "--project <id-or-name>",
4006
+ "Project the run belongs to (name or ID)"
4007
+ ).option("--out <path>", "Download the .webm to this file instead of printing the URL")
4008
+ ).action(
4009
+ async (options, command) => {
4010
+ const globalOptions = getGlobalOptions(command);
4011
+ const result = await runPlatformCommand(
4012
+ options,
4013
+ globalOptions.timeout,
4014
+ ({ client, signal }) => getEvalIterationTraceOperation.execute(
4015
+ {
4016
+ project: options.project,
4017
+ runId: options.run,
4018
+ iterationId: options.iteration
4019
+ },
4020
+ { client, signal }
4021
+ )
4022
+ );
4023
+ const videoUrl = extractIterationVideoUrl(result);
4024
+ const base = {
4025
+ project: result.project,
4026
+ runId: result.runId,
4027
+ iterationId: result.iterationId
4028
+ };
4029
+ const isJson = globalOptions.format === "json";
4030
+ if (!videoUrl) {
4031
+ if (isJson) {
4032
+ writeResult({ ...base, videoUrl: null });
4033
+ return;
4034
+ }
4035
+ process.stdout.write("No replay video for this iteration.\n");
4036
+ return;
4037
+ }
4038
+ if (options.out !== void 0) {
4039
+ const bytes = await fetchArtifactBytes(
4040
+ videoUrl,
4041
+ globalOptions.timeout,
4042
+ "video"
4043
+ );
4044
+ mkdirSync(dirname(options.out), { recursive: true });
4045
+ writeFileSync(options.out, bytes);
4046
+ if (isJson) {
4047
+ writeResult({ ...base, videoUrl, savedTo: options.out });
4048
+ return;
4049
+ }
4050
+ process.stdout.write(`Saved replay video \u2192 ${options.out}
4051
+ `);
4052
+ return;
4053
+ }
4054
+ if (isJson) {
4055
+ writeResult({ ...base, videoUrl });
4056
+ return;
4057
+ }
4058
+ process.stdout.write(`${videoUrl}
4059
+ `);
4060
+ }
4061
+ );
3931
4062
  addPlatformOptions(
3932
4063
  evals.command("get").description("Show an eval suite's full settings").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT)
3933
4064
  ).action(
@@ -4010,6 +4141,28 @@ function registerEvalCommands(program) {
4010
4141
  );
4011
4142
  }
4012
4143
  );
4144
+ addPlatformOptions(
4145
+ cases.command("run").description(
4146
+ "Run a single case as a persisted, fully-queryable run (inspect it with `eval iterations` / `eval steps` like any run)"
4147
+ ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").requiredOption("--case <id-or-title>", "Eval case title or ID").option("--project <id-or-name>", PROJECT_OPT).option(
4148
+ "--server <id-or-name...>",
4149
+ "Override the suite's saved servers for this run"
4150
+ )
4151
+ ).action(
4152
+ async (options, command) => {
4153
+ await executeOp(
4154
+ runEvalCaseOperation,
4155
+ {
4156
+ project: options.project,
4157
+ suite: options.suite,
4158
+ case: options.case,
4159
+ ...options.server?.length ? { servers: options.server } : {}
4160
+ },
4161
+ options,
4162
+ command
4163
+ );
4164
+ }
4165
+ );
4013
4166
  addPlatformOptions(
4014
4167
  cases.command("create").description("Add a test case to a suite (definition via --file/--json)").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--file <path>", "Case JSON body (or - for stdin)").option("--json <json>", "Inline case JSON (or @file, or -)").option("--title <title>", "Case title (overrides the body)")
4015
4168
  ).action(async (options, command) => {