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(pi): plumb local api_auth_key to Pi so bash/curl to localhost:3030 auths
Louis Beaumont3041df4198a4
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsxindex c0d0f7da1..631487a8a 100644--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx@@ -169,6 +169,9 @@ TOOL SELECTION (use the right tool for the job):- "what was on screen", "what was I reading/looking at" → search with content_type: "all" or "accessibility"- Broad overview ("what was I doing?") → activity-summary FIRST. The windows field shows exactly what the user was working on (window titles, URLs, time per tab). Usually sufficient without further searches.+LOCAL SERVER AUTH:+The local screenpipe server (localhost:3030) requires a bearer token. It is exposed to you as the env var $SCREENPIPE_API_AUTH_KEY. EVERY curl against localhost:3030 MUST include `-H "Authorization: Bearer $SCREENPIPE_API_AUTH_KEY"`. Do NOT ask the user for an API key — you already have it. If a call returns 401, the env var may be empty (auth disabled on this install) — retry without the header.+CRITICAL SEARCH RULES (database has 600k+ entries):1. ALWAYS include start_time in EVERY search - NEVER search without a time range2. Default time range: last 1-2 hours. Expand ONLY if no results founddiff --git a/apps/screenpipe-app-tauri/src-tauri/src/server_core.rs b/apps/screenpipe-app-tauri/src-tauri/src/server_core.rsindex 78e3258b5..318282755 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/server_core.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/server_core.rs@@ -277,7 +277,10 @@ impl ServerCore {std::fs::create_dir_all(&pipes_dir).ok();let user_token = config.user_id.clone();- let pi_executor = Arc::new(screenpipe_core::agents::pi::PiExecutor::new(user_token));+ let pi_executor = Arc::new(+ screenpipe_core::agents::pi::PiExecutor::new(user_token)+ .with_api_auth_key(config.api_auth_key.clone()),+ );let mut agent_executors: std::collections::HashMap<String,Arc<dyn screenpipe_core::agents::AgentExecutor>,diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rsindex 8809766d2..2b5bd2a4b 100644--- a/crates/screenpipe-core/src/agents/pi.rs+++ b/crates/screenpipe-core/src/agents/pi.rs@@ -116,6 +116,10 @@ pub struct PiExecutor {pub user_token: Option<String>,/// Screenpipe API base URL (default: `https://api.screenpi.pe/v1`).pub api_url: String,+ /// Bearer token for the *local* screenpipe-server API (localhost:3030).+ /// Exposed to the Pi subprocess as `SCREENPIPE_API_AUTH_KEY` so bash tool+ /// calls against the local server can authenticate. None = auth disabled.+ pub api_auth_key: Option<String>,}impl PiExecutor {@@ -123,9 +127,17 @@ impl PiExecutor {Self {user_token,api_url: SCREENPIPE_API_URL.to_string(),+ api_auth_key: None,}}+ /// Attach the local server's api_auth_key so Pi's bash tool can include+ /// `Authorization: Bearer ...` on localhost:3030 calls.+ pub fn with_api_auth_key(mut self, key: Option<String>) -> Self {+ self.api_auth_key = key.filter(|k| !k.is_empty());+ self+ }+/// Ensure screenpipe skills exist in `project_dir/.pi/skills/`.pub fn ensure_screenpipe_skill(project_dir: &Path) -> Result<()> {let skills: &[(&str, &str)] = &[@@ -631,6 +643,12 @@ impl PiExecutor {}}+ // Local server bearer token — kept separate from cloud keys so it+ // flows even in offline mode (the local server is always localhost).+ if let Some(ref key) = self.api_auth_key {+ cmd.env("SCREENPIPE_API_AUTH_KEY", key);+ }+cmd.stdout(std::process::Stdio::piped());cmd.stderr(std::process::Stdio::piped());@@ -743,6 +761,11 @@ impl PiExecutor {}}+ // Local server bearer token — unaffected by offline mode.+ if let Some(ref key) = self.api_auth_key {+ cmd.env("SCREENPIPE_API_AUTH_KEY", key);+ }+cmd.stdout(std::process::Stdio::piped());cmd.stderr(std::process::Stdio::piped());