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.
Files changed (96) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +151 -9
  3. package/dist/src/tools/browser/client.d.ts +125 -0
  4. package/dist/src/tools/browser/client.d.ts.map +1 -0
  5. package/dist/src/tools/browser/client.js +320 -0
  6. package/dist/src/tools/browser/client.js.map +1 -0
  7. package/dist/src/tools/browser/index.d.ts +4 -0
  8. package/dist/src/tools/browser/index.d.ts.map +1 -0
  9. package/dist/src/tools/browser/index.js +3 -0
  10. package/dist/src/tools/browser/index.js.map +1 -0
  11. package/dist/src/tools/browser/integrations/playwright/client.d.ts +147 -0
  12. package/dist/src/tools/browser/integrations/playwright/client.d.ts.map +1 -0
  13. package/dist/src/tools/browser/integrations/playwright/client.js +324 -0
  14. package/dist/src/tools/browser/integrations/playwright/client.js.map +1 -0
  15. package/dist/src/tools/browser/integrations/playwright/index.d.ts +20 -0
  16. package/dist/src/tools/browser/integrations/playwright/index.d.ts.map +1 -0
  17. package/dist/src/tools/browser/integrations/playwright/index.js +19 -0
  18. package/dist/src/tools/browser/integrations/playwright/index.js.map +1 -0
  19. package/dist/src/tools/browser/integrations/playwright/types.d.ts +169 -0
  20. package/dist/src/tools/browser/integrations/playwright/types.d.ts.map +1 -0
  21. package/dist/src/tools/browser/integrations/playwright/types.js +2 -0
  22. package/dist/src/tools/browser/integrations/playwright/types.js.map +1 -0
  23. package/dist/src/tools/browser/integrations/vercel-ai/click-tool.d.ts +18 -0
  24. package/dist/src/tools/browser/integrations/vercel-ai/click-tool.d.ts.map +1 -0
  25. package/dist/src/tools/browser/integrations/vercel-ai/click-tool.js +31 -0
  26. package/dist/src/tools/browser/integrations/vercel-ai/click-tool.js.map +1 -0
  27. package/dist/src/tools/browser/integrations/vercel-ai/evaluate-tool.d.ts +18 -0
  28. package/dist/src/tools/browser/integrations/vercel-ai/evaluate-tool.d.ts.map +1 -0
  29. package/dist/src/tools/browser/integrations/vercel-ai/evaluate-tool.js +32 -0
  30. package/dist/src/tools/browser/integrations/vercel-ai/evaluate-tool.js.map +1 -0
  31. package/dist/src/tools/browser/integrations/vercel-ai/get-html-tool.d.ts +17 -0
  32. package/dist/src/tools/browser/integrations/vercel-ai/get-html-tool.d.ts.map +1 -0
  33. package/dist/src/tools/browser/integrations/vercel-ai/get-html-tool.js +30 -0
  34. package/dist/src/tools/browser/integrations/vercel-ai/get-html-tool.js.map +1 -0
  35. package/dist/src/tools/browser/integrations/vercel-ai/get-text-tool.d.ts +17 -0
  36. package/dist/src/tools/browser/integrations/vercel-ai/get-text-tool.d.ts.map +1 -0
  37. package/dist/src/tools/browser/integrations/vercel-ai/get-text-tool.js +30 -0
  38. package/dist/src/tools/browser/integrations/vercel-ai/get-text-tool.js.map +1 -0
  39. package/dist/src/tools/browser/integrations/vercel-ai/index.d.ts +19 -0
  40. package/dist/src/tools/browser/integrations/vercel-ai/index.d.ts.map +1 -0
  41. package/dist/src/tools/browser/integrations/vercel-ai/index.js +19 -0
  42. package/dist/src/tools/browser/integrations/vercel-ai/index.js.map +1 -0
  43. package/dist/src/tools/browser/integrations/vercel-ai/navigate-tool.d.ts +19 -0
  44. package/dist/src/tools/browser/integrations/vercel-ai/navigate-tool.d.ts.map +1 -0
  45. package/dist/src/tools/browser/integrations/vercel-ai/navigate-tool.js +39 -0
  46. package/dist/src/tools/browser/integrations/vercel-ai/navigate-tool.js.map +1 -0
  47. package/dist/src/tools/browser/integrations/vercel-ai/screenshot-tool.d.ts +22 -0
  48. package/dist/src/tools/browser/integrations/vercel-ai/screenshot-tool.d.ts.map +1 -0
  49. package/dist/src/tools/browser/integrations/vercel-ai/screenshot-tool.js +44 -0
  50. package/dist/src/tools/browser/integrations/vercel-ai/screenshot-tool.js.map +1 -0
  51. package/dist/src/tools/browser/integrations/vercel-ai/tools.d.ts +123 -0
  52. package/dist/src/tools/browser/integrations/vercel-ai/tools.d.ts.map +1 -0
  53. package/dist/src/tools/browser/integrations/vercel-ai/tools.js +145 -0
  54. package/dist/src/tools/browser/integrations/vercel-ai/tools.js.map +1 -0
  55. package/dist/src/tools/browser/integrations/vercel-ai/type-tool.d.ts +20 -0
  56. package/dist/src/tools/browser/integrations/vercel-ai/type-tool.d.ts.map +1 -0
  57. package/dist/src/tools/browser/integrations/vercel-ai/type-tool.js +35 -0
  58. package/dist/src/tools/browser/integrations/vercel-ai/type-tool.js.map +1 -0
  59. package/dist/src/tools/browser/types.d.ts +336 -0
  60. package/dist/src/tools/browser/types.d.ts.map +1 -0
  61. package/dist/src/tools/browser/types.js +17 -0
  62. package/dist/src/tools/browser/types.js.map +1 -0
  63. package/dist/src/tools/code-interpreter/client.d.ts +212 -0
  64. package/dist/src/tools/code-interpreter/client.d.ts.map +1 -0
  65. package/dist/src/tools/code-interpreter/client.js +512 -0
  66. package/dist/src/tools/code-interpreter/client.js.map +1 -0
  67. package/dist/src/tools/code-interpreter/index.d.ts +4 -0
  68. package/dist/src/tools/code-interpreter/index.d.ts.map +1 -0
  69. package/dist/src/tools/code-interpreter/index.js +5 -0
  70. package/dist/src/tools/code-interpreter/index.js.map +1 -0
  71. package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.d.ts +27 -0
  72. package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.d.ts.map +1 -0
  73. package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.js +46 -0
  74. package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.js.map +1 -0
  75. package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.d.ts +26 -0
  76. package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.d.ts.map +1 -0
  77. package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.js +41 -0
  78. package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.js.map +1 -0
  79. package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.d.ts +32 -0
  80. package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.d.ts.map +1 -0
  81. package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.js +77 -0
  82. package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.js.map +1 -0
  83. package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.d.ts +26 -0
  84. package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.d.ts.map +1 -0
  85. package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.js +26 -0
  86. package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.js.map +1 -0
  87. package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.d.ts +94 -0
  88. package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.d.ts.map +1 -0
  89. package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.js +112 -0
  90. package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.js.map +1 -0
  91. package/dist/src/tools/code-interpreter/types.d.ts +473 -0
  92. package/dist/src/tools/code-interpreter/types.d.ts.map +1 -0
  93. package/dist/src/tools/code-interpreter/types.js +52 -0
  94. package/dist/src/tools/code-interpreter/types.js.map +1 -0
  95. package/package.json +99 -12
  96. package/index.js +0 -4
@@ -0,0 +1,512 @@
1
+ import { BedrockAgentCoreClient, StartCodeInterpreterSessionCommand, StopCodeInterpreterSessionCommand, InvokeCodeInterpreterCommand, GetCodeInterpreterSessionCommand, ListCodeInterpreterSessionsCommand, } from '@aws-sdk/client-bedrock-agentcore';
2
+ import { DEFAULT_IDENTIFIER, DEFAULT_SESSION_NAME, DEFAULT_TIMEOUT, DEFAULT_REGION } from './types.js';
3
+ /**
4
+ * Client for AWS Bedrock Code Interpreter.
5
+ *
6
+ * Provides functionality to execute Python, JavaScript, and TypeScript code
7
+ * in isolated sandbox environments with file system access and shell commands.
8
+ *
9
+ * Each CodeInterpreter instance manages a single session. Sessions are automatically
10
+ * created on first use and can be explicitly managed with startSession/stopSession.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const interpreter = new CodeInterpreter({ region: 'us-east-1' })
15
+ *
16
+ * // Execute code (auto-creates session)
17
+ * await interpreter.executeCode({ code: 'print("Hello")' })
18
+ *
19
+ * // Explicitly manage session lifecycle
20
+ * await interpreter.startSession({ sessionName: 'my-session' })
21
+ * await interpreter.executeCode({ code: 'x = 1' })
22
+ * await interpreter.stopSession()
23
+ * ```
24
+ */
25
+ export class CodeInterpreter {
26
+ region;
27
+ identifier;
28
+ _client;
29
+ _session = null;
30
+ _credentialsProvider = undefined;
31
+ /**
32
+ * Creates a new CodeInterpreter instance.
33
+ *
34
+ * @param config - Configuration options
35
+ */
36
+ constructor(config) {
37
+ this.region = config.region ?? process.env.AWS_REGION ?? DEFAULT_REGION;
38
+ this.identifier = config.identifier ?? DEFAULT_IDENTIFIER;
39
+ this._credentialsProvider = config.credentialsProvider;
40
+ this._client = new BedrockAgentCoreClient({
41
+ region: this.region,
42
+ ...(this._credentialsProvider && { credentials: this._credentialsProvider }),
43
+ ...config.clientConfig,
44
+ });
45
+ }
46
+ // ===========================
47
+ // Session Management
48
+ // ===========================
49
+ /**
50
+ * Start a new code interpreter session.
51
+ *
52
+ * @param params - Session configuration
53
+ * @returns Session information including AWS-assigned session ID
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const session = await interpreter.startSession({
58
+ * sessionName: 'data-analysis',
59
+ * description: 'Processing customer data',
60
+ * timeout: 1800
61
+ * })
62
+ * ```
63
+ */
64
+ async startSession(params) {
65
+ if (this._session) {
66
+ throw new Error('Session already active. Call stopSession() first.');
67
+ }
68
+ const sessionName = params?.sessionName ?? DEFAULT_SESSION_NAME;
69
+ // Call AWS SDK to start the session
70
+ const command = new StartCodeInterpreterSessionCommand({
71
+ codeInterpreterIdentifier: this.identifier,
72
+ name: sessionName,
73
+ sessionTimeoutSeconds: params?.timeout ?? DEFAULT_TIMEOUT,
74
+ });
75
+ const response = await this._client.send(command);
76
+ const sessionInfo = {
77
+ sessionName,
78
+ sessionId: response.sessionId,
79
+ createdAt: response.createdAt,
80
+ ...(params?.description !== undefined && { description: params.description }),
81
+ };
82
+ this._session = sessionInfo;
83
+ return sessionInfo;
84
+ }
85
+ /**
86
+ * Stop the active code interpreter session.
87
+ * Gracefully handles non-existent sessions without throwing errors.
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * await interpreter.stopSession()
92
+ * ```
93
+ */
94
+ async stopSession() {
95
+ // Gracefully return if session doesn't exist
96
+ if (!this._session) {
97
+ return;
98
+ }
99
+ // Call AWS SDK to stop the session
100
+ const command = new StopCodeInterpreterSessionCommand({
101
+ codeInterpreterIdentifier: this.identifier,
102
+ sessionId: this._session.sessionId,
103
+ });
104
+ await this._client.send(command);
105
+ this._session = null;
106
+ }
107
+ /**
108
+ * Get detailed information about a code interpreter session.
109
+ *
110
+ * @param params - Optional parameters specifying which session to query
111
+ * @returns Detailed session information
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * // Get current active session details
116
+ * const sessionInfo = await interpreter.getSession()
117
+ * console.log(`Session status: ${sessionInfo.status}`)
118
+ *
119
+ * // Get details for a specific session
120
+ * const sessionInfo = await interpreter.getSession({
121
+ * sessionId: 'specific-session-id'
122
+ * })
123
+ * ```
124
+ */
125
+ async getSession(params) {
126
+ const interpreterId = params?.interpreterId ?? this.identifier;
127
+ const sessionId = params?.sessionId ?? this._session?.sessionId;
128
+ if (!interpreterId || !sessionId) {
129
+ throw new Error('Interpreter ID and Session ID must be provided or available from current session. ' +
130
+ 'Start a session first or provide explicit IDs.');
131
+ }
132
+ const command = new GetCodeInterpreterSessionCommand({
133
+ codeInterpreterIdentifier: interpreterId,
134
+ sessionId,
135
+ });
136
+ const response = await this._client.send(command);
137
+ // Using type extension for fields not in SDK types yet
138
+ const responseWithExtras = response;
139
+ return {
140
+ sessionId: response.sessionId,
141
+ codeInterpreterIdentifier: response.codeInterpreterIdentifier,
142
+ name: response.name,
143
+ status: response.status ?? 'UNKNOWN',
144
+ createdAt: response.createdAt,
145
+ lastUpdatedAt: responseWithExtras.lastUpdatedAt ?? response.createdAt,
146
+ sessionTimeoutSeconds: response.sessionTimeoutSeconds,
147
+ };
148
+ }
149
+ /**
150
+ * List code interpreter sessions for this interpreter.
151
+ *
152
+ * @param params - Optional filtering and pagination parameters
153
+ * @returns List of session summaries with optional pagination token
154
+ *
155
+ * @example
156
+ * ```typescript
157
+ * // List all active sessions
158
+ * const response = await interpreter.listSessions({ status: 'READY' })
159
+ * for (const session of response.items) {
160
+ * console.log(`Session ${session.sessionId}: ${session.status}`)
161
+ * }
162
+ *
163
+ * // Paginate through results
164
+ * let response = await interpreter.listSessions({ maxResults: 10 })
165
+ * while (response.nextToken) {
166
+ * response = await interpreter.listSessions({
167
+ * maxResults: 10,
168
+ * nextToken: response.nextToken
169
+ * })
170
+ * }
171
+ * ```
172
+ */
173
+ async listSessions(params) {
174
+ const interpreterId = params?.interpreterId ?? this.identifier;
175
+ if (!interpreterId) {
176
+ throw new Error('Interpreter ID must be provided or available from configuration');
177
+ }
178
+ const command = new ListCodeInterpreterSessionsCommand({
179
+ codeInterpreterIdentifier: interpreterId,
180
+ ...(params?.status && {
181
+ status: params.status,
182
+ }),
183
+ ...(params?.maxResults && { maxResults: params.maxResults }),
184
+ ...(params?.nextToken && { nextToken: params.nextToken }),
185
+ });
186
+ const response = await this._client.send(command);
187
+ const items = response.items?.map((item) => ({
188
+ sessionId: item.sessionId,
189
+ name: item.name,
190
+ status: item.status ?? 'UNKNOWN',
191
+ createdAt: item.createdAt,
192
+ lastUpdatedAt: item.lastUpdatedAt,
193
+ })) ?? [];
194
+ return {
195
+ items,
196
+ ...(response.nextToken && { nextToken: response.nextToken }),
197
+ };
198
+ }
199
+ // ===========================
200
+ // Code Execution
201
+ // ===========================
202
+ /**
203
+ * Execute code in a code interpreter session.
204
+ * Automatically creates a session if one doesn't exist.
205
+ *
206
+ * @param params - Execution parameters
207
+ * @returns Execution result with output or error
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * // Auto-creates default session
212
+ * const result = await interpreter.executeCode({
213
+ * code: 'print("Hello")',
214
+ * language: 'python'
215
+ * })
216
+ * ```
217
+ */
218
+ async executeCode(params) {
219
+ if (!this._session) {
220
+ await this.startSession();
221
+ }
222
+ try {
223
+ const command = new InvokeCodeInterpreterCommand({
224
+ codeInterpreterIdentifier: this.identifier,
225
+ sessionId: this._session.sessionId,
226
+ name: 'executeCode',
227
+ arguments: {
228
+ code: params.code,
229
+ language: params.language ?? 'python',
230
+ ...(params.clearContext !== undefined && { clearContext: params.clearContext }),
231
+ },
232
+ });
233
+ const response = await this._client.send(command);
234
+ // Returns raw content string from AWS
235
+ return await this._parseInvokeResponse(response);
236
+ }
237
+ catch (error) {
238
+ return `Error: ${error instanceof Error ? error.message : 'Unknown execution error'}`;
239
+ }
240
+ }
241
+ // ===========================
242
+ // Command Execution
243
+ // ===========================
244
+ /**
245
+ * Execute a shell command in a code interpreter session.
246
+ * Automatically creates a session if one doesn't exist.
247
+ *
248
+ * @param params - Command parameters
249
+ * @returns Command result with output or error
250
+ *
251
+ * @example
252
+ * ```typescript
253
+ * const result = await interpreter.executeCommand({
254
+ * command: 'ls -la'
255
+ * })
256
+ * ```
257
+ */
258
+ async executeCommand(params) {
259
+ if (!this._session) {
260
+ await this.startSession();
261
+ }
262
+ try {
263
+ const command = new InvokeCodeInterpreterCommand({
264
+ codeInterpreterIdentifier: this.identifier,
265
+ sessionId: this._session.sessionId,
266
+ name: 'executeCommand',
267
+ arguments: {
268
+ command: params.command,
269
+ },
270
+ });
271
+ const response = await this._client.send(command);
272
+ // Returns raw content string from AWS
273
+ return await this._parseInvokeResponse(response);
274
+ }
275
+ catch (error) {
276
+ return `Error: ${error instanceof Error ? error.message : 'Command execution failed'}`;
277
+ }
278
+ }
279
+ // ===========================
280
+ // File Operations
281
+ // ===========================
282
+ /**
283
+ * Read files from the code interpreter sandbox.
284
+ * Automatically creates a session if one doesn't exist.
285
+ *
286
+ * @param params - Read parameters
287
+ * @returns Read result with file contents or errors
288
+ *
289
+ * @example
290
+ * ```typescript
291
+ * const result = await interpreter.readFiles({
292
+ * paths: ['data.txt', 'output.json']
293
+ * })
294
+ * ```
295
+ */
296
+ async readFiles(params) {
297
+ if (!this._session) {
298
+ await this.startSession();
299
+ }
300
+ try {
301
+ const command = new InvokeCodeInterpreterCommand({
302
+ codeInterpreterIdentifier: this.identifier,
303
+ sessionId: this._session.sessionId,
304
+ name: 'readFiles',
305
+ arguments: {
306
+ paths: params.paths,
307
+ },
308
+ });
309
+ const response = await this._client.send(command);
310
+ // Returns raw content string from AWS
311
+ return await this._parseInvokeResponse(response);
312
+ }
313
+ catch (error) {
314
+ return `Error: ${error instanceof Error ? error.message : 'Read failed'}`;
315
+ }
316
+ }
317
+ /**
318
+ * Write files to the code interpreter sandbox.
319
+ * Automatically creates a session if one doesn't exist.
320
+ *
321
+ * @param params - Write parameters
322
+ * @returns Write result with written file paths or errors
323
+ *
324
+ * @example
325
+ * ```typescript
326
+ * await interpreter.writeFiles({
327
+ * files: [
328
+ * { path: 'script.py', content: 'print("Hello")' },
329
+ * { path: 'data.json', content: '{"key": "value"}' }
330
+ * ]
331
+ * })
332
+ * ```
333
+ */
334
+ async writeFiles(params) {
335
+ if (!this._session) {
336
+ await this.startSession();
337
+ }
338
+ try {
339
+ const command = new InvokeCodeInterpreterCommand({
340
+ codeInterpreterIdentifier: this.identifier,
341
+ sessionId: this._session.sessionId,
342
+ name: 'writeFiles',
343
+ arguments: {
344
+ content: params.files.map((f) => ({
345
+ path: f.path,
346
+ text: f.content,
347
+ })),
348
+ },
349
+ });
350
+ const response = await this._client.send(command);
351
+ // Returns raw content string from AWS
352
+ return await this._parseInvokeResponse(response);
353
+ }
354
+ catch (error) {
355
+ return `Error: ${error instanceof Error ? error.message : 'Write failed'}`;
356
+ }
357
+ }
358
+ /**
359
+ * List files in the code interpreter sandbox.
360
+ * Automatically creates a session if one doesn't exist.
361
+ *
362
+ * @param params - List parameters
363
+ * @returns List result with file information or error
364
+ *
365
+ * @example
366
+ * ```typescript
367
+ * const result = await interpreter.listFiles({ path: '/tmp' })
368
+ * ```
369
+ */
370
+ async listFiles(params) {
371
+ if (!this._session) {
372
+ await this.startSession();
373
+ }
374
+ try {
375
+ const command = new InvokeCodeInterpreterCommand({
376
+ codeInterpreterIdentifier: this.identifier,
377
+ sessionId: this._session.sessionId,
378
+ name: 'listFiles',
379
+ arguments: {
380
+ path: params?.path ?? '.',
381
+ },
382
+ });
383
+ const response = await this._client.send(command);
384
+ // Returns raw content string from AWS
385
+ return await this._parseInvokeResponse(response);
386
+ }
387
+ catch (error) {
388
+ return `Error: ${error instanceof Error ? error.message : 'List failed'}`;
389
+ }
390
+ }
391
+ /**
392
+ * Remove files from the code interpreter sandbox.
393
+ * Automatically creates a session if one doesn't exist.
394
+ *
395
+ * @param params - Remove parameters
396
+ * @returns Remove result with removed file paths or errors
397
+ *
398
+ * @example
399
+ * ```typescript
400
+ * await interpreter.removeFiles({
401
+ * paths: ['temp.txt', 'cache.json']
402
+ * })
403
+ * ```
404
+ */
405
+ async removeFiles(params) {
406
+ if (!this._session) {
407
+ await this.startSession();
408
+ }
409
+ try {
410
+ const command = new InvokeCodeInterpreterCommand({
411
+ codeInterpreterIdentifier: this.identifier,
412
+ sessionId: this._session.sessionId,
413
+ name: 'removeFiles',
414
+ arguments: {
415
+ paths: params.paths,
416
+ },
417
+ });
418
+ const response = await this._client.send(command);
419
+ // Returns raw content string from AWS
420
+ return await this._parseInvokeResponse(response);
421
+ }
422
+ catch (error) {
423
+ return `Error: ${error instanceof Error ? error.message : 'Remove failed'}`;
424
+ }
425
+ }
426
+ // ===========================
427
+ // Private Helpers
428
+ // ===========================
429
+ /**
430
+ * Extract and parse the streaming response from InvokeCodeInterpreterCommand.
431
+ * Returns the raw content string from AWS without additional formatting.
432
+ */
433
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
434
+ async _parseInvokeResponse(response) {
435
+ let contentStr = '';
436
+ // Extract content string from stream
437
+ if (response.stream) {
438
+ for await (const event of response.stream) {
439
+ if (event.result?.content) {
440
+ const content = event.result.content;
441
+ // Handle AWS structured response format
442
+ if (Array.isArray(content)) {
443
+ contentStr = this._extractFromContentArray(content);
444
+ }
445
+ else if (typeof content === 'string') {
446
+ contentStr = content;
447
+ }
448
+ else {
449
+ // Fallback for unknown formats
450
+ contentStr = JSON.stringify(content);
451
+ }
452
+ }
453
+ if (event.error) {
454
+ contentStr = event.error.message || 'Unknown error';
455
+ }
456
+ }
457
+ }
458
+ else if (response.result?.content) {
459
+ const content = response.result.content;
460
+ // Handle AWS structured response format (same logic as streaming)
461
+ if (Array.isArray(content)) {
462
+ contentStr = this._extractFromContentArray(content);
463
+ }
464
+ else if (typeof content === 'string') {
465
+ contentStr = content;
466
+ }
467
+ else {
468
+ contentStr = JSON.stringify(content);
469
+ }
470
+ }
471
+ // Return raw content string - let the AI SDK handle formatting
472
+ return contentStr;
473
+ }
474
+ /**
475
+ * Extract text from AWS content array, handling multiple content types:
476
+ * - type: "text" - Direct text output (code execution, commands)
477
+ * - type: "resource" - File content with nested resource object
478
+ * - type: "resource_link" - File metadata (listFiles)
479
+ */
480
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
481
+ _extractFromContentArray(content) {
482
+ const parts = [];
483
+ for (const item of content) {
484
+ if (item.type === 'text') {
485
+ // Direct text output
486
+ parts.push(item.text);
487
+ }
488
+ else if (item.type === 'resource' && item.resource) {
489
+ // File content - extract text from nested resource object
490
+ if (item.resource.text) {
491
+ parts.push(item.resource.text);
492
+ }
493
+ else {
494
+ // Resource without text - show metadata
495
+ parts.push(JSON.stringify(item.resource));
496
+ }
497
+ }
498
+ else if (item.type === 'resource_link') {
499
+ // File metadata - format as human-readable string
500
+ const { name, description, mimeType, uri } = item;
501
+ const meta = [name, description, mimeType].filter(Boolean).join(' - ');
502
+ parts.push(`${meta} (${uri})`);
503
+ }
504
+ else {
505
+ // Unknown type - fallback to JSON
506
+ parts.push(JSON.stringify(item));
507
+ }
508
+ }
509
+ return parts.join('\n');
510
+ }
511
+ }
512
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/tools/code-interpreter/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,kCAAkC,EAClC,iCAAiC,EACjC,4BAA4B,EAC5B,gCAAgC,EAChC,kCAAkC,GACnC,MAAM,mCAAmC,CAAA;AAkB1C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEtG;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAAe;IACjB,MAAM,CAAQ;IACd,UAAU,CAAQ;IAEnB,OAAO,CAAwB;IAC/B,QAAQ,GAAuB,IAAI,CAAA;IACnC,oBAAoB,GAA8C,SAAS,CAAA;IAEnF;;;;OAIG;IACH,YAAY,MAA6B;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,cAAc,CAAA;QACvE,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,kBAAkB,CAAA;QACzD,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,mBAAmB,CAAA;QAEtD,IAAI,CAAC,OAAO,GAAG,IAAI,sBAAsB,CAAC;YACxC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,CAAC,IAAI,CAAC,oBAAoB,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5E,GAAG,MAAM,CAAC,YAAY;SACvB,CAAC,CAAA;IACJ,CAAC;IAED,8BAA8B;IAC9B,qBAAqB;IACrB,8BAA8B;IAE9B;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,YAAY,CAAC,MAA2B;QAC5C,IAAI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teCodeResult, ExecuteCommandParams, ExecuteCommandResult, ReadFilesParams, FileContent, ReadFilesResult, WriteFilesParams, WriteFilesResult, ListFilesParams, FileInfo, ListFilesResult, RemoveFilesParams, RemoveFilesResult, } from './types.js';
3
+ export { CodeLanguageSchema, ExecuteCodeParamsSchema, ExecuteCommandParamsSchema, ReadFilesParamsSchema, WriteFilesParamsSchema, ListFilesParamsSchema, RemoveFilesParamsSchema, DEFAULT_IDENTIFIER, DEFAULT_TIMEOUT, DEFAULT_SESSION_NAME, } from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/code-interpreter/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAG7C,YAAY,EACV,qBAAqB,EACrB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,eAAe,EACf,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,YAAY,CAAA;AAGnB,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACrB,MAAM,YAAY,CAAA"}
@@ -0,0 +1,5 @@
1
+ // Main client
2
+ export { CodeInterpreter } from './client.js';
3
+ // Zod schemas for validation
4
+ export { CodeLanguageSchema, ExecuteCodeParamsSchema, ExecuteCommandParamsSchema, ReadFilesParamsSchema, WriteFilesParamsSchema, ListFilesParamsSchema, RemoveFilesParamsSchema, DEFAULT_IDENTIFIER, DEFAULT_TIMEOUT, DEFAULT_SESSION_NAME, } from './types.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tools/code-interpreter/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAwB7C,6BAA6B;AAC7B,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,oBAAoB,GACrB,MAAM,YAAY,CAAA"}
@@ -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/sdk/code-interpreter/vercel-ai'
11
+ * import { CodeInterpreter } from '@bedrock-agentcore/sdk/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/sdk/code-interpreter/vercel-ai'
13
+ * import { CodeInterpreter } from '@bedrock-agentcore/sdk/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/sdk/code-interpreter/vercel-ai'
11
+ * import { CodeInterpreter } from '@bedrock-agentcore/sdk/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"}