replicas-cli 0.2.172 → 0.2.174

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.mjs +43 -19
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -7842,9 +7842,9 @@ import chalk5 from "chalk";
7842
7842
  // src/lib/ssh.ts
7843
7843
  import { spawn } from "child_process";
7844
7844
  var SSH_OPTIONS = ["-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null"];
7845
- async function connectSSH(token, host) {
7845
+ async function connectSSH(token, host, proxyCommand) {
7846
7846
  return new Promise((resolve, reject) => {
7847
- const sshArgs = [...SSH_OPTIONS, `${token}@${host}`];
7847
+ const sshArgs = proxyCommand ? [...SSH_OPTIONS, "-o", `ProxyCommand=${proxyCommand}`, `${token}@${host}`] : [...SSH_OPTIONS, `${token}@${host}`];
7848
7848
  const ssh = spawn("ssh", sshArgs, {
7849
7849
  stdio: "inherit"
7850
7850
  });
@@ -7949,6 +7949,7 @@ Found ${response.workspaces.length} workspaces matching "${workspaceName}":`));
7949
7949
  workspace: selectedWorkspace,
7950
7950
  sshToken: tokenResponse.token,
7951
7951
  sshHost: tokenResponse.host,
7952
+ sshProxyCommand: tokenResponse.proxyCommand,
7952
7953
  repoName
7953
7954
  };
7954
7955
  }
@@ -7960,13 +7961,13 @@ async function connectCommand(workspaceName) {
7960
7961
  process.exit(1);
7961
7962
  }
7962
7963
  try {
7963
- const { workspace, sshToken, sshHost } = await prepareWorkspaceConnection(workspaceName);
7964
+ const { workspace, sshToken, sshHost, sshProxyCommand } = await prepareWorkspaceConnection(workspaceName);
7964
7965
  console.log(chalk5.blue(`
7965
7966
  Connecting to ${workspace.name}...`));
7966
7967
  const sshCommand = `ssh ${sshToken}@${sshHost}`;
7967
7968
  console.log(chalk5.gray(`SSH command: ${sshCommand}`));
7968
7969
  console.log(chalk5.gray("\nPress Ctrl+D to disconnect.\n"));
7969
- await connectSSH(sshToken, sshHost);
7970
+ await connectSSH(sshToken, sshHost, sshProxyCommand);
7970
7971
  console.log(chalk5.green("\n\u2713 Disconnected from workspace.\n"));
7971
7972
  } catch (error) {
7972
7973
  console.error(chalk5.red(`
@@ -8059,14 +8060,25 @@ var SANDBOX_LIFECYCLE = {
8059
8060
  AUTO_DELETE_MINUTES: -1,
8060
8061
  SSH_TOKEN_EXPIRATION_MINUTES: 3 * 60
8061
8062
  };
8062
- var SANDBOX_PATHS = {
8063
- HOME_DIR: "/home/ubuntu",
8064
- WORKSPACES_DIR: "/home/ubuntu/workspaces",
8065
- REPLICAS_DIR: "/home/ubuntu/.replicas",
8066
- REPLICAS_FILES_DIR: "/home/ubuntu/.replicas/files",
8067
- REPLICAS_FILES_DISPLAY_DIR: "~/.replicas/files",
8068
- REPLICAS_RUNTIME_ENV_FILE: "/home/ubuntu/.replicas/runtime-env.sh"
8069
- };
8063
+ function buildPaths(homeDir) {
8064
+ return {
8065
+ HOME_DIR: homeDir,
8066
+ WORKSPACES_DIR: `${homeDir}/workspaces`,
8067
+ REPLICAS_DIR: `${homeDir}/.replicas`,
8068
+ REPLICAS_FILES_DIR: `${homeDir}/.replicas/files`,
8069
+ REPLICAS_RUNTIME_ENV_FILE: `${homeDir}/.replicas/runtime-env.sh`
8070
+ };
8071
+ }
8072
+ var DAYTONA_PATHS = buildPaths("/home/ubuntu");
8073
+ var E2B_PATHS = buildPaths("/home/user");
8074
+ function getSandboxPaths(providerId) {
8075
+ switch (providerId) {
8076
+ case "daytona":
8077
+ return DAYTONA_PATHS;
8078
+ case "e2b":
8079
+ return E2B_PATHS;
8080
+ }
8081
+ }
8070
8082
 
8071
8083
  // ../shared/src/urls.ts
8072
8084
  function getWorkspaceDashboardUrl(workspaceId, options = {}) {
@@ -9298,15 +9310,25 @@ function writeSSHConfig(content) {
9298
9310
  ensureSSHDir();
9299
9311
  fs2.writeFileSync(SSH_CONFIG_PATH, content, { mode: 384 });
9300
9312
  }
9313
+ function sanitizeSSHConfigValue(value) {
9314
+ return value.replace(/[\r\n]+/g, " ").trim();
9315
+ }
9301
9316
  function generateConfigBlock(entry) {
9317
+ const host = sanitizeSSHConfigValue(entry.host);
9318
+ const hostname = sanitizeSSHConfigValue(entry.hostname);
9319
+ const user = sanitizeSSHConfigValue(entry.user);
9320
+ const proxyCommand = entry.proxyCommand ? sanitizeSSHConfigValue(entry.proxyCommand) : void 0;
9302
9321
  const lines = [
9303
9322
  REPLICAS_MARKER_START,
9304
- `Host ${entry.host}`,
9305
- ` HostName ${entry.hostname}`,
9306
- ` User ${entry.user}`,
9323
+ `Host ${host}`,
9324
+ ` HostName ${hostname}`,
9325
+ ` User ${user}`,
9307
9326
  ` StrictHostKeyChecking no`,
9308
9327
  ` UserKnownHostsFile /dev/null`
9309
9328
  ];
9329
+ if (proxyCommand) {
9330
+ lines.push(` ProxyCommand ${proxyCommand}`);
9331
+ }
9310
9332
  lines.push(REPLICAS_MARKER_END);
9311
9333
  return lines.join("\n");
9312
9334
  }
@@ -9359,16 +9381,18 @@ async function codeCommand(workspaceName) {
9359
9381
  process.exit(1);
9360
9382
  }
9361
9383
  try {
9362
- const { workspace, sshToken, sshHost, repoName } = await prepareWorkspaceConnection(workspaceName);
9384
+ const { workspace, sshToken, sshHost, sshProxyCommand, repoName } = await prepareWorkspaceConnection(workspaceName);
9363
9385
  const hostAlias = getWorkspaceHostAlias(workspace.name);
9364
9386
  console.log(chalk6.blue("\nConfiguring SSH connection..."));
9365
9387
  addOrUpdateSSHConfigEntry({
9366
9388
  host: hostAlias,
9367
9389
  hostname: sshHost,
9368
- user: sshToken
9390
+ user: sshToken,
9391
+ proxyCommand: sshProxyCommand
9369
9392
  });
9370
9393
  console.log(chalk6.green(`\u2713 SSH config entry created: ${hostAlias}`));
9371
- const remotePath = repoName ? `${SANDBOX_PATHS.WORKSPACES_DIR}/${repoName}` : SANDBOX_PATHS.HOME_DIR;
9394
+ const paths = getSandboxPaths(workspace.sandbox_provider ?? "daytona");
9395
+ const remotePath = repoName ? `${paths.WORKSPACES_DIR}/${repoName}` : paths.HOME_DIR;
9372
9396
  const ideCommand = getIdeCommand();
9373
9397
  const fullCommand = `${ideCommand} --remote ssh-remote+${hostAlias} ${remotePath}`;
9374
9398
  console.log(chalk6.blue(`
@@ -14811,7 +14835,7 @@ Deleted file ${pathOrId}.
14811
14835
  }
14812
14836
 
14813
14837
  // src/index.ts
14814
- var CLI_VERSION = "0.2.172";
14838
+ var CLI_VERSION = "0.2.174";
14815
14839
  function parseBooleanOption(value) {
14816
14840
  if (value === "true") return true;
14817
14841
  if (value === "false") return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.2.172",
3
+ "version": "0.2.174",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.mjs",
6
6
  "bin": {