illuma-agents 1.0.27 → 1.0.28

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.
Files changed (42) hide show
  1. package/dist/cjs/graphs/Graph.cjs +28 -2
  2. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  3. package/dist/cjs/graphs/MultiAgentGraph.cjs +108 -0
  4. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  5. package/dist/cjs/messages/format.cjs.map +1 -1
  6. package/dist/cjs/stream.cjs +27 -0
  7. package/dist/cjs/stream.cjs.map +1 -1
  8. package/dist/cjs/tools/BrowserTools.cjs +53 -32
  9. package/dist/cjs/tools/BrowserTools.cjs.map +1 -1
  10. package/dist/esm/graphs/Graph.mjs +28 -2
  11. package/dist/esm/graphs/Graph.mjs.map +1 -1
  12. package/dist/esm/graphs/MultiAgentGraph.mjs +108 -0
  13. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  14. package/dist/esm/messages/format.mjs.map +1 -1
  15. package/dist/esm/stream.mjs +27 -0
  16. package/dist/esm/stream.mjs.map +1 -1
  17. package/dist/esm/tools/BrowserTools.mjs +53 -32
  18. package/dist/esm/tools/BrowserTools.mjs.map +1 -1
  19. package/dist/types/graphs/Graph.d.ts +14 -0
  20. package/dist/types/graphs/MultiAgentGraph.d.ts +41 -0
  21. package/dist/types/messages/format.d.ts +1 -1
  22. package/dist/types/tools/BrowserTools.d.ts +1 -1
  23. package/dist/types/types/stream.d.ts +13 -0
  24. package/package.json +4 -2
  25. package/src/graphs/Graph.ts +30 -2
  26. package/src/graphs/MultiAgentGraph.ts +119 -0
  27. package/src/messages/format.ts +2 -2
  28. package/src/scripts/multi-agent-chain.ts +59 -6
  29. package/src/scripts/multi-agent-parallel-start.ts +265 -0
  30. package/src/scripts/multi-agent-parallel.ts +61 -10
  31. package/src/scripts/multi-agent-sequence.ts +6 -1
  32. package/src/scripts/parallel-asymmetric-tools-test.ts +274 -0
  33. package/src/scripts/parallel-full-metadata-test.ts +240 -0
  34. package/src/scripts/parallel-tools-test.ts +340 -0
  35. package/src/scripts/sequential-full-metadata-test.ts +197 -0
  36. package/src/scripts/single-agent-metadata-test.ts +198 -0
  37. package/src/scripts/test-thinking-handoff.ts +8 -0
  38. package/src/scripts/tools.ts +31 -11
  39. package/src/stream.ts +32 -0
  40. package/src/tools/BrowserTools.ts +356 -350
  41. package/src/tools/__tests__/BrowserTools.test.ts +263 -257
  42. package/src/types/stream.ts +15 -0
@@ -1,350 +1,356 @@
1
- import { z } from 'zod';
2
- import { tool, DynamicStructuredTool } from '@langchain/core/tools';
3
- import type * as t from '@/types';
4
-
5
- /**
6
- * Browser tool names - keep in sync with ranger-browser extension
7
- * These tools execute locally in the browser extension, NOT on the server
8
- */
9
- export const EBrowserTools = {
10
- CLICK: 'browser_click',
11
- TYPE: 'browser_type',
12
- NAVIGATE: 'browser_navigate',
13
- SCROLL: 'browser_scroll',
14
- EXTRACT: 'browser_extract',
15
- HOVER: 'browser_hover',
16
- WAIT: 'browser_wait',
17
- BACK: 'browser_back',
18
- SCREENSHOT: 'browser_screenshot',
19
- GET_PAGE_STATE: 'browser_get_page_state',
20
- } as const;
21
-
22
- export type BrowserToolName = typeof EBrowserTools[keyof typeof EBrowserTools];
23
-
24
- /**
25
- * Callback function type for waiting on browser action results
26
- * This allows the server (Ranger) to provide a callback that waits for the extension
27
- * to POST results back to the server before returning to the LLM.
28
- *
29
- * @param action - The browser action (click, type, navigate, etc.)
30
- * @param args - Arguments for the action
31
- * @param toolCallId - Unique ID for this tool call (from config.toolCall.id)
32
- * @returns Promise that resolves with the actual browser result (page state, etc.)
33
- */
34
- export type BrowserToolCallback = (
35
- action: string,
36
- args: Record<string, unknown>,
37
- toolCallId: string
38
- ) => Promise<BrowserActionResult>;
39
-
40
- /**
41
- * Result returned from browser action execution
42
- */
43
- export interface BrowserActionResult {
44
- success: boolean;
45
- url?: string;
46
- title?: string;
47
- elementList?: string; // Text-based element list
48
- error?: string;
49
- screenshot?: string; // Base64 screenshot (if requested)
50
- }
51
-
52
- /**
53
- * Check if browser capability is available based on request headers or context
54
- * The browser extension sets these headers when connected:
55
- * - X-Ranger-Browser-Extension: true
56
- * - X-Ranger-Browser-Capable: true
57
- */
58
- export function hasBrowserCapability(req?: { headers?: Record<string, string | string[] | undefined> }): boolean {
59
- if (!req?.headers) {
60
- return false;
61
- }
62
-
63
- const browserExtension = req.headers['x-ranger-browser-extension'];
64
- const browserCapable = req.headers['x-ranger-browser-capable'];
65
-
66
- return browserExtension === 'true' || browserCapable === 'true';
67
- }
68
-
69
- // Tool schemas
70
- const BrowserClickSchema = z.object({
71
- index: z.number().describe('The index number [0], [1], etc. of the element to click from the page state element list'),
72
- });
73
-
74
- const BrowserTypeSchema = z.object({
75
- index: z.number().describe('The index number of the input element to type into'),
76
- text: z.string().describe('The text to type into the element'),
77
- pressEnter: z.boolean().optional().describe('Whether to press Enter after typing (useful for search forms)'),
78
- });
79
-
80
- const BrowserNavigateSchema = z.object({
81
- url: z.string().describe('The full URL to navigate to (must include https://)'),
82
- });
83
-
84
- const BrowserScrollSchema = z.object({
85
- direction: z.enum(['up', 'down', 'left', 'right']).describe('Direction to scroll'),
86
- amount: z.number().optional().describe('Pixels to scroll (default: one viewport height)'),
87
- });
88
-
89
- const BrowserExtractSchema = z.object({
90
- query: z.string().optional().describe('Optional: specific content to extract from the page'),
91
- });
92
-
93
- const BrowserHoverSchema = z.object({
94
- index: z.number().describe('The index number of the element to hover over'),
95
- });
96
-
97
- const BrowserWaitSchema = z.object({
98
- duration: z.number().optional().describe('Milliseconds to wait (default: 1000)'),
99
- });
100
-
101
- const BrowserBackSchema = z.object({});
102
-
103
- const BrowserScreenshotSchema = z.object({});
104
-
105
- const BrowserGetPageStateSchema = z.object({});
106
-
107
- /**
108
- * Browser tool response interface
109
- * This is what the extension returns after executing the action
110
- */
111
- export interface BrowserToolResponse {
112
- requiresBrowserExecution: true;
113
- action: string;
114
- args: Record<string, unknown>;
115
- toolCallId?: string; // Added to help extension correlate with callback
116
- }
117
-
118
- /**
119
- * Options for creating browser tools
120
- */
121
- export interface CreateBrowserToolsOptions {
122
- /**
123
- * Optional callback that waits for browser action results.
124
- * When provided, tools will await this callback to get actual results from the extension.
125
- * When not provided, tools return markers immediately (for non-server contexts).
126
- */
127
- waitForResult?: BrowserToolCallback;
128
- }
129
-
130
- /**
131
- * Format browser action result for LLM consumption
132
- */
133
- function formatResultForLLM(result: BrowserActionResult, action: string): string {
134
- if (!result.success && result.error) {
135
- return `Browser action "${action}" failed: ${result.error}`;
136
- }
137
-
138
- const parts: string[] = [];
139
-
140
- if (result.url) {
141
- parts.push(`**Current URL:** ${result.url}`);
142
- }
143
- if (result.title) {
144
- parts.push(`**Page Title:** ${result.title}`);
145
- }
146
- if (result.elementList) {
147
- parts.push(`\n**Interactive Elements:**\n${result.elementList}`);
148
- }
149
- if (result.screenshot) {
150
- parts.push(`\n[Screenshot captured and displayed to user]`);
151
- }
152
-
153
- if (parts.length === 0) {
154
- return `Browser action "${action}" completed successfully.`;
155
- }
156
-
157
- return parts.join('\n');
158
- }
159
-
160
- /**
161
- * Create browser tools with optional callback for waiting on results
162
- *
163
- * When waitForResult callback is provided:
164
- * 1. Tool returns marker that triggers extension
165
- * 2. Tool then awaits callback to get actual results
166
- * 3. Returns real page state to LLM
167
- *
168
- * When no callback:
169
- * 1. Tool returns marker only (for non-server contexts)
170
- *
171
- * NOTE: These tools use TEXT-BASED element lists, NOT screenshots
172
- * Screenshots would be 100K+ tokens each - element lists are ~100 tokens
173
- */
174
- export function createBrowserTools(options?: CreateBrowserToolsOptions): DynamicStructuredTool[] {
175
- const { waitForResult } = options || {};
176
- const tools: DynamicStructuredTool[] = [];
177
-
178
- /**
179
- * Helper to create tool function that optionally waits for results
180
- * The toolCallId is extracted from the RunnableConfig passed by LangChain
181
- */
182
- const createToolFunction = (action: string) => {
183
- return async (args: Record<string, unknown>, config?: { toolCall?: { id?: string } }): Promise<string> => {
184
- const toolCallId = config?.toolCall?.id || `tool_${Date.now()}_${Math.random().toString(36).slice(2)}`;
185
-
186
- // Create marker for extension
187
- const marker: BrowserToolResponse = {
188
- requiresBrowserExecution: true,
189
- action,
190
- args,
191
- toolCallId,
192
- };
193
-
194
- // If no callback, return marker immediately (extension handles via SSE interception)
195
- if (!waitForResult) {
196
- return JSON.stringify(marker);
197
- }
198
-
199
- // With callback: wait for actual results from extension
200
- // The marker is still returned initially via SSE, but we wait for the callback
201
- try {
202
- const result = await waitForResult(action, args, toolCallId);
203
- return formatResultForLLM(result, action);
204
- } catch (error) {
205
- const errorMessage = error instanceof Error ? error.message : String(error);
206
- return `Browser action "${action}" failed: ${errorMessage}`;
207
- }
208
- };
209
- };
210
-
211
- // browser_click
212
- tools.push(
213
- tool(
214
- createToolFunction('click'),
215
- {
216
- name: EBrowserTools.CLICK,
217
- description: `Click an element on the current web page by its index number.
218
- The element list shows clickable items like: [0]<button>Submit</button> [1]<a href="/home">Home</a>
219
- Use the index number in brackets to click that element.
220
- After clicking, you receive an updated element list showing the new page state.`,
221
- schema: BrowserClickSchema,
222
- }
223
- )
224
- );
225
-
226
- // browser_type
227
- tools.push(
228
- tool(
229
- createToolFunction('type'),
230
- {
231
- name: EBrowserTools.TYPE,
232
- description: `Type text into an input element on the page.
233
- Find the input element in the list by its index (e.g., [5]<input placeholder="Search">).
234
- Set pressEnter: true to submit forms after typing.
235
- After typing, you receive an updated element list.`,
236
- schema: BrowserTypeSchema,
237
- }
238
- )
239
- );
240
-
241
- // browser_navigate
242
- tools.push(
243
- tool(
244
- createToolFunction('navigate'),
245
- {
246
- name: EBrowserTools.NAVIGATE,
247
- description: `Navigate to a URL. Always include the full URL with https://.
248
- After navigation, you receive the new page's element list.`,
249
- schema: BrowserNavigateSchema,
250
- }
251
- )
252
- );
253
-
254
- // browser_scroll
255
- tools.push(
256
- tool(
257
- createToolFunction('scroll'),
258
- {
259
- name: EBrowserTools.SCROLL,
260
- description: `Scroll the page to reveal more content.
261
- Use 'down' to scroll down, 'up' to scroll up.
262
- After scrolling, you receive an updated element list with newly visible elements.`,
263
- schema: BrowserScrollSchema,
264
- }
265
- )
266
- );
267
-
268
- // browser_extract
269
- tools.push(
270
- tool(
271
- createToolFunction('extract'),
272
- {
273
- name: EBrowserTools.EXTRACT,
274
- description: `Extract content from the current page.
275
- Returns page URL, title, and element list.`,
276
- schema: BrowserExtractSchema,
277
- }
278
- )
279
- );
280
-
281
- // browser_hover
282
- tools.push(
283
- tool(
284
- createToolFunction('hover'),
285
- {
286
- name: EBrowserTools.HOVER,
287
- description: `Hover over an element to reveal tooltips, dropdowns, or other hover-triggered content.
288
- After hovering, you receive an updated element list with any newly revealed elements.`,
289
- schema: BrowserHoverSchema,
290
- }
291
- )
292
- );
293
-
294
- // browser_wait
295
- tools.push(
296
- tool(
297
- createToolFunction('wait'),
298
- {
299
- name: EBrowserTools.WAIT,
300
- description: `Wait for a specified duration for page content to load.
301
- Use this after actions that trigger async content loading.
302
- After waiting, you receive an updated element list.`,
303
- schema: BrowserWaitSchema,
304
- }
305
- )
306
- );
307
-
308
- // browser_back
309
- tools.push(
310
- tool(
311
- createToolFunction('back'),
312
- {
313
- name: EBrowserTools.BACK,
314
- description: `Go back to the previous page in browser history.
315
- After going back, you receive the previous page's element list.`,
316
- schema: BrowserBackSchema,
317
- }
318
- )
319
- );
320
-
321
- // browser_screenshot
322
- tools.push(
323
- tool(
324
- createToolFunction('screenshot'),
325
- {
326
- name: EBrowserTools.SCREENSHOT,
327
- description: `Capture a screenshot of the current page.
328
- Returns the page state with a note that screenshot was displayed to the user.
329
- Use browser_get_page_state to get the element list for automation.`,
330
- schema: BrowserScreenshotSchema,
331
- }
332
- )
333
- );
334
-
335
- // browser_get_page_state
336
- tools.push(
337
- tool(
338
- createToolFunction('get_page_state'),
339
- {
340
- name: EBrowserTools.GET_PAGE_STATE,
341
- description: `Get the current page state including URL, title, and all interactive elements.
342
- Use this at the start of a task to see what elements are available.
343
- Returns a text list of elements with their index numbers for interaction.`,
344
- schema: BrowserGetPageStateSchema,
345
- }
346
- )
347
- );
348
-
349
- return tools;
350
- }
1
+ import { z } from 'zod';
2
+ import { tool, DynamicStructuredTool } from '@langchain/core/tools';
3
+ import type * as _t from '@/types';
4
+
5
+ /**
6
+ * Browser tool names - keep in sync with ranger-browser extension
7
+ * These tools execute locally in the browser extension, NOT on the server
8
+ */
9
+ export const EBrowserTools = {
10
+ CLICK: 'browser_click',
11
+ TYPE: 'browser_type',
12
+ NAVIGATE: 'browser_navigate',
13
+ SCROLL: 'browser_scroll',
14
+ EXTRACT: 'browser_extract',
15
+ HOVER: 'browser_hover',
16
+ WAIT: 'browser_wait',
17
+ BACK: 'browser_back',
18
+ SCREENSHOT: 'browser_screenshot',
19
+ GET_PAGE_STATE: 'browser_get_page_state',
20
+ } as const;
21
+
22
+ export type BrowserToolName =
23
+ (typeof EBrowserTools)[keyof typeof EBrowserTools];
24
+
25
+ /**
26
+ * Callback function type for waiting on browser action results
27
+ * This allows the server (Ranger) to provide a callback that waits for the extension
28
+ * to POST results back to the server before returning to the LLM.
29
+ *
30
+ * @param action - The browser action (click, type, navigate, etc.)
31
+ * @param args - Arguments for the action
32
+ * @param toolCallId - Unique ID for this tool call (from config.toolCall.id)
33
+ * @returns Promise that resolves with the actual browser result (page state, etc.)
34
+ */
35
+ export type BrowserToolCallback = (
36
+ action: string,
37
+ args: Record<string, unknown>,
38
+ toolCallId: string
39
+ ) => Promise<BrowserActionResult>;
40
+
41
+ /**
42
+ * Result returned from browser action execution
43
+ */
44
+ export interface BrowserActionResult {
45
+ success: boolean;
46
+ url?: string;
47
+ title?: string;
48
+ elementList?: string; // Text-based element list
49
+ error?: string;
50
+ screenshot?: string; // Base64 screenshot (if requested)
51
+ }
52
+
53
+ /**
54
+ * Check if browser capability is available based on request headers or context
55
+ * The browser extension sets these headers when connected:
56
+ * - X-Ranger-Browser-Extension: true
57
+ * - X-Ranger-Browser-Capable: true
58
+ */
59
+ export function hasBrowserCapability(req?: {
60
+ headers?: Record<string, string | string[] | undefined>;
61
+ }): boolean {
62
+ if (!req?.headers) {
63
+ return false;
64
+ }
65
+
66
+ const browserExtension = req.headers['x-ranger-browser-extension'];
67
+ const browserCapable = req.headers['x-ranger-browser-capable'];
68
+
69
+ return browserExtension === 'true' || browserCapable === 'true';
70
+ }
71
+
72
+ // Tool schemas
73
+ const BrowserClickSchema = z.object({
74
+ index: z
75
+ .number()
76
+ .describe(
77
+ 'The index number [0], [1], etc. of the element to click from the page state element list'
78
+ ),
79
+ });
80
+
81
+ const BrowserTypeSchema = z.object({
82
+ index: z
83
+ .number()
84
+ .describe('The index number of the input element to type into'),
85
+ text: z.string().describe('The text to type into the element'),
86
+ pressEnter: z
87
+ .boolean()
88
+ .optional()
89
+ .describe('Whether to press Enter after typing (useful for search forms)'),
90
+ });
91
+
92
+ const BrowserNavigateSchema = z.object({
93
+ url: z
94
+ .string()
95
+ .describe('The full URL to navigate to (must include https://)'),
96
+ });
97
+
98
+ const BrowserScrollSchema = z.object({
99
+ direction: z
100
+ .enum(['up', 'down', 'left', 'right'])
101
+ .describe('Direction to scroll'),
102
+ amount: z
103
+ .number()
104
+ .optional()
105
+ .describe('Pixels to scroll (default: one viewport height)'),
106
+ });
107
+
108
+ const BrowserExtractSchema = z.object({
109
+ query: z
110
+ .string()
111
+ .optional()
112
+ .describe('Optional: specific content to extract from the page'),
113
+ });
114
+
115
+ const BrowserHoverSchema = z.object({
116
+ index: z.number().describe('The index number of the element to hover over'),
117
+ });
118
+
119
+ const BrowserWaitSchema = z.object({
120
+ duration: z
121
+ .number()
122
+ .optional()
123
+ .describe('Milliseconds to wait (default: 1000)'),
124
+ });
125
+
126
+ const BrowserBackSchema = z.object({});
127
+
128
+ const BrowserScreenshotSchema = z.object({});
129
+
130
+ const BrowserGetPageStateSchema = z.object({});
131
+
132
+ /**
133
+ * Browser tool response interface
134
+ * This is what the extension returns after executing the action
135
+ */
136
+ export interface BrowserToolResponse {
137
+ requiresBrowserExecution: true;
138
+ action: string;
139
+ args: Record<string, unknown>;
140
+ toolCallId?: string; // Added to help extension correlate with callback
141
+ }
142
+
143
+ /**
144
+ * Options for creating browser tools
145
+ */
146
+ export interface CreateBrowserToolsOptions {
147
+ /**
148
+ * Optional callback that waits for browser action results.
149
+ * When provided, tools will await this callback to get actual results from the extension.
150
+ * When not provided, tools return markers immediately (for non-server contexts).
151
+ */
152
+ waitForResult?: BrowserToolCallback;
153
+ }
154
+
155
+ /**
156
+ * Format browser action result for LLM consumption
157
+ */
158
+ function formatResultForLLM(
159
+ result: BrowserActionResult,
160
+ action: string
161
+ ): string {
162
+ if (!result.success && result.error) {
163
+ return `Browser action "${action}" failed: ${result.error}`;
164
+ }
165
+
166
+ const parts: string[] = [];
167
+
168
+ if (result.url != null && result.url !== '') {
169
+ parts.push(`**Current URL:** ${result.url}`);
170
+ }
171
+ if (result.title != null && result.title !== '') {
172
+ parts.push(`**Page Title:** ${result.title}`);
173
+ }
174
+ if (result.elementList != null && result.elementList !== '') {
175
+ parts.push(`\n**Interactive Elements:**\n${result.elementList}`);
176
+ }
177
+ if (result.screenshot != null && result.screenshot !== '') {
178
+ parts.push('\n[Screenshot captured and displayed to user]');
179
+ }
180
+
181
+ if (parts.length === 0) {
182
+ return `Browser action "${action}" completed successfully.`;
183
+ }
184
+
185
+ return parts.join('\n');
186
+ }
187
+
188
+ /**
189
+ * Create browser tools with optional callback for waiting on results
190
+ *
191
+ * When waitForResult callback is provided:
192
+ * 1. Tool returns marker that triggers extension
193
+ * 2. Tool then awaits callback to get actual results
194
+ * 3. Returns real page state to LLM
195
+ *
196
+ * When no callback:
197
+ * 1. Tool returns marker only (for non-server contexts)
198
+ *
199
+ * NOTE: These tools use TEXT-BASED element lists, NOT screenshots
200
+ * Screenshots would be 100K+ tokens each - element lists are ~100 tokens
201
+ */
202
+ export function createBrowserTools(
203
+ options?: CreateBrowserToolsOptions
204
+ ): DynamicStructuredTool[] {
205
+ const { waitForResult } = options || {};
206
+ const tools: DynamicStructuredTool[] = [];
207
+
208
+ /**
209
+ * Helper to create tool function that optionally waits for results
210
+ * The toolCallId is extracted from the RunnableConfig passed by LangChain
211
+ */
212
+ const createToolFunction = (action: string) => {
213
+ return async (
214
+ args: Record<string, unknown>,
215
+ config?: { toolCall?: { id?: string } }
216
+ ): Promise<string> => {
217
+ const toolCallId =
218
+ config?.toolCall?.id ??
219
+ `tool_${Date.now()}_${Math.random().toString(36).slice(2)}`;
220
+
221
+ // Create marker for extension
222
+ const marker: BrowserToolResponse = {
223
+ requiresBrowserExecution: true,
224
+ action,
225
+ args,
226
+ toolCallId,
227
+ };
228
+
229
+ // If no callback, return marker immediately (extension handles via SSE interception)
230
+ if (!waitForResult) {
231
+ return JSON.stringify(marker);
232
+ }
233
+
234
+ // With callback: wait for actual results from extension
235
+ // The marker is still returned initially via SSE, but we wait for the callback
236
+ try {
237
+ const result = await waitForResult(action, args, toolCallId);
238
+ return formatResultForLLM(result, action);
239
+ } catch (error) {
240
+ const errorMessage =
241
+ error instanceof Error ? error.message : String(error);
242
+ return `Browser action "${action}" failed: ${errorMessage}`;
243
+ }
244
+ };
245
+ };
246
+
247
+ // browser_click
248
+ tools.push(
249
+ tool(createToolFunction('click'), {
250
+ name: EBrowserTools.CLICK,
251
+ description: `Click an element on the current web page by its index number.
252
+ The element list shows clickable items like: [0]<button>Submit</button> [1]<a href="/home">Home</a>
253
+ Use the index number in brackets to click that element.
254
+ After clicking, you receive an updated element list showing the new page state.`,
255
+ schema: BrowserClickSchema,
256
+ })
257
+ );
258
+
259
+ // browser_type
260
+ tools.push(
261
+ tool(createToolFunction('type'), {
262
+ name: EBrowserTools.TYPE,
263
+ description: `Type text into an input element on the page.
264
+ Find the input element in the list by its index (e.g., [5]<input placeholder="Search">).
265
+ Set pressEnter: true to submit forms after typing.
266
+ After typing, you receive an updated element list.`,
267
+ schema: BrowserTypeSchema,
268
+ })
269
+ );
270
+
271
+ // browser_navigate
272
+ tools.push(
273
+ tool(createToolFunction('navigate'), {
274
+ name: EBrowserTools.NAVIGATE,
275
+ description: `Navigate to a URL. Always include the full URL with https://.
276
+ After navigation, you receive the new page's element list.`,
277
+ schema: BrowserNavigateSchema,
278
+ })
279
+ );
280
+
281
+ // browser_scroll
282
+ tools.push(
283
+ tool(createToolFunction('scroll'), {
284
+ name: EBrowserTools.SCROLL,
285
+ description: `Scroll the page to reveal more content.
286
+ Use 'down' to scroll down, 'up' to scroll up.
287
+ After scrolling, you receive an updated element list with newly visible elements.`,
288
+ schema: BrowserScrollSchema,
289
+ })
290
+ );
291
+
292
+ // browser_extract
293
+ tools.push(
294
+ tool(createToolFunction('extract'), {
295
+ name: EBrowserTools.EXTRACT,
296
+ description: `Extract content from the current page.
297
+ Returns page URL, title, and element list.`,
298
+ schema: BrowserExtractSchema,
299
+ })
300
+ );
301
+
302
+ // browser_hover
303
+ tools.push(
304
+ tool(createToolFunction('hover'), {
305
+ name: EBrowserTools.HOVER,
306
+ description: `Hover over an element to reveal tooltips, dropdowns, or other hover-triggered content.
307
+ After hovering, you receive an updated element list with any newly revealed elements.`,
308
+ schema: BrowserHoverSchema,
309
+ })
310
+ );
311
+
312
+ // browser_wait
313
+ tools.push(
314
+ tool(createToolFunction('wait'), {
315
+ name: EBrowserTools.WAIT,
316
+ description: `Wait for a specified duration for page content to load.
317
+ Use this after actions that trigger async content loading.
318
+ After waiting, you receive an updated element list.`,
319
+ schema: BrowserWaitSchema,
320
+ })
321
+ );
322
+
323
+ // browser_back
324
+ tools.push(
325
+ tool(createToolFunction('back'), {
326
+ name: EBrowserTools.BACK,
327
+ description: `Go back to the previous page in browser history.
328
+ After going back, you receive the previous page's element list.`,
329
+ schema: BrowserBackSchema,
330
+ })
331
+ );
332
+
333
+ // browser_screenshot
334
+ tools.push(
335
+ tool(createToolFunction('screenshot'), {
336
+ name: EBrowserTools.SCREENSHOT,
337
+ description: `Capture a screenshot of the current page.
338
+ Returns the page state with a note that screenshot was displayed to the user.
339
+ Use browser_get_page_state to get the element list for automation.`,
340
+ schema: BrowserScreenshotSchema,
341
+ })
342
+ );
343
+
344
+ // browser_get_page_state
345
+ tools.push(
346
+ tool(createToolFunction('get_page_state'), {
347
+ name: EBrowserTools.GET_PAGE_STATE,
348
+ description: `Get the current page state including URL, title, and all interactive elements.
349
+ Use this at the start of a task to see what elements are available.
350
+ Returns a text list of elements with their index numbers for interaction.`,
351
+ schema: BrowserGetPageStateSchema,
352
+ })
353
+ );
354
+
355
+ return tools;
356
+ }