/**
 * Claude In-Flight Hook command — internal handler for the workflow's
 * `SubagentStart` / `SubagentStop` / `TeammateIdle` hooks.
 *
 * Invoked as:
 *   atomic _claude-inflight-hook start   (SubagentStart)
 *   atomic _claude-inflight-hook stop    (SubagentStop)
 *   atomic _claude-inflight-hook wait    (TeammateIdle)
 *
 * `start` / `stop` maintain a directory of one marker file per in-flight
 * subagent under `~/.atomic/claude-inflight/<root_session_id>/<agent_id>`.
 * `<root_session_id>` is the stage's top-level Claude session — for nested
 * subagents (a subagent spawning its own subagent) we resolve the root by
 * looking up the parent session's mapping, so all descendants of a stage
 * funnel into the same marker dir.
 *
 * `wait` is the focused completion-signal handler used for `TeammateIdle`:
 * read `session_id` from the payload, await `waitForInflightDrained`, exit
 * 0. We don't reuse the Stop hook handler here because Stop also writes
 * `~/.atomic/claude-stop/<session_id>` (which the runtime's `waitForIdle`
 * watches) and polls queue/release — those are tied to the stage's root
 * session, and TeammateIdle's `session_id` may be a teammate's session
 * that the runtime never enqueues to or releases.
 *
 * Two consumers gate on the in-flight dir being empty:
 *
 *   1. `claudeStopHookCommand` — won't consume the `claude-release` marker
 *      until in-flight is empty, so Claude itself doesn't exit while
 *      backgrounded subagents are still running.
 *
 *   2. `clearClaudeSession` — calls `waitForInflightDrained` before tearing
 *      down the pane, so the executor doesn't advance to the next stage
 *      while the previous stage's subagents still hold FDs/PTYs on the
 *      atomic tmux server.
 *
 * Always exits 0 — a non-zero exit would surface as a hook error in
 * Claude's transcript, and silent miss + stale-sweep recovery is preferable
 * to red noise on every workflow run.
 */
/**
 * Shape of the JSON payload Claude pipes to the Subagent / TeammateIdle
 * lifecycle hooks via stdin.
 *
 *   SubagentStart / SubagentStop  → `agent_id` (uuid), `agent_type`
 *   TeammateIdle                  → `session_id` only (used by `wait` mode)
 *
 * `session_id` is the parent Claude session that triggered the event — for
 * a top-level subagent, that's the stage's root; for a nested subagent,
 * that's the spawning agent's session, and we look up its root via
 * `inflightRoots`.
 *
 * Extra fields are ignored; missing ones cause a graceful exit-0 no-op.
 */
export interface ClaudeInflightHookPayload {
    session_id: string;
    hook_event_name?: string;
    agent_id?: string;
    agent_type?: string;
    cwd?: string;
}
export type ClaudeInflightHookMode = "start" | "stop" | "wait";
/**
 * Handler for the hidden `_claude-inflight-hook` subcommand.
 *
 * Always returns 0 — silently swallows all errors. A buggy tracker must
 * never kill stages.
 */
export declare function claudeInflightHookCommand(mode: ClaudeInflightHookMode): Promise<number>;
/** True when the per-root marker dir is missing or contains no marker files. */
export declare function inflightDirIsEmpty(rootSessionId: string): Promise<boolean>;
/**
 * Remove markers older than `thresholdMs` (default `ATOMIC_INFLIGHT_STALE_MS`
 * or 2 h). Returns the number of markers reaped. Used by the Stop hook and
 * `waitForInflightDrained` to recover from subagents that crashed without
 * firing `SubagentStop`.
 */
export declare function sweepStaleInflight(rootSessionId: string, thresholdMs?: number): Promise<number>;
export interface WaitForInflightOptions {
    /** How long to wait before giving up. Default 30 minutes. */
    timeoutMs?: number;
    /** Poll cadence. Default 100 ms. */
    pollIntervalMs?: number;
    /** Stale-marker TTL. Default `ATOMIC_INFLIGHT_STALE_MS` or 2 h. */
    staleMs?: number;
}
/**
 * Resolve when the per-root marker dir is empty. Sweeps stale markers on
 * every tick. Resolves silently on timeout — the caller can't usefully
 * recover, so wedging vs. leaking is the only trade.
 */
export declare function waitForInflightDrained(rootSessionId: string, options?: WaitForInflightOptions): Promise<void>;
/**
 * Remove the per-root marker dir and any roots-mapping entries that point
 * at this root. Called by `clearClaudeSession` on stage teardown so
 * leftovers cannot bleed into a future session that reuses the same id
 * (UUID collision is astronomically unlikely, but stale-sweep + cleanup
 * costs nothing).
 */
export declare function clearInflightTracking(rootSessionId: string): Promise<void>;
//# sourceMappingURL=claude-inflight-hook.d.ts.map