@aws/nx-plugin 1.0.6 → 1.0.7

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.
Files changed (37) hide show
  1. package/LICENSE-THIRD-PARTY +3 -3
  2. package/migrations.json +11 -1
  3. package/package.json +1 -1
  4. package/src/migrations/latest/pin-strands-express-peer/metadata.json +3 -0
  5. package/src/migrations/latest/pin-strands-express-peer/migration.d.ts +29 -0
  6. package/src/migrations/latest/pin-strands-express-peer/migration.js +58 -0
  7. package/src/migrations/latest/pin-strands-express-peer/migration.js.map +1 -0
  8. package/src/migrations/latest/rdb-drop-lambda-rie/metadata.json +3 -0
  9. package/src/migrations/latest/rdb-drop-lambda-rie/migration.d.ts +6 -0
  10. package/src/migrations/latest/rdb-drop-lambda-rie/migration.js +105 -0
  11. package/src/migrations/latest/rdb-drop-lambda-rie/migration.js.map +1 -0
  12. package/src/py/rdb/__snapshots__/generator.spec.ts.snap +20 -8
  13. package/src/py/rdb/files/Dockerfile.create-db-user.template +5 -2
  14. package/src/py/rdb/files/Dockerfile.migration.template +5 -2
  15. package/src/ts/agent/a2a-connection/generator.d.ts +26 -30
  16. package/src/ts/agent/a2a-connection/generator.js +9 -5
  17. package/src/ts/agent/a2a-connection/generator.js.map +1 -1
  18. package/src/ts/agent/gateway-connection/generator.d.ts +5 -7
  19. package/src/ts/agent/gateway-connection/generator.js +12 -0
  20. package/src/ts/agent/gateway-connection/generator.js.map +1 -1
  21. package/src/ts/agent/generator.d.ts +3 -8
  22. package/src/ts/agent/generator.js +16 -2
  23. package/src/ts/agent/generator.js.map +1 -1
  24. package/src/ts/agent/mcp-connection/generator.d.ts +5 -7
  25. package/src/ts/agent/mcp-connection/generator.js +12 -0
  26. package/src/ts/agent/mcp-connection/generator.js.map +1 -1
  27. package/src/ts/astro-docs/generator.d.ts +4 -4
  28. package/src/ts/astro-docs/generator.js +10 -4
  29. package/src/ts/astro-docs/generator.js.map +1 -1
  30. package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +4 -2
  31. package/src/ts/rdb/files/Dockerfile.template +4 -2
  32. package/src/utils/agent-connection/agent-connection.d.ts +28 -5
  33. package/src/utils/agent-connection/agent-connection.js +39 -14
  34. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  35. package/src/utils/versions.d.ts +1 -1
  36. package/src/utils/versions.js +1 -1
  37. package/src/utils/versions.js.map +1 -1
@@ -4274,7 +4274,7 @@ SOFTWARE.
4274
4274
 
4275
4275
  ---
4276
4276
 
4277
- The following software may be included in this product: @oxc-project/types (0.151.0)
4277
+ The following software may be included in this product: @oxc-project/types (0.152.0)
4278
4278
  This software contains the following license and notice below:
4279
4279
 
4280
4280
  MIT License
@@ -13381,7 +13381,7 @@ SOFTWARE.**
13381
13381
 
13382
13382
  ---
13383
13383
 
13384
- The following software may be included in this product: proxy-addr (2.0.7)
13384
+ The following software may be included in this product: proxy-addr (2.0.8)
13385
13385
  This software contains the following license and notice below:
13386
13386
 
13387
13387
  (The MIT License)
@@ -14165,7 +14165,7 @@ SOFTWARE.
14165
14165
 
14166
14166
  ---
14167
14167
 
14168
- The following software may be included in this product: rolldown (1.2.11)
14168
+ The following software may be included in this product: rolldown (1.2.12)
14169
14169
  This software contains the following license and notice below:
14170
14170
 
14171
14171
  MIT License
package/migrations.json CHANGED
@@ -2,6 +2,16 @@
2
2
  "$schema": "http://json-schema.org/schema",
3
3
  "name": "@aws/nx-plugin",
4
4
  "generators": {
5
+ "latest-pin-strands-express-peer": {
6
+ "version": "1.0.7",
7
+ "description": "Declare express in every project that declares @strands-agents/sdk without it so @strands-agents/sdk resolves to a single peer-suffixed instance",
8
+ "implementation": "./src/migrations/latest/pin-strands-express-peer/migration"
9
+ },
10
+ "latest-rdb-drop-lambda-rie": {
11
+ "version": "1.0.7",
12
+ "description": "Remove the Lambda Runtime Interface Emulator from vended ts#rdb and py#rdb Dockerfiles so its known HIGH vulnerabilities are not present in the image",
13
+ "implementation": "./src/migrations/latest/rdb-drop-lambda-rie/migration"
14
+ },
5
15
  "v1.0.0-rc.50-0001-modernize-function-props-cast": {
6
16
  "version": "1.0.0-rc.50",
7
17
  "description": "Replace the legacy angle-bracket FunctionProps type assertion with the modern as syntax in generated API constructs",
@@ -383,7 +393,7 @@
383
393
  "implementation": "./src/migrations/v1.0.5/0001-api-custom-domain-runtime-config/migration"
384
394
  },
385
395
  "sync-vended-versions": {
386
- "version": "1.0.6",
396
+ "version": "1.0.7",
387
397
  "description": "Sync vended dependency versions and the tracked plugin version to those vended by this release",
388
398
  "implementation": "./src/utils/version-upgrade-migration/migration"
389
399
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -0,0 +1,3 @@
1
+ {
2
+ "description": "Declare express in every project that declares @strands-agents/sdk without it so @strands-agents/sdk resolves to a single peer-suffixed instance"
3
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { type Tree } from '@nx/devkit';
6
+ /**
7
+ * `express` is an optional peer of `@strands-agents/sdk` that any importer
8
+ * declaring strands without also declaring express can leave undeclared. pnpm
9
+ * suffixes each installed copy of a package by the versions of its peers, so
10
+ * such an importer can resolve express to a different version than the pin
11
+ * every other strands importer uses — splitting `@strands-agents/sdk` into two
12
+ * peer-suffixed instances of the same version.
13
+ *
14
+ * Anything importing both instances then sees two nominal identities of every
15
+ * SDK type — `Agent`, `McpClient`, `Plugin` — and fails to compile with "Types
16
+ * have separate declarations of a private property". Declaring express
17
+ * wherever strands is declared keeps the whole strands subgraph on the
18
+ * catalog's single pin. Mirrors the earlier `@aws-sdk/client-s3` peer fix, one
19
+ * optional peer further on.
20
+ *
21
+ * Detection is generic — every project's `package.json` plus the workspace
22
+ * root, checked for "declares @strands-agents/sdk but not express" — rather
23
+ * than listing the generators that currently produce that shape, so a future
24
+ * strands importer this migration predates is still covered. The shared
25
+ * agent-connection project is checked explicitly too, in case its project.json
26
+ * is missing or not yet registered when this runs — `getProjects` would miss
27
+ * it then, same as rc.95's `@aws-sdk/client-s3` migration guarded against.
28
+ */
29
+ export default function migration(tree: Tree): Promise<void>;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */ import { getProjects, joinPathFragments } from "@nx/devkit";
5
+ import { AGENT_CONNECTION_PROJECT_DIR } from "../../../utils/agent-connection/agent-connection.js";
6
+ import { addDependenciesToPackageJson } from "../../../utils/dependencies.js";
7
+ import { formatFilesInSubtree } from "../../../utils/format.js";
8
+ import { TS_VERSIONS } from "../../../utils/versions.js";
9
+ const EXPRESS = 'express';
10
+ const STRANDS_SDK = '@strands-agents/sdk';
11
+ const ROOT_PACKAGE_JSON = 'package.json';
12
+ /**
13
+ * `express` is an optional peer of `@strands-agents/sdk` that any importer
14
+ * declaring strands without also declaring express can leave undeclared. pnpm
15
+ * suffixes each installed copy of a package by the versions of its peers, so
16
+ * such an importer can resolve express to a different version than the pin
17
+ * every other strands importer uses — splitting `@strands-agents/sdk` into two
18
+ * peer-suffixed instances of the same version.
19
+ *
20
+ * Anything importing both instances then sees two nominal identities of every
21
+ * SDK type — `Agent`, `McpClient`, `Plugin` — and fails to compile with "Types
22
+ * have separate declarations of a private property". Declaring express
23
+ * wherever strands is declared keeps the whole strands subgraph on the
24
+ * catalog's single pin. Mirrors the earlier `@aws-sdk/client-s3` peer fix, one
25
+ * optional peer further on.
26
+ *
27
+ * Detection is generic — every project's `package.json` plus the workspace
28
+ * root, checked for "declares @strands-agents/sdk but not express" — rather
29
+ * than listing the generators that currently produce that shape, so a future
30
+ * strands importer this migration predates is still covered. The shared
31
+ * agent-connection project is checked explicitly too, in case its project.json
32
+ * is missing or not yet registered when this runs — `getProjects` would miss
33
+ * it then, same as rc.95's `@aws-sdk/client-s3` migration guarded against.
34
+ */ export default async function migration(tree) {
35
+ pinIfNeeded(tree, ROOT_PACKAGE_JSON);
36
+ pinIfNeeded(tree, joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'package.json'));
37
+ for (const project of getProjects(tree).values()){
38
+ pinIfNeeded(tree, joinPathFragments(project.root, 'package.json'));
39
+ }
40
+ await formatFilesInSubtree(tree);
41
+ }
42
+ /** Declare express on the given manifest, if it declares strands but not express. */ function pinIfNeeded(tree, packageJsonPath) {
43
+ if (!tree.exists(packageJsonPath)) {
44
+ return;
45
+ }
46
+ const packageJson = JSON.parse(tree.read(packageJsonPath, 'utf-8') ?? '{}');
47
+ // Only where a strands client is actually declared — that is what pulls the
48
+ // optional peer. An already-declared express (even a stale range) is left to
49
+ // addDependenciesToPackageJson, which resolves it onto the catalog.
50
+ if (!packageJson.dependencies?.[STRANDS_SDK]) {
51
+ return;
52
+ }
53
+ addDependenciesToPackageJson(tree, {
54
+ [EXPRESS]: TS_VERSIONS[EXPRESS]
55
+ }, {}, packageJsonPath);
56
+ }
57
+
58
+ //# sourceMappingURL=migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/latest/pin-strands-express-peer/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { getProjects, joinPathFragments, type Tree } from '@nx/devkit';\nimport { AGENT_CONNECTION_PROJECT_DIR } from '../../../utils/agent-connection/agent-connection.js';\nimport { addDependenciesToPackageJson } from '../../../utils/dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { TS_VERSIONS } from '../../../utils/versions.js';\n\nconst EXPRESS = 'express';\nconst STRANDS_SDK = '@strands-agents/sdk';\nconst ROOT_PACKAGE_JSON = 'package.json';\n\n/**\n * `express` is an optional peer of `@strands-agents/sdk` that any importer\n * declaring strands without also declaring express can leave undeclared. pnpm\n * suffixes each installed copy of a package by the versions of its peers, so\n * such an importer can resolve express to a different version than the pin\n * every other strands importer uses — splitting `@strands-agents/sdk` into two\n * peer-suffixed instances of the same version.\n *\n * Anything importing both instances then sees two nominal identities of every\n * SDK type — `Agent`, `McpClient`, `Plugin` — and fails to compile with \"Types\n * have separate declarations of a private property\". Declaring express\n * wherever strands is declared keeps the whole strands subgraph on the\n * catalog's single pin. Mirrors the earlier `@aws-sdk/client-s3` peer fix, one\n * optional peer further on.\n *\n * Detection is generic — every project's `package.json` plus the workspace\n * root, checked for \"declares @strands-agents/sdk but not express\" — rather\n * than listing the generators that currently produce that shape, so a future\n * strands importer this migration predates is still covered. The shared\n * agent-connection project is checked explicitly too, in case its project.json\n * is missing or not yet registered when this runs — `getProjects` would miss\n * it then, same as rc.95's `@aws-sdk/client-s3` migration guarded against.\n */\nexport default async function migration(tree: Tree): Promise<void> {\n pinIfNeeded(tree, ROOT_PACKAGE_JSON);\n pinIfNeeded(\n tree,\n joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'package.json'),\n );\n\n for (const project of getProjects(tree).values()) {\n pinIfNeeded(tree, joinPathFragments(project.root, 'package.json'));\n }\n\n await formatFilesInSubtree(tree);\n}\n\n/** Declare express on the given manifest, if it declares strands but not express. */\nfunction pinIfNeeded(tree: Tree, packageJsonPath: string): void {\n if (!tree.exists(packageJsonPath)) {\n return;\n }\n\n const packageJson = JSON.parse(tree.read(packageJsonPath, 'utf-8') ?? '{}');\n // Only where a strands client is actually declared — that is what pulls the\n // optional peer. An already-declared express (even a stale range) is left to\n // addDependenciesToPackageJson, which resolves it onto the catalog.\n if (!packageJson.dependencies?.[STRANDS_SDK]) {\n return;\n }\n\n addDependenciesToPackageJson(\n tree,\n { [EXPRESS]: TS_VERSIONS[EXPRESS] },\n {},\n packageJsonPath,\n );\n}\n"],"names":["getProjects","joinPathFragments","AGENT_CONNECTION_PROJECT_DIR","addDependenciesToPackageJson","formatFilesInSubtree","TS_VERSIONS","EXPRESS","STRANDS_SDK","ROOT_PACKAGE_JSON","migration","tree","pinIfNeeded","project","values","root","packageJsonPath","exists","packageJson","JSON","parse","read","dependencies"],"mappings":"AAAA;;;CAGC,GACD,SAASA,WAAW,EAAEC,iBAAiB,QAAmB,aAAa;AACvE,SAASC,4BAA4B,QAAQ,sDAAsD;AACnG,SAASC,4BAA4B,QAAQ,iCAAiC;AAC9E,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,WAAW,QAAQ,6BAA6B;AAEzD,MAAMC,UAAU;AAChB,MAAMC,cAAc;AACpB,MAAMC,oBAAoB;AAE1B;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,eAAe,eAAeC,UAAUC,IAAU;IAChDC,YAAYD,MAAMF;IAClBG,YACED,MACAT,kBAAkBC,8BAA8B;IAGlD,KAAK,MAAMU,WAAWZ,YAAYU,MAAMG,MAAM,GAAI;QAChDF,YAAYD,MAAMT,kBAAkBW,QAAQE,IAAI,EAAE;IACpD;IAEA,MAAMV,qBAAqBM;AAC7B;AAEA,mFAAmF,GACnF,SAASC,YAAYD,IAAU,EAAEK,eAAuB;IACtD,IAAI,CAACL,KAAKM,MAAM,CAACD,kBAAkB;QACjC;IACF;IAEA,MAAME,cAAcC,KAAKC,KAAK,CAACT,KAAKU,IAAI,CAACL,iBAAiB,YAAY;IACtE,4EAA4E;IAC5E,6EAA6E;IAC7E,oEAAoE;IACpE,IAAI,CAACE,YAAYI,YAAY,EAAE,CAACd,YAAY,EAAE;QAC5C;IACF;IAEAJ,6BACEO,MACA;QAAE,CAACJ,QAAQ,EAAED,WAAW,CAACC,QAAQ;IAAC,GAClC,CAAC,GACDS;AAEJ"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "description": "Remove the Lambda Runtime Interface Emulator from vended ts#rdb and py#rdb Dockerfiles so its known HIGH vulnerabilities are not present in the image"
3
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { type MigrationReturnObject, type Tree } from '@nx/devkit';
6
+ export default function migration(tree: Tree): Promise<MigrationReturnObject>;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */ import { getProjects, joinPathFragments } from "@nx/devkit";
5
+ import { PY_RDB_GENERATOR_INFO } from "../../../py/rdb/generator.js";
6
+ import { TS_RDB_GENERATOR_INFO } from "../../../ts/rdb/generator.js";
7
+ import { formatFilesInSubtree } from "../../../utils/format.js";
8
+ /**
9
+ * Remove the Lambda Runtime Interface Emulator (RIE) from the vended ts#rdb
10
+ * and py#rdb Dockerfiles.
11
+ *
12
+ * `/lambda-entrypoint.sh` only invokes RIE when AWS_LAMBDA_RUNTIME_API is
13
+ * unset, i.e. for local `docker run` emulation outside Lambda — the deployed
14
+ * function never runs it. Its upstream build lags the Go toolchain, so it
15
+ * carries known HIGH vulnerabilities (net/http and crypto/tls DoS CVEs) the
16
+ * image scan flags with no fixed upstream image coming soon. Stripping it
17
+ * follows the same pattern the templates already use for other unused,
18
+ * vulnerable parts of the base image (py#rdb removing pip, ts#rdb removing
19
+ * the runtime's AWS SDK copy). New workspaces get this from the generator
20
+ * templates; this brings existing ones up to date.
21
+ *
22
+ * Only the three Dockerfiles the ts#rdb / py#rdb generators vend are touched,
23
+ * located from each rdb project's root (recorded in its metadata). Each is
24
+ * edited in place only where its comment + `RUN microdnf upgrade ...` block
25
+ * still has the exact shape the generator wrote before this change; one that
26
+ * has diverged (a customised comment or upgrade command) is left untouched
27
+ * and reported via `nextSteps`.
28
+ */ const AWS_LAMBDA_RIE = '/usr/local/bin/aws-lambda-rie';
29
+ /**
30
+ * The exact comment + `RUN microdnf upgrade ...` block ts#rdb's Dockerfile had
31
+ * before this migration, and what it becomes.
32
+ */ const TS_RDB_OLD_UPGRADE = `# Patch OS packages beyond the base image's pinned release, and drop the
33
+ # runtime's convenience copy of the AWS SDK (the handler bundle inlines its
34
+ # own dependencies), keeping the image free of known HIGH/CRITICAL
35
+ # vulnerabilities
36
+ RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
37
+ && rm -rf /var/runtime/node_modules/@aws-sdk`;
38
+ const TS_RDB_NEW_UPGRADE = `# Patch OS packages beyond the base image's pinned release, and drop the
39
+ # runtime's convenience copy of the AWS SDK (the handler bundle inlines its
40
+ # own dependencies), keeping the image free of known HIGH/CRITICAL
41
+ # vulnerabilities. Also drop the Lambda Runtime Interface Emulator: it is only
42
+ # used for local \`docker run\` emulation outside Lambda, never by the deployed
43
+ # function, and carries known HIGH vulnerabilities.
44
+ RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
45
+ && rm -rf /var/runtime/node_modules/@aws-sdk ${AWS_LAMBDA_RIE}`;
46
+ /**
47
+ * The exact comment + `RUN microdnf upgrade ...` block py#rdb's two Dockerfiles
48
+ * had before this migration, and what it becomes. Both Dockerfile.migration and
49
+ * Dockerfile.create-db-user share this block verbatim.
50
+ */ const PY_RDB_OLD_UPGRADE = `# Patch OS packages beyond the base image's pinned release, and drop pip, whose
51
+ # vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
52
+ # The handler's dependencies are already installed in the image, so nothing
53
+ # installs packages at runtime.
54
+ RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
55
+ && rm -rf /var/lang/lib/python*/site-packages/pip \\
56
+ /var/lang/lib/python*/site-packages/pip-*.dist-info`;
57
+ const PY_RDB_NEW_UPGRADE = `# Patch OS packages beyond the base image's pinned release, and drop pip, whose
58
+ # vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
59
+ # The handler's dependencies are already installed in the image, so nothing
60
+ # installs packages at runtime. Also drop the Lambda Runtime Interface
61
+ # Emulator: it is only used for local \`docker run\` emulation outside Lambda,
62
+ # never by the deployed function, and carries known HIGH vulnerabilities.
63
+ RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
64
+ && rm -rf /var/lang/lib/python*/site-packages/pip \\
65
+ /var/lang/lib/python*/site-packages/pip-*.dist-info \\
66
+ ${AWS_LAMBDA_RIE}`;
67
+ /** The marker checked to detect an already-migrated (or user-added) removal. */ const RIE_REMOVED_MARKER = AWS_LAMBDA_RIE;
68
+ const divergedNextStep = (filePath)=>`${filePath}: its microdnf upgrade command has been customised, so it was left unchanged. Remove the Lambda Runtime Interface Emulator by adding "${AWS_LAMBDA_RIE}" to its "rm -rf" — it is only used for local \`docker run\` emulation outside Lambda and carries known HIGH vulnerabilities.`;
69
+ /**
70
+ * Replace a Dockerfile's old comment + upgrade block with the new one, only
71
+ * when the file still has the exact shape the generator wrote. Already
72
+ * migrated and diverged files are both left alone; the latter is reported via
73
+ * nextSteps.
74
+ */ const migrateDockerfile = (tree, filePath, oldBlock, newBlock, nextSteps)=>{
75
+ if (!tree.exists(filePath)) {
76
+ return;
77
+ }
78
+ const content = tree.read(filePath, 'utf-8') ?? '';
79
+ if (content.includes(RIE_REMOVED_MARKER)) {
80
+ return; // Already migrated (or user-added).
81
+ }
82
+ if (!content.includes(oldBlock)) {
83
+ nextSteps.push(divergedNextStep(filePath));
84
+ return;
85
+ }
86
+ tree.write(filePath, content.replace(oldBlock, newBlock));
87
+ };
88
+ export default async function migration(tree) {
89
+ const nextSteps = [];
90
+ for (const project of getProjects(tree).values()){
91
+ const generator = project.metadata?.generator;
92
+ if (generator === TS_RDB_GENERATOR_INFO.id) {
93
+ migrateDockerfile(tree, joinPathFragments(project.root, 'Dockerfile'), TS_RDB_OLD_UPGRADE, TS_RDB_NEW_UPGRADE, nextSteps);
94
+ } else if (generator === PY_RDB_GENERATOR_INFO.id) {
95
+ migrateDockerfile(tree, joinPathFragments(project.root, 'Dockerfile.migration'), PY_RDB_OLD_UPGRADE, PY_RDB_NEW_UPGRADE, nextSteps);
96
+ migrateDockerfile(tree, joinPathFragments(project.root, 'Dockerfile.create-db-user'), PY_RDB_OLD_UPGRADE, PY_RDB_NEW_UPGRADE, nextSteps);
97
+ }
98
+ }
99
+ await formatFilesInSubtree(tree);
100
+ return {
101
+ nextSteps
102
+ };
103
+ }
104
+
105
+ //# sourceMappingURL=migration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/latest/rdb-drop-lambda-rie/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n joinPathFragments,\n type MigrationReturnObject,\n type Tree,\n} from '@nx/devkit';\nimport { PY_RDB_GENERATOR_INFO } from '../../../py/rdb/generator.js';\nimport { TS_RDB_GENERATOR_INFO } from '../../../ts/rdb/generator.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\n\n/**\n * Remove the Lambda Runtime Interface Emulator (RIE) from the vended ts#rdb\n * and py#rdb Dockerfiles.\n *\n * `/lambda-entrypoint.sh` only invokes RIE when AWS_LAMBDA_RUNTIME_API is\n * unset, i.e. for local `docker run` emulation outside Lambda — the deployed\n * function never runs it. Its upstream build lags the Go toolchain, so it\n * carries known HIGH vulnerabilities (net/http and crypto/tls DoS CVEs) the\n * image scan flags with no fixed upstream image coming soon. Stripping it\n * follows the same pattern the templates already use for other unused,\n * vulnerable parts of the base image (py#rdb removing pip, ts#rdb removing\n * the runtime's AWS SDK copy). New workspaces get this from the generator\n * templates; this brings existing ones up to date.\n *\n * Only the three Dockerfiles the ts#rdb / py#rdb generators vend are touched,\n * located from each rdb project's root (recorded in its metadata). Each is\n * edited in place only where its comment + `RUN microdnf upgrade ...` block\n * still has the exact shape the generator wrote before this change; one that\n * has diverged (a customised comment or upgrade command) is left untouched\n * and reported via `nextSteps`.\n */\n\nconst AWS_LAMBDA_RIE = '/usr/local/bin/aws-lambda-rie';\n\n/**\n * The exact comment + `RUN microdnf upgrade ...` block ts#rdb's Dockerfile had\n * before this migration, and what it becomes.\n */\nconst TS_RDB_OLD_UPGRADE = `# Patch OS packages beyond the base image's pinned release, and drop the\n# runtime's convenience copy of the AWS SDK (the handler bundle inlines its\n# own dependencies), keeping the image free of known HIGH/CRITICAL\n# vulnerabilities\nRUN microdnf upgrade -y --releasever latest && microdnf clean all \\\\\n && rm -rf /var/runtime/node_modules/@aws-sdk`;\nconst TS_RDB_NEW_UPGRADE = `# Patch OS packages beyond the base image's pinned release, and drop the\n# runtime's convenience copy of the AWS SDK (the handler bundle inlines its\n# own dependencies), keeping the image free of known HIGH/CRITICAL\n# vulnerabilities. Also drop the Lambda Runtime Interface Emulator: it is only\n# used for local \\`docker run\\` emulation outside Lambda, never by the deployed\n# function, and carries known HIGH vulnerabilities.\nRUN microdnf upgrade -y --releasever latest && microdnf clean all \\\\\n && rm -rf /var/runtime/node_modules/@aws-sdk ${AWS_LAMBDA_RIE}`;\n\n/**\n * The exact comment + `RUN microdnf upgrade ...` block py#rdb's two Dockerfiles\n * had before this migration, and what it becomes. Both Dockerfile.migration and\n * Dockerfile.create-db-user share this block verbatim.\n */\nconst PY_RDB_OLD_UPGRADE = `# Patch OS packages beyond the base image's pinned release, and drop pip, whose\n# vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.\n# The handler's dependencies are already installed in the image, so nothing\n# installs packages at runtime.\nRUN microdnf upgrade -y --releasever latest && microdnf clean all \\\\\n && rm -rf /var/lang/lib/python*/site-packages/pip \\\\\n /var/lang/lib/python*/site-packages/pip-*.dist-info`;\nconst PY_RDB_NEW_UPGRADE = `# Patch OS packages beyond the base image's pinned release, and drop pip, whose\n# vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.\n# The handler's dependencies are already installed in the image, so nothing\n# installs packages at runtime. Also drop the Lambda Runtime Interface\n# Emulator: it is only used for local \\`docker run\\` emulation outside Lambda,\n# never by the deployed function, and carries known HIGH vulnerabilities.\nRUN microdnf upgrade -y --releasever latest && microdnf clean all \\\\\n && rm -rf /var/lang/lib/python*/site-packages/pip \\\\\n /var/lang/lib/python*/site-packages/pip-*.dist-info \\\\\n ${AWS_LAMBDA_RIE}`;\n\n/** The marker checked to detect an already-migrated (or user-added) removal. */\nconst RIE_REMOVED_MARKER = AWS_LAMBDA_RIE;\n\nconst divergedNextStep = (filePath: string): string =>\n `${filePath}: its microdnf upgrade command has been customised, so it was left unchanged. Remove the Lambda Runtime Interface Emulator by adding \"${AWS_LAMBDA_RIE}\" to its \"rm -rf\" — it is only used for local \\`docker run\\` emulation outside Lambda and carries known HIGH vulnerabilities.`;\n\n/**\n * Replace a Dockerfile's old comment + upgrade block with the new one, only\n * when the file still has the exact shape the generator wrote. Already\n * migrated and diverged files are both left alone; the latter is reported via\n * nextSteps.\n */\nconst migrateDockerfile = (\n tree: Tree,\n filePath: string,\n oldBlock: string,\n newBlock: string,\n nextSteps: string[],\n): void => {\n if (!tree.exists(filePath)) {\n return;\n }\n\n const content = tree.read(filePath, 'utf-8') ?? '';\n if (content.includes(RIE_REMOVED_MARKER)) {\n return; // Already migrated (or user-added).\n }\n\n if (!content.includes(oldBlock)) {\n nextSteps.push(divergedNextStep(filePath));\n return;\n }\n\n tree.write(filePath, content.replace(oldBlock, newBlock));\n};\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n for (const project of getProjects(tree).values()) {\n const generator = (project.metadata as { generator?: string } | undefined)\n ?.generator;\n\n if (generator === TS_RDB_GENERATOR_INFO.id) {\n migrateDockerfile(\n tree,\n joinPathFragments(project.root, 'Dockerfile'),\n TS_RDB_OLD_UPGRADE,\n TS_RDB_NEW_UPGRADE,\n nextSteps,\n );\n } else if (generator === PY_RDB_GENERATOR_INFO.id) {\n migrateDockerfile(\n tree,\n joinPathFragments(project.root, 'Dockerfile.migration'),\n PY_RDB_OLD_UPGRADE,\n PY_RDB_NEW_UPGRADE,\n nextSteps,\n );\n migrateDockerfile(\n tree,\n joinPathFragments(project.root, 'Dockerfile.create-db-user'),\n PY_RDB_OLD_UPGRADE,\n PY_RDB_NEW_UPGRADE,\n nextSteps,\n );\n }\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["getProjects","joinPathFragments","PY_RDB_GENERATOR_INFO","TS_RDB_GENERATOR_INFO","formatFilesInSubtree","AWS_LAMBDA_RIE","TS_RDB_OLD_UPGRADE","TS_RDB_NEW_UPGRADE","PY_RDB_OLD_UPGRADE","PY_RDB_NEW_UPGRADE","RIE_REMOVED_MARKER","divergedNextStep","filePath","migrateDockerfile","tree","oldBlock","newBlock","nextSteps","exists","content","read","includes","push","write","replace","migration","project","values","generator","metadata","id","root"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,qBAAqB,QAAQ,+BAA+B;AACrE,SAASC,qBAAqB,QAAQ,+BAA+B;AACrE,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE;;;;;;;;;;;;;;;;;;;;CAoBC,GAED,MAAMC,iBAAiB;AAEvB;;;CAGC,GACD,MAAMC,qBAAqB,CAAC;;;;;gDAKoB,CAAC;AACjD,MAAMC,qBAAqB,CAAC;;;;;;;iDAOqB,EAAEF,gBAAgB;AAEnE;;;;CAIC,GACD,MAAMG,qBAAqB,CAAC;;;;;;uDAM2B,CAAC;AACxD,MAAMC,qBAAqB,CAAC;;;;;;;;;IASxB,EAAEJ,gBAAgB;AAEtB,8EAA8E,GAC9E,MAAMK,qBAAqBL;AAE3B,MAAMM,mBAAmB,CAACC,WACxB,GAAGA,SAAS,sIAAsI,EAAEP,eAAe,6HAA6H,CAAC;AAEnS;;;;;CAKC,GACD,MAAMQ,oBAAoB,CACxBC,MACAF,UACAG,UACAC,UACAC;IAEA,IAAI,CAACH,KAAKI,MAAM,CAACN,WAAW;QAC1B;IACF;IAEA,MAAMO,UAAUL,KAAKM,IAAI,CAACR,UAAU,YAAY;IAChD,IAAIO,QAAQE,QAAQ,CAACX,qBAAqB;QACxC,QAAQ,oCAAoC;IAC9C;IAEA,IAAI,CAACS,QAAQE,QAAQ,CAACN,WAAW;QAC/BE,UAAUK,IAAI,CAACX,iBAAiBC;QAChC;IACF;IAEAE,KAAKS,KAAK,CAACX,UAAUO,QAAQK,OAAO,CAACT,UAAUC;AACjD;AAEA,eAAe,eAAeS,UAC5BX,IAAU;IAEV,MAAMG,YAAsB,EAAE;IAE9B,KAAK,MAAMS,WAAW1B,YAAYc,MAAMa,MAAM,GAAI;QAChD,MAAMC,YAAaF,QAAQG,QAAQ,EAC/BD;QAEJ,IAAIA,cAAczB,sBAAsB2B,EAAE,EAAE;YAC1CjB,kBACEC,MACAb,kBAAkByB,QAAQK,IAAI,EAAE,eAChCzB,oBACAC,oBACAU;QAEJ,OAAO,IAAIW,cAAc1B,sBAAsB4B,EAAE,EAAE;YACjDjB,kBACEC,MACAb,kBAAkByB,QAAQK,IAAI,EAAE,yBAChCvB,oBACAC,oBACAQ;YAEFJ,kBACEC,MACAb,kBAAkByB,QAAQK,IAAI,EAAE,8BAChCvB,oBACAC,oBACAQ;QAEJ;IACF;IAEA,MAAMb,qBAAqBU;IAE3B,OAAO;QAAEG;IAAU;AACrB"}
@@ -173,10 +173,13 @@ exports[`py#rdb generator > should generate MySQL dependencies and templates 4`]
173
173
  # Patch OS packages beyond the base image's pinned release, and drop pip, whose
174
174
  # vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
175
175
  # The handler's dependencies are already installed in the image, so nothing
176
- # installs packages at runtime.
176
+ # installs packages at runtime. Also drop the Lambda Runtime Interface
177
+ # Emulator: it is only used for local \`docker run\` emulation outside Lambda,
178
+ # never by the deployed function, and carries known HIGH vulnerabilities.
177
179
  RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
178
180
  && rm -rf /var/lang/lib/python*/site-packages/pip \\
179
- /var/lang/lib/python*/site-packages/pip-*.dist-info
181
+ /var/lang/lib/python*/site-packages/pip-*.dist-info \\
182
+ /usr/local/bin/aws-lambda-rie
180
183
 
181
184
  WORKDIR \${LAMBDA_TASK_ROOT}
182
185
 
@@ -195,10 +198,13 @@ exports[`py#rdb generator > should generate MySQL dependencies and templates 5`]
195
198
  # Patch OS packages beyond the base image's pinned release, and drop pip, whose
196
199
  # vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
197
200
  # The handler's dependencies are already installed in the image, so nothing
198
- # installs packages at runtime.
201
+ # installs packages at runtime. Also drop the Lambda Runtime Interface
202
+ # Emulator: it is only used for local \`docker run\` emulation outside Lambda,
203
+ # never by the deployed function, and carries known HIGH vulnerabilities.
199
204
  RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
200
205
  && rm -rf /var/lang/lib/python*/site-packages/pip \\
201
- /var/lang/lib/python*/site-packages/pip-*.dist-info
206
+ /var/lang/lib/python*/site-packages/pip-*.dist-info \\
207
+ /usr/local/bin/aws-lambda-rie
202
208
 
203
209
  WORKDIR \${LAMBDA_TASK_ROOT}
204
210
 
@@ -1393,10 +1399,13 @@ exports[`py#rdb generator > should generate a PostgreSQL SQLModel project with A
1393
1399
  # Patch OS packages beyond the base image's pinned release, and drop pip, whose
1394
1400
  # vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
1395
1401
  # The handler's dependencies are already installed in the image, so nothing
1396
- # installs packages at runtime.
1402
+ # installs packages at runtime. Also drop the Lambda Runtime Interface
1403
+ # Emulator: it is only used for local \`docker run\` emulation outside Lambda,
1404
+ # never by the deployed function, and carries known HIGH vulnerabilities.
1397
1405
  RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
1398
1406
  && rm -rf /var/lang/lib/python*/site-packages/pip \\
1399
- /var/lang/lib/python*/site-packages/pip-*.dist-info
1407
+ /var/lang/lib/python*/site-packages/pip-*.dist-info \\
1408
+ /usr/local/bin/aws-lambda-rie
1400
1409
 
1401
1410
  WORKDIR \${LAMBDA_TASK_ROOT}
1402
1411
 
@@ -1415,10 +1424,13 @@ exports[`py#rdb generator > should generate a PostgreSQL SQLModel project with A
1415
1424
  # Patch OS packages beyond the base image's pinned release, and drop pip, whose
1416
1425
  # vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
1417
1426
  # The handler's dependencies are already installed in the image, so nothing
1418
- # installs packages at runtime.
1427
+ # installs packages at runtime. Also drop the Lambda Runtime Interface
1428
+ # Emulator: it is only used for local \`docker run\` emulation outside Lambda,
1429
+ # never by the deployed function, and carries known HIGH vulnerabilities.
1419
1430
  RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
1420
1431
  && rm -rf /var/lang/lib/python*/site-packages/pip \\
1421
- /var/lang/lib/python*/site-packages/pip-*.dist-info
1432
+ /var/lang/lib/python*/site-packages/pip-*.dist-info \\
1433
+ /usr/local/bin/aws-lambda-rie
1422
1434
 
1423
1435
  WORKDIR \${LAMBDA_TASK_ROOT}
1424
1436
 
@@ -3,10 +3,13 @@ FROM public.ecr.aws/lambda/python:3.14
3
3
  # Patch OS packages beyond the base image's pinned release, and drop pip, whose
4
4
  # vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
5
5
  # The handler's dependencies are already installed in the image, so nothing
6
- # installs packages at runtime.
6
+ # installs packages at runtime. Also drop the Lambda Runtime Interface
7
+ # Emulator: it is only used for local `docker run` emulation outside Lambda,
8
+ # never by the deployed function, and carries known HIGH vulnerabilities.
7
9
  RUN microdnf upgrade -y --releasever latest && microdnf clean all \
8
10
  && rm -rf /var/lang/lib/python*/site-packages/pip \
9
- /var/lang/lib/python*/site-packages/pip-*.dist-info
11
+ /var/lang/lib/python*/site-packages/pip-*.dist-info \
12
+ /usr/local/bin/aws-lambda-rie
10
13
 
11
14
  WORKDIR ${LAMBDA_TASK_ROOT}
12
15
 
@@ -3,10 +3,13 @@ FROM public.ecr.aws/lambda/python:3.14
3
3
  # Patch OS packages beyond the base image's pinned release, and drop pip, whose
4
4
  # vendored copies of msgpack and setuptools carry known HIGH vulnerabilities.
5
5
  # The handler's dependencies are already installed in the image, so nothing
6
- # installs packages at runtime.
6
+ # installs packages at runtime. Also drop the Lambda Runtime Interface
7
+ # Emulator: it is only used for local `docker run` emulation outside Lambda,
8
+ # never by the deployed function, and carries known HIGH vulnerabilities.
7
9
  RUN microdnf upgrade -y --releasever latest && microdnf clean all \
8
10
  && rm -rf /var/lang/lib/python*/site-packages/pip \
9
- /var/lang/lib/python*/site-packages/pip-*.dist-info
11
+ /var/lang/lib/python*/site-packages/pip-*.dist-info \
12
+ /usr/local/bin/aws-lambda-rie
10
13
 
11
14
  WORKDIR ${LAMBDA_TASK_ROOT}
12
15
 
@@ -8,53 +8,49 @@ import type { TsAgentA2aConnectionGeneratorSchema } from './schema';
8
8
  export declare const DEPENDENCIES: import("../../../utils/declared-dependencies.js").DependencyDeclaration<readonly [{
9
9
  readonly name: "@a2a-js/sdk";
10
10
  readonly root: true;
11
- }, {
12
- readonly name: "@strands-agents/sdk";
13
- readonly root: true;
14
- }, {
15
- readonly name: "@aws-lambda-powertools/parameters";
16
- readonly root: true;
17
- }, {
18
- readonly name: "@aws-sdk/client-appconfigdata";
19
- readonly root: true;
20
- }, {
21
- readonly name: "aws4fetch";
22
- readonly root: true;
23
- }, {
24
- readonly name: "@aws-sdk/credential-providers";
25
- readonly root: true;
26
- }, {
27
- readonly name: "zod";
28
- readonly root: true;
29
- }, {
11
+ }, ...({
12
+ name: "@aws-sdk/client-s3" | "@strands-agents/sdk" | "express";
13
+ root: boolean;
14
+ } | ({
30
15
  readonly name: "@aws-lambda-powertools/parameters";
31
16
  } & {
32
17
  versionOnly: true;
33
- }, {
18
+ }) | ({
34
19
  readonly name: "@aws-sdk/credential-providers";
35
20
  } & {
36
21
  versionOnly: true;
37
- }, {
22
+ }) | ({
38
23
  readonly name: "aws4fetch";
39
24
  } & {
40
25
  versionOnly: true;
41
- }, {
26
+ }) | ({
42
27
  readonly name: "@modelcontextprotocol/sdk";
43
28
  } & {
44
29
  versionOnly: true;
45
- }, {
30
+ }) | ({
46
31
  readonly name: "@a2a-js/sdk";
47
32
  } & {
48
33
  versionOnly: true;
49
- }, {
50
- readonly name: "@strands-agents/sdk";
34
+ }) | ({
35
+ name: "@aws-sdk/client-s3" | "@strands-agents/sdk" | "express";
51
36
  } & {
52
37
  versionOnly: true;
53
- }, {
54
- readonly name: "@aws-sdk/client-s3";
55
- } & {
56
- versionOnly: true;
57
- }], readonly import("../../../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "pydantic" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
38
+ }) | {
39
+ readonly name: "@aws-lambda-powertools/parameters";
40
+ readonly root: true;
41
+ } | {
42
+ readonly name: "@aws-sdk/client-appconfigdata";
43
+ readonly root: true;
44
+ } | {
45
+ readonly name: "aws4fetch";
46
+ readonly root: true;
47
+ } | {
48
+ readonly name: "@aws-sdk/credential-providers";
49
+ readonly root: true;
50
+ } | {
51
+ readonly name: "zod";
52
+ readonly root: true;
53
+ })[]], readonly import("../../../utils/declared-dependencies.js").DeclaredPyDependency<"ruff" | "a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "pydantic" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", Record<string, never>>[]>;
58
54
  export declare const TS_AGENT_A2A_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
59
55
  export declare const tsAgentA2aConnectionGenerator: (tree: Tree, options: TsAgentA2aConnectionGeneratorSchema) => Promise<GeneratorCallback>;
60
56
  export default tsAgentA2aConnectionGenerator;
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */ import { generateFiles, joinPathFragments, OverwriteStrategy, updateProjectConfiguration } from "@nx/devkit";
5
5
  import { addTsDependencies } from "../../../utils/add-dependencies.js";
6
- import { AGENT_CONNECTION_DEPENDENCIES, AGENT_CONNECTION_PROJECT_DIR, addTypeScriptCoreClient, ensureTypeScriptAgentConnectionProject } from "../../../utils/agent-connection/agent-connection.js";
6
+ import { AGENT_CONNECTION_DEPENDENCIES, AGENT_CONNECTION_PROJECT_DIR, addTypeScriptCoreClient, ensureTypeScriptAgentConnectionProject, STRANDS_PEER_DEPENDENCY_NAMES } from "../../../utils/agent-connection/agent-connection.js";
7
7
  import { addDestructuredImport, addStarExport, appendToArrayViaGritQL, applyGritQL } from "../../../utils/ast.js";
8
8
  import { declareDependencies, ownedElsewhere } from "../../../utils/declared-dependencies.js";
9
9
  import { formatFilesInSubtree } from "../../../utils/format.js";
@@ -25,10 +25,14 @@ export const DEPENDENCIES = declareDependencies()({
25
25
  name: '@a2a-js/sdk',
26
26
  root: true
27
27
  },
28
- {
29
- name: '@strands-agents/sdk',
30
- root: true
31
- },
28
+ // @strands-agents/sdk and its peers (STRANDS_PEER_DEPENDENCY_NAMES),
29
+ // pinned at the root so the root strands copy resolves the same peers as
30
+ // every other importer (see agent-connection.ts's TS_TEMPLATE_DEPS for
31
+ // the same reasoning).
32
+ ...STRANDS_PEER_DEPENDENCY_NAMES.map((name)=>({
33
+ name,
34
+ root: true
35
+ })),
32
36
  {
33
37
  name: '@aws-lambda-powertools/parameters',
34
38
  root: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/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 { addTsDependencies } from '../../../utils/add-dependencies.js';\nimport {\n AGENT_CONNECTION_DEPENDENCIES,\n AGENT_CONNECTION_PROJECT_DIR,\n addTypeScriptCoreClient,\n ensureTypeScriptAgentConnectionProject,\n} from '../../../utils/agent-connection/agent-connection.js';\nimport {\n addDestructuredImport,\n addStarExport,\n appendToArrayViaGritQL,\n applyGritQL,\n} from '../../../utils/ast.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { installDependencies } from '../../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics.js';\nimport { esmVars } from '../../../utils/module-format.js';\nimport { kebabCase } from '../../../utils/names.js';\nimport { getNpmScope } from '../../../utils/npm-scope.js';\nimport {\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx.js';\nimport { toProjectRelativePath } from '../../../utils/paths.js';\nimport type { TsAgentA2aConnectionGeneratorSchema } from './schema';\n\n// The A2A core client + vended client need these whatever the connection's\n// options, so no entry is conditional.\n// The A2A client the generated agent code imports, plus the AppConfig lookup and\n// sigv4 signing it resolves the remote agent with. Added to the workspace root,\n// where this connection has always put them.\nexport const DEPENDENCIES = declareDependencies()({\n ts: [\n { name: '@a2a-js/sdk', root: true },\n { name: '@strands-agents/sdk', root: true },\n { name: '@aws-lambda-powertools/parameters', root: true },\n { name: '@aws-sdk/client-appconfigdata', root: true },\n { name: 'aws4fetch', root: true },\n { name: '@aws-sdk/credential-providers', root: true },\n { name: 'zod', root: true },\n ...ownedElsewhere(AGENT_CONNECTION_DEPENDENCIES),\n ],\n});\n\nexport const TS_AGENT_A2A_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const tsAgentA2aConnectionGenerator = async (\n tree: Tree,\n options: TsAgentA2aConnectionGeneratorSchema,\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 ts#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 targetAgentKebabCase = kebabCase(targetAgentClassName);\n const targetAgentPort = targetAgentComponent.port ?? 9000;\n\n const npmScope = getNpmScope(tree);\n\n // 1. Ensure the shared agent-connection project exists + has the A2A core client\n await ensureTypeScriptAgentConnectionProject(tree, DEPENDENCIES);\n await addTypeScriptCoreClient(tree, 'a2a', DEPENDENCIES);\n\n // 2. Generate the per-connection <Name>Client into app/\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'agent-connection', 'app'),\n joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'src', 'app'),\n {\n targetAgentKebabCase,\n targetAgentClassName,\n targetAgentPort,\n ...esmVars(tree),\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add re-export to index.ts\n await addStarExport(\n tree,\n joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'src', 'index.ts'),\n `./app/${targetAgentKebabCase}-client-strands.js`,\n );\n\n // 3. AST transform agent.ts to add the remote A2A agent as a tool\n const agentSourceDir = joinPathFragments(\n sourceProject.root,\n agentComponent.path ?? 'src',\n );\n const agentFilePath = joinPathFragments(agentSourceDir, 'agent.ts');\n\n if (tree.exists(agentFilePath)) {\n const clientClassName = `${targetAgentClassName}ClientStrands`;\n const clientVarName =\n targetAgentClassName.charAt(0).toLowerCase() +\n targetAgentClassName.slice(1);\n const toolName = `ask${targetAgentClassName}`;\n const toolVarName = `${clientVarName}Tool`;\n\n // Ensure tool + z imports are available\n await addDestructuredImport(\n tree,\n agentFilePath,\n ['tool'],\n '@strands-agents/sdk',\n );\n await addDestructuredImport(tree, agentFilePath, ['z'], 'zod');\n await addDestructuredImport(\n tree,\n agentFilePath,\n [clientClassName],\n `@${npmScope}/agent-connection`,\n );\n\n // Build the tool creation + Agent wiring.\n const toolCreationBlock = `const ${clientVarName} = await ${clientClassName}.create();\n const ${toolVarName} = tool({\n name: '${toolName}',\n description: 'Delegate a question to the remote ${targetAgentClassName} A2A agent and return its reply.',\n inputSchema: z.object({ prompt: z.string() }),\n callback: async ({ prompt }) => (await ${clientVarName}.invoke(prompt)).toString(),\n });`;\n\n // Transform the arrow function that contains `new Agent`:\n // - Expression body: wrap in block with tool creation and return\n // - Block body: prepend tool creation statement\n await applyGritQL(\n tree,\n agentFilePath,\n `or { \\`async ($p) => new Agent($args)\\` => raw\\`async ($p) => {\n ${toolCreationBlock}\n return new Agent($args);\n}\\` where { $program <: not contains \\`${clientClassName}.create\\` }, \\`async ($p) => { $body }\\` => raw\\`async ($p) => {\n ${toolCreationBlock}\n $body\n}\\` where { $body <: contains \\`new Agent($_)\\`, $program <: not contains \\`${clientClassName}.create\\` } }`,\n );\n\n // Append the tool to the tools array (after existing items)\n await appendToArrayViaGritQL(tree, agentFilePath, 'tools:', toolVarName, {\n scope: 'new Agent($_)',\n });\n }\n\n // 4. Set up dev target — depend on the target agent's dev\n // so running the host's dev also spins up the remote A2A 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 // 5. Add dependencies to the workspace root manifest\n addTsDependencies(tree, DEPENDENCIES);\n\n // Recorded so the version sync knows this connection's dependencies are ours.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n TS_AGENT_A2A_CONNECTION_GENERATOR_INFO,\n toProjectRelativePath(sourceProject, agentFilePath),\n targetAgentClassName,\n // The source component this connection is made from, so the pair is\n // identifiable rather than just the two projects.\n { sourcePath: options.sourceComponent?.path },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [\n TS_AGENT_A2A_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsAgentA2aConnectionGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addTsDependencies","AGENT_CONNECTION_DEPENDENCIES","AGENT_CONNECTION_PROJECT_DIR","addTypeScriptCoreClient","ensureTypeScriptAgentConnectionProject","addDestructuredImport","addStarExport","appendToArrayViaGritQL","applyGritQL","declareDependencies","ownedElsewhere","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","getNpmScope","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","DEPENDENCIES","ts","name","root","TS_AGENT_A2A_CONNECTION_GENERATOR_INFO","filename","tsAgentA2aConnectionGenerator","tree","options","sourceProject","targetProject","agentComponent","sourceComponent","targetAgentComponent","targetComponent","Error","protocol","toLowerCase","auth","targetAgentComponentName","targetAgentClassName","rc","targetAgentKebabCase","targetAgentPort","port","npmScope","dirname","overwriteStrategy","KeepExisting","agentSourceDir","path","agentFilePath","exists","clientClassName","clientVarName","charAt","slice","toolName","toolVarName","toolCreationBlock","scope","agentName","devTargetName","targetDevTargetName","targets","projects","target","sourcePath","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,qCAAqC;AACvE,SACEC,6BAA6B,EAC7BC,4BAA4B,EAC5BC,uBAAuB,EACvBC,sCAAsC,QACjC,sDAAsD;AAC7D,SACEC,qBAAqB,EACrBC,aAAa,EACbC,sBAAsB,EACtBC,WAAW,QACN,wBAAwB;AAC/B,SACEC,mBAAmB,EACnBC,cAAc,QACT,0CAA0C;AACjD,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,+BAA+B,QAAQ,4BAA4B;AAC5E,SAASC,OAAO,QAAQ,kCAAkC;AAC1D,SAASC,SAAS,QAAQ,0BAA0B;AACpD,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SACEC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAuB;AAC9B,SAASC,qBAAqB,QAAQ,0BAA0B;AAGhE,2EAA2E;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in/src/ts/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 { addTsDependencies } from '../../../utils/add-dependencies.js';\nimport {\n AGENT_CONNECTION_DEPENDENCIES,\n AGENT_CONNECTION_PROJECT_DIR,\n addTypeScriptCoreClient,\n ensureTypeScriptAgentConnectionProject,\n STRANDS_PEER_DEPENDENCY_NAMES,\n} from '../../../utils/agent-connection/agent-connection.js';\nimport {\n addDestructuredImport,\n addStarExport,\n appendToArrayViaGritQL,\n applyGritQL,\n} from '../../../utils/ast.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { installDependencies } from '../../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics.js';\nimport { esmVars } from '../../../utils/module-format.js';\nimport { kebabCase } from '../../../utils/names.js';\nimport { getNpmScope } from '../../../utils/npm-scope.js';\nimport {\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx.js';\nimport { toProjectRelativePath } from '../../../utils/paths.js';\nimport type { TsAgentA2aConnectionGeneratorSchema } from './schema';\n\n// The A2A core client + vended client need these whatever the connection's\n// options, so no entry is conditional.\n// The A2A client the generated agent code imports, plus the AppConfig lookup and\n// sigv4 signing it resolves the remote agent with. Added to the workspace root,\n// where this connection has always put them.\nexport const DEPENDENCIES = declareDependencies()({\n ts: [\n { name: '@a2a-js/sdk', root: true },\n // @strands-agents/sdk and its peers (STRANDS_PEER_DEPENDENCY_NAMES),\n // pinned at the root so the root strands copy resolves the same peers as\n // every other importer (see agent-connection.ts's TS_TEMPLATE_DEPS for\n // the same reasoning).\n ...STRANDS_PEER_DEPENDENCY_NAMES.map((name) => ({ name, root: true })),\n { name: '@aws-lambda-powertools/parameters', root: true },\n { name: '@aws-sdk/client-appconfigdata', root: true },\n { name: 'aws4fetch', root: true },\n { name: '@aws-sdk/credential-providers', root: true },\n { name: 'zod', root: true },\n ...ownedElsewhere(AGENT_CONNECTION_DEPENDENCIES),\n ],\n});\n\nexport const TS_AGENT_A2A_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const tsAgentA2aConnectionGenerator = async (\n tree: Tree,\n options: TsAgentA2aConnectionGeneratorSchema,\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 ts#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 targetAgentKebabCase = kebabCase(targetAgentClassName);\n const targetAgentPort = targetAgentComponent.port ?? 9000;\n\n const npmScope = getNpmScope(tree);\n\n // 1. Ensure the shared agent-connection project exists + has the A2A core client\n await ensureTypeScriptAgentConnectionProject(tree, DEPENDENCIES);\n await addTypeScriptCoreClient(tree, 'a2a', DEPENDENCIES);\n\n // 2. Generate the per-connection <Name>Client into app/\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'agent-connection', 'app'),\n joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'src', 'app'),\n {\n targetAgentKebabCase,\n targetAgentClassName,\n targetAgentPort,\n ...esmVars(tree),\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Add re-export to index.ts\n await addStarExport(\n tree,\n joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'src', 'index.ts'),\n `./app/${targetAgentKebabCase}-client-strands.js`,\n );\n\n // 3. AST transform agent.ts to add the remote A2A agent as a tool\n const agentSourceDir = joinPathFragments(\n sourceProject.root,\n agentComponent.path ?? 'src',\n );\n const agentFilePath = joinPathFragments(agentSourceDir, 'agent.ts');\n\n if (tree.exists(agentFilePath)) {\n const clientClassName = `${targetAgentClassName}ClientStrands`;\n const clientVarName =\n targetAgentClassName.charAt(0).toLowerCase() +\n targetAgentClassName.slice(1);\n const toolName = `ask${targetAgentClassName}`;\n const toolVarName = `${clientVarName}Tool`;\n\n // Ensure tool + z imports are available\n await addDestructuredImport(\n tree,\n agentFilePath,\n ['tool'],\n '@strands-agents/sdk',\n );\n await addDestructuredImport(tree, agentFilePath, ['z'], 'zod');\n await addDestructuredImport(\n tree,\n agentFilePath,\n [clientClassName],\n `@${npmScope}/agent-connection`,\n );\n\n // Build the tool creation + Agent wiring.\n const toolCreationBlock = `const ${clientVarName} = await ${clientClassName}.create();\n const ${toolVarName} = tool({\n name: '${toolName}',\n description: 'Delegate a question to the remote ${targetAgentClassName} A2A agent and return its reply.',\n inputSchema: z.object({ prompt: z.string() }),\n callback: async ({ prompt }) => (await ${clientVarName}.invoke(prompt)).toString(),\n });`;\n\n // Transform the arrow function that contains `new Agent`:\n // - Expression body: wrap in block with tool creation and return\n // - Block body: prepend tool creation statement\n await applyGritQL(\n tree,\n agentFilePath,\n `or { \\`async ($p) => new Agent($args)\\` => raw\\`async ($p) => {\n ${toolCreationBlock}\n return new Agent($args);\n}\\` where { $program <: not contains \\`${clientClassName}.create\\` }, \\`async ($p) => { $body }\\` => raw\\`async ($p) => {\n ${toolCreationBlock}\n $body\n}\\` where { $body <: contains \\`new Agent($_)\\`, $program <: not contains \\`${clientClassName}.create\\` } }`,\n );\n\n // Append the tool to the tools array (after existing items)\n await appendToArrayViaGritQL(tree, agentFilePath, 'tools:', toolVarName, {\n scope: 'new Agent($_)',\n });\n }\n\n // 4. Set up dev target — depend on the target agent's dev\n // so running the host's dev also spins up the remote A2A 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 // 5. Add dependencies to the workspace root manifest\n addTsDependencies(tree, DEPENDENCIES);\n\n // Recorded so the version sync knows this connection's dependencies are ours.\n addComponentGeneratorMetadata(\n tree,\n sourceProject.name,\n TS_AGENT_A2A_CONNECTION_GENERATOR_INFO,\n toProjectRelativePath(sourceProject, agentFilePath),\n targetAgentClassName,\n // The source component this connection is made from, so the pair is\n // identifiable rather than just the two projects.\n { sourcePath: options.sourceComponent?.path },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [\n TS_AGENT_A2A_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsAgentA2aConnectionGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addTsDependencies","AGENT_CONNECTION_DEPENDENCIES","AGENT_CONNECTION_PROJECT_DIR","addTypeScriptCoreClient","ensureTypeScriptAgentConnectionProject","STRANDS_PEER_DEPENDENCY_NAMES","addDestructuredImport","addStarExport","appendToArrayViaGritQL","applyGritQL","declareDependencies","ownedElsewhere","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","getNpmScope","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","DEPENDENCIES","ts","name","root","map","TS_AGENT_A2A_CONNECTION_GENERATOR_INFO","filename","tsAgentA2aConnectionGenerator","tree","options","sourceProject","targetProject","agentComponent","sourceComponent","targetAgentComponent","targetComponent","Error","protocol","toLowerCase","auth","targetAgentComponentName","targetAgentClassName","rc","targetAgentKebabCase","targetAgentPort","port","npmScope","dirname","overwriteStrategy","KeepExisting","agentSourceDir","path","agentFilePath","exists","clientClassName","clientVarName","charAt","slice","toolName","toolVarName","toolCreationBlock","scope","agentName","devTargetName","targetDevTargetName","targets","projects","target","sourcePath","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,qCAAqC;AACvE,SACEC,6BAA6B,EAC7BC,4BAA4B,EAC5BC,uBAAuB,EACvBC,sCAAsC,EACtCC,6BAA6B,QACxB,sDAAsD;AAC7D,SACEC,qBAAqB,EACrBC,aAAa,EACbC,sBAAsB,EACtBC,WAAW,QACN,wBAAwB;AAC/B,SACEC,mBAAmB,EACnBC,cAAc,QACT,0CAA0C;AACjD,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,+BAA+B,QAAQ,4BAA4B;AAC5E,SAASC,OAAO,QAAQ,kCAAkC;AAC1D,SAASC,SAAS,QAAQ,0BAA0B;AACpD,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SACEC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,mCAAmC,QAC9B,uBAAu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