@mcpjam/cli 5.0.0 → 5.1.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
@@ -9,10 +9,10 @@ import { mkdir, writeFile, readFile, chmod, rename, rm, open, unlink, stat } fro
9
9
  import { spawn } from 'child_process';
10
10
  import { createRequire } from 'module';
11
11
  import os, { homedir } from 'os';
12
- import { getRegistryDirectoryServerOperation, listOrganizationsOperation, listProjectsOperation, createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, listChatSessionsOperation, resolveProject, createTunnelOperation, listEvalSuiteRunsOperation, runEvalSuiteOperation, getEvalRunOperation, cancelEvalRunOperation, requestEvalRunJudgeOperation, listEvalCheckReposOperation, connectEvalCheckRepoOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createHostOperation, updateHostOperation, setHostServersOperation, duplicateHostOperation, createEnvironmentOperation, ensureAdhocEnvironmentOperation, nameEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, PlatformApiError, installRegistryServerOperation, installRegistryDirectoryServerOperation, getProjectServerOperation, DEFAULT_PLATFORM_API_BASE_URL, projectResolutionError, listProjectServersOperation, createProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, isPlatformApiError, createEvalSuiteOperation, listEvalSuitesOperation, resolveEnvironmentOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, getEnvironmentCapabilitiesOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, listScenariosOperation, getScenarioOperation, publishScenarioOperation, unpublishScenarioOperation, PlatformApiClient, getCapabilitiesOperation, searchSessionsOperation, sendChatMessageOperation, getChatSessionOperation, getChatSessionTraceOperation, listPersonasOperation, getPersonaOperation, createPersonaOperation, updatePersonaOperation, deletePersonaOperation, generatePersonasOperation, getJourneyOperation, createJourneyOperation, updateJourneyOperation, archiveJourneyOperation, generateJourneysOperation, getSwarmOverviewOperation, getJourneyRunScorecardOperation, listSwarmFindingsOperation, dismissSwarmFindingOperation, undismissSwarmFindingOperation, getWaveInsightsOperation, requestWaveInsightsOperation, cancelWaveInsightsOperation, listSwarmsOperation, getSwarmOperation, createSwarmOperation, updateSwarmOperation, archiveSwarmOperation, getUserTestingScenarioOperation, listUserTestingSessionsOperation, getUserTestingSessionOperation, getUserTestingMetricsOperation, getUserTestingUsageOperation, listUserTestingFindingsOperation, getUserTestingSignalsOperation, getUserTestingInsightsOperation, requestUserTestingInsightsOperation, cancelUserTestingInsightsOperation, dismissUserTestingFindingOperation, undismissUserTestingFindingOperation, updateUserTestingScenarioOperation, setUserTestingGuestExecutionOperation, rotateUserTestingLinkOperation, upsertUserTestingMemberOperation, removeUserTestingMemberOperation, rebindUserTestingScenarioOperation, startClaudeReadinessRunOperation, startOpenAIReadinessRunOperation, getReadinessRunOperation, listReadinessRunsOperation, cancelReadinessRunOperation, getReadinessReportOperation, listRegistryDirectorySourcesOperation, searchRegistryDirectoryOperation, listRegistryServersOperation, listRegistryConnectionsOperation, uninstallRegistryServerOperation } from '@mcpjam/sdk/platform';
12
+ import { getRegistryDirectoryServerOperation, listOrganizationsOperation, listProjectsOperation, createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, listChatSessionsOperation, resolveProject, createTunnelOperation, listEvalSuiteRunsOperation, runEvalSuiteOperation, getEvalRunOperation, cancelEvalRunOperation, requestEvalRunJudgeOperation, listEvalCheckReposOperation, connectEvalCheckRepoOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, createClientOperation, updateClientOperation, setClientServersOperation, duplicateClientOperation, createEnvironmentOperation, ensureAdhocEnvironmentOperation, nameEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, runOperationWithPermalinks, withPermalinkEnvelope, PlatformApiError, installRegistryServerOperation, installRegistryDirectoryServerOperation, getProjectServerOperation, DEFAULT_PLATFORM_API_BASE_URL, projectResolutionError, listProjectServersOperation, createProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, isPlatformApiError, createEvalSuiteOperation, listEvalSuitesOperation, buildAppPermalink, resolveEnvironmentOperation, listClientsOperation, getClientOperation, deleteClientOperation, listEnvironmentsOperation, getEnvironmentOperation, getEnvironmentCapabilitiesOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, listScenariosOperation, getScenarioOperation, publishScenarioOperation, unpublishScenarioOperation, PlatformApiClient, getCapabilitiesOperation, searchSessionsOperation, sendChatMessageOperation, getChatSessionOperation, getChatSessionTraceOperation, listPersonasOperation, getPersonaOperation, createPersonaOperation, updatePersonaOperation, deletePersonaOperation, generatePersonasOperation, getJourneyOperation, createJourneyOperation, updateJourneyOperation, archiveJourneyOperation, generateJourneysOperation, getSwarmOverviewOperation, getJourneyRunScorecardOperation, listSwarmFindingsOperation, dismissSwarmFindingOperation, undismissSwarmFindingOperation, getWaveInsightsOperation, requestWaveInsightsOperation, cancelWaveInsightsOperation, listSwarmsOperation, getSwarmOperation, createSwarmOperation, updateSwarmOperation, archiveSwarmOperation, getUserTestingScenarioOperation, listUserTestingSessionsOperation, getUserTestingSessionOperation, getUserTestingMetricsOperation, getUserTestingUsageOperation, listUserTestingFindingsOperation, getUserTestingSignalsOperation, getUserTestingInsightsOperation, requestUserTestingInsightsOperation, cancelUserTestingInsightsOperation, dismissUserTestingFindingOperation, undismissUserTestingFindingOperation, updateUserTestingScenarioOperation, setUserTestingGuestExecutionOperation, rotateUserTestingLinkOperation, upsertUserTestingMemberOperation, removeUserTestingMemberOperation, rebindUserTestingScenarioOperation, startClaudeReadinessRunOperation, startOpenAIReadinessRunOperation, getReadinessRunOperation, listReadinessRunsOperation, cancelReadinessRunOperation, getReadinessReportOperation, listRegistryDirectorySourcesOperation, searchRegistryDirectoryOperation, listRegistryServersOperation, listRegistryConnectionsOperation, uninstallRegistryServerOperation } from '@mcpjam/sdk/platform';
13
13
  import { isDeepStrictEqual } from 'util';
14
14
  import { MAX_BATCH_CREATE_CASES, evalSuiteFileSchema, isOpaqueId } from '@mcpjam/sdk/contract';
15
- import { HOST_TEMPLATES as HOST_TEMPLATES$1, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
15
+ import { HOST_TEMPLATES, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
16
16
  import http from 'http';
17
17
  import https from 'https';
18
18
  import { once } from 'events';
@@ -27,7 +27,7 @@ import { PostHog } from 'posthog-node';
27
27
 
28
28
  // package.json
29
29
  var package_default = {
30
- version: "5.0.0"};
30
+ version: "5.1.0"};
31
31
  function conformanceExitCode(result) {
32
32
  if (result.outcome === "incomplete") return 3;
33
33
  if (result.outcome === "failed") return 1;
@@ -4336,6 +4336,13 @@ function hasCloudAncestor(command) {
4336
4336
  function commandHasProjectOption(command) {
4337
4337
  return command.options.some((option) => option.long === "--project");
4338
4338
  }
4339
+ function writeHumanPermalinks(permalinks) {
4340
+ if (permalinks.length === 0) return;
4341
+ process.stdout.write(
4342
+ `${permalinks.map((permalink) => `View: ${permalink.url}`).join("\n")}
4343
+ `
4344
+ );
4345
+ }
4339
4346
  function bindOperation(command, operation, buildInput, bindExtras = {}) {
4340
4347
  if (!hasCloudAncestor(command)) {
4341
4348
  addPlatformOptions(command);
@@ -4350,13 +4357,37 @@ function bindOperation(command, operation, buildInput, bindExtras = {}) {
4350
4357
  const applyAmbient = (underCloud || bindExtras.ambientProject === true) && commandHasProjectOption(invoked);
4351
4358
  const resolved = applyAmbient ? resolveCloudProjectArgs({ project: merged.project }) : void 0;
4352
4359
  const inputOptions = resolved ? { ...options, project: resolved.project } : options;
4360
+ let permalinks = [];
4353
4361
  const result = await runPlatformOperation(
4354
4362
  platformOptionsOf(invoked),
4355
4363
  globalOptions.timeout,
4356
- ({ client, signal }) => operation.execute(buildInput(inputOptions, ...positionals), {
4357
- client,
4358
- signal
4359
- }),
4364
+ async ({ client, signal, webOrigin }) => {
4365
+ const input = buildInput(inputOptions, ...positionals);
4366
+ if (!operation.permalink || !operation.name) {
4367
+ return operation.execute(input, { client, signal });
4368
+ }
4369
+ const ran = await runOperationWithPermalinks(
4370
+ {
4371
+ name: operation.name,
4372
+ permalink: operation.permalink,
4373
+ execute: operation.execute
4374
+ },
4375
+ input,
4376
+ { client, signal },
4377
+ {
4378
+ appOrigin: webOrigin,
4379
+ // stderr, so `--format json` stdout stays a parseable contract.
4380
+ onError: (error, operationName) => {
4381
+ process.stderr.write(
4382
+ `mcpjam: could not build a permalink for ${operationName}: ${error instanceof Error ? error.message : String(error)}
4383
+ `
4384
+ );
4385
+ }
4386
+ }
4387
+ );
4388
+ permalinks = ran.permalinks;
4389
+ return ran.result;
4390
+ },
4360
4391
  {
4361
4392
  announce: bindExtras.announce ?? underCloud,
4362
4393
  quiet: globalOptions.quiet,
@@ -4366,12 +4397,20 @@ function bindOperation(command, operation, buildInput, bindExtras = {}) {
4366
4397
  } : bindExtras.cloudScope ? { cloudScope: bindExtras.cloudScope } : {}
4367
4398
  }
4368
4399
  );
4369
- if (bindExtras.formatHuman && globalOptions.format === "human") {
4370
- process.stdout.write(`${bindExtras.formatHuman(result)}
4400
+ if (globalOptions.format === "human") {
4401
+ if (bindExtras.formatHuman) {
4402
+ process.stdout.write(`${bindExtras.formatHuman(result)}
4371
4403
  `);
4404
+ } else {
4405
+ writeResult(result, globalOptions.format);
4406
+ }
4407
+ writeHumanPermalinks(permalinks);
4372
4408
  return;
4373
4409
  }
4374
- writeResult(result, globalOptions.format);
4410
+ writeResult(
4411
+ permalinks.length > 0 ? withPermalinkEnvelope(result, permalinks) : result,
4412
+ globalOptions.format
4413
+ );
4375
4414
  });
4376
4415
  }
4377
4416
  async function runCloudOp(command, options, execute, extra = {}) {
@@ -7050,14 +7089,24 @@ function writeRunLink(format, webOrigin, run) {
7050
7089
  if (format !== "human") return;
7051
7090
  const suiteId = run.suiteId?.trim();
7052
7091
  const runId = run.runId?.trim();
7053
- if (!suiteId || !runId) return;
7054
- const query = run.projectId?.trim() ? `?project=${encodeURIComponent(run.projectId.trim())}` : "";
7055
- process.stdout.write(
7056
- `View: ${webOrigin}/evals/suite/${encodeURIComponent(
7057
- suiteId
7058
- )}/runs/${encodeURIComponent(runId)}${query}
7059
- `
7060
- );
7092
+ const projectId = run.projectId?.trim();
7093
+ if (!suiteId || !runId || !projectId) return;
7094
+ let permalink;
7095
+ try {
7096
+ permalink = buildAppPermalink(
7097
+ {
7098
+ type: "eval_run",
7099
+ id: runId,
7100
+ parent: { type: "eval_suite", id: suiteId },
7101
+ projectId
7102
+ },
7103
+ { appOrigin: webOrigin }
7104
+ );
7105
+ } catch {
7106
+ return;
7107
+ }
7108
+ process.stdout.write(`View: ${permalink.url}
7109
+ `);
7061
7110
  }
7062
7111
  var JUDGE_LABELS = [
7063
7112
  ["goalCompletion", "goal completion"],
@@ -9554,7 +9603,22 @@ function registerEvalCommands(program) {
9554
9603
  }
9555
9604
  );
9556
9605
  }
9557
- var HOST_TEMPLATES = HOST_TEMPLATES$1.map(({ id, label }) => ({ id, label }));
9606
+ var CLIENT_TEMPLATES = HOST_TEMPLATES.map(({ id, label }) => ({ id, label }));
9607
+ function selectorOf(options) {
9608
+ if (options.client !== void 0 && options.host !== void 0) {
9609
+ throw usageError(
9610
+ "Use either --client or its deprecated --host alias, not both."
9611
+ );
9612
+ }
9613
+ const selector = options.client ?? options.host;
9614
+ if (selector === void 0) {
9615
+ throw usageError("--client <id-or-name> is required.");
9616
+ }
9617
+ return selector;
9618
+ }
9619
+ function withClientSelector(command) {
9620
+ return command.option("--client <id-or-name>", "Client name or ID").option("--host <id-or-name>", "Deprecated alias for --client");
9621
+ }
9558
9622
  function loadConfigObject(options) {
9559
9623
  if (options.file !== void 0 && options.json !== void 0) {
9560
9624
  throw usageError("Provide either --file or --json, not both.");
@@ -9583,62 +9647,164 @@ function loadConfigObject(options) {
9583
9647
  return void 0;
9584
9648
  }
9585
9649
  if (typeof base !== "object" || base === null || Array.isArray(base)) {
9586
- throw usageError("Host config must be a JSON object.");
9650
+ throw usageError("Client config must be a JSON object.");
9587
9651
  }
9588
9652
  return base;
9589
9653
  }
9590
- function registerHostsCommands(program) {
9591
- const hosts = program.command("hosts").description(
9592
- "List, create, and manage the hosts in your hosted MCPJam projects"
9654
+ var SETTABLE_FIELDS = {
9655
+ modelId: {
9656
+ kind: "string",
9657
+ unsettable: false,
9658
+ note: "a client cannot be edited into one that pins no model"
9659
+ },
9660
+ // Required-resettable: --unset resets to the canonical default.
9661
+ systemPrompt: { kind: "string", unsettable: true },
9662
+ temperature: { kind: "number", unsettable: true },
9663
+ requireToolApproval: { kind: "boolean", unsettable: true },
9664
+ connectionDefaults: { kind: "json", unsettable: true },
9665
+ // Optional-clearable: --unset clears to absent.
9666
+ respectToolVisibility: { kind: "boolean", unsettable: true },
9667
+ progressiveToolDiscovery: { kind: "boolean", unsettable: true },
9668
+ harness: { kind: "string", unsettable: true },
9669
+ computer: { kind: "json", unsettable: true },
9670
+ builtInToolIds: { kind: "json", unsettable: true },
9671
+ skillSelection: { kind: "json", unsettable: true },
9672
+ modelVisibleMcpToolResults: { kind: "json", unsettable: true },
9673
+ mcpToolResultImageRendering: { kind: "json", unsettable: true },
9674
+ mcpProfile: { kind: "json", unsettable: true },
9675
+ hostCapabilitiesOverride: { kind: "json", unsettable: true },
9676
+ chatUiOverride: { kind: "json", unsettable: true }
9677
+ };
9678
+ var SETTABLE_FIELD_LIST = Object.keys(SETTABLE_FIELDS).join(", ");
9679
+ function fieldSpec(field) {
9680
+ return Object.hasOwn(SETTABLE_FIELDS, field) ? SETTABLE_FIELDS[field] : void 0;
9681
+ }
9682
+ function unknownFieldError(field) {
9683
+ throw usageError(
9684
+ `Unknown client field "${field}". Settable fields: ${SETTABLE_FIELD_LIST}.`
9593
9685
  );
9594
- hosts.command("templates").description(
9595
- "List the built-in host templates usable with `hosts create --template`"
9686
+ }
9687
+ function parseSetPair(pair) {
9688
+ const separator = pair.indexOf("=");
9689
+ if (separator <= 0) {
9690
+ throw usageError(`--set expects key=value, got "${pair}".`);
9691
+ }
9692
+ const field = pair.slice(0, separator).trim();
9693
+ const raw = pair.slice(separator + 1);
9694
+ const spec = fieldSpec(field);
9695
+ if (!spec) unknownFieldError(field);
9696
+ switch (spec.kind) {
9697
+ case "string":
9698
+ return [field, raw];
9699
+ case "number": {
9700
+ const value = Number(raw);
9701
+ if (raw.trim() === "" || !Number.isFinite(value)) {
9702
+ throw usageError(`--set ${field} expects a number, got "${raw}".`);
9703
+ }
9704
+ return [field, value];
9705
+ }
9706
+ case "boolean":
9707
+ if (raw === "true") return [field, true];
9708
+ if (raw === "false") return [field, false];
9709
+ throw usageError(`--set ${field} expects true or false, got "${raw}".`);
9710
+ case "json":
9711
+ try {
9712
+ return [field, JSON.parse(raw)];
9713
+ } catch (error) {
9714
+ throw usageError(
9715
+ `--set ${field} expects JSON (it is an object or a list), got "${raw}".`,
9716
+ { source: error instanceof Error ? error.message : String(error) }
9717
+ );
9718
+ }
9719
+ }
9720
+ }
9721
+ function buildSetBlock(setPairs, unsetFields) {
9722
+ const set = /* @__PURE__ */ Object.create(null);
9723
+ for (const pair of setPairs ?? []) {
9724
+ const [field, value] = parseSetPair(pair);
9725
+ if (Object.hasOwn(set, field)) {
9726
+ throw usageError(`--set names "${field}" more than once; pass it once.`);
9727
+ }
9728
+ set[field] = value;
9729
+ }
9730
+ for (const field of unsetFields ?? []) {
9731
+ const spec = fieldSpec(field);
9732
+ if (!spec) unknownFieldError(field);
9733
+ if (!spec.unsettable) {
9734
+ throw usageError(
9735
+ `--unset ${field} is not allowed: ${spec.note ?? "this field has no cleared state"}.`
9736
+ );
9737
+ }
9738
+ if (Object.hasOwn(set, field)) {
9739
+ throw usageError(
9740
+ `--set and --unset both name "${field}"; pass one of them.`
9741
+ );
9742
+ }
9743
+ set[field] = null;
9744
+ }
9745
+ return Object.keys(set).length > 0 ? set : void 0;
9746
+ }
9747
+ function registerClientsCommands(program) {
9748
+ const clients = program.command("clients").alias("hosts").description(
9749
+ "List, create, and manage the clients in your hosted MCPJam projects"
9750
+ );
9751
+ clients.command("templates").description(
9752
+ "List the built-in templates usable with `clients create --template`"
9596
9753
  ).action((_options, command) => {
9597
9754
  const globalOptions = getGlobalOptions(command);
9598
- writeResult({ items: HOST_TEMPLATES }, globalOptions.format);
9755
+ writeResult({ items: CLIENT_TEMPLATES }, globalOptions.format);
9599
9756
  });
9600
- hosts.command("list").description("List the hosts saved in a project").option(
9757
+ clients.command("list").description("List the clients saved in a project").option(
9601
9758
  "--project <id-or-name>",
9602
9759
  "Project name or ID (defaults to the most recently updated project)"
9603
- ).action(async (options, command) => {
9604
- const globalOptions = getGlobalOptions(command);
9605
- const result = await runPlatformOperation(
9606
- platformOptionsOf(command),
9607
- globalOptions.timeout,
9608
- ({ client, signal }) => listHostsOperation.execute(
9609
- { project: resolveCloudProjectArgs(options).project },
9610
- { client, signal }
9611
- )
9612
- );
9613
- writeResult(result, globalOptions.format);
9614
- });
9615
- 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").action(
9760
+ ).action(
9761
+ async (options, command) => {
9762
+ const globalOptions = getGlobalOptions(command);
9763
+ const result = await runPlatformOperation(
9764
+ platformOptionsOf(command),
9765
+ globalOptions.timeout,
9766
+ ({ client, signal }) => listClientsOperation.execute(
9767
+ { project: resolveCloudProjectArgs(options).project },
9768
+ { client, signal }
9769
+ )
9770
+ );
9771
+ writeResult(result, globalOptions.format);
9772
+ }
9773
+ );
9774
+ withClientSelector(
9775
+ clients.command("get").description(
9776
+ "Show one client's full settings, its configId (the token every edit takes), and what a config edit would affect"
9777
+ )
9778
+ ).option("--project <id-or-name>", "Project name or ID").action(
9616
9779
  async (options, command) => {
9617
9780
  const globalOptions = getGlobalOptions(command);
9618
9781
  const result = await runPlatformOperation(
9619
9782
  platformOptionsOf(command),
9620
9783
  globalOptions.timeout,
9621
- ({ client, signal }) => getHostOperation.execute(
9622
- { project: resolveCloudProjectArgs(options).project, host: options.host },
9784
+ ({ client, signal }) => getClientOperation.execute(
9785
+ {
9786
+ project: resolveCloudProjectArgs(options).project,
9787
+ client: selectorOf(options)
9788
+ },
9623
9789
  { client, signal }
9624
9790
  )
9625
9791
  );
9626
9792
  writeResult(result, globalOptions.format);
9627
9793
  }
9628
9794
  );
9629
- hosts.command("create").description(
9630
- "Create a host from a built-in template (--template) or a full host config (--file/--json)"
9631
- ).requiredOption("--name <name>", "Display name for the new host").option("--project <id-or-name>", "Project name or ID").option(
9795
+ clients.command("create").description(
9796
+ "Create a client from a built-in template (--template) or a full config (--file/--json)"
9797
+ ).requiredOption("--name <name>", "Display name for the new client").option("--project <id-or-name>", "Project name or ID").option(
9632
9798
  "--template <id>",
9633
- "Built-in template id (see `hosts templates`), e.g. claude, chatgpt, cursor"
9799
+ "Built-in template id (see `clients templates`), e.g. claude, chatgpt, cursor"
9634
9800
  ).option(
9635
9801
  "--theme <theme>",
9636
9802
  "Theme for the seeded config: light or dark (template only)"
9637
- ).option("--file <path>", "Host config v2 JSON file (or - for stdin)").option("--json <json>", "Inline host config v2 JSON (or @file, or -)").action(
9803
+ ).option("--file <path>", "Client config v2 JSON file (or - for stdin)").option("--json <json>", "Inline client config v2 JSON (or @file, or -)").action(
9638
9804
  async (options, command) => {
9639
9805
  const globalOptions = getGlobalOptions(command);
9640
9806
  const config = loadConfigObject(options);
9641
- const input = validateInput2(createHostOperation, {
9807
+ const input = validateInput2(createClientOperation, {
9642
9808
  project: resolveCloudProjectArgs(options).project,
9643
9809
  name: options.name,
9644
9810
  ...options.template !== void 0 ? { template: options.template } : {},
@@ -9648,45 +9814,72 @@ function registerHostsCommands(program) {
9648
9814
  const result = await runPlatformOperation(
9649
9815
  platformOptionsOf(command),
9650
9816
  globalOptions.timeout,
9651
- ({ client, signal }) => createHostOperation.execute(input, { client, signal })
9817
+ ({ client, signal }) => createClientOperation.execute(input, { client, signal })
9652
9818
  );
9653
9819
  writeResult(result, globalOptions.format);
9654
9820
  }
9655
9821
  );
9656
- 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(
9822
+ withClientSelector(
9823
+ clients.command("update").description(
9824
+ "Edit a client's name and/or its config. Use --set/--unset for named fields, or --file/--json to replace the whole config"
9825
+ )
9826
+ ).option("--project <id-or-name>", "Project name or ID").option("--name <name>", "New display name").option(
9827
+ "--expected-name <name>",
9828
+ "The name you last read (required with --name)"
9829
+ ).option(
9830
+ "--expected-config-id <id>",
9831
+ "The configId you last read (required for any config edit)"
9832
+ ).option(
9833
+ "--set <key=value...>",
9834
+ `Set one field. Repeatable. Fields: ${SETTABLE_FIELD_LIST}`
9835
+ ).option(
9836
+ "--unset <key...>",
9837
+ "Clear an optional field to absent, or reset a required one to its default. Repeatable"
9838
+ ).option(
9657
9839
  "--file <path>",
9658
- "Replacement host config v2 JSON (or - for stdin)"
9840
+ "Replacement client config v2 JSON (or - for stdin)"
9659
9841
  ).option(
9660
9842
  "--json <json>",
9661
- "Inline replacement host config v2 JSON (or @file, or -)"
9843
+ "Inline replacement client config v2 JSON (or @file, or -)"
9662
9844
  ).action(
9663
9845
  async (options, command) => {
9664
9846
  const globalOptions = getGlobalOptions(command);
9665
9847
  const config = loadConfigObject(options);
9666
- const input = validateInput2(updateHostOperation, {
9848
+ const set = buildSetBlock(options.set, options.unset);
9849
+ if (config !== void 0 && set !== void 0) {
9850
+ throw usageError(
9851
+ "Use either --set/--unset (named fields) or --file/--json (whole-config replacement), not both."
9852
+ );
9853
+ }
9854
+ const input = validateInput2(updateClientOperation, {
9667
9855
  project: resolveCloudProjectArgs(options).project,
9668
- host: options.host,
9856
+ client: selectorOf(options),
9669
9857
  ...options.name !== void 0 ? { name: options.name } : {},
9670
- ...config !== void 0 ? { config } : {}
9858
+ ...options.expectedName !== void 0 ? { expectedName: options.expectedName } : {},
9859
+ ...options.expectedConfigId !== void 0 ? { expectedConfigId: options.expectedConfigId } : {},
9860
+ ...config !== void 0 ? { config } : {},
9861
+ ...set !== void 0 ? { set } : {}
9671
9862
  });
9672
9863
  const result = await runPlatformOperation(
9673
9864
  platformOptionsOf(command),
9674
9865
  globalOptions.timeout,
9675
- ({ client, signal }) => updateHostOperation.execute(input, { client, signal })
9866
+ ({ client, signal }) => updateClientOperation.execute(input, { client, signal })
9676
9867
  );
9677
9868
  writeResult(result, globalOptions.format);
9678
9869
  }
9679
9870
  );
9680
- 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").action(
9871
+ withClientSelector(
9872
+ clients.command("delete").description("Permanently delete a client from a project")
9873
+ ).option("--project <id-or-name>", "Project name or ID").action(
9681
9874
  async (options, command) => {
9682
9875
  const globalOptions = getGlobalOptions(command);
9683
9876
  const result = await runPlatformOperation(
9684
9877
  platformOptionsOf(command),
9685
9878
  globalOptions.timeout,
9686
- ({ client, signal }) => deleteHostOperation.execute(
9879
+ ({ client, signal }) => deleteClientOperation.execute(
9687
9880
  {
9688
9881
  project: resolveCloudProjectArgs(options).project,
9689
- host: options.host
9882
+ client: selectorOf(options)
9690
9883
  },
9691
9884
  { client, signal }
9692
9885
  )
@@ -9694,42 +9887,52 @@ function registerHostsCommands(program) {
9694
9887
  writeResult(result, globalOptions.format);
9695
9888
  }
9696
9889
  );
9697
- hosts.command("servers").description("Replace a host's required and optional server attachments").requiredOption("--host <id-or-name>", "Host name or ID").requiredOption(
9890
+ withClientSelector(
9891
+ clients.command("servers").description(
9892
+ "Replace a client's required and optional server attachments (servers you omit are detached)"
9893
+ )
9894
+ ).requiredOption(
9698
9895
  "--server-ids <id,...>",
9699
9896
  "Comma-separated required server IDs"
9700
9897
  ).option(
9701
9898
  "--optional-server-ids <id,...>",
9702
9899
  "Comma-separated optional server IDs"
9900
+ ).requiredOption(
9901
+ "--expected-config-id <id>",
9902
+ "The configId you last read for this client"
9703
9903
  ).option("--project <id-or-name>", "Project name or ID").action(
9704
9904
  async (options, command) => {
9705
9905
  const globalOptions = getGlobalOptions(command);
9706
9906
  const splitIds = (value) => value.split(",").map((id) => id.trim()).filter(Boolean);
9707
- const input = validateInput2(setHostServersOperation, {
9907
+ const input = validateInput2(setClientServersOperation, {
9708
9908
  project: resolveCloudProjectArgs(options).project,
9709
- host: options.host,
9909
+ client: selectorOf(options),
9710
9910
  serverIds: splitIds(options.serverIds),
9911
+ expectedConfigId: options.expectedConfigId,
9711
9912
  ...options.optionalServerIds ? { optionalServerIds: splitIds(options.optionalServerIds) } : {}
9712
9913
  });
9713
9914
  const result = await runPlatformOperation(
9714
9915
  platformOptionsOf(command),
9715
9916
  globalOptions.timeout,
9716
- ({ client, signal }) => setHostServersOperation.execute(input, { client, signal })
9917
+ ({ client, signal }) => setClientServersOperation.execute(input, { client, signal })
9717
9918
  );
9718
9919
  writeResult(result, globalOptions.format);
9719
9920
  }
9720
9921
  );
9721
- 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").action(
9922
+ withClientSelector(
9923
+ clients.command("duplicate").description("Duplicate a client's current config into a new client")
9924
+ ).option("--name <name>", "Name for the new client").option("--project <id-or-name>", "Project name or ID").action(
9722
9925
  async (options, command) => {
9723
9926
  const globalOptions = getGlobalOptions(command);
9724
- const input = validateInput2(duplicateHostOperation, {
9927
+ const input = validateInput2(duplicateClientOperation, {
9725
9928
  project: resolveCloudProjectArgs(options).project,
9726
- host: options.host,
9929
+ client: selectorOf(options),
9727
9930
  ...options.name === void 0 ? {} : { name: options.name }
9728
9931
  });
9729
9932
  const result = await runPlatformOperation(
9730
9933
  platformOptionsOf(command),
9731
9934
  globalOptions.timeout,
9732
- ({ client, signal }) => duplicateHostOperation.execute(input, { client, signal })
9935
+ ({ client, signal }) => duplicateClientOperation.execute(input, { client, signal })
9733
9936
  );
9734
9937
  writeResult(result, globalOptions.format);
9735
9938
  }
@@ -12825,7 +13028,7 @@ function registerCloudCommands(program) {
12825
13028
  registerTunnelCommands(cloud);
12826
13029
  cloud.commandsGroup("Eval and environments:");
12827
13030
  registerEvalCommands(cloud);
12828
- registerHostsCommands(cloud);
13031
+ registerClientsCommands(cloud);
12829
13032
  registerEnvironmentsCommands(cloud);
12830
13033
  registerImagesCommands(cloud);
12831
13034
  cloud.commandsGroup("Swarms and user testing:");