replicas-cli 0.3.345 → 0.3.348

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.
Files changed (2) hide show
  1. package/dist/index.cjs +85 -15
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -21700,7 +21700,7 @@ function classifyCanvasFilename(filename) {
21700
21700
  const ext = idx === -1 ? "" : filename.slice(idx).toLowerCase();
21701
21701
  return CANVAS_KIND_BY_EXTENSION[ext] ?? (detectLanguageByPath(filename) ? { kind: "text", mimeType: "text/plain; charset=utf-8" } : { kind: "other", mimeType: "application/octet-stream" });
21702
21702
  }
21703
- var CLAUDE_OPUS_1M_MODEL, LEGACY_CLAUDE_OPUS_1M_MODEL, CLAUDE_FABLE_5_2_MODEL, CLAUDE_FABLE_5_1_MODEL, CLAUDE_FABLE_5_MODEL, CLAUDE_OPUS_5_5_MODEL, CLAUDE_OPUS_5_MODEL, CLAUDE_OPUS_4_8_MODEL, CLAUDE_SONNET_5_5_MODEL, CLAUDE_SONNET_5_MODEL, CLAUDE_HAIKU_5_5_MODEL, CLAUDE_HAIKU_4_5_MODEL, CLAUDE_FABLE_5_2_BEDROCK_MODEL, CLAUDE_FABLE_5_1_BEDROCK_MODEL, CLAUDE_FABLE_5_BEDROCK_MODEL, CLAUDE_OPUS_5_5_BEDROCK_MODEL, CLAUDE_OPUS_5_BEDROCK_MODEL, CLAUDE_OPUS_4_8_BEDROCK_MODEL, CLAUDE_SONNET_5_5_BEDROCK_MODEL, CLAUDE_SONNET_5_BEDROCK_MODEL, CLAUDE_HAIKU_5_5_BEDROCK_MODEL, CLAUDE_HAIKU_4_5_BEDROCK_MODEL, DEFAULT_CLAUDE_MODEL, GPT_6_ASTRA_MODEL, GPT_6_1_SOL_MODEL, GPT_6_SOL_MODEL, GPT_6_LUNA_MODEL, GPT_5_6_SOL_MODEL, GPT_5_6_TERRA_MODEL, GPT_5_6_LUNA_MODEL, DEFAULT_CODEX_MODEL, DEFAULT_OPENCODE_MODEL, GLM_5_3_FLASH_MODEL, DEEPSEEK_V4_PRO_MODEL, DEEPSEEK_V4_FLASH_MODEL, MUSE_WONDER_1_0_MODEL, MUSE_SPARK_1_3_MODEL, DEFAULT_MUSE_MODEL, DEFAULT_OPENROUTER_MODELS, OPENROUTER_MODELS, CLAUDE_MODEL_CONTEXT_WINDOWS, CLAUDE_MODEL_MIN_SANDBOX_IMAGE, CODEX_MODEL_MIN_SANDBOX_IMAGE, AGENT_MODELS, HIDDEN_BY_DEFAULT_MODELS, withoutHiddenByDefault, DEFAULT_STATIC_AGENT_MODELS, DEFAULT_CURSOR_MODELS, SANDBOX_IMAGE_MODEL_FALLBACKS, MODEL_LABELS, IMAGE_MEDIA_TYPES, resourcePressure, sandboxResourceMinuteSchema, MAX_PENDING_RESOURCE_MINUTES, sandboxResourceMinutesSchema, sandboxMemorySampleSchema, MAX_CANVAS_FILE_BYTES, MAX_CANVAS_PREVIEW_BYTES, CANVAS_KIND_BY_EXTENSION;
21703
+ var CLAUDE_OPUS_1M_MODEL, LEGACY_CLAUDE_OPUS_1M_MODEL, CLAUDE_FABLE_5_2_MODEL, CLAUDE_FABLE_5_1_MODEL, CLAUDE_FABLE_5_MODEL, CLAUDE_OPUS_5_5_MODEL, CLAUDE_OPUS_5_MODEL, CLAUDE_OPUS_4_8_MODEL, CLAUDE_SONNET_5_5_MODEL, CLAUDE_SONNET_5_MODEL, CLAUDE_HAIKU_5_5_MODEL, CLAUDE_HAIKU_4_5_MODEL, CLAUDE_FABLE_5_2_BEDROCK_MODEL, CLAUDE_FABLE_5_1_BEDROCK_MODEL, CLAUDE_FABLE_5_BEDROCK_MODEL, CLAUDE_OPUS_5_5_BEDROCK_MODEL, CLAUDE_OPUS_5_BEDROCK_MODEL, CLAUDE_OPUS_4_8_BEDROCK_MODEL, CLAUDE_SONNET_5_5_BEDROCK_MODEL, CLAUDE_SONNET_5_BEDROCK_MODEL, CLAUDE_HAIKU_5_5_BEDROCK_MODEL, CLAUDE_HAIKU_4_5_BEDROCK_MODEL, DEFAULT_CLAUDE_MODEL, GPT_6_ASTRA_MODEL, GPT_6_1_SOL_MODEL, GPT_6_SOL_MODEL, GPT_6_LUNA_MODEL, GPT_5_6_SOL_MODEL, GPT_5_6_TERRA_MODEL, GPT_5_6_LUNA_MODEL, DEFAULT_CODEX_MODEL, DEFAULT_OPENCODE_MODEL, GLM_5_3_FLASH_MODEL, DEEPSEEK_V4_PRO_MODEL, DEEPSEEK_V4_FLASH_MODEL, MUSE_WONDER_1_0_MODEL, MUSE_SPARK_1_3_MODEL, DEFAULT_MUSE_MODEL, DEFAULT_OPENROUTER_MODELS, OPENROUTER_MODELS, CLAUDE_MODEL_CONTEXT_WINDOWS, CLAUDE_MODEL_MIN_SANDBOX_IMAGE, CODEX_MODEL_MIN_SANDBOX_IMAGE, AGENT_MODELS, HIDDEN_BY_DEFAULT_MODELS, withoutHiddenByDefault, DEFAULT_STATIC_AGENT_MODELS, DEFAULT_CURSOR_MODELS, SANDBOX_IMAGE_MODEL_FALLBACKS, MODEL_LABELS, IMAGE_MEDIA_TYPES, resourcePressure, sandboxResourceMinuteSchema, MAX_PENDING_RESOURCE_MINUTES, sandboxResourceMinutesSchema, sandboxMemorySampleSchema, engineUpdateProgressSchema, MAX_CANVAS_FILE_BYTES, MAX_CANVAS_PREVIEW_BYTES, CANVAS_KIND_BY_EXTENSION;
21704
21704
  var init_types4 = __esm({
21705
21705
  "../shared/src/engine/types.ts"() {
21706
21706
  "use strict";
@@ -21988,6 +21988,10 @@ var init_types4 = __esm({
21988
21988
  memoryUsedMb: external_exports.number().min(0),
21989
21989
  memoryPressureSome: resourcePressure
21990
21990
  });
21991
+ engineUpdateProgressSchema = external_exports.discriminatedUnion("state", [
21992
+ external_exports.object({ state: external_exports.enum(["updating", "updated"]), from: external_exports.string(), to: external_exports.string() }),
21993
+ external_exports.object({ state: external_exports.literal("failed"), from: external_exports.string(), to: external_exports.string(), reason: external_exports.string() })
21994
+ ]);
21991
21995
  MAX_CANVAS_FILE_BYTES = 100 * 1024 * 1024;
21992
21996
  MAX_CANVAS_PREVIEW_BYTES = 5 * 1024 * 1024;
21993
21997
  CANVAS_KIND_BY_EXTENSION = {
@@ -22785,7 +22789,7 @@ var init_workspace_identity = __esm({
22785
22789
  });
22786
22790
 
22787
22791
  // ../shared/src/routes/environment.ts
22788
- var ENVIRONMENT_MCP_TRANSPORTS, stringMap, createEnvironmentMcpRequestSchema, updateEnvironmentMcpRequestSchema, screenPasswordSchema, hostSchema, createEnvironmentDeviceRequestSchema, updateEnvironmentDeviceRequestSchema, deviceConnectionResponseSchema, deviceHostKeysRequestSchema, DEVICE_CONNECT_COMMAND, provisionedDeviceSchema;
22792
+ var ENVIRONMENT_MCP_TRANSPORTS, stringMap, createEnvironmentMcpRequestSchema, updateEnvironmentMcpRequestSchema, screenPasswordSchema, hostSchema, createEnvironmentDeviceRequestSchema, updateEnvironmentDeviceRequestSchema, DEVICE_ONLINE_WINDOW_MS, isDeviceOnline, deviceConnectionResponseSchema, deviceHostKeysRequestSchema, DEVICE_CONNECT_COMMAND, provisionedDeviceSchema;
22789
22793
  var init_environment = __esm({
22790
22794
  "../shared/src/routes/environment.ts"() {
22791
22795
  "use strict";
@@ -22816,6 +22820,8 @@ var init_environment = __esm({
22816
22820
  host: external_exports.union([hostSchema, external_exports.literal("")]).optional().describe("New hostname or IP, or an empty string for a device that connects to Replicas itself."),
22817
22821
  screen_password: external_exports.union([screenPasswordSchema, external_exports.literal("")]).optional().describe("New Screen Sharing password, or an empty string to remove it.")
22818
22822
  });
22823
+ DEVICE_ONLINE_WINDOW_MS = 3e4;
22824
+ isDeviceOnline = (lastSeenAt, now = Date.now()) => lastSeenAt !== null && now - Date.parse(lastSeenAt) < DEVICE_ONLINE_WINDOW_MS;
22819
22825
  deviceConnectionResponseSchema = external_exports.object({
22820
22826
  name: external_exports.string(),
22821
22827
  port: external_exports.number(),
@@ -23498,6 +23504,34 @@ until docker info >/dev/null 2>&1; do sleep 0.2; done
23498
23504
  });
23499
23505
 
23500
23506
  // ../shared/src/format.ts
23507
+ function relativeParts(input2, now = Date.now()) {
23508
+ const then = new Date(input2).getTime();
23509
+ if (Number.isNaN(then)) return null;
23510
+ const seconds = Math.max(0, Math.floor((now - then) / 1e3));
23511
+ const minutes = Math.floor(seconds / 60);
23512
+ const hours = Math.floor(minutes / 60);
23513
+ const days = Math.floor(hours / 24);
23514
+ const months = Math.floor(days / 30);
23515
+ return { then, seconds, minutes, hours, days, months, years: Math.floor(months / 12) };
23516
+ }
23517
+ function compactTimeAgo(input2, options) {
23518
+ const p = relativeParts(input2, options?.now);
23519
+ if (!p) return "";
23520
+ if (p.seconds < 60) return options?.seconds === false ? "now" : `${p.seconds}s`;
23521
+ if (p.minutes < 60) return `${p.minutes}m`;
23522
+ if (p.hours < 24) return `${p.hours}h`;
23523
+ if (p.days < 30) return `${p.days}d`;
23524
+ if (p.months < 12) return `${p.months}mo`;
23525
+ return `${p.years}y`;
23526
+ }
23527
+ function formatCompactRelativeTime(input2, now = Date.now()) {
23528
+ const then = new Date(input2).getTime();
23529
+ if (Number.isNaN(then)) return "";
23530
+ if (Math.abs(then - now) < 6e4) return "just now";
23531
+ const future = then > now;
23532
+ const compact = compactTimeAgo(future ? now - (then - now) : then, { now });
23533
+ return future ? `in ${compact}` : `${compact} ago`;
23534
+ }
23501
23535
  var init_format = __esm({
23502
23536
  "../shared/src/format.ts"() {
23503
23537
  "use strict";
@@ -37492,7 +37526,7 @@ var CLI_VERSION;
37492
37526
  var init_cli_version = __esm({
37493
37527
  "../shared/src/cli-version.ts"() {
37494
37528
  "use strict";
37495
- CLI_VERSION = "0.3.345";
37529
+ CLI_VERSION = "0.3.347";
37496
37530
  }
37497
37531
  });
37498
37532
 
@@ -50703,7 +50737,11 @@ function maskValue(value) {
50703
50737
  async function resolveEnvironmentId(input2) {
50704
50738
  if (input2 === "global") return "global";
50705
50739
  if (UUID_RE.test(input2)) return input2;
50706
- const response = await orgAuthenticatedFetch("/v1/environments");
50740
+ const response = await orgAuthenticatedFetch("/v1/environments?scope=all");
50741
+ const named = response.environments.filter((environment2) => environment2.name === input2);
50742
+ if (named.length > 1) {
50743
+ throw new Error(`Both a team and a personal environment are named ${input2}. Use an ID: ${named.map((e) => `${e.id}${e.user_id ? " (personal)" : ""}`).join(", ")}`);
50744
+ }
50707
50745
  const resolved = resolveByNameOrId(input2, response.environments);
50708
50746
  if (!resolved) {
50709
50747
  throw new Error(`Environment not found: ${input2}. Available: ${response.environments.map((e) => e.name).join(", ") || "(none)"}`);
@@ -50711,7 +50749,7 @@ async function resolveEnvironmentId(input2) {
50711
50749
  return resolved.id;
50712
50750
  }
50713
50751
  function printEnvironment(env) {
50714
- console.log(import_chalk20.default.white(` ${env.name}`));
50752
+ console.log(import_chalk20.default.white(` ${env.name}${env.user_id ? import_chalk20.default.gray(" (personal)") : ""}`));
50715
50753
  console.log(import_chalk20.default.gray(` ID: ${env.id}`));
50716
50754
  if (env.description) {
50717
50755
  console.log(import_chalk20.default.gray(` Description: ${env.description}`));
@@ -50728,7 +50766,7 @@ function printEnvironment(env) {
50728
50766
  }
50729
50767
  async function environmentListCommand() {
50730
50768
  ensureOrgApiAuthenticated();
50731
- const response = await orgAuthenticatedFetch("/v1/environments");
50769
+ const response = await orgAuthenticatedFetch("/v1/environments?scope=all");
50732
50770
  output2(response, ({ environments }) => {
50733
50771
  if (environments.length === 0) {
50734
50772
  console.log(import_chalk20.default.yellow("\nNo environments found.\n"));
@@ -51277,8 +51315,15 @@ async function envDevicesListCommand(env) {
51277
51315
  `/v1/environments/${await resolveEnvironmentId(env)}/devices`
51278
51316
  );
51279
51317
  output2(response, ({ environment_devices }) => {
51318
+ if (environment_devices.length === 0) {
51319
+ console.log(import_chalk20.default.yellow(`
51320
+ No devices. Add one with: replicas env devices add ${env} <name> --user <user>
51321
+ `));
51322
+ return;
51323
+ }
51280
51324
  for (const device of environment_devices) {
51281
- console.log(`${device.id} ${device.name} ${device.host === null ? `${device.username}, connects from the device` : `${device.username}@${device.host}:${device.port}`}`);
51325
+ const status = isDeviceOnline(device.last_seen_at) ? import_chalk20.default.green("online") : import_chalk20.default.yellow(device.last_seen_at ? `offline, last seen ${formatCompactRelativeTime(device.last_seen_at)}` : "offline");
51326
+ console.log(`${device.id} ${device.name} ${device.host === null ? `${device.username}, connects from the device ${status}` : `${device.username}@${device.host}:${device.port}`}`);
51282
51327
  }
51283
51328
  });
51284
51329
  }
@@ -51297,6 +51342,26 @@ async function envDevicesAddCommand(env, name, options) {
51297
51342
  }
51298
51343
  });
51299
51344
  }
51345
+ async function envDevicesEditCommand(env, nameOrId, options) {
51346
+ const body = { name: options.name, host: options.host, username: options.user, port: options.port, screen_password: options.screenPassword };
51347
+ if (Object.values(body).every((value) => value === void 0)) {
51348
+ throw new Error("No changes specified. Pass --name, --host, --user, --port, or --screen-password.");
51349
+ }
51350
+ const id = await resolveEnvironmentId(env);
51351
+ const { environment_devices } = await orgAuthenticatedFetch(`/v1/environments/${id}/devices`);
51352
+ const device = resolveByNameOrId(nameOrId, environment_devices);
51353
+ if (!device) throw new Error(`Device not found: ${nameOrId}`);
51354
+ const response = await orgAuthenticatedFetch(`/v1/environments/${id}/devices/${device.id}`, { method: "PATCH", body });
51355
+ const connect2 = device.host !== null && response.environment_device.host === null ? await orgAuthenticatedFetch(`/v1/environments/${id}/devices/${device.id}/connect-token`) : void 0;
51356
+ output2({ ...response, connect_token: connect2?.token }, ({ environment_device, connect_token }) => {
51357
+ console.log(import_chalk20.default.green(`Updated device ${environment_device.name}. Workspaces started from now on get the change.`));
51358
+ if (connect_token) {
51359
+ console.log(import_chalk20.default.green("It now connects from the device. Keep this running on it, and paste this token when it asks:"));
51360
+ console.log(DEVICE_CONNECT_COMMAND);
51361
+ console.log(connect_token);
51362
+ }
51363
+ });
51364
+ }
51300
51365
  async function envDevicesRemoveCommand(env, nameOrId) {
51301
51366
  const id = await resolveEnvironmentId(env);
51302
51367
  const { environment_devices } = await orgAuthenticatedFetch(`/v1/environments/${id}/devices`);
@@ -51524,7 +51589,7 @@ Replica: ${replica.name}
51524
51589
  }
51525
51590
  async function replicaCreateCommand(name, options) {
51526
51591
  ensureOrgApiAuthenticated();
51527
- const envResponse = await orgAuthenticatedFetch("/v1/environments");
51592
+ const envResponse = await orgAuthenticatedFetch("/v1/environments?scope=all");
51528
51593
  const environments = envResponse.environments;
51529
51594
  if (environments.length === 0) {
51530
51595
  throw new Error("No environments found. Please create an environment first.");
@@ -51561,7 +51626,7 @@ async function replicaCreateCommand(name, options) {
51561
51626
  name: "environment",
51562
51627
  message: "Select environment:",
51563
51628
  choices: environments.map((env) => ({
51564
- title: env.name,
51629
+ title: env.user_id ? `${env.name} (personal)` : env.name,
51565
51630
  value: env.id,
51566
51631
  description: `${env.repository_ids?.length ?? 0} repositories`
51567
51632
  }))
@@ -54604,7 +54669,7 @@ function registerEnvironmentHookCommands(parent, config3) {
54604
54669
  }
54605
54670
  hooks.command("repository-hooks <env>").description(`List per-repo ${config3.kind} hooks defined in replicas.json / replicas.yaml`).action(run(config3.repositoryHooks));
54606
54671
  }
54607
- var import_config20, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, org, config2, chat, chatQueue, share, pr2, canvas, credentials, automation, repos, plugins, skills, media, environment, envVars, envFiles, envSkills, envMcps, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
54672
+ var import_config20, import_commander, collect, program, organizationOptionalCommands, interactiveCommands, org, config2, chat, chatQueue, share, pr2, canvas, credentials, automation, repos, plugins, skills, media, environment, envVars, envFiles, envSkills, envMcps, parsePortOption, envDevices, envWarmPool, preview, authenticatedPreviewHelp;
54608
54673
  var init_src2 = __esm({
54609
54674
  "src/index.ts"() {
54610
54675
  "use strict";
@@ -54647,6 +54712,7 @@ var init_src2 = __esm({
54647
54712
  init_organization2();
54648
54713
  init_output();
54649
54714
  init_visuals();
54715
+ init_port();
54650
54716
  init_src();
54651
54717
  collect = (value, previous) => [...previous, value];
54652
54718
  program = new import_commander.Command();
@@ -54837,13 +54903,17 @@ var init_src2 = __esm({
54837
54903
  envMcps.command("list <env>").description("List MCP servers").action(run(envMcpsListCommand));
54838
54904
  envMcps.command("add <env> <name>").description("Add a remote (--url) or stdio (--command) MCP server").option("-u, --url <url>", "Remote server URL").addOption(new import_commander.Option("--transport <transport>", "Remote transport").choices(["http", "sse"])).option("-H, --header <key=value>", "HTTP header (repeatable)", collect, []).option("-c, --command <command>", "Executable for a stdio server").option("--arg <arg>", "Argument for the stdio command (repeatable)", collect, []).option("--env <key=value>", "Environment variable for the stdio command (repeatable)", collect, []).action(run(envMcpsAddCommand));
54839
54905
  envMcps.command("remove <env> <name-or-id>").description("Remove an MCP server").action(run(envMcpsRemoveCommand));
54906
+ parsePortOption = (value) => {
54907
+ try {
54908
+ return parsePort(value);
54909
+ } catch (error62) {
54910
+ throw new import_commander.InvalidArgumentError(String(error62 instanceof Error ? error62.message : error62));
54911
+ }
54912
+ };
54840
54913
  envDevices = environment.command("devices").description("Computers the agent reaches over SSH, like a Mac mini or your own laptop");
54841
54914
  envDevices.command("list <env>").description("List devices").action(run(envDevicesListCommand));
54842
- envDevices.command("add <env> <name>").description("Add a device and print the command that allows its key on the device").option("--host <host>", "Hostname or IP, such as its Tailscale name. Leave it out to connect from the device instead").requiredOption("--user <user>", "Account the agent signs in as").option("--port <port>", "SSH port (default 22)", (value) => {
54843
- const port = Number(value);
54844
- if (!Number.isInteger(port)) throw new import_commander.InvalidArgumentError("must be a whole number");
54845
- return port;
54846
- }).option("--screen-password <password>", "Screen Sharing password, so the agent can see and control the screen").action(run(envDevicesAddCommand));
54915
+ envDevices.command("add <env> <name>").description("Add a device and print the command that allows its key on the device").option("--host <host>", "Hostname or IP, such as its Tailscale name. Leave it out to connect from the device instead").requiredOption("--user <user>", "Account the agent signs in as").option("--port <port>", "SSH port (default 22)", parsePortOption).option("--screen-password <password>", "Screen Sharing password, so the agent can see and control the screen").action(run(envDevicesAddCommand));
54916
+ envDevices.command("edit <env> <name-or-id>").description("Change a device without replacing its key or connect token").option("--name <name>", "New name").option("--host <host>", 'New hostname or IP, or "" to connect from the device instead').option("--user <user>", "Account the agent signs in as").option("--port <port>", "SSH port", parsePortOption).option("--screen-password <password>", 'Screen Sharing password, or "" to remove it').action(run(envDevicesEditCommand));
54847
54917
  envDevices.command("remove <env> <name-or-id>").description("Remove a device and delete its key").action(run(envDevicesRemoveCommand));
54848
54918
  envDevices.command("reset <env> <name-or-id>").description("Replace the connect token of a device that connects from itself and forget its SSH identity, for a leaked token or a reinstalled device").action(run(envDevicesResetCommand));
54849
54919
  program.command("device").description("Run on one of your computers so Replicas workspaces can reach it").command("connect").description("Keep this computer reachable from the workspaces that have it, without opening ports or a tailnet. Asks for the token from the device's settings, or reads REPLICAS_DEVICE_TOKEN").action(run(deviceConnectCommand));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.345",
3
+ "version": "0.3.348",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {