bedrock-agentcore 0.0.1 → 0.1.1
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/LICENSE +202 -0
- package/README.md +151 -9
- package/dist/src/tools/browser/client.d.ts +125 -0
- package/dist/src/tools/browser/client.d.ts.map +1 -0
- package/dist/src/tools/browser/client.js +320 -0
- package/dist/src/tools/browser/client.js.map +1 -0
- package/dist/src/tools/browser/index.d.ts +4 -0
- package/dist/src/tools/browser/index.d.ts.map +1 -0
- package/dist/src/tools/browser/index.js +3 -0
- package/dist/src/tools/browser/index.js.map +1 -0
- package/dist/src/tools/browser/integrations/playwright/client.d.ts +147 -0
- package/dist/src/tools/browser/integrations/playwright/client.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/playwright/client.js +324 -0
- package/dist/src/tools/browser/integrations/playwright/client.js.map +1 -0
- package/dist/src/tools/browser/integrations/playwright/index.d.ts +20 -0
- package/dist/src/tools/browser/integrations/playwright/index.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/playwright/index.js +19 -0
- package/dist/src/tools/browser/integrations/playwright/index.js.map +1 -0
- package/dist/src/tools/browser/integrations/playwright/types.d.ts +169 -0
- package/dist/src/tools/browser/integrations/playwright/types.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/playwright/types.js +2 -0
- package/dist/src/tools/browser/integrations/playwright/types.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/click-tool.d.ts +18 -0
- package/dist/src/tools/browser/integrations/vercel-ai/click-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/click-tool.js +31 -0
- package/dist/src/tools/browser/integrations/vercel-ai/click-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/evaluate-tool.d.ts +18 -0
- package/dist/src/tools/browser/integrations/vercel-ai/evaluate-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/evaluate-tool.js +32 -0
- package/dist/src/tools/browser/integrations/vercel-ai/evaluate-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/get-html-tool.d.ts +17 -0
- package/dist/src/tools/browser/integrations/vercel-ai/get-html-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/get-html-tool.js +30 -0
- package/dist/src/tools/browser/integrations/vercel-ai/get-html-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/get-text-tool.d.ts +17 -0
- package/dist/src/tools/browser/integrations/vercel-ai/get-text-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/get-text-tool.js +30 -0
- package/dist/src/tools/browser/integrations/vercel-ai/get-text-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/index.d.ts +19 -0
- package/dist/src/tools/browser/integrations/vercel-ai/index.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/index.js +19 -0
- package/dist/src/tools/browser/integrations/vercel-ai/index.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/navigate-tool.d.ts +19 -0
- package/dist/src/tools/browser/integrations/vercel-ai/navigate-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/navigate-tool.js +39 -0
- package/dist/src/tools/browser/integrations/vercel-ai/navigate-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/screenshot-tool.d.ts +22 -0
- package/dist/src/tools/browser/integrations/vercel-ai/screenshot-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/screenshot-tool.js +44 -0
- package/dist/src/tools/browser/integrations/vercel-ai/screenshot-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/tools.d.ts +123 -0
- package/dist/src/tools/browser/integrations/vercel-ai/tools.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/tools.js +145 -0
- package/dist/src/tools/browser/integrations/vercel-ai/tools.js.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/type-tool.d.ts +20 -0
- package/dist/src/tools/browser/integrations/vercel-ai/type-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/vercel-ai/type-tool.js +35 -0
- package/dist/src/tools/browser/integrations/vercel-ai/type-tool.js.map +1 -0
- package/dist/src/tools/browser/types.d.ts +336 -0
- package/dist/src/tools/browser/types.d.ts.map +1 -0
- package/dist/src/tools/browser/types.js +17 -0
- package/dist/src/tools/browser/types.js.map +1 -0
- package/dist/src/tools/code-interpreter/client.d.ts +212 -0
- package/dist/src/tools/code-interpreter/client.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/client.js +512 -0
- package/dist/src/tools/code-interpreter/client.js.map +1 -0
- package/dist/src/tools/code-interpreter/index.d.ts +4 -0
- package/dist/src/tools/code-interpreter/index.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/index.js +5 -0
- package/dist/src/tools/code-interpreter/index.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.d.ts +27 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.js +46 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.d.ts +26 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.js +41 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.d.ts +32 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.js +77 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.d.ts +26 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.js +26 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.d.ts +94 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.js +112 -0
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.js.map +1 -0
- package/dist/src/tools/code-interpreter/types.d.ts +473 -0
- package/dist/src/tools/code-interpreter/types.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/types.js +52 -0
- package/dist/src/tools/code-interpreter/types.js.map +1 -0
- package/package.json +99 -12
- package/index.js +0 -4
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Vercel AI tool for evaluating JavaScript.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser.evaluate()
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
8
|
+
export function createEvaluateTool(client) {
|
|
9
|
+
return tool({
|
|
10
|
+
description: 'Evaluate JavaScript code in the page context',
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
script: z.string().describe('JavaScript code to execute'),
|
|
13
|
+
args: z.array(z.any()).optional().describe('Arguments to pass to the script'),
|
|
14
|
+
}),
|
|
15
|
+
execute: async ({ script, args }) => {
|
|
16
|
+
'use step';
|
|
17
|
+
try {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
const params = { script };
|
|
20
|
+
if (args !== undefined)
|
|
21
|
+
params.args = args;
|
|
22
|
+
const result = await client.evaluate(params);
|
|
23
|
+
return { success: true, result };
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
27
|
+
return { success: false, error: message };
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=evaluate-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/evaluate-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;GAGG;AACH,+HAA+H;AAC/H,MAAM,UAAU,kBAAkB,CAAC,MAAyB;IAC1D,OAAO,IAAI,CAAC;QACV,WAAW,EAAE,8CAA8C;QAC3D,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;YACzD,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;SAC9E,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;YAClC,UAAU,CAAA;YACV,IAAI,CAAC;gBACH,8DAA8D;gBAC9D,MAAM,MAAM,GAAqC,EAAE,MAAM,EAAE,CAAA;gBAC3D,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;gBAC1C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;gBAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;YAClC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAA;gBACxE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;YAC3C,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PlaywrightBrowser } from '../playwright/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Vercel AI tool for getting HTML content.
|
|
4
|
+
* Thin wrapper around PlaywrightBrowser.getHtml()
|
|
5
|
+
*/
|
|
6
|
+
export declare function createGetHtmlTool(client: PlaywrightBrowser): import("ai").Tool<{
|
|
7
|
+
selector?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
success: boolean;
|
|
10
|
+
html: string;
|
|
11
|
+
error?: never;
|
|
12
|
+
} | {
|
|
13
|
+
success: boolean;
|
|
14
|
+
error: string;
|
|
15
|
+
html?: never;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=get-html-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-html-tool.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/get-html-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE;;;GAGG;AAEH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB;;;;;;;;;;GAmB1D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Vercel AI tool for getting HTML content.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser.getHtml()
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
8
|
+
export function createGetHtmlTool(client) {
|
|
9
|
+
return tool({
|
|
10
|
+
description: 'Get HTML content from an element or the entire page',
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
selector: z.string().optional().describe('CSS selector for the element (omit for full page HTML)'),
|
|
13
|
+
}),
|
|
14
|
+
execute: async ({ selector }) => {
|
|
15
|
+
'use step';
|
|
16
|
+
try {
|
|
17
|
+
const params = {};
|
|
18
|
+
if (selector !== undefined)
|
|
19
|
+
params.selector = selector;
|
|
20
|
+
const html = await client.getHtml(params);
|
|
21
|
+
return { success: true, html };
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
25
|
+
return { success: false, error: message };
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=get-html-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-html-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/get-html-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;GAGG;AACH,+HAA+H;AAC/H,MAAM,UAAU,iBAAiB,CAAC,MAAyB;IACzD,OAAO,IAAI,CAAC;QACV,WAAW,EAAE,qDAAqD;QAClE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wDAAwD,CAAC;SACnG,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC9B,UAAU,CAAA;YACV,IAAI,CAAC;gBACH,MAAM,MAAM,GAA0B,EAAE,CAAA;gBACxC,IAAI,QAAQ,KAAK,SAAS;oBAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;gBACtD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;gBACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;YAChC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAA;gBACxE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;YAC3C,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PlaywrightBrowser } from '../playwright/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Vercel AI tool for getting text content.
|
|
4
|
+
* Thin wrapper around PlaywrightBrowser.getText()
|
|
5
|
+
*/
|
|
6
|
+
export declare function createGetTextTool(client: PlaywrightBrowser): import("ai").Tool<{
|
|
7
|
+
selector?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
success: boolean;
|
|
10
|
+
text: string;
|
|
11
|
+
error?: never;
|
|
12
|
+
} | {
|
|
13
|
+
success: boolean;
|
|
14
|
+
error: string;
|
|
15
|
+
text?: never;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=get-text-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-text-tool.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/get-text-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE;;;GAGG;AAEH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB;;;;;;;;;;GAmB1D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Vercel AI tool for getting text content.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser.getText()
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
8
|
+
export function createGetTextTool(client) {
|
|
9
|
+
return tool({
|
|
10
|
+
description: 'Get text content from an element or the entire page',
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
selector: z.string().optional().describe('CSS selector for the element (omit for full page text)'),
|
|
13
|
+
}),
|
|
14
|
+
execute: async ({ selector }) => {
|
|
15
|
+
'use step';
|
|
16
|
+
try {
|
|
17
|
+
const params = {};
|
|
18
|
+
if (selector !== undefined)
|
|
19
|
+
params.selector = selector;
|
|
20
|
+
const text = await client.getText(params);
|
|
21
|
+
return { success: true, text };
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
25
|
+
return { success: false, error: message };
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=get-text-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-text-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/get-text-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;GAGG;AACH,+HAA+H;AAC/H,MAAM,UAAU,iBAAiB,CAAC,MAAyB;IACzD,OAAO,IAAI,CAAC;QACV,WAAW,EAAE,qDAAqD;QAClE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wDAAwD,CAAC;SACnG,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC9B,UAAU,CAAA;YACV,IAAI,CAAC;gBACH,MAAM,MAAM,GAA0B,EAAE,CAAA;gBACxC,IAAI,QAAQ,KAAK,SAAS;oBAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;gBACtD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;gBACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAA;YAChC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAA;gBACxE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;YAC3C,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel AI Browser Tool Integration
|
|
3
|
+
*
|
|
4
|
+
* This module provides Vercel AI SDK integration for the AWS Bedrock AgentCore Browser service.
|
|
5
|
+
* It follows the three-layer architecture:
|
|
6
|
+
* - User Application Layer (Vercel AI)
|
|
7
|
+
* - Integration Layer (this module - thin wrappers)
|
|
8
|
+
* - Base Client Layer (BrowserClient - all browser logic)
|
|
9
|
+
* - AWS SDK Layer (\@aws-sdk/client-bedrock-agentcore)
|
|
10
|
+
*/
|
|
11
|
+
export { BrowserTools } from './tools.js';
|
|
12
|
+
export { createNavigateTool } from './navigate-tool.js';
|
|
13
|
+
export { createClickTool } from './click-tool.js';
|
|
14
|
+
export { createTypeTool } from './type-tool.js';
|
|
15
|
+
export { createGetTextTool } from './get-text-tool.js';
|
|
16
|
+
export { createGetHtmlTool } from './get-html-tool.js';
|
|
17
|
+
export { createScreenshotTool } from './screenshot-tool.js';
|
|
18
|
+
export { createEvaluateTool } from './evaluate-tool.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vercel AI Browser Tool Integration
|
|
3
|
+
*
|
|
4
|
+
* This module provides Vercel AI SDK integration for the AWS Bedrock AgentCore Browser service.
|
|
5
|
+
* It follows the three-layer architecture:
|
|
6
|
+
* - User Application Layer (Vercel AI)
|
|
7
|
+
* - Integration Layer (this module - thin wrappers)
|
|
8
|
+
* - Base Client Layer (BrowserClient - all browser logic)
|
|
9
|
+
* - AWS SDK Layer (\@aws-sdk/client-bedrock-agentcore)
|
|
10
|
+
*/
|
|
11
|
+
export { BrowserTools } from './tools.js';
|
|
12
|
+
export { createNavigateTool } from './navigate-tool.js';
|
|
13
|
+
export { createClickTool } from './click-tool.js';
|
|
14
|
+
export { createTypeTool } from './type-tool.js';
|
|
15
|
+
export { createGetTextTool } from './get-text-tool.js';
|
|
16
|
+
export { createGetHtmlTool } from './get-html-tool.js';
|
|
17
|
+
export { createScreenshotTool } from './screenshot-tool.js';
|
|
18
|
+
export { createEvaluateTool } from './evaluate-tool.js';
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PlaywrightBrowser } from '../playwright/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Vercel AI tool for browser navigation.
|
|
4
|
+
* Thin wrapper around PlaywrightBrowser.navigate()
|
|
5
|
+
*/
|
|
6
|
+
export declare function createNavigateTool(client: PlaywrightBrowser): import("ai").Tool<{
|
|
7
|
+
url: string;
|
|
8
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle" | undefined;
|
|
9
|
+
timeout?: number | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
success: boolean;
|
|
12
|
+
message: string;
|
|
13
|
+
error?: never;
|
|
14
|
+
} | {
|
|
15
|
+
success: boolean;
|
|
16
|
+
error: string;
|
|
17
|
+
message?: never;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=navigate-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate-tool.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/navigate-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE;;;GAGG;AAEH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB;;;;;;;;;;;;GA2B3D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Vercel AI tool for browser navigation.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser.navigate()
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
8
|
+
export function createNavigateTool(client) {
|
|
9
|
+
return tool({
|
|
10
|
+
description: 'Navigate to a URL in the browser',
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
url: z.string().url().describe('URL to navigate to'),
|
|
13
|
+
waitUntil: z
|
|
14
|
+
.enum(['load', 'domcontentloaded', 'networkidle'])
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('When to consider navigation successful'),
|
|
17
|
+
timeout: z.number().positive().optional().describe('Maximum navigation time in milliseconds'),
|
|
18
|
+
}),
|
|
19
|
+
execute: async ({ url, waitUntil, timeout }) => {
|
|
20
|
+
'use step';
|
|
21
|
+
try {
|
|
22
|
+
const params = {
|
|
23
|
+
url,
|
|
24
|
+
};
|
|
25
|
+
if (waitUntil !== undefined)
|
|
26
|
+
params.waitUntil = waitUntil;
|
|
27
|
+
if (timeout !== undefined)
|
|
28
|
+
params.timeout = timeout;
|
|
29
|
+
await client.navigate(params);
|
|
30
|
+
return { success: true, message: `Navigated to ${url}` };
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
34
|
+
return { success: false, error: message };
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=navigate-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/navigate-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;GAGG;AACH,+HAA+H;AAC/H,MAAM,UAAU,kBAAkB,CAAC,MAAyB;IAC1D,OAAO,IAAI,CAAC;QACV,WAAW,EAAE,kCAAkC;QAC/C,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC;YACpD,SAAS,EAAE,CAAC;iBACT,IAAI,CAAC,CAAC,MAAM,EAAE,kBAAkB,EAAE,aAAa,CAAC,CAAC;iBACjD,QAAQ,EAAE;iBACV,QAAQ,CAAC,wCAAwC,CAAC;YACrD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;SAC9F,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE;YAC7C,UAAU,CAAA;YACV,IAAI,CAAC;gBACH,MAAM,MAAM,GAA+F;oBACzG,GAAG;iBACJ,CAAA;gBACD,IAAI,SAAS,KAAK,SAAS;oBAAE,MAAM,CAAC,SAAS,GAAG,SAAS,CAAA;gBACzD,IAAI,OAAO,KAAK,SAAS;oBAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;gBACnD,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;gBAC7B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,GAAG,EAAE,EAAE,CAAA;YAC1D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAA;gBACxE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;YAC3C,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PlaywrightBrowser } from '../playwright/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Vercel AI tool for taking screenshots.
|
|
4
|
+
* Thin wrapper around PlaywrightBrowser.screenshot()
|
|
5
|
+
*/
|
|
6
|
+
export declare function createScreenshotTool(client: PlaywrightBrowser): import("ai").Tool<{
|
|
7
|
+
path?: string | undefined;
|
|
8
|
+
fullPage?: boolean | undefined;
|
|
9
|
+
type?: "png" | "jpeg" | undefined;
|
|
10
|
+
encoding?: "base64" | "binary" | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
success: boolean;
|
|
13
|
+
message: string;
|
|
14
|
+
screenshot: string | Buffer<ArrayBufferLike> | undefined;
|
|
15
|
+
error?: never;
|
|
16
|
+
} | {
|
|
17
|
+
success: boolean;
|
|
18
|
+
error: string;
|
|
19
|
+
message?: never;
|
|
20
|
+
screenshot?: never;
|
|
21
|
+
}>;
|
|
22
|
+
//# sourceMappingURL=screenshot-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot-tool.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/screenshot-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE;;;GAGG;AAEH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB;;;;;;;;;;;;;;;GA8B7D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { tool } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Vercel AI tool for taking screenshots.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser.screenshot()
|
|
6
|
+
*/
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
8
|
+
export function createScreenshotTool(client) {
|
|
9
|
+
return tool({
|
|
10
|
+
description: 'Take a screenshot of the page',
|
|
11
|
+
inputSchema: z.object({
|
|
12
|
+
path: z.string().optional().describe('Path to save the screenshot file'),
|
|
13
|
+
fullPage: z.boolean().optional().describe('Capture the full scrollable page'),
|
|
14
|
+
type: z.enum(['png', 'jpeg']).optional().describe('Image type'),
|
|
15
|
+
encoding: z.enum(['base64', 'binary']).optional().describe('Encoding format'),
|
|
16
|
+
}),
|
|
17
|
+
execute: async ({ path, fullPage, type, encoding }) => {
|
|
18
|
+
'use step';
|
|
19
|
+
try {
|
|
20
|
+
const params = {};
|
|
21
|
+
if (path !== undefined)
|
|
22
|
+
params.path = path;
|
|
23
|
+
if (fullPage !== undefined)
|
|
24
|
+
params.fullPage = fullPage;
|
|
25
|
+
if (type !== undefined)
|
|
26
|
+
params.type = type;
|
|
27
|
+
if (encoding !== undefined)
|
|
28
|
+
params.encoding = encoding;
|
|
29
|
+
const screenshot = await client.screenshot(params);
|
|
30
|
+
const isBase64 = encoding === 'base64';
|
|
31
|
+
return {
|
|
32
|
+
success: true,
|
|
33
|
+
message: path ? `Screenshot saved to ${path}` : 'Screenshot captured',
|
|
34
|
+
screenshot: isBase64 ? screenshot : undefined,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
39
|
+
return { success: false, error: message };
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=screenshot-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/screenshot-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;GAGG;AACH,+HAA+H;AAC/H,MAAM,UAAU,oBAAoB,CAAC,MAAyB;IAC5D,OAAO,IAAI,CAAC;QACV,WAAW,EAAE,+BAA+B;QAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;YACxE,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;YAC7E,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC;YAC/D,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC;SAC9E,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;YACpD,UAAU,CAAA;YACV,IAAI,CAAC;gBACH,MAAM,MAAM,GAAiG,EAAE,CAAA;gBAC/G,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;gBAC1C,IAAI,QAAQ,KAAK,SAAS;oBAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;gBACtD,IAAI,IAAI,KAAK,SAAS;oBAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;gBAC1C,IAAI,QAAQ,KAAK,SAAS;oBAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAA;gBACtD,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;gBAClD,MAAM,QAAQ,GAAG,QAAQ,KAAK,QAAQ,CAAA;gBACtC,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC,CAAC,qBAAqB;oBACrE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS;iBAC9C,CAAA;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAA;gBACxE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;YAC3C,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified BrowserTools for Vercel AI SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides browser automation tools and session management in one class.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser - all logic lives in the Playwright integration.
|
|
6
|
+
*/
|
|
7
|
+
import { PlaywrightBrowser } from '../playwright/client.js';
|
|
8
|
+
import type { BrowserClientConfig, SessionInfo } from '../../types.js';
|
|
9
|
+
import { createNavigateTool } from './navigate-tool.js';
|
|
10
|
+
import { createClickTool } from './click-tool.js';
|
|
11
|
+
import { createTypeTool } from './type-tool.js';
|
|
12
|
+
import { createGetTextTool } from './get-text-tool.js';
|
|
13
|
+
import { createGetHtmlTool } from './get-html-tool.js';
|
|
14
|
+
import { createScreenshotTool } from './screenshot-tool.js';
|
|
15
|
+
import { createEvaluateTool } from './evaluate-tool.js';
|
|
16
|
+
/**
|
|
17
|
+
* BrowserTools - All-in-one browser automation for Vercel AI SDK
|
|
18
|
+
*
|
|
19
|
+
* Provides browser automation tools and session management.
|
|
20
|
+
* All browser logic is in PlaywrightBrowser - this is just a thin wrapper.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { BrowserTools } from '@bedrock-agentcore/sdk/browser/vercel-ai'
|
|
25
|
+
* import { ToolLoopAgent } from 'ai'
|
|
26
|
+
* import { bedrock } from '@ai-sdk/amazon-bedrock'
|
|
27
|
+
*
|
|
28
|
+
* // Create tools instance
|
|
29
|
+
* const browser = new BrowserTools({ region: 'us-west-2' })
|
|
30
|
+
*
|
|
31
|
+
* // Start session (optional - automatically started on first use)
|
|
32
|
+
* await browser.startSession()
|
|
33
|
+
*
|
|
34
|
+
* // Create agent with browser tools
|
|
35
|
+
* const agent = new ToolLoopAgent({
|
|
36
|
+
* model: bedrock('global.anthropic.claude-sonnet-4-20250514-v1:0'),
|
|
37
|
+
* tools: browser.tools,
|
|
38
|
+
* })
|
|
39
|
+
*
|
|
40
|
+
* // Or use client directly
|
|
41
|
+
* await browser.getClient().navigate({ url: 'https://example.com' })
|
|
42
|
+
*
|
|
43
|
+
* // Clean up when done
|
|
44
|
+
* await browser.stopSession()
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class BrowserTools {
|
|
48
|
+
private client;
|
|
49
|
+
/**
|
|
50
|
+
* Tool for navigating to URLs
|
|
51
|
+
*/
|
|
52
|
+
readonly navigate: ReturnType<typeof createNavigateTool>;
|
|
53
|
+
/**
|
|
54
|
+
* Tool for clicking elements
|
|
55
|
+
*/
|
|
56
|
+
readonly click: ReturnType<typeof createClickTool>;
|
|
57
|
+
/**
|
|
58
|
+
* Tool for typing text
|
|
59
|
+
*/
|
|
60
|
+
readonly type: ReturnType<typeof createTypeTool>;
|
|
61
|
+
/**
|
|
62
|
+
* Tool for getting text content
|
|
63
|
+
*/
|
|
64
|
+
readonly getText: ReturnType<typeof createGetTextTool>;
|
|
65
|
+
/**
|
|
66
|
+
* Tool for getting HTML
|
|
67
|
+
*/
|
|
68
|
+
readonly getHtml: ReturnType<typeof createGetHtmlTool>;
|
|
69
|
+
/**
|
|
70
|
+
* Tool for taking screenshots
|
|
71
|
+
*/
|
|
72
|
+
readonly screenshot: ReturnType<typeof createScreenshotTool>;
|
|
73
|
+
/**
|
|
74
|
+
* Tool for evaluating JavaScript
|
|
75
|
+
*/
|
|
76
|
+
readonly evaluate: ReturnType<typeof createEvaluateTool>;
|
|
77
|
+
/**
|
|
78
|
+
* All tools in an object for easy spreading into agent config
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const agent = new ToolLoopAgent({
|
|
83
|
+
* tools: browser.tools, // spreads all browser tools
|
|
84
|
+
* })
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
readonly tools: {
|
|
88
|
+
navigate: ReturnType<typeof createNavigateTool>;
|
|
89
|
+
click: ReturnType<typeof createClickTool>;
|
|
90
|
+
type: ReturnType<typeof createTypeTool>;
|
|
91
|
+
getText: ReturnType<typeof createGetTextTool>;
|
|
92
|
+
getHtml: ReturnType<typeof createGetHtmlTool>;
|
|
93
|
+
screenshot: ReturnType<typeof createScreenshotTool>;
|
|
94
|
+
evaluate: ReturnType<typeof createEvaluateTool>;
|
|
95
|
+
};
|
|
96
|
+
constructor(config?: BrowserClientConfig);
|
|
97
|
+
/**
|
|
98
|
+
* Start a browser session
|
|
99
|
+
*
|
|
100
|
+
* Sessions are automatically started on first tool use, but you can
|
|
101
|
+
* call this explicitly to start the session upfront.
|
|
102
|
+
*
|
|
103
|
+
* @param sessionName - Optional session name for AWS
|
|
104
|
+
* @param timeout - Optional session timeout in seconds (default: 3600, max: 28800)
|
|
105
|
+
* @returns Session information
|
|
106
|
+
*/
|
|
107
|
+
startSession(sessionName?: string, timeout?: number): Promise<SessionInfo>;
|
|
108
|
+
/**
|
|
109
|
+
* Stop the current browser session
|
|
110
|
+
*
|
|
111
|
+
* Call this when you're done using the tools to clean up resources.
|
|
112
|
+
*/
|
|
113
|
+
stopSession(): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Get the underlying PlaywrightBrowser
|
|
116
|
+
*
|
|
117
|
+
* Provides direct access to the client for advanced use cases.
|
|
118
|
+
*
|
|
119
|
+
* @returns The PlaywrightBrowser instance
|
|
120
|
+
*/
|
|
121
|
+
getClient(): PlaywrightBrowser;
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAsB,MAAM,gBAAgB,CAAA;AAC1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAmB;IAEjC;;OAEG;IACH,SAAgB,QAAQ,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;IAE/D;;OAEG;IACH,SAAgB,KAAK,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAEzD;;OAEG;IACH,SAAgB,IAAI,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;IAEvD;;OAEG;IACH,SAAgB,OAAO,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;IAE7D;;OAEG;IACH,SAAgB,OAAO,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;IAE7D;;OAEG;IACH,SAAgB,UAAU,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;IAEnE;;OAEG;IACH,SAAgB,QAAQ,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;IAE/D;;;;;;;;;OASG;IACH,SAAgB,KAAK,EAAE;QACrB,QAAQ,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;QAC/C,KAAK,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;QACzC,IAAI,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;QACvC,OAAO,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;QAC7C,OAAO,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA;QAC7C,UAAU,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;QACnD,QAAQ,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAA;KAChD,CAAA;gBAEW,MAAM,GAAE,mBAAwB;IAwB5C;;;;;;;;;OASG;IACG,YAAY,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAOhF;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC;;;;;;OAMG;IACH,SAAS,IAAI,iBAAiB;CAG/B"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified BrowserTools for Vercel AI SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides browser automation tools and session management in one class.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser - all logic lives in the Playwright integration.
|
|
6
|
+
*/
|
|
7
|
+
import { PlaywrightBrowser } from '../playwright/client.js';
|
|
8
|
+
import { createNavigateTool } from './navigate-tool.js';
|
|
9
|
+
import { createClickTool } from './click-tool.js';
|
|
10
|
+
import { createTypeTool } from './type-tool.js';
|
|
11
|
+
import { createGetTextTool } from './get-text-tool.js';
|
|
12
|
+
import { createGetHtmlTool } from './get-html-tool.js';
|
|
13
|
+
import { createScreenshotTool } from './screenshot-tool.js';
|
|
14
|
+
import { createEvaluateTool } from './evaluate-tool.js';
|
|
15
|
+
/**
|
|
16
|
+
* BrowserTools - All-in-one browser automation for Vercel AI SDK
|
|
17
|
+
*
|
|
18
|
+
* Provides browser automation tools and session management.
|
|
19
|
+
* All browser logic is in PlaywrightBrowser - this is just a thin wrapper.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { BrowserTools } from '@bedrock-agentcore/sdk/browser/vercel-ai'
|
|
24
|
+
* import { ToolLoopAgent } from 'ai'
|
|
25
|
+
* import { bedrock } from '@ai-sdk/amazon-bedrock'
|
|
26
|
+
*
|
|
27
|
+
* // Create tools instance
|
|
28
|
+
* const browser = new BrowserTools({ region: 'us-west-2' })
|
|
29
|
+
*
|
|
30
|
+
* // Start session (optional - automatically started on first use)
|
|
31
|
+
* await browser.startSession()
|
|
32
|
+
*
|
|
33
|
+
* // Create agent with browser tools
|
|
34
|
+
* const agent = new ToolLoopAgent({
|
|
35
|
+
* model: bedrock('global.anthropic.claude-sonnet-4-20250514-v1:0'),
|
|
36
|
+
* tools: browser.tools,
|
|
37
|
+
* })
|
|
38
|
+
*
|
|
39
|
+
* // Or use client directly
|
|
40
|
+
* await browser.getClient().navigate({ url: 'https://example.com' })
|
|
41
|
+
*
|
|
42
|
+
* // Clean up when done
|
|
43
|
+
* await browser.stopSession()
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export class BrowserTools {
|
|
47
|
+
client;
|
|
48
|
+
/**
|
|
49
|
+
* Tool for navigating to URLs
|
|
50
|
+
*/
|
|
51
|
+
navigate;
|
|
52
|
+
/**
|
|
53
|
+
* Tool for clicking elements
|
|
54
|
+
*/
|
|
55
|
+
click;
|
|
56
|
+
/**
|
|
57
|
+
* Tool for typing text
|
|
58
|
+
*/
|
|
59
|
+
type;
|
|
60
|
+
/**
|
|
61
|
+
* Tool for getting text content
|
|
62
|
+
*/
|
|
63
|
+
getText;
|
|
64
|
+
/**
|
|
65
|
+
* Tool for getting HTML
|
|
66
|
+
*/
|
|
67
|
+
getHtml;
|
|
68
|
+
/**
|
|
69
|
+
* Tool for taking screenshots
|
|
70
|
+
*/
|
|
71
|
+
screenshot;
|
|
72
|
+
/**
|
|
73
|
+
* Tool for evaluating JavaScript
|
|
74
|
+
*/
|
|
75
|
+
evaluate;
|
|
76
|
+
/**
|
|
77
|
+
* All tools in an object for easy spreading into agent config
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const agent = new ToolLoopAgent({
|
|
82
|
+
* tools: browser.tools, // spreads all browser tools
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
tools;
|
|
87
|
+
constructor(config = {}) {
|
|
88
|
+
this.client = new PlaywrightBrowser(config);
|
|
89
|
+
// Create all tools - each is a thin wrapper around client methods
|
|
90
|
+
this.navigate = createNavigateTool(this.client);
|
|
91
|
+
this.click = createClickTool(this.client);
|
|
92
|
+
this.type = createTypeTool(this.client);
|
|
93
|
+
this.getText = createGetTextTool(this.client);
|
|
94
|
+
this.getHtml = createGetHtmlTool(this.client);
|
|
95
|
+
this.screenshot = createScreenshotTool(this.client);
|
|
96
|
+
this.evaluate = createEvaluateTool(this.client);
|
|
97
|
+
// Create tools object for easy spreading
|
|
98
|
+
this.tools = {
|
|
99
|
+
navigate: this.navigate,
|
|
100
|
+
click: this.click,
|
|
101
|
+
type: this.type,
|
|
102
|
+
getText: this.getText,
|
|
103
|
+
getHtml: this.getHtml,
|
|
104
|
+
screenshot: this.screenshot,
|
|
105
|
+
evaluate: this.evaluate,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Start a browser session
|
|
110
|
+
*
|
|
111
|
+
* Sessions are automatically started on first tool use, but you can
|
|
112
|
+
* call this explicitly to start the session upfront.
|
|
113
|
+
*
|
|
114
|
+
* @param sessionName - Optional session name for AWS
|
|
115
|
+
* @param timeout - Optional session timeout in seconds (default: 3600, max: 28800)
|
|
116
|
+
* @returns Session information
|
|
117
|
+
*/
|
|
118
|
+
async startSession(sessionName, timeout) {
|
|
119
|
+
const params = {};
|
|
120
|
+
if (sessionName !== undefined)
|
|
121
|
+
params.sessionName = sessionName;
|
|
122
|
+
if (timeout !== undefined)
|
|
123
|
+
params.timeout = timeout;
|
|
124
|
+
return this.client.startSession(Object.keys(params).length > 0 ? params : undefined);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Stop the current browser session
|
|
128
|
+
*
|
|
129
|
+
* Call this when you're done using the tools to clean up resources.
|
|
130
|
+
*/
|
|
131
|
+
async stopSession() {
|
|
132
|
+
await this.client.stopSession();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get the underlying PlaywrightBrowser
|
|
136
|
+
*
|
|
137
|
+
* Provides direct access to the client for advanced use cases.
|
|
138
|
+
*
|
|
139
|
+
* @returns The PlaywrightBrowser instance
|
|
140
|
+
*/
|
|
141
|
+
getClient() {
|
|
142
|
+
return this.client;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/vercel-ai/tools.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PlaywrightBrowser } from '../playwright/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Vercel AI tool for typing text.
|
|
4
|
+
* Thin wrapper around PlaywrightBrowser.type()
|
|
5
|
+
*/
|
|
6
|
+
export declare function createTypeTool(client: PlaywrightBrowser): import("ai").Tool<{
|
|
7
|
+
selector: string;
|
|
8
|
+
text: string;
|
|
9
|
+
delay?: number | undefined;
|
|
10
|
+
timeout?: number | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
success: boolean;
|
|
13
|
+
message: string;
|
|
14
|
+
error?: never;
|
|
15
|
+
} | {
|
|
16
|
+
success: boolean;
|
|
17
|
+
error: string;
|
|
18
|
+
message?: never;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=type-tool.d.ts.map
|