@aws/nx-plugin 0.99.0 → 0.100.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-THIRD-PARTY +14 -94
- package/generators.json +1 -0
- package/package.json +1 -1
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +10 -10
- package/src/py/mcp-server/files/deploy/Dockerfile.template +1 -1
- package/src/py/mcp-server/generator.js +10 -2
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +43 -12
- package/src/py/strands-agent/files/ag-ui/main.py.template +19 -0
- package/src/py/strands-agent/files/deploy/Dockerfile.template +3 -1
- package/src/py/strands-agent/generator.js +20 -7
- package/src/py/strands-agent/generator.js.map +1 -1
- package/src/py/strands-agent/react-connection/__snapshots__/generator.spec.ts.snap +133 -0
- package/src/py/strands-agent/react-connection/generator.js +69 -56
- package/src/py/strands-agent/react-connection/generator.js.map +1 -1
- package/src/py/strands-agent/react-connection/serve-local.d.ts +6 -2
- package/src/py/strands-agent/react-connection/serve-local.js +11 -6
- package/src/py/strands-agent/react-connection/serve-local.js.map +1 -1
- package/src/py/strands-agent/schema.d.ts +1 -1
- package/src/py/strands-agent/schema.json +2 -2
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/trpc/backend/files/src/middleware/metrics.ts.template +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +10 -10
- package/src/ts/mcp-server/files/Dockerfile.template +1 -1
- package/src/ts/mcp-server/generator.js +9 -1
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/react-website/agui/files/src/components/AguiProvider.tsx.template +19 -0
- package/src/ts/react-website/agui/files/src/hooks/useAgui__agentNameClassName__.tsx.template +142 -0
- package/src/ts/react-website/agui/generator.d.ts +26 -0
- package/src/ts/react-website/agui/generator.js +98 -0
- package/src/ts/react-website/agui/generator.js.map +1 -0
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +49 -0
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/ts/strands-agent/__snapshots__/generator.spec.ts.snap +43 -12
- package/src/ts/strands-agent/files/deploy/Dockerfile.template +1 -1
- package/src/ts/strands-agent/generator.js +14 -1
- package/src/ts/strands-agent/generator.js.map +1 -1
- package/src/ts/strands-agent/schema.d.ts +1 -1
- package/src/ts/strands-agent/schema.json +2 -2
- package/src/utils/__snapshots__/shared-constructs.spec.ts.snap +24 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +3 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js +2 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +26 -11
- package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +13 -1
- package/src/utils/files/common/constructs/src/core/index.ts.template +2 -1
- package/src/utils/files/common/constructs/src/core/workspace.ts.template +19 -0
- package/src/utils/versions.d.ts +6 -1
- package/src/utils/versions.js +5 -0
- package/src/utils/versions.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/Dockerfile.template +0 -1
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<%_ if (auth === 'IAM') { _%>
|
|
2
|
+
import { HttpAgent } from '@ag-ui/client';
|
|
3
|
+
import type { AbstractAgent, RunAgentInput } from '@ag-ui/client';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { useRuntimeConfig } from './useRuntimeConfig';
|
|
7
|
+
import { useSigV4, type SigV4Client } from './useSigV4';
|
|
8
|
+
<%_ } else if (auth === 'Cognito') { _%>
|
|
9
|
+
import { HttpAgent } from '@ag-ui/client';
|
|
10
|
+
import type { AbstractAgent, RunAgentInput } from '@ag-ui/client';
|
|
11
|
+
import { useMemo } from 'react';
|
|
12
|
+
import { useAuth } from 'react-oidc-context';
|
|
13
|
+
import { useRuntimeConfig } from './useRuntimeConfig';
|
|
14
|
+
<%_ } else { _%>
|
|
15
|
+
import { HttpAgent } from '@ag-ui/client';
|
|
16
|
+
import type { AbstractAgent, RunAgentInput } from '@ag-ui/client';
|
|
17
|
+
import { useMemo } from 'react';
|
|
18
|
+
import { useRuntimeConfig } from './useRuntimeConfig';
|
|
19
|
+
<%_ } _%>
|
|
20
|
+
|
|
21
|
+
function buildAgentCoreUrl(agentRuntimeArn: string): string {
|
|
22
|
+
const region = agentRuntimeArn.split(':')[3];
|
|
23
|
+
return `https://bedrock-agentcore.${region}.amazonaws.com/runtimes/${encodeURIComponent(agentRuntimeArn)}/invocations?qualifier=DEFAULT`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// AgentCore session ids must be at least 33 characters.
|
|
27
|
+
function agentCoreSessionId(input: RunAgentInput): string {
|
|
28
|
+
return (input.threadId ?? '').padEnd(33, '0');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
<%_ if (auth === 'IAM') { _%>
|
|
32
|
+
class SigV4HttpAgent extends HttpAgent {
|
|
33
|
+
sigV4Client: SigV4Client;
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
config: ConstructorParameters<typeof HttpAgent>[0],
|
|
37
|
+
sigV4Client: SigV4Client,
|
|
38
|
+
) {
|
|
39
|
+
super(config);
|
|
40
|
+
this.sigV4Client = sigV4Client;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
protected override requestInit(input: RunAgentInput): RequestInit {
|
|
44
|
+
const init = super.requestInit(input);
|
|
45
|
+
init.headers = {
|
|
46
|
+
...(init.headers as Record<string, string>),
|
|
47
|
+
'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id': agentCoreSessionId(input),
|
|
48
|
+
};
|
|
49
|
+
return init;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Remove this override once https://github.com/ag-ui-protocol/ag-ui/issues/1316 is fixed.
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
+
override run(input: RunAgentInput): any {
|
|
55
|
+
const sigV4Fetch = this.sigV4Client.fetch as typeof window.fetch;
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
return new Observable<any>((subscriber) => {
|
|
58
|
+
const originalFetch = window.fetch;
|
|
59
|
+
window.fetch = sigV4Fetch;
|
|
60
|
+
const sub = super.run(input).subscribe(subscriber);
|
|
61
|
+
window.fetch = originalFetch;
|
|
62
|
+
return () => sub.unsubscribe();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override clone(): SigV4HttpAgent {
|
|
67
|
+
const cloned = super.clone() as SigV4HttpAgent;
|
|
68
|
+
cloned.sigV4Client = this.sigV4Client;
|
|
69
|
+
return cloned;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
<%_ } else if (auth === 'Cognito') { _%>
|
|
73
|
+
class CognitoHttpAgent extends HttpAgent {
|
|
74
|
+
getAccessToken: () => string | undefined;
|
|
75
|
+
|
|
76
|
+
constructor(
|
|
77
|
+
config: ConstructorParameters<typeof HttpAgent>[0],
|
|
78
|
+
getAccessToken: () => string | undefined,
|
|
79
|
+
) {
|
|
80
|
+
super(config);
|
|
81
|
+
this.getAccessToken = getAccessToken;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
protected override requestInit(input: RunAgentInput): RequestInit {
|
|
85
|
+
const init = super.requestInit(input);
|
|
86
|
+
const token = this.getAccessToken();
|
|
87
|
+
init.headers = {
|
|
88
|
+
...(init.headers as Record<string, string>),
|
|
89
|
+
'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id': agentCoreSessionId(input),
|
|
90
|
+
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
|
91
|
+
};
|
|
92
|
+
return init;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
override clone(): CognitoHttpAgent {
|
|
96
|
+
const cloned = super.clone() as CognitoHttpAgent;
|
|
97
|
+
cloned.getAccessToken = this.getAccessToken;
|
|
98
|
+
return cloned;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
<%_ } else { _%>
|
|
102
|
+
class AgentCoreHttpAgent extends HttpAgent {
|
|
103
|
+
protected override requestInit(input: RunAgentInput): RequestInit {
|
|
104
|
+
const init = super.requestInit(input);
|
|
105
|
+
init.headers = {
|
|
106
|
+
...(init.headers as Record<string, string>),
|
|
107
|
+
'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id': agentCoreSessionId(input),
|
|
108
|
+
};
|
|
109
|
+
return init;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
<%_ } _%>
|
|
113
|
+
|
|
114
|
+
export const useAgui<%= agentNameClassName %> = (): Record<string, AbstractAgent> => {
|
|
115
|
+
const runtimeConfig = useRuntimeConfig();
|
|
116
|
+
const agentRuntimeValue = runtimeConfig.agentRuntimes.<%= agentNameClassName %>;
|
|
117
|
+
<%_ if (auth === 'IAM') { _%>
|
|
118
|
+
const sigv4 = useSigV4();
|
|
119
|
+
<%_ } else if (auth === 'Cognito') { _%>
|
|
120
|
+
const auth = useAuth();
|
|
121
|
+
<%_ } _%>
|
|
122
|
+
|
|
123
|
+
const url = useMemo(
|
|
124
|
+
() =>
|
|
125
|
+
agentRuntimeValue.startsWith('arn:')
|
|
126
|
+
? buildAgentCoreUrl(agentRuntimeValue)
|
|
127
|
+
: agentRuntimeValue,
|
|
128
|
+
[agentRuntimeValue],
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
return useMemo((): Record<string, AbstractAgent> => {
|
|
132
|
+
<%_ if (auth === 'IAM') { _%>
|
|
133
|
+
const agent = new SigV4HttpAgent({ url }, sigv4);
|
|
134
|
+
<%_ } else if (auth === 'Cognito') { _%>
|
|
135
|
+
const agent = new CognitoHttpAgent({ url }, () => auth.user?.access_token);
|
|
136
|
+
<%_ } else { _%>
|
|
137
|
+
const agent = new AgentCoreHttpAgent({ url });
|
|
138
|
+
<%_ } _%>
|
|
139
|
+
|
|
140
|
+
return { '<%= agentName %>': agent };
|
|
141
|
+
}, [url<% if (auth === 'IAM') { %>, sigv4<% } else if (auth === 'Cognito') { %>, auth<% } %>]);
|
|
142
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { ProjectConfiguration, Tree } from '@nx/devkit';
|
|
6
|
+
export type AgUiAuth = 'IAM' | 'Cognito' | 'None';
|
|
7
|
+
export interface AgUiReactConnectionOptions {
|
|
8
|
+
/** The React website project to connect FROM */
|
|
9
|
+
frontendProjectConfig: ProjectConfiguration;
|
|
10
|
+
/** The AG-UI agent's exposed name (used as CopilotKit's agent key) */
|
|
11
|
+
agentName: string;
|
|
12
|
+
/** PascalCase class name used for component names and runtime config keys */
|
|
13
|
+
agentNameClassName: string;
|
|
14
|
+
/** Auth scheme used by the agent */
|
|
15
|
+
auth: AgUiAuth;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wires a React website up to an AG-UI agent using CopilotKit and
|
|
19
|
+
* @ag-ui/client's HttpAgent. Agent-server-language agnostic.
|
|
20
|
+
*
|
|
21
|
+
* On first invocation creates a shared `AguiProvider` component (with an empty
|
|
22
|
+
* `selfManagedAgents` registry) and wraps `<App />` in it. Each invocation
|
|
23
|
+
* AST-patches `AguiProvider` to register one more agent hook — running the
|
|
24
|
+
* generator multiple times is idempotent and additive.
|
|
25
|
+
*/
|
|
26
|
+
export declare const addAgUiReactConnection: (tree: Tree, options: AgUiReactConnectionOptions) => Promise<void>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addAgUiReactConnection = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const generator_1 = require("../runtime-config/generator");
|
|
10
|
+
const versions_1 = require("../../../utils/versions");
|
|
11
|
+
const ast_1 = require("../../../utils/ast");
|
|
12
|
+
const agent_runtime_config_1 = require("../../../connection/agent-runtime-config");
|
|
13
|
+
const names_1 = require("../../../utils/names");
|
|
14
|
+
/**
|
|
15
|
+
* Wires a React website up to an AG-UI agent using CopilotKit and
|
|
16
|
+
* @ag-ui/client's HttpAgent. Agent-server-language agnostic.
|
|
17
|
+
*
|
|
18
|
+
* On first invocation creates a shared `AguiProvider` component (with an empty
|
|
19
|
+
* `selfManagedAgents` registry) and wraps `<App />` in it. Each invocation
|
|
20
|
+
* AST-patches `AguiProvider` to register one more agent hook — running the
|
|
21
|
+
* generator multiple times is idempotent and additive.
|
|
22
|
+
*/
|
|
23
|
+
const addAgUiReactConnection = async (tree, options) => {
|
|
24
|
+
const { frontendProjectConfig, agentName, agentNameClassName, auth } = options;
|
|
25
|
+
// Generates `src/components/AguiProvider.tsx` (if absent) and
|
|
26
|
+
// `src/hooks/useAgui<AgentName>.tsx`. Existing files are kept so re-running
|
|
27
|
+
// the generator is idempotent.
|
|
28
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files'), frontendProjectConfig.root, { agentName, agentNameClassName, auth }, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
29
|
+
if (auth === 'IAM') {
|
|
30
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '../../../utils/files/website/hooks/sigv4'), (0, devkit_1.joinPathFragments)(frontendProjectConfig.sourceRoot, 'hooks'), {}, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
31
|
+
}
|
|
32
|
+
await (0, generator_1.runtimeConfigGenerator)(tree, {
|
|
33
|
+
project: frontendProjectConfig.name,
|
|
34
|
+
});
|
|
35
|
+
// AST-patch AguiProvider to register this agent's hook
|
|
36
|
+
await registerAgentHookInProvider(tree, frontendProjectConfig, agentNameClassName);
|
|
37
|
+
// Wrap <App /> in <AguiProvider> in main.tsx (idempotent)
|
|
38
|
+
const mainTsxPath = (0, devkit_1.joinPathFragments)(frontendProjectConfig.sourceRoot, 'main.tsx');
|
|
39
|
+
await (0, ast_1.addSingleImport)(tree, mainTsxPath, 'AguiProvider', './components/AguiProvider');
|
|
40
|
+
await (0, ast_1.applyGritQL)(tree, mainTsxPath, `\`<App />\` => \`<AguiProvider><App /></AguiProvider>\` where { $program <: not contains \`<AguiProvider>$_</AguiProvider>\` }`);
|
|
41
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)([
|
|
42
|
+
'@copilotkit/react-core',
|
|
43
|
+
'@ag-ui/client',
|
|
44
|
+
...(auth === 'IAM'
|
|
45
|
+
? [
|
|
46
|
+
'oidc-client-ts',
|
|
47
|
+
'aws4fetch',
|
|
48
|
+
'@aws-sdk/credential-providers',
|
|
49
|
+
'react-oidc-context',
|
|
50
|
+
'rxjs',
|
|
51
|
+
]
|
|
52
|
+
: []),
|
|
53
|
+
...(auth === 'Cognito' ? ['react-oidc-context'] : []),
|
|
54
|
+
]), (0, versions_1.withVersions)([...(auth === 'IAM' ? ['@smithy/types'] : [])]));
|
|
55
|
+
// Agents only publish their runtime ARN to the 'agentcore' namespace by
|
|
56
|
+
// default, which isn't exposed to the website. Patch the agent's CDK/TF
|
|
57
|
+
// construct to also publish under 'connection' so the browser can read it
|
|
58
|
+
// from runtime-config.json.
|
|
59
|
+
await (0, agent_runtime_config_1.addAgentRuntimeToConnectionNamespace)(tree, {
|
|
60
|
+
agentNameKebabCase: (0, names_1.kebabCase)(agentNameClassName),
|
|
61
|
+
agentNameClassName,
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
exports.addAgUiReactConnection = addAgUiReactConnection;
|
|
65
|
+
/**
|
|
66
|
+
* Register this agent's hook in the shared `AguiProvider` using GritQL AST
|
|
67
|
+
* patches. The provider starts out with an empty `selfManagedAgents` registry
|
|
68
|
+
* (from the template); each call appends:
|
|
69
|
+
* - `import { useAgui<Name> } from '../hooks/useAgui<Name>';`
|
|
70
|
+
* - `const <varName> = useAgui<Name>();` before the `useMemo` call
|
|
71
|
+
* - `...<varName>` into the memoised object literal
|
|
72
|
+
* - `<varName>` into the `useMemo` deps array
|
|
73
|
+
*
|
|
74
|
+
* All steps are guarded so re-running produces byte-identical output.
|
|
75
|
+
*/
|
|
76
|
+
const registerAgentHookInProvider = async (tree, frontendProjectConfig, agentNameClassName) => {
|
|
77
|
+
const providerPath = (0, devkit_1.joinPathFragments)(frontendProjectConfig.sourceRoot, 'components', 'AguiProvider.tsx');
|
|
78
|
+
const hookName = `useAgui${agentNameClassName}`;
|
|
79
|
+
// useAguiStoryAgent -> storyAgentAgents
|
|
80
|
+
const varName = `${agentNameClassName.charAt(0).toLowerCase()}${agentNameClassName.slice(1)}Agents`;
|
|
81
|
+
// 1. Add the hook import
|
|
82
|
+
await (0, ast_1.addDestructuredImport)(tree, providerPath, [hookName], `../hooks/${hookName}`);
|
|
83
|
+
// 2. Insert `const <varName> = <hookName>();` before the useMemo declaration
|
|
84
|
+
await (0, ast_1.applyGritQL)(tree, providerPath, `\`const selfManagedAgents = useMemo<Record<string, AbstractAgent>>($body, $deps);\` => ` +
|
|
85
|
+
`\`const ${varName} = ${hookName}();\nconst selfManagedAgents = useMemo<Record<string, AbstractAgent>>($body, $deps);\` ` +
|
|
86
|
+
`where { $program <: not contains \`const ${varName} = ${hookName}()\` }`);
|
|
87
|
+
// 3. Spread `...<varName>` into the memoised object and add `<varName>` to
|
|
88
|
+
// the deps array. Branches on `{}`/`[]` vs populated so both the
|
|
89
|
+
// first-agent and nth-agent cases produce clean output.
|
|
90
|
+
await (0, ast_1.applyGritQL)(tree, providerPath, `\`useMemo<Record<string, AbstractAgent>>(() => ($obj), $deps)\` where {` +
|
|
91
|
+
` $obj <: not contains \`...${varName}\`,` +
|
|
92
|
+
` if ($obj <: \`{}\`) { $obj => \`{ ...${varName} }\` }` +
|
|
93
|
+
` else { $obj <: \`{$items}\` where { $items += \`, ...${varName}\` } },` +
|
|
94
|
+
` if ($deps <: \`[]\`) { $deps => \`[${varName}]\` }` +
|
|
95
|
+
` else { $deps <: \`[$dd]\` where { $dd += \`, ${varName}\` } }` +
|
|
96
|
+
` }`);
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/agui/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAOoB;AACpB,2DAAqE;AACrE,sDAAuD;AACvD,4CAI4B;AAC5B,mFAAgG;AAChG,gDAAiD;AAejD;;;;;;;;GAQG;AACI,MAAM,sBAAsB,GAAG,KAAK,EACzC,IAAU,EACV,OAAmC,EACnC,EAAE;IACF,MAAM,EAAE,qBAAqB,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAClE,OAAO,CAAC;IAEV,8DAA8D;IAC9D,4EAA4E;IAC5E,+BAA+B;IAC/B,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,OAAO,CAAC,EACrC,qBAAqB,CAAC,IAAI,EAC1B,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAI,EAAE,EACvC,EAAE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY,EAAE,CACtD,CAAC;IAEF,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,0CAA0C,CAAC,EACx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AAE,IAAA,iBAAS,EAAC,kBAAkB,CAAC;QACjD,kBAAkB;KACnB,CAAC,CAAC;AACL,CAAC,CAAC;AAnFW,QAAA,sBAAsB,0BAmFjC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,2BAA2B,GAAG,KAAK,EACvC,IAAU,EACV,qBAA2C,EAC3C,kBAA0B,EAC1B,EAAE;IACF,MAAM,YAAY,GAAG,IAAA,0BAAiB,EACpC,qBAAqB,CAAC,UAAU,EAChC,YAAY,EACZ,kBAAkB,CACnB,CAAC;IACF,MAAM,QAAQ,GAAG,UAAU,kBAAkB,EAAE,CAAC;IAChD,wCAAwC;IACxC,MAAM,OAAO,GAAG,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC;IAEpG,yBAAyB;IACzB,MAAM,IAAA,2BAAqB,EACzB,IAAI,EACJ,YAAY,EACZ,CAAC,QAAQ,CAAC,EACV,YAAY,QAAQ,EAAE,CACvB,CAAC;IAEF,6EAA6E;IAC7E,MAAM,IAAA,iBAAW,EACf,IAAI,EACJ,YAAY,EACZ,yFAAyF;QACvF,WAAW,OAAO,MAAM,QAAQ,yFAAyF;QACzH,4CAA4C,OAAO,MAAM,QAAQ,QAAQ,CAC5E,CAAC;IAEF,2EAA2E;IAC3E,oEAAoE;IACpE,2DAA2D;IAC3D,MAAM,IAAA,iBAAW,EACf,IAAI,EACJ,YAAY,EACZ,yEAAyE;QACvE,8BAA8B,OAAO,KAAK;QAC1C,yCAAyC,OAAO,QAAQ;QACxD,yDAAyD,OAAO,SAAS;QACzE,uCAAuC,OAAO,OAAO;QACrD,iDAAiD,OAAO,QAAQ;QAChE,IAAI,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1329,6 +1329,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1329
1329
|
export * from './app.js';
|
|
1330
1330
|
export * from './checkov.js';
|
|
1331
1331
|
export * from './runtime-config.js';
|
|
1332
|
+
export * from './workspace.js';
|
|
1332
1333
|
"
|
|
1333
1334
|
`;
|
|
1334
1335
|
|
|
@@ -1770,6 +1771,29 @@ export class CloudfrontWebAcl extends Stack {
|
|
|
1770
1771
|
"
|
|
1771
1772
|
`;
|
|
1772
1773
|
|
|
1774
|
+
exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/src/core/workspace.ts 1`] = `
|
|
1775
|
+
"import * as fs from 'fs';
|
|
1776
|
+
import * as path from 'path';
|
|
1777
|
+
|
|
1778
|
+
/**
|
|
1779
|
+
* Find the workspace root by walking up from the given file path
|
|
1780
|
+
* until we find nx.json (the marker for an Nx workspace root).
|
|
1781
|
+
*/
|
|
1782
|
+
export const findWorkspaceRoot = (startPath: string): string => {
|
|
1783
|
+
let dir = fs.statSync(startPath).isDirectory()
|
|
1784
|
+
? startPath
|
|
1785
|
+
: path.dirname(startPath);
|
|
1786
|
+
while (dir !== path.dirname(dir)) {
|
|
1787
|
+
if (fs.existsSync(path.join(dir, 'nx.json'))) {
|
|
1788
|
+
return dir;
|
|
1789
|
+
}
|
|
1790
|
+
dir = path.dirname(dir);
|
|
1791
|
+
}
|
|
1792
|
+
throw new Error(\`Could not find workspace root (nx.json) from \${startPath}\`);
|
|
1793
|
+
};
|
|
1794
|
+
"
|
|
1795
|
+
`;
|
|
1796
|
+
|
|
1773
1797
|
exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/src/index.ts 1`] = `
|
|
1774
1798
|
"export * from './app/index.js';
|
|
1775
1799
|
export * from './core/index.js';
|
|
@@ -2925,6 +2949,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2925
2949
|
export * from './app.js';
|
|
2926
2950
|
export * from './checkov.js';
|
|
2927
2951
|
export * from './runtime-config.js';
|
|
2952
|
+
export * from './workspace.js';
|
|
2928
2953
|
"
|
|
2929
2954
|
`;
|
|
2930
2955
|
|
|
@@ -3366,6 +3391,29 @@ export class CloudfrontWebAcl extends Stack {
|
|
|
3366
3391
|
"
|
|
3367
3392
|
`;
|
|
3368
3393
|
|
|
3394
|
+
exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/src/core/workspace.ts 1`] = `
|
|
3395
|
+
"import * as fs from 'fs';
|
|
3396
|
+
import * as path from 'path';
|
|
3397
|
+
|
|
3398
|
+
/**
|
|
3399
|
+
* Find the workspace root by walking up from the given file path
|
|
3400
|
+
* until we find nx.json (the marker for an Nx workspace root).
|
|
3401
|
+
*/
|
|
3402
|
+
export const findWorkspaceRoot = (startPath: string): string => {
|
|
3403
|
+
let dir = fs.statSync(startPath).isDirectory()
|
|
3404
|
+
? startPath
|
|
3405
|
+
: path.dirname(startPath);
|
|
3406
|
+
while (dir !== path.dirname(dir)) {
|
|
3407
|
+
if (fs.existsSync(path.join(dir, 'nx.json'))) {
|
|
3408
|
+
return dir;
|
|
3409
|
+
}
|
|
3410
|
+
dir = path.dirname(dir);
|
|
3411
|
+
}
|
|
3412
|
+
throw new Error(\`Could not find workspace root (nx.json) from \${startPath}\`);
|
|
3413
|
+
};
|
|
3414
|
+
"
|
|
3415
|
+
`;
|
|
3416
|
+
|
|
3369
3417
|
exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/src/index.ts 1`] = `
|
|
3370
3418
|
"export * from './app/index.js';
|
|
3371
3419
|
export * from './core/index.js';
|
|
@@ -4588,6 +4636,7 @@ exports[`react-website generator > should generate shared constructs > common/co
|
|
|
4588
4636
|
export * from './app.js';
|
|
4589
4637
|
export * from './checkov.js';
|
|
4590
4638
|
export * from './runtime-config.js';
|
|
4639
|
+
export * from './workspace.js';
|
|
4591
4640
|
"
|
|
4592
4641
|
`;
|
|
4593
4642
|
|
|
@@ -81,6 +81,7 @@ exports[`cognito-auth generator > should generate files > identity-index 1`] = `
|
|
|
81
81
|
export * from './app.js';
|
|
82
82
|
export * from './checkov.js';
|
|
83
83
|
export * from './runtime-config.js';
|
|
84
|
+
export * from './workspace.js';
|
|
84
85
|
"
|
|
85
86
|
`;
|
|
86
87
|
|
|
@@ -295,5 +296,6 @@ exports[`cognito-auth generator > should update shared constructs index.ts > com
|
|
|
295
296
|
export * from './app.js';
|
|
296
297
|
export * from './checkov.js';
|
|
297
298
|
export * from './runtime-config.js';
|
|
299
|
+
export * from './workspace.js';
|
|
298
300
|
"
|
|
299
301
|
`;
|
|
@@ -10,7 +10,7 @@ WORKDIR /app
|
|
|
10
10
|
RUN npm install @aws/aws-distro-opentelemetry-node-autoinstrumentation@0.10.0
|
|
11
11
|
|
|
12
12
|
# Copy bundled agent
|
|
13
|
-
COPY
|
|
13
|
+
COPY index.js /app
|
|
14
14
|
|
|
15
15
|
EXPOSE 8080
|
|
16
16
|
|
|
@@ -24,7 +24,6 @@ exports[`ts#strands-agent generator > should match snapshot for BedrockAgentCore
|
|
|
24
24
|
"import { Lazy, Names } from 'aws-cdk-lib';
|
|
25
25
|
import { Platform } from 'aws-cdk-lib/aws-ecr-assets';
|
|
26
26
|
import { Construct } from 'constructs';
|
|
27
|
-
import { execSync } from 'child_process';
|
|
28
27
|
import * as path from 'path';
|
|
29
28
|
import * as url from 'url';
|
|
30
29
|
import {
|
|
@@ -33,8 +32,14 @@ import {
|
|
|
33
32
|
Runtime,
|
|
34
33
|
RuntimeProps,
|
|
35
34
|
} from '@aws-cdk/aws-bedrock-agentcore-alpha';
|
|
36
|
-
import {
|
|
35
|
+
import {
|
|
36
|
+
PolicyStatement,
|
|
37
|
+
IGrantable,
|
|
38
|
+
IPrincipal,
|
|
39
|
+
Grant,
|
|
40
|
+
} from 'aws-cdk-lib/aws-iam';
|
|
37
41
|
import { RuntimeConfig } from '../../../core/runtime-config.js';
|
|
42
|
+
import { findWorkspaceRoot } from '../../../core/workspace.js';
|
|
38
43
|
|
|
39
44
|
export type SnapshotBedrockAgentProps = Omit<
|
|
40
45
|
RuntimeProps,
|
|
@@ -53,17 +58,16 @@ export class SnapshotBedrockAgent extends Construct implements IGrantable {
|
|
|
53
58
|
|
|
54
59
|
const rc = RuntimeConfig.ensure(this);
|
|
55
60
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
extraHash: execSync(
|
|
61
|
-
\`docker inspect proj-snapshot-bedrock-agent:latest --format '{{.Id}}'\`,
|
|
62
|
-
{ encoding: 'utf-8' },
|
|
63
|
-
).trim(),
|
|
64
|
-
},
|
|
61
|
+
// Resolve the bundle output directory containing the Dockerfile and built artifacts
|
|
62
|
+
const bundleDir = path.join(
|
|
63
|
+
findWorkspaceRoot(url.fileURLToPath(new URL(import.meta.url))),
|
|
64
|
+
'dist/apps/test-project/bundle/agent/snapshot-bedrock-agent',
|
|
65
65
|
);
|
|
66
66
|
|
|
67
|
+
this.dockerImage = AgentRuntimeArtifact.fromAsset(bundleDir, {
|
|
68
|
+
platform: Platform.LINUX_ARM64,
|
|
69
|
+
});
|
|
70
|
+
|
|
67
71
|
this.agentCoreRuntime = new Runtime(this, 'SnapshotBedrockAgent', {
|
|
68
72
|
runtimeName: Lazy.string({
|
|
69
73
|
produce: () =>
|
|
@@ -78,6 +82,20 @@ export class SnapshotBedrockAgent extends Construct implements IGrantable {
|
|
|
78
82
|
},
|
|
79
83
|
});
|
|
80
84
|
|
|
85
|
+
// Grant access for the agent to invoke bedrock models
|
|
86
|
+
this.agentCoreRuntime.addToRolePolicy(
|
|
87
|
+
new PolicyStatement({
|
|
88
|
+
actions: [
|
|
89
|
+
'bedrock:InvokeModel',
|
|
90
|
+
'bedrock:InvokeModelWithResponseStream',
|
|
91
|
+
],
|
|
92
|
+
resources: [
|
|
93
|
+
'arn:aws:bedrock:*:*:foundation-model/*',
|
|
94
|
+
'arn:aws:bedrock:*:*:inference-profile/*',
|
|
95
|
+
],
|
|
96
|
+
}),
|
|
97
|
+
);
|
|
98
|
+
|
|
81
99
|
rc.grantReadAppConfig(this.agentCoreRuntime);
|
|
82
100
|
|
|
83
101
|
rc.set('agentcore', 'agentRuntimes', {
|
|
@@ -128,6 +146,7 @@ exports[`ts#strands-agent generator > should match snapshot for BedrockAgentCore
|
|
|
128
146
|
"export * from './app.js';
|
|
129
147
|
export * from './checkov.js';
|
|
130
148
|
export * from './runtime-config.js';
|
|
149
|
+
export * from './workspace.js';
|
|
131
150
|
"
|
|
132
151
|
`;
|
|
133
152
|
|
|
@@ -177,6 +196,18 @@ module "agent_core_runtime" {
|
|
|
177
196
|
"appconfig:GetLatestConfiguration"
|
|
178
197
|
]
|
|
179
198
|
Resource = ["\${module.appconfig.application_arn}/*"]
|
|
199
|
+
},
|
|
200
|
+
# Grant access for the agent to invoke bedrock models
|
|
201
|
+
{
|
|
202
|
+
Effect = "Allow"
|
|
203
|
+
Action = [
|
|
204
|
+
"bedrock:InvokeModel",
|
|
205
|
+
"bedrock:InvokeModelWithResponseStream"
|
|
206
|
+
]
|
|
207
|
+
Resource = [
|
|
208
|
+
"arn:aws:bedrock:*:*:foundation-model/*",
|
|
209
|
+
"arn:aws:bedrock:*:*:inference-profile/*"
|
|
210
|
+
]
|
|
180
211
|
}
|
|
181
212
|
], var.additional_iam_policy_statements)
|
|
182
213
|
tags = var.tags
|
|
@@ -7,7 +7,7 @@ WORKDIR /app
|
|
|
7
7
|
RUN npm install @aws/aws-distro-opentelemetry-node-autoinstrumentation@<%- adotVersion %>
|
|
8
8
|
|
|
9
9
|
# Copy bundled agent
|
|
10
|
-
COPY
|
|
10
|
+
COPY index.js /app
|
|
11
11
|
|
|
12
12
|
<%_ if (protocol === 'A2A') { _%>
|
|
13
13
|
EXPOSE 9000
|
|
@@ -17,6 +17,7 @@ const iac_1 = require("../../utils/iac");
|
|
|
17
17
|
const shared_constructs_1 = require("../../utils/shared-constructs");
|
|
18
18
|
const agent_core_constructs_1 = require("../../utils/agent-core-constructs/agent-core-constructs");
|
|
19
19
|
const port_1 = require("../../utils/port");
|
|
20
|
+
const fs_1 = require("../../utils/fs");
|
|
20
21
|
exports.TS_STRANDS_AGENT_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
21
22
|
const tsStrandsAgentGenerator = async (tree, options) => {
|
|
22
23
|
const project = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.project);
|
|
@@ -34,6 +35,11 @@ const tsStrandsAgentGenerator = async (tree, options) => {
|
|
|
34
35
|
const computeType = options.computeType ?? 'BedrockAgentCoreRuntime';
|
|
35
36
|
const auth = options.auth ?? 'IAM';
|
|
36
37
|
const protocol = options.protocol ?? 'HTTP';
|
|
38
|
+
if (protocol === 'AG-UI') {
|
|
39
|
+
throw new Error(`The AG-UI protocol is not yet supported for TypeScript Strands Agents. ` +
|
|
40
|
+
`Use a Python Strands Agent with protocol='AG-UI' instead, or choose 'HTTP' or 'A2A' for TypeScript. ` +
|
|
41
|
+
`Track TypeScript support at https://github.com/strands-agents/sdk-typescript/issues/347`);
|
|
42
|
+
}
|
|
37
43
|
const templateContext = {
|
|
38
44
|
name,
|
|
39
45
|
agentNameClassName,
|
|
@@ -57,12 +63,18 @@ const tsStrandsAgentGenerator = async (tree, options) => {
|
|
|
57
63
|
protocol,
|
|
58
64
|
adotVersion: versions_1.TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'],
|
|
59
65
|
}, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
66
|
+
const dockerOutputDir = (0, devkit_1.joinPathFragments)('dist', project.root, 'bundle', 'agent', name);
|
|
60
67
|
const dockerTargetName = `${agentTargetPrefix}-docker`;
|
|
68
|
+
const fs = new fs_1.FsCommands(tree);
|
|
61
69
|
project.targets[dockerTargetName] = {
|
|
62
70
|
cache: true,
|
|
63
71
|
executor: 'nx:run-commands',
|
|
64
72
|
options: {
|
|
65
|
-
|
|
73
|
+
commands: [
|
|
74
|
+
fs.cp(`${targetSourceDir}/Dockerfile`, `${dockerOutputDir}/Dockerfile`),
|
|
75
|
+
`docker build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,
|
|
76
|
+
],
|
|
77
|
+
parallel: false,
|
|
66
78
|
},
|
|
67
79
|
dependsOn: ['bundle'],
|
|
68
80
|
};
|
|
@@ -76,6 +88,7 @@ const tsStrandsAgentGenerator = async (tree, options) => {
|
|
|
76
88
|
agentNameClassName,
|
|
77
89
|
projectName: project.name,
|
|
78
90
|
dockerImageTag,
|
|
91
|
+
dockerOutputDir,
|
|
79
92
|
iacProvider,
|
|
80
93
|
auth,
|
|
81
94
|
serverProtocol: protocol,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/strands-agent/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCASoB;AAEpB,uCAMwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,6CAA2D;AAC3D,mDAAiE;AACjE,qDAAoD;AACpD,sDAAsE;AACtE,yCAAqD;AACrD,qEAA0E;AAC1E,mGAAwF;AAExF,2CAA8C;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/strands-agent/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCASoB;AAEpB,uCAMwB;AACxB,iDAAsE;AACtE,+CAA0D;AAC1D,6CAA2D;AAC3D,mDAAiE;AACjE,qDAAoD;AACpD,sDAAsE;AACtE,yCAAqD;AACrD,qEAA0E;AAC1E,mGAAwF;AAExF,2CAA8C;AAC9C,uCAA4C;AAE/B,QAAA,+BAA+B,GAC1C,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,uBAAuB,GAAG,KAAK,EAC1C,IAAU,EACV,OAAsC,EACV,EAAE;IAC9B,MAAM,OAAO,GAAG,IAAA,wCAAmC,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAE3E,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAA,0BAAiB,EAAC,OAAO,CAAC,IAAI,EAAE,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CAA+B,EAC/B,oCAAoC,EACpC,iBAAiB,EACjB,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,QAAQ,EAAE,CAC/D,CAAC;IAEF,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE;QAC1C,uCAA+B;KAChC,CAAC,CAAC;IAEH,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE;QACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC,CAAC;AArNW,QAAA,uBAAuB,2BAqNlC;AAEF,kBAAe,+BAAuB,CAAC"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { IacProviderOption } from '../../utils/iac';
|
|
7
7
|
|
|
8
8
|
export type TsStrandsAgentComputeType = 'BedrockAgentCoreRuntime' | 'None';
|
|
9
|
-
export type StrandsAgentProtocol = 'HTTP' | 'A2A';
|
|
9
|
+
export type StrandsAgentProtocol = 'HTTP' | 'A2A' | 'AG-UI';
|
|
10
10
|
|
|
11
11
|
export type TsStrandsAgentAuth = 'IAM' | 'Cognito';
|
|
12
12
|
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
},
|
|
39
39
|
"protocol": {
|
|
40
40
|
"type": "string",
|
|
41
|
-
"description": "The server protocol for your Strands Agent. HTTP exposes a tRPC/WebSocket server. A2A exposes an Agent-to-Agent protocol server.",
|
|
41
|
+
"description": "The server protocol for your Strands Agent. HTTP exposes a tRPC/WebSocket server. A2A exposes an Agent-to-Agent protocol server. AG-UI is not yet supported for TypeScript agents.",
|
|
42
42
|
"x-prompt": "Which protocol would you like to use for your Strands Agent?",
|
|
43
|
-
"enum": ["HTTP", "A2A"],
|
|
43
|
+
"enum": ["HTTP", "A2A", "AG-UI"],
|
|
44
44
|
"default": "HTTP",
|
|
45
45
|
"x-priority": "important"
|
|
46
46
|
},
|
|
@@ -83,6 +83,7 @@ exports[`shared-constructs utils > sharedConstructsGenerator > should generate s
|
|
|
83
83
|
"export * from './app.js';
|
|
84
84
|
export * from './checkov.js';
|
|
85
85
|
export * from './runtime-config.js';
|
|
86
|
+
export * from './workspace.js';
|
|
86
87
|
"
|
|
87
88
|
`;
|
|
88
89
|
|
|
@@ -272,6 +273,29 @@ export class RuntimeConfig extends Construct {
|
|
|
272
273
|
"
|
|
273
274
|
`;
|
|
274
275
|
|
|
276
|
+
exports[`shared-constructs utils > sharedConstructsGenerator > should generate shared constructs when they do not exist > packages/common/constructs/src/core/workspace.ts 1`] = `
|
|
277
|
+
"import * as fs from 'fs';
|
|
278
|
+
import * as path from 'path';
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Find the workspace root by walking up from the given file path
|
|
282
|
+
* until we find nx.json (the marker for an Nx workspace root).
|
|
283
|
+
*/
|
|
284
|
+
export const findWorkspaceRoot = (startPath: string): string => {
|
|
285
|
+
let dir = fs.statSync(startPath).isDirectory()
|
|
286
|
+
? startPath
|
|
287
|
+
: path.dirname(startPath);
|
|
288
|
+
while (dir !== path.dirname(dir)) {
|
|
289
|
+
if (fs.existsSync(path.join(dir, 'nx.json'))) {
|
|
290
|
+
return dir;
|
|
291
|
+
}
|
|
292
|
+
dir = path.dirname(dir);
|
|
293
|
+
}
|
|
294
|
+
throw new Error(\`Could not find workspace root (nx.json) from \${startPath}\`);
|
|
295
|
+
};
|
|
296
|
+
"
|
|
297
|
+
`;
|
|
298
|
+
|
|
275
299
|
exports[`shared-constructs utils > sharedConstructsGenerator > should generate shared constructs when they do not exist > packages/common/constructs/src/index.ts 1`] = `
|
|
276
300
|
"export * from './app/index.js';
|
|
277
301
|
export * from './core/index.js';
|
|
@@ -13,6 +13,7 @@ export interface AddAgentCoreInfraProps {
|
|
|
13
13
|
nameKebabCase: string;
|
|
14
14
|
projectName: string;
|
|
15
15
|
dockerImageTag: string;
|
|
16
|
+
dockerOutputDir: string;
|
|
16
17
|
appDirectory: string;
|
|
17
18
|
serverProtocol: 'MCP' | 'HTTP' | 'A2A';
|
|
18
19
|
auth: AgentCoreAuth;
|
|
@@ -22,6 +23,7 @@ export interface AddMcpServerInfraProps {
|
|
|
22
23
|
mcpServerNameKebabCase: string;
|
|
23
24
|
projectName: string;
|
|
24
25
|
dockerImageTag: string;
|
|
26
|
+
dockerOutputDir: string;
|
|
25
27
|
auth: AgentCoreAuth;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
@@ -33,6 +35,7 @@ export interface AddAgentInfraProps {
|
|
|
33
35
|
agentNameKebabCase: string;
|
|
34
36
|
projectName: string;
|
|
35
37
|
dockerImageTag: string;
|
|
38
|
+
dockerOutputDir: string;
|
|
36
39
|
auth: AgentCoreAuth;
|
|
37
40
|
serverProtocol?: 'HTTP' | 'A2A';
|
|
38
41
|
}
|