MCPcopy Index your code
hub / github.com/callstack/agent-device / toWaitTarget

Function toWaitTarget

src/daemon/selector-runtime.ts:470–487  ·  view source on GitHub ↗
(parsed: WaitParsed, session: SessionState | undefined)

Source from the content-addressed store, hash-verified

468}
469
470function toWaitTarget(parsed: WaitParsed, session: SessionState | undefined) {
471 if (parsed.kind === 'sleep') return { kind: 'sleep' as const, durationMs: parsed.durationMs };
472 if (parsed.kind === 'selector') {
473 return {
474 kind: 'selector' as const,
475 selector: parsed.selectorExpression,
476 timeoutMs: parsed.timeoutMs,
477 };
478 }
479 if (parsed.kind === 'ref') {
480 if (!session?.snapshot) {
481 throw new AppError('INVALID_ARGS', 'Ref wait requires an existing snapshot in session.');
482 }
483 return { kind: 'ref' as const, ref: parsed.rawRef, timeoutMs: parsed.timeoutMs };
484 }
485 if (!parsed.text) throw new AppError('INVALID_ARGS', 'wait requires text');
486 return { kind: 'text' as const, text: parsed.text, timeoutMs: parsed.timeoutMs };
487}
488
489async function toDaemonResponse(
490 task: () => Promise<Record<string, unknown>>,

Callers 1

executeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected