@mcpjam/cli 3.18.0 → 3.20.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.
package/dist/index.js CHANGED
@@ -2,14 +2,14 @@
2
2
  import { Command, CommanderError } from 'commander';
3
3
  import { realpathSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, closeSync, renameSync, openSync } from 'fs';
4
4
  import { pathToFileURL } from 'url';
5
- import { probeMcpServer, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, classifyMcpHeader, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, SubscriptionCoordinator, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, MCPTasksConformanceTest, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, DEFAULT_SUBSCRIPTION_RECONNECT_POLICY, isKnownProtocolVersion, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeXaaClientAuth, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, getLocalConfidentialCimdProvider, MCP_PROTOCOL_VERSIONS, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, decodeMcpHeaderValue, canDeclareTasksExtension, createStrictElicitationContentValidator, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, MCP_TASKS_CHECK_CATEGORIES, MCP_TASKS_CHECK_IDS, OAuthProxyError, isLoopbackHost, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS, TaskLifecycleEngine, driveTaskToTerminal, extensionTaskToObservation, legacyTaskToObservation, isUnknownTaskError, isMCPTasksWireError, LEGACY_TASK_STATUSES } from '@mcpjam/sdk';
5
+ import { probeMcpServer, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, classifyMcpHeader, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, SubscriptionCoordinator, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, scoreFromAppsResult, MCPAppsConformanceSuite, MCPTasksConformanceTest, scoreFromTasksResult, runOAuthLogin, OAuthConformanceTest, scoreFromOAuthResult, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, scoreFromProtocolResult, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, DEFAULT_SUBSCRIPTION_RECONNECT_POLICY, isKnownProtocolVersion, describeConformanceScore, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeXaaClientAuth, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, getLocalConfidentialCimdProvider, MCP_PROTOCOL_VERSIONS, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, decodeMcpHeaderValue, canDeclareTasksExtension, createStrictElicitationContentValidator, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, MCP_TASKS_CHECK_CATEGORIES, MCP_TASKS_CHECK_IDS, OAuthProxyError, isLoopbackHost, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS, TaskLifecycleEngine, driveTaskToTerminal, extensionTaskToObservation, legacyTaskToObservation, isUnknownTaskError, isMCPTasksWireError, LEGACY_TASK_STATUSES } from '@mcpjam/sdk';
6
6
  import { mkdir, writeFile, readFile, chmod, rename, rm } from 'fs/promises';
7
7
  import path2, { dirname, join, basename } from 'path';
8
8
  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 { cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createHostOperation, updateHostOperation, createEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, resolveEnvironmentOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation } from '@mcpjam/sdk/platform';
12
+ import { createProjectOperation, updateProjectOperation, deleteProjectOperation, listEvalSuiteRunsOperation, cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, listChatboxesOperation, getChatboxOperation, listChatSessionsOperation, createHostOperation, updateHostOperation, setHostServersOperation, duplicateHostOperation, createEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, createProjectServerOperation, getProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, resolveEnvironmentOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, publishScenarioOperation, unpublishScenarioOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation } from '@mcpjam/sdk/platform';
13
13
  import { buildHostProfilesFromCatalog, buildMarketHostProfiles, scanWidgetUsage, evaluateMarketHosts, fetchHostCompatCatalog } from '@mcpjam/sdk/host-compat';
14
14
  import { HOST_TEMPLATES as HOST_TEMPLATES$1, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
15
15
  import { applyVisibilityPolicyAndCountSignals, isAppOnlyTool, extractHostExecutionPolicy, hostConnectionProfile } from '@mcpjam/sdk/host-config/internal';
@@ -25,7 +25,46 @@ import { WebSocket } from 'ws';
25
25
 
26
26
  // package.json
27
27
  var package_default = {
28
- version: "3.18.0"};
28
+ version: "3.20.0"};
29
+ function conformanceExitCode(result) {
30
+ if (result.outcome === "incomplete") return 3;
31
+ if (result.outcome === "failed") return 1;
32
+ return result.passed ? 0 : 1;
33
+ }
34
+ function conformanceSuiteExitCode(results) {
35
+ const codes = results.map(conformanceExitCode);
36
+ if (codes.includes(1)) return 1;
37
+ if (codes.includes(3)) return 3;
38
+ return 0;
39
+ }
40
+ function reportScore(score, command, label) {
41
+ if (score.score === null) return;
42
+ if (command.optsWithGlobals().quiet) return;
43
+ process.stderr.write(
44
+ `Score${label ? ` [${label}]` : ""}: ${describeConformanceScore(score)}
45
+ `
46
+ );
47
+ }
48
+ function reportReadiness(result, command) {
49
+ const readiness = result.readiness ?? [];
50
+ if (readiness.length === 0) return;
51
+ if (command.optsWithGlobals().quiet) return;
52
+ process.stderr.write(`Advice (${readiness.length}):
53
+ `);
54
+ for (const advice of readiness) {
55
+ process.stderr.write(
56
+ ` [${advice.specStrength}] ${advice.title}: ${advice.message}
57
+ `
58
+ );
59
+ }
60
+ }
61
+ function reportIncomplete(result, command) {
62
+ const reason = result.incompleteReason;
63
+ if (!reason) return;
64
+ if (command.optsWithGlobals().quiet) return;
65
+ process.stderr.write(`Run incomplete: ${reason}
66
+ `);
67
+ }
29
68
 
30
69
  // src/lib/output.ts
31
70
  var DEFAULT_OUTPUT_FORMAT = "json";
@@ -2715,8 +2754,11 @@ function registerAppsCommands(program) {
2715
2754
  writeConformanceOutput(
2716
2755
  renderConformanceForCli(outputResult, reporter, globalOptions.format)
2717
2756
  );
2718
- if (!result.passed) {
2719
- setProcessExitCode(1);
2757
+ reportScore(scoreFromAppsResult(result), command);
2758
+ reportIncomplete(result, command);
2759
+ const exitCode = conformanceExitCode(result);
2760
+ if (exitCode !== 0) {
2761
+ setProcessExitCode(exitCode);
2720
2762
  }
2721
2763
  });
2722
2764
  addSharedServerOptions(
@@ -2964,8 +3006,13 @@ function registerAppsCommands(program) {
2964
3006
  writeConformanceOutput(
2965
3007
  renderConformanceForCli(outputResult, reporter, globalOptions.format)
2966
3008
  );
2967
- if (!result.passed) {
2968
- setProcessExitCode(1);
3009
+ for (const run of result.results) {
3010
+ reportScore(scoreFromAppsResult(run), command, run.label);
3011
+ reportIncomplete(run, command);
3012
+ }
3013
+ const exitCode = conformanceSuiteExitCode(result.results);
3014
+ if (exitCode !== 0) {
3015
+ setProcessExitCode(exitCode);
2969
3016
  }
2970
3017
  });
2971
3018
  }
@@ -3101,6 +3148,7 @@ async function clearStoredAuth(filePath) {
3101
3148
  }
3102
3149
 
3103
3150
  // src/lib/platform-auth.ts
3151
+ var DEFAULT_PLATFORM_ORIGIN = "https://app.mcpjam.com";
3104
3152
  var LEGACY_API_KEY_PREFIX = "mcpjam_";
3105
3153
  var TOKEN_REFRESH_SKEW_MS = 6e4;
3106
3154
  var DEFAULT_LOGIN_TIMEOUT_MS = 5 * 6e4;
@@ -3347,14 +3395,22 @@ function buildPlatformClient(options, deps = {}) {
3347
3395
  const stored = readStoredAuth(deps.authFilePath ?? getAuthFilePath({ env }));
3348
3396
  baseUrl = stored?.apiUrl;
3349
3397
  }
3398
+ const resolvedBaseUrl = baseUrl ?? DEFAULT_PLATFORM_API_BASE_URL;
3350
3399
  const client = new PlatformApiClient({
3351
- baseUrl: baseUrl ?? DEFAULT_PLATFORM_API_BASE_URL,
3400
+ baseUrl: resolvedBaseUrl,
3352
3401
  getAuth: credential.getAuth,
3353
3402
  ...deps.fetchFn ? { fetch: deps.fetchFn } : {},
3354
3403
  ...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {},
3355
3404
  userAgent: `mcpjam-cli/${package_default.version}`
3356
3405
  });
3357
- return { client, credentialKind: credential.kind };
3406
+ return { client, credentialKind: credential.kind, baseUrl: resolvedBaseUrl };
3407
+ }
3408
+ function webOriginForApiBaseUrl(baseUrl) {
3409
+ try {
3410
+ return new URL(baseUrl).origin;
3411
+ } catch {
3412
+ return DEFAULT_PLATFORM_ORIGIN;
3413
+ }
3358
3414
  }
3359
3415
  function toCliError(error) {
3360
3416
  if (error instanceof CliError) {
@@ -4477,6 +4533,106 @@ async function runPlatformCommand2(options, timeoutMs, execute) {
4477
4533
  clearTimeout(timeoutHandle);
4478
4534
  }
4479
4535
  }
4536
+ function validateOpInput(op, raw) {
4537
+ const parsed = op.inputSchema.safeParse(raw);
4538
+ if (!parsed.success) {
4539
+ const detail = parsed.error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
4540
+ const error = new Error(`Invalid input: ${detail}`);
4541
+ error.exitCode = 2;
4542
+ throw error;
4543
+ }
4544
+ return parsed.data;
4545
+ }
4546
+ async function executeOp(op, input, options, command) {
4547
+ const globalOptions = getGlobalOptions(command);
4548
+ const result = await runPlatformCommand2(
4549
+ options,
4550
+ globalOptions.timeout,
4551
+ ({ client, signal }) => op.execute(input, { client, signal })
4552
+ );
4553
+ writeResult(result, globalOptions.format);
4554
+ }
4555
+ function registerChatCommands(program) {
4556
+ const chatboxes = program.command("chatboxes").description("Inspect the chatboxes published from a hosted project");
4557
+ addPlatformOptions2(
4558
+ chatboxes.command("list").description("List the chatboxes published from a project").option(
4559
+ "--project <id-or-name>",
4560
+ "Project name or ID (defaults to the most recently updated project)"
4561
+ )
4562
+ ).action(async (options, command) => {
4563
+ const input = validateOpInput(listChatboxesOperation, {
4564
+ ...options.project === void 0 ? {} : { project: options.project }
4565
+ });
4566
+ await executeOp(listChatboxesOperation, input, options, command);
4567
+ });
4568
+ addPlatformOptions2(
4569
+ chatboxes.command("get").description(
4570
+ "Show one chatbox: access mode, attached servers, share link"
4571
+ ).requiredOption("--chatbox <id-or-name>", "Chatbox name or ID").option(
4572
+ "--project <id-or-name>",
4573
+ "Project name or ID (defaults to the most recently updated project)"
4574
+ )
4575
+ ).action(
4576
+ async (options, command) => {
4577
+ const input = validateOpInput(getChatboxOperation, {
4578
+ chatbox: options.chatbox,
4579
+ ...options.project === void 0 ? {} : { project: options.project }
4580
+ });
4581
+ await executeOp(getChatboxOperation, input, options, command);
4582
+ }
4583
+ );
4584
+ const sessions = program.command("chat-sessions").description("Inspect saved chat sessions");
4585
+ addPlatformOptions2(
4586
+ sessions.command("list").description(
4587
+ "List chat sessions, newest first (all accessible projects unless --project is given)"
4588
+ ).option("--project <id-or-name>", "Restrict to one project").option("--status <status>", "Filter by session status").option(
4589
+ "--limit <n>",
4590
+ "Maximum sessions to return (1-200)",
4591
+ (value) => Number.parseInt(value, 10)
4592
+ )
4593
+ ).action(
4594
+ async (options, command) => {
4595
+ const input = validateOpInput(listChatSessionsOperation, {
4596
+ ...options.project === void 0 ? {} : { project: options.project },
4597
+ ...options.status === void 0 ? {} : { status: options.status },
4598
+ ...options.limit === void 0 ? {} : { limit: options.limit }
4599
+ });
4600
+ await executeOp(listChatSessionsOperation, input, options, command);
4601
+ }
4602
+ );
4603
+ }
4604
+ function addPlatformOptions3(command) {
4605
+ return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
4606
+ "--api-url <url>",
4607
+ "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
4608
+ );
4609
+ }
4610
+ async function runPlatformCommand3(options, timeoutMs, execute) {
4611
+ const controller = new AbortController();
4612
+ const timeoutHandle = setTimeout(() => {
4613
+ controller.abort(
4614
+ new PlatformApiError(
4615
+ `Request timed out after ${timeoutMs}ms`,
4616
+ "TIMEOUT",
4617
+ {
4618
+ status: 0
4619
+ }
4620
+ )
4621
+ );
4622
+ }, timeoutMs);
4623
+ timeoutHandle.unref?.();
4624
+ try {
4625
+ const { client } = buildPlatformClient({ ...options, timeoutMs });
4626
+ return await execute({ client, signal: controller.signal });
4627
+ } catch (error) {
4628
+ if (controller.signal.aborted && controller.signal.reason instanceof PlatformApiError) {
4629
+ throw toCliError(controller.signal.reason);
4630
+ }
4631
+ throw toCliError(error);
4632
+ } finally {
4633
+ clearTimeout(timeoutHandle);
4634
+ }
4635
+ }
4480
4636
  function validateInput2(op, raw) {
4481
4637
  const parsed = op.inputSchema.safeParse(raw);
4482
4638
  if (!parsed.success) {
@@ -4530,7 +4686,7 @@ function registerEnvironmentsCommands(program) {
4530
4686
  const environments = program.command("environments").description(
4531
4687
  "List, create, and manage the project environments (host + servers + pinned skills/plugins) in your hosted MCPJam projects"
4532
4688
  );
4533
- addPlatformOptions2(
4689
+ addPlatformOptions3(
4534
4690
  environments.command("list").description("List the project environments in a project").option(
4535
4691
  "--project <id-or-name>",
4536
4692
  "Project name or ID (defaults to the most recently updated project)"
@@ -4541,7 +4697,7 @@ function registerEnvironmentsCommands(program) {
4541
4697
  ).action(
4542
4698
  async (options, command) => {
4543
4699
  const globalOptions = getGlobalOptions(command);
4544
- const result = await runPlatformCommand2(
4700
+ const result = await runPlatformCommand3(
4545
4701
  options,
4546
4702
  globalOptions.timeout,
4547
4703
  ({ client, signal }) => listEnvironmentsOperation.execute(
@@ -4555,14 +4711,14 @@ function registerEnvironmentsCommands(program) {
4555
4711
  writeResult(result, globalOptions.format);
4556
4712
  }
4557
4713
  );
4558
- addPlatformOptions2(
4714
+ addPlatformOptions3(
4559
4715
  environments.command("get").description(
4560
4716
  "Show one environment's settings and its current revision (pass that revision to update/archive/restore)"
4561
4717
  ).requiredOption("--environment <id-or-name>", "Environment name or ID").option("--project <id-or-name>", "Project name or ID")
4562
4718
  ).action(
4563
4719
  async (options, command) => {
4564
4720
  const globalOptions = getGlobalOptions(command);
4565
- const result = await runPlatformCommand2(
4721
+ const result = await runPlatformCommand3(
4566
4722
  options,
4567
4723
  globalOptions.timeout,
4568
4724
  ({ client, signal }) => getEnvironmentOperation.execute(
@@ -4573,14 +4729,14 @@ function registerEnvironmentsCommands(program) {
4573
4729
  writeResult(result, globalOptions.format);
4574
4730
  }
4575
4731
  );
4576
- addPlatformOptions2(
4732
+ addPlatformOptions3(
4577
4733
  environments.command("resolve").description(
4578
4734
  "Preview what an environment resolves to right now: host config, closed server set, and pinned plugin versions"
4579
4735
  ).requiredOption("--environment <id-or-name>", "Environment name or ID").option("--project <id-or-name>", "Project name or ID")
4580
4736
  ).action(
4581
4737
  async (options, command) => {
4582
4738
  const globalOptions = getGlobalOptions(command);
4583
- const result = await runPlatformCommand2(
4739
+ const result = await runPlatformCommand3(
4584
4740
  options,
4585
4741
  globalOptions.timeout,
4586
4742
  ({ client, signal }) => resolveEnvironmentOperation.execute(
@@ -4591,7 +4747,7 @@ function registerEnvironmentsCommands(program) {
4591
4747
  writeResult(result, globalOptions.format);
4592
4748
  }
4593
4749
  );
4594
- addPlatformOptions2(
4750
+ addPlatformOptions3(
4595
4751
  environments.command("create").description(
4596
4752
  "Create a project environment (requires project admin). Body fields may be supplied via --file/--json"
4597
4753
  ).option("--project <id-or-name>", "Project name or ID").option("--name <name>", "Display name for the new environment").option("--host-id <id>", "ID of the host this environment runs against").option("--description <text>", "Optional description").option(
@@ -4613,7 +4769,7 @@ function registerEnvironmentsCommands(program) {
4613
4769
  ...options.description !== void 0 ? { description: options.description } : {},
4614
4770
  ...options.sandboxImage !== void 0 ? { sandboxImageId: options.sandboxImage } : {}
4615
4771
  });
4616
- const result = await runPlatformCommand2(
4772
+ const result = await runPlatformCommand3(
4617
4773
  options,
4618
4774
  globalOptions.timeout,
4619
4775
  ({ client, signal }) => createEnvironmentOperation.execute(input, { client, signal })
@@ -4621,7 +4777,7 @@ function registerEnvironmentsCommands(program) {
4621
4777
  writeResult(result, globalOptions.format);
4622
4778
  }
4623
4779
  );
4624
- addPlatformOptions2(
4780
+ addPlatformOptions3(
4625
4781
  environments.command("update").description(
4626
4782
  "Edit an environment. Only the fields you pass change; use --file/--json with a null value to clear serverAttachmentId, skillSelection, pluginVersionIds, or sandboxImageId"
4627
4783
  ).requiredOption("--environment <id-or-name>", "Environment name or ID").requiredOption(
@@ -4651,7 +4807,7 @@ function registerEnvironmentsCommands(program) {
4651
4807
  ...options.description !== void 0 ? { description: options.description } : {},
4652
4808
  ...options.sandboxImage !== void 0 ? { sandboxImageId: options.sandboxImage } : {}
4653
4809
  });
4654
- const result = await runPlatformCommand2(
4810
+ const result = await runPlatformCommand3(
4655
4811
  options,
4656
4812
  globalOptions.timeout,
4657
4813
  ({ client, signal }) => updateEnvironmentOperation.execute(input, { client, signal })
@@ -4659,7 +4815,7 @@ function registerEnvironmentsCommands(program) {
4659
4815
  writeResult(result, globalOptions.format);
4660
4816
  }
4661
4817
  );
4662
- addPlatformOptions2(
4818
+ addPlatformOptions3(
4663
4819
  environments.command("archive").description(
4664
4820
  "Archive an environment (reversible; frees its name for a new one)"
4665
4821
  ).requiredOption("--environment <id-or-name>", "Environment name or ID").requiredOption(
@@ -4669,7 +4825,7 @@ function registerEnvironmentsCommands(program) {
4669
4825
  ).action(
4670
4826
  async (options, command) => {
4671
4827
  const globalOptions = getGlobalOptions(command);
4672
- const result = await runPlatformCommand2(
4828
+ const result = await runPlatformCommand3(
4673
4829
  options,
4674
4830
  globalOptions.timeout,
4675
4831
  ({ client, signal }) => archiveEnvironmentOperation.execute(
@@ -4684,7 +4840,7 @@ function registerEnvironmentsCommands(program) {
4684
4840
  writeResult(result, globalOptions.format);
4685
4841
  }
4686
4842
  );
4687
- addPlatformOptions2(
4843
+ addPlatformOptions3(
4688
4844
  environments.command("restore").description(
4689
4845
  "Restore an archived environment. Plugin pins whose version no longer exists are dropped \u2014 check the returned pluginVersionIds"
4690
4846
  ).requiredOption("--environment <id-or-name>", "Environment name or ID").requiredOption(
@@ -4694,15 +4850,285 @@ function registerEnvironmentsCommands(program) {
4694
4850
  ).action(
4695
4851
  async (options, command) => {
4696
4852
  const globalOptions = getGlobalOptions(command);
4697
- const result = await runPlatformCommand2(
4853
+ const result = await runPlatformCommand3(
4854
+ options,
4855
+ globalOptions.timeout,
4856
+ ({ client, signal }) => restoreEnvironmentOperation.execute(
4857
+ {
4858
+ project: options.project,
4859
+ environment: options.environment,
4860
+ expectedRevision: parseRevision(options.expectedRevision)
4861
+ },
4862
+ { client, signal }
4863
+ )
4864
+ );
4865
+ writeResult(result, globalOptions.format);
4866
+ }
4867
+ );
4868
+ }
4869
+ function addPlatformOptions4(command) {
4870
+ return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
4871
+ "--api-url <url>",
4872
+ "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
4873
+ );
4874
+ }
4875
+ async function runPlatformCommand4(options, timeoutMs, execute) {
4876
+ const controller = new AbortController();
4877
+ const timeoutHandle = setTimeout(() => {
4878
+ controller.abort(
4879
+ new PlatformApiError(
4880
+ `Request timed out after ${timeoutMs}ms`,
4881
+ "TIMEOUT",
4882
+ {
4883
+ status: 0
4884
+ }
4885
+ )
4886
+ );
4887
+ }, timeoutMs);
4888
+ timeoutHandle.unref?.();
4889
+ try {
4890
+ const { client } = buildPlatformClient({ ...options, timeoutMs });
4891
+ return await execute({ client, signal: controller.signal });
4892
+ } catch (error) {
4893
+ if (controller.signal.aborted && controller.signal.reason instanceof PlatformApiError) {
4894
+ throw toCliError(controller.signal.reason);
4895
+ }
4896
+ throw toCliError(error);
4897
+ } finally {
4898
+ clearTimeout(timeoutHandle);
4899
+ }
4900
+ }
4901
+ function collectRepeatable(value, previous) {
4902
+ return [...previous, value];
4903
+ }
4904
+ var LIMIT_MIN = 1;
4905
+ var LIMIT_MAX = 200;
4906
+ function pageArgs(options) {
4907
+ let limit;
4908
+ if (options.limit !== void 0) {
4909
+ limit = Number(options.limit);
4910
+ if (!Number.isInteger(limit) || limit < LIMIT_MIN || limit > LIMIT_MAX) {
4911
+ throw usageError(
4912
+ `--limit must be a whole number between ${LIMIT_MIN} and ${LIMIT_MAX} (got "${options.limit}")`
4913
+ );
4914
+ }
4915
+ }
4916
+ return {
4917
+ ...options.cursor !== void 0 ? { cursor: options.cursor } : {},
4918
+ ...limit !== void 0 ? { limit } : {}
4919
+ };
4920
+ }
4921
+ function addPageOptions(command) {
4922
+ return command.option("--cursor <cursor>", "Page cursor from a previous response").option("--limit <n>", "Items per page (1-200)");
4923
+ }
4924
+ function registerJourneysCommands(program) {
4925
+ const journeys = program.command("journeys").description(
4926
+ "List journeys and inspect their runs (the Swarms product) in your hosted MCPJam projects"
4927
+ );
4928
+ addPlatformOptions4(
4929
+ journeys.command("list").description("List the journeys in a project").option(
4930
+ "--project <id-or-name>",
4931
+ "Project name or ID (defaults to the most recently updated project)"
4932
+ )
4933
+ ).action(async (options, command) => {
4934
+ const globalOptions = getGlobalOptions(command);
4935
+ const result = await runPlatformCommand4(
4936
+ options,
4937
+ globalOptions.timeout,
4938
+ ({ client, signal }) => listJourneysOperation.execute(
4939
+ { project: options.project },
4940
+ { client, signal }
4941
+ )
4942
+ );
4943
+ writeResult(result, globalOptions.format);
4944
+ });
4945
+ addPlatformOptions4(
4946
+ addPageOptions(
4947
+ journeys.command("runs").description("List a journey's runs, newest first").requiredOption("--journey <id>", "Journey ID (from `journeys list`)").option("--project <id-or-name>", "Project name or ID")
4948
+ )
4949
+ ).action(
4950
+ async (options, command) => {
4951
+ const globalOptions = getGlobalOptions(command);
4952
+ const result = await runPlatformCommand4(
4953
+ options,
4954
+ globalOptions.timeout,
4955
+ ({ client, signal }) => listJourneyRunsOperation.execute(
4956
+ {
4957
+ project: options.project,
4958
+ journey: options.journey,
4959
+ ...pageArgs(options)
4960
+ },
4961
+ { client, signal }
4962
+ )
4963
+ );
4964
+ writeResult(result, globalOptions.format);
4965
+ }
4966
+ );
4967
+ addPlatformOptions4(
4968
+ journeys.command("status").description(
4969
+ "Show one run's status, target rollups, and per-session attempts. Poll this after launching; `status` leaves 'running' once every attempt has settled. A run someone stopped reports 'failed' with canceled: true."
4970
+ ).requiredOption("--run <id>", "Journey run ID").option("--project <id-or-name>", "Project name or ID")
4971
+ ).action(
4972
+ async (options, command) => {
4973
+ const globalOptions = getGlobalOptions(command);
4974
+ const result = await runPlatformCommand4(
4975
+ options,
4976
+ globalOptions.timeout,
4977
+ ({ client, signal }) => getJourneyRunOperation.execute(
4978
+ { project: options.project, run: options.run },
4979
+ { client, signal }
4980
+ )
4981
+ );
4982
+ writeResult(result, globalOptions.format);
4983
+ }
4984
+ );
4985
+ addPlatformOptions4(
4986
+ journeys.command("run").description(
4987
+ "Launch a journey. Returns as soon as the run exists \u2014 poll `journeys status` for progress."
4988
+ ).requiredOption("--journey <id>", "Journey ID to launch").option("--project <id-or-name>", "Project name or ID").option(
4989
+ "--idempotency-key <key>",
4990
+ "Retry key. Pass one: a launch spends model credits, so a retry after a dropped response must not run the journey twice. Replaying a key returns the original run."
4991
+ ).option(
4992
+ "--wave <id>",
4993
+ "Opaque id linking the sibling runs of one co-launched batch"
4994
+ ).option(
4995
+ "--environment <id>",
4996
+ "Fan out across this project environment instead of the journey's authored targets (repeatable)",
4997
+ collectRepeatable,
4998
+ []
4999
+ )
5000
+ ).action(
5001
+ async (options, command) => {
5002
+ const globalOptions = getGlobalOptions(command);
5003
+ const result = await runPlatformCommand4(
5004
+ options,
5005
+ globalOptions.timeout,
5006
+ ({ client, signal }) => launchJourneyRunOperation.execute(
5007
+ {
5008
+ project: options.project,
5009
+ journey: options.journey,
5010
+ ...options.idempotencyKey ? { idempotencyKey: options.idempotencyKey } : {},
5011
+ ...options.wave ? { waveId: options.wave } : {},
5012
+ ...options.environment?.length ? { environmentIds: options.environment } : {}
5013
+ },
5014
+ { client, signal }
5015
+ )
5016
+ );
5017
+ writeResult(result, globalOptions.format);
5018
+ }
5019
+ );
5020
+ addPlatformOptions4(
5021
+ journeys.command("cancel").description(
5022
+ "Stop a running journey run. Idempotent \u2014 cancelling an already-cancelled run succeeds; a run that finished on its own conflicts instead."
5023
+ ).requiredOption("--run <id>", "Journey run ID").option("--project <id-or-name>", "Project name or ID")
5024
+ ).action(
5025
+ async (options, command) => {
5026
+ const globalOptions = getGlobalOptions(command);
5027
+ const result = await runPlatformCommand4(
5028
+ options,
5029
+ globalOptions.timeout,
5030
+ ({ client, signal }) => cancelJourneyRunOperation.execute(
5031
+ { project: options.project, run: options.run },
5032
+ { client, signal }
5033
+ )
5034
+ );
5035
+ writeResult(result, globalOptions.format);
5036
+ }
5037
+ );
5038
+ addPlatformOptions4(
5039
+ addPageOptions(
5040
+ journeys.command("sessions").description(
5041
+ "List the chat sessions a run produced, with readiness and goal scores"
5042
+ ).requiredOption("--run <id>", "Journey run ID").option("--project <id-or-name>", "Project name or ID")
5043
+ )
5044
+ ).action(
5045
+ async (options, command) => {
5046
+ const globalOptions = getGlobalOptions(command);
5047
+ const result = await runPlatformCommand4(
5048
+ options,
5049
+ globalOptions.timeout,
5050
+ ({ client, signal }) => listJourneyRunSessionsOperation.execute(
5051
+ {
5052
+ project: options.project,
5053
+ run: options.run,
5054
+ ...pageArgs(options)
5055
+ },
5056
+ { client, signal }
5057
+ )
5058
+ );
5059
+ writeResult(result, globalOptions.format);
5060
+ }
5061
+ );
5062
+ }
5063
+ function addPlatformOptions5(command) {
5064
+ return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
5065
+ "--api-url <url>",
5066
+ "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
5067
+ );
5068
+ }
5069
+ async function runPlatformCommand5(options, timeoutMs, execute) {
5070
+ const controller = new AbortController();
5071
+ const timeoutHandle = setTimeout(() => {
5072
+ controller.abort(
5073
+ new PlatformApiError(
5074
+ `Request timed out after ${timeoutMs}ms`,
5075
+ "TIMEOUT",
5076
+ {
5077
+ status: 0
5078
+ }
5079
+ )
5080
+ );
5081
+ }, timeoutMs);
5082
+ timeoutHandle.unref?.();
5083
+ try {
5084
+ const { client } = buildPlatformClient({ ...options, timeoutMs });
5085
+ return await execute({ client, signal: controller.signal });
5086
+ } catch (error) {
5087
+ if (controller.signal.aborted && controller.signal.reason instanceof PlatformApiError) {
5088
+ throw toCliError(controller.signal.reason);
5089
+ }
5090
+ throw toCliError(error);
5091
+ } finally {
5092
+ clearTimeout(timeoutHandle);
5093
+ }
5094
+ }
5095
+ function registerScenariosCommands(program) {
5096
+ const scenarios = program.command("scenarios").description(
5097
+ "Publish project environments for user testing, and take them down again"
5098
+ );
5099
+ addPlatformOptions5(
5100
+ scenarios.command("publish").description(
5101
+ "Publish an environment as a scenario and print its share link. Idempotent \u2014 re-publishing returns the existing scenario, with created: false."
5102
+ ).requiredOption("--environment <id>", "Project environment ID").option(
5103
+ "--project <id-or-name>",
5104
+ "Project name or ID (defaults to the most recently updated project)"
5105
+ )
5106
+ ).action(
5107
+ async (options, command) => {
5108
+ const globalOptions = getGlobalOptions(command);
5109
+ const result = await runPlatformCommand5(
5110
+ options,
5111
+ globalOptions.timeout,
5112
+ ({ client, signal }) => publishScenarioOperation.execute(
5113
+ { project: options.project, environment: options.environment },
5114
+ { client, signal }
5115
+ )
5116
+ );
5117
+ writeResult(result, globalOptions.format);
5118
+ }
5119
+ );
5120
+ addPlatformOptions5(
5121
+ scenarios.command("unpublish").description(
5122
+ "Take an environment's scenario down, invalidating its share link and any live guest sessions. Idempotent."
5123
+ ).requiredOption("--environment <id>", "Project environment ID").option("--project <id-or-name>", "Project name or ID")
5124
+ ).action(
5125
+ async (options, command) => {
5126
+ const globalOptions = getGlobalOptions(command);
5127
+ const result = await runPlatformCommand5(
4698
5128
  options,
4699
5129
  globalOptions.timeout,
4700
- ({ client, signal }) => restoreEnvironmentOperation.execute(
4701
- {
4702
- project: options.project,
4703
- environment: options.environment,
4704
- expectedRevision: parseRevision(options.expectedRevision)
4705
- },
5130
+ ({ client, signal }) => unpublishScenarioOperation.execute(
5131
+ { project: options.project, environment: options.environment },
4706
5132
  { client, signal }
4707
5133
  )
4708
5134
  );
@@ -4821,13 +5247,26 @@ function encodeInlineImage(data, protocol) {
4821
5247
  }
4822
5248
 
4823
5249
  // src/commands/eval.ts
4824
- function addPlatformOptions3(command) {
5250
+ function addPlatformOptions6(command) {
4825
5251
  return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
4826
5252
  "--api-url <url>",
4827
5253
  "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
4828
5254
  );
4829
5255
  }
4830
- async function runPlatformCommand3(options, timeoutMs, execute) {
5256
+ function writeRunLink(format, webOrigin, run) {
5257
+ if (format !== "human") return;
5258
+ const suiteId = run.suiteId?.trim();
5259
+ const runId = run.runId?.trim();
5260
+ if (!suiteId || !runId) return;
5261
+ const query = run.projectId?.trim() ? `?project=${encodeURIComponent(run.projectId.trim())}` : "";
5262
+ process.stdout.write(
5263
+ `View: ${webOrigin}/evals/suite/${encodeURIComponent(
5264
+ suiteId
5265
+ )}/runs/${encodeURIComponent(runId)}${query}
5266
+ `
5267
+ );
5268
+ }
5269
+ async function runPlatformCommand6(options, timeoutMs, execute) {
4831
5270
  const controller = new AbortController();
4832
5271
  const timeoutHandle = setTimeout(() => {
4833
5272
  controller.abort(
@@ -4842,8 +5281,12 @@ async function runPlatformCommand3(options, timeoutMs, execute) {
4842
5281
  }, timeoutMs);
4843
5282
  timeoutHandle.unref?.();
4844
5283
  try {
4845
- const { client } = buildPlatformClient({ ...options, timeoutMs });
4846
- return await execute({ client, signal: controller.signal });
5284
+ const { client, baseUrl } = buildPlatformClient({ ...options, timeoutMs });
5285
+ return await execute({
5286
+ client,
5287
+ signal: controller.signal,
5288
+ webOrigin: webOriginForApiBaseUrl(baseUrl)
5289
+ });
4847
5290
  } catch (error) {
4848
5291
  if (controller.signal.aborted && controller.signal.reason instanceof PlatformApiError) {
4849
5292
  throw toCliError(controller.signal.reason);
@@ -4927,7 +5370,7 @@ function loadBodyObject(options) {
4927
5370
  }
4928
5371
  return base;
4929
5372
  }
4930
- function validateOpInput(op, raw) {
5373
+ function validateOpInput2(op, raw) {
4931
5374
  const parsed = op.inputSchema.safeParse(raw);
4932
5375
  if (!parsed.success) {
4933
5376
  const detail = parsed.error.issues.map((issue) => `${issue.path.join(".") || "(root)"}: ${issue.message}`).join("; ");
@@ -4935,9 +5378,9 @@ function validateOpInput(op, raw) {
4935
5378
  }
4936
5379
  return parsed.data;
4937
5380
  }
4938
- async function executeOp(op, input, options, command) {
5381
+ async function executeOp2(op, input, options, command) {
4939
5382
  const globalOptions = getGlobalOptions(command);
4940
- const result = await runPlatformCommand3(
5383
+ const result = await runPlatformCommand6(
4941
5384
  options,
4942
5385
  globalOptions.timeout,
4943
5386
  ({ client, signal }) => op.execute(input, { client, signal })
@@ -5037,7 +5480,7 @@ function resolveScreenshotPath(out, shot, index, total) {
5037
5480
  }
5038
5481
  function registerEvalCommands(program) {
5039
5482
  const evals = program.command("eval").description("Author and run eval suites in your hosted MCPJam projects");
5040
- addPlatformOptions3(
5483
+ addPlatformOptions6(
5041
5484
  evals.command("create").description(
5042
5485
  "Create a runnable eval suite from authored test cases (does not run it)"
5043
5486
  ).option(
@@ -5062,21 +5505,21 @@ function registerEvalCommands(program) {
5062
5505
  ).action(async (options, command) => {
5063
5506
  const globalOptions = getGlobalOptions(command);
5064
5507
  const input = loadSuiteDefinition(options);
5065
- const result = await runPlatformCommand3(
5508
+ const result = await runPlatformCommand6(
5066
5509
  options,
5067
5510
  globalOptions.timeout,
5068
5511
  ({ client, signal }) => createEvalSuiteOperation.execute(input, { client, signal })
5069
5512
  );
5070
5513
  writeResult(result, globalOptions.format);
5071
5514
  });
5072
- addPlatformOptions3(
5515
+ addPlatformOptions6(
5073
5516
  evals.command("list").description("List the eval suites saved in a project").option(
5074
5517
  "--project <id-or-name>",
5075
5518
  "Project name or ID (defaults to the most recently updated project)"
5076
5519
  )
5077
5520
  ).action(async (options, command) => {
5078
5521
  const globalOptions = getGlobalOptions(command);
5079
- const result = await runPlatformCommand3(
5522
+ const result = await runPlatformCommand6(
5080
5523
  options,
5081
5524
  globalOptions.timeout,
5082
5525
  ({ client, signal }) => listEvalSuitesOperation.execute(
@@ -5086,55 +5529,96 @@ function registerEvalCommands(program) {
5086
5529
  );
5087
5530
  writeResult(result, globalOptions.format);
5088
5531
  });
5089
- addPlatformOptions3(
5532
+ addPlatformOptions6(
5533
+ evals.command("runs").description("List a suite's run history, newest first").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option(
5534
+ "--project <id-or-name>",
5535
+ "Project name or ID (defaults to the most recently updated project)"
5536
+ ).option(
5537
+ "--limit <n>",
5538
+ "Maximum number of runs to return (1-100)",
5539
+ (value) => Number.parseInt(value, 10)
5540
+ )
5541
+ ).action(
5542
+ async (options, command) => {
5543
+ const input = validateOpInput2(listEvalSuiteRunsOperation, {
5544
+ suite: options.suite,
5545
+ ...options.project === void 0 ? {} : { project: options.project },
5546
+ ...options.limit === void 0 ? {} : { limit: options.limit }
5547
+ });
5548
+ await executeOp2(listEvalSuiteRunsOperation, input, options, command);
5549
+ }
5550
+ );
5551
+ addPlatformOptions6(
5090
5552
  evals.command("run").description("Start an eval run of an existing suite (asynchronous)").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option(
5091
5553
  "--project <id-or-name>",
5092
5554
  "Project name or ID (defaults to the most recently updated project)"
5093
5555
  ).option(
5094
- "--server <name...>",
5556
+ "--server <id-or-name...>",
5095
5557
  "Override the suite's saved server selection (HTTP servers only)"
5558
+ ).option(
5559
+ "--environment <id-or-name>",
5560
+ "Project environment to run against (must be attached to the suite; optional when it has exactly one)"
5096
5561
  )
5097
5562
  ).action(
5098
5563
  async (options, command) => {
5099
5564
  const globalOptions = getGlobalOptions(command);
5100
- const result = await runPlatformCommand3(
5565
+ let webOrigin = DEFAULT_PLATFORM_ORIGIN;
5566
+ const result = await runPlatformCommand6(
5101
5567
  options,
5102
5568
  globalOptions.timeout,
5103
- ({ client, signal }) => runEvalSuiteOperation.execute(
5104
- {
5105
- project: options.project,
5106
- suite: options.suite,
5107
- ...options.server ? { servers: options.server } : {}
5108
- },
5109
- { client, signal }
5110
- )
5569
+ (context) => {
5570
+ webOrigin = context.webOrigin;
5571
+ return runEvalSuiteOperation.execute(
5572
+ {
5573
+ project: options.project,
5574
+ suite: options.suite,
5575
+ ...options.server ? { servers: options.server } : {},
5576
+ ...options.environment ? { environment: options.environment } : {}
5577
+ },
5578
+ { client: context.client, signal: context.signal }
5579
+ );
5580
+ }
5111
5581
  );
5112
5582
  writeResult(result, globalOptions.format);
5583
+ writeRunLink(globalOptions.format, webOrigin, {
5584
+ projectId: result.project.id,
5585
+ suiteId: result.suite.id,
5586
+ runId: result.runId
5587
+ });
5113
5588
  }
5114
5589
  );
5115
- addPlatformOptions3(
5590
+ addPlatformOptions6(
5116
5591
  evals.command("status").description("Get the status and summary of an eval run").requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption("--project <id-or-name>", "Project name or ID")
5117
5592
  ).action(
5118
5593
  async (options, command) => {
5119
5594
  const globalOptions = getGlobalOptions(command);
5120
- const result = await runPlatformCommand3(
5595
+ let webOrigin = DEFAULT_PLATFORM_ORIGIN;
5596
+ const result = await runPlatformCommand6(
5121
5597
  options,
5122
5598
  globalOptions.timeout,
5123
- ({ client, signal }) => getEvalRunOperation.execute(
5124
- { project: options.project, runId: options.run },
5125
- { client, signal }
5126
- )
5599
+ (context) => {
5600
+ webOrigin = context.webOrigin;
5601
+ return getEvalRunOperation.execute(
5602
+ { project: options.project, runId: options.run },
5603
+ { client: context.client, signal: context.signal }
5604
+ );
5605
+ }
5127
5606
  );
5128
5607
  writeResult(result, globalOptions.format);
5608
+ writeRunLink(globalOptions.format, webOrigin, {
5609
+ projectId: result.project.id,
5610
+ suiteId: result.run.suiteId,
5611
+ runId: result.run.id
5612
+ });
5129
5613
  }
5130
5614
  );
5131
- addPlatformOptions3(
5615
+ addPlatformOptions6(
5132
5616
  evals.command("cancel").description(
5133
5617
  "Cancel an in-flight eval run (no-op if already cancelled; errors if it already finished)"
5134
5618
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption("--project <id-or-name>", "Project name or ID")
5135
5619
  ).action(
5136
5620
  async (options, command) => {
5137
- await executeOp(
5621
+ await executeOp2(
5138
5622
  cancelEvalRunOperation,
5139
5623
  { project: options.project, runId: options.run },
5140
5624
  options,
@@ -5143,7 +5627,7 @@ function registerEvalCommands(program) {
5143
5627
  }
5144
5628
  );
5145
5629
  const PROJECT_OPT = "Project name or ID (defaults to most recently updated)";
5146
- addPlatformOptions3(
5630
+ addPlatformOptions6(
5147
5631
  evals.command("iterations").description(
5148
5632
  "List per-iteration results for an eval run (pass/fail, tool calls, tokens, latency)"
5149
5633
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -5152,16 +5636,16 @@ function registerEvalCommands(program) {
5152
5636
  ).option("--cursor <cursor>", "Pagination cursor from a previous response").option("--limit <n>", "Max iterations per page (1\u2013200)")
5153
5637
  ).action(
5154
5638
  async (options, command) => {
5155
- const input = validateOpInput(listEvalRunIterationsOperation, {
5639
+ const input = validateOpInput2(listEvalRunIterationsOperation, {
5156
5640
  project: options.project,
5157
5641
  runId: options.run,
5158
5642
  ...options.cursor !== void 0 ? { cursor: options.cursor } : {},
5159
5643
  ...options.limit !== void 0 ? { limit: Number(options.limit) } : {}
5160
5644
  });
5161
- await executeOp(listEvalRunIterationsOperation, input, options, command);
5645
+ await executeOp2(listEvalRunIterationsOperation, input, options, command);
5162
5646
  }
5163
5647
  );
5164
- addPlatformOptions3(
5648
+ addPlatformOptions6(
5165
5649
  evals.command("trace").description(
5166
5650
  "Fetch the full trace for one eval iteration (large: full message history + spans)"
5167
5651
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -5173,7 +5657,7 @@ function registerEvalCommands(program) {
5173
5657
  )
5174
5658
  ).action(
5175
5659
  async (options, command) => {
5176
- await executeOp(
5660
+ await executeOp2(
5177
5661
  getEvalIterationTraceOperation,
5178
5662
  {
5179
5663
  project: options.project,
@@ -5185,7 +5669,7 @@ function registerEvalCommands(program) {
5185
5669
  );
5186
5670
  }
5187
5671
  );
5188
- addPlatformOptions3(
5672
+ addPlatformOptions6(
5189
5673
  evals.command("steps").description(
5190
5674
  "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."
5191
5675
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -5197,7 +5681,7 @@ function registerEvalCommands(program) {
5197
5681
  )
5198
5682
  ).action(
5199
5683
  async (options, command) => {
5200
- await executeOp(
5684
+ await executeOp2(
5201
5685
  getEvalRunStepsOperation,
5202
5686
  {
5203
5687
  project: options.project,
@@ -5209,7 +5693,7 @@ function registerEvalCommands(program) {
5209
5693
  );
5210
5694
  }
5211
5695
  );
5212
- addPlatformOptions3(
5696
+ addPlatformOptions6(
5213
5697
  evals.command("screenshot").description(
5214
5698
  "Show the widget screenshot(s) an eval iteration rendered \u2014 inline when the terminal supports it, otherwise the image URL"
5215
5699
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -5226,7 +5710,7 @@ function registerEvalCommands(program) {
5226
5710
  async (options, command) => {
5227
5711
  const globalOptions = getGlobalOptions(command);
5228
5712
  const index = options.index !== void 0 ? parsePositiveInteger(options.index, "--index") : void 0;
5229
- const result = await runPlatformCommand3(
5713
+ const result = await runPlatformCommand6(
5230
5714
  options,
5231
5715
  globalOptions.timeout,
5232
5716
  ({ client, signal }) => getEvalIterationTraceOperation.execute(
@@ -5317,7 +5801,7 @@ function registerEvalCommands(program) {
5317
5801
  }
5318
5802
  }
5319
5803
  );
5320
- addPlatformOptions3(
5804
+ addPlatformOptions6(
5321
5805
  evals.command("video").description(
5322
5806
  "Get the Playwright replay video (.webm) an eval iteration recorded \u2014 prints the URL, or downloads it with --out"
5323
5807
  ).requiredOption("--run <id>", "Eval run ID (from `eval run`)").requiredOption(
@@ -5330,7 +5814,7 @@ function registerEvalCommands(program) {
5330
5814
  ).action(
5331
5815
  async (options, command) => {
5332
5816
  const globalOptions = getGlobalOptions(command);
5333
- const result = await runPlatformCommand3(
5817
+ const result = await runPlatformCommand6(
5334
5818
  options,
5335
5819
  globalOptions.timeout,
5336
5820
  ({ client, signal }) => getEvalIterationTraceOperation.execute(
@@ -5381,11 +5865,11 @@ function registerEvalCommands(program) {
5381
5865
  `);
5382
5866
  }
5383
5867
  );
5384
- addPlatformOptions3(
5868
+ addPlatformOptions6(
5385
5869
  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)
5386
5870
  ).action(
5387
5871
  async (options, command) => {
5388
- await executeOp(
5872
+ await executeOp2(
5389
5873
  getEvalSuiteOperation,
5390
5874
  { project: options.project, suite: options.suite },
5391
5875
  options,
@@ -5393,7 +5877,7 @@ function registerEvalCommands(program) {
5393
5877
  );
5394
5878
  }
5395
5879
  );
5396
- addPlatformOptions3(
5880
+ addPlatformOptions6(
5397
5881
  evals.command("update").description(
5398
5882
  "Edit an eval suite's settings (only the flags you pass change)"
5399
5883
  ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--file <path>", "Suite-update JSON body (or - for stdin)").option("--json <json>", "Inline suite-update JSON (or @file, or -)").option("--name <name>", "Rename the suite").option("--description <text>", "Suite description").option(
@@ -5401,17 +5885,17 @@ function registerEvalCommands(program) {
5401
5885
  "Replace the suite's server selection (project server names)"
5402
5886
  ).option("--host <name...>", "Replace host attachments (by name/ID)").option("--model <id>", "Execution model id").option("--system-prompt <text>", "Execution system prompt").option("--temperature <n>", "Execution temperature").option("--min-accuracy <pct>", "Minimum accuracy, 0\u2013100").option("--tool-call-order <any|in-order|exact>", "Tool call order").option("--arguments <ignore|partial|exact>", "Argument matching").option("--extra-tool-calls <unlimited|N>", "Allowed extra tool calls").option("--judge <on|off>", "Enable/disable LLM-as-judge grading").option("--judge-model <id>", "Judge model id")
5403
5887
  ).action(async (options, command) => {
5404
- const input = validateOpInput(
5888
+ const input = validateOpInput2(
5405
5889
  updateEvalSuiteOperation,
5406
5890
  buildSuiteUpdateInput(options)
5407
5891
  );
5408
- await executeOp(updateEvalSuiteOperation, input, options, command);
5892
+ await executeOp2(updateEvalSuiteOperation, input, options, command);
5409
5893
  });
5410
- addPlatformOptions3(
5894
+ addPlatformOptions6(
5411
5895
  evals.command("delete").description("Permanently delete an eval suite (and its cases and runs)").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT)
5412
5896
  ).action(
5413
5897
  async (options, command) => {
5414
- await executeOp(
5898
+ await executeOp2(
5415
5899
  deleteEvalSuiteOperation,
5416
5900
  { project: options.project, suite: options.suite },
5417
5901
  options,
@@ -5419,8 +5903,11 @@ function registerEvalCommands(program) {
5419
5903
  );
5420
5904
  }
5421
5905
  );
5422
- addPlatformOptions3(
5423
- evals.command("schedule").description("Enable or disable scheduled runs for a suite").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--enable", "Enable scheduled runs").option("--disable", "Disable scheduled runs").option("--interval <minutes>", "Run interval in minutes (5\u201310080)")
5906
+ addPlatformOptions6(
5907
+ evals.command("schedule").description("Enable or disable scheduled runs for a suite").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--enable", "Enable scheduled runs").option("--disable", "Disable scheduled runs").option("--interval <minutes>", "Run interval in minutes (5\u201310080)").option(
5908
+ "--environment <id-or-name>",
5909
+ "Project environment the scheduled runs launch (only with --enable)"
5910
+ )
5424
5911
  ).action(
5425
5912
  async (options, command) => {
5426
5913
  if (options.enable && options.disable) {
@@ -5429,21 +5916,64 @@ function registerEvalCommands(program) {
5429
5916
  if (!options.enable && !options.disable) {
5430
5917
  throw usageError("Pass --enable or --disable.");
5431
5918
  }
5432
- const input = validateOpInput(setEvalSuiteScheduleOperation, {
5919
+ const input = validateOpInput2(setEvalSuiteScheduleOperation, {
5433
5920
  project: options.project,
5434
5921
  suite: options.suite,
5435
5922
  enabled: Boolean(options.enable),
5436
- ...options.interval !== void 0 ? { intervalMinutes: Number(options.interval) } : {}
5923
+ ...options.interval !== void 0 ? { intervalMinutes: Number(options.interval) } : {},
5924
+ ...options.environment ? { environment: options.environment } : {}
5437
5925
  });
5438
- await executeOp(setEvalSuiteScheduleOperation, input, options, command);
5926
+ await executeOp2(setEvalSuiteScheduleOperation, input, options, command);
5927
+ }
5928
+ );
5929
+ const environments = evals.command("environments").description(
5930
+ "Attach or detach the project environments an eval suite runs against"
5931
+ );
5932
+ addPlatformOptions6(
5933
+ environments.command("set").description(
5934
+ "Replace the suite's attached environments (this sets the whole list)"
5935
+ ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").requiredOption(
5936
+ "--environment <id-or-name...>",
5937
+ "Project environments to attach, in order"
5938
+ ).option("--project <id-or-name>", PROJECT_OPT)
5939
+ ).action(
5940
+ async (options, command) => {
5941
+ await executeOp2(
5942
+ setEvalSuiteEnvironmentsOperation,
5943
+ {
5944
+ project: options.project,
5945
+ suite: options.suite,
5946
+ environments: options.environment
5947
+ },
5948
+ options,
5949
+ command
5950
+ );
5951
+ }
5952
+ );
5953
+ addPlatformOptions6(
5954
+ environments.command("clear").description(
5955
+ "Detach every environment, reverting the suite to its saved server selection"
5956
+ ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT)
5957
+ ).action(
5958
+ async (options, command) => {
5959
+ await executeOp2(
5960
+ setEvalSuiteEnvironmentsOperation,
5961
+ {
5962
+ project: options.project,
5963
+ suite: options.suite,
5964
+ environments: null
5965
+ },
5966
+ options,
5967
+ command
5968
+ );
5439
5969
  }
5440
5970
  );
5441
5971
  const cases = evals.command("cases").description("List, author, and edit an eval suite's test cases");
5442
- addPlatformOptions3(
5972
+ addPlatformOptions6(
5443
5973
  cases.command("list").description("List a suite's test cases").requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT)
5444
5974
  ).action(
5445
5975
  async (options, command) => {
5446
- await executeOp(
5976
+ await executeOp2(
5447
5977
  listEvalCasesOperation,
5448
5978
  { project: options.project, suite: options.suite },
5449
5979
  options,
@@ -5451,11 +5981,11 @@ function registerEvalCommands(program) {
5451
5981
  );
5452
5982
  }
5453
5983
  );
5454
- addPlatformOptions3(
5984
+ addPlatformOptions6(
5455
5985
  cases.command("get").description("Show one test case").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)
5456
5986
  ).action(
5457
5987
  async (options, command) => {
5458
- await executeOp(
5988
+ await executeOp2(
5459
5989
  getEvalCaseOperation,
5460
5990
  { project: options.project, suite: options.suite, case: options.case },
5461
5991
  options,
@@ -5463,51 +5993,55 @@ function registerEvalCommands(program) {
5463
5993
  );
5464
5994
  }
5465
5995
  );
5466
- addPlatformOptions3(
5996
+ addPlatformOptions6(
5467
5997
  cases.command("run").description(
5468
5998
  "Run a single case as a persisted, fully-queryable run (inspect it with `eval iterations` / `eval steps` like any run)"
5469
5999
  ).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(
5470
6000
  "--server <id-or-name...>",
5471
6001
  "Override the suite's saved servers for this run"
6002
+ ).option(
6003
+ "--environment <id-or-name>",
6004
+ "Project environment to run against (must be attached to the suite)"
5472
6005
  )
5473
6006
  ).action(
5474
6007
  async (options, command) => {
5475
- await executeOp(
6008
+ await executeOp2(
5476
6009
  runEvalCaseOperation,
5477
6010
  {
5478
6011
  project: options.project,
5479
6012
  suite: options.suite,
5480
6013
  case: options.case,
5481
- ...options.server?.length ? { servers: options.server } : {}
6014
+ ...options.server?.length ? { servers: options.server } : {},
6015
+ ...options.environment ? { environment: options.environment } : {}
5482
6016
  },
5483
6017
  options,
5484
6018
  command
5485
6019
  );
5486
6020
  }
5487
6021
  );
5488
- addPlatformOptions3(
6022
+ addPlatformOptions6(
5489
6023
  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)")
5490
6024
  ).action(async (options, command) => {
5491
- const input = validateOpInput(
6025
+ const input = validateOpInput2(
5492
6026
  createEvalCaseOperation,
5493
6027
  buildCaseInput(options, { requireCase: false })
5494
6028
  );
5495
- await executeOp(createEvalCaseOperation, input, options, command);
6029
+ await executeOp2(createEvalCaseOperation, input, options, command);
5496
6030
  });
5497
- addPlatformOptions3(
6031
+ addPlatformOptions6(
5498
6032
  cases.command("update").description("Edit a test case (definition via --file/--json)").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("--file <path>", "Case JSON body (or - for stdin)").option("--json <json>", "Inline case JSON (or @file, or -)").option("--title <title>", "Rename the case")
5499
6033
  ).action(async (options, command) => {
5500
- const input = validateOpInput(
6034
+ const input = validateOpInput2(
5501
6035
  updateEvalCaseOperation,
5502
6036
  buildCaseInput(options, { requireCase: true })
5503
6037
  );
5504
- await executeOp(updateEvalCaseOperation, input, options, command);
6038
+ await executeOp2(updateEvalCaseOperation, input, options, command);
5505
6039
  });
5506
- addPlatformOptions3(
6040
+ addPlatformOptions6(
5507
6041
  cases.command("delete").description("Permanently delete a test case").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)
5508
6042
  ).action(
5509
6043
  async (options, command) => {
5510
- await executeOp(
6044
+ await executeOp2(
5511
6045
  deleteEvalCaseOperation,
5512
6046
  { project: options.project, suite: options.suite, case: options.case },
5513
6047
  options,
@@ -5515,12 +6049,15 @@ function registerEvalCommands(program) {
5515
6049
  );
5516
6050
  }
5517
6051
  );
5518
- addPlatformOptions3(
6052
+ addPlatformOptions6(
5519
6053
  cases.command("generate").description(
5520
6054
  "AI-generate test cases from the suite's tools (spends credits)"
5521
6055
  ).requiredOption("--suite <id-or-name>", "Eval suite name or ID").option("--project <id-or-name>", PROJECT_OPT).option("--mode <normal|negative>", "Generation mode (default normal)").option(
5522
- "--server <name...>",
6056
+ "--server <id-or-name...>",
5523
6057
  "Servers to discover tools from (default: suite's)"
6058
+ ).option(
6059
+ "--environment <id-or-name>",
6060
+ "Discover tools from this attached environment's server set"
5524
6061
  ).option(
5525
6062
  "--case-model <id...>",
5526
6063
  "Execution model(s) for the generated cases"
@@ -5550,33 +6087,38 @@ function registerEvalCommands(program) {
5550
6087
  caseMix[key] = parsed;
5551
6088
  }
5552
6089
  }
5553
- const input = validateOpInput(generateEvalCasesOperation, {
6090
+ const input = validateOpInput2(generateEvalCasesOperation, {
5554
6091
  project: options.project,
5555
6092
  suite: options.suite,
5556
6093
  ...options.mode ? { mode: options.mode } : {},
5557
6094
  ...options.server ? { servers: options.server } : {},
6095
+ ...options.environment ? { environment: options.environment } : {},
5558
6096
  ...options.caseModel ? { caseModels: options.caseModel.map((model) => ({ model })) } : {},
5559
6097
  ...Object.keys(caseMix).length > 0 ? { caseMix } : {},
5560
6098
  ...options.varyUserStyles ? { varyUserStyles: true } : {}
5561
6099
  });
5562
- await executeOp(generateEvalCasesOperation, input, options, command);
6100
+ await executeOp2(generateEvalCasesOperation, input, options, command);
5563
6101
  }
5564
6102
  );
5565
6103
  }
5566
6104
  var HOST_TEMPLATES = HOST_TEMPLATES$1.map(({ id, label }) => ({ id, label }));
5567
- function addPlatformOptions4(command) {
6105
+ function addPlatformOptions7(command) {
5568
6106
  return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
5569
6107
  "--api-url <url>",
5570
6108
  "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
5571
6109
  );
5572
6110
  }
5573
- async function runPlatformCommand4(options, timeoutMs, execute) {
6111
+ async function runPlatformCommand7(options, timeoutMs, execute) {
5574
6112
  const controller = new AbortController();
5575
6113
  const timeoutHandle = setTimeout(() => {
5576
6114
  controller.abort(
5577
- new PlatformApiError(`Request timed out after ${timeoutMs}ms`, "TIMEOUT", {
5578
- status: 0
5579
- })
6115
+ new PlatformApiError(
6116
+ `Request timed out after ${timeoutMs}ms`,
6117
+ "TIMEOUT",
6118
+ {
6119
+ status: 0
6120
+ }
6121
+ )
5580
6122
  );
5581
6123
  }, timeoutMs);
5582
6124
  timeoutHandle.unref?.();
@@ -5625,31 +6167,38 @@ function loadConfigObject(options) {
5625
6167
  return base;
5626
6168
  }
5627
6169
  function registerHostsCommands(program) {
5628
- const hosts = program.command("hosts").description("List, create, and manage the hosts in your hosted MCPJam projects");
5629
- hosts.command("templates").description("List the built-in host templates usable with `hosts create --template`").action((_options, command) => {
6170
+ const hosts = program.command("hosts").description(
6171
+ "List, create, and manage the hosts in your hosted MCPJam projects"
6172
+ );
6173
+ hosts.command("templates").description(
6174
+ "List the built-in host templates usable with `hosts create --template`"
6175
+ ).action((_options, command) => {
5630
6176
  const globalOptions = getGlobalOptions(command);
5631
6177
  writeResult({ items: HOST_TEMPLATES }, globalOptions.format);
5632
6178
  });
5633
- addPlatformOptions4(
6179
+ addPlatformOptions7(
5634
6180
  hosts.command("list").description("List the hosts saved in a project").option(
5635
6181
  "--project <id-or-name>",
5636
6182
  "Project name or ID (defaults to the most recently updated project)"
5637
6183
  )
5638
6184
  ).action(async (options, command) => {
5639
6185
  const globalOptions = getGlobalOptions(command);
5640
- const result = await runPlatformCommand4(
6186
+ const result = await runPlatformCommand7(
5641
6187
  options,
5642
6188
  globalOptions.timeout,
5643
- ({ client, signal }) => listHostsOperation.execute({ project: options.project }, { client, signal })
6189
+ ({ client, signal }) => listHostsOperation.execute(
6190
+ { project: options.project },
6191
+ { client, signal }
6192
+ )
5644
6193
  );
5645
6194
  writeResult(result, globalOptions.format);
5646
6195
  });
5647
- addPlatformOptions4(
6196
+ addPlatformOptions7(
5648
6197
  hosts.command("get").description("Show one host's full settings, including its host config").requiredOption("--host <id-or-name>", "Host name or ID").option("--project <id-or-name>", "Project name or ID")
5649
6198
  ).action(
5650
6199
  async (options, command) => {
5651
6200
  const globalOptions = getGlobalOptions(command);
5652
- const result = await runPlatformCommand4(
6201
+ const result = await runPlatformCommand7(
5653
6202
  options,
5654
6203
  globalOptions.timeout,
5655
6204
  ({ client, signal }) => getHostOperation.execute(
@@ -5660,7 +6209,7 @@ function registerHostsCommands(program) {
5660
6209
  writeResult(result, globalOptions.format);
5661
6210
  }
5662
6211
  );
5663
- addPlatformOptions4(
6212
+ addPlatformOptions7(
5664
6213
  hosts.command("create").description(
5665
6214
  "Create a host from a built-in template (--template) or a full host config (--file/--json)"
5666
6215
  ).requiredOption("--name <name>", "Display name for the new host").option("--project <id-or-name>", "Project name or ID").option(
@@ -5681,7 +6230,7 @@ function registerHostsCommands(program) {
5681
6230
  ...options.theme !== void 0 ? { theme: options.theme } : {},
5682
6231
  ...config !== void 0 ? { config } : {}
5683
6232
  });
5684
- const result = await runPlatformCommand4(
6233
+ const result = await runPlatformCommand7(
5685
6234
  options,
5686
6235
  globalOptions.timeout,
5687
6236
  ({ client, signal }) => createHostOperation.execute(input, { client, signal })
@@ -5689,8 +6238,14 @@ function registerHostsCommands(program) {
5689
6238
  writeResult(result, globalOptions.format);
5690
6239
  }
5691
6240
  );
5692
- addPlatformOptions4(
5693
- hosts.command("update").description("Edit a host's name and/or its host config").requiredOption("--host <id-or-name>", "Host name or ID").option("--project <id-or-name>", "Project name or ID").option("--name <name>", "New display name").option("--file <path>", "Replacement host config v2 JSON (or - for stdin)").option("--json <json>", "Inline replacement host config v2 JSON (or @file, or -)")
6241
+ addPlatformOptions7(
6242
+ hosts.command("update").description("Edit a host's name and/or its host config").requiredOption("--host <id-or-name>", "Host name or ID").option("--project <id-or-name>", "Project name or ID").option("--name <name>", "New display name").option(
6243
+ "--file <path>",
6244
+ "Replacement host config v2 JSON (or - for stdin)"
6245
+ ).option(
6246
+ "--json <json>",
6247
+ "Inline replacement host config v2 JSON (or @file, or -)"
6248
+ )
5694
6249
  ).action(
5695
6250
  async (options, command) => {
5696
6251
  const globalOptions = getGlobalOptions(command);
@@ -5701,7 +6256,7 @@ function registerHostsCommands(program) {
5701
6256
  ...options.name !== void 0 ? { name: options.name } : {},
5702
6257
  ...config !== void 0 ? { config } : {}
5703
6258
  });
5704
- const result = await runPlatformCommand4(
6259
+ const result = await runPlatformCommand7(
5705
6260
  options,
5706
6261
  globalOptions.timeout,
5707
6262
  ({ client, signal }) => updateHostOperation.execute(input, { client, signal })
@@ -5709,12 +6264,12 @@ function registerHostsCommands(program) {
5709
6264
  writeResult(result, globalOptions.format);
5710
6265
  }
5711
6266
  );
5712
- addPlatformOptions4(
6267
+ addPlatformOptions7(
5713
6268
  hosts.command("delete").description("Permanently delete a host from a project").requiredOption("--host <id-or-name>", "Host name or ID").option("--project <id-or-name>", "Project name or ID")
5714
6269
  ).action(
5715
6270
  async (options, command) => {
5716
6271
  const globalOptions = getGlobalOptions(command);
5717
- const result = await runPlatformCommand4(
6272
+ const result = await runPlatformCommand7(
5718
6273
  options,
5719
6274
  globalOptions.timeout,
5720
6275
  ({ client, signal }) => deleteHostOperation.execute(
@@ -5728,6 +6283,50 @@ function registerHostsCommands(program) {
5728
6283
  writeResult(result, globalOptions.format);
5729
6284
  }
5730
6285
  );
6286
+ addPlatformOptions7(
6287
+ hosts.command("servers").description("Replace a host's required and optional server attachments").requiredOption("--host <id-or-name>", "Host name or ID").requiredOption(
6288
+ "--server-ids <ids>",
6289
+ "Comma-separated required server IDs"
6290
+ ).option(
6291
+ "--optional-server-ids <ids>",
6292
+ "Comma-separated optional server IDs"
6293
+ ).option("--project <id-or-name>", "Project name or ID")
6294
+ ).action(
6295
+ async (options, command) => {
6296
+ const globalOptions = getGlobalOptions(command);
6297
+ const splitIds = (value) => value.split(",").map((id) => id.trim()).filter(Boolean);
6298
+ const input = validateInput3(setHostServersOperation, {
6299
+ project: options.project,
6300
+ host: options.host,
6301
+ serverIds: splitIds(options.serverIds),
6302
+ ...options.optionalServerIds ? { optionalServerIds: splitIds(options.optionalServerIds) } : {}
6303
+ });
6304
+ const result = await runPlatformCommand7(
6305
+ options,
6306
+ globalOptions.timeout,
6307
+ ({ client, signal }) => setHostServersOperation.execute(input, { client, signal })
6308
+ );
6309
+ writeResult(result, globalOptions.format);
6310
+ }
6311
+ );
6312
+ addPlatformOptions7(
6313
+ hosts.command("duplicate").description("Duplicate a host's current config").requiredOption("--host <id-or-name>", "Host name or ID").option("--name <name>", "Name for the new host").option("--project <id-or-name>", "Project name or ID")
6314
+ ).action(
6315
+ async (options, command) => {
6316
+ const globalOptions = getGlobalOptions(command);
6317
+ const input = validateInput3(duplicateHostOperation, {
6318
+ project: options.project,
6319
+ host: options.host,
6320
+ ...options.name === void 0 ? {} : { name: options.name }
6321
+ });
6322
+ const result = await runPlatformCommand7(
6323
+ options,
6324
+ globalOptions.timeout,
6325
+ ({ client, signal }) => duplicateHostOperation.execute(input, { client, signal })
6326
+ );
6327
+ writeResult(result, globalOptions.format);
6328
+ }
6329
+ );
5731
6330
  }
5732
6331
  function validateInput3(op, raw) {
5733
6332
  const parsed = op.inputSchema.safeParse(raw);
@@ -6488,13 +7087,13 @@ function statusGlyph(status) {
6488
7087
  }
6489
7088
 
6490
7089
  // src/commands/projects.ts
6491
- function addPlatformOptions5(command) {
7090
+ function addPlatformOptions8(command) {
6492
7091
  return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
6493
7092
  "--api-url <url>",
6494
7093
  "MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
6495
7094
  );
6496
7095
  }
6497
- async function runPlatformCommand5(options, timeoutMs, execute) {
7096
+ async function runPlatformCommand8(options, timeoutMs, execute) {
6498
7097
  const controller = new AbortController();
6499
7098
  const timeoutHandle = setTimeout(() => {
6500
7099
  controller.abort(
@@ -6521,12 +7120,14 @@ async function runPlatformCommand5(options, timeoutMs, execute) {
6521
7120
  }
6522
7121
  }
6523
7122
  function registerProjectsCommands(program) {
6524
- const projects = program.command("projects").description("Operate the MCP servers saved in your hosted MCPJam projects");
6525
- addPlatformOptions5(
7123
+ const projects = program.command("projects").description(
7124
+ "Operate the MCP servers saved in your hosted MCPJam projects"
7125
+ );
7126
+ addPlatformOptions8(
6526
7127
  projects.command("list").description("List the projects you can access")
6527
7128
  ).action(async (options, command) => {
6528
7129
  const globalOptions = getGlobalOptions(command);
6529
- const result = await runPlatformCommand5(
7130
+ const result = await runPlatformCommand8(
6530
7131
  options,
6531
7132
  globalOptions.timeout,
6532
7133
  ({ client, signal }) => listProjectsOperation.execute({}, { client, signal })
@@ -6538,14 +7139,67 @@ function registerProjectsCommands(program) {
6538
7139
  writeResult(result, globalOptions.format);
6539
7140
  }
6540
7141
  });
6541
- addPlatformOptions5(
6542
- projects.command("servers").description("List the servers saved in a project").option(
6543
- "--project <id-or-name>",
6544
- "Project name or ID (defaults to the most recently updated project)"
6545
- )
7142
+ addPlatformOptions8(
7143
+ projects.command("create").description("Create a hosted MCPJam project").requiredOption("--name <name>", "Project name").option("--description <text>", "Project description").option("--organization-id <id>", "Organization ID").option("--visibility <visibility>", "public or private")
7144
+ ).action(
7145
+ async (options, command) => {
7146
+ const globalOptions = getGlobalOptions(command);
7147
+ const input = createProjectOperation.inputSchema.parse({
7148
+ name: options.name,
7149
+ ...options.description === void 0 ? {} : { description: options.description },
7150
+ ...options.organizationId === void 0 ? {} : { organizationId: options.organizationId },
7151
+ ...options.visibility === void 0 ? {} : { visibility: options.visibility }
7152
+ });
7153
+ const result = await runPlatformCommand8(
7154
+ options,
7155
+ globalOptions.timeout,
7156
+ ({ client, signal }) => createProjectOperation.execute(input, { client, signal })
7157
+ );
7158
+ writeResult(result, globalOptions.format);
7159
+ }
7160
+ );
7161
+ addPlatformOptions8(
7162
+ projects.command("update").description("Update project metadata").requiredOption("--project <id-or-name>", "Project name or ID").option("--name <name>", "New project name").option("--description <text>", "New project description").option("--visibility <visibility>", "public or private")
7163
+ ).action(
7164
+ async (options, command) => {
7165
+ const globalOptions = getGlobalOptions(command);
7166
+ const input = updateProjectOperation.inputSchema.parse({
7167
+ project: options.project,
7168
+ ...options.name === void 0 ? {} : { name: options.name },
7169
+ ...options.description === void 0 ? {} : { description: options.description },
7170
+ ...options.visibility === void 0 ? {} : { visibility: options.visibility }
7171
+ });
7172
+ const result = await runPlatformCommand8(
7173
+ options,
7174
+ globalOptions.timeout,
7175
+ ({ client, signal }) => updateProjectOperation.execute(input, { client, signal })
7176
+ );
7177
+ writeResult(result, globalOptions.format);
7178
+ }
7179
+ );
7180
+ addPlatformOptions8(
7181
+ projects.command("delete").description("Delete a project and its project-owned resources").requiredOption("--project <id-or-name>", "Project name or ID")
6546
7182
  ).action(async (options, command) => {
6547
7183
  const globalOptions = getGlobalOptions(command);
6548
- const result = await runPlatformCommand5(
7184
+ const input = deleteProjectOperation.inputSchema.parse({
7185
+ project: options.project
7186
+ });
7187
+ const result = await runPlatformCommand8(
7188
+ options,
7189
+ globalOptions.timeout,
7190
+ ({ client, signal }) => deleteProjectOperation.execute(input, { client, signal })
7191
+ );
7192
+ writeResult(result, globalOptions.format);
7193
+ });
7194
+ const servers = addPlatformOptions8(
7195
+ projects.command("servers").alias("server").description("List and manage the servers saved in a project")
7196
+ ).option(
7197
+ "--project <id-or-name>",
7198
+ "Project name or ID (defaults to the most recently updated project)"
7199
+ );
7200
+ servers.action(async (options, command) => {
7201
+ const globalOptions = getGlobalOptions(command);
7202
+ const result = await runPlatformCommand8(
6549
7203
  options,
6550
7204
  globalOptions.timeout,
6551
7205
  ({ client, signal }) => listProjectServersOperation.execute(
@@ -6560,7 +7214,76 @@ function registerProjectsCommands(program) {
6560
7214
  writeResult(result, globalOptions.format);
6561
7215
  }
6562
7216
  });
6563
- addPlatformOptions5(
7217
+ const parseBody = (raw) => {
7218
+ const parsed = JSON.parse(raw);
7219
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
7220
+ throw new Error("--body must be a JSON object");
7221
+ }
7222
+ return parsed;
7223
+ };
7224
+ addPlatformOptions8(
7225
+ servers.command("create").alias("add").description("Create a saved MCP server").requiredOption("--project <id-or-name>", "Project name or ID").requiredOption("--body <json>", "Server JSON body")
7226
+ ).action(async (options, command) => {
7227
+ const globalOptions = getGlobalOptions(command);
7228
+ const result = await runPlatformCommand8(
7229
+ options,
7230
+ globalOptions.timeout,
7231
+ ({ client, signal }) => createProjectServerOperation.execute(
7232
+ { project: options.project, body: parseBody(options.body) },
7233
+ { client, signal }
7234
+ )
7235
+ );
7236
+ writeResult(result, globalOptions.format);
7237
+ });
7238
+ addPlatformOptions8(
7239
+ servers.command("get").description("Get one saved MCP server").requiredOption("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID")
7240
+ ).action(async (options, command) => {
7241
+ const globalOptions = getGlobalOptions(command);
7242
+ const result = await runPlatformCommand8(
7243
+ options,
7244
+ globalOptions.timeout,
7245
+ ({ client, signal }) => getProjectServerOperation.execute(
7246
+ { project: options.project, serverId: options.server },
7247
+ { client, signal }
7248
+ )
7249
+ );
7250
+ writeResult(result, globalOptions.format);
7251
+ });
7252
+ addPlatformOptions8(
7253
+ servers.command("update").description("Update one saved MCP server").requiredOption("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID").requiredOption("--body <json>", "Patch JSON body")
7254
+ ).action(
7255
+ async (options, command) => {
7256
+ const globalOptions = getGlobalOptions(command);
7257
+ const result = await runPlatformCommand8(
7258
+ options,
7259
+ globalOptions.timeout,
7260
+ ({ client, signal }) => updateProjectServerOperation.execute(
7261
+ {
7262
+ project: options.project,
7263
+ serverId: options.server,
7264
+ body: parseBody(options.body)
7265
+ },
7266
+ { client, signal }
7267
+ )
7268
+ );
7269
+ writeResult(result, globalOptions.format);
7270
+ }
7271
+ );
7272
+ addPlatformOptions8(
7273
+ servers.command("delete").alias("remove").description("Delete one saved MCP server").requiredOption("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID")
7274
+ ).action(async (options, command) => {
7275
+ const globalOptions = getGlobalOptions(command);
7276
+ const result = await runPlatformCommand8(
7277
+ options,
7278
+ globalOptions.timeout,
7279
+ ({ client, signal }) => deleteProjectServerOperation.execute(
7280
+ { project: options.project, serverId: options.server },
7281
+ { client, signal }
7282
+ )
7283
+ );
7284
+ writeResult(result, globalOptions.format);
7285
+ });
7286
+ addPlatformOptions8(
6564
7287
  projects.command("status").description(
6565
7288
  "Health-check every server in a project (hosted doctor per server)"
6566
7289
  ).option(
@@ -6569,7 +7292,7 @@ function registerProjectsCommands(program) {
6569
7292
  )
6570
7293
  ).action(async (options, command) => {
6571
7294
  const globalOptions = getGlobalOptions(command);
6572
- const payload = await runPlatformCommand5(
7295
+ const payload = await runPlatformCommand8(
6573
7296
  options,
6574
7297
  globalOptions.timeout,
6575
7298
  ({ client, signal }) => showServersOperation.execute(
@@ -6622,8 +7345,12 @@ function registerProtocolCommands(program) {
6622
7345
  const config = buildConfig(options);
6623
7346
  const result = await new MCPConformanceTest(config).run();
6624
7347
  writeConformanceOutput2(renderConformanceForCli(result, reporter, format));
6625
- if (!result.passed) {
6626
- setProcessExitCode(1);
7348
+ reportScore(scoreFromProtocolResult(result), command);
7349
+ reportReadiness(result, command);
7350
+ reportIncomplete(result, command);
7351
+ const exitCode = conformanceExitCode(result);
7352
+ if (exitCode !== 0) {
7353
+ setProcessExitCode(exitCode);
6627
7354
  }
6628
7355
  });
6629
7356
  protocol.command("conformance-suite").description(
@@ -6637,8 +7364,14 @@ function registerProtocolCommands(program) {
6637
7364
  const config = loadProtocolSuiteConfig(options.config);
6638
7365
  const result = await new MCPConformanceSuite(config).run();
6639
7366
  writeConformanceOutput2(renderConformanceForCli(result, reporter, format));
6640
- if (!result.passed) {
6641
- setProcessExitCode(1);
7367
+ for (const run of result.results) {
7368
+ reportScore(scoreFromProtocolResult(run), command, run.label);
7369
+ reportReadiness(run, command);
7370
+ reportIncomplete(run, command);
7371
+ }
7372
+ const exitCode = conformanceSuiteExitCode(result.results);
7373
+ if (exitCode !== 0) {
7374
+ setProcessExitCode(exitCode);
6642
7375
  }
6643
7376
  });
6644
7377
  }
@@ -6999,8 +7732,12 @@ function registerOAuthCommands(program) {
6999
7732
  if (credentialsFileError) {
7000
7733
  throw credentialsFileError;
7001
7734
  }
7002
- if (!result.passed) {
7735
+ reportScore(scoreFromOAuthResult(result), command);
7736
+ reportIncomplete(result, command);
7737
+ if (result.outcome === "failed") {
7003
7738
  setProcessExitCode(1);
7739
+ } else if (result.outcome === "incomplete") {
7740
+ setProcessExitCode(3);
7004
7741
  }
7005
7742
  });
7006
7743
  oauth.command("conformance-suite").description(
@@ -7058,8 +7795,17 @@ function registerOAuthCommands(program) {
7058
7795
  if (credentialsFileError) {
7059
7796
  throw credentialsFileError;
7060
7797
  }
7061
- if (!result.passed) {
7798
+ for (const run of result.results) {
7799
+ reportScore(scoreFromOAuthResult(run), command, run.label);
7800
+ reportIncomplete(run, command);
7801
+ }
7802
+ const flowOutcomes = result.results.map(
7803
+ (run) => run.outcome ?? (run.passed ? "passed" : "failed")
7804
+ );
7805
+ if (flowOutcomes.includes("failed")) {
7062
7806
  setProcessExitCode(1);
7807
+ } else if (flowOutcomes.includes("incomplete")) {
7808
+ setProcessExitCode(3);
7063
7809
  }
7064
7810
  });
7065
7811
  oauth.command("metadata").description("Fetch OAuth metadata from a URL").requiredOption("--url <url>", "OAuth metadata URL").action(async (options, command) => {
@@ -9788,11 +10534,7 @@ var TASKS_CHECK_IDS_BY_CATEGORY = {
9788
10534
  "tasks-undeclared-capability-rejected"
9789
10535
  ]
9790
10536
  };
9791
- function tasksConformanceExitCode(result) {
9792
- if (result.outcome === "incomplete") return 3;
9793
- if (result.outcome === "failed") return 1;
9794
- return result.passed ? 0 : 1;
9795
- }
10537
+ var tasksConformanceExitCode = conformanceExitCode;
9796
10538
  function collectInvalidEntries3(values, allowed) {
9797
10539
  return (values ?? []).filter((value) => !allowed.includes(value));
9798
10540
  }
@@ -10228,6 +10970,7 @@ function registerTasksCommands(program) {
10228
10970
  const output = renderConformanceForCli(outputResult, reporter, format);
10229
10971
  process.stdout.write(output.endsWith("\n") ? output : `${output}
10230
10972
  `);
10973
+ reportScore(scoreFromTasksResult(result), command);
10231
10974
  const incompleteReason = result.incompleteReason;
10232
10975
  if (incompleteReason && !globalOptions.quiet) {
10233
10976
  process.stderr.write(`Run incomplete: ${incompleteReason}
@@ -12305,8 +13048,11 @@ async function main(argv = process.argv, dependencies = {}) {
12305
13048
  registerAuthCommands(program);
12306
13049
  registerProjectsCommands(program);
12307
13050
  registerEvalCommands(program);
13051
+ registerChatCommands(program);
12308
13052
  registerHostsCommands(program);
12309
13053
  registerEnvironmentsCommands(program);
13054
+ registerJourneysCommands(program);
13055
+ registerScenariosCommands(program);
12310
13056
  registerImagesCommands(program);
12311
13057
  registerTunnelCommands(program);
12312
13058
  registerInspectorCommands(program);