( events: readonly Event[], predicate: (event: Event) => boolean, )
| 704 | }); |
| 705 | |
| 706 | async function waitForEvent( |
| 707 | events: readonly Event[], |
| 708 | predicate: (event: Event) => boolean, |
| 709 | ): Promise<Event> { |
| 710 | const deadline = Date.now() + 1_000; |
| 711 | while (Date.now() < deadline) { |
| 712 | const event = events.find(predicate); |
| 713 | if (event !== undefined) return event; |
| 714 | await delay(10); |
| 715 | } |
| 716 | throw new Error('Timed out waiting for event'); |
| 717 | } |
| 718 | |
| 719 | async function readMainWire(sessionDir: string): Promise<Array<Record<string, unknown>>> { |
| 720 | const raw = await readFile(join(sessionDir, 'agents', 'main', 'wire.jsonl'), 'utf-8'); |
no test coverage detected