@framers/agentos-ext-web-browser 1.1.0 → 1.2.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/README.md +22 -23
- package/dist/index.d.ts +68 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -23
- package/dist/index.js.map +1 -1
- package/dist/services/browserService.d.ts +1 -1
- package/dist/services/browserService.d.ts.map +1 -1
- package/dist/services/browserService.js.map +1 -1
- package/dist/tools/click.d.ts +15 -18
- package/dist/tools/click.d.ts.map +1 -1
- package/dist/tools/click.js +27 -27
- package/dist/tools/click.js.map +1 -1
- package/dist/tools/navigate.d.ts +17 -18
- package/dist/tools/navigate.d.ts.map +1 -1
- package/dist/tools/navigate.js +64 -39
- package/dist/tools/navigate.js.map +1 -1
- package/dist/tools/scrape.d.ts +15 -18
- package/dist/tools/scrape.d.ts.map +1 -1
- package/dist/tools/scrape.js +31 -31
- package/dist/tools/scrape.js.map +1 -1
- package/dist/tools/screenshot.d.ts +15 -18
- package/dist/tools/screenshot.d.ts.map +1 -1
- package/dist/tools/screenshot.js +38 -38
- package/dist/tools/screenshot.js.map +1 -1
- package/dist/tools/snapshot.d.ts +16 -19
- package/dist/tools/snapshot.d.ts.map +1 -1
- package/dist/tools/snapshot.js +36 -27
- package/dist/tools/snapshot.js.map +1 -1
- package/dist/tools/type.d.ts +15 -18
- package/dist/tools/type.d.ts.map +1 -1
- package/dist/tools/type.js +36 -36
- package/dist/tools/type.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/manifest.json +13 -7
- package/package.json +2 -1
package/dist/tools/navigate.js
CHANGED
|
@@ -9,20 +9,64 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export class NavigateTool {
|
|
11
11
|
browserService;
|
|
12
|
-
id = '
|
|
13
|
-
name
|
|
14
|
-
|
|
12
|
+
id = 'web-browser-navigate-v1';
|
|
13
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
14
|
+
name = 'browser_navigate';
|
|
15
|
+
displayName = 'Browser Navigate';
|
|
16
|
+
description = 'Navigate the browser to a URL and return full page text, all links on the page, and optionally raw HTML. Use this to visit websites and extract specific information including footer links, navigation items, and page content.';
|
|
17
|
+
category = 'research';
|
|
18
|
+
hasSideEffects = false;
|
|
19
|
+
inputSchema = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
required: ['url'],
|
|
22
|
+
properties: {
|
|
23
|
+
url: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'The URL to navigate to',
|
|
26
|
+
},
|
|
27
|
+
waitFor: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
enum: ['load', 'domcontentloaded', 'networkidle0', 'networkidle2'],
|
|
30
|
+
default: 'networkidle2',
|
|
31
|
+
description: 'When to consider navigation complete',
|
|
32
|
+
},
|
|
33
|
+
returnHtml: {
|
|
34
|
+
type: 'boolean',
|
|
35
|
+
default: false,
|
|
36
|
+
description: 'Include full HTML in response',
|
|
37
|
+
},
|
|
38
|
+
returnText: {
|
|
39
|
+
type: 'boolean',
|
|
40
|
+
default: true,
|
|
41
|
+
description: 'Include extracted text in response',
|
|
42
|
+
},
|
|
43
|
+
returnLinks: {
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
default: true,
|
|
46
|
+
description: 'Include all links found on the page (text + href)',
|
|
47
|
+
},
|
|
48
|
+
maxTextLength: {
|
|
49
|
+
type: 'number',
|
|
50
|
+
default: 50000,
|
|
51
|
+
description: 'Maximum characters of page text to return (default 50000)',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
additionalProperties: false,
|
|
55
|
+
};
|
|
15
56
|
constructor(browserService) {
|
|
16
57
|
this.browserService = browserService;
|
|
17
58
|
}
|
|
18
59
|
/**
|
|
19
60
|
* Execute navigation
|
|
20
61
|
*/
|
|
21
|
-
async execute(input) {
|
|
62
|
+
async execute(input, _context) {
|
|
22
63
|
try {
|
|
23
64
|
const result = await this.browserService.navigate(input.url, {
|
|
24
65
|
waitFor: input.waitFor,
|
|
25
66
|
});
|
|
67
|
+
const maxLen = typeof input.maxTextLength === 'number' && input.maxTextLength > 0
|
|
68
|
+
? input.maxTextLength
|
|
69
|
+
: 50000;
|
|
26
70
|
// Optionally strip html/text to reduce response size
|
|
27
71
|
const output = {
|
|
28
72
|
url: result.url,
|
|
@@ -35,8 +79,20 @@ export class NavigateTool {
|
|
|
35
79
|
output.html = result.html;
|
|
36
80
|
}
|
|
37
81
|
if (input.returnText !== false) {
|
|
38
|
-
|
|
39
|
-
|
|
82
|
+
output.text = result.text?.slice(0, maxLen);
|
|
83
|
+
}
|
|
84
|
+
// Extract and return all links from the page (default: on)
|
|
85
|
+
if (input.returnLinks !== false) {
|
|
86
|
+
try {
|
|
87
|
+
const links = await this.browserService.evaluate(() => Array.from(document.querySelectorAll('a[href]')).map(a => ({
|
|
88
|
+
text: (a.textContent || '').trim().slice(0, 200),
|
|
89
|
+
href: a.href,
|
|
90
|
+
})).filter(l => l.href && l.text));
|
|
91
|
+
output.links = links;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Non-fatal — page may have restrictive CSP
|
|
95
|
+
}
|
|
40
96
|
}
|
|
41
97
|
return { success: true, output };
|
|
42
98
|
}
|
|
@@ -47,7 +103,7 @@ export class NavigateTool {
|
|
|
47
103
|
/**
|
|
48
104
|
* Validate input
|
|
49
105
|
*/
|
|
50
|
-
|
|
106
|
+
validateArgs(input) {
|
|
51
107
|
const errors = [];
|
|
52
108
|
if (!input.url) {
|
|
53
109
|
errors.push('URL is required');
|
|
@@ -63,38 +119,7 @@ export class NavigateTool {
|
|
|
63
119
|
errors.push('Invalid URL format');
|
|
64
120
|
}
|
|
65
121
|
}
|
|
66
|
-
return
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Get JSON schema for tool
|
|
70
|
-
*/
|
|
71
|
-
getSchema() {
|
|
72
|
-
return {
|
|
73
|
-
type: 'object',
|
|
74
|
-
required: ['url'],
|
|
75
|
-
properties: {
|
|
76
|
-
url: {
|
|
77
|
-
type: 'string',
|
|
78
|
-
description: 'The URL to navigate to',
|
|
79
|
-
},
|
|
80
|
-
waitFor: {
|
|
81
|
-
type: 'string',
|
|
82
|
-
enum: ['load', 'domcontentloaded', 'networkidle0', 'networkidle2'],
|
|
83
|
-
default: 'networkidle2',
|
|
84
|
-
description: 'When to consider navigation complete',
|
|
85
|
-
},
|
|
86
|
-
returnHtml: {
|
|
87
|
-
type: 'boolean',
|
|
88
|
-
default: false,
|
|
89
|
-
description: 'Include full HTML in response',
|
|
90
|
-
},
|
|
91
|
-
returnText: {
|
|
92
|
-
type: 'boolean',
|
|
93
|
-
default: true,
|
|
94
|
-
description: 'Include extracted text in response',
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
};
|
|
122
|
+
return errors.length === 0 ? { isValid: true } : { isValid: false, errors };
|
|
98
123
|
}
|
|
99
124
|
}
|
|
100
125
|
//# sourceMappingURL=navigate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../src/tools/navigate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../src/tools/navigate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,YAAY;IA+CH;IA9CJ,EAAE,GAAG,yBAAyB,CAAC;IAC/C,qDAAqD;IACrC,IAAI,GAAG,kBAAkB,CAAC;IAC1B,WAAW,GAAG,kBAAkB,CAAC;IACjC,WAAW,GAAG,kOAAkO,CAAC;IACjP,QAAQ,GAAG,UAAU,CAAC;IACtB,cAAc,GAAG,KAAK,CAAC;IAEvB,WAAW,GAAqB;QAC9C,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,KAAK,CAAC;QACjB,UAAU,EAAE;YACV,GAAG,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,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,KAA0B;QACrC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC;aAAM,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;YACzC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC;gBACH,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF"}
|
package/dist/tools/scrape.d.ts
CHANGED
|
@@ -4,17 +4,22 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module @framers/agentos-ext-web-browser
|
|
6
6
|
*/
|
|
7
|
-
import type { ITool } from '@framers/agentos';
|
|
8
|
-
import type { BrowserService } from '../services/browserService';
|
|
9
|
-
import type { ScrapeResult } from '../types';
|
|
7
|
+
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
8
|
+
import type { BrowserService } from '../services/browserService.js';
|
|
9
|
+
import type { ScrapeResult } from '../types.js';
|
|
10
10
|
/**
|
|
11
11
|
* Tool for scraping page content
|
|
12
12
|
*/
|
|
13
13
|
export declare class ScrapeTool implements ITool {
|
|
14
14
|
private browserService;
|
|
15
|
-
readonly id = "
|
|
16
|
-
|
|
17
|
-
readonly
|
|
15
|
+
readonly id = "web-browser-scrape-v1";
|
|
16
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
17
|
+
readonly name = "browser_scrape";
|
|
18
|
+
readonly displayName = "Browser Scrape";
|
|
19
|
+
readonly description = "Extract content from the current page using a CSS selector.";
|
|
20
|
+
readonly category = "research";
|
|
21
|
+
readonly hasSideEffects = false;
|
|
22
|
+
readonly inputSchema: JSONSchemaObject;
|
|
18
23
|
constructor(browserService: BrowserService);
|
|
19
24
|
/**
|
|
20
25
|
* Execute scraping
|
|
@@ -23,21 +28,13 @@ export declare class ScrapeTool implements ITool {
|
|
|
23
28
|
selector: string;
|
|
24
29
|
limit?: number;
|
|
25
30
|
attributes?: string[];
|
|
26
|
-
}): Promise<
|
|
27
|
-
success: boolean;
|
|
28
|
-
output?: ScrapeResult;
|
|
29
|
-
error?: string;
|
|
30
|
-
}>;
|
|
31
|
+
}, _context: ToolExecutionContext): Promise<ToolExecutionResult<ScrapeResult>>;
|
|
31
32
|
/**
|
|
32
33
|
* Validate input
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
errors
|
|
35
|
+
validateArgs(input: Record<string, any>): {
|
|
36
|
+
isValid: boolean;
|
|
37
|
+
errors?: any[];
|
|
37
38
|
};
|
|
38
|
-
/**
|
|
39
|
-
* Get JSON schema for tool
|
|
40
|
-
*/
|
|
41
|
-
getSchema(): any;
|
|
42
39
|
}
|
|
43
40
|
//# sourceMappingURL=scrape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrape.d.ts","sourceRoot":"","sources":["../../src/tools/scrape.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"scrape.d.ts","sourceRoot":"","sources":["../../src/tools/scrape.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,qBAAa,UAAW,YAAW,KAAK;IA+B1B,OAAO,CAAC,cAAc;IA9BlC,SAAgB,EAAE,2BAA2B;IAC7C,qDAAqD;IACrD,SAAgB,IAAI,oBAAoB;IACxC,SAAgB,WAAW,oBAAoB;IAC/C,SAAgB,WAAW,iEAAiE;IAC5F,SAAgB,QAAQ,cAAc;IACtC,SAAgB,cAAc,SAAS;IAEvC,SAAgB,WAAW,EAAE,gBAAgB,CAoB3C;gBAEkB,cAAc,EAAE,cAAc;IAElD;;OAEG;IACG,OAAO,CACX,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,EAClE,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;IA4B7C;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE;CAiB/E"}
|
package/dist/tools/scrape.js
CHANGED
|
@@ -9,16 +9,41 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export class ScrapeTool {
|
|
11
11
|
browserService;
|
|
12
|
-
id = '
|
|
13
|
-
name
|
|
14
|
-
|
|
12
|
+
id = 'web-browser-scrape-v1';
|
|
13
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
14
|
+
name = 'browser_scrape';
|
|
15
|
+
displayName = 'Browser Scrape';
|
|
16
|
+
description = 'Extract content from the current page using a CSS selector.';
|
|
17
|
+
category = 'research';
|
|
18
|
+
hasSideEffects = false;
|
|
19
|
+
inputSchema = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
required: ['selector'],
|
|
22
|
+
properties: {
|
|
23
|
+
selector: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'CSS selector to match elements',
|
|
26
|
+
},
|
|
27
|
+
limit: {
|
|
28
|
+
type: 'number',
|
|
29
|
+
description: 'Maximum number of elements to return',
|
|
30
|
+
minimum: 1,
|
|
31
|
+
},
|
|
32
|
+
attributes: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: { type: 'string' },
|
|
35
|
+
description: 'Specific attributes to extract',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
additionalProperties: false,
|
|
39
|
+
};
|
|
15
40
|
constructor(browserService) {
|
|
16
41
|
this.browserService = browserService;
|
|
17
42
|
}
|
|
18
43
|
/**
|
|
19
44
|
* Execute scraping
|
|
20
45
|
*/
|
|
21
|
-
async execute(input) {
|
|
46
|
+
async execute(input, _context) {
|
|
22
47
|
try {
|
|
23
48
|
const result = await this.browserService.scrape(input.selector);
|
|
24
49
|
// Apply limit if specified
|
|
@@ -42,7 +67,7 @@ export class ScrapeTool {
|
|
|
42
67
|
/**
|
|
43
68
|
* Validate input
|
|
44
69
|
*/
|
|
45
|
-
|
|
70
|
+
validateArgs(input) {
|
|
46
71
|
const errors = [];
|
|
47
72
|
if (!input.selector) {
|
|
48
73
|
errors.push('Selector is required');
|
|
@@ -55,32 +80,7 @@ export class ScrapeTool {
|
|
|
55
80
|
errors.push('Limit must be a positive number');
|
|
56
81
|
}
|
|
57
82
|
}
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get JSON schema for tool
|
|
62
|
-
*/
|
|
63
|
-
getSchema() {
|
|
64
|
-
return {
|
|
65
|
-
type: 'object',
|
|
66
|
-
required: ['selector'],
|
|
67
|
-
properties: {
|
|
68
|
-
selector: {
|
|
69
|
-
type: 'string',
|
|
70
|
-
description: 'CSS selector to match elements',
|
|
71
|
-
},
|
|
72
|
-
limit: {
|
|
73
|
-
type: 'number',
|
|
74
|
-
description: 'Maximum number of elements to return',
|
|
75
|
-
minimum: 1,
|
|
76
|
-
},
|
|
77
|
-
attributes: {
|
|
78
|
-
type: 'array',
|
|
79
|
-
items: { type: 'string' },
|
|
80
|
-
description: 'Specific attributes to extract',
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
};
|
|
83
|
+
return errors.length === 0 ? { isValid: true } : { isValid: false, errors };
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
//# sourceMappingURL=scrape.js.map
|
package/dist/tools/scrape.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrape.js","sourceRoot":"","sources":["../../src/tools/scrape.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,UAAU;
|
|
1
|
+
{"version":3,"file":"scrape.js","sourceRoot":"","sources":["../../src/tools/scrape.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,UAAU;IA+BD;IA9BJ,EAAE,GAAG,uBAAuB,CAAC;IAC7C,qDAAqD;IACrC,IAAI,GAAG,gBAAgB,CAAC;IACxB,WAAW,GAAG,gBAAgB,CAAC;IAC/B,WAAW,GAAG,6DAA6D,CAAC;IAC5E,QAAQ,GAAG,UAAU,CAAC;IACtB,cAAc,GAAG,KAAK,CAAC;IAEvB,WAAW,GAAqB;QAC9C,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,UAAU,CAAC;QACtB,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,gCAAgC;aAC9C;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sCAAsC;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EAAE,MAAM,EAAE,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,KAA0B;QACrC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YACpB,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtC,CAAC;aAAM,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;gBACxD,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -4,17 +4,22 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module @framers/agentos-ext-web-browser
|
|
6
6
|
*/
|
|
7
|
-
import type { ITool } from '@framers/agentos';
|
|
8
|
-
import type { BrowserService } from '../services/browserService';
|
|
9
|
-
import type { ScreenshotResult } from '../types';
|
|
7
|
+
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
8
|
+
import type { BrowserService } from '../services/browserService.js';
|
|
9
|
+
import type { ScreenshotResult } from '../types.js';
|
|
10
10
|
/**
|
|
11
11
|
* Tool for taking screenshots
|
|
12
12
|
*/
|
|
13
13
|
export declare class ScreenshotTool implements ITool {
|
|
14
14
|
private browserService;
|
|
15
|
-
readonly id = "
|
|
16
|
-
|
|
17
|
-
readonly
|
|
15
|
+
readonly id = "web-browser-screenshot-v1";
|
|
16
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
17
|
+
readonly name = "browser_screenshot";
|
|
18
|
+
readonly displayName = "Browser Screenshot";
|
|
19
|
+
readonly description = "Capture a screenshot of the current page or a specific element.";
|
|
20
|
+
readonly category = "research";
|
|
21
|
+
readonly hasSideEffects = false;
|
|
22
|
+
readonly inputSchema: JSONSchemaObject;
|
|
18
23
|
constructor(browserService: BrowserService);
|
|
19
24
|
/**
|
|
20
25
|
* Execute screenshot capture
|
|
@@ -24,21 +29,13 @@ export declare class ScreenshotTool implements ITool {
|
|
|
24
29
|
selector?: string;
|
|
25
30
|
format?: 'png' | 'jpeg' | 'webp';
|
|
26
31
|
quality?: number;
|
|
27
|
-
}): Promise<
|
|
28
|
-
success: boolean;
|
|
29
|
-
output?: ScreenshotResult;
|
|
30
|
-
error?: string;
|
|
31
|
-
}>;
|
|
32
|
+
}, _context: ToolExecutionContext): Promise<ToolExecutionResult<ScreenshotResult>>;
|
|
32
33
|
/**
|
|
33
34
|
* Validate input
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
errors
|
|
36
|
+
validateArgs(input: Record<string, any>): {
|
|
37
|
+
isValid: boolean;
|
|
38
|
+
errors?: any[];
|
|
38
39
|
};
|
|
39
|
-
/**
|
|
40
|
-
* Get JSON schema for tool
|
|
41
|
-
*/
|
|
42
|
-
getSchema(): any;
|
|
43
40
|
}
|
|
44
41
|
//# sourceMappingURL=screenshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/tools/screenshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG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|
|
10
10
|
export class ScreenshotTool {
|
|
11
11
|
browserService;
|
|
12
|
-
id = '
|
|
13
|
-
name
|
|
14
|
-
|
|
12
|
+
id = 'web-browser-screenshot-v1';
|
|
13
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
14
|
+
name = 'browser_screenshot';
|
|
15
|
+
displayName = 'Browser Screenshot';
|
|
16
|
+
description = 'Capture a screenshot of the current page or a specific element.';
|
|
17
|
+
category = 'research';
|
|
18
|
+
hasSideEffects = false;
|
|
19
|
+
inputSchema = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
fullPage: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
default: false,
|
|
25
|
+
description: 'Capture full scrollable page',
|
|
26
|
+
},
|
|
27
|
+
selector: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'CSS selector for specific element to capture',
|
|
30
|
+
},
|
|
31
|
+
format: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
enum: ['png', 'jpeg', 'webp'],
|
|
34
|
+
default: 'png',
|
|
35
|
+
description: 'Image format',
|
|
36
|
+
},
|
|
37
|
+
quality: {
|
|
38
|
+
type: 'number',
|
|
39
|
+
minimum: 0,
|
|
40
|
+
maximum: 100,
|
|
41
|
+
default: 80,
|
|
42
|
+
description: 'Quality for jpeg/webp (0-100)',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
};
|
|
15
47
|
constructor(browserService) {
|
|
16
48
|
this.browserService = browserService;
|
|
17
49
|
}
|
|
18
50
|
/**
|
|
19
51
|
* Execute screenshot capture
|
|
20
52
|
*/
|
|
21
|
-
async execute(input) {
|
|
53
|
+
async execute(input, _context) {
|
|
22
54
|
try {
|
|
23
55
|
const result = await this.browserService.screenshot({
|
|
24
56
|
fullPage: input.fullPage,
|
|
@@ -35,7 +67,7 @@ export class ScreenshotTool {
|
|
|
35
67
|
/**
|
|
36
68
|
* Validate input
|
|
37
69
|
*/
|
|
38
|
-
|
|
70
|
+
validateArgs(input) {
|
|
39
71
|
const errors = [];
|
|
40
72
|
if (input.format && !['png', 'jpeg', 'webp'].includes(input.format)) {
|
|
41
73
|
errors.push('Format must be png, jpeg, or webp');
|
|
@@ -45,39 +77,7 @@ export class ScreenshotTool {
|
|
|
45
77
|
errors.push('Quality must be a number between 0 and 100');
|
|
46
78
|
}
|
|
47
79
|
}
|
|
48
|
-
return
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Get JSON schema for tool
|
|
52
|
-
*/
|
|
53
|
-
getSchema() {
|
|
54
|
-
return {
|
|
55
|
-
type: 'object',
|
|
56
|
-
properties: {
|
|
57
|
-
fullPage: {
|
|
58
|
-
type: 'boolean',
|
|
59
|
-
default: false,
|
|
60
|
-
description: 'Capture full scrollable page',
|
|
61
|
-
},
|
|
62
|
-
selector: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
description: 'CSS selector for specific element to capture',
|
|
65
|
-
},
|
|
66
|
-
format: {
|
|
67
|
-
type: 'string',
|
|
68
|
-
enum: ['png', 'jpeg', 'webp'],
|
|
69
|
-
default: 'png',
|
|
70
|
-
description: 'Image format',
|
|
71
|
-
},
|
|
72
|
-
quality: {
|
|
73
|
-
type: 'number',
|
|
74
|
-
minimum: 0,
|
|
75
|
-
maximum: 100,
|
|
76
|
-
default: 80,
|
|
77
|
-
description: 'Quality for jpeg/webp (0-100)',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
};
|
|
80
|
+
return errors.length === 0 ? { isValid: true } : { isValid: false, errors };
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
//# sourceMappingURL=screenshot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/tools/screenshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,cAAc;
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot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gBACpB,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CAAC;YAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QAC3C,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QAClD,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,KAA0B;QACrC,MAAM,MAAM,GAAa,EAAE,CAAC;QAE5B,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACpE,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC;gBAClF,MAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF"}
|
package/dist/tools/snapshot.d.ts
CHANGED
|
@@ -4,39 +4,36 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module @framers/agentos-ext-web-browser
|
|
6
6
|
*/
|
|
7
|
-
import type { ITool } from '@framers/agentos';
|
|
8
|
-
import type { BrowserService } from '../services/browserService';
|
|
9
|
-
import type { PageSnapshot } from '../types';
|
|
7
|
+
import type { ITool, JSONSchemaObject, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
8
|
+
import type { BrowserService } from '../services/browserService.js';
|
|
9
|
+
import type { PageSnapshot } from '../types.js';
|
|
10
10
|
/**
|
|
11
11
|
* Tool for getting page snapshot
|
|
12
12
|
*/
|
|
13
13
|
export declare class SnapshotTool implements ITool {
|
|
14
14
|
private browserService;
|
|
15
|
-
readonly id = "
|
|
16
|
-
|
|
17
|
-
readonly
|
|
15
|
+
readonly id = "web-browser-snapshot-v1";
|
|
16
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
17
|
+
readonly name = "browser_snapshot";
|
|
18
|
+
readonly displayName = "Browser Snapshot";
|
|
19
|
+
readonly description = "Get an accessibility-like snapshot of the current page (interactive elements, links, forms).";
|
|
20
|
+
readonly category = "research";
|
|
21
|
+
readonly hasSideEffects = false;
|
|
22
|
+
readonly inputSchema: JSONSchemaObject;
|
|
18
23
|
constructor(browserService: BrowserService);
|
|
19
24
|
/**
|
|
20
25
|
* Execute snapshot capture
|
|
21
26
|
*/
|
|
22
|
-
execute(
|
|
27
|
+
execute(input: {
|
|
23
28
|
includeLinks?: boolean;
|
|
24
29
|
includeForms?: boolean;
|
|
25
|
-
}): Promise<
|
|
26
|
-
success: boolean;
|
|
27
|
-
output?: PageSnapshot;
|
|
28
|
-
error?: string;
|
|
29
|
-
}>;
|
|
30
|
+
}, _context: ToolExecutionContext): Promise<ToolExecutionResult<PageSnapshot>>;
|
|
30
31
|
/**
|
|
31
32
|
* Validate input
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
errors
|
|
34
|
+
validateArgs(_input: Record<string, any>): {
|
|
35
|
+
isValid: boolean;
|
|
36
|
+
errors?: any[];
|
|
36
37
|
};
|
|
37
|
-
/**
|
|
38
|
-
* Get JSON schema for tool
|
|
39
|
-
*/
|
|
40
|
-
getSchema(): any;
|
|
41
38
|
}
|
|
42
39
|
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/tools/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/tools/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,qBAAa,YAAa,YAAW,KAAK;IA0B5B,OAAO,CAAC,cAAc;IAzBlC,SAAgB,EAAE,6BAA6B;IAC/C,qDAAqD;IACrD,SAAgB,IAAI,sBAAsB;IAC1C,SAAgB,WAAW,sBAAsB;IACjD,SAAgB,WAAW,kGAAkG;IAC7H,SAAgB,QAAQ,cAAc;IACtC,SAAgB,cAAc,SAAS;IAEvC,SAAgB,WAAW,EAAE,gBAAgB,CAe3C;gBAEkB,cAAc,EAAE,cAAc;IAElD;;OAEG;IACG,OAAO,CACX,KAAK,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,EACzD,QAAQ,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;IAoB7C;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAA;KAAE;CAGhF"}
|
package/dist/tools/snapshot.js
CHANGED
|
@@ -9,19 +9,48 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export class SnapshotTool {
|
|
11
11
|
browserService;
|
|
12
|
-
id = '
|
|
13
|
-
name
|
|
14
|
-
|
|
12
|
+
id = 'web-browser-snapshot-v1';
|
|
13
|
+
/** Tool call name used by the LLM / ToolExecutor. */
|
|
14
|
+
name = 'browser_snapshot';
|
|
15
|
+
displayName = 'Browser Snapshot';
|
|
16
|
+
description = 'Get an accessibility-like snapshot of the current page (interactive elements, links, forms).';
|
|
17
|
+
category = 'research';
|
|
18
|
+
hasSideEffects = false;
|
|
19
|
+
inputSchema = {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
includeLinks: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
default: true,
|
|
25
|
+
description: 'Include links in snapshot',
|
|
26
|
+
},
|
|
27
|
+
includeForms: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
default: true,
|
|
30
|
+
description: 'Include forms in snapshot',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
};
|
|
15
35
|
constructor(browserService) {
|
|
16
36
|
this.browserService = browserService;
|
|
17
37
|
}
|
|
18
38
|
/**
|
|
19
39
|
* Execute snapshot capture
|
|
20
40
|
*/
|
|
21
|
-
async execute(
|
|
41
|
+
async execute(input, _context) {
|
|
22
42
|
try {
|
|
23
43
|
const snapshot = await this.browserService.getSnapshot();
|
|
24
|
-
|
|
44
|
+
const includeLinks = input.includeLinks !== false;
|
|
45
|
+
const includeForms = input.includeForms !== false;
|
|
46
|
+
return {
|
|
47
|
+
success: true,
|
|
48
|
+
output: {
|
|
49
|
+
...snapshot,
|
|
50
|
+
links: includeLinks ? snapshot.links : [],
|
|
51
|
+
forms: includeForms ? snapshot.forms : [],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
25
54
|
}
|
|
26
55
|
catch (error) {
|
|
27
56
|
return { success: false, error: error.message };
|
|
@@ -30,28 +59,8 @@ export class SnapshotTool {
|
|
|
30
59
|
/**
|
|
31
60
|
* Validate input
|
|
32
61
|
*/
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Get JSON schema for tool
|
|
38
|
-
*/
|
|
39
|
-
getSchema() {
|
|
40
|
-
return {
|
|
41
|
-
type: 'object',
|
|
42
|
-
properties: {
|
|
43
|
-
includeLinks: {
|
|
44
|
-
type: 'boolean',
|
|
45
|
-
default: true,
|
|
46
|
-
description: 'Include links in snapshot',
|
|
47
|
-
},
|
|
48
|
-
includeForms: {
|
|
49
|
-
type: 'boolean',
|
|
50
|
-
default: true,
|
|
51
|
-
description: 'Include forms in snapshot',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
};
|
|
62
|
+
validateArgs(_input) {
|
|
63
|
+
return { isValid: true };
|
|
55
64
|
}
|
|
56
65
|
}
|
|
57
66
|
//# sourceMappingURL=snapshot.js.map
|