@mcpjam/cli 5.13.0 → 5.14.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
@@ -29,7 +29,7 @@ import { selectPluginMcpServerMap, detectPluginMcpTransport } from '@mcpjam/sdk/
29
29
 
30
30
  // package.json
31
31
  var package_default = {
32
- version: "5.13.0"};
32
+ version: "5.14.1"};
33
33
  function conformanceExitCode(result) {
34
34
  if (result.outcome === "incomplete") return 3;
35
35
  if (result.outcome === "failed") return 1;
@@ -7471,7 +7471,11 @@ function compareGateInputFrom(compare, latency = {}) {
7471
7471
  }
7472
7472
  function flakyInputFrom(iterations) {
7473
7473
  return iterations.filter(
7474
- (iteration) => iteration.result === "passed" || iteration.result === "failed"
7474
+ (iteration) => (
7475
+ // An infra-failed trial (`infraError`) is stored `failed` but
7476
+ // measured nothing; counting it would fabricate a flake.
7477
+ !iteration.infraError && (iteration.result === "passed" || iteration.result === "failed")
7478
+ )
7475
7479
  ).map((iteration) => ({
7476
7480
  // Falls back to the iteration's own id, never a shared literal: a
7477
7481
  // single "unknown" bucket would pool unrelated iterations, and one pass
@@ -10741,6 +10745,147 @@ function registerEvalCommands(program) {
10741
10745
  );
10742
10746
  }
10743
10747
  );
10748
+ addProjectOption(
10749
+ evals.command("rerun").description(
10750
+ "Rerun a finished eval run's failed cases as a new run. The platform picks the cases: any with a trial that did not complete and pass (cancelled and skipped trials do not count)"
10751
+ ).argument("<run-id>", "Eval run ID to rerun (from `eval run`)").option(
10752
+ "--failed",
10753
+ "Rerun only the cases that did not pass (required; the only rerun scope)"
10754
+ ).option(
10755
+ "--dry-run",
10756
+ "Show which cases would rerun, and why, without starting anything"
10757
+ ).option("--notes <text>", "Free-text note stored on the new run").option(
10758
+ "--idempotency-key <key>",
10759
+ "Retry-safety key: repeating the call returns the run it already started"
10760
+ ).option("--wait", "Wait for the rerun to reach a terminal status").option(
10761
+ "--wait-timeout <ms>",
10762
+ "Maximum time to wait for completion (default 2100000; a run held for its judge gets up to 31 more minutes unless this flag is set)"
10763
+ ).option("--json", "Print machine-readable JSON (same as --format json)")
10764
+ ).action(
10765
+ async (runId, options, command) => {
10766
+ if (!options.failed) {
10767
+ throw usageError(
10768
+ "Pass --failed: rerunning the cases that did not pass is the only rerun scope."
10769
+ );
10770
+ }
10771
+ if (options.waitTimeout !== void 0 && !options.wait) {
10772
+ throw usageError("--wait-timeout requires --wait.");
10773
+ }
10774
+ if (options.dryRun && options.wait) {
10775
+ throw usageError("--dry-run starts nothing, so it cannot --wait.");
10776
+ }
10777
+ const globalOptions = getGlobalOptions(command);
10778
+ const format = options.json ? "json" : globalOptions.format;
10779
+ const waitTimeoutMs = options.waitTimeout !== void 0 ? parsePositiveInteger(options.waitTimeout, "--wait-timeout") : DEFAULT_RUN_WAIT_TIMEOUT_MS;
10780
+ const gradingExtensionMs = options.waitTimeout !== void 0 ? 0 : GRADING_WAIT_EXTENSION_MS;
10781
+ const resolved = resolveCloudProjectArgs(options);
10782
+ let webOrigin = DEFAULT_PLATFORM_ORIGIN;
10783
+ let outcome;
10784
+ try {
10785
+ outcome = await runPlatformOperation(
10786
+ platformOptionsOf(command),
10787
+ options.wait ? Math.max(
10788
+ globalOptions.timeout,
10789
+ waitTimeoutMs + gradingExtensionMs
10790
+ ) : globalOptions.timeout,
10791
+ async (context) => {
10792
+ webOrigin = context.webOrigin;
10793
+ const { client, signal } = context;
10794
+ const projects = await client.listProjects({}, { signal });
10795
+ const resolution = resolveProject(projects.items, resolved.project);
10796
+ if (!resolution.ok) {
10797
+ throw usageError(
10798
+ appendProjectLinkHint(resolution.message, resolved.projectScope)
10799
+ );
10800
+ }
10801
+ const projectId = resolution.project.id;
10802
+ if (options.dryRun) {
10803
+ const preview = await client.getEvalRunRerunPreview(
10804
+ { projectId, runId },
10805
+ { signal }
10806
+ );
10807
+ return { projectId, preview };
10808
+ }
10809
+ const rerun2 = await client.rerunEvalRun(
10810
+ {
10811
+ projectId,
10812
+ runId,
10813
+ scope: "failed_cases",
10814
+ ...options.notes !== void 0 ? { notes: options.notes } : {},
10815
+ ...options.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {}
10816
+ },
10817
+ { signal }
10818
+ );
10819
+ if (!options.wait) return { projectId, rerun: rerun2 };
10820
+ try {
10821
+ const run2 = await waitForEvalRun(
10822
+ client,
10823
+ signal,
10824
+ projectId,
10825
+ rerun2.runId,
10826
+ Date.now() + waitTimeoutMs,
10827
+ gradingExtensionMs
10828
+ );
10829
+ return { projectId, rerun: rerun2, run: run2 };
10830
+ } catch (error) {
10831
+ return {
10832
+ projectId,
10833
+ rerun: rerun2,
10834
+ waitError: {
10835
+ message: error instanceof Error ? error.message : String(error),
10836
+ ...isPlatformApiError(error) ? { errorCode: error.code } : {}
10837
+ }
10838
+ };
10839
+ }
10840
+ },
10841
+ { projectScope: resolved.projectScope, quiet: globalOptions.quiet }
10842
+ );
10843
+ } catch (error) {
10844
+ if (options.wait && error instanceof CliError && error.exitCode !== 2) {
10845
+ throw new CliError(
10846
+ error.code,
10847
+ error.message,
10848
+ classifyLaunchErrorExitCode(error.code, error.details),
10849
+ error.details
10850
+ );
10851
+ }
10852
+ throw error;
10853
+ }
10854
+ if ("preview" in outcome) {
10855
+ writeResult({ preview: outcome.preview }, format);
10856
+ if (outcome.preview?.rerunnable !== true) setProcessExitCode(1);
10857
+ return;
10858
+ }
10859
+ const { rerun } = outcome;
10860
+ const run = "run" in outcome ? outcome.run : void 0;
10861
+ const waitError = "waitError" in outcome ? outcome.waitError : void 0;
10862
+ writeResult(
10863
+ { rerun, ...run ? { run } : {}, ...waitError ? { waitError } : {} },
10864
+ format
10865
+ );
10866
+ writeRunLink(format, webOrigin, {
10867
+ projectId: outcome.projectId,
10868
+ suiteId: rerun.suiteId,
10869
+ runId: rerun.runId
10870
+ });
10871
+ if (waitError) {
10872
+ throw cliError(
10873
+ "OPERATIONAL_ERROR",
10874
+ `Did not observe completion for: ${rerun.runId}. ${waitError.message}`,
10875
+ classifyWaitErrorExitCode(waitError.errorCode)
10876
+ );
10877
+ }
10878
+ if (run) {
10879
+ setProcessExitCode(
10880
+ evalRunWaitExitCode({
10881
+ launchOutcome: "started",
10882
+ runs: [{ status: run.status, result: run.result }],
10883
+ waitErrors: []
10884
+ })
10885
+ );
10886
+ }
10887
+ }
10888
+ );
10744
10889
  addProjectOption(
10745
10890
  evals.command("judge-backtest").description(
10746
10891
  "Preview draft grading instructions on recorded evidence (uses credits)"
@@ -12554,9 +12699,22 @@ function registerGoalsCommands(program) {
12554
12699
  "Fan out across this project environment instead of the goal's authored targets (repeatable)",
12555
12700
  collectRepeatable2,
12556
12701
  []
12702
+ ).option(
12703
+ "--expected-sponsored <n>",
12704
+ "How many of this launch's conversations you expect to be sponsored (paid from MCPJam's allowance instead of your organization's credits). If the split differs the launch is refused with nothing created."
12557
12705
  ).action(
12558
12706
  async (options, command) => {
12559
12707
  const globalOptions = getGlobalOptions(command);
12708
+ let expectedSponsored;
12709
+ if (options.expectedSponsored !== void 0) {
12710
+ const raw = options.expectedSponsored.trim();
12711
+ expectedSponsored = /^\d+$/.test(raw) ? Number(raw) : Number.NaN;
12712
+ if (!Number.isSafeInteger(expectedSponsored)) {
12713
+ throw usageError(
12714
+ `--expected-sponsored must be a whole number, 0 or more (got "${options.expectedSponsored}")`
12715
+ );
12716
+ }
12717
+ }
12560
12718
  const result = await runPlatformOperation(
12561
12719
  platformOptionsOf(command),
12562
12720
  globalOptions.timeout,
@@ -12569,7 +12727,8 @@ function registerGoalsCommands(program) {
12569
12727
  // with the rest of the noun, and the conditional spread means
12570
12728
  // a stale key would be dropped in silence rather than refused.
12571
12729
  ...foldSwarmRunId(options) ? { swarmRunId: foldSwarmRunId(options) } : {},
12572
- ...options.environment?.length ? { environmentIds: options.environment } : {}
12730
+ ...options.environment?.length ? { environmentIds: options.environment } : {},
12731
+ ...expectedSponsored !== void 0 ? { expectedSponsored } : {}
12573
12732
  },
12574
12733
  { client, signal }
12575
12734
  )