pinggy 0.6.11 → 0.7.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.cjs CHANGED
@@ -3529,6 +3529,15 @@ var init_servicePaths = __esm({
3529
3529
  });
3530
3530
 
3531
3531
  // src/daemon/lifecycle/serviceInstaller.ts
3532
+ function machineServiceInstallContext() {
3533
+ return {
3534
+ platform: import_node_os2.default.platform(),
3535
+ isPkg: "pkg" in process,
3536
+ execPath: process.execPath,
3537
+ home: import_node_os2.default.homedir(),
3538
+ env: process.env
3539
+ };
3540
+ }
3532
3541
  function realPath(p) {
3533
3542
  try {
3534
3543
  return import_node_fs5.default.realpathSync(p);
@@ -3558,25 +3567,25 @@ function isInstallerBinary(ctx) {
3558
3567
  }
3559
3568
  function installerFix(platform3) {
3560
3569
  return [
3561
- "pinggy can only run as a service when it is installed with the Pinggy installer.",
3570
+ "Autostart works only for pinggy installed with the Pinggy installer.",
3562
3571
  "Install it, then run this command again:",
3563
3572
  ` ${installCommandFor(platform3)}`,
3564
- " pinggy daemon service-install"
3573
+ ` ${AUTOSTART_ON_COMMAND}`
3565
3574
  ].join("\n");
3566
3575
  }
3567
3576
  function npmInstallerFix(platform3) {
3568
3577
  return [
3569
- "The npm version of pinggy cannot run as a service.",
3578
+ "The npm version of pinggy cannot turn on autostart.",
3570
3579
  "Remove it, install pinggy with the Pinggy installer, then run this command again:",
3571
3580
  ` ${NPM_UNINSTALL_COMMAND}`,
3572
3581
  ` ${installCommandFor(platform3)}`,
3573
- " pinggy daemon service-install"
3582
+ ` ${AUTOSTART_ON_COMMAND}`
3574
3583
  ].join("\n");
3575
3584
  }
3576
3585
  function installedCopyFix(installedPath) {
3577
3586
  return [
3578
3587
  "This pinggy is not the installed one. Run this command with the installed copy:",
3579
- ` ${installedPath} daemon service-install`
3588
+ ` ${installedPath} autostart on`
3580
3589
  ].join("\n");
3581
3590
  }
3582
3591
  function serviceInstallRefusal(ctx, fileExists = import_node_fs5.default.existsSync) {
@@ -3586,19 +3595,46 @@ function serviceInstallRefusal(ctx, fileExists = import_node_fs5.default.existsS
3586
3595
  if (fileExists(installedPath)) return installedCopyFix(installedPath);
3587
3596
  return installerFix(ctx.platform);
3588
3597
  }
3589
- function printInstalled() {
3590
- printer_default.success("pinggy now starts automatically when this computer starts.");
3591
- }
3592
- function printUninstalled() {
3593
- printer_default.success("pinggy no longer starts automatically when this computer starts.");
3594
- }
3595
- function printNotInstalled() {
3596
- printer_default.print("pinggy is not set to start automatically.");
3597
- }
3598
3598
  function toolError(err) {
3599
3599
  const stderr = err.stderr?.toString().trim();
3600
3600
  return stderr ? stderr.replace(/^ERROR:\s*/i, "") : errorMessage(err);
3601
3601
  }
3602
+ function unescapeXml(value) {
3603
+ return value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
3604
+ }
3605
+ function bootEntryProgram(platform3, text) {
3606
+ let match = null;
3607
+ if (platform3 === "linux") {
3608
+ match = /^ExecStart=(.+) --_daemon-child\s*$/m.exec(text);
3609
+ } else if (platform3 === "darwin") {
3610
+ match = /<key>ProgramArguments<\/key>\s*<array>\s*<string>([^<]+)<\/string>/.exec(text);
3611
+ } else if (platform3 === "win32") {
3612
+ match = /<Command>([^<]+)<\/Command>/.exec(text);
3613
+ }
3614
+ return match ? unescapeXml(match[1].trim()) : null;
3615
+ }
3616
+ function sameProgram(platform3, left, right) {
3617
+ return platform3 === "win32" ? left.toLowerCase() === right.toLowerCase() : left === right;
3618
+ }
3619
+ function readBootEntry(platform3 = import_node_os2.default.platform()) {
3620
+ if (platform3 === "win32") {
3621
+ return readWindowsTask();
3622
+ }
3623
+ const entryPath = platform3 === "linux" ? getSystemdServicePath() : platform3 === "darwin" ? getLaunchdPlistPath() : null;
3624
+ if (!entryPath || !import_node_fs5.default.existsSync(entryPath)) {
3625
+ return NO_BOOT_ENTRY;
3626
+ }
3627
+ let text = "";
3628
+ try {
3629
+ text = import_node_fs5.default.readFileSync(entryPath, "utf-8");
3630
+ } catch (err) {
3631
+ logger.debug("Could not read the boot entry", { entryPath, error: errorMessage(err) });
3632
+ }
3633
+ return { present: true, program: bootEntryProgram(platform3, text) };
3634
+ }
3635
+ function startsBeforeSignIn(platform3 = import_node_os2.default.platform()) {
3636
+ return platform3 === "linux" && lingerEnabled(import_node_os2.default.userInfo().username);
3637
+ }
3602
3638
  function getSystemdServicePath() {
3603
3639
  return systemdServicePath(import_node_os2.default.homedir());
3604
3640
  }
@@ -3628,7 +3664,6 @@ function installSystemd(program) {
3628
3664
  (0, import_node_child_process.execSync)(`systemctl --user enable ${SYSTEMD_SERVICE_NAME}`, QUIET);
3629
3665
  (0, import_node_child_process.execSync)(`systemctl --user start ${SYSTEMD_SERVICE_NAME}`, QUIET);
3630
3666
  logger.info("systemd user service installed", { servicePath });
3631
- printInstalled();
3632
3667
  enableLinger(import_node_os2.default.userInfo().username);
3633
3668
  }
3634
3669
  function lingerEnabled(username) {
@@ -3649,24 +3684,22 @@ function enableLinger(username) {
3649
3684
  logger.info("systemd lingering enabled", { username });
3650
3685
  } catch (err) {
3651
3686
  logger.warn("loginctl enable-linger failed", { error: errorMessage(err) });
3652
- printer_default.print(`pinggy starts when ${username} signs in. To start it before anyone signs in, run: loginctl enable-linger ${username}`);
3653
3687
  }
3654
3688
  }
3655
- function uninstallSystemd() {
3689
+ function removeSystemd() {
3656
3690
  const servicePath = getSystemdServicePath();
3657
3691
  try {
3658
- (0, import_node_child_process.execSync)(`systemctl --user stop ${SYSTEMD_SERVICE_NAME} 2>/dev/null || true`);
3659
- (0, import_node_child_process.execSync)(`systemctl --user disable ${SYSTEMD_SERVICE_NAME} 2>/dev/null || true`);
3660
- } catch {
3692
+ (0, import_node_child_process.execSync)(`systemctl --user disable ${SYSTEMD_SERVICE_NAME}`, QUIET);
3693
+ } catch (err) {
3694
+ logger.debug("systemctl disable failed", { error: toolError(err) });
3661
3695
  }
3662
- if (import_node_fs5.default.existsSync(servicePath)) {
3663
- import_node_fs5.default.unlinkSync(servicePath);
3696
+ import_node_fs5.default.rmSync(servicePath, { force: true });
3697
+ try {
3664
3698
  (0, import_node_child_process.execSync)("systemctl --user daemon-reload", QUIET);
3665
- logger.info("systemd user service removed", { servicePath });
3666
- printUninstalled();
3667
- } else {
3668
- printNotInstalled();
3699
+ } catch (err) {
3700
+ logger.debug("systemctl daemon-reload failed", { error: toolError(err) });
3669
3701
  }
3702
+ logger.info("systemd user service removed", { servicePath });
3670
3703
  }
3671
3704
  function getLaunchdPlistPath() {
3672
3705
  return launchdPlistPath(import_node_os2.default.homedir());
@@ -3693,48 +3726,45 @@ ${programArgs}
3693
3726
  </plist>
3694
3727
  `;
3695
3728
  }
3729
+ function launchdUid() {
3730
+ return process.getuid?.() ?? 501;
3731
+ }
3732
+ function launchdJobLoaded(uid) {
3733
+ try {
3734
+ (0, import_node_child_process.execFileSync)("launchctl", ["print", `gui/${uid}/${SERVICE_LABEL}`], QUIET);
3735
+ return true;
3736
+ } catch {
3737
+ return false;
3738
+ }
3739
+ }
3696
3740
  function installLaunchd(program) {
3697
3741
  const plistPath = getLaunchdPlistPath();
3698
3742
  const dir = import_node_path5.default.dirname(plistPath);
3699
3743
  import_node_fs5.default.mkdirSync(dir, { recursive: true });
3700
3744
  import_node_fs5.default.writeFileSync(plistPath, generateLaunchdPlist(program), "utf-8");
3701
- const uid = process.getuid?.() ?? 501;
3702
- try {
3703
- (0, import_node_child_process.execSync)(`launchctl bootout gui/${uid}/${SERVICE_LABEL} 2>/dev/null || true`);
3704
- } catch {
3745
+ const uid = launchdUid();
3746
+ if (launchdJobLoaded(uid)) {
3747
+ try {
3748
+ (0, import_node_child_process.execFileSync)("launchctl", ["kickstart", `gui/${uid}/${SERVICE_LABEL}`], QUIET);
3749
+ } catch (err) {
3750
+ logger.debug("launchctl kickstart failed", { error: toolError(err) });
3751
+ }
3752
+ } else {
3753
+ loadLaunchdPlist(uid, plistPath);
3705
3754
  }
3706
- loadLaunchdPlist(uid, plistPath);
3707
3755
  logger.info("launchd agent installed", { plistPath });
3708
- printInstalled();
3709
3756
  }
3710
3757
  function loadLaunchdPlist(uid, plistPath) {
3711
3758
  try {
3712
- (0, import_node_child_process.execSync)(`launchctl bootstrap gui/${uid} ${plistPath}`);
3759
+ (0, import_node_child_process.execFileSync)("launchctl", ["bootstrap", `gui/${uid}`, plistPath], QUIET);
3713
3760
  } catch {
3714
- try {
3715
- (0, import_node_child_process.execSync)(`launchctl load -w ${plistPath}`);
3716
- } catch {
3717
- }
3761
+ (0, import_node_child_process.execFileSync)("launchctl", ["load", "-w", plistPath], QUIET);
3718
3762
  }
3719
3763
  }
3720
- function uninstallLaunchd() {
3764
+ function removeLaunchd() {
3721
3765
  const plistPath = getLaunchdPlistPath();
3722
- const uid = process.getuid?.() ?? 501;
3723
- try {
3724
- (0, import_node_child_process.execSync)(`launchctl bootout gui/${uid}/${SERVICE_LABEL} 2>/dev/null || true`);
3725
- } catch {
3726
- try {
3727
- (0, import_node_child_process.execSync)(`launchctl unload ${plistPath} 2>/dev/null || true`);
3728
- } catch {
3729
- }
3730
- }
3731
- if (import_node_fs5.default.existsSync(plistPath)) {
3732
- import_node_fs5.default.unlinkSync(plistPath);
3733
- logger.info("launchd agent removed", { plistPath });
3734
- printUninstalled();
3735
- } else {
3736
- printNotInstalled();
3737
- }
3766
+ import_node_fs5.default.rmSync(plistPath, { force: true });
3767
+ logger.info("launchd agent removed", { plistPath });
3738
3768
  }
3739
3769
  function escapeXml(value) {
3740
3770
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
@@ -3801,6 +3831,18 @@ function windowsTaskExists() {
3801
3831
  return false;
3802
3832
  }
3803
3833
  }
3834
+ function readWindowsTask() {
3835
+ try {
3836
+ const xml = (0, import_node_child_process.execFileSync)("schtasks", ["/Query", "/TN", WINDOWS_TASK_NAME, "/XML"], {
3837
+ encoding: "utf-8",
3838
+ stdio: ["ignore", "pipe", "ignore"],
3839
+ windowsHide: true
3840
+ });
3841
+ return { present: true, program: bootEntryProgram("win32", xml) };
3842
+ } catch {
3843
+ return NO_BOOT_ENTRY;
3844
+ }
3845
+ }
3804
3846
  function isElevated() {
3805
3847
  try {
3806
3848
  return /S-1-16-(12288|16384)\b/.test((0, import_node_child_process.execFileSync)("whoami", ["/groups"], { encoding: "utf-8" }));
@@ -3819,29 +3861,17 @@ function installWindows(program) {
3819
3861
  createWindowsTask(program);
3820
3862
  (0, import_node_child_process.execFileSync)("schtasks", ["/Run", "/TN", WINDOWS_TASK_NAME], QUIET);
3821
3863
  } catch (err) {
3822
- printer_default.error(windowsTaskError("set pinggy to start automatically", "change it", err));
3823
- process.exit(1);
3864
+ throw new Error(windowsTaskError("turn on autostart", "change it", err));
3824
3865
  }
3825
3866
  logger.info("Scheduled task installed", { task: WINDOWS_TASK_NAME });
3826
- printInstalled();
3827
3867
  }
3828
- async function uninstallWindows() {
3829
- if (!windowsTaskExists()) {
3830
- printNotInstalled();
3831
- return;
3832
- }
3868
+ function removeWindows() {
3833
3869
  try {
3834
3870
  (0, import_node_child_process.execFileSync)("schtasks", ["/Delete", "/TN", WINDOWS_TASK_NAME, "/F"], QUIET);
3835
3871
  } catch (err) {
3836
- printer_default.error(windowsTaskError("stop pinggy from starting automatically", "turn it off", err));
3837
- process.exit(1);
3872
+ throw new Error(windowsTaskError("turn off autostart", "turn it off", err));
3838
3873
  }
3839
3874
  logger.info("Scheduled task removed", { task: WINDOWS_TASK_NAME });
3840
- if (isDaemonRunning()) {
3841
- const result = await stopDaemon();
3842
- if (!result.ok) console.log(`Could not stop the daemon: ${result.error}`);
3843
- }
3844
- printUninstalled();
3845
3875
  }
3846
3876
  function readServiceEntryText() {
3847
3877
  const platform3 = import_node_os2.default.platform();
@@ -3871,54 +3901,37 @@ function serviceRestartInstruction(info, platform3 = import_node_os2.default.pla
3871
3901
  }
3872
3902
  return null;
3873
3903
  }
3874
- function installService() {
3875
- const platform3 = import_node_os2.default.platform();
3876
- const context = {
3877
- platform: platform3,
3878
- isPkg: "pkg" in process,
3879
- execPath: process.execPath,
3880
- home: import_node_os2.default.homedir(),
3881
- env: process.env
3882
- };
3883
- const refusal = serviceInstallRefusal(context);
3884
- if (refusal) {
3885
- console.error(refusal);
3886
- process.exit(1);
3904
+ function installBootEntry(program, platform3 = import_node_os2.default.platform()) {
3905
+ if (platform3 === "win32") {
3906
+ installWindows(program);
3907
+ return;
3887
3908
  }
3888
- const program = serviceProgramPath(context);
3889
- switch (platform3) {
3890
- case "linux":
3891
- installSystemd(program);
3892
- break;
3893
- case "darwin":
3894
- installLaunchd(program);
3895
- break;
3896
- case "win32":
3897
- installWindows(program);
3898
- break;
3899
- default:
3900
- console.error(`Unsupported platform: ${platform3}`);
3901
- process.exit(1);
3909
+ if (platform3 !== "linux" && platform3 !== "darwin") {
3910
+ throw new Error(`Autostart is not supported on ${platform3}.`);
3911
+ }
3912
+ try {
3913
+ if (platform3 === "linux") installSystemd(program);
3914
+ else installLaunchd(program);
3915
+ } catch (err) {
3916
+ throw new Error(`Could not turn on autostart: ${toolError(err)}`);
3902
3917
  }
3903
3918
  }
3904
- async function uninstallService() {
3905
- const platform3 = import_node_os2.default.platform();
3906
- switch (platform3) {
3907
- case "linux":
3908
- uninstallSystemd();
3909
- break;
3910
- case "darwin":
3911
- uninstallLaunchd();
3912
- break;
3913
- case "win32":
3914
- await uninstallWindows();
3915
- break;
3916
- default:
3917
- console.error(`Unsupported platform: ${platform3}`);
3918
- process.exit(1);
3919
+ function removeBootEntry(platform3 = import_node_os2.default.platform()) {
3920
+ if (platform3 === "win32") {
3921
+ removeWindows();
3922
+ return;
3923
+ }
3924
+ if (platform3 !== "linux" && platform3 !== "darwin") {
3925
+ throw new Error(`Autostart is not supported on ${platform3}.`);
3926
+ }
3927
+ try {
3928
+ if (platform3 === "linux") removeSystemd();
3929
+ else removeLaunchd();
3930
+ } catch (err) {
3931
+ throw new Error(`Could not turn off autostart: ${toolError(err)}`);
3919
3932
  }
3920
3933
  }
3921
- var import_node_os2, import_node_fs5, import_node_path5, import_node_child_process, SERVICE_ANY_LOCATION_ENV, QUIET, WINDOWS_TASK_NAME, SERVICE_QUERY_TIMEOUT_MILLIS;
3934
+ var import_node_os2, import_node_fs5, import_node_path5, import_node_child_process, AUTOSTART_ON_COMMAND, AUTOSTART_OFF_COMMAND, SERVICE_ANY_LOCATION_ENV, QUIET, NO_BOOT_ENTRY, WINDOWS_TASK_NAME, SERVICE_QUERY_TIMEOUT_MILLIS;
3922
3935
  var init_serviceInstaller = __esm({
3923
3936
  "src/daemon/lifecycle/serviceInstaller.ts"() {
3924
3937
  "use strict";
@@ -3928,14 +3941,15 @@ var init_serviceInstaller = __esm({
3928
3941
  import_node_path5 = __toESM(require("path"), 1);
3929
3942
  import_node_child_process = require("child_process");
3930
3943
  init_logger();
3931
- init_printer();
3932
3944
  init_util();
3933
- init_daemonManager();
3934
3945
  init_installKind();
3935
3946
  init_servicePaths();
3936
3947
  init_servicePaths();
3948
+ AUTOSTART_ON_COMMAND = "pinggy autostart on";
3949
+ AUTOSTART_OFF_COMMAND = "pinggy autostart off";
3937
3950
  SERVICE_ANY_LOCATION_ENV = "PINGGY_SERVICE_ANY_LOCATION";
3938
3951
  QUIET = { stdio: ["ignore", "ignore", "pipe"] };
3952
+ NO_BOOT_ENTRY = { present: false, program: null };
3939
3953
  WINDOWS_TASK_NAME = "PinggyDaemon";
3940
3954
  SERVICE_QUERY_TIMEOUT_MILLIS = 2e3;
3941
3955
  }
@@ -4141,6 +4155,7 @@ function printHelpMessage() {
4141
4155
  console.log(" pinggy device login --foreground # Same, with the agent in this terminal");
4142
4156
  console.log(" pinggy device status # Show this device and its agent");
4143
4157
  console.log(" pinggy device stop # Stop the background agent");
4158
+ console.log(" pinggy autostart on # Bring this device online each time this computer starts");
4144
4159
  console.log("\nUpdates:");
4145
4160
  console.log(" pinggy update --check # Print the latest version");
4146
4161
  console.log(" pinggy update # Update to the latest version now");
@@ -4150,8 +4165,6 @@ function printHelpMessage() {
4150
4165
  console.log(" pinggy daemon start # Start the background daemon");
4151
4166
  console.log(" pinggy daemon stop # Stop the daemon (stops all tunnels)");
4152
4167
  console.log(" pinggy daemon status # Show daemon PID and uptime");
4153
- console.log(" pinggy daemon service-install # Run the daemon at login as a system service");
4154
- console.log(" pinggy daemon service-uninstall # Stop the daemon and remove the system service");
4155
4168
  }
4156
4169
  var init_help = __esm({
4157
4170
  "src/cli/help.ts"() {
@@ -7669,6 +7682,7 @@ var init_configStore = __esm({
7669
7682
  Restart: "restart",
7670
7683
  Device: "device",
7671
7684
  Update: "update",
7685
+ Autostart: "autostart",
7672
7686
  // The old spelling, refused with a hint. As a subcommand it never reaches tunnel mode, where `--token` is the
7673
7687
  // tunnel token and a device token would go to the tunnel server.
7674
7688
  Devices: "devices"
@@ -9758,8 +9772,6 @@ function printDaemonHelp() {
9758
9772
  console.log(" start Start the daemon process");
9759
9773
  console.log(" stop Stop the daemon (stops all tunnels)");
9760
9774
  console.log(" status Show daemon PID and uptime");
9761
- console.log(" service-install Run the daemon at login as a system service");
9762
- console.log(" service-uninstall Stop the daemon and remove the system service");
9763
9775
  console.log("Tunnel operations:");
9764
9776
  console.log(" pinggy ps List running tunnels");
9765
9777
  console.log(" pinggy stop <name|id> Stop a specific tunnel");
@@ -9809,6 +9821,11 @@ function printDeviceHelp() {
9809
9821
  console.log(" The device stays in the dashboard\n");
9810
9822
  console.log("By default the agent runs in the daemon, and stays connected after this terminal closes.");
9811
9823
  console.log("Each time the daemon starts, it starts the agent again, until remove.\n");
9824
+ console.log("Start on boot:");
9825
+ console.log(" pinggy autostart on Bring this device online each time this computer starts");
9826
+ console.log(" pinggy autostart off Stop that. The device stays online until the next restart");
9827
+ console.log(" pinggy autostart status Show whether it is on");
9828
+ console.log("On macOS and Windows it starts when you sign in. On Linux it starts at boot.\n");
9812
9829
  console.log("Options:");
9813
9830
  console.log(" --foreground login, connect and start: run the agent in this terminal until Ctrl+C");
9814
9831
  console.log(" -b login, connect and start: run the agent in the background. The default");
@@ -9822,6 +9839,16 @@ function printDeviceHelp() {
9822
9839
  console.log(" DEVICE_AGENT_TOKEN connect and start: the device token, when --token is not given.");
9823
9840
  console.log(" With no --manage, it dials dashboard.pinggy.io. Removed once read\n");
9824
9841
  }
9842
+ function printAutostartHelp() {
9843
+ console.log("\nUsage: pinggy autostart [on | off | status]\n");
9844
+ console.log("Bring this device online each time this computer starts.");
9845
+ console.log("On macOS and Windows it starts when you sign in. On Linux it starts at boot.\n");
9846
+ console.log("Commands:");
9847
+ console.log(" on Turn it on. Asks first when the device agent does not run in the");
9848
+ console.log(" background");
9849
+ console.log(" off Turn it off. The device stays online until the next restart");
9850
+ console.log(" status Show whether it is on. The default\n");
9851
+ }
9825
9852
  function printUpdateHelp() {
9826
9853
  console.log("\nUsage: pinggy update [--check | --rollback]\n");
9827
9854
  console.log("Commands:");
@@ -15932,6 +15959,10 @@ var init_backgroundAgent = __esm({
15932
15959
  });
15933
15960
 
15934
15961
  // src/cli/subcommand/handlers/daemonCommandsHandler.ts
15962
+ function renamedDaemonVerbMessage(verb) {
15963
+ const replacement = RENAMED_DAEMON_VERBS.get(verb);
15964
+ return replacement ? `"pinggy daemon ${verb}" is now "${replacement}".` : null;
15965
+ }
15935
15966
  async function handleDaemon(args) {
15936
15967
  if (args.length === 0) {
15937
15968
  printDaemonHelp();
@@ -15948,16 +15979,21 @@ async function handleDaemon(args) {
15948
15979
  case "status":
15949
15980
  await handleDaemonStatus();
15950
15981
  return;
15951
- case "service-install":
15952
- installService();
15953
- return;
15954
- case "service-uninstall":
15955
- await uninstallService();
15982
+ case "help":
15983
+ case "--help":
15984
+ case "-h":
15985
+ printDaemonHelp();
15956
15986
  return;
15957
- default:
15987
+ default: {
15988
+ const renamed = renamedDaemonVerbMessage(verb);
15989
+ if (renamed) {
15990
+ printer_default.error(renamed);
15991
+ process.exit(1);
15992
+ }
15958
15993
  printer_default.error(`Unknown daemon command: "${verb}"`);
15959
15994
  printDaemonHelp();
15960
15995
  return;
15996
+ }
15961
15997
  }
15962
15998
  }
15963
15999
  async function handleDaemonStart() {
@@ -16031,7 +16067,7 @@ async function handleDaemonStatus() {
16031
16067
  printer_default.print(` Device: ${describeAgentForDaemonStatus(agent.status)}`);
16032
16068
  }
16033
16069
  }
16034
- var import_picocolors10;
16070
+ var import_picocolors10, RENAMED_DAEMON_VERBS;
16035
16071
  var init_daemonCommandsHandler = __esm({
16036
16072
  "src/cli/subcommand/handlers/daemonCommandsHandler.ts"() {
16037
16073
  "use strict";
@@ -16045,6 +16081,10 @@ var init_daemonCommandsHandler = __esm({
16045
16081
  init_helpMessages();
16046
16082
  init_util();
16047
16083
  init_backgroundAgent();
16084
+ RENAMED_DAEMON_VERBS = /* @__PURE__ */ new Map([
16085
+ ["service-install", AUTOSTART_ON_COMMAND],
16086
+ ["service-uninstall", AUTOSTART_OFF_COMMAND]
16087
+ ]);
16048
16088
  }
16049
16089
  });
16050
16090
 
@@ -16633,10 +16673,11 @@ var init_restartCommand = __esm({
16633
16673
  });
16634
16674
 
16635
16675
  // src/devices/removeDevice.ts
16636
- function machineDeviceRemoveDependencies(background) {
16676
+ function machineDeviceRemoveDependencies(background, bootEntry) {
16637
16677
  return {
16638
16678
  background,
16639
16679
  foreground: machineForegroundStopDependencies(),
16680
+ bootEntry,
16640
16681
  clearIdentity: clearDeviceIdentity,
16641
16682
  isInteractive: isInteractiveTerminal,
16642
16683
  prompter: terminalPrompter,
@@ -16650,11 +16691,12 @@ async function readActivity(dependencies) {
16650
16691
  return {
16651
16692
  identity: dependencies.background.readIdentity(),
16652
16693
  background: reading && isAgentRunning(reading.status) ? reading : null,
16653
- foreground: dependencies.background.readForegroundAgent()
16694
+ foreground: dependencies.background.readForegroundAgent(),
16695
+ autostart: dependencies.bootEntry.read().present
16654
16696
  };
16655
16697
  }
16656
16698
  function describeActivity(activity) {
16657
- const { identity, background, foreground } = activity;
16699
+ const { identity, background, foreground, autostart } = activity;
16658
16700
  const lines = [];
16659
16701
  if (identity) {
16660
16702
  const deviceAgentId = identity.device_agent_id ?? "(id not yet assigned)";
@@ -16671,6 +16713,9 @@ function describeActivity(activity) {
16671
16713
  } else {
16672
16714
  lines.push("The device is not connected now.");
16673
16715
  }
16716
+ if (autostart) {
16717
+ lines.push("Removing it also turns off autostart.");
16718
+ }
16674
16719
  return lines;
16675
16720
  }
16676
16721
  async function confirmed(options, dependencies) {
@@ -16706,6 +16751,15 @@ async function runDeviceRemove(options, dependencies) {
16706
16751
  dependencies.printSuccess("Local device credential removed.");
16707
16752
  dependencies.print(import_picocolors13.default.gray("The device still exists in the dashboard. Delete it there to revoke it."));
16708
16753
  }
16754
+ if (activity.autostart) {
16755
+ try {
16756
+ dependencies.bootEntry.remove();
16757
+ } catch (err) {
16758
+ dependencies.printError(errorMessage(err));
16759
+ return EXIT_FAILED;
16760
+ }
16761
+ dependencies.printSuccess("Autostart is off.");
16762
+ }
16709
16763
  return EXIT_OK;
16710
16764
  }
16711
16765
  var import_picocolors13, YES_ANSWER2, NO_TERMINAL_MESSAGE2;
@@ -16714,6 +16768,7 @@ var init_removeDevice = __esm({
16714
16768
  "use strict";
16715
16769
  init_cjs_shims();
16716
16770
  import_picocolors13 = __toESM(require("picocolors"), 1);
16771
+ init_util();
16717
16772
  init_deviceIdentity();
16718
16773
  init_backgroundAgent();
16719
16774
  init_foregroundAgent();
@@ -16725,6 +16780,180 @@ var init_removeDevice = __esm({
16725
16780
  }
16726
16781
  });
16727
16782
 
16783
+ // src/devices/autostart.ts
16784
+ function machineBootEntryDependencies() {
16785
+ const context = machineServiceInstallContext();
16786
+ return {
16787
+ platform: context.platform,
16788
+ read: () => readBootEntry(context.platform),
16789
+ program: () => serviceProgramPath(context),
16790
+ refusal: () => serviceInstallRefusal(context),
16791
+ startsBeforeSignIn: () => startsBeforeSignIn(context.platform),
16792
+ username: () => import_node_os6.default.userInfo().username,
16793
+ install: (program) => installBootEntry(program, context.platform),
16794
+ remove: () => removeBootEntry(context.platform)
16795
+ };
16796
+ }
16797
+ function machineAutostartDependencies(background, bootEntry, startAgent) {
16798
+ return {
16799
+ background,
16800
+ bootEntry,
16801
+ startAgent,
16802
+ isInteractive: isInteractiveTerminal,
16803
+ prompter: terminalPrompter,
16804
+ print: (message) => printer_default.print(message),
16805
+ printSuccess: (message) => printer_default.success(message),
16806
+ printError: (message) => printer_default.error(message)
16807
+ };
16808
+ }
16809
+ function describeBootStart(bootEntry) {
16810
+ return bootEntry.startsBeforeSignIn() ? "each time this computer starts" : "each time you sign in to this computer";
16811
+ }
16812
+ function isAutostartOn(background, bootEntry) {
16813
+ return background.hasSavedAgent() && bootEntry.read().present;
16814
+ }
16815
+ function describeAutostartRow(on, bootEntry) {
16816
+ if (on) {
16817
+ return `on, comes online ${describeBootStart(bootEntry)}`;
16818
+ }
16819
+ return `${import_picocolors14.default.gray("off")}. To turn it on, run: ${AUTOSTART_ON_COMMAND}`;
16820
+ }
16821
+ function printLingerHint(dependencies) {
16822
+ const { bootEntry } = dependencies;
16823
+ if (bootEntry.platform === "linux" && !bootEntry.startsBeforeSignIn()) {
16824
+ dependencies.print(`To bring it online before anyone signs in, run: loginctl enable-linger ${bootEntry.username()}`);
16825
+ }
16826
+ }
16827
+ async function startAgentAfterAsking(dependencies) {
16828
+ const foreground = dependencies.background.readForegroundAgent();
16829
+ if (foreground) {
16830
+ dependencies.printError(`${foregroundAgentRefusal(foreground)} Then run: ${AUTOSTART_ON_COMMAND}`);
16831
+ return EXIT_FAILED;
16832
+ }
16833
+ if (!dependencies.isInteractive()) {
16834
+ dependencies.printError([
16835
+ NO_SAVED_AGENT_MESSAGE,
16836
+ "Start it first, then run this command again:",
16837
+ " pinggy device start",
16838
+ ` ${AUTOSTART_ON_COMMAND}`
16839
+ ].join("\n"));
16840
+ return EXIT_FAILED;
16841
+ }
16842
+ dependencies.print(NO_SAVED_AGENT_MESSAGE);
16843
+ let answer;
16844
+ try {
16845
+ answer = await dependencies.prompter.ask(START_AGENT_QUESTION);
16846
+ } catch (err) {
16847
+ if (!isCtrlCAtPrompt(err)) throw err;
16848
+ dependencies.print(import_picocolors14.default.yellow("Cancelled. Nothing changed."));
16849
+ return EXIT_FAILED;
16850
+ }
16851
+ if (NO_ANSWER3.test(answer.trim())) {
16852
+ dependencies.print("Nothing changed.");
16853
+ return EXIT_OK;
16854
+ }
16855
+ const exitCode = await dependencies.startAgent();
16856
+ return exitCode === EXIT_OK ? null : exitCode;
16857
+ }
16858
+ async function runAutostartOn(dependencies) {
16859
+ const { background, bootEntry } = dependencies;
16860
+ if (!background.readIdentity()?.token) {
16861
+ dependencies.printError(NOT_ENROLLED_MESSAGE);
16862
+ return EXIT_FAILED;
16863
+ }
16864
+ const refusal = bootEntry.refusal();
16865
+ if (refusal) {
16866
+ dependencies.printError(refusal);
16867
+ return EXIT_FAILED;
16868
+ }
16869
+ let agentStarted = false;
16870
+ if (!background.hasSavedAgent()) {
16871
+ const stopped = await startAgentAfterAsking(dependencies);
16872
+ if (stopped !== null) {
16873
+ return stopped;
16874
+ }
16875
+ agentStarted = true;
16876
+ }
16877
+ const program = bootEntry.program();
16878
+ const reading = bootEntry.read();
16879
+ if (reading.present && reading.program !== null && sameProgram(bootEntry.platform, reading.program, program)) {
16880
+ const state = agentStarted ? "on" : "already on";
16881
+ dependencies.print(`Autostart is ${state}. This device comes online ${describeBootStart(bootEntry)}.`);
16882
+ printLingerHint(dependencies);
16883
+ return EXIT_OK;
16884
+ }
16885
+ try {
16886
+ bootEntry.install(program);
16887
+ } catch (err) {
16888
+ dependencies.printError(errorMessage(err));
16889
+ return EXIT_FAILED;
16890
+ }
16891
+ dependencies.printSuccess(`Autostart is on. This device comes online ${describeBootStart(bootEntry)}.`);
16892
+ printLingerHint(dependencies);
16893
+ return EXIT_OK;
16894
+ }
16895
+ async function runAutostartOff(dependencies) {
16896
+ if (!dependencies.bootEntry.read().present) {
16897
+ dependencies.print("Autostart is already off.");
16898
+ return EXIT_OK;
16899
+ }
16900
+ try {
16901
+ dependencies.bootEntry.remove();
16902
+ } catch (err) {
16903
+ dependencies.printError(errorMessage(err));
16904
+ return EXIT_FAILED;
16905
+ }
16906
+ dependencies.printSuccess("Autostart is off.");
16907
+ const reading = await readBackgroundAgent(dependencies.background);
16908
+ if (reading && isAgentRunning(reading.status)) {
16909
+ dependencies.print("This device stays online until this computer restarts. To take it offline now, run: pinggy device stop");
16910
+ }
16911
+ return EXIT_OK;
16912
+ }
16913
+ function runAutostartStatus(dependencies) {
16914
+ const { background, bootEntry } = dependencies;
16915
+ if (!background.readIdentity()?.token) {
16916
+ dependencies.print(import_picocolors14.default.yellow("This machine is not enrolled. Run: pinggy device login"));
16917
+ if (bootEntry.read().present) {
16918
+ dependencies.print(`pinggy still starts ${describeBootStart(bootEntry)}. To stop that, run: ${AUTOSTART_OFF_COMMAND}`);
16919
+ }
16920
+ return EXIT_OK;
16921
+ }
16922
+ if (isAutostartOn(background, bootEntry)) {
16923
+ dependencies.print(`Autostart is on. This device comes online ${describeBootStart(bootEntry)}.`);
16924
+ printLingerHint(dependencies);
16925
+ return EXIT_OK;
16926
+ }
16927
+ dependencies.print("Autostart is off. After a restart, this device stays offline.");
16928
+ dependencies.print(`To turn it on, run: ${AUTOSTART_ON_COMMAND}`);
16929
+ return EXIT_OK;
16930
+ }
16931
+ var import_node_os6, import_picocolors14, AutostartVerb, NOT_ENROLLED_MESSAGE, NO_SAVED_AGENT_MESSAGE, START_AGENT_QUESTION, NO_ANSWER3;
16932
+ var init_autostart = __esm({
16933
+ "src/devices/autostart.ts"() {
16934
+ "use strict";
16935
+ init_cjs_shims();
16936
+ import_node_os6 = __toESM(require("os"), 1);
16937
+ import_picocolors14 = __toESM(require("picocolors"), 1);
16938
+ init_printer();
16939
+ init_util();
16940
+ init_serviceInstaller();
16941
+ init_backgroundAgent();
16942
+ init_foregroundAgent();
16943
+ init_deviceLogin();
16944
+ init_prompts();
16945
+ AutostartVerb = {
16946
+ On: "on",
16947
+ Off: "off",
16948
+ Status: "status"
16949
+ };
16950
+ NOT_ENROLLED_MESSAGE = "This machine is not enrolled. Sign it in first: pinggy device login";
16951
+ NO_SAVED_AGENT_MESSAGE = "The device agent does not run in the background, so a restart would leave this device offline.";
16952
+ START_AGENT_QUESTION = "Start it now, and each time this computer starts? [Y/n] ";
16953
+ NO_ANSWER3 = /^n/i;
16954
+ }
16955
+ });
16956
+
16728
16957
  // src/cli/subcommand/handlers/deviceCommand.ts
16729
16958
  function takeEnvironmentToken() {
16730
16959
  const value = process.env[DEVICE_AGENT_TOKEN_VARIABLE]?.trim();
@@ -16743,7 +16972,7 @@ function resolveConnectTarget(flagToken, environmentToken, manage, stored) {
16743
16972
  }
16744
16973
  return null;
16745
16974
  }
16746
- async function handleDevice(args, background = machineBackgroundAgentDependencies(), fileAccess = machineFileAccessDependencies()) {
16975
+ async function handleDevice(args, background = machineBackgroundAgentDependencies(), fileAccess = machineFileAccessDependencies(), bootEntry = machineBootEntryDependencies()) {
16747
16976
  const environmentToken = takeEnvironmentToken();
16748
16977
  if (args.length === 0) {
16749
16978
  printDeviceHelp();
@@ -16785,12 +17014,12 @@ async function handleDevice(args, background = machineBackgroundAgentDependencie
16785
17014
  exitUnlessOk(await stopAgentInBackground(background));
16786
17015
  return;
16787
17016
  case DeviceVerb.Status:
16788
- await handleDeviceStatus(background);
17017
+ await handleDeviceStatus(background, bootEntry);
16789
17018
  return;
16790
17019
  case DeviceVerb.Remove:
16791
17020
  exitUnlessOk(await runDeviceRemove(
16792
17021
  { skipConfirmation: Boolean(values.force) },
16793
- machineDeviceRemoveDependencies(background)
17022
+ machineDeviceRemoveDependencies(background, bootEntry)
16794
17023
  ));
16795
17024
  return;
16796
17025
  default:
@@ -16798,10 +17027,43 @@ async function handleDevice(args, background = machineBackgroundAgentDependencie
16798
17027
  printDeviceHelp();
16799
17028
  return;
16800
17029
  }
16801
- printer_default.error(`Unknown command "${verb}". Valid commands: login, connect, start, stop, status, remove.`);
17030
+ printer_default.error(`Unknown command "${verb}". Valid commands: ${Object.values(DeviceVerb).join(", ")}.`);
16802
17031
  process.exit(1);
16803
17032
  }
16804
17033
  }
17034
+ async function handleAutostart(args, background = machineBackgroundAgentDependencies(), fileAccess = machineFileAccessDependencies(), bootEntry = machineBootEntryDependencies()) {
17035
+ takeEnvironmentToken();
17036
+ const { values, positionals } = parseCliArgs(cliOptions, args);
17037
+ configureLogger(values);
17038
+ if (values.help || positionals[0] === "help") {
17039
+ printAutostartHelp();
17040
+ return;
17041
+ }
17042
+ const startAgent = () => handleDeviceConnect({
17043
+ flagToken: void 0,
17044
+ environmentToken: void 0,
17045
+ manage: void 0,
17046
+ inBackground: true,
17047
+ fileManager: void 0
17048
+ }, background, fileAccess);
17049
+ exitUnlessOk(await runAutostartVerb(
17050
+ positionals[0],
17051
+ machineAutostartDependencies(background, bootEntry, startAgent)
17052
+ ));
17053
+ }
17054
+ async function runAutostartVerb(word, dependencies) {
17055
+ switch (word ?? AutostartVerb.Status) {
17056
+ case AutostartVerb.On:
17057
+ return runAutostartOn(dependencies);
17058
+ case AutostartVerb.Off:
17059
+ return runAutostartOff(dependencies);
17060
+ case AutostartVerb.Status:
17061
+ return runAutostartStatus(dependencies);
17062
+ default:
17063
+ dependencies.printError(`Unknown autostart command "${word}". Valid commands: ${Object.values(AutostartVerb).join(", ")}.`);
17064
+ return EXIT_FAILED;
17065
+ }
17066
+ }
16805
17067
  function exitUnlessOk(exitCode) {
16806
17068
  if (exitCode !== EXIT_OK) {
16807
17069
  process.exit(exitCode);
@@ -16857,7 +17119,7 @@ async function handleDeviceConnect(request2, background, fileAccess) {
16857
17119
  fileManager = await settleFileAccess(request2.fileManager, target.token, stored, fileAccess);
16858
17120
  } catch (err) {
16859
17121
  if (!isCtrlCAtPrompt(err)) throw err;
16860
- fileAccess.print(import_picocolors14.default.yellow("Cancelled. Nothing changed."));
17122
+ fileAccess.print(import_picocolors15.default.yellow("Cancelled. Nothing changed."));
16861
17123
  return EXIT_FAILED;
16862
17124
  }
16863
17125
  if (request2.inBackground) {
@@ -16866,33 +17128,33 @@ async function handleDeviceConnect(request2, background, fileAccess) {
16866
17128
  await runDeviceAgent(target.token, target.manage, { fileManager });
16867
17129
  return EXIT_OK;
16868
17130
  }
16869
- async function handleDeviceStatus(background) {
17131
+ async function handleDeviceStatus(background, bootEntry) {
16870
17132
  const identity = background.readIdentity();
16871
17133
  if (!identity) {
16872
- printer_default.print(import_picocolors14.default.yellow("This machine is not enrolled. Run: pinggy device login"));
17134
+ printer_default.print(import_picocolors15.default.yellow("This machine is not enrolled. Run: pinggy device login"));
16873
17135
  return;
16874
17136
  }
16875
17137
  const reading = await readBackgroundAgent(background);
16876
17138
  const foreground = background.readForegroundAgent();
16877
17139
  const daemonFound = background.findDaemon() !== null;
16878
17140
  printer_default.print(` State ${describeDeviceState(reading, daemonFound, foreground)}`);
16879
- printer_default.print(` Device id ${identity.device_agent_id ?? import_picocolors14.default.gray("not yet assigned")}`);
17141
+ printer_default.print(` Device id ${identity.device_agent_id ?? import_picocolors15.default.gray("not yet assigned")}`);
16880
17142
  printer_default.print(` Server ${identity.server}`);
16881
17143
  printer_default.print(` Token ${maskToken(identity.token)}`);
16882
- printer_default.print(` Enrolled ${identity.enrolled_at ?? import_picocolors14.default.gray("never")}`);
16883
- printer_default.print(` Autostart ${background.hasSavedAgent() ? "on, starts with the daemon" : import_picocolors14.default.gray("off")}`);
17144
+ printer_default.print(` Enrolled ${identity.enrolled_at ?? import_picocolors15.default.gray("never")}`);
17145
+ printer_default.print(` Autostart ${describeAutostartRow(isAutostartOn(background, bootEntry), bootEntry)}`);
16884
17146
  printer_default.print(` Files ${describeFileAccess(identity)}`);
16885
17147
  if (foreground) {
16886
17148
  printer_default.print(` Foreground running in another terminal, PID ${foreground.pid}`);
16887
17149
  }
16888
17150
  printBackgroundStatus(reading, background);
16889
17151
  }
16890
- var import_picocolors14, DeviceVerb, DEVICE_AGENT_TOKEN_VARIABLE;
17152
+ var import_picocolors15, DeviceVerb, DEVICE_AGENT_TOKEN_VARIABLE;
16891
17153
  var init_deviceCommand = __esm({
16892
17154
  "src/cli/subcommand/handlers/deviceCommand.ts"() {
16893
17155
  "use strict";
16894
17156
  init_cjs_shims();
16895
- import_picocolors14 = __toESM(require("picocolors"), 1);
17157
+ import_picocolors15 = __toESM(require("picocolors"), 1);
16896
17158
  init_options();
16897
17159
  init_parseArgs();
16898
17160
  init_logger();
@@ -16906,6 +17168,7 @@ var init_deviceCommand = __esm({
16906
17168
  init_removeDevice();
16907
17169
  init_fileAccess();
16908
17170
  init_prompts();
17171
+ init_autostart();
16909
17172
  DeviceVerb = {
16910
17173
  Login: "login",
16911
17174
  Connect: "connect",
@@ -17229,6 +17492,9 @@ async function handleSubcommand(rawArgs) {
17229
17492
  case Subcommand.Update:
17230
17493
  await handleUpdate(rest);
17231
17494
  return;
17495
+ case Subcommand.Autostart:
17496
+ await handleAutostart(rest);
17497
+ return;
17232
17498
  }
17233
17499
  }
17234
17500
  function handleConfig(args) {
@@ -17617,7 +17883,7 @@ function removeStaleFilesFor(platform3, homeRealPath) {
17617
17883
  }
17618
17884
  function writeLogLine(logPath, line) {
17619
17885
  try {
17620
- import_node_fs17.default.appendFileSync(logPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}${import_node_os6.default.EOL}`);
17886
+ import_node_fs17.default.appendFileSync(logPath, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}${import_node_os7.default.EOL}`);
17621
17887
  } catch {
17622
17888
  }
17623
17889
  }
@@ -17662,13 +17928,13 @@ function createUpdateChildEnvironment() {
17662
17928
  exitProcess: () => process.exit(0)
17663
17929
  };
17664
17930
  }
17665
- var import_node_fs17, import_node_os6, TIME_LIMIT_MILLIS, CHECK_TIMEOUT_MILLIS2, CHECK_INTERVAL_SECONDS2, MAX_FAILED_ATTEMPTS, Outcome;
17931
+ var import_node_fs17, import_node_os7, TIME_LIMIT_MILLIS, CHECK_TIMEOUT_MILLIS2, CHECK_INTERVAL_SECONDS2, MAX_FAILED_ATTEMPTS, Outcome;
17666
17932
  var init_updateChild = __esm({
17667
17933
  "src/update/updateChild.ts"() {
17668
17934
  "use strict";
17669
17935
  init_cjs_shims();
17670
17936
  import_node_fs17 = __toESM(require("fs"), 1);
17671
- import_node_os6 = __toESM(require("os"), 1);
17937
+ import_node_os7 = __toESM(require("os"), 1);
17672
17938
  init_daemonManager();
17673
17939
  init_configDir();
17674
17940
  init_util();
@@ -18572,7 +18838,7 @@ function machineDeviceAgentHostDependencies(port, record) {
18572
18838
  now: () => /* @__PURE__ */ new Date()
18573
18839
  };
18574
18840
  }
18575
- var NOT_ENROLLED_MESSAGE, DeviceAgentHost;
18841
+ var NOT_ENROLLED_MESSAGE2, DeviceAgentHost;
18576
18842
  var init_deviceAgentHost = __esm({
18577
18843
  "src/daemon/deviceAgentHost.ts"() {
18578
18844
  "use strict";
@@ -18584,7 +18850,7 @@ var init_deviceAgentHost = __esm({
18584
18850
  init_tunnelActions();
18585
18851
  init_types();
18586
18852
  init_ipcRoutes();
18587
- NOT_ENROLLED_MESSAGE = "This machine is not enrolled. Sign it in first: pinggy device login";
18853
+ NOT_ENROLLED_MESSAGE2 = "This machine is not enrolled. Sign it in first: pinggy device login";
18588
18854
  DeviceAgentHost = class {
18589
18855
  constructor(dependencies) {
18590
18856
  this.dependencies = dependencies;
@@ -18611,7 +18877,7 @@ var init_deviceAgentHost = __esm({
18611
18877
  }
18612
18878
  const identity = this.dependencies.readIdentity();
18613
18879
  if (!identity?.token) {
18614
- return newErrorResponse(ErrorCode.DeviceNotEnrolled, NOT_ENROLLED_MESSAGE);
18880
+ return newErrorResponse(ErrorCode.DeviceNotEnrolled, NOT_ENROLLED_MESSAGE2);
18615
18881
  }
18616
18882
  const current = this.current;
18617
18883
  if (current && current.token === identity.token && current.server === identity.server) {
@@ -19225,7 +19491,7 @@ function printDaemonVersionNoticeOnce(info, restartInstruction = serviceRestartI
19225
19491
  function startDaemonFromInstalledBinary(binaryPath) {
19226
19492
  installedBinaryForDaemon = binaryPath;
19227
19493
  }
19228
- function getDaemonSpawnArgs(isPackaged = isPackagedBinary(), executableExists = import_node_fs22.default.existsSync(process.execPath), linkPath = unixLayoutPaths(import_node_os7.default.homedir()).link, installedBinary = installedBinaryForDaemon) {
19494
+ function getDaemonSpawnArgs(isPackaged = isPackagedBinary(), executableExists = import_node_fs22.default.existsSync(process.execPath), linkPath = unixLayoutPaths(import_node_os8.default.homedir()).link, installedBinary = installedBinaryForDaemon) {
19229
19495
  if (isPackaged && installedBinary) {
19230
19496
  return { command: installedBinary, args: ["--_daemon-child"], env: { ...process.env } };
19231
19497
  }
@@ -19252,7 +19518,7 @@ async function startDaemon() {
19252
19518
  detached: true,
19253
19519
  stdio: ["ignore", "ignore", "pipe"],
19254
19520
  env,
19255
- ...import_node_os7.default.platform() === "win32" ? { windowsHide: true } : {}
19521
+ ...import_node_os8.default.platform() === "win32" ? { windowsHide: true } : {}
19256
19522
  });
19257
19523
  child.stderr?.on("data", (chunk) => {
19258
19524
  stderrOutput += chunk.toString("utf-8");
@@ -19406,12 +19672,12 @@ async function waitForExit2(pid, timeoutMs) {
19406
19672
  }
19407
19673
  return !isProcessAlive(pid);
19408
19674
  }
19409
- var import_node_os7, import_node_fs22, import_node_child_process6, inProcessHandle, daemonLauncher, DAEMON_SPAWN_TIMEOUT_MS, DAEMON_POLL_INTERVAL_MS, SPAWN_FAILED_EXIT_CODE, DAEMON_STOP_INSTRUCTION, installedBinaryForDaemon;
19675
+ var import_node_os8, import_node_fs22, import_node_child_process6, inProcessHandle, daemonLauncher, DAEMON_SPAWN_TIMEOUT_MS, DAEMON_POLL_INTERVAL_MS, SPAWN_FAILED_EXIT_CODE, DAEMON_STOP_INSTRUCTION, installedBinaryForDaemon;
19410
19676
  var init_daemonManager = __esm({
19411
19677
  "src/daemon/lifecycle/daemonManager.ts"() {
19412
19678
  "use strict";
19413
19679
  init_cjs_shims();
19414
- import_node_os7 = __toESM(require("os"), 1);
19680
+ import_node_os8 = __toESM(require("os"), 1);
19415
19681
  import_node_fs22 = __toESM(require("fs"), 1);
19416
19682
  import_node_child_process6 = require("child_process");
19417
19683
  init_configDir();