#!/bin/bash
# Fix pass for 19107: venv had no pip (Debian minimal python), VAE download failed transiently.
cd /home/agent/.claude/workspace/project || exit 1
exec >> logs/fix.log 2>&1
set -x
/home/agent/zimage-venv/bin/pip install --upgrade pip
/home/agent/zimage-venv/bin/pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130
/home/agent/zimage-venv/bin/pip install -r ComfyUI/requirements.txt
/home/agent/zimage-venv/bin/pip install flask Pillow
cd ComfyUI/models/vae
[ -f ae.safetensors ] && [ $(stat -c%s ae.safetensors) -gt 100000000 ] || curl -L -o ae.safetensors https://huggingface.co/Comfy-Org/Z-Image-Turbo/resolve/main/split_files/vae/ae.safetensors
cd /home/agent/.claude/workspace/project
ls -lh ComfyUI/models/diffusion_models ComfyUI/models/text_encoders ComfyUI/models/vae
/home/agent/zimage-venv/bin/python -c "import torch; print('cuda', torch.cuda.is_available())"
echo FIX_DONE
