@aws/nx-plugin 1.0.0-rc.54 → 1.0.0-rc.55
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/migrations.json +45 -0
- package/package.json +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.js +3 -1
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/generator.d.ts +49 -1
- package/src/agentcore-gateway/generator.js +55 -22
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.js +3 -1
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/infra/app/generator.d.ts +43 -0
- package/src/infra/app/generator.js +47 -18
- package/src/infra/app/generator.js.map +1 -1
- package/src/init/generator.d.ts +13 -0
- package/src/init/generator.js +14 -3
- package/src/init/generator.js.map +1 -1
- package/src/migrations/latest/backfill-generator-metadata/migration.d.ts +96 -0
- package/src/migrations/latest/backfill-generator-metadata/migration.js +670 -0
- package/src/migrations/latest/backfill-generator-metadata/migration.js.map +1 -0
- package/src/preset/generator.d.ts +13 -0
- package/src/preset/generator.js +12 -3
- package/src/preset/generator.js.map +1 -1
- package/src/py/agent/a2a-connection/generator.d.ts +24 -0
- package/src/py/agent/a2a-connection/generator.js +49 -20
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +23 -0
- package/src/py/agent/gateway-connection/generator.js +45 -11
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/generator.d.ts +146 -1
- package/src/py/agent/generator.js +173 -76
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +23 -0
- package/src/py/agent/mcp-connection/generator.js +45 -11
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/generator.d.ts +146 -0
- package/src/py/agent/react-connection/generator.js +27 -4
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/dynamodb/agent-connection/generator.js +7 -1
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/py/dynamodb/fast-api-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/py/dynamodb/fast-api-connection/generator.js +3 -1
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
- package/src/py/dynamodb/generator.d.ts +29 -0
- package/src/py/dynamodb/generator.js +32 -12
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/dynamodb/mcp-server-connection/generator.js +7 -1
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/fast-api/generator.d.ts +63 -0
- package/src/py/fast-api/generator.js +58 -23
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.d.ts +16 -1
- package/src/py/fast-api/react/generator.js +15 -3
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/lambda-function/generator.d.ts +21 -0
- package/src/py/lambda-function/generator.js +29 -10
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/mcp-server/generator.d.ts +60 -0
- package/src/py/mcp-server/generator.js +62 -25
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/project/generator.d.ts +13 -0
- package/src/py/project/generator.js +29 -10
- package/src/py/project/generator.js.map +1 -1
- package/src/py/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +19 -0
- package/src/py/rdb/agent-connection/generator.js +7 -1
- package/src/py/rdb/agent-connection/generator.js.map +1 -1
- package/src/py/rdb/fast-api-connection/__snapshots__/generator.spec.ts.snap +7 -0
- package/src/py/rdb/fast-api-connection/generator.js +3 -1
- package/src/py/rdb/fast-api-connection/generator.js.map +1 -1
- package/src/py/rdb/generator.d.ts +89 -0
- package/src/py/rdb/generator.js +88 -40
- package/src/py/rdb/generator.js.map +1 -1
- package/src/py/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/py/rdb/mcp-server-connection/generator.js +7 -1
- package/src/py/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/smithy/project/generator.d.ts +7 -0
- package/src/smithy/project/generator.js +8 -2
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/generator.d.ts +15 -0
- package/src/smithy/react-connection/generator.js +17 -3
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/smithy/ts/api/generator.d.ts +79 -0
- package/src/smithy/ts/api/generator.js +77 -33
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/terraform/project/generator.d.ts +50 -0
- package/src/terraform/project/generator.js +63 -17
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/backend/generator.d.ts +84 -0
- package/src/trpc/backend/generator.js +98 -38
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/react/generator.d.ts +37 -0
- package/src/trpc/react/generator.js +63 -26
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/generator.d.ts +46 -0
- package/src/ts/agent/a2a-connection/generator.js +53 -16
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +37 -0
- package/src/ts/agent/gateway-connection/generator.js +41 -14
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.d.ts +162 -0
- package/src/ts/agent/generator.js +166 -75
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +37 -0
- package/src/ts/agent/mcp-connection/generator.js +41 -14
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +186 -0
- package/src/ts/agent/react-connection/generator.js +70 -21
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/astro-docs/generator.d.ts +38 -0
- package/src/ts/astro-docs/generator.js +58 -19
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +24 -0
- package/src/ts/dcr-proxy/generator.js +31 -14
- package/src/ts/dcr-proxy/generator.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/ts/dynamodb/agent-connection/generator.js +7 -1
- package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/generator.d.ts +41 -0
- package/src/ts/dynamodb/generator.js +47 -20
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +18 -0
- package/src/ts/dynamodb/mcp-server-connection/generator.js +7 -1
- package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/smithy-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/dynamodb/smithy-connection/generator.js +3 -1
- package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
- package/src/ts/dynamodb/trpc-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/dynamodb/trpc-connection/generator.js +3 -1
- package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
- package/src/ts/lambda-function/generator.d.ts +38 -0
- package/src/ts/lambda-function/generator.js +49 -20
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lib/generator.d.ts +7 -0
- package/src/ts/lib/generator.js +8 -1
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.d.ts +3 -1
- package/src/ts/lib/ts-project-utils.js +3 -2
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.d.ts +10 -1
- package/src/ts/lib/vitest.js +14 -2
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/generator.d.ts +71 -0
- package/src/ts/mcp-server/generator.js +73 -36
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/generator.d.ts +3 -0
- package/src/ts/nx-generator/generator.js +8 -2
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-migration/generator.d.ts +3 -0
- package/src/ts/nx-migration/generator.js +8 -2
- package/src/ts/nx-migration/generator.js.map +1 -1
- package/src/ts/nx-plugin/generator.d.ts +3 -0
- package/src/ts/nx-plugin/generator.js +8 -2
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/utils.d.ts +7 -2
- package/src/ts/nx-plugin/utils.js +10 -4
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/ts/rdb/agent-connection/generator.js +8 -1
- package/src/ts/rdb/agent-connection/generator.js.map +1 -1
- package/src/ts/rdb/generator.d.ts +101 -0
- package/src/ts/rdb/generator.js +93 -41
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +10 -0
- package/src/ts/rdb/mcp-server-connection/generator.js +8 -1
- package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/rdb/smithy-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/rdb/smithy-connection/generator.js +4 -1
- package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/__snapshots__/generator.spec.ts.snap +9 -0
- package/src/ts/rdb/trpc-connection/generator.js +3 -1
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/react-website/agui/generator.d.ts +86 -0
- package/src/ts/react-website/agui/generator.js +63 -28
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +8 -2
- package/src/ts/react-website/app/generator.d.ts +136 -1
- package/src/ts/react-website/app/generator.js +109 -40
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/generator.d.ts +19 -0
- package/src/ts/react-website/cognito-auth/generator.js +21 -9
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/utils/add-dependencies.d.ts +38 -0
- package/src/utils/add-dependencies.js +83 -0
- package/src/utils/add-dependencies.js.map +1 -0
- package/src/utils/agent-connection/agent-connection.d.ts +27 -6
- package/src/utils/agent-connection/agent-connection.js +47 -18
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +19 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js +26 -6
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/api-constructs/api-constructs.d.ts +21 -2
- package/src/utils/api-constructs/api-constructs.js +26 -5
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/bundle/bundle.d.ts +6 -1
- package/src/utils/bundle/bundle.js +8 -2
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/commands.d.ts +5 -4
- package/src/utils/commands.js +2 -6
- package/src/utils/commands.js.map +1 -1
- package/src/utils/connection/open-api/react.d.ts +18 -1
- package/src/utils/connection/open-api/react.js +27 -3
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/declared-dependencies.d.ts +140 -0
- package/src/utils/declared-dependencies.js +64 -0
- package/src/utils/declared-dependencies.js.map +1 -0
- package/src/utils/docker.d.ts +10 -1
- package/src/utils/docker.js +7 -3
- package/src/utils/docker.js.map +1 -1
- package/src/utils/fs.d.ts +15 -4
- package/src/utils/fs.js +26 -13
- package/src/utils/fs.js.map +1 -1
- package/src/utils/init.d.ts +14 -1
- package/src/utils/init.js +25 -7
- package/src/utils/init.js.map +1 -1
- package/src/utils/migration-versions.d.ts +15 -1
- package/src/utils/migration-versions.js +53 -7
- package/src/utils/migration-versions.js.map +1 -1
- package/src/utils/nx.d.ts +18 -0
- package/src/utils/nx.js +4 -0
- package/src/utils/nx.js.map +1 -1
- package/src/utils/py.d.ts +3 -2
- package/src/utils/py.js +10 -10
- package/src/utils/py.js.map +1 -1
- package/src/utils/shared-constructs-constants.d.ts +39 -4
- package/src/utils/shared-constructs-constants.js +29 -0
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +4 -1
- package/src/utils/shared-constructs.js +5 -4
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.d.ts +8 -1
- package/src/utils/shared-dynamodb-scripts.js +11 -3
- package/src/utils/shared-dynamodb-scripts.js.map +1 -1
- package/src/utils/shared-infra-scripts.d.ts +16 -1
- package/src/utils/shared-infra-scripts.js +18 -3
- package/src/utils/shared-infra-scripts.js.map +1 -1
- package/src/utils/shared-rdb-scripts.d.ts +12 -1
- package/src/utils/shared-rdb-scripts.js +17 -3
- package/src/utils/shared-rdb-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.d.ts +26 -1
- package/src/utils/shared-shadcn.js +31 -14
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/version-upgrade-migration/migration.d.ts +14 -0
- package/src/utils/version-upgrade-migration/migration.js +16 -0
- package/src/utils/version-upgrade-migration/migration.js.map +1 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.d.ts +35 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.js +42 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.d.ts +50 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.js +98 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.js.map +1 -0
- package/src/utils/version-upgrade-migration/register.d.ts +18 -0
- package/src/utils/version-upgrade-migration/register.js +33 -0
- package/src/utils/version-upgrade-migration/register.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.d.ts +13 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.js +33 -0
- package/src/utils/version-upgrade-migration/sync-metrics-version.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.d.ts +10 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js +504 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.d.ts +14 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.js +40 -0
- package/src/utils/version-upgrade-migration/vended-upgrade.js.map +1 -0
- package/src/utils/versions.d.ts +25 -5
- package/src/utils/versions.js +46 -4
- package/src/utils/versions.js.map +1 -1
|
@@ -3,14 +3,37 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/ import { generateFiles, joinPathFragments, OverwriteStrategy, updateProjectConfiguration } from "@nx/devkit";
|
|
5
5
|
import { readAgentCoreGatewayMetadata } from "../../../agentcore-gateway/generator.js";
|
|
6
|
-
import {
|
|
6
|
+
import { addPyDependencies } from "../../../utils/add-dependencies.js";
|
|
7
|
+
import { AGENT_CONNECTION_PY_DEPENDENCIES, addPythonCoreClient, addPythonReExport, ensurePythonAgentConnectionProject, getPythonAgentConnectionModuleName, getPythonAgentConnectionProject, getPythonAgentConnectionProjectDir, PY_MCP_FAMILY_CONNECTIONS, resolveAgentFramework } from "../../../utils/agent-connection/agent-connection.js";
|
|
7
8
|
import { addPythonDestructuredImport } from "../../../utils/ast.js";
|
|
9
|
+
import { declareDependencies, ownedElsewhere } from "../../../utils/declared-dependencies.js";
|
|
8
10
|
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
9
11
|
import { installDependencies } from "../../../utils/install.js";
|
|
10
12
|
import { addGeneratorMetricsIfApplicable } from "../../../utils/metrics.js";
|
|
11
13
|
import { snakeCase } from "../../../utils/names.js";
|
|
12
|
-
import { addDependencyToTargetIfNotPresent, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
13
|
-
import {
|
|
14
|
+
import { addComponentGeneratorMetadata, addDependencyToTargetIfNotPresent, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
15
|
+
import { toProjectRelativePath } from "../../../utils/paths.js";
|
|
16
|
+
import { addWorkspaceDependencyToPyProject } from "../../../utils/py.js";
|
|
17
|
+
// The framework picks the MCP client's extra deps, so it names its branch here.
|
|
18
|
+
export const DEPENDENCIES = declareDependencies()({
|
|
19
|
+
py: [
|
|
20
|
+
{
|
|
21
|
+
name: 'boto3'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'httpx'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'mcp'
|
|
28
|
+
},
|
|
29
|
+
// Backs the LangChain client; it must not pull Strands in.
|
|
30
|
+
{
|
|
31
|
+
name: 'langchain-mcp-adapters',
|
|
32
|
+
when: (m)=>m.framework === 'langchain'
|
|
33
|
+
},
|
|
34
|
+
...ownedElsewhere(AGENT_CONNECTION_PY_DEPENDENCIES)
|
|
35
|
+
]
|
|
36
|
+
});
|
|
14
37
|
export const PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
15
38
|
export const pyAgentGatewayConnectionGenerator = async (tree, options)=>{
|
|
16
39
|
const sourceProject = readProjectConfigurationUnqualified(tree, options.sourceProject);
|
|
@@ -40,18 +63,22 @@ export const pyAgentGatewayConnectionGenerator = async (tree, options)=>{
|
|
|
40
63
|
// its tools over MCP, so it reuses the same wiring as an MCP server connection.
|
|
41
64
|
const framework = resolveAgentFramework(agentComponent.framework);
|
|
42
65
|
const connection = PY_MCP_FAMILY_CONNECTIONS[framework];
|
|
43
|
-
|
|
44
|
-
|
|
66
|
+
// Recorded below and read by the declaration's predicates, so the packages
|
|
67
|
+
// added here are exactly the ones the version sync will own.
|
|
68
|
+
const metadata = {
|
|
69
|
+
framework
|
|
70
|
+
};
|
|
71
|
+
await ensurePythonAgentConnectionProject(tree, DEPENDENCIES);
|
|
72
|
+
await addPythonCoreClient(tree, 'gateway', DEPENDENCIES, framework);
|
|
45
73
|
const agentConnectionProjectDir = getPythonAgentConnectionProjectDir(tree);
|
|
46
74
|
const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);
|
|
47
75
|
// Shared MCP transport + signed httpx auth deps, plus whatever extra deps the
|
|
48
76
|
// framework's MCP client needs (e.g. langchain-mcp-adapters for LangChain).
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]);
|
|
77
|
+
// These belong to the shared agent-connection project, which holds the client.
|
|
78
|
+
addPyDependencies(tree, DEPENDENCIES, {
|
|
79
|
+
metadata,
|
|
80
|
+
projectRoot: agentConnectionProjectDir
|
|
81
|
+
});
|
|
55
82
|
const appDir = joinPathFragments(agentConnectionProjectDir, agentConnectionModuleName, 'app');
|
|
56
83
|
// Local mode points at the gateway project's local gateway port.
|
|
57
84
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', connection.appTemplateSubdir), appDir, {
|
|
@@ -104,6 +131,13 @@ export const pyAgentGatewayConnectionGenerator = async (tree, options)=>{
|
|
|
104
131
|
if (projectConfigChanged) {
|
|
105
132
|
updateProjectConfiguration(tree, sourceProject.name, sourceProject);
|
|
106
133
|
}
|
|
134
|
+
// Recorded so the version sync knows this connection's dependencies are ours.
|
|
135
|
+
addComponentGeneratorMetadata(tree, sourceProject.name, PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO, toProjectRelativePath(sourceProject, agentFilePath), gatewayClassName, // `sourcePath` names the source component this connection is made from, so
|
|
136
|
+
// the pair is identifiable rather than just the two projects.
|
|
137
|
+
{
|
|
138
|
+
...metadata,
|
|
139
|
+
sourcePath: options.sourceComponent?.path
|
|
140
|
+
});
|
|
107
141
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
108
142
|
PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO
|
|
109
143
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/agent/gateway-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { readAgentCoreGatewayMetadata } from '../../../agentcore-gateway/generator';\nimport {\n addPythonCoreClient,\n addPythonReExport,\n ensurePythonAgentConnectionProject,\n getPythonAgentConnectionModuleName,\n getPythonAgentConnectionProject,\n getPythonAgentConnectionProjectDir,\n PY_MCP_FAMILY_CONNECTIONS,\n resolveAgentFramework,\n} from '../../../utils/agent-connection/agent-connection';\nimport { addPythonDestructuredImport } from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { snakeCase } from '../../../utils/names';\nimport {\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport {\n addDependenciesToPyProjectToml,\n addWorkspaceDependencyToPyProject,\n} from '../../../utils/py';\nimport type { PyAgentGatewayConnectionGeneratorSchema } from './schema';\n\nexport const PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const pyAgentGatewayConnectionGenerator = async (\n tree: Tree,\n options: PyAgentGatewayConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n const agentComponent = options.sourceComponent;\n if (!agentComponent) {\n throw new Error(\n 'sourceComponent must be provided for py#agent -> agentcore-gateway connections',\n );\n }\n const gateway = readAgentCoreGatewayMetadata(targetProject);\n\n if (gateway.protocol !== 'mcp') {\n throw new Error(\n `Gateway '${gateway.name}' has protocol='${gateway.protocol}'. Only MCP-protocol gateways are supported.`,\n );\n }\n if (gateway.auth !== 'iam') {\n throw new Error(\n `Gateway '${gateway.name}' uses auth='${gateway.auth}'. Agent connections currently require the gateway to use IAM authentication.`,\n );\n }\n if (agentComponent.auth && agentComponent.auth !== 'iam') {\n throw new Error(\n `Agent '${agentComponent.name}' uses auth='${agentComponent.auth}'. Only IAM-authenticated agents can connect to IAM gateways.`,\n );\n }\n\n const gatewayClassName = gateway.rc;\n const gatewaySnakeCase = snakeCase(gatewayClassName);\n // A gateway is its own standalone project, so it exposes plain serve / dev.\n const gatewayServeTargetName = 'serve';\n const gatewayDevTargetName = 'dev';\n\n // The source agent's framework selects the client shape, dependencies and the\n // agent.py transform — see PY_MCP_FAMILY_CONNECTIONS (keyed by framework, not a\n // boolean, so a third framework is an additive entry there). A Gateway exposes\n // its tools over MCP, so it reuses the same wiring as an MCP server connection.\n const framework = resolveAgentFramework(agentComponent.framework);\n const connection = PY_MCP_FAMILY_CONNECTIONS[framework];\n\n await ensurePythonAgentConnectionProject(tree);\n await addPythonCoreClient(tree, 'gateway', framework);\n\n const agentConnectionProjectDir = getPythonAgentConnectionProjectDir(tree);\n const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);\n\n // Shared MCP transport + signed httpx auth deps, plus whatever extra deps the\n // framework's MCP client needs (e.g. langchain-mcp-adapters for LangChain).\n addDependenciesToPyProjectToml(tree, agentConnectionProjectDir, [\n 'boto3',\n 'httpx',\n 'mcp',\n ...connection.deps,\n ]);\n\n const appDir = joinPathFragments(\n agentConnectionProjectDir,\n agentConnectionModuleName,\n 'app',\n );\n // Local mode points at the gateway project's local gateway port.\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n connection.appTemplateSubdir,\n ),\n appDir,\n {\n gatewaySnakeCase,\n gatewayClassName,\n agentConnectionModuleName,\n gatewayPort: gateway.port,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const appInitPath = joinPathFragments(appDir, '__init__.py');\n if (!tree.exists(appInitPath)) {\n tree.write(appInitPath, '');\n }\n\n const moduleInitPath = joinPathFragments(\n agentConnectionProjectDir,\n agentConnectionModuleName,\n '__init__.py',\n );\n await addPythonReExport(\n tree,\n moduleInitPath,\n `.app.${gatewaySnakeCase}_client_${connection.clientModuleSuffix}`,\n `${gatewayClassName}Client${connection.clientClassSuffix}`,\n );\n\n const agentSourceDir = joinPathFragments(\n sourceProject.root,\n agentComponent.path ?? 'src',\n );\n const agentFilePath = joinPathFragments(agentSourceDir, 'agent.py');\n\n if (tree.exists(agentFilePath)) {\n const clientClassName = `${gatewayClassName}Client${connection.clientClassSuffix}`;\n const clientVarName = gatewaySnakeCase;\n\n await addPythonDestructuredImport(\n tree,\n agentFilePath,\n [clientClassName],\n agentConnectionModuleName,\n );\n await connection.wireClientIntoAgent(\n tree,\n agentFilePath,\n clientClassName,\n clientVarName,\n );\n }\n\n addWorkspaceDependencyToPyProject(\n tree,\n sourceProject,\n getPythonAgentConnectionProject(tree),\n );\n\n const agentName = agentComponent.name ?? 'agent';\n const serveTargetName = `${agentName}-serve`;\n const devTargetName = `${agentName}-dev`;\n let projectConfigChanged = false;\n if (sourceProject.targets?.[serveTargetName]) {\n addDependencyToTargetIfNotPresent(sourceProject, serveTargetName, {\n projects: [targetProject.name],\n target: gatewayServeTargetName,\n });\n projectConfigChanged = true;\n }\n if (sourceProject.targets?.[devTargetName]) {\n addDependencyToTargetIfNotPresent(sourceProject, devTargetName, {\n projects: [targetProject.name],\n target: gatewayDevTargetName,\n });\n projectConfigChanged = true;\n }\n if (projectConfigChanged) {\n updateProjectConfiguration(tree, sourceProject.name, sourceProject);\n }\n\n await addGeneratorMetricsIfApplicable(tree, [\n PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default pyAgentGatewayConnectionGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","readAgentCoreGatewayMetadata","addPythonCoreClient","addPythonReExport","ensurePythonAgentConnectionProject","getPythonAgentConnectionModuleName","getPythonAgentConnectionProject","getPythonAgentConnectionProjectDir","PY_MCP_FAMILY_CONNECTIONS","resolveAgentFramework","addPythonDestructuredImport","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","snakeCase","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","addDependenciesToPyProjectToml","addWorkspaceDependencyToPyProject","PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO","filename","pyAgentGatewayConnectionGenerator","tree","options","sourceProject","targetProject","agentComponent","sourceComponent","Error","gateway","protocol","name","auth","gatewayClassName","rc","gatewaySnakeCase","gatewayServeTargetName","gatewayDevTargetName","framework","connection","agentConnectionProjectDir","agentConnectionModuleName","deps","appDir","dirname","appTemplateSubdir","gatewayPort","port","overwriteStrategy","KeepExisting","appInitPath","exists","write","moduleInitPath","clientModuleSuffix","clientClassSuffix","agentSourceDir","root","path","agentFilePath","clientClassName","clientVarName","wireClientIntoAgent","agentName","serveTargetName","devTargetName","projectConfigChanged","targets","projects","target","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,4BAA4B,QAAQ,0CAAuC;AACpF,SACEC,mBAAmB,EACnBC,iBAAiB,EACjBC,kCAAkC,EAClCC,kCAAkC,EAClCC,+BAA+B,EAC/BC,kCAAkC,EAClCC,yBAAyB,EACzBC,qBAAqB,QAChB,sDAAmD;AAC1D,SAASC,2BAA2B,QAAQ,wBAAqB;AACjE,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;AACzE,SAASC,SAAS,QAAQ,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eACAnB,gCAAgCiB;IAGlC,MAAMyC,YAAYrC,eAAeK,IAAI,IAAI;IACzC,MAAMiC,kBAAkB,GAAGD,UAAU,MAAM,CAAC;IAC5C,MAAME,gBAAgB,GAAGF,UAAU,IAAI,CAAC;IACxC,IAAIG,uBAAuB;IAC3B,IAAI1C,cAAc2C,OAAO,EAAE,CAACH,gBAAgB,EAAE;QAC5ClD,kCAAkCU,eAAewC,iBAAiB;YAChEI,UAAU;gBAAC3C,cAAcM,IAAI;aAAC;YAC9BsC,QAAQjC;QACV;QACA8B,uBAAuB;IACzB;IACA,IAAI1C,cAAc2C,OAAO,EAAE,CAACF,cAAc,EAAE;QAC1CnD,kCAAkCU,eAAeyC,eAAe;YAC9DG,UAAU;gBAAC3C,cAAcM,IAAI;aAAC;YAC9BsC,QAAQhC;QACV;QACA6B,uBAAuB;IACzB;IACA,IAAIA,sBAAsB;QACxBnE,2BAA2BuB,MAAME,cAAcO,IAAI,EAAEP;IACvD;IAEA,MAAMZ,gCAAgCU,MAAM;QAC1CH;KACD;IAED,MAAMT,qBAAqBY;IAC3B,OAAO,IACLX,oBAAoBW,MAAMC,QAAQ+C,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAelD,kCAAkC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/agent/gateway-connection/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { readAgentCoreGatewayMetadata } from '../../../agentcore-gateway/generator';\nimport { addPyDependencies } from '../../../utils/add-dependencies';\nimport {\n AGENT_CONNECTION_PY_DEPENDENCIES,\n type AgentFramework,\n addPythonCoreClient,\n addPythonReExport,\n ensurePythonAgentConnectionProject,\n getPythonAgentConnectionModuleName,\n getPythonAgentConnectionProject,\n getPythonAgentConnectionProjectDir,\n PY_MCP_FAMILY_CONNECTIONS,\n resolveAgentFramework,\n} from '../../../utils/agent-connection/agent-connection';\nimport { addPythonDestructuredImport } from '../../../utils/ast';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { snakeCase } from '../../../utils/names';\nimport {\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { toProjectRelativePath } from '../../../utils/paths';\nimport { addWorkspaceDependencyToPyProject } from '../../../utils/py';\nimport type { PyAgentGatewayConnectionGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface PyAgentGatewayConnectionMetadata {\n readonly framework: AgentFramework;\n}\n\n// The framework picks the MCP client's extra deps, so it names its branch here.\nexport const DEPENDENCIES =\n declareDependencies<PyAgentGatewayConnectionMetadata>()({\n py: [\n { name: 'boto3' },\n { name: 'httpx' },\n { name: 'mcp' },\n // Backs the LangChain client; it must not pull Strands in.\n {\n name: 'langchain-mcp-adapters',\n when: (m) => m.framework === 'langchain',\n },\n ...ownedElsewhere(AGENT_CONNECTION_PY_DEPENDENCIES),\n ],\n });\n\nexport const PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const pyAgentGatewayConnectionGenerator = async (\n tree: Tree,\n options: PyAgentGatewayConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const sourceProject = readProjectConfigurationUnqualified(\n tree,\n options.sourceProject,\n );\n const targetProject = readProjectConfigurationUnqualified(\n tree,\n options.targetProject,\n );\n\n const agentComponent = options.sourceComponent;\n if (!agentComponent) {\n throw new Error(\n 'sourceComponent must be provided for py#agent -> agentcore-gateway connections',\n );\n }\n const gateway = readAgentCoreGatewayMetadata(targetProject);\n\n if (gateway.protocol !== 'mcp') {\n throw new Error(\n `Gateway '${gateway.name}' has protocol='${gateway.protocol}'. Only MCP-protocol gateways are supported.`,\n );\n }\n if (gateway.auth !== 'iam') {\n throw new Error(\n `Gateway '${gateway.name}' uses auth='${gateway.auth}'. Agent connections currently require the gateway to use IAM authentication.`,\n );\n }\n if (agentComponent.auth && agentComponent.auth !== 'iam') {\n throw new Error(\n `Agent '${agentComponent.name}' uses auth='${agentComponent.auth}'. Only IAM-authenticated agents can connect to IAM gateways.`,\n );\n }\n\n const gatewayClassName = gateway.rc;\n const gatewaySnakeCase = snakeCase(gatewayClassName);\n // A gateway is its own standalone project, so it exposes plain serve / dev.\n const gatewayServeTargetName = 'serve';\n const gatewayDevTargetName = 'dev';\n\n // The source agent's framework selects the client shape, dependencies and the\n // agent.py transform — see PY_MCP_FAMILY_CONNECTIONS (keyed by framework, not a\n // boolean, so a third framework is an additive entry there). A Gateway exposes\n // its tools over MCP, so it reuses the same wiring as an MCP server connection.\n const framework = resolveAgentFramework(agentComponent.framework);\n const connection = PY_MCP_FAMILY_CONNECTIONS[framework];\n\n // Recorded below and read by the declaration's predicates, so the packages\n // added here are exactly the ones the version sync will own.\n const metadata: PyAgentGatewayConnectionMetadata = { framework };\n\n await ensurePythonAgentConnectionProject(tree, DEPENDENCIES);\n await addPythonCoreClient(tree, 'gateway', DEPENDENCIES, framework);\n\n const agentConnectionProjectDir = getPythonAgentConnectionProjectDir(tree);\n const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);\n\n // Shared MCP transport + signed httpx auth deps, plus whatever extra deps the\n // framework's MCP client needs (e.g. langchain-mcp-adapters for LangChain).\n // These belong to the shared agent-connection project, which holds the client.\n addPyDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: agentConnectionProjectDir,\n });\n\n const appDir = joinPathFragments(\n agentConnectionProjectDir,\n agentConnectionModuleName,\n 'app',\n );\n // Local mode points at the gateway project's local gateway port.\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'files',\n connection.appTemplateSubdir,\n ),\n appDir,\n {\n gatewaySnakeCase,\n gatewayClassName,\n agentConnectionModuleName,\n gatewayPort: gateway.port,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const appInitPath = joinPathFragments(appDir, '__init__.py');\n if (!tree.exists(appInitPath)) {\n tree.write(appInitPath, '');\n }\n\n const moduleInitPath = joinPathFragments(\n agentConnectionProjectDir,\n agentConnectionModuleName,\n '__init__.py',\n );\n await addPythonReExport(\n tree,\n moduleInitPath,\n `.app.${gatewaySnakeCase}_client_${connection.clientModuleSuffix}`,\n `${gatewayClassName}Client${connection.clientClassSuffix}`,\n );\n\n const agentSourceDir = joinPathFragments(\n sourceProject.root,\n agentComponent.path ?? 'src',\n );\n const agentFilePath = joinPathFragments(agentSourceDir, 'agent.py');\n\n if (tree.exists(agentFilePath)) {\n const clientClassName = `${gatewayClassName}Client${connection.clientClassSuffix}`;\n const clientVarName = gatewaySnakeCase;\n\n await addPythonDestructuredImport(\n tree,\n agentFilePath,\n [clientClassName],\n agentConnectionModuleName,\n );\n await connection.wireClientIntoAgent(\n tree,\n agentFilePath,\n clientClassName,\n clientVarName,\n );\n }\n\n addWorkspaceDependencyToPyProject(\n tree,\n sourceProject,\n getPythonAgentConnectionProject(tree),\n );\n\n const agentName = agentComponent.name ?? 'agent';\n const serveTargetName = `${agentName}-serve`;\n const devTargetName = `${agentName}-dev`;\n let projectConfigChanged = false;\n if (sourceProject.targets?.[serveTargetName]) {\n addDependencyToTargetIfNotPresent(sourceProject, serveTargetName, {\n projects: [targetProject.name],\n target: gatewayServeTargetName,\n });\n projectConfigChanged = true;\n }\n if (sourceProject.targets?.[devTargetName]) {\n addDependencyToTargetIfNotPresent(sourceProject, devTargetName, {\n projects: [targetProject.name],\n target: gatewayDevTargetName,\n });\n projectConfigChanged = true;\n }\n if (projectConfigChanged) {\n updateProjectConfiguration(tree, sourceProject.name, sourceProject);\n }\n\n // Recorded so the version sync knows this connection's dependencies are ours.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO,\n toProjectRelativePath(sourceProject, agentFilePath),\n gatewayClassName,\n // `sourcePath` names the source component this connection is made from, so\n // the pair is identifiable rather than just the two projects.\n { ...metadata, sourcePath: options.sourceComponent?.path },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [\n PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default pyAgentGatewayConnectionGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","readAgentCoreGatewayMetadata","addPyDependencies","AGENT_CONNECTION_PY_DEPENDENCIES","addPythonCoreClient","addPythonReExport","ensurePythonAgentConnectionProject","getPythonAgentConnectionModuleName","getPythonAgentConnectionProject","getPythonAgentConnectionProjectDir","PY_MCP_FAMILY_CONNECTIONS","resolveAgentFramework","addPythonDestructuredImport","declareDependencies","ownedElsewhere","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","snakeCase","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","addWorkspaceDependencyToPyProject","DEPENDENCIES","py","name","when","m","framework","PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO","filename","pyAgentGatewayConnectionGenerator","tree","options","sourceProject","targetProject","agentComponent","sourceComponent","Error","gateway","protocol","auth","gatewayClassName","rc","gatewaySnakeCase","gatewayServeTargetName","gatewayDevTargetName","connection","metadata","agentConnectionProjectDir","agentConnectionModuleName","projectRoot","appDir","dirname","appTemplateSubdir","gatewayPort","port","overwriteStrategy","KeepExisting","appInitPath","exists","write","moduleInitPath","clientModuleSuffix","clientClassSuffix","agentSourceDir","root","path","agentFilePath","clientClassName","clientVarName","wireClientIntoAgent","agentName","serveTargetName","devTargetName","projectConfigChanged","targets","projects","target","sourcePath","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,4BAA4B,QAAQ,0CAAuC;AACpF,SAASC,iBAAiB,QAAQ,qCAAkC;AACpE,SACEC,gCAAgC,EAEhCC,mBAAmB,EACnBC,iBAAiB,EACjBC,kCAAkC,EAClCC,kCAAkC,EAClCC,+BAA+B,EAC/BC,kCAAkC,EAClCC,yBAAyB,EACzBC,qBAAqB,QAChB,sDAAmD;AAC1D,SAASC,2BAA2B,QAAQ,wBAAqB;AACjE,SACEC,mBAAmB,EACnBC,cAAc,QACT,0CAAuC;AAC9C,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;AACzE,SAASC,SAAS,QAAQ,0BAAuB;AACjD,SACEC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAoB;AAC3B,SAASC,qBAAqB,QAAQ,0BAAuB;AAC7D,SAASC,iCAAiC,QAAQ,uBAAoB;AAQtE,gFAAgF;AAChF,OAAO,MAAMC,eACXZ,sBAAwD;IACtDa,IAAI;QACF;YAAEC,MAAM;QAAQ;QAChB;YAAEA,MAAM;QAAQ;QAChB;YAAEA,MAAM;QAAM;QACd,2DAA2D;QAC3D;YACEA,MAAM;YACNC,MAAM,CAACC,IAAMA,EAAEC,SAAS,KAAK;QAC/B;WACGhB,eAAeX;KACnB;AACH,GAAG;AAEL,OAAO,MAAM4B,6CACXV,iBAAiB,YAAYW,QAAQ,EAAE;AAEzC,OAAO,MAAMC,oCAAoC,OAC/CC,MACAC;I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AI,CAAC;IACxC,IAAIG,uBAAuB;IAC3B,IAAIzC,cAAc0C,OAAO,EAAE,CAACH,gBAAgB,EAAE;QAC5CvD,kCAAkCgB,eAAeuC,iBAAiB;YAChEI,UAAU;gBAAC1C,cAAcV,IAAI;aAAC;YAC9BqD,QAAQjC;QACV;QACA8B,uBAAuB;IACzB;IACA,IAAIzC,cAAc0C,OAAO,EAAE,CAACF,cAAc,EAAE;QAC1CxD,kCAAkCgB,eAAewC,eAAe;YAC9DG,UAAU;gBAAC1C,cAAcV,IAAI;aAAC;YAC9BqD,QAAQhC;QACV;QACA6B,uBAAuB;IACzB;IACA,IAAIA,sBAAsB;QACxB7E,2BAA2BkC,MAAME,cAAcT,IAAI,EAAES;IACvD;IAEA,8EAA8E;IAC9EjB,8BACEe,MACAE,cAAcT,IAAI,EAClBI,4CACAR,sBAAsBa,eAAekC,gBACrC1B,kBACA,2EAA2E;IAC3E,8DAA8D;IAC9D;QAAE,GAAGM,QAAQ;QAAE+B,YAAY9C,QAAQI,eAAe,EAAE8B;IAAK;IAG3D,MAAMpD,gCAAgCiB,MAAM;QAC1CH;KACD;IAED,MAAMhB,qBAAqBmB;IAC3B,OAAO,IACLlB,oBAAoBkB,MAAMC,QAAQ+C,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAelD,kCAAkC"}
|
|
@@ -4,7 +4,152 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
6
|
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
7
|
-
import type {
|
|
7
|
+
import type { IacMetadata } from '../../utils/shared-constructs-constants';
|
|
8
|
+
import type { AgentProtocol, PyAgentFramework, PyAgentGeneratorSchema } from './schema';
|
|
9
|
+
/** The metadata this generator records, which its predicates read. */
|
|
10
|
+
export interface PyAgentMetadata extends IacMetadata {
|
|
11
|
+
readonly port: number;
|
|
12
|
+
readonly rc: string;
|
|
13
|
+
readonly auth: string;
|
|
14
|
+
readonly protocol: AgentProtocol;
|
|
15
|
+
/**
|
|
16
|
+
* The mcp / gateway connection generators dispatch on this field to pick the
|
|
17
|
+
* Strands vs LangChain Layer-2 client + agent.py transform.
|
|
18
|
+
*/
|
|
19
|
+
readonly framework: PyAgentFramework;
|
|
20
|
+
}
|
|
21
|
+
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
22
|
+
readonly name: "agent-chat-cli";
|
|
23
|
+
readonly dev: true;
|
|
24
|
+
readonly root: true;
|
|
25
|
+
}, {
|
|
26
|
+
readonly name: "tsx";
|
|
27
|
+
readonly dev: true;
|
|
28
|
+
readonly root: true;
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "@types/node";
|
|
31
|
+
readonly dev: true;
|
|
32
|
+
readonly root: true;
|
|
33
|
+
}, {
|
|
34
|
+
readonly name: "@aws-lambda-powertools/parameters";
|
|
35
|
+
readonly dev: true;
|
|
36
|
+
readonly root: true;
|
|
37
|
+
}, {
|
|
38
|
+
readonly name: "@aws-sdk/client-appconfigdata";
|
|
39
|
+
readonly dev: true;
|
|
40
|
+
readonly root: true;
|
|
41
|
+
}, {
|
|
42
|
+
readonly name: "aws4fetch";
|
|
43
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
44
|
+
readonly dev: true;
|
|
45
|
+
readonly root: true;
|
|
46
|
+
}, {
|
|
47
|
+
readonly name: "@aws-sdk/credential-providers";
|
|
48
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
49
|
+
readonly dev: true;
|
|
50
|
+
readonly root: true;
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "@a2a-js/sdk";
|
|
53
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
54
|
+
readonly dev: true;
|
|
55
|
+
readonly root: true;
|
|
56
|
+
}, {
|
|
57
|
+
readonly name: "ncp";
|
|
58
|
+
} & {
|
|
59
|
+
versionOnly: true;
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "rimraf";
|
|
62
|
+
} & {
|
|
63
|
+
versionOnly: true;
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "make-dir-cli";
|
|
66
|
+
} & {
|
|
67
|
+
versionOnly: true;
|
|
68
|
+
}, {
|
|
69
|
+
readonly name: "ncp";
|
|
70
|
+
} & {
|
|
71
|
+
versionOnly: true;
|
|
72
|
+
}, {
|
|
73
|
+
readonly name: "rimraf";
|
|
74
|
+
} & {
|
|
75
|
+
versionOnly: true;
|
|
76
|
+
}, {
|
|
77
|
+
readonly name: "make-dir-cli";
|
|
78
|
+
} & {
|
|
79
|
+
versionOnly: true;
|
|
80
|
+
}, {
|
|
81
|
+
readonly name: "constructs";
|
|
82
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
83
|
+
} & {
|
|
84
|
+
versionOnly: true;
|
|
85
|
+
}, {
|
|
86
|
+
readonly name: "aws-cdk-lib";
|
|
87
|
+
readonly when: (m: IacMetadata) => boolean;
|
|
88
|
+
} & {
|
|
89
|
+
versionOnly: true;
|
|
90
|
+
}, {
|
|
91
|
+
readonly name: "@types/node";
|
|
92
|
+
} & {
|
|
93
|
+
versionOnly: true;
|
|
94
|
+
}], readonly [{
|
|
95
|
+
readonly name: "aws-lambda-powertools";
|
|
96
|
+
}, {
|
|
97
|
+
readonly name: "aws-opentelemetry-distro";
|
|
98
|
+
}, {
|
|
99
|
+
readonly name: "bedrock-agentcore";
|
|
100
|
+
}, {
|
|
101
|
+
readonly name: "boto3";
|
|
102
|
+
}, {
|
|
103
|
+
readonly name: "fastapi";
|
|
104
|
+
}, {
|
|
105
|
+
readonly name: "mcp";
|
|
106
|
+
}, {
|
|
107
|
+
readonly name: "langchain";
|
|
108
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
109
|
+
}, {
|
|
110
|
+
readonly name: "langchain-aws";
|
|
111
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
112
|
+
}, {
|
|
113
|
+
readonly name: "langgraph";
|
|
114
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
115
|
+
}, {
|
|
116
|
+
readonly name: "ag-ui-protocol";
|
|
117
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
118
|
+
}, {
|
|
119
|
+
readonly name: "ag-ui-langgraph";
|
|
120
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
121
|
+
}, {
|
|
122
|
+
readonly name: "a2a-sdk";
|
|
123
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
124
|
+
}, {
|
|
125
|
+
readonly name: "strands-agents[a2a]";
|
|
126
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
127
|
+
}, {
|
|
128
|
+
readonly name: "strands-agents";
|
|
129
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
130
|
+
}, {
|
|
131
|
+
readonly name: "strands-agents-tools";
|
|
132
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: "ag-ui-protocol";
|
|
135
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
136
|
+
}, {
|
|
137
|
+
readonly name: "ag-ui-strands";
|
|
138
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
139
|
+
}, {
|
|
140
|
+
readonly name: "uvicorn";
|
|
141
|
+
}, {
|
|
142
|
+
readonly name: "fastapi[standard]";
|
|
143
|
+
readonly group: "dev";
|
|
144
|
+
}, {
|
|
145
|
+
readonly name: "aws-lambda-powertools";
|
|
146
|
+
} & {
|
|
147
|
+
versionOnly: true;
|
|
148
|
+
}, {
|
|
149
|
+
readonly name: "strands-agents";
|
|
150
|
+
} & {
|
|
151
|
+
versionOnly: true;
|
|
152
|
+
}]>;
|
|
8
153
|
export declare const PY_AGENT_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
154
|
export declare const pyAgentGenerator: (tree: Tree, options: PyAgentGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
155
|
export default pyAgentGenerator;
|
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
*/ import { generateFiles, joinPathFragments, OverwriteStrategy, updateProjectConfiguration } from "@nx/devkit";
|
|
5
5
|
import { ensureLicenseExceptions } from "../../license/config.js";
|
|
6
6
|
import { AG_UI_LANGGRAPH_EXCEPTIONS } from "../../license/known-exceptions.js";
|
|
7
|
+
import { addPyDependencies, addTsDependencies } from "../../utils/add-dependencies.js";
|
|
7
8
|
import { addAgentChatScripts } from "../../utils/agent-chat/agent-chat.js";
|
|
8
|
-
import { addPythonFrameworkBase, ensurePythonAgentConnectionProject, getPythonAgentConnectionModuleName, getPythonAgentConnectionProject } from "../../utils/agent-connection/agent-connection.js";
|
|
9
|
+
import { AGENT_CONNECTION_PY_DEPENDENCIES, addPythonFrameworkBase, ensurePythonAgentConnectionProject, getPythonAgentConnectionModuleName, getPythonAgentConnectionProject } from "../../utils/agent-connection/agent-connection.js";
|
|
9
10
|
import { addAgentInfra } from "../../utils/agent-core-constructs/agent-core-constructs.js";
|
|
10
11
|
import { addPythonBundleTarget } from "../../utils/bundle/bundle.js";
|
|
11
12
|
import { resolveContainers } from "../../utils/containers.js";
|
|
12
|
-
import {
|
|
13
|
-
import { addDockerScanTarget } from "../../utils/docker.js";
|
|
13
|
+
import { declareDependencies, ownedElsewhere } from "../../utils/declared-dependencies.js";
|
|
14
|
+
import { addDockerScanTarget, DOCKER_DEPENDENCIES } from "../../utils/docker.js";
|
|
14
15
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
15
|
-
import { FsCommands } from "../../utils/fs.js";
|
|
16
|
+
import { FS_DEPENDENCIES, FsCommands } from "../../utils/fs.js";
|
|
16
17
|
import { updateGitIgnore } from "../../utils/git.js";
|
|
17
18
|
import { resolveIac } from "../../utils/iac.js";
|
|
18
19
|
import { installDependencies } from "../../utils/install.js";
|
|
@@ -23,9 +24,145 @@ import { addComponentDevTarget, addComponentGeneratorMetadata, addDependencyToTa
|
|
|
23
24
|
import { sortObjectKeys } from "../../utils/object.js";
|
|
24
25
|
import { toProjectRelativePath } from "../../utils/paths.js";
|
|
25
26
|
import { assignPort } from "../../utils/port.js";
|
|
26
|
-
import {
|
|
27
|
-
import { sharedConstructsGenerator } from "../../utils/shared-constructs.js";
|
|
28
|
-
import { BASE_IMAGES
|
|
27
|
+
import { addWorkspaceDependencyToPyProject } from "../../utils/py.js";
|
|
28
|
+
import { SHARED_CONSTRUCTS_DEPENDENCIES, sharedConstructsGenerator } from "../../utils/shared-constructs.js";
|
|
29
|
+
import { BASE_IMAGES } from "../../utils/versions.js";
|
|
30
|
+
/** Whether the chat CLI signs its requests, which only IAM auth needs. */ const isIam = (m)=>m.auth === 'iam';
|
|
31
|
+
// Each entry names the framework and protocol branch it belongs to, so the same
|
|
32
|
+
// declaration drives both adding and the version sync.
|
|
33
|
+
export const DEPENDENCIES = declareDependencies()({
|
|
34
|
+
ts: [
|
|
35
|
+
// The chat CLI, which runs standalone via tsx for every protocol and
|
|
36
|
+
// resolves the deployed agent from AppConfig. `agent-chat-cli` transitively
|
|
37
|
+
// bundles the protocol clients (@a2a-js/sdk, @ag-ui/client).
|
|
38
|
+
{
|
|
39
|
+
name: 'agent-chat-cli',
|
|
40
|
+
dev: true,
|
|
41
|
+
root: true
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'tsx',
|
|
45
|
+
dev: true,
|
|
46
|
+
root: true
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: '@types/node',
|
|
50
|
+
dev: true,
|
|
51
|
+
root: true
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: '@aws-lambda-powertools/parameters',
|
|
55
|
+
dev: true,
|
|
56
|
+
root: true
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: '@aws-sdk/client-appconfigdata',
|
|
60
|
+
dev: true,
|
|
61
|
+
root: true
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'aws4fetch',
|
|
65
|
+
when: isIam,
|
|
66
|
+
dev: true,
|
|
67
|
+
root: true
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: '@aws-sdk/credential-providers',
|
|
71
|
+
when: isIam,
|
|
72
|
+
dev: true,
|
|
73
|
+
root: true
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: '@a2a-js/sdk',
|
|
77
|
+
when: (m)=>m.protocol === 'a2a',
|
|
78
|
+
dev: true,
|
|
79
|
+
root: true
|
|
80
|
+
},
|
|
81
|
+
// Added by the helpers that own the projects they belong to.
|
|
82
|
+
...ownedElsewhere(FS_DEPENDENCIES),
|
|
83
|
+
...ownedElsewhere(DOCKER_DEPENDENCIES),
|
|
84
|
+
...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES)
|
|
85
|
+
],
|
|
86
|
+
py: [
|
|
87
|
+
{
|
|
88
|
+
name: 'aws-lambda-powertools'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'aws-opentelemetry-distro'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: 'bedrock-agentcore'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'boto3'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'fastapi'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'mcp'
|
|
104
|
+
},
|
|
105
|
+
// langchain pulls no Strands dependencies — the langchain model binding
|
|
106
|
+
// plus the per-protocol server adapter: ag-ui-langgraph for AG-UI, a2a-sdk
|
|
107
|
+
// for A2A, nothing extra for HTTP (FastAPI is added for every agent).
|
|
108
|
+
{
|
|
109
|
+
name: 'langchain',
|
|
110
|
+
when: (m)=>m.framework === 'langchain'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'langchain-aws',
|
|
114
|
+
when: (m)=>m.framework === 'langchain'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'langgraph',
|
|
118
|
+
when: (m)=>m.framework === 'langchain'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'ag-ui-protocol',
|
|
122
|
+
when: (m)=>m.framework === 'langchain' && m.protocol === 'ag-ui'
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'ag-ui-langgraph',
|
|
126
|
+
when: (m)=>m.framework === 'langchain' && m.protocol === 'ag-ui'
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'a2a-sdk',
|
|
130
|
+
when: (m)=>m.framework === 'langchain' && m.protocol === 'a2a'
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'strands-agents[a2a]',
|
|
134
|
+
when: (m)=>m.framework !== 'langchain' && m.protocol === 'a2a'
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'strands-agents',
|
|
138
|
+
when: (m)=>m.framework !== 'langchain' && m.protocol !== 'a2a'
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: 'strands-agents-tools',
|
|
142
|
+
when: (m)=>m.framework !== 'langchain'
|
|
143
|
+
},
|
|
144
|
+
// Declared again here so a Strands AG-UI agent lists it in the same order
|
|
145
|
+
// the generated pyproject.toml had before.
|
|
146
|
+
{
|
|
147
|
+
name: 'ag-ui-protocol',
|
|
148
|
+
when: (m)=>m.framework !== 'langchain' && m.protocol === 'ag-ui'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'ag-ui-strands',
|
|
152
|
+
when: (m)=>m.framework !== 'langchain' && m.protocol === 'ag-ui'
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
name: 'uvicorn'
|
|
156
|
+
},
|
|
157
|
+
// `fastapi dev` runs the local server for every protocol.
|
|
158
|
+
{
|
|
159
|
+
name: 'fastapi[standard]',
|
|
160
|
+
group: 'dev'
|
|
161
|
+
},
|
|
162
|
+
// The agent-connection helper adds these to its own project.
|
|
163
|
+
...ownedElsewhere(AGENT_CONNECTION_PY_DEPENDENCIES)
|
|
164
|
+
]
|
|
165
|
+
});
|
|
29
166
|
export const PY_AGENT_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
30
167
|
export const pyAgentGenerator = async (tree, options)=>{
|
|
31
168
|
const project = readProjectConfigurationUnqualified(tree, options.project);
|
|
@@ -48,6 +185,10 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
48
185
|
const infra = options.infra ?? 'agentcore';
|
|
49
186
|
const protocol = options.protocol ?? 'http';
|
|
50
187
|
const framework = options.framework ?? 'strands';
|
|
188
|
+
// Recorded in the metadata below so the version sync can tell a CDK
|
|
189
|
+
// project from a Terraform one; undefined when no infrastructure was
|
|
190
|
+
// generated, in which case neither provider's packages were added.
|
|
191
|
+
const iac = infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;
|
|
51
192
|
if (infra === 'none' && options.auth && options.auth !== 'iam') {
|
|
52
193
|
console.warn('Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)');
|
|
53
194
|
}
|
|
@@ -56,12 +197,12 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
56
197
|
// point can import `session_id_context` and propagate the AgentCore
|
|
57
198
|
// session ID to any downstream MCP / A2A clients a later connection
|
|
58
199
|
// generator wires into this agent.
|
|
59
|
-
await ensurePythonAgentConnectionProject(tree);
|
|
200
|
+
await ensurePythonAgentConnectionProject(tree, DEPENDENCIES);
|
|
60
201
|
// The agent server imports the framework base helpers (session cache + model
|
|
61
202
|
// error logging) regardless of whether a connection client is wired in. The
|
|
62
203
|
// langchain framework has no base layer (its AG-UI foundation reuses only the
|
|
63
204
|
// framework-agnostic session context), so this is a no-op for langchain.
|
|
64
|
-
await addPythonFrameworkBase(tree, framework);
|
|
205
|
+
await addPythonFrameworkBase(tree, DEPENDENCIES, framework);
|
|
65
206
|
const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);
|
|
66
207
|
addWorkspaceDependencyToPyProject(tree, project, getPythonAgentConnectionProject(tree));
|
|
67
208
|
const templateContext = {
|
|
@@ -105,43 +246,6 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
105
246
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
106
247
|
});
|
|
107
248
|
}
|
|
108
|
-
addDependenciesToPyProjectToml(tree, project.root, [
|
|
109
|
-
'aws-lambda-powertools',
|
|
110
|
-
'aws-opentelemetry-distro',
|
|
111
|
-
'bedrock-agentcore',
|
|
112
|
-
'boto3',
|
|
113
|
-
'fastapi',
|
|
114
|
-
'mcp',
|
|
115
|
-
...framework === 'langchain' ? // (langchain, langchain-aws, langgraph) plus the per-protocol server
|
|
116
|
-
// adapter: ag-ui-langgraph for AG-UI, a2a-sdk for A2A, nothing extra for
|
|
117
|
-
// HTTP (FastAPI is added above for every agent).
|
|
118
|
-
[
|
|
119
|
-
'langchain',
|
|
120
|
-
'langchain-aws',
|
|
121
|
-
'langgraph',
|
|
122
|
-
...protocol === 'ag-ui' ? [
|
|
123
|
-
'ag-ui-protocol',
|
|
124
|
-
'ag-ui-langgraph'
|
|
125
|
-
] : protocol === 'a2a' ? [
|
|
126
|
-
'a2a-sdk'
|
|
127
|
-
] : []
|
|
128
|
-
] : protocol === 'a2a' ? [
|
|
129
|
-
'strands-agents[a2a]',
|
|
130
|
-
'strands-agents-tools'
|
|
131
|
-
] : protocol === 'ag-ui' ? [
|
|
132
|
-
'strands-agents',
|
|
133
|
-
'strands-agents-tools',
|
|
134
|
-
'ag-ui-protocol',
|
|
135
|
-
'ag-ui-strands'
|
|
136
|
-
] : [
|
|
137
|
-
'strands-agents',
|
|
138
|
-
'strands-agents-tools'
|
|
139
|
-
],
|
|
140
|
-
'uvicorn'
|
|
141
|
-
]);
|
|
142
|
-
addDependenciesToDependencyGroupInPyProjectToml(tree, project.root, 'dev', [
|
|
143
|
-
'fastapi[standard]'
|
|
144
|
-
]);
|
|
145
249
|
if (infra === 'agentcore') {
|
|
146
250
|
const containers = await resolveContainers(tree, 'inherit');
|
|
147
251
|
const dockerImageTag = `${getNpmScope(tree)}-${name}:latest`;
|
|
@@ -162,7 +266,7 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
162
266
|
const dockerOutputDir = joinPathFragments('dist', project.root, 'docker', name);
|
|
163
267
|
const dockerTargetName = `${agentTargetPrefix}-docker`;
|
|
164
268
|
// Add a docker target that prepares the docker context and builds the image
|
|
165
|
-
const fs = new FsCommands(tree);
|
|
269
|
+
const fs = new FsCommands(tree, DEPENDENCIES);
|
|
166
270
|
project.targets[dockerTargetName] = {
|
|
167
271
|
cache: true,
|
|
168
272
|
executor: 'nx:run-commands',
|
|
@@ -190,12 +294,11 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
190
294
|
imageTags: [
|
|
191
295
|
dockerImageTag
|
|
192
296
|
]
|
|
193
|
-
});
|
|
297
|
+
}, DEPENDENCIES);
|
|
194
298
|
// Add shared constructs
|
|
195
|
-
const iac = await resolveIac(tree, options.iac);
|
|
196
299
|
await sharedConstructsGenerator(tree, {
|
|
197
300
|
iac
|
|
198
|
-
});
|
|
301
|
+
}, DEPENDENCIES);
|
|
199
302
|
// Add the construct to deploy the agent.
|
|
200
303
|
// AG-UI uses HTTP as the AgentCore protocol type (AG-UI is HTTP-based with SSE over POST).
|
|
201
304
|
const infraProtocol = protocol === 'ag-ui' ? 'http' : protocol;
|
|
@@ -220,6 +323,25 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
220
323
|
name: agentTargetPrefix
|
|
221
324
|
}
|
|
222
325
|
});
|
|
326
|
+
// Recorded below and read by the declaration's predicates, so the packages
|
|
327
|
+
// added here are exactly the ones the version sync will own.
|
|
328
|
+
const metadata = {
|
|
329
|
+
port: localDevPort,
|
|
330
|
+
rc: agentNameClassName,
|
|
331
|
+
auth,
|
|
332
|
+
protocol,
|
|
333
|
+
framework,
|
|
334
|
+
...iac ? {
|
|
335
|
+
iac
|
|
336
|
+
} : {}
|
|
337
|
+
};
|
|
338
|
+
addPyDependencies(tree, DEPENDENCIES, {
|
|
339
|
+
metadata,
|
|
340
|
+
projectRoot: project.root
|
|
341
|
+
});
|
|
342
|
+
addTsDependencies(tree, DEPENDENCIES, {
|
|
343
|
+
metadata
|
|
344
|
+
});
|
|
223
345
|
// All protocols use fastapi dev for hot reload:
|
|
224
346
|
// - HTTP: FastAPI app directly defined in init.py
|
|
225
347
|
// - A2A: A2AServer.to_fastapi_app() creates a FastAPI app in main.py
|
|
@@ -256,23 +378,6 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
256
378
|
agentNameClassName,
|
|
257
379
|
auth
|
|
258
380
|
});
|
|
259
|
-
// TypeScript deps for the chat CLI, which runs standalone via tsx for every
|
|
260
|
-
// protocol and resolves the deployed agent from AppConfig. `agent-chat-cli`
|
|
261
|
-
// transitively bundles the protocol clients (@a2a-js/sdk, @ag-ui/client).
|
|
262
|
-
addDependenciesToPackageJson(tree, {}, withVersions([
|
|
263
|
-
'agent-chat-cli',
|
|
264
|
-
'tsx',
|
|
265
|
-
'@types/node',
|
|
266
|
-
'@aws-lambda-powertools/parameters',
|
|
267
|
-
'@aws-sdk/client-appconfigdata',
|
|
268
|
-
...auth === 'iam' ? [
|
|
269
|
-
'aws4fetch',
|
|
270
|
-
'@aws-sdk/credential-providers'
|
|
271
|
-
] : [],
|
|
272
|
-
...protocol === 'a2a' ? [
|
|
273
|
-
'@a2a-js/sdk'
|
|
274
|
-
] : []
|
|
275
|
-
]));
|
|
276
381
|
const chatUrl = protocol === 'ag-ui' ? `http://localhost:${localDevPort}/invocations` : `http://localhost:${localDevPort}`;
|
|
277
382
|
const chatCommand = `tsx ./scripts/${agentTargetPrefix}/chat.ts`;
|
|
278
383
|
const httpOnlyTargets = protocol === 'http' ? {
|
|
@@ -367,15 +472,7 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
367
472
|
...project,
|
|
368
473
|
targets: sortObjectKeys(agentTargets)
|
|
369
474
|
});
|
|
370
|
-
addComponentGeneratorMetadata(tree, project.name, PY_AGENT_GENERATOR_INFO, toProjectRelativePath(project, targetSourceDir), agentTargetPrefix,
|
|
371
|
-
port: localDevPort,
|
|
372
|
-
rc: agentNameClassName,
|
|
373
|
-
auth,
|
|
374
|
-
protocol,
|
|
375
|
-
// The mcp / gateway connection generators dispatch on this field to pick
|
|
376
|
-
// the Strands vs LangChain Layer-2 client + agent.py transform.
|
|
377
|
-
framework
|
|
378
|
-
});
|
|
475
|
+
addComponentGeneratorMetadata(tree, project.name, PY_AGENT_GENERATOR_INFO, toProjectRelativePath(project, targetSourceDir), agentTargetPrefix, metadata);
|
|
379
476
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
380
477
|
PY_AGENT_GENERATOR_INFO
|
|
381
478
|
]);
|