1/**
2 * Copy for Claude's resume compaction dialog, shared by the server adapter
3 * (which asks the question) and the web client (which recognizes the
4 * question and its "never" answer in resolved user-input activities to
5 * mirror the dismissal). Both sides must agree on these strings, so they
6 * live here: reword the question or the answer label in this file only.
7 */
8export const CLAUDE_RESUME_COMPACTION_NEVER_ANSWER = "Don't ask again";
9
10export function formatClaudeResumeCompactionQuestion(input: {
11 readonly ageMinutes: number;
12 readonly estimatedTokens: number;
13}): string {
14 const ageLabel =
15 input.ageMinutes >= 60
16 ? `${Math.floor(input.ageMinutes / 60)}h ${input.ageMinutes % 60}m`
17 : `${input.ageMinutes}m`;
18 return `This session is ${ageLabel} old and uses ${input.estimatedTokens.toLocaleString("en-US")} tokens. Compact it before continuing?`;
19}
20
21const CLAUDE_RESUME_COMPACTION_QUESTION_PATTERN =
22 /^This session is (?:\d+h \d+m|\d+m) old and uses \d{1,3}(?:,\d{3})* tokens\. Compact it before continuing\?$/u;
23
24export function isClaudeResumeCompactionQuestion(question: string): boolean {
25 return CLAUDE_RESUME_COMPACTION_QUESTION_PATTERN.test(question);
26}