@framers/agentos-ext-web-browser 1.1.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 +161 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +128 -0
- package/dist/index.js.map +1 -0
- package/dist/services/browserService.d.ts +81 -0
- package/dist/services/browserService.d.ts.map +1 -0
- package/dist/services/browserService.js +381 -0
- package/dist/services/browserService.js.map +1 -0
- package/dist/tools/click.d.ts +42 -0
- package/dist/tools/click.d.ts.map +1 -0
- package/dist/tools/click.js +66 -0
- package/dist/tools/click.js.map +1 -0
- package/dist/tools/navigate.d.ts +44 -0
- package/dist/tools/navigate.d.ts.map +1 -0
- package/dist/tools/navigate.js +100 -0
- package/dist/tools/navigate.js.map +1 -0
- package/dist/tools/scrape.d.ts +43 -0
- package/dist/tools/scrape.d.ts.map +1 -0
- package/dist/tools/scrape.js +86 -0
- package/dist/tools/scrape.js.map +1 -0
- package/dist/tools/screenshot.d.ts +44 -0
- package/dist/tools/screenshot.d.ts.map +1 -0
- package/dist/tools/screenshot.js +83 -0
- package/dist/tools/screenshot.js.map +1 -0
- package/dist/tools/snapshot.d.ts +42 -0
- package/dist/tools/snapshot.d.ts.map +1 -0
- package/dist/tools/snapshot.js +57 -0
- package/dist/tools/snapshot.js.map +1 -0
- package/dist/tools/type.d.ts +44 -0
- package/dist/tools/type.d.ts.map +1 -0
- package/dist/tools/type.js +82 -0
- package/dist/tools/type.js.map +1 -0
- package/dist/types.d.ts +168 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/manifest.json +93 -0
- package/package.json +63 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scrape Tool
|
|
3
|
+
* Extract content from web pages using CSS selectors.
|
|
4
|
+
*
|
|
5
|
+
* @module @framers/agentos-ext-web-browser
|
|
6
|
+
*/
|
|
7
|
+
import type { ITool } from '@framers/agentos';
|
|
8
|
+
import type { BrowserService } from '../services/browserService';
|
|
9
|
+
import type { ScrapeResult } from '../types';
|
|
10
|
+
/**
|
|
11
|
+
* Tool for scraping page content
|
|
12
|
+
*/
|
|
13
|
+
export declare class ScrapeTool implements ITool {
|
|
14
|
+
private browserService;
|
|
15
|
+
readonly id = "browserScrape";
|
|
16
|
+
readonly name = "Scrape Content";
|
|
17
|
+
readonly description = "Extract content from web page using CSS selectors";
|
|
18
|
+
constructor(browserService: BrowserService);
|
|
19
|
+
/**
|
|
20
|
+
* Execute scraping
|
|
21
|
+
*/
|
|
22
|
+
execute(input: {
|
|
23
|
+
selector: string;
|
|
24
|
+
limit?: number;
|
|
25
|
+
attributes?: string[];
|
|
26
|
+
}): Promise<{
|
|
27
|
+
success: boolean;
|
|
28
|
+
output?: ScrapeResult;
|
|
29
|
+
error?: string;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Validate input
|
|
33
|
+
*/
|
|
34
|
+
validate(input: any): {
|
|
35
|
+
valid: boolean;
|
|
36
|
+
errors: string[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Get JSON schema for tool
|
|
40
|
+
*/
|
|
41
|
+
getSchema(): any;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=scrape.d.ts.map
|
|
@@ -0,0 +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;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,qBAAa,UAAW,YAAW,KAAK;IAK1B,OAAO,CAAC,cAAc;IAJlC,SAAgB,EAAE,mBAAmB;IACrC,SAAgB,IAAI,oBAAoB;IACxC,SAAgB,WAAW,uDAAuD;gBAE9D,cAAc,EAAE,cAAc;IAElD;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,YAAY,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IA4BxE;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;IAkB1D;;OAEG;IACH,SAAS,IAAI,GAAG;CAsBjB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scrape Tool
|
|
3
|
+
* Extract content from web pages using CSS selectors.
|
|
4
|
+
*
|
|
5
|
+
* @module @framers/agentos-ext-web-browser
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Tool for scraping page content
|
|
9
|
+
*/
|
|
10
|
+
export class ScrapeTool {
|
|
11
|
+
browserService;
|
|
12
|
+
id = 'browserScrape';
|
|
13
|
+
name = 'Scrape Content';
|
|
14
|
+
description = 'Extract content from web page using CSS selectors';
|
|
15
|
+
constructor(browserService) {
|
|
16
|
+
this.browserService = browserService;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Execute scraping
|
|
20
|
+
*/
|
|
21
|
+
async execute(input) {
|
|
22
|
+
try {
|
|
23
|
+
const result = await this.browserService.scrape(input.selector);
|
|
24
|
+
// Apply limit if specified
|
|
25
|
+
if (input.limit && result.elements.length > input.limit) {
|
|
26
|
+
result.elements = result.elements.slice(0, input.limit);
|
|
27
|
+
result.count = result.elements.length;
|
|
28
|
+
}
|
|
29
|
+
// Filter attributes if specified
|
|
30
|
+
if (input.attributes) {
|
|
31
|
+
result.elements = result.elements.map((el) => ({
|
|
32
|
+
...el,
|
|
33
|
+
attributes: Object.fromEntries(Object.entries(el.attributes).filter(([key]) => input.attributes.includes(key))),
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
return { success: true, output: result };
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return { success: false, error: error.message };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Validate input
|
|
44
|
+
*/
|
|
45
|
+
validate(input) {
|
|
46
|
+
const errors = [];
|
|
47
|
+
if (!input.selector) {
|
|
48
|
+
errors.push('Selector is required');
|
|
49
|
+
}
|
|
50
|
+
else if (typeof input.selector !== 'string') {
|
|
51
|
+
errors.push('Selector must be a string');
|
|
52
|
+
}
|
|
53
|
+
if (input.limit !== undefined) {
|
|
54
|
+
if (typeof input.limit !== 'number' || input.limit <= 0) {
|
|
55
|
+
errors.push('Limit must be a positive number');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return { valid: errors.length === 0, errors };
|
|
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
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
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,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACzB,WAAW,EAAE,gCAAgC;iBAC9C;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screenshot Tool
|
|
3
|
+
* Capture screenshots of the current page.
|
|
4
|
+
*
|
|
5
|
+
* @module @framers/agentos-ext-web-browser
|
|
6
|
+
*/
|
|
7
|
+
import type { ITool } from '@framers/agentos';
|
|
8
|
+
import type { BrowserService } from '../services/browserService';
|
|
9
|
+
import type { ScreenshotResult } from '../types';
|
|
10
|
+
/**
|
|
11
|
+
* Tool for taking screenshots
|
|
12
|
+
*/
|
|
13
|
+
export declare class ScreenshotTool implements ITool {
|
|
14
|
+
private browserService;
|
|
15
|
+
readonly id = "browserScreenshot";
|
|
16
|
+
readonly name = "Take Screenshot";
|
|
17
|
+
readonly description = "Capture screenshot of current page or element";
|
|
18
|
+
constructor(browserService: BrowserService);
|
|
19
|
+
/**
|
|
20
|
+
* Execute screenshot capture
|
|
21
|
+
*/
|
|
22
|
+
execute(input: {
|
|
23
|
+
fullPage?: boolean;
|
|
24
|
+
selector?: string;
|
|
25
|
+
format?: 'png' | 'jpeg' | 'webp';
|
|
26
|
+
quality?: number;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
output?: ScreenshotResult;
|
|
30
|
+
error?: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Validate input
|
|
34
|
+
*/
|
|
35
|
+
validate(input: any): {
|
|
36
|
+
valid: boolean;
|
|
37
|
+
errors: string[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Get JSON schema for tool
|
|
41
|
+
*/
|
|
42
|
+
getSchema(): any;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=screenshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/tools/screenshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEjD;;GAEG;AACH,qBAAa,cAAe,YAAW,KAAK;IAK9B,OAAO,CAAC,cAAc;IAJlC,SAAgB,EAAE,uBAAuB;IACzC,SAAgB,IAAI,qBAAqB;IACzC,SAAgB,WAAW,mDAAmD;gBAE1D,cAAc,EAAE,cAAc;IAElD;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;QACjC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAe5E;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;IAgB1D;;OAEG;IACH,SAAS,IAAI,GAAG;CA6BjB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screenshot Tool
|
|
3
|
+
* Capture screenshots of the current page.
|
|
4
|
+
*
|
|
5
|
+
* @module @framers/agentos-ext-web-browser
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Tool for taking screenshots
|
|
9
|
+
*/
|
|
10
|
+
export class ScreenshotTool {
|
|
11
|
+
browserService;
|
|
12
|
+
id = 'browserScreenshot';
|
|
13
|
+
name = 'Take Screenshot';
|
|
14
|
+
description = 'Capture screenshot of current page or element';
|
|
15
|
+
constructor(browserService) {
|
|
16
|
+
this.browserService = browserService;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Execute screenshot capture
|
|
20
|
+
*/
|
|
21
|
+
async execute(input) {
|
|
22
|
+
try {
|
|
23
|
+
const result = await this.browserService.screenshot({
|
|
24
|
+
fullPage: input.fullPage,
|
|
25
|
+
selector: input.selector,
|
|
26
|
+
format: input.format,
|
|
27
|
+
quality: input.quality,
|
|
28
|
+
});
|
|
29
|
+
return { success: true, output: result };
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
return { success: false, error: error.message };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validate input
|
|
37
|
+
*/
|
|
38
|
+
validate(input) {
|
|
39
|
+
const errors = [];
|
|
40
|
+
if (input.format && !['png', 'jpeg', 'webp'].includes(input.format)) {
|
|
41
|
+
errors.push('Format must be png, jpeg, or webp');
|
|
42
|
+
}
|
|
43
|
+
if (input.quality !== undefined) {
|
|
44
|
+
if (typeof input.quality !== 'number' || input.quality < 0 || input.quality > 100) {
|
|
45
|
+
errors.push('Quality must be a number between 0 and 100');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { valid: errors.length === 0, errors };
|
|
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
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=screenshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/tools/screenshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,cAAc;IAKL;IAJJ,EAAE,GAAG,mBAAmB,CAAC;IACzB,IAAI,GAAG,iBAAiB,CAAC;IACzB,WAAW,GAAG,+CAA+C,CAAC;IAE9E,YAAoB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAEtD;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,KAKb;QACC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC;gBAClD,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,MAAM,EAAE,KAAK,CAAC,MAAM;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,QAAQ,CAAC,KAAU;QACjB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
+
/**
|
|
2
|
+
* Snapshot Tool
|
|
3
|
+
* Get accessibility snapshot of the current page.
|
|
4
|
+
*
|
|
5
|
+
* @module @framers/agentos-ext-web-browser
|
|
6
|
+
*/
|
|
7
|
+
import type { ITool } from '@framers/agentos';
|
|
8
|
+
import type { BrowserService } from '../services/browserService';
|
|
9
|
+
import type { PageSnapshot } from '../types';
|
|
10
|
+
/**
|
|
11
|
+
* Tool for getting page snapshot
|
|
12
|
+
*/
|
|
13
|
+
export declare class SnapshotTool implements ITool {
|
|
14
|
+
private browserService;
|
|
15
|
+
readonly id = "browserSnapshot";
|
|
16
|
+
readonly name = "Page Snapshot";
|
|
17
|
+
readonly description = "Get accessibility snapshot of current page with interactive elements";
|
|
18
|
+
constructor(browserService: BrowserService);
|
|
19
|
+
/**
|
|
20
|
+
* Execute snapshot capture
|
|
21
|
+
*/
|
|
22
|
+
execute(_input: {
|
|
23
|
+
includeLinks?: boolean;
|
|
24
|
+
includeForms?: boolean;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
success: boolean;
|
|
27
|
+
output?: PageSnapshot;
|
|
28
|
+
error?: string;
|
|
29
|
+
}>;
|
|
30
|
+
/**
|
|
31
|
+
* Validate input
|
|
32
|
+
*/
|
|
33
|
+
validate(_input: any): {
|
|
34
|
+
valid: boolean;
|
|
35
|
+
errors: string[];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Get JSON schema for tool
|
|
39
|
+
*/
|
|
40
|
+
getSchema(): any;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +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;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,qBAAa,YAAa,YAAW,KAAK;IAK5B,OAAO,CAAC,cAAc;IAJlC,SAAgB,EAAE,qBAAqB;IACvC,SAAgB,IAAI,mBAAmB;IACvC,SAAgB,WAAW,0EAA0E;gBAEjF,cAAc,EAAE,cAAc;IAElD;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE;QACpB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,YAAY,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAUxE;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;IAI3D;;OAEG;IACH,SAAS,IAAI,GAAG;CAiBjB"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Snapshot Tool
|
|
3
|
+
* Get accessibility snapshot of the current page.
|
|
4
|
+
*
|
|
5
|
+
* @module @framers/agentos-ext-web-browser
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Tool for getting page snapshot
|
|
9
|
+
*/
|
|
10
|
+
export class SnapshotTool {
|
|
11
|
+
browserService;
|
|
12
|
+
id = 'browserSnapshot';
|
|
13
|
+
name = 'Page Snapshot';
|
|
14
|
+
description = 'Get accessibility snapshot of current page with interactive elements';
|
|
15
|
+
constructor(browserService) {
|
|
16
|
+
this.browserService = browserService;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Execute snapshot capture
|
|
20
|
+
*/
|
|
21
|
+
async execute(_input) {
|
|
22
|
+
try {
|
|
23
|
+
const snapshot = await this.browserService.getSnapshot();
|
|
24
|
+
return { success: true, output: snapshot };
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return { success: false, error: error.message };
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Validate input
|
|
32
|
+
*/
|
|
33
|
+
validate(_input) {
|
|
34
|
+
return { valid: true, errors: [] };
|
|
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
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/tools/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,YAAY;IAKH;IAJJ,EAAE,GAAG,iBAAiB,CAAC;IACvB,IAAI,GAAG,eAAe,CAAC;IACvB,WAAW,GAAG,sEAAsE,CAAC;IAErG,YAAoB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAEtD;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,MAGb;QACC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;YAEzD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC7C,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,QAAQ,CAAC,MAAW;QAClB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,YAAY,EAAE;oBACZ,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,IAAI;oBACb,WAAW,EAAE,2BAA2B;iBACzC;gBACD,YAAY,EAAE;oBACZ,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,IAAI;oBACb,WAAW,EAAE,2BAA2B;iBACzC;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Tool
|
|
3
|
+
* Type text into input fields.
|
|
4
|
+
*
|
|
5
|
+
* @module @framers/agentos-ext-web-browser
|
|
6
|
+
*/
|
|
7
|
+
import type { ITool } from '@framers/agentos';
|
|
8
|
+
import type { BrowserService } from '../services/browserService';
|
|
9
|
+
import type { TypeResult } from '../types';
|
|
10
|
+
/**
|
|
11
|
+
* Tool for typing into inputs
|
|
12
|
+
*/
|
|
13
|
+
export declare class TypeTool implements ITool {
|
|
14
|
+
private browserService;
|
|
15
|
+
readonly id = "browserType";
|
|
16
|
+
readonly name = "Type Text";
|
|
17
|
+
readonly description = "Type text into an input field";
|
|
18
|
+
constructor(browserService: BrowserService);
|
|
19
|
+
/**
|
|
20
|
+
* Execute typing
|
|
21
|
+
*/
|
|
22
|
+
execute(input: {
|
|
23
|
+
selector: string;
|
|
24
|
+
text: string;
|
|
25
|
+
delay?: number;
|
|
26
|
+
clear?: boolean;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
success: boolean;
|
|
29
|
+
output?: TypeResult;
|
|
30
|
+
error?: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Validate input
|
|
34
|
+
*/
|
|
35
|
+
validate(input: any): {
|
|
36
|
+
valid: boolean;
|
|
37
|
+
errors: string[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Get JSON schema for tool
|
|
41
|
+
*/
|
|
42
|
+
getSchema(): any;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../src/tools/type.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,qBAAa,QAAS,YAAW,KAAK;IAKxB,OAAO,CAAC,cAAc;IAJlC,SAAgB,EAAE,iBAAiB;IACnC,SAAgB,IAAI,eAAe;IACnC,SAAgB,WAAW,mCAAmC;gBAE1C,cAAc,EAAE,cAAc;IAElD;;OAEG;IACG,OAAO,CAAC,KAAK,EAAE;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAatE;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;IAkB1D;;OAEG;IACH,SAAS,IAAI,GAAG;CA0BjB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type Tool
|
|
3
|
+
* Type text into input fields.
|
|
4
|
+
*
|
|
5
|
+
* @module @framers/agentos-ext-web-browser
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Tool for typing into inputs
|
|
9
|
+
*/
|
|
10
|
+
export class TypeTool {
|
|
11
|
+
browserService;
|
|
12
|
+
id = 'browserType';
|
|
13
|
+
name = 'Type Text';
|
|
14
|
+
description = 'Type text into an input field';
|
|
15
|
+
constructor(browserService) {
|
|
16
|
+
this.browserService = browserService;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Execute typing
|
|
20
|
+
*/
|
|
21
|
+
async execute(input) {
|
|
22
|
+
try {
|
|
23
|
+
const result = await this.browserService.type(input.selector, input.text, {
|
|
24
|
+
delay: input.delay,
|
|
25
|
+
clear: input.clear,
|
|
26
|
+
});
|
|
27
|
+
return { success: result.success, output: result };
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return { success: false, error: error.message };
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validate input
|
|
35
|
+
*/
|
|
36
|
+
validate(input) {
|
|
37
|
+
const errors = [];
|
|
38
|
+
if (!input.selector) {
|
|
39
|
+
errors.push('Selector is required');
|
|
40
|
+
}
|
|
41
|
+
else if (typeof input.selector !== 'string') {
|
|
42
|
+
errors.push('Selector must be a string');
|
|
43
|
+
}
|
|
44
|
+
if (input.text === undefined || input.text === null) {
|
|
45
|
+
errors.push('Text is required');
|
|
46
|
+
}
|
|
47
|
+
else if (typeof input.text !== 'string') {
|
|
48
|
+
errors.push('Text must be a string');
|
|
49
|
+
}
|
|
50
|
+
return { valid: errors.length === 0, errors };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get JSON schema for tool
|
|
54
|
+
*/
|
|
55
|
+
getSchema() {
|
|
56
|
+
return {
|
|
57
|
+
type: 'object',
|
|
58
|
+
required: ['selector', 'text'],
|
|
59
|
+
properties: {
|
|
60
|
+
selector: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'CSS selector for the input element',
|
|
63
|
+
},
|
|
64
|
+
text: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'Text to type',
|
|
67
|
+
},
|
|
68
|
+
delay: {
|
|
69
|
+
type: 'number',
|
|
70
|
+
description: 'Delay between keystrokes (ms)',
|
|
71
|
+
default: 0,
|
|
72
|
+
},
|
|
73
|
+
clear: {
|
|
74
|
+
type: 'boolean',
|
|
75
|
+
description: 'Clear existing text before typing',
|
|
76
|
+
default: false,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/tools/type.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;GAEG;AACH,MAAM,OAAO,QAAQ;IAKC;IAJJ,EAAE,GAAG,aAAa,CAAC;IACnB,IAAI,GAAG,WAAW,CAAC;IACnB,WAAW,GAAG,+BAA+B,CAAC;IAE9D,YAAoB,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAEtD;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,KAKb;QACC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE;gBACxE,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB,CAAC,CAAC;YAEH,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QACrD,CAAC;QAAC,OAAO,KAAU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