diff --git a/convert_to_webp.py b/convert_to_webp.py index 396db86..0cf31f4 100644 --- a/convert_to_webp.py +++ b/convert_to_webp.py @@ -9,7 +9,8 @@ import os from PIL import Image # 路径 -FRONTEND_DIR = "/root/.openclaw/workspace/star-office-ui/frontend" +ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) +FRONTEND_DIR = os.path.join(ROOT_DIR, "frontend") STATIC_DIR = os.path.join(FRONTEND_DIR, "") # 文件分类配置 diff --git a/healthcheck.sh b/healthcheck.sh index b5b2890..ae20032 100755 --- a/healthcheck.sh +++ b/healthcheck.sh @@ -2,14 +2,16 @@ # Star Office UI Health Check # Checks if backend is responding, restarts if not -BACKEND_URL="http://127.0.0.1:18791/health" -LOG_FILE="/root/.openclaw/workspace/star-office-ui/healthcheck.log" +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +OFFICE_PORT="${OFFICE_PORT:-19000}" +BACKEND_URL="http://127.0.0.1:${OFFICE_PORT}/health" +LOG_FILE="${SCRIPT_DIR}/healthcheck.log" # Log timestamp echo "[$(date '+%Y-%m-%d %H:%M:%S')] Health check starting..." >> "$LOG_FILE" # Check backend -if curl -sS "$BACKEND_URL" > /dev/null 2>&1; then +if curl -fsS --max-time 5 "$BACKEND_URL" > /dev/null 2>&1; then echo "[$(date '+%Y-%m-%d %H:%M:%S')] Backend is healthy" >> "$LOG_FILE" else echo "[$(date '+%Y-%m-%d %H:%M:%S')] Backend is NOT healthy - restarting..." >> "$LOG_FILE" diff --git a/office-agent-push.py b/office-agent-push.py index 7184623..ac8f905 100644 --- a/office-agent-push.py +++ b/office-agent-push.py @@ -31,16 +31,15 @@ STATE_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "office-ag # 优先读取本机 OpenClaw 工作区的状态文件(更贴合 AGENTS.md 的工作流) # 支持自动发现,减少对方手动配置成本。 +_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) DEFAULT_STATE_CANDIDATES = [ - "/root/.openclaw/workspace/star-office-ui/state.json", - "/root/.openclaw/workspace/state.json", + os.path.join(_SCRIPT_DIR, "state.json"), os.path.join(os.getcwd(), "state.json"), - os.path.join(os.path.dirname(os.path.abspath(__file__)), "state.json"), ] # 如果对方本地 /status 需要鉴权,可在这里填写 token(或通过环境变量 OFFICE_LOCAL_STATUS_TOKEN) LOCAL_STATUS_TOKEN = os.environ.get("OFFICE_LOCAL_STATUS_TOKEN", "") -LOCAL_STATUS_URL = os.environ.get("OFFICE_LOCAL_STATUS_URL", "http://127.0.0.1:18791/status") +LOCAL_STATUS_URL = os.environ.get("OFFICE_LOCAL_STATUS_URL", "http://127.0.0.1:19000/status") # 可选:直接指定本地状态文件路径(最简单方案:绕过 /status 鉴权) LOCAL_STATE_FILE = os.environ.get("OFFICE_LOCAL_STATE_FILE", "") VERBOSE = os.environ.get("OFFICE_VERBOSE", "0") in {"1", "true", "TRUE", "yes", "YES"} diff --git a/repack_star_working.py b/repack_star_working.py index 82f86f1..26a8e5a 100644 --- a/repack_star_working.py +++ b/repack_star_working.py @@ -23,7 +23,7 @@ import math import os from PIL import Image -ROOT = "/root/.openclaw/workspace/star-office-ui" +ROOT = os.path.dirname(os.path.abspath(__file__)) IN_PATH = os.path.join(ROOT, "frontend", "star-working-spritesheet.png") OUT_PATH = os.path.join(ROOT, "frontend", "star-working-spritesheet-grid.png") diff --git a/set_state.py b/set_state.py index 3092b37..79096c5 100644 --- a/set_state.py +++ b/set_state.py @@ -6,7 +6,8 @@ import os import sys from datetime import datetime -STATE_FILE = "/root/.openclaw/workspace/star-office-ui/state.json" +ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) +STATE_FILE = os.path.join(ROOT_DIR, "state.json") VALID_STATES = [ "idle",