-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathMakefile
More file actions
1514 lines (1379 loc) · 57 KB
/
Makefile
File metadata and controls
1514 lines (1379 loc) · 57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Makefile for Step Functions AI Agent project
# ============================================
# Environment variables
PYTHON := python3
UV := uv
NPM := npm
CARGO := cargo
CARGO_LAMBDA := cargo lambda
MVN := mvn
GO := go
CDK := npx cdk
# AWS Configuration
AWS_PROFILE ?= default
AWS_REGION ?= us-west-2
ENV_NAME ?= prod
# Directories
LAMBDA_DIR := lambda
TOOLS_DIR := $(LAMBDA_DIR)/tools
CALL_LLM_DIR := $(LAMBDA_DIR)/call_llm
CALL_LLM_RUST_DIR := $(LAMBDA_DIR)/call_llm_rust
TEST_DIR := tests
UI_DIR := ui_amplify
AGENT_CORE_DIR := agent_core
# Python tools directories
PYTHON_TOOLS := $(TOOLS_DIR)/code-interpreter $(TOOLS_DIR)/db-interface $(TOOLS_DIR)/graphql-interface $(TOOLS_DIR)/cloudwatch-queries
# TypeScript tools directories
TS_TOOLS := $(TOOLS_DIR)/google-maps
# Rust tools directories
RUST_TOOLS := $(TOOLS_DIR)/rust-clustering $(TOOLS_DIR)/local-agent
RUST_LLM := $(CALL_LLM_RUST_DIR)
# Java tools directories
JAVA_TOOLS := $(TOOLS_DIR)/stock-analyzer
# Go tools directories
GO_TOOLS := $(TOOLS_DIR)/web-research $(TOOLS_DIR)/web-scraper
# Virtual environment
VENV := venv
VENV_BIN := $(VENV)/bin
VENV_PYTHON := $(shell pwd)/$(VENV)/bin/python
VENV_PIP := $(VENV_BIN)/pip
# ============================================
# Default target
# ============================================
.PHONY: all
all: clean setup build test
# ============================================
# Help target - Display available commands
# ============================================
.PHONY: help
help:
@echo "╔════════════════════════════════════════════════════════════════════╗"
@echo "║ Step Functions AI Agent Framework - Makefile Commands ║"
@echo "╚════════════════════════════════════════════════════════════════════╝"
@echo ""
@echo "🎯 Main Targets:"
@echo " make help - Display this help message"
@echo " make all - Run clean, setup, build, and test"
@echo " make deploy-prep - Prepare for deployment (clean, setup, build, test)"
@echo ""
@echo "🚀 Unified Rust LLM Service:"
@echo " make build-llm-rust - Build the unified Rust LLM service"
@echo " make test-llm-rust - Run unit tests for Rust LLM service"
@echo " make test-llm-rust-integration - Run all provider integration tests"
@echo " make test-llm-rust-openai - Test OpenAI tool calling"
@echo " make test-llm-rust-anthropic - Test Anthropic tool calling"
@echo " make test-llm-rust-gemini - Test Gemini tool calling"
@echo " make deploy-llm-rust - Build and prepare Rust LLM for deployment"
@echo " make clean-llm-rust - Clean Rust LLM build artifacts"
@echo ""
@echo "🛠️ Setup & Environment:"
@echo " make setup - Set up all environments"
@echo " make venv - Create Python virtual environment"
@echo " make setup-env - Create .env file template"
@echo " make install-deps - Install all dependencies"
@echo ""
@echo "🏗️ Build Commands:"
@echo " make build - Build all Lambda functions"
@echo " make build-python - Build Python Lambda functions"
@echo " make build-typescript - Build TypeScript Lambda functions"
@echo " make build-rust - Build all Rust Lambda functions"
@echo " make build-java - Build Java Lambda functions"
@echo " make build-go - Build Go Lambda functions"
@echo ""
@echo "🧪 Testing:"
@echo " make test - Run all tests"
@echo " make test-python - Run Python tests"
@echo " make test-typescript - Run TypeScript tests"
@echo " make test-rust - Run Rust tests"
@echo " make test-java - Run Java tests"
@echo " make test-go - Run Go tests"
@echo " make test-call-llm - Test Python LLM handlers"
@echo " make test-robustness - Run robustness tests"
@echo ""
@echo "🔍 Validation:"
@echo " make validate-tools - Check tool name alignment across stacks"
@echo " make validate-all - Run all validation checks"
@echo ""
@echo "📊 Database Population:"
@echo " make populate-tables - Populate all configuration tables"
@echo " make populate-llm-models - Populate LLM Models table"
@echo " make populate-tool-secrets - Populate Tool Secrets table"
@echo ""
@echo "🌐 MCP Registry Commands:"
@echo " make populate-mcp-registry - Manually populate MCP Registry table"
@echo ""
@echo "🧹 Cleanup:"
@echo " make clean - Clean all build artifacts"
@echo " make clean-venv - Clean and recreate virtual environment"
@echo " make clean-cache - Clean Python cache files"
@echo ""
@echo "🚢 Deployment:"
@echo " make deploy-all - Deploy all CDK stacks"
@echo " make deploy-tools - Deploy all tool stacks"
@echo " make deploy-agents - Deploy all agent stacks"
@echo ""
@echo "🤖 AgentCore Browser Commands (CDK-based):"
@echo " make create-agentcore-ecr-repos - Create ECR repositories"
@echo " make build-agentcore-containers - Build and push Docker containers to ECR"
@echo " make deploy-agentcore-full - Full deployment (repos + images + CDK)"
@echo " make test-agentcore-browser - Test browser tool invocation"
@echo " make logs-agentcore-browser - View Lambda logs"
@echo ""
@echo "📱 UI Commands:"
@echo " make ui-build - Build Amplify UI"
@echo " make ui-dev - Start UI development server"
@echo " make ui-deploy - Deploy UI to Amplify"
@echo ""
@echo "🔧 Utilities:"
@echo " make logs - Tail CloudWatch logs for Lambda functions"
@echo " make check-deps - Check if all required tools are installed"
@echo " make update-deps - Update all dependencies to latest versions"
@echo ""
@echo "Environment Variables:"
@echo " AWS_PROFILE=$(AWS_PROFILE)"
@echo " AWS_REGION=$(AWS_REGION)"
@echo " ENV_NAME=$(ENV_NAME)"
@echo ""
@echo "Examples:"
@echo " AWS_PROFILE=prod make deploy-all"
@echo " ENV_NAME=dev make build-llm-rust"
# ============================================
# Unified Rust LLM Service Commands
# ============================================
.PHONY: build-llm-rust
build-llm-rust:
@echo "🦀 Building Unified LLM Service (Rust) with ADOT Observability..."
@if ! $(CARGO) lambda --version &> /dev/null; then \
echo "📦 Installing cargo-lambda..."; \
$(CARGO) install cargo-lambda; \
fi
@cd $(CALL_LLM_RUST_DIR) && \
echo "🧹 Cleaning previous builds..." && \
rm -rf target/lambda deployment && \
echo "🔨 Building for Lambda (ARM64)..." && \
$(CARGO_LAMBDA) build --release --arm64 && \
echo "📋 Preparing clean deployment package..." && \
mkdir -p deployment && \
if [ -f target/lambda/bootstrap/bootstrap ]; then \
cp target/lambda/bootstrap/bootstrap deployment/bootstrap; \
elif [ -f target/lambda/bootstrap ]; then \
cp target/lambda/bootstrap deployment/bootstrap; \
fi && \
cp collector.yaml deployment/ && \
echo "📦 Deployment package size: $$(du -sh deployment | cut -f1)" && \
echo "✅ Build complete! Clean deployment package at: lambda/call_llm_rust/deployment/"
.PHONY: test-llm-rust
test-llm-rust:
@echo "🧪 Testing Unified LLM Service (Rust)..."
@cd $(CALL_LLM_RUST_DIR) && \
RUST_LOG=debug $(CARGO) test --lib -- --nocapture
.PHONY: verify-llm-rust
verify-llm-rust:
@echo "🔍 Verifying Rust Lambda build with ADOT observability..."
@cd $(CALL_LLM_RUST_DIR) && \
if [ -d deployment ]; then \
if [ -f deployment/bootstrap ]; then \
echo "✅ deployment/bootstrap found (size: $$(ls -lh deployment/bootstrap | awk '{print $$5}'))"; \
else \
echo "❌ deployment/bootstrap NOT found"; \
exit 1; \
fi && \
if [ -f deployment/collector.yaml ]; then \
echo "✅ deployment/collector.yaml found for ADOT"; \
else \
echo "❌ deployment/collector.yaml NOT found"; \
exit 1; \
fi && \
echo "📦 CDK deployment package:" && \
ls -la deployment/ | sed 's/^/ /' && \
echo "📏 Total size: $$(du -sh deployment | cut -f1)" && \
echo "🚀 Ready for deployment: cdk deploy SharedLLMStack-prod"; \
else \
echo "❌ deployment directory NOT found - run: make build-llm-rust"; \
exit 1; \
fi
.PHONY: test-llm-rust-integration
test-llm-rust-integration:
@echo "🧪 Running LLM Service Integration Tests..."
@echo "Checking for API keys..."
@if [ ! -f $(CALL_LLM_RUST_DIR)/.env ] && [ -z "$$OPENAI_API_KEY" ] && [ -z "$$ANTHROPIC_API_KEY" ]; then \
echo "❌ No API keys found. Please set environment variables or create .env file:"; \
echo " export OPENAI_API_KEY='sk-...'"; \
echo " export ANTHROPIC_API_KEY='sk-ant-...'"; \
echo " Or copy lambda/call_llm_rust/.env.example to .env and add keys"; \
exit 1; \
fi
@cd $(CALL_LLM_RUST_DIR) && \
$(CARGO) test --test service_integration_test test_all_providers -- --ignored --nocapture
.PHONY: test-llm-rust-openai
test-llm-rust-openai:
@echo "🧪 Testing OpenAI through UnifiedLLMService..."
@cd $(CALL_LLM_RUST_DIR) && \
$(CARGO) test --test service_integration_test test_openai_service -- --ignored --nocapture
.PHONY: test-llm-rust-anthropic
test-llm-rust-anthropic:
@echo "🧪 Testing Anthropic through UnifiedLLMService..."
@cd $(CALL_LLM_RUST_DIR) && \
$(CARGO) test --test service_integration_test test_anthropic_service -- --ignored --nocapture
.PHONY: test-llm-rust-gemini
test-llm-rust-gemini:
@echo "🧪 Testing Gemini through UnifiedLLMService..."
@cd $(CALL_LLM_RUST_DIR) && \
$(CARGO) test --test service_integration_test test_gemini_service -- --ignored --nocapture
.PHONY: deploy-llm-rust
deploy-llm-rust: build-llm-rust
@echo "📦 Preparing Rust LLM service for deployment..."
@cd $(CALL_LLM_RUST_DIR) && \
mkdir -p deployment && \
cp -r target/lambda/unified-llm-service/* deployment/
@echo "✅ Ready for deployment at $(CALL_LLM_RUST_DIR)/deployment/"
@echo "Run: make deploy-stack STACK=UnifiedLLMServiceStack-$(ENV_NAME)"
.PHONY: clean-llm-rust
clean-llm-rust:
@echo "🧹 Cleaning Rust LLM build artifacts..."
@cd $(CALL_LLM_RUST_DIR) && \
$(CARGO) clean && \
rm -rf deployment
# ============================================
# MCP Server Build Commands
# ============================================
MCP_TEMPLATE_DIR := $(HOME)/Development/Xecutive-AI/general-mcp-examples/mcp-template
MCP_SERVERS_DIR := lambda/mcp-servers
.PHONY: build-mcp-reinvent
build-mcp-reinvent:
@echo "🦀 Building re:Invent MCP server..."
@cd $(MCP_TEMPLATE_DIR) && \
$(CARGO_LAMBDA) build --release --arm64 -p reinvent-server
@echo "📦 Copying bootstrap to lambda directory..."
@mkdir -p $(MCP_SERVERS_DIR)/reinvent
@cp $(MCP_TEMPLATE_DIR)/target/lambda/reinvent-server/bootstrap $(MCP_SERVERS_DIR)/reinvent/
@echo "✅ re:Invent MCP server built and ready for deployment"
@echo "Deploy with: cdk deploy ReinventMcpStack-prod"
.PHONY: clean-mcp-reinvent
clean-mcp-reinvent:
@echo "🧹 Cleaning re:Invent MCP server build artifacts..."
@rm -rf $(MCP_SERVERS_DIR)/reinvent
@cd $(MCP_TEMPLATE_DIR) && \
$(CARGO) clean -p reinvent-server
.PHONY: build-mcp-all
build-mcp-all: build-mcp-reinvent
@echo "✅ All MCP servers built"
.PHONY: clean-mcp-all
clean-mcp-all: clean-mcp-reinvent
@echo "✅ All MCP server artifacts cleaned"
# ============================================
# Setup Commands
# ============================================
.PHONY: setup
setup: check-deps setup-env setup-python setup-node setup-rust setup-java setup-go
.PHONY: check-deps
check-deps:
@echo "🔍 Checking required dependencies..."
@command -v $(PYTHON) >/dev/null 2>&1 || { echo "❌ Python not found"; exit 1; }
@command -v $(UV) >/dev/null 2>&1 || { echo "❌ uv not found. Install with: pip install uv"; exit 1; }
@command -v $(NPM) >/dev/null 2>&1 || { echo "❌ npm not found"; exit 1; }
@command -v $(CARGO) >/dev/null 2>&1 || { echo "❌ cargo not found"; exit 1; }
@command -v $(GO) >/dev/null 2>&1 || { echo "❌ go not found"; exit 1; }
@echo "✅ All dependencies found!"
.PHONY: setup-env
setup-env:
@echo "📝 Setting up .env file..."
@if [ ! -f .env ]; then \
echo "Creating .env file template..."; \
echo "# LLM Provider API Keys" > .env; \
echo "ANTHROPIC_API_KEY=your_anthropic_api_key" >> .env; \
echo "OPENAI_API_KEY=your_openai_api_key" >> .env; \
echo "AI21_API_KEY=your_ai21_api_key" >> .env; \
echo "GEMINI_API_KEY=your_gemini_api_key" >> .env; \
echo "" >> .env; \
echo "# AWS Configuration" >> .env; \
echo "AWS_PROFILE=$(AWS_PROFILE)" >> .env; \
echo "AWS_REGION=$(AWS_REGION)" >> .env; \
echo "" >> .env; \
echo "⚠️ Please update .env with your actual API keys"; \
else \
echo "✅ .env file already exists"; \
fi
.PHONY: setup-python
setup-python:
@echo "🐍 Setting up Python environment..."
@$(UV) venv
@. $(VENV_BIN)/activate && \
for dir in $(PYTHON_TOOLS); do \
if [ -f $$dir/requirements.in ]; then \
echo " 📦 Building requirements for $$dir..."; \
$(UV) pip compile $$dir/requirements.in --output-file $$dir/requirements.txt; \
fi \
done
.PHONY: setup-node
setup-node:
@echo "📦 Setting up Node.js environment..."
@for dir in $(TS_TOOLS); do \
if [ -f $$dir/package.json ]; then \
echo " 📦 Installing dependencies for $$dir..."; \
cd $$dir && $(NPM) install && cd -; \
fi \
done
.PHONY: setup-rust
setup-rust:
@echo "🦀 Setting up Rust environment..."
@for dir in $(RUST_TOOLS) $(RUST_LLM); do \
if [ -f $$dir/Cargo.toml ]; then \
echo " 📦 Building Rust project in $$dir..."; \
cd $$dir && $(CARGO) build && cd -; \
fi \
done
.PHONY: setup-java
setup-java:
@echo "☕ Setting up Java environment..."
@for dir in $(JAVA_TOOLS); do \
if [ -f $$dir/pom.xml ]; then \
echo " 📦 Building Java project in $$dir..."; \
cd $$dir && $(MVN) install && cd -; \
fi \
done
.PHONY: setup-go
setup-go:
@echo "🐹 Setting up Go environment..."
@for dir in $(GO_TOOLS); do \
if [ -f $$dir/go.mod ]; then \
echo " 📦 Building Go project in $$dir..."; \
cd $$dir && $(GO) mod tidy && $(GO) build -o bootstrap . && cd -; \
fi \
done
# ============================================
# Build Commands
# ============================================
.PHONY: build
build: build-python build-typescript build-rust build-java build-go
.PHONY: build-python
build-python:
@echo "🐍 Building Python Lambda functions..."
@for dir in $(PYTHON_TOOLS); do \
echo " 🔨 Building $$dir..."; \
cd $$dir && $(UV) pip install -r requirements.txt && cd -; \
done
.PHONY: build-typescript
build-typescript:
@echo "📦 Building TypeScript Lambda functions..."
@for dir in $(TS_TOOLS); do \
if [ -f $$dir/package.json ]; then \
echo " 🔨 Building $$dir..."; \
cd $$dir && $(NPM) run build && cd -; \
fi \
done
.PHONY: build-rust
build-rust: build-llm-rust
@echo "🦀 Building Rust Lambda functions..."
@for dir in $(RUST_TOOLS); do \
if [ -f $$dir/Cargo.toml ]; then \
echo " 🔨 Building $$dir..."; \
if [ "$$dir" = "$(TOOLS_DIR)/local-agent" ]; then \
echo " Using special build for local-agent (Lambda deployment)"; \
cd $$dir && $(MAKE) all && cd -; \
else \
cd $$dir && $(CARGO) build --release && cd -; \
fi \
fi \
done
.PHONY: build-java
build-java:
@echo "☕ Building Java Lambda functions..."
@for dir in $(JAVA_TOOLS); do \
if [ -f $$dir/pom.xml ]; then \
echo " 🔨 Building $$dir..."; \
cd $$dir && $(MVN) package && cd -; \
fi \
done
.PHONY: build-go
build-go:
@echo "🐹 Building Go Lambda functions..."
@for dir in $(GO_TOOLS); do \
if [ -f $$dir/go.mod ]; then \
echo " 🔨 Building $$dir..."; \
cd $$dir && $(GO) build -o bootstrap . && cd -; \
fi \
done
# ============================================
# Test Commands
# ============================================
.PHONY: test
test: test-python test-typescript test-rust test-java test-go test-call-llm
.PHONY: test-python
test-python:
@echo "🧪 Running Python tests..."
@for dir in $(PYTHON_TOOLS); do \
if [ -d $$dir/tests ]; then \
echo " Testing $$dir..."; \
cd $$dir && python -m pytest tests/ && cd -; \
fi \
done
.PHONY: test-typescript
test-typescript:
@echo "🧪 Running TypeScript tests..."
@for dir in $(TS_TOOLS); do \
if [ -f $$dir/package.json ]; then \
echo " Testing $$dir..."; \
cd $$dir && $(NPM) test && cd -; \
fi \
done
.PHONY: test-rust
test-rust: test-llm-rust
@echo "🧪 Running Rust tests..."
@for dir in $(RUST_TOOLS); do \
if [ -f $$dir/Cargo.toml ]; then \
echo " Testing $$dir..."; \
cd $$dir && $(CARGO) test && cd -; \
fi \
done
.PHONY: test-java
test-java:
@echo "🧪 Running Java tests..."
@for dir in $(JAVA_TOOLS); do \
if [ -f $$dir/pom.xml ]; then \
echo " Testing $$dir..."; \
cd $$dir && $(MVN) test && cd -; \
fi \
done
.PHONY: test-go
test-go:
@echo "🧪 Running Go tests..."
@for dir in $(GO_TOOLS); do \
if [ -f $$dir/go.mod ]; then \
echo " Testing $$dir..."; \
cd $$dir && $(GO) test ./... && cd -; \
fi \
done
# ============================================
# Virtual Environment Management
# ============================================
.PHONY: venv
venv:
@echo "🐍 Creating Python virtual environment with uv..."
@$(UV) venv $(VENV) --python 3.12
@echo "✅ Virtual environment created. Activate with: source venv/bin/activate"
.PHONY: install-deps
install-deps: venv
@echo "📦 Installing all dependencies..."
@make install-call-llm
.PHONY: install-call-llm
install-call-llm: venv
@echo "📦 Installing call_llm dependencies with uv..."
@cd $(CALL_LLM_DIR) && \
$(UV) pip compile --python $(VENV_PYTHON) requirements.in -o requirements.txt && \
$(UV) pip compile --python $(VENV_PYTHON) requirements-dev.in -o requirements-dev.txt && \
$(UV) pip sync --python $(VENV_PYTHON) requirements-dev.txt
.PHONY: test-call-llm
test-call-llm: install-call-llm
@echo "🧪 Running call_llm tests..."
@. $(VENV_BIN)/activate && \
export AWS_PROFILE=$(AWS_PROFILE) && \
export USE_ENV_KEYS=true && \
cd $(CALL_LLM_DIR) && \
python -m pytest tests/ --ignore=tests/test_gemini_handler.py -v
.PHONY: test-robustness
test-robustness: install-call-llm
@echo "🧪 Running robustness improvement tests..."
@. $(VENV_BIN)/activate && \
export AWS_PROFILE=$(AWS_PROFILE) && \
export USE_ENV_KEYS=true && \
cd $(CALL_LLM_DIR) && \
python -m pytest tests/test_robustness_improvements.py -v
# ============================================
# Clean Commands
# ============================================
.PHONY: clean
clean: clean-cache clean-llm-rust
@echo "🧹 Cleaning build artifacts..."
@find . -type d -name "node_modules" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name "target" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name "dist" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name "build" -exec rm -rf {} + 2>/dev/null || true
@echo "✅ Clean complete"
.PHONY: clean-cache
clean-cache:
@echo "🧹 Cleaning Python cache files..."
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
.PHONY: clean-venv
clean-venv:
@echo "🧹 Cleaning virtual environment..."
@rm -rf $(VENV)
@make venv
# ============================================
# Validation Commands
# ============================================
.PHONY: validate-tools
validate-tools:
@echo "🔍 Validating tool name alignment across stacks..."
@$(PYTHON) scripts/validate_tool_alignment.py
.PHONY: validate-all
validate-all: validate-tools
@echo "✅ All validations completed"
# ============================================
# Deployment Commands
# ============================================
.PHONY: deploy-prep
deploy-prep: clean setup build test validate-all
@echo "✅ Ready for deployment!"
@echo "Run 'make deploy-all' to deploy all stacks"
.PHONY: deploy-all
deploy-all:
@echo "🚀 Deploying all CDK stacks..."
@$(CDK) deploy --all --require-approval never --profile $(AWS_PROFILE)
.PHONY: deploy-stack
deploy-stack:
@if [ -z "$(STACK)" ]; then \
echo "❌ Please specify STACK=<stack-name>"; \
exit 1; \
fi
@echo "🚀 Deploying $(STACK)..."
@$(CDK) deploy $(STACK) --require-approval never --profile $(AWS_PROFILE)
.PHONY: deploy-tools
deploy-tools:
@echo "🚀 Deploying all tool stacks..."
@$(CDK) deploy "*ToolStack-$(ENV_NAME)" --require-approval never --profile $(AWS_PROFILE)
.PHONY: deploy-agents
deploy-agents:
@echo "🚀 Deploying all agent stacks..."
@$(CDK) deploy "*AgentStack-$(ENV_NAME)" --require-approval never --profile $(AWS_PROFILE)
# ============================================
# Database Population Commands
# ============================================
.PHONY: populate-tables
populate-tables: populate-llm-models populate-tool-secrets
@echo "✅ All tables populated successfully!"
.PHONY: populate-llm-models
populate-llm-models:
@echo "📊 Populating LLM Models table..."
@$(PYTHON) scripts/populate_llm_models.py
.PHONY: populate-tool-secrets
populate-tool-secrets:
@echo "🔐 Populating Tool Secrets table..."
@$(PYTHON) scripts/populate_tool_secrets.py $(AWS_PROFILE) $(AWS_REGION)
# ============================================
# MCP Registry Commands
# ============================================
.PHONY: populate-mcp-registry
populate-mcp-registry:
@echo "📊 Populating MCP Registry table..."
@$(PYTHON) scripts/populate_mcp_registry.py
# ============================================
# Template Registry Commands
# ============================================
TEMPLATE_FILE ?= templates/broadband_availability_bt_wholesale_v1.0.0.json
.PHONY: register-template
register-template:
@if [ -z "$(TEMPLATE)" ]; then \
echo "❌ Please specify TEMPLATE=<template-file>"; \
echo "Example: make register-template TEMPLATE=templates/broadband_availability_bt_wholesale_v1.0.0.json"; \
exit 1; \
fi
@echo "📝 Registering template: $(TEMPLATE)"
@$(PYTHON) scripts/register_template.py $(TEMPLATE) --env $(ENV_NAME) --profile $(AWS_PROFILE)
.PHONY: update-broadband-template
update-broadband-template:
@echo "📝 Updating BT Wholesale broadband availability template..."
@$(PYTHON) scripts/register_template.py \
templates/broadband_availability_bt_wholesale_v1.0.0.json \
--env $(ENV_NAME) \
--profile $(AWS_PROFILE)
.PHONY: deploy-broadband-agent
deploy-broadband-agent: update-broadband-template
@echo "🚀 Deploying broadband availability agent stack..."
@$(CDK) deploy BroadbandAvailabilityBtWholesaleStack-$(ENV_NAME) \
--require-approval never \
--profile $(AWS_PROFILE)
@echo "✅ Broadband agent deployed with updated schema!"
# ============================================
# UI Commands
# ============================================
.PHONY: ui-build
ui-build:
@echo "🎨 Building Amplify UI..."
@cd $(UI_DIR) && npm run build
.PHONY: ui-dev
ui-dev:
@echo "🎨 Starting UI development server..."
@cd $(UI_DIR) && npm run dev
.PHONY: ui-deploy
ui-deploy: ui-build
@echo "🚀 Deploying UI to Amplify..."
@cd $(UI_DIR) && npx amplify push --yes
# ============================================
# Utility Commands
# ============================================
.PHONY: logs
logs:
@if [ -z "$(FUNCTION)" ]; then \
echo "❌ Please specify FUNCTION=<function-name>"; \
echo "Example: make logs FUNCTION=unified-llm-service-prod"; \
exit 1; \
fi
@echo "📋 Tailing logs for $(FUNCTION)..."
@aws logs tail /aws/lambda/$(FUNCTION) --follow --profile $(AWS_PROFILE)
.PHONY: update-deps
update-deps:
@echo "🔄 Updating all dependencies..."
@echo " Updating Python dependencies..."
@for dir in $(PYTHON_TOOLS); do \
if [ -f $$dir/requirements.in ]; then \
cd $$dir && $(UV) pip compile --upgrade requirements.in -o requirements.txt && cd -; \
fi \
done
@echo " Updating Node.js dependencies..."
@for dir in $(TS_TOOLS); do \
if [ -f $$dir/package.json ]; then \
cd $$dir && $(NPM) update && cd -; \
fi \
done
@echo " Updating Rust dependencies..."
@for dir in $(RUST_TOOLS) $(RUST_LLM); do \
if [ -f $$dir/Cargo.toml ]; then \
cd $$dir && $(CARGO) update && cd -; \
fi \
done
@echo "✅ All dependencies updated!"
# Keep backward compatibility
.PHONY: install
install: install-deps
.PHONY: format
format:
@echo "🎨 Formatting code..."
@echo " Formatting Python code..."
@find . -name "*.py" -type f -exec black {} \;
@echo " Formatting Rust code..."
@for dir in $(RUST_TOOLS) $(RUST_LLM); do \
if [ -f $$dir/Cargo.toml ]; then \
cd $$dir && $(CARGO) fmt && cd -; \
fi \
done
@echo "✅ Code formatted!"
# ============================================
# Agent Core Commands (NEW Service - Bedrock Agent Core)
# ============================================
AGENTCORE_DIR := agent_core
AGENTCORE_NAME ?= web-search-agent
# Legacy Agent Commands (OLD Service - Bedrock Agents)
# ============================================
# Agent Core deployment has been moved to a separate project
# See ~/projects/nova-act for Agent Core agent implementations
AGENT_NAME ?= web-search-agent
# ============================================
# Agent Core targets have been moved to ~/projects/nova-act
# The Lambda tools that call Agent Core runtime remain in this project
# ============================================
# Commented out Agent Core deployment targets - now in ~/projects/nova-act
# All the Agent Core deployment, testing, and management targets have been removed
# from this Makefile as they are now in the dedicated nova-act project.
#
# The following targets have been removed:
# - deploy-agent-core
# - deploy-agent-wrapper
# - agentcore-broadband-*
# - deploy-agent-full
# - list-agent-core
# - delete-agent-core
# - clean-agent-core
# - test-agent-core
#
# This project still maintains:
# - Lambda tools that call Agent Core runtime (agentcore_browser)
# - CDK stacks for those tools
# - Agent stacks that use those tools
: <<'AGENT_CORE_REMOVED'
@echo "🚀 Deploying Agent Core agent from $(CONFIG)..."
@echo "📍 Using AWS Profile: $(AWS_PROFILE), Region: $(AWS_REGION)"
@NOVA_ACT_ARN=$$(aws cloudformation describe-stacks \
--stack-name "NovaActBrowserToolStack-$(ENV_NAME)" \
--region "$(AWS_REGION)" \
$${AWS_PROFILE:+--profile "$$AWS_PROFILE"} \
--query "Stacks[0].Outputs[?OutputKey=='NovaActBrowserFunctionArn'].OutputValue" \
--output text 2>/dev/null); \
if [ -z "$$NOVA_ACT_ARN" ]; then \
echo "❌ Nova Act Browser stack not found. Deploy it first:"; \
echo " make deploy-stack STACK=NovaActBrowserToolStack-$(ENV_NAME)"; \
exit 1; \
fi; \
echo "✅ Found Nova Act Browser Lambda: $$NOVA_ACT_ARN"; \
sed "s|\$${NOVA_ACT_BROWSER_LAMBDA_ARN}|$$NOVA_ACT_ARN|g" \
"$(AGENT_CORE_CONFIGS)/$(CONFIG)" > "/tmp/agent-config-temp.yaml"; \
if $(PYTHON) $(AGENT_CORE_DIR)/deploy_agent.py \
"/tmp/agent-config-temp.yaml" \
--region $(AWS_REGION) \
$${AWS_PROFILE:+--profile "$$AWS_PROFILE"}; then \
rm -f "/tmp/agent-config-temp.yaml"; \
echo "✅ Agent Core deployment complete!"; \
else \
rm -f "/tmp/agent-config-temp.yaml"; \
echo "❌ Agent Core deployment failed!"; \
exit 1; \
fi
.PHONY: deploy-agent-wrapper
deploy-agent-wrapper:
@if [ -z "$(AGENT)" ]; then \
echo "❌ Please specify AGENT=<agent-name>"; \
echo "Example: make deploy-agent-wrapper AGENT=web-search-agent"; \
exit 1; \
fi
@echo "🚀 Deploying Step Functions wrapper for $(AGENT)..."
@if [ ! -f "agent-core-output-$(AGENT).json" ]; then \
echo "❌ Agent Core output file not found: agent-core-output-$(AGENT).json"; \
echo "Run 'make deploy-agent-core CONFIG=<config>' first"; \
exit 1; \
fi; \
echo "#!/usr/bin/env python3" > /tmp/agent-wrapper-app.py; \
echo "import os" >> /tmp/agent-wrapper-app.py; \
echo "import aws_cdk as cdk" >> /tmp/agent-wrapper-app.py; \
echo "from stacks.agents.agent_core_wrapper_stack import AgentCoreWrapperStack" >> /tmp/agent-wrapper-app.py; \
echo "" >> /tmp/agent-wrapper-app.py; \
echo "app = cdk.App()" >> /tmp/agent-wrapper-app.py; \
echo "env = cdk.Environment(" >> /tmp/agent-wrapper-app.py; \
echo " account=os.environ.get('CDK_DEFAULT_ACCOUNT')," >> /tmp/agent-wrapper-app.py; \
echo " region='$(AWS_REGION)'" >> /tmp/agent-wrapper-app.py; \
echo ")" >> /tmp/agent-wrapper-app.py; \
echo "" >> /tmp/agent-wrapper-app.py; \
echo "wrapper_stack = AgentCoreWrapperStack.from_deployment_output(" >> /tmp/agent-wrapper-app.py; \
echo " app," >> /tmp/agent-wrapper-app.py; \
echo " 'AgentCoreWrapper-$(AGENT)-$(ENV_NAME)'," >> /tmp/agent-wrapper-app.py; \
echo " output_file='agent-core-output-$(AGENT).json'," >> /tmp/agent-wrapper-app.py; \
echo " env_name='$(ENV_NAME)'," >> /tmp/agent-wrapper-app.py; \
echo " env=env" >> /tmp/agent-wrapper-app.py; \
echo ")" >> /tmp/agent-wrapper-app.py; \
echo "app.synth()" >> /tmp/agent-wrapper-app.py; \
CDK_APP="python3 /tmp/agent-wrapper-app.py" $(CDK) deploy \
"AgentCoreWrapper-$(AGENT)-$(ENV_NAME)" \
--require-approval never \
--profile $(AWS_PROFILE); \
rm -f /tmp/agent-wrapper-app.py; \
echo "✅ Wrapper deployment complete!"
# ============================================
# Agent Core - Broadband Checker Deployment
# ============================================
.PHONY: agentcore-broadband-build
agentcore-broadband-build:
@echo "🔨 Building Broadband Checker Agent Docker image..."
@docker build -f $(AGENT_CORE_DIR)/Dockerfile.broadband \
-t broadband-checker-agent:latest \
$(AGENT_CORE_DIR) && \
echo "✅ Docker image built: broadband-checker-agent:latest"
.PHONY: agentcore-broadband-test-local
agentcore-broadband-test-local: agentcore-broadband-build
@echo "🧪 Testing Broadband Checker Agent locally..."
@docker run --rm \
-e AWS_REGION=$(AWS_REGION) \
-e BYPASS_TOOL_CONSENT=true \
broadband-checker-agent:latest \
python -c "import json; from broadband_checker_agent import handler; \
result = handler({'test': True}, {}); \
print('Test Result:'); print(json.dumps(result, indent=2)[:500])"
.PHONY: agentcore-broadband-deploy-lambda
agentcore-broadband-deploy-lambda:
@echo "🚀 Deploying Broadband Checker as Lambda function..."
@cd $(AGENT_CORE_DIR) && \
python3 deploy_broadband_agent.py \
--agent-name broadband-checker \
--region $(AWS_REGION) \
--deployment-type lambda \
--test
.PHONY: agentcore-broadband-configure
agentcore-broadband-configure:
@echo "⚙️ Configuring Broadband Checker Agent..."
@cd $(AGENT_CORE_DIR) && \
source ../venv/bin/activate && \
agentcore configure -e broadband_checker_agent.py && \
echo "✅ Agent configured successfully"
.PHONY: agentcore-broadband-deploy-agentcore
agentcore-broadband-deploy-agentcore: agentcore-broadband-configure
@echo "🚀 Deploying Broadband Checker to Agent Core runtime using agentcore CLI..."
@cd $(AGENT_CORE_DIR) && \
source ../venv/bin/activate && \
agentcore launch --agent broadband_checker_agent && \
echo "✅ Agent deployed successfully"
.PHONY: agentcore-broadband-test-deployed
agentcore-broadband-test-deployed:
@echo "🧪 Testing deployed Broadband Checker Agent..."
@cd $(AGENT_CORE_DIR) && \
source ../venv/bin/activate && \
agentcore invoke broadband_checker_agent '{"test": true}' && \
echo "✅ Test completed"
.PHONY: agentcore-broadband-logs
agentcore-broadband-logs:
@echo "📋 Viewing Broadband Checker Agent logs (full)..."
@aws logs tail /aws/agentcore/runtimes/broadband_checker_agent-KcXxkNFCkG-DEFAULT \
--profile $(AWS_PROFILE) \
--region $(AWS_REGION) \
--follow
.PHONY: agentcore-broadband-logs-body
agentcore-broadband-logs-body:
@echo "📋 Viewing Broadband Checker Agent logs (body field only with timestamp)..."
@echo "📍 Log group: /aws/agentcore/runtimes/broadband_checker_agent-KcXxkNFCkG-DEFAULT"
@echo "⏰ Following new logs as they arrive..."
@echo "----------------------------------------"
@aws logs tail /aws/agentcore/runtimes/broadband_checker_agent-KcXxkNFCkG-DEFAULT --follow | \
awk '{ts=$$1; $$1=""; stream=$$2; $$2=""; sub(/^ */,""); print ts "|" $$0}' | \
while IFS="|" read -r ts json; do \
body=$$(printf "%s\n" "$$json" | jq -r 'try .body // empty' 2>/dev/null); \
if [ -n "$$body" ]; then printf "%s %s\n" "$$ts" "$$body"; fi; \
done
.PHONY: agentcore-broadband-batch-test
agentcore-broadband-batch-test:
@echo "🧪 Testing batch processing..."
@aws lambda invoke \
--function-name broadband-checker-agent-$(AWS_REGION) \
--payload '{"addresses":[{"postcode":"E8 4LX","building_number":"13"},{"postcode":"SW1A 1AA","building_number":"10"}],"parallel":false}' \
--profile $(AWS_PROFILE) \
--region $(AWS_REGION) \
/tmp/broadband-batch-response.json && \
echo "Batch Response:" && \
cat /tmp/broadband-batch-response.json | python3 -m json.tool
.PHONY: agentcore-broadband-clean
agentcore-broadband-clean:
@echo "🧹 Cleaning Broadband Checker build artifacts..."
@cd $(AGENT_CORE_DIR) && \
rm -f deployment-broadband-checker-*.json && \
docker rmi broadband-checker-agent:latest 2>/dev/null || true
.PHONY: deploy-agent-full
deploy-agent-full:
@if [ -z "$(CONFIG)" ]; then \
echo "❌ Please specify CONFIG=<config-file>"; \
echo "Example: make deploy-agent-full CONFIG=web_search_agent.yaml"; \
exit 1; \
fi
@# Extract agent name from config
@AGENT_NAME=$$(python3 -c "import yaml; f=open('$(AGENT_CORE_CONFIGS)/$(CONFIG)', 'r'); print(yaml.safe_load(f).get('agent_name', 'unknown')); f.close()") && \
echo "🚀 Full deployment for agent: $$AGENT_NAME" && \
$(MAKE) deploy-agent-core CONFIG=$(CONFIG) && \
$(MAKE) deploy-agent-wrapper AGENT=$$AGENT_NAME && \
WRAPPER_ARN=$$(aws cloudformation describe-stacks \
--stack-name "AgentCoreWrapper-$$AGENT_NAME-$(ENV_NAME)" \
--region "$(AWS_REGION)" \
--profile "$(AWS_PROFILE)" \
--query "Stacks[0].Outputs[?contains(OutputKey, 'StateMachineArn')].OutputValue" \
--output text) && \
echo "" && \
echo "✅ Full deployment complete!" && \
echo "" && \
echo "Integration details:" && \
echo " Agent: $$AGENT_NAME" && \
echo " Wrapper State Machine: $$WRAPPER_ARN" && \
echo "" && \
echo "Add to hybrid supervisor agent_configs:" && \
echo " \"$$AGENT_NAME\": {" && \
echo " \"arn\": \"$$WRAPPER_ARN\"," && \
echo " \"description\": \"Agent Core $$AGENT_NAME\"" && \
echo " }"
.PHONY: list-agent-core
list-agent-core:
@echo "📋 Listing Agent Core agents..."
@echo "📍 Using AWS Profile: $(AWS_PROFILE), Region: $(AWS_REGION)"
@aws bedrock-agent list-agents \
--region $(AWS_REGION) \
$${AWS_PROFILE:+--profile "$$AWS_PROFILE"} \
--output table
.PHONY: delete-agent-core
delete-agent-core:
@if [ -z "$(AGENT_ID)" ] && [ -z "$(AGENT_NAME)" ]; then \
echo "❌ Please specify AGENT_ID=<agent-id> or AGENT_NAME=<agent-name>"; \
echo "Run 'make list-agent-core' to see available agents"; \
exit 1; \
fi
@echo "🗑️ Deleting Agent Core agent..."
@echo "📍 Using AWS Profile: $(AWS_PROFILE), Region: $(AWS_REGION)"
@if [ -n "$(AGENT_ID)" ]; then \
$(PYTHON) $(AGENT_CORE_DIR)/clean_agent.py \
--agent-id $(AGENT_ID) \
--region $(AWS_REGION) \
$${AWS_PROFILE:+--profile "$$AWS_PROFILE"}; \
else \
$(PYTHON) $(AGENT_CORE_DIR)/clean_agent.py \
--agent-name $(AGENT_NAME) \
--region $(AWS_REGION) \
$${AWS_PROFILE:+--profile "$$AWS_PROFILE"}; \
fi
.PHONY: clean-agent-core
clean-agent-core:
@if [ -z "$(CONFIG)" ]; then \
echo "❌ Please specify CONFIG=<config-file>"; \
echo "Example: make clean-agent-core CONFIG=web_search_agent.yaml"; \
exit 1; \
fi
@AGENT_NAME=$$(python3 -c "import yaml; f=open('$(AGENT_CORE_CONFIGS)/$(CONFIG)', 'r'); print(yaml.safe_load(f).get('agent_name', 'unknown')); f.close()") && \
echo "🧹 Cleaning up agent: $$AGENT_NAME" && \
$(MAKE) delete-agent-core AGENT_NAME=$$AGENT_NAME