illuma-agents 1.0.26 → 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 +125 -113
  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 +125 -113
  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 +45 -5
  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 -310
  41. package/src/tools/__tests__/BrowserTools.test.ts +263 -257
  42. package/src/types/stream.ts +15 -0
@@ -1,310 +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
- * Check if browser capability is available based on request headers or context
26
- * The browser extension sets these headers when connected:
27
- * - X-Ranger-Browser-Extension: true
28
- * - X-Ranger-Browser-Capable: true
29
- */
30
- export function hasBrowserCapability(req?: { headers?: Record<string, string | string[] | undefined> }): boolean {
31
- if (!req?.headers) {
32
- return false;
33
- }
34
-
35
- const browserExtension = req.headers['x-ranger-browser-extension'];
36
- const browserCapable = req.headers['x-ranger-browser-capable'];
37
-
38
- return browserExtension === 'true' || browserCapable === 'true';
39
- }
40
-
41
- // Tool schemas
42
- const BrowserClickSchema = z.object({
43
- index: z.number().describe('The index number [0], [1], etc. of the element to click from the page state element list'),
44
- });
45
-
46
- const BrowserTypeSchema = z.object({
47
- index: z.number().describe('The index number of the input element to type into'),
48
- text: z.string().describe('The text to type into the element'),
49
- pressEnter: z.boolean().optional().describe('Whether to press Enter after typing (useful for search forms)'),
50
- });
51
-
52
- const BrowserNavigateSchema = z.object({
53
- url: z.string().describe('The full URL to navigate to (must include https://)'),
54
- });
55
-
56
- const BrowserScrollSchema = z.object({
57
- direction: z.enum(['up', 'down', 'left', 'right']).describe('Direction to scroll'),
58
- amount: z.number().optional().describe('Pixels to scroll (default: one viewport height)'),
59
- });
60
-
61
- const BrowserExtractSchema = z.object({
62
- query: z.string().optional().describe('Optional: specific content to extract from the page'),
63
- });
64
-
65
- const BrowserHoverSchema = z.object({
66
- index: z.number().describe('The index number of the element to hover over'),
67
- });
68
-
69
- const BrowserWaitSchema = z.object({
70
- duration: z.number().optional().describe('Milliseconds to wait (default: 1000)'),
71
- });
72
-
73
- const BrowserBackSchema = z.object({});
74
-
75
- const BrowserScreenshotSchema = z.object({});
76
-
77
- const BrowserGetPageStateSchema = z.object({});
78
-
79
- /**
80
- * Browser tool response interface
81
- * This is what the extension returns after executing the action
82
- */
83
- export interface BrowserToolResponse {
84
- requiresBrowserExecution: true;
85
- action: string;
86
- args: Record<string, unknown>;
87
- }
88
-
89
- /**
90
- * Create placeholder browser tools that signal to the extension to execute locally
91
- * The server creates these tools to give the LLM the schema, but actual execution
92
- * happens in the browser extension which intercepts tool calls
93
- *
94
- * NOTE: These tools use TEXT-BASED element lists, NOT screenshots
95
- * Screenshots would be 100K+ tokens each - element lists are ~100 tokens
96
- */
97
- export function createBrowserTools(): DynamicStructuredTool[] {
98
- const tools: DynamicStructuredTool[] = [];
99
-
100
- // browser_click
101
- tools.push(
102
- tool(
103
- async (args): Promise<string> => {
104
- // This returns a marker that tells the extension to execute locally
105
- const response: BrowserToolResponse = {
106
- requiresBrowserExecution: true,
107
- action: 'click',
108
- args,
109
- };
110
- return JSON.stringify(response);
111
- },
112
- {
113
- name: EBrowserTools.CLICK,
114
- description: `Click an element on the current web page by its index number.
115
- The element list shows clickable items like: [0]<button>Submit</button> [1]<a href="/home">Home</a>
116
- Use the index number in brackets to click that element.
117
- After clicking, you receive an updated element list showing the new page state.`,
118
- schema: BrowserClickSchema,
119
- }
120
- )
121
- );
122
-
123
- // browser_type
124
- tools.push(
125
- tool(
126
- async (args): Promise<string> => {
127
- const response: BrowserToolResponse = {
128
- requiresBrowserExecution: true,
129
- action: 'type',
130
- args,
131
- };
132
- return JSON.stringify(response);
133
- },
134
- {
135
- name: EBrowserTools.TYPE,
136
- description: `Type text into an input element on the page.
137
- Find the input element in the list by its index (e.g., [5]<input placeholder="Search">).
138
- Set pressEnter: true to submit forms after typing.
139
- After typing, you receive an updated element list.`,
140
- schema: BrowserTypeSchema,
141
- }
142
- )
143
- );
144
-
145
- // browser_navigate
146
- tools.push(
147
- tool(
148
- async (args): Promise<string> => {
149
- const response: BrowserToolResponse = {
150
- requiresBrowserExecution: true,
151
- action: 'navigate',
152
- args,
153
- };
154
- return JSON.stringify(response);
155
- },
156
- {
157
- name: EBrowserTools.NAVIGATE,
158
- description: `Navigate to a URL. Always include the full URL with https://.
159
- After navigation, you receive the new page's element list.`,
160
- schema: BrowserNavigateSchema,
161
- }
162
- )
163
- );
164
-
165
- // browser_scroll
166
- tools.push(
167
- tool(
168
- async (args): Promise<string> => {
169
- const response: BrowserToolResponse = {
170
- requiresBrowserExecution: true,
171
- action: 'scroll',
172
- args,
173
- };
174
- return JSON.stringify(response);
175
- },
176
- {
177
- name: EBrowserTools.SCROLL,
178
- description: `Scroll the page to reveal more content.
179
- Use 'down' to scroll down, 'up' to scroll up.
180
- After scrolling, you receive an updated element list with newly visible elements.`,
181
- schema: BrowserScrollSchema,
182
- }
183
- )
184
- );
185
-
186
- // browser_extract
187
- tools.push(
188
- tool(
189
- async (args): Promise<string> => {
190
- const response: BrowserToolResponse = {
191
- requiresBrowserExecution: true,
192
- action: 'extract',
193
- args,
194
- };
195
- return JSON.stringify(response);
196
- },
197
- {
198
- name: EBrowserTools.EXTRACT,
199
- description: `Extract content from the current page.
200
- Returns page URL, title, and element list.`,
201
- schema: BrowserExtractSchema,
202
- }
203
- )
204
- );
205
-
206
- // browser_hover
207
- tools.push(
208
- tool(
209
- async (args): Promise<string> => {
210
- const response: BrowserToolResponse = {
211
- requiresBrowserExecution: true,
212
- action: 'hover',
213
- args,
214
- };
215
- return JSON.stringify(response);
216
- },
217
- {
218
- name: EBrowserTools.HOVER,
219
- description: `Hover over an element to reveal tooltips, dropdowns, or other hover-triggered content.
220
- After hovering, you receive an updated element list with any newly revealed elements.`,
221
- schema: BrowserHoverSchema,
222
- }
223
- )
224
- );
225
-
226
- // browser_wait
227
- tools.push(
228
- tool(
229
- async (args): Promise<string> => {
230
- const response: BrowserToolResponse = {
231
- requiresBrowserExecution: true,
232
- action: 'wait',
233
- args,
234
- };
235
- return JSON.stringify(response);
236
- },
237
- {
238
- name: EBrowserTools.WAIT,
239
- description: `Wait for a specified duration for page content to load.
240
- Use this after actions that trigger async content loading.
241
- After waiting, you receive an updated element list.`,
242
- schema: BrowserWaitSchema,
243
- }
244
- )
245
- );
246
-
247
- // browser_back
248
- tools.push(
249
- tool(
250
- async (args): Promise<string> => {
251
- const response: BrowserToolResponse = {
252
- requiresBrowserExecution: true,
253
- action: 'back',
254
- args,
255
- };
256
- return JSON.stringify(response);
257
- },
258
- {
259
- name: EBrowserTools.BACK,
260
- description: `Go back to the previous page in browser history.
261
- After going back, you receive the previous page's element list.`,
262
- schema: BrowserBackSchema,
263
- }
264
- )
265
- );
266
-
267
- // browser_screenshot
268
- tools.push(
269
- tool(
270
- async (args): Promise<string> => {
271
- const response: BrowserToolResponse = {
272
- requiresBrowserExecution: true,
273
- action: 'screenshot',
274
- args,
275
- };
276
- return JSON.stringify(response);
277
- },
278
- {
279
- name: EBrowserTools.SCREENSHOT,
280
- description: `Capture a screenshot of the current page.
281
- NOTE: Screenshot is displayed to the USER only, not returned to you.
282
- Use browser_get_page_state instead to get the element list.`,
283
- schema: BrowserScreenshotSchema,
284
- }
285
- )
286
- );
287
-
288
- // browser_get_page_state
289
- tools.push(
290
- tool(
291
- async (args): Promise<string> => {
292
- const response: BrowserToolResponse = {
293
- requiresBrowserExecution: true,
294
- action: 'get_page_state',
295
- args,
296
- };
297
- return JSON.stringify(response);
298
- },
299
- {
300
- name: EBrowserTools.GET_PAGE_STATE,
301
- description: `Get the current page state including URL, title, and all interactive elements.
302
- Use this at the start of a task to see what elements are available.
303
- Returns a text list of elements with their index numbers.`,
304
- schema: BrowserGetPageStateSchema,
305
- }
306
- )
307
- );
308
-
309
- return tools;
310
- }
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
+ }