MCPcopy
hub / github.com/callstack/agent-device / parseWaitPositionals

Function parseWaitPositionals

src/core/wait-positionals.ts:10–28  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

8 | { kind: 'text'; text: string; timeoutMs: number | null };
9
10export function parseWaitPositionals(args: string[]): WaitParsed | null {
11 const firstArg = args[0];
12 if (firstArg === undefined) return null;
13 const sleepMs = parseTimeout(firstArg);
14 if (sleepMs !== null) return { kind: 'sleep', durationMs: sleepMs };
15 const timeoutMs = parseTimeout(args[args.length - 1]);
16 if (firstArg === 'text') {
17 const text = timeoutMs !== null ? args.slice(1, -1).join(' ') : args.slice(1).join(' ');
18 return { kind: 'text', text: text.trim(), timeoutMs };
19 }
20 if (firstArg.startsWith('@')) return { kind: 'ref', rawRef: firstArg, timeoutMs };
21 const argsWithoutTimeout = timeoutMs !== null ? args.slice(0, -1) : args.slice();
22 const split = splitSelectorFromArgs(argsWithoutTimeout);
23 if (split && split.rest.length === 0 && tryParseSelectorChain(split.selectorExpression)) {
24 return { kind: 'selector', selectorExpression: split.selectorExpression, timeoutMs };
25 }
26 const text = timeoutMs !== null ? args.slice(0, -1).join(' ') : args.join(' ');
27 return { kind: 'text', text: text.trim(), timeoutMs };
28}

Callers 2

dispatchWaitViaRuntimeFunction · 0.90

Calls 4

parseTimeoutFunction · 0.90
splitSelectorFromArgsFunction · 0.90
tryParseSelectorChainFunction · 0.90
startsWithMethod · 0.80

Tested by

no test coverage detected