@vm0/runner 2.0.2 → 2.0.3

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/index.js +28 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -824,6 +824,28 @@ var SSHClient = class {
824
824
  }
825
825
  }
826
826
  }
827
+ /**
828
+ * Write content to a file on the remote VM using sudo
829
+ * Used for writing to privileged locations like /usr/local/bin
830
+ */
831
+ async writeFileWithSudo(remotePath, content) {
832
+ const encoded = Buffer.from(content).toString("base64");
833
+ const maxChunkSize = 65e3;
834
+ if (encoded.length <= maxChunkSize) {
835
+ await this.execOrThrow(
836
+ `echo '${encoded}' | base64 -d | sudo tee '${remotePath}' > /dev/null`
837
+ );
838
+ } else {
839
+ await this.execOrThrow(`sudo rm -f '${remotePath}'`);
840
+ for (let i = 0; i < encoded.length; i += maxChunkSize) {
841
+ const chunk = encoded.slice(i, i + maxChunkSize);
842
+ const teeFlag = i === 0 ? "" : "-a";
843
+ await this.execOrThrow(
844
+ `echo '${chunk}' | base64 -d | sudo tee ${teeFlag} '${remotePath}' > /dev/null`
845
+ );
846
+ }
847
+ }
848
+ }
827
849
  /**
828
850
  * Read a file from the remote VM
829
851
  */
@@ -9050,13 +9072,13 @@ var ENV_JSON_PATH = "/tmp/vm0-env.json";
9050
9072
  async function uploadScripts(ssh) {
9051
9073
  const scripts = getAllScripts();
9052
9074
  await ssh.execOrThrow(
9053
- `mkdir -p ${SCRIPT_PATHS.baseDir} ${SCRIPT_PATHS.libDir}`
9075
+ `sudo mkdir -p ${SCRIPT_PATHS.baseDir} ${SCRIPT_PATHS.libDir}`
9054
9076
  );
9055
9077
  for (const script of scripts) {
9056
- await ssh.writeFile(script.path, script.content);
9078
+ await ssh.writeFileWithSudo(script.path, script.content);
9057
9079
  }
9058
9080
  await ssh.execOrThrow(
9059
- `chmod +x ${SCRIPT_PATHS.baseDir}/*.py ${SCRIPT_PATHS.libDir}/*.py 2>/dev/null || true`
9081
+ `sudo chmod +x ${SCRIPT_PATHS.baseDir}/*.py ${SCRIPT_PATHS.libDir}/*.py 2>/dev/null || true`
9060
9082
  );
9061
9083
  }
9062
9084
  async function downloadStorages(ssh, manifest) {
@@ -9101,7 +9123,7 @@ async function configureDNS(ssh) {
9101
9123
  nameserver 8.8.4.4
9102
9124
  nameserver 1.1.1.1`;
9103
9125
  await ssh.execOrThrow(
9104
- `rm -f /etc/resolv.conf && echo '${dnsConfig}' > /etc/resolv.conf`
9126
+ `sudo sh -c 'rm -f /etc/resolv.conf && echo "${dnsConfig}" > /etc/resolv.conf'`
9105
9127
  );
9106
9128
  }
9107
9129
  async function executeJob(context, config) {
@@ -9128,7 +9150,7 @@ async function executeJob(context, config) {
9128
9150
  }
9129
9151
  console.log(`[Executor] VM ${vmId} started, guest IP: ${guestIp}`);
9130
9152
  const privateKeyPath = getRunnerSSHKeyPath();
9131
- const ssh = createVMSSHClient(guestIp, "root", privateKeyPath || void 0);
9153
+ const ssh = createVMSSHClient(guestIp, "user", privateKeyPath || void 0);
9132
9154
  console.log(`[Executor] Waiting for SSH on ${guestIp}...`);
9133
9155
  await ssh.waitUntilReachable(12e4, 2e3);
9134
9156
  console.log(`[Executor] SSH ready on ${guestIp}`);
@@ -9333,7 +9355,7 @@ var statusCommand = new Command2("status").description("Show runner status").act
9333
9355
  });
9334
9356
 
9335
9357
  // src/index.ts
9336
- var version = true ? "2.0.2" : "0.1.0";
9358
+ var version = true ? "2.0.3" : "0.1.0";
9337
9359
  program.name("vm0-runner").version(version).description("Self-hosted runner for VM0 agents");
9338
9360
  program.addCommand(startCommand);
9339
9361
  program.addCommand(statusCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm0/runner",
3
- "version": "2.0.2",
3
+ "version": "2.0.3",
4
4
  "description": "Self-hosted runner for VM0 agents",
5
5
  "repository": {
6
6
  "type": "git",