export declare const SERVICE_LABEL = "com.wickedagile.wicked-crew"; export declare const SYSTEMD_UNIT_NAME = "wicked-crew.service"; export declare const INSTALL_SERVICE_FLAG = "--install-service"; export declare const UNINSTALL_SERVICE_FLAG = "--uninstall-service"; export type ServicePlatform = 'darwin' | 'linux' | 'other'; export declare function servicePlatform(platform?: NodeJS.Platform): ServicePlatform; /** Where the unit file lives for this platform, or `null` where nothing is automated. */ export declare function serviceUnitPath(platform: ServicePlatform, home?: string): string | null; export interface CapturedEnv { env: Record; /** Names that would have been carried but look like secrets — reported, never written. */ omitted: string[]; } /** The service environment: the allowlist + every `WICKED_*` variable, minus anything secret-shaped. */ export declare function captureServiceEnv(source?: NodeJS.ProcessEnv): CapturedEnv; export interface ServiceSpec { /** Absolute argv: the node binary, the CLI entry, `serve`, and the forwarded serve options. */ program: string[]; env: Record; /** stdout + stderr of the daemon. */ logPath: string; workingDir: string; } /** The serve options the service re-runs with: argv minus the two service flags. */ export declare function forwardedServeArgs(argv: string[]): string[]; export declare function renderPlist(spec: ServiceSpec): string; export declare function renderSystemdUnit(spec: ServiceSpec): string; /** The daemon log an installed unit writes to — read back from the unit text (`status` names it). */ export declare function logPathFromUnit(text: string): string | null; /** An installed service on this host: its unit path and the log it writes, or `null`. */ export declare function installedService(platform?: ServicePlatform, home?: string): { unitPath: string; logPath: string | null; } | null; /** Printed where nothing is automated (Windows): a Task Scheduler recipe for the same command. */ export declare function windowsRecipe(spec: ServiceSpec): string; export interface CommandResult { status: number | null; stdout: string; stderr: string; } export type CommandRunner = (cmd: string, args: string[]) => CommandResult; export declare const runCommand: CommandRunner; export interface ServiceDeps { platform: ServicePlatform; home: string; uid: number; run: CommandRunner; /** A process already listening on the daemon port (`null` = nothing answering). */ portHolder: () => Promise<{ pid: number | null; } | null>; log: (line: string) => void; } export interface InstallInput { /** The CLI entry the service runs (`process.argv[1]`). */ cliPath: string; nodePath: string; serveArgs: string[]; env: NodeJS.ProcessEnv; /** The daemon's state home (the `--db` parent or `~/.wicked-crew`) — the log lands there. */ stateHome: string; port: number; } /** * The node binary the unit names. `process.execPath` is the resolved binary (Homebrew: * `/opt/homebrew/Cellar/node//bin/node`), which a node upgrade deletes. When a `node` on * the captured PATH resolves to that same binary, name the PATH entry instead (the stable symlink). */ export declare function stableNodePath(execPath: string, path: string | undefined): string; /** `0` on success, `1` on a refusal or a failed service-manager call (the reason is logged). */ export declare function installService(input: InstallInput, deps: ServiceDeps): Promise; /** The pid of the loaded service's running process, or `null` (not loaded, not running, unknown). */ export declare function runningServicePid(deps: Pick): number | null; export declare function uninstallService(deps: Pick): number; /** The pid listening on a TCP port (lsof; best-effort, `null` when unknown). */ export declare function listeningPid(port: number, run?: CommandRunner): number | null; //# sourceMappingURL=service.d.ts.map