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,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,cAAc,CAAA;AAC7C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IAEjB;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAE/B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAExC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAE9B;;;OAGG;IACH,iBAAiB,CAA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AO,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,125 @@
|
|
|
1
|
+
import { BedrockAgentCoreClient } from '@aws-sdk/client-bedrock-agentcore';
|
|
2
|
+
import type { BrowserClientConfig, SessionInfo, StartSessionParams, WebSocketConnection, GetSessionParams, GetSessionResponse, ListSessionsParams, ListSessionsResponse, UpdateStreamParams, UpdateStreamResponse } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Base client for AWS Bedrock AgentCore Browser service.
|
|
5
|
+
*
|
|
6
|
+
* Provides core AWS SDK operations for browser session management and WebSocket connectivity.
|
|
7
|
+
* This client handles session lifecycle and authentication but does not include browser
|
|
8
|
+
* automation methods. Use PlaywrightBrowser for full browser automation capabilities.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const browser = new Browser({ region: 'us-east-1' })
|
|
13
|
+
*
|
|
14
|
+
* // Start a session
|
|
15
|
+
* const session = await browser.startSession({ sessionName: 'my-session' })
|
|
16
|
+
*
|
|
17
|
+
* // Get WebSocket URL for custom browser integration
|
|
18
|
+
* const wsConnection = await browser.generateWebSocketUrl()
|
|
19
|
+
*
|
|
20
|
+
* // Stop the session
|
|
21
|
+
* await browser.stopSession()
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class Browser {
|
|
25
|
+
readonly region: string;
|
|
26
|
+
readonly identifier: string;
|
|
27
|
+
protected _client: BedrockAgentCoreClient;
|
|
28
|
+
protected _session: SessionInfo | null;
|
|
29
|
+
private _credentialsProvider;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new BrowserClient instance.
|
|
32
|
+
*
|
|
33
|
+
* @param config - Configuration options for the client
|
|
34
|
+
*/
|
|
35
|
+
constructor(config: BrowserClientConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Starts a new browser session.
|
|
38
|
+
*
|
|
39
|
+
* @param params - Optional parameters for session configuration
|
|
40
|
+
* @returns Information about the started session
|
|
41
|
+
*
|
|
42
|
+
* @throws Error if a session is already active
|
|
43
|
+
*/
|
|
44
|
+
startSession(params?: StartSessionParams): Promise<SessionInfo>;
|
|
45
|
+
/**
|
|
46
|
+
* Stops the active browser session.
|
|
47
|
+
*
|
|
48
|
+
* @throws Error if no session is active
|
|
49
|
+
*/
|
|
50
|
+
stopSession(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Get detailed information about a browser session.
|
|
53
|
+
*
|
|
54
|
+
* @param params - Optional parameters specifying which session to query
|
|
55
|
+
* @returns Detailed session information
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* // Get current active session details
|
|
60
|
+
* const sessionInfo = await browser.getSession()
|
|
61
|
+
* console.log(`Session status: ${sessionInfo.status}`)
|
|
62
|
+
*
|
|
63
|
+
* // Get details for a specific session
|
|
64
|
+
* const sessionInfo = await browser.getSession({
|
|
65
|
+
* sessionId: 'specific-session-id'
|
|
66
|
+
* })
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
getSession(params?: GetSessionParams): Promise<GetSessionResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* List browser sessions for this browser.
|
|
72
|
+
*
|
|
73
|
+
* @param params - Optional filtering and pagination parameters
|
|
74
|
+
* @returns List of session summaries with optional pagination token
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* // List all active sessions
|
|
79
|
+
* const response = await browser.listSessions({ status: 'READY' })
|
|
80
|
+
* for (const session of response.items) {
|
|
81
|
+
* console.log(`Session ${session.sessionId}: ${session.status}`)
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* // Paginate through results
|
|
85
|
+
* let response = await browser.listSessions({ maxResults: 10 })
|
|
86
|
+
* while (response.nextToken) {
|
|
87
|
+
* response = await browser.listSessions({
|
|
88
|
+
* maxResults: 10,
|
|
89
|
+
* nextToken: response.nextToken
|
|
90
|
+
* })
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
listSessions(params?: ListSessionsParams): Promise<ListSessionsResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Update the browser automation stream status.
|
|
97
|
+
*
|
|
98
|
+
* @param params - Stream update parameters
|
|
99
|
+
* @returns Updated stream information
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* // Enable automation stream
|
|
104
|
+
* const result = await browser.updateBrowserStream({
|
|
105
|
+
* streamStatus: 'ENABLED'
|
|
106
|
+
* })
|
|
107
|
+
*
|
|
108
|
+
* // Disable automation stream
|
|
109
|
+
* await browser.updateBrowserStream({
|
|
110
|
+
* streamStatus: 'DISABLED'
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
updateBrowserStream(params: UpdateStreamParams): Promise<UpdateStreamResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Generates a WebSocket URL and authentication headers for browser automation.
|
|
117
|
+
* Uses AWS Signature Version 4 to sign the WebSocket connection request.
|
|
118
|
+
*
|
|
119
|
+
* @returns WebSocket connection details with URL and authentication headers
|
|
120
|
+
*
|
|
121
|
+
* @throws Error if no session is active
|
|
122
|
+
*/
|
|
123
|
+
generateWebSocketUrl(): Promise<WebSocketConnection>;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/tools/browser/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAOvB,MAAM,mCA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