The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat: bundle pinned Windows native modules with desktop installer
Steven Enamakel4730d97039f5
diff --git a/.github/workflows/build-desktop.yml b/.github/workflows/build-desktop.ymlindex 59a03126ee..d5acd93d0d 100644--- a/.github/workflows/build-desktop.yml+++ b/.github/workflows/build-desktop.yml@@ -371,6 +371,11 @@ jobs:"${{ steps.core-paths.outputs.sidecar_base }}"# ---- Tauri build -------------------------------------------------------+ - name: Bundle pinned Windows native modules+ if: matrix.settings.platform == 'windows-latest'+ shell: bash+ run: node scripts/release/stage-windows-modules.mjs+# Vite is invoked via tauri.conf.json's beforeBuildCommand inside# `cargo tauri build`, so all VITE_* env must be present here for the# bundle to bake them in. macOS signing is intentionally skipped herediff --git a/crates/openhuman-app/.gitignore b/crates/openhuman-app/.gitignoreindex 2949449ef6..9497d648d7 100644--- a/crates/openhuman-app/.gitignore+++ b/crates/openhuman-app/.gitignore@@ -2,6 +2,8 @@# will have compiled files and executables/target//binaries/+/bundled-modules/*+!/bundled-modules/.gitkeep# Generated by Tauri# will have schema files for capabilities auto-completiondiff --git a/crates/openhuman-app/bundled-modules/.gitkeep b/crates/openhuman-app/bundled-modules/.gitkeepnew file mode 100644index 0000000000..8b13789179--- /dev/null+++ b/crates/openhuman-app/bundled-modules/.gitkeep@@ -0,0 +1 @@+diff --git a/crates/openhuman-app/src/lib.rs b/crates/openhuman-app/src/lib.rsindex 0bc42dc71d..7f8efe462d 100644--- a/crates/openhuman-app/src/lib.rs+++ b/crates/openhuman-app/src/lib.rs@@ -3043,6 +3043,23 @@ pub fn run() {let builder = builder.manage(std::sync::Arc::new(imessage_scanner::ScannerRegistry::new()));builder.setup(move |app| {+ #[cfg(windows)]+ {+ if let Ok(resource_dir) = app.path().resource_dir() {+ let bundled = resource_dir.join("bundled-modules");+ if bundled.is_dir() {+ if openhuman_core::modules::ops::set_bundled_releases_dir(bundled)+ .is_err()+ {+ log::warn!("[modules] bundled release directory was already set");+ }+ } else {+ log::warn!("[modules] installer has no bundled release directory");+ }+ } else {+ log::warn!("[modules] installer resource directory is unavailable");+ }+ }#[cfg(windows)]{// `register_all` writes HKCU\Software\Classes\openhuman so thediff --git a/crates/openhuman-app/tauri.conf.json b/crates/openhuman-app/tauri.conf.jsonindex 2030f35fd0..c4af82dadf 100644--- a/crates/openhuman-app/tauri.conf.json+++ b/crates/openhuman-app/tauri.conf.json@@ -52,7 +52,8 @@"icons/icon.ico"],"resources": [- "../../crates/openhuman-core/src/agent/prompts"+ "../../crates/openhuman-core/src/agent/prompts",+ "bundled-modules"],"linux": {"deb": {diff --git a/crates/openhuman-core/src/modules/README.md b/crates/openhuman-core/src/modules/README.mdindex c841f340f4..2f1b3780bb 100644--- a/crates/openhuman-core/src/modules/README.md+++ b/crates/openhuman-core/src/modules/README.md@@ -68,6 +68,12 @@ layer.it against the digest pinned in `registry.rs`, hashes the archive, extracts,and `dlopen`s — on the module runtime's blocking pool so a cold downloadnever stalls another task.+ On Windows desktop installs, the installer contains the registry-pinned+ `windows-2022-x86_64` archives and their extracted DLLs under+ `bundled-modules/`. The host registers that read-only directory before+ starting the core. The same archive digest and TinyBus admission checks run+ against these local files first, so normal use needs no runtime download.+ Headless and development hosts continue to use the release cache.6. tinybus's ABI descriptor, manifest, and dependency gates decide whether theartifact is *admitted*; a faulted or refused module is recorded as`Resolution::Failed` in the resolution table (surfaced asdiff --git a/crates/openhuman-core/src/modules/ops.rs b/crates/openhuman-core/src/modules/ops.rsindex ec23335913..2f7f8dac89 100644--- a/crates/openhuman-core/src/modules/ops.rs+++ b/crates/openhuman-core/src/modules/ops.rs@@ -32,6 +32,7 @@//! as still loading instead of hanging into that deadline.use std::path::{Path, PathBuf};+use std::sync::OnceLock;use std::time::Duration;use super::resolution::{self, Claim, Resolution, ResolutionState, ResolutionTable, Waited};@@ -39,6 +40,16 @@ use super::types::{ModuleRecord, ModuleState, ModuleStatus};use super::{host, platform, registry};use crate::config::Config;+/// Installer-owned, read-only release cache. The desktop host sets this before+/// starting the embedded core; other hosts continue using the user cache.+static BUNDLED_RELEASES: OnceLock<PathBuf> = OnceLock::new();++/// Register the directory of release archives shipped with the desktop app.+/// Its contents still pass the compiled digest and TinyBus admission gates.+pub fn set_bundled_releases_dir(path: PathBuf) -> Result<(), PathBuf> {+ BUNDLED_RELEASES.set(path)+}+/// Why a bounded [`ensure_loaded_within`] did not end with the module serving.#[derive(Debug, Clone, PartialEq, Eq)]pub enum LoadError {@@ -297,6 +308,49 @@ fn load_cached(}let mut last_error = String::new();+ let mut found_bundled = false;+ if let Some(bundled_root) = BUNDLED_RELEASES.get() {+ for asset in &assets {+ let Some(cache_dir) = artifact_dir(bundled_root, record, asset.host_key) else {+ continue;+ };+ if !cache_dir.join(asset.archive).is_file() {+ continue;+ }+ found_bundled = true;+ let release = tinybus::module::CachedRelease {+ release_url: record.release_url,+ asset_name: asset.archive,+ expected_sha256: Some(asset.sha256),+ cache_dir: &cache_dir,+ allow_download: false,+ };+ match runtime+ .host()+ .load_github_release_cached(&release, module_config.clone())+ {+ Ok(_) => {+ log::info!("[modules] loaded '{}' from the installer bundle", record.id);+ return Ok(());+ }+ Err(err) => {+ last_error = err.to_string();+ log::warn!(+ "[modules] bundled '{}' artifact for {} was not admitted: {last_error}",+ record.id,+ asset.host_key+ );+ }+ }+ }+ }+ if found_bundled {+ return Err(format!(+ "module '{}' could not be loaded from the installer bundle: {last_error}. \+ Restart the app after repairing the installation",+ record.id+ ));+ }for asset in assets {let Some(cache_dir) = artifact_dir(install_root, record, asset.host_key) else {last_error =diff --git a/scripts/__tests__/stage-windows-modules.test.mjs b/scripts/__tests__/stage-windows-modules.test.mjsnew file mode 100644index 0000000000..93ec166512--- /dev/null+++ b/scripts/__tests__/stage-windows-modules.test.mjs@@ -0,0 +1,27 @@+import assert from "node:assert/strict";+import { test } from "node:test";++import { readRegistrySource } from "../ci/self-hosted/test-module-assets.mjs";+import { parseAllList } from "../lib/module-pins.mjs";+import { bundledAssets } from "../release/stage-windows-modules.mjs";++test("every compiled module has one pinned Windows installer asset", () => {+ const source = readRegistrySource();+ const assets = bundledAssets(source);+ assert.equal(assets.length, parseAllList(source).length);+ assert.equal(new Set(assets.map((asset) => asset.id)).size, assets.length);+ for (const asset of assets) {+ assert.equal(asset.hostKey, "windows-2022-x86_64");+ assert.match(asset.url, /^https:\/\/github\.com\/tinyhumansai\//);+ assert.match(asset.archive, /-windows-2022-x86_64\.zip$/);+ assert.match(asset.sha256, /^[a-f0-9]{64}$/);+ }+});++test("a missing Windows pin fails staging before any download", () => {+ const source = readRegistrySource().replace(+ 'host_key: "windows-2022-x86_64"',+ 'host_key: "removed-windows-asset"',+ );+ assert.throws(() => bundledAssets(source), /has no windows-2022-x86_64 asset/);+});diff --git a/scripts/release/stage-windows-modules.mjs b/scripts/release/stage-windows-modules.mjsnew file mode 100644index 0000000000..99aa6859d2--- /dev/null+++ b/scripts/release/stage-windows-modules.mjs@@ -0,0 +1,81 @@+#!/usr/bin/env node+// Stage the registry-pinned Windows modules as Tauri resources. Downloading is+// a build-time operation; a shipped installer needs no GitHub access to load.+import { createHash } from "node:crypto";+import { execFileSync } from "node:child_process";+import { mkdirSync, readFileSync, readdirSync, rmSync } from "node:fs";+import { dirname, join, resolve } from "node:path";+import { fileURLToPath } from "node:url";++import { parseAllList, parseRecords } from "../lib/module-pins.mjs";+import {+ parseReleaseUrls,+ readRegistrySource,+ resolveTestModuleAssets,+} from "../ci/self-hosted/test-module-assets.mjs";++const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");+const HOST_KEY = "windows-2022-x86_64";+const OUTPUT = join(ROOT, "crates/openhuman-app/bundled-modules");++export function bundledAssets(source) {+ const names = parseAllList(source);+ const records = parseRecords(source);+ const urls = parseReleaseUrls(source);+ const ids = names.map((name) => {+ const record = records.get(name);+ if (!record) throw new Error(`missing module record ${name}`);+ if (!urls.has(record.id)) throw new Error(`missing release URL for ${record.id}`);+ return record.id;+ });+ const assets = resolveTestModuleAssets(source, HOST_KEY, ids);+ return assets.map((asset) => {+ const record = [...records.values()].find((r) => r.id === asset.id);+ for (const component of [record.id, record.version, HOST_KEY, asset.archive]) {+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(component) || component === "..") {+ throw new Error(`unsafe registry path component for ${record.id}`);+ }+ }+ return { ...asset, version: record.version, hostKey: HOST_KEY };+ });+}++function dllsUnder(dir) {+ return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {+ const path = join(dir, entry.name);+ if (entry.isDirectory()) return dllsUnder(path);+ return entry.isFile() && entry.name.toLowerCase().endsWith(".dll")+ ? [path]+ : [];+ });+}++export function stageWindowsModules(output = OUTPUT) {+ if (process.platform !== "win32") {+ throw new Error("stage-windows-modules must run on a Windows build runner");+ }+ const assets = bundledAssets(readRegistrySource());+ rmSync(output, { recursive: true, force: true });+ for (const asset of assets) {+ const dir = join(output, asset.id, asset.version, asset.hostKey);+ mkdirSync(dir, { recursive: true });+ const archive = join(dir, asset.archive);+ execFileSync("curl.exe", ["--fail", "--location", "--retry", "3", "--output", archive, asset.url], {+ stdio: "inherit",+ });+ const actual = createHash("sha256").update(readFileSync(archive)).digest("hex");+ if (actual !== asset.sha256.toLowerCase()) {+ throw new Error(`${asset.id}: downloaded archive does not match the compiled registry pin`);+ }+ execFileSync("tar.exe", ["-xf", archive, "-C", dir], { stdio: "inherit" });+ if (dllsUnder(dir).length !== 1) {+ throw new Error(`${asset.id}: expected exactly one DLL in the release archive`);+ }+ console.log(`[bundled-modules] staged ${asset.id} ${asset.version} (${asset.hostKey})`);+ }+ console.log(`[bundled-modules] staged ${assets.length} verified releases`);+}++if (process.argv[1] === fileURLToPath(import.meta.url)) {+ stageWindowsModules();+}