diff --git a/README.md b/README.md index ab25c6b..99218e6 100644 --- a/README.md +++ b/README.md @@ -726,7 +726,10 @@ Optional model prewarming is also declarative: programs.openclaw.qmd.prewarmModels.enable = true; ``` -That runs `qmd pull` during Home Manager activation and stores the default embedding, expansion, and reranking models in the user's QMD cache. Expect about 2.25GB of cache use. +That runs a temporary QMD collection through `qmd update`, `qmd embed`, and +`qmd query` during Home Manager activation, which warms the default embedding, +expansion, and reranking models in the user's QMD cache. Expect about 2.25GB of +cache use. ### What we manage vs what you manage diff --git a/nix/checks/openclaw-default-instance.nix b/nix/checks/openclaw-default-instance.nix index 14d825d..ea8c58e 100644 --- a/nix/checks/openclaw-default-instance.nix +++ b/nix/checks/openclaw-default-instance.nix @@ -212,10 +212,13 @@ let qmdPrewarmCheck = builtins.deepSeq (requireNoAssertionFailures "qmd.prewarmModels" qmdPrewarmEval) ( - if lib.hasInfix "/bin/qmd pull" qmdPrewarmActivation then + if + lib.hasInfix "OPENCLAW_QMD_BIN=" qmdPrewarmActivation + && lib.hasInfix "openclaw-qmd-prewarm.sh" qmdPrewarmActivation + then "ok" else - throw "qmd.prewarmModels did not wire qmd pull activation." + throw "qmd.prewarmModels did not wire QMD model-cache prewarm activation." ); checkKey = builtins.deepSeq [ diff --git a/nix/modules/home-manager/openclaw/config.nix b/nix/modules/home-manager/openclaw/config.nix index b592b8a..8e79395 100644 --- a/nix/modules/home-manager/openclaw/config.nix +++ b/nix/modules/home-manager/openclaw/config.nix @@ -332,7 +332,8 @@ in XDG_CACHE_HOME=${lib.escapeShellArg "${homeDir}/.cache"} \ XDG_CONFIG_HOME=${lib.escapeShellArg "${homeDir}/.config"} \ XDG_DATA_HOME=${lib.escapeShellArg "${homeDir}/.local/share"} \ - ${qmdPackage}/bin/qmd pull + OPENCLAW_QMD_BIN=${lib.escapeShellArg "${qmdPackage}/bin/qmd"} \ + ${pkgs.bash}/bin/bash ${../../../scripts/openclaw-qmd-prewarm.sh} '' ); diff --git a/nix/scripts/openclaw-qmd-prewarm.sh b/nix/scripts/openclaw-qmd-prewarm.sh new file mode 100644 index 0000000..c2f3b04 --- /dev/null +++ b/nix/scripts/openclaw-qmd-prewarm.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -euo pipefail + +qmd="${OPENCLAW_QMD_BIN:?OPENCLAW_QMD_BIN is required}" +tmp_dir="$(mktemp -d)" + +cleanup() { + rm -rf "$tmp_dir" + "$qmd" collection remove openclaw-prewarm >/dev/null 2>&1 || true +} +trap cleanup EXIT + +printf "%s\n\n%s\n" \ + "# OpenClaw QMD prewarm" \ + "This temporary document warms QMD model caches." \ + > "$tmp_dir/prewarm.md" + +"$qmd" collection remove openclaw-prewarm >/dev/null 2>&1 || true +"$qmd" collection add "$tmp_dir" --name openclaw-prewarm >/dev/null +"$qmd" update >/dev/null +"$qmd" embed >/dev/null +"$qmd" query "OpenClaw QMD prewarm" -n 1 --json >/dev/null