MCPcopy Create free account
hub / github.com/different-ai/opencode-browser / waitForCount

Function waitForCount

src/agent-backend.ts:520–537  ·  view source on GitHub ↗
(
    selector: string,
    minimum: number,
    timeoutMs: number,
    pollMs: number
  )

Source from the content-addressed store, hash-verified

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;

Callers 1

agentQueryFunction · 0.85

Calls 2

agentCommandFunction · 0.85
sleepFunction · 0.70

Tested by

no test coverage detected