chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 12:58:18 +08:00
commit 6d5d58c1a9
18293 changed files with 3502153 additions and 0 deletions
@@ -0,0 +1,24 @@
# ── Stack ──────────────────────────────────────────────────────────────────────
# Get these from your deployed stack outputs:
# aws cloudformation describe-stacks --stack-name <name> --query "Stacks[0].Outputs"
STACK_NAME=my-copilotkit-agentcore-lg # or -st for Strands
MEMORY_ID= # MemoryArn last segment (after final /)
# ── AWS credentials ────────────────────────────────────────────────────────────
# Docker containers can't read ~/.aws/credentials — paste your creds here.
# Run: aws configure export-credentials --format env (for SSO / temp creds)
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_SESSION_TOKEN= # leave blank if using long-term creds
AWS_DEFAULT_REGION=us-east-1
# ── Agent selection ────────────────────────────────────────────────────────────
# Which agent to run locally: langgraph or strands (default: strands)
AGENT=strands
# ── CopilotKit Intelligence / Threads (optional) ──────────────────────────────
# Enables persistent Threads in the CopilotKit bridge + frontend.
COPILOTKIT_LICENSE_TOKEN=
INTELLIGENCE_API_KEY=
INTELLIGENCE_API_URL=http://localhost:4201
INTELLIGENCE_GATEWAY_WS_URL=ws://localhost:4401
@@ -0,0 +1,7 @@
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
CMD ["node", "dist/server.js"]
@@ -0,0 +1,21 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy source code
COPY . .
# Expose port
EXPOSE 3000
# Start development server (--host exposes to Docker network)
CMD ["npm", "run", "dev", "--", "--host"]
@@ -0,0 +1,100 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Use ./up.sh instead of docker compose directly —
# it resolves STACK_NAME + MEMORY_ID and generates a local aws-exports.json.
#
# Requires a deployed AWS stack. See ../docs/LOCAL_DEVELOPMENT.md.
#
# Frontend hot reloads on save (volume mount + Vite).
# Agent changes require: docker compose up --build agent
services:
agent:
build:
context: ..
dockerfile: agents/${AGENT:-langgraph}-single-agent/Dockerfile
platforms:
- linux/arm64
ports:
- "8080:8080"
environment:
- MEMORY_ID=${MEMORY_ID}
- STACK_NAME=${STACK_NAME}
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-us-east-1}
- AWS_REGION=${AWS_DEFAULT_REGION:-us-east-1}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
- AGUI_ENABLED=true
- GATEWAY_CREDENTIAL_PROVIDER_NAME=${STACK_NAME}-runtime-gateway-auth
- OTEL_SDK_DISABLED=true
develop:
watch:
- action: sync+restart
path: ../agents/${AGENT:-langgraph}-single-agent
target: /app
ignore:
- __pycache__/
- "*.pyc"
- action: sync+restart
path: ../agents/utils
target: /app/utils
ignore:
- __pycache__/
healthcheck:
test:
[
"CMD",
"python",
"-c",
"import urllib.request; urllib.request.urlopen('http://localhost:8080/ping', timeout=2)",
]
interval: 30s
timeout: 3s
retries: 3
start_period: 15s
networks:
- agentcore-network
bridge:
build:
context: ../infra-cdk/lambdas/copilotkit-runtime
dockerfile: ../../../docker/Dockerfile.bridge.dev
ports:
- "3001:3001"
environment:
- AGENTCORE_AG_UI_URL=http://agent:8080/invocations
- PORT=3001
- OTEL_SDK_DISABLED=true
- COPILOTKIT_LICENSE_TOKEN=${COPILOTKIT_LICENSE_TOKEN}
- INTELLIGENCE_API_KEY=${INTELLIGENCE_API_KEY}
- INTELLIGENCE_API_URL=${INTELLIGENCE_API_URL:-http://localhost:4201}
- INTELLIGENCE_GATEWAY_WS_URL=${INTELLIGENCE_GATEWAY_WS_URL:-ws://localhost:4401}
depends_on:
agent:
condition: service_healthy
networks:
- agentcore-network
frontend:
build:
context: ../frontend
dockerfile: ../docker/Dockerfile.frontend.dev
ports:
- "3000:3000"
volumes:
- ../frontend:/app
- /app/node_modules
environment:
- NODE_ENV=development
- VITE_COPILOTKIT_THREADS_ENABLED=${COPILOTKIT_LICENSE_TOKEN:+true}
depends_on:
bridge:
condition: service_started
networks:
- agentcore-network
networks:
agentcore-network:
driver: bridge
@@ -0,0 +1,35 @@
"""
Resolves STACK_NAME and MEMORY_ID from config.yaml + CloudFormation
and writes them to /env/agent.env for the agent container.
"""
import boto3
import os
import re
import yaml
with open("/config.yaml") as f:
cfg = yaml.safe_load(f)
base = re.sub(r"-(lg|st)$", "", cfg["stack_name_base"])
agent = os.environ.get("AGENT", "langgraph")
suffix = "lg" if agent == "langgraph" else "st"
stack_name = f"{base}-{suffix}"
cf = boto3.client(
"cloudformation", region_name=os.environ.get("AWS_DEFAULT_REGION", "us-east-1")
)
stacks = cf.describe_stacks(StackName=stack_name)["Stacks"]
outputs = {
o["OutputKey"]: o["OutputValue"] for s in stacks for o in s.get("Outputs", [])
}
memory_arn = outputs.get("MemoryArn", "")
memory_id = memory_arn.split("/")[-1] if "/" in memory_arn else memory_arn
os.makedirs("/out", exist_ok=True)
with open("/out/agent.env", "w") as f:
f.write(f"STACK_NAME={stack_name}\n")
f.write(f"MEMORY_ID={memory_id}\n")
print(f"Stack: {stack_name} | Memory: {memory_id}")
+84
View File
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
# Convenience wrapper — auto-fills .env with stack outputs, generates a local
# aws-exports.json pointing at localhost, then runs docker compose.
#
# Usage: ./up.sh [--build]
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG="$SCRIPT_DIR/../config.yaml"
ENV_FILE="$SCRIPT_DIR/.env"
[[ -f "$ENV_FILE" ]] || { echo "ERROR: .env not found. Run: cp .env.example .env"; exit 1; }
# Read AGENT from .env
AGENT=$(grep "^AGENT=" "$ENV_FILE" 2>/dev/null | cut -d= -f2 || echo "langgraph")
AGENT="${AGENT:-langgraph}"
# Derive stack name from config.yaml
BASE=$(python3 -c "
import re, yaml
cfg = yaml.safe_load(open('$CONFIG'))
print(re.sub(r'-(lg|st)$', '', cfg['stack_name_base']))
")
SUFFIX="st" && [[ "$AGENT" == "langgraph" ]] && SUFFIX="lg"
STACK_NAME="${BASE}-${SUFFIX}"
echo "Agent: $AGENT | Resolving stack: $STACK_NAME..."
OUTPUTS=$(aws cloudformation describe-stacks \
--stack-name "$STACK_NAME" \
--query "Stacks[0].Outputs" \
--output json)
python3 - "$OUTPUTS" "$STACK_NAME" "$ENV_FILE" "$SCRIPT_DIR/../frontend/public" "$AGENT" <<'PYEOF'
import json, os, sys, re
outputs_json, stack_name, env_file, public_dir, agent = sys.argv[1:]
outputs = {o["OutputKey"]: o["OutputValue"] for o in json.loads(outputs_json)}
# Patch STACK_NAME and MEMORY_ID into .env
memory_arn = outputs.get("MemoryArn", "")
memory_id = memory_arn.split("/")[-1] if "/" in memory_arn else memory_arn
with open(env_file) as f:
content = f.read()
for key, val in [("STACK_NAME", stack_name), ("MEMORY_ID", memory_id)]:
if re.search(rf"^{key}=", content, re.MULTILINE):
content = re.sub(rf"^{key}=.*", f"{key}={val}", content, flags=re.MULTILINE)
else:
content += f"\n{key}={val}"
with open(env_file, "w") as f:
f.write(content)
# Generate local aws-exports.json pointing at localhost
pool_id = outputs.get("CognitoUserPoolId", "")
client_id = outputs.get("CognitoClientId", "")
runtime_arn = outputs.get("RuntimeArn", "")
pattern = "langgraph-single-agent" if agent == "langgraph" else "strands-single-agent"
aws_exports = {
"authority": f"https://cognito-idp.us-east-1.amazonaws.com/{pool_id}",
"client_id": client_id,
"redirect_uri": "http://localhost:3000",
"post_logout_redirect_uri": "http://localhost:3000",
"response_type": "code",
"scope": "email openid profile",
"automaticSilentRenew": True,
"agentRuntimeArn": runtime_arn,
"awsRegion": "us-east-1",
"copilotKitRuntimeUrl": "http://localhost:3001/copilotkit",
"agentPattern": pattern,
}
os.makedirs(public_dir, exist_ok=True)
with open(f"{public_dir}/aws-exports.json", "w") as f:
json.dump(aws_exports, f, indent=2)
print(f"✓ Stack: {stack_name} | Memory: {memory_id}")
print(f"✓ aws-exports.json → localhost:3001")
PYEOF
set -a && source "$ENV_FILE" 2>/dev/null || true && set +a
AGENT="$AGENT" STACK_NAME="$STACK_NAME" \
docker compose -f "$SCRIPT_DIR/docker-compose.yml" up --watch "$@"