@longleash/cli 0.1.0-rc.7 → 0.1.0-rc.9

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/bin/longleash.mjs CHANGED
@@ -1879,7 +1879,7 @@ function startService(context = {}) {
1879
1879
  assertServiceInstallation(resolved);
1880
1880
  if (resolved.platform === "darwin") {
1881
1881
  if (launchdLoaded(resolved)) requireSuccess(resolved, "/bin/launchctl", ["kickstart", "-k", serviceTarget(resolved)]);
1882
- else requireSuccess(resolved, "/bin/launchctl", ["bootstrap", launchDomain(resolved), resolved.paths.definition]);
1882
+ else bootstrapLaunchAgent(resolved);
1883
1883
  } else {
1884
1884
  requireSuccess(resolved, "systemctl", ["--user", "start", SYSTEMD_UNIT]);
1885
1885
  }
@@ -1904,7 +1904,7 @@ function restartService(context = {}) {
1904
1904
  assertServiceInstallation(resolved);
1905
1905
  if (resolved.platform === "darwin") {
1906
1906
  if (launchdLoaded(resolved)) requireSuccess(resolved, "/bin/launchctl", ["kickstart", "-k", serviceTarget(resolved)]);
1907
- else requireSuccess(resolved, "/bin/launchctl", ["bootstrap", launchDomain(resolved), resolved.paths.definition]);
1907
+ else bootstrapLaunchAgent(resolved);
1908
1908
  } else {
1909
1909
  requireSuccess(resolved, "systemctl", ["--user", "restart", SYSTEMD_UNIT]);
1910
1910
  }
@@ -1960,13 +1960,26 @@ function installLaunchAgent(context) {
1960
1960
  writeManagedAtomically(context.paths.definition, content, 384, (temporary) => {
1961
1961
  requireSuccess(context, "/usr/bin/plutil", ["-lint", temporary]);
1962
1962
  });
1963
- requireSuccess(context, "/bin/launchctl", ["bootstrap", launchDomain(context), context.paths.definition]);
1963
+ bootstrapLaunchAgent(context);
1964
1964
  } catch (error) {
1965
1965
  restore(context.paths.definition, previous);
1966
1966
  if (previous !== null && wasLoaded) run(context, "/bin/launchctl", ["bootstrap", launchDomain(context), context.paths.definition]);
1967
1967
  throw error;
1968
1968
  }
1969
1969
  }
1970
+ function bootstrapLaunchAgent(context) {
1971
+ const args = ["bootstrap", launchDomain(context), context.paths.definition];
1972
+ const first = run(context, "/bin/launchctl", args);
1973
+ if (first.status === 0 || launchdLoaded(context)) return;
1974
+ run(context, "/bin/launchctl", ["bootout", serviceTarget(context)]);
1975
+ const retry = run(context, "/bin/launchctl", args);
1976
+ if (retry.status === 0 || launchdLoaded(context)) return;
1977
+ const failure = commandError("/bin/launchctl", args, retry);
1978
+ const firstDetail = (first.stderr || first.stdout).trim().replace(/\s+/g, " ").slice(0, 240);
1979
+ throw new Error(
1980
+ `${failure.message} launchd still rejected the managed job after one stale-state recovery attempt${firstDetail ? ` (first response: ${firstDetail})` : ""}. Run \`longleash service logs\` for daemon output.`
1981
+ );
1982
+ }
1970
1983
  function installSystemdService(context) {
1971
1984
  if (!context.paths.environment) throw new Error("The Linux service environment path is missing.");
1972
1985
  const previousUnit = snapshot(context.paths.definition);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@longleash/cli",
3
- "version": "0.1.0-rc.7",
3
+ "version": "0.1.0-rc.9",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@longleash/cli",
9
- "version": "0.1.0-rc.7",
9
+ "version": "0.1.0-rc.9",
10
10
  "license": "MIT",
11
11
  "os": [
12
12
  "darwin",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longleash/cli",
3
- "version": "0.1.0-rc.7",
3
+ "version": "0.1.0-rc.9",
4
4
  "description": "Securely control Claude Code and Codex sessions on your laptop from your phone.",
5
5
  "license": "MIT",
6
6
  "type": "module",