Skip to content

The agent that grows with you

fix appinstaller update

ethernet60a84773f510
diff --git a/apps/desktop/scripts/check-appinstaller-update.py b/apps/desktop/scripts/check-appinstaller-update.py
index b37e87c626b..dd98ba7ef07 100644
--- a/apps/desktop/scripts/check-appinstaller-update.py
+++ b/apps/desktop/scripts/check-appinstaller-update.py
@@ -11,9 +11,9 @@ Run with the BUNDLED payload python (the winrt package ships there):
<payload>/tools/<python-entry>/python.exe scripts/check-appinstaller-update.py
Exit codes:
- 0 no update available (or no App Installer source — nothing to do)
+ 0 no update available, or this process has no package identity
2 update available (the caller decides whether to prompt/teardown)
- 1 error (update availability unknown; the caller reports it honestly)
+ 1 error, including a missing registered App Installer update source
API shape (pywinrt projection, verified against the installed winrt 3.2.1):
``Package.current`` is a static PROPERTY; the update check is the instance
@@ -63,7 +63,14 @@ def main() -> int:
try:
source = package.get_app_installer_info()
- source_uri = source.uri.absolute_uri if source is not None else None
+ if source is None:
+ print(json.dumps({
+ "available": None,
+ "reason": "no-app-installer-source",
+ "error": "No App Installer update source is registered. Install Hermes through its .appinstaller file to enable updates.",
+ }))
+ return 1
+ source_uri = source.uri.absolute_uri
result = package.check_update_availability_async().get()
availability = PackageUpdateAvailability(result.availability)
except Exception as exc: # noqa: BLE001
diff --git a/pyproject.toml b/pyproject.toml
index b8c802088de..72b66496df8 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -149,16 +149,10 @@ dependencies = [
# imports win32security/win32file/etc. directly — declare pywin32 rather than
# relying on the concurrent-log-handler → portalocker transitive chain.
"pywin32>=306,<312; sys_platform == 'win32'",
- # App Installer update checks (apps/desktop/scripts/check-appinstaller-update.py)
- # use the WinRT Management.Deployment API to ask the OS whether a newer
- # MSIX package version is registered for the installed package. The payload
- # python runs it on Windows only — gate the dep so POSIX/macOS don't carry
- # the Windows-only winrt runtime. The script imports BOTH the applicationmodel
- # (Package/PackageUpdateAvailability) and management.deployment (PackageManager)
- # namespaces — these are separate winrt-windows-* distributions; the `[all]`
- # extra on a single member does not exist (uv warns + desyncs the lock).
+ # App Installer checks use Package from ApplicationModel. Foundation
+ # supplies the URI and async result types projected when the checker runs.
"winrt-windows-applicationmodel>=3.2.1,<4; sys_platform == 'win32'",
- "winrt-windows-management-deployment>=3.2.1,<4; sys_platform == 'win32'",
+ "winrt-windows-foundation>=3.2.1,<4; sys_platform == 'win32'",
# Image resize recovery for the vision tools. Pillow shrinks oversized images
# (>5 MB or >8000px) at embed time; without it the byte AND pixel-dimension
# shrink paths no-op, so an oversized image bakes into immutable history and
diff --git a/tests/desktop/test_appinstaller_check_script.py b/tests/desktop/test_appinstaller_check_script.py
index e155708132b..3b465cbaaf8 100644
--- a/tests/desktop/test_appinstaller_check_script.py
+++ b/tests/desktop/test_appinstaller_check_script.py
@@ -1,6 +1,7 @@
-"""Tests: apps/desktop/scripts/check-appinstaller-update.py speaks the REAL
-pywinrt projection (subprocess-level, stub winrt on PYTHONPATH — no packaged
-process, no network, no OS update call).
+"""App Installer checker output contracts and native WinRT dependency coverage.
+
+Stubbed subprocess checks cover OS outcomes without a packaged process.
+The native Windows test checks the URI and async projection types.
Root causes pinned here (audit C08):
- ``Package.current`` is a PROPERTY, not a callable.
@@ -19,6 +20,8 @@ import subprocess
import sys
from pathlib import Path
+import pytest
+
HERMES_PYTHON = sys.executable
SCRIPT = (
@@ -122,6 +125,25 @@ def _run(root: Path) -> tuple[int, dict]:
return proc.returncode, json.loads(proc.stdout.strip().splitlines()[-1])
+def test_installed_winrt_projects_checker_uri_and_async_types(tmp_path):
+ # A dev process has no package identity, so exercise the types that the
+ # packaged update call projects only after Package.current succeeds.
+ probe = subprocess.run(
+ [HERMES_PYTHON, "-I", "-c",
+ "import runpy; "
+ "from winrt.windows.foundation import IAsyncOperation, Uri; "
+ "uri = Uri('https://example.invalid/updates.appinstaller'); "
+ "assert uri.absolute_uri == 'https://example.invalid/updates.appinstaller'; "
+ "assert callable(IAsyncOperation.get); "
+ f"runpy.run_path({str(SCRIPT)!r})['_load_projection'](); "
+ "print('WINRT_CHECKER_TYPES_OK')"],
+ cwd=tmp_path, capture_output=True, text=True, timeout=30,
+ )
+ assert probe.returncode == 0, probe.stderr
+ assert probe.stdout.strip() == "WINRT_CHECKER_TYPES_OK"
+
+
def test_not_packaged_is_reported_as_not_packaged(tmp_path):
root = _stub_winrt(tmp_path, _stub_module(identity_error=True, availability=None, check_raises=False))
code, payload = _run(root)
@@ -163,6 +185,19 @@ def test_error_availability_is_not_no_update(tmp_path):
assert "error" in payload
+def test_missing_appinstaller_source_explains_the_remedy(tmp_path):
+ module = _stub_module(identity_error=False, availability="unknown", check_raises=False).replace(
+ "return SimpleNamespace(uri=SimpleNamespace(absolute_uri='https://registered.example/updates.appinstaller'))",
+ "return None",
+ )
+ root = _stub_winrt(tmp_path, module)
+ code, payload = _run(root)
+ assert code == 1
+ assert payload["available"] is None
+ assert payload["reason"] == "no-app-installer-source"
+ assert ".appinstaller" in payload["error"]
+
+
def test_check_failure_is_unknown_not_no_update(tmp_path):
root = _stub_winrt(tmp_path, _stub_module(identity_error=False, availability=None, check_raises=True))
code, payload = _run(root)
diff --git a/uv.lock b/uv.lock
index 7260445cbff..01c03415149 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1596,7 +1596,7 @@ dependencies = [
{ name = "uvicorn", extra = ["standard"] },
{ name = "websockets" },
{ name = "winrt-windows-applicationmodel", marker = "sys_platform == 'win32'" },
- { name = "winrt-windows-management-deployment", marker = "sys_platform == 'win32'" },
+ { name = "winrt-windows-foundation", marker = "sys_platform == 'win32'" },
]
[package.optional-dependencies]
@@ -1990,7 +1990,7 @@ requires-dist = [
{ name = "vercel", marker = "extra == 'vercel'", specifier = "==0.7.2" },
{ name = "websockets", specifier = "==15.0.1" },
{ name = "winrt-windows-applicationmodel", marker = "sys_platform == 'win32'", specifier = ">=3.2.1,<4" },
- { name = "winrt-windows-management-deployment", marker = "sys_platform == 'win32'", specifier = ">=3.2.1,<4" },
+ { name = "winrt-windows-foundation", marker = "sys_platform == 'win32'", specifier = ">=3.2.1,<4" },
{ name = "youtube-transcript-api", marker = "extra == 'youtube'", specifier = "==1.2.4" },
]
provides-extras = ["anthropic", "exa", "firecrawl", "parallel-web", "fal", "edge-tts", "modal", "daytona", "vercel", "hindsight", "dev", "messaging", "cron", "slack", "matrix", "wecom", "tts-premium", "voice", "wake", "honcho", "telegram", "discord", "stt-whisper", "audio-io", "silk", "wake-openwakeword", "wake-sherpa", "wake-porcupine", "google-chat", "doc-extract", "trace-upload", "supermemory", "mem0", "vision", "pty", "mcp", "nemo-relay", "homeassistant", "sms", "teams", "computer-use", "acp", "mistral", "otlp", "bedrock", "vertex", "azure-identity", "termux", "termux-all", "dingtalk", "feishu", "google", "youtube", "web", "all"]
@@ -4449,17 +4449,17 @@ wheels = [
]
[[package]]
-name = "winrt-windows-management-deployment"
+name = "winrt-windows-foundation"
version = "3.2.1"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "winrt-runtime" },
]
-sdist = { url = "https://files.pythonhosted.org/packages/4f/74/6000c3e31c80185e18ab590a7f979f61c5c71aaaf61c67f2c37386d25c53/winrt_windows_management_deployment-3.2.1.tar.gz", hash = "sha256:9e2b9e08c55e321a0c31bbce6047f1038b0e1c1ce36204f5fb725778c33f5b81", size = 29650, upload-time = "2025-06-06T14:42:18.882Z" }
+sdist = { url = "https://files.pythonhosted.org/packages/0c/55/098ce7ea0679efcc1298b269c48768f010b6c68f90c588f654ec874c8a74/winrt_windows_foundation-3.2.1.tar.gz", hash = "sha256:ad2f1fcaa6c34672df45527d7c533731fdf65b67c4638c2b4aca949f6eec0656", size = 30485, upload-time = "2025-06-06T14:41:53.344Z" }
wheels = [
- { url = "https://files.pythonhosted.org/packages/a8/33/94a1e5fed09550e1d200e28922c2666501acf4ce715f6ce7d08632375976/winrt_windows_management_deployment-3.2.1-cp314-cp314-win32.whl", hash = "sha256:1b8d50598b0c3fd5580b4bcb9383007a248fc49f6c8863ed2093b0db577574cb", size = 155730, upload-time = "2025-09-20T07:13:26.681Z" },
- { url = "https://files.pythonhosted.org/packages/d7/34/9a2205298282e4635bf2f065fa39b98fec48ce67c297de8c9b81822d57d1/winrt_windows_management_deployment-3.2.1-cp314-cp314-win_amd64.whl", hash = "sha256:fbf20fa4becf20edb9980bfb9e4f45dfd323d57e4819c49c40a65fde82a1bb24", size = 176999, upload-time = "2025-09-20T07:13:27.613Z" },
- { url = "https://files.pythonhosted.org/packages/6b/c4/5bc3d686a3bf831e2ce7dbccf2cd329a46aa7755b37c1a0f71d1b7107be3/winrt_windows_management_deployment-3.2.1-cp314-cp314-win_arm64.whl", hash = "sha256:ba9477e3b5024e74d60432b488f625628c7c35c2409d10cd9324a5770a4e8a18", size = 166450, upload-time = "2025-09-20T07:13:28.585Z" },
+ { url = "https://files.pythonhosted.org/packages/e3/0a/d77346e39fe0c81f718cde49f83fe77c368c0e14c6418f72dfa1e7ef22d0/winrt_windows_foundation-3.2.1-cp314-cp314-win32.whl", hash = "sha256:35e973ab3c77c2a943e139302256c040e017fd6ff1a75911c102964603bba1da", size = 114590, upload-time = "2025-09-20T07:11:49.97Z" },
+ { url = "https://files.pythonhosted.org/packages/a1/56/4d2b545bea0f34f68df6d4d4ca22950ff8a935497811dccdc0ca58737a05/winrt_windows_foundation-3.2.1-cp314-cp314-win_amd64.whl", hash = "sha256:a22a7ebcec0d262e60119cff728f32962a02df60471ded8b2735a655eccc0ef5", size = 122148, upload-time = "2025-09-20T07:11:50.826Z" },
+ { url = "https://files.pythonhosted.org/packages/ed/ed/b9d3a11cac73444c0a3703200161cd7267dab5ab85fd00e1f965526e74a8/winrt_windows_foundation-3.2.1-cp314-cp314-win_arm64.whl", hash = "sha256:3be7fbae829b98a6a946db4fbaf356b11db1fbcbb5d4f37e7a73ac6b25de8b87", size = 114360, upload-time = "2025-09-20T07:11:51.626Z" },
]
[[package]]