* Uses the opencode.ai zen API with gpt-5-nano for fast, lightweight summarization.
* Used by all TTS implementations (Browser, Say, OpenAI).
*/
functionbuildSummarizationPrompt(maxLength){
return`You are a text summarizer for text-to-speech output. Create a concise, natural-sounding summary that captures the key points. Keep the summary under ${maxLength} characters.
CRITICAL INSTRUCTIONS:
1. Output ONLY the final summary - no thinking, no reasoning, no explanations
2. Do not show your work or thought process
3. Do not use any special characters, markdown, code, URLs, file paths, or formatting
4. Do not include phrases like "Here's a summary" or "In summary"
5. Just provide clean, speakable text that can be read aloud
6. Stay within the ${maxLength} character limit
Your response should be ready to speak immediately.`;
}
constSUMMARIZE_TIMEOUT_MS=30_000;
/**
* Sanitize text for TTS output
* Removes markdown, URLs, file paths, and other non-speakable content
*/
exportfunctionsanitizeForTTS(text){
if(!text||typeoftext!=='string')return'';
returntext
// Remove markdown formatting
.replace(/[*_~`#]/g,'')
// Remove code blocks
.replace(/```[\s\S]*?```/g,'')
.replace(/`[^`]*`/g,'')
// Remove shell-like command patterns
.replace(/^\s*[$#>]\s*/gm,'')
// Remove common shell operators
.replace(/[|&;<>]/g,' ')
// Remove backslashes (escape characters)
.replace(/\\/g,'')
// Remove brackets that might be interpreted specially