illuma-agents 1.0.18 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,458 @@
1
+ import { z } from 'zod';
2
+ import { tool } from '@langchain/core/tools';
3
+
4
+ /**
5
+ * Browser Automation Tools for Ranger Browser Extension
6
+ *
7
+ * These tools allow the LLM to interact with the browser through the
8
+ * ranger-browser extension. They generate structured actions that are
9
+ * sent to the extension via SSE streaming for execution.
10
+ *
11
+ * The extension handles:
12
+ * - DOM extraction with element indexing
13
+ * - Click, type, hover, scroll actions
14
+ * - Navigation and page context
15
+ * - Visual element highlighting
16
+ */
17
+ // ============================================
18
+ // Tool Schemas
19
+ // ============================================
20
+ /**
21
+ * Enhanced click schema that supports both index-based and coordinate-based clicking
22
+ */
23
+ const BrowserClickSchema = z.object({
24
+ index: z.number().optional().describe('The index of the element to click, as shown in the page context (e.g., [0], [1], [2]). ' +
25
+ 'Use the element index from the interactive elements list provided in the page context. ' +
26
+ 'Either index OR coordinates must be provided.'),
27
+ coordinates: z.object({
28
+ x: z.number().describe('X coordinate in viewport pixels'),
29
+ y: z.number().describe('Y coordinate in viewport pixels'),
30
+ }).optional().describe('Coordinates for clicking elements that lack semantic info (marked with ⚠️). ' +
31
+ 'The coordinates are provided in the element listing as coords:(x,y). ' +
32
+ 'Either index OR coordinates must be provided.'),
33
+ visualDescription: z.string().optional().describe('Description of what the element looks like visually. Used when clicking by appearance ' +
34
+ '(e.g., "blue button in top right corner", "hamburger menu icon")'),
35
+ reason: z.string().optional().describe('Brief explanation of why you are clicking this element (for user transparency)'),
36
+ });
37
+ const BrowserTypeSchema = z.object({
38
+ index: z.number().describe('The index of the input element to type into, as shown in the page context'),
39
+ text: z.string().describe('The text to type into the input field'),
40
+ clear: z.boolean().optional().describe('Whether to clear the existing content before typing (default: false)'),
41
+ pressEnter: z.boolean().optional().describe('Whether to press Enter after typing (useful for search fields, default: false)'),
42
+ });
43
+ const BrowserNavigateSchema = z.object({
44
+ url: z.string().describe('The URL to navigate to. Can be a full URL or a relative path.'),
45
+ reason: z.string().optional().describe('Brief explanation of why you are navigating to this URL'),
46
+ });
47
+ const BrowserScrollSchema = z.object({
48
+ direction: z.enum(['up', 'down', 'left', 'right']).describe('The direction to scroll'),
49
+ amount: z.number().optional().describe('The amount to scroll in pixels (default: 500)'),
50
+ });
51
+ const BrowserExtractSchema = z.object({
52
+ query: z.string().optional().describe('Optional query to filter extracted content. If provided, only content related to the query will be extracted.'),
53
+ selector: z.string().optional().describe('Optional CSS selector to extract content from a specific element'),
54
+ });
55
+ const BrowserHoverSchema = z.object({
56
+ index: z.number().describe('The index of the element to hover over, as shown in the page context'),
57
+ });
58
+ const BrowserWaitSchema = z.object({
59
+ duration: z.number().optional().describe('Duration to wait in milliseconds (default: 1000)'),
60
+ reason: z.string().optional().describe('Why we are waiting (e.g., "for page to load", "for animation to complete")'),
61
+ });
62
+ const BrowserGoBackSchema = z.object({
63
+ reason: z.string().optional().describe('Brief explanation of why you are going back'),
64
+ });
65
+ const BrowserScreenshotSchema = z.object({
66
+ fullPage: z.boolean().optional().describe('Whether to capture the full page or just the viewport (default: viewport only)'),
67
+ reason: z.string().optional().describe('Why you need a screenshot (e.g., "to identify visual elements", "to analyze page layout")'),
68
+ });
69
+ // ============================================
70
+ // Tool Implementations
71
+ // ============================================
72
+ /**
73
+ * Browser click tool - clicks an element by index or coordinates
74
+ * Supports both semantic (index-based) and vision (coordinate-based) clicking
75
+ */
76
+ function createBrowserClickTool() {
77
+ return tool(async ({ index, coordinates, visualDescription, reason }) => {
78
+ // Validate that at least one targeting method is provided
79
+ if (index === undefined && !coordinates) {
80
+ return JSON.stringify({
81
+ type: 'error',
82
+ error: 'Either index or coordinates must be provided to click an element',
83
+ });
84
+ }
85
+ // Return a structured action for the extension to execute
86
+ // The actual execution happens in the browser extension
87
+ return JSON.stringify({
88
+ type: 'browser_action',
89
+ action: {
90
+ type: 'click',
91
+ ...(index !== undefined && { index }),
92
+ ...(coordinates && { coordinates }),
93
+ ...(visualDescription && { visualDescription }),
94
+ reason,
95
+ },
96
+ // Signal that this requires browser execution
97
+ requiresBrowserExecution: true,
98
+ });
99
+ }, {
100
+ name: EBrowserTools.CLICK,
101
+ description: `Click an interactive element on the current page.
102
+
103
+ **Two ways to target elements:**
104
+
105
+ 1. **By index (preferred)**: Use the element's index number from the interactive elements list
106
+ - Format: [index] {semantic role} <tag>text</tag>
107
+ - Example: browser_click({ index: 5 }) to click element [5]
108
+
109
+ 2. **By coordinates (vision fallback)**: For elements marked with ⚠️ that lack semantic info
110
+ - Use the coords:(x,y) shown after the ⚠️ marker
111
+ - Example: browser_click({ coordinates: { x: 150, y: 200 } })
112
+
113
+ **When to use coordinates:**
114
+ - Elements marked with ⚠️ have poor semantic understanding
115
+ - Icon-only buttons without labels
116
+ - Custom canvas/SVG elements
117
+ - When you identify an element visually in a screenshot
118
+
119
+ Example: If element shows \`[12] {button} <div>⚠️ [left side, small, clickable] coords:(45,120)\`
120
+ Use either: browser_click({ index: 12 }) or browser_click({ coordinates: { x: 45, y: 120 } })`,
121
+ schema: BrowserClickSchema,
122
+ });
123
+ }
124
+ /**
125
+ * Browser type tool - types text into an input field
126
+ */
127
+ function createBrowserTypeTool() {
128
+ return tool(async ({ index, text, clear, pressEnter }) => {
129
+ return JSON.stringify({
130
+ type: 'browser_action',
131
+ action: {
132
+ type: 'type',
133
+ index,
134
+ text,
135
+ clear: clear ?? false,
136
+ pressEnter: pressEnter ?? false,
137
+ },
138
+ requiresBrowserExecution: true,
139
+ });
140
+ }, {
141
+ name: EBrowserTools.TYPE,
142
+ description: `Type text into an input field on the current page.
143
+
144
+ Use this tool when you need to:
145
+ - Fill in a text input or textarea
146
+ - Enter a search query
147
+ - Fill out form fields
148
+
149
+ The element index comes from the page context's interactive elements list.
150
+ Set 'clear: true' to clear existing content before typing.
151
+ Set 'pressEnter: true' to submit after typing (useful for search fields).
152
+
153
+ Example: To type "hello world" into a search field shown as "[2]<input>Search...</input>",
154
+ use index: 2, text: "hello world"`,
155
+ schema: BrowserTypeSchema,
156
+ });
157
+ }
158
+ /**
159
+ * Browser navigate tool - navigates to a URL
160
+ */
161
+ function createBrowserNavigateTool() {
162
+ return tool(async ({ url, reason }) => {
163
+ return JSON.stringify({
164
+ type: 'browser_action',
165
+ action: {
166
+ type: 'navigate',
167
+ url,
168
+ reason,
169
+ },
170
+ requiresBrowserExecution: true,
171
+ });
172
+ }, {
173
+ name: EBrowserTools.NAVIGATE,
174
+ description: `Navigate to a specific URL in the browser.
175
+
176
+ Use this tool when you need to:
177
+ - Go to a specific website
178
+ - Navigate to a different page
179
+ - Open a new URL
180
+
181
+ Provide the full URL including the protocol (https://).
182
+
183
+ Example: browser_navigate({ url: "https://www.google.com" })`,
184
+ schema: BrowserNavigateSchema,
185
+ });
186
+ }
187
+ /**
188
+ * Browser scroll tool - scrolls the page
189
+ */
190
+ function createBrowserScrollTool() {
191
+ return tool(async ({ direction, amount }) => {
192
+ return JSON.stringify({
193
+ type: 'browser_action',
194
+ action: {
195
+ type: 'scroll',
196
+ scroll: {
197
+ direction,
198
+ amount: amount ?? 500,
199
+ },
200
+ },
201
+ requiresBrowserExecution: true,
202
+ });
203
+ }, {
204
+ name: EBrowserTools.SCROLL,
205
+ description: `Scroll the current page in a specified direction.
206
+
207
+ Use this tool when you need to:
208
+ - See more content on the page
209
+ - Scroll to find elements not currently visible
210
+ - Navigate long pages
211
+
212
+ Default scroll amount is 500 pixels. Adjust as needed.
213
+
214
+ Example: browser_scroll({ direction: "down", amount: 800 })`,
215
+ schema: BrowserScrollSchema,
216
+ });
217
+ }
218
+ /**
219
+ * Browser extract tool - extracts content from the page
220
+ */
221
+ function createBrowserExtractTool() {
222
+ return tool(async ({ query, selector }) => {
223
+ return JSON.stringify({
224
+ type: 'browser_action',
225
+ action: {
226
+ type: 'extract',
227
+ query,
228
+ selector,
229
+ },
230
+ requiresBrowserExecution: true,
231
+ });
232
+ }, {
233
+ name: EBrowserTools.EXTRACT,
234
+ description: `Extract text content from the current page.
235
+
236
+ Use this tool when you need to:
237
+ - Get specific information from the page
238
+ - Extract text that matches a query
239
+ - Read content from a specific element
240
+
241
+ If no query or selector is provided, extracts the main page content.
242
+ Use a CSS selector to extract from a specific element.
243
+ Use a query to filter for relevant content.
244
+
245
+ Example: browser_extract({ query: "price" }) - extracts content related to pricing`,
246
+ schema: BrowserExtractSchema,
247
+ });
248
+ }
249
+ /**
250
+ * Browser hover tool - hovers over an element
251
+ */
252
+ function createBrowserHoverTool() {
253
+ return tool(async ({ index }) => {
254
+ return JSON.stringify({
255
+ type: 'browser_action',
256
+ action: {
257
+ type: 'hover',
258
+ index,
259
+ },
260
+ requiresBrowserExecution: true,
261
+ });
262
+ }, {
263
+ name: EBrowserTools.HOVER,
264
+ description: `Hover over an element to reveal tooltips or dropdown menus.
265
+
266
+ Use this tool when you need to:
267
+ - Reveal a dropdown menu
268
+ - Show a tooltip
269
+ - Trigger hover effects
270
+
271
+ Example: browser_hover({ index: 3 }) - hovers over element at index 3`,
272
+ schema: BrowserHoverSchema,
273
+ });
274
+ }
275
+ /**
276
+ * Browser wait tool - waits for a specified duration
277
+ */
278
+ function createBrowserWaitTool() {
279
+ return tool(async ({ duration, reason }) => {
280
+ return JSON.stringify({
281
+ type: 'browser_action',
282
+ action: {
283
+ type: 'wait',
284
+ duration: duration ?? 1000,
285
+ reason,
286
+ },
287
+ requiresBrowserExecution: true,
288
+ });
289
+ }, {
290
+ name: EBrowserTools.WAIT,
291
+ description: `Wait for a specified duration before the next action.
292
+
293
+ Use this tool when you need to:
294
+ - Wait for a page to load
295
+ - Wait for an animation to complete
296
+ - Add delay between actions
297
+
298
+ Default wait time is 1000ms (1 second).
299
+
300
+ Example: browser_wait({ duration: 2000, reason: "waiting for page to load" })`,
301
+ schema: BrowserWaitSchema,
302
+ });
303
+ }
304
+ /**
305
+ * Browser go back tool - navigates back in history
306
+ */
307
+ function createBrowserGoBackTool() {
308
+ return tool(async ({ reason }) => {
309
+ return JSON.stringify({
310
+ type: 'browser_action',
311
+ action: {
312
+ type: 'back',
313
+ reason,
314
+ },
315
+ requiresBrowserExecution: true,
316
+ });
317
+ }, {
318
+ name: EBrowserTools.BACK,
319
+ description: `Navigate back to the previous page in browser history.
320
+
321
+ Use this tool when you need to:
322
+ - Return to a previous page
323
+ - Undo a navigation
324
+
325
+ Example: browser_back({ reason: "returning to search results" })`,
326
+ schema: BrowserGoBackSchema,
327
+ });
328
+ }
329
+ /**
330
+ * Browser screenshot tool - captures a screenshot
331
+ */
332
+ function createBrowserScreenshotTool() {
333
+ return tool(async ({ fullPage }) => {
334
+ return JSON.stringify({
335
+ type: 'browser_action',
336
+ action: {
337
+ type: 'screenshot',
338
+ fullPage: fullPage ?? false,
339
+ },
340
+ requiresBrowserExecution: true,
341
+ });
342
+ }, {
343
+ name: EBrowserTools.SCREENSHOT,
344
+ description: `Capture a screenshot of the current page.
345
+
346
+ Use this tool when you need to:
347
+ - Capture the current state of a page
348
+ - Document visual elements
349
+ - Verify page appearance
350
+
351
+ Set fullPage: true to capture the entire page (may be large).
352
+ Default captures only the visible viewport.
353
+
354
+ Example: browser_screenshot({ fullPage: false })`,
355
+ schema: BrowserScreenshotSchema,
356
+ });
357
+ }
358
+ /**
359
+ * Create all browser automation tools
360
+ *
361
+ * IMPORTANT: These tools should ONLY be registered when:
362
+ * 1. The request comes from a browser extension that can execute them
363
+ * 2. The client has indicated browser capability (e.g., via header or parameter)
364
+ *
365
+ * DO NOT register these for normal web UI users - they cannot execute browser actions.
366
+ *
367
+ * Detection in Ranger API:
368
+ * - Check for `X-Ranger-Browser-Extension: true` header
369
+ * - Or check for `browserCapable: true` in request body
370
+ * - Or check user agent for extension identifier
371
+ *
372
+ * @example
373
+ * // In Ranger API endpoint:
374
+ * const hasBrowserExtension = req.headers['x-ranger-browser-extension'] === 'true';
375
+ * const tools = hasBrowserExtension
376
+ * ? [...normalTools, ...createBrowserTools()]
377
+ * : normalTools;
378
+ */
379
+ function createBrowserTools(config = {}) {
380
+ const tools = [];
381
+ // Enable all by default
382
+ const { enableClick = true, enableType = true, enableNavigate = true, enableScroll = true, enableExtract = true, enableHover = true, enableWait = true, enableBack = true, enableScreenshot = true, } = config;
383
+ if (enableClick)
384
+ tools.push(createBrowserClickTool());
385
+ if (enableType)
386
+ tools.push(createBrowserTypeTool());
387
+ if (enableNavigate)
388
+ tools.push(createBrowserNavigateTool());
389
+ if (enableScroll)
390
+ tools.push(createBrowserScrollTool());
391
+ if (enableExtract)
392
+ tools.push(createBrowserExtractTool());
393
+ if (enableHover)
394
+ tools.push(createBrowserHoverTool());
395
+ if (enableWait)
396
+ tools.push(createBrowserWaitTool());
397
+ if (enableBack)
398
+ tools.push(createBrowserGoBackTool());
399
+ if (enableScreenshot)
400
+ tools.push(createBrowserScreenshotTool());
401
+ return tools;
402
+ }
403
+ /**
404
+ * Browser tool name constants
405
+ * Use these instead of magic strings
406
+ */
407
+ const EBrowserTools = {
408
+ CLICK: 'browser_click',
409
+ TYPE: 'browser_type',
410
+ NAVIGATE: 'browser_navigate',
411
+ SCROLL: 'browser_scroll',
412
+ EXTRACT: 'browser_extract',
413
+ HOVER: 'browser_hover',
414
+ WAIT: 'browser_wait',
415
+ BACK: 'browser_back',
416
+ SCREENSHOT: 'browser_screenshot',
417
+ };
418
+ /**
419
+ * Get browser tool names for filtering/identification
420
+ */
421
+ const BROWSER_TOOL_NAMES = [
422
+ EBrowserTools.CLICK,
423
+ EBrowserTools.TYPE,
424
+ EBrowserTools.NAVIGATE,
425
+ EBrowserTools.SCROLL,
426
+ EBrowserTools.EXTRACT,
427
+ EBrowserTools.HOVER,
428
+ EBrowserTools.WAIT,
429
+ EBrowserTools.BACK,
430
+ EBrowserTools.SCREENSHOT,
431
+ ];
432
+ /**
433
+ * Check if a tool call is a browser action
434
+ */
435
+ function isBrowserToolCall(toolName) {
436
+ return BROWSER_TOOL_NAMES.includes(toolName);
437
+ }
438
+ /**
439
+ * Check if request indicates browser extension capability
440
+ * Use this to conditionally register browser tools
441
+ *
442
+ * @example
443
+ * // In Express middleware or endpoint:
444
+ * if (hasBrowserCapability(req.headers)) {
445
+ * tools.push(...createBrowserTools());
446
+ * }
447
+ */
448
+ function hasBrowserCapability(headers) {
449
+ const extensionHeader = headers['x-ranger-browser-extension'];
450
+ const capableHeader = headers['x-ranger-browser-capable'];
451
+ return (extensionHeader === 'true' ||
452
+ capableHeader === 'true' ||
453
+ (Array.isArray(extensionHeader) && extensionHeader.includes('true')) ||
454
+ (Array.isArray(capableHeader) && capableHeader.includes('true')));
455
+ }
456
+
457
+ export { BROWSER_TOOL_NAMES, EBrowserTools, createBrowserClickTool, createBrowserExtractTool, createBrowserGoBackTool, createBrowserHoverTool, createBrowserNavigateTool, createBrowserScreenshotTool, createBrowserScrollTool, createBrowserTools, createBrowserTypeTool, createBrowserWaitTool, hasBrowserCapability, isBrowserToolCall };
458
+ //# sourceMappingURL=BrowserTools.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BrowserTools.mjs","sources":["../../../src/tools/BrowserTools.ts"],"sourcesContent":["/**\r\n * Browser Automation Tools for Ranger Browser Extension\r\n * \r\n * These tools allow the LLM to interact with the browser through the \r\n * ranger-browser extension. They generate structured actions that are\r\n * sent to the extension via SSE streaming for execution.\r\n * \r\n * The extension handles:\r\n * - DOM extraction with element indexing\r\n * - Click, type, hover, scroll actions\r\n * - Navigation and page context\r\n * - Visual element highlighting\r\n */\r\n\r\nimport { z } from 'zod';\r\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\r\n\r\n// ============================================\r\n// Tool Schemas\r\n// ============================================\r\n\r\n/**\r\n * Enhanced click schema that supports both index-based and coordinate-based clicking\r\n */\r\nconst BrowserClickSchema = z.object({\r\n index: z.number().optional().describe(\r\n 'The index of the element to click, as shown in the page context (e.g., [0], [1], [2]). ' +\r\n 'Use the element index from the interactive elements list provided in the page context. ' +\r\n 'Either index OR coordinates must be provided.'\r\n ),\r\n coordinates: z.object({\r\n x: z.number().describe('X coordinate in viewport pixels'),\r\n y: z.number().describe('Y coordinate in viewport pixels'),\r\n }).optional().describe(\r\n 'Coordinates for clicking elements that lack semantic info (marked with ⚠️). ' +\r\n 'The coordinates are provided in the element listing as coords:(x,y). ' +\r\n 'Either index OR coordinates must be provided.'\r\n ),\r\n visualDescription: z.string().optional().describe(\r\n 'Description of what the element looks like visually. Used when clicking by appearance ' +\r\n '(e.g., \"blue button in top right corner\", \"hamburger menu icon\")'\r\n ),\r\n reason: z.string().optional().describe(\r\n 'Brief explanation of why you are clicking this element (for user transparency)'\r\n ),\r\n});\r\n\r\nconst BrowserTypeSchema = z.object({\r\n index: z.number().describe(\r\n 'The index of the input element to type into, as shown in the page context'\r\n ),\r\n text: z.string().describe(\r\n 'The text to type into the input field'\r\n ),\r\n clear: z.boolean().optional().describe(\r\n 'Whether to clear the existing content before typing (default: false)'\r\n ),\r\n pressEnter: z.boolean().optional().describe(\r\n 'Whether to press Enter after typing (useful for search fields, default: false)'\r\n ),\r\n});\r\n\r\nconst BrowserNavigateSchema = z.object({\r\n url: z.string().describe(\r\n 'The URL to navigate to. Can be a full URL or a relative path.'\r\n ),\r\n reason: z.string().optional().describe(\r\n 'Brief explanation of why you are navigating to this URL'\r\n ),\r\n});\r\n\r\nconst BrowserScrollSchema = z.object({\r\n direction: z.enum(['up', 'down', 'left', 'right']).describe(\r\n 'The direction to scroll'\r\n ),\r\n amount: z.number().optional().describe(\r\n 'The amount to scroll in pixels (default: 500)'\r\n ),\r\n});\r\n\r\nconst BrowserExtractSchema = z.object({\r\n query: z.string().optional().describe(\r\n 'Optional query to filter extracted content. If provided, only content related to the query will be extracted.'\r\n ),\r\n selector: z.string().optional().describe(\r\n 'Optional CSS selector to extract content from a specific element'\r\n ),\r\n});\r\n\r\nconst BrowserHoverSchema = z.object({\r\n index: z.number().describe(\r\n 'The index of the element to hover over, as shown in the page context'\r\n ),\r\n});\r\n\r\nconst BrowserWaitSchema = z.object({\r\n duration: z.number().optional().describe(\r\n 'Duration to wait in milliseconds (default: 1000)'\r\n ),\r\n reason: z.string().optional().describe(\r\n 'Why we are waiting (e.g., \"for page to load\", \"for animation to complete\")'\r\n ),\r\n});\r\n\r\nconst BrowserGoBackSchema = z.object({\r\n reason: z.string().optional().describe(\r\n 'Brief explanation of why you are going back'\r\n ),\r\n});\r\n\r\nconst BrowserScreenshotSchema = z.object({\r\n fullPage: z.boolean().optional().describe(\r\n 'Whether to capture the full page or just the viewport (default: viewport only)'\r\n ),\r\n reason: z.string().optional().describe(\r\n 'Why you need a screenshot (e.g., \"to identify visual elements\", \"to analyze page layout\")'\r\n ),\r\n});\r\n\r\n// ============================================\r\n// Tool Implementations\r\n// ============================================\r\n\r\n/**\r\n * Browser click tool - clicks an element by index or coordinates\r\n * Supports both semantic (index-based) and vision (coordinate-based) clicking\r\n */\r\nexport function createBrowserClickTool(): DynamicStructuredTool<typeof BrowserClickSchema> {\r\n return tool<typeof BrowserClickSchema>(\r\n async ({ index, coordinates, visualDescription, reason }) => {\r\n // Validate that at least one targeting method is provided\r\n if (index === undefined && !coordinates) {\r\n return JSON.stringify({\r\n type: 'error',\r\n error: 'Either index or coordinates must be provided to click an element',\r\n });\r\n }\r\n\r\n // Return a structured action for the extension to execute\r\n // The actual execution happens in the browser extension\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'click',\r\n ...(index !== undefined && { index }),\r\n ...(coordinates && { coordinates }),\r\n ...(visualDescription && { visualDescription }),\r\n reason,\r\n },\r\n // Signal that this requires browser execution\r\n requiresBrowserExecution: true,\r\n });\r\n },\r\n {\r\n name: EBrowserTools.CLICK,\r\n description: `Click an interactive element on the current page.\r\n\r\n**Two ways to target elements:**\r\n\r\n1. **By index (preferred)**: Use the element's index number from the interactive elements list\r\n - Format: [index] {semantic role} <tag>text</tag>\r\n - Example: browser_click({ index: 5 }) to click element [5]\r\n\r\n2. **By coordinates (vision fallback)**: For elements marked with ⚠️ that lack semantic info\r\n - Use the coords:(x,y) shown after the ⚠️ marker\r\n - Example: browser_click({ coordinates: { x: 150, y: 200 } })\r\n\r\n**When to use coordinates:**\r\n- Elements marked with ⚠️ have poor semantic understanding\r\n- Icon-only buttons without labels\r\n- Custom canvas/SVG elements\r\n- When you identify an element visually in a screenshot\r\n\r\nExample: If element shows \\`[12] {button} <div>⚠️ [left side, small, clickable] coords:(45,120)\\`\r\nUse either: browser_click({ index: 12 }) or browser_click({ coordinates: { x: 45, y: 120 } })`,\r\n schema: BrowserClickSchema,\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Browser type tool - types text into an input field\r\n */\r\nexport function createBrowserTypeTool(): DynamicStructuredTool<typeof BrowserTypeSchema> {\r\n return tool<typeof BrowserTypeSchema>(\r\n async ({ index, text, clear, pressEnter }) => {\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'type',\r\n index,\r\n text,\r\n clear: clear ?? false,\r\n pressEnter: pressEnter ?? false,\r\n },\r\n requiresBrowserExecution: true,\r\n });\r\n },\r\n {\r\n name: EBrowserTools.TYPE,\r\n description: `Type text into an input field on the current page.\r\n\r\nUse this tool when you need to:\r\n- Fill in a text input or textarea\r\n- Enter a search query\r\n- Fill out form fields\r\n\r\nThe element index comes from the page context's interactive elements list.\r\nSet 'clear: true' to clear existing content before typing.\r\nSet 'pressEnter: true' to submit after typing (useful for search fields).\r\n\r\nExample: To type \"hello world\" into a search field shown as \"[2]<input>Search...</input>\",\r\nuse index: 2, text: \"hello world\"`,\r\n schema: BrowserTypeSchema,\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Browser navigate tool - navigates to a URL\r\n */\r\nexport function createBrowserNavigateTool(): DynamicStructuredTool<typeof BrowserNavigateSchema> {\r\n return tool<typeof BrowserNavigateSchema>(\r\n async ({ url, reason }) => {\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'navigate',\r\n url,\r\n reason,\r\n },\r\n requiresBrowserExecution: true,\r\n });\r\n },\r\n {\r\n name: EBrowserTools.NAVIGATE,\r\n description: `Navigate to a specific URL in the browser.\r\n\r\nUse this tool when you need to:\r\n- Go to a specific website\r\n- Navigate to a different page\r\n- Open a new URL\r\n\r\nProvide the full URL including the protocol (https://).\r\n\r\nExample: browser_navigate({ url: \"https://www.google.com\" })`,\r\n schema: BrowserNavigateSchema,\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Browser scroll tool - scrolls the page\r\n */\r\nexport function createBrowserScrollTool(): DynamicStructuredTool<typeof BrowserScrollSchema> {\r\n return tool<typeof BrowserScrollSchema>(\r\n async ({ direction, amount }) => {\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'scroll',\r\n scroll: {\r\n direction,\r\n amount: amount ?? 500,\r\n },\r\n },\r\n requiresBrowserExecution: true,\r\n });\r\n },\r\n {\r\n name: EBrowserTools.SCROLL,\r\n description: `Scroll the current page in a specified direction.\r\n\r\nUse this tool when you need to:\r\n- See more content on the page\r\n- Scroll to find elements not currently visible\r\n- Navigate long pages\r\n\r\nDefault scroll amount is 500 pixels. Adjust as needed.\r\n\r\nExample: browser_scroll({ direction: \"down\", amount: 800 })`,\r\n schema: BrowserScrollSchema,\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Browser extract tool - extracts content from the page\r\n */\r\nexport function createBrowserExtractTool(): DynamicStructuredTool<typeof BrowserExtractSchema> {\r\n return tool<typeof BrowserExtractSchema>(\r\n async ({ query, selector }) => {\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'extract',\r\n query,\r\n selector,\r\n },\r\n requiresBrowserExecution: true,\r\n });\r\n },\r\n {\r\n name: EBrowserTools.EXTRACT,\r\n description: `Extract text content from the current page.\r\n\r\nUse this tool when you need to:\r\n- Get specific information from the page\r\n- Extract text that matches a query\r\n- Read content from a specific element\r\n\r\nIf no query or selector is provided, extracts the main page content.\r\nUse a CSS selector to extract from a specific element.\r\nUse a query to filter for relevant content.\r\n\r\nExample: browser_extract({ query: \"price\" }) - extracts content related to pricing`,\r\n schema: BrowserExtractSchema,\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Browser hover tool - hovers over an element\r\n */\r\nexport function createBrowserHoverTool(): DynamicStructuredTool<typeof BrowserHoverSchema> {\r\n return tool<typeof BrowserHoverSchema>(\r\n async ({ index }) => {\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'hover',\r\n index,\r\n },\r\n requiresBrowserExecution: true,\r\n });\r\n },\r\n {\r\n name: EBrowserTools.HOVER,\r\n description: `Hover over an element to reveal tooltips or dropdown menus.\r\n\r\nUse this tool when you need to:\r\n- Reveal a dropdown menu\r\n- Show a tooltip\r\n- Trigger hover effects\r\n\r\nExample: browser_hover({ index: 3 }) - hovers over element at index 3`,\r\n schema: BrowserHoverSchema,\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Browser wait tool - waits for a specified duration\r\n */\r\nexport function createBrowserWaitTool(): DynamicStructuredTool<typeof BrowserWaitSchema> {\r\n return tool<typeof BrowserWaitSchema>(\r\n async ({ duration, reason }) => {\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'wait',\r\n duration: duration ?? 1000,\r\n reason,\r\n },\r\n requiresBrowserExecution: true,\r\n });\r\n },\r\n {\r\n name: EBrowserTools.WAIT,\r\n description: `Wait for a specified duration before the next action.\r\n\r\nUse this tool when you need to:\r\n- Wait for a page to load\r\n- Wait for an animation to complete\r\n- Add delay between actions\r\n\r\nDefault wait time is 1000ms (1 second).\r\n\r\nExample: browser_wait({ duration: 2000, reason: \"waiting for page to load\" })`,\r\n schema: BrowserWaitSchema,\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Browser go back tool - navigates back in history\r\n */\r\nexport function createBrowserGoBackTool(): DynamicStructuredTool<typeof BrowserGoBackSchema> {\r\n return tool<typeof BrowserGoBackSchema>(\r\n async ({ reason }) => {\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'back',\r\n reason,\r\n },\r\n requiresBrowserExecution: true,\r\n });\r\n },\r\n {\r\n name: EBrowserTools.BACK,\r\n description: `Navigate back to the previous page in browser history.\r\n\r\nUse this tool when you need to:\r\n- Return to a previous page\r\n- Undo a navigation\r\n\r\nExample: browser_back({ reason: \"returning to search results\" })`,\r\n schema: BrowserGoBackSchema,\r\n }\r\n );\r\n}\r\n\r\n/**\r\n * Browser screenshot tool - captures a screenshot\r\n */\r\nexport function createBrowserScreenshotTool(): DynamicStructuredTool<typeof BrowserScreenshotSchema> {\r\n return tool<typeof BrowserScreenshotSchema>(\r\n async ({ fullPage }) => {\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'screenshot',\r\n fullPage: fullPage ?? false,\r\n },\r\n requiresBrowserExecution: true,\r\n });\r\n },\r\n {\r\n name: EBrowserTools.SCREENSHOT,\r\n description: `Capture a screenshot of the current page.\r\n\r\nUse this tool when you need to:\r\n- Capture the current state of a page\r\n- Document visual elements\r\n- Verify page appearance\r\n\r\nSet fullPage: true to capture the entire page (may be large).\r\nDefault captures only the visible viewport.\r\n\r\nExample: browser_screenshot({ fullPage: false })`,\r\n schema: BrowserScreenshotSchema,\r\n }\r\n );\r\n}\r\n\r\n// ============================================\r\n// Tool Collection\r\n// ============================================\r\n\r\nexport type BrowserToolsConfig = {\r\n /** Enable click tool */\r\n enableClick?: boolean;\r\n /** Enable type tool */\r\n enableType?: boolean;\r\n /** Enable navigate tool */\r\n enableNavigate?: boolean;\r\n /** Enable scroll tool */\r\n enableScroll?: boolean;\r\n /** Enable extract tool */\r\n enableExtract?: boolean;\r\n /** Enable hover tool */\r\n enableHover?: boolean;\r\n /** Enable wait tool */\r\n enableWait?: boolean;\r\n /** Enable back tool */\r\n enableBack?: boolean;\r\n /** Enable screenshot tool */\r\n enableScreenshot?: boolean;\r\n};\r\n\r\n/**\r\n * Create all browser automation tools\r\n * \r\n * IMPORTANT: These tools should ONLY be registered when:\r\n * 1. The request comes from a browser extension that can execute them\r\n * 2. The client has indicated browser capability (e.g., via header or parameter)\r\n * \r\n * DO NOT register these for normal web UI users - they cannot execute browser actions.\r\n * \r\n * Detection in Ranger API:\r\n * - Check for `X-Ranger-Browser-Extension: true` header\r\n * - Or check for `browserCapable: true` in request body\r\n * - Or check user agent for extension identifier\r\n * \r\n * @example\r\n * // In Ranger API endpoint:\r\n * const hasBrowserExtension = req.headers['x-ranger-browser-extension'] === 'true';\r\n * const tools = hasBrowserExtension \r\n * ? [...normalTools, ...createBrowserTools()]\r\n * : normalTools;\r\n */\r\nexport function createBrowserTools(config: BrowserToolsConfig = {}): DynamicStructuredTool[] {\r\n const tools: DynamicStructuredTool[] = [];\r\n \r\n // Enable all by default\r\n const {\r\n enableClick = true,\r\n enableType = true,\r\n enableNavigate = true,\r\n enableScroll = true,\r\n enableExtract = true,\r\n enableHover = true,\r\n enableWait = true,\r\n enableBack = true,\r\n enableScreenshot = true,\r\n } = config;\r\n \r\n if (enableClick) tools.push(createBrowserClickTool());\r\n if (enableType) tools.push(createBrowserTypeTool());\r\n if (enableNavigate) tools.push(createBrowserNavigateTool());\r\n if (enableScroll) tools.push(createBrowserScrollTool());\r\n if (enableExtract) tools.push(createBrowserExtractTool());\r\n if (enableHover) tools.push(createBrowserHoverTool());\r\n if (enableWait) tools.push(createBrowserWaitTool());\r\n if (enableBack) tools.push(createBrowserGoBackTool());\r\n if (enableScreenshot) tools.push(createBrowserScreenshotTool());\r\n \r\n return tools;\r\n}\r\n\r\n/**\r\n * Browser tool name constants\r\n * Use these instead of magic strings\r\n */\r\nexport const EBrowserTools = {\r\n CLICK: 'browser_click',\r\n TYPE: 'browser_type',\r\n NAVIGATE: 'browser_navigate',\r\n SCROLL: 'browser_scroll',\r\n EXTRACT: 'browser_extract',\r\n HOVER: 'browser_hover',\r\n WAIT: 'browser_wait',\r\n BACK: 'browser_back',\r\n SCREENSHOT: 'browser_screenshot',\r\n} as const;\r\n\r\n/**\r\n * Get browser tool names for filtering/identification\r\n */\r\nexport const BROWSER_TOOL_NAMES = [\r\n EBrowserTools.CLICK,\r\n EBrowserTools.TYPE,\r\n EBrowserTools.NAVIGATE,\r\n EBrowserTools.SCROLL,\r\n EBrowserTools.EXTRACT,\r\n EBrowserTools.HOVER,\r\n EBrowserTools.WAIT,\r\n EBrowserTools.BACK,\r\n EBrowserTools.SCREENSHOT,\r\n] as const;\r\n\r\nexport type BrowserToolName = typeof BROWSER_TOOL_NAMES[number];\r\n\r\n/**\r\n * Check if a tool call is a browser action\r\n */\r\nexport function isBrowserToolCall(toolName: string): toolName is BrowserToolName {\r\n return BROWSER_TOOL_NAMES.includes(toolName as BrowserToolName);\r\n}\r\n\r\n/**\r\n * Check if request indicates browser extension capability\r\n * Use this to conditionally register browser tools\r\n * \r\n * @example\r\n * // In Express middleware or endpoint:\r\n * if (hasBrowserCapability(req.headers)) {\r\n * tools.push(...createBrowserTools());\r\n * }\r\n */\r\nexport function hasBrowserCapability(headers: Record<string, string | string[] | undefined>): boolean {\r\n const extensionHeader = headers['x-ranger-browser-extension'];\r\n const capableHeader = headers['x-ranger-browser-capable'];\r\n \r\n return (\r\n extensionHeader === 'true' || \r\n capableHeader === 'true' ||\r\n (Array.isArray(extensionHeader) && extensionHeader.includes('true')) ||\r\n (Array.isArray(capableHeader) && capableHeader.includes('true'))\r\n );\r\n}\r\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;AAYG;AAKH;AACA;AACA;AAEA;;AAEG;AACH,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACnC,yFAAyF;QACzF,yFAAyF;AACzF,QAAA,+CAA+C,CAChD;AACD,IAAA,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;QACzD,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,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,IAAA,OAAO,EAAE,iBAAiB;AAC1B,IAAA,KAAK,EAAE,eAAe;AACtB,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,UAAU,EAAE,oBAAoB;;AAGlC;;AAEG;AACU,MAAA,kBAAkB,GAAG;AAChC,IAAA,aAAa,CAAC,KAAK;AACnB,IAAA,aAAa,CAAC,IAAI;AAClB,IAAA,aAAa,CAAC,QAAQ;AACtB,IAAA,aAAa,CAAC,MAAM;AACpB,IAAA,aAAa,CAAC,OAAO;AACrB,IAAA,aAAa,CAAC,KAAK;AACnB,IAAA,aAAa,CAAC,IAAI;AAClB,IAAA,aAAa,CAAC,IAAI;AAClB,IAAA,aAAa,CAAC,UAAU;;AAK1B;;AAEG;AACG,SAAU,iBAAiB,CAAC,QAAgB,EAAA;AAChD,IAAA,OAAO,kBAAkB,CAAC,QAAQ,CAAC,QAA2B,CAAC;AACjE;AAEA;;;;;;;;;AASG;AACG,SAAU,oBAAoB,CAAC,OAAsD,EAAA;AACzF,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,4BAA4B,CAAC;AAC7D,IAAA,MAAM,aAAa,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAEzD,QACE,eAAe,KAAK,MAAM;AAC1B,QAAA,aAAa,KAAK,MAAM;AACxB,SAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpE,SAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEpE;;;;"}
@@ -8,6 +8,7 @@ export * from './tools/Calculator';
8
8
  export * from './tools/CodeExecutor';
9
9
  export * from './tools/ProgrammaticToolCalling';
10
10
  export * from './tools/ToolSearchRegex';
11
+ export * from './tools/BrowserTools';
11
12
  export * from './tools/handlers';
12
13
  export * from './tools/search';
13
14
  export * from './common';