YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(app): stage macOS sidecars at build time (#5036)
Divanshua7ecd127d75c
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.ymlindex 92e57476a..88801fe0b 100644--- a/.github/workflows/release-app.yml+++ b/.github/workflows/release-app.yml@@ -1069,11 +1069,8 @@ jobs:# build-keychain dance (the `errSecInternalComponent` class — see# the keychain setup above) only surfaces as a notarization failure# much later in the workflow.- #- # The aarch64 re-sign path at "Inject mlx.metallib..." below already- # runs --verify after its own re-sign; this step also covers x86_64- # (which has no re-sign path) and protects against a regression in- # the initial Tauri-side sign too.+ # Covers the single Tauri codesign pass (mlx.metallib / libonnxruntime.dylib+ # are staged into Contents/MacOS/ at build time via bundle.macOS.files).if: matrix.os_type == 'macos'shell: bashrun: |@@ -1093,245 +1090,6 @@ jobs:doneecho "all .app bundles pass codesign --verify --deep --strict"- - name: Inject mlx.metallib into Contents/MacOS/ + re-sign (macOS)- # MLX's runtime library search looks for mlx.metallib next to the- # binary (Contents/MacOS/), not in the app's Resources dir. Tauri's- # `bundle.resources` always lands in Contents/Resources/, so we have- # to physically copy the file into Contents/MacOS/ ourselves.- #- # This must happen BEFORE notarization. Adding files inside an already- # signed bundle invalidates the cdhash — that was the v2.4.133–149- # "screenpipe is damaged" bug, which surfaced as repeated Gatekeeper- # popups + the embedded server (port 3030) being killed mid-launch.- # The runtime symlink approach we used to do is gone (see main.rs).- # Now: copy + re-sign + rebuild DMG so the very first signature- # already covers Contents/MacOS/mlx.metallib.- #- # Only runs for the macOS aarch64 build, which is the only target- # that enables parakeet-mlx. Other macOS targets (x86_64) ship the- # metallib via bundle.resources too (because build.rs downloads it- # whenever the build host is aarch64), but parakeet-mlx isn't- # compiled in for x86_64 so MLX never tries to load it — and the- # disk-mount + DMG-rebuild step blew through CI runner disk space- # on x86_64 in v2.4.154 ("fcopyfile failed: No space left on- # device") for no benefit. Narrow to where it actually matters.- if: matrix.target == 'aarch64-apple-darwin'- shell: bash- env:- APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}- run: |- set -euo pipefail- TARGET="${{ matrix.target }}"- BUNDLE_DIR="apps/screenpipe-app-tauri/src-tauri/target/${TARGET}/release/bundle"- APP_DIR="${BUNDLE_DIR}/macos"-- # Find the .app bundle Tauri produced- shopt -s nullglob- apps=( "${APP_DIR}"/*.app )- if [ ${#apps[@]} -eq 0 ]; then- echo "no .app to patch — skipping mlx.metallib inject"- exit 0- fi- APP="${apps[0]}"- RES_LIB="${APP}/Contents/Resources/mlx.metallib"-- if [ ! -f "$RES_LIB" ]; then- echo "no Contents/Resources/mlx.metallib — non-mlx build, skipping"- exit 0- fi-- # Empty/placeholder metallib (created by build.rs on non-aarch64 macOS,- # or when the GitHub release download failed) — don't bother injecting,- # MLX would fail anyway. Real metallib is ~84 MB.- SIZE=$(stat -f%z "$RES_LIB")- if [ "$SIZE" -lt 1000000 ]; then- echo "Resources/mlx.metallib is only ${SIZE} bytes (placeholder) — skipping inject"- exit 0- fi-- echo "=== Injecting mlx.metallib into Contents/MacOS/ (${SIZE} bytes) ==="- cp "$RES_LIB" "${APP}/Contents/MacOS/mlx.metallib"-- # Re-unlock the keychain before re-signing — same retry pattern the- # build step uses, since codesign needs the cert.- BUILD_KC="$HOME/Library/Keychains/build.keychain-db"- if [ -f "$BUILD_KC" ]; then- security unlock-keychain -p "build_password" "$BUILD_KC"- security set-keychain-settings -t 3600 "$BUILD_KC"- fi-- # Re-sign the bundle. --deep so all inner binaries stay covered;- # --force so the existing signature is replaced. Same identity +- # entitlements + hardened-runtime flags Tauri used.- codesign --force --deep \- --sign "$APPLE_SIGNING_IDENTITY" \- --options runtime \- --entitlements apps/screenpipe-app-tauri/src-tauri/entitlements.plist \- --timestamp \- "$APP"-- codesign --verify --deep --strict --verbose=2 "$APP"- echo "✅ ${APP##*/} re-signed with mlx.metallib in Contents/MacOS/"-- # Rebuild the DMG so it ships the modified .app.- #- # The mount-and-swap approach (UDRW convert → attach → cp .app →- # detach → UDZO convert) blew through CI runner disk space — the- # ~600 MB .app gets duplicated into the mounted DMG, on top of- # the existing UDRW + UDZO copies (~3× peak disk usage). v2.4.154- # hit "fcopyfile failed: No space left on device".- #- # Cheaper: delete the original DMG to free space, then create a- # fresh DMG from a staging dir that contains BOTH the patched- # .app AND an `Applications` symlink → /Applications. The- # symlink is what gives users the drag-to-install affordance- # — without it, opening the DMG just shows the app icon with- # nowhere to drag it (regression: v2.4.156 shipped a bare- # `-srcfolder "$APP"` and dropped the Applications symlink;- # users opened the DMG and couldn't install).- DMG_DIR="${BUNDLE_DIR}/dmg"- dmgs=( "${DMG_DIR}"/*.dmg )- if [ ${#dmgs[@]} -eq 0 ]; then- echo "no DMG produced — skipping DMG patch"- exit 0- fi- DMG="${dmgs[0]}"- echo "=== Replacing DMG: ${DMG##*/} ==="- df -h "$DMG_DIR" | tail -1- rm -f "$DMG"-- # Stage the .app alongside an Applications symlink. The- # symlink itself adds zero bytes to the DMG — when hdiutil- # walks the staging dir, the Applications target is OUTSIDE- # the staging root so it's preserved as a symlink (not- # followed, which would copy /Applications recursively).- # We `cp -R` rather than `mv` because the next workflow step- # ("Staple .app and rebuild updater tarball") needs the- # original .app at bundle/macos/ to staple + repackage for- # the Tauri auto-updater.- DMG_STAGE="${RUNNER_TEMP:-/tmp}/screenpipe-dmg-stage-$$"- mkdir -p "$DMG_STAGE"- cp -R "$APP" "$DMG_STAGE/"- ln -s /Applications "$DMG_STAGE/Applications"-- hdiutil create \- -volname "Screenpipe" \- -srcfolder "$DMG_STAGE" \- -ov \- -format UDZO \- -imagekey zlib-level=9 \- "$DMG"-- rm -rf "$DMG_STAGE"-- # Sign the new DMG so notarization sees a clean cdhash.- codesign --force --sign "$APPLE_SIGNING_IDENTITY" --timestamp "$DMG"- codesign --verify --verbose=2 "$DMG"- echo "✅ ${DMG##*/} re-created + signed from patched .app (with Applications symlink)"-- - name: Inject libonnxruntime.dylib into Contents/MacOS/ + re-sign (Intel macOS)- # ort rc.12 ships no x86_64-apple-darwin prebuilt (pyke + upstream ONNX- # Runtime are arm64-only since ~1.20), so the Intel build links ONNX- # Runtime via `load-dynamic` and loads libonnxruntime.dylib at runtime.- # ort's loader resolves the bare "libonnxruntime.dylib" relative to the- # executable dir (Contents/MacOS/), so the dylib must sit next to the- # binary — same constraint, and same inject + re-sign + rebuild-DMG- # flow, as the mlx.metallib step above. Must run BEFORE notarization.- #- # Source: the Homebrew onnxruntime bottle (x86_64, 1.26.0), pinned by- # immutable ghcr blob digest (QQ== is Homebrew's anonymous ghcr token).- # ort only warns (never errors) when the dylib is newer than its target- # 1.24, so the 1.26 build is accepted.- if: matrix.target == 'x86_64-apple-darwin'- shell: bash- env:- APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}- run: |- set -euo pipefail- TARGET="${{ matrix.target }}"- BUNDLE_DIR="apps/screenpipe-app-tauri/src-tauri/target/${TARGET}/release/bundle"- APP_DIR="${BUNDLE_DIR}/macos"-- shopt -s nullglob- apps=( "${APP_DIR}"/*.app )- if [ ${#apps[@]} -eq 0 ]; then- echo "no .app to patch — skipping libonnxruntime inject"- exit 0- fi- APP="${apps[0]}"-- # Fetch the x86_64 ONNX Runtime dylib from the Homebrew bottle- # (content-addressed = immutable; won't move if the formula bumps).- ORT_BLOB="https://ghcr.io/v2/homebrew/core/onnxruntime/blobs/sha256:afe69511a14f1b9351074b0bf9e5de65858d25a6795ab7f228ba78b149079c3d"- TMP="${RUNNER_TEMP:-/tmp}/ort-x64-$$"- mkdir -p "$TMP"- echo "=== Downloading x86_64 libonnxruntime.dylib (Homebrew bottle) ==="- curl -fsSL -H "Authorization: Bearer QQ==" "$ORT_BLOB" -o "$TMP/bottle.tar.gz"- tar -xzf "$TMP/bottle.tar.gz" -C "$TMP"- SRC_DYLIB="$(find "$TMP" -name 'libonnxruntime*.dylib' | head -1)"- if [ -z "$SRC_DYLIB" ]; then- echo "ERROR: no libonnxruntime dylib found in bottle" >&2- exit 1- fi- if ! lipo -info "$SRC_DYLIB" | grep -q 'x86_64'; then- echo "ERROR: dylib is not x86_64: $(lipo -info "$SRC_DYLIB")" >&2- exit 1- fi- DEST="${APP}/Contents/MacOS/libonnxruntime.dylib"- echo "=== Injecting $(basename "$SRC_DYLIB") -> Contents/MacOS/libonnxruntime.dylib ==="- cp "$SRC_DYLIB" "$DEST"- chmod 0644 "$DEST"-- # Re-unlock the keychain before re-signing — same retry pattern the- # build + metallib steps use, since codesign needs the cert.- BUILD_KC="$HOME/Library/Keychains/build.keychain-db"- if [ -f "$BUILD_KC" ]; then- security unlock-keychain -p "build_password" "$BUILD_KC"- security set-keychain-settings -t 3600 "$BUILD_KC"- fi-- # Sign the injected dylib (hardened runtime + timestamp, required for- # notarization), then re-sign the whole bundle so the cdhash covers it.- codesign --force --sign "$APPLE_SIGNING_IDENTITY" --options runtime --timestamp "$DEST"- codesign --force --deep \- --sign "$APPLE_SIGNING_IDENTITY" \- --options runtime \- --entitlements apps/screenpipe-app-tauri/src-tauri/entitlements.plist \- --timestamp \- "$APP"- codesign --verify --deep --strict --verbose=2 "$APP"- echo "✅ ${APP##*/} re-signed with libonnxruntime.dylib in Contents/MacOS/"-- # Rebuild the DMG so it ships the patched .app (same cheaper- # delete + recreate-from-staging flow as the metallib step, with the- # Applications symlink so drag-to-install still works).- DMG_DIR="${BUNDLE_DIR}/dmg"- dmgs=( "${DMG_DIR}"/*.dmg )- if [ ${#dmgs[@]} -eq 0 ]; then- echo "no DMG produced — skipping DMG patch"- rm -rf "$TMP"- exit 0- fi- DMG="${dmgs[0]}"- echo "=== Replacing DMG: ${DMG##*/} ==="- df -h "$DMG_DIR" | tail -1- rm -f "$DMG"- DMG_STAGE="${RUNNER_TEMP:-/tmp}/screenpipe-dmg-stage-$$"- mkdir -p "$DMG_STAGE"- cp -R "$APP" "$DMG_STAGE/"- ln -s /Applications "$DMG_STAGE/Applications"- hdiutil create \- -volname "Screenpipe" \- -srcfolder "$DMG_STAGE" \- -ov \- -format UDZO \- -imagekey zlib-level=9 \- "$DMG"- rm -rf "$DMG_STAGE" "$TMP"- codesign --force --sign "$APPLE_SIGNING_IDENTITY" --timestamp "$DMG"- codesign --verify --verbose=2 "$DMG"- echo "✅ ${DMG##*/} re-created + signed from patched .app (with libonnxruntime.dylib)"-- name: Clean up signing cert from login keychain (macOS)if: matrix.os_type == 'macos' && always()shell: bashdiff --git a/.github/workflows/release-enterprise.yml b/.github/workflows/release-enterprise.ymlindex 1a37e7337..d914be79a 100644--- a/.github/workflows/release-enterprise.yml+++ b/.github/workflows/release-enterprise.yml@@ -761,124 +761,6 @@ jobs:fidone- - name: Inject mlx.metallib into Contents/MacOS/ + re-sign- # MLX's runtime library search looks for mlx.metallib next to the- # binary (Contents/MacOS/), not in the app's Resources dir. Tauri's- # `bundle.resources` always lands in Contents/Resources/, so we have- # to physically copy the file into Contents/MacOS/ ourselves.- #- # Without this the enterprise build ships parakeet-mlx (see the- # --features list in the build step) but no Metal shader library:- # MLX throws "Failed to load the default metallib", its default C- # error handler calls exit() mid-startup, and static-destructor- # teardown races the ONNX CoreML model compile threads → SIGSEGV- # at launch (v2.5.29 enterprise crash).- #- # Mirrors "Inject mlx.metallib into Contents/MacOS/ + re-sign" in- # release-app.yml: copy + re-sign + rebuild DMG BEFORE notarization- # (adding files to a signed bundle invalidates the cdhash). Unlike- # the consumer step this also rebuilds the updater tarball here,- # since this workflow has no separate staple/tarball step and the- # R2 upload ships macos/*.app.tar.gz for auto-updates.- shell: bash- env:- APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}- TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}- TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}- run: |- set -euo pipefail- TARGET="aarch64-apple-darwin"- BUNDLE_DIR="${GITHUB_WORKSPACE}/apps/screenpipe-app-tauri/src-tauri/target/${TARGET}/release/bundle"- APP_DIR="${BUNDLE_DIR}/macos"-- shopt -s nullglob- apps=( "${APP_DIR}"/*.app )- if [ ${#apps[@]} -eq 0 ]; then- echo "::error::no .app bundle in ${APP_DIR} — Tauri build did not produce one"- exit 1- fi- APP="${apps[0]}"- RES_LIB="${APP}/Contents/Resources/mlx.metallib"-- # The enterprise build always compiles parakeet-mlx, so a missing- # or placeholder metallib means we would ship the launch crash —- # hard-fail instead of soft-skipping like the consumer workflow- # (which also builds non-mlx targets).- if [ ! -f "$RES_LIB" ]; then- echo "::error::no Contents/Resources/mlx.metallib — check bundle.resources in tauri.enterprise.conf.json"- exit 1- fi- SIZE=$(stat -f%z "$RES_LIB")- if [ "$SIZE" -lt 1000000 ]; then- echo "::error::Resources/mlx.metallib is only ${SIZE} bytes (placeholder) — build.rs metallib download failed; parakeet-mlx would crash at runtime"- exit 1- fi-- echo "=== Injecting mlx.metallib into Contents/MacOS/ (${SIZE} bytes) ==="- cp "$RES_LIB" "${APP}/Contents/MacOS/mlx.metallib"-- # Re-unlock the keychain before re-signing — same retry pattern the- # build step uses, since codesign needs the cert.- BUILD_KC="$HOME/Library/Keychains/build.keychain-db"- if [ -f "$BUILD_KC" ]; then- security unlock-keychain -p "build_password" "$BUILD_KC"- security set-keychain-settings -t 3600 "$BUILD_KC"- fi-- # Re-sign the bundle. --deep so all inner binaries stay covered;- # --force so the existing signature is replaced. Same identity +- # entitlements + hardened-runtime flags Tauri used.- codesign --force --deep \- --sign "$APPLE_SIGNING_IDENTITY" \- --options runtime \- --entitlements apps/screenpipe-app-tauri/src-tauri/entitlements.plist \- --timestamp \- "$APP"- codesign --verify --deep --strict --verbose=2 "$APP"- echo "${APP##*/} re-signed with mlx.metallib in Contents/MacOS/"-- # Rebuild the DMG from the patched .app, keeping the Applications- # symlink so users still get the drag-to-install affordance.- DMG_DIR="${BUNDLE_DIR}/dmg"- dmgs=( "${DMG_DIR}"/*.dmg )- if [ ${#dmgs[@]} -gt 0 ]; then- DMG="${dmgs[0]}"- echo "=== Replacing DMG: ${DMG##*/} ==="- rm -f "$DMG"- DMG_STAGE="${RUNNER_TEMP:-/tmp}/screenpipe-enterprise-dmg-stage-$$"- mkdir -p "$DMG_STAGE"- cp -R "$APP" "$DMG_STAGE/"- ln -s /Applications "$DMG_STAGE/Applications"- hdiutil create \- -volname "screenpipe enterprise" \- -srcfolder "$DMG_STAGE" \- -ov \- -format UDZO \- -imagekey zlib-level=9 \- "$DMG"- rm -rf "$DMG_STAGE"- codesign --force --sign "$APPLE_SIGNING_IDENTITY" --timestamp "$DMG"- codesign --verify --verbose=2 "$DMG"- echo "${DMG##*/} re-created + signed from patched .app"- else- echo "no DMG produced — skipping DMG rebuild"- fi-- # Rebuild the updater tarball so auto-updates ship the patched- # .app, and re-sign it — the Tauri-built .sig covers the- # pre-patch bytes and would no longer match.- APP_NAME="${APP##*/}"- TARBALL="${APP_DIR}/${APP_NAME}.tar.gz"- if [ -f "$TARBALL" ]; then- echo "=== Rebuilding updater tarball ${APP_NAME}.tar.gz ==="- rm -f "$TARBALL" "${TARBALL}.sig"- ( cd "$APP_DIR" && tar czf "${APP_NAME}.tar.gz" "${APP_NAME}" )- ( cd "${GITHUB_WORKSPACE}/apps/screenpipe-app-tauri" && bunx tauri signer sign "$TARBALL" )- echo "${APP_NAME}.tar.gz rebuilt and re-signed"- else- echo "no updater tarball produced — skipping tarball rebuild"- fi-- name: Notarize and staple DMGenv:APPLE_ID: ${{ secrets.APPLE_ID }}diff --git a/.gitignore b/.gitignoreindex 13ddfef85..317a8e72f 100644--- a/.gitignore+++ b/.gitignore@@ -83,6 +83,7 @@ crates/screenpipe-audio/openblas-0.3.31-x64.zipcrates/screenpipe-audio/openblas-0.3.31-woa64-dll.zipapps/screenpipe-app-tauri/src-tauri/openblas/apps/screenpipe-app-tauri/src-tauri/mlx.metallib+apps/screenpipe-app-tauri/src-tauri/libonnxruntime.dylib.serena/.worktrees/diff --git a/apps/screenpipe-app-tauri/src-tauri/build.rs b/apps/screenpipe-app-tauri/src-tauri/build.rsindex e8f52cc43..0cb1b3e31 100644--- a/apps/screenpipe-app-tauri/src-tauri/build.rs+++ b/apps/screenpipe-app-tauri/src-tauri/build.rs@@ -341,6 +341,11 @@ fn main() {// Build SwiftUI shortcut reminderbuild_shortcut_reminder();+ // Copy mlx.metallib and libonnxruntime.dylib to src-tauri/ for bundle.macOS.files+ // (Contents/MacOS/). MLX metallib must be next to the binary; onnx dylib+ // is loaded via ort load-dynamic on x86_64.+ stage_macos_sidecar_libs();+// Stage permission-flow's resource bundle for Tauri to pick up.copy_permission_flow_bundle();}@@ -359,54 +364,6 @@ fn main() {}}- // Copy mlx.metallib to a known location so Tauri can bundle it as a resource.- // MLX compiles Metal shaders into this file during mlx-sys build. Without it,- // parakeet-mlx crashes with "Failed to load the default metallib".- #[cfg(all(target_os = "macos", target_arch = "aarch64"))]- {- // Download mlx.metallib (pre-compiled MLX Metal shaders) for parakeet-mlx.- // MLX needs this file next to the binary at runtime. Tauri bundles it into- // Contents/Resources/ and main.rs symlinks it to Contents/MacOS/.- let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();- let metallib = std::path::Path::new(&manifest_dir).join("mlx.metallib");- let min_size = 1_000_000; // real metallib is ~84MB-- let needs_download = !metallib.exists()- || std::fs::metadata(&metallib).map(|m| m.len()).unwrap_or(0) < min_size;-- if needs_download {- println!("cargo:warning=mlx-metallib: downloading from GitHub releases...");- let url = "https://github.com/screenpipe/screenpipe/releases/download/mlx-metallib-v0.2.0/mlx.metallib";- let status = std::process::Command::new("curl")- .args(["-L", "-f", "-o", metallib.to_str().unwrap(), url])- .status();- match status {- Ok(s) if s.success() => {- let size = std::fs::metadata(&metallib).map(|m| m.len()).unwrap_or(0);- println!("cargo:warning=mlx-metallib: downloaded ({} MB)", size / 1_000_000);- }- _ => println!("cargo:warning=mlx-metallib: download failed — parakeet-mlx will crash at runtime"),- }- } else {- let size = std::fs::metadata(&metallib).map(|m| m.len()).unwrap_or(0);- println!(- "cargo:warning=mlx-metallib: already present ({} MB)",- size / 1_000_000- );- }- }-- // Ensure mlx.metallib exists so Tauri doesn't fail on the resource declaration.- // On non-aarch64-macOS builds, create an empty placeholder (it won't be used).- #[cfg(not(all(target_os = "macos", target_arch = "aarch64")))]- {- let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();- let metallib = std::path::Path::new(&manifest_dir).join("mlx.metallib");- if !metallib.exists() {- let _ = std::fs::write(&metallib, b"");- }- }-// Windows MSVC: provide the GCC `__builtin_bswap{16,32,64}` intrinsics// as real functions. aws-lc-sys (pulled in by rustls 0.23) ships C// that calls them, but cl.exe doesn't recognize the names, so it@@ -597,6 +554,192 @@ int shortcut_is_available(void) { return 0; }println!("cargo:rustc-link-lib=static=shortcut_reminder");}+/// Stage mlx.metallib and libonnxruntime.dylib into `src-tauri/` so Tauri's+/// `bundle.macOS.files` can copy them into `Contents/MacOS/` before codesign.+/// MLX needs metallib next to the binary at runtime (parakeet-mlx crashes without it).+/// x86_64 Intel builds need libonnxruntime.dylib colocated for ort `load-dynamic`.+/// Same build-time staging pattern as `copy_permission_flow_bundle` (#3990).+#[cfg(target_os = "macos")]+fn stage_macos_sidecar_libs() {+ stage_mlx_metallib();+ stage_libonnxruntime_dylib();+}++/// Copy mlx.metallib to a known location so Tauri can bundle it via bundle.macOS.files.+/// MLX compiles Metal shaders into this file during mlx-sys build. Without it,+/// parakeet-mlx crashes with "Failed to load the default metallib".+#[cfg(all(target_os = "macos", target_arch = "aarch64"))]+fn stage_mlx_metallib() {+ let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();+ let metallib = std::path::Path::new(&manifest_dir).join("mlx.metallib");+ let min_size = 1_000_000; // real metallib is ~84MB++ let needs_download = !metallib.exists()+ || std::fs::metadata(&metallib).map(|m| m.len()).unwrap_or(0) < min_size;++ if needs_download {+ // Download mlx.metallib (pre-compiled MLX Metal shaders) for parakeet-mlx.+ // MLX needs this file next to the binary at runtime. Tauri copies it into+ // Contents/MacOS/ via bundle.macOS.files (see tauri.macos.conf.json).+ println!("cargo:warning=mlx-metallib: downloading from GitHub releases...");+ let url =+ "https://github.com/screenpipe/screenpipe/releases/download/mlx-metallib-v0.2.0/mlx.metallib";+ let status = std::process::Command::new("curl")+ .args(["-L", "-f", "-o", metallib.to_str().unwrap(), url])+ .status();+ match status {+ Ok(s) if s.success() => {+ let size = std::fs::metadata(&metallib).map(|m| m.len()).unwrap_or(0);+ println!("cargo:warning=mlx-metallib: downloaded ({} MB)", size / 1_000_000);+ }+ _ => println!(+ "cargo:warning=mlx-metallib: download failed — parakeet-mlx will crash at runtime"+ ),+ }+ } else {+ let size = std::fs::metadata(&metallib).map(|m| m.len()).unwrap_or(0);+ println!(+ "cargo:warning=mlx-metallib: already present ({} MB)",+ size / 1_000_000+ );+ }+}++/// Ensure mlx.metallib exists so Tauri doesn't fail on the bundle.macOS.files entry.+/// On non-aarch64-macOS builds, create an empty placeholder (it won't be used).+#[cfg(all(target_os = "macos", not(target_arch = "aarch64")))]+fn stage_mlx_metallib() {+ let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();+ let metallib = std::path::Path::new(&manifest_dir).join("mlx.metallib");+ if !metallib.exists() {+ let _ = std::fs::write(&metallib, b"");+ }+}++/// Stage libonnxruntime.dylib for x86_64 Intel builds. ort `load-dynamic` resolves+/// relative paths from the executable, so the dylib must live in Contents/MacOS/.+#[cfg(target_os = "macos")]+fn stage_libonnxruntime_dylib() {+ use std::path::PathBuf;++ let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();+ let dylib = PathBuf::from(&manifest_dir).join("libonnxruntime.dylib");+ let target_arch =+ std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| "aarch64".to_string());+ let is_release = std::env::var("PROFILE").as_deref() == Ok("release");+ let min_size = 100_000;++ if target_arch == "x86_64" {+ if !dylib.exists() || std::fs::metadata(&dylib).map(|m| m.len()).unwrap_or(0) < min_size {+ if let Ok(ort_path) = std::env::var("ORT_DYLIB_PATH") {+ let src = PathBuf::from(&ort_path);+ if src.is_file() {+ if let Err(e) = std::fs::copy(&src, &dylib) {+ println!("cargo:warning=libonnxruntime: ORT_DYLIB_PATH copy failed: {e}");+ } else {+ println!(+ "cargo:warning=libonnxruntime: copied from ORT_DYLIB_PATH ({})",+ src.display()+ );+ }+ }+ }+ }++ let still_needs_fetch =+ !dylib.exists() || std::fs::metadata(&dylib).map(|m| m.len()).unwrap_or(0) < min_size;++ if still_needs_fetch {+ println!(+ "cargo:warning=libonnxruntime: downloading x86_64 dylib from Homebrew bottle..."+ );+ match download_homebrew_onnxruntime_dylib(&dylib) {+ Ok(size) => println!(+ "cargo:warning=libonnxruntime: downloaded ({} MB)",+ size / 1_000_000+ ),+ Err(e) => {+ let msg = format!("libonnxruntime dylib fetch failed: {e}");+ if is_release {+ panic!("{msg}");+ }+ println!("cargo:warning={msg} (debug build, staging empty stub)");+ let _ = std::fs::write(&dylib, b"");+ }+ }+ }+ } else if !dylib.exists() {+ let _ = std::fs::write(&dylib, b"");+ }+}++#[cfg(target_os = "macos")]+fn download_homebrew_onnxruntime_dylib(dst: &std::path::Path) -> Result<u64, String> {+ use std::path::PathBuf;++ let tmp = std::env::temp_dir().join(format!("ort-app-{}", std::process::id()));+ std::fs::create_dir_all(&tmp).map_err(|e| e.to_string())?;+ let tarball = tmp.join("bottle.tar.gz");++ let curl_status = std::process::Command::new("curl")+ .args([+ "-fsSL",+ "-H",+ "Authorization: Bearer QQ==",+ "-o",+ tarball.to_str().ok_or("invalid temp path")?,+ "https://ghcr.io/v2/homebrew/core/onnxruntime/blobs/sha256:afe69511a14f1b9351074b0bf9e5de65858d25a6795ab7f228ba78b149079c3d",+ ])+ .status()+ .map_err(|e| e.to_string())?;+ if !curl_status.success() {+ let _ = std::fs::remove_dir_all(&tmp);+ return Err("curl download failed".into());+ }++ let tar_status = std::process::Command::new("tar")+ .args(["-xzf", tarball.to_str().ok_or("invalid temp path")?, "-C"])+ .arg(&tmp)+ .status()+ .map_err(|e| e.to_string())?;+ if !tar_status.success() {+ let _ = std::fs::remove_dir_all(&tmp);+ return Err("tar extract failed".into());+ }++ let src = find_onnxruntime_dylib(&tmp).ok_or_else(|| {+ let _ = std::fs::remove_dir_all(&tmp);+ "no libonnxruntime dylib in bottle".to_string()+ })?;++ std::fs::copy(&src, dst).map_err(|e| e.to_string())?;+ let _ = std::fs::remove_dir_all(&tmp);+ std::fs::metadata(dst)+ .map(|m| m.len())+ .map_err(|e| e.to_string())+}++#[cfg(target_os = "macos")]+fn find_onnxruntime_dylib(root: &std::path::Path) -> Option<std::path::PathBuf> {+ let mut stack = vec![root.to_path_buf()];+ while let Some(dir) = stack.pop() {+ let entries = std::fs::read_dir(&dir).ok()?;+ for entry in entries.flatten() {+ let path = entry.path();+ if path.is_dir() {+ stack.push(path);+ } else if path+ .file_name()+ .and_then(|n| n.to_str())+ .is_some_and(|n| n.starts_with("libonnxruntime") && n.ends_with(".dylib"))+ {+ return Some(path);+ }+ }+ }+ None+}+/// Stage `PermissionFlow_PermissionFlow.bundle` into `src-tauri/` so Tauri/// bundles it into `Contents/Resources/`. Missing it crashes onboarding with/// `fatalError` on the first localized string in a shipped `.app`.diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rsindex 7f2536d3c..470d9a657 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs@@ -1128,10 +1128,9 @@ async fn main() {env::set_var("TESSDATA_PREFIX", tessdata_path);}- // mlx.metallib is now placed at Contents/MacOS/mlx.metallib at- // build time (see "Inject mlx.metallib into Contents/MacOS/" step- // in .github/workflows/release-app.yml), then signed as part of- // the normal codesign pass.+ // mlx.metallib and libonnxruntime.dylib are placed at Contents/MacOS/ at+ // build time via bundle.macOS.files (see build.rs stage_macos_sidecar_libs),+ // then signed as part of the normal codesign pass.//// Previously this block created a symlink at Contents/MacOS/mlx.metallib// pointing at Contents/Resources/mlx.metallib on first launch. Applediff --git a/apps/screenpipe-app-tauri/src-tauri/tauri.conf.json b/apps/screenpipe-app-tauri/src-tauri/tauri.conf.jsonindex 36144def7..0536d3a70 100644--- a/apps/screenpipe-app-tauri/src-tauri/tauri.conf.json+++ b/apps/screenpipe-app-tauri/src-tauri/tauri.conf.json@@ -37,7 +37,6 @@],"resources": ["assets/*",- "mlx.metallib","PermissionFlow_PermissionFlow.bundle"],"macOS": {diff --git a/apps/screenpipe-app-tauri/src-tauri/tauri.enterprise.conf.json b/apps/screenpipe-app-tauri/src-tauri/tauri.enterprise.conf.jsonindex 28cf0dfd4..58eea7d6d 100644--- a/apps/screenpipe-app-tauri/src-tauri/tauri.enterprise.conf.json+++ b/apps/screenpipe-app-tauri/src-tauri/tauri.enterprise.conf.json@@ -40,7 +40,6 @@],"resources": ["assets/*",- "mlx.metallib","PermissionFlow_PermissionFlow.bundle"],"macOS": {diff --git a/apps/screenpipe-app-tauri/src-tauri/tauri.macos.conf.json b/apps/screenpipe-app-tauri/src-tauri/tauri.macos.conf.jsonindex d8c89d4bb..b5e2615f9 100644--- a/apps/screenpipe-app-tauri/src-tauri/tauri.macos.conf.json+++ b/apps/screenpipe-app-tauri/src-tauri/tauri.macos.conf.json@@ -6,6 +6,10 @@"hardenedRuntime": true,"exceptionDomain": "screenpipe.com","provisioningProfile": null,+ "files": {+ "MacOS/mlx.metallib": "mlx.metallib",+ "MacOS/libonnxruntime.dylib": "libonnxruntime.dylib"+ },"dmg": {"background": "assets/dmg-background.png"}diff --git a/apps/screenpipe-app-tauri/src-tauri/tauri.prod.conf.json b/apps/screenpipe-app-tauri/src-tauri/tauri.prod.conf.jsonindex 59fe9bda8..b347b292d 100644--- a/apps/screenpipe-app-tauri/src-tauri/tauri.prod.conf.json+++ b/apps/screenpipe-app-tauri/src-tauri/tauri.prod.conf.json@@ -40,7 +40,6 @@],"resources": ["assets/*",- "mlx.metallib","PermissionFlow_PermissionFlow.bundle"],"macOS": {