bedrock-agentcore 0.1.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/README.md +94 -114
- 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/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/tools.d.ts +1 -1
- package/dist/src/tools/browser/integrations/vercel-ai/tools.js +1 -1
- package/dist/src/tools/code-interpreter/client.d.ts +2 -0
- package/dist/src/tools/code-interpreter/client.d.ts.map +1 -1
- package/dist/src/tools/code-interpreter/client.js +31 -25
- package/dist/src/tools/code-interpreter/client.js.map +1 -1
- 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 +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-code-tool.js +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.d.ts +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/execute-command-tool.js +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.d.ts +3 -3
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/file-operations-tool.js +2 -2
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.d.ts +1 -1
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/index.js +1 -1
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.d.ts +1 -1
- package/dist/src/tools/code-interpreter/integrations/vercel-ai/tools.js +1 -1
- package/package.json +46 -11
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import type { AwsCredentialIdentityProvider } from '@aws-sdk/types';
|
|
2
|
+
import type { FastifyBodyParser, FastifyContentTypeParser, FastifyBaseLogger, FastifyLoggerOptions, FastifyRequest } from 'fastify';
|
|
3
|
+
import { Buffer } from 'buffer';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import type { WebSocket } from '@fastify/websocket';
|
|
6
|
+
import type { SSESource } from '@fastify/sse';
|
|
7
|
+
/**
|
|
8
|
+
* Context provided to handler functions for each invocation request.
|
|
9
|
+
*/
|
|
10
|
+
export interface RequestContext {
|
|
11
|
+
/**
|
|
12
|
+
* Unique identifier for the session making the request.
|
|
13
|
+
*/
|
|
14
|
+
sessionId: string;
|
|
15
|
+
/**
|
|
16
|
+
* HTTP headers from the incoming request.
|
|
17
|
+
* Filtered to include only Authorization and Custom-* headers.
|
|
18
|
+
*/
|
|
19
|
+
headers: Record<string, string>;
|
|
20
|
+
/**
|
|
21
|
+
* Workload access token for authenticating with AgentCore Identity.
|
|
22
|
+
* Set by RuntimeApp when WorkloadAccessToken header is present.
|
|
23
|
+
* Used by Identity SDK to fetch OAuth2 tokens and API keys.
|
|
24
|
+
*/
|
|
25
|
+
workloadAccessToken?: string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Request ID for tracing and log correlation.
|
|
28
|
+
* Extracted from X-Amzn-Bedrock-AgentCore-Runtime-Request-Id header
|
|
29
|
+
* or auto-generated if not provided.
|
|
30
|
+
*/
|
|
31
|
+
requestId?: string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* OAuth2 callback URL for authentication flows.
|
|
34
|
+
* Extracted from OAuth2CallbackUrl header when present.
|
|
35
|
+
*/
|
|
36
|
+
oauth2CallbackUrl?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Request-scoped logger with automatic context (request ID, method, URL).
|
|
39
|
+
* Handlers should use this for all logging to ensure proper request correlation.
|
|
40
|
+
*/
|
|
41
|
+
log: FastifyBaseLogger;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Handler function type for processing agent invocations.
|
|
45
|
+
*
|
|
46
|
+
* The handler accepts and returns unknown types to support
|
|
47
|
+
* arbitrary JSON payloads from AgentCore Runtime. The handler can also
|
|
48
|
+
* return an async generator for streaming responses via Server-Sent Events.
|
|
49
|
+
*
|
|
50
|
+
* @param request - The request payload from AgentCore Runtime
|
|
51
|
+
* @param context - Additional context including sessionId and headers
|
|
52
|
+
* @returns Response data (any serializable type) or async generator for streaming
|
|
53
|
+
*/
|
|
54
|
+
export type InvocationHandler<TRequest = unknown> = (request: TRequest, context: RequestContext) => Promise<unknown> | unknown | AsyncGenerator<SSESource, void, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* WebSocket handler function type for processing WebSocket connections.
|
|
57
|
+
*
|
|
58
|
+
* @param connection - Fastify WebSocket connection object
|
|
59
|
+
* @param context - Request context including sessionId and headers
|
|
60
|
+
*/
|
|
61
|
+
export type WebSocketHandler = (socket: WebSocket, context: RequestContext) => Promise<void> | void;
|
|
62
|
+
/**
|
|
63
|
+
* Content type parser configuration using Fastify's native types.
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const app = new BedrockAgentCoreApp({
|
|
67
|
+
* invocationHandler: { process: myHandler },
|
|
68
|
+
* config: {
|
|
69
|
+
* contentTypeParsers: [
|
|
70
|
+
* {
|
|
71
|
+
* contentType: 'application/xml',
|
|
72
|
+
* parser: (request, body) => parseXML(body as string),
|
|
73
|
+
* parseAs: 'string'
|
|
74
|
+
* },
|
|
75
|
+
* {
|
|
76
|
+
* contentType: 'application/pdf',
|
|
77
|
+
* parser: (request, body) => parsePDF(body as Buffer),
|
|
78
|
+
* parseAs: 'buffer'
|
|
79
|
+
* },
|
|
80
|
+
* {
|
|
81
|
+
* contentType: 'application/large-csv',
|
|
82
|
+
* parser: (request, payload) => parseStreamingCSV(payload),
|
|
83
|
+
* // parseAs omitted for stream mode (uses FastifyContentTypeParser)
|
|
84
|
+
* }
|
|
85
|
+
* ]
|
|
86
|
+
* }
|
|
87
|
+
* })
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export interface ContentTypeParserConfig {
|
|
91
|
+
/**
|
|
92
|
+
* Content type to handle (e.g., 'application/xml', 'text/csv').
|
|
93
|
+
* Can be a string, array of strings, or RegExp.
|
|
94
|
+
*/
|
|
95
|
+
contentType: string | string[] | RegExp;
|
|
96
|
+
/**
|
|
97
|
+
* Parser function to process the request body.
|
|
98
|
+
* Uses Fastify's native FastifyBodyParser for string/buffer modes,
|
|
99
|
+
* or FastifyContentTypeParser for stream mode.
|
|
100
|
+
*/
|
|
101
|
+
parser: FastifyBodyParser<string | Buffer> | FastifyContentTypeParser;
|
|
102
|
+
/**
|
|
103
|
+
* How to parse the raw request body before passing to the parser function.
|
|
104
|
+
* - 'string': body is parsed as string (uses FastifyBodyParser<string>)
|
|
105
|
+
* - 'buffer': body is parsed as buffer (uses FastifyBodyParser<Buffer>)
|
|
106
|
+
* - 'stream': body is passed as raw stream (uses FastifyContentTypeParser)
|
|
107
|
+
*
|
|
108
|
+
* Defaults to 'string' when not specified.
|
|
109
|
+
*/
|
|
110
|
+
parseAs?: 'string' | 'buffer' | 'stream';
|
|
111
|
+
/**
|
|
112
|
+
* The maximum payload size, in bytes, that the custom parser will accept
|
|
113
|
+
* Defaults to Fastify's global body limit (1MB default)
|
|
114
|
+
*/
|
|
115
|
+
bodyLimit?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Configuration options for BedrockAgentCoreApp.
|
|
119
|
+
*/
|
|
120
|
+
export interface BedrockAgentCoreAppConfig {
|
|
121
|
+
/**
|
|
122
|
+
* Logging configuration options.
|
|
123
|
+
*/
|
|
124
|
+
logging?: {
|
|
125
|
+
/**
|
|
126
|
+
* Enable or disable logging.
|
|
127
|
+
* Defaults to true.
|
|
128
|
+
*/
|
|
129
|
+
enabled?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Disable automatic request/response logging.
|
|
132
|
+
*
|
|
133
|
+
* Can be:
|
|
134
|
+
* - `boolean` - Disable for all requests
|
|
135
|
+
* - `function` - Conditionally disable based on request properties
|
|
136
|
+
*
|
|
137
|
+
* When enabled, Fastify won't log "incoming request" and "request completed" messages.
|
|
138
|
+
* Manual logging with context.log still works.
|
|
139
|
+
*
|
|
140
|
+
* Defaults to `(req) =\> req.url === '/ping'` - disables logging for health checks
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* // Disable for all requests
|
|
145
|
+
* disableRequestLogging: true
|
|
146
|
+
*
|
|
147
|
+
* // Disable only for health checks (default behavior)
|
|
148
|
+
* disableRequestLogging: (request) => request.url === '/ping'
|
|
149
|
+
*
|
|
150
|
+
* // Disable for multiple endpoints
|
|
151
|
+
* disableRequestLogging: (request) => {
|
|
152
|
+
* return ['/ping', '/health', '/metrics'].includes(request.url)
|
|
153
|
+
* }
|
|
154
|
+
*
|
|
155
|
+
* // Disable for load balancer health checks
|
|
156
|
+
* disableRequestLogging: (request) => {
|
|
157
|
+
* return request.headers['user-agent']?.includes('ELB-HealthChecker')
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
disableRequestLogging?: boolean | ((request: FastifyRequest) => boolean);
|
|
162
|
+
/**
|
|
163
|
+
* Fastify logger options.
|
|
164
|
+
*
|
|
165
|
+
* Configure log level, custom serializers, streams, and more.
|
|
166
|
+
*
|
|
167
|
+
* @see https://fastify.dev/docs/latest/Reference/Server/#logger
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* // Set log level
|
|
172
|
+
* logging: {
|
|
173
|
+
* options: { level: 'debug' }
|
|
174
|
+
* }
|
|
175
|
+
*
|
|
176
|
+
* // Custom stream (e.g., CloudWatch)
|
|
177
|
+
* logging: {
|
|
178
|
+
* options: {
|
|
179
|
+
* level: 'info',
|
|
180
|
+
* stream: cloudWatchStream
|
|
181
|
+
* }
|
|
182
|
+
* }
|
|
183
|
+
*
|
|
184
|
+
* // Filter sensitive data
|
|
185
|
+
* logging: {
|
|
186
|
+
* options: {
|
|
187
|
+
* level: 'info',
|
|
188
|
+
* serializers: {
|
|
189
|
+
* req: (req) => ({
|
|
190
|
+
* method: req.method,
|
|
191
|
+
* url: req.url
|
|
192
|
+
* // Authorization header excluded
|
|
193
|
+
* })
|
|
194
|
+
* }
|
|
195
|
+
* }
|
|
196
|
+
* }
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
options?: FastifyLoggerOptions;
|
|
200
|
+
};
|
|
201
|
+
/**
|
|
202
|
+
* Custom content type parsers for handling custom content-types.
|
|
203
|
+
* 'application/json' and 'text/plain' are natively supported.
|
|
204
|
+
*/
|
|
205
|
+
contentTypeParsers?: ContentTypeParserConfig[];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Parameters for BedrockAgentCoreApp constructor.
|
|
209
|
+
*/
|
|
210
|
+
export interface BedrockAgentCoreAppParams<TSchema extends z.ZodSchema = z.ZodSchema<unknown>> {
|
|
211
|
+
/**
|
|
212
|
+
* Invocation handler configuration with validation and typing.
|
|
213
|
+
*/
|
|
214
|
+
invocationHandler: {
|
|
215
|
+
/**
|
|
216
|
+
* The function to process invocation requests.
|
|
217
|
+
*/
|
|
218
|
+
process: InvocationHandler<z.infer<TSchema>>;
|
|
219
|
+
/**
|
|
220
|
+
* Optional Zod schema for request validation and TypeScript typing.
|
|
221
|
+
* When provided, validates request.body before passing to handler.
|
|
222
|
+
* When omitted, handler receives unknown request type.
|
|
223
|
+
*/
|
|
224
|
+
requestSchema?: TSchema;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* WebSocket handler for the /ws endpoint.
|
|
228
|
+
*/
|
|
229
|
+
websocketHandler?: WebSocketHandler;
|
|
230
|
+
/**
|
|
231
|
+
* Additional configuration options.
|
|
232
|
+
*/
|
|
233
|
+
config?: BedrockAgentCoreAppConfig;
|
|
234
|
+
/**
|
|
235
|
+
* Custom ping handler to determine health status.
|
|
236
|
+
*/
|
|
237
|
+
pingHandler?: () => HealthStatus | Promise<HealthStatus>;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Health status values for the /ping endpoint.
|
|
241
|
+
*/
|
|
242
|
+
export type HealthStatus = 'Healthy' | 'HealthyBusy';
|
|
243
|
+
/**
|
|
244
|
+
* Health check response format.
|
|
245
|
+
*/
|
|
246
|
+
export interface HealthCheckResponse {
|
|
247
|
+
/**
|
|
248
|
+
* Current health status of the application.
|
|
249
|
+
*/
|
|
250
|
+
status: HealthStatus;
|
|
251
|
+
/**
|
|
252
|
+
* ISO 8601 timestamp of the last update.
|
|
253
|
+
*/
|
|
254
|
+
time_of_last_update: string;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Information about a tracked async task.
|
|
258
|
+
*/
|
|
259
|
+
export interface AsyncTaskInfo {
|
|
260
|
+
name: string;
|
|
261
|
+
startTime: number;
|
|
262
|
+
metadata?: Record<string, unknown>;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Status information about all async tasks.
|
|
266
|
+
*/
|
|
267
|
+
export interface AsyncTaskStatus {
|
|
268
|
+
activeCount: number;
|
|
269
|
+
runningJobs: Array<{
|
|
270
|
+
name: string;
|
|
271
|
+
duration: number;
|
|
272
|
+
}>;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Default presigned URL timeout in seconds (5 minutes).
|
|
276
|
+
*/
|
|
277
|
+
export declare const DEFAULT_PRESIGNED_URL_TIMEOUT = 300;
|
|
278
|
+
/**
|
|
279
|
+
* Maximum presigned URL timeout in seconds (5 minutes).
|
|
280
|
+
*/
|
|
281
|
+
export declare const MAX_PRESIGNED_URL_TIMEOUT = 300;
|
|
282
|
+
/**
|
|
283
|
+
* Default AWS region.
|
|
284
|
+
*/
|
|
285
|
+
export declare const DEFAULT_REGION = "us-west-2";
|
|
286
|
+
/**
|
|
287
|
+
* Zod schema for validating runtime ARN format.
|
|
288
|
+
*
|
|
289
|
+
* Expected format: arn:aws:bedrock-agentcore:\{region\}:\{account\}:runtime/\{runtime_id\}
|
|
290
|
+
*/
|
|
291
|
+
export declare const RuntimeArnSchema: z.ZodString;
|
|
292
|
+
/**
|
|
293
|
+
* Parsed components of a runtime ARN.
|
|
294
|
+
*/
|
|
295
|
+
export interface ParsedRuntimeArn {
|
|
296
|
+
/**
|
|
297
|
+
* AWS region where the runtime is located.
|
|
298
|
+
*/
|
|
299
|
+
region: string;
|
|
300
|
+
/**
|
|
301
|
+
* AWS account ID that owns the runtime.
|
|
302
|
+
*/
|
|
303
|
+
accountId: string;
|
|
304
|
+
/**
|
|
305
|
+
* Unique identifier for the runtime.
|
|
306
|
+
*/
|
|
307
|
+
runtimeId: string;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Configuration options for RuntimeClient.
|
|
311
|
+
*/
|
|
312
|
+
export interface RuntimeClientConfig {
|
|
313
|
+
/**
|
|
314
|
+
* AWS region where the runtime service is deployed.
|
|
315
|
+
* Defaults to process.env.AWS_REGION or 'us-west-2'.
|
|
316
|
+
*/
|
|
317
|
+
region?: string;
|
|
318
|
+
/**
|
|
319
|
+
* Optional AWS credentials provider.
|
|
320
|
+
* When omitted, the SDK uses the default Node.js credential provider chain.
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* Using custom credentials:
|
|
324
|
+
* ```ts
|
|
325
|
+
* import { fromIni } from '@aws-sdk/credential-providers'
|
|
326
|
+
*
|
|
327
|
+
* const client = new RuntimeClient({
|
|
328
|
+
* region: 'us-west-2',
|
|
329
|
+
* credentialsProvider: fromIni({ profile: 'my-profile' })
|
|
330
|
+
* })
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
credentialsProvider?: AwsCredentialIdentityProvider;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Parameters for generating WebSocket connection credentials.
|
|
337
|
+
*/
|
|
338
|
+
export interface GenerateWsConnectionParams {
|
|
339
|
+
/**
|
|
340
|
+
* Full runtime ARN.
|
|
341
|
+
*
|
|
342
|
+
* Example: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-runtime-abc'
|
|
343
|
+
*/
|
|
344
|
+
runtimeArn: string;
|
|
345
|
+
/**
|
|
346
|
+
* Optional session ID to use.
|
|
347
|
+
* If not provided, a UUID will be auto-generated.
|
|
348
|
+
*/
|
|
349
|
+
sessionId?: string;
|
|
350
|
+
/**
|
|
351
|
+
* Optional endpoint name to use as 'qualifier' query parameter.
|
|
352
|
+
* If provided, adds ?qualifier=\{endpointName\} to the URL.
|
|
353
|
+
*/
|
|
354
|
+
endpointName?: string;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Parameters for generating presigned WebSocket URL.
|
|
358
|
+
*/
|
|
359
|
+
export interface GeneratePresignedUrlParams {
|
|
360
|
+
/**
|
|
361
|
+
* Full runtime ARN.
|
|
362
|
+
*
|
|
363
|
+
* Example: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-runtime-abc'
|
|
364
|
+
*/
|
|
365
|
+
runtimeArn: string;
|
|
366
|
+
/**
|
|
367
|
+
* Optional session ID to use.
|
|
368
|
+
* If not provided, a UUID will be auto-generated.
|
|
369
|
+
*/
|
|
370
|
+
sessionId?: string;
|
|
371
|
+
/**
|
|
372
|
+
* Optional endpoint name to use as 'qualifier' query parameter.
|
|
373
|
+
* If provided, adds ?qualifier=\{endpointName\} to the URL before signing.
|
|
374
|
+
*/
|
|
375
|
+
endpointName?: string;
|
|
376
|
+
/**
|
|
377
|
+
* Additional query parameters to include in the presigned URL before signing.
|
|
378
|
+
*
|
|
379
|
+
* Example: \{ "customParam": "value", "anotherParam": "value2" \}
|
|
380
|
+
*/
|
|
381
|
+
customHeaders?: Record<string, string>;
|
|
382
|
+
/**
|
|
383
|
+
* Seconds until URL expires.
|
|
384
|
+
* Must be between 1 and 300 seconds.
|
|
385
|
+
* Defaults to 300 seconds (5 minutes).
|
|
386
|
+
*/
|
|
387
|
+
expires?: number;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Parameters for generating WebSocket connection with OAuth authentication.
|
|
391
|
+
*/
|
|
392
|
+
export interface GenerateWsConnectionOAuthParams {
|
|
393
|
+
/**
|
|
394
|
+
* Full runtime ARN.
|
|
395
|
+
*
|
|
396
|
+
* Example: 'arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/my-runtime-abc'
|
|
397
|
+
*/
|
|
398
|
+
runtimeArn: string;
|
|
399
|
+
/**
|
|
400
|
+
* OAuth bearer token for authentication.
|
|
401
|
+
* Must not be empty.
|
|
402
|
+
*/
|
|
403
|
+
bearerToken: string;
|
|
404
|
+
/**
|
|
405
|
+
* Optional session ID to use.
|
|
406
|
+
* If not provided, a UUID will be auto-generated.
|
|
407
|
+
*/
|
|
408
|
+
sessionId?: string;
|
|
409
|
+
/**
|
|
410
|
+
* Optional endpoint name to use as 'qualifier' query parameter.
|
|
411
|
+
* If provided, adds ?qualifier=\{endpointName\} to the URL.
|
|
412
|
+
*/
|
|
413
|
+
endpointName?: string;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* WebSocket connection details with URL and authentication headers.
|
|
417
|
+
*/
|
|
418
|
+
export interface WebSocketConnection {
|
|
419
|
+
/**
|
|
420
|
+
* WebSocket URL (wss://) with query parameters.
|
|
421
|
+
*/
|
|
422
|
+
url: string;
|
|
423
|
+
/**
|
|
424
|
+
* Authentication headers for WebSocket connection.
|
|
425
|
+
* Includes SigV4 signature and session information.
|
|
426
|
+
*/
|
|
427
|
+
headers: Record<string, string>;
|
|
428
|
+
}
|
|
429
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACf,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,c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GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAA;IAEnB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IAEX;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// RuntimeClient Types (WebSocket Client)
|
|
5
|
+
// =============================================================================
|
|
6
|
+
/**
|
|
7
|
+
* Default presigned URL timeout in seconds (5 minutes).
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_PRESIGNED_URL_TIMEOUT = 300;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum presigned URL timeout in seconds (5 minutes).
|
|
12
|
+
*/
|
|
13
|
+
export const MAX_PRESIGNED_URL_TIMEOUT = 300;
|
|
14
|
+
/**
|
|
15
|
+
* Default AWS region.
|
|
16
|
+
*/
|
|
17
|
+
export const DEFAULT_REGION = 'us-west-2';
|
|
18
|
+
/**
|
|
19
|
+
* Zod schema for validating runtime ARN format.
|
|
20
|
+
*
|
|
21
|
+
* Expected format: arn:aws:bedrock-agentcore:\{region\}:\{account\}:runtime/\{runtime_id\}
|
|
22
|
+
*/
|
|
23
|
+
export const RuntimeArnSchema = z
|
|
24
|
+
.string()
|
|
25
|
+
.regex(/^arn:aws:bedrock-agentcore:[^:]+:[^:]+:runtime\/.+$/, 'Invalid runtime ARN format. Expected: arn:aws:bedrock-agentcore:{region}:{account}:runtime/{runtime_id}');
|
|
26
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/types.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA4SvB,gFAAgF;AAChF,yCAAyC;AACzC,gFAAgF;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAA;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAA;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,EAAE;KACR,KAAK,CACJ,qDAAqD,EACrD,yGAAyG,CAC1G,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PlaywrightBrowser } from '../playwright/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Strands SDK tool for clicking elements.
|
|
4
|
+
* Thin wrapper around PlaywrightBrowser.click()
|
|
5
|
+
*
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export declare function createClickTool(client: PlaywrightBrowser): import("@strands-agents/sdk").InvokableTool<{
|
|
9
|
+
selector: string;
|
|
10
|
+
timeout?: number | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
success: true;
|
|
13
|
+
message: string;
|
|
14
|
+
error?: never;
|
|
15
|
+
} | {
|
|
16
|
+
success: false;
|
|
17
|
+
error: string;
|
|
18
|
+
message?: never;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=click-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"click-tool.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/strands/click-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE;;;;;GAKG;AAEH,wBAAgB,eAAe,CAAC,MAAM,EAAE,iBAAiB;;;;;;;;;;;GAoBxD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { tool } from '@strands-agents/sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Strands SDK tool for clicking elements.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser.click()
|
|
6
|
+
*
|
|
7
|
+
* @experimental
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
10
|
+
export function createClickTool(client) {
|
|
11
|
+
return tool({
|
|
12
|
+
name: 'click',
|
|
13
|
+
description: 'Click an element on the page',
|
|
14
|
+
inputSchema: z.object({
|
|
15
|
+
selector: z.string().describe('CSS selector for the element to click'),
|
|
16
|
+
timeout: z.number().positive().optional().describe('Maximum time in milliseconds'),
|
|
17
|
+
}),
|
|
18
|
+
callback: async ({ selector, timeout }) => {
|
|
19
|
+
try {
|
|
20
|
+
const params = { selector };
|
|
21
|
+
if (timeout !== undefined)
|
|
22
|
+
params.timeout = timeout;
|
|
23
|
+
await client.click(params);
|
|
24
|
+
return { success: true, message: `Clicked element: ${selector}` };
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
28
|
+
return { success: false, error: message };
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=click-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"click-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/strands/click-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO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aluate()
|
|
5
|
+
*
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export declare function createEvaluateTool(client: PlaywrightBrowser): import("@strands-agents/sdk").InvokableTool<{
|
|
9
|
+
script: string;
|
|
10
|
+
args?: any[] | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
success: true;
|
|
13
|
+
result: any;
|
|
14
|
+
error?: never;
|
|
15
|
+
} | {
|
|
16
|
+
success: false;
|
|
17
|
+
error: string;
|
|
18
|
+
result?: never;
|
|
19
|
+
}>;
|
|
20
|
+
//# sourceMappingURL=evaluate-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-tool.d.ts","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/strands/evaluate-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB;;;;;;;;;;;GAqB3D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { tool } from '@strands-agents/sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Strands SDK tool for evaluating JavaScript.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser.evaluate()
|
|
6
|
+
*
|
|
7
|
+
* @experimental
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
10
|
+
export function createEvaluateTool(client) {
|
|
11
|
+
return tool({
|
|
12
|
+
name: 'evaluate',
|
|
13
|
+
description: 'Evaluate JavaScript code in the page context',
|
|
14
|
+
inputSchema: z.object({
|
|
15
|
+
script: z.string().describe('JavaScript code to execute'),
|
|
16
|
+
args: z.array(z.any()).optional().describe('Arguments to pass to the script'),
|
|
17
|
+
}),
|
|
18
|
+
callback: async ({ script, args }) => {
|
|
19
|
+
try {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const params = { script };
|
|
22
|
+
if (args !== undefined)
|
|
23
|
+
params.args = args;
|
|
24
|
+
const result = await client.evaluate(params);
|
|
25
|
+
return { success: true, result };
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
29
|
+
return { success: false, error: message };
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=evaluate-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/strands/evaluate-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;GAKG;AACH,+HAA+H;AAC/H,MAAM,UAAU,kBAAkB,CAAC,MAAyB;IAC1D,OAAO,IAAI,CAAC;QACV,IAAI,EAAE,UAAU;QAChB,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,QAAQ,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;YACnC,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,19 @@
|
|
|
1
|
+
import type { PlaywrightBrowser } from '../playwright/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Strands SDK tool for getting HTML content.
|
|
4
|
+
* Thin wrapper around PlaywrightBrowser.getHtml()
|
|
5
|
+
*
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export declare function createGetHtmlTool(client: PlaywrightBrowser): import("@strands-agents/sdk").InvokableTool<{
|
|
9
|
+
selector?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
success: true;
|
|
12
|
+
html: string;
|
|
13
|
+
error?: never;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
error: string;
|
|
17
|
+
html?: never;
|
|
18
|
+
}>;
|
|
19
|
+
//# 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/strands/get-html-tool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAEhE;;;;;GAKG;AAEH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB;;;;;;;;;;GAmB1D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { tool } from '@strands-agents/sdk';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Strands SDK tool for getting HTML content.
|
|
5
|
+
* Thin wrapper around PlaywrightBrowser.getHtml()
|
|
6
|
+
*
|
|
7
|
+
* @experimental
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
10
|
+
export function createGetHtmlTool(client) {
|
|
11
|
+
return tool({
|
|
12
|
+
name: 'getHtml',
|
|
13
|
+
description: 'Get HTML content from an element or the entire page',
|
|
14
|
+
inputSchema: z.object({
|
|
15
|
+
selector: z.string().optional().describe('CSS selector for the element (omit for full page HTML)'),
|
|
16
|
+
}),
|
|
17
|
+
callback: async ({ selector }) => {
|
|
18
|
+
try {
|
|
19
|
+
const params = {};
|
|
20
|
+
if (selector !== undefined)
|
|
21
|
+
params.selector = selector;
|
|
22
|
+
const html = await client.getHtml(params);
|
|
23
|
+
return { success: true, html };
|
|
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=get-html-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-html-tool.js","sourceRoot":"","sources":["../../../../../../src/tools/browser/integrations/strands/get-html-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB;;;;;GAKG;AACH,+HAA+H;AAC/H,MAAM,UAAU,iBAAiB,CAAC,MAAyB;IACzD,OAAO,IAAI,CAAC;QACV,IAAI,EAAE,SAAS;QACf,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,QAAQ,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;YAC/B,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
|
+
import type { PlaywrightBrowser } from '../playwright/client.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Strands SDK tool for getting text content.
|
|
4
|
+
* Thin wrapper around PlaywrightBrowser.getText()
|
|
5
|
+
*
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
export declare function createGetTextTool(client: PlaywrightBrowser): import("@strands-agents/sdk").InvokableTool<{
|
|
9
|
+
selector?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
success: true;
|
|
12
|
+
text: string;
|
|
13
|
+
error?: never;
|
|
14
|
+
} | {
|
|
15
|
+
success: false;
|
|
16
|
+
error: string;
|
|
17
|
+
text?: never;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=get-text-tool.d.ts.map
|