bedrock-agentcore 0.0.1 → 0.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/LICENSE +202 -0
- package/README.md +131 -9
- package/dist/src/_utils/endpoints.d.ts +28 -0
- package/dist/src/_utils/endpoints.d.ts.map +1 -0
- package/dist/src/_utils/endpoints.js +44 -0
- package/dist/src/_utils/endpoints.js.map +1 -0
- package/dist/src/identity/client.d.ts +40 -0
- package/dist/src/identity/client.d.ts.map +1 -0
- package/dist/src/identity/client.js +109 -0
- package/dist/src/identity/client.js.map +1 -0
- package/dist/src/identity/index.d.ts +22 -0
- package/dist/src/identity/index.d.ts.map +1 -0
- package/dist/src/identity/index.js +24 -0
- package/dist/src/identity/index.js.map +1 -0
- package/dist/src/identity/types.d.ts +82 -0
- package/dist/src/identity/types.d.ts.map +1 -0
- package/dist/src/identity/types.js +5 -0
- package/dist/src/identity/types.js.map +1 -0
- package/dist/src/identity/wrappers.d.ts +54 -0
- package/dist/src/identity/wrappers.d.ts.map +1 -0
- package/dist/src/identity/wrappers.js +95 -0
- package/dist/src/identity/wrappers.js.map +1 -0
- package/dist/src/runtime/app.d.ts +144 -0
- package/dist/src/runtime/app.d.ts.map +1 -0
- package/dist/src/runtime/app.js +485 -0
- package/dist/src/runtime/app.js.map +1 -0
- package/dist/src/runtime/client.d.ts +154 -0
- package/dist/src/runtime/client.d.ts.map +1 -0
- package/dist/src/runtime/client.js +319 -0
- package/dist/src/runtime/client.js.map +1 -0
- package/dist/src/runtime/context.d.ts +33 -0
- package/dist/src/runtime/context.d.ts.map +1 -0
- package/dist/src/runtime/context.js +49 -0
- package/dist/src/runtime/context.js.map +1 -0
- package/dist/src/runtime/index.d.ts +8 -0
- package/dist/src/runtime/index.d.ts.map +1 -0
- package/dist/src/runtime/index.js +7 -0
- package/dist/src/runtime/index.js.map +1 -0
- package/dist/src/runtime/types.d.ts +429 -0
- package/dist/src/runtime/types.d.ts.map +1 -0
- package/dist/src/runtime/types.js +26 -0
- package/dist/src/runtime/types.js.map +1 -0
- 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/strands/click-tool.d.ts +20 -0
- package/dist/src/tools/browser/integrations/strands/click-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/click-tool.js +33 -0
- package/dist/src/tools/browser/integrations/strands/click-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/evaluate-tool.d.ts +20 -0
- package/dist/src/tools/browser/integrations/strands/evaluate-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/evaluate-tool.js +34 -0
- package/dist/src/tools/browser/integrations/strands/evaluate-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/get-html-tool.d.ts +19 -0
- package/dist/src/tools/browser/integrations/strands/get-html-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/get-html-tool.js +32 -0
- package/dist/src/tools/browser/integrations/strands/get-html-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/get-text-tool.d.ts +19 -0
- package/dist/src/tools/browser/integrations/strands/get-text-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/get-text-tool.js +32 -0
- package/dist/src/tools/browser/integrations/strands/get-text-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/index.d.ts +25 -0
- package/dist/src/tools/browser/integrations/strands/index.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/index.js +25 -0
- package/dist/src/tools/browser/integrations/strands/index.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/navigate-tool.d.ts +21 -0
- package/dist/src/tools/browser/integrations/strands/navigate-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/navigate-tool.js +41 -0
- package/dist/src/tools/browser/integrations/strands/navigate-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/screenshot-tool.d.ts +29 -0
- package/dist/src/tools/browser/integrations/strands/screenshot-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/screenshot-tool.js +52 -0
- package/dist/src/tools/browser/integrations/strands/screenshot-tool.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/tools.d.ts +119 -0
- package/dist/src/tools/browser/integrations/strands/tools.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/tools.js +141 -0
- package/dist/src/tools/browser/integrations/strands/tools.js.map +1 -0
- package/dist/src/tools/browser/integrations/strands/type-tool.d.ts +22 -0
- package/dist/src/tools/browser/integrations/strands/type-tool.d.ts.map +1 -0
- package/dist/src/tools/browser/integrations/strands/type-tool.js +37 -0
- package/dist/src/tools/browser/integrations/strands/type-tool.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 +214 -0
- package/dist/src/tools/code-interpreter/client.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/client.js +518 -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/strands/execute-code-tool.d.ts +28 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-code-tool.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-code-tool.js +47 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-code-tool.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-command-tool.d.ts +27 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-command-tool.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-command-tool.js +42 -0
- package/dist/src/tools/code-interpreter/integrations/strands/execute-command-tool.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/file-operations-tool.d.ts +33 -0
- package/dist/src/tools/code-interpreter/integrations/strands/file-operations-tool.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/file-operations-tool.js +78 -0
- package/dist/src/tools/code-interpreter/integrations/strands/file-operations-tool.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/index.d.ts +32 -0
- package/dist/src/tools/code-interpreter/integrations/strands/index.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/index.js +32 -0
- package/dist/src/tools/code-interpreter/integrations/strands/index.js.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/tools.d.ts +94 -0
- package/dist/src/tools/code-interpreter/integrations/strands/tools.d.ts.map +1 -0
- package/dist/src/tools/code-interpreter/integrations/strands/tools.js +112 -0
- package/dist/src/tools/code-interpreter/integrations/strands/tools.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 +134 -12
- package/index.js +0 -4
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { tool } from '@strands-agents/sdk';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Strands SDK tool for executing shell commands in CodeInterpreter.
|
|
6
|
+
*
|
|
7
|
+
* @param interpreter - CodeInterpreter instance
|
|
8
|
+
* @returns Strands SDK tool for command execution
|
|
9
|
+
*
|
|
10
|
+
* @experimental
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createExecuteCommandTool } from 'bedrock-agentcore/experimental/code-interpreter/strands'
|
|
14
|
+
* import { CodeInterpreter } from 'bedrock-agentcore/code-interpreter'
|
|
15
|
+
*
|
|
16
|
+
* const interpreter = new CodeInterpreter({ region: 'us-west-2' })
|
|
17
|
+
* const executeCommandTool = createExecuteCommandTool(interpreter)
|
|
18
|
+
*
|
|
19
|
+
* // Use with Strands SDK Agent
|
|
20
|
+
* const agent = new Agent({
|
|
21
|
+
* model: new BedrockModel({ modelId: 'anthropic.claude-sonnet-4-20250514-v1:0' }),
|
|
22
|
+
* tools: [executeCommandTool]
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
27
|
+
export function createExecuteCommandTool(interpreter) {
|
|
28
|
+
return tool({
|
|
29
|
+
name: 'executeCommand',
|
|
30
|
+
description: `Execute shell commands in the sandbox environment.
|
|
31
|
+
Use this to run system commands, install packages, manipulate files with Unix tools, etc.
|
|
32
|
+
The environment persists across executions within the same session.`,
|
|
33
|
+
inputSchema: z.object({
|
|
34
|
+
command: z.string().describe('The shell command to execute'),
|
|
35
|
+
}),
|
|
36
|
+
callback: async ({ command }) => {
|
|
37
|
+
const result = await interpreter.executeCommand({ command });
|
|
38
|
+
return result;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=execute-command-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-command-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/strands/execute-command-tool.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,+HAA+H;AAC/H,MAAM,UAAU,wBAAwB,CAAC,WAA4B;IACnE,OAAO,IAAI,CAAC;QACV,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE;;oEAEmD;QAChE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;SAC7D,CAAC;QACF,QAAQ,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;YAC9B,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;YAE5D,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CodeInterpreter } from '../../client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Strands SDK tool for file operations in CodeInterpreter.
|
|
4
|
+
*
|
|
5
|
+
* @param interpreter - CodeInterpreter instance
|
|
6
|
+
* @returns Strands SDK tool for file operations
|
|
7
|
+
*
|
|
8
|
+
* @experimental
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { createFileOperationsTool } from 'bedrock-agentcore/experimental/code-interpreter/strands'
|
|
12
|
+
* import { CodeInterpreter } from 'bedrock-agentcore/code-interpreter'
|
|
13
|
+
*
|
|
14
|
+
* const interpreter = new CodeInterpreter({ region: 'us-west-2' })
|
|
15
|
+
* const fileOpsTool = createFileOperationsTool(interpreter)
|
|
16
|
+
*
|
|
17
|
+
* // Use with Strands SDK Agent
|
|
18
|
+
* const agent = new Agent({
|
|
19
|
+
* model: new BedrockModel({ modelId: 'anthropic.claude-sonnet-4-20250514-v1:0' }),
|
|
20
|
+
* tools: [fileOpsTool]
|
|
21
|
+
* })
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createFileOperationsTool(interpreter: CodeInterpreter): import("@strands-agents/sdk").InvokableTool<{
|
|
25
|
+
operation: "remove" | "write" | "read" | "list";
|
|
26
|
+
path: string;
|
|
27
|
+
files?: {
|
|
28
|
+
path: string;
|
|
29
|
+
content: string;
|
|
30
|
+
}[] | undefined;
|
|
31
|
+
paths?: string[] | undefined;
|
|
32
|
+
}, string>;
|
|
33
|
+
//# sourceMappingURL=file-operations-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-operations-tool.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/strands/file-operations-tool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,eAAe;;;;;;;;WAwDpE"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { tool } from '@strands-agents/sdk';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Strands SDK tool for file operations in CodeInterpreter.
|
|
6
|
+
*
|
|
7
|
+
* @param interpreter - CodeInterpreter instance
|
|
8
|
+
* @returns Strands SDK tool for file operations
|
|
9
|
+
*
|
|
10
|
+
* @experimental
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createFileOperationsTool } from 'bedrock-agentcore/experimental/code-interpreter/strands'
|
|
14
|
+
* import { CodeInterpreter } from 'bedrock-agentcore/code-interpreter'
|
|
15
|
+
*
|
|
16
|
+
* const interpreter = new CodeInterpreter({ region: 'us-west-2' })
|
|
17
|
+
* const fileOpsTool = createFileOperationsTool(interpreter)
|
|
18
|
+
*
|
|
19
|
+
* // Use with Strands SDK Agent
|
|
20
|
+
* const agent = new Agent({
|
|
21
|
+
* model: new BedrockModel({ modelId: 'anthropic.claude-sonnet-4-20250514-v1:0' }),
|
|
22
|
+
* tools: [fileOpsTool]
|
|
23
|
+
* })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
27
|
+
export function createFileOperationsTool(interpreter) {
|
|
28
|
+
return tool({
|
|
29
|
+
name: 'fileOperations',
|
|
30
|
+
description: `Manage files in the code execution sandbox.
|
|
31
|
+
Use this to create notebooks/scripts, store intermediate results, and inspect outputs.
|
|
32
|
+
Operations: write (create/update files), read (get file contents), list (show directory contents), remove (delete files).`,
|
|
33
|
+
inputSchema: z.object({
|
|
34
|
+
operation: z.enum(['write', 'read', 'list', 'remove']).describe('File operation to perform'),
|
|
35
|
+
files: z
|
|
36
|
+
.array(z.object({
|
|
37
|
+
path: z.string().describe('File path'),
|
|
38
|
+
content: z.string().describe('File content (for write operation)'),
|
|
39
|
+
}))
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('Files to write (for write operation)'),
|
|
42
|
+
paths: z.array(z.string()).optional().describe('File paths to read or remove (for read/remove operations)'),
|
|
43
|
+
path: z.string().optional().default('.').describe('Directory path to list (for list operation)'),
|
|
44
|
+
}),
|
|
45
|
+
callback: async ({ operation, files, paths, path }) => {
|
|
46
|
+
switch (operation) {
|
|
47
|
+
case 'write': {
|
|
48
|
+
if (!files || files.length === 0) {
|
|
49
|
+
return 'status: error\nerror: No files specified for write operation';
|
|
50
|
+
}
|
|
51
|
+
const result = await interpreter.writeFiles({ files });
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
case 'read': {
|
|
55
|
+
if (!paths || paths.length === 0) {
|
|
56
|
+
return 'status: error\nerror: No paths specified for read operation';
|
|
57
|
+
}
|
|
58
|
+
const result = await interpreter.readFiles({ paths });
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
case 'list': {
|
|
62
|
+
const result = await interpreter.listFiles({ path });
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
case 'remove': {
|
|
66
|
+
if (!paths || paths.length === 0) {
|
|
67
|
+
return 'status: error\nerror: No paths specified for remove operation';
|
|
68
|
+
}
|
|
69
|
+
const result = await interpreter.removeFiles({ paths });
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
default:
|
|
73
|
+
return 'status: error\nerror: Invalid operation';
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=file-operations-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-operations-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/strands/file-operations-tool.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,+HAA+H;AAC/H,MAAM,UAAU,wBAAwB,CAAC,WAA4B;IACnE,OAAO,IAAI,CAAC;QACV,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE;;0HAEyG;QACtH,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,2BAA2B,CAAC;YAC5F,KAAK,EAAE,CAAC;iBACL,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;gBACP,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACtC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;aACnE,CAAC,CACH;iBACA,QAAQ,EAAE;iBACV,QAAQ,CAAC,sCAAsC,CAAC;YACnD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2DAA2D,CAAC;YAC3G,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,6CAA6C,CAAC;SACjG,CAAC;QACF,QAAQ,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE;YACpD,QAAQ,SAAS,EAAE,CAAC;gBAClB,KAAK,OAAO,CAAC,CAAC,CAAC;oBACb,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBACjC,OAAO,8DAA8D,CAAA;oBACvE,CAAC;oBACD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;oBACtD,OAAO,MAAM,CAAA;gBACf,CAAC;gBAED,KAAK,MAAM,CAAC,CAAC,CAAC;oBACZ,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBACjC,OAAO,6DAA6D,CAAA;oBACtE,CAAC;oBACD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;oBACrD,OAAO,MAAM,CAAA;gBACf,CAAC;gBAED,KAAK,MAAM,CAAC,CAAC,CAAC;oBACZ,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;oBACpD,OAAO,MAAM,CAAA;gBACf,CAAC;gBAED,KAAK,QAAQ,CAAC,CAAC,CAAC;oBACd,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;wBACjC,OAAO,+DAA+D,CAAA;oBACxE,CAAC;oBACD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;oBACvD,OAAO,MAAM,CAAA;gBACf,CAAC;gBAED;oBACE,OAAO,yCAAyC,CAAA;YACpD,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strands SDK integrations for AWS Bedrock AgentCore CodeInterpreter.
|
|
3
|
+
*
|
|
4
|
+
* **⚠️ EXPERIMENTAL:** This integration uses the Strands TypeScript SDK, which is
|
|
5
|
+
* currently experimental and subject to breaking changes.
|
|
6
|
+
*
|
|
7
|
+
* This module provides a unified CodeInterpreterTools class that simplifies
|
|
8
|
+
* integration with Strands SDK Agent.
|
|
9
|
+
*
|
|
10
|
+
* @experimental
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { Agent, BedrockModel } from '@strands-agents/sdk'
|
|
14
|
+
* import { CodeInterpreterTools } from 'bedrock-agentcore/experimental/code-interpreter/strands'
|
|
15
|
+
*
|
|
16
|
+
* const codeInterpreter = new CodeInterpreterTools({ region: 'us-west-2' })
|
|
17
|
+
*
|
|
18
|
+
* const agent = new Agent({
|
|
19
|
+
* model: new BedrockModel({ modelId: 'anthropic.claude-sonnet-4-20250514-v1:0' }),
|
|
20
|
+
* instructions: 'You are a helpful coding assistant...',
|
|
21
|
+
* tools: codeInterpreter.tools,
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* // Clean up when done
|
|
25
|
+
* await codeInterpreter.stopSession()
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export { CodeInterpreterTools } from './tools.js';
|
|
29
|
+
export { createExecuteCodeTool } from './execute-code-tool.js';
|
|
30
|
+
export { createExecuteCommandTool } from './execute-command-tool.js';
|
|
31
|
+
export { createFileOperationsTool } from './file-operations-tool.js';
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/strands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strands SDK integrations for AWS Bedrock AgentCore CodeInterpreter.
|
|
3
|
+
*
|
|
4
|
+
* **⚠️ EXPERIMENTAL:** This integration uses the Strands TypeScript SDK, which is
|
|
5
|
+
* currently experimental and subject to breaking changes.
|
|
6
|
+
*
|
|
7
|
+
* This module provides a unified CodeInterpreterTools class that simplifies
|
|
8
|
+
* integration with Strands SDK Agent.
|
|
9
|
+
*
|
|
10
|
+
* @experimental
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { Agent, BedrockModel } from '@strands-agents/sdk'
|
|
14
|
+
* import { CodeInterpreterTools } from 'bedrock-agentcore/experimental/code-interpreter/strands'
|
|
15
|
+
*
|
|
16
|
+
* const codeInterpreter = new CodeInterpreterTools({ region: 'us-west-2' })
|
|
17
|
+
*
|
|
18
|
+
* const agent = new Agent({
|
|
19
|
+
* model: new BedrockModel({ modelId: 'anthropic.claude-sonnet-4-20250514-v1:0' }),
|
|
20
|
+
* instructions: 'You are a helpful coding assistant...',
|
|
21
|
+
* tools: codeInterpreter.tools,
|
|
22
|
+
* })
|
|
23
|
+
*
|
|
24
|
+
* // Clean up when done
|
|
25
|
+
* await codeInterpreter.stopSession()
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export { CodeInterpreterTools } from './tools.js';
|
|
29
|
+
export { createExecuteCodeTool } from './execute-code-tool.js';
|
|
30
|
+
export { createExecuteCommandTool } from './execute-command-tool.js';
|
|
31
|
+
export { createFileOperationsTool } from './file-operations-tool.js';
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/strands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified CodeInterpreter Tools for Strands SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides all three CodeInterpreter tools and session management in one class.
|
|
5
|
+
*/
|
|
6
|
+
import { CodeInterpreter } from '../../client.js';
|
|
7
|
+
import type { CodeInterpreterConfig, SessionInfo } from '../../types.js';
|
|
8
|
+
import { createExecuteCodeTool } from './execute-code-tool.js';
|
|
9
|
+
import { createFileOperationsTool } from './file-operations-tool.js';
|
|
10
|
+
import { createExecuteCommandTool } from './execute-command-tool.js';
|
|
11
|
+
/**
|
|
12
|
+
* CodeInterpreterTools - All-in-one CodeInterpreter integration for Strands SDK
|
|
13
|
+
*
|
|
14
|
+
* Provides three ready-to-use tools and session management in a single class.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { CodeInterpreterTools } from 'bedrock-agentcore/experimental/code-interpreter/strands'
|
|
19
|
+
* import { Agent, BedrockModel } from '@strands-agents/sdk'
|
|
20
|
+
*
|
|
21
|
+
* // Create tools instance
|
|
22
|
+
* const codeInterpreter = new CodeInterpreterTools({ region: 'us-west-2' })
|
|
23
|
+
*
|
|
24
|
+
* // Start session (optional - automatically started on first use)
|
|
25
|
+
* await codeInterpreter.startSession()
|
|
26
|
+
*
|
|
27
|
+
* // Create agent with all three tools
|
|
28
|
+
* const agent = new Agent({
|
|
29
|
+
* model: new BedrockModel({ modelId: 'anthropic.claude-sonnet-4-20250514-v1:0' }),
|
|
30
|
+
* tools: codeInterpreter.tools,
|
|
31
|
+
* })
|
|
32
|
+
*
|
|
33
|
+
* // Clean up when done
|
|
34
|
+
* await codeInterpreter.stopSession()
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class CodeInterpreterTools {
|
|
38
|
+
private interpreter;
|
|
39
|
+
/**
|
|
40
|
+
* Tool for executing Python, JavaScript, or TypeScript code
|
|
41
|
+
*/
|
|
42
|
+
readonly executeCode: ReturnType<typeof createExecuteCodeTool>;
|
|
43
|
+
/**
|
|
44
|
+
* Tool for file operations (read, write, list, remove)
|
|
45
|
+
*/
|
|
46
|
+
readonly fileOperations: ReturnType<typeof createFileOperationsTool>;
|
|
47
|
+
/**
|
|
48
|
+
* Tool for executing shell commands
|
|
49
|
+
*/
|
|
50
|
+
readonly executeCommand: ReturnType<typeof createExecuteCommandTool>;
|
|
51
|
+
/**
|
|
52
|
+
* All three tools in an array for easy spreading into agent config
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const agent = new Agent({
|
|
57
|
+
* tools: codeInterpreter.tools, // spreads all three tools
|
|
58
|
+
* })
|
|
59
|
+
*
|
|
60
|
+
* // Or combine with other tools
|
|
61
|
+
* const agent = new Agent({
|
|
62
|
+
* tools: [...codeInterpreter.tools, ...browserTools.tools],
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
readonly tools: Array<ReturnType<typeof createExecuteCodeTool> | ReturnType<typeof createFileOperationsTool> | ReturnType<typeof createExecuteCommandTool>>;
|
|
67
|
+
constructor(config?: CodeInterpreterConfig);
|
|
68
|
+
/**
|
|
69
|
+
* Start a CodeInterpreter session
|
|
70
|
+
*
|
|
71
|
+
* Sessions are automatically started on first tool use, but you can
|
|
72
|
+
* call this explicitly to start the session upfront.
|
|
73
|
+
*
|
|
74
|
+
* @param sessionName - Optional session name for AWS
|
|
75
|
+
* @param timeout - Optional session timeout in seconds (default: 900, max: 28800)
|
|
76
|
+
* @returns Session information
|
|
77
|
+
*/
|
|
78
|
+
startSession(sessionName?: string, timeout?: number): Promise<SessionInfo>;
|
|
79
|
+
/**
|
|
80
|
+
* Stop the current CodeInterpreter session
|
|
81
|
+
*
|
|
82
|
+
* Call this when you're done using the tools to clean up resources.
|
|
83
|
+
*/
|
|
84
|
+
stopSession(): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Get the underlying CodeInterpreter client
|
|
87
|
+
*
|
|
88
|
+
* Provides direct access to the client for advanced use cases.
|
|
89
|
+
*
|
|
90
|
+
* @returns The CodeInterpreter client instance
|
|
91
|
+
*/
|
|
92
|
+
getClient(): CodeInterpreter;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/strands/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,KAAK,EAAE,qBAAqB,EAAE,WAAW,EAAsB,MAAM,gBAAgB,CAAA;AAC5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,WAAW,CAAiB;IAEpC;;OAEG;IACH,SAAgB,WAAW,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;IAErE;;OAEG;IACH,SAAgB,cAAc,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;IAE3E;;OAEG;IACH,SAAgB,cAAc,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;IAE3E;;;;;;;;;;;;;;OAcG;IACH,SAAgB,KAAK,EAAE,KAAK,CACxB,UAAU,CAAC,OAAO,qBAAqB,CAAC,GACxC,UAAU,CAAC,OAAO,wBAAwB,CAAC,GAC3C,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAC9C,CAAA;gBAEW,MAAM,GAAE,qBAA0B;IAY9C;;;;;;;;;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,eAAe;CAG7B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified CodeInterpreter Tools for Strands SDK
|
|
3
|
+
*
|
|
4
|
+
* Provides all three CodeInterpreter tools and session management in one class.
|
|
5
|
+
*/
|
|
6
|
+
import { CodeInterpreter } from '../../client.js';
|
|
7
|
+
import { createExecuteCodeTool } from './execute-code-tool.js';
|
|
8
|
+
import { createFileOperationsTool } from './file-operations-tool.js';
|
|
9
|
+
import { createExecuteCommandTool } from './execute-command-tool.js';
|
|
10
|
+
/**
|
|
11
|
+
* CodeInterpreterTools - All-in-one CodeInterpreter integration for Strands SDK
|
|
12
|
+
*
|
|
13
|
+
* Provides three ready-to-use tools and session management in a single class.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { CodeInterpreterTools } from 'bedrock-agentcore/experimental/code-interpreter/strands'
|
|
18
|
+
* import { Agent, BedrockModel } from '@strands-agents/sdk'
|
|
19
|
+
*
|
|
20
|
+
* // Create tools instance
|
|
21
|
+
* const codeInterpreter = new CodeInterpreterTools({ region: 'us-west-2' })
|
|
22
|
+
*
|
|
23
|
+
* // Start session (optional - automatically started on first use)
|
|
24
|
+
* await codeInterpreter.startSession()
|
|
25
|
+
*
|
|
26
|
+
* // Create agent with all three tools
|
|
27
|
+
* const agent = new Agent({
|
|
28
|
+
* model: new BedrockModel({ modelId: 'anthropic.claude-sonnet-4-20250514-v1:0' }),
|
|
29
|
+
* tools: codeInterpreter.tools,
|
|
30
|
+
* })
|
|
31
|
+
*
|
|
32
|
+
* // Clean up when done
|
|
33
|
+
* await codeInterpreter.stopSession()
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export class CodeInterpreterTools {
|
|
37
|
+
interpreter;
|
|
38
|
+
/**
|
|
39
|
+
* Tool for executing Python, JavaScript, or TypeScript code
|
|
40
|
+
*/
|
|
41
|
+
executeCode;
|
|
42
|
+
/**
|
|
43
|
+
* Tool for file operations (read, write, list, remove)
|
|
44
|
+
*/
|
|
45
|
+
fileOperations;
|
|
46
|
+
/**
|
|
47
|
+
* Tool for executing shell commands
|
|
48
|
+
*/
|
|
49
|
+
executeCommand;
|
|
50
|
+
/**
|
|
51
|
+
* All three tools in an array for easy spreading into agent config
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const agent = new Agent({
|
|
56
|
+
* tools: codeInterpreter.tools, // spreads all three tools
|
|
57
|
+
* })
|
|
58
|
+
*
|
|
59
|
+
* // Or combine with other tools
|
|
60
|
+
* const agent = new Agent({
|
|
61
|
+
* tools: [...codeInterpreter.tools, ...browserTools.tools],
|
|
62
|
+
* })
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
tools;
|
|
66
|
+
constructor(config = {}) {
|
|
67
|
+
this.interpreter = new CodeInterpreter(config);
|
|
68
|
+
// Create all three tools
|
|
69
|
+
this.executeCode = createExecuteCodeTool(this.interpreter);
|
|
70
|
+
this.fileOperations = createFileOperationsTool(this.interpreter);
|
|
71
|
+
this.executeCommand = createExecuteCommandTool(this.interpreter);
|
|
72
|
+
// Create tools array for Strands SDK (uses arrays, not objects)
|
|
73
|
+
this.tools = [this.executeCode, this.fileOperations, this.executeCommand];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Start a CodeInterpreter session
|
|
77
|
+
*
|
|
78
|
+
* Sessions are automatically started on first tool use, but you can
|
|
79
|
+
* call this explicitly to start the session upfront.
|
|
80
|
+
*
|
|
81
|
+
* @param sessionName - Optional session name for AWS
|
|
82
|
+
* @param timeout - Optional session timeout in seconds (default: 900, max: 28800)
|
|
83
|
+
* @returns Session information
|
|
84
|
+
*/
|
|
85
|
+
async startSession(sessionName, timeout) {
|
|
86
|
+
const params = {};
|
|
87
|
+
if (sessionName !== undefined)
|
|
88
|
+
params.sessionName = sessionName;
|
|
89
|
+
if (timeout !== undefined)
|
|
90
|
+
params.timeout = timeout;
|
|
91
|
+
return this.interpreter.startSession(Object.keys(params).length > 0 ? params : undefined);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Stop the current CodeInterpreter session
|
|
95
|
+
*
|
|
96
|
+
* Call this when you're done using the tools to clean up resources.
|
|
97
|
+
*/
|
|
98
|
+
async stopSession() {
|
|
99
|
+
await this.interpreter.stopSession();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get the underlying CodeInterpreter client
|
|
103
|
+
*
|
|
104
|
+
* Provides direct access to the client for advanced use cases.
|
|
105
|
+
*
|
|
106
|
+
* @returns The CodeInterpreter client instance
|
|
107
|
+
*/
|
|
108
|
+
getClient() {
|
|
109
|
+
return this.interpreter;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/strands/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,oBAAoB;IACvB,WAAW,CAAiB;IAEpC;;OAEG;IACa,WAAW,CAA0C;IAErE;;OAEG;IACa,cAAc,CAA6C;IAE3E;;OAEG;IACa,cAAc,CAA6C;IAE3E;;;;;;;;;;;;;;OAcG;IACa,KAAK,CAIpB;IAED,YAAY,SAAgC,EAAE;QAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAA;QAE9C,yBAAyB;QACzB,IAAI,CAAC,WAAW,GAAG,qBAAqB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAC1D,IAAI,CAAC,cAAc,GAAG,wBAAwB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAChE,IAAI,CAAC,cAAc,GAAG,wBAAwB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAEhE,gEAAgE;QAChE,IAAI,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IAC3E,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,YAAY,CAAC,WAAoB,EAAE,OAAgB;QACvD,MAAM,MAAM,GAAuB,EAAE,CAAA;QACrC,IAAI,WAAW,KAAK,SAAS;YAAE,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;QAC/D,IAAI,OAAO,KAAK,SAAS;YAAE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;QACnD,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IAC3F,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAA;IACtC,CAAC;IAED;;;;;;OAMG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CodeInterpreter } from '../../client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Vercel AI SDK tool for executing code in CodeInterpreter.
|
|
4
|
+
*
|
|
5
|
+
* @param interpreter - CodeInterpreter instance
|
|
6
|
+
* @returns Vercel AI SDK tool for code execution
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createExecuteCodeTool } from 'bedrock-agentcore/code-interpreter/vercel-ai'
|
|
11
|
+
* import { CodeInterpreter } from 'bedrock-agentcore/code-interpreter'
|
|
12
|
+
*
|
|
13
|
+
* const interpreter = new CodeInterpreter({ region: 'us-west-2' })
|
|
14
|
+
* const executeCodeTool = createExecuteCodeTool(interpreter)
|
|
15
|
+
*
|
|
16
|
+
* // Use with Vercel AI SDK Agent
|
|
17
|
+
* const agent = new ToolLoopAgent({
|
|
18
|
+
* model: bedrock('global.anthropic.claude-sonnet-4-20250514-v1:0'),
|
|
19
|
+
* tools: { executeCode: executeCodeTool }
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function createExecuteCodeTool(interpreter: CodeInterpreter): import("ai").Tool<{
|
|
24
|
+
code: string;
|
|
25
|
+
language: "python" | "javascript" | "typescript";
|
|
26
|
+
}, string>;
|
|
27
|
+
//# sourceMappingURL=execute-code-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-code-tool.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,eAAe;;;WAqBjE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Vercel AI SDK tool for executing code in CodeInterpreter.
|
|
6
|
+
*
|
|
7
|
+
* @param interpreter - CodeInterpreter instance
|
|
8
|
+
* @returns Vercel AI SDK tool for code execution
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { createExecuteCodeTool } from 'bedrock-agentcore/code-interpreter/vercel-ai'
|
|
13
|
+
* import { CodeInterpreter } from 'bedrock-agentcore/code-interpreter'
|
|
14
|
+
*
|
|
15
|
+
* const interpreter = new CodeInterpreter({ region: 'us-west-2' })
|
|
16
|
+
* const executeCodeTool = createExecuteCodeTool(interpreter)
|
|
17
|
+
*
|
|
18
|
+
* // Use with Vercel AI SDK Agent
|
|
19
|
+
* const agent = new ToolLoopAgent({
|
|
20
|
+
* model: bedrock('global.anthropic.claude-sonnet-4-20250514-v1:0'),
|
|
21
|
+
* tools: { executeCode: executeCodeTool }
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
26
|
+
export function createExecuteCodeTool(interpreter) {
|
|
27
|
+
return tool({
|
|
28
|
+
description: `Execute code in a secure sandbox environment.
|
|
29
|
+
Use this to perform calculations, data analysis, create visualizations, or run any code.
|
|
30
|
+
The environment persists across executions within the same session.
|
|
31
|
+
Supports Python, JavaScript, and TypeScript.`,
|
|
32
|
+
inputSchema: z.object({
|
|
33
|
+
code: z.string().describe('The code to execute. Can use imports and access files.'),
|
|
34
|
+
language: z
|
|
35
|
+
.enum(['python', 'javascript', 'typescript'])
|
|
36
|
+
.default('python')
|
|
37
|
+
.describe('Programming language to use (default: python)'),
|
|
38
|
+
}),
|
|
39
|
+
execute: async ({ code, language }) => {
|
|
40
|
+
'use step';
|
|
41
|
+
const result = await interpreter.executeCode({ code, language });
|
|
42
|
+
return result;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=execute-code-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-code-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,+HAA+H;AAC/H,MAAM,UAAU,qBAAqB,CAAC,WAA4B;IAChE,OAAO,IAAI,CAAC;QACV,WAAW,EAAE;;;6CAG4B;QACzC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wDAAwD,CAAC;YACnF,QAAQ,EAAE,CAAC;iBACR,IAAI,CAAC,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;iBAC5C,OAAO,CAAC,QAAQ,CAAC;iBACjB,QAAQ,CAAC,+CAA+C,CAAC;SAC7D,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;YACpC,UAAU,CAAA;YAEV,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;YAEhE,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CodeInterpreter } from '../../client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Vercel AI SDK tool for executing shell commands in CodeInterpreter.
|
|
4
|
+
*
|
|
5
|
+
* @param interpreter - CodeInterpreter instance
|
|
6
|
+
* @returns Vercel AI SDK tool for command execution
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createExecuteCommandTool } from 'bedrock-agentcore/code-interpreter/vercel-ai'
|
|
11
|
+
* import { CodeInterpreter } from 'bedrock-agentcore/code-interpreter'
|
|
12
|
+
*
|
|
13
|
+
* const interpreter = new CodeInterpreter({ region: 'us-west-2' })
|
|
14
|
+
* const executeCommandTool = createExecuteCommandTool(interpreter)
|
|
15
|
+
*
|
|
16
|
+
* // Use with Vercel AI SDK Agent
|
|
17
|
+
* const agent = new ToolLoopAgent({
|
|
18
|
+
* model: bedrock('global.anthropic.claude-sonnet-4-20250514-v1:0'),
|
|
19
|
+
* tools: { executeCommand: executeCommandTool }
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function createExecuteCommandTool(interpreter: CodeInterpreter): import("ai").Tool<{
|
|
24
|
+
command: string;
|
|
25
|
+
}, string>;
|
|
26
|
+
//# sourceMappingURL=execute-command-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-command-tool.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,eAAe;;WAgBpE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a Vercel AI SDK tool for executing shell commands in CodeInterpreter.
|
|
6
|
+
*
|
|
7
|
+
* @param interpreter - CodeInterpreter instance
|
|
8
|
+
* @returns Vercel AI SDK tool for command execution
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { createExecuteCommandTool } from 'bedrock-agentcore/code-interpreter/vercel-ai'
|
|
13
|
+
* import { CodeInterpreter } from 'bedrock-agentcore/code-interpreter'
|
|
14
|
+
*
|
|
15
|
+
* const interpreter = new CodeInterpreter({ region: 'us-west-2' })
|
|
16
|
+
* const executeCommandTool = createExecuteCommandTool(interpreter)
|
|
17
|
+
*
|
|
18
|
+
* // Use with Vercel AI SDK Agent
|
|
19
|
+
* const agent = new ToolLoopAgent({
|
|
20
|
+
* model: bedrock('global.anthropic.claude-sonnet-4-20250514-v1:0'),
|
|
21
|
+
* tools: { executeCommand: executeCommandTool }
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
26
|
+
export function createExecuteCommandTool(interpreter) {
|
|
27
|
+
return tool({
|
|
28
|
+
description: `Execute shell commands in the sandbox environment.
|
|
29
|
+
Use this to run system commands, install packages, manipulate files with Unix tools, etc.
|
|
30
|
+
The environment persists across executions within the same session.`,
|
|
31
|
+
inputSchema: z.object({
|
|
32
|
+
command: z.string().describe('The shell command to execute'),
|
|
33
|
+
}),
|
|
34
|
+
execute: async ({ command }) => {
|
|
35
|
+
'use step';
|
|
36
|
+
const result = await interpreter.executeCommand({ command });
|
|
37
|
+
return result;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=execute-command-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-command-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AACzB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,+HAA+H;AAC/H,MAAM,UAAU,wBAAwB,CAAC,WAA4B;IACnE,OAAO,IAAI,CAAC;QACV,WAAW,EAAE;;oEAEmD;QAChE,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;SAC7D,CAAC;QACF,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;YAC7B,UAAU,CAAA;YAEV,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,CAAC,CAAA;YAE5D,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CodeInterpreter } from '../../client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Vercel AI SDK tool for file operations in CodeInterpreter.
|
|
4
|
+
*
|
|
5
|
+
* @param interpreter - CodeInterpreter instance
|
|
6
|
+
* @returns Vercel AI SDK tool for file operations
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createFileOperationsTool } from 'bedrock-agentcore/code-interpreter/vercel-ai'
|
|
11
|
+
* import { CodeInterpreter } from 'bedrock-agentcore/code-interpreter'
|
|
12
|
+
*
|
|
13
|
+
* const interpreter = new CodeInterpreter({ region: 'us-west-2' })
|
|
14
|
+
* const fileOpsTool = createFileOperationsTool(interpreter)
|
|
15
|
+
*
|
|
16
|
+
* // Use with Vercel AI SDK Agent
|
|
17
|
+
* const agent = new ToolLoopAgent({
|
|
18
|
+
* model: bedrock('global.anthropic.claude-sonnet-4-20250514-v1:0'),
|
|
19
|
+
* tools: { fileOps: fileOpsTool }
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function createFileOperationsTool(interpreter: CodeInterpreter): import("ai").Tool<{
|
|
24
|
+
operation: "remove" | "write" | "read" | "list";
|
|
25
|
+
path: string;
|
|
26
|
+
files?: {
|
|
27
|
+
path: string;
|
|
28
|
+
content: string;
|
|
29
|
+
}[] | undefined;
|
|
30
|
+
paths?: string[] | undefined;
|
|
31
|
+
}, string>;
|
|
32
|
+
//# sourceMappingURL=file-operations-tool.d.ts.map
|