import { spawnSync } from "node:child_process"; import { type RunnerClaimScope } from "./index.js"; /** * The runner must never import the local daemon (the cloud-boundary test * enforces this across every file under src/runner), so the small unit/plist * formatting helpers are mirrored here rather than imported from the daemon's * install module. */ export interface StartupEnableResult { command: string; status: number | null; stdout: string; stderr: string; } export interface RunnerStartupOptions { cliEntry: string; execPath?: string; platform?: NodeJS.Platform; claimScope?: RunnerClaimScope; machineId?: string; } export interface RunnerStartupResult { platform: NodeJS.Platform; path: string; instructions: string[]; enableResults?: StartupEnableResult[]; /** The mode-600 per-station config surface this unit references. */ envFile: RunnerEnvConfigResult; } export interface RunnerEnvConfigResult { path: string; present: boolean; wrote: string[]; } /** * Write (or merge into) the per-station runner env file at mode 0600. Only the * non-credential identity keys (`LOOPS_RUNNER_MACHINE_ID`, * `LOOPS_RUNNER_CLAIM_SCOPE`) are written here; existing lines — including the * control-plane URL and API key written by the provision step — are preserved * byte-for-byte, so this never touches a live credential. */ export declare function writeRunnerEnvConfig(values: { claimScope?: string; machineId?: string; }): RunnerEnvConfigResult; /** * Write the package-owned runner service unit: a systemd-user unit on Linux * referencing the mode-600 env file via `EnvironmentFile` (the credential * never appears in the unit), and a launchd plist on macOS. On macOS launchd * has no EnvironmentFile primitive, so the runner loads the same env file * itself at startup. The run args carry `--claim-scope` so the unit's claim * scope is visible in the unit file, while the machine id lives in the env * file with the rest of the per-station config. */ export declare function installRunnerStartup(opts: RunnerStartupOptions): RunnerStartupResult; export interface RunnerServiceResult { commands: StartupEnableResult[]; } /** * Exit code the CLI should propagate for a service-control result: non-zero * when any underlying systemctl/launchctl command failed, so deployment * automation never sees exit 0 for a runner that failed to start or stop. */ export declare function runnerServiceExitCode(result: RunnerServiceResult): number; export declare function startRunnerService(opts?: { platform?: NodeJS.Platform; spawnImpl?: typeof spawnSync; }): RunnerServiceResult; export declare function stopRunnerService(opts?: { platform?: NodeJS.Platform; spawnImpl?: typeof spawnSync; }): RunnerServiceResult; export interface RunnerServiceStatus { installed: boolean; active: boolean | null; unitPath?: string; } export declare function runnerServiceStatus(opts?: { platform?: NodeJS.Platform; spawnImpl?: typeof spawnSync; }): RunnerServiceStatus;