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.
- package/dist/cjs/graphs/Graph.cjs +3 -3
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/main.cjs +12 -34
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/run.cjs +3 -209
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +3 -3
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/main.mjs +5 -4
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/run.mjs +4 -208
- package/dist/esm/run.mjs.map +1 -1
- package/dist/types/index.d.ts +4 -3
- package/dist/types/run.d.ts +0 -48
- package/dist/types/types/run.d.ts +0 -8
- package/package.json +1 -1
- package/src/graphs/Graph.ts +3 -3
- package/src/index.ts +5 -4
- package/src/run.ts +3 -260
- package/src/types/run.ts +0 -8
- package/dist/cjs/tools/BrowserInterruptTools.cjs +0 -431
- package/dist/cjs/tools/BrowserInterruptTools.cjs.map +0 -1
- package/dist/cjs/tools/BrowserTools.cjs +0 -533
- package/dist/cjs/tools/BrowserTools.cjs.map +0 -1
- package/dist/esm/tools/BrowserInterruptTools.mjs +0 -415
- package/dist/esm/tools/BrowserInterruptTools.mjs.map +0 -1
- package/dist/esm/tools/BrowserTools.mjs +0 -517
- package/dist/esm/tools/BrowserTools.mjs.map +0 -1
- package/dist/types/tools/BrowserInterruptTools.d.ts +0 -282
- package/dist/types/tools/BrowserTools.d.ts +0 -259
- package/src/specs/browser-interrupt-tools.test.ts +0 -235
- package/src/tools/BrowserInterruptTools.ts +0 -571
- package/src/tools/BrowserTools.test.ts +0 -563
- package/src/tools/BrowserTools.ts +0 -650
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser Automation Tools with LangGraph Interrupt Support
|
|
3
|
-
*
|
|
4
|
-
* These tools use LangGraph's interrupt() mechanism to pause execution
|
|
5
|
-
* and wait for the browser extension to execute actions and return results.
|
|
6
|
-
*
|
|
7
|
-
* Flow:
|
|
8
|
-
* 1. Agent calls browser tool (e.g., browser_navigate)
|
|
9
|
-
* 2. Tool calls interrupt() with action details
|
|
10
|
-
* 3. Graph pauses and returns interrupt to client
|
|
11
|
-
* 4. Extension executes action in browser
|
|
12
|
-
* 5. Extension sends resume Command with actual result
|
|
13
|
-
* 6. Graph continues with real browser data
|
|
14
|
-
*
|
|
15
|
-
* This enables proper chain-of-thought with browser context because
|
|
16
|
-
* the agent receives ACTUAL results (page elements, screenshots, etc.)
|
|
17
|
-
* instead of placeholder acknowledgments.
|
|
18
|
-
*/
|
|
19
|
-
import { z } from 'zod';
|
|
20
|
-
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
21
|
-
/**
|
|
22
|
-
* Interrupt payload sent to the extension
|
|
23
|
-
*/
|
|
24
|
-
export interface BrowserInterrupt {
|
|
25
|
-
/** Type of browser action to execute */
|
|
26
|
-
type: 'browser_interrupt';
|
|
27
|
-
/** The specific action to perform */
|
|
28
|
-
action: BrowserAction;
|
|
29
|
-
/** Unique ID for this interrupt (for matching resume) */
|
|
30
|
-
interruptId: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Browser action types
|
|
34
|
-
*/
|
|
35
|
-
export type BrowserAction = {
|
|
36
|
-
type: 'navigate';
|
|
37
|
-
url: string;
|
|
38
|
-
reason?: string;
|
|
39
|
-
} | {
|
|
40
|
-
type: 'click';
|
|
41
|
-
index?: number;
|
|
42
|
-
coordinates?: {
|
|
43
|
-
x: number;
|
|
44
|
-
y: number;
|
|
45
|
-
};
|
|
46
|
-
reason?: string;
|
|
47
|
-
} | {
|
|
48
|
-
type: 'type';
|
|
49
|
-
index: number;
|
|
50
|
-
text: string;
|
|
51
|
-
clear?: boolean;
|
|
52
|
-
pressEnter?: boolean;
|
|
53
|
-
} | {
|
|
54
|
-
type: 'scroll';
|
|
55
|
-
direction: 'up' | 'down' | 'left' | 'right';
|
|
56
|
-
amount?: number;
|
|
57
|
-
} | {
|
|
58
|
-
type: 'extract';
|
|
59
|
-
query?: string;
|
|
60
|
-
selector?: string;
|
|
61
|
-
} | {
|
|
62
|
-
type: 'hover';
|
|
63
|
-
index: number;
|
|
64
|
-
} | {
|
|
65
|
-
type: 'wait';
|
|
66
|
-
duration?: number;
|
|
67
|
-
reason?: string;
|
|
68
|
-
} | {
|
|
69
|
-
type: 'back';
|
|
70
|
-
reason?: string;
|
|
71
|
-
} | {
|
|
72
|
-
type: 'screenshot';
|
|
73
|
-
fullPage?: boolean;
|
|
74
|
-
} | {
|
|
75
|
-
type: 'get_page_state';
|
|
76
|
-
reason?: string;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* Result returned from extension after executing action
|
|
80
|
-
*/
|
|
81
|
-
export interface BrowserActionResult {
|
|
82
|
-
success: boolean;
|
|
83
|
-
error?: string;
|
|
84
|
-
/** Page state after action (for navigate, click, get_page_state) */
|
|
85
|
-
pageState?: {
|
|
86
|
-
url: string;
|
|
87
|
-
title: string;
|
|
88
|
-
/** Formatted element list for LLM */
|
|
89
|
-
elementList: string;
|
|
90
|
-
elementCount: number;
|
|
91
|
-
scrollPosition: number;
|
|
92
|
-
scrollHeight: number;
|
|
93
|
-
viewportHeight: number;
|
|
94
|
-
};
|
|
95
|
-
/** Screenshot data URL */
|
|
96
|
-
screenshot?: string;
|
|
97
|
-
/** Extracted content */
|
|
98
|
-
extractedContent?: string;
|
|
99
|
-
/** Any additional data */
|
|
100
|
-
data?: unknown;
|
|
101
|
-
}
|
|
102
|
-
declare const BrowserClickSchema: z.ZodObject<{
|
|
103
|
-
index: z.ZodOptional<z.ZodNumber>;
|
|
104
|
-
coordinates: z.ZodOptional<z.ZodObject<{
|
|
105
|
-
x: z.ZodNumber;
|
|
106
|
-
y: z.ZodNumber;
|
|
107
|
-
}, "strip", z.ZodTypeAny, {
|
|
108
|
-
y: number;
|
|
109
|
-
x: number;
|
|
110
|
-
}, {
|
|
111
|
-
y: number;
|
|
112
|
-
x: number;
|
|
113
|
-
}>>;
|
|
114
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
115
|
-
}, "strip", z.ZodTypeAny, {
|
|
116
|
-
index?: number | undefined;
|
|
117
|
-
coordinates?: {
|
|
118
|
-
y: number;
|
|
119
|
-
x: number;
|
|
120
|
-
} | undefined;
|
|
121
|
-
reason?: string | undefined;
|
|
122
|
-
}, {
|
|
123
|
-
index?: number | undefined;
|
|
124
|
-
coordinates?: {
|
|
125
|
-
y: number;
|
|
126
|
-
x: number;
|
|
127
|
-
} | undefined;
|
|
128
|
-
reason?: string | undefined;
|
|
129
|
-
}>;
|
|
130
|
-
declare const BrowserTypeSchema: z.ZodObject<{
|
|
131
|
-
index: z.ZodNumber;
|
|
132
|
-
text: z.ZodString;
|
|
133
|
-
clear: z.ZodOptional<z.ZodBoolean>;
|
|
134
|
-
pressEnter: z.ZodOptional<z.ZodBoolean>;
|
|
135
|
-
}, "strip", z.ZodTypeAny, {
|
|
136
|
-
text: string;
|
|
137
|
-
index: number;
|
|
138
|
-
clear?: boolean | undefined;
|
|
139
|
-
pressEnter?: boolean | undefined;
|
|
140
|
-
}, {
|
|
141
|
-
text: string;
|
|
142
|
-
index: number;
|
|
143
|
-
clear?: boolean | undefined;
|
|
144
|
-
pressEnter?: boolean | undefined;
|
|
145
|
-
}>;
|
|
146
|
-
declare const BrowserNavigateSchema: z.ZodObject<{
|
|
147
|
-
url: z.ZodString;
|
|
148
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
149
|
-
}, "strip", z.ZodTypeAny, {
|
|
150
|
-
url: string;
|
|
151
|
-
reason?: string | undefined;
|
|
152
|
-
}, {
|
|
153
|
-
url: string;
|
|
154
|
-
reason?: string | undefined;
|
|
155
|
-
}>;
|
|
156
|
-
declare const BrowserScrollSchema: z.ZodObject<{
|
|
157
|
-
direction: z.ZodEnum<["up", "down", "left", "right"]>;
|
|
158
|
-
amount: z.ZodOptional<z.ZodNumber>;
|
|
159
|
-
}, "strip", z.ZodTypeAny, {
|
|
160
|
-
direction: "up" | "down" | "left" | "right";
|
|
161
|
-
amount?: number | undefined;
|
|
162
|
-
}, {
|
|
163
|
-
direction: "up" | "down" | "left" | "right";
|
|
164
|
-
amount?: number | undefined;
|
|
165
|
-
}>;
|
|
166
|
-
declare const BrowserExtractSchema: z.ZodObject<{
|
|
167
|
-
query: z.ZodOptional<z.ZodString>;
|
|
168
|
-
selector: z.ZodOptional<z.ZodString>;
|
|
169
|
-
}, "strip", z.ZodTypeAny, {
|
|
170
|
-
query?: string | undefined;
|
|
171
|
-
selector?: string | undefined;
|
|
172
|
-
}, {
|
|
173
|
-
query?: string | undefined;
|
|
174
|
-
selector?: string | undefined;
|
|
175
|
-
}>;
|
|
176
|
-
declare const BrowserHoverSchema: z.ZodObject<{
|
|
177
|
-
index: z.ZodNumber;
|
|
178
|
-
}, "strip", z.ZodTypeAny, {
|
|
179
|
-
index: number;
|
|
180
|
-
}, {
|
|
181
|
-
index: number;
|
|
182
|
-
}>;
|
|
183
|
-
declare const BrowserWaitSchema: z.ZodObject<{
|
|
184
|
-
duration: z.ZodOptional<z.ZodNumber>;
|
|
185
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
186
|
-
}, "strip", z.ZodTypeAny, {
|
|
187
|
-
duration?: number | undefined;
|
|
188
|
-
reason?: string | undefined;
|
|
189
|
-
}, {
|
|
190
|
-
duration?: number | undefined;
|
|
191
|
-
reason?: string | undefined;
|
|
192
|
-
}>;
|
|
193
|
-
declare const BrowserGoBackSchema: z.ZodObject<{
|
|
194
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
195
|
-
}, "strip", z.ZodTypeAny, {
|
|
196
|
-
reason?: string | undefined;
|
|
197
|
-
}, {
|
|
198
|
-
reason?: string | undefined;
|
|
199
|
-
}>;
|
|
200
|
-
declare const BrowserScreenshotSchema: z.ZodObject<{
|
|
201
|
-
fullPage: z.ZodOptional<z.ZodBoolean>;
|
|
202
|
-
}, "strip", z.ZodTypeAny, {
|
|
203
|
-
fullPage?: boolean | undefined;
|
|
204
|
-
}, {
|
|
205
|
-
fullPage?: boolean | undefined;
|
|
206
|
-
}>;
|
|
207
|
-
declare const BrowserGetPageStateSchema: z.ZodObject<{
|
|
208
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
209
|
-
}, "strip", z.ZodTypeAny, {
|
|
210
|
-
reason?: string | undefined;
|
|
211
|
-
}, {
|
|
212
|
-
reason?: string | undefined;
|
|
213
|
-
}>;
|
|
214
|
-
/**
|
|
215
|
-
* Navigate tool - navigates to URL and returns page state
|
|
216
|
-
*/
|
|
217
|
-
export declare function createBrowserNavigateInterruptTool(): DynamicStructuredTool<typeof BrowserNavigateSchema>;
|
|
218
|
-
/**
|
|
219
|
-
* Click tool - clicks element and returns updated state
|
|
220
|
-
*/
|
|
221
|
-
export declare function createBrowserClickInterruptTool(): DynamicStructuredTool<typeof BrowserClickSchema>;
|
|
222
|
-
/**
|
|
223
|
-
* Type tool - types text into input field
|
|
224
|
-
*/
|
|
225
|
-
export declare function createBrowserTypeInterruptTool(): DynamicStructuredTool<typeof BrowserTypeSchema>;
|
|
226
|
-
/**
|
|
227
|
-
* Get page state tool - captures current page elements
|
|
228
|
-
*/
|
|
229
|
-
export declare function createBrowserGetPageStateInterruptTool(): DynamicStructuredTool<typeof BrowserGetPageStateSchema>;
|
|
230
|
-
/**
|
|
231
|
-
* Scroll tool
|
|
232
|
-
*/
|
|
233
|
-
export declare function createBrowserScrollInterruptTool(): DynamicStructuredTool<typeof BrowserScrollSchema>;
|
|
234
|
-
/**
|
|
235
|
-
* Extract tool
|
|
236
|
-
*/
|
|
237
|
-
export declare function createBrowserExtractInterruptTool(): DynamicStructuredTool<typeof BrowserExtractSchema>;
|
|
238
|
-
/**
|
|
239
|
-
* Hover tool
|
|
240
|
-
*/
|
|
241
|
-
export declare function createBrowserHoverInterruptTool(): DynamicStructuredTool<typeof BrowserHoverSchema>;
|
|
242
|
-
/**
|
|
243
|
-
* Wait tool
|
|
244
|
-
*/
|
|
245
|
-
export declare function createBrowserWaitInterruptTool(): DynamicStructuredTool<typeof BrowserWaitSchema>;
|
|
246
|
-
/**
|
|
247
|
-
* Go back tool
|
|
248
|
-
*/
|
|
249
|
-
export declare function createBrowserGoBackInterruptTool(): DynamicStructuredTool<typeof BrowserGoBackSchema>;
|
|
250
|
-
/**
|
|
251
|
-
* Screenshot tool
|
|
252
|
-
*/
|
|
253
|
-
export declare function createBrowserScreenshotInterruptTool(): DynamicStructuredTool<typeof BrowserScreenshotSchema>;
|
|
254
|
-
export declare const EBrowserInterruptTools: {
|
|
255
|
-
readonly CLICK: "browser_click";
|
|
256
|
-
readonly TYPE: "browser_type";
|
|
257
|
-
readonly NAVIGATE: "browser_navigate";
|
|
258
|
-
readonly SCROLL: "browser_scroll";
|
|
259
|
-
readonly EXTRACT: "browser_extract";
|
|
260
|
-
readonly HOVER: "browser_hover";
|
|
261
|
-
readonly WAIT: "browser_wait";
|
|
262
|
-
readonly BACK: "browser_back";
|
|
263
|
-
readonly SCREENSHOT: "browser_screenshot";
|
|
264
|
-
readonly GET_PAGE_STATE: "browser_get_page_state";
|
|
265
|
-
};
|
|
266
|
-
export declare const BROWSER_INTERRUPT_TOOL_NAMES: ("browser_navigate" | "browser_click" | "browser_type" | "browser_get_page_state" | "browser_scroll" | "browser_extract" | "browser_hover" | "browser_wait" | "browser_back" | "browser_screenshot")[];
|
|
267
|
-
export type BrowserInterruptToolName = typeof BROWSER_INTERRUPT_TOOL_NAMES[number];
|
|
268
|
-
export declare function isBrowserInterruptToolCall(toolName: string): toolName is BrowserInterruptToolName;
|
|
269
|
-
/**
|
|
270
|
-
* Create all interrupt-based browser tools
|
|
271
|
-
*
|
|
272
|
-
* Use these when the client is a browser extension that can:
|
|
273
|
-
* 1. Detect browser_interrupt events in the stream
|
|
274
|
-
* 2. Execute browser actions locally
|
|
275
|
-
* 3. Send Command({ resume: result }) to continue the graph
|
|
276
|
-
*/
|
|
277
|
-
export declare function createBrowserInterruptTools(): DynamicStructuredTool[];
|
|
278
|
-
/**
|
|
279
|
-
* Check if an interrupt is a browser interrupt
|
|
280
|
-
*/
|
|
281
|
-
export declare function isBrowserInterrupt(value: unknown): value is BrowserInterrupt;
|
|
282
|
-
export {};
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser Automation Tools for Ranger Browser Extension
|
|
3
|
-
*
|
|
4
|
-
* These tools allow the LLM to interact with the browser through the
|
|
5
|
-
* ranger-browser extension. They generate structured actions that are
|
|
6
|
-
* sent to the extension via SSE streaming for execution.
|
|
7
|
-
*
|
|
8
|
-
* The extension handles:
|
|
9
|
-
* - DOM extraction with element indexing
|
|
10
|
-
* - Click, type, hover, scroll actions
|
|
11
|
-
* - Navigation and page context
|
|
12
|
-
* - Visual element highlighting
|
|
13
|
-
*/
|
|
14
|
-
import { z } from 'zod';
|
|
15
|
-
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
16
|
-
/**
|
|
17
|
-
* Enhanced click schema that supports both index-based and coordinate-based clicking
|
|
18
|
-
*/
|
|
19
|
-
declare const BrowserClickSchema: z.ZodObject<{
|
|
20
|
-
index: z.ZodOptional<z.ZodNumber>;
|
|
21
|
-
coordinates: z.ZodOptional<z.ZodObject<{
|
|
22
|
-
x: z.ZodNumber;
|
|
23
|
-
y: z.ZodNumber;
|
|
24
|
-
}, "strip", z.ZodTypeAny, {
|
|
25
|
-
y: number;
|
|
26
|
-
x: number;
|
|
27
|
-
}, {
|
|
28
|
-
y: number;
|
|
29
|
-
x: number;
|
|
30
|
-
}>>;
|
|
31
|
-
visualDescription: z.ZodOptional<z.ZodString>;
|
|
32
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
33
|
-
}, "strip", z.ZodTypeAny, {
|
|
34
|
-
index?: number | undefined;
|
|
35
|
-
coordinates?: {
|
|
36
|
-
y: number;
|
|
37
|
-
x: number;
|
|
38
|
-
} | undefined;
|
|
39
|
-
reason?: string | undefined;
|
|
40
|
-
visualDescription?: string | undefined;
|
|
41
|
-
}, {
|
|
42
|
-
index?: number | undefined;
|
|
43
|
-
coordinates?: {
|
|
44
|
-
y: number;
|
|
45
|
-
x: number;
|
|
46
|
-
} | undefined;
|
|
47
|
-
reason?: string | undefined;
|
|
48
|
-
visualDescription?: string | undefined;
|
|
49
|
-
}>;
|
|
50
|
-
declare const BrowserTypeSchema: z.ZodObject<{
|
|
51
|
-
index: z.ZodNumber;
|
|
52
|
-
text: z.ZodString;
|
|
53
|
-
clear: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
-
pressEnter: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
-
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
text: string;
|
|
57
|
-
index: number;
|
|
58
|
-
clear?: boolean | undefined;
|
|
59
|
-
pressEnter?: boolean | undefined;
|
|
60
|
-
}, {
|
|
61
|
-
text: string;
|
|
62
|
-
index: number;
|
|
63
|
-
clear?: boolean | undefined;
|
|
64
|
-
pressEnter?: boolean | undefined;
|
|
65
|
-
}>;
|
|
66
|
-
declare const BrowserNavigateSchema: z.ZodObject<{
|
|
67
|
-
url: z.ZodString;
|
|
68
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
69
|
-
}, "strip", z.ZodTypeAny, {
|
|
70
|
-
url: string;
|
|
71
|
-
reason?: string | undefined;
|
|
72
|
-
}, {
|
|
73
|
-
url: string;
|
|
74
|
-
reason?: string | undefined;
|
|
75
|
-
}>;
|
|
76
|
-
declare const BrowserScrollSchema: z.ZodObject<{
|
|
77
|
-
direction: z.ZodEnum<["up", "down", "left", "right"]>;
|
|
78
|
-
amount: z.ZodOptional<z.ZodNumber>;
|
|
79
|
-
}, "strip", z.ZodTypeAny, {
|
|
80
|
-
direction: "up" | "down" | "left" | "right";
|
|
81
|
-
amount?: number | undefined;
|
|
82
|
-
}, {
|
|
83
|
-
direction: "up" | "down" | "left" | "right";
|
|
84
|
-
amount?: number | undefined;
|
|
85
|
-
}>;
|
|
86
|
-
declare const BrowserExtractSchema: z.ZodObject<{
|
|
87
|
-
query: z.ZodOptional<z.ZodString>;
|
|
88
|
-
selector: z.ZodOptional<z.ZodString>;
|
|
89
|
-
}, "strip", z.ZodTypeAny, {
|
|
90
|
-
query?: string | undefined;
|
|
91
|
-
selector?: string | undefined;
|
|
92
|
-
}, {
|
|
93
|
-
query?: string | undefined;
|
|
94
|
-
selector?: string | undefined;
|
|
95
|
-
}>;
|
|
96
|
-
declare const BrowserHoverSchema: z.ZodObject<{
|
|
97
|
-
index: z.ZodNumber;
|
|
98
|
-
}, "strip", z.ZodTypeAny, {
|
|
99
|
-
index: number;
|
|
100
|
-
}, {
|
|
101
|
-
index: number;
|
|
102
|
-
}>;
|
|
103
|
-
declare const BrowserWaitSchema: z.ZodObject<{
|
|
104
|
-
duration: z.ZodOptional<z.ZodNumber>;
|
|
105
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
106
|
-
}, "strip", z.ZodTypeAny, {
|
|
107
|
-
duration?: number | undefined;
|
|
108
|
-
reason?: string | undefined;
|
|
109
|
-
}, {
|
|
110
|
-
duration?: number | undefined;
|
|
111
|
-
reason?: string | undefined;
|
|
112
|
-
}>;
|
|
113
|
-
declare const BrowserGoBackSchema: z.ZodObject<{
|
|
114
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
115
|
-
}, "strip", z.ZodTypeAny, {
|
|
116
|
-
reason?: string | undefined;
|
|
117
|
-
}, {
|
|
118
|
-
reason?: string | undefined;
|
|
119
|
-
}>;
|
|
120
|
-
declare const BrowserScreenshotSchema: z.ZodObject<{
|
|
121
|
-
fullPage: z.ZodOptional<z.ZodBoolean>;
|
|
122
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
123
|
-
}, "strip", z.ZodTypeAny, {
|
|
124
|
-
reason?: string | undefined;
|
|
125
|
-
fullPage?: boolean | undefined;
|
|
126
|
-
}, {
|
|
127
|
-
reason?: string | undefined;
|
|
128
|
-
fullPage?: boolean | undefined;
|
|
129
|
-
}>;
|
|
130
|
-
declare const BrowserGetPageStateSchema: z.ZodObject<{
|
|
131
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
132
|
-
}, "strip", z.ZodTypeAny, {
|
|
133
|
-
reason?: string | undefined;
|
|
134
|
-
}, {
|
|
135
|
-
reason?: string | undefined;
|
|
136
|
-
}>;
|
|
137
|
-
/**
|
|
138
|
-
* Browser click tool - clicks an element by index or coordinates
|
|
139
|
-
* Supports both semantic (index-based) and vision (coordinate-based) clicking
|
|
140
|
-
*/
|
|
141
|
-
export declare function createBrowserClickTool(): DynamicStructuredTool<typeof BrowserClickSchema>;
|
|
142
|
-
/**
|
|
143
|
-
* Browser type tool - types text into an input field
|
|
144
|
-
*/
|
|
145
|
-
export declare function createBrowserTypeTool(): DynamicStructuredTool<typeof BrowserTypeSchema>;
|
|
146
|
-
/**
|
|
147
|
-
* Browser navigate tool - navigates to a URL
|
|
148
|
-
*/
|
|
149
|
-
export declare function createBrowserNavigateTool(): DynamicStructuredTool<typeof BrowserNavigateSchema>;
|
|
150
|
-
/**
|
|
151
|
-
* Browser scroll tool - scrolls the page
|
|
152
|
-
*/
|
|
153
|
-
export declare function createBrowserScrollTool(): DynamicStructuredTool<typeof BrowserScrollSchema>;
|
|
154
|
-
/**
|
|
155
|
-
* Browser extract tool - extracts content from the page
|
|
156
|
-
*/
|
|
157
|
-
export declare function createBrowserExtractTool(): DynamicStructuredTool<typeof BrowserExtractSchema>;
|
|
158
|
-
/**
|
|
159
|
-
* Browser hover tool - hovers over an element
|
|
160
|
-
*/
|
|
161
|
-
export declare function createBrowserHoverTool(): DynamicStructuredTool<typeof BrowserHoverSchema>;
|
|
162
|
-
/**
|
|
163
|
-
* Browser wait tool - waits for a specified duration
|
|
164
|
-
*/
|
|
165
|
-
export declare function createBrowserWaitTool(): DynamicStructuredTool<typeof BrowserWaitSchema>;
|
|
166
|
-
/**
|
|
167
|
-
* Browser go back tool - navigates back in history
|
|
168
|
-
*/
|
|
169
|
-
export declare function createBrowserGoBackTool(): DynamicStructuredTool<typeof BrowserGoBackSchema>;
|
|
170
|
-
/**
|
|
171
|
-
* Browser screenshot tool - captures a screenshot
|
|
172
|
-
*/
|
|
173
|
-
export declare function createBrowserScreenshotTool(): DynamicStructuredTool<typeof BrowserScreenshotSchema>;
|
|
174
|
-
/**
|
|
175
|
-
* Browser get page state tool - gets fresh page context after navigation or actions
|
|
176
|
-
* CRITICAL: Use this after browser_navigate or any action that changes the page
|
|
177
|
-
*/
|
|
178
|
-
export declare function createBrowserGetPageStateTool(): DynamicStructuredTool<typeof BrowserGetPageStateSchema>;
|
|
179
|
-
export type BrowserToolsConfig = {
|
|
180
|
-
/** Enable click tool */
|
|
181
|
-
enableClick?: boolean;
|
|
182
|
-
/** Enable type tool */
|
|
183
|
-
enableType?: boolean;
|
|
184
|
-
/** Enable navigate tool */
|
|
185
|
-
enableNavigate?: boolean;
|
|
186
|
-
/** Enable scroll tool */
|
|
187
|
-
enableScroll?: boolean;
|
|
188
|
-
/** Enable extract tool */
|
|
189
|
-
enableExtract?: boolean;
|
|
190
|
-
/** Enable hover tool */
|
|
191
|
-
enableHover?: boolean;
|
|
192
|
-
/** Enable wait tool */
|
|
193
|
-
enableWait?: boolean;
|
|
194
|
-
/** Enable back tool */
|
|
195
|
-
enableBack?: boolean;
|
|
196
|
-
/** Enable screenshot tool */
|
|
197
|
-
enableScreenshot?: boolean;
|
|
198
|
-
/** Enable get page state tool */
|
|
199
|
-
enableGetPageState?: boolean;
|
|
200
|
-
};
|
|
201
|
-
/**
|
|
202
|
-
* Create all browser automation tools
|
|
203
|
-
*
|
|
204
|
-
* IMPORTANT: These tools should ONLY be registered when:
|
|
205
|
-
* 1. The request comes from a browser extension that can execute them
|
|
206
|
-
* 2. The client has indicated browser capability (e.g., via header or parameter)
|
|
207
|
-
*
|
|
208
|
-
* DO NOT register these for normal web UI users - they cannot execute browser actions.
|
|
209
|
-
*
|
|
210
|
-
* Detection in Ranger API:
|
|
211
|
-
* - Check for `X-Ranger-Browser-Extension: true` header
|
|
212
|
-
* - Or check for `browserCapable: true` in request body
|
|
213
|
-
* - Or check user agent for extension identifier
|
|
214
|
-
*
|
|
215
|
-
* @example
|
|
216
|
-
* // In Ranger API endpoint:
|
|
217
|
-
* const hasBrowserExtension = req.headers['x-ranger-browser-extension'] === 'true';
|
|
218
|
-
* const tools = hasBrowserExtension
|
|
219
|
-
* ? [...normalTools, ...createBrowserTools()]
|
|
220
|
-
* : normalTools;
|
|
221
|
-
*/
|
|
222
|
-
export declare function createBrowserTools(config?: BrowserToolsConfig): DynamicStructuredTool[];
|
|
223
|
-
/**
|
|
224
|
-
* Browser tool name constants
|
|
225
|
-
* Use these instead of magic strings
|
|
226
|
-
*/
|
|
227
|
-
export declare const EBrowserTools: {
|
|
228
|
-
readonly CLICK: "browser_click";
|
|
229
|
-
readonly TYPE: "browser_type";
|
|
230
|
-
readonly NAVIGATE: "browser_navigate";
|
|
231
|
-
readonly SCROLL: "browser_scroll";
|
|
232
|
-
readonly EXTRACT: "browser_extract";
|
|
233
|
-
readonly HOVER: "browser_hover";
|
|
234
|
-
readonly WAIT: "browser_wait";
|
|
235
|
-
readonly BACK: "browser_back";
|
|
236
|
-
readonly SCREENSHOT: "browser_screenshot";
|
|
237
|
-
readonly GET_PAGE_STATE: "browser_get_page_state";
|
|
238
|
-
};
|
|
239
|
-
/**
|
|
240
|
-
* Get browser tool names for filtering/identification
|
|
241
|
-
*/
|
|
242
|
-
export declare const BROWSER_TOOL_NAMES: readonly ["browser_click", "browser_type", "browser_navigate", "browser_scroll", "browser_extract", "browser_hover", "browser_wait", "browser_back", "browser_screenshot", "browser_get_page_state"];
|
|
243
|
-
export type BrowserToolName = typeof BROWSER_TOOL_NAMES[number];
|
|
244
|
-
/**
|
|
245
|
-
* Check if a tool call is a browser action
|
|
246
|
-
*/
|
|
247
|
-
export declare function isBrowserToolCall(toolName: string): toolName is BrowserToolName;
|
|
248
|
-
/**
|
|
249
|
-
* Check if request indicates browser extension capability
|
|
250
|
-
* Use this to conditionally register browser tools
|
|
251
|
-
*
|
|
252
|
-
* @example
|
|
253
|
-
* // In Express middleware or endpoint:
|
|
254
|
-
* if (hasBrowserCapability(req.headers)) {
|
|
255
|
-
* tools.push(...createBrowserTools());
|
|
256
|
-
* }
|
|
257
|
-
*/
|
|
258
|
-
export declare function hasBrowserCapability(headers: Record<string, string | string[] | undefined>): boolean;
|
|
259
|
-
export {};
|