import type { HarnessRegistry } from "#src/harness/registry"; import { type TmuxManager } from "#src/tmux-manager"; import type { SubagentRecord } from "#src/types"; export interface TeardownOutcome { agentId: string; killedWindow: boolean; killedSession: boolean; killedProcess: boolean; /** Owned runtime dir (new-layout records) recursively removed. */ removedRuntimeDir: boolean; /** Separately-rooted owned sandbox TMPDIR removed. */ removedSandboxTempDir: boolean; removedConfigDir: boolean; removedTempFiles: number; removedWorktree: boolean; errors: string[]; } /** * Parse a `recoveryId` of the form `:` into its * parts. `sessionName` may itself contain colons, so split on the LAST colon. */ export declare function parseRecoveryId(recoveryId: string | undefined): { sessionName: string; windowIndex: number; } | undefined; /** * Physically tear down a single subagent's resources. Best-effort and * idempotent: anything already gone is simply skipped. Never throws — all * failures are collected into `outcome.errors`. */ export declare function teardownSubagent(record: SubagentRecord, tmux: TmuxManager, harnessRegistry?: HarnessRegistry): TeardownOutcome; /** * Result of the shared window-liveness check. `"unknown"` means the record's * window could not be verified (missing/malformed recoveryId or a tmux * error) — callers decide how conservative to be with it. */ export type WindowLiveness = "alive" | "dead" | "unknown"; /** * THE single window-liveness primitive: is the tmux window recorded for this * subagent still present? Shared by GC's zombie detection (`isReapable`) and * the `StartupReconciler`, so both always agree on what "alive" means. * * When the record has a persisted `windowId`, liveness requires the stable * ID AND the re-derived window name to agree (design D5): a stored ID that * now matches a DIFFERENTLY-named window (e.g. after a tmux server restart * reassigns IDs to new, unrelated windows) is reported dead, never treated * as proof of liveness. Legacy records with no persisted `windowId` fall * back to the name-only existence check. * * `tmux` must be the instance reaching the RECORD's server — resolve it via * `tmuxForRecord(record, parentTmux)`. An unreachable socket (server exited, * socket file gone) surfaces as a failed lookup and reads as "dead". */ export declare function subagentWindowLiveness(record: SubagentRecord, tmux: TmuxManager): WindowLiveness; /** * Decide whether a record is garbage — eligible for a GC sweep. * * Reaps any terminal-state record, PLUS a record still marked `running` whose * tmux window is actually gone (a zombie from a previous process). A genuinely * live `running` agent (window present) is never reaped, and neither is an * unverifiable one (GC stays conservative on "unknown"). */ export declare function isReapable(record: SubagentRecord, tmux: TmuxManager): boolean; //# sourceMappingURL=subagent-teardown.d.ts.map