#!/bin/bash
# Agent Node Distribution Build Script
set -e

echo "[*] Building Cortex Agent Node distribution package..."

# 1. Compile Protos (ensure we have latest stubs)
python3 -m grpc_tools.protoc -I./protos --python_out=. --grpc_python_out=. ./protos/agent.proto
echo "[+] Protobuf compiled."

# 2. Cleanup
find . -type d -name "__pycache__" -exec rm -rf {} +
echo "[+] Cleanup complete."

# 3. Validation (Optional: run unit tests)
# python3 -m unittest discover tests

echo "[✅] Build successful. Source is ready for distribution."
