feat: ASRX hybrid pipeline, identity history, worker fixes, checkpoint system

This commit is contained in:
Accusys
2026-06-02 07:13:23 +08:00
parent e3066c3f49
commit e1572907ae
198 changed files with 43705 additions and 8910 deletions

View File

@@ -4,6 +4,24 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
ENV_FILE="${PROJECT_DIR}/.env.development"
# Load env vars (silently)
source "$ENV_FILE" 2>/dev/null || true
# Path defaults (can be overridden by env vars above)
LOG_DIR="${MOMENTRY_LOG_DIR:-/Users/accusys/momentry/logs}"
PG_BIN_DIR="${MOMENTRY_PG_BIN_DIR:-/Users/accusys/pgsql/18.3/bin}"
PG_DATA_DIR="${MOMENTRY_PG_DATA_DIR:-/Users/accusys/pgsql/data}"
QDRANT_BIN="${MOMENTRY_QDRANT_BIN:-/Users/accusys/.cargo/bin/qdrant}"
QDRANT_STORAGE_DIR="${MOMENTRY_QDRANT_STORAGE_DIR:-/Users/accusys/momentry/qdrant_storage}"
LLAMACPP_BIN="${MOMENTRY_LLAMACPP_BIN:-/Users/accusys/llama/bin/llama-server}"
A4B_MODEL="${MOMENTRY_LLM_A4B_MODEL_PATH:-/Users/accusys/models/google_gemma-4-26B-A4B-it-Q5_K_M.gguf}"
A4B_MMPROJ="${MOMENTRY_LLM_A4B_MMPROJ_PATH:-/Users/accusys/models/gemma-4-26B-A4B-it.mmproj-f16.gguf}"
E4B_MODEL="${MOMENTRY_LLM_E4B_MODEL_PATH:-/Users/accusys/models/gemma-4-E4B-it-Q4_K_M.gguf}"
E4B_MMPROJ="${MOMENTRY_LLM_E4B_MMPROJ_PATH:-/Users/accusys/models/mmproj-gemma-4-E4B-it-BF16.gguf}"
OLLAMA_BIN="${MOMENTRY_OLLAMA_BIN:-/Users/accusys/bin/ollama}"
PLAYGROUND_BIN="${MOMENTRY_PLAYGROUND_BIN:-target/debug/momentry_playground}"
API_KEY="${MOMENTRY_API_KEY:-muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69}"
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
@@ -17,27 +35,23 @@ check() {
if [ $? -eq 0 ]; then echo -e " ${GREEN}${NC} $1"; else echo -e " ${RED}${NC} $1"; FAILURES+=("$1"); fi
}
echo -e "${CYAN}====================================${NC}"
echo -e "${CYAN}========================================${NC}"
echo -e "${CYAN} Momentry Core - Startup Sequence${NC}"
echo -e "${CYAN}====================================${NC}"
echo -e "${CYAN}========================================${NC}"
echo ""
LOG_DIR="/Users/accusys/momentry/logs"
# ── 1. PostgreSQL ──
echo -e "${YELLOW}[1/8] PostgreSQL${NC}"
PG_DATA="/Users/accusys/pgsql/data"
PG_BIN="/Users/accusys/pgsql/18.3/bin"
if $PG_BIN/pg_isready -q 2>/dev/null; then
echo -e "${YELLOW}[1/10] PostgreSQL${NC}"
if "$PG_BIN_DIR/pg_isready" -q 2>/dev/null; then
echo -e " ${GREEN}${NC} already running"
else
$PG_BIN/pg_ctl -D "$PG_DATA" -l "$LOG_DIR/pg.log" start 2>/dev/null
"$PG_BIN_DIR/pg_ctl" -D "$PG_DATA_DIR" -l "$LOG_DIR/pg.log" start 2>/dev/null
sleep 2
$PG_BIN/pg_isready -q 2>/dev/null; check "started"
"$PG_BIN_DIR/pg_isready" -q 2>/dev/null; check "started"
fi
# ── 2. Redis ──
echo -e "${YELLOW}[2/8] Redis${NC}"
echo -e "${YELLOW}[2/10] Redis${NC}"
if redis-cli ping 2>/dev/null | grep -q PONG; then
echo -e " ${GREEN}${NC} already running"
else
@@ -46,14 +60,22 @@ else
redis-cli ping 2>/dev/null | grep -q PONG; check "started"
fi
# ── 3. Qdrant ──
echo -e "${YELLOW}[3/8] Qdrant${NC}"
QDRANT_BIN="/Users/accusys/momentry_resources/bin/qdrant"
QDRANT_STORAGE="/Users/accusys/momentry/qdrant_storage"
# ── 3. MongoDB ──
echo -e "${YELLOW}[3/10] MongoDB${NC}"
if pgrep -q mongod 2>/dev/null; then
echo -e " ${GREEN}${NC} already running"
else
brew services start mongodb-community 2>/dev/null || mongod --dbpath /opt/homebrew/var/mongodb --logpath "$LOG_DIR/mongodb.log" --fork 2>/dev/null
sleep 2
pgrep -q mongod 2>/dev/null; check "started"
fi
# ── 4. Qdrant ──
echo -e "${YELLOW}[4/10] Qdrant${NC}"
if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 http://localhost:6333/healthz 2>/dev/null | grep -q 200; then
echo -e " ${GREEN}${NC} already running"
else
mkdir -p "$QDRANT_STORAGE"
mkdir -p "$QDRANT_STORAGE_DIR"
"$QDRANT_BIN" > "$LOG_DIR/qdrant.log" 2>&1 &
for i in $(seq 1 15); do
sleep 2
@@ -64,9 +86,8 @@ else
curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 http://localhost:6333/healthz 2>/dev/null | grep -q 200; check "started"
fi
# ── 4. Qdrant Collection ──
echo -e "${YELLOW}[4/8] Qdrant Collection${NC}"
source "$ENV_FILE" 2>/dev/null || true
# ── 5. Qdrant Collection ──
echo -e "${YELLOW}[5/10] Qdrant Collection${NC}"
COLLECTION="${QDRANT_COLLECTION:-momentry_dev_rule1_v2}"
EXISTS=$(curl -s "http://localhost:6333/collections/$COLLECTION" 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('result',{}).get('status','not_found'))" 2>/dev/null)
if [ "$EXISTS" = "not_found" ]; then
@@ -78,15 +99,19 @@ fi
curl -s "http://localhost:6333/collections/$COLLECTION" 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); s=d.get('result',{}).get('status','not_found'); assert s in ('green','ok'), f'unexpected status: {s}'" 2>/dev/null
check "collection '$COLLECTION' ready"
# ── 5. LLM (Gemma4 / llama.cpp) ──
echo -e "${YELLOW}[5/8] LLM Server (Gemma4)${NC}"
# ── 6a. LLM Chat (A4B, port 8082) ──
echo -e "${YELLOW}[6a/10] LLM Chat - A4B (port 8082)${NC}"
if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 http://localhost:8082/health 2>/dev/null | grep -q 200; then
echo -e " ${GREEN}${NC} already running"
else
LLM_BIN="/Users/accusys/momentry_resources/llama/bin/llama-server"
LLM_MODEL="/Users/accusys/momentry/models/llm/google_gemma-4-26B-A4B-it-Q5_K_M.gguf"
"$LLM_BIN" -m "$LLM_MODEL" --host 0.0.0.0 --port 8082 -ngl 99 -c 16384 --temp 0.1 --mlock --reasoning off > "$LOG_DIR/llama_server.log" 2>&1 &
echo -e " ${YELLOW}⏳ loading model (~30s)...${NC}"
LLAMA_ARGS_A4B=(
-m "$A4B_MODEL"
--mmproj "$A4B_MMPROJ"
--host 0.0.0.0 --port 8082
-ngl 99 -c 16384 --temp 0.1 --mlock --reasoning off
)
"$LLAMACPP_BIN" "${LLAMA_ARGS_A4B[@]}" > "$LOG_DIR/llama_a4b.log" 2>&1 &
echo -e " ${YELLOW}⏳ loading A4B model (~30s)...${NC}"
for i in $(seq 1 30); do
sleep 2
if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 2 http://localhost:8082/health 2>/dev/null | grep -q 200; then
@@ -96,8 +121,30 @@ else
curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 http://localhost:8082/health 2>/dev/null | grep -q 200; check "started"
fi
# ── 6. Embedding Server ──
echo -e "${YELLOW}[6/8] EmbeddingGemma${NC}"
# ── 6b. LLM Vision (E4B, port 8083) ──
echo -e "${YELLOW}[6b/10] LLM Vision - E4B (port 8083)${NC}"
if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 http://localhost:8083/health 2>/dev/null | grep -q 200; then
echo -e " ${GREEN}${NC} already running"
else
LLAMA_ARGS_E4B=(
-m "$E4B_MODEL"
--mmproj "$E4B_MMPROJ"
--host 0.0.0.0 --port 8083
-ngl 99 -c 16384 --temp 0.1 --mlock
)
"$LLAMACPP_BIN" "${LLAMA_ARGS_E4B[@]}" > "$LOG_DIR/llama_e4b.log" 2>&1 &
echo -e " ${YELLOW}⏳ loading E4B model (~30s)...${NC}"
for i in $(seq 1 30); do
sleep 2
if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 2 http://localhost:8083/health 2>/dev/null | grep -q 200; then
break
fi
done
curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 http://localhost:8083/health 2>/dev/null | grep -q 200; check "started"
fi
# ── 7. Embedding Server ──
echo -e "${YELLOW}[7/10] EmbeddingGemma${NC}"
if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 http://localhost:11436/health 2>/dev/null | grep -q 200; then
echo -e " ${GREEN}${NC} already running"
else
@@ -112,23 +159,22 @@ else
curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 http://localhost:11436/health 2>/dev/null | grep -q 200; check "started"
fi
# ── 7. Playground Server ──
echo -e "${YELLOW}[7/8] Playground API Server${NC}"
if curl -s -o /dev/null -w "%{http_code}" -H "X-API-Key: muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69" --connect-timeout 5 http://127.0.0.1:3003/api/v1/agents/5w1h/status 2>/dev/null | grep -q 200; then
# ── 8. Playground Server ──
echo -e "${YELLOW}[8/10] Playground API Server${NC}"
if curl -s -o /dev/null -w "%{http_code}" -H "X-API-Key: $API_KEY" --connect-timeout 5 http://127.0.0.1:3003/api/v1/agents/5w1h/status 2>/dev/null | grep -q 200; then
echo -e " ${GREEN}${NC} already running"
else
cd "$PROJECT_DIR"
target/debug/momentry_playground server > "$LOG_DIR/playground.log" 2>&1 &
$PLAYGROUND_BIN server > "$LOG_DIR/playground.log" 2>&1 &
sleep 4
curl -s -o /dev/null -w "%{http_code}" -H "X-API-Key: muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69" --connect-timeout 5 http://127.0.0.1:3003/api/v1/agents/5w1h/status 2>/dev/null | grep -q 200; check "started"
curl -s -o /dev/null -w "%{http_code}" -H "X-API-Key: $API_KEY" --connect-timeout 5 http://127.0.0.1:3003/api/v1/agents/5w1h/status 2>/dev/null | grep -q 200; check "started"
fi
# ── 8. Ollama (Gemma4 E4B) ──
echo -e "${YELLOW}[8/8] Ollama (Gemma4 E4B)${NC}"
# ── 9. Ollama ──
echo -e "${YELLOW}[9/10] Ollama${NC}"
if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 http://localhost:11434/api/tags 2>/dev/null | grep -q 200; then
echo -e " ${GREEN}${NC} already running"
else
OLLAMA_BIN="/Users/accusys/momentry_resources/bin/ollama"
if [ ! -f "$OLLAMA_BIN" ]; then
echo -e " ${YELLOW}⚠ ollama binary not found, skipping${NC}"
else
@@ -138,6 +184,16 @@ else
fi
fi
# ── 10. SFTPGo ──
echo -e "${YELLOW}[10/10] SFTPGo${NC}"
if curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 http://localhost:8080/api/v1/version 2>/dev/null | grep -q 200; then
echo -e " ${GREEN}${NC} already running"
else
/Users/accusys/bin/sftpgo serve -c /Users/accusys/momentry/etc/sftpgo > "$LOG_DIR/sftpgo.log" 2>&1 &
sleep 3
curl -s -o /dev/null -w "%{http_code}" --connect-timeout 5 http://localhost:8080/api/v1/version 2>/dev/null | grep -q 200; check "started"
fi
echo ""
if [ ${#FAILURES[@]} -eq 0 ]; then
echo -e "${GREEN}====================================${NC}"
@@ -151,10 +207,13 @@ else
fi
echo ""
echo " Playground: http://127.0.0.1:3003"
echo " LLM: http://127.0.0.1:8082"
echo " LLM Chat: http://127.0.0.1:8082"
echo " LLM Vision: http://127.0.0.1:8083"
echo " Embedding: http://127.0.0.1:11436"
echo " Ollama: http://localhost:11434"
echo " Qdrant: http://localhost:6333"
echo " PostgreSQL: localhost:5432"
echo " Redis: localhost:6379"
echo " MongoDB: localhost:27017"
echo " SFTPGo: http://localhost:8080 (SFTP: port 2022)"
echo ""