/** * v0.3.0 — read Claude Code's own session jsonl files. * * Used by workflow-reconciler.ts when the bot crashed after a PM message * was processed (claude wrote the assistant reply to its jsonl) but * before the messenger pipe got to deliver it. We re-emit the most * recent assistant turn so the user sees the reply on bot restart. * * Couples us to Claude Code's internal jsonl format — keep it defensive. * Every helper here returns null on any parse/structure miss instead of * throwing. * * Per docs/plan/v0.3-pm-mode-orchestration.md §3.2 + RECOVERY-AND-TEST-DESIGN.md §3.4. */ export interface AssistantTurn { text: string; /** Claude Code's per-message uuid (different from session_id). */ uuid?: string; /** ISO timestamp from the jsonl line (or null if absent). */ timestamp?: string; /** "end_turn", "tool_use", "max_tokens", etc. */ stopReason?: string | null; } /** * Encode a working-directory the same way Claude Code does when it picks * the project subdirectory under `~/.claude/projects/`. * * Empirically: drive colons collapse, slashes become "-", leading dashes * are not stripped (observed `C--Users-...` on Windows). */ export declare function encodeCwdForClaudeCode(cwd: string): string; export declare function sessionJsonlPath(cwd: string, sessionId: string): string; /** * Return the last `{type:"assistant", message:{role:"assistant", content:[{type:"text"}…]}}` * line in the given session jsonl. Returns null if the file is missing, * unparseable, or has no usable assistant turn. */ export declare function readLastAssistantTurn(jsonlPath: string): AssistantTurn | null; /** * Quick "does this jsonl belong to a still-recoverable session" check. * Returns the timestamp of the latest line or null. */ export declare function readLatestTimestamp(jsonlPath: string): string | null;