@aws/nx-plugin 1.0.0-rc.71 → 1.0.0-rc.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +6 -1
- package/package.json +1 -1
- package/src/agentcore-harness/generator.d.ts +1 -1
- package/src/infra/app/generator.d.ts +1 -1
- package/src/init/generator.d.ts +1 -1
- package/src/license/dependency-check/evaluator.js +55 -10
- package/src/license/dependency-check/evaluator.js.map +1 -1
- package/src/migrations/latest/py-agent-session-management-support/metadata.json +3 -0
- package/src/migrations/latest/py-agent-session-management-support/migration.d.ts +2 -0
- package/src/migrations/latest/py-agent-session-management-support/migration.js +308 -0
- package/src/migrations/latest/py-agent-session-management-support/migration.js.map +1 -0
- package/src/preset/generator.d.ts +1 -1
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +615 -6
- package/src/py/agent/__snapshots__/generator.core.spec.ts.snap +186 -0
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +47 -3
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +667 -2
- package/src/py/agent/files/langchain/common/__init__.py.template +0 -0
- package/src/py/agent/files/langchain/common/agent.py.template +3 -3
- package/src/py/agent/files/langchain/common/session.py.template +61 -0
- package/src/py/agent/files/strands/ag-ui/main.py.template +5 -1
- package/src/py/agent/files/strands/common/agent.py.template +9 -2
- package/src/py/agent/files/strands/common/session.py.template +36 -0
- package/src/py/agent/generator.d.ts +11 -1
- package/src/py/agent/generator.js +78 -28
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/py/agent/react-connection/generator.d.ts +1 -1
- package/src/py/agent/schema.d.js.map +1 -1
- package/src/py/agent/schema.d.ts +1 -1
- package/src/py/agent/schema.json +3 -3
- package/src/py/fast-api/react/generator.d.ts +1 -1
- package/src/smithy/project/generator.d.ts +1 -1
- package/src/smithy/react-connection/generator.d.ts +1 -1
- package/src/terraform/project/generator.d.ts +1 -1
- package/src/trpc/react/generator.d.ts +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +27 -6
- package/src/ts/agent/a2a-connection/generator.d.ts +1 -1
- package/src/ts/agent/gateway-connection/generator.d.ts +1 -1
- package/src/ts/agent/mcp-connection/generator.d.ts +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +1 -1
- package/src/ts/astro-docs/generator.d.ts +1 -1
- package/src/ts/dcr-proxy/generator.d.ts +1 -1
- package/src/ts/dynamodb/generator.d.ts +1 -1
- package/src/ts/lambda-function/generator.d.ts +1 -1
- package/src/ts/lib/generator.d.ts +1 -1
- package/src/ts/nx-generator/generator.d.ts +1 -1
- package/src/ts/nx-migration/generator.d.ts +1 -1
- package/src/ts/nx-plugin/generator.d.ts +1 -1
- package/src/ts/rdb/generator.d.ts +1 -1
- package/src/ts/react-website/agui/generator.d.ts +1 -1
- package/src/utils/agent-connection/agent-connection.d.ts +10 -0
- package/src/utils/agent-connection/agent-connection.js +15 -0
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-runtime-config/runtime-config.ts.template +5 -3
- package/src/utils/agent-connection/files/py-core-langchain/s3/s3_checkpoint_saver_langchain.py.template +360 -0
- package/src/utils/agent-connection/files/py-core-runtime-config/runtime_config.py.template +2 -4
- package/src/utils/agent-connection/files/py-core-strands/base/tool_errors_strands.py.template +24 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +113 -13
- package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +76 -7
- package/src/utils/versions.d.ts +3 -0
- package/src/utils/versions.js +3 -0
- package/src/utils/versions.js.map +1 -1
|
@@ -3,7 +3,8 @@ import os
|
|
|
3
3
|
from langchain.agents import create_agent
|
|
4
4
|
from langchain_aws import ChatBedrockConverse
|
|
5
5
|
from langchain_core.tools import tool
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
from .session import get_checkpointer
|
|
7
8
|
|
|
8
9
|
REGION = os.environ.get("AWS_REGION", "us-east-1")
|
|
9
10
|
MODEL_ID = os.environ.get("MODEL_ID", "global.anthropic.claude-haiku-4-5-20251001-v1:0")
|
|
@@ -17,7 +18,6 @@ def subtract(a: int, b: int) -> int:
|
|
|
17
18
|
|
|
18
19
|
def get_agent():
|
|
19
20
|
model = ChatBedrockConverse(model=MODEL_ID, region_name=REGION)
|
|
20
|
-
# Swap InMemorySaver for a durable checkpointer in a multi-replica deployment.
|
|
21
21
|
return create_agent(
|
|
22
22
|
model=model,
|
|
23
23
|
tools=[subtract],
|
|
@@ -26,5 +26,5 @@ You are a mathematical wizard.
|
|
|
26
26
|
Use your tools for mathematical tasks.
|
|
27
27
|
Refer to tools as your 'spellbook'.
|
|
28
28
|
""",
|
|
29
|
-
checkpointer=
|
|
29
|
+
checkpointer=get_checkpointer(),
|
|
30
30
|
)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
<%_ if (session === 's3') { _%>
|
|
4
|
+
import boto3
|
|
5
|
+
<%_ } _%>
|
|
6
|
+
import aiosqlite
|
|
7
|
+
from langgraph.checkpoint.base import BaseCheckpointSaver
|
|
8
|
+
<%_ if (session === 'in-memory') { _%>
|
|
9
|
+
from langgraph.checkpoint.memory import InMemorySaver
|
|
10
|
+
<%_ } _%>
|
|
11
|
+
from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
|
|
12
|
+
<%_ if (session === 's3') { _%>
|
|
13
|
+
from <%- agentConnectionModuleName %>.core.s3_checkpoint_saver_langchain import S3CheckpointSaver
|
|
14
|
+
<%_ } else if (session === 'dynamodb-s3') { _%>
|
|
15
|
+
from langgraph_checkpoint_aws import DynamoDBSaver
|
|
16
|
+
<%_ } _%>
|
|
17
|
+
<%_ if (session === 's3' || session === 'dynamodb-s3') { _%>
|
|
18
|
+
from <%- agentConnectionModuleName %>.core.runtime_config import get_agentcore_runtime_config
|
|
19
|
+
<%_ } _%>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def get_checkpointer() -> BaseCheckpointSaver:
|
|
23
|
+
"""Returns a LangGraph checkpointer for persisting conversation state across
|
|
24
|
+
invocations. Local development always uses a local SQLite database for
|
|
25
|
+
convenience, regardless of the configured session option.
|
|
26
|
+
"""
|
|
27
|
+
if os.environ.get("LOCAL_DEV") == "true":
|
|
28
|
+
os.makedirs("<%- localSessionsDir %>", exist_ok=True)
|
|
29
|
+
conn = aiosqlite.connect(os.path.join("<%- localSessionsDir %>", "checkpoints.sqlite"))
|
|
30
|
+
return AsyncSqliteSaver(conn)
|
|
31
|
+
|
|
32
|
+
<%_ if (session === 's3') { _%>
|
|
33
|
+
config = get_agentcore_runtime_config()
|
|
34
|
+
session_config = (config.get("agentRuntimes") or {}).get("<%- agentNameClassName %>", {}).get("session", {})
|
|
35
|
+
bucket_name = session_config.get("bucketName")
|
|
36
|
+
if not bucket_name:
|
|
37
|
+
raise RuntimeError(
|
|
38
|
+
"No S3 checkpoint bucket configured for this agent in runtime configuration."
|
|
39
|
+
)
|
|
40
|
+
return S3CheckpointSaver(
|
|
41
|
+
bucket_name=bucket_name,
|
|
42
|
+
prefix="checkpoints/",
|
|
43
|
+
s3_client=boto3.client("s3"),
|
|
44
|
+
)
|
|
45
|
+
<%_ } else if (session === 'dynamodb-s3') { _%>
|
|
46
|
+
config = get_agentcore_runtime_config()
|
|
47
|
+
session_config = (config.get("agentRuntimes") or {}).get("<%- agentNameClassName %>", {}).get("session", {})
|
|
48
|
+
table_name = session_config.get("tableName")
|
|
49
|
+
bucket_name = session_config.get("bucketName")
|
|
50
|
+
if not table_name or not bucket_name:
|
|
51
|
+
raise RuntimeError(
|
|
52
|
+
"No DynamoDB checkpoint table or S3 offload bucket configured for this agent in runtime configuration."
|
|
53
|
+
)
|
|
54
|
+
return DynamoDBSaver(
|
|
55
|
+
table_name=table_name,
|
|
56
|
+
region_name=os.environ.get("AWS_REGION"),
|
|
57
|
+
s3_offload_config={"bucket_name": bucket_name},
|
|
58
|
+
)
|
|
59
|
+
<%_ } else { _%>
|
|
60
|
+
return InMemorySaver()
|
|
61
|
+
<%_ } _%>
|
|
@@ -4,7 +4,7 @@ from contextlib import asynccontextmanager
|
|
|
4
4
|
|
|
5
5
|
from ag_ui.core import EventType, RunAgentInput, RunErrorEvent
|
|
6
6
|
from ag_ui.encoder import EventEncoder
|
|
7
|
-
from ag_ui_strands import StrandsAgent
|
|
7
|
+
from ag_ui_strands import StrandsAgent, StrandsAgentConfig
|
|
8
8
|
from fastapi import FastAPI, Request
|
|
9
9
|
from fastapi.middleware.cors import CORSMiddleware
|
|
10
10
|
from fastapi.responses import StreamingResponse
|
|
@@ -12,6 +12,7 @@ from <%- agentConnectionModuleName %> import get_current_session_id, session_id_
|
|
|
12
12
|
from starlette.middleware.base import BaseHTTPMiddleware
|
|
13
13
|
|
|
14
14
|
from .agent import get_agent
|
|
15
|
+
from .session import get_session_manager
|
|
15
16
|
|
|
16
17
|
logging.basicConfig(level=logging.INFO)
|
|
17
18
|
|
|
@@ -25,6 +26,9 @@ async def lifespan(app: FastAPI):
|
|
|
25
26
|
agent=agent,
|
|
26
27
|
name="<%= agentNameClassName %>",
|
|
27
28
|
description="A Strands Agent exposed via the AG-UI protocol.",
|
|
29
|
+
# A per-thread session manager, not the template Agent's own, since
|
|
30
|
+
# AG-UI caches one Strands agent per thread_id.
|
|
31
|
+
config=StrandsAgentConfig(session_manager_provider=lambda _input_data: get_session_manager()),
|
|
28
32
|
)
|
|
29
33
|
yield
|
|
30
34
|
|
|
@@ -2,7 +2,11 @@ from contextlib import contextmanager
|
|
|
2
2
|
|
|
3
3
|
from strands import Agent, tool
|
|
4
4
|
from strands_tools import current_time
|
|
5
|
-
from <%- agentConnectionModuleName %> import log_model_errors
|
|
5
|
+
from <%- agentConnectionModuleName %> import log_model_errors, log_tool_errors
|
|
6
|
+
<%_ if (protocol !== 'ag-ui') { _%>
|
|
7
|
+
|
|
8
|
+
from .session import get_session_manager
|
|
9
|
+
<%_ } _%>
|
|
6
10
|
|
|
7
11
|
|
|
8
12
|
@tool
|
|
@@ -21,5 +25,8 @@ Use your tools for mathematical tasks.
|
|
|
21
25
|
Refer to tools as your 'spellbook'.
|
|
22
26
|
""",
|
|
23
27
|
tools=[subtract, current_time],
|
|
24
|
-
hooks=[log_model_errors],
|
|
28
|
+
hooks=[log_model_errors, log_tool_errors],
|
|
29
|
+
<%_ if (protocol !== 'ag-ui') { _%>
|
|
30
|
+
session_manager=get_session_manager(),
|
|
31
|
+
<%_ } _%>
|
|
25
32
|
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from strands.session import FileSessionManager, SessionManager<% if (session === 's3') { %>, S3SessionManager<% } %>
|
|
4
|
+
|
|
5
|
+
from <%- agentConnectionModuleName %> import get_current_session_id
|
|
6
|
+
<%_ if (session === 's3') { _%>
|
|
7
|
+
from <%- agentConnectionModuleName %>.core.runtime_config import get_agentcore_runtime_config
|
|
8
|
+
<%_ } _%>
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def get_session_manager() -> SessionManager | None:
|
|
12
|
+
"""Returns a SessionManager for persisting conversation state across
|
|
13
|
+
invocations. Local development always uses local file storage for
|
|
14
|
+
convenience, regardless of the configured session option. Without a
|
|
15
|
+
configured session option, conversation state is kept in memory only and
|
|
16
|
+
does not survive process restarts.
|
|
17
|
+
"""
|
|
18
|
+
session_id = get_current_session_id()
|
|
19
|
+
if not session_id:
|
|
20
|
+
raise RuntimeError(
|
|
21
|
+
"No current session id — cannot resolve a SessionManager outside of a request scope."
|
|
22
|
+
)
|
|
23
|
+
if os.environ.get("LOCAL_DEV") == "true":
|
|
24
|
+
return FileSessionManager(session_id=session_id, storage_dir="<%- localSessionsDir %>")
|
|
25
|
+
|
|
26
|
+
<%_ if (session === 's3') { _%>
|
|
27
|
+
config = get_agentcore_runtime_config()
|
|
28
|
+
bucket_name = (
|
|
29
|
+
(config.get("agentRuntimes") or {}).get("<%- agentNameClassName %>", {}).get("session", {}).get("bucketName")
|
|
30
|
+
)
|
|
31
|
+
if not bucket_name:
|
|
32
|
+
raise RuntimeError("No S3 bucket configured for this agent's session in runtime configuration.")
|
|
33
|
+
return S3SessionManager(session_id=session_id, bucket=bucket_name)
|
|
34
|
+
<%_ } else { _%>
|
|
35
|
+
return None
|
|
36
|
+
<%_ } _%>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
6
|
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
7
7
|
import type { IacMetadata } from '../../utils/shared-constructs-constants';
|
|
8
|
-
import type { AgentProtocol, PyAgentFramework, PyAgentGeneratorSchema } from './schema';
|
|
8
|
+
import type { AgentProtocol, PyAgentFramework, PyAgentGeneratorSchema, PyAgentSession } from './schema';
|
|
9
9
|
/** The metadata this generator records, which its predicates read. */
|
|
10
10
|
export interface PyAgentMetadata extends IacMetadata {
|
|
11
11
|
readonly port: number;
|
|
@@ -17,6 +17,7 @@ export interface PyAgentMetadata extends IacMetadata {
|
|
|
17
17
|
* Strands vs LangChain Layer-2 client + agent.py transform.
|
|
18
18
|
*/
|
|
19
19
|
readonly framework: PyAgentFramework;
|
|
20
|
+
readonly session: PyAgentSession;
|
|
20
21
|
}
|
|
21
22
|
export declare const DEPENDENCIES: import("../../utils/declared-dependencies").DependencyDeclaration<readonly [{
|
|
22
23
|
readonly name: "agent-chat-cli";
|
|
@@ -120,6 +121,15 @@ export declare const DEPENDENCIES: import("../../utils/declared-dependencies").D
|
|
|
120
121
|
}, {
|
|
121
122
|
readonly name: "langgraph";
|
|
122
123
|
readonly when: (m: PyAgentMetadata) => boolean;
|
|
124
|
+
}, {
|
|
125
|
+
readonly name: "langgraph-checkpoint-sqlite";
|
|
126
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
127
|
+
}, {
|
|
128
|
+
readonly name: "aiosqlite";
|
|
129
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
130
|
+
}, {
|
|
131
|
+
readonly name: "langgraph-checkpoint-aws";
|
|
132
|
+
readonly when: (m: PyAgentMetadata) => boolean;
|
|
123
133
|
}, {
|
|
124
134
|
readonly name: "ag-ui-protocol";
|
|
125
135
|
readonly when: (m: PyAgentMetadata) => boolean;
|
|
@@ -6,7 +6,7 @@ import { ensureLicenseExceptions } from "../../license/config.js";
|
|
|
6
6
|
import { AG_UI_LANGGRAPH_EXCEPTIONS } from "../../license/known-exceptions.js";
|
|
7
7
|
import { addPyDependencies, addTsDependencies } from "../../utils/add-dependencies.js";
|
|
8
8
|
import { addAgentChatScripts } from "../../utils/agent-chat/agent-chat.js";
|
|
9
|
-
import { AGENT_CONNECTION_PY_DEPENDENCIES, addPythonFrameworkBase, ensurePythonAgentConnectionProject, getPythonAgentConnectionModuleName, getPythonAgentConnectionProject } from "../../utils/agent-connection/agent-connection.js";
|
|
9
|
+
import { AGENT_CONNECTION_PY_DEPENDENCIES, addPythonFrameworkBase, ensureLangchainS3CheckpointSaver, ensurePythonAgentConnectionProject, getPythonAgentConnectionModuleName, getPythonAgentConnectionProject } from "../../utils/agent-connection/agent-connection.js";
|
|
10
10
|
import { addAgentInfra } from "../../utils/agent-core-constructs/agent-core-constructs.js";
|
|
11
11
|
import { addPythonBundleTarget } from "../../utils/bundle/bundle.js";
|
|
12
12
|
import { resolveContainers } from "../../utils/containers.js";
|
|
@@ -22,7 +22,7 @@ import { kebabCase, toClassName, toSnakeCase } from "../../utils/names.js";
|
|
|
22
22
|
import { getNpmScope } from "../../utils/npm-scope.js";
|
|
23
23
|
import { addComponentDevTarget, addComponentGeneratorMetadata, addDependencyToTargetIfNotPresent, getGeneratorInfo, normalizeTargetKeyOrder, readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
24
24
|
import { sortObjectKeys } from "../../utils/object.js";
|
|
25
|
-
import { toProjectRelativePath } from "../../utils/paths.js";
|
|
25
|
+
import { getRelativePathToRootByDirectory, toProjectRelativePath } from "../../utils/paths.js";
|
|
26
26
|
import { assignPort } from "../../utils/port.js";
|
|
27
27
|
import { addWorkspaceDependencyToPyProject } from "../../utils/py.js";
|
|
28
28
|
import { SHARED_CONSTRUCTS_DEPENDENCIES, sharedConstructsGenerator } from "../../utils/shared-constructs.js";
|
|
@@ -117,6 +117,22 @@ export const DEPENDENCIES = declareDependencies()({
|
|
|
117
117
|
name: 'langgraph',
|
|
118
118
|
when: (m)=>m.framework === 'langchain'
|
|
119
119
|
},
|
|
120
|
+
// Local dev uses a SQLite-backed checkpointer for convenience (parity
|
|
121
|
+
// with the strands framework's local FileSessionManager).
|
|
122
|
+
{
|
|
123
|
+
name: 'langgraph-checkpoint-sqlite',
|
|
124
|
+
when: (m)=>m.framework === 'langchain'
|
|
125
|
+
},
|
|
126
|
+
// AsyncSqliteSaver's driver, required alongside langgraph-checkpoint-sqlite.
|
|
127
|
+
{
|
|
128
|
+
name: 'aiosqlite',
|
|
129
|
+
when: (m)=>m.framework === 'langchain'
|
|
130
|
+
},
|
|
131
|
+
// Provides DynamoDBSaver (with S3 offloading for large checkpoints).
|
|
132
|
+
{
|
|
133
|
+
name: 'langgraph-checkpoint-aws',
|
|
134
|
+
when: (m)=>m.framework === 'langchain' && m.session === 'dynamodb-s3'
|
|
135
|
+
},
|
|
120
136
|
{
|
|
121
137
|
name: 'ag-ui-protocol',
|
|
122
138
|
when: (m)=>m.framework === 'langchain' && m.protocol === 'ag-ui'
|
|
@@ -131,25 +147,25 @@ export const DEPENDENCIES = declareDependencies()({
|
|
|
131
147
|
},
|
|
132
148
|
{
|
|
133
149
|
name: 'strands-agents[a2a]',
|
|
134
|
-
when: (m)=>m.framework
|
|
150
|
+
when: (m)=>m.framework === 'strands' && m.protocol === 'a2a'
|
|
135
151
|
},
|
|
136
152
|
{
|
|
137
153
|
name: 'strands-agents',
|
|
138
|
-
when: (m)=>m.framework
|
|
154
|
+
when: (m)=>m.framework === 'strands' && m.protocol !== 'a2a'
|
|
139
155
|
},
|
|
140
156
|
{
|
|
141
157
|
name: 'strands-agents-tools',
|
|
142
|
-
when: (m)=>m.framework
|
|
158
|
+
when: (m)=>m.framework === 'strands'
|
|
143
159
|
},
|
|
144
160
|
// Declared again here so a Strands AG-UI agent lists it in the same order
|
|
145
161
|
// the generated pyproject.toml had before.
|
|
146
162
|
{
|
|
147
163
|
name: 'ag-ui-protocol',
|
|
148
|
-
when: (m)=>m.framework
|
|
164
|
+
when: (m)=>m.framework === 'strands' && m.protocol === 'ag-ui'
|
|
149
165
|
},
|
|
150
166
|
{
|
|
151
167
|
name: 'ag-ui-strands',
|
|
152
|
-
when: (m)=>m.framework
|
|
168
|
+
when: (m)=>m.framework === 'strands' && m.protocol === 'ag-ui'
|
|
153
169
|
},
|
|
154
170
|
{
|
|
155
171
|
name: 'uvicorn'
|
|
@@ -193,9 +209,41 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
193
209
|
console.warn('Warning: auth is ignored when no infrastructure is configured (no infrastructure is generated)');
|
|
194
210
|
}
|
|
195
211
|
const auth = options.auth ?? 'iam';
|
|
196
|
-
//
|
|
197
|
-
//
|
|
198
|
-
|
|
212
|
+
// Session backends are framework-specific: Strands' SessionManager only has
|
|
213
|
+
// an S3-backed implementation here (via strands.session.S3SessionManager),
|
|
214
|
+
// while LangChain uses dedicated S3 and DynamoDB checkpointer libraries.
|
|
215
|
+
// 'in-memory' is valid for both.
|
|
216
|
+
const SESSIONS_BY_FRAMEWORK = {
|
|
217
|
+
strands: [
|
|
218
|
+
's3',
|
|
219
|
+
'in-memory'
|
|
220
|
+
],
|
|
221
|
+
langchain: [
|
|
222
|
+
's3',
|
|
223
|
+
'dynamodb-s3',
|
|
224
|
+
'in-memory'
|
|
225
|
+
]
|
|
226
|
+
};
|
|
227
|
+
if (options.session && !SESSIONS_BY_FRAMEWORK[framework].includes(options.session)) {
|
|
228
|
+
throw new Error(`Unsupported combination: session '${options.session}' is not implemented for the ${framework} framework (supported: ${SESSIONS_BY_FRAMEWORK[framework].join(', ')}).`);
|
|
229
|
+
}
|
|
230
|
+
const session = options.session ?? 's3';
|
|
231
|
+
// With infra=none there's no CDK/Terraform construct to provision a bucket
|
|
232
|
+
// or table or set RUNTIME_CONFIG_APP_ID, so session.py's non-local-dev
|
|
233
|
+
// branch has nothing to read from AppConfig at runtime — the generated code
|
|
234
|
+
// still honors `session`, but only works outside local dev if the caller
|
|
235
|
+
// wires up matching infra/runtime config themselves.
|
|
236
|
+
if (infra === 'none' && session !== 'in-memory') {
|
|
237
|
+
console.warn(`Warning: session '${session}' requires infrastructure to configure it automatically (no infrastructure is generated for infra=none) — outside local dev this will fail unless you configure matching runtime config yourself`);
|
|
238
|
+
}
|
|
239
|
+
// Local-dev session storage lives at the workspace root
|
|
240
|
+
// (`tmp/agents/<framework>/<agent-name>`), not inside the project, so each
|
|
241
|
+
// agent gets its own storage directory — shared by both frameworks
|
|
242
|
+
// (Strands' FileSessionManager, LangChain's SqliteSaver). The
|
|
243
|
+
// `-dev`/`-serve` targets run with cwd={projectRoot}, so compute that
|
|
244
|
+
// directory relative to the project root here rather than resolving it at
|
|
245
|
+
// runtime.
|
|
246
|
+
const localSessionsDir = joinPathFragments(getRelativePathToRootByDirectory(project.root), `tmp/agents/${framework}/${name}`);
|
|
199
247
|
// Ensure the shared agent-connection project exists so the server entry
|
|
200
248
|
// point can import `session_id_context` and propagate the AgentCore
|
|
201
249
|
// session ID to any downstream MCP / A2A clients a later connection
|
|
@@ -203,8 +251,8 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
203
251
|
await ensurePythonAgentConnectionProject(tree, DEPENDENCIES);
|
|
204
252
|
// The agent server imports the framework base helpers (session cache + model
|
|
205
253
|
// error logging) regardless of whether a connection client is wired in. The
|
|
206
|
-
//
|
|
207
|
-
// framework-agnostic session context), so this is a no-op for
|
|
254
|
+
// LangChain framework has no base layer (its AG-UI foundation reuses only the
|
|
255
|
+
// framework-agnostic session context), so this is a no-op for LangChain.
|
|
208
256
|
await addPythonFrameworkBase(tree, DEPENDENCIES, framework);
|
|
209
257
|
const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);
|
|
210
258
|
addWorkspaceDependencyToPyProject(tree, project, getPythonAgentConnectionProject(tree));
|
|
@@ -214,27 +262,28 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
214
262
|
agentNameClassName,
|
|
215
263
|
moduleName,
|
|
216
264
|
agentConnectionModuleName,
|
|
217
|
-
framework
|
|
265
|
+
framework,
|
|
266
|
+
protocol,
|
|
267
|
+
session,
|
|
268
|
+
localSessionsDir
|
|
218
269
|
};
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
270
|
+
// Files live under a per-framework dir (files/strands, files/langchain),
|
|
271
|
+
// mirrored one-for-one — including files that don't vary by framework
|
|
272
|
+
// (e.g. the empty package __init__.py) — so there's a single, uniform
|
|
273
|
+
// <framework>/<protocol> layout with no cross-framework fallbacks.
|
|
274
|
+
// `framework` is itself the directory name.
|
|
275
|
+
// Common files shared by both protocols: the agent module (Strands yields a
|
|
276
|
+
// contextmanaged Agent with a session.py sibling; LangChain returns a
|
|
277
|
+
// compiled create_agent graph) and the package __init__.py.
|
|
223
278
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', framework, 'common'), targetSourceDir, templateContext, {
|
|
224
279
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
225
280
|
});
|
|
226
|
-
if (framework === 'langchain') {
|
|
227
|
-
|
|
228
|
-
// framework-agnostic, so emit it from the strands `common` dir.
|
|
229
|
-
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'strands', 'common'), targetSourceDir, templateContext, {
|
|
230
|
-
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
231
|
-
});
|
|
281
|
+
if (framework === 'langchain' && session === 's3') {
|
|
282
|
+
ensureLangchainS3CheckpointSaver(tree);
|
|
232
283
|
}
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
// a compiled create_agent graph), so it comes from a per-framework,
|
|
237
|
-
// per-protocol dir: `files/<framework>/<protocol>`.
|
|
284
|
+
// Protocol-specific files. Each protocol's server entry point is
|
|
285
|
+
// framework-specific (Strands yields a contextmanaged Agent; LangChain
|
|
286
|
+
// drives a compiled create_agent graph).
|
|
238
287
|
const protocolLower = protocol.toLowerCase();
|
|
239
288
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', framework, protocolLower), targetSourceDir, templateContext, {
|
|
240
289
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
@@ -325,6 +374,7 @@ export const pyAgentGenerator = async (tree, options)=>{
|
|
|
325
374
|
auth,
|
|
326
375
|
protocol,
|
|
327
376
|
framework,
|
|
377
|
+
session,
|
|
328
378
|
...iac ? {
|
|
329
379
|
iac
|
|
330
380
|
} : {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/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 { ensureLicenseExceptions } from '../../license/config';\nimport { AG_UI_LANGGRAPH_EXCEPTIONS } from '../../license/known-exceptions';\nimport {\n addPyDependencies,\n addTsDependencies,\n} from '../../utils/add-dependencies';\nimport { addAgentChatScripts } from '../../utils/agent-chat/agent-chat';\nimport {\n AGENT_CONNECTION_PY_DEPENDENCIES,\n addPythonFrameworkBase,\n ensurePythonAgentConnectionProject,\n getPythonAgentConnectionModuleName,\n getPythonAgentConnectionProject,\n} from '../../utils/agent-connection/agent-connection';\nimport { addAgentInfra } from '../../utils/agent-core-constructs/agent-core-constructs';\nimport { addPythonBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport { addDockerScanTarget, DOCKER_DEPENDENCIES } from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs';\nimport { updateGitIgnore } from '../../utils/git';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase, toClassName, toSnakeCase } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n normalizeTargetKeyOrder,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { toProjectRelativePath } from '../../utils/paths';\nimport { assignPort } from '../../utils/port';\nimport { addWorkspaceDependencyToPyProject } from '../../utils/py';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs';\nimport type { IacMetadata } from '../../utils/shared-constructs-constants';\nimport { BASE_IMAGES } from '../../utils/versions';\nimport type {\n AgentProtocol,\n PyAgentFramework,\n PyAgentGeneratorSchema,\n} from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface PyAgentMetadata extends IacMetadata {\n readonly port: number;\n readonly rc: string;\n readonly auth: string;\n readonly protocol: AgentProtocol;\n /**\n * The mcp / gateway connection generators dispatch on this field to pick the\n * Strands vs LangChain Layer-2 client + agent.py transform.\n */\n readonly framework: PyAgentFramework;\n}\n\n/** Whether the chat CLI signs its requests, which only IAM auth needs. */\nconst isIam = (m: PyAgentMetadata) => m.auth === 'iam';\n\n// Each entry names the framework and protocol branch it belongs to, so the same\n// declaration drives both adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<PyAgentMetadata>()({\n ts: [\n // The chat CLI, which runs standalone via tsx for every protocol and\n // resolves the deployed agent from AppConfig. `agent-chat-cli` transitively\n // bundles the protocol clients (@a2a-js/sdk, @ag-ui/client).\n { name: 'agent-chat-cli', dev: true, root: true },\n { name: 'tsx', dev: true, root: true },\n { name: '@types/node', dev: true, root: true },\n { name: '@aws-lambda-powertools/parameters', dev: true, root: true },\n { name: '@aws-sdk/client-appconfigdata', dev: true, root: true },\n { name: 'aws4fetch', when: isIam, dev: true, root: true },\n {\n name: '@aws-sdk/credential-providers',\n when: isIam,\n dev: true,\n root: true,\n },\n {\n name: '@a2a-js/sdk',\n when: (m) => m.protocol === 'a2a',\n dev: true,\n root: true,\n },\n // Added by the helpers that own the projects they belong to.\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: [\n { name: 'aws-lambda-powertools' },\n { name: 'aws-opentelemetry-distro' },\n { name: 'bedrock-agentcore' },\n { name: 'boto3' },\n { name: 'fastapi' },\n { name: 'mcp' },\n // langchain pulls no Strands dependencies — the langchain model binding\n // plus the per-protocol server adapter: ag-ui-langgraph for AG-UI, a2a-sdk\n // for A2A, nothing extra for HTTP (FastAPI is added for every agent).\n { name: 'langchain', when: (m) => m.framework === 'langchain' },\n { name: 'langchain-aws', when: (m) => m.framework === 'langchain' },\n { name: 'langgraph', when: (m) => m.framework === 'langchain' },\n {\n name: 'ag-ui-protocol',\n when: (m) => m.framework === 'langchain' && m.protocol === 'ag-ui',\n },\n {\n name: 'ag-ui-langgraph',\n when: (m) => m.framework === 'langchain' && m.protocol === 'ag-ui',\n },\n {\n name: 'a2a-sdk',\n when: (m) => m.framework === 'langchain' && m.protocol === 'a2a',\n },\n {\n name: 'strands-agents[a2a]',\n when: (m) => m.framework !== 'langchain' && m.protocol === 'a2a',\n },\n {\n name: 'strands-agents',\n when: (m) => m.framework !== 'langchain' && m.protocol !== 'a2a',\n },\n {\n name: 'strands-agents-tools',\n when: (m) => m.framework !== 'langchain',\n },\n // Declared again here so a Strands AG-UI agent lists it in the same order\n // the generated pyproject.toml had before.\n {\n name: 'ag-ui-protocol',\n when: (m) => m.framework !== 'langchain' && m.protocol === 'ag-ui',\n },\n {\n name: 'ag-ui-strands',\n when: (m) => m.framework !== 'langchain' && m.protocol === 'ag-ui',\n },\n { name: 'uvicorn' },\n // `fastapi dev` runs the local server for every protocol.\n { name: 'fastapi[standard]', group: 'dev' },\n // The agent-connection helper adds these to its own project.\n ...ownedElsewhere(AGENT_CONNECTION_PY_DEPENDENCIES),\n ],\n});\n\nexport const PY_AGENT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const pyAgentGenerator = async (\n tree: Tree,\n options: PyAgentGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n const pyProjectPath = joinPathFragments(project.root, 'pyproject.toml');\n\n // Check if the project has a pyproject.toml file\n if (!pyProjectPath) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a Python project (with a pyproject.toml)`,\n );\n }\n\n if (!project.sourceRoot) {\n throw new Error(\n `This project does not have a source root. Please add a source root to the project configuration before running this generator.`,\n );\n }\n\n // Module name is the last part of the source root,\n const sourceParts = project.sourceRoot.split('/');\n const moduleName = sourceParts[sourceParts.length - 1];\n\n const name = kebabCase(\n options.name || `${kebabCase(project.name.split('.').pop())}-agent`,\n );\n const agentTargetPrefix = options.name ? name : 'agent';\n\n const agentNameSnakeCase = toSnakeCase(options.name || 'agent');\n const agentNameClassName = toClassName(name);\n\n const targetSourceDir = joinPathFragments(\n project.sourceRoot,\n agentNameSnakeCase,\n );\n\n const infra = options.infra ?? 'agentcore';\n const protocol = options.protocol ?? 'http';\n const framework = options.framework ?? 'strands';\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 // Only 'in-memory' is currently supported for Python agents (session manager\n // support for Python is not yet implemented).\n const session = options.session ?? 'in-memory';\n\n // Ensure the shared agent-connection project exists so the server entry\n // point can import `session_id_context` and propagate the AgentCore\n // session ID to any downstream MCP / A2A clients a later connection\n // generator wires into this agent.\n await ensurePythonAgentConnectionProject(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. The\n // langchain framework has no base layer (its AG-UI foundation reuses only the\n // framework-agnostic session context), so this is a no-op for langchain.\n await addPythonFrameworkBase(tree, DEPENDENCIES, framework);\n const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);\n addWorkspaceDependencyToPyProject(\n tree,\n project,\n getPythonAgentConnectionProject(tree),\n );\n\n const templateContext = {\n name,\n agentNameSnakeCase,\n agentNameClassName,\n moduleName,\n agentConnectionModuleName,\n framework,\n };\n\n // Generate common files shared by both protocols. The agent module (agent.py)\n // is framework-specific (Strands yields a contextmanaged Agent; LangChain\n // returns a compiled create_agent graph), so it comes from a per-framework\n // dir. The package __init__.py is framework-agnostic (it stays in `common`).\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', framework, 'common'),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n if (framework === 'langchain') {\n // langchain/common only carries agent.py; the empty package __init__.py is\n // framework-agnostic, so emit it from the strands `common` dir.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'strands', 'common'),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n }\n\n // Generate protocol-specific files. Each protocol's server entry point (and,\n // for HTTP, its init.py building the FastAPI app + lifespan) is\n // framework-specific (Strands yields a contextmanaged Agent; LangChain drives\n // a compiled create_agent graph), so it comes from a per-framework,\n // per-protocol dir: `files/<framework>/<protocol>`.\n const protocolLower = protocol.toLowerCase();\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', framework, protocolLower),\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 const { bundleTargetName, bundleOutputDir } = addPythonBundleTarget(\n project,\n {\n pythonPlatform: 'aarch64-manylinux_2_28',\n },\n );\n\n // Add the Dockerfile\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'deploy'),\n targetSourceDir,\n {\n agentNameSnakeCase,\n moduleName,\n bundleOutputDir,\n protocol,\n pythonBaseImage: BASE_IMAGES.python,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'docker',\n name,\n );\n const dockerTargetName = `${agentTargetPrefix}-docker`;\n\n // Add a docker target that prepares the docker context and builds the image\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.rm(dockerOutputDir),\n fs.mkdir(dockerOutputDir),\n fs.cp(bundleOutputDir, dockerOutputDir),\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: [bundleTargetName],\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 // Add the construct to deploy the agent.\n // AG-UI uses HTTP as the AgentCore protocol type (AG-UI is HTTP-based with SSE over POST).\n const infraProtocol =\n protocol === 'ag-ui' ? ('http' as const) : (protocol as 'http' | 'a2a');\n await addAgentInfra(tree, {\n agentNameKebabCase: name,\n agentNameClassName,\n dockerImageTag,\n dockerOutputDir,\n iac,\n projectName: project.name,\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: PY_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: PyAgentMetadata = {\n port: localDevPort,\n rc: agentNameClassName,\n auth,\n protocol,\n framework,\n ...(iac ? { iac } : {}),\n };\n\n addPyDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: project.root,\n });\n addTsDependencies(tree, DEPENDENCIES, { metadata });\n\n // All protocols use fastapi dev for hot reload:\n // - HTTP: FastAPI app directly defined in init.py\n // - A2A: A2AServer.to_fastapi_app() creates a FastAPI app in main.py\n // - AG-UI: create_strands_app() creates a FastAPI app in main.py\n const serveCommand = `uv run fastapi dev ${moduleName}/${agentNameSnakeCase}/main.py --port ${localDevPort}`;\n\n // HTTP chat uses the type-safe TypeScript client generated from the\n // agent's OpenAPI spec (same generated client the react-connection\n // generator produces). A2A and AG-UI speak standard protocols, so\n // we can run `agent-chat-cli` directly as a binary.\n const openApiTargetName = `${agentTargetPrefix}-openapi`;\n const clientGenTargetName = `${agentTargetPrefix}-generate-client`;\n\n const scriptsDir = joinPathFragments(\n project.root,\n 'scripts',\n agentTargetPrefix,\n );\n\n if (protocol === 'http') {\n // Emit the OpenAPI spec generator script (shared with react-connection)\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'react-connection',\n 'files',\n 'agent',\n ),\n project.root,\n {\n moduleName,\n agentNameSnakeCase,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Ignore the generated client directory\n updateGitIgnore(tree, project.root, (patterns) => [\n ...patterns,\n `scripts/${agentTargetPrefix}/generated/`,\n ]);\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 addAgentChatScripts(tree, {\n scriptsDir,\n protocol,\n language: 'py',\n agentNameClassName,\n auth,\n });\n\n const chatUrl =\n protocol === 'ag-ui'\n ? `http://localhost:${localDevPort}/invocations`\n : `http://localhost:${localDevPort}`;\n const chatCommand = `tsx ./scripts/${agentTargetPrefix}/chat.ts`;\n\n const httpOnlyTargets =\n protocol === 'http'\n ? {\n [openApiTargetName]: {\n cache: true,\n executor: 'nx:run-commands',\n outputs: [\n `{workspaceRoot}/dist/{projectRoot}/openapi/${agentNameSnakeCase}`,\n ],\n options: {\n commands: [\n `uv run python {projectRoot}/scripts/${agentNameSnakeCase}_openapi.py \"dist/{projectRoot}/openapi/${agentNameSnakeCase}/openapi.json\"`,\n ],\n },\n },\n [clientGenTargetName]: {\n cache: true,\n executor: 'nx:run-commands',\n dependsOn: [openApiTargetName],\n inputs: [\n {\n dependentTasksOutputFiles: '**/*.json',\n },\n ],\n outputs: [`{projectRoot}/scripts/${agentTargetPrefix}/generated`],\n options: {\n commands: [\n `nx g @aws/nx-plugin:open-api#ts-client --openApiSpecPath=\"dist/${project.root}/openapi/${agentNameSnakeCase}/openapi.json\" --outputPath=\"${project.root}/scripts/${agentTargetPrefix}/generated\" --no-interactive`,\n ],\n },\n },\n }\n : {};\n\n const agentTargets = {\n ...project.targets,\n ...httpOnlyTargets,\n [`${agentTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [serveCommand],\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: [serveCommand],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n // HTTP chat imports the generated client, so ensure it's built first.\n // No dev dependency — chat runs standalone against a local or\n // deployed agent. normalizeTargetKeyOrder keeps the conditional dependsOn\n // in Nx 23's serialization order so re-runs stay byte-identical.\n [`${agentTargetPrefix}-chat`]: normalizeTargetKeyOrder({\n executor: 'nx:run-commands',\n options: {\n commands: [chatCommand],\n cwd: '{projectRoot}',\n env: {\n URL: chatUrl,\n },\n },\n ...(protocol === 'http' ? { dependsOn: [clientGenTargetName] } : {}),\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 targets: sortObjectKeys(agentTargets),\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n PY_AGENT_GENERATOR_INFO,\n toProjectRelativePath(project, targetSourceDir),\n agentTargetPrefix,\n metadata,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [PY_AGENT_GENERATOR_INFO]);\n\n // langchain-core (pulled by every langchain agent regardless of protocol)\n // brings jsonpatch/jsonpointer, whose wheels ship without resolvable SPDX\n // license metadata, so register those exceptions so the workspace license\n // check still passes.\n if (framework === 'langchain') {\n await ensureLicenseExceptions(tree, AG_UI_LANGGRAPH_EXCEPTIONS);\n }\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyAgentGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","ensureLicenseExceptions","AG_UI_LANGGRAPH_EXCEPTIONS","addPyDependencies","addTsDependencies","addAgentChatScripts","AGENT_CONNECTION_PY_DEPENDENCIES","addPythonFrameworkBase","ensurePythonAgentConnectionProject","getPythonAgentConnectionModuleName","getPythonAgentConnectionProject","addAgentInfra","addPythonBundleTarget","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","toSnakeCase","getNpmScope","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","normalizeTargetKeyOrder","readProjectConfigurationUnqualified","sortObjectKeys","toProjectRelativePath","assignPort","addWorkspaceDependencyToPyProject","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","BASE_IMAGES","isIam","m","auth","DEPENDENCIES","ts","name","dev","root","when","protocol","py","framework","group","PY_AGENT_GENERATOR_INFO","filename","pyAgentGenerator","tree","options","project","pyProjectPath","Error","sourceRoot","sourceParts","split","moduleName","length","pop","agentTargetPrefix","agentNameSnakeCase","agentNameClassName","targetSourceDir","infra","iac","undefined","console","warn","session","agentConnectionModuleName","templateContext","dirname","overwriteStrategy","KeepExisting","protocolLower","toLowerCase","containers","dockerImageTag","bundleTargetName","bundleOutputDir","pythonPlatform","pythonBaseImage","python","dockerOutputDir","dockerTargetName","fs","targets","cache","executor","commands","rm","mkdir","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","infraProtocol","agentNameKebabCase","projectName","serverProtocol","localDevPortStart","localDevPort","component","info","metadata","port","rc","projectRoot","serveCommand","openApiTargetName","clientGenTargetName","scriptsDir","patterns","language","chatUrl","chatCommand","httpOnlyTargets","outputs","inputs","dependentTasksOutputFiles","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,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,0BAA0B,QAAQ,oCAAiC;AAC5E,SACEC,iBAAiB,EACjBC,iBAAiB,QACZ,kCAA+B;AACtC,SAASC,mBAAmB,QAAQ,uCAAoC;AACxE,SACEC,gCAAgC,EAChCC,sBAAsB,EACtBC,kCAAkC,EAClCC,kCAAkC,EAClCC,+BAA+B,QAC1B,mDAAgD;AACvD,SAASC,aAAa,QAAQ,6DAA0D;AACxF,SAASC,qBAAqB,QAAQ,+BAA4B;AAClE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAoC;AAC3C,SAASC,mBAAmB,EAAEC,mBAAmB,QAAQ,wBAAqB;AAC9E,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAiB;AAC7D,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,SAAS,EAAEC,WAAW,EAAEC,WAAW,QAAQ,uBAAoB;AACxE,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,qBAAqB,EACrBC,6BAA6B,EAC7BC,iCAAiC,EACjCC,gBAAgB,EAEhBC,uBAAuB,EACvBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,SAASC,qBAAqB,QAAQ,uBAAoB;AAC1D,SAASC,UAAU,QAAQ,sBAAmB;AAC9C,SAASC,iCAAiC,QAAQ,oBAAiB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cAAc;oBACvBwB,WAAW;gBACb;YACF;QACF;QACA,sEAAsE;QACtE,8DAA8D;QAC9D,0EAA0E;QAC1E,iEAAiE;QACjE,CAAC,GAAGpE,kBAAkB,KAAK,CAAC,CAAC,EAAEpC,wBAAwB;YACrDiE,UAAU;YACVvC,SAAS;gBACPwC,UAAU;oBAAC4B;iBAAY;gBACvBO,KAAK;gBACLC,KAAK;oBACHG,KAAKZ;gBACP;YACF;YACA,GAAI3E,aAAa,SAAS;gBAAEqD,WAAW;oBAACkB;iBAAoB;YAAC,IAAI,CAAC,CAAC;QACrE;IACF;IAEA,gEAAgE;IAChE7F,sBAAsBuG,cAAc,GAAG/D,kBAAkB,IAAI,CAAC;IAE9DrE,2BAA2B0D,MAAME,QAAQb,IAAI,EAAE;QAC7C,GAAGa,OAAO;QACVoC,SAAS7D,eAAeiG;IAC1B;IAEAtG,8BACE4B,MACAE,QAAQb,IAAI,EACZQ,yBACAnB,sBAAsBwB,SAASY,kBAC/BH,mBACA+C;IAGF,MAAM5F,gCAAgCkC,MAAM;QAACH;KAAwB;IAErE,0EAA0E;IAC1E,0EAA0E;IAC1E,0EAA0E;IAC1E,sBAAsB;IACtB,IAAIF,cAAc,aAAa;QAC7B,MAAMpD,wBAAwByD,MAAMxD;IACtC;IAEA,MAAMgB,qBAAqBwC;IAC3B,OAAO,IACLnC,oBAAoBmC,MAAMC,QAAQgF,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAenF,iBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/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 { ensureLicenseExceptions } from '../../license/config';\nimport { AG_UI_LANGGRAPH_EXCEPTIONS } from '../../license/known-exceptions';\nimport {\n addPyDependencies,\n addTsDependencies,\n} from '../../utils/add-dependencies';\nimport { addAgentChatScripts } from '../../utils/agent-chat/agent-chat';\nimport {\n AGENT_CONNECTION_PY_DEPENDENCIES,\n addPythonFrameworkBase,\n ensureLangchainS3CheckpointSaver,\n ensurePythonAgentConnectionProject,\n getPythonAgentConnectionModuleName,\n getPythonAgentConnectionProject,\n} from '../../utils/agent-connection/agent-connection';\nimport { addAgentInfra } from '../../utils/agent-core-constructs/agent-core-constructs';\nimport { addPythonBundleTarget } from '../../utils/bundle/bundle';\nimport { resolveContainers } from '../../utils/containers';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies';\nimport { addDockerScanTarget, DOCKER_DEPENDENCIES } from '../../utils/docker';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs';\nimport { updateGitIgnore } from '../../utils/git';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase, toClassName, toSnakeCase } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addComponentDevTarget,\n addComponentGeneratorMetadata,\n addDependencyToTargetIfNotPresent,\n getGeneratorInfo,\n type NxGeneratorInfo,\n normalizeTargetKeyOrder,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport {\n getRelativePathToRootByDirectory,\n toProjectRelativePath,\n} from '../../utils/paths';\nimport { assignPort } from '../../utils/port';\nimport { addWorkspaceDependencyToPyProject } from '../../utils/py';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs';\nimport type { IacMetadata } from '../../utils/shared-constructs-constants';\nimport { BASE_IMAGES } from '../../utils/versions';\nimport type {\n AgentProtocol,\n PyAgentFramework,\n PyAgentGeneratorSchema,\n PyAgentSession,\n} from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface PyAgentMetadata extends IacMetadata {\n readonly port: number;\n readonly rc: string;\n readonly auth: string;\n readonly protocol: AgentProtocol;\n /**\n * The mcp / gateway connection generators dispatch on this field to pick the\n * Strands vs LangChain Layer-2 client + agent.py transform.\n */\n readonly framework: PyAgentFramework;\n readonly session: PyAgentSession;\n}\n\n/** Whether the chat CLI signs its requests, which only IAM auth needs. */\nconst isIam = (m: PyAgentMetadata) => m.auth === 'iam';\n\n// Each entry names the framework and protocol branch it belongs to, so the same\n// declaration drives both adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<PyAgentMetadata>()({\n ts: [\n // The chat CLI, which runs standalone via tsx for every protocol and\n // resolves the deployed agent from AppConfig. `agent-chat-cli` transitively\n // bundles the protocol clients (@a2a-js/sdk, @ag-ui/client).\n { name: 'agent-chat-cli', dev: true, root: true },\n { name: 'tsx', dev: true, root: true },\n { name: '@types/node', dev: true, root: true },\n { name: '@aws-lambda-powertools/parameters', dev: true, root: true },\n { name: '@aws-sdk/client-appconfigdata', dev: true, root: true },\n { name: 'aws4fetch', when: isIam, dev: true, root: true },\n {\n name: '@aws-sdk/credential-providers',\n when: isIam,\n dev: true,\n root: true,\n },\n {\n name: '@a2a-js/sdk',\n when: (m) => m.protocol === 'a2a',\n dev: true,\n root: true,\n },\n // Added by the helpers that own the projects they belong to.\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: [\n { name: 'aws-lambda-powertools' },\n { name: 'aws-opentelemetry-distro' },\n { name: 'bedrock-agentcore' },\n { name: 'boto3' },\n { name: 'fastapi' },\n { name: 'mcp' },\n // langchain pulls no Strands dependencies — the langchain model binding\n // plus the per-protocol server adapter: ag-ui-langgraph for AG-UI, a2a-sdk\n // for A2A, nothing extra for HTTP (FastAPI is added for every agent).\n { name: 'langchain', when: (m) => m.framework === 'langchain' },\n { name: 'langchain-aws', when: (m) => m.framework === 'langchain' },\n { name: 'langgraph', when: (m) => m.framework === 'langchain' },\n // Local dev uses a SQLite-backed checkpointer for convenience (parity\n // with the strands framework's local FileSessionManager).\n {\n name: 'langgraph-checkpoint-sqlite',\n when: (m) => m.framework === 'langchain',\n },\n // AsyncSqliteSaver's driver, required alongside langgraph-checkpoint-sqlite.\n { name: 'aiosqlite', when: (m) => m.framework === 'langchain' },\n // Provides DynamoDBSaver (with S3 offloading for large checkpoints).\n {\n name: 'langgraph-checkpoint-aws',\n when: (m) => m.framework === 'langchain' && m.session === 'dynamodb-s3',\n },\n {\n name: 'ag-ui-protocol',\n when: (m) => m.framework === 'langchain' && m.protocol === 'ag-ui',\n },\n {\n name: 'ag-ui-langgraph',\n when: (m) => m.framework === 'langchain' && m.protocol === 'ag-ui',\n },\n {\n name: 'a2a-sdk',\n when: (m) => m.framework === 'langchain' && m.protocol === 'a2a',\n },\n {\n name: 'strands-agents[a2a]',\n when: (m) => m.framework === 'strands' && m.protocol === 'a2a',\n },\n {\n name: 'strands-agents',\n when: (m) => m.framework === 'strands' && m.protocol !== 'a2a',\n },\n {\n name: 'strands-agents-tools',\n when: (m) => m.framework === 'strands',\n },\n // Declared again here so a Strands AG-UI agent lists it in the same order\n // the generated pyproject.toml had before.\n {\n name: 'ag-ui-protocol',\n when: (m) => m.framework === 'strands' && m.protocol === 'ag-ui',\n },\n {\n name: 'ag-ui-strands',\n when: (m) => m.framework === 'strands' && m.protocol === 'ag-ui',\n },\n { name: 'uvicorn' },\n // `fastapi dev` runs the local server for every protocol.\n { name: 'fastapi[standard]', group: 'dev' },\n // The agent-connection helper adds these to its own project.\n ...ownedElsewhere(AGENT_CONNECTION_PY_DEPENDENCIES),\n ],\n});\n\nexport const PY_AGENT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const pyAgentGenerator = async (\n tree: Tree,\n options: PyAgentGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const project = readProjectConfigurationUnqualified(tree, options.project);\n\n const pyProjectPath = joinPathFragments(project.root, 'pyproject.toml');\n\n // Check if the project has a pyproject.toml file\n if (!pyProjectPath) {\n throw new Error(\n `Unsupported project ${options.project}. Expected a Python project (with a pyproject.toml)`,\n );\n }\n\n if (!project.sourceRoot) {\n throw new Error(\n `This project does not have a source root. Please add a source root to the project configuration before running this generator.`,\n );\n }\n\n // Module name is the last part of the source root,\n const sourceParts = project.sourceRoot.split('/');\n const moduleName = sourceParts[sourceParts.length - 1];\n\n const name = kebabCase(\n options.name || `${kebabCase(project.name.split('.').pop())}-agent`,\n );\n const agentTargetPrefix = options.name ? name : 'agent';\n\n const agentNameSnakeCase = toSnakeCase(options.name || 'agent');\n const agentNameClassName = toClassName(name);\n\n const targetSourceDir = joinPathFragments(\n project.sourceRoot,\n agentNameSnakeCase,\n );\n\n const infra = options.infra ?? 'agentcore';\n const protocol = options.protocol ?? 'http';\n const framework = options.framework ?? 'strands';\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 // Session backends are framework-specific: Strands' SessionManager only has\n // an S3-backed implementation here (via strands.session.S3SessionManager),\n // while LangChain uses dedicated S3 and DynamoDB checkpointer libraries.\n // 'in-memory' is valid for both.\n const SESSIONS_BY_FRAMEWORK: Record<\n PyAgentFramework,\n readonly PyAgentSession[]\n > = {\n strands: ['s3', 'in-memory'],\n langchain: ['s3', 'dynamodb-s3', 'in-memory'],\n };\n if (\n options.session &&\n !SESSIONS_BY_FRAMEWORK[framework].includes(options.session)\n ) {\n throw new Error(\n `Unsupported combination: session '${options.session}' is not implemented for the ${framework} framework (supported: ${SESSIONS_BY_FRAMEWORK[framework].join(', ')}).`,\n );\n }\n const session = options.session ?? 's3';\n\n // With infra=none there's no CDK/Terraform construct to provision a bucket\n // or table or set RUNTIME_CONFIG_APP_ID, so session.py's non-local-dev\n // branch has nothing to read from AppConfig at runtime — the generated code\n // still honors `session`, but only works outside local dev if the caller\n // wires up matching infra/runtime config themselves.\n if (infra === 'none' && session !== 'in-memory') {\n console.warn(\n `Warning: session '${session}' requires infrastructure to configure it automatically (no infrastructure is generated for infra=none) — outside local dev this will fail unless you configure matching runtime config yourself`,\n );\n }\n\n // Local-dev session storage lives at the workspace root\n // (`tmp/agents/<framework>/<agent-name>`), not inside the project, so each\n // agent gets its own storage directory — shared by both frameworks\n // (Strands' FileSessionManager, LangChain's SqliteSaver). The\n // `-dev`/`-serve` targets run with cwd={projectRoot}, so compute that\n // directory relative to the project root here rather than resolving it at\n // runtime.\n const localSessionsDir = joinPathFragments(\n getRelativePathToRootByDirectory(project.root),\n `tmp/agents/${framework}/${name}`,\n );\n\n // Ensure the shared agent-connection project exists so the server entry\n // point can import `session_id_context` and propagate the AgentCore\n // session ID to any downstream MCP / A2A clients a later connection\n // generator wires into this agent.\n await ensurePythonAgentConnectionProject(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. The\n // LangChain framework has no base layer (its AG-UI foundation reuses only the\n // framework-agnostic session context), so this is a no-op for LangChain.\n await addPythonFrameworkBase(tree, DEPENDENCIES, framework);\n const agentConnectionModuleName = getPythonAgentConnectionModuleName(tree);\n addWorkspaceDependencyToPyProject(\n tree,\n project,\n getPythonAgentConnectionProject(tree),\n );\n\n const templateContext = {\n name,\n agentNameSnakeCase,\n agentNameClassName,\n moduleName,\n agentConnectionModuleName,\n framework,\n protocol,\n session,\n localSessionsDir,\n };\n\n // Files live under a per-framework dir (files/strands, files/langchain),\n // mirrored one-for-one — including files that don't vary by framework\n // (e.g. the empty package __init__.py) — so there's a single, uniform\n // <framework>/<protocol> layout with no cross-framework fallbacks.\n // `framework` is itself the directory name.\n\n // Common files shared by both protocols: the agent module (Strands yields a\n // contextmanaged Agent with a session.py sibling; LangChain returns a\n // compiled create_agent graph) and the package __init__.py.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', framework, 'common'),\n targetSourceDir,\n templateContext,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n if (framework === 'langchain' && session === 's3') {\n ensureLangchainS3CheckpointSaver(tree);\n }\n\n // Protocol-specific files. Each protocol's server entry point is\n // framework-specific (Strands yields a contextmanaged Agent; LangChain\n // drives a compiled create_agent graph).\n const protocolLower = protocol.toLowerCase();\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', framework, protocolLower),\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 const { bundleTargetName, bundleOutputDir } = addPythonBundleTarget(\n project,\n {\n pythonPlatform: 'aarch64-manylinux_2_28',\n },\n );\n\n // Add the Dockerfile\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'deploy'),\n targetSourceDir,\n {\n agentNameSnakeCase,\n moduleName,\n bundleOutputDir,\n protocol,\n pythonBaseImage: BASE_IMAGES.python,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n const dockerOutputDir = joinPathFragments(\n 'dist',\n project.root,\n 'docker',\n name,\n );\n const dockerTargetName = `${agentTargetPrefix}-docker`;\n\n // Add a docker target that prepares the docker context and builds the image\n const fs = new FsCommands(tree, DEPENDENCIES);\n project.targets[dockerTargetName] = {\n cache: true,\n executor: 'nx:run-commands',\n options: {\n commands: [\n fs.rm(dockerOutputDir),\n fs.mkdir(dockerOutputDir),\n fs.cp(bundleOutputDir, dockerOutputDir),\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: [bundleTargetName],\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 // Add the construct to deploy the agent.\n // AG-UI uses HTTP as the AgentCore protocol type (AG-UI is HTTP-based with SSE over POST).\n const infraProtocol =\n protocol === 'ag-ui' ? ('http' as const) : (protocol as 'http' | 'a2a');\n await addAgentInfra(tree, {\n agentNameKebabCase: name,\n agentNameClassName,\n dockerImageTag,\n dockerOutputDir,\n iac,\n projectName: project.name,\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: PY_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: PyAgentMetadata = {\n port: localDevPort,\n rc: agentNameClassName,\n auth,\n protocol,\n framework,\n session,\n ...(iac ? { iac } : {}),\n };\n\n addPyDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: project.root,\n });\n addTsDependencies(tree, DEPENDENCIES, { metadata });\n\n // All protocols use fastapi dev for hot reload:\n // - HTTP: FastAPI app directly defined in init.py\n // - A2A: A2AServer.to_fastapi_app() creates a FastAPI app in main.py\n // - AG-UI: create_strands_app() creates a FastAPI app in main.py\n const serveCommand = `uv run fastapi dev ${moduleName}/${agentNameSnakeCase}/main.py --port ${localDevPort}`;\n\n // HTTP chat uses the type-safe TypeScript client generated from the\n // agent's OpenAPI spec (same generated client the react-connection\n // generator produces). A2A and AG-UI speak standard protocols, so\n // we can run `agent-chat-cli` directly as a binary.\n const openApiTargetName = `${agentTargetPrefix}-openapi`;\n const clientGenTargetName = `${agentTargetPrefix}-generate-client`;\n\n const scriptsDir = joinPathFragments(\n project.root,\n 'scripts',\n agentTargetPrefix,\n );\n\n if (protocol === 'http') {\n // Emit the OpenAPI spec generator script (shared with react-connection)\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n 'react-connection',\n 'files',\n 'agent',\n ),\n project.root,\n {\n moduleName,\n agentNameSnakeCase,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Ignore the generated client directory\n updateGitIgnore(tree, project.root, (patterns) => [\n ...patterns,\n `scripts/${agentTargetPrefix}/generated/`,\n ]);\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 addAgentChatScripts(tree, {\n scriptsDir,\n protocol,\n language: 'py',\n agentNameClassName,\n auth,\n });\n\n const chatUrl =\n protocol === 'ag-ui'\n ? `http://localhost:${localDevPort}/invocations`\n : `http://localhost:${localDevPort}`;\n const chatCommand = `tsx ./scripts/${agentTargetPrefix}/chat.ts`;\n\n const httpOnlyTargets =\n protocol === 'http'\n ? {\n [openApiTargetName]: {\n cache: true,\n executor: 'nx:run-commands',\n outputs: [\n `{workspaceRoot}/dist/{projectRoot}/openapi/${agentNameSnakeCase}`,\n ],\n options: {\n commands: [\n `uv run python {projectRoot}/scripts/${agentNameSnakeCase}_openapi.py \"dist/{projectRoot}/openapi/${agentNameSnakeCase}/openapi.json\"`,\n ],\n },\n },\n [clientGenTargetName]: {\n cache: true,\n executor: 'nx:run-commands',\n dependsOn: [openApiTargetName],\n inputs: [\n {\n dependentTasksOutputFiles: '**/*.json',\n },\n ],\n outputs: [`{projectRoot}/scripts/${agentTargetPrefix}/generated`],\n options: {\n commands: [\n `nx g @aws/nx-plugin:open-api#ts-client --openApiSpecPath=\"dist/${project.root}/openapi/${agentNameSnakeCase}/openapi.json\" --outputPath=\"${project.root}/scripts/${agentTargetPrefix}/generated\" --no-interactive`,\n ],\n },\n },\n }\n : {};\n\n const agentTargets = {\n ...project.targets,\n ...httpOnlyTargets,\n [`${agentTargetPrefix}-serve`]: {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [serveCommand],\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: [serveCommand],\n cwd: '{projectRoot}',\n env: {\n PORT: `${localDevPort}`,\n LOCAL_DEV: 'true',\n },\n },\n },\n // HTTP chat imports the generated client, so ensure it's built first.\n // No dev dependency — chat runs standalone against a local or\n // deployed agent. normalizeTargetKeyOrder keeps the conditional dependsOn\n // in Nx 23's serialization order so re-runs stay byte-identical.\n [`${agentTargetPrefix}-chat`]: normalizeTargetKeyOrder({\n executor: 'nx:run-commands',\n options: {\n commands: [chatCommand],\n cwd: '{projectRoot}',\n env: {\n URL: chatUrl,\n },\n },\n ...(protocol === 'http' ? { dependsOn: [clientGenTargetName] } : {}),\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 targets: sortObjectKeys(agentTargets),\n });\n\n addComponentGeneratorMetadata(\n tree,\n project.name,\n PY_AGENT_GENERATOR_INFO,\n toProjectRelativePath(project, targetSourceDir),\n agentTargetPrefix,\n metadata,\n );\n\n await addGeneratorMetricsIfApplicable(tree, [PY_AGENT_GENERATOR_INFO]);\n\n // langchain-core (pulled by every langchain agent regardless of protocol)\n // brings jsonpatch/jsonpointer, whose wheels ship without resolvable SPDX\n // license metadata, so register those exceptions so the workspace license\n // check still passes.\n if (framework === 'langchain') {\n await ensureLicenseExceptions(tree, AG_UI_LANGGRAPH_EXCEPTIONS);\n }\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default pyAgentGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","ensureLicenseExceptions","AG_UI_LANGGRAPH_EXCEPTIONS","addPyDependencies","addTsDependencies","addAgentChatScripts","AGENT_CONNECTION_PY_DEPENDENCIES","addPythonFrameworkBase","ensureLangchainS3CheckpointSaver","ensurePythonAgentConnectionProject","getPythonAgentConnectionModuleName","getPythonAgentConnectionProject","addAgentInfra","addPythonBundleTarget","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","toSnakeCase","getNpmScope","addComponentDevTarget","addComponentGeneratorMetadata","addDependencyToTargetIfNotPresent","getGeneratorInfo","normalizeTargetKeyOrder","readProjectConfigurationUnqualified","sortObjectKeys","getRelativePathToRootByDirectory","toProjectRelativePath","assignPort","addWorkspaceDependencyToPyProject","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","BASE_IMAGES","isIam","m","auth","DEPENDENCIES","ts","name","dev","root","when","protocol","py","framework","session","group","PY_AGENT_GENERATOR_INFO","filename","pyAgentGenerator","tree","options","project","pyProjectPath","Error","sourceRoot","sourceParts","split","moduleName","length","pop","agentTargetPrefix","agentNameSnakeCase","agentNameClassName","targetSourceDir","infra","iac","undefined","console","warn","SESSIONS_BY_FRAMEWORK","strands","langchain","includes","join","localSessionsDir","agentConnectionModuleName","templateContext","dirname","overwriteStrategy","KeepExisting","protocolLower","toLowerCase","containers","dockerImageTag","bundleTargetName","bundleOutputDir","pythonPlatform","pythonBaseImage","python","dockerOutputDir","dockerTargetName","fs","targets","cache","executor","commands","rm","mkdir","cp","parallel","dependsOn","containerEngine","trivyTargetName","imageTags","infraProtocol","agentNameKebabCase","projectName","serverProtocol","localDevPortStart","localDevPort","component","info","metadata","port","rc","projectRoot","serveCommand","openApiTargetName","clientGenTargetName","scriptsDir","patterns","language","chatUrl","chatCommand","httpOnlyTargets","outputs","inputs","dependentTasksOutputFiles","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,uBAAuB,QAAQ,0BAAuB;AAC/D,SAASC,0BAA0B,QAAQ,oCAAiC;AAC5E,SACEC,iBAAiB,EACjBC,iBAAiB,QACZ,kCAA+B;AACtC,SAASC,mBAAmB,QAAQ,uCAAoC;AACxE,SACEC,gCAAgC,EAChCC,sBAAsB,EACtBC,gCAAgC,EAChCC,kCAAkC,EAClCC,kCAAkC,EAClCC,+BAA+B,QAC1B,mDAAgD;AACvD,SAASC,aAAa,QAAQ,6DAA0D;AACxF,SAASC,qBAAqB,QAAQ,+BAA4B;AAClE,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAoC;AAC3C,SAASC,mBAAmB,EAAEC,mBAAmB,QAAQ,wBAAqB;AAC9E,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAiB;AAC7D,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B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A,CAAC,GAAGjD,kBAAkB,IAAI,CAAC,CAAC,EAAE;YAC5BkC,UAAU;YACVmC,YAAY;YACZ/E,SAAS;gBACP6C,UAAU;oBAACqB;iBAAa;gBACxBc,KAAK;gBACLC,KAAK;oBACHC,MAAM,GAAGvB,cAAc;oBACvBwB,WAAW;gBACb;YACF;QACF;QACA,sEAAsE;QACtE,8DAA8D;QAC9D,0EAA0E;QAC1E,iEAAiE;QACjE,CAAC,GAAGzE,kBAAkB,KAAK,CAAC,CAAC,EAAEtC,wBAAwB;YACrDwE,UAAU;YACV5C,SAAS;gBACP6C,UAAU;oBAAC4B;iBAAY;gBACvBO,KAAK;gBACLC,KAAK;oBACHG,KAAKZ;gBACP;YACF;YACA,GAAIjF,aAAa,SAAS;gBAAE2D,WAAW;oBAACkB;iBAAoB;YAAC,IAAI,CAAC,CAAC;QACrE;IACF;IAEA,gEAAgE;IAChEpG,sBAAsB8G,cAAc,GAAGpE,kBAAkB,IAAI,CAAC;IAE9DxE,2BAA2B6D,MAAME,QAAQd,IAAI,EAAE;QAC7C,GAAGc,OAAO;QACVyC,SAASpE,eAAewG;IAC1B;IAEA7G,8BACE8B,MACAE,QAAQd,IAAI,EACZS,yBACApB,sBAAsByB,SAASY,kBAC/BH,mBACAoD;IAGF,MAAMnG,gCAAgCoC,MAAM;QAACH;KAAwB;IAErE,0EAA0E;IAC1E,0EAA0E;IAC1E,0EAA0E;IAC1E,sBAAsB;IACtB,IAAIH,cAAc,aAAa;QAC7B,MAAMtD,wBAAwB4D,MAAM3D;IACtC;IAEA,MAAMiB,qBAAqB0C;IAC3B,OAAO,IACLrC,oBAAoBqC,MAAMC,QAAQqF,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAexF,iBAAiB"}
|
|
@@ -6,6 +6,7 @@ exports[`py#agent#mcp-connection generator > should match snapshot for generated
|
|
|
6
6
|
from .app.inventory_mcp_client_strands import InventoryMcpClientStrands
|
|
7
7
|
from .core.model_errors_strands import log_model_errors
|
|
8
8
|
from .core.session_context import get_current_session_id, session_id_context
|
|
9
|
+
from .core.tool_errors_strands import log_tool_errors
|
|
9
10
|
from .core.with_session_id_strands import with_session_id
|
|
10
11
|
|
|
11
12
|
__all__ = [
|
|
@@ -13,6 +14,7 @@ __all__ = [
|
|
|
13
14
|
"session_id_context",
|
|
14
15
|
"with_session_id",
|
|
15
16
|
"log_model_errors",
|
|
17
|
+
"log_tool_errors",
|
|
16
18
|
"InventoryMcpClientStrands",
|
|
17
19
|
]
|
|
18
20
|
"
|
|
@@ -151,7 +151,7 @@ export declare const DEPENDENCIES: import("../../../utils/declared-dependencies"
|
|
|
151
151
|
versionOnly: true;
|
|
152
152
|
}, "when"> & {
|
|
153
153
|
when: (m: PyAgentReactConnectionMetadata) => boolean;
|
|
154
|
-
}], readonly import("../../../utils/declared-dependencies").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "mcp" | "pip-check-updates" | "pip-licenses" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", PyAgentReactConnectionMetadata>[]>;
|
|
154
|
+
}], readonly import("../../../utils/declared-dependencies").DeclaredPyDependency<"a2a-sdk" | "ag-ui-langgraph" | "ag-ui-protocol" | "ag-ui-strands" | "aiosqlite" | "aws-lambda-powertools" | "aws-lambda-powertools[tracer]" | "aws-lambda-powertools[parser]" | "aws-opentelemetry-distro" | "bedrock-agentcore" | "boto3" | "checkov" | "fastapi" | "fastapi[standard]" | "httpx" | "langchain" | "langchain-aws" | "langchain-mcp-adapters" | "langgraph" | "langgraph-checkpoint-aws" | "langgraph-checkpoint-sqlite" | "mcp" | "pip-check-updates" | "pip-licenses" | "ruff" | "strands-agents" | "strands-agents[a2a]" | "strands-agents-tools" | "ty" | "pynamodb" | "uvicorn" | "sqlmodel" | "alembic" | "aiomysql" | "asyncpg" | "greenlet", PyAgentReactConnectionMetadata>[]>;
|
|
155
155
|
export declare const PY_AGENT_REACT_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
156
156
|
export declare const pyAgentReactConnectionGenerator: (tree: Tree, options: ResolvedConnectionOptions & {
|
|
157
157
|
gatewayRoute?: AgentGatewayRoute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/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 PyAgentFramework = 'strands' | 'langchain';\nexport type PyAgentInfra = 'agentcore' | 'none';\nexport type AgentProtocol = 'http' | 'a2a' | 'ag-ui';\n\nexport type PyAgentAuth = 'iam' | 'cognito';\n\nexport type PyAgentSession = 'in-memory';\n\nexport interface PyAgentGeneratorSchema {\n project: string;\n framework?: PyAgentFramework;\n name?: string;\n infra?: PyAgentInfra;\n auth?: PyAgentAuth;\n protocol?: AgentProtocol;\n session?: PyAgentSession;\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAYD,WAUC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/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 PyAgentFramework = 'strands' | 'langchain';\nexport type PyAgentInfra = 'agentcore' | 'none';\nexport type AgentProtocol = 'http' | 'a2a' | 'ag-ui';\n\nexport type PyAgentAuth = 'iam' | 'cognito';\n\nexport type PyAgentSession = 's3' | 'dynamodb-s3' | 'in-memory';\n\nexport interface PyAgentGeneratorSchema {\n project: string;\n framework?: PyAgentFramework;\n name?: string;\n infra?: PyAgentInfra;\n auth?: PyAgentAuth;\n protocol?: AgentProtocol;\n session?: PyAgentSession;\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAYD,WAUC"}
|
package/src/py/agent/schema.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type AgentProtocol = 'http' | 'a2a' | 'ag-ui';
|
|
|
11
11
|
|
|
12
12
|
export type PyAgentAuth = 'iam' | 'cognito';
|
|
13
13
|
|
|
14
|
-
export type PyAgentSession = 'in-memory';
|
|
14
|
+
export type PyAgentSession = 's3' | 'dynamodb-s3' | 'in-memory';
|
|
15
15
|
|
|
16
16
|
export interface PyAgentGeneratorSchema {
|
|
17
17
|
project: string;
|