/** * daemon/setup.ts — `aibroker setup` / `aibroker uninstall`. * * One idempotent command wires the four things a user otherwise does by hand: * the service (systemd --user on Linux, LaunchAgent on macOS), the MCP server * registration for Claude Code, the Claude Code hooks, and ~/.aibroker/env. * Every host fact (home, platform, which binaries exist, running a command) is * behind `Sys`, so tests run under a temp HOME without touching the machine. */ export interface Sys { home: string; platform: NodeJS.Platform; env: NodeJS.ProcessEnv; execPath: string; nodeVersion: string; /** Root of the installed aibroker package (holds dist/, hooks/, templates/). */ pkgRoot: string; user: string; uid: number; /** Absolute path of a binary, or null when it is not installed. */ which(bin: string): string | null; /** Run a command; never throws. */ run(cmd: string, args: string[]): { ok: boolean; out: string; }; } /** * The first `node` on PATH that is the running binary, so a versioned path * (Homebrew Cellar) becomes its stable alias. Falls back to execPath. */ export declare function stableNodePath(execPath: string, pathEnv: string, realpath: (p: string) => string): string; export declare function realSys(): Sys; export declare const UNIT_NAME = "aibroker.service"; export declare const PLIST_LABEL = "com.aibroker.daemon"; export declare const unitPath: (s: Sys) => string; export declare const plistPath: (s: Sys) => string; export declare const envFilePath: (s: Sys) => string; export declare const daemonLogPath: (s: Sys) => string; export declare const claudeJsonPath: (s: Sys) => string; export declare const settingsPath: (s: Sys) => string; export declare const cliJs: (s: Sys) => string; export declare const mcpJs: (s: Sys) => string; export declare const hooksDir: (s: Sys) => string; export interface HookSpec { event: string; matcher?: string; file: string; } /** * Which hook file runs on which Claude Code event, from each file's own header * and docs/mailbox.md. budget-stop.mjs is left out on purpose: it reads PAI's * advisor file and only means something on a PAI install. */ export declare const HOOK_PLAN: HookSpec[]; type Json = Record; export declare function mergeHooks(settings: Json, s: Sys): { settings: Json; added: string[]; present: string[]; updated: string[]; }; /** Remove exactly the entries whose command lives under this install's hooks/ dir. */ export declare function unmergeHooks(settings: Json, s: Sys): { settings: Json; removed: number; }; /** The `aibroker` entry in ~/.claude.json: whether present and the .js it launches. */ export declare function readMcpEntry(s: Sys): { found: boolean; target?: string; command?: string; }; export declare function renderUnit(s: Sys): string; export declare function renderPlist(s: Sys): string; export declare const ENV_TEMPLATE = "# AIBroker environment: KEY=value per line, read by the daemon at start.\n# Restart the daemon after editing (aibroker restart).\n#\n# AIBROKER_TRANSPORT=tmux\n# PAILOT_PORT=8765\n# TODOIST_API_TOKEN=\n"; export interface Opts { service: boolean; mcp: boolean; hooks: boolean; dryRun: boolean; force: boolean; purge: boolean; } export declare function parseOpts(argv: string[]): Opts; type Say = (line: string) => void; /** Returns the number of failed steps. */ export declare function setup(s: Sys, opts: Opts, say?: Say): number; export declare function uninstall(s: Sys, opts: Opts, say?: Say): number; declare const FLAGS: { setup: string[]; uninstall: string[]; }; export declare const usage: (cmd: keyof typeof FLAGS) => string; /** Help or a bad flag ends the command before anything is touched; returns the exit code, or null to proceed. */ export declare function checkArgs(cmd: keyof typeof FLAGS, argv: string[], say?: Say): number | null; export declare function runSetup(argv: string[], s?: Sys, say?: Say): Promise; export declare function runUninstall(argv: string[], s?: Sys, say?: Say): Promise; export {}; //# sourceMappingURL=setup.d.ts.map