Skip to content

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

release-app got rid of the f* swift stuff

Louis Beaumontb78abc016f92
diff --git a/.github/workflows/release-app.yml b/.github/workflows/release-app.yml
index 95564755b..23be82935 100644
--- a/.github/workflows/release-app.yml
+++ b/.github/workflows/release-app.yml
@@ -351,7 +351,6 @@ jobs:
if [[ "${{ matrix.platform }}" == "macos-latest" ]]; then
export PKG_CONFIG_PATH="/usr/local/opt/ffmpeg/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_ALLOW_CROSS=1
- export RUSTFLAGS="-C link-arg=-Wl,-rpath,@executable_path/../Frameworks -C link-arg=-Wl,-rpath,@loader_path/../Frameworks -C link-arg=-Wl,-install_name,@rpath/libscreenpipe.dylib"
fi
cargo build --release -p screenpipe-server ${{ matrix.args }}
diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml
index b3d5c180a..1ea922989 100644
--- a/.github/workflows/release-cli.yml
+++ b/.github/workflows/release-cli.yml
@@ -80,17 +80,7 @@ jobs:
- name: Create deployment package
run: |
mkdir -p screenpipe-${{ env.VERSION }}-${{ matrix.target }}/bin
- mkdir -p screenpipe-${{ env.VERSION }}-${{ matrix.target }}/lib
cp target/${{ matrix.target }}/release/screenpipe screenpipe-${{ env.VERSION }}-${{ matrix.target }}/bin/
- cp screenpipe-vision/lib/libscreenpipe.dylib screenpipe-${{ env.VERSION }}-${{ matrix.target }}/lib/libscreenpipe.dylib
- if [ "${{ matrix.target }}" = "x86_64-apple-darwin" ]; then
- cp screenpipe-vision/lib/libscreenpipe_x86_64.dylib screenpipe-${{ env.VERSION }}-${{ matrix.target }}/lib/libscreenpipe_x86_64.dylib
- elif [ "${{ matrix.target }}" = "aarch64-apple-darwin" ]; then
- cp screenpipe-vision/lib/libscreenpipe_arm64.dylib screenpipe-${{ env.VERSION }}-${{ matrix.target }}/lib/libscreenpipe_arm64.dylib
- else
- echo "Unknown target: ${{ matrix.target }}"
- exit 1
- fi
tar -czf screenpipe-${{ env.VERSION }}-${{ matrix.target }}.tar.gz -C screenpipe-${{ env.VERSION }}-${{ matrix.target }} .
- name: Calculate SHA256
diff --git a/.gitignore b/.gitignore
index a983444a5..dc5c8d335 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,9 +26,6 @@ text_json/
src-tauri/deno-*
-# Unignore
-!screenpipe-vision/lib/libscreenpipe*.dylib
-
# Tauri signing key
tauri_key_louis.key
pnpm-lock.yaml
diff --git a/install.sh b/install.sh
index 728718073..b880fccdc 100755
--- a/install.sh
+++ b/install.sh
@@ -228,24 +228,6 @@ if ! mkdir -p "$INSTALL_DIR/screenpipe-vision/lib"; then
exit 1
fi
-# Download and install libraries for macOS
-if [ "$(uname)" = "Darwin" ]; then
- echo "downloading required libraries..."
-
- if [ "$arch" = "aarch64" ]; then
- LIB_URL="https://raw.githubusercontent.com/mediar-ai/screenpipe/main/screenpipe-vision/lib/libscreenpipe_arm64.dylib"
- if ! curl -sL "$LIB_URL" -o "$INSTALL_DIR/screenpipe-vision/lib/libscreenpipe_arm64.dylib"; then
- echo "Failed to download arm64 library"
- exit 1
- fi
- elif [ "$arch" = "x86_64" ]; then
- LIB_URL="https://raw.githubusercontent.com/mediar-ai/screenpipe/main/screenpipe-vision/lib/libscreenpipe_x86_64.dylib"
- if ! curl -sL "$LIB_URL" -o "$INSTALL_DIR/screenpipe-vision/lib/libscreenpipe_x86_64.dylib"; then
- echo "Failed to download x86_64 library"
- exit 1
- fi
- fi
-fi
# Copy binary
if ! cp bin/screenpipe "$INSTALL_DIR/"; then
@@ -253,27 +235,6 @@ if ! cp bin/screenpipe "$INSTALL_DIR/"; then
exit 1
fi
-# Fix binary linking on macOS
-if [ "$(uname)" = "Darwin" ]; then
- echo "fixing binary linking..."
- cd "$INSTALL_DIR" || exit 1
-
- # Remove any existing rpaths
- install_name_tool -delete_rpath "@executable_path/screenpipe-vision/lib" "./screenpipe" 2>/dev/null || true
-
- # Add new rpath
- install_name_tool -add_rpath "@executable_path/screenpipe-vision/lib" "./screenpipe"
-
- # Change the library path in the binary
- if [ "$arch" = "aarch64" ]; then
- install_name_tool -change "screenpipe-vision/lib/libscreenpipe_arm64.dylib" "@rpath/libscreenpipe_arm64.dylib" "./screenpipe"
- install_name_tool -id "@rpath/libscreenpipe_arm64.dylib" "$INSTALL_DIR/screenpipe-vision/lib/libscreenpipe_arm64.dylib"
- elif [ "$arch" = "x86_64" ]; then
- install_name_tool -change "screenpipe-vision/lib/libscreenpipe_x86_64.dylib" "@rpath/libscreenpipe_x86_64.dylib" "./screenpipe"
- install_name_tool -id "@rpath/libscreenpipe_x86_64.dylib" "$INSTALL_DIR/screenpipe-vision/lib/libscreenpipe_x86_64.dylib"
- fi
-fi
-
# Remove quarantine attributes on macOS
if [ "$(uname)" = "Darwin" ]; then
echo "removing quarantine attributes..."
diff --git a/screenpipe-app-tauri/scripts/pre_build.js b/screenpipe-app-tauri/scripts/pre_build.js
index f32789ba7..9ca61b8d7 100644
--- a/screenpipe-app-tauri/scripts/pre_build.js
+++ b/screenpipe-app-tauri/scripts/pre_build.js
@@ -328,21 +328,6 @@ if (platform == 'macos') {
} else {
console.error("No suitable arm64 screenpipe binary found");
}
- try {
- // if the binary exists, hard code the fucking dylib
- if (await fs.exists('screenpipe-aarch64-apple-darwin') && !isDevMode) {
- await $`install_name_tool -change screenpipe-vision/lib/libscreenpipe_arm64.dylib @rpath/../Frameworks/libscreenpipe_arm64.dylib ./screenpipe-aarch64-apple-darwin`
- await $`install_name_tool -change screenpipe-vision/lib/libscreenpipe.dylib @rpath/../Frameworks/libscreenpipe.dylib ./screenpipe-aarch64-apple-darwin`
- console.log(`hard coded the dylib`);
- } else if (await fs.exists('screenpipe-aarch64-apple-darwin') && isDevMode) {
- await $`install_name_tool -change screenpipe-vision/lib/libscreenpipe_arm64.dylib @executable_path/../Frameworks/libscreenpipe_arm64.dylib ./screenpipe-aarch64-apple-darwin`
- await $`install_name_tool -change screenpipe-vision/lib/libscreenpipe.dylib @executable_path/../Frameworks/libscreenpipe.dylib ./screenpipe-aarch64-apple-darwin`
- await $`install_name_tool -add_rpath @executable_path/../Frameworks ./screenpipe-aarch64-apple-darwin`
- console.log(`Updated dylib paths for arm64 in dev mode`);
- }
- } catch (error) {
- console.error('Error updating dylib paths:', error);
- }
} else if (arch === 'x86_64') {
// copy screenpipe binary (more recent one)
const paths = [
@@ -356,16 +341,6 @@ if (platform == 'macos') {
} else {
console.error("No suitable x86_64 screenpipe binary found");
}
- try {
- // hard code the dylib
- if (await fs.exists('screenpipe-x86_64-apple-darwin') && !isDevMode) {
- await $`install_name_tool -change screenpipe-vision/lib/libscreenpipe_x86_64.dylib @rpath/../Frameworks/libscreenpipe_x86_64.dylib ./screenpipe-x86_64-apple-darwin`
- await $`install_name_tool -change screenpipe-vision/lib/libscreenpipe.dylib @rpath/../Frameworks/libscreenpipe.dylib ./screenpipe-x86_64-apple-darwin`
- console.log(`hard coded the dylib`);
- }
- } catch (error) {
- console.error('Error updating dylib paths:', error);
- }
}
console.log(`screenpipe for ${arch} set up successfully.`);
}
@@ -380,14 +355,6 @@ if (platform == 'macos') {
console.log('FFMPEG already exists');
}
- // // Move and rename ffmpeg and ffprobe binaries
- // const ffmpegSrc = path.join(cwd, config.ffmpegRealname, 'bin', 'ffmpeg');
-
- // // For x86_64
- // await fs.copyFile(ffmpegSrc, path.join(cwd, 'ffmpeg-x86_64-apple-darwin'));
-
- // // For arm64
- // await fs.copyFile(ffmpegSrc, path.join(cwd, 'ffmpeg-aarch64-apple-darwin'));
console.log('Moved and renamed ffmpeg binary for externalBin');
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index a10b93d86..671ea99f0 100644
--- a/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "0.19.0"
+version = "0.19.1"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/build.rs b/screenpipe-app-tauri/src-tauri/build.rs
index a30499e28..b57caaa4f 100644
--- a/screenpipe-app-tauri/src-tauri/build.rs
+++ b/screenpipe-app-tauri/src-tauri/build.rs
@@ -1,77 +1,5 @@
-// #[cfg(target_os = "macos")]
-// use std::{env, fs, process::Command};
fn main() {
- // #[cfg(target_arch = "x86_64")]
- // {
- // let primary_path = "../../target/x86_64-apple-darwin/release/screenpipe";
- // let fallback_path = "../../target/release/screenpipe";
-
- // let source_path = if fs::metadata(primary_path).is_ok() {
- // primary_path
- // } else {
- // fallback_path
- // };
-
- // fs::copy(source_path, "screenpipe-x86_64-apple-darwin")
- // .expect("failed to copy screenpipe binary");
-
- // if env::var("PROFILE").unwrap() != "debug" {
- // Command::new("install_name_tool")
- // .args([
- // "-change",
- // "../../screenpipe-vision/lib/libscreenpipe_x86_64.dylib",
- // "@executable_path/../Frameworks/libscreenpipe_x86_64.dylib",
- // "./screenpipe-x86_64-apple-darwin",
- // ])
- // .status()
- // .expect("failed to execute process");
- // Command::new("install_name_tool")
- // .args([
- // "-change",
- // "../../screenpipe-vision/lib/libscreenpipe.dylib",
- // "@executable_path/../Frameworks/libscreenpipe.dylib",
- // "./screenpipe-x86_64-apple-darwin",
- // ])
- // .status()
- // .expect("failed to execute process");
- // }
- // }
- // #[cfg(target_arch = "aarch64")]
- // if env::var("TARGET").unwrap() == "aarch64-apple-darwin" {
- // let primary_path = "../../target/aarch64-apple-darwin/release/screenpipe";
- // let fallback_path = "../../target/release/screenpipe";
-
- // let source_path = if fs::metadata(primary_path).is_ok() {
- // primary_path
- // } else {
- // fallback_path
- // };
-
- // fs::copy(source_path, "screenpipe-aarch64-apple-darwin")
- // .expect("failed to copy screenpipe binary");
-
- // if env::var("PROFILE").unwrap() != "debug" {
- // Command::new("install_name_tool")
- // .args([
- // "-change",
- // "../../screenpipe-vision/lib/libscreenpipe_arm64.dylib",
- // "@executable_path/../Frameworks/libscreenpipe_arm64.dylib",
- // "./screenpipe-aarch64-apple-darwin",
- // ])
- // .status()
- // .expect("failed to execute process");
- // Command::new("install_name_tool")
- // .args([
- // "-change",
- // "../../screenpipe-vision/lib/libscreenpipe.dylib",
- // "@executable_path/../Frameworks/libscreenpipe.dylib",
- // "./screenpipe-aarch64-apple-darwin",
- // ])
- // .status()
- // .expect("failed to execute process");
- // }
- // }
#[cfg(target_os = "macos")]
println!("cargo:rustc-link-lib=framework=AVFoundation");
tauri_build::build()
diff --git a/screenpipe-app-tauri/src-tauri/tauri.macos.conf.json b/screenpipe-app-tauri/src-tauri/tauri.macos.conf.json
index f3366af93..bcaceee36 100644
--- a/screenpipe-app-tauri/src-tauri/tauri.macos.conf.json
+++ b/screenpipe-app-tauri/src-tauri/tauri.macos.conf.json
@@ -1,11 +1,6 @@
{
"bundle": {
"macOS": {
- "frameworks": [
- "../../screenpipe-vision/lib/libscreenpipe.dylib",
- "../../screenpipe-vision/lib/libscreenpipe_x86_64.dylib",
- "../../screenpipe-vision/lib/libscreenpipe_arm64.dylib"
- ],
"entitlements": "entitlements.plist",
"hardenedRuntime": true,
"exceptionDomain": "screenpi.pe",
@@ -21,4 +16,4 @@
"ui_monitor"
]
}
-}
\ No newline at end of file
+}
diff --git a/screenpipe-vision/bin/ui_monitor-aarch64-apple-darwin b/screenpipe-vision/bin/ui_monitor-aarch64-apple-darwin
index 6eb0da298..1546bce73 100755
Binary files a/screenpipe-vision/bin/ui_monitor-aarch64-apple-darwin and b/screenpipe-vision/bin/ui_monitor-aarch64-apple-darwin differ
diff --git a/screenpipe-vision/build.rs b/screenpipe-vision/build.rs
index 15d4063d2..815594d99 100644
--- a/screenpipe-vision/build.rs
+++ b/screenpipe-vision/build.rs
@@ -1,50 +1,9 @@
#[cfg(target_os = "macos")]
use std::{env, process::Command, path::PathBuf};
-#[cfg(target_os = "macos")]
-fn compile_swift_library() {
- let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
- let lib_path = PathBuf::from(&manifest_dir).join("lib");
-
- // Create lib directory if it doesn't exist
- std::fs::create_dir_all(&lib_path).expect("failed to create lib directory");
-
- // Compile for both architectures
- let status = Command::new("swiftc")
- .args(&[
- "-emit-library",
- "-target", if cfg!(target_arch = "aarch64") {
- "arm64-apple-macosx11.0"
- } else {
- "x86_64-apple-macosx11.0"
- },
- "-o", lib_path.join(if cfg!(target_arch = "aarch64") {
- "libscreenpipe_arm64.dylib"
- } else {
- "libscreenpipe_x86_64.dylib"
- }).to_str().unwrap(),
- "src/ocr.swift",
- "-framework", "Metal",
- "-framework", "MetalPerformanceShaders",
- "-framework", "Vision",
- "-framework", "CoreImage",
- ])
- .status()
- .expect("failed to compile Swift library");
-
- if !status.success() {
- panic!("failed to compile Swift library");
- }
-
- // Tell cargo to link the library
- println!("cargo:rustc-link-search=native={}", lib_path.display());
- println!("cargo:rustc-link-lib=dylib=screenpipe");
-}
-
fn main() {
#[cfg(target_os = "macos")]
{
- compile_swift_library();
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
let bin_path = PathBuf::from(&manifest_dir).join("bin");
diff --git a/screenpipe-vision/lib/libscreenpipe.dylib b/screenpipe-vision/lib/libscreenpipe.dylib
deleted file mode 100755
index 6cb0b1798..000000000
Binary files a/screenpipe-vision/lib/libscreenpipe.dylib and /dev/null differ
diff --git a/screenpipe-vision/lib/libscreenpipe_arm64.dylib b/screenpipe-vision/lib/libscreenpipe_arm64.dylib
deleted file mode 100755
index abd2e1192..000000000
Binary files a/screenpipe-vision/lib/libscreenpipe_arm64.dylib and /dev/null differ
diff --git a/screenpipe-vision/lib/libscreenpipe_x86_64.dylib b/screenpipe-vision/lib/libscreenpipe_x86_64.dylib
deleted file mode 100755
index cd6138741..000000000
Binary files a/screenpipe-vision/lib/libscreenpipe_x86_64.dylib and /dev/null differ
diff --git a/screenpipe-vision/src/ocr.swift b/screenpipe-vision/src/ocr.swift
deleted file mode 100644
index 6b4816d51..000000000
--- a/screenpipe-vision/src/ocr.swift
+++ /dev/null
@@ -1,170 +0,0 @@
-import CoreGraphics
-import CoreImage
-import Foundation
-import Vision
-
-extension String {
- /// Create UnsafeMutableBufferPointer holding a null-terminated UTF8 copy of the string
- public func unsafeUTF8Copy() -> UnsafeMutableBufferPointer<CChar> { self.utf8CString.unsafeCopy() }
-}
-
-extension Collection {
- /// Creates an UnsafeMutableBufferPointer with enough space to hold the elements of self.
- public func unsafeCopy() -> UnsafeMutableBufferPointer<Self.Element> {
- let copy = UnsafeMutableBufferPointer<Self.Element>.allocate(capacity: self.underestimatedCount)
- _ = copy.initialize(from: self)
- return copy
- }
-}
-
-// TODO: how can we use Metal to speed this up?
-
-@available(macOS 10.15, *)
-@_cdecl("perform_ocr")
-public func performOCR(imageData: UnsafePointer<UInt8>, length: Int, width: Int, height: Int, languages: UnsafePointer<UnsafePointer<CChar>?>, languagesCount: Int)
- -> UnsafeMutablePointer<CChar>? {
- return autoreleasepool {
-
- guard let dataProvider = CGDataProvider(data: Data(bytes: imageData, count: length) as CFData),
- let cgImage = CGImage(
- width: width,
- height: height,
- bitsPerComponent: 8,
- bitsPerPixel: 32,
- bytesPerRow: width * 4,
- space: CGColorSpaceCreateDeviceRGB(),
- bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.premultipliedLast.rawValue),
- provider: dataProvider,
- decode: nil,
- shouldInterpolate: false,
- intent: .defaultIntent
- )
- else {
- return strdup("Error: Failed to create CGImage")
- }
-
- // Preprocess the image
- let ciImage = CIImage(cgImage: cgImage)
- let context = CIContext(options: nil)
-
- guard let preprocessedCGImage = context.createCGImage(ciImage, from: ciImage.extent) else {
- return strdup("Error: Failed to create preprocessed image")
- }
-
- var ocrResult = ""
- var textElements: [[String: Any]] = []
- var totalConfidence: Float = 0.0
- var observationCount: Int = 0
-
- let textRequest = VNRecognizeTextRequest { request, error in
- if let error = error {
- print("Error: \(error.localizedDescription)")
- return
- }
-
- guard let observations = request.results as? [VNRecognizedTextObservation] else {
- print("Error: Failed to process image or no text found")
- return
- }
-
- for observation in observations {
- guard let topCandidate = observation.topCandidates(1).first else {
- continue
- }
- let text = topCandidate.string
- let confidence = topCandidate.confidence
-
- // Reduced threshold for including results
- if confidence < 0.2 {
- continue // Skip very low-confidence results
- }
- let boundingBox = observation.boundingBox
- textElements.append([
- "text": text,
- "confidence": confidence,
- "boundingBox": [
- "x": boundingBox.origin.x,
- "y": boundingBox.origin.y,
- "width": boundingBox.size.width,
- "height": boundingBox.size.height
- ]
- ])
-
- ocrResult += "\(text)\n"
- totalConfidence += confidence
- observationCount += 1
- }
- }
-
- // Convert C string array to Swift string array
- var recognitionLanguages: [String] = []
- for i in 0..<languagesCount {
- if let langCString = languages[i] {
- if let langString = String(cString: langCString, encoding: .utf8) {
- recognitionLanguages.append(langString)
- }
- }
- }
-
- // If no languages are provided, use a default set
- if recognitionLanguages.isEmpty {
- recognitionLanguages = ["zh-Hans", "zh-Hant", "en-US"]
- }
-
- textRequest.recognitionLanguages = recognitionLanguages
- textRequest.recognitionLevel = .accurate
- textRequest.usesLanguageCorrection = true
-
- let handler = VNImageRequestHandler(cgImage: preprocessedCGImage, options: [:])
- do {
- try handler.perform([textRequest])
- } catch {
- print("Error: Failed to perform OCR - \(error.localizedDescription)")
- }
-
- let overallConfidence = observationCount > 0 ? totalConfidence / Float(observationCount) : 0.0
- // print("Overall confidence: \(overallConfidence)")
- let result: [String: Any] = [
- "ocrResult": ocrResult.isEmpty ? NSNull() : ocrResult,
- "textElements": textElements,
- "overallConfidence": overallConfidence
- ]
-
- if let jsonData = try? JSONSerialization.data(withJSONObject: result, options: []),
- let jsonString = String(data: jsonData, encoding: .utf8) {
- let cString = jsonString.cString(using: .utf8)
- let buffer = UnsafeMutablePointer<Int8>.allocate(capacity: cString!.count)
- buffer.initialize(from: cString!, count: cString!.count)
- return buffer
- } else {
- let errorString = "Error: Failed to serialize result to JSON"
- let cString = errorString.cString(using: .utf8)!
- let buffer = UnsafeMutablePointer<Int8>.allocate(capacity: cString.count)
- buffer.initialize(from: cString, count: cString.count)
- return buffer
- }
- }
-}
-
-@_cdecl("free_string")
-public func freeString(_ ptr: UnsafeMutablePointer<Int8>?) {
- if let ptr = ptr {
- ptr.deallocate()
- }
-}
-
-/*
-Compile for multi arch:
-
-swiftc -emit-library -target x86_64-apple-macosx11.0 -o screenpipe-vision/lib/libscreenpipe_x86_64.dylib screenpipe-vision/src/ocr.swift -framework Metal -framework MetalPerformanceShaders -framework Vision -framework CoreImage \
-&& swiftc -emit-library -target arm64-apple-macosx11.0 -o screenpipe-vision/lib/libscreenpipe_arm64.dylib screenpipe-vision/src/ocr.swift -framework Metal -framework MetalPerformanceShaders -framework Vision -framework CoreImage \
-&& lipo -create screenpipe-vision/lib/libscreenpipe_x86_64.dylib screenpipe-vision/lib/libscreenpipe_arm64.dylib -output screenpipe-vision/lib/libscreenpipe.dylib
-
-atm dirty hack: cp screenpipe-vision/lib* /usr/local/lib
-
-How to optimise this code:
-
-1. run cargo bench --bench ocr_benchmark
-2. change the code & compile again
-3. run cargo bench --bench ocr_benchmark again to see if it's faster or more accurate
-*/