diff --git a/ai-hub/app/api/routes/nodes.py b/ai-hub/app/api/routes/nodes.py index cb29710..b0fe226 100644 --- a/ai-hub/app/api/routes/nodes.py +++ b/ai-hub/app/api/routes/nodes.py @@ -421,8 +421,9 @@ # Cortex Agent Node — Seamless Runner set -e -# Ensure we are in the script's directory (crucial for double-clicking on Mac) -cd "$(dirname "$0")" +# Ensure we are in the script's directory (crucial for double-clicking and manual runs) +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" +cd "$SCRIPT_DIR" || { echo "❌ Error: Could not change directory to $SCRIPT_DIR"; exit 1; } echo "🚀 Starting Cortex Agent Node..." @@ -453,9 +454,24 @@ # Activate venv # shellcheck source=/dev/null -source "$VENV/bin/activate" +if [ -f "$VENV/bin/activate" ]; then + source "$VENV/bin/activate" +elif [ -f "$VENV/Scripts/activate" ]; then + # Fallback for some windows environments running bash + source "$VENV/Scripts/activate" +else + echo "❌ Error: Could not find activation script in $VENV" + exit 1 +fi # 3. Dependency Installation +if [ ! -f "requirements.txt" ]; then + echo "❌ Error: requirements.txt not found in $(pwd)" + echo "Contents of $(pwd):" + ls -la + exit 1 +fi + echo "[*] Ensuring dependencies (pip, gRPC, etc.) are installed..." pip install --upgrade pip --quiet pip install -r requirements.txt --quiet @@ -552,8 +568,8 @@ # Create ZIP in memory zip_buffer = io.BytesIO() with zipfile.ZipFile(zip_buffer, "a", zipfile.ZIP_DEFLATED, False) as zip_file: - # 1. Add Agent Node source files from /app/agent-node - source_dir = "/app/agent-node" + # 1. Add Agent Node source files from /app/agent-node-source + source_dir = "/app/agent-node-source" if os.path.exists(source_dir): for root, dirs, files in os.walk(source_dir): # Exclude unwanted directories