import { type SessionHostEndpoint, type SessionHostRequestType } from '@adhdev/session-host-core';
/**
 * Shared managed-session-host process helpers.
 *
 * The cloud (`packages/daemon-cloud`) and standalone (`oss/packages/daemon-standalone`)
 * daemons carried byte-for-byte copies of `buildSessionHostEnv`, `resolveSessionHostEntry`,
 * `getSessionHostPidFile`, `killPid`, a base `stopManagedSessionHostProcess`, and the
 * `ensureSessionHostReady` retry-wrapper. Those live here now. The pieces that genuinely
 * differ between the two daemons (kill windowsHide, quarantine preamble, spawn stdio,
 * required request types, cloud's socket-owner sweep) are injected via options so the
 * observable behavior of each daemon is preserved exactly.
 */
export interface ManagedSessionHostOptions {
    /** Session-host namespace (app name). Drives the socket endpoint and pidfile path. */
    appName: string;
    /** Capability probe: request types the host must advertise before it's considered ready. */
    requiredRequestTypes: readonly SessionHostRequestType[];
    /** Ready timeout for the spawn/poll loop. Defaults to the shared runtime default. */
    timeoutMs?: number;
    /**
     * `killPid` on win32 uses `taskkill /T /F`. Cloud passes `windowsHide: true`; standalone
     * historically did not. Kept as a flag to preserve each daemon's exact spawn options.
     */
    killWindowsHide?: boolean;
    /**
     * How the detached host child's stdio is wired. 'ignore' matches standalone; 'logfile'
     * matches cloud (append to `~/.adhdev/logs/session-host.log`).
     */
    spawnStdio?: 'ignore' | 'logfile';
    /**
     * Optional preamble run at the start of `ensureReady` (before the first connect probe).
     * Cloud uses this to quarantine legacy standalone runtime files.
     */
    beforeEnsureReady?: () => void;
    /**
     * Optional extra stop pass appended to `stopManagedSessionHostProcess`. Cloud sweeps
     * managed session-host processes that own the default socket but predate pidfile tracking.
     * Returns true if it stopped anything.
     */
    extraStop?: (endpoint: SessionHostEndpoint) => boolean;
    /**
     * Optional guard applied to a pidfile-tracked pid before killing it in
     * `stopManagedSessionHostProcess`. Cloud verifies the command line is an ADHDev
     * session-host daemon; standalone kills unconditionally (returns true here).
     */
    isManagedPid?: (pid: number) => boolean;
}
export interface ManagedSessionHost {
    readonly appName: string;
    readonly endpoint: SessionHostEndpoint;
    getPidFile(): string;
    getPid(): number | null;
    buildEnv(baseEnv: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
    resolveEntry(): string;
    killPid(pid: number): boolean;
    spawnHost(): void;
    stopManagedSessionHostProcess(): boolean;
    ensureReady(): Promise<SessionHostEndpoint>;
    getStatusPaths(): {
        pidFile: string;
        endpoint: SessionHostEndpoint;
    };
}
export declare function createManagedSessionHost(options: ManagedSessionHostOptions): ManagedSessionHost;
