chore: sync current workspace changes

This commit is contained in:
2026-03-27 11:27:26 +08:00
parent 6ecc224427
commit 5c08c1865c
33 changed files with 1450 additions and 724 deletions

View File

@@ -1,8 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
# EvoTraders Development Startup Script
# Split-service mode only
set -e
set -euo pipefail
echo "=========================================="
echo "EvoTraders Development Environment"
@@ -14,24 +14,84 @@ GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check virtual environment
if [ -z "$VIRTUAL_ENV" ]; then
echo -e "${YELLOW}Warning: Virtual environment not activated${NC}"
echo "Activating .venv..."
source .venv/bin/activate
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"
# Load environment variables
if [ -f .env ]; then
echo -e "${GREEN}Loading environment from .env${NC}"
export $(grep -v '^#' .env | xargs)
else
echo -e "${YELLOW}Warning: .env file not found${NC}"
fi
cd /Users/cillin/workspeace/evotraders
PIDS=()
require_command() {
local command_name="$1"
if ! command -v "${command_name}" >/dev/null 2>&1; then
echo -e "${RED}Missing required command: ${command_name}${NC}"
exit 1
fi
}
check_python_module() {
local module_name="$1"
if ! python -c "import ${module_name}" >/dev/null 2>&1; then
echo -e "${RED}Missing required Python module: ${module_name}${NC}"
echo "Install dependencies with one of:"
echo " pip install -r requirements.txt"
echo " pip install -r requirements-dev.txt"
echo " uv pip install -e '.[dev]'"
exit 1
fi
}
load_env_file() {
if [ -f .env ]; then
echo -e "${GREEN}Loading environment from .env${NC}"
set -a
source .env
set +a
else
echo -e "${YELLOW}Warning: .env file not found. Copy env.template to .env first if you need live credentials.${NC}"
fi
}
check_env_var() {
local var_name="$1"
local severity="${2:-warn}"
local value="${!var_name:-}"
if [ -z "${value}" ]; then
if [ "${severity}" = "error" ]; then
echo -e "${RED}Missing required environment variable: ${var_name}${NC}"
exit 1
fi
echo -e "${YELLOW}Warning: ${var_name} is not set${NC}"
fi
}
check_openclaw_gateway() {
local target_host="127.0.0.1"
local target_port="18789"
if python - <<PY >/dev/null 2>&1
import socket
sock = socket.socket()
sock.settimeout(1.0)
sock.connect(("${target_host}", ${target_port}))
sock.close()
PY
then
echo -e "${GREEN}OpenClaw gateway reachable at ws://${target_host}:${target_port}${NC}"
else
echo -e "${YELLOW}Warning: OpenClaw gateway is not reachable at ws://${target_host}:${target_port}${NC}"
echo " OpenClaw panel features may be unavailable until it is started."
fi
}
print_prereq_help() {
echo "Environment checks:"
echo " - repo root: ${SCRIPT_DIR}"
echo " - python: $(command -v python)"
if [ -n "${VIRTUAL_ENV:-}" ]; then
echo " - virtualenv: ${VIRTUAL_ENV}"
else
echo " - virtualenv: not activated"
fi
}
start_service() {
local name="$1"
local app_path="$2"
@@ -74,16 +134,56 @@ if [ $# -gt 0 ]; then
echo "Split-service mode is now the only supported development mode."
fi
require_command python
require_command lsof
if [ -z "${VIRTUAL_ENV:-}" ]; then
if [ -f ".venv/bin/activate" ]; then
echo -e "${YELLOW}Virtual environment not activated; auto-activating .venv${NC}"
# shellcheck disable=SC1091
source .venv/bin/activate
else
echo -e "${YELLOW}Warning: no active virtual environment and .venv not found${NC}"
fi
fi
load_env_file
print_prereq_help
python - <<'PY'
import sys
if sys.version_info < (3, 9):
raise SystemExit("Python 3.9+ is required")
print(f"Python version OK: {sys.version.split()[0]}")
PY
check_python_module fastapi
check_python_module uvicorn
check_python_module websockets
check_python_module yaml
check_python_module dotenv
check_env_var OPENAI_API_KEY
check_env_var FINNHUB_API_KEY
check_env_var FIN_DATA_SOURCE
if ! command -v npm >/dev/null 2>&1; then
echo -e "${YELLOW}Warning: npm is not installed. Frontend startup via 'evotraders frontend' will not work.${NC}"
fi
export TRADING_SERVICE_URL="${TRADING_SERVICE_URL:-http://localhost:8001}"
export NEWS_SERVICE_URL="${NEWS_SERVICE_URL:-http://localhost:8002}"
export RUNTIME_SERVICE_URL="${RUNTIME_SERVICE_URL:-http://localhost:8003}"
export OPENCLAW_SERVICE_URL="${OPENCLAW_SERVICE_URL:-http://localhost:18789}"
check_openclaw_gateway
echo ""
echo -e "${GREEN}Starting EvoTraders split services (default mode)...${NC}"
echo " agent_service: http://localhost:8000"
echo " runtime_service: http://localhost:8003"
echo " openclaw_gateway: ws://localhost:18789"
echo " openclaw_gateway: ws://localhost:18789"
echo " trading_service: http://localhost:8001"
echo " news_service: http://localhost:8002"
echo ""