@aws/nx-plugin 1.0.0-rc.17 → 1.0.0-rc.19
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/generators.json +9 -1
- package/package.json +1 -1
- package/src/agentcore-gateway/attach-upstream.d.ts +33 -0
- package/src/agentcore-gateway/attach-upstream.js +41 -0
- package/src/agentcore-gateway/attach-upstream.js.map +1 -0
- package/src/agentcore-gateway/files/project/serve-local.ts.template +3 -2
- package/src/agentcore-gateway/gateway-connection/generator.d.ts +21 -0
- package/src/agentcore-gateway/gateway-connection/generator.js +102 -0
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -0
- package/src/agentcore-gateway/gateway-connection/schema.d.ts +12 -0
- package/src/agentcore-gateway/gateway-connection/schema.json +26 -0
- package/src/agentcore-gateway/mcp-connection/generator.js +8 -24
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/connection/generator.js +66 -63
- package/src/connection/generator.js.map +1 -1
- package/src/license/generator.js +8 -19
- package/src/license/generator.js.map +1 -1
- package/src/license/known-exceptions.d.ts +0 -1
- package/src/license/known-exceptions.js +1 -8
- package/src/license/known-exceptions.js.map +1 -1
- package/src/py/agent/__snapshots__/generator.spec.ts.snap +15 -6
- package/src/py/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +201 -0
- package/src/py/agent/a2a-connection/files/agent-connection/app/{__targetAgentSnakeCase___client.py.template → __targetAgentSnakeCase___client_strands.py.template} +7 -5
- package/src/py/agent/a2a-connection/generator.js +6 -5
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/files/http/main.py.template +2 -2
- package/src/py/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +197 -0
- package/src/py/agent/gateway-connection/files/agent-connection/app/{__gatewaySnakeCase___client.py.template → __gatewaySnakeCase___client_strands.py.template} +6 -6
- package/src/py/agent/gateway-connection/generator.js +5 -5
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/generator.js +3 -5
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +157 -79
- package/src/py/agent/mcp-connection/files/agent-connection/app/{__mcpServerSnakeCase___client.py.template → __mcpServerSnakeCase___client_strands.py.template} +7 -5
- package/src/py/agent/mcp-connection/generator.js +5 -5
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +37 -3
- package/src/py/fast-api/files/app/__name__/main.py.template +4 -1
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +13 -4
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/smithy/project/files/src/operations/echo.smithy.template +1 -0
- package/src/terraform/project/files/application/src/main.tf.template +6 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +35 -4
- package/src/trpc/backend/files/src/procedures/echo.ts.template +1 -1
- package/src/trpc/backend/files/src/schema/echo.ts.template +2 -2
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +14 -5
- package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +256 -0
- package/src/ts/agent/a2a-connection/files/agent-connection/app/{__targetAgentKebabCase__-client.ts.template → __targetAgentKebabCase__-client-strands.ts.template} +5 -5
- package/src/ts/agent/a2a-connection/generator.js +3 -3
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/files/http/router.ts.template +1 -1
- package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +220 -0
- package/src/ts/agent/gateway-connection/files/agent-connection/app/{__gatewayKebabCase__-client.ts.template → __gatewayKebabCase__-client-strands.ts.template} +5 -5
- package/src/ts/agent/gateway-connection/generator.js +3 -3
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.js +3 -0
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +183 -110
- package/src/ts/agent/mcp-connection/files/agent-connection/app/{__mcpServerKebabCase__-client.ts.template → __mcpServerKebabCase__-client-strands.ts.template} +5 -5
- package/src/ts/agent/mcp-connection/generator.js +3 -3
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +13 -4
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +64 -24
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +13 -4
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +9 -3
- package/src/utils/agent-connection/agent-connection.d.ts +50 -24
- package/src/utils/agent-connection/agent-connection.js +137 -45
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client-config.ts.template +93 -0
- package/src/utils/agent-connection/files/core-auth/agentcore-endpoints.ts.template +37 -0
- package/src/utils/agent-connection/files/core-auth/agentcore-fetch.ts.template +54 -0
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +41 -0
- package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-transport.ts.template +70 -0
- package/src/utils/agent-connection/files/core-shared/agentcore-transport.ts.template +39 -0
- package/src/utils/agent-connection/files/core-strands/a2a/agentcore-a2a-client-strands.ts.template +61 -0
- package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +26 -0
- package/src/utils/agent-connection/files/core-strands/mcp/agentcore-mcp-client-strands.ts.template +27 -0
- package/src/utils/agent-connection/files/py-core-a2a/agentcore_a2a_client_config.py.template +43 -0
- package/src/utils/agent-connection/files/py-core-auth/agentcore_endpoints.py.template +47 -0
- package/src/utils/agent-connection/files/py-core-auth/auth/session.py.template +51 -0
- package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_transport.py.template +28 -0
- package/src/utils/agent-connection/files/py-core-mcp/agentcore_mcp_transport.py.template +34 -0
- package/src/utils/agent-connection/files/py-core-shared/agentcore_transport.py.template +40 -0
- package/src/utils/agent-connection/files/py-core-strands/a2a/agentcore_a2a_client_strands.py.template +66 -0
- package/src/utils/agent-connection/files/py-core-strands/gateway/agentcore_gateway_mcp_client_strands.py.template +22 -0
- package/src/utils/agent-connection/files/py-core-strands/mcp/agentcore_mcp_client_strands.py.template +30 -0
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +3 -0
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +110 -28
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +95 -2
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +13 -4
- package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +9 -0
- package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +23 -1
- package/src/utils/files/terraform/src/core/runtime-config/appconfig-deployment/appconfig-deployment.tf.template +9 -3
- package/src/utils/files/terraform/src/core/runtime-config/read/read.tf.template +7 -2
- package/src/utils/identity-constructs/files/terraform/core/user-identity/add-callback-url/add-callback-url.tf.template +9 -3
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +22 -8
- package/src/utils/rdb-constructs/files/terraform/core/rdb/aurora/aurora.tf.template +10 -4
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
- package/src/utils/website-constructs/files/terraform/core/static-website/static-website.tf.template +13 -4
- package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client.ts.template +0 -123
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-client.ts.template +0 -78
- package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-client.ts.template +0 -128
- package/src/utils/agent-connection/files/py-core-a2a/agentcore_a2a_client.py.template +0 -120
- package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_client.py.template +0 -78
- package/src/utils/agent-connection/files/py-core-mcp/agentcore_mcp_client.py.template +0 -89
- /package/src/utils/agent-connection/files/{core-runtime-config/model-errors.ts.template → core-strands/base/model-errors-strands.ts.template} +0 -0
- /package/src/utils/agent-connection/files/{core-runtime-config/with-session-id.ts.template → core-strands/base/with-session-id-strands.ts.template} +0 -0
- /package/src/utils/agent-connection/files/{py-core-runtime-config/model_errors.py.template → py-core-strands/base/model_errors_strands.py.template} +0 -0
- /package/src/utils/agent-connection/files/{py-core-runtime-config/with_session_id.py.template → py-core-strands/base/with_session_id_strands.py.template} +0 -0
package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_client.py.template
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import re
|
|
2
|
-
|
|
3
|
-
import boto3
|
|
4
|
-
import httpx
|
|
5
|
-
from mcp.client.streamable_http import streamablehttp_client
|
|
6
|
-
from strands.tools.mcp.mcp_client import MCPClient
|
|
7
|
-
|
|
8
|
-
from .auth import SigV4HTTPXAuth
|
|
9
|
-
from .session_context import get_current_session_id
|
|
10
|
-
|
|
11
|
-
SESSION_HEADER = "X-Amzn-Bedrock-AgentCore-Runtime-Session-Id"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class _SessionHeaderAuth(httpx.Auth):
|
|
15
|
-
"""Stamps the AgentCore session header from the current async context."""
|
|
16
|
-
|
|
17
|
-
requires_request_body = True
|
|
18
|
-
requires_response_body = True
|
|
19
|
-
|
|
20
|
-
def __init__(self, inner: httpx.Auth | None = None):
|
|
21
|
-
self._inner = inner
|
|
22
|
-
|
|
23
|
-
def auth_flow(self, request: httpx.Request): # type: ignore[override]
|
|
24
|
-
sid = get_current_session_id()
|
|
25
|
-
if sid:
|
|
26
|
-
request.headers[SESSION_HEADER] = sid
|
|
27
|
-
if self._inner is None:
|
|
28
|
-
yield request
|
|
29
|
-
return
|
|
30
|
-
yield from self._inner.auth_flow(request)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def _parse_region_from_gateway_url(gateway_url: str) -> str:
|
|
34
|
-
match = re.search(r"\.bedrock-agentcore\.([^.]+)\.amazonaws\.com", gateway_url)
|
|
35
|
-
if not match:
|
|
36
|
-
raise ValueError(
|
|
37
|
-
f"Cannot determine region from gateway URL '{gateway_url}'. "
|
|
38
|
-
"Pass region explicitly."
|
|
39
|
-
)
|
|
40
|
-
return match.group(1)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class AgentCoreGatewayMCPClient:
|
|
44
|
-
"""Factory for MCP clients that connect to an AgentCore Gateway. Forwards
|
|
45
|
-
the current async-context session via the AgentCore session header, which
|
|
46
|
-
the gateway propagates to downstream MCP server targets.
|
|
47
|
-
"""
|
|
48
|
-
|
|
49
|
-
@staticmethod
|
|
50
|
-
def with_iam_auth(
|
|
51
|
-
gateway_url: str,
|
|
52
|
-
region: str | None = None,
|
|
53
|
-
) -> MCPClient:
|
|
54
|
-
"""Create a gateway MCP client authenticated with IAM SigV4."""
|
|
55
|
-
resolved_region = region or _parse_region_from_gateway_url(gateway_url)
|
|
56
|
-
credentials = boto3.Session(region_name=resolved_region).get_credentials()
|
|
57
|
-
return _create_client(
|
|
58
|
-
gateway_url,
|
|
59
|
-
_SessionHeaderAuth(
|
|
60
|
-
SigV4HTTPXAuth(credentials, "bedrock-agentcore", resolved_region),
|
|
61
|
-
),
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
@staticmethod
|
|
65
|
-
def without_auth(gateway_url: str) -> MCPClient:
|
|
66
|
-
"""Plain-HTTP gateway client, for the local gateway started by serve-local."""
|
|
67
|
-
return _create_client(gateway_url, _SessionHeaderAuth())
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def _create_client(gateway_url: str, auth: httpx.Auth) -> MCPClient:
|
|
71
|
-
return MCPClient(
|
|
72
|
-
lambda: streamablehttp_client(
|
|
73
|
-
gateway_url,
|
|
74
|
-
auth=auth,
|
|
75
|
-
timeout=120,
|
|
76
|
-
terminate_on_close=False,
|
|
77
|
-
)
|
|
78
|
-
)
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
from collections.abc import Callable
|
|
2
|
-
|
|
3
|
-
import boto3
|
|
4
|
-
import httpx
|
|
5
|
-
from mcp.client.streamable_http import streamablehttp_client
|
|
6
|
-
from strands.tools.mcp.mcp_client import MCPClient
|
|
7
|
-
|
|
8
|
-
from .auth import SigV4HTTPXAuth
|
|
9
|
-
from .session_context import get_current_session_id
|
|
10
|
-
|
|
11
|
-
SESSION_HEADER = "X-Amzn-Bedrock-AgentCore-Runtime-Session-Id"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class _SessionHeaderAuth(httpx.Auth):
|
|
15
|
-
"""Stamps the AgentCore session header from the current async context."""
|
|
16
|
-
|
|
17
|
-
requires_request_body = True
|
|
18
|
-
requires_response_body = True
|
|
19
|
-
|
|
20
|
-
def __init__(self, inner: httpx.Auth | None = None):
|
|
21
|
-
self._inner = inner
|
|
22
|
-
|
|
23
|
-
def auth_flow(self, request: httpx.Request): # type: ignore[override]
|
|
24
|
-
sid = get_current_session_id()
|
|
25
|
-
if sid:
|
|
26
|
-
request.headers[SESSION_HEADER] = sid
|
|
27
|
-
if self._inner is None:
|
|
28
|
-
yield request
|
|
29
|
-
return
|
|
30
|
-
yield from self._inner.auth_flow(request)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class AgentCoreMCPClient:
|
|
34
|
-
"""Factory for MCP clients that forward the current async-context session."""
|
|
35
|
-
|
|
36
|
-
@staticmethod
|
|
37
|
-
def _build_url(agent_runtime_arn: str) -> tuple[str, str]:
|
|
38
|
-
"""Extract region from ARN and construct the invocation URL.
|
|
39
|
-
|
|
40
|
-
ARN format: arn:partition:service:region:account-id:resource
|
|
41
|
-
"""
|
|
42
|
-
region = agent_runtime_arn.split(":")[3]
|
|
43
|
-
encoded_arn = agent_runtime_arn.replace(":", "%3A").replace("/", "%2F")
|
|
44
|
-
url = (
|
|
45
|
-
f"https://bedrock-agentcore.{region}.amazonaws.com/runtimes/"
|
|
46
|
-
f"{encoded_arn}/invocations?qualifier=DEFAULT"
|
|
47
|
-
)
|
|
48
|
-
return region, url
|
|
49
|
-
|
|
50
|
-
@staticmethod
|
|
51
|
-
def _create(url: str, auth: httpx.Auth | None = None) -> MCPClient:
|
|
52
|
-
return MCPClient(
|
|
53
|
-
lambda: streamablehttp_client(
|
|
54
|
-
url,
|
|
55
|
-
auth=_SessionHeaderAuth(auth),
|
|
56
|
-
timeout=120,
|
|
57
|
-
terminate_on_close=False,
|
|
58
|
-
)
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
@staticmethod
|
|
62
|
-
def with_iam_auth(agent_runtime_arn: str) -> MCPClient:
|
|
63
|
-
"""SigV4-authenticated client for a Bedrock AgentCore runtime."""
|
|
64
|
-
region, url = AgentCoreMCPClient._build_url(agent_runtime_arn)
|
|
65
|
-
credentials = boto3.Session(region_name=region).get_credentials()
|
|
66
|
-
return AgentCoreMCPClient._create(
|
|
67
|
-
url, SigV4HTTPXAuth(credentials, "bedrock-agentcore", region)
|
|
68
|
-
)
|
|
69
|
-
|
|
70
|
-
@staticmethod
|
|
71
|
-
def with_jwt_auth(
|
|
72
|
-
agent_runtime_arn: str, access_token_provider: Callable[[], str]
|
|
73
|
-
) -> MCPClient:
|
|
74
|
-
"""Bearer-authenticated client for a Bedrock AgentCore runtime."""
|
|
75
|
-
_, url = AgentCoreMCPClient._build_url(agent_runtime_arn)
|
|
76
|
-
return MCPClient(
|
|
77
|
-
lambda: streamablehttp_client(
|
|
78
|
-
url,
|
|
79
|
-
auth=_SessionHeaderAuth(),
|
|
80
|
-
headers={"Authorization": f"Bearer {access_token_provider()}"},
|
|
81
|
-
timeout=120,
|
|
82
|
-
terminate_on_close=False,
|
|
83
|
-
)
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
@staticmethod
|
|
87
|
-
def without_auth(url: str) -> MCPClient:
|
|
88
|
-
"""Plain-HTTP client — for local dev."""
|
|
89
|
-
return AgentCoreMCPClient._create(url)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|