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(windows): keep post-update pi repair hidden (#6061)
Ezra Ellette83cb542bde45
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rsindex c5cf75d17..6fc11b291 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs@@ -55,6 +55,8 @@ const TITLE_SESSION_PREFIX: &str = "__title:";const REQUIRED_PI_EXTENSION_PACKAGE: &str = "npm:pi-subagents";const CONVERSATION_HISTORY_OPEN: &str = "<conversation_history>";const CONVERSATION_HISTORY_CLOSE: &str = "</conversation_history>";+const PI_INSTALL_ARGS: [&str; 2] = ["install", "--ignore-scripts"];+const NPM_INSTALL_ARGS: [&str; 4] = ["install", "--ignore-scripts", "--no-audit", "--no-fund"];#[derive(Clone, Copy, Debug, Eq, PartialEq)]enum PiConversationSyncState {@@ -1284,7 +1286,8 @@ fn npm_install_command(install_dir: &Path) -> Command {#[cfg(windows)]{let mut cmd = Command::new("cmd.exe");- cmd.args(["/C", "npm", "install", "--no-audit", "--no-fund"])+ cmd.args(["/C", "npm"])+ .args(NPM_INSTALL_ARGS).current_dir(install_dir);cmd}@@ -1292,8 +1295,7 @@ fn npm_install_command(install_dir: &Path) -> Command {#[cfg(not(windows))]{let mut cmd = Command::new("npm");- cmd.args(["install", "--no-audit", "--no-fund"])- .current_dir(install_dir);+ cmd.args(NPM_INSTALL_ARGS).current_dir(install_dir);cmd}}@@ -1383,8 +1385,9 @@ fn run_pi_package_install_once(install_dir: &Path, bun: &str) -> Result<(), Stri// from the log alone; a bun that can't even execute (e.g. SIGILL on an// unsupported CPU) shows up right here as the version probe failing.info!(- "Running Pi dependency install: {} install (cwd: {}, bun version: {})",+ "Running Pi dependency install: {} {} (cwd: {}, bun version: {})",bun,+ PI_INSTALL_ARGS.join(" "),install_dir.display(),screenpipe_core::agents::pi::bun_version_string(bun),);@@ -1393,7 +1396,10 @@ fn run_pi_package_install_once(install_dir: &Path, bun: &str) -> Result<(), Stribun_cmd.current_dir(install_dir).env("BUN_INSTALL_CACHE_DIR", &cache_dir)- .args(["install"]);+ // CREATE_NO_WINDOW only applies to this Bun process. Lifecycle scripts+ // can launch fresh console processes, so disable them for ScreenPipe's+ // app-managed dependency set as well.+ .args(PI_INSTALL_ARGS);match run_command_output(bun_cmd) {Ok(output) if output.status.success() => verify_pi_package_install(install_dir),@@ -5426,6 +5432,12 @@ mod tests {const REPLAYED_HISTORY: &str ="<conversation_history>\nuser: hello\nassistant: hi\n</conversation_history>\n\nwhat next?";+ #[test]+ fn managed_pi_installs_disable_dependency_lifecycle_scripts() {+ assert!(super::PI_INSTALL_ARGS.contains(&"--ignore-scripts"));+ assert!(super::NPM_INSTALL_ARGS.contains(&"--ignore-scripts"));+ }+#[test]fn prepares_prompt_for_pi_conversation_state() {use super::PiConversationSyncState::{NeedsRecovery, Synced};diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rsindex dc86d012b..ff9b3d07e 100644--- a/crates/screenpipe-core/src/agents/pi.rs+++ b/crates/screenpipe-core/src/agents/pi.rs@@ -20,6 +20,13 @@ pub const PI_PACKAGE: &str = "@earendil-works/[email protected]";pub const PI_AI_PACKAGE: &str = "@earendil-works/[email protected]";pub const PI_NAMESPACE_DIR: &str = "@earendil-works";pub const SCREENPIPE_API_URL: &str = "https://api.screenpipe.com/v1";+const PI_INSTALL_ARGS: [&str; 5] = [+ "add",+ "--ignore-scripts",+ PI_PACKAGE,+ PI_AI_PACKAGE,+ "@anthropic-ai/sdk",+];const CUSTOM_PROVIDER_USER_AGENT: &str = "screenpipe";const DEFAULT_CLOUD_MAX_OUTPUT_TOKENS: u64 = 32_000;@@ -2246,20 +2253,21 @@ impl AgentExecutor for PiExecutor {// Log the exact command + bun version up front so a failed install is// reproducible from the log alone (and a bun that can't even run —// e.g. SIGILL on an unsupported CPU — is exposed before the install).- let args = ["add", PI_PACKAGE, PI_AI_PACKAGE, "@anthropic-ai/sdk"];info!("installing pi into {} via bun at {} (version: {}); command: bun {}",install_dir.display(),bun,bun_version_string(&bun),- args.join(" "),+ PI_INSTALL_ARGS.join(" "),);// Seed package.json with overrides to fix lru-cache resolution on Windowsseed_pi_package_json(&install_dir);let mut cmd = tokio_bun_command(&bun);- cmd.current_dir(&install_dir).args(args);+ // CREATE_NO_WINDOW only covers this Bun process. Lifecycle scripts can+ // launch new consoles, so disable them for this pinned managed install.+ cmd.current_dir(&install_dir).args(PI_INSTALL_ARGS);#[cfg(windows)]{@@ -3854,6 +3862,11 @@ pub fn ensure_bash_available() -> Option<String> {mod tests {use super::*;+ #[test]+ fn managed_pi_install_disables_dependency_lifecycle_scripts() {+ assert!(PI_INSTALL_ARGS.contains(&"--ignore-scripts"));+ }+#[test]fn tool_use_without_an_executable_call_is_a_protocol_error() {let malformed = json!({