Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(install): keep Windows on Arm on x64 Python, and the Model Hub engine native (#2476)
Call Whiteb83d6e83f946
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex 0883452a6..d76a7c86b 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -411,9 +411,14 @@ jobs:fiecho "All install and upgrade suites passed."- windows-install-smoke:- runs-on: windows-latest+ windows-install-smoke-runners:+ name: windows-install-smoke (${{ matrix.runner }})+ runs-on: ${{ matrix.runner }}needs: build-linux-artifacts+ strategy:+ fail-fast: false+ matrix:+ runner: [windows-latest, windows-11-arm]steps:- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5@@ -474,6 +479,29 @@ jobs:throw "vibe version output missing expected marker"}+ # Windows on Arm installs on x64 Python: cryptography and claude-agent-sdk+ # publish no win_arm64 wheels, so install.ps1 asks uv for x64 there.+ - name: Verify the installed Python is x64+ shell: pwsh+ run: |+ $python = @(Get-ChildItem "$env:USERPROFILE\.avibe\runtime\install-generations\*\uv\tools\avibe-os\Scripts\python.exe")[0].FullName+ $platform = & $python -c "import sysconfig; print(sysconfig.get_platform())"+ if ($platform -ne "win-amd64") {+ throw "The installed Python reports $platform, expected win-amd64"+ }++ # The Model Hub engine needs no Python, so it stays native: arm64 on+ # Windows on Arm even though Avibe's Python there is x64.+ - name: Verify the Model Hub engine targets the native architecture+ shell: pwsh+ run: |+ $python = @(Get-ChildItem "$env:USERPROFILE\.avibe\runtime\install-generations\*\uv\tools\avibe-os\Scripts\python.exe")[0].FullName+ $expected = if ("${{ matrix.runner }}" -eq "windows-11-arm") { "windows-arm64" } else { "windows-amd64" }+ $platform = & $python -c "from vibe.model_hub_runtime.installer import EngineRuntimeManager; print(EngineRuntimeManager(offline=True).host_platform())"+ if ($platform -ne $expected) {+ throw "The engine would install $platform, expected $expected"+ }+# Windows PowerShell 5.1 is what `irm ... | iex` runs for most users, so# the uninstall owner runs there, in both its file and script-block forms.- name: Uninstall keeps user data and a purge needs confirmation@@ -549,6 +577,23 @@ jobs:if (-not (Test-Path -LiteralPath $foreign)) { throw "A purge removed a vibe.exe it did not install" }if (-not (Select-String -Path purge.log -Pattern "session kept" -SimpleMatch -Quiet)) { throw "The script-block form ended the session" }+ # The required check: the matrix above reports one check per runner under+ # its own name, so this job keeps the name branch protection requires.+ windows-install-smoke:+ runs-on: ubuntu-latest+ needs: windows-install-smoke-runners+ if: always()+ steps:+ - name: Verify the installer on every Windows runner+ env:+ SMOKE_RESULT: ${{ needs['windows-install-smoke-runners'].result }}+ run: |+ if [ "$SMOKE_RESULT" != "success" ]; then+ echo "Windows installer smoke finished with result: $SMOKE_RESULT"+ exit 1+ fi+ echo "The installer passed on every Windows runner."+windows-control-ipc:runs-on: windows-latestneeds: build-linux-artifactsdiff --git a/core/windows_arch.py b/core/windows_arch.pynew file mode 100644index 000000000..1f2ee19ca--- /dev/null+++ b/core/windows_arch.py@@ -0,0 +1,54 @@+"""The architecture Windows itself runs on, which emulated x64 Python does not report.++On Windows on Arm, Avibe runs on x64 Python under Windows' x64 emulation until+cryptography and claude-agent-sdk publish win_arm64 wheels. Python's own+platform tag then says x64, while a standalone native program, such as the+Model Hub engine, should still run as arm64.+"""++from __future__ import annotations++import logging+import os+from functools import lru_cache++logger = logging.getLogger(__name__)++_IMAGE_FILE_MACHINE_ARM64 = 0xAA64+# The interpreter a uv install uses on Windows on Arm; install.ps1 carries its+# own copy, since it runs before any Avibe Python exists.+WINDOWS_ARM64_UV_PYTHON = "cpython-3.12-windows-x86_64-none"+++@lru_cache(maxsize=1)+def windows_native_arm64() -> bool:+ """Whether this is Windows running natively on Arm64, whatever Python's architecture."""++ if os.name != "nt":+ return False+ import ctypes+ from ctypes import wintypes++ kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)+ try:+ is_wow64_process2 = kernel32.IsWow64Process2+ except AttributeError:+ # Older than Windows 10 1709, which is also older than x64 emulation on Arm64.+ return False+ is_wow64_process2.argtypes = [+ wintypes.HANDLE,+ ctypes.POINTER(wintypes.USHORT),+ ctypes.POINTER(wintypes.USHORT),+ ]+ is_wow64_process2.restype = wintypes.BOOL+ kernel32.GetCurrentProcess.restype = wintypes.HANDLE+ process_machine = wintypes.USHORT()+ native_machine = wintypes.USHORT()+ if not is_wow64_process2(+ kernel32.GetCurrentProcess(), ctypes.byref(process_machine), ctypes.byref(native_machine),+ ):+ # Without an answer, Python's own architecture is the only one known;+ # an x64 choice still runs here, emulated if the machine is Arm64.+ logger.warning("Cannot read the native Windows architecture: %s", ctypes.WinError(ctypes.get_last_error()))+ return False+ return native_machine.value == _IMAGE_FILE_MACHINE_ARM64diff --git a/install.ps1 b/install.ps1index 35635d46c..4ab42083d 100644--- a/install.ps1+++ b/install.ps1@@ -454,6 +454,20 @@ function Get-RuntimeHome {return Resolve-InstallPath $runtimeHome}+# Windows on Arm, whatever this PowerShell process runs as: an emulated x64+# shell can still find an arm64 uv, which would pick an arm64 Python.+function Test-WindowsOnArm {+ if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64" -or $env:PROCESSOR_ARCHITEW6432 -eq "ARM64") {+ return $true+ }+ try {+ # Win32_Processor.Architecture 12 is ARM64, reported for the hardware.+ return [bool]@(Get-CimInstance -ClassName Win32_Processor -ErrorAction Stop | Where-Object { $_.Architecture -eq 12 }).Count+ } catch {+ return $false+ }+}+function Invoke-UvToolInstallAttempt {param([string[]]$Arguments, [string]$PythonInstallMirror)@@ -490,8 +504,16 @@ function Invoke-UvToolInstallAttempt {if ($PythonInstallMirror) {$env:UV_PYTHON_INSTALL_MIRROR = $PythonInstallMirror}+ # Windows on Arm runs Avibe on x64 Python under Windows' x64 emulation:+ # cryptography and claude-agent-sdk publish no win_arm64 wheels yet, so a+ # native arm64 interpreter cannot install it. Drop this once both do.+ # vibe upgrade carries the same rule (core/windows_arch.py).+ $pythonArguments = @()+ if (Test-WindowsOnArm) {+ $pythonArguments = @("--python", "cpython-3.12-windows-x86_64-none")+ }try {- $result = Invoke-NativeCommand -FilePath "uv" -Arguments (@("tool", "install") + $Arguments)+ $result = Invoke-NativeCommand -FilePath "uv" -Arguments (@("tool", "install") + $pythonArguments + $Arguments)} finally {# Only an unset variable is ever given the mirror, so unset restores it.if ($PythonInstallMirror) { Remove-Item Env:UV_PYTHON_INSTALL_MIRROR -ErrorAction SilentlyContinue }diff --git a/tests/test_ci_pipeline.py b/tests/test_ci_pipeline.pyindex a41b1920d..0225084ca 100644--- a/tests/test_ci_pipeline.py+++ b/tests/test_ci_pipeline.py@@ -473,7 +473,7 @@ def test_ui_checks_run_once_without_fencing_artifact_consumers() -> None:assert not job.get("if")assert not job.get("continue-on-error")assert all(not step.get("if") and not step.get("continue-on-error") for step in job["steps"])- for name in ("install-upgrade-shards", "windows-install-smoke"):+ for name in ("install-upgrade-shards", "windows-install-smoke-runners"):assert jobs[name]["needs"] == "build-linux-artifacts"@@ -544,7 +544,11 @@ def test_distribution_contracts_consume_same_run_artifacts_without_fencing_otherassert "pytest tests/test_distribution_artifacts.py -v -ra" in contracts["run"]assert not contracts.get("continue-on-error")assert jobs["install-upgrade-regression"]["needs"] == "install-upgrade-shards"- assert jobs["windows-install-smoke"]["needs"] == "build-linux-artifacts"+ assert jobs["windows-install-smoke-runners"]["needs"] == "build-linux-artifacts"+ # Branch protection requires `windows-install-smoke`; the per-runner matrix+ # reports under other names, so the required name gates on all of them.+ assert jobs["windows-install-smoke"]["needs"] == "windows-install-smoke-runners"+ assert jobs["windows-install-smoke"]["if"] == "always()"@pytest.mark.parametrize(("pytest_exit", "summary"), [(0, "21 passed"), (1, "1 failed"), (0, "14 passed, 7 skipped")])diff --git a/tests/test_model_hub_runtime.py b/tests/test_model_hub_runtime.pyindex f78c7a289..b35203b2b 100644--- a/tests/test_model_hub_runtime.py+++ b/tests/test_model_hub_runtime.py@@ -879,10 +879,14 @@ def test_orphaned_oauth_cleanup_never_existed_ref_is_converged(asyncio.run(run())[email protected]("windows_on_arm", [False, True])def test_packaged_manifest_matches_frozen_runtime_dependency_values(tmp_path: Path,monkeypatch: pytest.MonkeyPatch,+ windows_on_arm: bool,) -> None:+ # The contract lists every asset, whichever host reads it.+ monkeypatch.setattr(runtime_installer_module, "windows_native_arm64", lambda: windows_on_arm)manager = EngineRuntimeManager(runtime_dir=tmp_path / "runtime", offline=True)manifest = manager.contract_manifest()@@ -932,7 +936,8 @@ def test_packaged_manifest_matches_frozen_runtime_dependency_values(],}- for host_platform, asset_platform in (("win32-x64", "windows-amd64"), ("win32-arm64", "windows-arm64")):+ x64_python_asset = "windows-arm64" if windows_on_arm else "windows-amd64"+ for host_platform, asset_platform in (("win32-x64", x64_python_asset), ("win32-arm64", "windows-arm64")):monkeypatch.setattr(managed_runtime, "runtime_platform_tag", lambda tag=host_platform: tag)assert manager.host_platform() == asset_platformassert manager.supports_host_platform() is True@@ -1423,10 +1428,11 @@ def test_installing_projection_matches_live_owner_or_resumable_claim(@pytest.mark.parametrize(- ("host_platform", "asset_platform", "size_bytes", "archive_sha256", "binary_sha256", "bin_path"),+ ("host_platform", "windows_on_arm", "asset_platform", "size_bytes", "archive_sha256", "binary_sha256", "bin_path"),[("darwin-arm64",+ False,"darwin-arm64",40511180,"bd863d04d950390b745dd4414ea8c8be715cb5c21b492d3c0d71504f64fca978",@@ -1435,6 +1441,7 @@ def test_installing_projection_matches_live_owner_or_resumable_claim(),("darwin-x64",+ False,"darwin-x64",42973748,"eda0092a9d1afecf8471fc95e4c077825a3db8059df7caa6a06816a2a8a438eb",@@ -1443,6 +1450,7 @@ def test_installing_projection_matches_live_owner_or_resumable_claim(),("linux-x64",+ False,"linux-amd64",40932246,"e72351f5280f943233c9ddc8ab9f51556f57e9f95d68bf13a15b141a95e48b65",@@ -1451,6 +1459,7 @@ def test_installing_projection_matches_live_owner_or_resumable_claim(),("linux-arm64",+ False,"linux-arm64",37548183,"ca06e508c654d6c8cfc5af44341eeac339e0a033d217a480c44043b8e8c81ebc",@@ -1459,14 +1468,26 @@ def test_installing_projection_matches_live_owner_or_resumable_claim(),("win32-x64",+ False,"windows-amd64",41444644,"7d138744b44a7ee103f15d065712f97798db0259cdafce2a93819b4135b69006","c265136d64bc6fdb7a4737e28333ff58ed995407d50b0581857e6693a2952a32","cli-proxy-api.exe",),+ # x64 Python on Windows on Arm still gets the native engine.+ (+ "win32-x64",+ True,+ "windows-arm64",+ 37803078,+ "969997f1dbe169c83e227def75ca51e105aafb9f3d30bb3bb615685fc289b525",+ "0ba1b87a3c562f5121f2902507e6608713237a3daafa229bca5b4829b29c29ec",+ "cli-proxy-api.exe",+ ),("win32-arm64",+ True,"windows-arm64",37803078,"969997f1dbe169c83e227def75ca51e105aafb9f3d30bb3bb615685fc289b525",@@ -1479,6 +1500,7 @@ def test_engine_installer_selects_verified_packaged_asset(tmp_path: Path,monkeypatch: pytest.MonkeyPatch,host_platform: str,+ windows_on_arm: bool,asset_platform: str,size_bytes: int,archive_sha256: str,@@ -1486,6 +1508,7 @@ def test_engine_installer_selects_verified_packaged_asset(bin_path: str,) -> None:monkeypatch.setattr(managed_runtime, "runtime_platform_tag", lambda: host_platform)+ monkeypatch.setattr(runtime_installer_module, "windows_native_arm64", lambda: windows_on_arm)manager = EngineRuntimeManager(runtime_dir=tmp_path / host_platform, offline=True)manifest = manager._load_manifest(allow_network=False)@@ -1500,10 +1523,11 @@ def test_engine_installer_selects_verified_packaged_asset(assert archive.bin_path == bin_path-def test_engine_platform_identity_is_normalized_locally() -> None:- assert dict(runtime_installer_module._ENGINE_SPEC.platform_aliases) == runtime_installer_module._ENGINE_PLATFORM_MAP- assert EngineRuntimeManager._normalize_engine_platform("linux-x64") == "linux-amd64"- assert EngineRuntimeManager._normalize_engine_platform("linux-amd64") == "linux-amd64"+def test_engine_platform_identity_is_normalized_locally(tmp_path: Path) -> None:+ manager = EngineRuntimeManager(runtime_dir=tmp_path / "runtime", offline=True)+ assert dict(manager.spec.platform_aliases) == manager._platform_map+ assert manager._normalize_engine_platform("linux-x64") == "linux-amd64"+ assert manager._normalize_engine_platform("linux-amd64") == "linux-amd64"def test_engine_installer_is_idempotent_and_rejects_tampered_archive(tmp_path: Path) -> None:diff --git a/tests/test_upgrade_flow.py b/tests/test_upgrade_flow.pyindex 6ec001d7b..2a82761ed 100644--- a/tests/test_upgrade_flow.py+++ b/tests/test_upgrade_flow.py@@ -137,6 +137,31 @@ def test_build_upgrade_plan_stages_uv_install_for_a_stable_launcher(monkeypatch,assert bin_dir.parent.parent == tmp_path / "home" / "runtime" / "install-generations"[email protected]("on_arm", [False, True])+def test_build_upgrade_plan_keeps_windows_on_arm_on_x64_python(monkeypatch, tmp_path, on_arm):+ """A staged uv upgrade picks its interpreter afresh; on Arm64 that must stay x64."""+ launcher = tmp_path / "bin" / "vibe"+ target = tmp_path / "old" / "vibe"+ target.parent.mkdir(parents=True)+ target.write_text("#!/bin/sh\n", encoding="utf-8")+ launcher.parent.mkdir(parents=True)+ launcher.symlink_to(target)+ monkeypatch.setattr("vibe.upgrade.config_paths.get_vibe_remote_dir", lambda: tmp_path / "home")+ monkeypatch.setattr("vibe.upgrade.os.path.exists", lambda path: True)+ monkeypatch.setattr("vibe.upgrade.os.access", lambda path, mode: True)+ monkeypatch.setattr("vibe.upgrade.windows_native_arm64", lambda: on_arm)++ plan = build_upgrade_plan(+ python_executable="/tmp/.local/share/uv/tools/avibe-os/bin/python",+ uv_path="/usr/local/bin/uv",+ vibe_path=str(launcher),+ base_env={"PATH": "/usr/bin"},+ )++ pinned = ["--python", "cpython-3.12-windows-x86_64-none"]+ assert (plan.command[4:6] == pinned) is on_arm, plan.command++def test_build_upgrade_plan_refuses_uv_install_without_activation_point(monkeypatch):monkeypatch.setattr("vibe.upgrade.os.path.exists", lambda path: True)monkeypatch.setattr("vibe.upgrade.os.access", lambda path, mode: True)diff --git a/vibe/model_hub_runtime/installer.py b/vibe/model_hub_runtime/installer.pyindex 6e5708978..672b283bc 100644--- a/vibe/model_hub_runtime/installer.py+++ b/vibe/model_hub_runtime/installer.py@@ -8,7 +8,7 @@ import subprocessimport threadingimport uuidfrom collections.abc import Mapping-from dataclasses import dataclass+from dataclasses import dataclass, replacefrom enum import Enumfrom pathlib import Pathfrom typing import Any, Callable@@ -23,21 +23,37 @@ from core.managed_runtime import (env_flag_enabled,)from core.process_isolation import isolated_subprocess_kwargs+from core.windows_arch import windows_native_arm64from storage.lock import MigrationFileLockfrom vibe.model_hub_runtime.environment import engine_subprocess_environment_ENGINE_VERSION_RE = re.compile(r"CLIProxyAPI Version:\s*([\w.-]+)")+++def _engine_platform_map(windows_on_arm: bool) -> dict[str, str]:+ """Python's platform tag -> the engine asset this host runs.++ x64 Python runs emulated on Windows on Arm (core/windows_arch.py), but the+ engine is a native program, so there it is still the arm64 build. The base+ manager reads this as its platform aliases, so every install, status and+ pointer check agrees on that choice.+ """+ return {+ "darwin-arm64": "darwin-arm64",+ "darwin-x64": "darwin-x64",+ "linux-x64": "linux-amd64",+ "linux-arm64": "linux-arm64",+ "win32-x64": "windows-arm64" if windows_on_arm else "windows-amd64",+ "win32-arm64": "windows-arm64",+ }++# A manifest override must not silently expand the engine's supported host set.-_ENGINE_PLATFORM_MAP = {- "darwin-arm64": "darwin-arm64",- "darwin-x64": "darwin-x64",- "linux-x64": "linux-amd64",- "linux-arm64": "linux-arm64",- "win32-x64": "windows-amd64",- "win32-arm64": "windows-arm64",-}-_ENGINE_ASSET_PLATFORMS = frozenset(_ENGINE_PLATFORM_MAP.values())+# Every asset any host runs, whichever host this is.+_ENGINE_ASSET_PLATFORMS = frozenset(+ {*_engine_platform_map(False).values(), *_engine_platform_map(True).values()}+)_INSTALL_STATE_SCHEMA_VERSION = 3_INSTALL_STATE_RELEASED_SCHEMA_VERSIONS = frozenset({1, 2})_INSTALL_STATE_SUPPORTED_SCHEMA_VERSIONS = frozenset(@@ -78,7 +94,8 @@ _ENGINE_SPEC = ManagedRuntimeSpec(default_bin_path="cli-proxy-api",archives_field="assets",archive_size_field="size_bytes",- platform_aliases=tuple(_ENGINE_PLATFORM_MAP.items()),+ # Set per manager from the host it runs on; see _engine_platform_map.+ platform_aliases=(),)@@ -117,8 +134,9 @@ class EngineRuntimeManager(ManagedRuntimeManager):manifest_url: str | None = None,offline: bool | None = None,) -> None:+ self._platform_map = _engine_platform_map(windows_native_arm64())super().__init__(- spec=_ENGINE_SPEC,+ spec=replace(_ENGINE_SPEC, platform_aliases=tuple(self._platform_map.items())),runtime_dir=runtime_dir or paths.get_runtime_dir() / "model-hub" / "engine",manifest_path=manifest_path or os.environ.get("VIBE_MODEL_HUB_ENGINE_MANIFEST_PATH"),manifest_url=(@@ -237,9 +255,8 @@ class EngineRuntimeManager(ManagedRuntimeManager):resolution, _archive = self._resolve_manifest_state(manifest)return resolution is not ManifestResolution.UNSUPPORTED- @staticmethod- def _normalize_engine_platform(platform_tag: str) -> str:- return _ENGINE_PLATFORM_MAP.get(platform_tag, platform_tag)+ def _normalize_engine_platform(self, platform_tag: str) -> str:+ return self._platform_map.get(platform_tag, platform_tag)def install_failure_reasons(self) -> frozenset[str]:"""Return every admission failure emitted by the shared installer."""@@ -603,7 +620,7 @@ class EngineRuntimeManager(ManagedRuntimeManager):and re.fullmatch(r"[0-9a-f]{40}", str(payload.get("source_sha") or ""))):return ManifestResolution.UNRESOLVED, None- asset_platform = _ENGINE_PLATFORM_MAP.get(managed_runtime.runtime_platform_tag())+ asset_platform = self._platform_map.get(managed_runtime.runtime_platform_tag())archive = manifest.archives.get(asset_platform) if asset_platform is not None else Noneif archive is None:return ManifestResolution.UNSUPPORTED, Nonediff --git a/vibe/upgrade.py b/vibe/upgrade.pyindex 4decd5d5a..3d614953b 100644--- a/vibe/upgrade.py+++ b/vibe/upgrade.py@@ -33,6 +33,7 @@ from core.install_integrity import (run_isolated_probe,verify_python_environment,)+from core.windows_arch import WINDOWS_ARM64_UV_PYTHON, windows_native_arm64from storage.lock import MigrationFileLockfrom vibe import runtime as runtime_mod@@ -1642,6 +1643,10 @@ def build_upgrade_plan(env["UV_TOOL_DIR"] = str(tool_dir)env["UV_TOOL_BIN_DIR"] = str(bin_dir)command = [uv_binary, "tool", "install", package_spec]+ if windows_native_arm64():+ # The staged environment is new, so uv would pick a native arm64+ # interpreter again; keep the x64 one install.ps1 chose.+ command += ["--python", WINDOWS_ARM64_UV_PYTHON]if not version:command.append("--upgrade")if version or package_spec != PACKAGE_NAME or is_legacy_uv_tool_install(executable):