import { isRufloProject } from './project-root.js'; /** True if a live daemon already holds the project's pidfile. */ export declare function isDaemonAlive(projectRoot: string): boolean; /** * #4654: an explicit `daemon stop` is an opt-out that must survive the next * hook. Every ruflo-core plugin hook (PreToolUse/PostToolUse, PreCompact, Stop) * runs the CLI, and the CLI auto-starts a daemon whenever none is alive, so a * stopped daemon came back within minutes. `daemon stop` now writes this * marker, auto-start honours it, and only an explicit `daemon start` clears it. */ export declare const DAEMON_STOP_MARKER = "daemon.stopped"; /** * Set on the daemon that auto-start spawns, so that spawned `daemon start` does * not clear a stop marker written after auto-start checked it (a `daemon stop` * racing a hook). Only a user-driven start clears the marker. */ export declare const AUTOSTART_ENV = "RUFLO_DAEMON_AUTOSTARTED"; /** True if the user explicitly stopped the daemon for this project (#4654). */ export declare function isDaemonStopMarked(projectRoot: string): boolean; /** * Record an explicit `daemon stop` (#4654). Writes only into a directory that is * already a Ruflo project or already has `.claude-flow/`, so `daemon stop` in an * unrelated directory does not litter it. Best-effort; never throws. */ export declare function writeDaemonStopMarker(projectRoot: string): boolean; /** Clear the stop marker. Called by an explicit `daemon start` (#4654). Never throws. */ export declare function clearDaemonStopMarker(projectRoot: string): void; /** * Return true only when the directory contains a durable Ruflo project marker. * Implementation lives in ./project-root.ts (shared with #2633 state anchoring); * re-exported here for existing importers. */ export { isRufloProject }; /** * #2877: Normalize a working directory to the project root that owns the * daemon lock/PID key. * * The lock (`/.claude-flow/daemon.lock`) and PID file * (`/.claude-flow/daemon.pid`) were keyed to the raw cwd, so invoking * the CLI from `/proj` and from `/proj/packages/foo` produced two different * keys for one logical project — bypassing the atomic-lockfile dedup added * for #2407/#2484 entirely (each cwd races against a different lock file) * and leaving two daemons supervising the same tree. * * Resolution walks up from `startDir` and returns the NEAREST enclosing * directory carrying a durable Ruflo marker (`isRufloProject`). Nearest-wins * is what keeps a monorepo's independently-initialized sub-project on its own * daemon: it matches its own marker before the walk ever reaches the parent. * * A `.git` directory is a hard stop — the repository boundary. Without it the * walk could escape into an unrelated ancestor (a Ruflo project living at * `$HOME`, say) and hand every repo below it the same daemon. * * Returns the resolved `startDir` unchanged when no marker is found, so a * non-Ruflo directory still fails `isRufloProject` and declines autostart. */ export declare function resolveDaemonProjectRoot(startDir: string): string; export interface EnsureResult { started: boolean; reason?: string; } /** Spawn `daemon start` detached, reusing all its lock/TTL machinery. Injectable for tests. */ export type SpawnDaemonFn = (projectRoot: string) => void; /** * Ensure a daemon is running for the project enclosing `startDir`. No-op when * disabled or when one is already alive. Best-effort; never throws. * * #2877: `startDir` is normalized to the owning project root first, so a call * from a subdirectory reads the same config, pidfile, and lock as a call from * the root and cannot spawn a second daemon for the same project. */ export declare function ensureDaemonRunning(startDir: string, opts?: { spawnFn?: SpawnDaemonFn; isAlive?: (root: string) => boolean; }): EnsureResult; //# sourceMappingURL=daemon-autostart.d.ts.map