Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(a2ui): 增加桌面安装包冻结资源校验

jack_rickyff17738e24bd
diff --git a/scripts/build-exe.bat b/scripts/build-exe.bat
index 0fe5acf540..0bfb4d2d71 100644
--- a/scripts/build-exe.bat
+++ b/scripts/build-exe.bat
@@ -32,6 +32,11 @@ echo [3/3] Running PyInstaller...
call uv run pyinstaller scripts\jiuwenswarm.spec --noconfirm
if errorlevel 1 exit /b 1
+echo.
+echo Verifying frozen A2UI v0.8 bundle...
+start "" /wait "%cd%\dist\jiuwenswarm\jiuwenswarm.exe" "%cd%\scripts\verify_a2ui_bundle.py"
+if errorlevel 1 exit /b 1
+
echo.
echo === Build complete ===
echo Desktop dir: %cd%\dist\jiuwenswarm
diff --git a/scripts/build-exe.ps1 b/scripts/build-exe.ps1
index 9eab65bcee..ef03e7a5da 100644
--- a/scripts/build-exe.ps1
+++ b/scripts/build-exe.ps1
@@ -203,6 +203,19 @@ Write-Host "`n[3/4] Running PyInstaller..." -ForegroundColor Yellow
uv run pyinstaller scripts\jiuwenswarm.spec --noconfirm
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
+# Verify the actual frozen runtime, not only the PyInstaller source configuration.
+$FrozenExe = Join-Path $ProjectRoot "dist\jiuwenswarm\jiuwenswarm.exe"
+$A2UIVerifier = Join-Path $ProjectRoot "scripts\verify_a2ui_bundle.py"
+$VerifyProcess = Start-Process `
+ -FilePath $FrozenExe `
+ -ArgumentList @($A2UIVerifier) `
+ -Wait `
+ -PassThru `
+ -NoNewWindow
+if ($VerifyProcess.ExitCode -ne 0) {
+ throw "Frozen A2UI bundle verification failed. See ~/.jiuwenswarm/logs/jiuwenswarm_exe_error.log"
+}
+
# 3.5 Bundle Node.js runtime for browser tools
if (Test-Truthy $BundleNode) {
Write-Host "`n[3.5/4] Bundling Node.js runtime..." -ForegroundColor Yellow
@@ -247,4 +260,4 @@ $InstallerPath = (Get-ChildItem "$ProjectRoot\dist\JiuwenSwarm-setup-*.exe" | Se
Write-Host "`n=== Build complete ===" -ForegroundColor Green
Write-Host "Installer: $InstallerPath" -ForegroundColor Green
-Write-Host "Size: $([math]::Round((Get-Item $InstallerPath).Length / 1MB, 1)) MB" -ForegroundColor Green
\ No newline at end of file
+Write-Host "Size: $([math]::Round((Get-Item $InstallerPath).Length / 1MB, 1)) MB" -ForegroundColor Green
diff --git a/scripts/build-macos.sh b/scripts/build-macos.sh
index a648d5364f..18198b6643 100644
--- a/scripts/build-macos.sh
+++ b/scripts/build-macos.sh
@@ -210,6 +210,9 @@ if [[ ! -d "$APP_PATH" ]]; then
exit 1
fi
+printf 'Verifying frozen A2UI v0.8 bundle...\n'
+"$APP_PATH/Contents/MacOS/jiuwenswarm" "$PROJECT_ROOT/scripts/verify_a2ui_bundle.py"
+
if [[ -n "$TUI_BINARY" && -f "$TUI_BINARY" ]]; then
printf 'Copying TUI binary into app bundle...\n'
cp "$TUI_BINARY" "$APP_PATH/Contents/MacOS/jiuwenswarm-tui"
diff --git a/scripts/verify_a2ui_bundle.py b/scripts/verify_a2ui_bundle.py
new file mode 100644
index 0000000000..c80fccbaba
--- /dev/null
+++ b/scripts/verify_a2ui_bundle.py
@@ -0,0 +1,47 @@
+# Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.
+"""Verify that a frozen JiuwenSwarm build can initialize A2UI v0.8."""
+
+from __future__ import annotations
+
+import logging
+import sys
+from importlib.resources import files
+
+from jiuwenswarm.server.runtime.a2ui.protocol import get_protocol_spec
+
+
+LOGGER = logging.getLogger(__name__)
+EXPECTED_PROTOCOL_VERSION = "0.8"
+REQUIRED_ASSET_FILENAMES = (
+ "server_to_client.json",
+ "standard_catalog_definition.json",
+)
+
+
+def verify_a2ui_bundle() -> None:
+ """Raise when the current frozen bundle cannot initialize A2UI v0.8."""
+ if not getattr(sys, "frozen", False):
+ raise RuntimeError("A2UI bundle verification must run inside the frozen executable")
+
+ asset_root = files("a2ui").joinpath("assets").joinpath(EXPECTED_PROTOCOL_VERSION)
+ missing_assets = []
+ for filename in REQUIRED_ASSET_FILENAMES:
+ asset = asset_root.joinpath(filename)
+ if not asset.is_file():
+ missing_assets.append(str(asset))
+ if missing_assets:
+ missing_text = ", ".join(missing_assets)
+ raise RuntimeError(f"Frozen A2UI assets are missing: {missing_text}")
+
+ spec = get_protocol_spec()
+ if spec.version != EXPECTED_PROTOCOL_VERSION:
+ raise RuntimeError(
+ f"Unexpected frozen A2UI protocol: {spec.version}; "
+ f"expected {EXPECTED_PROTOCOL_VERSION}"
+ )
+
+
+if __name__ == "__main__":
+ logging.basicConfig(level=logging.INFO, format="%(message)s")
+ verify_a2ui_bundle()
+ LOGGER.info("A2UI frozen bundle verification passed (protocol 0.8)")
diff --git a/tests/unit_tests/a2ui/test_module_boundaries.py b/tests/unit_tests/a2ui/test_module_boundaries.py
index fef6f65e5d..72f905cd0e 100644
--- a/tests/unit_tests/a2ui/test_module_boundaries.py
+++ b/tests/unit_tests/a2ui/test_module_boundaries.py
@@ -1,6 +1,8 @@
# Copyright (c) Huawei Technologies Co., Ltd. 2026. All rights reserved.
import json
+import runpy
+import sys
import tomllib
from pathlib import Path
@@ -58,3 +60,22 @@ def test_pyinstaller_bundle_includes_only_a2ui_v08_schema_assets():
assert 'includes=["assets/0.8/*.json"]' in spec
assert 'collect_data_files("a2ui", include_py_files=False)' not in spec
+
+
+def test_a2ui_bundle_verifier_accepts_v08_source_assets(monkeypatch):
+ verifier = runpy.run_path(str(ROOT / "scripts/verify_a2ui_bundle.py"))
+ monkeypatch.setattr(sys, "frozen", True, raising=False)
+
+ verifier["verify_a2ui_bundle"]()
+
+
+def test_all_desktop_builds_run_frozen_a2ui_verifier():
+ build_scripts = (
+ ROOT / "scripts/build-exe.ps1",
+ ROOT / "scripts/build-exe.bat",
+ ROOT / "scripts/build-macos.sh",
+ )
+
+ for build_script in build_scripts:
+ source = build_script.read_text(encoding="utf-8")
+ assert "verify_a2ui_bundle.py" in source