MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / execute

Method execute

src/tools/browser/tools.ts:321–345  ·  view source on GitHub ↗
(args: z.infer<typeof WaitForArgs>, _ctx: ToolContext)

Source from the content-addressed store, hash-verified

319 argsSchema = WaitForArgs;
320
321 async execute(args: z.infer<typeof WaitForArgs>, _ctx: ToolContext): Promise<ToolResult> {
322 try {
323 const s = await getSession();
324 const timeout = args.timeout_ms ?? 10_000;
325 if (args.kind === 'selector') {
326 if (!args.value) return { content: '[BROWSER_ERROR] selector kind requires `value`', isError: true };
327 await s.page.waitForSelector(args.value, { timeout });
328 return { content: `Selector visible: ${args.value}` };
329 } else if (args.kind === 'url') {
330 if (!args.value) return { content: '[BROWSER_ERROR] url kind requires `value`', isError: true };
331 await s.page.waitForURL(args.value, { timeout });
332 return { content: `URL matched: ${s.page.url()}` };
333 } else if (args.kind === 'networkidle') {
334 await s.page.waitForLoadState('networkidle', { timeout });
335 return { content: 'Network idle reached' };
336 } else if (args.kind === 'function') {
337 if (!args.value) return { content: '[BROWSER_ERROR] function kind requires `value`', isError: true };
338 await s.page.waitForFunction(args.value, undefined, { timeout });
339 return { content: `Predicate satisfied: ${args.value.slice(0, 80)}` };
340 }
341 return { content: '[BROWSER_ERROR] unknown wait kind', isError: true };
342 } catch (e: any) {
343 return { content: `[BROWSER_ERROR] wait_for failed: ${e?.message ?? String(e)}`, isError: true };
344 }
345 }
346}
347
348const CloseArgs = z.object({});

Callers

nothing calls this directly

Calls 1

getSessionFunction · 0.85

Tested by

no test coverage detected