MCPcopy Create free account
hub / github.com/PawanOsman/OpenCursor / waitForShell

Function waitForShell

src/agent/tools/shared.ts:276–286  ·  view source on GitHub ↗
(sh: BgShell, ms: number, pattern?: RegExp)

Source from the content-addressed store, hash-verified

274
275/** Wait until the shell finishes, `pattern` matches its output, or `ms` elapses. */
276export function waitForShell(sh: BgShell, ms: number, pattern?: RegExp): Promise<void> {
277 return new Promise((resolve) => {
278 const deadline = Date.now() + Math.max(0, ms);
279 const tick = () => {
280 sh.pump?.();
281 if (sh.done || (pattern && pattern.test(sh.output)) || Date.now() >= deadline) return resolve();
282 setTimeout(tick, 100);
283 };
284 tick();
285 });
286}
287
288/**
289 * Render a shell's state. Header + footer carry metadata (pid, timings,

Callers 1

shell.tsFile · 0.90

Calls 1

tickFunction · 0.85

Tested by

no test coverage detected