/**
 * WHAT the lifecycle supervisor is launched with and WHAT it launches: its hidden argv route, the
 * argv it parses, and the host child it spawns. Split out of `host-lifecycle.ts`, which keeps the
 * supervisor's orchestration; every name stays re-exported there for existing importers.
 */
import { type ChildProcess } from "node:child_process";
import { type SocketFileIdentity } from "./socket-ownership.ts";
export interface SupervisorLaunch {
    readonly presenterBootstrapFd?: number;
    readonly socket: string;
    readonly hostArgs: readonly string[];
    /** Optional runtime command used by rebranded/bundled callers. */
    readonly childCommand?: string;
    readonly childArgs?: readonly string[];
    /** Explicit ownership directory for callers whose environment is not yet branded. */
    readonly agentDir?: string;
    /** Inherited caller-lifetime pipe, distinct from the supervisor-to-host watchdog pipe. */
    readonly ownerFd?: number;
    /**
     * Where this supervisor BINDS, when it is a successor generation: `<socket>.next-<gen>`.
     * It renames that entry over `socket` once its host answers - and never binds the live
     * public path, which belongs to the generation currently serving it.
     */
    readonly bindSocket?: string;
    /**
     * The public socket entry this generation is allowed to replace (`<dev>:<ino>`). The rename
     * happens only while the path still refers to it: a socket that changed underneath belongs to
     * somebody else now, and replacing it would unlink an endpoint this process cannot prove it owns.
     */
    readonly replaceIdentity?: SocketFileIdentity;
    /**
     * The predecessor generation whose owner token the adoption must find (senpi#4602): passed only for a predecessor
     * that advertises the endpoint owner fence. Without it the adoption checks the entry identity alone, as before.
     */
    readonly replaceOwner?: string;
}
export { resolveCliMainPath } from "./host-cli-entry.ts";
/** Hidden internal launch route: wire-invisible, never advertised by the public CLI surface. */
export declare const INTERNAL_SUPERVISOR_FLAG = "--internal-rpc-host-supervisor";
/**
 * Returns the internal supervisor payload when argv selects that route.
 *
 * The route dispatches when the sentinel is argv[0] OR is preceded only by
 * known injectable prefix flags and their values - the one perturbation
 * wrappers legitimately perform. Everything else disqualifies it: a positional
 * operand, `--`, or an unknown flag before the sentinel all return undefined,
 * so a user-supplied value that happens to equal the sentinel can never reach
 * the supervisor.
 *
 * The skipped prefix is deliberately NOT forwarded to the host: a wrapper
 * re-injects its own prefix on every re-entry, so the host child receives it
 * from the wrapper rather than twice from here.
 */
export declare function findInternalSupervisorArgs(argv: readonly string[]): readonly string[] | undefined;
/** `--socket <path>` selects the public socket; every other argument is forwarded to the host CLI. */
export declare function parseSupervisorArgs(argv: readonly string[]): SupervisorLaunch | undefined;
export declare const OWNER_WATCH_FD = 3;
export declare function keepOwnerPipe(child: ChildProcess): void;
/**
 * Resolves the host child spawn. Explicit child commands (desktop launchers)
 * are forwarded untouched. The default re-enters the committed CLI entry
 * through the runtime, except in compiled standalone binaries, which always
 * boot their embedded entrypoint and would parse a script path as CLI
 * arguments - there the executable itself is the CLI, so the mode flags are
 * passed directly. Exported for tests.
 */
export declare function resolveHostChildLaunch(launch: SupervisorLaunch, internalSocket: string, compiled?: boolean): {
    command: string;
    args: string[];
};
/**
 * Windows refuses to spawn a `.cmd`/`.bat` without a shell, and Node's
 * `shell: true` concatenates argv without escaping it. Escape each original
 * value before adding the surrounding quotes so `.cmd`/`.bat` launchers survive
 * cmd.exe parsing without double-escaping.
 * Exported for tests.
 */
export declare function spawnableChildLaunch(launch: {
    command: string;
    args: string[];
}, platform?: NodeJS.Platform): {
    command: string;
    args: string[];
    shell: boolean;
};
/**
 * Child stdio slot carrying the supervisor-lifetime pipe. The supervisor holds
 * the write end open and never writes; the kernel closes it when the supervisor
 * dies for ANY reason (SIGKILL, OOM kill, crash), so the host sees EOF on this
 * fd and shuts itself down. Catchable-signal cleanup alone cannot do this.
 */
export declare const HOST_CHILD_WATCH_FD = 3;
export interface HostChildOptions {
    readonly launch: SupervisorLaunch;
    readonly internalSocket: string;
    readonly internal: {
        readonly dir?: string;
        readonly secretPath: string;
    };
    readonly internalSecret?: Buffer;
    readonly internalKey?: Buffer;
    readonly supervisorStart?: {
        readonly time?: string;
        readonly ticks?: string;
    };
    readonly lifetimeFifo?: string;
    readonly daemonDir: string;
    readonly instanceId: string;
    readonly cleanupPaths: readonly string[];
    readonly publicSocket: string;
    /** Give the child the startup pipe and its hand-off (a coordinated start of the engine's own host, senpi#4602). */
    readonly reportsStartup?: boolean;
    /**
     * The adopted engine trust generation's hand-off (`loadHostChildTrustHandOff`), empty when none was adopted. A child
     * that arrives without it imports trust again and re-execs, closing the startup pipe (senpi#6312).
     */
    readonly trustHandOff: Readonly<Record<string, string>>;
}
/**
 * The same hand-off an initial daemon or successor spawn carries (`adoptedEngineTrustHandOff`). Both modules load
 * lazily, keeping the marker writer and its zod schema out of the supervisor's startup graph
 * (`test/supervisor-import-graph.test.ts`): only a supervisor that adopted a generation loads the writer.
 */
export declare function loadHostChildTrustHandOff(): Promise<Record<string, string>>;
/**
 * The variables that bind the host child to this supervisor and its generation. The public socket is
 * passed on every platform: the child stamps it as its sessions' `host_socket`, and a host session
 * without one cannot register a control endpoint, so nothing would drain its gateway deliveries
 * (omo#12486). Exported for tests.
 */
export declare function hostChildEnvironment(options: HostChildOptions, startupHandOff: string | undefined, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
/** Spawns the host child with the environment that binds it to this supervisor and its generation. */
export declare function spawnHostChild(options: HostChildOptions): ChildProcess;
//# sourceMappingURL=host-lifecycle-launch.d.ts.map