mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-08-29 04:26:38 +00:00
feat(python-runtime): package the Windows x64 dsh executable
Add node24-win-x64 as the only supported Windows runtime target and publish it as a py3-none-win_amd64 wheel containing the conventional dsh and ripgrep .exe payload names. Keep Windows ARM64 rejected explicitly so Python cannot claim a carrier that CI and release automation do not build. Teach the pkg builder to require a native x64 Windows host, validate both node-pty ConPTY addons, copy @vscode's win32 ripgrep executable, and recognize pkg's .exe output. Extend runtime resolution, wheel staging, payload validation, and the preset closure check so the Windows-specific PowerShell plugins and sidecars fail loud when omitted. The sidecar resolver now maps a packaged main.exe to main-rg.exe; focused TypeScript and Python tests cover that name, the win_amd64 manifest, x64-only host selection, complete wheel payload, ConPTY inventory, and platform-conditioned plugin closure.
This commit is contained in:
@@ -39,7 +39,15 @@ def _host_platform_tag() -> str:
|
||||
machine = platform.machine().lower()
|
||||
arch = "arm64" if machine in {"arm64", "aarch64"} else "x64" if machine in {"x86_64", "amd64"} else machine
|
||||
system = platform.system().lower()
|
||||
key = f"macos-{arch}" if system == "darwin" else f"linux-{arch}" if system == "linux" else system
|
||||
key = (
|
||||
f"macos-{arch}"
|
||||
if system == "darwin"
|
||||
else f"linux-{arch}"
|
||||
if system == "linux"
|
||||
else f"win-{arch}"
|
||||
if system == "windows"
|
||||
else system
|
||||
)
|
||||
try:
|
||||
return _PLATFORMS[key][0]
|
||||
except KeyError as exc:
|
||||
@@ -69,16 +77,21 @@ class RuntimeBuildHook(BuildHookInterface):
|
||||
runtime_files = sorted(
|
||||
runtime_dir.glob("deepseek-harness-sdk-runtime-*") if runtime_dir.is_dir() else []
|
||||
)
|
||||
expected_files = [expected_executable, f"{expected_executable}-rg"]
|
||||
expected_files = (
|
||||
[expected_executable, f"{expected_executable.removesuffix('.exe')}-rg.exe"]
|
||||
if expected_executable.endswith(".exe")
|
||||
else [expected_executable, f"{expected_executable}-rg"]
|
||||
)
|
||||
if "-macos-" in expected_executable:
|
||||
expected_files.append(f"{expected_executable}-spawn-helper")
|
||||
expected_files.sort()
|
||||
found_files = [path.name for path in runtime_files]
|
||||
if found_files != expected_files:
|
||||
raise RuntimeError(
|
||||
f"runtime wheel {platform_tag} payload must be {expected_files}; found {found_files}"
|
||||
)
|
||||
for executable in runtime_files:
|
||||
if executable.stat().st_mode & stat.S_IXUSR == 0:
|
||||
if platform_tag != "win_amd64" and executable.stat().st_mode & stat.S_IXUSR == 0:
|
||||
raise RuntimeError(f"runtime executable is not executable: {executable}")
|
||||
build_data["pure_python"] = False
|
||||
build_data["infer_tag"] = False
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
"@deepseek-ai/dsh-plan-mode": "workspace:^",
|
||||
"@deepseek-ai/dsh-persona": "workspace:^",
|
||||
"@deepseek-ai/dsh-pwsh-local": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-pwsh-persistent": "workspace:^",
|
||||
"@deepseek-ai/dsh-terminal": "workspace:^",
|
||||
"@deepseek-ai/dsh-terminal-bash": "workspace:^",
|
||||
"@deepseek-ai/dsh-repeat-tool-reminder": "workspace:^",
|
||||
@@ -103,6 +104,7 @@
|
||||
"@deepseek-ai/dsh-tool-fs": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-fs-search": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-goal": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-pwsh": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-ralph": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-skill": "workspace:^",
|
||||
"@deepseek-ai/dsh-tool-str-replace-editor": "workspace:^",
|
||||
|
||||
@@ -10,5 +10,9 @@
|
||||
"macos-arm64": {
|
||||
"tag": "macosx_14_0_arm64",
|
||||
"executable": "deepseek-harness-sdk-runtime-macos-arm64"
|
||||
},
|
||||
"win-x64": {
|
||||
"tag": "win_amd64",
|
||||
"executable": "deepseek-harness-sdk-runtime-win-x64.exe"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,10 @@ Two runtime carriers coexist under ``runtime/``, both injected by the repo's
|
||||
``scripts/build-exe-for-python-sdk.ts`` build (neither is checked into git):
|
||||
|
||||
- **exe (production)**: single-file Node executables named
|
||||
``deepseek-harness-sdk-runtime-<platform>-<arch>`` (platform in {linux, macos}, arch in
|
||||
{x64, arm64}) with a sibling ``-rg`` executable; macOS also uses a sibling
|
||||
``-spawn-helper``. The target machine needs no Node installation.
|
||||
``deepseek-harness-sdk-runtime-<platform>-<arch>`` for Linux/macOS and an
|
||||
``.exe`` counterpart for Windows. Each has a sibling ripgrep executable;
|
||||
macOS also uses a sibling ``-spawn-helper``. The target machine needs no
|
||||
Node installation.
|
||||
- **node (dev-only)**: the full deploy closure under ``runtime/node/``
|
||||
(``package.json`` + ``node_modules/``), executed as ``node
|
||||
runtime/node/node_modules/@deepseek-ai/dsh/lib/bin.js`` on a
|
||||
@@ -30,7 +31,7 @@ PACKAGE_METADATA_FILENAME = "deepseek-harness-runtime.json"
|
||||
|
||||
RUNTIME_MODE_ENV_VAR = "DSH_RUNTIME_MODE"
|
||||
|
||||
_PLATFORM_TAGS = {"linux": "linux", "darwin": "macos"}
|
||||
_PLATFORM_TAGS = {"linux": "linux", "darwin": "macos", "win32": "win"}
|
||||
_ARCH_TAGS = {"x86_64": "x64", "amd64": "x64", "arm64": "arm64", "aarch64": "arm64"}
|
||||
|
||||
_EXE_ACQUISITION_HINT = (
|
||||
@@ -62,13 +63,18 @@ def bundled_runtime_path() -> Path:
|
||||
touching callers).
|
||||
"""
|
||||
tag = _current_platform_tag()
|
||||
path = bundled_package_dir() / "runtime" / f"deepseek-harness-sdk-runtime-{tag}"
|
||||
extension = ".exe" if tag.startswith("win-") else ""
|
||||
path = bundled_package_dir() / "runtime" / f"deepseek-harness-sdk-runtime-{tag}{extension}"
|
||||
if not path.is_file():
|
||||
raise FileNotFoundError(
|
||||
f"deepseek-harness-runtime-bin is missing the runtime executable at {path}. "
|
||||
+ _EXE_ACQUISITION_HINT
|
||||
)
|
||||
ripgrep = Path(f"{path}-rg")
|
||||
ripgrep = (
|
||||
path.with_name(f"{path.stem}-rg.exe")
|
||||
if tag.startswith("win-")
|
||||
else Path(f"{path}-rg")
|
||||
)
|
||||
if not ripgrep.is_file():
|
||||
raise FileNotFoundError(
|
||||
f"deepseek-harness-runtime-bin is missing the ripgrep sidecar at {ripgrep}. "
|
||||
@@ -110,11 +116,11 @@ def resolve_bundled_launch_args(mode: str | None = None) -> tuple[str, ...]:
|
||||
def _current_platform_tag() -> str:
|
||||
plat = _PLATFORM_TAGS.get(sys.platform)
|
||||
arch = _ARCH_TAGS.get(platform.machine().lower())
|
||||
if plat is None or arch is None:
|
||||
if plat is None or arch is None or (plat == "win" and arch != "x64"):
|
||||
raise FileNotFoundError(
|
||||
"no bundled DeepSeek Harness SDK runtime exists for this platform "
|
||||
f"(sys.platform={sys.platform!r}, machine={platform.machine()!r}); supported: "
|
||||
"linux/macos on x64/arm64. " + _EXE_ACQUISITION_HINT
|
||||
"Linux x64/arm64, macOS arm64, and Windows x64. " + _EXE_ACQUISITION_HINT
|
||||
)
|
||||
return f"{plat}-{arch}"
|
||||
|
||||
|
||||
@@ -93,11 +93,14 @@ class HarnessClient:
|
||||
self._start_stderr_thread()
|
||||
|
||||
def close(self) -> None:
|
||||
"""Close the runtime after a bounded opportunity to flush durable state."""
|
||||
proc = self._proc
|
||||
if proc is None:
|
||||
return
|
||||
shutdown_completed = False
|
||||
try:
|
||||
self.request("shutdown", None, response_model=_ShutdownResponse, timeout_seconds=self.config.shutdown_timeout_seconds)
|
||||
shutdown_completed = True
|
||||
except Exception as exc:
|
||||
self._stderr_lines.append(f"shutdown request failed: {exc}")
|
||||
if proc.stdin:
|
||||
@@ -105,16 +108,22 @@ class HarnessClient:
|
||||
proc.stdin.close()
|
||||
except Exception as exc:
|
||||
self._stderr_lines.append(f"stdin close failed: {exc}")
|
||||
if shutdown_completed:
|
||||
try:
|
||||
proc.wait(timeout=self.config.shutdown_timeout_seconds)
|
||||
except subprocess.TimeoutExpired:
|
||||
pass
|
||||
if proc.poll() is None:
|
||||
try:
|
||||
proc.terminate()
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
try:
|
||||
proc.wait(timeout=self.config.shutdown_timeout_seconds)
|
||||
except subprocess.TimeoutExpired:
|
||||
proc.kill()
|
||||
proc.wait()
|
||||
if proc.poll() is None:
|
||||
try:
|
||||
proc.wait(timeout=self.config.shutdown_timeout_seconds)
|
||||
except subprocess.TimeoutExpired:
|
||||
proc.kill()
|
||||
proc.wait()
|
||||
self._proc = None
|
||||
self._fail_waiters(self._runtime_closed_error("DeepSeek Harness runtime closed"))
|
||||
if self._reader_thread and self._reader_thread.is_alive():
|
||||
|
||||
@@ -783,6 +783,43 @@ for line in sys.stdin:
|
||||
assert client._proc is None
|
||||
|
||||
|
||||
def test_client_close_allows_eof_quiescence_after_shutdown_response(tmp_path: Path) -> None:
|
||||
script = tmp_path / "fake_runtime.py"
|
||||
marker = tmp_path / "quiesced.txt"
|
||||
script.write_text(
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import time
|
||||
|
||||
for line in sys.stdin:
|
||||
msg = json.loads(line)
|
||||
if msg.get("method") == "initialize":
|
||||
print(json.dumps({"jsonrpc": "2.0", "id": msg["id"], "result": {"serverInfo": {"name": "fake-dsh"}}}), flush=True)
|
||||
elif msg.get("method") == "shutdown":
|
||||
print(json.dumps({"jsonrpc": "2.0", "id": msg["id"], "result": {}}), flush=True)
|
||||
|
||||
time.sleep(0.05)
|
||||
Path(os.environ["QUIESCED_MARKER"]).write_text("quiesced")
|
||||
""".strip()
|
||||
)
|
||||
|
||||
client = HarnessClient(
|
||||
HarnessConfig(
|
||||
_launch_args=(sys.executable, str(script)),
|
||||
env={"QUIESCED_MARKER": str(marker)},
|
||||
shutdown_timeout_seconds=1,
|
||||
)
|
||||
)
|
||||
client.start()
|
||||
client.initialize(provider="deepseek-official", cwd="/workspace", model="dsagent")
|
||||
client.close()
|
||||
|
||||
assert marker.read_text() == "quiesced"
|
||||
|
||||
|
||||
def test_initialize_failure_reaps_started_runtime(tmp_path: Path) -> None:
|
||||
script = tmp_path / "rejecting_runtime.py"
|
||||
script.write_text(
|
||||
|
||||
@@ -62,6 +62,14 @@ def test_macos_wheel_tag_does_not_claim_unsupported_node_platforms() -> None:
|
||||
assert build_python_release.PLATFORMS["macos-arm64"][1] == "deepseek-harness-sdk-runtime-macos-arm64"
|
||||
|
||||
|
||||
def test_windows_wheel_tag_and_payload_are_x64_only() -> None:
|
||||
assert build_python_release.PLATFORMS["win-x64"] == (
|
||||
"win_amd64",
|
||||
"deepseek-harness-sdk-runtime-win-x64.exe",
|
||||
)
|
||||
assert not any(name.startswith("win-") and name != "win-x64" for name in build_python_release.PLATFORMS)
|
||||
|
||||
|
||||
def test_platform_manifest_rejects_incomplete_entries(tmp_path: Path) -> None:
|
||||
manifest = tmp_path / "platforms.json"
|
||||
manifest.write_text('{"macos-arm64":{"tag":"macosx_14_0_arm64"}}\n')
|
||||
@@ -85,7 +93,10 @@ def test_stage_sdk_keeps_distribution_module_and_runtime_pin_distinct(tmp_path:
|
||||
assert (destination / "src" / "deepseek_harness" / "__init__.py").is_file()
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("target", "with_helper"), [("linux-x64", False), ("macos-arm64", True)])
|
||||
@pytest.mark.parametrize(
|
||||
("target", "with_helper"),
|
||||
[("linux-x64", False), ("macos-arm64", True), ("win-x64.exe", False)],
|
||||
)
|
||||
def test_stage_runtime_copies_platform_payload(
|
||||
tmp_path: Path, target: str, with_helper: bool
|
||||
) -> None:
|
||||
@@ -93,7 +104,11 @@ def test_stage_runtime_copies_platform_payload(
|
||||
executable.write_bytes(b"runtime")
|
||||
executable.chmod(0o755)
|
||||
expected = {executable.name: b"runtime"}
|
||||
ripgrep = Path(f"{executable}-rg")
|
||||
ripgrep = (
|
||||
executable.with_name(f"{executable.stem}-rg.exe")
|
||||
if executable.suffix == ".exe"
|
||||
else Path(f"{executable}-rg")
|
||||
)
|
||||
ripgrep.write_bytes(b"ripgrep")
|
||||
ripgrep.chmod(0o755)
|
||||
expected[ripgrep.name] = b"ripgrep"
|
||||
|
||||
@@ -55,6 +55,30 @@ def test_runtime_requires_spawn_helper_only_on_macos(
|
||||
assert runtime.bundled_runtime_path() == linux
|
||||
|
||||
|
||||
def test_windows_runtime_uses_exe_payload_and_exe_sidecar(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
runtime_dir = tmp_path / "runtime"
|
||||
runtime_dir.mkdir()
|
||||
executable = runtime_dir / "deepseek-harness-sdk-runtime-win-x64.exe"
|
||||
executable.touch()
|
||||
(runtime_dir / "deepseek-harness-sdk-runtime-win-x64-rg.exe").touch()
|
||||
monkeypatch.setattr(runtime, "bundled_package_dir", lambda: tmp_path)
|
||||
monkeypatch.setattr(runtime, "_current_platform_tag", lambda: "win-x64")
|
||||
|
||||
assert runtime.bundled_runtime_path() == executable
|
||||
|
||||
|
||||
def test_current_platform_supports_windows_x64_only(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(runtime.sys, "platform", "win32")
|
||||
monkeypatch.setattr(runtime.platform, "machine", lambda: "AMD64")
|
||||
assert runtime._current_platform_tag() == "win-x64"
|
||||
|
||||
monkeypatch.setattr(runtime.platform, "machine", lambda: "ARM64")
|
||||
with pytest.raises(FileNotFoundError, match="Windows x64"):
|
||||
runtime._current_platform_tag()
|
||||
|
||||
|
||||
def test_runtime_requires_ripgrep_sidecar(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
|
||||
Reference in New Issue
Block a user