export { clearRollHeadVerdict, createSessionRollTracker, scanTranscriptHead } from "./session-roll.js"; export type { HeadScan, SessionRollTracker } from "./session-roll.js"; export type SessionLifecycleState = "session_running" | "session_stopped_background_running" | "session_unrecognized" | "session_waiting"; export type PaneLifecycle = { currentSessionId: string | null; paneId: string; processes?: PaneProcessLifecycle[]; rootPid: number; sessionIds: string[]; target: string; }; /** Exact live process inventory rooted at one host-owned pane. This is * machine evidence, not an agent-session inference, so non-agent services can * retain the same PID/start-time/listener authority as agent descendants. */ export type PaneProcessLifecycle = { args?: string; command?: string; listeners?: ProcessListener[]; pgid?: number; pid: number; ppid?: number; processStartTime?: string; }; export type SessionAttentionSignal = "asking" | "errored"; export type DerivationSource = "agent-declared" | "cooperative" | "launch-context" | "process-tree" | "screen-heuristic" | "transcript"; export type DerivationConfidence = "high" | "low"; export type SessionDerivation = { confidence: DerivationConfidence; disagrees?: DerivationSource[]; source: DerivationSource; value: TValue; }; export type CooperativeSignalEvent = "turn-end" | "turn-start"; export type CooperativeSignal = { atMs: number; event: CooperativeSignalEvent; }; export type CooperativeSignalStore = Map; export declare const COOPERATIVE_SIGNAL_TTL_MS = 120000; export declare function createCooperativeSignalStore(): CooperativeSignalStore; export declare function recordCooperativeSignal(store: CooperativeSignalStore, sessionId: string, event: string, nowMs: number): void; export type AttentionUrgency = "now" | "soon" | "whenever"; export type AttentionRequest = { detail?: string; raisedAt: string; reason: string; urgency: AttentionUrgency; }; export type AttentionRequestStore = Map; export declare function createAttentionRequestStore(): AttentionRequestStore; export declare function isAttentionUrgency(value: unknown): value is AttentionUrgency; export declare function recordAttentionRequest(store: AttentionRequestStore, sessionId: string, request: { detail?: string; reason: string; urgency: AttentionUrgency; }, nowMs: number): AttentionRequest; export declare function clearAttentionRequest(store: AttentionRequestStore, sessionId: string): void; export type SessionLifecycle = { sessionId: string; agentSessionId?: string; harness: string; cwd?: string; isControl?: boolean; attachedPaneId: string | null; lastPaneId: string | null; firstSeenAt: string; lastSeenAt: string; state: SessionLifecycleState; derivation: SessionDerivation; signal?: SessionAttentionSignal; mainPid?: number; mainProcessStartTime?: string; backgroundLeaseDir?: string; background: BackgroundWorkItem[]; attentionRequest?: AttentionRequest; }; export type LifecycleSnapshot = { observedAt: string; panes: PaneLifecycle[]; sessions: SessionLifecycle[]; }; export type LifecycleStore = { derivationUnknownCount: number; observeDurationMs: number; panes: Map; sessions: Map; }; export type PaneProcessObservation = { backgroundLeaseDir?: string; contents?: string; controlCwd?: string; isControl?: boolean; paneId: string; target: string; rootPid: number; knownAgentSessionId?: string; }; export type ProcessTreeRow = { pid: number; ppid: number; pgid?: number; stat?: string; command: string; args: string; listeners?: ProcessListener[]; processStartTime?: string; }; export type ProcessListener = { address: string; port: number; }; export type BackgroundWorkItem = { args?: string; command?: string; description?: string; listeners?: ProcessListener[]; pid: number; ppid?: number; pgid?: number; processStartTime?: string; source: "descendant" | "explicit-lease" | "leased-descendant"; }; type BackgroundLeaseFile = { args?: unknown; command?: unknown; description?: unknown; pid?: unknown; processStartTime?: unknown; }; export declare function snapshotProcessTreeAsync(rootPids?: number[], options?: { additionalPids?: number[]; includeListeners?: boolean; }): Promise>; export declare function snapshotProcessTree(rootPids?: number[]): Map; export declare function snapshotDescendantPids(rootPids: number[]): number[]; export declare function createLifecycleStore(): LifecycleStore; export type ObserveIo = { cooperativeSignals?: CooperativeSignalStore; leasesByDir: Map; sessionRolls?: Map; sessionRollClaims?: ReadonlyMap; startTimes: Map; }; export declare function gatherLifecycleObservation(panes: PaneProcessObservation[], store: LifecycleStore, rollTracker?: { gather(sessionIds: string[], detectedIdsByPane?: ReadonlyMap): Promise>; }): Promise<{ leasesByDir: ObserveIo["leasesByDir"]; processRows: Map; sessionRolls?: Map; startTimes: Map; }>; export declare function observeLifecycle(options: { io?: ObserveIo; now?: Date; panes: PaneProcessObservation[]; processRows: Map; store?: LifecycleStore; }): LifecycleSnapshot; export declare function classifyAttentionSignal(contents?: string): SessionAttentionSignal | undefined; export declare const DERIVATION_DEGRADED_LOG_TAG = "[substrate:lifecycle.derivation-degraded]"; export declare function gatherProcessStartTimes(): Promise>; export declare function gatherBackgroundLeases(dirs: Array): Promise>;