@aws/nx-plugin 1.0.0-rc.11 → 1.0.0-rc.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-THIRD-PARTY +81 -3
- package/generators.json +31 -1
- package/package.json +2 -2
- package/sdk/agentcore-gateway.d.ts +6 -0
- package/sdk/agentcore-gateway.js +11 -0
- package/sdk/agentcore-gateway.js.map +1 -0
- package/sdk/license.d.ts +4 -4
- package/sdk/license.js +5 -4
- package/sdk/license.js.map +1 -1
- package/sdk/py.d.ts +6 -6
- package/sdk/py.js +7 -7
- package/sdk/py.js.map +1 -1
- package/sdk/ts.d.ts +18 -14
- package/sdk/ts.js +38 -32
- package/sdk/ts.js.map +1 -1
- package/src/agentcore-gateway/files/cedar/policies/README.md +52 -0
- package/src/agentcore-gateway/files/cedar/policies/permit-all.cedar +11 -0
- package/src/agentcore-gateway/files/project/serve-local.ts.template +133 -0
- package/src/agentcore-gateway/generator.d.ts +25 -0
- package/src/agentcore-gateway/generator.js +129 -0
- package/src/agentcore-gateway/generator.js.map +1 -0
- package/src/agentcore-gateway/mcp-connection/generator.d.ts +19 -0
- package/src/agentcore-gateway/mcp-connection/generator.js +79 -0
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -0
- package/src/agentcore-gateway/mcp-connection/schema.d.ts +12 -0
- package/src/agentcore-gateway/mcp-connection/schema.json +26 -0
- package/src/agentcore-gateway/schema.d.ts +16 -0
- package/src/agentcore-gateway/schema.json +65 -0
- package/src/connection/generator.d.ts +1 -1
- package/src/connection/generator.js +64 -46
- package/src/connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +9 -9
- package/src/mcp-server/schema-registry.d.ts +9 -3
- package/src/mcp-server/schema-registry.js +22 -6
- package/src/mcp-server/schema-registry.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +3 -1
- package/src/py/agent/__snapshots__/generator.spec.ts.snap +629 -7
- package/src/py/agent/a2a-connection/files/agent-connection/app/__targetAgentSnakeCase___client.py.template +9 -3
- package/src/py/agent/a2a-connection/generator.js +1 -1
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/files/http/init.py.template +5 -23
- package/src/py/agent/gateway-connection/files/agent-connection/app/__gatewaySnakeCase___client.py.template +35 -0
- package/src/py/agent/gateway-connection/generator.d.ts +10 -0
- package/src/py/agent/gateway-connection/generator.js +106 -0
- package/src/py/agent/gateway-connection/generator.js.map +1 -0
- package/src/py/agent/gateway-connection/schema.d.ts +12 -0
- package/src/py/agent/gateway-connection/schema.json +26 -0
- package/src/py/agent/generator.js +27 -22
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +8 -4
- package/src/py/agent/mcp-connection/files/agent-connection/app/__mcpServerSnakeCase___client.py.template +9 -3
- package/src/py/agent/mcp-connection/generator.js +2 -72
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +5 -22
- package/src/py/fast-api/files/app/__name__/init.py.template +5 -22
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +58 -3
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +619 -2
- package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client.ts.template +10 -6
- package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client.ts.template +30 -0
- package/src/ts/agent/gateway-connection/generator.d.ts +10 -0
- package/src/ts/agent/gateway-connection/generator.js +106 -0
- package/src/ts/agent/gateway-connection/generator.js.map +1 -0
- package/src/ts/agent/gateway-connection/schema.d.ts +12 -0
- package/src/ts/agent/gateway-connection/schema.json +26 -0
- package/src/ts/agent/generator.js +23 -19
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +9 -4
- package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client.ts.template +9 -6
- package/src/ts/agent/mcp-connection/generator.js +1 -13
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +58 -3
- package/src/ts/nx-generator/generator.js +29 -0
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +86 -39
- package/src/utils/agent-chat/agent-chat.d.ts +31 -0
- package/src/utils/agent-chat/agent-chat.js +30 -0
- package/src/utils/agent-chat/agent-chat.js.map +1 -0
- package/src/utils/agent-chat/files/a2a/chat.ts.template +33 -0
- package/src/utils/agent-chat/files/ag-ui/chat.ts.template +17 -0
- package/src/utils/agent-chat/files/common/agentcore.ts.template +81 -0
- package/src/utils/agent-chat/files/http-py/chat.ts.template +43 -0
- package/src/utils/agent-chat/files/http-ts/chat.ts.template +54 -0
- package/src/utils/agent-connection/agent-connection.d.ts +17 -0
- package/src/utils/agent-connection/agent-connection.js +94 -0
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-client.ts.template +78 -0
- package/src/utils/agent-connection/files/core-runtime-config/runtime-config.ts.template +22 -32
- package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_client.py.template +78 -0
- package/src/utils/agent-connection/files/py-core-runtime-config/runtime_config.py.template +5 -18
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +8 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js +54 -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 +4 -0
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +37 -0
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +293 -0
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/readiness-probe/index.js.template +55 -0
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +242 -0
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/render-cedar.cjs.template +13 -0
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +55 -2
- package/src/utils/agent-core-constructs/files/terraform/core/agentcore-gateway/gateway.tf.template +14 -0
- package/src/utils/versions.d.ts +46 -44
- package/src/utils/versions.js +45 -43
- package/src/utils/versions.js.map +1 -1
- package/src/py/agent/scripts/http/chat.ts.template +0 -38
- package/src/ts/agent/scripts/http/chat.ts.template +0 -35
|
@@ -8,7 +8,6 @@ from urllib.parse import urlparse
|
|
|
8
8
|
from aws_lambda_powertools import Logger, Metrics, Tracer
|
|
9
9
|
from aws_lambda_powertools.metrics import MetricUnit
|
|
10
10
|
from fastapi import FastAPI, Request, Response
|
|
11
|
-
from fastapi.openapi.utils import get_openapi
|
|
12
11
|
from fastapi.responses import JSONResponse, StreamingResponse
|
|
13
12
|
from fastapi.routing import APIRoute
|
|
14
13
|
from pydantic import BaseModel
|
|
@@ -73,7 +72,11 @@ class JsonStreamingResponse(StreamingResponse):
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
|
|
76
|
-
app = FastAPI(
|
|
75
|
+
app = FastAPI(
|
|
76
|
+
title="<%= apiNameClassName %>",
|
|
77
|
+
responses={500: {"model": InternalServerErrorDetails}},
|
|
78
|
+
generate_unique_id_function=lambda route: route.name,
|
|
79
|
+
)
|
|
77
80
|
|
|
78
81
|
|
|
79
82
|
# Add cors middleware
|
|
@@ -174,23 +177,3 @@ class LoggerRouteHandler(APIRoute):
|
|
|
174
177
|
|
|
175
178
|
|
|
176
179
|
app.router.route_class = LoggerRouteHandler
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def custom_openapi() -> dict[str, Any]:
|
|
180
|
-
if app.openapi_schema:
|
|
181
|
-
return app.openapi_schema
|
|
182
|
-
for route in app.routes:
|
|
183
|
-
if isinstance(route, APIRoute):
|
|
184
|
-
route.operation_id = route.name
|
|
185
|
-
openapi_schema = get_openapi(
|
|
186
|
-
title=app.title,
|
|
187
|
-
version=app.version,
|
|
188
|
-
openapi_version=app.openapi_version,
|
|
189
|
-
description=app.description,
|
|
190
|
-
routes=app.routes,
|
|
191
|
-
)
|
|
192
|
-
app.openapi_schema = openapi_schema
|
|
193
|
-
return app.openapi_schema
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
app.openapi = custom_openapi # ty: ignore[invalid-assignment]
|
|
@@ -44,6 +44,8 @@ export class SnapshotBedrockServer
|
|
|
44
44
|
{
|
|
45
45
|
public readonly dockerImage: AgentRuntimeArtifact;
|
|
46
46
|
public readonly agentCoreRuntime: Runtime;
|
|
47
|
+
/** Default Gateway target name for this MCP server. */
|
|
48
|
+
public readonly mcpServerName = 'snapshot-bedrock-server';
|
|
47
49
|
|
|
48
50
|
constructor(
|
|
49
51
|
scope: Construct,
|
|
@@ -464,6 +466,59 @@ resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
|
|
|
464
466
|
]
|
|
465
467
|
}
|
|
466
468
|
|
|
469
|
+
# MCP consumers (e.g. gateway targets, which fetch tools at creation) can race
|
|
470
|
+
# the runtime's first cold start, so probe it until it serves MCP. The ARN
|
|
471
|
+
# output is routed through this resource so consumers wait for readiness.
|
|
472
|
+
resource "null_resource" "runtime_ready" {
|
|
473
|
+
count = var.server_protocol == "MCP" ? 1 : 0
|
|
474
|
+
|
|
475
|
+
triggers = {
|
|
476
|
+
runtime_arn = aws_bedrockagentcore_agent_runtime.agent_runtime.agent_runtime_arn
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
provisioner "local-exec" {
|
|
480
|
+
command = <<-EOT
|
|
481
|
+
uv run --with boto3 python -c "
|
|
482
|
+
import boto3
|
|
483
|
+
import json
|
|
484
|
+
import time
|
|
485
|
+
import uuid
|
|
486
|
+
|
|
487
|
+
runtime_arn = '\${self.triggers.runtime_arn}'
|
|
488
|
+
client = boto3.client('bedrock-agentcore')
|
|
489
|
+
initialize_request = json.dumps({
|
|
490
|
+
'jsonrpc': '2.0',
|
|
491
|
+
'id': 1,
|
|
492
|
+
'method': 'initialize',
|
|
493
|
+
'params': {
|
|
494
|
+
'protocolVersion': '2025-03-26',
|
|
495
|
+
'capabilities': {},
|
|
496
|
+
'clientInfo': {'name': 'readiness-probe', 'version': '1.0'},
|
|
497
|
+
},
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
deadline = time.time() + 3 * 60
|
|
501
|
+
while True:
|
|
502
|
+
try:
|
|
503
|
+
client.invoke_agent_runtime(
|
|
504
|
+
agentRuntimeArn=runtime_arn,
|
|
505
|
+
runtimeSessionId=f'readiness-probe-{uuid.uuid4()}',
|
|
506
|
+
contentType='application/json',
|
|
507
|
+
accept='application/json, text/event-stream',
|
|
508
|
+
payload=initialize_request,
|
|
509
|
+
)
|
|
510
|
+
break
|
|
511
|
+
except Exception:
|
|
512
|
+
if time.time() >= deadline:
|
|
513
|
+
raise
|
|
514
|
+
time.sleep(5)
|
|
515
|
+
|
|
516
|
+
print(f'Runtime {runtime_arn} is serving MCP')
|
|
517
|
+
"
|
|
518
|
+
EOT
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
467
522
|
# Outputs
|
|
468
523
|
output "agent_core_runtime_role_arn" {
|
|
469
524
|
description = "ARN of the Agent Core Runtime IAM role"
|
|
@@ -481,8 +536,8 @@ output "agent_runtime_name" {
|
|
|
481
536
|
}
|
|
482
537
|
|
|
483
538
|
output "agent_core_runtime_arn" {
|
|
484
|
-
description = "ARN of the Bedrock Agent Core runtime"
|
|
485
|
-
value = aws_bedrockagentcore_agent_runtime.agent_runtime.agent_runtime_arn
|
|
539
|
+
description = "ARN of the Bedrock Agent Core runtime. For MCP runtimes the value flows through the readiness probe, so consumers wait until the runtime serves MCP."
|
|
540
|
+
value = var.server_protocol == "MCP" ? null_resource.runtime_ready[0].triggers.runtime_arn : aws_bedrockagentcore_agent_runtime.agent_runtime.agent_runtime_arn
|
|
486
541
|
}
|
|
487
542
|
|
|
488
543
|
output "agent_runtime_id" {
|
|
@@ -649,7 +704,7 @@ dependencies = [
|
|
|
649
704
|
"aws-lambda-powertools==3.29.0",
|
|
650
705
|
"mcp==1.27.2",
|
|
651
706
|
"uvicorn==0.49.0",
|
|
652
|
-
"boto3==1.43.
|
|
707
|
+
"boto3==1.43.29",
|
|
653
708
|
"aws-opentelemetry-distro==0.17.1"
|
|
654
709
|
]
|
|
655
710
|
|