( finalResponse: string, isHeadless: boolean, silent?: boolean, format?: "json", )
| 195 | |
| 196 | // Helper function to process and output response in headless mode |
| 197 | function processAndOutputResponse( |
| 198 | finalResponse: string, |
| 199 | isHeadless: boolean, |
| 200 | silent?: boolean, |
| 201 | format?: "json", |
| 202 | ): void { |
| 203 | if (isHeadless && finalResponse && finalResponse.trim()) { |
| 204 | let processedResponse = finalResponse; |
| 205 | |
| 206 | // Strip think tags if --silent flag is enabled |
| 207 | if (silent) { |
| 208 | processedResponse = stripThinkTags(processedResponse); |
| 209 | } |
| 210 | |
| 211 | // Process output based on format |
| 212 | const outputResponse = |
| 213 | format === "json" |
| 214 | ? processJsonOutput(processedResponse) |
| 215 | : processedResponse; |
| 216 | |
| 217 | safeStdout(outputResponse + "\n"); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | // Helper function to handle auto-compaction for headless mode |
| 222 | async function handleAutoCompaction( |
no test coverage detected