@aws/nx-plugin 1.0.0-rc.54 → 1.0.0-rc.56
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 +50 -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/migrations/latest/dynamodb-local-remove-optimize-flag/migration.d.ts +6 -0
- package/src/migrations/latest/dynamodb-local-remove-optimize-flag/migration.js +89 -0
- package/src/migrations/latest/dynamodb-local-remove-optimize-flag/migration.js.map +1 -0
- package/src/migrations/latest/modernize-function-props-cast/migration.js +0 -1
- package/src/migrations/latest/modernize-function-props-cast/migration.js.map +1 -1
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js +0 -1
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js.map +1 -1
- package/src/migrations/latest/restrict-cors-to-custom-domains/migration.js +0 -2
- package/src/migrations/latest/restrict-cors-to-custom-domains/migration.js.map +1 -1
- package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.js +0 -1
- package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.js.map +1 -1
- package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.js +0 -2
- package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.js.map +1 -1
- 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/__snapshots__/generator.spec.ts.snap +0 -2
- 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/__snapshots__/generator.spec.ts.snap +0 -2
- 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/files/migration.ts.template +4 -0
- 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/files/common/scripts/src/dynamodb/start-container.ts.template +0 -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 +25 -6
- package/src/utils/migration-versions.js +72 -14
- 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 +45 -0
- package/src/utils/version-upgrade-migration/nx-package-updates.js +50 -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 +23 -0
- package/src/utils/version-upgrade-migration/register.js +38 -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
package/src/preset/generator.js
CHANGED
|
@@ -6,12 +6,21 @@ import { execSync } from "child_process";
|
|
|
6
6
|
import enquirer from "enquirer";
|
|
7
7
|
import { readFileSync } from "fs";
|
|
8
8
|
import { ensureAwsNxPluginConfig, updateAwsNxPluginConfig } from "../utils/config/utils.js";
|
|
9
|
+
import { declareDependencies } from "../utils/declared-dependencies.js";
|
|
9
10
|
import { addDependenciesToPackageJson } from "../utils/dependencies.js";
|
|
10
11
|
import { formatFilesInSubtree } from "../utils/format.js";
|
|
11
|
-
import { applyWorkspaceInit } from "../utils/init.js";
|
|
12
|
+
import { applyWorkspaceInit, INIT_DEPENDENCIES } from "../utils/init.js";
|
|
12
13
|
import { installDependencies } from "../utils/install.js";
|
|
13
14
|
import { getGeneratorInfo } from "../utils/nx.js";
|
|
14
15
|
import { withVersions } from "../utils/versions.js";
|
|
16
|
+
export const DEPENDENCIES = declareDependencies()({
|
|
17
|
+
ts: [
|
|
18
|
+
{
|
|
19
|
+
name: 'husky'
|
|
20
|
+
},
|
|
21
|
+
...INIT_DEPENDENCIES
|
|
22
|
+
]
|
|
23
|
+
});
|
|
15
24
|
export const PRESET_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
16
25
|
/**
|
|
17
26
|
* Determines if the current user is an Amazon employee based on their git configuration.
|
|
@@ -72,7 +81,7 @@ const setUpGitSecrets = (tree)=>{
|
|
|
72
81
|
prepare: 'husky'
|
|
73
82
|
}
|
|
74
83
|
}));
|
|
75
|
-
addDependenciesToPackageJson(tree, {}, withVersions([
|
|
84
|
+
addDependenciesToPackageJson(tree, {}, withVersions(DEPENDENCIES, [
|
|
76
85
|
'husky'
|
|
77
86
|
]));
|
|
78
87
|
};
|
|
@@ -112,7 +121,7 @@ export const presetGenerator = async (tree, { iac, gitSecrets, mcp, containers,
|
|
|
112
121
|
catalogs: catalog ?? true,
|
|
113
122
|
readmeOverwriteStrategy: OverwriteStrategy.Overwrite,
|
|
114
123
|
overwriteScripts: true
|
|
115
|
-
});
|
|
124
|
+
}, DEPENDENCIES);
|
|
116
125
|
tree.delete('apps/.gitkeep');
|
|
117
126
|
tree.delete('libs/.gitkeep');
|
|
118
127
|
tree.write('packages/.gitkeep', '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/preset/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 joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { execSync } from 'child_process';\nimport enquirer from 'enquirer';\nimport { readFileSync } from 'fs';\nimport {\n ensureAwsNxPluginConfig,\n updateAwsNxPluginConfig,\n} from '../utils/config/utils';\nimport { addDependenciesToPackageJson } from '../utils/dependencies';\nimport { formatFilesInSubtree } from '../utils/format';\nimport { applyWorkspaceInit } from '../utils/init';\nimport { installDependencies } from '../utils/install';\nimport { getGeneratorInfo, type NxGeneratorInfo } from '../utils/nx';\nimport { withVersions } from '../utils/versions';\nimport type { PresetGeneratorSchema } from './schema';\n\nexport const PRESET_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Determines if the current user is an Amazon employee based on their git configuration.\n *\n * This function checks the git user email configuration to identify Amazon employees\n * by looking for email addresses with Amazon domains (e.g., @amazon.com, @amazon.co.uk).\n *\n * @returns {boolean} True if the user's git email has an Amazon domain, false otherwise\n *\n * @example\n * // Returns true for Amazon employee emails\n * // git config user.email = \"john.doe@amazon.com\"\n * isAmazonian(); // true\n *\n * @example\n * // Returns false for non-Amazon emails\n * // git config user.email = \"user@example.com\"\n * isAmazonian(); // false\n *\n * @example\n * // Returns false when git config is not available or throws an error\n * isAmazonian(); // false\n */\nexport function isAmazonian(): boolean {\n try {\n // Execute git command to retrieve the user's configured email address\n const gitEmail = execSync('git config user.email', {\n encoding: 'utf8',\n }).trim();\n\n // Return false if no email is configured\n if (!gitEmail) {\n return false;\n }\n\n // Split email address to extract domain part\n const emailParts = gitEmail.split('@');\n if (emailParts.length < 2) {\n return false;\n }\n\n // Extract domain and normalize to lowercase for comparison\n const domain = emailParts[1].toLowerCase();\n\n // Check if domain starts with 'amazon.' (covers amazon.com, amazon.co.uk, etc.)\n return domain.startsWith('amazon.');\n } catch (error) {\n // Return false if git command fails or any other error occurs\n // This handles cases where git is not installed or configured\n return false;\n }\n}\n\nconst setUpGitSecrets = (tree: Tree) => {\n const gitSecretsDir = joinPathFragments(\n import.meta.dirname,\n 'git-secrets-files',\n 'git-secrets-dir',\n );\n const huskyDir = joinPathFragments(\n import.meta.dirname,\n 'git-secrets-files',\n 'husky-dir',\n );\n\n tree.write(\n '.git-secrets/git-secrets',\n readFileSync(joinPathFragments(gitSecretsDir, 'git-secrets'), 'utf-8'),\n );\n tree.write(\n '.husky/pre-commit',\n readFileSync(joinPathFragments(huskyDir, 'pre-commit'), 'utf-8'),\n );\n tree.write('.gitallowed', '\\\\.git-secrets/git-secrets:\\n');\n\n updateJson(tree, 'package.json', (json) => ({\n ...json,\n scripts: {\n ...json.scripts,\n prepare: 'husky',\n },\n }));\n\n addDependenciesToPackageJson(tree, {}, withVersions(['husky']));\n};\n\nexport const presetGenerator = async (\n tree: Tree,\n {\n iac,\n gitSecrets,\n mcp,\n containers,\n module,\n catalog,\n preferInstallDependencies,\n }: PresetGeneratorSchema,\n): Promise<GeneratorCallback> => {\n if (\n isAmazonian() &&\n !process.env.VITEST &&\n !process.env.CI &&\n process.env.NX_DRY_RUN !== 'true' &&\n process.env.NX_INTERACTIVE !== 'false'\n ) {\n const { engagementId } = await enquirer.prompt<{ engagementId?: string }>([\n {\n name: 'engagementId',\n message: 'Please enter your engagementId (if known)',\n type: 'input',\n initial: 'None',\n },\n ]);\n\n if (engagementId != 'None') {\n await ensureAwsNxPluginConfig(tree);\n await updateAwsNxPluginConfig(tree, { tags: [engagementId] });\n }\n }\n\n // The preset owns the greenfield workspace's module format: write the root\n // `type` explicitly from the chosen `--module` so later generators can\n // infer it. The `init` generator never touches an existing workspace's\n // `type` field.\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n type: (module ?? 'esm') === 'esm' ? 'module' : 'commonjs',\n }));\n\n // Apply the deterministic workspace configuration shared with the `init`\n // generator. The preset owns the README of a greenfield workspace.\n await applyWorkspaceInit(tree
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/preset/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 joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { execSync } from 'child_process';\nimport enquirer from 'enquirer';\nimport { readFileSync } from 'fs';\nimport {\n ensureAwsNxPluginConfig,\n updateAwsNxPluginConfig,\n} from '../utils/config/utils';\nimport { declareDependencies } from '../utils/declared-dependencies';\nimport { addDependenciesToPackageJson } from '../utils/dependencies';\nimport { formatFilesInSubtree } from '../utils/format';\nimport { applyWorkspaceInit, INIT_DEPENDENCIES } from '../utils/init';\nimport { installDependencies } from '../utils/install';\nimport { getGeneratorInfo, type NxGeneratorInfo } from '../utils/nx';\nimport { withVersions } from '../utils/versions';\nimport type { PresetGeneratorSchema } from './schema';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [{ name: 'husky' }, ...INIT_DEPENDENCIES],\n});\n\nexport const PRESET_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Determines if the current user is an Amazon employee based on their git configuration.\n *\n * This function checks the git user email configuration to identify Amazon employees\n * by looking for email addresses with Amazon domains (e.g., @amazon.com, @amazon.co.uk).\n *\n * @returns {boolean} True if the user's git email has an Amazon domain, false otherwise\n *\n * @example\n * // Returns true for Amazon employee emails\n * // git config user.email = \"john.doe@amazon.com\"\n * isAmazonian(); // true\n *\n * @example\n * // Returns false for non-Amazon emails\n * // git config user.email = \"user@example.com\"\n * isAmazonian(); // false\n *\n * @example\n * // Returns false when git config is not available or throws an error\n * isAmazonian(); // false\n */\nexport function isAmazonian(): boolean {\n try {\n // Execute git command to retrieve the user's configured email address\n const gitEmail = execSync('git config user.email', {\n encoding: 'utf8',\n }).trim();\n\n // Return false if no email is configured\n if (!gitEmail) {\n return false;\n }\n\n // Split email address to extract domain part\n const emailParts = gitEmail.split('@');\n if (emailParts.length < 2) {\n return false;\n }\n\n // Extract domain and normalize to lowercase for comparison\n const domain = emailParts[1].toLowerCase();\n\n // Check if domain starts with 'amazon.' (covers amazon.com, amazon.co.uk, etc.)\n return domain.startsWith('amazon.');\n } catch (error) {\n // Return false if git command fails or any other error occurs\n // This handles cases where git is not installed or configured\n return false;\n }\n}\n\nconst setUpGitSecrets = (tree: Tree) => {\n const gitSecretsDir = joinPathFragments(\n import.meta.dirname,\n 'git-secrets-files',\n 'git-secrets-dir',\n );\n const huskyDir = joinPathFragments(\n import.meta.dirname,\n 'git-secrets-files',\n 'husky-dir',\n );\n\n tree.write(\n '.git-secrets/git-secrets',\n readFileSync(joinPathFragments(gitSecretsDir, 'git-secrets'), 'utf-8'),\n );\n tree.write(\n '.husky/pre-commit',\n readFileSync(joinPathFragments(huskyDir, 'pre-commit'), 'utf-8'),\n );\n tree.write('.gitallowed', '\\\\.git-secrets/git-secrets:\\n');\n\n updateJson(tree, 'package.json', (json) => ({\n ...json,\n scripts: {\n ...json.scripts,\n prepare: 'husky',\n },\n }));\n\n addDependenciesToPackageJson(tree, {}, withVersions(DEPENDENCIES, ['husky']));\n};\n\nexport const presetGenerator = async (\n tree: Tree,\n {\n iac,\n gitSecrets,\n mcp,\n containers,\n module,\n catalog,\n preferInstallDependencies,\n }: PresetGeneratorSchema,\n): Promise<GeneratorCallback> => {\n if (\n isAmazonian() &&\n !process.env.VITEST &&\n !process.env.CI &&\n process.env.NX_DRY_RUN !== 'true' &&\n process.env.NX_INTERACTIVE !== 'false'\n ) {\n const { engagementId } = await enquirer.prompt<{ engagementId?: string }>([\n {\n name: 'engagementId',\n message: 'Please enter your engagementId (if known)',\n type: 'input',\n initial: 'None',\n },\n ]);\n\n if (engagementId != 'None') {\n await ensureAwsNxPluginConfig(tree);\n await updateAwsNxPluginConfig(tree, { tags: [engagementId] });\n }\n }\n\n // The preset owns the greenfield workspace's module format: write the root\n // `type` explicitly from the chosen `--module` so later generators can\n // infer it. The `init` generator never touches an existing workspace's\n // `type` field.\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n type: (module ?? 'esm') === 'esm' ? 'module' : 'commonjs',\n }));\n\n // Apply the deterministic workspace configuration shared with the `init`\n // generator. The preset owns the README of a greenfield workspace.\n await applyWorkspaceInit(\n tree,\n {\n iac,\n containers,\n mcp,\n catalogs: catalog ?? true,\n readmeOverwriteStrategy: OverwriteStrategy.Overwrite,\n overwriteScripts: true,\n },\n DEPENDENCIES,\n );\n\n tree.delete('apps/.gitkeep');\n tree.delete('libs/.gitkeep');\n tree.write('packages/.gitkeep', '');\n\n if (gitSecrets !== false) {\n setUpGitSecrets(tree);\n }\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default presetGenerator;\n"],"names":["joinPathFragments","OverwriteStrategy","updateJson","execSync","enquirer","readFileSync","ensureAwsNxPluginConfig","updateAwsNxPluginConfig","declareDependencies","addDependenciesToPackageJson","formatFilesInSubtree","applyWorkspaceInit","INIT_DEPENDENCIES","installDependencies","getGeneratorInfo","withVersions","DEPENDENCIES","ts","name","PRESET_GENERATOR_INFO","filename","isAmazonian","gitEmail","encoding","trim","emailParts","split","length","domain","toLowerCase","startsWith","error","setUpGitSecrets","tree","gitSecretsDir","dirname","huskyDir","write","json","scripts","prepare","presetGenerator","iac","gitSecrets","mcp","containers","module","catalog","preferInstallDependencies","process","env","VITEST","CI","NX_DRY_RUN","NX_INTERACTIVE","engagementId","prompt","message","type","initial","tags","packageJson","catalogs","readmeOverwriteStrategy","Overwrite","overwriteScripts","delete","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,iBAAiB,EACjB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AG;QACAD;QACAkB,UAAUf,WAAW;QACrBgB,yBAAyB9D,kBAAkB+D,SAAS;QACpDC,kBAAkB;IACpB,GACAjD;IAGFiB,KAAKiC,MAAM,CAAC;IACZjC,KAAKiC,MAAM,CAAC;IACZjC,KAAKI,KAAK,CAAC,qBAAqB;IAEhC,IAAIM,eAAe,OAAO;QACxBX,gBAAgBC;IAClB;IAEA,MAAMvB,qBAAqBuB;IAC3B,OAAO,IACLpB,oBAAoBoB,MAAMe,2BAA2B;YACnDmB,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe1B,gBAAgB"}
|
|
@@ -3,8 +3,32 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
|
+
import { type AgentFramework } from '../../../utils/agent-connection/agent-connection';
|
|
6
7
|
import { type NxGeneratorInfo } from '../../../utils/nx';
|
|
7
8
|
import type { PyAgentA2aConnectionGeneratorSchema } from './schema';
|
|
9
|
+
/** The metadata this generator records, which its predicates read. */
|
|
10
|
+
export interface PyAgentA2aConnectionMetadata {
|
|
11
|
+
readonly framework: AgentFramework;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEPENDENCIES: import("../../../utils/declared-dependencies").DependencyDeclaration<readonly import("../../../utils/declared-dependencies").DeclaredTsDependency<"@a2a-js/sdk" | "@aws/aws-distro-opentelemetry-node-autoinstrumentation" | "@opentelemetry/propagator-jaeger" | "minimatch" | "@aws-sdk/client-dynamodb" | "@aws-sdk/client-api-gateway" | "@aws-sdk/client-iam" | "@aws-sdk/client-bedrock-agentcore" | "@aws-sdk/client-bedrock-runtime" | "@aws-sdk/client-s3" | "@aws-sdk/client-sts" | "@aws-sdk/credential-providers" | "@aws-sdk/credential-provider-cognito-identity" | "@aws-sdk/client-secrets-manager" | "@aws-sdk/rds-signer" | "@aws-smithy/server-apigateway" | "@aws-smithy/server-node" | "@aws-lambda-powertools/logger" | "@aws-lambda-powertools/metrics" | "@aws-lambda-powertools/parameters" | "@aws-lambda-powertools/tracer" | "@aws-lambda-powertools/parser" | "@aws-sdk/client-appconfigdata" | "@middy/core" | "@nxlv/python" | "@nx-extend/terraform" | "nx" | "@nx/devkit" | "@nx/js" | "@nx/react" | "@nx/vite" | "@nx/vitest" | "@nx/workspace" | "create-nx-workspace" | "@swc-node/register" | "@swc/core" | "@modelcontextprotocol/sdk" | "@modelcontextprotocol/inspector" | "@ag-ui/a2ui-toolkit" | "@ag-ui/aws-strands" | "@ag-ui/client" | "@ag-ui/core" | "@ag-ui/encoder" | "agent-chat-cli" | "@copilotkit/react-core" | "rxjs" | "@strands-agents/sdk" | "@tanstack/react-router" | "@tanstack/router-plugin" | "@tanstack/router-generator" | "@tanstack/virtual-file-routes" | "@tanstack/router-utils" | "@cloudscape-design/board-components" | "@cloudscape-design/chat-components" | "@cloudscape-design/components" | "@cloudscape-design/global-styles" | "@tanstack/react-query" | "@tanstack/react-query-devtools" | "@trpc/tanstack-react-query" | "@trpc/client" | "@trpc/server" | "@types/node" | "@types/aws-lambda" | "@types/cors" | "@types/pg" | "@types/ws" | "@types/express" | "@smithy/config-resolver" | "@smithy/node-config-provider" | "@smithy/node-http-handler" | "@smithy/types" | "@vitest/coverage-v8" | "@vitest/ui" | "@astrojs/react" | "@astrojs/starlight" | "astro" | "aws4fetch" | "aws-cdk" | "aws-cdk-lib" | "aws-xray-sdk-core" | "constructs" | "cors" | "chalk" | "class-variance-authority" | "clsx" | "commander" | "electrodb" | "esbuild" | "event-source-polyfill" | "@types/event-source-polyfill" | "@biomejs/biome" | "@prisma/adapter-mariadb" | "@prisma/adapter-pg" | "@prisma/client" | "ejs" | "@types/ejs" | "express" | "fast-glob" | "husky" | "fs-extra" | "@types/fs-extra" | "make-dir-cli" | "mariadb" | "ncp" | "npm" | "npm-check-updates" | "oidc-client-ts" | "pg" | "prisma" | "react-oidc-context" | "react" | "react-dom" | "rimraf" | "rolldown" | "simple-git" | "source-map-support" | "starlight-blog" | "tailwindcss" | "@tailwindcss/vite" | "tsx" | "lucide-react" | "radix-ui" | "shadcn" | "tw-animate-css" | "tailwind-merge" | "vite" | "typescript" | "vitest" | "zod" | "ws", PyAgentA2aConnectionMetadata>[], readonly [{
|
|
14
|
+
readonly name: "boto3";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "httpx";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "strands-agents[a2a]";
|
|
19
|
+
readonly when: (m: PyAgentA2aConnectionMetadata) => boolean;
|
|
20
|
+
}, {
|
|
21
|
+
readonly name: "a2a-sdk";
|
|
22
|
+
readonly when: (m: PyAgentA2aConnectionMetadata) => boolean;
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "aws-lambda-powertools";
|
|
25
|
+
} & {
|
|
26
|
+
versionOnly: true;
|
|
27
|
+
}, {
|
|
28
|
+
readonly name: "strands-agents";
|
|
29
|
+
} & {
|
|
30
|
+
versionOnly: true;
|
|
31
|
+
}]>;
|
|
8
32
|
export declare const PY_AGENT_A2A_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
33
|
export declare const pyAgentA2aConnectionGenerator: (tree: Tree, options: PyAgentA2aConnectionGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
34
|
export default pyAgentA2aConnectionGenerator;
|
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/ import { generateFiles, joinPathFragments, OverwriteStrategy, updateProjectConfiguration } from "@nx/devkit";
|
|
5
|
-
import {
|
|
5
|
+
import { addPyDependencies } from "../../../utils/add-dependencies.js";
|
|
6
|
+
import { AGENT_CONNECTION_PY_DEPENDENCIES, addPythonCoreClient, addPythonReExport, ensurePythonAgentConnectionProject, getPythonAgentConnectionModuleName, getPythonAgentConnectionProject, getPythonAgentConnectionProjectDir, PY_CLIENT_NAMING, resolveAgentFramework } from "../../../utils/agent-connection/agent-connection.js";
|
|
6
7
|
import { addPythonDestructuredImport, applyGritQL, matchGritQL } from "../../../utils/ast.js";
|
|
8
|
+
import { declareDependencies, ownedElsewhere } from "../../../utils/declared-dependencies.js";
|
|
7
9
|
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
8
10
|
import { installDependencies } from "../../../utils/install.js";
|
|
9
11
|
import { addGeneratorMetricsIfApplicable } from "../../../utils/metrics.js";
|
|
10
12
|
import { snakeCase } from "../../../utils/names.js";
|
|
11
|
-
import { addDependencyToTargetIfNotPresent, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
12
|
-
import {
|
|
13
|
+
import { addComponentGeneratorMetadata, addDependencyToTargetIfNotPresent, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
14
|
+
import { toProjectRelativePath } from "../../../utils/paths.js";
|
|
15
|
+
import { addWorkspaceDependencyToPyProject } from "../../../utils/py.js";
|
|
13
16
|
/** Prefix a GritQL pattern with `language python` */ const py = (pattern)=>`language python\n${pattern}`;
|
|
14
17
|
/** The module each framework imports the `tool` decorator from. */ const TOOL_IMPORT_MODULE = {
|
|
15
18
|
strands: 'strands',
|
|
@@ -19,14 +22,28 @@ import { addDependenciesToPyProjectToml, addWorkspaceDependencyToPyProject } fro
|
|
|
19
22
|
strands: 'yield Agent($_)',
|
|
20
23
|
langchain: 'create_agent($_)'
|
|
21
24
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
25
|
+
// Each framework's Layer-2 client needs its own A2A transport: Strands wraps
|
|
26
|
+
// strands' `A2AAgent` (strands-agents[a2a]); LangChain drives the a2a SDK
|
|
27
|
+
// directly (a2a-sdk) and must not pull Strands in.
|
|
28
|
+
export const DEPENDENCIES = declareDependencies()({
|
|
29
|
+
py: [
|
|
30
|
+
{
|
|
31
|
+
name: 'boto3'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'httpx'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'strands-agents[a2a]',
|
|
38
|
+
when: (m)=>m.framework === 'strands'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'a2a-sdk',
|
|
42
|
+
when: (m)=>m.framework === 'langchain'
|
|
43
|
+
},
|
|
44
|
+
...ownedElsewhere(AGENT_CONNECTION_PY_DEPENDENCIES)
|
|
45
|
+
]
|
|
46
|
+
});
|
|
30
47
|
export const PY_AGENT_A2A_CONNECTION_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
31
48
|
export const pyAgentA2aConnectionGenerator = async (tree, options)=>{
|
|
32
49
|
const sourceProject = readProjectConfigurationUnqualified(tree, options.sourceProject);
|
|
@@ -48,26 +65,31 @@ export const pyAgentA2aConnectionGenerator = async (tree, options)=>{
|
|
|
48
65
|
const targetAgentPort = targetAgentComponent.port ?? 9000;
|
|
49
66
|
// The source agent's framework drives everything that varies: the client
|
|
50
67
|
// naming + app template (shared with the mcp/gateway generators via
|
|
51
|
-
// PY_CLIENT_NAMING), the A2A transport dep (see
|
|
68
|
+
// PY_CLIENT_NAMING), the A2A transport dep (see DEPENDENCIES), and the
|
|
52
69
|
// agent.py transform below. Each framework wraps its own A2A Layer-2 client
|
|
53
70
|
// (Strands' A2AAgent vs an a2a-sdk-only client) over the shared,
|
|
54
71
|
// framework-agnostic A2A client config. Keyed on the framework, not a
|
|
55
72
|
// boolean, so a third framework stays additive.
|
|
56
73
|
const framework = resolveAgentFramework(agentComponent.framework);
|
|
57
74
|
const naming = PY_CLIENT_NAMING[framework];
|
|
75
|
+
// Recorded below and read by the declaration's predicates, so the packages
|
|
76
|
+
// added here are exactly the ones the version sync will own.
|
|
77
|
+
const metadata = {
|
|
78
|
+
framework
|
|
79
|
+
};
|
|
58
80
|
// 1. Ensure the shared Python agent-connection project exists + has the
|
|
59
81
|
// A2A core client (framework Layer-2) and its shared SigV4 auth helper.
|
|
60
|
-
await ensurePythonAgentConnectionProject(tree);
|
|
61
|
-
await addPythonCoreClient(tree, 'a2a', framework);
|
|
82
|
+
await ensurePythonAgentConnectionProject(tree, DEPENDENCIES);
|
|
83
|
+
await addPythonCoreClient(tree, 'a2a', DEPENDENCIES, framework);
|
|
62
84
|
const agentConnectionProjectDir = getPythonAgentConnectionProjectDir(tree);
|
|
63
85
|
const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);
|
|
64
86
|
// A2A client config + shared auth helper deps, plus the framework's A2A
|
|
65
|
-
// transport dep
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
87
|
+
// transport dep. These belong to the shared agent-connection project, which
|
|
88
|
+
// holds the client.
|
|
89
|
+
addPyDependencies(tree, DEPENDENCIES, {
|
|
90
|
+
metadata,
|
|
91
|
+
projectRoot: agentConnectionProjectDir
|
|
92
|
+
});
|
|
71
93
|
// 2. Generate the per-connection client into the shared agent-connection project
|
|
72
94
|
const appDir = joinPathFragments(agentConnectionProjectDir, agentConnectionModuleName, 'app');
|
|
73
95
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', naming.appTemplateSubdir), appDir, {
|
|
@@ -112,6 +134,13 @@ export const pyAgentA2aConnectionGenerator = async (tree, options)=>{
|
|
|
112
134
|
});
|
|
113
135
|
updateProjectConfiguration(tree, sourceProject.name, sourceProject);
|
|
114
136
|
}
|
|
137
|
+
// Recorded so the version sync knows this connection's dependencies are ours.
|
|
138
|
+
addComponentGeneratorMetadata(tree, sourceProject.name, PY_AGENT_A2A_CONNECTION_GENERATOR_INFO, toProjectRelativePath(sourceProject, agentFilePath), targetAgentClassName, // `sourcePath` names the source component this connection is made from, so
|
|
139
|
+
// the pair is identifiable rather than just the two projects.
|
|
140
|
+
{
|
|
141
|
+
...metadata,
|
|
142
|
+
sourcePath: options.sourceComponent?.path
|
|
143
|
+
});
|
|
115
144
|
await addGeneratorMetricsIfApplicable(tree, [
|
|
116
145
|
PY_AGENT_A2A_CONNECTION_GENERATOR_INFO
|
|
117
146
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/agent/a2a-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 {\n type AgentFramework,\n addPythonCoreClient,\n addPythonReExport,\n ensurePythonAgentConnectionProject,\n getPythonAgentConnectionModuleName,\n getPythonAgentConnectionProject,\n getPythonAgentConnectionProjectDir,\n PY_CLIENT_NAMING,\n resolveAgentFramework,\n} from '../../../utils/agent-connection/agent-connection';\nimport {\n addPythonDestructuredImport,\n applyGritQL,\n matchGritQL,\n} 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 { IPyDepVersion } from '../../../utils/versions';\nimport type { PyAgentA2aConnectionGeneratorSchema } from './schema';\n\n/** Prefix a GritQL pattern with `language python` */\nconst py = (pattern: string) => `language python\\n${pattern}`;\n\n/** The module each framework imports the `tool` decorator from. */\nconst TOOL_IMPORT_MODULE: Record<AgentFramework, string> = {\n strands: 'strands',\n langchain: 'langchain_core.tools',\n};\n\n/** The GritQL pattern matching each framework's agent constructor. */\nconst AGENT_CONSTRUCTOR: Record<AgentFramework, string> = {\n strands: 'yield Agent($_)',\n langchain: 'create_agent($_)',\n};\n\n/**\n * The A2A transport dependency each framework's Layer-2 client needs. Strands\n * wraps strands' `A2AAgent` (strands-agents[a2a]); LangChain drives the a2a SDK\n * directly (a2a-sdk) and must not pull Strands in.\n */\nconst A2A_TRANSPORT_DEP: Record<AgentFramework, IPyDepVersion> = {\n strands: 'strands-agents[a2a]',\n langchain: 'a2a-sdk',\n};\n\nexport const PY_AGENT_A2A_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const pyAgentA2aConnectionGenerator = async (\n tree: Tree,\n options: PyAgentA2aConnectionGeneratorSchema,\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 const targetAgentComponent = options.targetComponent;\n\n if (!agentComponent || !targetAgentComponent) {\n throw new Error(\n 'Both sourceComponent and targetComponent must be provided for py#agent -> a2a connections',\n );\n }\n\n if ((targetAgentComponent.protocol ?? '').toLowerCase() !== 'a2a') {\n throw new Error(\n `Target agent '${targetAgentComponent.name}' uses the ${targetAgentComponent.protocol ?? 'http'} protocol — only A2A agents can be connected as tools.`,\n );\n }\n\n if (\n targetAgentComponent.auth &&\n targetAgentComponent.auth.toLowerCase() !== 'iam'\n ) {\n throw new Error(\n `A2A agent connection currently only supports IAM authentication, but '${targetAgentComponent.name}' uses '${targetAgentComponent.auth}' authentication.`,\n );\n }\n\n const targetAgentComponentName = targetAgentComponent.name ?? 'agent';\n const targetAgentClassName = targetAgentComponent.rc as string;\n const targetAgentSnakeCase = snakeCase(targetAgentClassName);\n const targetAgentPort = targetAgentComponent.port ?? 9000;\n\n // The source agent's framework drives everything that varies: the client\n // naming + app template (shared with the mcp/gateway generators via\n // PY_CLIENT_NAMING), the A2A transport dep (see A2A_TRANSPORT_DEP), and the\n // agent.py transform below. Each framework wraps its own A2A Layer-2 client\n // (Strands' A2AAgent vs an a2a-sdk-only client) over the shared,\n // framework-agnostic A2A client config. Keyed on the framework, not a\n // boolean, so a third framework stays additive.\n const framework = resolveAgentFramework(agentComponent.framework);\n const naming = PY_CLIENT_NAMING[framework];\n\n // 1. Ensure the shared Python agent-connection project exists + has the\n // A2A core client (framework Layer-2) and its shared SigV4 auth helper.\n await ensurePythonAgentConnectionProject(tree);\n await addPythonCoreClient(tree, 'a2a', framework);\n\n const agentConnectionProjectDir = getPythonAgentConnectionProjectDir(tree);\n const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);\n\n // A2A client config + shared auth helper deps, plus the framework's A2A\n // transport dep (see A2A_TRANSPORT_DEP).\n addDependenciesToPyProjectToml(tree, agentConnectionProjectDir, [\n 'boto3',\n 'httpx',\n A2A_TRANSPORT_DEP[framework],\n ]);\n\n // 2. Generate the per-connection client into the shared agent-connection project\n const appDir = joinPathFragments(\n agentConnectionProjectDir,\n agentConnectionModuleName,\n 'app',\n );\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', naming.appTemplateSubdir),\n appDir,\n {\n targetAgentSnakeCase,\n targetAgentClassName,\n targetAgentPort,\n agentConnectionModuleName,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Ensure app/__init__.py exists\n const appInitPath = joinPathFragments(appDir, '__init__.py');\n if (!tree.exists(appInitPath)) {\n tree.write(appInitPath, '');\n }\n\n // Add re-export to module __init__.py\n const moduleInitPath = joinPathFragments(\n agentConnectionProjectDir,\n agentConnectionModuleName,\n '__init__.py',\n );\n await addPythonReExport(\n tree,\n moduleInitPath,\n `.app.${targetAgentSnakeCase}_client_${naming.clientModuleSuffix}`,\n `${targetAgentClassName}Client${naming.clientClassSuffix}`,\n );\n\n // 3. Transform agent.py to add the A2A client import + wrap it as a tool\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 = `${targetAgentClassName}Client${naming.clientClassSuffix}`;\n const clientVarName = targetAgentSnakeCase;\n const toolName = `ask_${targetAgentSnakeCase}`;\n\n await addImportToAgentFile(\n tree,\n agentFilePath,\n agentConnectionModuleName,\n clientClassName,\n framework,\n );\n await addToolToAgent(tree, agentFilePath, toolName, framework);\n await addClientToolToGetAgent(\n tree,\n agentFilePath,\n clientClassName,\n clientVarName,\n toolName,\n targetAgentClassName,\n framework,\n );\n }\n\n // 4. Add workspace dependency from agent project to agent-connection project\n addWorkspaceDependencyToPyProject(\n tree,\n sourceProject,\n getPythonAgentConnectionProject(tree),\n );\n\n // 5. Set up dev target dependencies — chain onto the target agent\n const agentName = agentComponent.name ?? 'agent';\n const devTargetName = `${agentName}-dev`;\n const targetDevTargetName = `${targetAgentComponentName}-dev`;\n\n if (sourceProject.targets?.[devTargetName]) {\n addDependencyToTargetIfNotPresent(sourceProject, devTargetName, {\n projects: [targetProject.name],\n target: targetDevTargetName,\n });\n updateProjectConfiguration(tree, sourceProject.name, sourceProject);\n }\n\n await addGeneratorMetricsIfApplicable(tree, [\n PY_AGENT_A2A_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\n/**\n * Add imports to agent.py:\n * - `tool` (from `strands`, or `langchain_core.tools` for LangChain agents)\n * - the per-connection client class from the shared agent-connection module\n */\nconst addImportToAgentFile = async (\n tree: Tree,\n filePath: string,\n agentConnectionModuleName: string,\n clientClassName: string,\n framework: AgentFramework,\n): Promise<void> => {\n await addPythonDestructuredImport(\n tree,\n filePath,\n ['tool'],\n TOOL_IMPORT_MODULE[framework],\n );\n await addPythonDestructuredImport(\n tree,\n filePath,\n [clientClassName],\n agentConnectionModuleName,\n );\n};\n\n/**\n * Add the A2A tool to the Agent's tools array using GritQL.\n *\n * Scoped to the framework's agent constructor so unrelated `tools=` keyword\n * arguments elsewhere in the file are not touched.\n */\nconst addToolToAgent = async (\n tree: Tree,\n filePath: string,\n toolName: string,\n framework: AgentFramework,\n): Promise<void> => {\n const scope = AGENT_CONSTRUCTOR[framework];\n await applyGritQL(\n tree,\n filePath,\n py(`\\`tools=$old\\` where {\n $old <: within \\`${scope}\\`,\n $old <: not contains \\`${toolName}\\`,\n if ($old <: \\`[]\\`) {\n $old => \\`[${toolName}]\\`\n } else {\n $old <: \\`[$items]\\` where { $items += \\`, ${toolName}\\` }\n }\n}`),\n );\n};\n\n/**\n * Wrap the get_agent body so the remote A2A client is created and exposed\n * as a `@tool`-decorated closure before constructing the Agent.\n *\n * Unlike MCP clients, A2A clients aren't context managers — we don't need\n * a `with` block around them. Creation + tool definition happen at the\n * top of the function body, anchored on the framework's agent constructor.\n */\nconst addClientToolToGetAgent = async (\n tree: Tree,\n filePath: string,\n clientClassName: string,\n clientVarName: string,\n toolName: string,\n targetAgentClassName: string,\n framework: AgentFramework,\n): Promise<void> => {\n if (await matchGritQL(tree, filePath, py(`\\`${clientClassName}.create\\``))) {\n return;\n }\n\n // Both frameworks' tools are @tool-decorated callables (the decorator's\n // import differs, handled in addImportToAgentFile), defined inline in\n // get_agent. The client is directly callable, returning the remote's reply.\n const toolBlock = `${clientVarName} = ${clientClassName}.create()\n\n @tool\n def ${toolName}(prompt: str) -> str:\n \"\"\"Delegate a question to the remote ${targetAgentClassName} A2A agent and return its reply.\"\"\"\n return str(${clientVarName}(prompt))\n`;\n\n // Prepend client creation + tool definition to the function body, anchored on\n // the framework's agent constructor. This works whether or not a prior MCP\n // block is present since we insert before any existing statements.\n const anchor = AGENT_CONSTRUCTOR[framework];\n await applyGritQL(\n tree,\n filePath,\n py(`\\`def get_agent($params):\n $body\\` where {\n $body <: contains \\`${anchor}\\`,\n $body <: not contains \\`${clientClassName}.create\\`\n} => \\`def get_agent($params):\n ${toolBlock}\n $body\\``),\n );\n};\n\nexport default pyAgentA2aConnectionGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addPythonCoreClient","addPythonReExport","ensurePythonAgentConnectionProject","getPythonAgentConnectionModuleName","getPythonAgentConnectionProject","getPythonAgentConnectionProjectDir","PY_CLIENT_NAMING","resolveAgentFramework","addPythonDestructuredImport","applyGritQL","matchGritQL","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","snakeCase","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","addDependenciesToPyProjectToml","addWorkspaceDependencyToPyProject","py","pattern","TOOL_IMPORT_MODULE","strands","langchain","AGENT_CONSTRUCTOR","A2A_TRANSPORT_DEP","PY_AGENT_A2A_CONNECTION_GENERATOR_INFO","filename","pyAgentA2aConnectionGenerator","tree","options","sourceProject","targetProject","agentComponent","sourceComponent","targetAgentComponent","targetComponent","Error","protocol","toLowerCase","name","auth","targetAgentComponentName","targetAgentClassName","rc","targetAgentSnakeCase","targetAgentPort","port","framework","naming","agentConnectionProjectDir","agentConnectionModuleName","appDir","dirname","appTemplateSubdir","overwriteStrategy","KeepExisting","appInitPath","exists","write","moduleInitPath","clientModuleSuffix","clientClassSuffix","agentSourceDir","root","path","agentFilePath","clientClassName","clientVarName","toolName","addImportToAgentFile","addToolToAgent","addClientToolToGetAgent","agentName","devTargetName","targetDevTargetName","targets","projects","target","preferInstallDependencies","languages","filePath","scope","toolBlock","anchor"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAEEC,mBAAmB,EACnBC,iBAAiB,EACjBC,kCAAkC,EAClCC,kCAAkC,EAClCC,+BAA+B,EAC/BC,kCAAkC,EAClCC,gBAAgB,EAChBC,qBAAqB,QAChB,sDAAmD;AAC1D,SACEC,2BAA2B,EAC3BC,WAAW,EACXC,WAAW,QACN,wBAAqB;AAC5B,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,mBA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AC2B,UAAU;IAE/B,MAAMzC,4BACJsB,MACAoD,UACA;QAACd;KAAgB,EACjBhB;AAEJ;AAEA;;;;;CAKC,GACD,MAAMoB,iBAAiB,OACrB1C,MACAoD,UACAZ,UACArB;IAEA,MAAMkC,QAAQ1D,iBAAiB,CAACwB,UAAU;IAC1C,MAAMxC,YACJqB,MACAoD,UACA9D,GAAG,CAAC;mBACW,EAAE+D,MAAM;yBACF,EAAEb,SAAS;;eAErB,EAAEA,SAAS;;+CAEqB,EAAEA,SAAS;;CAEzD,CAAC;AAEF;AAEA;;;;;;;CAOC,GACD,MAAMG,0BAA0B,OAC9B3C,MACAoD,UACAd,iBACAC,eACAC,UACA1B,sBACAK;IAEA,IAAI,MAAMvC,YAAYoB,MAAMoD,UAAU9D,GAAG,CAAC,EAAE,EAAEgD,gBAAgB,SAAS,CAAC,IAAI;QAC1E;IACF;IAEA,wEAAwE;IACxE,sEAAsE;IACtE,4EAA4E;IAC5E,MAAMgB,YAAY,GAAGf,cAAc,GAAG,EAAED,gBAAgB;;;QAGlD,EAAEE,SAAS;6CAC0B,EAAE1B,qBAAqB;mBACjD,EAAEyB,cAAc;AACnC,CAAC;IAEC,8EAA8E;IAC9E,2EAA2E;IAC3E,mEAAmE;IACnE,MAAMgB,SAAS5D,iBAAiB,CAACwB,UAAU;IAC3C,MAAMxC,YACJqB,MACAoD,UACA9D,GAAG,CAAC;;sBAEc,EAAEiE,OAAO;0BACL,EAAEjB,gBAAgB;;IAExC,EAAEgB,UAAU;WACL,CAAC;AAEZ;AAEA,eAAevD,8BAA8B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/py/agent/a2a-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 { 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_CLIENT_NAMING,\n resolveAgentFramework,\n} from '../../../utils/agent-connection/agent-connection';\nimport {\n addPythonDestructuredImport,\n applyGritQL,\n matchGritQL,\n} 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 { PyAgentA2aConnectionGeneratorSchema } from './schema';\n\n/** Prefix a GritQL pattern with `language python` */\nconst py = (pattern: string) => `language python\\n${pattern}`;\n\n/** The module each framework imports the `tool` decorator from. */\nconst TOOL_IMPORT_MODULE: Record<AgentFramework, string> = {\n strands: 'strands',\n langchain: 'langchain_core.tools',\n};\n\n/** The GritQL pattern matching each framework's agent constructor. */\nconst AGENT_CONSTRUCTOR: Record<AgentFramework, string> = {\n strands: 'yield Agent($_)',\n langchain: 'create_agent($_)',\n};\n\n/** The metadata this generator records, which its predicates read. */\nexport interface PyAgentA2aConnectionMetadata {\n readonly framework: AgentFramework;\n}\n\n// Each framework's Layer-2 client needs its own A2A transport: Strands wraps\n// strands' `A2AAgent` (strands-agents[a2a]); LangChain drives the a2a SDK\n// directly (a2a-sdk) and must not pull Strands in.\nexport const DEPENDENCIES = declareDependencies<PyAgentA2aConnectionMetadata>()(\n {\n py: [\n { name: 'boto3' },\n { name: 'httpx' },\n { name: 'strands-agents[a2a]', when: (m) => m.framework === 'strands' },\n { name: 'a2a-sdk', when: (m) => m.framework === 'langchain' },\n ...ownedElsewhere(AGENT_CONNECTION_PY_DEPENDENCIES),\n ],\n },\n);\n\nexport const PY_AGENT_A2A_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const pyAgentA2aConnectionGenerator = async (\n tree: Tree,\n options: PyAgentA2aConnectionGeneratorSchema,\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 const targetAgentComponent = options.targetComponent;\n\n if (!agentComponent || !targetAgentComponent) {\n throw new Error(\n 'Both sourceComponent and targetComponent must be provided for py#agent -> a2a connections',\n );\n }\n\n if ((targetAgentComponent.protocol ?? '').toLowerCase() !== 'a2a') {\n throw new Error(\n `Target agent '${targetAgentComponent.name}' uses the ${targetAgentComponent.protocol ?? 'http'} protocol — only A2A agents can be connected as tools.`,\n );\n }\n\n if (\n targetAgentComponent.auth &&\n targetAgentComponent.auth.toLowerCase() !== 'iam'\n ) {\n throw new Error(\n `A2A agent connection currently only supports IAM authentication, but '${targetAgentComponent.name}' uses '${targetAgentComponent.auth}' authentication.`,\n );\n }\n\n const targetAgentComponentName = targetAgentComponent.name ?? 'agent';\n const targetAgentClassName = targetAgentComponent.rc as string;\n const targetAgentSnakeCase = snakeCase(targetAgentClassName);\n const targetAgentPort = targetAgentComponent.port ?? 9000;\n\n // The source agent's framework drives everything that varies: the client\n // naming + app template (shared with the mcp/gateway generators via\n // PY_CLIENT_NAMING), the A2A transport dep (see DEPENDENCIES), and the\n // agent.py transform below. Each framework wraps its own A2A Layer-2 client\n // (Strands' A2AAgent vs an a2a-sdk-only client) over the shared,\n // framework-agnostic A2A client config. Keyed on the framework, not a\n // boolean, so a third framework stays additive.\n const framework = resolveAgentFramework(agentComponent.framework);\n const naming = PY_CLIENT_NAMING[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: PyAgentA2aConnectionMetadata = { framework };\n\n // 1. Ensure the shared Python agent-connection project exists + has the\n // A2A core client (framework Layer-2) and its shared SigV4 auth helper.\n await ensurePythonAgentConnectionProject(tree, DEPENDENCIES);\n await addPythonCoreClient(tree, 'a2a', DEPENDENCIES, framework);\n\n const agentConnectionProjectDir = getPythonAgentConnectionProjectDir(tree);\n const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);\n\n // A2A client config + shared auth helper deps, plus the framework's A2A\n // transport dep. These belong to the shared agent-connection project, which\n // holds the client.\n addPyDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: agentConnectionProjectDir,\n });\n\n // 2. Generate the per-connection client into the shared agent-connection project\n const appDir = joinPathFragments(\n agentConnectionProjectDir,\n agentConnectionModuleName,\n 'app',\n );\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', naming.appTemplateSubdir),\n appDir,\n {\n targetAgentSnakeCase,\n targetAgentClassName,\n targetAgentPort,\n agentConnectionModuleName,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Ensure app/__init__.py exists\n const appInitPath = joinPathFragments(appDir, '__init__.py');\n if (!tree.exists(appInitPath)) {\n tree.write(appInitPath, '');\n }\n\n // Add re-export to module __init__.py\n const moduleInitPath = joinPathFragments(\n agentConnectionProjectDir,\n agentConnectionModuleName,\n '__init__.py',\n );\n await addPythonReExport(\n tree,\n moduleInitPath,\n `.app.${targetAgentSnakeCase}_client_${naming.clientModuleSuffix}`,\n `${targetAgentClassName}Client${naming.clientClassSuffix}`,\n );\n\n // 3. Transform agent.py to add the A2A client import + wrap it as a tool\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 = `${targetAgentClassName}Client${naming.clientClassSuffix}`;\n const clientVarName = targetAgentSnakeCase;\n const toolName = `ask_${targetAgentSnakeCase}`;\n\n await addImportToAgentFile(\n tree,\n agentFilePath,\n agentConnectionModuleName,\n clientClassName,\n framework,\n );\n await addToolToAgent(tree, agentFilePath, toolName, framework);\n await addClientToolToGetAgent(\n tree,\n agentFilePath,\n clientClassName,\n clientVarName,\n toolName,\n targetAgentClassName,\n framework,\n );\n }\n\n // 4. Add workspace dependency from agent project to agent-connection project\n addWorkspaceDependencyToPyProject(\n tree,\n sourceProject,\n getPythonAgentConnectionProject(tree),\n );\n\n // 5. Set up dev target dependencies — chain onto the target agent\n const agentName = agentComponent.name ?? 'agent';\n const devTargetName = `${agentName}-dev`;\n const targetDevTargetName = `${targetAgentComponentName}-dev`;\n\n if (sourceProject.targets?.[devTargetName]) {\n addDependencyToTargetIfNotPresent(sourceProject, devTargetName, {\n projects: [targetProject.name],\n target: targetDevTargetName,\n });\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_A2A_CONNECTION_GENERATOR_INFO,\n toProjectRelativePath(sourceProject, agentFilePath),\n targetAgentClassName,\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_A2A_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\n/**\n * Add imports to agent.py:\n * - `tool` (from `strands`, or `langchain_core.tools` for LangChain agents)\n * - the per-connection client class from the shared agent-connection module\n */\nconst addImportToAgentFile = async (\n tree: Tree,\n filePath: string,\n agentConnectionModuleName: string,\n clientClassName: string,\n framework: AgentFramework,\n): Promise<void> => {\n await addPythonDestructuredImport(\n tree,\n filePath,\n ['tool'],\n TOOL_IMPORT_MODULE[framework],\n );\n await addPythonDestructuredImport(\n tree,\n filePath,\n [clientClassName],\n agentConnectionModuleName,\n );\n};\n\n/**\n * Add the A2A tool to the Agent's tools array using GritQL.\n *\n * Scoped to the framework's agent constructor so unrelated `tools=` keyword\n * arguments elsewhere in the file are not touched.\n */\nconst addToolToAgent = async (\n tree: Tree,\n filePath: string,\n toolName: string,\n framework: AgentFramework,\n): Promise<void> => {\n const scope = AGENT_CONSTRUCTOR[framework];\n await applyGritQL(\n tree,\n filePath,\n py(`\\`tools=$old\\` where {\n $old <: within \\`${scope}\\`,\n $old <: not contains \\`${toolName}\\`,\n if ($old <: \\`[]\\`) {\n $old => \\`[${toolName}]\\`\n } else {\n $old <: \\`[$items]\\` where { $items += \\`, ${toolName}\\` }\n }\n}`),\n );\n};\n\n/**\n * Wrap the get_agent body so the remote A2A client is created and exposed\n * as a `@tool`-decorated closure before constructing the Agent.\n *\n * Unlike MCP clients, A2A clients aren't context managers — we don't need\n * a `with` block around them. Creation + tool definition happen at the\n * top of the function body, anchored on the framework's agent constructor.\n */\nconst addClientToolToGetAgent = async (\n tree: Tree,\n filePath: string,\n clientClassName: string,\n clientVarName: string,\n toolName: string,\n targetAgentClassName: string,\n framework: AgentFramework,\n): Promise<void> => {\n if (await matchGritQL(tree, filePath, py(`\\`${clientClassName}.create\\``))) {\n return;\n }\n\n // Both frameworks' tools are @tool-decorated callables (the decorator's\n // import differs, handled in addImportToAgentFile), defined inline in\n // get_agent. The client is directly callable, returning the remote's reply.\n const toolBlock = `${clientVarName} = ${clientClassName}.create()\n\n @tool\n def ${toolName}(prompt: str) -> str:\n \"\"\"Delegate a question to the remote ${targetAgentClassName} A2A agent and return its reply.\"\"\"\n return str(${clientVarName}(prompt))\n`;\n\n // Prepend client creation + tool definition to the function body, anchored on\n // the framework's agent constructor. This works whether or not a prior MCP\n // block is present since we insert before any existing statements.\n const anchor = AGENT_CONSTRUCTOR[framework];\n await applyGritQL(\n tree,\n filePath,\n py(`\\`def get_agent($params):\n $body\\` where {\n $body <: contains \\`${anchor}\\`,\n $body <: not contains \\`${clientClassName}.create\\`\n} => \\`def get_agent($params):\n ${toolBlock}\n $body\\``),\n );\n};\n\nexport default pyAgentA2aConnectionGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addPyDependencies","AGENT_CONNECTION_PY_DEPENDENCIES","addPythonCoreClient","addPythonReExport","ensurePythonAgentConnectionProject","getPythonAgentConnectionModuleName","getPythonAgentConnectionProject","getPythonAgentConnectionProjectDir","PY_CLIENT_NAMING","resolveAgentFramework","addPythonDestructuredImport","applyGritQL","matchGritQL","declareDependencies","ownedElsewhere","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","snakeCase","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","addWorkspaceDependencyToPyProject","py","pattern","TOOL_IMPORT_MODULE","strands","langchain","AGENT_CONSTRUCTOR","DEPENDENCIES","name","when","m","framework","PY_AGENT_A2A_CONNECTION_GENERATOR_INFO","filename","pyAgentA2aConnectionGenerator","tree","options","sourceProject","targetProject","agentComponent","sourceComponent","targetAgentComponent","targetComponent","Error","protocol","toLowerCase","auth","targetAgentComponentName","targetAgentClassName","rc","targetAgentSnakeCase","targetAgentPort","port","naming","metadata","agentConnectionProjectDir","agentConnectionModuleName","projectRoot","appDir","dirname","appTemplateSubdir","overwriteStrategy","KeepExisting","appInitPath","exists","write","moduleInitPath","clientModuleSuffix","clientClassSuffix","agentSourceDir","root","path","agentFilePath","clientClassName","clientVarName","toolName","addImportToAgentFile","addToolToAgent","addClientToolToGetAgent","agentName","devTargetName","targetDevTargetName","targets","projects","target","sourcePath","preferInstallDependencies","languages","filePath","scope","toolBlock","anchor"],"mappings":"AAAA;;;C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D,UACAnE,GAAG,CAAC;mBACW,EAAEoE,MAAM;yBACF,EAAEd,SAAS;;eAErB,EAAEA,SAAS;;+CAEqB,EAAEA,SAAS;;CAEzD,CAAC;AAEF;AAEA;;;;;;;CAOC,GACD,MAAMG,0BAA0B,OAC9B3C,MACAqD,UACAf,iBACAC,eACAC,UACA3B,sBACAjB;IAEA,IAAI,MAAMvB,YAAY2B,MAAMqD,UAAUnE,GAAG,CAAC,EAAE,EAAEoD,gBAAgB,SAAS,CAAC,IAAI;QAC1E;IACF;IAEA,wEAAwE;IACxE,sEAAsE;IACtE,4EAA4E;IAC5E,MAAMiB,YAAY,GAAGhB,cAAc,GAAG,EAAED,gBAAgB;;;QAGlD,EAAEE,SAAS;6CAC0B,EAAE3B,qBAAqB;mBACjD,EAAE0B,cAAc;AACnC,CAAC;IAEC,8EAA8E;IAC9E,2EAA2E;IAC3E,mEAAmE;IACnE,MAAMiB,SAASjE,iBAAiB,CAACK,UAAU;IAC3C,MAAMxB,YACJ4B,MACAqD,UACAnE,GAAG,CAAC;;sBAEc,EAAEsE,OAAO;0BACL,EAAElB,gBAAgB;;IAExC,EAAEiB,UAAU;WACL,CAAC;AAEZ;AAEA,eAAexD,8BAA8B"}
|
|
@@ -3,8 +3,31 @@
|
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
5
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
|
+
import { type AgentFramework } from '../../../utils/agent-connection/agent-connection';
|
|
6
7
|
import { type NxGeneratorInfo } from '../../../utils/nx';
|
|
7
8
|
import type { PyAgentGatewayConnectionGeneratorSchema } from './schema';
|
|
9
|
+
/** The metadata this generator records, which its predicates read. */
|
|
10
|
+
export interface PyAgentGatewayConnectionMetadata {
|
|
11
|
+
readonly framework: AgentFramework;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEPENDENCIES: import("../../../utils/declared-dependencies").DependencyDeclaration<readonly import("../../../utils/declared-dependencies").DeclaredTsDependency<"@a2a-js/sdk" | "@aws/aws-distro-opentelemetry-node-autoinstrumentation" | "@opentelemetry/propagator-jaeger" | "minimatch" | "@aws-sdk/client-dynamodb" | "@aws-sdk/client-api-gateway" | "@aws-sdk/client-iam" | "@aws-sdk/client-bedrock-agentcore" | "@aws-sdk/client-bedrock-runtime" | "@aws-sdk/client-s3" | "@aws-sdk/client-sts" | "@aws-sdk/credential-providers" | "@aws-sdk/credential-provider-cognito-identity" | "@aws-sdk/client-secrets-manager" | "@aws-sdk/rds-signer" | "@aws-smithy/server-apigateway" | "@aws-smithy/server-node" | "@aws-lambda-powertools/logger" | "@aws-lambda-powertools/metrics" | "@aws-lambda-powertools/parameters" | "@aws-lambda-powertools/tracer" | "@aws-lambda-powertools/parser" | "@aws-sdk/client-appconfigdata" | "@middy/core" | "@nxlv/python" | "@nx-extend/terraform" | "nx" | "@nx/devkit" | "@nx/js" | "@nx/react" | "@nx/vite" | "@nx/vitest" | "@nx/workspace" | "create-nx-workspace" | "@swc-node/register" | "@swc/core" | "@modelcontextprotocol/sdk" | "@modelcontextprotocol/inspector" | "@ag-ui/a2ui-toolkit" | "@ag-ui/aws-strands" | "@ag-ui/client" | "@ag-ui/core" | "@ag-ui/encoder" | "agent-chat-cli" | "@copilotkit/react-core" | "rxjs" | "@strands-agents/sdk" | "@tanstack/react-router" | "@tanstack/router-plugin" | "@tanstack/router-generator" | "@tanstack/virtual-file-routes" | "@tanstack/router-utils" | "@cloudscape-design/board-components" | "@cloudscape-design/chat-components" | "@cloudscape-design/components" | "@cloudscape-design/global-styles" | "@tanstack/react-query" | "@tanstack/react-query-devtools" | "@trpc/tanstack-react-query" | "@trpc/client" | "@trpc/server" | "@types/node" | "@types/aws-lambda" | "@types/cors" | "@types/pg" | "@types/ws" | "@types/express" | "@smithy/config-resolver" | "@smithy/node-config-provider" | "@smithy/node-http-handler" | "@smithy/types" | "@vitest/coverage-v8" | "@vitest/ui" | "@astrojs/react" | "@astrojs/starlight" | "astro" | "aws4fetch" | "aws-cdk" | "aws-cdk-lib" | "aws-xray-sdk-core" | "constructs" | "cors" | "chalk" | "class-variance-authority" | "clsx" | "commander" | "electrodb" | "esbuild" | "event-source-polyfill" | "@types/event-source-polyfill" | "@biomejs/biome" | "@prisma/adapter-mariadb" | "@prisma/adapter-pg" | "@prisma/client" | "ejs" | "@types/ejs" | "express" | "fast-glob" | "husky" | "fs-extra" | "@types/fs-extra" | "make-dir-cli" | "mariadb" | "ncp" | "npm" | "npm-check-updates" | "oidc-client-ts" | "pg" | "prisma" | "react-oidc-context" | "react" | "react-dom" | "rimraf" | "rolldown" | "simple-git" | "source-map-support" | "starlight-blog" | "tailwindcss" | "@tailwindcss/vite" | "tsx" | "lucide-react" | "radix-ui" | "shadcn" | "tw-animate-css" | "tailwind-merge" | "vite" | "typescript" | "vitest" | "zod" | "ws", PyAgentGatewayConnectionMetadata>[], readonly [{
|
|
14
|
+
readonly name: "boto3";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "httpx";
|
|
17
|
+
}, {
|
|
18
|
+
readonly name: "mcp";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "langchain-mcp-adapters";
|
|
21
|
+
readonly when: (m: PyAgentGatewayConnectionMetadata) => boolean;
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "aws-lambda-powertools";
|
|
24
|
+
} & {
|
|
25
|
+
versionOnly: true;
|
|
26
|
+
}, {
|
|
27
|
+
readonly name: "strands-agents";
|
|
28
|
+
} & {
|
|
29
|
+
versionOnly: true;
|
|
30
|
+
}]>;
|
|
8
31
|
export declare const PY_AGENT_GATEWAY_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
32
|
export declare const pyAgentGatewayConnectionGenerator: (tree: Tree, options: PyAgentGatewayConnectionGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
33
|
export default pyAgentGatewayConnectionGenerator;
|
|
@@ -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,0BAAuB;AACjD,SACEC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAoB;AAC3B,SACEC,8BAA8B,EAC9BC,iCAAiC,QAC5B,uBAAoB;AAG3B,OAAO,MAAMC,6CACXJ,iBAAiB,YAAYK,QAAQ,EAAE;AAEzC,OAAO,MAAMC,oCAAoC,OAC/CC,MACAC;IAEA,MAAMC,gBAAgBR,oCACpBM,MACAC,QAAQC,aAAa;IAEvB,MAAMC,gBAAgBT,oCACpBM,MACAC,QAAQE,aAAa;IAGvB,MAAMC,iBAAiBH,QAAQI,eAAe;IAC9C,IAAI,CAACD,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AACF,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,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