#!/usr/bin/env bash # Start the EvoScientist backend for local development FROM SOURCE. # # Always use this script instead of a globally installed `langgraph` binary: # the uv-tool install runs the stale site-packages copy of EvoScientist, # which lacks newer HTTP routes (e.g. /api/image-generation → 404). set -euo pipefail REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" WORKSPACE_DIR="$REPO_ROOT/EvoScientist/langgraph_dev" VENV_PYTHON="$REPO_ROOT/.venv/bin/python" PORT="${PORT:-6174}" WEBUI_PORT="${WEBUI_PORT:-4716}" cd "$REPO_ROOT" export EVOSCIENTIST_WORKSPACE_DIR="$WORKSPACE_DIR" export EVOSCIENTIST_DEPLOY_MODE=full export PYTHONIOENCODING=utf-8 export PYTHONUTF8=1 # Must match EVOSCIENTIST_BACKEND_SERVICE_TOKEN in EvoScientist-WebUI/.env. # Stored at /.evoscientist/control/scope-service-token (same file # `EvoSci deploy` uses), created on first run. export EVOSCIENTIST_BACKEND_SERVICE_TOKEN="$("$VENV_PYTHON" -c \ "from EvoScientist.scope_registry import get_scope_service_token; print(get_scope_service_token('$WORKSPACE_DIR'))")" # Usage reporting identities (stable; secrets live under ~/.evoscientist). eval "$("$VENV_PYTHON" -c \ "from EvoScientist.usage.identity import prepare_usage_environment for k, v in prepare_usage_environment('$WORKSPACE_DIR', webui_port=$WEBUI_PORT).items(): print(f'export {k}={v}')")" # langgraph dev resolves the graph/app modules relative to the workspace dir. # cd here, after the python -c calls above: running them with the workspace as # cwd would put langgraph_dev/ on sys.path, where http.py shadows the stdlib # http package and breaks the httpx import chain. cd "$WORKSPACE_DIR" exec "$REPO_ROOT/.venv/bin/langgraph" dev \ --config "$WORKSPACE_DIR/langgraph.json" \ --port "$PORT" \ --n-jobs-per-worker 10 \ --no-browser \ --no-reload