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
Bump app to v2.4.186 — flip MLX on for image-PII on Apple Silicon — release-app
Louis Beaumont1ebaa3d1b698
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.ymlindex 02e75099c..bd766290e 100644--- a/.github/workflows/release-app.yml+++ b/.github/workflows/release-app.yml@@ -166,9 +166,9 @@ jobs:include:# GitHub-hosted macOS 26 runner for Apple Silicon + Apple Intelligence- platform: ${{ needs.check_commit.outputs.macos_arm_runner || 'macos-latest' }}- args: "--target aarch64-apple-darwin --features metal,parakeet-mlx"+ args: "--target aarch64-apple-darwin --features metal,parakeet-mlx,rfdetr-mlx"target: aarch64-apple-darwin- tauri-args: "--target aarch64-apple-darwin --features metal,parakeet-mlx,official-build"+ tauri-args: "--target aarch64-apple-darwin --features metal,parakeet-mlx,rfdetr-mlx,official-build"os_type: "macos"- platform: "macos-26"args: "--target x86_64-apple-darwin --features metal"diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lockindex 100b97631..a2fba239a 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock@@ -10557,7 +10557,7 @@ dependencies = [[[package]]name = "screenpipe-app"-version = "2.4.185"+version = "2.4.186"dependencies = ["aes","anyhow",diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 3e96e3c1c..1ed812dc9 100644--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "2.4.185"+version = "2.4.186"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs b/crates/screenpipe-engine/src/bin/screenpipe-engine.rsindex db4e17182..7d9132b82 100644--- a/crates/screenpipe-engine/src/bin/screenpipe-engine.rs+++ b/crates/screenpipe-engine/src/bin/screenpipe-engine.rs@@ -1582,18 +1582,27 @@ async fn main() -> anyhow::Result<()> {// ~/.screenpipe/models/. Subsequent starts are instant.#[allow(unused_mut)]let mut detector_arc: Option<Arc<dyn ImageRedactor>> = None;- #[cfg(all(feature = "rfdetr-mlx", target_os = "macos"))]+ #[cfg(all(feature = "rfdetr-mlx", target_os = "macos", target_arch = "aarch64"))]{use screenpipe_redact::adapters::rfdetr_mlx::{RfdetrMlxConfig, RfdetrMlxRedactor};- match RfdetrMlxRedactor::load(RfdetrMlxConfig::default()) {- Ok(d) => {- info!("image-PII detector: rfdetr-mlx (Apple Silicon GPU)");- detector_arc = Some(Arc::new(d) as Arc<dyn ImageRedactor>);- }- Err(e) => {- tracing::info!(- "rfdetr-mlx unavailable ({e}); falling back to ONNX adapter"- );+ let mlx_cfg = RfdetrMlxConfig::default();+ // Mirrors the ONNX adapter: download once, verify SHA-256,+ // cache at ~/.screenpipe/models/rfdetr_v9.safetensors.+ if let Err(e) = mlx_cfg.ensure_model_present().await {+ tracing::info!(+ "rfdetr-mlx safetensors download failed ({e}); falling back to ONNX adapter"+ );+ } else {+ match RfdetrMlxRedactor::load(mlx_cfg) {+ Ok(d) => {+ info!("image-PII detector: rfdetr-mlx (Apple Silicon GPU)");+ detector_arc = Some(Arc::new(d) as Arc<dyn ImageRedactor>);+ }+ Err(e) => {+ tracing::info!(+ "rfdetr-mlx load failed ({e}); falling back to ONNX adapter"+ );+ }}}}diff --git a/crates/screenpipe-redact/Cargo.toml b/crates/screenpipe-redact/Cargo.tomlindex e924a41e9..5152dbd9f 100644--- a/crates/screenpipe-redact/Cargo.toml+++ b/crates/screenpipe-redact/Cargo.toml@@ -106,9 +106,10 @@ rev = "e725ad5e8a89ae46e4cb38022a26e746c37329b6"optional = truefeatures = ["metal"]-# MLX-based rfdetr runtime — only meaningful on Apple Silicon. On-# Linux/Windows the dep is an empty optional, the `mlx-mac` feature is-# never enabled, and nothing pulls mlx-rs.-[target.'cfg(target_os = "macos")'.dependencies.screenpipe-rfdetr-mlx]+# MLX-based rfdetr runtime — Apple-Silicon-only (mlx-rs links against+# Metal Performance Shaders Graph, which is unavailable on Intel+# macOS). Cargo target_arch gate keeps the dep out of x86_64 macOS,+# Linux, and Windows builds entirely.+[target.'cfg(all(target_os = "macos", target_arch = "aarch64"))'.dependencies.screenpipe-rfdetr-mlx]path = "../screenpipe-rfdetr-mlx"optional = truediff --git a/crates/screenpipe-redact/src/adapters/rfdetr_mlx.rs b/crates/screenpipe-redact/src/adapters/rfdetr_mlx.rsindex d1dd43da1..162edb1fc 100644--- a/crates/screenpipe-redact/src/adapters/rfdetr_mlx.rs+++ b/crates/screenpipe-redact/src/adapters/rfdetr_mlx.rs@@ -13,13 +13,13 @@//!//! ## Weight file//!-//! MLX consumes safetensors, not ONNX. Until we publish a safetensors-//! sibling next to `rfdetr_v9.onnx` on HuggingFace, this adapter-//! expects the file at `~/.screenpipe/models/rfdetr_v9.safetensors`-//! (use `convert/onnx_to_mlx.py` from the model release to produce-//! it). If the file is missing, [`RfdetrMlxRedactor::load`] returns-//! [`RedactError::Unavailable`] so the engine can fall back to the-//! ONNX path cleanly.+//! MLX consumes safetensors, not ONNX, so this adapter ships its own+//! download flow (mirroring [`super::rfdetr::RfdetrConfig`]): pulls+//! `rfdetr_v9.safetensors` from+//! `huggingface.co/screenpipe/pii-image-redactor` on first run+//! (~108 MB), verifies SHA-256, atomic-renames into+//! `~/.screenpipe/models/rfdetr_v9.safetensors`. Subsequent starts+//! are instant.use std::path::{Path, PathBuf};@@ -27,7 +27,7 @@ use async_trait::async_trait;use crate::image::{ImageRedactor, ImageRegion};use crate::RedactError;-#[cfg(all(feature = "mlx-mac", target_os = "macos"))]+#[cfg(all(feature = "mlx-mac", target_os = "macos", target_arch = "aarch64"))]use crate::SpanLabel;const NAME: &str = "rfdetr-mlx";@@ -63,11 +63,110 @@ impl RfdetrMlxConfig {.join("models").join("rfdetr_v9.safetensors")}++ /// HuggingFace download URL for the safetensors weights. Pinned to+ /// `main` so a model bump goes through a deliberate code change+ /// (URL + expected SHA-256 + [`VERSION`] all bumped together).+ pub const HF_DOWNLOAD_URL: &'static str =+ "https://huggingface.co/screenpipe/pii-image-redactor/resolve/main/rfdetr_v9.safetensors";++ /// Expected SHA-256 of the canonical `rfdetr_v9.safetensors`.+ /// Verified after every download. If a future training run+ /// produces a new best, bump [`VERSION`], re-publish to HF,+ /// update this constant.+ pub const EXPECTED_SHA256: &'static str =+ "6afe6974653a68a2d56efe74c13adfa6b54dd8d0cf43b8eb0603c85e0884b6e6";++ /// Make sure the safetensors is present on disk. Idempotent —+ /// does nothing if [`Self::model_path`] already exists with the+ /// expected SHA-256. Otherwise downloads from+ /// [`Self::HF_DOWNLOAD_URL`], verifies, atomic-renames into place.+ ///+ /// Atomic semantics: download lands at+ /// `<model_path>.partial`, gets verified, then renames over+ /// `<model_path>`. A killed process leaves at most a `.partial`+ /// that the next call cleans up.+ pub async fn ensure_model_present(&self) -> Result<(), RedactError> {+ if self.model_path.exists() && Self::sha256_matches(&self.model_path)? {+ return Ok(());+ }++ if let Some(parent) = self.model_path.parent() {+ tokio::fs::create_dir_all(parent)+ .await+ .map_err(|e| RedactError::Runtime(format!("mkdir {}: {e}", parent.display())))?;+ }++ let tmp = self.model_path.with_extension("safetensors.partial");+ let _ = tokio::fs::remove_file(&tmp).await;++ tracing::info!(+ url = Self::HF_DOWNLOAD_URL,+ target = %self.model_path.display(),+ "downloading rfdetr_v9.safetensors (~108 MB) — first-run only"+ );+ let resp = reqwest::Client::new()+ .get(Self::HF_DOWNLOAD_URL)+ .send()+ .await+ .map_err(|e| RedactError::Runtime(format!("rfdetr-mlx download GET: {e}")))?;+ if !resp.status().is_success() {+ return Err(RedactError::Runtime(format!(+ "rfdetr-mlx download returned {}",+ resp.status()+ )));+ }+ let bytes = resp+ .bytes()+ .await+ .map_err(|e| RedactError::Runtime(format!("rfdetr-mlx download body: {e}")))?;++ let actual = Self::hex_sha256(&bytes);+ if actual != Self::EXPECTED_SHA256 {+ return Err(RedactError::Runtime(format!(+ "rfdetr-mlx download checksum mismatch: got {}, want {}",+ actual,+ Self::EXPECTED_SHA256+ )));+ }++ tokio::fs::write(&tmp, &bytes)+ .await+ .map_err(|e| RedactError::Runtime(format!("rfdetr-mlx write tmp: {e}")))?;+ tokio::fs::rename(&tmp, &self.model_path)+ .await+ .map_err(|e| RedactError::Runtime(format!("rfdetr-mlx rename: {e}")))?;+ tracing::info!(+ target = %self.model_path.display(),+ bytes = bytes.len(),+ "rfdetr_v9.safetensors ready"+ );+ Ok(())+ }++ fn hex_sha256(bytes: &[u8]) -> String {+ use sha2::{Digest, Sha256};+ let mut hasher = Sha256::new();+ hasher.update(bytes);+ let digest = hasher.finalize();+ let mut s = String::with_capacity(64);+ for b in digest {+ use std::fmt::Write;+ let _ = write!(&mut s, "{b:02x}");+ }+ s+ }++ fn sha256_matches(path: &Path) -> Result<bool, RedactError> {+ let bytes = std::fs::read(path)+ .map_err(|e| RedactError::Runtime(format!("read {}: {e}", path.display())))?;+ Ok(Self::hex_sha256(&bytes) == Self::EXPECTED_SHA256)+ }}// ─── feature-on path: real implementation ─────────────────────────-#[cfg(all(feature = "mlx-mac", target_os = "macos"))]+#[cfg(all(feature = "mlx-mac", target_os = "macos", target_arch = "aarch64"))]mod imp {use super::*;use std::sync::Mutex;@@ -176,17 +275,17 @@ mod imp {}}-#[cfg(all(feature = "mlx-mac", target_os = "macos"))]+#[cfg(all(feature = "mlx-mac", target_os = "macos", target_arch = "aarch64"))]pub use imp::RfdetrMlxRedactor;// ─── feature-off path: stub ──────────────────────────────────────-#[cfg(not(all(feature = "mlx-mac", target_os = "macos")))]+#[cfg(not(all(feature = "mlx-mac", target_os = "macos", target_arch = "aarch64")))]pub struct RfdetrMlxRedactor {_cfg: RfdetrMlxConfig,}-#[cfg(not(all(feature = "mlx-mac", target_os = "macos")))]+#[cfg(not(all(feature = "mlx-mac", target_os = "macos", target_arch = "aarch64")))]impl RfdetrMlxRedactor {pub fn load(_cfg: RfdetrMlxConfig) -> Result<Self, RedactError> {Err(RedactError::Unavailable(@@ -195,7 +294,7 @@ impl RfdetrMlxRedactor {}}-#[cfg(not(all(feature = "mlx-mac", target_os = "macos")))]+#[cfg(not(all(feature = "mlx-mac", target_os = "macos", target_arch = "aarch64")))]#[async_trait]impl ImageRedactor for RfdetrMlxRedactor {fn name(&self) -> &str {