diff --git a/openclaw_assistant/Dockerfile b/openclaw_assistant/Dockerfile index 4af525d..fb823ac 100644 --- a/openclaw_assistant/Dockerfile +++ b/openclaw_assistant/Dockerfile @@ -26,6 +26,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ nano \ fd-find \ ripgrep \ + rsync \ bat \ less \ && apt-get clean \ diff --git a/openclaw_assistant/config.yaml b/openclaw_assistant/config.yaml index 3e9927f..729faaf 100644 --- a/openclaw_assistant/config.yaml +++ b/openclaw_assistant/config.yaml @@ -1,5 +1,5 @@ name: OpenClaw Assistant -version: "0.5.40" +version: "0.5.41" slug: openclaw_assistant description: Run OpenClaw Assistant (OpenClaw-compatible) as a Home Assistant add-on. url: https://github.com/techartdev/OpenClawHomeAssistant diff --git a/openclaw_assistant/run.sh b/openclaw_assistant/run.sh index 5f785e6..0d151df 100644 --- a/openclaw_assistant/run.sh +++ b/openclaw_assistant/run.sh @@ -67,6 +67,53 @@ export XDG_CONFIG_HOME=/config mkdir -p /config/.openclaw /config/clawd /config/keys /config/secrets +# ------------------------------------------------------------------------------ +# Sync built-in OpenClaw skills from image to persistent storage +# On each startup, copy new/updated built-in skills so they survive rebuilds. +# We sync them to /config/.openclaw/skills and symlink back. +# NOTE: We cannot use `npm root -g` here because HOME=/config may contain a +# persisted .npmrc with a custom prefix from a previous run. Instead, we +# resolve the real image path by temporarily overriding HOME. +# ------------------------------------------------------------------------------ +IMAGE_SKILLS_DIR="$(HOME=/root npm root -g 2>/dev/null)/openclaw/skills" +PERSISTENT_SKILLS_DIR="/config/.openclaw/skills" + +if [ -d "$IMAGE_SKILLS_DIR" ] && [ ! -L "$IMAGE_SKILLS_DIR" ]; then + mkdir -p "$PERSISTENT_SKILLS_DIR" + # Sync skills: --update replaces older files so upgrades propagate, + # but doesn't delete user-added files in persistent storage. + if command -v rsync >/dev/null 2>&1; then + rsync -a --update "$IMAGE_SKILLS_DIR/" "$PERSISTENT_SKILLS_DIR/" 2>/dev/null || true + else + cp -ru "$IMAGE_SKILLS_DIR/"* "$PERSISTENT_SKILLS_DIR/" 2>/dev/null || true + fi + # Replace image skills dir with symlink to persistent copy + rm -rf "$IMAGE_SKILLS_DIR" + ln -sf "$PERSISTENT_SKILLS_DIR" "$IMAGE_SKILLS_DIR" + echo "INFO: Synced built-in skills to persistent storage at $PERSISTENT_SKILLS_DIR" +elif [ -L "$IMAGE_SKILLS_DIR" ]; then + echo "INFO: Built-in skills already linked to persistent storage" +else + echo "WARN: Built-in skills directory not found at $IMAGE_SKILLS_DIR" +fi + +# ------------------------------------------------------------------------------ +# Persist user-installed node skills across Docker image rebuilds +# Redirect npm/pnpm global installs to /config/.node_global (persistent storage) +# so that skills installed via the dashboard survive container rebuilds. +# NOTE: This MUST come after the skills sync above (which needs the original npm root -g). +# ------------------------------------------------------------------------------ +PERSISTENT_NODE_GLOBAL="/config/.node_global" +mkdir -p "$PERSISTENT_NODE_GLOBAL" +npm config set prefix "$PERSISTENT_NODE_GLOBAL" 2>/dev/null || true +export PATH="${PERSISTENT_NODE_GLOBAL}/bin:${PATH}" +export NODE_PATH="${PERSISTENT_NODE_GLOBAL}/lib/node_modules:${NODE_PATH:-}" + +# Also configure pnpm global dir to persistent storage +export PNPM_HOME="${PERSISTENT_NODE_GLOBAL}/pnpm" +mkdir -p "$PNPM_HOME" +export PATH="${PNPM_HOME}:${PATH}" + # Back-compat: some docs/scripts assume /data; point it at /config. if [ ! -e /data ]; then ln -s /config /data || true