@aws/nx-plugin 1.0.0-rc.55 → 1.0.0-rc.57

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 (81) hide show
  1. package/migrations.json +13 -3
  2. package/package.json +1 -1
  3. package/src/migrations/latest/dynamodb-local-remove-optimize-flag/migration.d.ts +6 -0
  4. package/src/migrations/latest/dynamodb-local-remove-optimize-flag/migration.js +89 -0
  5. package/src/migrations/latest/dynamodb-local-remove-optimize-flag/migration.js.map +1 -0
  6. package/src/migrations/latest/modernize-function-props-cast/migration.js +0 -1
  7. package/src/migrations/latest/modernize-function-props-cast/migration.js.map +1 -1
  8. package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js +0 -1
  9. package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js.map +1 -1
  10. package/src/migrations/latest/restrict-cors-to-custom-domains/migration.js +0 -2
  11. package/src/migrations/latest/restrict-cors-to-custom-domains/migration.js.map +1 -1
  12. package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.js +0 -1
  13. package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.js.map +1 -1
  14. package/src/migrations/latest/ts-agent-session-management-support/migration.d.ts +6 -0
  15. package/src/migrations/latest/ts-agent-session-management-support/migration.js +449 -0
  16. package/src/migrations/latest/ts-agent-session-management-support/migration.js.map +1 -0
  17. package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.js +0 -2
  18. package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.js.map +1 -1
  19. package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +3 -1
  20. package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +12 -12
  21. package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +1 -1
  22. package/src/py/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +2 -1
  23. package/src/py/agent/a2a-connection/files/agent-connection/app/__targetAgentSnakeCase___client_strands.py.template +2 -1
  24. package/src/py/agent/a2a-connection/files/langchain/agent-connection/app/__targetAgentSnakeCase___client_langchain.py.template +2 -1
  25. package/src/py/agent/generator.js +4 -0
  26. package/src/py/agent/generator.js.map +1 -1
  27. package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +2 -1
  28. package/src/py/agent/mcp-connection/files/agent-connection/app/__mcpServerSnakeCase___client_strands.py.template +2 -1
  29. package/src/py/agent/mcp-connection/files/langchain/agent-connection/app/__mcpServerSnakeCase___client_langchain.py.template +2 -1
  30. package/src/py/agent/react-connection/__snapshots__/generator.spec.ts.snap +6 -0
  31. package/src/py/agent/schema.d.js.map +1 -1
  32. package/src/py/agent/schema.d.ts +3 -0
  33. package/src/py/agent/schema.json +8 -0
  34. package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +0 -2
  35. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +4 -2
  36. package/src/ts/agent/__snapshots__/generator.spec.ts.snap +663 -19
  37. package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +2 -1
  38. package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +1 -1
  39. package/src/ts/agent/files/ag-ui/index.ts.template +10 -1
  40. package/src/ts/agent/files/common/agent.ts.template +11 -3
  41. package/src/ts/agent/files/common/session.ts.template +43 -0
  42. package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +1 -0
  43. package/src/ts/agent/generator.d.ts +4 -0
  44. package/src/ts/agent/generator.js +21 -0
  45. package/src/ts/agent/generator.js.map +1 -1
  46. package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +2 -1
  47. package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +2 -1
  48. package/src/ts/agent/react-connection/__snapshots__/generator.spec.ts.snap +8 -4
  49. package/src/ts/agent/react-connection/files/src/components/__agentNameClassName__AgentClientProvider.tsx.template +2 -1
  50. package/src/ts/agent/schema.d.js.map +1 -1
  51. package/src/ts/agent/schema.d.ts +3 -0
  52. package/src/ts/agent/schema.json +8 -0
  53. package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +0 -2
  54. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +4 -2
  55. package/src/ts/nx-migration/files/migration.ts.template +4 -0
  56. package/src/utils/agent-chat/files/common/agentcore.ts.template +2 -2
  57. package/src/utils/agent-connection/agent-connection.js +4 -0
  58. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  59. package/src/utils/agent-connection/files/core-runtime-config/runtime-config.ts.template +11 -1
  60. package/src/utils/agent-connection/files/core-strands/base/model-errors-strands.ts.template +26 -15
  61. package/src/utils/agent-connection/files/core-strands/base/tool-errors-strands.ts.template +23 -16
  62. package/src/utils/agent-connection/files/py-core-runtime-config/runtime_config.py.template +4 -3
  63. package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +4 -0
  64. package/src/utils/agent-core-constructs/agent-core-constructs.js +7 -1
  65. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  66. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +131 -3
  67. package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +180 -1
  68. package/src/utils/ast.d.ts +5 -0
  69. package/src/utils/ast.js +25 -0
  70. package/src/utils/ast.js.map +1 -1
  71. package/src/utils/connection/open-api/files/components/__apiNameClassName__Provider.tsx.template +2 -0
  72. package/src/utils/files/common/scripts/src/dynamodb/start-container.ts.template +0 -1
  73. package/src/utils/migration-versions.d.ts +15 -10
  74. package/src/utils/migration-versions.js +48 -36
  75. package/src/utils/migration-versions.js.map +1 -1
  76. package/src/utils/version-upgrade-migration/nx-package-updates.d.ts +18 -8
  77. package/src/utils/version-upgrade-migration/nx-package-updates.js +19 -11
  78. package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -1
  79. package/src/utils/version-upgrade-migration/register.d.ts +6 -1
  80. package/src/utils/version-upgrade-migration/register.js +8 -3
  81. package/src/utils/version-upgrade-migration/register.js.map +1 -1
@@ -5,6 +5,7 @@ exports[`ts#agent#a2a-connection generator > should match snapshot for agent-con
5
5
  export * from './core/tool-errors-strands.js';
6
6
  export * from './core/model-errors-strands.js';
7
7
  export * from './core/with-session-id-strands.js';
8
+ export * from './core/runtime-config.js';
8
9
  export * from './core/session-context.js';
9
10
  // Export your library code here
10
11
  "
@@ -244,7 +245,7 @@ export class RemoteClientStrands {
244
245
  });
245
246
  }
246
247
  const config = await getAgentCoreRuntimeConfig();
247
- const agentRuntimeArn = config.agentRuntimes?.['Remote'];
248
+ const agentRuntimeArn = config.agentRuntimes?.['Remote']?.arn;
248
249
  if (!agentRuntimeArn) {
249
250
  throw new Error(
250
251
  \`No connected agent runtime named 'Remote' found in runtime configuration.\`,
@@ -12,7 +12,7 @@ export class <%- targetAgentClassName %>ClientStrands {
12
12
  }
13
13
  const config = await getAgentCoreRuntimeConfig();
14
14
  const agentRuntimeArn =
15
- config.agentRuntimes?.['<%- targetAgentClassName %>'];
15
+ config.agentRuntimes?.['<%- targetAgentClassName %>']?.arn;
16
16
  if (!agentRuntimeArn) {
17
17
  throw new Error(
18
18
  `No connected agent runtime named '<%- targetAgentClassName %>' found in runtime configuration.`,
@@ -7,8 +7,13 @@ import {
7
7
  import express, { type Request, type Response, type NextFunction } from 'express';
8
8
  import cors from 'cors';
9
9
  import { randomUUID } from 'node:crypto';
10
- import { runWithSessionId } from '<%- agentConnectionImport %>';
10
+ import {
11
+ ModelErrorLoggingPlugin,
12
+ ToolErrorLoggingPlugin,
13
+ runWithSessionId,
14
+ } from '<%- agentConnectionImport %>';
11
15
  import { getAgent } from './agent<% if (esm) { %>.js<% } %>';
16
+ import { getSessionManager } from './session<% if (esm) { %>.js<% } %>';
12
17
 
13
18
  const PORT = parseInt(process.env.PORT || '8080');
14
19
  const HOST = '0.0.0.0';
@@ -32,6 +37,10 @@ void (async () => {
32
37
  agent,
33
38
  name: '<%= agentNameClassName %>',
34
39
  description: 'A Strands Agent exposed via the AG-UI protocol.',
40
+ plugins: [new ModelErrorLoggingPlugin(), new ToolErrorLoggingPlugin()],
41
+ config: {
42
+ sessionManagerProvider: getSessionManager,
43
+ },
35
44
  });
36
45
 
37
46
  // Built up manually (mirroring createStrandsApp's defaults) rather than via createStrandsApp
@@ -1,5 +1,11 @@
1
1
  import { Agent, tool } from '@strands-agents/sdk';
2
- import { logModelErrors, logToolErrors } from '<%- agentConnectionImport %>';
2
+ <%_ if (protocol !== 'ag-ui') { _%>
3
+ import {
4
+ ModelErrorLoggingPlugin,
5
+ ToolErrorLoggingPlugin,
6
+ } from '<%- agentConnectionImport %>';
7
+ import { getSessionManager } from './session<% if (esm) { %>.js<% } %>';
8
+ <%_ } _%>
3
9
  import { z } from 'zod';
4
10
 
5
11
  const multiply = tool({
@@ -18,8 +24,10 @@ export const getAgent = async () => {
18
24
  Use your tools for mathematical tasks.
19
25
  Refer to tools as your 'spellbook'.`,
20
26
  tools: [multiply],
27
+ <%_ if (protocol !== 'ag-ui') { _%>
28
+ sessionManager: await getSessionManager(),
29
+ plugins: [new ModelErrorLoggingPlugin(), new ToolErrorLoggingPlugin()],
30
+ <%_ } _%>
21
31
  });
22
- logModelErrors(agent);
23
- logToolErrors(agent);
24
32
  return agent;
25
33
  };
@@ -0,0 +1,43 @@
1
+ import { SessionManager } from '@strands-agents/sdk';
2
+ import { LocalFileStorage<% if (session === 's3') { %>, S3Storage<% } else { %>, InMemoryStorage<% } %> } from '@strands-agents/sdk/storage';
3
+ import {
4
+ getCurrentSessionId,
5
+ <%_ if (session === 's3') { _%>
6
+ getAgentCoreRuntimeConfig,
7
+ <%_ } _%>
8
+ } from '<%- agentConnectionImport %>';
9
+
10
+ /**
11
+ * Returns a SessionManager for persisting conversation state across
12
+ * invocations. Local development always uses local file storage for
13
+ * convenience, regardless of the configured session option. Without a
14
+ * configured session option, conversation state is kept in memory only and
15
+ * does not survive process restarts.
16
+ */
17
+ export const getSessionManager = async (): Promise<SessionManager> => {
18
+ const sessionId = getCurrentSessionId();
19
+ if (!sessionId) {
20
+ throw new Error(
21
+ 'No current session id — cannot resolve a SessionManager outside of a request scope.',
22
+ );
23
+ }
24
+ if (process.env.LOCAL_DEV === 'true') {
25
+ return new SessionManager({
26
+ sessionId,
27
+ storage: new LocalFileStorage('<%- localSessionsDir %>'),
28
+ });
29
+ }
30
+ <%_ if (session === 's3') { _%>
31
+ const config = await getAgentCoreRuntimeConfig();
32
+ const bucketName =
33
+ config.agentRuntimes?.['<%- agentNameClassName %>']?.session?.bucketName;
34
+ if (!bucketName) {
35
+ throw new Error(
36
+ "No S3 bucket configured for this agent's session in runtime configuration.",
37
+ );
38
+ }
39
+ return new SessionManager({ sessionId, storage: new S3Storage(bucketName) });
40
+ <%_ } else { _%>
41
+ return new SessionManager({ sessionId, storage: new InMemoryStorage() });
42
+ <%_ } _%>
43
+ };
@@ -5,6 +5,7 @@ exports[`ts#agent#gateway-connection generator > should match snapshot for agent
5
5
  export * from './core/tool-errors-strands.js';
6
6
  export * from './core/model-errors-strands.js';
7
7
  export * from './core/with-session-id-strands.js';
8
+ export * from './core/runtime-config.js';
8
9
  export * from './core/session-context.js';
9
10
  // Export your library code here
10
11
  "
@@ -12,6 +12,7 @@ export interface TsAgentMetadata extends IacMetadata {
12
12
  readonly rc: string;
13
13
  readonly auth: string;
14
14
  readonly protocol: string;
15
+ readonly session: string;
15
16
  }
16
17
  export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
17
18
  readonly name: "zod";
@@ -25,6 +26,9 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
25
26
  readonly name: "@aws-lambda-powertools/parameters";
26
27
  }, {
27
28
  readonly name: "@modelcontextprotocol/sdk";
29
+ }, {
30
+ readonly name: "@aws-sdk/client-s3";
31
+ readonly when: (m: TsAgentMetadata) => boolean;
28
32
  }, {
29
33
  readonly name: "express";
30
34
  readonly when: (m: TsAgentMetadata) => boolean;
@@ -20,6 +20,7 @@ import { kebabCase, toClassName } from "../../utils/names.js";
20
20
  import { getNpmScope } from "../../utils/npm-scope.js";
21
21
  import { addComponentDevTarget, addComponentGeneratorMetadata, addDependencyToTargetIfNotPresent, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
22
22
  import { sortObjectKeys } from "../../utils/object.js";
23
+ import { getRelativePathToRootByDirectory } from "../../utils/paths.js";
23
24
  import { assignPort } from "../../utils/port.js";
24
25
  import { SHARED_CONSTRUCTS_DEPENDENCIES, sharedConstructsGenerator } from "../../utils/shared-constructs.js";
25
26
  import { BASE_IMAGES, TS_VERSIONS } from "../../utils/versions.js";
@@ -45,6 +46,10 @@ export const DEPENDENCIES = declareDependencies()({
45
46
  {
46
47
  name: '@modelcontextprotocol/sdk'
47
48
  },
49
+ {
50
+ name: '@aws-sdk/client-s3',
51
+ when: (m)=>m.session === 's3'
52
+ },
48
53
  {
49
54
  name: 'express',
50
55
  when: (m)=>m.protocol !== 'http'
@@ -179,6 +184,17 @@ export const tsAgentGenerator = async (tree, options)=>{
179
184
  console.warn('Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)');
180
185
  }
181
186
  const auth = options.auth ?? 'iam';
187
+ const session = options.session ?? 's3';
188
+ if (infra === 'none' && session !== 'in-memory') {
189
+ console.warn('Warning: session is ignored when no infrastructure is configured (no infrastructure is generated)');
190
+ }
191
+ // Local-dev session storage lives at the workspace root
192
+ // (`tmp/agents/strands/<agent-name>`), not inside the project, so each agent
193
+ // gets its own storage directory. The `-dev`/`-serve` targets run with
194
+ // cwd={projectRoot}, so compute that directory relative to the project root
195
+ // here rather than resolving it at runtime (e.g. via import.meta.url),
196
+ // which would need an extra runtime helper.
197
+ const localSessionsDir = joinPathFragments(getRelativePathToRootByDirectory(project.root), `tmp/agents/strands/${name}`);
182
198
  // Ensure the shared agent-connection project exists so the server entry
183
199
  // point can import `runWithSessionId` and propagate the AgentCore session
184
200
  // ID to any downstream MCP / A2A clients a later connection generator
@@ -191,6 +207,9 @@ export const tsAgentGenerator = async (tree, options)=>{
191
207
  name,
192
208
  agentNameClassName,
193
209
  distDir,
210
+ protocol,
211
+ session,
212
+ localSessionsDir,
194
213
  agentConnectionImport: `@${getNpmScope(tree)}/agent-connection`,
195
214
  ...esmVars(tree)
196
215
  };
@@ -268,6 +287,7 @@ export const tsAgentGenerator = async (tree, options)=>{
268
287
  dockerOutputDir,
269
288
  iac,
270
289
  auth,
290
+ session,
271
291
  serverProtocol: infraProtocol,
272
292
  containers
273
293
  });
@@ -288,6 +308,7 @@ export const tsAgentGenerator = async (tree, options)=>{
288
308
  rc: agentNameClassName,
289
309
  auth,
290
310
  protocol,
311
+ session,
291
312
  ...iac ? {
292
313
  iac
293
314
  } : {}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/agent/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies';\nimport { addAgentChatScripts } from '../../utils/agent-chat/agent-chat';\nimport {\n AGENT_CONNECTION_DEPENDENCIES,\n addTypeScriptFrameworkBase,\n ensureTypeScriptAgentConnectionProject,\n} from '../../utils/agent-connection/agent-connection';\nimport { addAgentInfra } from '../../utils/agent-core-constructs/agent-core-constructs';\nimport {\n addTypeScriptBundleTarget,\n BUNDLE_DEPENDENCIES,\n} from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport {\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n nodeImageVersions,\n} from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { assignPort } from '../../utils/port';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs';\nimport type { IacMetadata } from '../../utils/shared-constructs-constants';\nimport { BASE_IMAGES, TS_VERSIONS, withVersions } from '../../utils/versions';\nimport type { TsAgentGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsAgentMetadata extends IacMetadata {\n readonly port: number;\n readonly rc: string;\n readonly auth: string;\n readonly protocol: string;\n}\n\n// Each entry names the branch it belongs to, so the same declaration drives both\n// adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsAgentMetadata>()({\n ts: [\n { name: 'zod' },\n { name: '@strands-agents/sdk' },\n { name: '@aws-sdk/credential-providers' },\n { name: '@aws-sdk/client-appconfigdata' },\n { name: '@aws-lambda-powertools/parameters' },\n { name: '@modelcontextprotocol/sdk' },\n { name: 'express', when: (m) => m.protocol !== 'http' },\n { name: '@a2a-js/sdk', when: (m) => m.protocol === 'a2a' },\n { name: '@ag-ui/aws-strands', when: (m) => m.protocol === 'ag-ui' },\n // @ag-ui/aws-strands declares these as peer dependencies but statically\n // imports them, so they must be installed for the bundler to inline them.\n { name: '@ag-ui/a2ui-toolkit', when: (m) => m.protocol === 'ag-ui' },\n { name: '@ag-ui/client', when: (m) => m.protocol === 'ag-ui' },\n { name: '@ag-ui/core', when: (m) => m.protocol === 'ag-ui' },\n { name: '@ag-ui/encoder', when: (m) => m.protocol === 'ag-ui' },\n { name: '@trpc/server', when: (m) => m.protocol === 'http' },\n { name: '@trpc/client', when: (m) => m.protocol === 'http' },\n { name: 'ws', when: (m) => m.protocol === 'http' },\n { name: 'cors', when: (m) => m.protocol !== 'a2a' },\n { name: 'aws4fetch', when: (m) => m.protocol === 'http' },\n { name: 'aws4fetch', when: (m) => m.auth === 'iam', dev: true },\n {\n name: '@aws-sdk/credential-providers',\n when: (m) => m.auth === 'iam',\n dev: true,\n },\n { name: '@types/node', dev: true },\n // The chat CLI runs standalone via tsx and resolves the deployed agent from\n // AppConfig when `RUNTIME_CONFIG_APP_ID` is set.\n { name: 'agent-chat-cli', dev: true },\n { name: '@aws-lambda-powertools/parameters', dev: true },\n { name: '@aws-sdk/client-appconfigdata', dev: true },\n // A2A chat builds a signed @a2a-js client factory for the deployed agent.\n { name: '@a2a-js/sdk', when: (m) => m.protocol === 'a2a', dev: true },\n { name: '@types/express', when: (m) => m.protocol !== 'http', dev: true },\n { name: '@types/ws', when: (m) => m.protocol === 'http', dev: true },\n { name: '@types/cors', dev: true },\n { name: 'tsx', dev: true, root: true },\n ...ownedElsewhere(AGENT_CONNECTION_DEPENDENCIES),\n ...ownedElsewhere(BUNDLE_DEPENDENCIES),\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n});\n\nexport const TS_AGENT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsAgentGenerator = async (\n tree: Tree,\n options: TsAgentGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n if (!tree.exists(joinPathFragments(project.root, 'tsconfig.json'))) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a TypeScript project (with a tsconfig.json)`,\n );\n }\n\n const defaultName = `${kebabCase(project.name.split('/').pop())}-agent`;\n const name = kebabCase(options.name || defaultName);\n const agentNameClassName = toClassName(name);\n const agentTargetPrefix = options.name ? name : 'agent';\n const targetSourceDirRelativeToProjectRoot = joinPathFragments(\n 'src',\n agentTargetPrefix,\n );\n const targetSourceDir = joinPathFragments(\n project.root,\n targetSourceDirRelativeToProjectRoot,\n );\n const relativeSourceDir = targetSourceDir.replace(project.root + '/', './');\n const distDir = joinPathFragments('dist', project.root);\n\n const infra = options.infra ?? 'agentcore';\n const protocol = options.protocol ?? 'http';\n\n // Recorded in the metadata below so the version sync can tell a CDK\n // project from a Terraform one; undefined when no infrastructure was\n // generated, in which case neither provider's packages were added.\n const iac =\n infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n if (infra === 'none' && options.auth && options.auth !== 'iam') {\n console.warn(\n 'Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)',\n );\n }\n\n const auth = options.auth ?? 'iam';\n\n // Ensure the shared agent-connection project exists so the server entry\n // point can import `runWithSessionId` and propagate the AgentCore session\n // ID to any downstream MCP / A2A clients a later connection generator\n // wires into this agent.\n await ensureTypeScriptAgentConnectionProject(tree, DEPENDENCIES);\n // The agent server imports the framework base helpers (session cache + model\n // error logging) regardless of whether a connection client is wired in.\n await addTypeScriptFrameworkBase(tree, DEPENDENCIES);\n\n const templateContext = {\n name,\n agentNameClassName,\n distDir,\n agentConnectionImport: `@${getNpmScope(tree)}/agent-connection`,\n ...esmVars(tree),\n };\n\n // Generate common files shared by both protocols\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'common'),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Generate protocol-specific files\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', protocol.toLowerCase()),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n if (infra === 'agentcore') {\n const containers = await resolveContainers(tree, 'inherit');\n const dockerImageTag = `${getNpmScope(tree)}-${name}:latest`;\n\n // Add bundle target\n await addTypeScriptBundleTarget(\n tree,\n project,\n {\n targetFilePath: `${targetSourceDirRelativeToProjectRoot}/index.ts`,\n bundleOutputDir: joinPathFragments('agent', name),\n },\n DEPENDENCIES,\n );\n\n // Add the Dockerfile\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'deploy'),\n targetSourceDir,\n {\n distDir,\n name,\n protocol,\n adotVersion:\n TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'],\n jaegerVersion: TS_VERSIONS['@opentelemetry/propagator-jaeger'],\n nodeBaseImage: BASE_IMAGES.node,\n ...nodeImageVersions(),\n ...esmVars(tree),\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'bundle',\n 'agent',\n name,\n );\n const dockerTargetName = `${agentTargetPrefix}-docker`;\n\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: true,\n outputs: [`{workspaceRoot}/${dockerOutputDir}/Dockerfile`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.cp(\n `${targetSourceDir}/Dockerfile`,\n `${dockerOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: ['bundle'],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project,\n containerEngine: containers,\n trivyTargetName: `${agentTargetPrefix}-trivy`,\n dockerTargetName,\n imageTags: [dockerImageTag],\n },\n DEPENDENCIES,\n );\n\n // Add shared constructs\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n\n // AG-UI uses HTTP as the AgentCore protocol type (AG-UI is HTTP-based with SSE over POST).\n const infraProtocol: 'http' | 'a2a' =\n protocol === 'ag-ui' ? 'http' : (protocol as 'http' | 'a2a');\n\n await addAgentInfra(tree, {\n agentNameKebabCase: name,\n agentNameClassName,\n projectName: project.name,\n dockerImageTag,\n dockerOutputDir,\n iac,\n auth,\n serverProtocol: infraProtocol,\n containers,\n });\n }\n\n // A2A servers use port 9000 as per the Strands A2A SDK default and AgentCore A2A contract.\n // HTTP and AG-UI agents use port 8081+ to avoid conflict with VS Code server on 8080.\n const localDevPortStart = protocol === 'a2a' ? 9000 : 8081;\n const localDevPort = assignPort(tree, project, localDevPortStart, {\n component: { info: TS_AGENT_GENERATOR_INFO, name: agentTargetPrefix },\n });\n\n // Recorded below and read by the declaration's predicates, so the packages\n // added here are exactly the ones the version sync will own.\n const metadata: TsAgentMetadata = {\n port: localDevPort,\n rc: agentNameClassName,\n auth,\n protocol,\n ...(iac ? { iac } : {}),\n };\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: project.root,\n });\n\n // Every protocol gets a standalone `chat.ts`. It connects to the local\n // `dev` server by default, or to the deployed agent (with the\n // appropriate auth) when `RUNTIME_CONFIG_APP_ID` is set.\n const scriptsDir = joinPathFragments(\n project.root,\n 'scripts',\n agentTargetPrefix,\n );\n addAgentChatScripts(tree, {\n scriptsDir,\n protocol,\n language: 'ts',\n agentNameClassName,\n auth,\n relativeAgentImport: `../../${targetSourceDirRelativeToProjectRoot}`,\n });\n\n const chatUrl =\n protocol === 'http'\n ? `ws://localhost:${localDevPort}/ws`\n : protocol === 'ag-ui'\n ? `http://localhost:${localDevPort}/invocations`\n : `http://localhost:${localDevPort}`;\n const chatCommand = `tsx ./scripts/${agentTargetPrefix}/chat.ts`;\n\n const agentTargets = {\n ...project.targets,\n [`${agentTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/index.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n },\n },\n },\n [`${agentTargetPrefix}-dev`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/index.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n [`${agentTargetPrefix}-chat`]: {\n executor: 'nx:run-commands',\n options: {\n commands: [chatCommand],\n cwd: '{projectRoot}',\n env: {\n URL: chatUrl,\n },\n },\n },\n };\n\n // Aggregate `<agent>-dev` under the project-level `dev` target.\n addComponentDevTarget(agentTargets, `${agentTargetPrefix}-dev`);\n\n updateProjectConfiguration(tree, project.name, {\n ...project,\n // Sort targets so their order is stable regardless of insertion order on\n // first run vs re-run.\n targets: sortObjectKeys(agentTargets),\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n TS_AGENT_GENERATOR_INFO,\n targetSourceDirRelativeToProjectRoot,\n agentTargetPrefix,\n metadata,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_AGENT_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsAgentGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addTsDependencies","addAgentChatScripts","AGENT_CONNECTION_DEPENDENCIES","addTypeScriptFrameworkBase","ensureTypeScriptAgentConnectionProject","addAgentInfra","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","nodeImageVersions","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","toClassName","getNpmScope","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","assignPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","BASE_IMAGES","TS_VERSIONS","DEPENDENCIES","ts","name","when","m","protocol","auth","dev","root","TS_AGENT_GENERATOR_INFO","filename","tsAgentGenerator","tree","options","project","exists","Error","defaultName","split","pop","agentNameClassName","agentTargetPrefix","targetSourceDirRelativeToProjectRoot","targetSourceDir","relativeSourceDir","replace","distDir","infra","iac","undefined","console","warn","templateContext","agentConnectionImport","dirname","overwriteStrategy","KeepExisting","toLowerCase","containers","dockerImageTag","targetFilePath","bundleOutputDir","adotVersion","jaegerVersion","nodeBaseImage","node","dockerOutputDir","dockerTargetName","fs","targets","cache","outputs","executor","commands","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","infraProtocol","agentNameKebabCase","projectName","serverProtocol","localDevPortStart","localDevPort","component","info","metadata","port","rc","projectRoot","scriptsDir","language","relativeAgentImport","chatUrl","chatCommand","agentTargets","continuous","cwd","env","PORT","LOCAL_DEV","URL","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAA+B;AACjE,SAASC,mBAAmB,QAAQ,uCAAoC;AACxE,SACEC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,sCAAsC,QACjC,mDAAgD;AACvD,SAASC,aAAa,QAAQ,6DAA0D;AACxF,SACEC,yBAAyB,EACzBC,mBAAmB,QACd,+BAA4B;AACnC,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAoC;AAC3C,SACEC,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,QACZ,wBAAqB;AAC5B,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAiB;AAC7D,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ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,GAAGY,OAAO;QACV,yEAAyE;QACzE,uBAAuB;QACvBmC,SAASvD,eAAemF;IAC1B;IAEAvF,8BACEsB,MACAE,QAAQZ,IAAI,EACZO,yBACAa,sCACAD,mBACA+C;IAGF,MAAMpF,gCAAgC4B,MAAM;QAACH;KAAwB;IAErE,MAAM9B,qBAAqBiC;IAC3B,OAAO,IACL7B,oBAAoB6B,MAAMC,QAAQuE,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe1E,iBAAiB"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/agent/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies';\nimport { addAgentChatScripts } from '../../utils/agent-chat/agent-chat';\nimport {\n AGENT_CONNECTION_DEPENDENCIES,\n addTypeScriptFrameworkBase,\n ensureTypeScriptAgentConnectionProject,\n} from '../../utils/agent-connection/agent-connection';\nimport { addAgentInfra } from '../../utils/agent-core-constructs/agent-core-constructs';\nimport {\n addTypeScriptBundleTarget,\n BUNDLE_DEPENDENCIES,\n} from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport {\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n nodeImageVersions,\n} from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths';\nimport { assignPort } from '../../utils/port';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs';\nimport type { IacMetadata } from '../../utils/shared-constructs-constants';\nimport { BASE_IMAGES, TS_VERSIONS } from '../../utils/versions';\nimport type { TsAgentGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsAgentMetadata extends IacMetadata {\n readonly port: number;\n readonly rc: string;\n readonly auth: string;\n readonly protocol: string;\n readonly session: string;\n}\n\n// Each entry names the branch it belongs to, so the same declaration drives both\n// adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsAgentMetadata>()({\n ts: [\n { name: 'zod' },\n { name: '@strands-agents/sdk' },\n { name: '@aws-sdk/credential-providers' },\n { name: '@aws-sdk/client-appconfigdata' },\n { name: '@aws-lambda-powertools/parameters' },\n { name: '@modelcontextprotocol/sdk' },\n { name: '@aws-sdk/client-s3', when: (m) => m.session === 's3' },\n { name: 'express', when: (m) => m.protocol !== 'http' },\n { name: '@a2a-js/sdk', when: (m) => m.protocol === 'a2a' },\n { name: '@ag-ui/aws-strands', when: (m) => m.protocol === 'ag-ui' },\n // @ag-ui/aws-strands declares these as peer dependencies but statically\n // imports them, so they must be installed for the bundler to inline them.\n { name: '@ag-ui/a2ui-toolkit', when: (m) => m.protocol === 'ag-ui' },\n { name: '@ag-ui/client', when: (m) => m.protocol === 'ag-ui' },\n { name: '@ag-ui/core', when: (m) => m.protocol === 'ag-ui' },\n { name: '@ag-ui/encoder', when: (m) => m.protocol === 'ag-ui' },\n { name: '@trpc/server', when: (m) => m.protocol === 'http' },\n { name: '@trpc/client', when: (m) => m.protocol === 'http' },\n { name: 'ws', when: (m) => m.protocol === 'http' },\n { name: 'cors', when: (m) => m.protocol !== 'a2a' },\n { name: 'aws4fetch', when: (m) => m.protocol === 'http' },\n { name: 'aws4fetch', when: (m) => m.auth === 'iam', dev: true },\n {\n name: '@aws-sdk/credential-providers',\n when: (m) => m.auth === 'iam',\n dev: true,\n },\n { name: '@types/node', dev: true },\n // The chat CLI runs standalone via tsx and resolves the deployed agent from\n // AppConfig when `RUNTIME_CONFIG_APP_ID` is set.\n { name: 'agent-chat-cli', dev: true },\n { name: '@aws-lambda-powertools/parameters', dev: true },\n { name: '@aws-sdk/client-appconfigdata', dev: true },\n // A2A chat builds a signed @a2a-js client factory for the deployed agent.\n { name: '@a2a-js/sdk', when: (m) => m.protocol === 'a2a', dev: true },\n { name: '@types/express', when: (m) => m.protocol !== 'http', dev: true },\n { name: '@types/ws', when: (m) => m.protocol === 'http', dev: true },\n { name: '@types/cors', dev: true },\n { name: 'tsx', dev: true, root: true },\n ...ownedElsewhere(AGENT_CONNECTION_DEPENDENCIES),\n ...ownedElsewhere(BUNDLE_DEPENDENCIES),\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n});\n\nexport const TS_AGENT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsAgentGenerator = async (\n tree: Tree,\n options: TsAgentGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n if (!tree.exists(joinPathFragments(project.root, 'tsconfig.json'))) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a TypeScript project (with a tsconfig.json)`,\n );\n }\n\n const defaultName = `${kebabCase(project.name.split('/').pop())}-agent`;\n const name = kebabCase(options.name || defaultName);\n const agentNameClassName = toClassName(name);\n const agentTargetPrefix = options.name ? name : 'agent';\n const targetSourceDirRelativeToProjectRoot = joinPathFragments(\n 'src',\n agentTargetPrefix,\n );\n const targetSourceDir = joinPathFragments(\n project.root,\n targetSourceDirRelativeToProjectRoot,\n );\n const relativeSourceDir = targetSourceDir.replace(project.root + '/', './');\n const distDir = joinPathFragments('dist', project.root);\n\n const infra = options.infra ?? 'agentcore';\n const protocol = options.protocol ?? 'http';\n\n // Recorded in the metadata below so the version sync can tell a CDK\n // project from a Terraform one; undefined when no infrastructure was\n // generated, in which case neither provider's packages were added.\n const iac =\n infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n if (infra === 'none' && options.auth && options.auth !== 'iam') {\n console.warn(\n 'Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)',\n );\n }\n\n const auth = options.auth ?? 'iam';\n\n const session = options.session ?? 's3';\n\n if (infra === 'none' && session !== 'in-memory') {\n console.warn(\n 'Warning: session is ignored when no infrastructure is configured (no infrastructure is generated)',\n );\n }\n\n // Local-dev session storage lives at the workspace root\n // (`tmp/agents/strands/<agent-name>`), not inside the project, so each agent\n // gets its own storage directory. The `-dev`/`-serve` targets run with\n // cwd={projectRoot}, so compute that directory relative to the project root\n // here rather than resolving it at runtime (e.g. via import.meta.url),\n // which would need an extra runtime helper.\n const localSessionsDir = joinPathFragments(\n getRelativePathToRootByDirectory(project.root),\n `tmp/agents/strands/${name}`,\n );\n\n // Ensure the shared agent-connection project exists so the server entry\n // point can import `runWithSessionId` and propagate the AgentCore session\n // ID to any downstream MCP / A2A clients a later connection generator\n // wires into this agent.\n await ensureTypeScriptAgentConnectionProject(tree, DEPENDENCIES);\n // The agent server imports the framework base helpers (session cache + model\n // error logging) regardless of whether a connection client is wired in.\n await addTypeScriptFrameworkBase(tree, DEPENDENCIES);\n\n const templateContext = {\n name,\n agentNameClassName,\n distDir,\n protocol,\n session,\n localSessionsDir,\n agentConnectionImport: `@${getNpmScope(tree)}/agent-connection`,\n ...esmVars(tree),\n };\n\n // Generate common files shared by both protocols\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'common'),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Generate protocol-specific files\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', protocol.toLowerCase()),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n if (infra === 'agentcore') {\n const containers = await resolveContainers(tree, 'inherit');\n const dockerImageTag = `${getNpmScope(tree)}-${name}:latest`;\n\n // Add bundle target\n await addTypeScriptBundleTarget(\n tree,\n project,\n {\n targetFilePath: `${targetSourceDirRelativeToProjectRoot}/index.ts`,\n bundleOutputDir: joinPathFragments('agent', name),\n },\n DEPENDENCIES,\n );\n\n // Add the Dockerfile\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'deploy'),\n targetSourceDir,\n {\n distDir,\n name,\n protocol,\n adotVersion:\n TS_VERSIONS['@aws/aws-distro-opentelemetry-node-autoinstrumentation'],\n jaegerVersion: TS_VERSIONS['@opentelemetry/propagator-jaeger'],\n nodeBaseImage: BASE_IMAGES.node,\n ...nodeImageVersions(),\n ...esmVars(tree),\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'bundle',\n 'agent',\n name,\n );\n const dockerTargetName = `${agentTargetPrefix}-docker`;\n\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: true,\n outputs: [`{workspaceRoot}/${dockerOutputDir}/Dockerfile`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.cp(\n `${targetSourceDir}/Dockerfile`,\n `${dockerOutputDir}/Dockerfile`,\n ),\n `${containers} build --platform linux/arm64 -t ${dockerImageTag} ${dockerOutputDir}`,\n ],\n parallel: false,\n },\n dependsOn: ['bundle'],\n };\n\n addDependencyToTargetIfNotPresent(project, 'docker', dockerTargetName);\n addDependencyToTargetIfNotPresent(project, 'build', 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project,\n containerEngine: containers,\n trivyTargetName: `${agentTargetPrefix}-trivy`,\n dockerTargetName,\n imageTags: [dockerImageTag],\n },\n DEPENDENCIES,\n );\n\n // Add shared constructs\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n\n // AG-UI uses HTTP as the AgentCore protocol type (AG-UI is HTTP-based with SSE over POST).\n const infraProtocol: 'http' | 'a2a' =\n protocol === 'ag-ui' ? 'http' : (protocol as 'http' | 'a2a');\n\n await addAgentInfra(tree, {\n agentNameKebabCase: name,\n agentNameClassName,\n projectName: project.name,\n dockerImageTag,\n dockerOutputDir,\n iac,\n auth,\n session,\n serverProtocol: infraProtocol,\n containers,\n });\n }\n\n // A2A servers use port 9000 as per the Strands A2A SDK default and AgentCore A2A contract.\n // HTTP and AG-UI agents use port 8081+ to avoid conflict with VS Code server on 8080.\n const localDevPortStart = protocol === 'a2a' ? 9000 : 8081;\n const localDevPort = assignPort(tree, project, localDevPortStart, {\n component: { info: TS_AGENT_GENERATOR_INFO, name: agentTargetPrefix },\n });\n\n // Recorded below and read by the declaration's predicates, so the packages\n // added here are exactly the ones the version sync will own.\n const metadata: TsAgentMetadata = {\n port: localDevPort,\n rc: agentNameClassName,\n auth,\n protocol,\n session,\n ...(iac ? { iac } : {}),\n };\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: project.root,\n });\n\n // Every protocol gets a standalone `chat.ts`. It connects to the local\n // `dev` server by default, or to the deployed agent (with the\n // appropriate auth) when `RUNTIME_CONFIG_APP_ID` is set.\n const scriptsDir = joinPathFragments(\n project.root,\n 'scripts',\n agentTargetPrefix,\n );\n addAgentChatScripts(tree, {\n scriptsDir,\n protocol,\n language: 'ts',\n agentNameClassName,\n auth,\n relativeAgentImport: `../../${targetSourceDirRelativeToProjectRoot}`,\n });\n\n const chatUrl =\n protocol === 'http'\n ? `ws://localhost:${localDevPort}/ws`\n : protocol === 'ag-ui'\n ? `http://localhost:${localDevPort}/invocations`\n : `http://localhost:${localDevPort}`;\n const chatCommand = `tsx ./scripts/${agentTargetPrefix}/chat.ts`;\n\n const agentTargets = {\n ...project.targets,\n [`${agentTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/index.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n },\n },\n },\n [`${agentTargetPrefix}-dev`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [`tsx --watch ${relativeSourceDir}/index.ts`],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n [`${agentTargetPrefix}-chat`]: {\n executor: 'nx:run-commands',\n options: {\n commands: [chatCommand],\n cwd: '{projectRoot}',\n env: {\n URL: chatUrl,\n },\n },\n },\n };\n\n // Aggregate `<agent>-dev` under the project-level `dev` target.\n addComponentDevTarget(agentTargets, `${agentTargetPrefix}-dev`);\n\n updateProjectConfiguration(tree, project.name, {\n ...project,\n // Sort targets so their order is stable regardless of insertion order on\n // first run vs re-run.\n targets: sortObjectKeys(agentTargets),\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n TS_AGENT_GENERATOR_INFO,\n targetSourceDirRelativeToProjectRoot,\n agentTargetPrefix,\n metadata,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_AGENT_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsAgentGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","addTsDependencies","addAgentChatScripts","AGENT_CONNECTION_DEPENDENCIES","addTypeScriptFrameworkBase","ensureTypeScriptAgentConnectionProject","addAgentInfra","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","nodeImageVersions","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","toClassName","getNpmScope","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","getRelativePathToRootByDirectory","assignPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","BASE_IMAGES","TS_VERSIONS","DEPENDENCIES","ts","name","when","m","session","protocol","auth","dev","root","TS_AGENT_GENERATOR_INFO","filename","tsAgentGenerator","tree","options","project","exists","Error","defaultName","split","pop","agentNameClassName","agentTargetPrefix","targetSourceDirRelativeToProjectRoot","targetSourceDir","relativeSourceDir","replace","distDir","infra","iac","undefined","console","warn","localSessionsDir","templateContext","agentConnectionImport","dirname","overwriteStrategy","KeepExisting","toLowerCase","containers","dockerImageTag","targetFilePath","bundleOutputDir","adotVersion","jaegerVersion","nodeBaseImage","node","dockerOutputDir","dockerTargetName","fs","targets","cache","outputs","executor","commands","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","infraProtocol","agentNameKebabCase","projectName","serverProtocol","localDevPortStart","localDevPort","component","info","metadata","port","rc","projectRoot","scriptsDir","language","relativeAgentImport","chatUrl","chatCommand","agentTargets","continuous","cwd","env","PORT","LOCAL_DEV","URL","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAA+B;AACjE,SAASC,mBAAmB,QAAQ,uCAAoC;AACxE,SACEC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,sCAAsC,QACjC,mDAAgD;AACvD,SAASC,aAAa,QAAQ,6DAA0D;AACxF,SACEC,yBAAyB,EACzBC,mBAAmB,QACd,+BAA4B;AAC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AClB,CAAC,GAAG7B,kBAAkB,MAAM,CAAC,CAAC,EAAE;YAC9BgC,UAAU;YACV0B,YAAY;YACZlE,SAAS;gBACPyC,UAAU;oBAAC,CAAC,YAAY,EAAE9B,kBAAkB,SAAS,CAAC;iBAAC;gBACvDwD,KAAK;gBACLC,KAAK;oBACHC,MAAM,GAAGhB,cAAc;gBACzB;YACF;QACF;QACA,CAAC,GAAG7C,kBAAkB,IAAI,CAAC,CAAC,EAAE;YAC5BgC,UAAU;YACV0B,YAAY;YACZlE,SAAS;gBACPyC,UAAU;oBAAC,CAAC,YAAY,EAAE9B,kBAAkB,SAAS,CAAC;iBAAC;gBACvDwD,KAAK;gBACLC,KAAK;oBACHC,MAAM,GAAGhB,cAAc;oBACvBiB,WAAW;gBACb;YACF;QACF;QACA,CAAC,GAAG9D,kBAAkB,KAAK,CAAC,CAAC,EAAE;YAC7BgC,UAAU;YACVxC,SAAS;gBACPyC,UAAU;oBAACuB;iBAAY;gBACvBG,KAAK;gBACLC,KAAK;oBACHG,KAAKR;gBACP;YACF;QACF;IACF;IAEA,gEAAgE;IAChEzF,sBAAsB2F,cAAc,GAAGzD,kBAAkB,IAAI,CAAC;IAE9D3D,2BAA2BkD,MAAME,QAAQb,IAAI,EAAE;QAC7C,GAAGa,OAAO;QACV,yEAAyE;QACzE,uBAAuB;QACvBoC,SAAS1D,eAAesF;IAC1B;IAEA1F,8BACEwB,MACAE,QAAQb,IAAI,EACZQ,yBACAa,sCACAD,mBACAgD;IAGF,MAAMvF,gCAAgC8B,MAAM;QAACH;KAAwB;IAErE,MAAMhC,qBAAqBmC;IAC3B,OAAO,IACL/B,oBAAoB+B,MAAMC,QAAQwE,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe3E,iBAAiB"}
@@ -5,6 +5,7 @@ exports[`ts#agent#mcp-connection generator > should match snapshot for agent-con
5
5
  export * from './core/tool-errors-strands.js';
6
6
  export * from './core/model-errors-strands.js';
7
7
  export * from './core/with-session-id-strands.js';
8
+ export * from './core/runtime-config.js';
8
9
  export * from './core/session-context.js';
9
10
  // Export your library code here
10
11
  "
@@ -231,7 +232,7 @@ export class InventoryMcpClientStrands {
231
232
  });
232
233
  }
233
234
  const config = await getAgentCoreRuntimeConfig();
234
- const agentRuntimeArn = config.agentRuntimes?.['InventoryMcp'];
235
+ const agentRuntimeArn = config.agentRuntimes?.['InventoryMcp']?.arn;
235
236
  if (!agentRuntimeArn) {
236
237
  throw new Error(
237
238
  \`No connected MCP server runtime named 'InventoryMcp' found in runtime configuration.\`,
@@ -11,7 +11,8 @@ export class <%- mcpServerClassName %>ClientStrands {
11
11
  });
12
12
  }
13
13
  const config = await getAgentCoreRuntimeConfig();
14
- const agentRuntimeArn = config.agentRuntimes?.['<%- mcpServerClassName %>'];
14
+ const agentRuntimeArn =
15
+ config.agentRuntimes?.['<%- mcpServerClassName %>']?.arn;
15
16
  if (!agentRuntimeArn) {
16
17
  throw new Error(
17
18
  `No connected MCP server runtime named '<%- mcpServerClassName %>' found in runtime configuration.`,
@@ -39,7 +39,8 @@ export const TestAgentAgentClientProvider: FC<PropsWithChildren> = ({
39
39
  const sigv4Client = useSigV4();
40
40
 
41
41
  const container = useMemo<TestAgentAgentTRPCContextValue>(() => {
42
- // If the value is an ARN, convert it to a WebSocket URL
42
+ // A local-dev override is a plain URL; otherwise it's the agent's
43
+ // runtime ARN, so build a WebSocket URL from it.
43
44
  const wsUrl = agentRuntimeValue.startsWith('arn:')
44
45
  ? buildAgentCoreWsUrl(agentRuntimeValue)
45
46
  : agentRuntimeValue;
@@ -155,7 +156,8 @@ export const TestAgentAgentClientProvider: FC<PropsWithChildren> = ({
155
156
  const accessToken = auth?.user?.access_token;
156
157
 
157
158
  const container = useMemo<TestAgentAgentTRPCContextValue>(() => {
158
- // If the value is an ARN, convert it to a WebSocket URL
159
+ // A local-dev override is a plain URL; otherwise it's the agent's
160
+ // runtime ARN, so build a WebSocket URL from it.
159
161
  const wsUrl = agentRuntimeValue.startsWith('arn:')
160
162
  ? buildAgentCoreWsUrl(agentRuntimeValue)
161
163
  : agentRuntimeValue;
@@ -245,7 +247,8 @@ export const TestAgentAgentClientProvider: FC<PropsWithChildren> = ({
245
247
  const sigv4Client = useSigV4();
246
248
 
247
249
  const container = useMemo<TestAgentAgentTRPCContextValue>(() => {
248
- // If the value is an ARN, convert it to a WebSocket URL
250
+ // A local-dev override is a plain URL; otherwise it's the agent's
251
+ // runtime ARN, so build a WebSocket URL from it.
249
252
  const wsUrl = agentRuntimeValue.startsWith('arn:')
250
253
  ? buildAgentCoreWsUrl(agentRuntimeValue)
251
254
  : agentRuntimeValue;
@@ -320,7 +323,8 @@ export const TestAgentAgentClientProvider: FC<PropsWithChildren> = ({
320
323
  const agentRuntimeValue = runtimeConfig.agentRuntimes.TestAgent;
321
324
 
322
325
  const container = useMemo<TestAgentAgentTRPCContextValue>(() => {
323
- // If the value is an ARN, convert it to a WebSocket URL
326
+ // A local-dev override is a plain URL; otherwise it's the agent's
327
+ // runtime ARN, so build a WebSocket URL from it.
324
328
  const wsUrl = agentRuntimeValue.startsWith('arn:')
325
329
  ? buildAgentCoreWsUrl(agentRuntimeValue)
326
330
  : agentRuntimeValue;
@@ -51,7 +51,8 @@ export const <%= agentNameClassName %>AgentClientProvider: FC<PropsWithChildren>
51
51
  <%_ } _%>
52
52
 
53
53
  const container = useMemo<<%= agentNameClassName %>AgentTRPCContextValue>(() => {
54
- // If the value is an ARN, convert it to a WebSocket URL
54
+ // A local-dev override is a plain URL; otherwise it's the agent's
55
+ // runtime ARN, so build a WebSocket URL from it.
55
56
  const wsUrl = agentRuntimeValue.startsWith('arn:')
56
57
  ? buildAgentCoreWsUrl(agentRuntimeValue)
57
58
  : agentRuntimeValue;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/agent/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac';\n\nexport type TsAgentFramework = 'strands';\nexport type TsAgentInfra = 'agentcore' | 'none';\nexport type AgentProtocol = 'http' | 'a2a' | 'ag-ui';\n\nexport type TsAgentAuth = 'iam' | 'cognito';\n\nexport interface TsAgentGeneratorSchema {\n project: string;\n framework?: TsAgentFramework;\n name?: string;\n infra?: TsAgentInfra;\n auth?: TsAgentAuth;\n protocol?: AgentProtocol;\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAUD,WASC"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/agent/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { IacOption } from '../../utils/iac';\n\nexport type TsAgentFramework = 'strands';\nexport type TsAgentInfra = 'agentcore' | 'none';\nexport type AgentProtocol = 'http' | 'a2a' | 'ag-ui';\n\nexport type TsAgentAuth = 'iam' | 'cognito';\n\nexport type TsAgentSession = 's3' | 'in-memory';\n\nexport interface TsAgentGeneratorSchema {\n project: string;\n framework?: TsAgentFramework;\n name?: string;\n infra?: TsAgentInfra;\n auth?: TsAgentAuth;\n protocol?: AgentProtocol;\n session?: TsAgentSession;\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAYD,WAUC"}
@@ -11,6 +11,8 @@ export type AgentProtocol = 'http' | 'a2a' | 'ag-ui';
11
11
 
12
12
  export type TsAgentAuth = 'iam' | 'cognito';
13
13
 
14
+ export type TsAgentSession = 's3' | 'in-memory';
15
+
14
16
  export interface TsAgentGeneratorSchema {
15
17
  project: string;
16
18
  framework?: TsAgentFramework;
@@ -18,6 +20,7 @@ export interface TsAgentGeneratorSchema {
18
20
  infra?: TsAgentInfra;
19
21
  auth?: TsAgentAuth;
20
22
  protocol?: AgentProtocol;
23
+ session?: TsAgentSession;
21
24
  iac: IacOption;
22
25
  preferInstallDependencies?: boolean;
23
26
  }
@@ -60,6 +60,14 @@
60
60
  "default": "agentcore",
61
61
  "x-priority": "important"
62
62
  },
63
+ "session": {
64
+ "type": "string",
65
+ "description": "The storage used to persist session for your Agent.",
66
+ "x-prompt": "How would you like to persist session for your Agent?",
67
+ "enum": ["s3", "in-memory"],
68
+ "default": "s3",
69
+ "x-priority": "important"
70
+ },
63
71
  "preferInstallDependencies": {
64
72
  "type": "boolean",
65
73
  "description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
@@ -565,7 +565,6 @@ for (;;) {
565
565
  './data',
566
566
  '-port',
567
567
  \`\${port}\`,
568
- '-optimizeDbBeforeStartup',
569
568
  ];
570
569
  const create = spawnSync(containerEngine, runArgs, { stdio: 'pipe' });
571
570
  if (create.status === 0) {
@@ -1213,7 +1212,6 @@ for (;;) {
1213
1212
  './data',
1214
1213
  '-port',
1215
1214
  \`\${port}\`,
1216
- '-optimizeDbBeforeStartup',
1217
1215
  ];
1218
1216
  const create = spawnSync(containerEngine, runArgs, { stdio: 'pipe' });
1219
1217
  if (create.status === 0) {
@@ -85,7 +85,9 @@ export class SnapshotBedrockServer
85
85
 
86
86
  rc.set('agentcore', 'agentRuntimes', {
87
87
  ...rc.get('agentcore').agentRuntimes,
88
- SnapshotBedrockServer: this.agentCoreRuntime.agentRuntimeArn,
88
+ SnapshotBedrockServer: {
89
+ arn: this.agentCoreRuntime.agentRuntimeArn,
90
+ },
89
91
  });
90
92
  }
91
93
 
@@ -738,7 +740,7 @@ module "add_agent_runtime_to_runtime_config" {
738
740
 
739
741
  namespace = "agentcore"
740
742
  key = "agentRuntimes"
741
- value = { "TerraformSnapshotServer" = module.agent_core_runtime.agent_core_runtime_arn }
743
+ value = { "TerraformSnapshotServer" = { arn = module.agent_core_runtime.agent_core_runtime_arn } }
742
744
 
743
745
  depends_on = [module.agent_core_runtime]
744
746
  }
@@ -19,6 +19,8 @@ import { formatFilesInSubtree } from '<%- formatImportPath %>';
19
19
  * - Pattern-match before writing: skip files that have diverged from the shape
20
20
  * your generators produce, and report them via `agentContext` so the prompt
21
21
  * can pick them up, rather than clobbering the user's changes.
22
+ * - `nextSteps` is for work left for the user to do by hand, not a log of the
23
+ * edits you made: an edit that applied cleanly needs no entry.
22
24
  * - Idempotent: re-running must be a no-op.
23
25
  * - Format what you write: finish with `formatFilesInSubtree` so the files your
24
26
  * migration wrote are formatted correctly.
@@ -36,6 +38,8 @@ import { formatFilesInSubtree } from '<%- formatImportPath %>';
36
38
  * - Pattern-match before writing: skip files that have diverged from the shape
37
39
  * your generators produce and report them via `nextSteps`, or consider a
38
40
  * hybrid migration, rather than clobbering the user's changes.
41
+ * - `nextSteps` is for work left for the user to do by hand, not a log of the
42
+ * edits you made: an edit that applied cleanly needs no entry.
39
43
  * - Idempotent: re-running must be a no-op.
40
44
  * - Format what you write: finish with `formatFilesInSubtree` so the files your
41
45
  * migration wrote are formatted correctly.
@@ -30,8 +30,8 @@ export const resolveRemoteAgent = async (): Promise<
30
30
  application,
31
31
  environment: 'default',
32
32
  transform: 'json',
33
- })) as { agentRuntimes?: Record<string, string> };
34
- const arn = config?.agentRuntimes?.['<%- agentNameClassName %>'];
33
+ })) as { agentRuntimes?: Record<string, { arn: string }> };
34
+ const arn = config?.agentRuntimes?.['<%- agentNameClassName %>']?.arn;
35
35
  if (!arn) {
36
36
  throw new Error(
37
37
  `No deployed agent named '<%- agentNameClassName %>' found in runtime configuration (application ${application}).`,
@@ -255,6 +255,10 @@ const emitTs = (tree, templateDir, declaration)=>{
255
255
  // Re-export session-context helpers so agent server entry points can set the
256
256
  // current session on each inbound request without pulling in internals.
257
257
  await addStarExport(tree, joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'src', 'index.ts'), './core/session-context.js');
258
+ // Re-export the runtime-config loader so agent server entry points can read
259
+ // their own connected resources (e.g. session storage) without pulling in
260
+ // internals.
261
+ await addStarExport(tree, joinPathFragments(AGENT_CONNECTION_PROJECT_DIR, 'src', 'index.ts'), './core/runtime-config.js');
258
262
  }
259
263
  /**
260
264
  * Emit a framework's base Layer-2 helpers (model-error logging + per-session