|
1 | 1 | import { z } from 'zod';
|
2 |
| -// import type { ToolSchema, ToolResult } from "./tool.js"; |
3 |
| -// import type { Context } from '../context.js'; |
4 |
| -// import type { ToolActionResult } from '../context.js'; |
5 | 2 | import { defineTool, type ToolFactory } from './tool.js';
|
6 | 3 |
|
7 |
| -// --- Tool: Press Key --- |
8 |
| -// const PressKeyInputSchema = z.object({ |
9 |
| -// key: z.string().describe("Key to press (e.g., 'Enter', 'Tab', 'a', 'Shift+A')"), |
10 |
| -// selector: z.string().optional().describe("Optional CSS selector for target element"), |
11 |
| -// sessionId: z.string().optional(), |
12 |
| -// }); |
13 |
| -// type PressKeyInput = z.infer<typeof PressKeyInputSchema>; |
14 |
| - |
15 |
| -// const pressKeySchema: ToolSchema<typeof PressKeyInputSchema> = { |
16 |
| -// name: "browserbase_press_key", |
17 |
| -// description: "Press a specific key on a selected element or globally.", |
18 |
| -// inputSchema: PressKeyInputSchema, |
19 |
| -// }; |
20 |
| - |
21 |
| -// // Handle function for PressKey |
22 |
| -// async function handlePressKey(context: Context, params: PressKeyInput): Promise<ToolResult> { |
23 |
| -// const action = async (): Promise<ToolActionResult> => { |
24 |
| -// const page = await context.getActivePage(); |
25 |
| -// if (!page) { |
26 |
| -// throw new Error('No active page found for pressKey'); |
27 |
| -// } |
28 |
| -// try { |
29 |
| -// if (params.selector) { |
30 |
| -// await page.press(params.selector, params.key, { timeout: 10000 }); |
31 |
| -// } else { |
32 |
| -// await page.keyboard.press(params.key); |
33 |
| -// } |
34 |
| -// return { content: [{ type: 'text', text: `Pressed key: ${params.key}${params.selector ? ' on ' + params.selector : ' globally'}` }] }; |
35 |
| -// } catch (error) { |
36 |
| -// console.error(`PressKey action failed: ${error}`); |
37 |
| -// throw error; // Rethrow |
38 |
| -// } |
39 |
| -// }; |
40 |
| - |
41 |
| -// return { |
42 |
| -// action, |
43 |
| -// code: [], // Add code property |
44 |
| -// captureSnapshot: true, // Pressing key might change state |
45 |
| -// waitForNetwork: true, // Pressing key might trigger navigation/requests |
46 |
| -// }; |
47 |
| -// } |
48 |
| - |
49 | 4 | const pressKey: ToolFactory = captureSnapshot => defineTool({
|
50 | 5 | capability: 'core',
|
51 | 6 |
|
@@ -73,8 +28,8 @@ const pressKey: ToolFactory = captureSnapshot => defineTool({
|
73 | 28 | return {
|
74 | 29 | code,
|
75 | 30 | action,
|
76 |
| - captureSnapshot, // Passed from factory |
77 |
| - waitForNetwork: true // Kept from user's code |
| 31 | + captureSnapshot, |
| 32 | + waitForNetwork: true |
78 | 33 | };
|
79 | 34 | },
|
80 | 35 | });
|
|
0 commit comments