5ba367af2f
- backend/app.py: add Depends(_require_auth) to /api/copilotkit endpoint (critical security fix — endpoint was fully unprotected; now requires valid session cookie) - backend/app.py: move 'from ag_ui.core import RunStartedEvent' from inline function body to top-level imports (style consistency) - backend/auth.py: remove dead AUTH_PASS_HASH module-level constant (verify_password already reads from os.environ at call time; the cached binding was unused dead code) - backend/artifacts.py: add path traversal guards to list_artifacts, get_artifact, and save_artifact — resolve paths and verify they stay within ARTIFACTS_DIR - entrypoint.sh: health-check loop now sets READY flag and exits 1 if amplifierd fails to start within 30s (previously fell through silently, causing 502s) - tests/test_app.py: add TestCopilotKitAuth — verifies unauthenticated requests to /api/copilotkit return 401; includes note explaining why streaming is not tested here - tests/test_structure.sh: update to reflect that Dockerfile and entrypoint.sh now exist (created in Tasks 7+8); convert absent-checks to presence-checks Co-authored-by: Amplifier <amplifier@anthropic.com>
59 lines
1.3 KiB
Bash
Executable File
59 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
export DISPLAY=:99
|
|
|
|
echo "=== Starting Research Workbench ==="
|
|
|
|
# (1) Start Xvfb
|
|
Xvfb :99 -screen 0 1280x720x24 -ac &
|
|
sleep 1
|
|
echo "[OK] Xvfb display :99"
|
|
|
|
# (2) Start x11vnc (suppress stderr)
|
|
x11vnc -display :99 -forever -nopw -listen 0.0.0.0 -rfbport 5900 -shared 2>/dev/null &
|
|
sleep 1
|
|
echo "[OK] x11vnc on :5900"
|
|
|
|
# (3) Start noVNC via websockify
|
|
websockify --web=/usr/share/novnc/ 6080 localhost:5900 &
|
|
sleep 1
|
|
echo "[OK] noVNC on :6080"
|
|
|
|
# (4) Start amplifierd and wait for it to be healthy
|
|
cd /app
|
|
amplifierd --port 8410 --bundle /app/bundle/bundle.md &
|
|
AMPLIFIERD_PID=$!
|
|
|
|
echo "Waiting for amplifierd..."
|
|
READY=0
|
|
for i in $(seq 1 30); do
|
|
if curl -s http://localhost:8410/health > /dev/null 2>&1; then
|
|
echo "[OK] amplifierd on :8410"
|
|
READY=1
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
if [ "$READY" -eq 0 ]; then
|
|
echo "[ERROR] amplifierd failed to start within 30s — aborting" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# (5) Start FastAPI backend
|
|
cd /app/backend
|
|
uv run python -m uvicorn app:app --host 0.0.0.0 --port 8080 --log-level info &
|
|
sleep 2
|
|
echo "[OK] FastAPI on :8080"
|
|
|
|
echo ""
|
|
echo "Research Workbench: http://localhost:8080"
|
|
echo "Browser VNC: http://localhost:6080"
|
|
|
|
# CMD passthrough or wait on amplifierd
|
|
if [ $# -eq 0 ]; then
|
|
wait $AMPLIFIERD_PID
|
|
else
|
|
exec "$@"
|
|
fi
|