Large paste collapsing for the chat input.
When the user pastes text exceeding a size or line threshold, the full text
is stored off-screen and a compact [Pasted text #N +M lines] placeholder
is inserted into the input box instead. At submission time the placeholder
is expanded back to the original content so the agent receives the full text.
This mirrors the behavior of Claude Code's paste-collapsing system.
Minimum character count for a paste to be collapsed into a placeholder.
Minimum line count (newline-separated) for a paste to be collapsed.
Regex matching [Pasted text #N] or [Pasted text #N +M lines].
Return the number of newline characters in text.
Return whether text should be collapsed into a placeholder.
Collapses when the text exceeds the character threshold or the line threshold.
Format a paste placeholder reference string.
Replace all paste placeholders in text with their full content.
Placeholders whose IDs are not in pasted_contents are left unchanged.
Stored content for a collapsed paste.
The paste's numeric identifier is the key under which this record is stored in the input's paste map, so it is not duplicated on the record.