/** * Session Lifecycle Manager for oh-my-codex * * Tracks session start/end, detects stale sessions from crashed launches, * and provides structured logging for session events. */ export interface SessionState { session_id: string; native_session_id?: string; previous_native_session_id?: string; native_session_switched_at?: string; owner_omx_session_id?: string; started_at: string; cwd: string; pid: number; platform?: NodeJS.Platform; pid_start_ticks?: number; pid_cmdline?: string; tmux_session_name?: string; } /** * Reset session-scoped HUD/metrics files at launch so stale values do not leak * into a new Codex session. */ export declare function resetSessionMetrics(cwd: string, sessionId?: string): Promise; /** * Read current session state. Returns null if no session file exists. */ export declare function readSessionState(cwd: string): Promise; export declare function isSessionStateAuthoritativeForCwd(state: SessionState, cwd: string): boolean; export declare function isSessionStateUsable(state: SessionState, cwd: string, options?: SessionStaleCheckOptions): boolean; export declare function readUsableSessionState(cwd: string, options?: SessionStaleCheckOptions): Promise; interface LinuxProcessIdentity { startTicks: number; cmdline: string | null; } interface SessionStaleCheckOptions { platform?: NodeJS.Platform; isPidAlive?: (pid: number) => boolean; readLinuxIdentity?: (pid: number) => LinuxProcessIdentity | null; } interface SessionStartOptions { pid?: number; platform?: NodeJS.Platform; nativeSessionId?: string; previousNativeSessionId?: string; nativeSessionSwitchedAt?: string; ownerOmxSessionId?: string; tmuxSessionName?: string; } /** * Check if a session is stale. * - If the owning PID is dead, it is stale. * - On Linux, require process identity validation (start ticks, optional cmdline). * If identity cannot be validated, treat the session as stale. */ export declare function isSessionStale(state: SessionState, options?: SessionStaleCheckOptions): boolean; /** * Write session start state. */ export declare function writeSessionStart(cwd: string, sessionId: string, options?: SessionStartOptions): Promise; /** * Reconcile a native/Codex SessionStart with the canonical OMX launch session. * Same-native restarts preserve the current logical session and refresh * PID/native metadata. Native-session replacements start a fresh native-scoped * session to avoid inheriting stale task-scoped state; when the replaced session * belongs to an OMX launch wrapper, retain that wrapper as owner for later * archive/cleanup and log the replacement chain. */ export declare function reconcileNativeSessionStart(cwd: string, nativeSessionId: string, options?: SessionStartOptions): Promise; /** * Write session end: archive to history, delete session.json. */ export declare function writeSessionEnd(cwd: string, sessionId: string): Promise; /** * Append a structured JSONL entry to the daily log file. */ export declare function appendToLog(cwd: string, entry: Record): Promise; export {}; //# sourceMappingURL=session.d.ts.map