illuma-agents 1.0.18 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,259 @@
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
+ visualDescription?: string | undefined;
40
+ reason?: string | undefined;
41
+ }, {
42
+ index?: number | undefined;
43
+ coordinates?: {
44
+ y: number;
45
+ x: number;
46
+ } | undefined;
47
+ visualDescription?: string | undefined;
48
+ reason?: 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 {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "illuma-agents",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "main": "./dist/cjs/main.cjs",
5
5
  "module": "./dist/esm/main.mjs",
6
6
  "types": "./dist/types/index.d.ts",
@@ -13,6 +13,10 @@
13
13
  },
14
14
  "type": "module",
15
15
  "description": "Illuma AI Agents Library",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/codevakure/agents"
19
+ },
16
20
  "author": "Illuma Team",
17
21
  "license": "MIT",
18
22
  "packageManager": "npm@10.5.2",
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ export * from './tools/Calculator';
13
13
  export * from './tools/CodeExecutor';
14
14
  export * from './tools/ProgrammaticToolCalling';
15
15
  export * from './tools/ToolSearchRegex';
16
+ export * from './tools/BrowserTools';
16
17
  export * from './tools/handlers';
17
18
  export * from './tools/search';
18
19