@aws/nx-plugin 1.0.0-rc.11 → 1.0.0-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/LICENSE-THIRD-PARTY +81 -3
  2. package/generators.json +31 -1
  3. package/package.json +2 -2
  4. package/sdk/agentcore-gateway.d.ts +6 -0
  5. package/sdk/agentcore-gateway.js +11 -0
  6. package/sdk/agentcore-gateway.js.map +1 -0
  7. package/sdk/license.d.ts +4 -4
  8. package/sdk/license.js +5 -4
  9. package/sdk/license.js.map +1 -1
  10. package/sdk/py.d.ts +6 -6
  11. package/sdk/py.js +7 -7
  12. package/sdk/py.js.map +1 -1
  13. package/sdk/ts.d.ts +18 -14
  14. package/sdk/ts.js +38 -32
  15. package/sdk/ts.js.map +1 -1
  16. package/src/agentcore-gateway/files/cedar/policies/README.md +52 -0
  17. package/src/agentcore-gateway/files/cedar/policies/permit-all.cedar +11 -0
  18. package/src/agentcore-gateway/files/project/serve-local.ts.template +133 -0
  19. package/src/agentcore-gateway/generator.d.ts +25 -0
  20. package/src/agentcore-gateway/generator.js +129 -0
  21. package/src/agentcore-gateway/generator.js.map +1 -0
  22. package/src/agentcore-gateway/mcp-connection/generator.d.ts +19 -0
  23. package/src/agentcore-gateway/mcp-connection/generator.js +79 -0
  24. package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -0
  25. package/src/agentcore-gateway/mcp-connection/schema.d.ts +12 -0
  26. package/src/agentcore-gateway/mcp-connection/schema.json +26 -0
  27. package/src/agentcore-gateway/schema.d.ts +16 -0
  28. package/src/agentcore-gateway/schema.json +65 -0
  29. package/src/connection/generator.d.ts +1 -1
  30. package/src/connection/generator.js +64 -46
  31. package/src/connection/generator.js.map +1 -1
  32. package/src/infra/app/__snapshots__/generator.spec.ts.snap +9 -9
  33. package/src/mcp-server/schema-registry.d.ts +9 -3
  34. package/src/mcp-server/schema-registry.js +22 -6
  35. package/src/mcp-server/schema-registry.js.map +1 -1
  36. package/src/preset/__snapshots__/generator.spec.ts.snap +3 -1
  37. package/src/py/agent/__snapshots__/generator.spec.ts.snap +629 -7
  38. package/src/py/agent/a2a-connection/files/agent-connection/app/__targetAgentSnakeCase___client.py.template +9 -3
  39. package/src/py/agent/a2a-connection/generator.js +1 -1
  40. package/src/py/agent/a2a-connection/generator.js.map +1 -1
  41. package/src/py/agent/files/http/init.py.template +5 -23
  42. package/src/py/agent/gateway-connection/files/agent-connection/app/__gatewaySnakeCase___client.py.template +35 -0
  43. package/src/py/agent/gateway-connection/generator.d.ts +10 -0
  44. package/src/py/agent/gateway-connection/generator.js +106 -0
  45. package/src/py/agent/gateway-connection/generator.js.map +1 -0
  46. package/src/py/agent/gateway-connection/schema.d.ts +12 -0
  47. package/src/py/agent/gateway-connection/schema.json +26 -0
  48. package/src/py/agent/generator.js +27 -22
  49. package/src/py/agent/generator.js.map +1 -1
  50. package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +8 -4
  51. package/src/py/agent/mcp-connection/files/agent-connection/app/__mcpServerSnakeCase___client.py.template +9 -3
  52. package/src/py/agent/mcp-connection/generator.js +2 -72
  53. package/src/py/agent/mcp-connection/generator.js.map +1 -1
  54. package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +5 -22
  55. package/src/py/fast-api/files/app/__name__/init.py.template +5 -22
  56. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +58 -3
  57. package/src/ts/agent/__snapshots__/generator.spec.ts.snap +619 -2
  58. package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client.ts.template +10 -6
  59. package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client.ts.template +30 -0
  60. package/src/ts/agent/gateway-connection/generator.d.ts +10 -0
  61. package/src/ts/agent/gateway-connection/generator.js +106 -0
  62. package/src/ts/agent/gateway-connection/generator.js.map +1 -0
  63. package/src/ts/agent/gateway-connection/schema.d.ts +12 -0
  64. package/src/ts/agent/gateway-connection/schema.json +26 -0
  65. package/src/ts/agent/generator.js +23 -19
  66. package/src/ts/agent/generator.js.map +1 -1
  67. package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +9 -4
  68. package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client.ts.template +9 -6
  69. package/src/ts/agent/mcp-connection/generator.js +1 -13
  70. package/src/ts/agent/mcp-connection/generator.js.map +1 -1
  71. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +58 -3
  72. package/src/ts/nx-generator/generator.js +29 -0
  73. package/src/ts/nx-generator/generator.js.map +1 -1
  74. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +86 -39
  75. package/src/utils/agent-chat/agent-chat.d.ts +31 -0
  76. package/src/utils/agent-chat/agent-chat.js +30 -0
  77. package/src/utils/agent-chat/agent-chat.js.map +1 -0
  78. package/src/utils/agent-chat/files/a2a/chat.ts.template +33 -0
  79. package/src/utils/agent-chat/files/ag-ui/chat.ts.template +17 -0
  80. package/src/utils/agent-chat/files/common/agentcore.ts.template +81 -0
  81. package/src/utils/agent-chat/files/http-py/chat.ts.template +43 -0
  82. package/src/utils/agent-chat/files/http-ts/chat.ts.template +54 -0
  83. package/src/utils/agent-connection/agent-connection.d.ts +17 -0
  84. package/src/utils/agent-connection/agent-connection.js +94 -0
  85. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  86. package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-client.ts.template +78 -0
  87. package/src/utils/agent-connection/files/core-runtime-config/runtime-config.ts.template +22 -32
  88. package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_client.py.template +78 -0
  89. package/src/utils/agent-connection/files/py-core-runtime-config/runtime_config.py.template +5 -18
  90. package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +8 -0
  91. package/src/utils/agent-core-constructs/agent-core-constructs.js +54 -1
  92. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  93. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +4 -0
  94. package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +37 -0
  95. package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +293 -0
  96. package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/readiness-probe/index.js.template +55 -0
  97. package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +242 -0
  98. package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/render-cedar.cjs.template +13 -0
  99. package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +55 -2
  100. package/src/utils/agent-core-constructs/files/terraform/core/agentcore-gateway/gateway.tf.template +14 -0
  101. package/src/utils/versions.d.ts +46 -44
  102. package/src/utils/versions.js +45 -43
  103. package/src/utils/versions.js.map +1 -1
  104. package/src/py/agent/scripts/http/chat.ts.template +0 -38
  105. package/src/ts/agent/scripts/http/chat.ts.template +0 -35
@@ -7,6 +7,8 @@ import { tanstackRouter } from '@tanstack/router-plugin/vite';
7
7
  /// <reference types='vitest' />
8
8
  import { defineConfig } from 'vite';
9
9
  import react from '@vitejs/plugin-react';
10
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
11
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
10
12
 
11
13
  export default defineConfig(() => ({
12
14
  root: import.meta.dirname,
@@ -25,11 +27,13 @@ export default defineConfig(() => ({
25
27
  generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts'),
26
28
  }),
27
29
  react(),
30
+ nxViteTsPaths(),
31
+ nxCopyAssetsPlugin(['*.md']),
28
32
  tailwindcss(),
29
33
  ],
30
34
  // Uncomment this if you are using workers.
31
35
  // worker: {
32
- // plugins: [],
36
+ // plugins: () => [ nxViteTsPaths() ],
33
37
  // },
34
38
  build: {
35
39
  outDir: '../dist/test-app',
@@ -48,7 +52,7 @@ export default defineConfig(() => ({
48
52
  include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
49
53
  reporters: ['default'],
50
54
  coverage: {
51
- reportsDirectory: './test-output/vitest/coverage',
55
+ reportsDirectory: '../coverage/test-app',
52
56
  provider: 'v8' as const,
53
57
  },
54
58
  },
@@ -64,6 +68,8 @@ import { tanstackRouter } from '@tanstack/router-plugin/vite';
64
68
  /// <reference types='vitest' />
65
69
  import { defineConfig } from 'vite';
66
70
  import react from '@vitejs/plugin-react';
71
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
72
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
67
73
 
68
74
  export default defineConfig(() => ({
69
75
  root: import.meta.dirname,
@@ -82,10 +88,12 @@ export default defineConfig(() => ({
82
88
  generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts'),
83
89
  }),
84
90
  react(),
91
+ nxViteTsPaths(),
92
+ nxCopyAssetsPlugin(['*.md']),
85
93
  ],
86
94
  // Uncomment this if you are using workers.
87
95
  // worker: {
88
- // plugins: [],
96
+ // plugins: () => [ nxViteTsPaths() ],
89
97
  // },
90
98
  build: {
91
99
  outDir: '../dist/test-app',
@@ -104,7 +112,7 @@ export default defineConfig(() => ({
104
112
  include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
105
113
  reporters: ['default'],
106
114
  coverage: {
107
- reportsDirectory: './test-output/vitest/coverage',
115
+ reportsDirectory: '../coverage/test-app',
108
116
  provider: 'v8' as const,
109
117
  },
110
118
  },
@@ -932,7 +940,18 @@ vitest.config.*.timestamp*
932
940
  runtime-config.json"
933
941
  `;
934
942
 
935
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > .prettierrc 1`] = `"{"singleQuote":true}"`;
943
+ exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > .prettierignore 1`] = `
944
+ "# Add files here to ignore them from prettier formatting
945
+ /dist
946
+ /coverage
947
+ /.nx/cache
948
+ /.nx/workspace-data"
949
+ `;
950
+
951
+ exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > .prettierrc 1`] = `
952
+ "{ "singleQuote": true }
953
+ "
954
+ `;
936
955
 
937
956
  exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > biome.json 1`] = `
938
957
  "{
@@ -1076,10 +1095,10 @@ exports[`react-website generator > Tanstack router integration > should generate
1076
1095
  "{
1077
1096
  "name": "@proj/source",
1078
1097
  "dependencies": {
1079
- "@cloudscape-design/board-components": "3.0.189",
1080
- "@cloudscape-design/components": "3.0.1308",
1081
- "@cloudscape-design/global-styles": "1.0.59",
1082
- "aws-cdk-lib": "2.258.0",
1098
+ "@cloudscape-design/board-components": "3.0.190",
1099
+ "@cloudscape-design/components": "3.0.1310",
1100
+ "@cloudscape-design/global-styles": "1.0.60",
1101
+ "aws-cdk-lib": "2.259.0",
1083
1102
  "constructs": "10.6.0",
1084
1103
  "react": "19.2.7",
1085
1104
  "react-dom": "19.2.7",
@@ -1097,7 +1116,7 @@ exports[`react-website generator > Tanstack router integration > should generate
1097
1116
  "@tailwindcss/vite": "4.2.2",
1098
1117
  "@testing-library/dom": "10.4.0",
1099
1118
  "@testing-library/react": "16.3.0",
1100
- "@types/node": "25.9.2",
1119
+ "@types/node": "25.9.3",
1101
1120
  "@types/react": "^19.0.0",
1102
1121
  "@types/react-dom": "^19.0.0",
1103
1122
  "@vitejs/plugin-react": "^6.0.0",
@@ -1105,6 +1124,7 @@ exports[`react-website generator > Tanstack router integration > should generate
1105
1124
  "@vitest/ui": "4.1.8",
1106
1125
  "jiti": "2.4.2",
1107
1126
  "jsdom": "~22.1.0",
1127
+ "prettier": "~3.6.2",
1108
1128
  "typescript": "~5.9.2",
1109
1129
  "vite": "8.0.16",
1110
1130
  "vitest": "4.1.8"
@@ -1948,9 +1968,9 @@ export default defineConfig(() => ({
1948
1968
 
1949
1969
  exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > pnpm-workspace.yaml 1`] = `
1950
1970
  "packages:
1951
- - "packages/*"
1952
- - "test-app"
1953
- - "packages/common/*"
1971
+ - 'packages/*'
1972
+ - 'test-app'
1973
+ - 'packages/common/*'
1954
1974
  "
1955
1975
  `;
1956
1976
 
@@ -2005,7 +2025,7 @@ In order to integrate with cognito or trpc backends, you need to have a \`runtim
2005
2025
  `;
2006
2026
 
2007
2027
  exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > test-app/index.html 1`] = `
2008
- "<!DOCTYPE html>
2028
+ "<!doctype html>
2009
2029
  <html lang="en">
2010
2030
  <head>
2011
2031
  <meta charset="utf-8" />
@@ -2406,9 +2426,9 @@ exports[`react-website generator > Tanstack router integration > should generate
2406
2426
 
2407
2427
  exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > test-app/tsconfig.spec.json 1`] = `
2408
2428
  "{
2409
- "extends": "../tsconfig.base.json",
2429
+ "extends": "./tsconfig.json",
2410
2430
  "compilerOptions": {
2411
- "outDir": "./out-tsc/vitest",
2431
+ "outDir": "../dist/out-tsc",
2412
2432
  "types": [
2413
2433
  "vitest/globals",
2414
2434
  "vitest/importMeta",
@@ -2448,6 +2468,8 @@ exports[`react-website generator > Tanstack router integration > should generate
2448
2468
  /// <reference types='vitest' />
2449
2469
  import { defineConfig } from 'vite';
2450
2470
  import react from '@vitejs/plugin-react';
2471
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
2472
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
2451
2473
 
2452
2474
  export default defineConfig(() => ({
2453
2475
  root: import.meta.dirname,
@@ -2460,10 +2482,15 @@ export default defineConfig(() => ({
2460
2482
  port: 4300,
2461
2483
  host: 'localhost',
2462
2484
  },
2463
- plugins: [react(), tailwindcss()],
2485
+ plugins: [
2486
+ react(),
2487
+ nxViteTsPaths(),
2488
+ nxCopyAssetsPlugin(['*.md']),
2489
+ tailwindcss(),
2490
+ ],
2464
2491
  // Uncomment this if you are using workers.
2465
2492
  // worker: {
2466
- // plugins: [],
2493
+ // plugins: () => [ nxViteTsPaths() ],
2467
2494
  // },
2468
2495
  build: {
2469
2496
  outDir: '../dist/test-app',
@@ -2482,7 +2509,7 @@ export default defineConfig(() => ({
2482
2509
  include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
2483
2510
  reporters: ['default'],
2484
2511
  coverage: {
2485
- reportsDirectory: './test-output/vitest/coverage',
2512
+ reportsDirectory: '../coverage/test-app',
2486
2513
  provider: 'v8' as const,
2487
2514
  },
2488
2515
  },
@@ -2535,7 +2562,18 @@ vitest.config.*.timestamp*
2535
2562
  runtime-config.json"
2536
2563
  `;
2537
2564
 
2538
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > .prettierrc 1`] = `"{"singleQuote":true}"`;
2565
+ exports[`react-website generator > Tanstack router integration > should generate website with router correctly > .prettierignore 1`] = `
2566
+ "# Add files here to ignore them from prettier formatting
2567
+ /dist
2568
+ /coverage
2569
+ /.nx/cache
2570
+ /.nx/workspace-data"
2571
+ `;
2572
+
2573
+ exports[`react-website generator > Tanstack router integration > should generate website with router correctly > .prettierrc 1`] = `
2574
+ "{ "singleQuote": true }
2575
+ "
2576
+ `;
2539
2577
 
2540
2578
  exports[`react-website generator > Tanstack router integration > should generate website with router correctly > biome.json 1`] = `
2541
2579
  "{
@@ -2679,11 +2717,11 @@ exports[`react-website generator > Tanstack router integration > should generate
2679
2717
  "{
2680
2718
  "name": "@proj/source",
2681
2719
  "dependencies": {
2682
- "@cloudscape-design/board-components": "3.0.189",
2683
- "@cloudscape-design/components": "3.0.1308",
2684
- "@cloudscape-design/global-styles": "1.0.59",
2720
+ "@cloudscape-design/board-components": "3.0.190",
2721
+ "@cloudscape-design/components": "3.0.1310",
2722
+ "@cloudscape-design/global-styles": "1.0.60",
2685
2723
  "@tanstack/react-router": "1.170.15",
2686
- "aws-cdk-lib": "2.258.0",
2724
+ "aws-cdk-lib": "2.259.0",
2687
2725
  "constructs": "10.6.0",
2688
2726
  "react": "19.2.7",
2689
2727
  "react-dom": "19.2.7",
@@ -2705,7 +2743,7 @@ exports[`react-website generator > Tanstack router integration > should generate
2705
2743
  "@tanstack/virtual-file-routes": "1.162.0",
2706
2744
  "@testing-library/dom": "10.4.0",
2707
2745
  "@testing-library/react": "16.3.0",
2708
- "@types/node": "25.9.2",
2746
+ "@types/node": "25.9.3",
2709
2747
  "@types/react": "^19.0.0",
2710
2748
  "@types/react-dom": "^19.0.0",
2711
2749
  "@vitejs/plugin-react": "^6.0.0",
@@ -2713,6 +2751,7 @@ exports[`react-website generator > Tanstack router integration > should generate
2713
2751
  "@vitest/ui": "4.1.8",
2714
2752
  "jiti": "2.4.2",
2715
2753
  "jsdom": "~22.1.0",
2754
+ "prettier": "~3.6.2",
2716
2755
  "typescript": "~5.9.2",
2717
2756
  "vite": "8.0.16",
2718
2757
  "vitest": "4.1.8"
@@ -3556,9 +3595,9 @@ export default defineConfig(() => ({
3556
3595
 
3557
3596
  exports[`react-website generator > Tanstack router integration > should generate website with router correctly > pnpm-workspace.yaml 1`] = `
3558
3597
  "packages:
3559
- - "packages/*"
3560
- - "test-app"
3561
- - "packages/common/*"
3598
+ - 'packages/*'
3599
+ - 'test-app'
3600
+ - 'packages/common/*'
3562
3601
  "
3563
3602
  `;
3564
3603
 
@@ -3613,7 +3652,7 @@ In order to integrate with cognito or trpc backends, you need to have a \`runtim
3613
3652
  `;
3614
3653
 
3615
3654
  exports[`react-website generator > Tanstack router integration > should generate website with router correctly > test-app/index.html 1`] = `
3616
- "<!DOCTYPE html>
3655
+ "<!doctype html>
3617
3656
  <html lang="en">
3618
3657
  <head>
3619
3658
  <meta charset="utf-8" />
@@ -4198,9 +4237,9 @@ exports[`react-website generator > Tanstack router integration > should generate
4198
4237
 
4199
4238
  exports[`react-website generator > Tanstack router integration > should generate website with router correctly > test-app/tsconfig.spec.json 1`] = `
4200
4239
  "{
4201
- "extends": "../tsconfig.base.json",
4240
+ "extends": "./tsconfig.json",
4202
4241
  "compilerOptions": {
4203
- "outDir": "./out-tsc/vitest",
4242
+ "outDir": "../dist/out-tsc",
4204
4243
  "types": [
4205
4244
  "vitest/globals",
4206
4245
  "vitest/importMeta",
@@ -4242,6 +4281,8 @@ import { tanstackRouter } from '@tanstack/router-plugin/vite';
4242
4281
  /// <reference types='vitest' />
4243
4282
  import { defineConfig } from 'vite';
4244
4283
  import react from '@vitejs/plugin-react';
4284
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
4285
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
4245
4286
 
4246
4287
  export default defineConfig(() => ({
4247
4288
  root: import.meta.dirname,
@@ -4260,11 +4301,13 @@ export default defineConfig(() => ({
4260
4301
  generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts'),
4261
4302
  }),
4262
4303
  react(),
4304
+ nxViteTsPaths(),
4305
+ nxCopyAssetsPlugin(['*.md']),
4263
4306
  tailwindcss(),
4264
4307
  ],
4265
4308
  // Uncomment this if you are using workers.
4266
4309
  // worker: {
4267
- // plugins: [],
4310
+ // plugins: () => [ nxViteTsPaths() ],
4268
4311
  // },
4269
4312
  build: {
4270
4313
  outDir: '../dist/test-app',
@@ -4283,7 +4326,7 @@ export default defineConfig(() => ({
4283
4326
  include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
4284
4327
  reporters: ['default'],
4285
4328
  coverage: {
4286
- reportsDirectory: './test-output/vitest/coverage',
4329
+ reportsDirectory: '../coverage/test-app',
4287
4330
  provider: 'v8' as const,
4288
4331
  },
4289
4332
  },
@@ -4355,6 +4398,8 @@ import { tanstackRouter } from '@tanstack/router-plugin/vite';
4355
4398
  /// <reference types='vitest' />
4356
4399
  import { defineConfig } from 'vite';
4357
4400
  import react from '@vitejs/plugin-react';
4401
+ import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
4402
+ import { nxCopyAssetsPlugin } from '@nx/vite/plugins/nx-copy-assets.plugin';
4358
4403
 
4359
4404
  export default defineConfig(() => ({
4360
4405
  root: import.meta.dirname,
@@ -4373,11 +4418,13 @@ export default defineConfig(() => ({
4373
4418
  generatedRouteTree: resolve(__dirname, 'src/routeTree.gen.ts'),
4374
4419
  }),
4375
4420
  react(),
4421
+ nxViteTsPaths(),
4422
+ nxCopyAssetsPlugin(['*.md']),
4376
4423
  tailwindcss(),
4377
4424
  ],
4378
4425
  // Uncomment this if you are using workers.
4379
4426
  // worker: {
4380
- // plugins: [],
4427
+ // plugins: () => [ nxViteTsPaths() ],
4381
4428
  // },
4382
4429
  build: {
4383
4430
  outDir: '../dist/test-app',
@@ -4396,7 +4443,7 @@ export default defineConfig(() => ({
4396
4443
  include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
4397
4444
  reporters: ['default'],
4398
4445
  coverage: {
4399
- reportsDirectory: './test-output/vitest/coverage',
4446
+ reportsDirectory: '../coverage/test-app',
4400
4447
  provider: 'v8' as const,
4401
4448
  },
4402
4449
  },
@@ -5011,11 +5058,11 @@ root &&
5011
5058
 
5012
5059
  exports[`react-website generator > should handle npm scope prefix correctly > scoped-dependencies 1`] = `
5013
5060
  {
5014
- "@cloudscape-design/board-components": "3.0.189",
5015
- "@cloudscape-design/components": "3.0.1308",
5016
- "@cloudscape-design/global-styles": "1.0.59",
5061
+ "@cloudscape-design/board-components": "3.0.190",
5062
+ "@cloudscape-design/components": "3.0.1310",
5063
+ "@cloudscape-design/global-styles": "1.0.60",
5017
5064
  "@tanstack/react-router": "1.170.15",
5018
- "aws-cdk-lib": "2.258.0",
5065
+ "aws-cdk-lib": "2.259.0",
5019
5066
  "constructs": "10.6.0",
5020
5067
  "react": "19.2.7",
5021
5068
  "react-dom": "19.2.7",
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import type { Tree } from '@nx/devkit';
6
+ export type AgentChatProtocol = 'http' | 'a2a' | 'ag-ui';
7
+ export type AgentChatAuth = 'iam' | 'cognito';
8
+ export interface AddAgentChatScriptsOptions {
9
+ /** Absolute (tree) directory to emit the chat scripts into. */
10
+ scriptsDir: string;
11
+ protocol: AgentChatProtocol;
12
+ /** Agent server language. Only affects the HTTP chat adapter. */
13
+ language: 'ts' | 'py';
14
+ /** Construct class name — the runtime-config key for the deployed agent. */
15
+ agentNameClassName: string;
16
+ /** Authentication used by the deployed agent. */
17
+ auth: AgentChatAuth;
18
+ /**
19
+ * Import path to the agent's `client.ts` (TypeScript HTTP agents only),
20
+ * relative to the chat script.
21
+ */
22
+ relativeAgentImport?: string;
23
+ }
24
+ /**
25
+ * Emit the chat CLI scripts for an agent. Every protocol gets a small
26
+ * `chat.ts` that connects to the local `serve-local` server by default, and
27
+ * to the deployed agent on Bedrock AgentCore (resolved from runtime config)
28
+ * when `RUNTIME_CONFIG_APP_ID` is set. The shared `agentcore.ts` helper
29
+ * handles ARN resolution and request authentication.
30
+ */
31
+ export declare const addAgentChatScripts: (tree: Tree, options: AddAgentChatScriptsOptions) => void;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.addAgentChatScripts = void 0;
8
+ const devkit_1 = require("@nx/devkit");
9
+ /**
10
+ * Emit the chat CLI scripts for an agent. Every protocol gets a small
11
+ * `chat.ts` that connects to the local `serve-local` server by default, and
12
+ * to the deployed agent on Bedrock AgentCore (resolved from runtime config)
13
+ * when `RUNTIME_CONFIG_APP_ID` is set. The shared `agentcore.ts` helper
14
+ * handles ARN resolution and request authentication.
15
+ */
16
+ const addAgentChatScripts = (tree, options) => {
17
+ const templateContext = {
18
+ agentNameClassName: options.agentNameClassName,
19
+ auth: options.auth,
20
+ relativeAgentImport: options.relativeAgentImport ?? '',
21
+ };
22
+ // Shared remote-resolution + auth helper, used by every protocol.
23
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'common'), options.scriptsDir, templateContext, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
24
+ // Protocol-specific chat adapter. HTTP differs by server language; A2A and
25
+ // AG-UI speak standard protocols so the same script serves both languages.
26
+ const protocolDir = options.protocol === 'http' ? `http-${options.language}` : options.protocol;
27
+ (0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', protocolDir), options.scriptsDir, templateContext, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
28
+ };
29
+ exports.addAgentChatScripts = addAgentChatScripts;
30
+ //# sourceMappingURL=agent-chat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-chat.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/utils/agent-chat/agent-chat.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,uCAIoB;AAsBpB;;;;;;GAMG;AACI,MAAM,mBAAmB,GAAG,CACjC,IAAU,EACV,OAAmC,EAC7B,EAAE;IACR,MAAM,eAAe,GAAG;QACtB,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,mBAAmB,EAAE,OAAO,CAAC,mBAAmB,IAAI,EAAE;KACvD,CAAC;IAEF,kEAAkE;IAClE,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,EAC/C,OAAO,CAAC,UAAU,EAClB,eAAe,EACf,EAAE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY,EAAE,CACtD,CAAC;IAEF,2EAA2E;IAC3E,2EAA2E;IAC3E,MAAM,WAAW,GACf,OAAO,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC9E,IAAA,sBAAa,EACX,IAAI,EACJ,IAAA,0BAAiB,EAAC,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC,EAClD,OAAO,CAAC,UAAU,EAClB,eAAe,EACf,EAAE,iBAAiB,EAAE,0BAAiB,CAAC,YAAY,EAAE,CACtD,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,mBAAmB,uBA8B9B"}
@@ -0,0 +1,33 @@
1
+ // Chat CLI for <%- agentNameClassName %> (A2A protocol). Connects to the local
2
+ // `serve-local` server, or the deployed agent when `RUNTIME_CONFIG_APP_ID` is set.
3
+ import {
4
+ ClientFactory,
5
+ ClientFactoryOptions,
6
+ DefaultAgentCardResolver,
7
+ JsonRpcTransportFactory,
8
+ } from '@a2a-js/sdk/client';
9
+ import { A2AChatAdapter, chatLoop } from 'agent-chat-cli';
10
+ import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore.js';
11
+
12
+ const remote = await resolveRemoteAgent();
13
+
14
+ const url = remote
15
+ ? `https://bedrock-agentcore.${remote.region}.amazonaws.com/runtimes/${encodeURIComponent(remote.arn)}/invocations/`
16
+ : process.env.URL!;
17
+
18
+ // Remote requests are authenticated via a custom fetch; locally the default client talks plain HTTP.
19
+ const clientFactory = remote
20
+ ? new ClientFactory({
21
+ ...ClientFactoryOptions.default,
22
+ transports: [
23
+ new JsonRpcTransportFactory({
24
+ fetchImpl: createAgentCoreFetch(<%- auth === 'iam' ? 'remote.region' : '' %>),
25
+ }),
26
+ ],
27
+ cardResolver: new DefaultAgentCardResolver({
28
+ fetchImpl: createAgentCoreFetch(<%- auth === 'iam' ? 'remote.region' : '' %>),
29
+ }),
30
+ })
31
+ : undefined;
32
+
33
+ await chatLoop(new A2AChatAdapter({ clientFactory }), url);
@@ -0,0 +1,17 @@
1
+ // Chat CLI for <%- agentNameClassName %> (AG-UI protocol). Connects to the local
2
+ // `serve-local` server, or the deployed agent when `RUNTIME_CONFIG_APP_ID` is set.
3
+ import { AGUIChatAdapter, chatLoop } from 'agent-chat-cli';
4
+ import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore.js';
5
+
6
+ const remote = await resolveRemoteAgent();
7
+
8
+ const url = remote
9
+ ? `https://bedrock-agentcore.${remote.region}.amazonaws.com/runtimes/${encodeURIComponent(remote.arn)}/invocations?qualifier=DEFAULT`
10
+ : process.env.URL!;
11
+
12
+ // Remote requests are authenticated via a custom fetch; locally the default agent talks plain HTTP.
13
+ const fetchImpl = remote
14
+ ? createAgentCoreFetch(<%- auth === 'iam' ? 'remote.region' : '' %>)
15
+ : undefined;
16
+
17
+ await chatLoop(new AGUIChatAdapter({ fetch: fetchImpl }), url);
@@ -0,0 +1,81 @@
1
+ // Resolves the deployed <%- agentNameClassName %> agent from runtime config and authenticates requests to it.
2
+ import { randomUUID } from 'node:crypto';
3
+ import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';
4
+ <%_ if (auth === 'iam') { _%>
5
+ import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
6
+ import { AwsClient } from 'aws4fetch';
7
+ <%_ } _%>
8
+
9
+ const SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
10
+
11
+ // AgentCore session ids must be at least 33 characters.
12
+ export const SESSION_ID = randomUUID().replaceAll('-', '').padEnd(33, '0');
13
+
14
+ export interface RemoteAgent {
15
+ /** ARN of the deployed Bedrock AgentCore runtime. */
16
+ arn: string;
17
+ /** AWS region parsed from the runtime ARN. */
18
+ region: string;
19
+ }
20
+
21
+ // Returns the deployed agent when `RUNTIME_CONFIG_APP_ID` is set, otherwise `undefined` to chat locally.
22
+ export const resolveRemoteAgent = async (): Promise<
23
+ RemoteAgent | undefined
24
+ > => {
25
+ const application = process.env.RUNTIME_CONFIG_APP_ID;
26
+ if (!application) {
27
+ return undefined;
28
+ }
29
+ const config = (await getAppConfig('agentcore', {
30
+ application,
31
+ environment: 'default',
32
+ transform: 'json',
33
+ })) as { agentRuntimes?: Record<string, string> };
34
+ const arn = config?.agentRuntimes?.['<%- agentNameClassName %>'];
35
+ if (!arn) {
36
+ throw new Error(
37
+ `No deployed agent named '<%- agentNameClassName %>' found in runtime configuration (application ${application}).`,
38
+ );
39
+ }
40
+ return { arn, region: arn.split(':')[3] };
41
+ };
42
+
43
+ <%_ if (auth === 'cognito') { _%>
44
+ /** The Cognito access token used to authenticate with the deployed agent. */
45
+ export const getAccessToken = (): string => {
46
+ const accessToken = process.env.AGENT_ACCESS_TOKEN;
47
+ if (!accessToken) {
48
+ throw new Error(
49
+ 'AGENT_ACCESS_TOKEN is not set. Provide a Cognito access token to chat with the deployed agent.',
50
+ );
51
+ }
52
+ return accessToken;
53
+ };
54
+ <%_ } _%>
55
+
56
+ // A `fetch` that authenticates requests to the deployed agent and forwards the session id.
57
+ <%_ if (auth === 'iam') { _%>
58
+ export const createAgentCoreFetch = (region: string): typeof fetch => {
59
+ const credentialProvider = fromNodeProviderChain();
60
+ return async (input, init) => {
61
+ const headers = new Headers(init?.headers);
62
+ headers.set(SESSION_HEADER, SESSION_ID);
63
+ const client = new AwsClient({
64
+ ...(await credentialProvider()),
65
+ service: 'bedrock-agentcore',
66
+ region,
67
+ });
68
+ return client.fetch(input, { ...init, headers });
69
+ };
70
+ };
71
+ <%_ } else { _%>
72
+ export const createAgentCoreFetch = (): typeof fetch => {
73
+ const accessToken = getAccessToken();
74
+ return (input, init) => {
75
+ const headers = new Headers(init?.headers);
76
+ headers.set(SESSION_HEADER, SESSION_ID);
77
+ headers.set('Authorization', `Bearer ${accessToken}`);
78
+ return fetch(input, { ...init, headers });
79
+ };
80
+ };
81
+ <%_ } _%>
@@ -0,0 +1,43 @@
1
+ // Chat CLI for <%- agentNameClassName %> (Python FastAPI / JSONL streaming), using the
2
+ // generated client. Connects to the local `serve-local` server, or the deployed
3
+ // agent when `RUNTIME_CONFIG_APP_ID` is set.
4
+ import { chatLoop, type ChatAdapter } from 'agent-chat-cli';
5
+ import { <%- agentNameClassName %> } from './generated/client.gen.js';
6
+ import {
7
+ createAgentCoreFetch,
8
+ resolveRemoteAgent,
9
+ SESSION_ID,
10
+ } from './agentcore.js';
11
+
12
+ const SESSION_ID_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
13
+
14
+ const remote = await resolveRemoteAgent();
15
+
16
+ class <%- agentNameClassName %>Adapter implements ChatAdapter {
17
+ private client!: <%- agentNameClassName %>;
18
+
19
+ async connect(url: string) {
20
+ this.client = remote
21
+ ? new <%- agentNameClassName %>({
22
+ url: `https://bedrock-agentcore.${remote.region}.amazonaws.com/runtimes/${encodeURIComponent(remote.arn)}`,
23
+ fetch: createAgentCoreFetch(<%- auth === 'iam' ? 'remote.region' : '' %>),
24
+ })
25
+ : new <%- agentNameClassName %>({
26
+ url,
27
+ fetch: (input, init) => {
28
+ const headers = new Headers(init?.headers);
29
+ headers.set(SESSION_ID_HEADER, SESSION_ID);
30
+ return fetch(input, { ...init, headers });
31
+ },
32
+ });
33
+ return { agentName: '<%- agentNameClassName %>' };
34
+ }
35
+
36
+ async *sendMessage(text: string): AsyncIterable<string> {
37
+ for await (const chunk of this.client.invoke({ message: text })) {
38
+ if (typeof chunk.content === 'string') yield chunk.content;
39
+ }
40
+ }
41
+ }
42
+
43
+ await chatLoop(new <%- agentNameClassName %>Adapter(), process.env.URL ?? '');
@@ -0,0 +1,54 @@
1
+ // Chat CLI for <%- agentNameClassName %> (HTTP / tRPC WebSocket). Connects to the local
2
+ // `serve-local` server, or the deployed agent when `RUNTIME_CONFIG_APP_ID` is set.
3
+ import { chatLoop, type ChatAdapter } from 'agent-chat-cli';
4
+ import { <%- agentNameClassName %>Client } from '<%- relativeAgentImport %>/client.js';
5
+ import {
6
+ resolveRemoteAgent,
7
+ SESSION_ID,
8
+ <%_ if (auth === 'cognito') { _%>
9
+ getAccessToken,
10
+ <%_ } _%>
11
+ } from './agentcore.js';
12
+
13
+ const remote = await resolveRemoteAgent();
14
+
15
+ class TrpcWebSocketAdapter implements ChatAdapter {
16
+ private client!: ReturnType<typeof <%- agentNameClassName %>Client.local>;
17
+
18
+ async connect(url: string) {
19
+ this.client = remote
20
+ <%_ if (auth === 'iam') { _%>
21
+ ? <%- agentNameClassName %>Client.withIamAuth({
22
+ agentRuntimeArn: remote.arn,
23
+ sessionId: SESSION_ID,
24
+ })
25
+ <%_ } else { _%>
26
+ ? <%- agentNameClassName %>Client.withJwtAuth({
27
+ agentRuntimeArn: remote.arn,
28
+ sessionId: SESSION_ID,
29
+ accessTokenProvider: async () => getAccessToken(),
30
+ })
31
+ <%_ } _%>
32
+ : <%- agentNameClassName %>Client.local({ url, sessionId: SESSION_ID });
33
+ return { agentName: '<%- agentNameClassName %>' };
34
+ }
35
+
36
+ async *sendMessage(text: string): AsyncIterable<string> {
37
+ const stream = new ReadableStream<string>({
38
+ start: (controller) => {
39
+ this.client.invoke.subscribe(
40
+ { message: text },
41
+ {
42
+ onData: (chunk: string) => controller.enqueue(chunk),
43
+ onComplete: () => controller.close(),
44
+ onError: (err: unknown) => controller.error(err),
45
+ },
46
+ );
47
+ },
48
+ });
49
+
50
+ yield* stream as unknown as AsyncIterable<string>;
51
+ }
52
+ }
53
+
54
+ await chatLoop(new TrpcWebSocketAdapter(), process.env.URL ?? '');