(
selector: string,
minimum: number,
timeoutMs: number,
pollMs: number
)
| 518 | } |
| 519 | |
| 520 | async function waitForCount( |
| 521 | selector: string, |
| 522 | minimum: number, |
| 523 | timeoutMs: number, |
| 524 | pollMs: number |
| 525 | ): Promise<number> { |
| 526 | const timeout = Math.max(0, timeoutMs); |
| 527 | const poll = Math.max(0, pollMs || DEFAULT_POLL_MS); |
| 528 | const start = Date.now(); |
| 529 | |
| 530 | while (true) { |
| 531 | const data = await agentCommand("count", { selector }); |
| 532 | const count = Number(data?.count ?? 0); |
| 533 | if (count >= minimum) return count; |
| 534 | if (!timeout || Date.now() - start >= timeout) return count; |
| 535 | await sleep(poll); |
| 536 | } |
| 537 | } |
| 538 | |
| 539 | async function agentQuery(args: Record<string, any>): Promise<{ content: string }> { |
| 540 | const selector = typeof args.selector === "string" ? args.selector : undefined; |
no test coverage detected