bedrock-agentcore 0.1.1 → 0.2.2
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 +102 -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/client.d.ts +19 -0
- package/dist/src/tools/browser/client.d.ts.map +1 -1
- package/dist/src/tools/browser/client.js +56 -0
- package/dist/src/tools/browser/client.js.map +1 -1
- package/dist/src/tools/browser/index.d.ts +1 -1
- package/dist/src/tools/browser/index.d.ts.map +1 -1
- package/dist/src/tools/browser/index.js.map +1 -1
- 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/browser/live-view/BrowserLiveView.d.ts +10 -0
- package/dist/src/tools/browser/live-view/BrowserLiveView.d.ts.map +1 -0
- package/dist/src/tools/browser/live-view/BrowserLiveView.js +180 -0
- package/dist/src/tools/browser/live-view/BrowserLiveView.js.map +1 -0
- package/dist/src/tools/browser/live-view/index.d.ts +4 -0
- package/dist/src/tools/browser/live-view/index.d.ts.map +1 -0
- package/dist/src/tools/browser/live-view/index.js +3 -0
- package/dist/src/tools/browser/live-view/index.js.map +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/README.md +26 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcv-ui/EULA.txt +403 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcv-ui/README.md +57 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcv-ui/dcv-ui.js +7 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcv-ui/third-party-licenses.txt +145 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/EULA.txt +403 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/README.md +50 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/dcv/broadwayh264decoder-worker.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/dcv/jsmpegdecoder-worker.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/dcv/lz4decoder-worker.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/dcv/microphoneprocessor.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/dcv.js +33 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/lib/broadway/Decoder.js +850 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/lib/jsmpeg/jsmpeg.min.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/lib/lz4/lz4_decoder.js +12 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-esm/third-party-licenses.txt +1068 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/EULA.txt +403 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/README.md +50 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/dcv/broadwayh264decoder-worker.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/dcv/jsmpegdecoder-worker.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/dcv/lz4decoder-worker.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/dcv/microphoneprocessor.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/dcv.js +33 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/lib/broadway/Decoder.js +850 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/lib/jsmpeg/jsmpeg.min.js +1 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/lib/lz4/lz4_decoder.js +12 -0
- package/dist/src/tools/browser/live-view/nice-dcv-web-client-sdk/dcvjs-umd/third-party-licenses.txt +1068 -0
- package/dist/src/tools/browser/live-view/scaling.d.ts +9 -0
- package/dist/src/tools/browser/live-view/scaling.d.ts.map +1 -0
- package/dist/src/tools/browser/live-view/scaling.js +13 -0
- package/dist/src/tools/browser/live-view/scaling.js.map +1 -0
- package/dist/src/tools/browser/types.d.ts +152 -0
- package/dist/src/tools/browser/types.d.ts.map +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 +69 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/identity/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,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4DAA4D;IAC5D,mBAAmB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IACzC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;CACtD;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,qBAAqB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1C,sCAAsC;IACtC,YAAY,EAAE,MAAM,CAAA;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/identity/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Higher-order functions for wrapping tools with automatic credential injection
|
|
3
|
+
*/
|
|
4
|
+
import type { OAuth2WrapperConfig, ApiKeyWrapperConfig } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Helper type to extract all parameters except the last one (the token/apiKey)
|
|
7
|
+
*/
|
|
8
|
+
type InitParams<T extends unknown[]> = T extends [...infer Init, unknown] ? Init : never;
|
|
9
|
+
/**
|
|
10
|
+
* Wraps an async function to automatically inject OAuth2 access token.
|
|
11
|
+
* The token is injected as the last parameter of the wrapped function.
|
|
12
|
+
*
|
|
13
|
+
* @param config - OAuth2 configuration
|
|
14
|
+
* @returns Function wrapper that injects token as last parameter
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const myTool = withAccessToken({
|
|
19
|
+
* workloadIdentityToken: token,
|
|
20
|
+
* providerName: 'github',
|
|
21
|
+
* scopes: ['repo'],
|
|
22
|
+
* authFlow: 'M2M'
|
|
23
|
+
* })(async (input: string, token: string) => {
|
|
24
|
+
* // Use token to call GitHub API
|
|
25
|
+
* return { result: input };
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* await myTool('hello'); // token injected automatically
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function withAccessToken(config: OAuth2WrapperConfig): <TParams extends [...unknown[], string], TReturn>(fn: (...args: TParams) => Promise<TReturn>) => ((...args: InitParams<TParams>) => Promise<TReturn>);
|
|
32
|
+
/**
|
|
33
|
+
* Wraps an async function to automatically inject API key.
|
|
34
|
+
* The API key is injected as the last parameter of the wrapped function.
|
|
35
|
+
*
|
|
36
|
+
* @param config - API key configuration
|
|
37
|
+
* @returns Function wrapper that injects API key as last parameter
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const myTool = withApiKey({
|
|
42
|
+
* workloadIdentityToken: token,
|
|
43
|
+
* providerName: 'openai'
|
|
44
|
+
* })(async (input: string, apiKey: string) => {
|
|
45
|
+
* // Use API key to call OpenAI API
|
|
46
|
+
* return { result: input };
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* await myTool('hello'); // apiKey injected automatically
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function withApiKey(config: ApiKeyWrapperConfig): <TParams extends [...unknown[], string], TReturn>(fn: (...args: TParams) => Promise<TReturn>) => ((...args: InitParams<TParams>) => Promise<TReturn>);
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=wrappers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrappers.d.ts","sourceRoot":"","sources":["../../../src/identity/wrappers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAG1E;;GAEG;AACH,KAAK,UAAU,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,MAAM,IAAI,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,KAAK,CAAA;AAExF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,mBAAmB,IAGjD,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,EACrD,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,KACzC,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CA6BxD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,mBAAmB,IAG5C,OAAO,SAAS,CAAC,GAAG,OAAO,EAAE,EAAE,MAAM,CAAC,EAAE,OAAO,EACrD,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,KACzC,CAAC,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAsBxD"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Higher-order functions for wrapping tools with automatic credential injection
|
|
3
|
+
*/
|
|
4
|
+
import { IdentityClient } from './client.js';
|
|
5
|
+
import { getContext } from '../runtime/context.js';
|
|
6
|
+
/**
|
|
7
|
+
* Wraps an async function to automatically inject OAuth2 access token.
|
|
8
|
+
* The token is injected as the last parameter of the wrapped function.
|
|
9
|
+
*
|
|
10
|
+
* @param config - OAuth2 configuration
|
|
11
|
+
* @returns Function wrapper that injects token as last parameter
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const myTool = withAccessToken({
|
|
16
|
+
* workloadIdentityToken: token,
|
|
17
|
+
* providerName: 'github',
|
|
18
|
+
* scopes: ['repo'],
|
|
19
|
+
* authFlow: 'M2M'
|
|
20
|
+
* })(async (input: string, token: string) => {
|
|
21
|
+
* // Use token to call GitHub API
|
|
22
|
+
* return { result: input };
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* await myTool('hello'); // token injected automatically
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function withAccessToken(config) {
|
|
29
|
+
const client = new IdentityClient();
|
|
30
|
+
return (fn) => {
|
|
31
|
+
return async (...args) => {
|
|
32
|
+
// Get context and fallback to it if config doesn't provide token
|
|
33
|
+
const context = getContext();
|
|
34
|
+
const workloadToken = config.workloadIdentityToken ?? context?.workloadAccessToken;
|
|
35
|
+
if (!workloadToken) {
|
|
36
|
+
throw new Error('workloadIdentityToken not provided and no context available. ' +
|
|
37
|
+
'Either pass workloadIdentityToken in config or call from within a request handler.');
|
|
38
|
+
}
|
|
39
|
+
const token = await client.getOAuth2Token({
|
|
40
|
+
providerName: config.providerName,
|
|
41
|
+
scopes: config.scopes,
|
|
42
|
+
authFlow: config.authFlow,
|
|
43
|
+
workloadIdentityToken: workloadToken,
|
|
44
|
+
onAuthUrl: config.onAuthUrl,
|
|
45
|
+
forceAuthentication: config.forceAuthentication,
|
|
46
|
+
callbackUrl: config.callbackUrl ?? context?.oauth2CallbackUrl,
|
|
47
|
+
customState: config.customState,
|
|
48
|
+
customParameters: config.customParameters,
|
|
49
|
+
});
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
return fn(...[...args, token]);
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Wraps an async function to automatically inject API key.
|
|
57
|
+
* The API key is injected as the last parameter of the wrapped function.
|
|
58
|
+
*
|
|
59
|
+
* @param config - API key configuration
|
|
60
|
+
* @returns Function wrapper that injects API key as last parameter
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const myTool = withApiKey({
|
|
65
|
+
* workloadIdentityToken: token,
|
|
66
|
+
* providerName: 'openai'
|
|
67
|
+
* })(async (input: string, apiKey: string) => {
|
|
68
|
+
* // Use API key to call OpenAI API
|
|
69
|
+
* return { result: input };
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* await myTool('hello'); // apiKey injected automatically
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export function withApiKey(config) {
|
|
76
|
+
const client = new IdentityClient();
|
|
77
|
+
return (fn) => {
|
|
78
|
+
return async (...args) => {
|
|
79
|
+
// Get context and fallback to it if config doesn't provide token
|
|
80
|
+
const context = getContext();
|
|
81
|
+
const workloadToken = config.workloadIdentityToken ?? context?.workloadAccessToken;
|
|
82
|
+
if (!workloadToken) {
|
|
83
|
+
throw new Error('workloadIdentityToken not provided and no context available. ' +
|
|
84
|
+
'Either pass workloadIdentityToken in config or call from within a request handler.');
|
|
85
|
+
}
|
|
86
|
+
const apiKey = await client.getApiKey({
|
|
87
|
+
providerName: config.providerName,
|
|
88
|
+
workloadIdentityToken: workloadToken,
|
|
89
|
+
});
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
return fn(...[...args, apiKey]);
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=wrappers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrappers.js","sourceRoot":"","sources":["../../../src/identity/wrappers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAOlD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,eAAe,CAAC,MAA2B;IACzD,MAAM,MAAM,GAAG,IAAI,cAAc,EAAE,CAAA;IAEnC,OAAO,CACL,EAA0C,EACY,EAAE;QACxD,OAAO,KAAK,E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,CAAC;gBACnB,MAAM,IAAI,KAAK,CACb,+DAA+D;oBAC7D,oFAAoF,CACvF,CAAA;YACH,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC;gBACpC,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,qBAAqB,EAAE,aAAa;aACrC,CAAC,CAAA;YAEF,8DAA8D;YAC9D,OAAO,EAAE,CAAC,GAAI,CAAC,GAAG,IAAI,EAAE,MAAM,CAAS,CAAC,CAAA;QAC1C,CAAC,CAAA;IACH,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { BedrockAgentCoreAppParams, AsyncTaskStatus, HealthStatus } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Fastify-based HTTP server for hosting agents on AWS Bedrock AgentCore Runtime.
|
|
5
|
+
*
|
|
6
|
+
* This class provides an HTTP server that implements the AgentCore Runtime protocol
|
|
7
|
+
* with health check and invocation endpoints. The server runs on port 8080 and
|
|
8
|
+
* handles both JSON responses and Server-Sent Events (SSE) streaming.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const app = new BedrockAgentCoreApp({
|
|
13
|
+
* invocationHandler: {
|
|
14
|
+
* requestSchema: z.object({ message: z.string() }),
|
|
15
|
+
* process: async (request, context) => {
|
|
16
|
+
* console.log(`Processing request with session ${context.sessionId}`)
|
|
17
|
+
* return `Hello ${request.message}!`
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* app.run()
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class BedrockAgentCoreApp<TSchema extends z.ZodSchema = z.ZodSchema<unknown>> {
|
|
26
|
+
private readonly _app;
|
|
27
|
+
private readonly _config;
|
|
28
|
+
private readonly _handler;
|
|
29
|
+
private _websocketHandler;
|
|
30
|
+
private readonly _activeTasksMap;
|
|
31
|
+
private _taskCounter;
|
|
32
|
+
private _pingHandler;
|
|
33
|
+
private _forcedPingStatus?;
|
|
34
|
+
private _lastStatusUpdateTime;
|
|
35
|
+
private _lastKnownStatus?;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new BedrockAgentCoreApp instance.
|
|
38
|
+
*
|
|
39
|
+
* @param params - Configuration including handler and optional settings
|
|
40
|
+
*/
|
|
41
|
+
constructor(params: BedrockAgentCoreAppParams<TSchema>);
|
|
42
|
+
/**
|
|
43
|
+
* Starts the Fastify server on port 8080.
|
|
44
|
+
*/
|
|
45
|
+
run(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Register an async task for health tracking.
|
|
48
|
+
*
|
|
49
|
+
* @param name - Human-readable task name
|
|
50
|
+
* @param metadata - Optional task metadata
|
|
51
|
+
* @returns Task ID for completion tracking
|
|
52
|
+
*/
|
|
53
|
+
addAsyncTask(name: string, metadata?: Record<string, unknown>): number;
|
|
54
|
+
/**
|
|
55
|
+
* Mark an async task as complete.
|
|
56
|
+
*
|
|
57
|
+
* @param taskId - Task ID from addAsyncTask
|
|
58
|
+
* @returns True if task was found and removed
|
|
59
|
+
*/
|
|
60
|
+
completeAsyncTask(taskId: number): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Get current ping status based on priority system.
|
|
63
|
+
* Priority: Forced \> Custom Handler \> Automatic
|
|
64
|
+
*
|
|
65
|
+
* @returns Current health status
|
|
66
|
+
*/
|
|
67
|
+
getCurrentPingStatus(): HealthStatus;
|
|
68
|
+
/**
|
|
69
|
+
* Decorator to automatically track async tasks.
|
|
70
|
+
* Status becomes HealthyBusy during execution.
|
|
71
|
+
*
|
|
72
|
+
* @param fn - Async function to wrap
|
|
73
|
+
* @returns Wrapped function with automatic task tracking
|
|
74
|
+
* @throws Error if fn is not an async function
|
|
75
|
+
*/
|
|
76
|
+
asyncTask<T extends (...args: unknown[]) => Promise<unknown>>(fn: T): T;
|
|
77
|
+
/**
|
|
78
|
+
* Get information about currently running async tasks.
|
|
79
|
+
*
|
|
80
|
+
* @returns Task status with count and details
|
|
81
|
+
*/
|
|
82
|
+
getAsyncTaskInfo(): AsyncTaskStatus;
|
|
83
|
+
/**
|
|
84
|
+
* Sets up HTTP routes for the server.
|
|
85
|
+
*/
|
|
86
|
+
private _setupRoutes;
|
|
87
|
+
/**
|
|
88
|
+
* Register custom content type parsers using Fastify's native addContentTypeParser.
|
|
89
|
+
*/
|
|
90
|
+
private _setupContentTypeParsers;
|
|
91
|
+
/**
|
|
92
|
+
* Registers Fastify plugins.
|
|
93
|
+
*/
|
|
94
|
+
private _registerPlugins;
|
|
95
|
+
/**
|
|
96
|
+
* Gets the logger configuration based on BedrockAgentCoreAppConfig.
|
|
97
|
+
*
|
|
98
|
+
* @returns Fastify logger configuration
|
|
99
|
+
*/
|
|
100
|
+
private _getLoggerConfig;
|
|
101
|
+
/**
|
|
102
|
+
* Handles health check requests.
|
|
103
|
+
*
|
|
104
|
+
* @param request - Fastify request object
|
|
105
|
+
* @param reply - Fastify reply object
|
|
106
|
+
*/
|
|
107
|
+
private _handlePing;
|
|
108
|
+
/**
|
|
109
|
+
* Handles agent invocation requests.
|
|
110
|
+
*
|
|
111
|
+
* @param request - Fastify request object
|
|
112
|
+
* @param reply - Fastify reply object
|
|
113
|
+
*/
|
|
114
|
+
private _handleInvocation;
|
|
115
|
+
/**
|
|
116
|
+
* Checks if a value is an async generator.
|
|
117
|
+
*
|
|
118
|
+
* @param value - Value to check
|
|
119
|
+
* @returns True if the value is an async generator
|
|
120
|
+
*/
|
|
121
|
+
private _isAsyncGenerator;
|
|
122
|
+
/**
|
|
123
|
+
* Handles streaming response using Server-Sent Events (SSE) via Fastify SSE plugin.
|
|
124
|
+
*
|
|
125
|
+
* @param reply - Fastify reply object
|
|
126
|
+
* @param generator - Async generator that yields data chunks
|
|
127
|
+
*/
|
|
128
|
+
private _handleStreamingResponse;
|
|
129
|
+
/**
|
|
130
|
+
* Handles WebSocket connections at /ws endpoint.
|
|
131
|
+
*
|
|
132
|
+
* @param connection - Fastify WebSocket connection
|
|
133
|
+
* @param request - Fastify request object
|
|
134
|
+
*/
|
|
135
|
+
private _handleWebSocket;
|
|
136
|
+
/**
|
|
137
|
+
* Extracts request context from the incoming request.
|
|
138
|
+
*
|
|
139
|
+
* @param request - Fastify request object
|
|
140
|
+
* @returns Request context with sessionId, headers, and request-scoped logger
|
|
141
|
+
*/
|
|
142
|
+
private _extractContext;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/runtime/app.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAYvB,OAAO,KAAK,EACV,yBAAyB,EAOzB,eAAe,EACf,YAAY,EACb,MAAM,YAAY,CAAA;AAOnB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,mBAAmB,CAAC,OAAO,SAAS,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC;IACjF,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2B;IACnD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2E;IACpG,OAAO,CAAC,iBAAiB,CAA8B;IACvD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwC;IACxE,OAAO,CAAC,YAAY,CAAY;IAChC,OAAO,CAAC,YAAY,CAA0D;IAC9E,OAAO,CAAC,iBAAiB,CAAC,CAAc;IACxC,OAAO,CAAC,qBAAqB,CAAqB;IAClD,OAAO,CAAC,gBAAgB,CAAC,CAAc;IAEvC;;;;OAIG;gBACS,MAAM,EAAE,yBAAyB,CAAC,OAAO,CAAC;IA0BtD;;OAEG;IACH,GAAG,IAAI,IAAI;IAmBX;;;;;;OAMG;IACI,YAAY,CAAC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