| 5387 | }; |
| 5388 | |
| 5389 | const startReportTimeout = () => { |
| 5390 | if (timeout) return; |
| 5391 | notifyExecutionStarted(); |
| 5392 | timeout = setTimeout(() => { |
| 5393 | // Prefer a persisted terminal failure over a generic timeout so late |
| 5394 | // awaits surface the typed failure (e.g. model_refusal) even when the |
| 5395 | // live rejection was missed (restart/cleanup windows). |
| 5396 | void (async () => { |
| 5397 | const persistedFailure = await tryReadPersistedFailureError().catch(() => null); |
| 5398 | entry.cleanup(); |
| 5399 | reject(persistedFailure ?? new AgentReportWaitTimeoutError()); |
| 5400 | })(); |
| 5401 | }, timeoutMs); |
| 5402 | }; |
| 5403 | |
| 5404 | const cleanupStartWaiter = () => { |
| 5405 | if (!startWaiter) return; |