• Trim a JSONL session file: strip bloat, keep conversation.

    Rules:

    1. Pre-compaction content → skip entirely (dead weight), unless the boundary preserves earlier messages
    2. file-history-snapshot entries → skip entirely
    3. queue-operation entries → skip entirely
    4. Image blocks in tool results → strip always
    5. tool_result content > threshold → stub with summary
    6. tool_use input for write ops (+ broad fallback) → stub large fields
    7. thinking blocks → remove entirely (signature is required by API)
    8. API usage metadata → strip
    9. Everything else → preserved verbatim

    Rows left with no content (e.g. a thinking-only assistant row) are dropped and their children re-linked to the nearest kept ancestor, so the parentUuid chain Claude Code walks on resume stays unbroken.

    Parameters

    • sourcePath: string
    • destPath: string
    • options: TrimOptions = {}

    Returns Promise<TrimMetrics>