illuma-agents 1.0.23 → 1.0.25

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.
@@ -1,517 +0,0 @@
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
- const BrowserGetPageStateSchema = z.object({
70
- reason: z.string().optional().describe('Why you need fresh page state (e.g., "after navigation", "to see updated elements")'),
71
- });
72
- // ============================================
73
- // Tool Implementations
74
- // ============================================
75
- /**
76
- * Browser click tool - clicks an element by index or coordinates
77
- * Supports both semantic (index-based) and vision (coordinate-based) clicking
78
- */
79
- function createBrowserClickTool() {
80
- return tool(async ({ index, coordinates, visualDescription, reason }) => {
81
- // Validate that at least one targeting method is provided
82
- if (index === undefined && !coordinates) {
83
- return JSON.stringify({
84
- type: 'error',
85
- error: 'Either index or coordinates must be provided to click an element',
86
- });
87
- }
88
- // Return a structured action for the extension to execute
89
- // The actual execution happens in the browser extension
90
- return JSON.stringify({
91
- type: 'browser_action',
92
- action: {
93
- type: 'click',
94
- ...(index !== undefined && { index }),
95
- ...(coordinates && { coordinates }),
96
- ...(visualDescription && { visualDescription }),
97
- reason,
98
- },
99
- // Signal that this requires browser execution
100
- requiresBrowserExecution: true,
101
- });
102
- }, {
103
- name: EBrowserTools.CLICK,
104
- description: `Click an interactive element on the current page.
105
-
106
- **Two ways to target elements:**
107
-
108
- 1. **By index (preferred)**: Use the element's index number from the interactive elements list
109
- - Format: [index] {semantic role} <tag>text</tag>
110
- - Example: browser_click({ index: 5 }) to click element [5]
111
-
112
- 2. **By coordinates (vision fallback)**: For elements marked with ⚠️ that lack semantic info
113
- - Use the coords:(x,y) shown after the ⚠️ marker
114
- - Example: browser_click({ coordinates: { x: 150, y: 200 } })
115
-
116
- **When to use coordinates:**
117
- - Elements marked with ⚠️ have poor semantic understanding
118
- - Icon-only buttons without labels
119
- - Custom canvas/SVG elements
120
- - When you identify an element visually in a screenshot
121
-
122
- Example: If element shows \`[12] {button} <div>⚠️ [left side, small, clickable] coords:(45,120)\`
123
- Use either: browser_click({ index: 12 }) or browser_click({ coordinates: { x: 45, y: 120 } })`,
124
- schema: BrowserClickSchema,
125
- });
126
- }
127
- /**
128
- * Browser type tool - types text into an input field
129
- */
130
- function createBrowserTypeTool() {
131
- return tool(async ({ index, text, clear, pressEnter }) => {
132
- return JSON.stringify({
133
- type: 'browser_action',
134
- action: {
135
- type: 'type',
136
- index,
137
- text,
138
- clear: clear ?? false,
139
- pressEnter: pressEnter ?? false,
140
- },
141
- requiresBrowserExecution: true,
142
- });
143
- }, {
144
- name: EBrowserTools.TYPE,
145
- description: `Type text into an input field on the current page.
146
-
147
- Use this tool when you need to:
148
- - Fill in a text input or textarea
149
- - Enter a search query
150
- - Fill out form fields
151
-
152
- The element index comes from the page context's interactive elements list.
153
- Set 'clear: true' to clear existing content before typing.
154
- Set 'pressEnter: true' to submit after typing (useful for search fields).
155
-
156
- Example: To type "hello world" into a search field shown as "[2]<input>Search...</input>",
157
- use index: 2, text: "hello world"`,
158
- schema: BrowserTypeSchema,
159
- });
160
- }
161
- /**
162
- * Browser navigate tool - navigates to a URL
163
- */
164
- function createBrowserNavigateTool() {
165
- return tool(async ({ url, reason }) => {
166
- return JSON.stringify({
167
- type: 'browser_action',
168
- action: {
169
- type: 'navigate',
170
- url,
171
- reason,
172
- },
173
- requiresBrowserExecution: true,
174
- });
175
- }, {
176
- name: EBrowserTools.NAVIGATE,
177
- description: `Navigate to a specific URL in the browser.
178
-
179
- Use this tool when you need to:
180
- - Go to a specific website
181
- - Navigate to a different page
182
- - Open a new URL
183
-
184
- **IMPORTANT**: After calling browser_navigate, you MUST call browser_get_page_state
185
- before using browser_click or browser_type. This is because navigation changes the page,
186
- and you need to see the new page's elements before you can interact with them.
187
-
188
- Provide the full URL including the protocol (https://).
189
-
190
- **Correct workflow**:
191
- 1. browser_navigate({ url: "https://www.amazon.com" })
192
- 2. browser_get_page_state({ reason: "see elements on Amazon" })
193
- 3. Now find the search input's [index] in the returned state
194
- 4. browser_type({ index: <search_input_index>, text: "query", pressEnter: true })
195
-
196
- Example: browser_navigate({ url: "https://www.google.com" })`,
197
- schema: BrowserNavigateSchema,
198
- });
199
- }
200
- /**
201
- * Browser scroll tool - scrolls the page
202
- */
203
- function createBrowserScrollTool() {
204
- return tool(async ({ direction, amount }) => {
205
- return JSON.stringify({
206
- type: 'browser_action',
207
- action: {
208
- type: 'scroll',
209
- scroll: {
210
- direction,
211
- amount: amount ?? 500,
212
- },
213
- },
214
- requiresBrowserExecution: true,
215
- });
216
- }, {
217
- name: EBrowserTools.SCROLL,
218
- description: `Scroll the current page in a specified direction.
219
-
220
- Use this tool when you need to:
221
- - See more content on the page
222
- - Scroll to find elements not currently visible
223
- - Navigate long pages
224
-
225
- Default scroll amount is 500 pixels. Adjust as needed.
226
-
227
- Example: browser_scroll({ direction: "down", amount: 800 })`,
228
- schema: BrowserScrollSchema,
229
- });
230
- }
231
- /**
232
- * Browser extract tool - extracts content from the page
233
- */
234
- function createBrowserExtractTool() {
235
- return tool(async ({ query, selector }) => {
236
- return JSON.stringify({
237
- type: 'browser_action',
238
- action: {
239
- type: 'extract',
240
- query,
241
- selector,
242
- },
243
- requiresBrowserExecution: true,
244
- });
245
- }, {
246
- name: EBrowserTools.EXTRACT,
247
- description: `Extract text content from the current page.
248
-
249
- Use this tool when you need to:
250
- - Get specific information from the page
251
- - Extract text that matches a query
252
- - Read content from a specific element
253
-
254
- If no query or selector is provided, extracts the main page content.
255
- Use a CSS selector to extract from a specific element.
256
- Use a query to filter for relevant content.
257
-
258
- Example: browser_extract({ query: "price" }) - extracts content related to pricing`,
259
- schema: BrowserExtractSchema,
260
- });
261
- }
262
- /**
263
- * Browser hover tool - hovers over an element
264
- */
265
- function createBrowserHoverTool() {
266
- return tool(async ({ index }) => {
267
- return JSON.stringify({
268
- type: 'browser_action',
269
- action: {
270
- type: 'hover',
271
- index,
272
- },
273
- requiresBrowserExecution: true,
274
- });
275
- }, {
276
- name: EBrowserTools.HOVER,
277
- description: `Hover over an element to reveal tooltips or dropdown menus.
278
-
279
- Use this tool when you need to:
280
- - Reveal a dropdown menu
281
- - Show a tooltip
282
- - Trigger hover effects
283
-
284
- Example: browser_hover({ index: 3 }) - hovers over element at index 3`,
285
- schema: BrowserHoverSchema,
286
- });
287
- }
288
- /**
289
- * Browser wait tool - waits for a specified duration
290
- */
291
- function createBrowserWaitTool() {
292
- return tool(async ({ duration, reason }) => {
293
- return JSON.stringify({
294
- type: 'browser_action',
295
- action: {
296
- type: 'wait',
297
- duration: duration ?? 1000,
298
- reason,
299
- },
300
- requiresBrowserExecution: true,
301
- });
302
- }, {
303
- name: EBrowserTools.WAIT,
304
- description: `Wait for a specified duration before the next action.
305
-
306
- Use this tool when you need to:
307
- - Wait for a page to load
308
- - Wait for an animation to complete
309
- - Add delay between actions
310
-
311
- Default wait time is 1000ms (1 second).
312
-
313
- Example: browser_wait({ duration: 2000, reason: "waiting for page to load" })`,
314
- schema: BrowserWaitSchema,
315
- });
316
- }
317
- /**
318
- * Browser go back tool - navigates back in history
319
- */
320
- function createBrowserGoBackTool() {
321
- return tool(async ({ reason }) => {
322
- return JSON.stringify({
323
- type: 'browser_action',
324
- action: {
325
- type: 'back',
326
- reason,
327
- },
328
- requiresBrowserExecution: true,
329
- });
330
- }, {
331
- name: EBrowserTools.BACK,
332
- description: `Navigate back to the previous page in browser history.
333
-
334
- Use this tool when you need to:
335
- - Return to a previous page
336
- - Undo a navigation
337
-
338
- Example: browser_back({ reason: "returning to search results" })`,
339
- schema: BrowserGoBackSchema,
340
- });
341
- }
342
- /**
343
- * Browser screenshot tool - captures a screenshot
344
- */
345
- function createBrowserScreenshotTool() {
346
- return tool(async ({ fullPage }) => {
347
- return JSON.stringify({
348
- type: 'browser_action',
349
- action: {
350
- type: 'screenshot',
351
- fullPage: fullPage ?? false,
352
- },
353
- requiresBrowserExecution: true,
354
- });
355
- }, {
356
- name: EBrowserTools.SCREENSHOT,
357
- description: `Capture a screenshot of the current page.
358
-
359
- Use this tool when you need to:
360
- - Capture the current state of a page
361
- - Document visual elements
362
- - Verify page appearance
363
-
364
- Set fullPage: true to capture the entire page (may be large).
365
- Default captures only the visible viewport.
366
-
367
- Example: browser_screenshot({ fullPage: false })`,
368
- schema: BrowserScreenshotSchema,
369
- });
370
- }
371
- /**
372
- * Browser get page state tool - gets fresh page context after navigation or actions
373
- * CRITICAL: Use this after browser_navigate or any action that changes the page
374
- */
375
- function createBrowserGetPageStateTool() {
376
- return tool(async ({ reason }) => {
377
- return JSON.stringify({
378
- type: 'browser_action',
379
- action: {
380
- type: 'get_page_state',
381
- reason,
382
- },
383
- requiresBrowserExecution: true,
384
- // Special flag: extension should inject fresh context into the conversation
385
- requiresContextRefresh: true,
386
- // IMPORTANT: Tell the agent to wait
387
- message: 'Page state is being captured by the browser extension. The element list will be provided in the next message. DO NOT proceed with click or type actions until you receive the actual element list.',
388
- });
389
- }, {
390
- name: EBrowserTools.GET_PAGE_STATE,
391
- description: `Get fresh page state showing current interactive elements.
392
-
393
- **CRITICAL WORKFLOW**: After calling this tool, you MUST STOP and WAIT. The browser extension will capture the page state and return the element list. DO NOT plan any browser_click or browser_type actions in the same response - you don't have the element indices yet!
394
-
395
- **When to use**:
396
- - After browser_navigate (to see elements on the new page)
397
- - After browser_click (if it caused navigation or page changes)
398
- - Any time you need to see what elements are currently on the page
399
-
400
- **IMPORTANT**: This tool captures the page state asynchronously. The actual element list will be provided AFTER this tool completes. You should:
401
- 1. Call this tool
402
- 2. STOP and wait for the response with the element list
403
- 3. In your NEXT response, use the element indices for click/type actions
404
-
405
- Example workflow:
406
- - Turn 1: browser_navigate to amazon.com, then browser_get_page_state
407
- - Turn 2: (After receiving element list) browser_type with the correct search input index
408
-
409
- Example: browser_get_page_state({ reason: "to see elements after navigation" })`,
410
- schema: BrowserGetPageStateSchema,
411
- });
412
- }
413
- /**
414
- * Create all browser automation tools
415
- *
416
- * IMPORTANT: These tools should ONLY be registered when:
417
- * 1. The request comes from a browser extension that can execute them
418
- * 2. The client has indicated browser capability (e.g., via header or parameter)
419
- *
420
- * DO NOT register these for normal web UI users - they cannot execute browser actions.
421
- *
422
- * Detection in Ranger API:
423
- * - Check for `X-Ranger-Browser-Extension: true` header
424
- * - Or check for `browserCapable: true` in request body
425
- * - Or check user agent for extension identifier
426
- *
427
- * @example
428
- * // In Ranger API endpoint:
429
- * const hasBrowserExtension = req.headers['x-ranger-browser-extension'] === 'true';
430
- * const tools = hasBrowserExtension
431
- * ? [...normalTools, ...createBrowserTools()]
432
- * : normalTools;
433
- */
434
- function createBrowserTools(config = {}) {
435
- const tools = [];
436
- // Enable all by default
437
- const { enableClick = true, enableType = true, enableNavigate = true, enableScroll = true, enableExtract = true, enableHover = true, enableWait = true, enableBack = true, enableScreenshot = true, enableGetPageState = true, } = config;
438
- if (enableClick)
439
- tools.push(createBrowserClickTool());
440
- if (enableType)
441
- tools.push(createBrowserTypeTool());
442
- if (enableNavigate)
443
- tools.push(createBrowserNavigateTool());
444
- if (enableScroll)
445
- tools.push(createBrowserScrollTool());
446
- if (enableExtract)
447
- tools.push(createBrowserExtractTool());
448
- if (enableHover)
449
- tools.push(createBrowserHoverTool());
450
- if (enableWait)
451
- tools.push(createBrowserWaitTool());
452
- if (enableBack)
453
- tools.push(createBrowserGoBackTool());
454
- if (enableScreenshot)
455
- tools.push(createBrowserScreenshotTool());
456
- if (enableGetPageState)
457
- tools.push(createBrowserGetPageStateTool());
458
- return tools;
459
- }
460
- /**
461
- * Browser tool name constants
462
- * Use these instead of magic strings
463
- */
464
- const EBrowserTools = {
465
- CLICK: 'browser_click',
466
- TYPE: 'browser_type',
467
- NAVIGATE: 'browser_navigate',
468
- SCROLL: 'browser_scroll',
469
- EXTRACT: 'browser_extract',
470
- HOVER: 'browser_hover',
471
- WAIT: 'browser_wait',
472
- BACK: 'browser_back',
473
- SCREENSHOT: 'browser_screenshot',
474
- GET_PAGE_STATE: 'browser_get_page_state',
475
- };
476
- /**
477
- * Get browser tool names for filtering/identification
478
- */
479
- const BROWSER_TOOL_NAMES = [
480
- EBrowserTools.CLICK,
481
- EBrowserTools.TYPE,
482
- EBrowserTools.NAVIGATE,
483
- EBrowserTools.SCROLL,
484
- EBrowserTools.EXTRACT,
485
- EBrowserTools.HOVER,
486
- EBrowserTools.WAIT,
487
- EBrowserTools.BACK,
488
- EBrowserTools.SCREENSHOT,
489
- EBrowserTools.GET_PAGE_STATE,
490
- ];
491
- /**
492
- * Check if a tool call is a browser action
493
- */
494
- function isBrowserToolCall(toolName) {
495
- return BROWSER_TOOL_NAMES.includes(toolName);
496
- }
497
- /**
498
- * Check if request indicates browser extension capability
499
- * Use this to conditionally register browser tools
500
- *
501
- * @example
502
- * // In Express middleware or endpoint:
503
- * if (hasBrowserCapability(req.headers)) {
504
- * tools.push(...createBrowserTools());
505
- * }
506
- */
507
- function hasBrowserCapability(headers) {
508
- const extensionHeader = headers['x-ranger-browser-extension'];
509
- const capableHeader = headers['x-ranger-browser-capable'];
510
- return (extensionHeader === 'true' ||
511
- capableHeader === 'true' ||
512
- (Array.isArray(extensionHeader) && extensionHeader.includes('true')) ||
513
- (Array.isArray(capableHeader) && capableHeader.includes('true')));
514
- }
515
-
516
- export { BROWSER_TOOL_NAMES, EBrowserTools, createBrowserClickTool, createBrowserExtractTool, createBrowserGetPageStateTool, createBrowserGoBackTool, createBrowserHoverTool, createBrowserNavigateTool, createBrowserScreenshotTool, createBrowserScrollTool, createBrowserTools, createBrowserTypeTool, createBrowserWaitTool, hasBrowserCapability, isBrowserToolCall };
517
- //# sourceMappingURL=BrowserTools.mjs.map
@@ -1 +0,0 @@
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\nconst BrowserGetPageStateSchema = z.object({\r\n reason: z.string().optional().describe(\r\n 'Why you need fresh page state (e.g., \"after navigation\", \"to see updated elements\")'\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\n**IMPORTANT**: After calling browser_navigate, you MUST call browser_get_page_state \r\nbefore using browser_click or browser_type. This is because navigation changes the page,\r\nand you need to see the new page's elements before you can interact with them.\r\n\r\nProvide the full URL including the protocol (https://).\r\n\r\n**Correct workflow**:\r\n1. browser_navigate({ url: \"https://www.amazon.com\" })\r\n2. browser_get_page_state({ reason: \"see elements on Amazon\" })\r\n3. Now find the search input's [index] in the returned state\r\n4. browser_type({ index: <search_input_index>, text: \"query\", pressEnter: true })\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 * Browser get page state tool - gets fresh page context after navigation or actions\r\n * CRITICAL: Use this after browser_navigate or any action that changes the page\r\n */\r\nexport function createBrowserGetPageStateTool(): DynamicStructuredTool<typeof BrowserGetPageStateSchema> {\r\n return tool<typeof BrowserGetPageStateSchema>(\r\n async ({ reason }) => {\r\n return JSON.stringify({\r\n type: 'browser_action',\r\n action: {\r\n type: 'get_page_state',\r\n reason,\r\n },\r\n requiresBrowserExecution: true,\r\n // Special flag: extension should inject fresh context into the conversation\r\n requiresContextRefresh: true,\r\n // IMPORTANT: Tell the agent to wait\r\n message: 'Page state is being captured by the browser extension. The element list will be provided in the next message. DO NOT proceed with click or type actions until you receive the actual element list.',\r\n });\r\n },\r\n {\r\n name: EBrowserTools.GET_PAGE_STATE,\r\n description: `Get fresh page state showing current interactive elements.\r\n\r\n**CRITICAL WORKFLOW**: After calling this tool, you MUST STOP and WAIT. The browser extension will capture the page state and return the element list. DO NOT plan any browser_click or browser_type actions in the same response - you don't have the element indices yet!\r\n\r\n**When to use**:\r\n- After browser_navigate (to see elements on the new page)\r\n- After browser_click (if it caused navigation or page changes)\r\n- Any time you need to see what elements are currently on the page\r\n\r\n**IMPORTANT**: This tool captures the page state asynchronously. The actual element list will be provided AFTER this tool completes. You should:\r\n1. Call this tool\r\n2. STOP and wait for the response with the element list\r\n3. In your NEXT response, use the element indices for click/type actions\r\n\r\nExample workflow:\r\n- Turn 1: browser_navigate to amazon.com, then browser_get_page_state\r\n- Turn 2: (After receiving element list) browser_type with the correct search input index\r\n\r\nExample: browser_get_page_state({ reason: \"to see elements after navigation\" })`,\r\n schema: BrowserGetPageStateSchema,\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 /** Enable get page state tool */\r\n enableGetPageState?: 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 enableGetPageState = 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 if (enableGetPageState) tools.push(createBrowserGetPageStateTool());\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 GET_PAGE_STATE: 'browser_get_page_state',\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 EBrowserTools.GET_PAGE_STATE,\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,iC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