/** * Daemon management * * Tracks running daemon tunnels via a state file at ~/.otterkit/daemons.json. * Supports spawning detached child processes that survive terminal close, * and auto-expire based on TTL. */ export interface DaemonEntry { pid: number; subdomain: string; publicUrl: string; connectUrl: string; port: number; host: string; ttl: string; startedAt: string; expiresAt: string; capture?: boolean; /** Basic auth is enabled. Credentials live only in the worker process env. */ auth?: boolean; /** Local delivery is armed. The target/command live only in the worker env. */ deliver?: boolean; /** Interactive terminal session (not a daemon) - registered so `status` * and the Mac app see it; the entry dies with the process. */ foreground?: boolean; /** Config profile name this daemon was started from (`otterkit up`). */ profile?: string; /** * Who started the session: the MCP server ('agent'), the Mac app ('app'), * or a person at a shell ('terminal'). From OTTERKIT_ORIGIN; see daemonOrigin. */ origin?: 'agent' | 'terminal' | 'app'; /** * Set for `otterkit mcp publish` sessions: the server's name, its full link * (the key in the path is the access control, so treat it like a secret), * and the log file a background session writes to. */ mcp?: { name: string; endpoint: string; logPath?: string; }; /** * Session archive: set when the session ends (stopped, expired, or the * owning process died). Ended entries and their capture logs are kept for * inspection/replay until the retention sweep prunes them. */ endedAt?: string; } /** * Session origin for a new registry entry. The MCP server and the Mac app * set OTTERKIT_ORIGIN (inherited by spawned workers); anything else is a * person at a terminal. */ export declare function daemonOrigin(): 'agent' | 'terminal' | 'app'; export declare function addDaemon(entry: DaemonEntry): void; /** * A session ended (stopped, expired, or its process died): archive the entry * instead of deleting it, keeping the capture log for inspection/replay. * The retention sweep in cleanupDaemons prunes old archives. */ export declare function removeDaemon(subdomain: string): void; /** * Check if a process is still running */ export declare function isProcessAlive(pid: number): boolean; /** * Reconcile the registry: archive sessions that ended, prune old archives * (and their capture logs) past retention. Returns the ACTIVE entries - * callers that manage running sessions keep their old semantics; ended * entries stay in the file for `status`, the Mac app, and inspection. */ export declare function cleanupDaemons(): DaemonEntry[]; /** * Parse an auto-stop TTL string to milliseconds; "never" (run until stopped) * returns null. TTL is a safety auto-stop, not a price - billing is per * connected hour. */ export declare function parseTtlMs(ttl: string): number | null;