MCPcopy Create free account
hub / github.com/anomalyco/opencode / pollUntil

Function pollUntil

packages/opencode/test/acp/event.test.ts:20–31  ·  view source on GitHub ↗
(
  check: () => boolean | Promise<boolean>,
  message: string,
  opts?: { timeoutMs?: number; intervalMs?: number },
)

Source from the content-addressed store, hash-verified

18type DeltaPartType = Extract<Part, { type: "text" | "reasoning" }>["type"]
19
20const pollUntil = async (
21 check: () => boolean | Promise<boolean>,
22 message: string,
23 opts?: { timeoutMs?: number; intervalMs?: number },
24) => {
25 const started = Date.now()
26 while (true) {
27 if (await check()) return
28 if (Date.now() - started > (opts?.timeoutMs ?? 2000)) throw new Error(message)
29 await new Promise((resolve) => setTimeout(resolve, opts?.intervalMs ?? 5))
30 }
31}
32
33function makeSessionService() {
34 return ManagedRuntime.make(LayerNode.compile(ACPSession.node)).runSync(

Callers 1

event.test.tsFile · 0.70

Calls 1

checkFunction · 0.50

Tested by

no test coverage detected