Build a user-facing failure message. Deliberately does NOT inline the * prompt — see EngineInvocationError for why.
( engineName: string, reason: 'timeout' | 'maxbuffer' | 'exit' | 'spawn', stderr: string, code: number | null, signal: NodeJS.Signals | null, timeoutMs: number, )
| 319 | /** Build a user-facing failure message. Deliberately does NOT inline the |
| 320 | * prompt — see EngineInvocationError for why. */ |
| 321 | function buildMessage( |
| 322 | engineName: string, |
| 323 | reason: 'timeout' | 'maxbuffer' | 'exit' | 'spawn', |
| 324 | stderr: string, |
| 325 | code: number | null, |
| 326 | signal: NodeJS.Signals | null, |
| 327 | timeoutMs: number, |
| 328 | ): string { |
| 329 | const stderrSnippet = stderr.trim().slice(-500); |
| 330 | const detail = stderrSnippet ? ` \u2014 ${stderrSnippet}` : ''; |
| 331 | switch (reason) { |
| 332 | case 'timeout': { |
| 333 | const duration = timeoutMs < 1000 ? `${timeoutMs}ms` : `${Math.round(timeoutMs / 1000)}s`; |
| 334 | return `${engineName} timed out after ${duration}${detail}`; |
| 335 | } |
| 336 | case 'maxbuffer': |
| 337 | return `${engineName} output exceeded buffer cap${detail}`; |
| 338 | case 'spawn': |
| 339 | return `${engineName} failed to start${detail}`; |
| 340 | case 'exit': |
| 341 | default: { |
| 342 | const signalPart = signal ? ` (signal ${signal})` : ''; |
| 343 | const codePart = code !== null ? ` exit ${code}` : ''; |
| 344 | return `${engineName} failed${codePart}${signalPart}${detail}`; |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * Synchronous engine call — uses `spawnSync` with `input: ''` so the child's |
no outgoing calls
no test coverage detected