11# Local Development Script - Start frontend and AgentCore backend locally
22
3- Write-Host " 🚀 Starting Local Development Mode" - ForegroundColor Cyan
4- Write-Host " ==================================" - ForegroundColor Cyan
3+ Write-Host " === Local Development Mode ===" - ForegroundColor Cyan
54
6- # Check if Python is available
5+ # Step 1: Verify AWS credentials
6+ Write-Host " `n [1/7] Verifying AWS credentials..." - ForegroundColor Yellow
7+ Write-Host " (Required for AWS service access when running agent locally)" - ForegroundColor Gray
8+
9+ # Check if AWS credentials are configured
10+ $callerIdentity = aws sts get-caller - identity 2>&1
11+
12+ if ($LASTEXITCODE -ne 0 ) {
13+ Write-Host " ❌ AWS credentials are not configured or have expired" - ForegroundColor Red
14+ Write-Host " `n Please configure AWS credentials using one of these methods:" - ForegroundColor Yellow
15+ Write-Host " 1. Run: aws configure" - ForegroundColor Cyan
16+ Write-Host " 2. Set environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY" - ForegroundColor Cyan
17+ Write-Host " 3. Use AWS SSO: aws sso login --profile <profile-name>" - ForegroundColor Cyan
18+ Write-Host " `n For more info: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html" - ForegroundColor Gray
19+ exit 1
20+ }
21+
22+ # Display current AWS identity
23+ $accountId = ($callerIdentity | ConvertFrom-Json ).Account
24+ $arn = ($callerIdentity | ConvertFrom-Json ).Arn
25+ Write-Host " ✓ Authenticated as: $arn " - ForegroundColor Green
26+ Write-Host " AWS Account: $accountId " - ForegroundColor Green
27+
28+ # Step 2: Check AWS CLI version
29+ Write-Host " `n [2/7] Checking AWS CLI version..." - ForegroundColor Yellow
30+ Write-Host " (Ensuring compatibility with Bedrock service)" - ForegroundColor Gray
31+ $awsVersion = aws -- version 2>&1
32+ $versionMatch = $awsVersion -match ' aws-cli/(\d+)\.(\d+)\.(\d+)'
33+ if ($versionMatch ) {
34+ $major = [int ]$Matches [1 ]
35+ $minor = [int ]$Matches [2 ]
36+ $patch = [int ]$Matches [3 ]
37+ Write-Host " Current version: aws-cli/$major .$minor .$patch " - ForegroundColor Gray
38+
39+ # Check if version is >= 2.31.13 (recommended for Bedrock)
40+ $isVersionValid = ($major -gt 2 ) -or
41+ ($major -eq 2 -and $minor -gt 31 ) -or
42+ ($major -eq 2 -and $minor -eq 31 -and $patch -ge 13 )
43+
44+ if (-not $isVersionValid ) {
45+ Write-Host " ⚠ AWS CLI version 2.31.13 or later is recommended for Bedrock" - ForegroundColor Yellow
46+ Write-Host " Your current version: aws-cli/$major .$minor .$patch " - ForegroundColor Yellow
47+ Write-Host " Consider upgrading: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html" - ForegroundColor Gray
48+ } else {
49+ Write-Host " ✓ AWS CLI version is compatible" - ForegroundColor Green
50+ }
51+ } else {
52+ Write-Host " ⚠ Could not parse AWS CLI version, continuing anyway..." - ForegroundColor Yellow
53+ }
54+
55+ # Step 3: Check AgentCore availability in current region
56+ Write-Host " `n [3/7] Checking AgentCore availability in current region..." - ForegroundColor Yellow
57+ Write-Host " (Verifying AgentCore service availability)" - ForegroundColor Gray
58+ # Detect current region from AWS CLI configuration
59+ $currentRegion = aws configure get region
60+ if ([string ]::IsNullOrEmpty($currentRegion )) {
61+ Write-Host " ❌ No AWS region configured" - ForegroundColor Red
62+ Write-Host " "
63+ Write-Host " Please configure your AWS region using:" - ForegroundColor Yellow
64+ Write-Host " aws configure set region <your-region>" - ForegroundColor Cyan
65+ Write-Host " "
66+ Write-Host " For supported regions, see:" - ForegroundColor Gray
67+ Write-Host " https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-regions.html" - ForegroundColor Gray
68+ exit 1
69+ }
70+ Write-Host " Target region: $currentRegion " - ForegroundColor Gray
71+
72+ # Try to list AgentCore runtimes to verify service availability
73+ $agentCoreCheck = aws bedrock- agentcore- control list- agent- runtimes -- region $currentRegion -- max- results 1 2>&1
74+ if ($LASTEXITCODE -ne 0 ) {
75+ $errorMessage = $agentCoreCheck | Out-String
76+ Write-Host " ❌ AgentCore is not available in region: $currentRegion " - ForegroundColor Red
77+ Write-Host " "
78+ Write-Host " Error details:" - ForegroundColor Gray
79+ Write-Host " $errorMessage " - ForegroundColor DarkGray
80+ Write-Host " "
81+ Write-Host " For supported regions, see:" - ForegroundColor Gray
82+ Write-Host " https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-regions.html" - ForegroundColor Gray
83+ exit 1
84+ }
85+ Write-Host " ✓ AgentCore is available in $currentRegion " - ForegroundColor Green
86+
87+ # Step 4: Check Python availability
88+ Write-Host " `n [4/7] Checking Python installation..." - ForegroundColor Yellow
89+ Write-Host " (Required for running the agent locally)" - ForegroundColor Gray
790if (-not (Get-Command python - ErrorAction SilentlyContinue)) {
8- Write-Host " ❌ Python 3 is required but not installed" - ForegroundColor Red
91+ Write-Host " ❌ Python 3.8+ is required but not installed" - ForegroundColor Red
92+ Write-Host " "
93+ Write-Host " Please install Python 3.8 or later:" - ForegroundColor Yellow
94+ Write-Host " https://www.python.org/downloads/" - ForegroundColor Cyan
995 exit 1
1096}
1197
12- # Check if Node.js is available
98+ $pythonVersion = python -- version 2>&1
99+ Write-Host " ✓ $pythonVersion " - ForegroundColor Green
100+
101+ # Step 5: Check Node.js availability
102+ Write-Host " `n [5/7] Checking Node.js installation..." - ForegroundColor Yellow
103+ Write-Host " (Required for frontend development server)" - ForegroundColor Gray
13104if (-not (Get-Command node - ErrorAction SilentlyContinue)) {
14- Write-Host " ❌ Node.js is required but not installed" - ForegroundColor Red
105+ Write-Host " ❌ Node.js 18+ is required but not installed" - ForegroundColor Red
106+ Write-Host " "
107+ Write-Host " Please install Node.js 18 or later:" - ForegroundColor Yellow
108+ Write-Host " https://nodejs.org/en/download/" - ForegroundColor Cyan
15109 exit 1
16110}
17111
112+ $nodeVersion = node -- version 2>&1
113+ Write-Host " ✓ Node.js $nodeVersion " - ForegroundColor Green
114+
115+ # Step 6: Install dependencies
116+ Write-Host " `n [6/7] Installing dependencies..." - ForegroundColor Yellow
117+
18118# Install agent dependencies if needed
19- Write-Host " 📦 Installing agent dependencies..." - ForegroundColor Yellow
119+ Write-Host " Installing agent dependencies..." - ForegroundColor Gray
120+ Write-Host " (bedrock-agentcore for local HTTP server, strands-agents framework, boto3 for AWS)" - ForegroundColor DarkGray
20121if (-not (Test-Path " agent/venv" )) {
21- Write-Host " Creating Python virtual environment..." - ForegroundColor Gray
122+ Write-Host " Creating Python virtual environment and installing dependencies ..." - ForegroundColor DarkGray
22123 Push-Location agent
23124 python - m venv venv
24125 & " venv/Scripts/Activate.ps1"
25126 pip install - r requirements.txt
26127 Pop-Location
27128} else {
28- Write-Host " Virtual environment already exists" - ForegroundColor Gray
129+ Write-Host " Virtual environment already exists" - ForegroundColor DarkGray
29130}
30131
31132# Install frontend dependencies if needed
32- Write-Host " 📦 Installing frontend dependencies..." - ForegroundColor Yellow
133+ Write-Host " Installing frontend dependencies..." - ForegroundColor Gray
33134Push-Location frontend
34135if (-not (Test-Path " node_modules" )) {
35136 npm install
137+ } else {
138+ Write-Host " Frontend dependencies already installed" - ForegroundColor DarkGray
36139}
37140Pop-Location
38141
39142# Create local environment file for frontend
40- Write-Host " ⚙️ Setting up local environment..." - ForegroundColor Yellow
143+ Write-Host " Setting up local environment configuration ..." - ForegroundColor Gray
41144
42145# Remove any production environment file
43146if (Test-Path " frontend/.env.production.local" ) {
@@ -49,37 +152,31 @@ VITE_LOCAL_DEV=true
49152VITE_AGENT_RUNTIME_URL=/api
50153"@ | Out-File - FilePath " frontend/.env.local" - Encoding UTF8
51154
52- Write-Host " Created local development environment configuration" - ForegroundColor Gray
155+ Write-Host " ✓ Created local development environment configuration" - ForegroundColor Green
156+
157+ # Step 7: Start services
158+ Write-Host " `n [7/7] Starting local development services..." - ForegroundColor Yellow
53159
54160Write-Host " "
55- Write-Host " 🎯 Starting services..." - ForegroundColor Green
56161Write-Host " Backend will be available at: http://localhost:8080" - ForegroundColor Cyan
57162Write-Host " Frontend will be available at: http://localhost:5173" - ForegroundColor Cyan
58163Write-Host " "
164+ Write-Host " Development Workflow:" - ForegroundColor Yellow
165+ Write-Host " • Changes to frontend\ files → Immediate hot reload" - ForegroundColor Gray
166+ Write-Host " • Changes to agent\ files → Restart this script (Ctrl+C then re-run)" - ForegroundColor Gray
167+ Write-Host " "
59168Write-Host " Press Ctrl+C to stop all services" - ForegroundColor Yellow
60169Write-Host " "
61170
62171# Start AgentCore backend in background
63- Write-Host " 🔧 Starting AgentCore backend..." - ForegroundColor Blue
64-
65- # Check if AWS credentials are available
66- $callerIdentity = aws sts get-caller - identity 2>&1
67- if ($LASTEXITCODE -ne 0 ) {
68- Write-Host " ⚠️ AWS credentials not found. The agent needs AWS credentials to call Bedrock." - ForegroundColor Yellow
69- Write-Host " Please configure AWS credentials using one of these methods:" - ForegroundColor Yellow
70- Write-Host " 1. aws configure" - ForegroundColor Cyan
71- Write-Host " 2. aws sso login --profile <profile-name>" - ForegroundColor Cyan
72- Write-Host " 3. Set environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY" - ForegroundColor Cyan
73- Write-Host " "
74- Write-Host " Press Enter to continue anyway, or Ctrl+C to exit and configure credentials first..." - ForegroundColor Yellow
75- Read-Host
76- }
77-
172+ Write-Host " Starting AgentCore backend..." - ForegroundColor Blue
78173Push-Location agent
79174& " venv/Scripts/Activate.ps1"
80175$backendJob = Start-Job - ScriptBlock {
81176 Set-Location $using :PWD / agent
82177 & " venv/Scripts/Activate.ps1"
178+ # Set UTF-8 encoding for Python to handle Unicode characters properly on Windows
179+ $env: PYTHONIOENCODING = " utf-8"
83180 python strands_agent.py
84181}
85182Pop-Location
@@ -88,7 +185,7 @@ Pop-Location
88185Start-Sleep - Seconds 3
89186
90187# Start frontend dev server in background
91- Write-Host " 🎨 Starting frontend dev server..." - ForegroundColor Magenta
188+ Write-Host " Starting frontend dev server..." - ForegroundColor Magenta
92189Push-Location frontend
93190$frontendJob = Start-Job - ScriptBlock {
94191 Set-Location $using :PWD / frontend
@@ -99,7 +196,7 @@ Pop-Location
99196# Function to cleanup
100197function Cleanup {
101198 Write-Host " "
102- Write-Host " 🛑 Stopping services..." - ForegroundColor Red
199+ Write-Host " `n Stopping services..." - ForegroundColor Red
103200 Stop-Job $backendJob , $frontendJob - ErrorAction SilentlyContinue
104201 Remove-Job $backendJob , $frontendJob - ErrorAction SilentlyContinue
105202}
0 commit comments