@aws/nx-plugin 1.0.0-rc.65 → 1.0.0-rc.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-THIRD-PARTY +59 -87
- package/migrations.json +57 -57
- package/package.json +4 -4
- package/src/agentcore-gateway/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/migrations/v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.59/0001-gateway-agent-targets/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.60/0001-gateway-cognito-passthrough/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.60/0002-waf-log-group-removal/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.60/0003-strip-pip-from-python-images/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.61/0001-py-agent-lifespan-construction/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.62/0001-rename-load-runtime-config-target/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.63/0001-add-deploy-sandbox-target/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.64/0001-smithy-build-without-docker/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.65/0001-vite-config-import-meta-dirname/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.65/0002-rolldown-code-splitting/migration.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +4 -4
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +3 -3
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +2 -2
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +12 -12
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +7 -7
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +12 -12
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/dcr-proxy/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +19 -19
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
- package/src/utils/versions.d.ts +47 -47
- package/src/utils/versions.js +46 -46
- package/src/utils/versions.js.map +1 -1
- package/src/migrations/latest/add-deploy-sandbox-target/migration.js.map +0 -1
- package/src/migrations/latest/gateway-agent-targets/migration.js.map +0 -1
- package/src/migrations/latest/gateway-cognito-passthrough/migration.js.map +0 -1
- package/src/migrations/latest/py-agent-lifespan-construction/migration.js.map +0 -1
- package/src/migrations/latest/rename-load-runtime-config-target/migration.js.map +0 -1
- package/src/migrations/latest/rolldown-code-splitting/migration.js.map +0 -1
- package/src/migrations/latest/smithy-build-without-docker/migration.js.map +0 -1
- package/src/migrations/latest/smithy-ssdk-bundle-pins/migration.js.map +0 -1
- package/src/migrations/latest/strip-pip-from-python-images/migration.js.map +0 -1
- package/src/migrations/latest/vite-config-import-meta-dirname/migration.js.map +0 -1
- package/src/migrations/latest/waf-log-group-removal/migration.js.map +0 -1
- /package/src/migrations/{latest/smithy-ssdk-bundle-pins → v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins}/metadata.json +0 -0
- /package/src/migrations/{latest/add-deploy-sandbox-target → v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins}/migration.d.ts +0 -0
- /package/src/migrations/{latest/smithy-ssdk-bundle-pins → v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins}/migration.js +0 -0
- /package/src/migrations/{latest/smithy-ssdk-bundle-pins → v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins}/rc57-service.Dockerfile.fixture +0 -0
- /package/src/migrations/{latest/gateway-agent-targets → v1.0.0-rc.59/0001-gateway-agent-targets}/__snapshots__/migration.spec.ts.snap +0 -0
- /package/src/migrations/{latest/gateway-agent-targets → v1.0.0-rc.59/0001-gateway-agent-targets}/metadata.json +0 -0
- /package/src/migrations/{latest/gateway-agent-targets → v1.0.0-rc.59/0001-gateway-agent-targets}/migration.d.ts +0 -0
- /package/src/migrations/{latest/gateway-agent-targets → v1.0.0-rc.59/0001-gateway-agent-targets}/migration.js +0 -0
- /package/src/migrations/{latest/gateway-cognito-passthrough → v1.0.0-rc.60/0001-gateway-cognito-passthrough}/__snapshots__/migration.spec.ts.snap +0 -0
- /package/src/migrations/{latest/gateway-cognito-passthrough → v1.0.0-rc.60/0001-gateway-cognito-passthrough}/metadata.json +0 -0
- /package/src/migrations/{latest/gateway-cognito-passthrough → v1.0.0-rc.60/0001-gateway-cognito-passthrough}/migration.d.ts +0 -0
- /package/src/migrations/{latest/gateway-cognito-passthrough → v1.0.0-rc.60/0001-gateway-cognito-passthrough}/migration.js +0 -0
- /package/src/migrations/{latest/waf-log-group-removal → v1.0.0-rc.60/0002-waf-log-group-removal}/__snapshots__/migration.spec.ts.snap +0 -0
- /package/src/migrations/{latest/waf-log-group-removal → v1.0.0-rc.60/0002-waf-log-group-removal}/metadata.json +0 -0
- /package/src/migrations/{latest/waf-log-group-removal → v1.0.0-rc.60/0002-waf-log-group-removal}/migration.d.ts +0 -0
- /package/src/migrations/{latest/waf-log-group-removal → v1.0.0-rc.60/0002-waf-log-group-removal}/migration.js +0 -0
- /package/src/migrations/{latest/strip-pip-from-python-images → v1.0.0-rc.60/0003-strip-pip-from-python-images}/__snapshots__/migration.spec.ts.snap +0 -0
- /package/src/migrations/{latest/strip-pip-from-python-images → v1.0.0-rc.60/0003-strip-pip-from-python-images}/metadata.json +0 -0
- /package/src/migrations/{latest/py-agent-lifespan-construction → v1.0.0-rc.60/0003-strip-pip-from-python-images}/migration.d.ts +0 -0
- /package/src/migrations/{latest/strip-pip-from-python-images → v1.0.0-rc.60/0003-strip-pip-from-python-images}/migration.js +0 -0
- /package/src/migrations/{latest/py-agent-lifespan-construction → v1.0.0-rc.61/0001-py-agent-lifespan-construction}/metadata.json +0 -0
- /package/src/migrations/{latest/rename-load-runtime-config-target → v1.0.0-rc.61/0001-py-agent-lifespan-construction}/migration.d.ts +0 -0
- /package/src/migrations/{latest/py-agent-lifespan-construction → v1.0.0-rc.61/0001-py-agent-lifespan-construction}/migration.js +0 -0
- /package/src/migrations/{latest/rename-load-runtime-config-target → v1.0.0-rc.62/0001-rename-load-runtime-config-target}/metadata.json +0 -0
- /package/src/migrations/{latest/rolldown-code-splitting → v1.0.0-rc.62/0001-rename-load-runtime-config-target}/migration.d.ts +0 -0
- /package/src/migrations/{latest/rename-load-runtime-config-target → v1.0.0-rc.62/0001-rename-load-runtime-config-target}/migration.js +0 -0
- /package/src/migrations/{latest/add-deploy-sandbox-target → v1.0.0-rc.63/0001-add-deploy-sandbox-target}/metadata.json +0 -0
- /package/src/migrations/{latest/smithy-build-without-docker → v1.0.0-rc.63/0001-add-deploy-sandbox-target}/migration.d.ts +0 -0
- /package/src/migrations/{latest/add-deploy-sandbox-target → v1.0.0-rc.63/0001-add-deploy-sandbox-target}/migration.js +0 -0
- /package/src/migrations/{latest/smithy-build-without-docker → v1.0.0-rc.64/0001-smithy-build-without-docker}/legacy-service.Dockerfile.fixture +0 -0
- /package/src/migrations/{latest/smithy-build-without-docker → v1.0.0-rc.64/0001-smithy-build-without-docker}/metadata.json +0 -0
- /package/src/migrations/{latest/smithy-ssdk-bundle-pins → v1.0.0-rc.64/0001-smithy-build-without-docker}/migration.d.ts +0 -0
- /package/src/migrations/{latest/smithy-build-without-docker → v1.0.0-rc.64/0001-smithy-build-without-docker}/migration.js +0 -0
- /package/src/migrations/{latest/vite-config-import-meta-dirname → v1.0.0-rc.65/0001-vite-config-import-meta-dirname}/metadata.json +0 -0
- /package/src/migrations/{latest/strip-pip-from-python-images → v1.0.0-rc.65/0001-vite-config-import-meta-dirname}/migration.d.ts +0 -0
- /package/src/migrations/{latest/vite-config-import-meta-dirname → v1.0.0-rc.65/0001-vite-config-import-meta-dirname}/migration.js +0 -0
- /package/src/migrations/{latest/rolldown-code-splitting → v1.0.0-rc.65/0002-rolldown-code-splitting}/metadata.json +0 -0
- /package/src/migrations/{latest/vite-config-import-meta-dirname → v1.0.0-rc.65/0002-rolldown-code-splitting}/migration.d.ts +0 -0
- /package/src/migrations/{latest/rolldown-code-splitting → v1.0.0-rc.65/0002-rolldown-code-splitting}/migration.js +0 -0
package/LICENSE-THIRD-PARTY
CHANGED
|
@@ -217,7 +217,7 @@ OTHER DEALINGS IN THE SOFTWARE.
|
|
|
217
217
|
|
|
218
218
|
---
|
|
219
219
|
|
|
220
|
-
The following software may be included in this product: @astral-sh/ruff-wasm-nodejs (0.16.
|
|
220
|
+
The following software may be included in this product: @astral-sh/ruff-wasm-nodejs (0.16.2)
|
|
221
221
|
This software contains the following license and notice below:
|
|
222
222
|
|
|
223
223
|
MIT License
|
|
@@ -3892,6 +3892,30 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
3892
3892
|
|
|
3893
3893
|
---
|
|
3894
3894
|
|
|
3895
|
+
The following software may be included in this product: @esbuild/linux-x64 (0.28.2)
|
|
3896
|
+
This software contains the following license and notice below:
|
|
3897
|
+
|
|
3898
|
+
MIT License
|
|
3899
|
+
|
|
3900
|
+
Copyright (c) The maintainers of @esbuild/linux-x64 <https://github.com/evanw/esbuild#readme>
|
|
3901
|
+
|
|
3902
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
3903
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
3904
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
3905
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
3906
|
+
following conditions:
|
|
3907
|
+
|
|
3908
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
3909
|
+
portions of the Software.
|
|
3910
|
+
|
|
3911
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
3912
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
3913
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
3914
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
3915
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
3916
|
+
|
|
3917
|
+
---
|
|
3918
|
+
|
|
3895
3919
|
The following software may be included in this product: @eslint-community/eslint-utils (4.9.1)
|
|
3896
3920
|
This software contains the following license and notice below:
|
|
3897
3921
|
|
|
@@ -5770,7 +5794,7 @@ SOFTWARE.
|
|
|
5770
5794
|
|
|
5771
5795
|
---
|
|
5772
5796
|
|
|
5773
|
-
The following software may be included in this product: @oxc-project/types (0.
|
|
5797
|
+
The following software may be included in this product: @oxc-project/types (0.142.0)
|
|
5774
5798
|
This software contains the following license and notice below:
|
|
5775
5799
|
|
|
5776
5800
|
MIT License
|
|
@@ -6107,7 +6131,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
6107
6131
|
|
|
6108
6132
|
---
|
|
6109
6133
|
|
|
6110
|
-
The following software may be included in this product: @rolldown/binding-linux-x64-gnu (1.2.
|
|
6134
|
+
The following software may be included in this product: @rolldown/binding-linux-x64-gnu (1.2.2)
|
|
6111
6135
|
This software contains the following license and notice below:
|
|
6112
6136
|
|
|
6113
6137
|
MIT License
|
|
@@ -7444,34 +7468,7 @@ SOFTWARE
|
|
|
7444
7468
|
|
|
7445
7469
|
---
|
|
7446
7470
|
|
|
7447
|
-
The following software may be included in this product: @types/node (26.
|
|
7448
|
-
This software contains the following license and notice below:
|
|
7449
|
-
|
|
7450
|
-
MIT License
|
|
7451
|
-
|
|
7452
|
-
Copyright (c) Microsoft Corporation.
|
|
7453
|
-
|
|
7454
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7455
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7456
|
-
in the Software without restriction, including without limitation the rights
|
|
7457
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7458
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
7459
|
-
furnished to do so, subject to the following conditions:
|
|
7460
|
-
|
|
7461
|
-
The above copyright notice and this permission notice shall be included in all
|
|
7462
|
-
copies or substantial portions of the Software.
|
|
7463
|
-
|
|
7464
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
7465
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
7466
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
7467
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
7468
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
7469
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
7470
|
-
SOFTWARE
|
|
7471
|
-
|
|
7472
|
-
---
|
|
7473
|
-
|
|
7474
|
-
The following software may be included in this product: @types/node (26.1.2)
|
|
7471
|
+
The following software may be included in this product: @types/node (26.2.0)
|
|
7475
7472
|
This software contains the following license and notice below:
|
|
7476
7473
|
|
|
7477
7474
|
MIT License
|
|
@@ -13661,6 +13658,33 @@ SOFTWARE.
|
|
|
13661
13658
|
|
|
13662
13659
|
---
|
|
13663
13660
|
|
|
13661
|
+
The following software may be included in this product: esbuild (0.28.2)
|
|
13662
|
+
This software contains the following license and notice below:
|
|
13663
|
+
|
|
13664
|
+
MIT License
|
|
13665
|
+
|
|
13666
|
+
Copyright (c) 2020 Evan Wallace
|
|
13667
|
+
|
|
13668
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13669
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13670
|
+
in the Software without restriction, including without limitation the rights
|
|
13671
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13672
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13673
|
+
furnished to do so, subject to the following conditions:
|
|
13674
|
+
|
|
13675
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13676
|
+
copies or substantial portions of the Software.
|
|
13677
|
+
|
|
13678
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13679
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
13680
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13681
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
13682
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
13683
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
13684
|
+
SOFTWARE.
|
|
13685
|
+
|
|
13686
|
+
---
|
|
13687
|
+
|
|
13664
13688
|
The following software may be included in this product: escalade (3.2.0)
|
|
13665
13689
|
This software contains the following license and notice below:
|
|
13666
13690
|
|
|
@@ -20895,32 +20919,6 @@ SOFTWARE.
|
|
|
20895
20919
|
|
|
20896
20920
|
---
|
|
20897
20921
|
|
|
20898
|
-
The following software may be included in this product: nanoid (3.3.12)
|
|
20899
|
-
This software contains the following license and notice below:
|
|
20900
|
-
|
|
20901
|
-
The MIT License (MIT)
|
|
20902
|
-
|
|
20903
|
-
Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
|
|
20904
|
-
|
|
20905
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
20906
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
20907
|
-
the Software without restriction, including without limitation the rights to
|
|
20908
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
20909
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
20910
|
-
subject to the following conditions:
|
|
20911
|
-
|
|
20912
|
-
The above copyright notice and this permission notice shall be included in all
|
|
20913
|
-
copies or substantial portions of the Software.
|
|
20914
|
-
|
|
20915
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20916
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
20917
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
20918
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
20919
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20920
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20921
|
-
|
|
20922
|
-
---
|
|
20923
|
-
|
|
20924
20922
|
The following software may be included in this product: nanoid (3.3.17)
|
|
20925
20923
|
This software contains the following license and notice below:
|
|
20926
20924
|
|
|
@@ -22595,32 +22593,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
22595
22593
|
|
|
22596
22594
|
---
|
|
22597
22595
|
|
|
22598
|
-
The following software may be included in this product: postcss (8.5.19)
|
|
22599
|
-
This software contains the following license and notice below:
|
|
22600
|
-
|
|
22601
|
-
The MIT License (MIT)
|
|
22602
|
-
|
|
22603
|
-
Copyright 2013 Andrey Sitnik <andrey@sitnik.es>
|
|
22604
|
-
|
|
22605
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
22606
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
22607
|
-
the Software without restriction, including without limitation the rights to
|
|
22608
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
22609
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
22610
|
-
subject to the following conditions:
|
|
22611
|
-
|
|
22612
|
-
The above copyright notice and this permission notice shall be included in all
|
|
22613
|
-
copies or substantial portions of the Software.
|
|
22614
|
-
|
|
22615
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22616
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
22617
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
22618
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
22619
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
22620
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22621
|
-
|
|
22622
|
-
---
|
|
22623
|
-
|
|
22624
22596
|
The following software may be included in this product: postcss (8.5.25)
|
|
22625
22597
|
This software contains the following license and notice below:
|
|
22626
22598
|
|
|
@@ -24012,7 +23984,7 @@ IN THE SOFTWARE.
|
|
|
24012
23984
|
|
|
24013
23985
|
---
|
|
24014
23986
|
|
|
24015
|
-
The following software may be included in this product: rolldown (1.2.
|
|
23987
|
+
The following software may be included in this product: rolldown (1.2.2)
|
|
24016
23988
|
This software contains the following license and notice below:
|
|
24017
23989
|
|
|
24018
23990
|
MIT License
|
|
@@ -27207,7 +27179,7 @@ SOFTWARE.
|
|
|
27207
27179
|
|
|
27208
27180
|
---
|
|
27209
27181
|
|
|
27210
|
-
The following software may be included in this product: tsx (4.23.
|
|
27182
|
+
The following software may be included in this product: tsx (4.23.11)
|
|
27211
27183
|
This software contains the following license and notice below:
|
|
27212
27184
|
|
|
27213
27185
|
MIT License
|
|
@@ -28191,7 +28163,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
28191
28163
|
|
|
28192
28164
|
---
|
|
28193
28165
|
|
|
28194
|
-
The following software may be included in this product: vite (8.2.
|
|
28166
|
+
The following software may be included in this product: vite (8.2.1)
|
|
28195
28167
|
This software contains the following license and notice below:
|
|
28196
28168
|
|
|
28197
28169
|
# Vite core license
|
|
@@ -29452,7 +29424,7 @@ Repository: https://github.com/lydell/js-tokens
|
|
|
29452
29424
|
|
|
29453
29425
|
> The MIT License (MIT)
|
|
29454
29426
|
>
|
|
29455
|
-
> Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Simon Lydell
|
|
29427
|
+
> Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 Simon Lydell
|
|
29456
29428
|
>
|
|
29457
29429
|
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
29458
29430
|
> of this software and associated documentation files (the "Software"), to deal
|
package/migrations.json
CHANGED
|
@@ -2,61 +2,6 @@
|
|
|
2
2
|
"$schema": "http://json-schema.org/schema",
|
|
3
3
|
"name": "@aws/nx-plugin",
|
|
4
4
|
"generators": {
|
|
5
|
-
"latest-gateway-agent-targets": {
|
|
6
|
-
"version": "1.0.0-rc.59",
|
|
7
|
-
"description": "Add agent runtime target support to the vended AgentCoreGateway construct and an agentName member to vended agent constructs",
|
|
8
|
-
"implementation": "./src/migrations/latest/gateway-agent-targets/migration"
|
|
9
|
-
},
|
|
10
|
-
"latest-smithy-ssdk-bundle-pins": {
|
|
11
|
-
"version": "1.0.0-rc.58",
|
|
12
|
-
"description": "Bump the rolldown and dts plugin pins in the Smithy build.Dockerfile so the bundled SSDK type declaration resolves",
|
|
13
|
-
"implementation": "./src/migrations/latest/smithy-ssdk-bundle-pins/migration"
|
|
14
|
-
},
|
|
15
|
-
"latest-gateway-cognito-passthrough": {
|
|
16
|
-
"version": "1.0.0-rc.60",
|
|
17
|
-
"description": "Front Cognito agents with an AgentCore Gateway via JWT passthrough: addAgent picks the target credential from the agent's auth, agent constructs gain an auth member, and Cognito runtimes allowlist the Authorization header",
|
|
18
|
-
"implementation": "./src/migrations/latest/gateway-cognito-passthrough/migration"
|
|
19
|
-
},
|
|
20
|
-
"latest-waf-log-group-removal": {
|
|
21
|
-
"version": "1.0.0-rc.60",
|
|
22
|
-
"description": "Set RemovalPolicy.DESTROY on WAF log groups in the vended AgentCoreGateway and REST API constructs so a rolled-back deploy does not orphan them",
|
|
23
|
-
"implementation": "./src/migrations/latest/waf-log-group-removal/migration"
|
|
24
|
-
},
|
|
25
|
-
"latest-strip-pip-from-python-images": {
|
|
26
|
-
"version": "1.0.0-rc.60",
|
|
27
|
-
"description": "Remove pip from vended Python agent / MCP server images so its vulnerable vendored packages are not present at runtime",
|
|
28
|
-
"implementation": "./src/migrations/latest/strip-pip-from-python-images/migration"
|
|
29
|
-
},
|
|
30
|
-
"latest-py-agent-lifespan-construction": {
|
|
31
|
-
"version": "1.0.0-rc.61",
|
|
32
|
-
"description": "Move py#agent HTTP/AG-UI agent construction out of module import time and into a FastAPI lifespan handler, stored on app.state",
|
|
33
|
-
"implementation": "./src/migrations/latest/py-agent-lifespan-construction/migration"
|
|
34
|
-
},
|
|
35
|
-
"latest-rename-load-runtime-config-target": {
|
|
36
|
-
"version": "1.0.0-rc.62",
|
|
37
|
-
"description": "Clone the react website 'load:runtime-config' target to a 'load-runtime-config' target so it can be run with the verb syntax (nx load-runtime-config <project>)",
|
|
38
|
-
"implementation": "./src/migrations/latest/rename-load-runtime-config-target/migration"
|
|
39
|
-
},
|
|
40
|
-
"latest-add-deploy-sandbox-target": {
|
|
41
|
-
"version": "1.0.0-rc.63",
|
|
42
|
-
"description": "Add a deploy-sandbox target to CDK infrastructure projects which deploys the sandbox stage",
|
|
43
|
-
"implementation": "./src/migrations/latest/add-deploy-sandbox-target/migration"
|
|
44
|
-
},
|
|
45
|
-
"latest-smithy-build-without-docker": {
|
|
46
|
-
"version": "1.0.0-rc.64",
|
|
47
|
-
"description": "Build Smithy projects with the Smithy CLI directly rather than in a container, removing the Docker prerequisite",
|
|
48
|
-
"implementation": "./src/migrations/latest/smithy-build-without-docker/migration"
|
|
49
|
-
},
|
|
50
|
-
"latest-vite-config-import-meta-dirname": {
|
|
51
|
-
"version": "1.0.0-rc.65",
|
|
52
|
-
"description": "Resolve vite and vitest config paths from import.meta.dirname rather than __dirname",
|
|
53
|
-
"implementation": "./src/migrations/latest/vite-config-import-meta-dirname/migration"
|
|
54
|
-
},
|
|
55
|
-
"latest-rolldown-code-splitting": {
|
|
56
|
-
"version": "1.0.0-rc.65",
|
|
57
|
-
"description": "Replace the deprecated inlineDynamicImports rolldown output option with codeSplitting",
|
|
58
|
-
"implementation": "./src/migrations/latest/rolldown-code-splitting/migration"
|
|
59
|
-
},
|
|
60
5
|
"v1.0.0-rc.50-0001-modernize-function-props-cast": {
|
|
61
6
|
"version": "1.0.0-rc.50",
|
|
62
7
|
"description": "Replace the legacy angle-bracket FunctionProps type assertion with the modern as syntax in generated API constructs",
|
|
@@ -97,15 +42,70 @@
|
|
|
97
42
|
"description": "Add session management support to ts#agent",
|
|
98
43
|
"implementation": "./src/migrations/v1.0.0-rc.57/0001-ts-agent-session-management-support/migration"
|
|
99
44
|
},
|
|
100
|
-
"
|
|
45
|
+
"v1.0.0-rc.58-0001-smithy-ssdk-bundle-pins": {
|
|
46
|
+
"version": "1.0.0-rc.58",
|
|
47
|
+
"description": "Bump the rolldown and dts plugin pins in the Smithy build.Dockerfile so the bundled SSDK type declaration resolves",
|
|
48
|
+
"implementation": "./src/migrations/v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins/migration"
|
|
49
|
+
},
|
|
50
|
+
"v1.0.0-rc.59-0001-gateway-agent-targets": {
|
|
51
|
+
"version": "1.0.0-rc.59",
|
|
52
|
+
"description": "Add agent runtime target support to the vended AgentCoreGateway construct and an agentName member to vended agent constructs",
|
|
53
|
+
"implementation": "./src/migrations/v1.0.0-rc.59/0001-gateway-agent-targets/migration"
|
|
54
|
+
},
|
|
55
|
+
"v1.0.0-rc.60-0001-gateway-cognito-passthrough": {
|
|
56
|
+
"version": "1.0.0-rc.60",
|
|
57
|
+
"description": "Front Cognito agents with an AgentCore Gateway via JWT passthrough: addAgent picks the target credential from the agent's auth, agent constructs gain an auth member, and Cognito runtimes allowlist the Authorization header",
|
|
58
|
+
"implementation": "./src/migrations/v1.0.0-rc.60/0001-gateway-cognito-passthrough/migration"
|
|
59
|
+
},
|
|
60
|
+
"v1.0.0-rc.60-0002-waf-log-group-removal": {
|
|
61
|
+
"version": "1.0.0-rc.60",
|
|
62
|
+
"description": "Set RemovalPolicy.DESTROY on WAF log groups in the vended AgentCoreGateway and REST API constructs so a rolled-back deploy does not orphan them",
|
|
63
|
+
"implementation": "./src/migrations/v1.0.0-rc.60/0002-waf-log-group-removal/migration"
|
|
64
|
+
},
|
|
65
|
+
"v1.0.0-rc.60-0003-strip-pip-from-python-images": {
|
|
66
|
+
"version": "1.0.0-rc.60",
|
|
67
|
+
"description": "Remove pip from vended Python agent / MCP server images so its vulnerable vendored packages are not present at runtime",
|
|
68
|
+
"implementation": "./src/migrations/v1.0.0-rc.60/0003-strip-pip-from-python-images/migration"
|
|
69
|
+
},
|
|
70
|
+
"v1.0.0-rc.61-0001-py-agent-lifespan-construction": {
|
|
71
|
+
"version": "1.0.0-rc.61",
|
|
72
|
+
"description": "Move py#agent HTTP/AG-UI agent construction out of module import time and into a FastAPI lifespan handler, stored on app.state",
|
|
73
|
+
"implementation": "./src/migrations/v1.0.0-rc.61/0001-py-agent-lifespan-construction/migration"
|
|
74
|
+
},
|
|
75
|
+
"v1.0.0-rc.62-0001-rename-load-runtime-config-target": {
|
|
76
|
+
"version": "1.0.0-rc.62",
|
|
77
|
+
"description": "Clone the react website 'load:runtime-config' target to a 'load-runtime-config' target so it can be run with the verb syntax (nx load-runtime-config <project>)",
|
|
78
|
+
"implementation": "./src/migrations/v1.0.0-rc.62/0001-rename-load-runtime-config-target/migration"
|
|
79
|
+
},
|
|
80
|
+
"v1.0.0-rc.63-0001-add-deploy-sandbox-target": {
|
|
81
|
+
"version": "1.0.0-rc.63",
|
|
82
|
+
"description": "Add a deploy-sandbox target to CDK infrastructure projects which deploys the sandbox stage",
|
|
83
|
+
"implementation": "./src/migrations/v1.0.0-rc.63/0001-add-deploy-sandbox-target/migration"
|
|
84
|
+
},
|
|
85
|
+
"v1.0.0-rc.64-0001-smithy-build-without-docker": {
|
|
86
|
+
"version": "1.0.0-rc.64",
|
|
87
|
+
"description": "Build Smithy projects with the Smithy CLI directly rather than in a container, removing the Docker prerequisite",
|
|
88
|
+
"implementation": "./src/migrations/v1.0.0-rc.64/0001-smithy-build-without-docker/migration"
|
|
89
|
+
},
|
|
90
|
+
"v1.0.0-rc.65-0001-vite-config-import-meta-dirname": {
|
|
101
91
|
"version": "1.0.0-rc.65",
|
|
92
|
+
"description": "Resolve vite and vitest config paths from import.meta.dirname rather than __dirname",
|
|
93
|
+
"implementation": "./src/migrations/v1.0.0-rc.65/0001-vite-config-import-meta-dirname/migration"
|
|
94
|
+
},
|
|
95
|
+
"v1.0.0-rc.65-0002-rolldown-code-splitting": {
|
|
96
|
+
"version": "1.0.0-rc.65",
|
|
97
|
+
"description": "Replace the deprecated inlineDynamicImports rolldown output option with codeSplitting",
|
|
98
|
+
"implementation": "./src/migrations/v1.0.0-rc.65/0002-rolldown-code-splitting/migration"
|
|
99
|
+
},
|
|
100
|
+
"sync-vended-versions": {
|
|
101
|
+
"version": "1.0.0-rc.66",
|
|
102
102
|
"description": "Sync vended dependency versions and the tracked plugin version to those vended by this release",
|
|
103
103
|
"implementation": "./src/utils/version-upgrade-migration/migration"
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
"packageJsonUpdates": {
|
|
107
107
|
"nx-23.1.1-nx-packages": {
|
|
108
|
-
"version": "1.0.0-rc.
|
|
108
|
+
"version": "1.0.0-rc.58",
|
|
109
109
|
"packages": {
|
|
110
110
|
"nx": {
|
|
111
111
|
"version": "23.1.1",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws/nx-plugin",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.66",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/awslabs/nx-plugin-for-aws.git",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@apidevtools/swagger-parser": "12.1.0",
|
|
43
|
-
"@astral-sh/ruff-wasm-nodejs": "0.16.
|
|
43
|
+
"@astral-sh/ruff-wasm-nodejs": "0.16.2",
|
|
44
44
|
"@biomejs/js-api": "6.0.0",
|
|
45
|
-
"@biomejs/wasm-nodejs": "2.5.
|
|
45
|
+
"@biomejs/wasm-nodejs": "2.5.7",
|
|
46
46
|
"@getgrit/gritql": "0.0.3",
|
|
47
47
|
"@iarna/toml": "2.2.5",
|
|
48
48
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"typescript": "6.0.3",
|
|
80
80
|
"unified": "11.0.5",
|
|
81
81
|
"unist-util-visit": "5.1.0",
|
|
82
|
-
"vite": "8.2.
|
|
82
|
+
"vite": "8.2.1",
|
|
83
83
|
"vitest": "4.1.10",
|
|
84
84
|
"zod": "4.4.3"
|
|
85
85
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins/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 { SMITHY_PROJECT_GENERATOR_INFO } from '../../../smithy/project/generator';\nimport { applyGritQL } from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { isVendedUpgrade } from '../../../utils/version-upgrade-migration/vended-upgrade';\n\n/**\n * Move a Smithy `build.Dockerfile` onto the SSDK bundle pins this release fixes.\n *\n * `rolldown-plugin-dts` named the bundled declaration after its content hash\n * before 0.20.0, so the generated handler's `./generated/ssdk/index.js` import\n * found no `index.d.ts` beside it and `compile` failed with TS7016. The two pins\n * move together: the plugin release that fixed the naming needs a rolldown past\n * the pin this shipped with.\n *\n * There is no Dockerfile grammar, so each pin is matched as an anchored rewrite\n * over the whole file with the version captured — `${...}` in these patterns is\n * GritQL metavariable syntax, not interpolation.\n */\n\n/** A pin in the file body, and the version this migration moves it to. */\ninterface Pin {\n /** The package as the install command names it. */\n readonly name: string;\n readonly target: string;\n}\n\n/**\n * Hardcoded rather than read from `TS_VERSIONS`: this runs once, for the release\n * that fixed the declaration naming, so it must keep applying that exact change\n * however far the vended versions move afterwards. A workspace on a later release\n * gets the newer pins from the version sync instead.\n */\nconst PINS: readonly Pin[] = [\n { name: 'rolldown', target: '1.2.0' },\n { name: 'rolldown-plugin-dts', target: '0.28.0' },\n { name: '@rollup/plugin-esm-shim', target: '0.1.8' },\n];\n\n/** A version ends at whitespace, a line break or the end of the command. */\nconst VERSION = String.raw`[^\\s\\\\]+`;\n\nconst escapeRegExp = (value: string): string =>\n value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n\n/**\n * Rewrite every occurrence of one pin to its target version.\n *\n * The pin is matched by name, so a `rolldown-plugin-dts@x` in the same command as\n * `rolldown@y` keeps its own version — the `@` before the version terminates the\n * match, so the shorter name does not match the longer one.\n */\nconst rewritePin = ({ name, target }: Pin): string =>\n `r\"[\\\\s\\\\S]*${escapeRegExp(name)}@(${VERSION})[\\\\s\\\\S]*\"($version) where { $version => \\`${target}\\` }`;\n\n/** Whether the file pins this package behind the target version. */\nconst isBehindTarget = (contents: string, { name, target }: Pin): boolean => {\n const matches = contents.matchAll(\n new RegExp(`${escapeRegExp(name)}@(${VERSION})`, 'g'),\n );\n const declared = [...matches].flatMap((match) =>\n match[1] ? [match[1]] : [],\n );\n // A rewrite replaces every occurrence at once, so this has to hold for all of\n // them. Compared rather than tested for inequality, so a workspace a later\n // release has already moved past the target keeps its newer pin.\n return (\n declared.length > 0 &&\n declared.every((version) => isVendedUpgrade(target, version))\n );\n};\n\nconst divergedNextStep = (path: string): string =>\n `${path}: the Smithy build image's bundle pins have diverged from the generated shape - left untouched. Update \\`rolldown\\` to 1.2.0 and \\`rolldown-plugin-dts\\` to 0.28.0.`;\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n // Only a Smithy service project bundles the SSDK; the shapes type builds the\n // model alone and pins none of this.\n const buildDockerfiles = [...getProjects(tree).values()]\n .filter((project) => {\n const metadata = project.metadata as\n | { generator?: string; smithyType?: string }\n | undefined;\n return (\n metadata?.generator === SMITHY_PROJECT_GENERATOR_INFO.id &&\n metadata.smithyType === 'service'\n );\n })\n .map((project) => joinPathFragments(project.root, 'build.Dockerfile'))\n .filter((filePath) => tree.exists(filePath));\n\n for (const path of buildDockerfiles) {\n const contents = tree.read(path, 'utf-8') ?? '';\n\n for (const pin of PINS) {\n if (!isBehindTarget(contents, pin)) {\n continue;\n }\n if (!(await applyGritQL(tree, path, rewritePin(pin)))) {\n nextSteps.push(divergedNextStep(path));\n break;\n }\n }\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["getProjects","joinPathFragments","SMITHY_PROJECT_GENERATOR_INFO","applyGritQL","formatFilesInSubtree","isVendedUpgrade","PINS","name","target","VERSION","String","raw","escapeRegExp","value","replace","rewritePin","isBehindTarget","contents","matches","matchAll","RegExp","declared","flatMap","match","length","every","version","divergedNextStep","path","migration","tree","nextSteps","buildDockerfiles","values","filter","project","metadata","generator","id","smithyType","map","root","filePath","exists","read","pin","push"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,6BAA6B,QAAQ,uCAAoC;AAClF,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,eAAe,QAAQ,6DAA0D;AAuB1F;;;;;CAKC,GACD,MAAMC,OAAuB;IAC3B;QAAEC,MAAM;QAAYC,QAAQ;IAAQ;IACpC;QAAED,MAAM;QAAuBC,QAAQ;IAAS;IAChD;QAAED,MAAM;QAA2BC,QAAQ;IAAQ;CACpD;AAED,0EAA0E,GAC1E,MAAMC,UAAUC,OAAOC,GAAG,CAAC,QAAQ,CAAC;AAEpC,MAAMC,eAAe,CAACC,QACpBA,MAAMC,OAAO,CAAC,uBAAuB;AAEvC;;;;;;CAMC,GACD,MAAMC,aAAa,CAAC,EAAER,IAAI,EAAEC,MAAM,EAAO,GACvC,CAAC,WAAW,EAAEI,aAAaL,MAAM,EAAE,EAAEE,QAAQ,4CAA4C,EAAED,OAAO,IAAI,CAAC;AAEzG,kEAAkE,GAClE,MAAMQ,iBAAiB,CAACC,UAAkB,EAAEV,IAAI,EAAEC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
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.59/0001-gateway-agent-targets/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MigrationReturnObject, Tree } from '@nx/devkit';\nimport {\n applyGritQL,\n GRIT_INSERT_PLACEHOLDER,\n insertViaGritQL,\n matchGritQL,\n} from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n} from '../../../utils/shared-constructs-constants';\n\n/**\n * Bring existing workspaces up to the generators' current gateway-target\n * support, so agents can be attached to an http-protocol AgentCore Gateway:\n *\n * - The vended `AgentCoreGateway` core construct gains the `protocol` prop\n * (http gateways have no protocol type, which AgentCore Runtime targets\n * require) and the `addAgent` / `addAgentTarget` methods.\n * - Vended agent constructs gain the `agentName` member `addAgent` reads as\n * the default gateway target name.\n *\n * Both files are generated with `KeepExisting`, so without this an upgraded\n * workspace pairs new app-level constructs with stale core ones.\n */\n\nconst GATEWAY_CONSTRUCT_FILE = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src/core/agentcore-gateway/agentcore-gateway.ts`;\n\nconst AGENTS_DIR = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src/app/agents`;\n\nconst PROTOCOL_PROP = `/**\n * The gateway's protocol. An \\`mcp\\` gateway aggregates MCP server targets\n * into a single MCP endpoint. An \\`http\\` gateway has no protocol type and\n * proxies requests to AgentCore Runtime targets via path-based routing\n * (\\`/<targetName>/invocations\\`) — the target type AgentCore only allows on\n * gateways without a protocol type.\n *\n * @default 'mcp'\n */\n readonly protocol?: 'mcp' | 'http';`;\n\nconst PROTOCOL_CONSTRUCTOR_STATEMENTS = `this.protocol = props?.protocol ?? 'mcp';\n`;\n\nconst PROTOCOL_TYPE_REMOVAL = `\n if (this.protocol === 'http') {\n // AgentCore Runtime targets require a gateway without a protocol type,\n // which the Gateway L2 cannot express — it always renders MCP — so\n // remove the protocol from the underlying CloudFormation resource.\n const cfnGateway = this.gateway.node.defaultChild as agentcore.CfnGateway;\n cfnGateway.addPropertyDeletionOverride('ProtocolType');\n cfnGateway.addPropertyDeletionOverride('ProtocolConfiguration');\n }`;\n\nconst AGENT_TARGET_METHODS = `\n /**\n * Add an agent runtime construct as a target of this Gateway. Requires the\n * \\`http\\` protocol — the gateway proxies requests for the agent under\n * \\`<gatewayUrl>/<targetName>/invocations\\`, without protocol translation.\n *\n * The target name defaults to the agent construct's \\`agentName\\` (its\n * project's class name in kebab-case, e.g. \\`MyAgent\\` -> \\`my-agent\\`). It\n * forms the target's invocation path, so renaming it later is a breaking\n * change for consumers.\n */\n public addAgent(\n agent: Construct & {\n readonly agentCoreRuntime: agentcore.Runtime;\n readonly agentName: string;\n },\n props?: {\n gatewayTargetName?: string;\n },\n ): agentcore.CfnGatewayTarget {\n return this.addAgentTarget({\n gatewayTargetName: props?.gatewayTargetName ?? agent.agentName,\n agentRuntimeArn: agent.agentCoreRuntime.agentRuntimeArn,\n });\n }\n\n /**\n * Register an agent runtime ARN as a Gateway target. Prefer\n * {@link addAgent} when the construct is in scope.\n */\n public addAgentTarget(props: {\n gatewayTargetName: string;\n agentRuntimeArn: string;\n }): agentcore.CfnGatewayTarget {\n if (this.protocol !== 'http') {\n throw new Error(\n \\`Agent runtime targets require an http-protocol gateway, but this gateway uses '\\${this.protocol}'.\\`,\n );\n }\n\n // The construct id is derived from the target name so the two change\n // together — target names are unique per gateway, and replacing a target\n // under an unchanged name fails with AlreadyExists.\n const target = new agentcore.CfnGatewayTarget(\n this,\n \\`Target-\\${props.gatewayTargetName}\\`,\n {\n gatewayIdentifier: this.gateway.gatewayId,\n name: props.gatewayTargetName,\n targetConfiguration: {\n http: {\n agentcoreRuntime: {\n arn: props.agentRuntimeArn,\n qualifier: 'DEFAULT',\n },\n },\n },\n // The bare gateway IAM role credential: runtime targets reject the\n // iamCredentialProvider detail MCP targets carry.\n credentialProviderConfigurations: [\n {\n credentialProviderType: 'GATEWAY_IAM_ROLE',\n },\n ],\n },\n );\n\n // Grant the gateway role invoke access to the target runtime before the\n // target is created — AgentCore validates access to the runtime during\n // target creation.\n const grant = this.gateway.role.addToPrincipalPolicy(\n new iam.PolicyStatement({\n actions: [\n 'bedrock-agentcore:InvokeAgentRuntime',\n 'bedrock-agentcore:InvokeAgentRuntimeWithWebSocketStream',\n // A2A targets additionally serve their agent card via the gateway.\n 'bedrock-agentcore:GetAgentCard',\n ],\n resources: [props.agentRuntimeArn, \\`\\${props.agentRuntimeArn}/*\\`],\n }),\n );\n if (grant.policyDependable) {\n target.node.addDependency(grant.policyDependable);\n }\n\n return target;\n }`;\n\n/**\n * Add the `protocol` prop, its constructor handling and the agent-target\n * methods to the vended `AgentCoreGateway` core construct.\n */\nconst migrateGatewayConstruct = async (\n tree: Tree,\n nextSteps: string[],\n): Promise<void> => {\n if (!tree.exists(GATEWAY_CONSTRUCT_FILE)) {\n // No vended gateway construct in this workspace - nothing to migrate.\n return;\n }\n\n if (\n (tree.read(GATEWAY_CONSTRUCT_FILE, 'utf-8') ?? '').includes(\n 'addAgentTarget',\n )\n ) {\n // Already migrated.\n return;\n }\n\n const divergedMessage = `${GATEWAY_CONSTRUCT_FILE}: the AgentCoreGateway construct has diverged from the generated shape - left untouched. Re-run the agentcore-gateway generator in a fresh workspace to see the current construct, which supports agent runtime targets via a 'protocol' prop and addAgent()/addAgentTarget() methods.`;\n\n // Anchored on the shapes every vended version of the construct carries: the\n // props interface, the class field the protocol field is inserted after,\n // and the Gateway creation in the constructor.\n const hasVendedShape =\n (await matchGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n '`export interface AgentCoreGatewayProps { $_ }`',\n )) &&\n (await matchGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n '`private readonly targetRuntimeArns: string[] = []`',\n )) &&\n (await matchGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n \"`this.gateway = new agentcore.Gateway(this, 'Gateway', $_)`\",\n ));\n\n if (!hasVendedShape) {\n nextSteps.push(divergedMessage);\n return;\n }\n\n // 1. The protocol prop on AgentCoreGatewayProps. The placeholder keeps the\n // prop's doc comment (with its backticks) out of the GritQL pattern.\n await insertViaGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n `\\`export interface AgentCoreGatewayProps { $members }\\` where {\n $members <: not contains \\`protocol\\`\n} => \\`export interface AgentCoreGatewayProps { $members\n ${GRIT_INSERT_PLACEHOLDER}\n}\\``,\n PROTOCOL_PROP,\n );\n\n // 2. The protocol class field. Matched without the trailing semicolon —\n // GritQL parses the snippet standalone, where the semicolon is not part\n // of the field's AST node.\n await applyGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n `\\`private readonly targetRuntimeArns: string[] = []\\` as $field where {\n $program <: not contains \\`private readonly protocol\\`\n} => \\`$field;\n private readonly protocol: 'mcp' | 'http'\\``,\n );\n\n // 3. Assign the field and remove the protocol type for http gateways.\n await insertViaGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n `\\`this.gateway = new agentcore.Gateway($args);\\` as $stmt where {\n $program <: not contains \\`this.protocol = props\\`\n} => \\`${GRIT_INSERT_PLACEHOLDER}\n $stmt\\``,\n PROTOCOL_CONSTRUCTOR_STATEMENTS,\n );\n await insertViaGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n `\\`this.gateway = new agentcore.Gateway($args);\\` as $stmt where {\n $program <: not contains \\`addPropertyDeletionOverride\\`\n} => \\`$stmt\n${GRIT_INSERT_PLACEHOLDER}\\``,\n PROTOCOL_TYPE_REMOVAL,\n );\n\n // 4. The agent-target methods, inserted after addGatewayTarget (present in\n // every vended version that also has the readiness probe field).\n const addedMethods = await insertViaGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n `\\`public addGatewayTarget($params): agentcore.CfnGatewayTarget { $body }\\` as $method where {\n $program <: not contains \\`addAgentTarget\\`\n} => \\`$method\n${GRIT_INSERT_PLACEHOLDER}\\``,\n AGENT_TARGET_METHODS,\n );\n\n if (!addedMethods) {\n nextSteps.push(divergedMessage);\n return;\n }\n};\n\n/**\n * Add the `agentName` member to each vended agent construct, which\n * `AgentCoreGateway.addAgent` reads as the default gateway target name.\n */\nconst migrateAgentConstructs = async (\n tree: Tree,\n nextSteps: string[],\n): Promise<void> => {\n if (!tree.exists(AGENTS_DIR)) {\n return;\n }\n for (const dir of tree.children(AGENTS_DIR)) {\n const constructFile = `${AGENTS_DIR}/${dir}/${dir}.ts`;\n if (!tree.exists(constructFile)) {\n continue;\n }\n if ((tree.read(constructFile, 'utf-8') ?? '').includes('agentName')) {\n // Already migrated (or user-added).\n continue;\n }\n const added = await insertViaGritQL(\n tree,\n constructFile,\n `\\`public readonly agentCoreRuntime: Runtime\\` as $field => \\`$field;\n ${GRIT_INSERT_PLACEHOLDER}\\``,\n `/** Default Gateway target name for this agent. */\n public readonly agentName = '${dir}'`,\n );\n if (!added) {\n nextSteps.push(\n `${constructFile}: the agent construct has diverged from the generated shape - left untouched. To attach this agent to a gateway with addAgent(), add a \\`public readonly agentName = '${dir}';\\` member (or use addAgentTarget() with an explicit target name).`,\n );\n }\n }\n};\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n await migrateGatewayConstruct(tree, nextSteps);\n await migrateAgentConstructs(tree, nextSteps);\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["applyGritQL","GRIT_INSERT_PLACEHOLDER","insertViaGritQL","matchGritQL","formatFilesInSubtree","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","GATEWAY_CONSTRUCT_FILE","AGENTS_DIR","PROTOCOL_PROP","PROTOCOL_CONSTRUCTOR_STATEMENTS","PROTOCOL_TYPE_REMOVAL","AGENT_TARGET_METHODS","migrateGatewayConstruct","tree","nextSteps","exists","read","includes","divergedMessage","hasVendedShape","push","addedMethods","migrateAgentConstructs","dir","children","constructFile","added","migration"],"mappings":"AAAA;;;CAGC,GAED,SACEA,WAAW,EACXC,uBAAuB,EACvBC,eAAe,EACfC,WAAW,QACN,wBAAqB;AAC5B,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SACEC,YAAY,EACZC,qBAAqB,QAChB,gDAA6C;AAEpD;;;;;;;;;;;;CAYC,GAED,MAAMC,yBAAyB,GAAGF,aAAa,CAAC,EAAEC,sBAAsB,gDAAgD,CAAC;AAEzH,MAAME,aAAa,GAAGH,aAAa,CAAC,EAAEC,sBAAsB,eAAe,CAAC;AAE5E,MAAMG,gBAAgB,CAAC;;;;;;;;;qCASc,CAAC;AAEtC,MAAMC,kCAAkC,CAAC;AACzC,CAAC;AAED,MAAMC,wBAAwB,CAAC;;;;;;;;KAQ1B,CAAC;AAEN,MAAMC,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsF3B,CAAC;AAEJ;;;CAGC,GACD,MAAMC,0BAA0B,OAC9BC,MACAC;IAEA,IAAI,CAACD,KAAKE,MAAM,CAACT,yBAAyB;QACxC,sEAAsE;QACtE;IACF;IAEA,IACE,AAACO,CAAAA,KAAKG,IAAI,CAACV,wBAAwB,YAAY,EAAC,EAAGW,QAAQ,CACzD,mBAEF;QACA,oBAAoB;QACpB;IACF;IAEA,MAAMC,kBAAkB,GAAGZ,uBAAuB,sRAAsR,CAAC;IAEzU,4EAA4E;IAC5E,yEAAyE;IACzE,+CAA+C;IAC/C,MAAMa,iBACJ,AAAC,MAAMjB,YACLW,MACAP,wBACA,sDAED,MAAMJ,YACLW,MACAP,wBACA,0DAED,MAAMJ,YACLW,MACAP,wBACA;IAGJ,IAAI,CAACa,gBAAgB;QACnBL,UAAUM,IAAI,CAACF;QACf;IACF;IAEA,2EAA2E;IAC3E,wEA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,UAC5Bd,IAAU;IAEV,MAAMC,YAAsB,EAAE;IAE9B,MAAMF,wBAAwBC,MAAMC;IACpC,MAAMQ,uBAAuBT,MAAMC;IAEnC,MAAMX,qBAAqBU;IAE3B,OAAO;QAAEC;IAAU;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.60/0001-gateway-cognito-passthrough/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MigrationReturnObject, Tree } from '@nx/devkit';\nimport {\n applyGritQL,\n GRIT_INSERT_PLACEHOLDER,\n insertViaGritQL,\n matchGritQL,\n} from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../../../utils/shared-constructs-constants';\n\n/**\n * Bring existing workspaces up to the generators' current gateway->agent\n * support for Cognito agents, which forward the caller's JWT to the runtime:\n *\n * - The vended `AgentCoreGateway` construct's `addAgent`/`addAgentTarget` pick\n * the outbound credential from the agent's `auth`: a `cognito` agent uses\n * `JWT_PASSTHROUGH` (the caller's token reaches the runtime), an `iam` agent\n * the gateway role (`GATEWAY_IAM_ROLE`, the previous behaviour).\n * - Vended agent constructs gain an `auth` member `addAgent` reads, and Cognito\n * agents allowlist the `Authorization` header (CDK + Terraform runtime) so the\n * runtime receives the forwarded token.\n *\n * These files are generated with `KeepExisting`, so without this an upgraded\n * workspace pairs new app-level constructs with stale core ones. Diverged files\n * are left untouched and reported via `nextSteps`.\n */\n\nconst GATEWAY_CONSTRUCT_FILE = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src/core/agentcore-gateway/agentcore-gateway.ts`;\nconst AGENTS_DIR = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src/app/agents`;\nconst TF_RUNTIME_FILE = `${PACKAGES_DIR}/${SHARED_TERRAFORM_DIR}/src/core/agent-core/runtime.tf`;\n\n/**\n * Teach the vended `AgentCoreGateway` construct to pick the target credential\n * from the agent's `auth` (JWT passthrough for Cognito, gateway role for IAM).\n */\nconst migrateGatewayConstruct = async (\n tree: Tree,\n nextSteps: string[],\n): Promise<void> => {\n if (!tree.exists(GATEWAY_CONSTRUCT_FILE)) {\n return; // No vended gateway construct.\n }\n // Predates agent-target support (the gateway-agent-targets migration adds\n // addAgentTarget first) — match the method, not a bare identifier.\n if (\n !(await matchGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n '`addAgentTarget(props: { $_ }): agentcore.CfnGatewayTarget { $_ }`',\n ))\n ) {\n return;\n }\n // Already migrated: the credentials member is on addAgentTarget's props.\n if (\n await matchGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n \"`credentials?: 'gateway-iam' | 'jwt-passthrough'`\",\n )\n ) {\n return;\n }\n\n const divergedMessage = `In ${GATEWAY_CONSTRUCT_FILE}: have addAgent read the agent's \\`auth\\` and pass \\`credentials: 'jwt-passthrough'\\` to addAgentTarget, so the target's credentialProviderType becomes 'JWT_PASSTHROUGH' for Cognito agents.`;\n\n // GritQL patterns for each of the four edits. Verified against the tree\n // up-front so the transform is all-or-nothing: a construct missing any\n // anchor is left untouched with a single actionable next step, rather than\n // half-migrated.\n const authParamPattern = `\\`readonly agentName: string\\` as $sig where {\n $program <: not contains \\`readonly auth?\\`\n} => \\`$sig;\n readonly auth?: 'iam' | 'cognito'\\``;\n\n const callPattern = `\\`agentRuntimeArn: agent.agentCoreRuntime.agentRuntimeArn\\` as $prop where {\n $program <: not contains \\`credentials:\\`\n} => \\`$prop,\n credentials: agent.auth === 'cognito' ? 'jwt-passthrough' : 'gateway-iam'\\``;\n\n // The addAgentTarget props type: matched on its `agentRuntimeArn: string`\n // member signature (without trailing semicolon), which the rewrite re-adds\n // followed by the credentials member. The `: string` type distinguishes it\n // from the `agentRuntimeArn:` value in the addAgent call.\n const paramPattern = `\\`agentRuntimeArn: string\\` as $sig where {\n $program <: not contains \\`credentials?\\`\n} => \\`$sig;\n credentials?: 'gateway-iam' | 'jwt-passthrough'\\``;\n\n // Scoped to the agent target's own CfnGatewayTarget (the one configured with\n // an agentcoreRuntime), so the MCP server target's GATEWAY_IAM_ROLE — a\n // sibling method with its own credential block — is left untouched.\n const credentialPattern = `\\`credentialProviderType: 'GATEWAY_IAM_ROLE'\\` as $cred where {\n $cred <: within \\`new agentcore.CfnGatewayTarget($_, $_, $config)\\`,\n $config <: contains \\`agentcoreRuntime\\`\n} => \\`credentialProviderType:\n props.credentials === 'jwt-passthrough'\n ? 'JWT_PASSTHROUGH'\n : 'GATEWAY_IAM_ROLE'\\``;\n\n // Verify every anchor matches before mutating anything (matchGritQL is\n // read-only), so a diverged construct is never left partially migrated.\n for (const pattern of [\n authParamPattern,\n callPattern,\n paramPattern,\n credentialPattern,\n ]) {\n if (!(await matchGritQL(tree, GATEWAY_CONSTRUCT_FILE, pattern))) {\n nextSteps.push(divergedMessage);\n return;\n }\n }\n\n await applyGritQL(tree, GATEWAY_CONSTRUCT_FILE, authParamPattern);\n await applyGritQL(tree, GATEWAY_CONSTRUCT_FILE, callPattern);\n await applyGritQL(tree, GATEWAY_CONSTRUCT_FILE, paramPattern);\n await applyGritQL(tree, GATEWAY_CONSTRUCT_FILE, credentialPattern);\n};\n\n/**\n * Add the `auth` member to each vended agent construct, and for Cognito agents\n * allowlist the Authorization header so the runtime receives the forwarded JWT.\n */\nconst migrateAgentConstructs = async (\n tree: Tree,\n nextSteps: string[],\n): Promise<void> => {\n if (!tree.exists(AGENTS_DIR)) {\n return;\n }\n for (const dir of tree.children(AGENTS_DIR)) {\n const constructFile = `${AGENTS_DIR}/${dir}/${dir}.ts`;\n if (!tree.exists(constructFile)) {\n continue;\n }\n // Only agents (which carry a gateway target name), not MCP servers.\n if (\n !(await matchGritQL(\n tree,\n constructFile,\n '`public readonly agentName = $_`',\n ))\n ) {\n continue;\n }\n if (await matchGritQL(tree, constructFile, '`public readonly auth = $_`')) {\n continue; // Already migrated (or user-added).\n }\n\n // Cognito agents configure the runtime's inbound authorizer with a Cognito\n // JWT — match that authorizerConfiguration property specifically.\n const isCognito = await matchGritQL(\n tree,\n constructFile,\n '`authorizerConfiguration: RuntimeAuthorizerConfiguration.usingCognito($_)`',\n );\n const authValue = isCognito ? 'cognito' : 'iam';\n\n // The `auth` member, after the agentName member. Matched without the\n // trailing semicolon — GritQL parses the field's initializer as its AST\n // node, so the semicolon is appended by the rewrite.\n const authPattern = `\\`public readonly agentName = $name\\` as $field => \\`$field;\n /** Inbound auth — a fronting Gateway uses this to pick its outbound credential. */\n public readonly auth = '${authValue}'\\``;\n\n // Cognito agents allowlist the Authorization header so the runtime (and a\n // fronting gateway, via passthrough) receives the caller's token.\n const headerNeeded =\n isCognito &&\n !(await matchGritQL(\n tree,\n constructFile,\n '`requestHeaderConfiguration: $_`',\n ));\n const headerPattern = `\\`authorizerConfiguration: RuntimeAuthorizerConfiguration.usingCognito($args)\\` as $authz where {\n $program <: not contains \\`requestHeaderConfiguration\\`\n} => \\`$authz,\n ${GRIT_INSERT_PLACEHOLDER}\\``;\n const headerText = `// Receive the caller's Authorization header (validated by the authorizer).\n requestHeaderConfiguration: {\n allowlistedHeaders: ['Authorization'],\n }`;\n\n // Verify every anchor up-front so the construct is never half-migrated:\n // if any edit can't be applied, leave the file untouched with one\n // actionable next step.\n const authOk = await matchGritQL(tree, constructFile, authPattern);\n const headerOk =\n !headerNeeded || (await matchGritQL(tree, constructFile, headerPattern));\n if (!authOk || !headerOk) {\n const actions = [\n `add a \\`public readonly auth = '${authValue}';\\` member`,\n ];\n if (headerNeeded) {\n actions.push(\n `add \\`requestHeaderConfiguration: { allowlistedHeaders: ['Authorization'] }\\` to its Runtime so a gateway can pass the caller's JWT through`,\n );\n }\n nextSteps.push(`In ${constructFile}: ${actions.join('; and ')}.`);\n continue;\n }\n\n await applyGritQL(tree, constructFile, authPattern);\n if (headerNeeded) {\n await insertViaGritQL(tree, constructFile, headerPattern, headerText);\n }\n }\n};\n\n/**\n * Add the `request_header_configuration` block to the vended Terraform runtime\n * module so a JWT-authorized runtime receives the forwarded Authorization\n * header (the analogue of the CDK requestHeaderConfiguration).\n */\nconst migrateTerraformRuntime = async (\n tree: Tree,\n nextSteps: string[],\n): Promise<void> => {\n if (!tree.exists(TF_RUNTIME_FILE)) {\n return;\n }\n if (\n await matchGritQL(\n tree,\n TF_RUNTIME_FILE,\n 'language hcl\\n`dynamic \"request_header_configuration\" { $_ }`',\n )\n ) {\n return; // Already migrated.\n }\n\n const tfActionMessage = `In ${TF_RUNTIME_FILE}: add a \\`request_header_configuration { request_header_allowlist = [\"Authorization\"] }\\` block (guarded by the JWT authorizer) to the aws_bedrockagentcore_agent_runtime resource so a gateway can pass the caller's JWT through.`;\n\n const hasAuthorizerBlock = await matchGritQL(\n tree,\n TF_RUNTIME_FILE,\n 'language hcl\\n`dynamic \"authorizer_configuration\" { $_ }`',\n );\n if (!hasAuthorizerBlock) {\n nextSteps.push(tfActionMessage);\n return;\n }\n\n const added = await insertViaGritQL(\n tree,\n TF_RUNTIME_FILE,\n `language hcl\n\\`dynamic \"authorizer_configuration\" { $body }\\` as $block where {\n $block <: within \\`resource \"aws_bedrockagentcore_agent_runtime\" $_ { $_ }\\`\n} => \\`$block\n\n ${GRIT_INSERT_PLACEHOLDER}\\``,\n `# Receive the caller's Authorization header (validated by the JWT authorizer).\n dynamic \"request_header_configuration\" {\n for_each = var.authorizer_configuration != null && try(var.authorizer_configuration.custom_jwt_authorizer, null) != null ? [1] : []\n content {\n request_header_allowlist = [\"Authorization\"]\n }\n }`,\n );\n if (!added) {\n nextSteps.push(tfActionMessage);\n }\n};\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n await migrateGatewayConstruct(tree, nextSteps);\n await migrateAgentConstructs(tree, nextSteps);\n await migrateTerraformRuntime(tree, nextSteps);\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["applyGritQL","GRIT_INSERT_PLACEHOLDER","insertViaGritQL","matchGritQL","formatFilesInSubtree","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","GATEWAY_CONSTRUCT_FILE","AGENTS_DIR","TF_RUNTIME_FILE","migrateGatewayConstruct","tree","nextSteps","exists","divergedMessage","authParamPattern","callPattern","paramPattern","credentialPattern","pattern","push","migrateAgentConstructs","dir","children","constructFile","isCognito","authValue","authPattern","headerNeeded","headerPattern","headerText","authOk","headerOk","actions","join","migrateTerraformRuntime","tfActionMessage","hasAuthorizerBlock","added","migration"],"mappings":"AAAA;;;CAGC,GAED,SACEA,WAAW,EACXC,uBAAuB,EACvBC,eAAe,EACfC,WAAW,QACN,wBAAqB;AAC5B,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SACEC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,QACf,gDAA6C;AAEpD;;;;;;;;;;;;;;;CAeC,GAED,MAAMC,yBAAyB,GAAGH,aAAa,CAAC,EAAEC,sBAAsB,gDAAgD,CAAC;AACzH,MAAMG,aAAa,GAAGJ,aAAa,CAAC,EAAEC,sBAAsB,eAAe,CAAC;AAC5E,MAAMI,kBAAkB,GAAGL,aAAa,CAAC,EAAEE,qBAAqB,+BAA+B,CAAC;AAEhG;;;CAGC,GACD,MAAMI,0BAA0B,OAC9BC,MACAC;IAEA,IAAI,CAACD,KAAKE,MAAM,CAACN,yBAAyB;QACxC,QAAQ,+BAA+B;IACzC;IACA,0EAA0E;IAC1E,mEAAmE;IACnE,IACE,CAAE,MAAML,YACNS,MACAJ,wBACA,uEAEF;QACA;IACF;IACA,yEAAyE;IACzE,IACE,MAAML,YACJS,MACAJ,wBACA,sDAEF;QACA;IACF;IAEA,MAAMO,kBAAkB,CAAC,GAAG,EAAEP,uBAAuB,6LAA6L,CAAC;IAEnP,wEAAwE;I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gB;QACf;IACF;IAEA,MAAME,QAAQ,MAAMrC,gBAClBU,MACAF,iBACA,CAAC;;;;;EAKH,EAAET,wBAAwB,EAAE,CAAC,EAC3B,CAAC;;;;;;GAMF,CAAC;IAEF,IAAI,CAACsC,OAAO;QACV1B,UAAUQ,IAAI,CAACgB;IACjB;AACF;AAEA,eAAe,eAAeG,UAC5B5B,IAAU;IAEV,MAAMC,YAAsB,EAAE;IAE9B,MAAMF,wBAAwBC,MAAMC;IACpC,MAAMS,uBAAuBV,MAAMC;IACnC,MAAMuB,wBAAwBxB,MAAMC;IAEpC,MAAMT,qBAAqBQ;IAE3B,OAAO;QAAEC;IAAU;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.60/0002-waf-log-group-removal/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MigrationReturnObject, Tree } from '@nx/devkit';\nimport {\n addDestructuredImport,\n insertViaGritQL,\n matchGritQL,\n} from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n} from '../../../utils/shared-constructs-constants';\n\n/**\n * Vended WAF log groups have a deterministic name (WAFv2 requires the\n * `aws-waf-logs-` prefix, so the name can't be CloudFormation-generated) and,\n * without an explicit removal policy, inherit CloudFormation's default RETAIN\n * for log groups. A rolled-back or replaced deploy then orphans the log group,\n * so the next deploy fails to create one of the same name. Set\n * `RemovalPolicy.DESTROY` so it is torn down with the stack, matching the\n * vended user-identity (Cognito) construct.\n */\n\nconst CONSTRUCTS_SRC = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src`;\n\n/**\n * A vended construct carrying a WAF log group. They differ in how the log\n * group is constructed and how `cdk` is imported: the gateway namespaces both\n * (`logs.LogGroup`, `cdk.RemovalPolicy`), the rest api destructures both\n * (`LogGroup`, `RemovalPolicy` — the latter added by this migration when\n * absent).\n */\ninterface WafConstruct {\n file: string;\n /** How `LogGroup` is referenced in this file (`LogGroup` or `logs.LogGroup`). */\n logGroupExpr: string;\n /** The removal policy expression, matching the file's import style. */\n removalPolicyExpr: string;\n /** When set, ensure this destructured import from `aws-cdk-lib`. */\n destructuredImport?: string;\n}\n\nconst WAF_CONSTRUCTS: WafConstruct[] = [\n {\n file: `${CONSTRUCTS_SRC}/core/agentcore-gateway/agentcore-gateway.ts`,\n logGroupExpr: 'logs.LogGroup',\n removalPolicyExpr: 'cdk.RemovalPolicy.DESTROY',\n },\n {\n file: `${CONSTRUCTS_SRC}/core/api/rest-api.ts`,\n logGroupExpr: 'LogGroup',\n removalPolicyExpr: 'RemovalPolicy.DESTROY',\n destructuredImport: 'RemovalPolicy',\n },\n];\n\nconst migrateConstruct = async (\n tree: Tree,\n construct: WafConstruct,\n nextSteps: string[],\n): Promise<void> => {\n const { file, logGroupExpr } = construct;\n if (!tree.exists(file)) {\n // Construct not vended in this workspace - nothing to migrate.\n return;\n }\n\n const contents = tree.read(file, 'utf-8') ?? '';\n\n // The WAF web ACL (and its log group) is optional in some constructs, so it\n // may be absent. Nothing to do if it is.\n if (!contents.includes(`new ${logGroupExpr}(this, 'WebAclLogs'`)) {\n return;\n }\n\n // Already migrated (or user-added a removal policy).\n if (\n await matchGritQL(\n tree,\n file,\n `\\`new ${logGroupExpr}(this, 'WebAclLogs', { $props })\\` where { $props <: contains \\`removalPolicy\\` }`,\n )\n ) {\n return;\n }\n\n // Append the removal policy after the WAF log group's `encryptionKey`\n // property. The rewrite is scoped to the `WebAclLogs` LogGroup because a\n // construct can have other log groups sharing the `encryptionKey: logsKey`\n // shape (e.g. the rest api's access logs).\n const added = await insertViaGritQL(\n tree,\n file,\n `\\`new ${logGroupExpr}(this, 'WebAclLogs', { $props })\\` where {\n $props <: contains \\`encryptionKey: logsKey\\` as $enc,\n $enc => \\`encryptionKey: logsKey,\n __GRIT_INSERT_PLACEHOLDER__\\`\n}`,\n `// The log group name is deterministic, so retaining it on delete would\n // orphan it and block re-creation (e.g. after a rolled-back deploy).\n removalPolicy: ${construct.removalPolicyExpr}`,\n );\n\n if (!added) {\n nextSteps.push(\n `${file}: could not add a removal policy to the WAF log group automatically - it may have diverged from the generated shape. Add \\`removalPolicy: ${construct.removalPolicyExpr}\\` to the \\`new ${logGroupExpr}(this, 'WebAclLogs', ...)\\` call so a rolled-back deploy does not orphan the log group.`,\n );\n return;\n }\n\n if (construct.destructuredImport) {\n await addDestructuredImport(\n tree,\n file,\n [construct.destructuredImport],\n 'aws-cdk-lib',\n );\n }\n};\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n for (const construct of WAF_CONSTRUCTS) {\n await migrateConstruct(tree, construct, nextSteps);\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["addDestructuredImport","insertViaGritQL","matchGritQL","formatFilesInSubtree","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","CONSTRUCTS_SRC","WAF_CONSTRUCTS","file","logGroupExpr","removalPolicyExpr","destructuredImport","migrateConstruct","tree","construct","nextSteps","exists","contents","read","includes","added","push","migration"],"mappings":"AAAA;;;CAGC,GAED,SACEA,qBAAqB,EACrBC,eAAe,EACfC,WAAW,QACN,wBAAqB;AAC5B,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SACEC,YAAY,EACZC,qBAAqB,QAChB,gDAA6C;AAEpD;;;;;;;;CAQC,GAED,MAAMC,iBAAiB,GAAGF,aAAa,CAAC,EAAEC,sBAAsB,IAAI,CAAC;AAmBrE,MAAME,iBAAiC;IACrC;QACEC,MAAM,GAAGF,eAAe,4CAA4C,CAAC;QACrEG,cAAc;QACdC,mBAAmB;IACrB;IACA;QACEF,MAAM,GAAGF,eAAe,qBAAqB,CAAC;QAC9CG,cAAc;QACdC,mBAAmB;QACnBC,oBAAoB;IACtB;CACD;AAED,MAAMC,mBAAmB,OACvBC,MACAC,WACAC;IAEA,MAAM,EAAEP,IAAI,EAAEC,YAAY,EAAE,GAAGK;IAC/B,IAAI,CAACD,KAAKG,MAAM,CAACR,OAAO;QACtB,+DAA+D;QAC/D;IACF;IAEA,MAAMS,WAAWJ,KAAKK,IAAI,CAACV,MAAM,YAAY;IAE7C,4EAA4E;IAC5E,yCAAyC;IACzC,IAAI,CAACS,SAASE,QAAQ,CAAC,CAAC,IAAI,EAAEV,aAAa,mBAAmB,CAAC,GAAG;QAChE;IACF;IAEA,qDAAqD;IACrD,IACE,MAAMP,YACJW,MACAL,MACA,CAAC,MAAM,EAAEC,aAAa,iFAAiF,CAAC,GAE1G;QACA;IACF;IAEA,sEAAsE;IACtE,yEAAyE;IACzE,2EAA2E;IAC3E,2CAA2C;IAC3C,MAAMW,QAAQ,MAAMnB,gBAClBY,MACAL,MACA,CAAC,MAAM,EAAEC,aAAa;;;;CAIzB,CAAC,EACE,CAAC;;qBAEgB,EAAEK,UAAUJ,iBAAiB,EAAE;IAGlD,IAAI,CAACU,OAAO;QACVL,UAAUM,IAAI,CACZ,GAAGb,KAAK,0IAA0I,EAAEM,UAAUJ,iBAAiB,CAAC,gBAAgB,EAAED,aAAa,uFAAuF,CAAC;QAEzS;IACF;IAEA,IAAIK,UAAUH,kBAAkB,EAAE;QAChC,MAAMX,sBACJa,MACAL,MACA;YAACM,UAAUH,kBAAkB;SAAC,EAC9B;IAEJ;AACF;AAEA,eAAe,eAAeW,UAC5BT,IAAU;IAEV,MAAME,YAAsB,EAAE;IAE9B,KAAK,MAAMD,aAAaP,eAAgB;QACtC,MAAMK,iBAAiBC,MAAMC,WAAWC;IAC1C;IAEA,MAAMZ,qBAAqBU;IAE3B,OAAO;QAAEE;IAAU;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.60/0003-strip-pip-from-python-images/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 ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport type { ComponentMetadata } from '../../../utils/nx';\n\n/**\n * Remove pip from the vended Python agent / MCP server images.\n *\n * The runtime runs entirely from the bundled `/app` environment and never needs\n * pip, whose vendored packages (setuptools, msgpack) in the base image carry\n * known HIGH/CRITICAL vulnerabilities the image scan flags. New workspaces get\n * this from the generator templates; this brings existing ones up to date.\n *\n * Only the Dockerfiles of `py#agent` / `py#mcp-server` components are touched,\n * located from their project metadata. The Dockerfile is generated\n * `KeepExisting`, so it is edited in place: the pip removal is inserted right\n * after the `FROM` line. A Dockerfile whose pip usage has been customised (an\n * added `pip install`, or any pip command other than this removal) is left\n * untouched and reported via `nextSteps`, since stripping pip could break it.\n */\n\n/**\n * The generators whose runtime images vend pip and should have it stripped.\n * Hardcoded rather than imported from the generators: a migration matches the\n * ids workspaces recorded at generation time, which must stay fixed even if the\n * generators' current ids change later.\n */\nconst RUNTIME_IMAGE_GENERATOR_IDS = ['py#agent', 'py#mcp-server'];\n\nconst PIP_REMOVAL = `# Remove the base image's pip: the runtime runs from the bundled environment and\n# never needs it, and pip's vendored packages carry known HIGH/CRITICAL\n# vulnerabilities flagged by the image scan.\nRUN python -m pip uninstall -y pip && \\\\\n rm -rf /usr/local/lib/python*/site-packages/pip \\\\\n /usr/local/lib/python*/site-packages/pip-*.dist-info`;\n\n/** The exact pip command this migration adds; used to detect an applied fix. */\nconst PIP_UNINSTALL = 'pip uninstall -y pip';\n\n/** Matches any `pip` invocation in a RUN instruction (python -m pip … or pip …). */\nconst PIP_COMMAND = /\\b(?:python\\s+-m\\s+)?pip\\s+\\S+/g;\n\n/**\n * The Dockerfiles of every `py#agent` / `py#mcp-server` component, located from\n * each project's recorded component metadata (`path` is the component directory\n * relative to the project root).\n */\nconst runtimeImageDockerfiles = (tree: Tree): string[] => {\n const paths: string[] = [];\n for (const project of getProjects(tree).values()) {\n const components = ((\n project.metadata as { components?: ComponentMetadata[] }\n )?.components ?? []) as ComponentMetadata[];\n for (const component of components) {\n if (\n !RUNTIME_IMAGE_GENERATOR_IDS.includes(component.generator) ||\n !component.path\n ) {\n continue;\n }\n const dockerfile = joinPathFragments(\n projectRoot(project),\n component.path,\n 'Dockerfile',\n );\n if (tree.exists(dockerfile)) {\n paths.push(dockerfile);\n }\n }\n }\n return paths;\n};\n\n/** A project's root, falling back to sourceRoot for the TS-solution layout. */\nconst projectRoot = (project: ProjectConfiguration): string =>\n project.root ?? project.sourceRoot ?? '';\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n for (const filePath of runtimeImageDockerfiles(tree)) {\n const content = tree.read(filePath, 'utf-8');\n if (!content) {\n continue;\n }\n if (content.includes(PIP_UNINSTALL)) {\n continue; // Already stripped (migrated or user-added).\n }\n\n // Leave a customised Dockerfile alone: any pip usage other than this\n // migration's removal (e.g. an added `pip install`) means stripping pip\n // could break the image, so flag it for the user instead of editing.\n const pipUsages = content.match(PIP_COMMAND) ?? [];\n if (pipUsages.length > 0) {\n nextSteps.push(\n `In ${filePath}: this image uses pip (${pipUsages.join(', ')}), so it was left unchanged. pip's vendored packages carry known vulnerabilities flagged by the image scan — remove pip once it is no longer needed, e.g. \\`RUN python -m pip uninstall -y pip && rm -rf /usr/local/lib/python*/site-packages/pip /usr/local/lib/python*/site-packages/pip-*.dist-info\\`.`,\n );\n continue;\n }\n\n // Insert the pip removal after the FROM line and its trailing blank line,\n // matching the spacing a freshly generated Dockerfile has.\n const updated = content.replace(\n /^(FROM\\s+\\S*python:.*\\n)\\n/m,\n `$1\\n${PIP_REMOVAL}\\n\\n`,\n );\n if (updated === content) {\n nextSteps.push(\n `In ${filePath}: remove pip from the image so its vulnerable vendored packages are not scanned — add \\`RUN python -m pip uninstall -y pip && rm -rf /usr/local/lib/python*/site-packages/pip /usr/local/lib/python*/site-packages/pip-*.dist-info\\` after the FROM line (the runtime does not need pip).`,\n );\n continue;\n }\n tree.write(filePath, updated);\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["getProjects","joinPathFragments","formatFilesInSubtree","RUNTIME_IMAGE_GENERATOR_IDS","PIP_REMOVAL","PIP_UNINSTALL","PIP_COMMAND","runtimeImageDockerfiles","tree","paths","project","values","components","metadata","component","includes","generator","path","dockerfile","projectRoot","exists","push","root","sourceRoot","migration","nextSteps","filePath","content","read","pipUsages","match","length","join","updated","replace","write"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,iBAAiB,QAIZ,aAAa;AACpB,SAASC,oBAAoB,QAAQ,2BAAwB;AAG7D;;;;;;;;;;;;;;CAcC,GAED;;;;;CAKC,GACD,MAAMC,8BAA8B;IAAC;IAAY;CAAgB;AAEjE,MAAMC,cAAc,CAAC;;;;;+DAK0C,CAAC;AAEhE,8EAA8E,GAC9E,MAAMC,gBAAgB;AAEtB,kFAAkF,GAClF,MAAMC,cAAc;AAEpB;;;;CAIC,GACD,MAAMC,0BAA0B,CAACC;IAC/B,MAAMC,QAAkB,EAAE;IAC1B,KAAK,MAAMC,WAAWV,YAAYQ,MAAMG,MAAM,GAAI;QAChD,MAAMC,aAAc,AAClBF,QAAQG,QAAQ,EACfD,cAAc,EAAE;QACnB,KAAK,MAAME,aAAaF,WAAY;YAClC,IACE,CAACT,4BAA4BY,QAAQ,CAACD,UAAUE,SAAS,KACzD,CAACF,UAAUG,IAAI,EACf;gBACA;YACF;YACA,MAAMC,aAAajB,kBACjBkB,YAAYT,UACZI,UAAUG,IAAI,EACd;YAEF,IAAIT,KAAKY,MAAM,CAACF,aAAa;gBAC3BT,MAAMY,IAAI,CAACH;YACb;QACF;IACF;IACA,OAAOT;AACT;AAEA,6EAA6E,GAC7E,MAAMU,cAAc,CAACT,UACnBA,QAAQY,IAAI,IAAIZ,QAAQa,UAAU,IAAI;AAExC,eAAe,eAAeC,UAC5BhB,IAAU;IAEV,MAAMiB,YAAsB,EAAE;IAE9B,KAAK,MAAMC,YAAYnB,wBAAwBC,MAAO;QACpD,MAAMmB,UAAUnB,KAAKoB,IAAI,CAACF,UAAU;QACpC,IAAI,CAACC,SAAS;YACZ;QACF;QACA,IAAIA,QAAQZ,QAAQ,CAACV,gBAAgB;YACnC,UAAU,6CAA6C;QACzD;QAEA,qEAAqE;QACrE,wEAAwE;QACxE,qEAAqE;QACrE,MAAMwB,YAAYF,QAAQG,KAAK,CAACxB,gBAAgB,EAAE;QAClD,IAAIuB,UAAUE,MAAM,GAAG,GAAG;YACxBN,UAAUJ,IAAI,CACZ,CAAC,GAAG,EAAEK,SAAS,uBAAuB,EAAEG,UAAUG,IAAI,CAAC,MAAM,ySAAyS,CAAC;YAEzW;QACF;QAEA,0EAA0E;QAC1E,2DAA2D;QAC3D,MAAMC,UAAUN,QAAQO,OAAO,CAC7B,+BACA,CAAC,IAAI,EAAE9B,YAAY,IAAI,CAAC;QAE1B,IAAI6B,YAAYN,SAAS;YACvBF,UAAUJ,IAAI,CACZ,CAAC,GAAG,EAAEK,SAAS,yRAAyR,CAAC;YAE3S;QACF;QACAlB,KAAK2B,KAAK,CAACT,UAAUO;IACvB;IAEA,MAAM/B,qBAAqBM;IAE3B,OAAO;QAAEiB;IAAU;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.61/0001-py-agent-lifespan-construction/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_AGENT_GENERATOR_INFO } from '../../../py/agent/generator';\nimport {\n addPythonDestructuredImport,\n applyGritQL,\n captureGritQLVariable,\n matchGritQL,\n} from '../../../utils/ast';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport type { ComponentMetadata } from '../../../utils/nx';\n\n/**\n * Move py#agent HTTP/AG-UI agent construction out of module import time and\n * into a FastAPI `lifespan` handler, stored on `app.state`.\n *\n * Building the agent eagerly at import time breaks any codepath that imports\n * the module before `RUNTIME_CONFIG_APP_ID`/AgentCore env vars are set (e.g.\n * OpenAPI spec generation, tests) - and, for AgentCore, construction belongs\n * at container/app startup rather than import, since AgentCore hands each\n * session its own container. The A2A protocol is unaffected: `with_session_id`\n * only touches the agent factory lazily on first use, so its eager\n * `__enter__()` was never actually eager in practice.\n *\n * How to write a migration:\n * - https://nx.dev/docs/kb/migration-generators\n * - What `nextSteps` means: https://nx.dev/docs/reference/devkit/MigrationReturnObject\n *\n * Guardrails:\n * - Pattern-match before writing: every rewrite this migration makes to a file\n * is preceded by a read-only `matchGritQL` check of every pattern it will\n * need - so a diverged file is reported via `nextSteps` and left completely\n * untouched, rather than partially rewritten into a broken state.\n * - Idempotent: re-running must be a no-op (each rewrite's own shape change\n * means its pattern no longer matches on a second pass).\n * - Format what you write: finish with `formatFilesInSubtree`.\n */\n\n/** A read-only GritQL match against a python file (no rewrite). */\nconst pyMatch = (snippet: string) => `language python\\n\\`${snippet}\\``;\n\n/** A GritQL rewrite deleting the matched python snippet entirely. */\nconst pyDelete = (snippet: string) => `${pyMatch(snippet)} => .`;\n\n/**\n * A GritQL rewrite of one python snippet into another. Multi-line\n * replacements go through `raw` so GritQL's own reformatting doesn't fight\n * the exact shape being written (formatFilesInSubtree normalizes it after).\n */\nconst pyRewrite = (from: string, to: string, where?: string): string => {\n const replacement = to.includes('\\n') ? `raw\\`${to}\\`` : `\\`${to}\\``;\n return `${pyMatch(from)} => ${replacement}${where ? ` where { ${where} }` : ''}`;\n};\n\n/** All checks must match before anything is written for that agent. */\nconst allMatch = async (\n tree: Tree,\n checks: ReadonlyArray<readonly [filePath: string, pattern: string]>,\n): Promise<boolean> => {\n for (const [filePath, pattern] of checks) {\n if (!(await matchGritQL(tree, filePath, pattern))) return false;\n }\n return true;\n};\n\nconst AGENT_CONNECTION_MODULE_PATTERN = (names: string) =>\n pyMatch(`from $mod import ${names}`);\n\nconst STRANDS_HTTP_MARKER = '_agent_ctx = with_session_id(';\nconst LANGCHAIN_HTTP_MARKER = '_graph = get_agent()';\nconst STRANDS_AGUI_MARKER = 'create_strands_app';\nconst LANGCHAIN_AGUI_MARKER = '_graph = get_agent()';\n\n// Shared by strands/http and langchain/http - only the lifespan body differs.\nconst HTTP_INIT_APP_OLD = `app = FastAPI(\n title=\"$name\",\n responses={500: {\"model\": InternalServerErrorDetails}},\n generate_unique_id_function=lambda route: route.name,\n)`;\n\n// --- Strands HTTP -----------------------------------------------------------\n\nconst STRANDS_HTTP_MAIN_CTX_OLD = `_agent_ctx = with_session_id(\n get_agent,\n name=\"$name\",\n description=\"A Strands Agent exposed via HTTP streaming.\",\n)`;\n\nconst STRANDS_HTTP_INIT_APP_NEW = `@asynccontextmanager\nasync def lifespan(app: FastAPI):\n with with_session_id(\n get_agent,\n name=\"$name\",\n description=\"A Strands Agent exposed via HTTP streaming.\",\n ) as agent:\n app.state.agent = agent\n yield\n\n\napp = FastAPI(\n title=\"$name\",\n responses={500: {\"model\": InternalServerErrorDetails}},\n generate_unique_id_function=lambda route: route.name,\n lifespan=lifespan,\n)`;\n\nconst migrateStrandsHttpAgent = async (\n tree: Tree,\n dir: string,\n nextSteps: string[],\n): Promise<void> => {\n const initPath = joinPathFragments(dir, 'init.py');\n const mainPath = joinPathFragments(dir, 'main.py');\n if (!tree.exists(initPath) || !tree.exists(mainPath)) return;\n\n const mainContents = tree.read(mainPath, 'utf-8') ?? '';\n if (!mainContents.includes(STRANDS_HTTP_MARKER)) return;\n\n const mod = await captureGritQLVariable(\n tree,\n mainPath,\n AGENT_CONNECTION_MODULE_PATTERN('session_id_context, with_session_id'),\n 'mod',\n );\n\n const ready =\n !!mod &&\n (await allMatch(tree, [\n [mainPath, pyMatch(STRANDS_HTTP_MAIN_CTX_OLD)],\n [mainPath, pyMatch('_agent = _agent_ctx.__enter__()')],\n [mainPath, pyMatch('from .agent import get_agent')],\n [mainPath, pyMatch('_agent.stream_async($prompt)')],\n [initPath, pyMatch(HTTP_INIT_APP_OLD)],\n ]));\n\n if (!ready) {\n nextSteps.push(\n `${mainPath}: diverged from the generated shape - left untouched, along with ${initPath}. Manually move agent construction into an \\`init.py\\` \\`lifespan\\` handler storing the agent on \\`app.state.agent\\` (see the py#agent generator's strands/http template).`,\n );\n return;\n }\n\n await addPythonDestructuredImport(\n tree,\n initPath,\n ['asynccontextmanager'],\n 'contextlib',\n );\n await addPythonDestructuredImport(tree, initPath, ['get_agent'], '.agent');\n await addPythonDestructuredImport(tree, initPath, ['with_session_id'], mod);\n await applyGritQL(\n tree,\n initPath,\n pyRewrite(HTTP_INIT_APP_OLD, STRANDS_HTTP_INIT_APP_NEW),\n );\n\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite(\n 'from $mod import session_id_context, with_session_id',\n 'from $mod import session_id_context',\n ),\n );\n await applyGritQL(tree, mainPath, pyDelete('from .agent import get_agent'));\n await applyGritQL(tree, mainPath, pyDelete(STRANDS_HTTP_MAIN_CTX_OLD));\n await applyGritQL(\n tree,\n mainPath,\n pyDelete('_agent = _agent_ctx.__enter__()'),\n );\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite(\n '_agent.stream_async($prompt)',\n 'app.state.agent.stream_async($prompt)',\n ),\n );\n};\n\n// --- LangChain HTTP ----------------------------------------------------------\n\nconst LANGCHAIN_HTTP_INIT_APP_NEW = `@asynccontextmanager\nasync def lifespan(app: FastAPI):\n app.state.graph = get_agent()\n yield\n\n\napp = FastAPI(\n title=\"$name\",\n responses={500: {\"model\": InternalServerErrorDetails}},\n generate_unique_id_function=lambda route: route.name,\n lifespan=lifespan,\n)`;\n\nconst migrateLangchainHttpAgent = async (\n tree: Tree,\n dir: string,\n nextSteps: string[],\n): Promise<void> => {\n const initPath = joinPathFragments(dir, 'init.py');\n const mainPath = joinPathFragments(dir, 'main.py');\n if (!tree.exists(initPath) || !tree.exists(mainPath)) return;\n\n const mainContents = tree.read(mainPath, 'utf-8') ?? '';\n if (!mainContents.includes(LANGCHAIN_HTTP_MARKER)) return;\n\n const ready = await allMatch(tree, [\n [mainPath, pyMatch('_graph = get_agent()')],\n [mainPath, pyMatch('from .agent import get_agent')],\n [mainPath, pyMatch('_graph.astream($args)')],\n [initPath, pyMatch(HTTP_INIT_APP_OLD)],\n ]);\n\n if (!ready) {\n nextSteps.push(\n `${mainPath}: diverged from the generated shape - left untouched, along with ${initPath}. Manually wrap \\`get_agent()\\` in an \\`init.py\\` \\`lifespan\\` handler storing the graph on \\`app.state.graph\\` (see the py#agent generator's langchain/http template).`,\n );\n return;\n }\n\n await addPythonDestructuredImport(\n tree,\n initPath,\n ['asynccontextmanager'],\n 'contextlib',\n );\n await addPythonDestructuredImport(tree, initPath, ['get_agent'], '.agent');\n await applyGritQL(\n tree,\n initPath,\n pyRewrite(HTTP_INIT_APP_OLD, LANGCHAIN_HTTP_INIT_APP_NEW),\n );\n\n await applyGritQL(tree, mainPath, pyDelete('from .agent import get_agent'));\n await applyGritQL(tree, mainPath, pyDelete('_graph = get_agent()'));\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite('_graph.astream($args)', 'app.state.graph.astream($args)'),\n );\n};\n\n// --- LangChain AG-UI ---------------------------------------------------------\n\nconst LANGCHAIN_AGUI_AGENT_OLD = `agui_agent = LangGraphAgent(\n name=\"$name\",\n graph=_graph,\n description=\"A LangChain/LangGraph Agent exposed via the AG-UI protocol.\",\n)`;\n\nconst LANGCHAIN_AGUI_AGENT_NEW = `@asynccontextmanager\nasync def lifespan(app: FastAPI):\n graph = get_agent()\n app.state.agui_agent = LangGraphAgent(\n name=\"$name\",\n graph=graph,\n description=\"A LangChain/LangGraph Agent exposed via the AG-UI protocol.\",\n )\n yield`;\n\nconst migrateLangchainAgUiAgent = async (\n tree: Tree,\n dir: string,\n nextSteps: string[],\n): Promise<void> => {\n const mainPath = joinPathFragments(dir, 'main.py');\n if (!tree.exists(mainPath)) return;\n\n const mainContents = tree.read(mainPath, 'utf-8') ?? '';\n if (!mainContents.includes(LANGCHAIN_AGUI_MARKER)) return;\n\n const ready = await allMatch(tree, [\n [mainPath, pyMatch('_graph = get_agent()')],\n [mainPath, pyMatch(LANGCHAIN_AGUI_AGENT_OLD)],\n [mainPath, pyMatch('agui_agent.run($input)')],\n [mainPath, pyMatch('app = FastAPI(title=\"$name\")')],\n ]);\n\n if (!ready) {\n nextSteps.push(\n `${mainPath}: diverged from the generated shape - left untouched. Manually wrap graph + \\`LangGraphAgent\\` construction in a \\`lifespan\\` handler storing the wrapper on \\`app.state.agui_agent\\` (see the py#agent generator's langchain/ag-ui template).`,\n );\n return;\n }\n\n await addPythonDestructuredImport(\n tree,\n mainPath,\n ['asynccontextmanager'],\n 'contextlib',\n );\n\n await applyGritQL(tree, mainPath, pyDelete('_graph = get_agent()'));\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite(LANGCHAIN_AGUI_AGENT_OLD, LANGCHAIN_AGUI_AGENT_NEW),\n );\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite(\n 'agui_agent.run($input)',\n 'request.app.state.agui_agent.run($input)',\n ),\n );\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite(\n 'app = FastAPI(title=\"$name\")',\n 'app = FastAPI(title=\"$name\", lifespan=lifespan)',\n ),\n );\n};\n\n// --- Strands AG-UI -----------------------------------------------------------\n// The biggest of the four: `ag_ui_strands.create_strands_app` is dropped\n// entirely for an inlined FastAPI app (matching upstream `ag_ui_strands`,\n// plus a Content-Type-independent body-parsing fix and an explicit session\n// re-bind `create_strands_app` was missing), so most of the file is new.\n\nconst STRANDS_AGUI_IMPORT_OLD =\n 'from ag_ui_strands import StrandsAgent, create_strands_app';\n\nconst STRANDS_AGUI_AGENT_OLD = `agui_agent = StrandsAgent(\n agent=_agent,\n name=\"$name\",\n description=\"A Strands Agent exposed via the AG-UI protocol.\",\n)`;\n\nconst STRANDS_AGUI_AGENT_NEW = `@asynccontextmanager\nasync def lifespan(app: FastAPI):\n with get_agent() as agent:\n app.state.agui_agent = StrandsAgent(\n agent=agent,\n name=\"$name\",\n description=\"A Strands Agent exposed via the AG-UI protocol.\",\n )\n yield`;\n\nconst STRANDS_AGUI_APP_OLD =\n 'app = create_strands_app(agui_agent, path=\"/invocations\")';\n\n// `$name` isn't bound within this match (unlike STRANDS_AGUI_AGENT_OLD above),\n// so the title is built from a name captured separately rather than reused as\n// a metavariable - GritQL leaves a rewrite whose replacement references an\n// unbound metavariable unapplied.\nconst strandsAguiAppNew = (\n name: string,\n) => `app = FastAPI(title=\"AWS Strands - ${name}\", lifespan=lifespan)\napp.add_middleware(\n CORSMiddleware,\n allow_origins=[\"*\"],\n allow_credentials=True,\n allow_methods=[\"*\"],\n allow_headers=[\"*\"],\n)`;\n\nconst STRANDS_AGUI_MIDDLEWARE_OLD = 'app.add_middleware(_SessionIdMiddleware)';\n\nconst STRANDS_AGUI_ROUTES_NEW = `app.add_middleware(_SessionIdMiddleware)\n\n\n@app.post(\"/invocations\")\nasync def invocations(request: Request):\n # Validate the body manually since AgentCore may omit Content-Type.\n encoder = EventEncoder(accept=request.headers.get(\"accept\") or \"\")\n raw = await request.body()\n try:\n input_data = RunAgentInput.model_validate_json(raw)\n except Exception as exc:\n message = f\"Invalid RunAgentInput: {str(exc)[:200]}\"\n\n async def _bad():\n yield encoder.encode(RunErrorEvent(type=EventType.RUN_ERROR, message=message, code=\"BAD_REQUEST\"))\n\n return StreamingResponse(_bad(), media_type=encoder.get_content_type())\n\n session_id = request.headers.get(SESSION_ID_HEADER) or get_current_session_id()\n\n async def event_generator():\n # Re-bind the session: the streaming body runs outside the middleware.\n with session_id_context(session_id or str(uuid.uuid4())):\n async for event in request.app.state.agui_agent.run(input_data):\n try:\n yield encoder.encode(event)\n except Exception as e:\n error_event = RunErrorEvent(\n type=EventType.RUN_ERROR,\n message=f\"Encoding error: {e}\",\n code=\"ENCODING_ERROR\",\n )\n yield encoder.encode(error_event)\n break\n\n return StreamingResponse(event_generator(), media_type=encoder.get_content_type())\n\n\n@app.get(\"/ping\")\nasync def ping():\n return {\"status\": \"healthy\"}`;\n\nconst STRANDS_AGUI_COMMENTS_OLD = [\n '# Create AG-UI agent wrapper',\n '# Create FastAPI app with AG-UI endpoint and health check',\n];\n\nconst migrateStrandsAgUiAgent = async (\n tree: Tree,\n dir: string,\n nextSteps: string[],\n): Promise<void> => {\n const mainPath = joinPathFragments(dir, 'main.py');\n if (!tree.exists(mainPath)) return;\n\n const mainContents = tree.read(mainPath, 'utf-8') ?? '';\n if (!mainContents.includes(STRANDS_AGUI_MARKER)) return;\n\n const mod = await captureGritQLVariable(\n tree,\n mainPath,\n AGENT_CONNECTION_MODULE_PATTERN('session_id_context'),\n 'mod',\n );\n const agentClassName = await captureGritQLVariable(\n tree,\n mainPath,\n pyMatch(STRANDS_AGUI_AGENT_OLD),\n 'name',\n );\n\n const ready =\n !!mod &&\n !!agentClassName &&\n (await allMatch(tree, [\n [mainPath, pyMatch(STRANDS_AGUI_IMPORT_OLD)],\n [mainPath, pyMatch('_agent_ctx = get_agent()')],\n [mainPath, pyMatch('_agent = _agent_ctx.__enter__()')],\n [mainPath, pyMatch(STRANDS_AGUI_AGENT_OLD)],\n [mainPath, pyMatch(STRANDS_AGUI_APP_OLD)],\n [mainPath, pyMatch(STRANDS_AGUI_MIDDLEWARE_OLD)],\n ]));\n\n if (!ready) {\n nextSteps.push(\n `${mainPath}: diverged from the generated shape - left untouched. Manually rebuild this file without \\`create_strands_app\\`: a \\`lifespan\\` handler storing the wrapper on \\`app.state.agui_agent\\`, and inlined \\`/invocations\\`/\\`/ping\\` routes with Content-Type-independent body parsing (see the py#agent generator's strands/ag-ui template).`,\n );\n return;\n }\n\n await addPythonDestructuredImport(\n tree,\n mainPath,\n ['asynccontextmanager'],\n 'contextlib',\n );\n await addPythonDestructuredImport(\n tree,\n mainPath,\n ['EventType', 'RunAgentInput', 'RunErrorEvent'],\n 'ag_ui.core',\n );\n await addPythonDestructuredImport(\n tree,\n mainPath,\n ['EventEncoder'],\n 'ag_ui.encoder',\n );\n await addPythonDestructuredImport(tree, mainPath, ['FastAPI'], 'fastapi');\n await addPythonDestructuredImport(\n tree,\n mainPath,\n ['CORSMiddleware'],\n 'fastapi.middleware.cors',\n );\n await addPythonDestructuredImport(\n tree,\n mainPath,\n ['StreamingResponse'],\n 'fastapi.responses',\n );\n await addPythonDestructuredImport(\n tree,\n mainPath,\n ['get_current_session_id'],\n mod,\n );\n\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite(\n STRANDS_AGUI_IMPORT_OLD,\n 'from ag_ui_strands import StrandsAgent',\n ),\n );\n await applyGritQL(tree, mainPath, pyDelete('_agent_ctx = get_agent()'));\n await applyGritQL(\n tree,\n mainPath,\n pyDelete('_agent = _agent_ctx.__enter__()'),\n );\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite(STRANDS_AGUI_AGENT_OLD, STRANDS_AGUI_AGENT_NEW),\n );\n for (const comment of STRANDS_AGUI_COMMENTS_OLD) {\n await applyGritQL(tree, mainPath, pyDelete(comment));\n }\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite(STRANDS_AGUI_APP_OLD, strandsAguiAppNew(agentClassName)),\n );\n await applyGritQL(\n tree,\n mainPath,\n pyRewrite(STRANDS_AGUI_MIDDLEWARE_OLD, STRANDS_AGUI_ROUTES_NEW),\n );\n};\n\n/** This agent's ComponentMetadata entries. */\nconst findAgentComponents = (\n components: ComponentMetadata[] | undefined,\n): ComponentMetadata[] =>\n (components ?? []).filter(\n (component) => component.generator === PY_AGENT_GENERATOR_INFO.id,\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 components = findAgentComponents(\n (project.metadata as { components?: ComponentMetadata[] })?.components,\n );\n\n for (const component of components) {\n if (!component.path) continue;\n const dir = joinPathFragments(project.root, component.path);\n const framework = component.framework ?? 'strands';\n\n if (component.protocol === 'http') {\n if (framework === 'langchain') {\n await migrateLangchainHttpAgent(tree, dir, nextSteps);\n } else {\n await migrateStrandsHttpAgent(tree, dir, nextSteps);\n }\n } else if (component.protocol === 'ag-ui') {\n if (framework === 'langchain') {\n await migrateLangchainAgUiAgent(tree, dir, nextSteps);\n } else {\n await migrateStrandsAgUiAgent(tree, dir, nextSteps);\n }\n }\n }\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["getProjects","joinPathFragments","PY_AGENT_GENERATOR_INFO","addPythonDestructuredImport","applyGritQL","captureGritQLVariable","matchGritQL","formatFilesInSubtree","pyMatch","snippet","pyDelete","pyRewrite","from","to","where","replacement","includes","allMatch","tree","checks","filePath","pattern","AGENT_CONNECTION_MODULE_PATTERN","names","STRANDS_HTTP_MARKER","LANGCHAIN_HTTP_MARKER","STRANDS_AGUI_MARKER","LANGCHAIN_AGUI_MARKER","HTTP_INIT_APP_OLD","STRANDS_HTTP_MAIN_CTX_OLD","STRANDS_HTTP_INIT_APP_NEW","migrateStrandsHttpAgent","dir","nextSteps","initPath","mainPath","exists","mainContents","read","mod","ready","push","LANGCHAIN_HTTP_INIT_APP_NEW","migrateLangchainHttpAgent","LANGCHAIN_AGUI_AGENT_OLD","LANGCHAIN_AGUI_AGENT_NEW","migrateLangchainAgUiAgent","STRANDS_AGUI_IMPORT_OLD","STRANDS_AGUI_AGENT_OLD","STRANDS_AGUI_AGENT_NEW","STRANDS_AGUI_APP_OLD","strandsAguiAppNew","name","STRANDS_AGUI_MIDDLEWARE_OLD","STRANDS_AGUI_ROUTES_NEW","STRANDS_AGUI_COMMENTS_OLD","migrateStrandsAgUiAgent","agentClassName","comment","findAgentComponents","components","filter","component","generator","id","migration","project","values","metadata","path","root","framework","protocol"],"mappings":"A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AAMnD,YAAYc,MAAMiB,UAAUzB,SAASgD;IAC7C;IACA,MAAMtD,YACJc,MACAiB,UACAxB,UAAUuC,sBAAsBC,kBAAkBM;IAEpD,MAAMrD,YACJc,MACAiB,UACAxB,UAAU0C,6BAA6BC;AAE3C;AAEA,4CAA4C,GAC5C,MAAMK,sBAAsB,CAC1BC,aAEA,AAACA,CAAAA,cAAc,EAAE,AAAD,EAAGC,MAAM,CACvB,CAACC,YAAcA,UAAUC,SAAS,KAAK7D,wBAAwB8D,EAAE;AAGrE,eAAe,eAAeC,UAC5B/C,IAAU;IAEV,MAAMe,YAAsB,EAAE;IAE9B,KAAK,MAAMiC,WAAWlE,YAAYkB,MAAMiD,MAAM,GAAI;QAChD,MAAMP,aAAaD,oBAChBO,QAAQE,QAAQ,EAA2CR;QAG9D,KAAK,MAAME,aAAaF,WAAY;YAClC,IAAI,CAACE,UAAUO,IAAI,EAAE;YACrB,MAAMrC,MAAM/B,kBAAkBiE,QAAQI,IAAI,EAAER,UAAUO,IAAI;YAC1D,MAAME,YAAYT,UAAUS,SAAS,IAAI;YAEzC,IAAIT,UAAUU,QAAQ,KAAK,QAAQ;gBACjC,IAAID,cAAc,aAAa;oBAC7B,MAAM5B,0BAA0BzB,MAAMc,KAAKC;gBAC7C,OAAO;oBACL,MAAMF,wBAAwBb,MAAMc,KAAKC;gBAC3C;YACF,OAAO,IAAI6B,UAAUU,QAAQ,KAAK,SAAS;gBACzC,IAAID,cAAc,aAAa;oBAC7B,MAAMzB,0BAA0B5B,MAAMc,KAAKC;gBAC7C,OAAO;oBACL,MAAMuB,wBAAwBtC,MAAMc,KAAKC;gBAC3C;YACF;QACF;IACF;IAEA,MAAM1B,qBAAqBW;IAE3B,OAAO;QAAEe;IAAU;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.62/0001-rename-load-runtime-config-target/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 type MigrationReturnObject,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../../utils/format';\n\n/**\n * React website projects gained a `load-runtime-config` target so the config\n * can be loaded with the verb syntax (`nx load-runtime-config <project>`),\n * replacing the colon-separated `load:runtime-config` that had to be quoted on\n * the CLI. This clones the existing target under the new name in workspaces\n * generated before the rename, leaving the original in place so any scripts\n * still referencing it keep working.\n */\n\nconst OLD_TARGET = 'load:runtime-config';\nconst NEW_TARGET = 'load-runtime-config';\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n for (const [projectName, project] of getProjects(tree)) {\n const targets = project.targets;\n if (!targets?.[OLD_TARGET] || targets[NEW_TARGET]) {\n // No target to clone, or the new target already exists.\n continue;\n }\n\n const cloned = structuredClone(targets[OLD_TARGET]);\n // Point the description at the verb syntax for the new target.\n if (cloned.metadata?.description) {\n cloned.metadata.description = cloned.metadata.description.replace(\n new RegExp(`nx run (\\\\S+):${OLD_TARGET}`, 'g'),\n `nx ${NEW_TARGET} $1`,\n );\n }\n targets[NEW_TARGET] = cloned;\n\n updateProjectConfiguration(tree, projectName, project);\n }\n\n await formatFilesInSubtree(tree);\n\n return {};\n}\n"],"names":["getProjects","updateProjectConfiguration","formatFilesInSubtree","OLD_TARGET","NEW_TARGET","migration","tree","projectName","project","targets","cloned","structuredClone","metadata","description","replace","RegExp"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EAGXC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,2BAAwB;AAE7D;;;;;;;CAOC,GAED,MAAMC,aAAa;AACnB,MAAMC,aAAa;AAEnB,eAAe,eAAeC,UAC5BC,IAAU;IAEV,KAAK,MAAM,CAACC,aAAaC,QAAQ,IAAIR,YAAYM,MAAO;QACtD,MAAMG,UAAUD,QAAQC,OAAO;QAC/B,IAAI,CAACA,SAAS,CAACN,WAAW,IAAIM,OAAO,CAACL,WAAW,EAAE;YAEjD;QACF;QAEA,MAAMM,SAASC,gBAAgBF,OAAO,CAACN,WAAW;QAClD,+DAA+D;QAC/D,IAAIO,OAAOE,QAAQ,EAAEC,aAAa;YAChCH,OAAOE,QAAQ,CAACC,WAAW,GAAGH,OAAOE,QAAQ,CAACC,WAAW,CAACC,OAAO,CAC/D,IAAIC,OAAO,CAAC,cAAc,EAAEZ,YAAY,EAAE,MAC1C,CAAC,GAAG,EAAEC,WAAW,GAAG,CAAC;QAEzB;QACAK,OAAO,CAACL,WAAW,GAAGM;QAEtBT,2BAA2BK,MAAMC,aAAaC;IAChD;IAEA,MAAMN,qBAAqBI;IAE3B,OAAO,CAAC;AACV"}
|