#!/usr/bin/env bash
# Quick local dev mode - no podman
set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"

if [ ! -f ".env" ]; then
  cp .env.example .env
fi

# Ensure workspace dirs exist
mkdir -p workspace/documents

echo "Starting Agentic Research in dev mode..."
echo "  UI: http://localhost:8000"
echo "  Docs: http://localhost:8000/docs"
echo "  Marker API: http://localhost:8001"
echo ""

# Start marker API in background
cd marker-api
python3 server.py &
MARKER_PID=$!
cd ../

sleep 1
python3 -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload

kill $MARKER_PID 2>/dev/null || true
