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): isolate Live View editor tools
Louis Beaumonta50449e96d18
diff --git a/apps/screenpipe-app-tauri/lib/live-views/generate-live-view-with-pi.ts b/apps/screenpipe-app-tauri/lib/live-views/generate-live-view-with-pi.tsindex 304a40086..0861cb447 100644--- a/apps/screenpipe-app-tauri/lib/live-views/generate-live-view-with-pi.ts+++ b/apps/screenpipe-app-tauri/lib/live-views/generate-live-view-with-pi.ts@@ -348,6 +348,10 @@ function providerConfig(preset: AIPreset): PiProviderConfig {? { maxContextChars: preset.maxContextChars }: {}),systemPrompt: null,+ // This foreground editor only needs a read of the referenced Live View.+ // Restrict the runtime itself so normal Chat, MCP, web, filesystem, and+ // artifact tools are never advertised on this private editing surface.+ allowedTools: ["screenpipe_live_view"],};}diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.tsindex 1e7ddc4c1..236fcaecc 100644--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts@@ -3119,7 +3119,12 @@ maxContextChars?: number | null;/*** Optional system prompt from AI preset (appended to Pi's built-in system prompt)*/-systemPrompt?: string | null }+systemPrompt?: string | null;+/**+ * Optional exact Pi tool allowlist for bounded agent surfaces. `None`+ * preserves the normal Chat tool surface; an empty list disables tools.+ */+allowedTools?: string[] | null }/*** A user prompt that's been enqueued but not yet written to Pi's stdin.* Surfaced to the UI so the chat can render "queued" cards while a priordiff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rsindex f41d6cb31..657fca42a 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs@@ -1600,6 +1600,10 @@ pub struct PiProviderConfig {/// Optional system prompt from AI preset (appended to Pi's built-in system prompt)#[serde(default)]pub system_prompt: Option<String>,+ /// Optional exact Pi tool allowlist for bounded agent surfaces. `None`+ /// preserves the normal Chat tool surface; an empty list disables tools.+ #[serde(default)]+ pub allowed_tools: Option<Vec<String>>,}fn default_max_tokens() -> i32 {@@ -1657,6 +1661,23 @@ fn pi_launch_fingerprint(hasher.finish()}+fn apply_pi_tool_allowlist(command: &mut Command, provider_config: Option<&PiProviderConfig>) {+ let Some(allowed_tools) = provider_config.and_then(|config| config.allowed_tools.as_ref())+ else {+ return;+ };+ let allowed_tools = allowed_tools+ .iter()+ .map(|tool| tool.trim())+ .filter(|tool| !tool.is_empty())+ .collect::<Vec<_>>();+ if allowed_tools.is_empty() {+ command.arg("--no-tools");+ } else {+ command.arg("--tools").arg(allowed_tools.join(","));+ }+}+fn model_supports_reasoning(provider: &str, model: &str) -> bool {let model = model.to_ascii_lowercase();match provider {@@ -2434,6 +2455,7 @@ pub async fn pi_start_inner();apply_pi_extension_safe_mode(&mut command, &project_dir);}+ apply_pi_tool_allowlist(&mut command, provider_config.as_ref());command};@@ -4685,6 +4707,7 @@ mod tests {max_tokens: 4096,max_context_chars: Some(512_000),system_prompt: Some("system context".to_string()),+ allowed_tools: None,};let first = super::pi_launch_fingerprint("/tmp/pi-chat", Some("token"), Some(&config));let duplicate = super::pi_launch_fingerprint("/tmp/pi-chat", Some("token"), Some(&config));@@ -5897,6 +5920,7 @@ error: InstallFailed extracting tarball"#;max_tokens: 4096,max_context_chars: Some(512_000),system_prompt: None,+ allowed_tools: None,}}@@ -6030,6 +6054,34 @@ error: InstallFailed extracting tarball"#;assert!(!args.iter().any(|arg| arg.ends_with("third-party.ts")));}+ #[test]+ fn test_tool_allowlist_restricts_bounded_pi_sessions() {+ let mut config = make_provider_config("screenpipe-cloud", "auto");+ config.allowed_tools = Some(vec!["screenpipe_live_view".to_string()]);+ let mut command = Command::new("pi");+ super::apply_pi_tool_allowlist(&mut command, Some(&config));+ let args = command+ .get_args()+ .map(|arg| arg.to_string_lossy().into_owned())+ .collect::<Vec<_>>();++ assert_eq!(args, vec!["--tools", "screenpipe_live_view"]);+ }++ #[test]+ fn test_empty_tool_allowlist_disables_all_pi_tools() {+ let mut config = make_provider_config("screenpipe-cloud", "auto");+ config.allowed_tools = Some(vec![]);+ let mut command = Command::new("pi");+ super::apply_pi_tool_allowlist(&mut command, Some(&config));+ let args = command+ .get_args()+ .map(|arg| arg.to_string_lossy().into_owned())+ .collect::<Vec<_>>();++ assert_eq!(args, vec!["--no-tools"]);+ }+#[tokio::test]async fn test_build_models_json_api_keys_use_env_var_syntax() {// Regression: pi >= 0.80 sends bare apiKey strings to the provider as