fix(document): select Office engines from declared native targets

This commit is contained in:
yudshj
2026-09-16 14:55:38 +08:00
parent fd3cdf539b
commit fcf9f4cfa2
39 changed files with 187 additions and 90 deletions
@@ -21,6 +21,7 @@ console command requires ``DSH_HOME`` for the same reason.
from __future__ import annotations
import json
import os
import platform
import shutil
@@ -89,13 +90,20 @@ def bundled_runtime_path() -> Path:
+ _EXE_ACQUISITION_HINT
)
office = path.with_name(f"{path.name.removesuffix('.exe')}-office")
engine = "wasm" if tag.startswith("linux-") else tag.replace("win-", "win32-").replace("macos-", "darwin-")
for required in ("@deepseek-ai/libreoffice-kit/package.json", f"@deepseek-ai/libreoffice-kit-{engine}/prebuilds.json"):
if not (office / "node_modules" / required).is_file():
raise FileNotFoundError(
f"deepseek-harness-runtime-bin is missing the Office sidecar at {office}. "
+ _EXE_ACQUISITION_HINT
)
adapter = office / "node_modules/@deepseek-ai/libreoffice-kit/package.json"
if not adapter.is_file():
raise FileNotFoundError(
f"deepseek-harness-runtime-bin is missing the Office sidecar at {office}. "
+ _EXE_ACQUISITION_HINT
)
native = tag.replace("win-", "win32-").replace("macos-", "darwin-")
declared = json.loads(adapter.read_text(encoding="utf-8")).get("optionalDependencies", {})
engine = native if f"@deepseek-ai/libreoffice-kit-{native}" in declared else "wasm"
if not (office / "node_modules" / f"@deepseek-ai/libreoffice-kit-{engine}/prebuilds.json").is_file():
raise FileNotFoundError(
f"deepseek-harness-runtime-bin is missing the Office sidecar engine {engine} at {office}. "
+ _EXE_ACQUISITION_HINT
)
return path