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

Function findCommand

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

Source from the content-addressed store, hash-verified

145const POLL_INTERVAL_MS = 300;
146
147export const findCommand: RuntimeCommand<FindReadCommandOptions, FindReadCommandResult> = async (
148 runtime,
149 options,
150): Promise<FindReadCommandResult> => {
151 const locator = options.locator ?? 'any';
152 if (!options.query) {
153 throw new AppError('INVALID_ARGS', 'find requires a value');
154 }
155 if (options.action === 'wait') {
156 return await waitForFindMatch(runtime, options, locator);
157 }
158
159 const { capture, match } = await findFirstLocatorMatch(runtime, options, locator);
160 if (!match) {
161 throw new AppError('COMMAND_FAILED', 'find did not match any element');
162 }
163
164 if (options.action === 'exists') return { kind: 'found', found: true };
165 const ref = `@${match.ref}`;
166 if (options.action === 'get_attrs') return { kind: 'attrs', ref, node: match };
167 const text = await readText(runtime, capture, match);
168 return { kind: 'text', ref, text, node: match };
169};
170
171export const getCommand: RuntimeCommand<GetCommandOptions, GetCommandResult> = async (
172 runtime,

Callers

nothing calls this directly

Calls 3

readTextFunction · 0.90
waitForFindMatchFunction · 0.85
findFirstLocatorMatchFunction · 0.85

Tested by

no test coverage detected