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

Function waitCommand

src/commands/interaction/runtime/selector-read.ts:350–379  ·  view source on GitHub ↗
(
  runtime,
  options,
)

Source from the content-addressed store, hash-verified

348 });
349
350export const waitCommand: RuntimeCommand<WaitCommandOptions, WaitCommandResult> = async (
351 runtime,
352 options,
353): Promise<WaitCommandResult> => {
354 if (options.target.kind === 'sleep') {
355 await sleep(runtime, options.target.durationMs);
356 return { kind: 'sleep', waitedMs: options.target.durationMs };
357 }
358 if (options.target.kind === 'ref') {
359 const capture = await requireSnapshotSession(runtime, options.session);
360 const ref = normalizeRef(options.target.ref);
361 if (!ref) throw new AppError('INVALID_ARGS', `Invalid ref: ${options.target.ref}`);
362 const node = findNodeByRef(capture.snapshot.nodes, ref);
363 const text = node ? resolveRefLabel(node, capture.snapshot.nodes) : undefined;
364 if (!text) {
365 throw new AppError('COMMAND_FAILED', `Ref ${options.target.ref} not found or has no label`);
366 }
367 return await waitForText(runtime, options, text, options.target.timeoutMs);
368 }
369 if (options.target.kind === 'selector') {
370 return await waitForSelector(
371 runtime,
372 options,
373 options.target.selector,
374 options.target.timeoutMs,
375 );
376 }
377 if (!options.target.text) throw new AppError('INVALID_ARGS', 'wait requires text');
378 return await waitForText(runtime, options, options.target.text, options.target.timeoutMs);
379};
380
381export const waitForTextCommand: RuntimeCommand<
382 WaitForTextCommandOptions,

Callers 1

waitForTextCommandFunction · 0.85

Calls 7

sleepFunction · 0.90
requireSnapshotSessionFunction · 0.90
normalizeRefFunction · 0.90
findNodeByRefFunction · 0.90
resolveRefLabelFunction · 0.90
waitForTextFunction · 0.85
waitForSelectorFunction · 0.85

Tested by

no test coverage detected