overlord-cli 0.2607100901.0 → 0.2607101820.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.js CHANGED
@@ -7999,20 +7999,57 @@ function applyPollJitter(intervalMs, random = Math.random) {
7999
7999
  const spread = intervalMs * 0.1;
8000
8000
  return Math.round(intervalMs + (random() * 2 - 1) * spread);
8001
8001
  }
8002
+ function resolveOverlordAppInvocation({
8003
+ platform: platform2 = process.platform,
8004
+ homedir: homedir2 = os4.homedir(),
8005
+ exists = existsSync19
8006
+ } = {}) {
8007
+ if (platform2 !== "darwin") return null;
8008
+ const appDirs = [
8009
+ "/Applications/Overlord.app",
8010
+ path23.join(homedir2, "Applications", "Overlord.app")
8011
+ ];
8012
+ for (const appDir of appDirs) {
8013
+ const program = path23.join(appDir, "Contents", "MacOS", "Overlord");
8014
+ const script = path23.join(appDir, "Contents", "Resources", "cli", "bin", "ovld.mjs");
8015
+ if (exists(program) && exists(script)) {
8016
+ return { program, args: [script, "runner", "supervise"], runAsElectronNode: true };
8017
+ }
8018
+ }
8019
+ return null;
8020
+ }
8002
8021
  function resolveOvldInvocation(argv = process.argv, execPath = process.execPath) {
8003
8022
  const override = process.env.OVLD_RUNNER_EXEC?.trim();
8004
8023
  if (override) {
8005
8024
  return { program: override, args: ["runner", "supervise"] };
8006
8025
  }
8007
8026
  const scriptPath = argv[1] ? path23.resolve(argv[1]) : "";
8027
+ if (process.env.ELECTRON_RUN_AS_NODE) {
8028
+ return scriptPath ? { program: execPath, args: [scriptPath, "runner", "supervise"], runAsElectronNode: true } : { program: execPath, args: ["runner", "supervise"], runAsElectronNode: true };
8029
+ }
8030
+ const appInvocation = resolveOverlordAppInvocation();
8031
+ if (appInvocation) return appInvocation;
8008
8032
  if (scriptPath) {
8009
8033
  return { program: execPath, args: [scriptPath, "runner", "supervise"] };
8010
8034
  }
8011
8035
  return { program: execPath, args: ["runner", "supervise"] };
8012
8036
  }
8037
+ function describeServicePublisher({
8038
+ execProgram,
8039
+ platform: platform2 = process.platform
8040
+ }) {
8041
+ if (platform2 !== "darwin" || !execProgram) {
8042
+ return { publisher: "unknown", needsReinstallForOverlord: false };
8043
+ }
8044
+ if (execProgram.includes(".app/Contents/MacOS/")) {
8045
+ return { publisher: "overlord", needsReinstallForOverlord: false };
8046
+ }
8047
+ return { publisher: "node", needsReinstallForOverlord: true };
8048
+ }
8013
8049
  function buildRunnerServiceEnv({
8014
8050
  backendUrl,
8015
- overlordHome
8051
+ overlordHome,
8052
+ runAsElectronNode
8016
8053
  }) {
8017
8054
  const env = {
8018
8055
  OVERLORD_BACKEND_URL: backendUrl,
@@ -8022,6 +8059,7 @@ function buildRunnerServiceEnv({
8022
8059
  if (home) env.OVLD_HOME = path23.resolve(home);
8023
8060
  const token = process.env.OVERLORD_USER_TOKEN?.trim() || process.env.OVLD_USER_TOKEN?.trim();
8024
8061
  if (token) env.OVERLORD_USER_TOKEN = token;
8062
+ if (runAsElectronNode || process.env.ELECTRON_RUN_AS_NODE) env.ELECTRON_RUN_AS_NODE = "1";
8025
8063
  return env;
8026
8064
  }
8027
8065
  function xmlEscape(value) {
@@ -9438,6 +9476,10 @@ async function runRunnerServiceCommand({
9438
9476
  if (action === "status") {
9439
9477
  const runState = await manager.status();
9440
9478
  const state = readRunnerServiceState();
9479
+ const { publisher, needsReinstallForOverlord } = describeServicePublisher({
9480
+ execProgram: state.execProgram
9481
+ });
9482
+ const reinstallHint = runState.installed && needsReinstallForOverlord ? 'This service is registered under "Node.js Foundation" because it runs the plain node binary. Reinstall it from the Overlord desktop app (or with the desktop app present) to re-register it under "Overlord".' : null;
9441
9483
  const payload = {
9442
9484
  supported: true,
9443
9485
  kind: manager.kind,
@@ -9451,7 +9493,9 @@ async function runRunnerServiceCommand({
9451
9493
  lastClaimedAt: state.lastClaimedAt,
9452
9494
  lastLaunchedAt: state.lastLaunchedAt,
9453
9495
  lastError: state.lastError,
9454
- currentPollIntervalMs: state.currentPollIntervalMs
9496
+ currentPollIntervalMs: state.currentPollIntervalMs,
9497
+ publisher,
9498
+ reinstallHint
9455
9499
  };
9456
9500
  if (json) printJson(payload);
9457
9501
  else {
@@ -9459,12 +9503,15 @@ async function runRunnerServiceCommand({
9459
9503
  Service: `${manager.kind} (${manager.identifier})`,
9460
9504
  Installed: runState.installed ? "yes" : "no",
9461
9505
  Running: runState.running,
9506
+ Publisher: publisher === "unknown" ? "(unknown)" : publisher,
9462
9507
  Backend: state.backendUrl ?? "(unknown)",
9463
9508
  "Last heartbeat": state.lastHeartbeatAt ?? "(never)",
9464
9509
  "Last launched": state.lastLaunchedAt ?? "(never)",
9465
9510
  "Poll interval": state.currentPollIntervalMs ? `${state.currentPollIntervalMs}ms` : "(idle)",
9466
9511
  "Last error": state.lastError ?? "(none)"
9467
9512
  });
9513
+ if (reinstallHint) console.log(`
9514
+ Note: ${reinstallHint}`);
9468
9515
  }
9469
9516
  return;
9470
9517
  }
@@ -9472,7 +9519,10 @@ async function runRunnerServiceCommand({
9472
9519
  const config = loadConfig();
9473
9520
  const backendUrl = resolveBackendUrl(config);
9474
9521
  const invocation = resolveOvldInvocation();
9475
- const env = buildRunnerServiceEnv({ backendUrl });
9522
+ const env = buildRunnerServiceEnv({
9523
+ backendUrl,
9524
+ runAsElectronNode: invocation.runAsElectronNode
9525
+ });
9476
9526
  const autoStart = !flagBoolean(parsed.flags, "--no-start");
9477
9527
  await manager.install({ invocation, env, autoStart });
9478
9528
  writeRunnerServiceState({