2026-03-01 04:01:58 +01:00
|
|
|
/**
|
|
|
|
|
* @fileoverview Session lifecycle audit types
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** Types of session lifecycle events recorded to the audit log */
|
|
|
|
|
export type LifecycleEventType =
|
|
|
|
|
| 'created' // Session object created
|
|
|
|
|
| 'started' // PTY process launched (interactive/shell/prompt)
|
|
|
|
|
| 'exit' // PTY process exited (with exit code)
|
|
|
|
|
| 'deleted' // cleanupSession() called — session removed
|
|
|
|
|
| 'detached' // Server shutdown — PTY left alive in tmux for recovery
|
|
|
|
|
| 'recovered' // Session restored from tmux on server restart
|
|
|
|
|
| 'stale_cleaned' // Removed from state.json by cleanupStaleSessions()
|
|
|
|
|
| 'mux_died' // tmux session died (detected by reconciliation)
|
|
|
|
|
| 'server_started' // Server started (marker for restart detection)
|
2026-03-01 06:05:26 +01:00
|
|
|
| 'server_stopped' // Server shutting down
|
|
|
|
|
| 'qr_auth'; // Device authenticated via QR code scan
|
2026-03-01 04:01:58 +01:00
|
|
|
|
|
|
|
|
/** A single entry in the session lifecycle audit log */
|
|
|
|
|
export interface LifecycleEntry {
|
|
|
|
|
ts: number;
|
|
|
|
|
event: LifecycleEventType;
|
|
|
|
|
sessionId: string;
|
|
|
|
|
name?: string;
|
|
|
|
|
mode?: string;
|
|
|
|
|
reason?: string;
|
|
|
|
|
exitCode?: number | null;
|
|
|
|
|
extra?: Record<string, unknown>;
|
|
|
|
|
}
|