@webmux/agent 0.1.2 → 0.1.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/dist/cli.js +21 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -619,6 +619,7 @@ service.command("install").description("Install and start the agent as a systemd
619
619
  }
620
620
  const serviceDir = path2.join(os2.homedir(), ".config", "systemd", "user");
621
621
  const servicePath = path2.join(serviceDir, `${SERVICE_NAME}.service`);
622
+ const npmPath = findBinary("npm") ?? "npm";
622
623
  const unit = `[Unit]
623
624
  Description=Webmux Agent (${creds.name})
624
625
  After=network-online.target
@@ -626,9 +627,10 @@ Wants=network-online.target
626
627
 
627
628
  [Service]
628
629
  Type=simple
629
- ExecStart=${npxPath} -y @webmux/agent start
630
+ ExecStartPre=${npmPath} install -g @webmux/agent@latest
631
+ ExecStart=${findBinary("webmux-agent") ?? `${npxPath} -y @webmux/agent`} start
630
632
  Restart=always
631
- RestartSec=5
633
+ RestartSec=10
632
634
  Environment=HOME=${os2.homedir()}
633
635
  Environment=PATH=${process.env.PATH}
634
636
  WorkingDirectory=${os2.homedir()}
@@ -684,6 +686,23 @@ service.command("status").description("Show systemd service status").action(() =
684
686
  console.log(`[agent] Service is not installed or not running.`);
685
687
  }
686
688
  });
689
+ service.command("upgrade").description("Upgrade agent to latest version and restart service").action(() => {
690
+ console.log("[agent] Upgrading @webmux/agent to latest...");
691
+ try {
692
+ execSync("npm install -g @webmux/agent@latest", { stdio: "inherit" });
693
+ } catch {
694
+ console.error("[agent] Failed to upgrade. Try manually: npm install -g @webmux/agent@latest");
695
+ process.exit(1);
696
+ }
697
+ console.log("[agent] Restarting service...");
698
+ try {
699
+ execSync(`systemctl --user restart ${SERVICE_NAME}`, { stdio: "inherit" });
700
+ console.log("[agent] Upgrade complete!");
701
+ } catch {
702
+ console.log("[agent] Package upgraded. Service not installed or restart failed.");
703
+ console.log("[agent] If running manually, restart with: npx @webmux/agent@latest start");
704
+ }
705
+ });
687
706
  function findBinary(name) {
688
707
  try {
689
708
  return execSync(`which ${name} 2>/dev/null`, { encoding: "utf-8" }).trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webmux/agent",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "webmux-agent": "./dist/cli.js"