/**
 * Remove thinking-token blocks from an LLM response so they don't end up in
 * the visible output or downstream prompts.
 *
 * Supported flavors:
 *   - DeepSeek-R1 / Qwen:  <think>...</think>
 *   - Generic:             <|thinking|>...<|/thinking|>
 *   - Gemma4:              thought\n<channel|>  and  <channel|>...<channel|>
 */
export function stripThinkingTokens(text: string): string {
  return text
    .replace(/<think>[\s\S]*?<\/think>/g, '')
    .replace(/<\|thinking\|>[\s\S]*?<\|\/thinking\|>/g, '')
    .replace(/thought\s*\n?\s*<channel\|>/g, '')
    .replace(/<channel\|>[\s\S]*?<channel\|>/g, '')
    .trim();
}
