/** * Persistent loopsy_session_id → claude_session_id map. * * Why this exists: the user-facing "session" lives in the loopsy * SessionMeta on the phone and the PTY id on the daemon. The Claude CLI * inside the PTY generates its own session id (the JSONL filename under * ~/.claude/projects). Without persistence: * - When the daemon's PTY is reaped (idle timeout, daemon restart), * reattaching from the phone spawns a brand-new `claude` instance * with a fresh session id and an empty conversation. * - The user loses their chat history every time the daemon bounces, * even though the JSONL files are still on disk. * * With persistence: * - First spawn: watch ~/.claude/projects// for the JSONL Claude * creates immediately after launch (birthtime within ±10s of PTY * spawn). Save loopsy_session_id → claude_session_id to disk. * - Respawn: look up the prior claude_session_id and prepend * `--resume ` so the user's conversation continues. * * State file: ~/.loopsy/claude-sessions.json. Tiny JSON object, atomic * write, in-memory cache. Survives daemon restarts. */ /** * Look up the Claude session-id we previously discovered for this loopsy * session. Returns null if we haven't seen this session before, or if * the JSONL file referenced no longer exists on disk (Claude rotated it * away, user manually deleted, etc.) — in either case the caller should * spawn fresh rather than risk a `--resume` against a stale id. */ export declare function getClaudeSessionForLoopsy(loopsyId: string): Promise; /** * Record a discovered mapping. Called once per (loopsy session, Claude * session) pair — typically right after the first JSONL appears * following a fresh PTY spawn. */ export declare function rememberClaudeSession(loopsyId: string, claudeSessionId: string, cwd: string): Promise; /** * Poll the project dir for a JSONL whose birthtime is within ±10s of the * PTY spawn time, and remember the mapping. Times out after 30s. Safe to * run as fire-and-forget — on success it updates the persistent map; on * failure it just logs and gives up. * * Why a poll loop rather than fs.watch: macOS' fs.watch can miss events * on first-create depending on the parent dir watcher state, and the * grace window is short enough that a 500ms poll is dirt-cheap. */ export declare function discoverClaudeSession(opts: { loopsyId: string; cwd: string; spawnedAtMs: number; deadlineMs?: number; }): Promise; //# sourceMappingURL=claude-session-tracker.d.ts.map