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 model validation no longer blocks gateway-supported models
Louis Beaumontf0866494194e
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rsindex 52cb4f4ce..478385552 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs@@ -890,30 +890,21 @@ fn kill_orphan_pi_processes(managed_alive: bool) {/// Keep this short — the process is ready as soon as it starts the readline loop.const PI_READY_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(2);-/// Resolve a model name against the screenpipe cloud models list.-/// Handles mismatches like "claude-haiku-4-5@20251001" when the list only has-/// "claude-haiku-4-5" (or vice versa) by stripping date suffixes and finding-/// the closest match by shared prefix.+/// Resolve a model name for the screenpipe provider.+///+/// The gateway (api.screenpi.pe) is the source of truth for model validation+/// and supports many more models than the local hardcoded list (OpenRouter,+/// Gemini, Anthropic, etc.). We only do lightweight normalization here+/// (strip date suffixes) and pass through to the gateway which will reject+/// unknown models with a proper error.fn resolve_screenpipe_model(requested: &str, provider: &str) -> String {- // Only resolve for screenpipe provider — other providers use their own model names+ // Only touch screenpipe provider — other providers use their own model namesif provider != "screenpipe" {return requested.to_string();}- let models = screenpipe_cloud_models();- let model_ids: Vec<&str> = models- .as_array()- .map(|arr| arr.iter().filter_map(|m| m["id"].as_str()).collect())- .unwrap_or_default();-- // Exact match — no resolution needed- if model_ids.contains(&requested) {- return requested.to_string();- }-- // Strip date suffix (@20251001 or -20251001) and try again+ // Strip date suffix (@20251001 or -20251001) for cleaner model IDslet base = requested.split('@').next().unwrap_or(requested);- // Also strip trailing -YYYYMMDD patternlet base = if base.len() > 9 && base.as_bytes()[base.len() - 9] == b'-' {let suffix = &base[base.len() - 8..];if suffix.chars().all(|c| c.is_ascii_digit()) {@@ -925,33 +916,14 @@ fn resolve_screenpipe_model(requested: &str, provider: &str) -> String {base};- // Find the best match: exact base match first, then longest shared prefix- if let Some(exact) = model_ids.iter().find(|id| {- let id_base = id.split('@').next().unwrap_or(id);- id_base == base- }) {+ if base != requested {info!("resolved model '{}' -> '{}' (stripped date suffix)",- requested, exact+ requested, base);- return exact.to_string();}- // Fallback: find model whose id starts with the same base- if let Some(prefix_match) = model_ids.iter().find(|id| id.starts_with(base)) {- info!(- "resolved model '{}' -> '{}' (prefix match)",- requested, prefix_match- );- return prefix_match.to_string();- }-- // No match found — return as-is and let Pi report the error- warn!(- "could not resolve model '{}' against available models: {:?}",- requested, model_ids- );- requested.to_string()+ base.to_string()}/// Maximum number of concurrent Pi sessions before evicting old ones.diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rsindex f65ecf5cd..b42d14c08 100644--- a/crates/screenpipe-core/src/agents/pi.rs+++ b/crates/screenpipe-core/src/agents/pi.rs@@ -19,62 +19,28 @@ pub const SCREENPIPE_API_URL: &str = "https://api.screenpi.pe/v1";/// Returns the screenpipe cloud models array as a serde_json::Value./// Shared between server-side pipe executor and desktop Pi chat so the/// model list stays in sync.+/// Full model catalog matching the Cloudflare Worker gateway.+/// Must stay in sync with packages/ai-gateway/src/handlers/models.ts.pub fn screenpipe_cloud_models() -> serde_json::Value {json!([- {- "id": "claude-opus-4-6",- "name": "Claude Opus 4.6",- "reasoning": true,- "input": ["text", "image"],- "cost": {"input": 15, "output": 75, "cacheRead": 1.5, "cacheWrite": 18.75},- "contextWindow": 200000,- "maxTokens": 32000- },- {- "id": "claude-sonnet-4-5",- "name": "Claude Sonnet 4.5",- "reasoning": true,- "input": ["text", "image"],- "cost": {"input": 3, "output": 15, "cacheRead": 0.3, "cacheWrite": 3.75},- "contextWindow": 200000,- "maxTokens": 64000- },- {- "id": "claude-opus-4-5@20251101",- "name": "Claude Opus 4.5",- "reasoning": true,- "input": ["text", "image"],- "cost": {"input": 15, "output": 75, "cacheRead": 1.5, "cacheWrite": 18.75},- "contextWindow": 200000,- "maxTokens": 32000- },- {- "id": "claude-haiku-4-5",- "name": "Claude Haiku 4.5",- "reasoning": true,- "input": ["text", "image"],- "cost": {"input": 0.8, "output": 4, "cacheRead": 0.08, "cacheWrite": 1},- "contextWindow": 200000,- "maxTokens": 64000- },- {- "id": "gemini-3-flash",- "name": "Gemini 3 Flash",- "reasoning": false,- "input": ["text", "image"],- "cost": {"input": 0.10, "output": 0.40, "cacheRead": 0, "cacheWrite": 0},- "contextWindow": 1000000,- "maxTokens": 65536- },- {- "id": "gemini-3.1-pro",- "name": "Gemini 3.1 Pro",- "reasoning": true,- "input": ["text", "image"],- "cost": {"input": 1.25, "output": 10.00, "cacheRead": 0, "cacheWrite": 0},- "contextWindow": 1000000,- "maxTokens": 65536- }+ // ── Free models ──+ {"id": "qwen/qwen3-coder:free", "name": "Qwen3 Coder 480B", "reasoning": true, "input": ["text"], "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 262000, "maxTokens": 32000},+ {"id": "stepfun/step-3.5-flash:free", "name": "Step 3.5 Flash", "reasoning": false, "input": ["text"], "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 256000, "maxTokens": 32000},+ {"id": "gemini-3-flash", "name": "Gemini 3 Flash", "reasoning": false, "input": ["text", "image"], "cost": {"input": 0.10, "output": 0.40, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 1000000, "maxTokens": 65536},+ {"id": "gemini-2.5-flash", "name": "Gemini 2.5 Flash", "reasoning": false, "input": ["text", "image"], "cost": {"input": 0.075, "output": 0.30, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 1000000, "maxTokens": 65536},+ // ── Anthropic ──+ {"id": "claude-opus-4-6", "name": "Claude Opus 4.6", "reasoning": true, "input": ["text", "image"], "cost": {"input": 15, "output": 75, "cacheRead": 1.5, "cacheWrite": 18.75}, "contextWindow": 200000, "maxTokens": 32000},+ {"id": "claude-sonnet-4-5", "name": "Claude Sonnet 4.5", "reasoning": true, "input": ["text", "image"], "cost": {"input": 3, "output": 15, "cacheRead": 0.3, "cacheWrite": 3.75}, "contextWindow": 200000, "maxTokens": 64000},+ {"id": "claude-haiku-4-5", "name": "Claude Haiku 4.5", "reasoning": true, "input": ["text", "image"], "cost": {"input": 0.8, "output": 4, "cacheRead": 0.08, "cacheWrite": 1}, "contextWindow": 200000, "maxTokens": 64000},+ // ── OpenRouter ──+ {"id": "qwen/qwen3.5-flash-02-23", "name": "Qwen3.5 Flash", "reasoning": false, "input": ["text"], "cost": {"input": 0.065, "output": 0.26, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 1000000, "maxTokens": 32000},+ {"id": "deepseek/deepseek-chat", "name": "DeepSeek V3.2", "reasoning": true, "input": ["text"], "cost": {"input": 0.26, "output": 0.38, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 128000, "maxTokens": 32000},+ {"id": "deepseek/deepseek-v3.2-speciale", "name": "DeepSeek V3.2 Speciale", "reasoning": true, "input": ["text"], "cost": {"input": 2.19, "output": 8.76, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 128000, "maxTokens": 32000},+ {"id": "qwen/qwen3.5-397b-a17b", "name": "Qwen3.5 397B", "reasoning": true, "input": ["text", "image"], "cost": {"input": 1.50, "output": 3.00, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 131000, "maxTokens": 32000},+ {"id": "meta-llama/llama-4-scout", "name": "Llama 4 Scout", "reasoning": false, "input": ["text"], "cost": {"input": 0.11, "output": 0.34, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 512000, "maxTokens": 32000},+ {"id": "meta-llama/llama-4-maverick", "name": "Llama 4 Maverick", "reasoning": true, "input": ["text"], "cost": {"input": 0.50, "output": 0.77, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 256000, "maxTokens": 32000},+ // ── Google ──+ {"id": "gemini-3.1-pro", "name": "Gemini 3.1 Pro", "reasoning": true, "input": ["text", "image"], "cost": {"input": 1.25, "output": 10.00, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 1000000, "maxTokens": 65536},])}