@modelrelay/sdk 1.28.0 → 1.29.0
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/chunk-CV3DTA6P.js +1196 -0
- package/dist/index.cjs +1 -584
- package/dist/index.d.cts +1 -200
- package/dist/index.d.ts +1 -200
- package/dist/index.js +1 -579
- package/dist/node.cjs +590 -1
- package/dist/node.d.cts +200 -1
- package/dist/node.d.ts +200 -1
- package/dist/node.js +581 -2
- package/package.json +1 -1
package/dist/node.d.cts
CHANGED
|
@@ -146,4 +146,203 @@ declare function createLocalFSToolPack(options: LocalFSToolPackOptions): LocalFS
|
|
|
146
146
|
*/
|
|
147
147
|
declare function createLocalFSTools(options: LocalFSToolPackOptions): ToolRegistry;
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Browser automation tools using Playwright with accessibility tree extraction.
|
|
151
|
+
*
|
|
152
|
+
* Uses CDP (Chrome DevTools Protocol) for semantic element targeting instead of
|
|
153
|
+
* pixel-based screenshots, making it 10-100x cheaper than vision-based automation.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* import { BrowserToolPack, createBrowserTools } from "@modelrelay/sdk";
|
|
158
|
+
*
|
|
159
|
+
* // Create a browser tool pack with domain restrictions
|
|
160
|
+
* const pack = new BrowserToolPack({
|
|
161
|
+
* allowedDomains: ["example.com", "docs.example.com"],
|
|
162
|
+
* headless: true,
|
|
163
|
+
* });
|
|
164
|
+
*
|
|
165
|
+
* // Initialize the browser (must be called before use)
|
|
166
|
+
* await pack.initialize();
|
|
167
|
+
*
|
|
168
|
+
* // Get tool definitions for LLM
|
|
169
|
+
* const tools = pack.getToolDefinitions();
|
|
170
|
+
*
|
|
171
|
+
* // Get registry for executing tool calls
|
|
172
|
+
* const registry = pack.toRegistry();
|
|
173
|
+
*
|
|
174
|
+
* // Clean up when done
|
|
175
|
+
* await pack.close();
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @module
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
type Browser = any;
|
|
182
|
+
type BrowserContext = any;
|
|
183
|
+
/**
|
|
184
|
+
* Tool names for browser automation.
|
|
185
|
+
*/
|
|
186
|
+
declare const BrowserToolNames: {
|
|
187
|
+
/** Navigate to a URL and return accessibility tree */
|
|
188
|
+
readonly NAVIGATE: "browser.navigate";
|
|
189
|
+
/** Click an element by accessible name/role */
|
|
190
|
+
readonly CLICK: "browser.click";
|
|
191
|
+
/** Type text into an input field */
|
|
192
|
+
readonly TYPE: "browser.type";
|
|
193
|
+
/** Get current accessibility tree */
|
|
194
|
+
readonly SNAPSHOT: "browser.snapshot";
|
|
195
|
+
/** Scroll the page */
|
|
196
|
+
readonly SCROLL: "browser.scroll";
|
|
197
|
+
/** Capture a screenshot */
|
|
198
|
+
readonly SCREENSHOT: "browser.screenshot";
|
|
199
|
+
/** Extract data using CSS selectors */
|
|
200
|
+
readonly EXTRACT: "browser.extract";
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Default configuration values for browser tools.
|
|
204
|
+
*/
|
|
205
|
+
declare const BrowserDefaults: {
|
|
206
|
+
/** Navigation timeout in milliseconds */
|
|
207
|
+
readonly NAVIGATION_TIMEOUT_MS: 30000;
|
|
208
|
+
/** Action timeout in milliseconds */
|
|
209
|
+
readonly ACTION_TIMEOUT_MS: 5000;
|
|
210
|
+
/** Maximum nodes to include in accessibility tree output */
|
|
211
|
+
readonly MAX_SNAPSHOT_NODES: 500;
|
|
212
|
+
/** Maximum screenshot size in bytes */
|
|
213
|
+
readonly MAX_SCREENSHOT_BYTES: 5000000;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Configuration options for BrowserToolPack.
|
|
217
|
+
*/
|
|
218
|
+
interface BrowserToolPackOptions {
|
|
219
|
+
/**
|
|
220
|
+
* Whitelist of allowed domains. If set, only URLs matching these domains
|
|
221
|
+
* will be allowed. Supports suffix matching (e.g., "example.com" matches
|
|
222
|
+
* "sub.example.com").
|
|
223
|
+
*/
|
|
224
|
+
allowedDomains?: string[];
|
|
225
|
+
/**
|
|
226
|
+
* Blacklist of blocked domains. URLs matching these domains will be rejected.
|
|
227
|
+
* Supports suffix matching.
|
|
228
|
+
*/
|
|
229
|
+
blockedDomains?: string[];
|
|
230
|
+
/**
|
|
231
|
+
* Navigation timeout in milliseconds. Default: 30000
|
|
232
|
+
*/
|
|
233
|
+
navigationTimeoutMs?: number;
|
|
234
|
+
/**
|
|
235
|
+
* Action timeout in milliseconds. Default: 5000
|
|
236
|
+
*/
|
|
237
|
+
actionTimeoutMs?: number;
|
|
238
|
+
/**
|
|
239
|
+
* Maximum nodes to include in accessibility tree. Default: 500
|
|
240
|
+
*/
|
|
241
|
+
maxSnapshotNodes?: number;
|
|
242
|
+
/**
|
|
243
|
+
* Run browser in headless mode. Default: true
|
|
244
|
+
*/
|
|
245
|
+
headless?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Existing Browser instance to use instead of creating a new one.
|
|
248
|
+
*/
|
|
249
|
+
browser?: Browser;
|
|
250
|
+
/**
|
|
251
|
+
* Existing BrowserContext to use instead of creating a new one.
|
|
252
|
+
*/
|
|
253
|
+
context?: BrowserContext;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* A tool pack for browser automation using Playwright.
|
|
257
|
+
*
|
|
258
|
+
* Uses accessibility tree extraction via CDP for efficient, semantic-based
|
|
259
|
+
* browser automation. This is much cheaper than vision-based approaches
|
|
260
|
+
* because it works with structured text instead of screenshots.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* const pack = new BrowserToolPack({
|
|
265
|
+
* allowedDomains: ["example.com"],
|
|
266
|
+
* });
|
|
267
|
+
* await pack.initialize();
|
|
268
|
+
*
|
|
269
|
+
* const registry = pack.toRegistry();
|
|
270
|
+
* const result = await registry.execute(toolCall);
|
|
271
|
+
*
|
|
272
|
+
* await pack.close();
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
declare class BrowserToolPack {
|
|
276
|
+
private browser;
|
|
277
|
+
private context;
|
|
278
|
+
private page;
|
|
279
|
+
private cdpSession;
|
|
280
|
+
private ownsBrowser;
|
|
281
|
+
private ownsContext;
|
|
282
|
+
private cfg;
|
|
283
|
+
constructor(options?: BrowserToolPackOptions);
|
|
284
|
+
/**
|
|
285
|
+
* Initialize the browser. Must be called before using any tools.
|
|
286
|
+
*/
|
|
287
|
+
initialize(): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* Close the browser and clean up resources.
|
|
290
|
+
*/
|
|
291
|
+
close(): Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Get tool definitions for use with LLM APIs.
|
|
294
|
+
*/
|
|
295
|
+
getToolDefinitions(): Tool[];
|
|
296
|
+
/**
|
|
297
|
+
* Register tool handlers into an existing registry.
|
|
298
|
+
*/
|
|
299
|
+
registerInto(registry: ToolRegistry): ToolRegistry;
|
|
300
|
+
/**
|
|
301
|
+
* Create a new registry with just this pack's tools.
|
|
302
|
+
*/
|
|
303
|
+
toRegistry(): ToolRegistry;
|
|
304
|
+
private ensureInitialized;
|
|
305
|
+
private parseArgs;
|
|
306
|
+
private validateUrl;
|
|
307
|
+
/**
|
|
308
|
+
* Validates the current page URL against allowlist/blocklist.
|
|
309
|
+
* Called after navigation and before any action to catch redirects
|
|
310
|
+
* and in-session navigation to blocked domains.
|
|
311
|
+
*/
|
|
312
|
+
private ensureCurrentUrlAllowed;
|
|
313
|
+
private getAccessibilityTree;
|
|
314
|
+
private formatAXTree;
|
|
315
|
+
private navigate;
|
|
316
|
+
private click;
|
|
317
|
+
private type;
|
|
318
|
+
private snapshot;
|
|
319
|
+
private scroll;
|
|
320
|
+
private screenshot;
|
|
321
|
+
private extract;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Create a BrowserToolPack with the given options.
|
|
325
|
+
*/
|
|
326
|
+
declare function createBrowserToolPack(options?: BrowserToolPackOptions): BrowserToolPack;
|
|
327
|
+
/**
|
|
328
|
+
* Create a ToolRegistry with browser tools registered.
|
|
329
|
+
*
|
|
330
|
+
* Note: You must call `pack.initialize()` before using the registry.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* const { pack, registry } = createBrowserTools({ headless: true });
|
|
335
|
+
* await pack.initialize();
|
|
336
|
+
*
|
|
337
|
+
* // Use registry to execute tool calls
|
|
338
|
+
* const result = await registry.execute(toolCall);
|
|
339
|
+
*
|
|
340
|
+
* await pack.close();
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare function createBrowserTools(options?: BrowserToolPackOptions): {
|
|
344
|
+
pack: BrowserToolPack;
|
|
345
|
+
registry: ToolRegistry;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
export { BrowserDefaults, BrowserToolNames, BrowserToolPack, type BrowserToolPackOptions, DEFAULT_IGNORE_DIRS, FSDefaults, ToolNames as FSToolNames, LocalFSToolPack, type LocalFSToolPackOptions, createBrowserToolPack, createBrowserTools, createLocalFSToolPack, createLocalFSTools };
|
package/dist/node.d.ts
CHANGED
|
@@ -146,4 +146,203 @@ declare function createLocalFSToolPack(options: LocalFSToolPackOptions): LocalFS
|
|
|
146
146
|
*/
|
|
147
147
|
declare function createLocalFSTools(options: LocalFSToolPackOptions): ToolRegistry;
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Browser automation tools using Playwright with accessibility tree extraction.
|
|
151
|
+
*
|
|
152
|
+
* Uses CDP (Chrome DevTools Protocol) for semantic element targeting instead of
|
|
153
|
+
* pixel-based screenshots, making it 10-100x cheaper than vision-based automation.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* import { BrowserToolPack, createBrowserTools } from "@modelrelay/sdk";
|
|
158
|
+
*
|
|
159
|
+
* // Create a browser tool pack with domain restrictions
|
|
160
|
+
* const pack = new BrowserToolPack({
|
|
161
|
+
* allowedDomains: ["example.com", "docs.example.com"],
|
|
162
|
+
* headless: true,
|
|
163
|
+
* });
|
|
164
|
+
*
|
|
165
|
+
* // Initialize the browser (must be called before use)
|
|
166
|
+
* await pack.initialize();
|
|
167
|
+
*
|
|
168
|
+
* // Get tool definitions for LLM
|
|
169
|
+
* const tools = pack.getToolDefinitions();
|
|
170
|
+
*
|
|
171
|
+
* // Get registry for executing tool calls
|
|
172
|
+
* const registry = pack.toRegistry();
|
|
173
|
+
*
|
|
174
|
+
* // Clean up when done
|
|
175
|
+
* await pack.close();
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @module
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
type Browser = any;
|
|
182
|
+
type BrowserContext = any;
|
|
183
|
+
/**
|
|
184
|
+
* Tool names for browser automation.
|
|
185
|
+
*/
|
|
186
|
+
declare const BrowserToolNames: {
|
|
187
|
+
/** Navigate to a URL and return accessibility tree */
|
|
188
|
+
readonly NAVIGATE: "browser.navigate";
|
|
189
|
+
/** Click an element by accessible name/role */
|
|
190
|
+
readonly CLICK: "browser.click";
|
|
191
|
+
/** Type text into an input field */
|
|
192
|
+
readonly TYPE: "browser.type";
|
|
193
|
+
/** Get current accessibility tree */
|
|
194
|
+
readonly SNAPSHOT: "browser.snapshot";
|
|
195
|
+
/** Scroll the page */
|
|
196
|
+
readonly SCROLL: "browser.scroll";
|
|
197
|
+
/** Capture a screenshot */
|
|
198
|
+
readonly SCREENSHOT: "browser.screenshot";
|
|
199
|
+
/** Extract data using CSS selectors */
|
|
200
|
+
readonly EXTRACT: "browser.extract";
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Default configuration values for browser tools.
|
|
204
|
+
*/
|
|
205
|
+
declare const BrowserDefaults: {
|
|
206
|
+
/** Navigation timeout in milliseconds */
|
|
207
|
+
readonly NAVIGATION_TIMEOUT_MS: 30000;
|
|
208
|
+
/** Action timeout in milliseconds */
|
|
209
|
+
readonly ACTION_TIMEOUT_MS: 5000;
|
|
210
|
+
/** Maximum nodes to include in accessibility tree output */
|
|
211
|
+
readonly MAX_SNAPSHOT_NODES: 500;
|
|
212
|
+
/** Maximum screenshot size in bytes */
|
|
213
|
+
readonly MAX_SCREENSHOT_BYTES: 5000000;
|
|
214
|
+
};
|
|
215
|
+
/**
|
|
216
|
+
* Configuration options for BrowserToolPack.
|
|
217
|
+
*/
|
|
218
|
+
interface BrowserToolPackOptions {
|
|
219
|
+
/**
|
|
220
|
+
* Whitelist of allowed domains. If set, only URLs matching these domains
|
|
221
|
+
* will be allowed. Supports suffix matching (e.g., "example.com" matches
|
|
222
|
+
* "sub.example.com").
|
|
223
|
+
*/
|
|
224
|
+
allowedDomains?: string[];
|
|
225
|
+
/**
|
|
226
|
+
* Blacklist of blocked domains. URLs matching these domains will be rejected.
|
|
227
|
+
* Supports suffix matching.
|
|
228
|
+
*/
|
|
229
|
+
blockedDomains?: string[];
|
|
230
|
+
/**
|
|
231
|
+
* Navigation timeout in milliseconds. Default: 30000
|
|
232
|
+
*/
|
|
233
|
+
navigationTimeoutMs?: number;
|
|
234
|
+
/**
|
|
235
|
+
* Action timeout in milliseconds. Default: 5000
|
|
236
|
+
*/
|
|
237
|
+
actionTimeoutMs?: number;
|
|
238
|
+
/**
|
|
239
|
+
* Maximum nodes to include in accessibility tree. Default: 500
|
|
240
|
+
*/
|
|
241
|
+
maxSnapshotNodes?: number;
|
|
242
|
+
/**
|
|
243
|
+
* Run browser in headless mode. Default: true
|
|
244
|
+
*/
|
|
245
|
+
headless?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Existing Browser instance to use instead of creating a new one.
|
|
248
|
+
*/
|
|
249
|
+
browser?: Browser;
|
|
250
|
+
/**
|
|
251
|
+
* Existing BrowserContext to use instead of creating a new one.
|
|
252
|
+
*/
|
|
253
|
+
context?: BrowserContext;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* A tool pack for browser automation using Playwright.
|
|
257
|
+
*
|
|
258
|
+
* Uses accessibility tree extraction via CDP for efficient, semantic-based
|
|
259
|
+
* browser automation. This is much cheaper than vision-based approaches
|
|
260
|
+
* because it works with structured text instead of screenshots.
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* const pack = new BrowserToolPack({
|
|
265
|
+
* allowedDomains: ["example.com"],
|
|
266
|
+
* });
|
|
267
|
+
* await pack.initialize();
|
|
268
|
+
*
|
|
269
|
+
* const registry = pack.toRegistry();
|
|
270
|
+
* const result = await registry.execute(toolCall);
|
|
271
|
+
*
|
|
272
|
+
* await pack.close();
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
declare class BrowserToolPack {
|
|
276
|
+
private browser;
|
|
277
|
+
private context;
|
|
278
|
+
private page;
|
|
279
|
+
private cdpSession;
|
|
280
|
+
private ownsBrowser;
|
|
281
|
+
private ownsContext;
|
|
282
|
+
private cfg;
|
|
283
|
+
constructor(options?: BrowserToolPackOptions);
|
|
284
|
+
/**
|
|
285
|
+
* Initialize the browser. Must be called before using any tools.
|
|
286
|
+
*/
|
|
287
|
+
initialize(): Promise<void>;
|
|
288
|
+
/**
|
|
289
|
+
* Close the browser and clean up resources.
|
|
290
|
+
*/
|
|
291
|
+
close(): Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Get tool definitions for use with LLM APIs.
|
|
294
|
+
*/
|
|
295
|
+
getToolDefinitions(): Tool[];
|
|
296
|
+
/**
|
|
297
|
+
* Register tool handlers into an existing registry.
|
|
298
|
+
*/
|
|
299
|
+
registerInto(registry: ToolRegistry): ToolRegistry;
|
|
300
|
+
/**
|
|
301
|
+
* Create a new registry with just this pack's tools.
|
|
302
|
+
*/
|
|
303
|
+
toRegistry(): ToolRegistry;
|
|
304
|
+
private ensureInitialized;
|
|
305
|
+
private parseArgs;
|
|
306
|
+
private validateUrl;
|
|
307
|
+
/**
|
|
308
|
+
* Validates the current page URL against allowlist/blocklist.
|
|
309
|
+
* Called after navigation and before any action to catch redirects
|
|
310
|
+
* and in-session navigation to blocked domains.
|
|
311
|
+
*/
|
|
312
|
+
private ensureCurrentUrlAllowed;
|
|
313
|
+
private getAccessibilityTree;
|
|
314
|
+
private formatAXTree;
|
|
315
|
+
private navigate;
|
|
316
|
+
private click;
|
|
317
|
+
private type;
|
|
318
|
+
private snapshot;
|
|
319
|
+
private scroll;
|
|
320
|
+
private screenshot;
|
|
321
|
+
private extract;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Create a BrowserToolPack with the given options.
|
|
325
|
+
*/
|
|
326
|
+
declare function createBrowserToolPack(options?: BrowserToolPackOptions): BrowserToolPack;
|
|
327
|
+
/**
|
|
328
|
+
* Create a ToolRegistry with browser tools registered.
|
|
329
|
+
*
|
|
330
|
+
* Note: You must call `pack.initialize()` before using the registry.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* const { pack, registry } = createBrowserTools({ headless: true });
|
|
335
|
+
* await pack.initialize();
|
|
336
|
+
*
|
|
337
|
+
* // Use registry to execute tool calls
|
|
338
|
+
* const result = await registry.execute(toolCall);
|
|
339
|
+
*
|
|
340
|
+
* await pack.close();
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare function createBrowserTools(options?: BrowserToolPackOptions): {
|
|
344
|
+
pack: BrowserToolPack;
|
|
345
|
+
registry: ToolRegistry;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
export { BrowserDefaults, BrowserToolNames, BrowserToolPack, type BrowserToolPackOptions, DEFAULT_IGNORE_DIRS, FSDefaults, ToolNames as FSToolNames, LocalFSToolPack, type LocalFSToolPackOptions, createBrowserToolPack, createBrowserTools, createLocalFSToolPack, createLocalFSTools };
|