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

feat: pi as default chat preset, image support, frame fetching skill

Louis Beaumont46420fd83ceb
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index ab7984970..20ab48fde 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -1116,12 +1116,51 @@ export function StandaloneChat() {
}, 180000);
try {
+ // Collect images (pasted image + prefill frame)
+ const piImages: Array<{ type: string; source: { type: string; mediaType: string; data: string } }> = [];
+
+ if (prefillFrameId) {
+ try {
+ const response = await fetch(`http://localhost:3030/frames/${prefillFrameId}`);
+ if (response.ok) {
+ const blob = await response.blob();
+ const arrayBuffer = await blob.arrayBuffer();
+ const base64 = btoa(
+ new Uint8Array(arrayBuffer).reduce((data, byte) => data + String.fromCharCode(byte), '')
+ );
+ const mimeType = blob.type || 'image/png';
+ piImages.push({
+ type: "image",
+ source: { type: "base64", mediaType: mimeType, data: base64 },
+ });
+ }
+ } catch (error) {
+ console.error("Failed to fetch frame image for Pi:", error);
+ }
+ setPrefillFrameId(null);
+ }
+
+ if (pastedImage) {
+ // pastedImage is a data URL like "data:image/png;base64,..."
+ const match = pastedImage.match(/^data:(image\/[^;]+);base64,(.+)$/);
+ if (match) {
+ piImages.push({
+ type: "image",
+ source: { type: "base64", mediaType: match[1], data: match[2] },
+ });
+ }
+ setPastedImage(null);
+ }
+
setMessages((prev) => [
...prev,
{ id: assistantMessageId, role: "assistant", content: "Processing...", timestamp: Date.now() },
]);
- const result = await commands.piPrompt(userMessage);
+ const result = await commands.piPrompt(
+ userMessage,
+ piImages.length > 0 ? piImages : null,
+ );
if (result.status === "error") {
clearTimeout(timeoutId);
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index d31ef610c..c00c7a9f0 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -49,6 +49,9 @@ export type AIPreset = {
provider: "custom";
apiKey?: string;
}
+ | {
+ provider: "pi";
+ }
);
export type UpdateChannel = "stable" | "beta";
@@ -129,19 +132,29 @@ const DEFAULT_IGNORED_WINDOWS_PER_OS: Record<string, string[]> = {
linux: ["Info center", "Discover", "Parted"],
};
-// Default free AI preset that works without login
-// Note: screenpipe-cloud provider doesn't require apiKey
+// Default Pi agent preset — local coding agent with screenpipe search skill
+const DEFAULT_PI_PRESET: AIPreset = {
+ id: "pi-agent",
+ provider: "pi",
+ url: "",
+ model: "claude-haiku-4-5@20251001",
+ maxContextChars: 200000,
+ defaultPreset: true,
+ prompt: "",
+};
+
+// Screenpipe cloud preset (direct API, no agent)
const DEFAULT_FREE_PRESET: AIPreset = {
id: "screenpipe-free",
provider: "screenpipe-cloud",
url: "https://api.screenpi.pe/v1",
model: "claude-haiku-4-5@20251001",
maxContextChars: 128000,
- defaultPreset: true,
+ defaultPreset: false,
prompt: DEFAULT_PROMPT,
};
-// Second default preset with Gemini Flash 3 (also free, supports web search)
+// Gemini Flash 3 preset (direct API, supports web search via Google grounding)
const DEFAULT_GEMINI_PRESET: AIPreset = {
id: "gemini-flash",
provider: "screenpipe-cloud",
@@ -153,7 +166,7 @@ const DEFAULT_GEMINI_PRESET: AIPreset = {
};
let DEFAULT_SETTINGS: Settings = {
- aiPresets: [DEFAULT_FREE_PRESET as any, DEFAULT_GEMINI_PRESET as any],
+ aiPresets: [DEFAULT_PI_PRESET as any, DEFAULT_FREE_PRESET as any, DEFAULT_GEMINI_PRESET as any],
deviceId: crypto.randomUUID(),
deepgramApiKey: "",
isLoading: false,
@@ -282,9 +295,9 @@ function createSettingsStore() {
needsUpdate = true;
}
- // Migration: Add default free preset if user has no presets
+ // Migration: Add default presets if user has none
if (!settings.aiPresets || settings.aiPresets.length === 0) {
- settings.aiPresets = [DEFAULT_FREE_PRESET as any, DEFAULT_GEMINI_PRESET as any];
+ settings.aiPresets = [DEFAULT_PI_PRESET as any, DEFAULT_FREE_PRESET as any, DEFAULT_GEMINI_PRESET as any];
needsUpdate = true;
}
@@ -297,6 +310,18 @@ function createSettingsStore() {
needsUpdate = true;
}
+ // Migration: Add Pi agent preset for existing users and make it default
+ const hasPiPreset = settings.aiPresets?.some(
+ (p: any) => p.id === "pi-agent" || p.provider === "pi"
+ );
+ if (settings.aiPresets && settings.aiPresets.length > 0 && !hasPiPreset) {
+ // Demote all existing presets from default
+ settings.aiPresets = settings.aiPresets.map((p: any) => ({ ...p, defaultPreset: false }));
+ // Add Pi as default at the front
+ settings.aiPresets = [DEFAULT_PI_PRESET as any, ...settings.aiPresets];
+ needsUpdate = true;
+ }
+
// Migration: Add chat history for existing users
if (!settings.chatHistory) {
settings.chatHistory = {
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index 0dc08dafe..f07f82ae7 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -136,7 +136,7 @@ async closeWindow(window: ShowRewindWindow) : Promise<Result<null, string>> {
}
},
/**
- * Destroy the Main window/panel so it gets recreated fresh (e.g. after switching overlay mode)
+ * Hide the Main panel so the next shortcut press reconfigures it for the new mode.
*/
async resetMainWindow() : Promise<void> {
await TAURI_INVOKE("reset_main_window");
@@ -414,11 +414,11 @@ async piInstall() : Promise<Result<null, string>> {
}
},
/**
- * Send a prompt to Pi
+ * Send a prompt to Pi, optionally with images
*/
-async piPrompt(message: string) : Promise<Result<null, string>> {
+async piPrompt(message: string, images: PiImageContent[] | null) : Promise<Result<null, string>> {
try {
- return { status: "ok", data: await TAURI_INVOKE("pi_prompt", { message }) };
+ return { status: "ok", data: await TAURI_INVOKE("pi_prompt", { message, images }) };
} catch (e) {
if(e instanceof Error) throw e;
else return { status: "error", error: e as any };
@@ -593,6 +593,11 @@ export type OnboardingStore = { isCompleted: boolean; completedAt: string | null
*/
currentStep?: string | null }
export type PiCheckResult = { available: boolean; path: string | null }
+/**
+ * Image content for Pi RPC protocol
+ */
+export type PiImageContent = { type: string; source: PiImageSource }
+export type PiImageSource = { type: string; mediaType: string; data: string }
export type PiInfo = { running: boolean; projectDir: string | null; pid: number | null; sessionId: string | null }
export type SettingsStore = { aiPresets: AIPreset[]; deepgramApiKey: string; isLoading: boolean; userId: string;
/**
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
index 586aa70ca..e18722e04 100755
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -9089,7 +9089,7 @@ dependencies = [
[[package]]
name = "screenpipe-audio"
-version = "0.3.63"
+version = "0.3.64"
dependencies = [
"anyhow",
"bytemuck",
@@ -9137,7 +9137,7 @@ dependencies = [
[[package]]
name = "screenpipe-core"
-version = "0.3.63"
+version = "0.3.64"
dependencies = [
"accessibility",
"accessibility-sys",
@@ -9188,7 +9188,7 @@ dependencies = [
[[package]]
name = "screenpipe-db"
-version = "0.3.63"
+version = "0.3.64"
dependencies = [
"anyhow",
"chrono",
@@ -9212,7 +9212,7 @@ dependencies = [
[[package]]
name = "screenpipe-events"
-version = "0.3.63"
+version = "0.3.64"
dependencies = [
"anyhow",
"chrono",
@@ -9228,7 +9228,7 @@ dependencies = [
[[package]]
name = "screenpipe-integrations"
-version = "0.3.63"
+version = "0.3.64"
dependencies = [
"anyhow",
"image 0.25.9",
@@ -9243,7 +9243,7 @@ dependencies = [
[[package]]
name = "screenpipe-server"
-version = "0.3.63"
+version = "0.3.64"
dependencies = [
"anyhow",
"async-trait",
@@ -9307,7 +9307,7 @@ dependencies = [
[[package]]
name = "screenpipe-vision"
-version = "0.3.63"
+version = "0.3.64"
dependencies = [
"accessibility-sys",
"anyhow",
diff --git a/apps/screenpipe-app-tauri/src-tauri/assets/skills/screenpipe-search/SKILL.md b/apps/screenpipe-app-tauri/src-tauri/assets/skills/screenpipe-search/SKILL.md
index 3828c719d..309734fb7 100644
--- a/apps/screenpipe-app-tauri/src-tauri/assets/skills/screenpipe-search/SKILL.md
+++ b/apps/screenpipe-app-tauri/src-tauri/assets/skills/screenpipe-search/SKILL.md
@@ -120,6 +120,40 @@ curl "http://localhost:3030/search?app_name=Google%20Chrome&content_type=ocr&lim
}
```
+## Fetching Frames (Screenshots)
+
+You can fetch actual screenshot frames from search results. Each OCR result has a `frame_id`.
+
+```bash
+# Get a specific frame as an image
+curl -o /tmp/frame.png "http://localhost:3030/frames/{frame_id}"
+```
+
+This returns the raw PNG image. Use the `read` tool to view it (pi supports images).
+
+### When to fetch frames
+- When the user asks "show me what I was looking at" or "what was on screen"
+- When you need visual context to answer a question (e.g. UI layout, charts, design)
+- When OCR text is ambiguous and you need to see the actual screen
+
+### CRITICAL: Token budget for frames
+- Each frame is ~1000-2000 tokens when sent to the LLM
+- **NEVER fetch more than 2-3 frames per query** — it's expensive and slow
+- Prefer using OCR text from search results first. Only fetch frames when text isn't enough.
+- If the user asks about many moments, summarize from OCR text and only fetch 1-2 key frames.
+
+### Example workflow
+```bash
+# 1. Search for relevant content
+curl "http://localhost:3030/search?q=dashboard&app_name=Chrome&content_type=ocr&limit=5&start_time=2024-01-15T10:00:00Z"
+
+# 2. Pick the most relevant frame_id from results
+# 3. Fetch that specific frame
+curl -o /tmp/frame_12345.png "http://localhost:3030/frames/12345"
+
+# 4. Read/view the image
+```
+
## Other Useful Endpoints
### Health Check
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
index 6588f89a2..a8997b941 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
@@ -488,12 +488,30 @@ pub async fn pi_start(
Ok(snapshot)
}
-/// Send a prompt to Pi
+/// Image content for Pi RPC protocol
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
+pub struct PiImageContent {
+ #[serde(rename = "type")]
+ pub content_type: String, // always "image"
+ pub source: PiImageSource,
+}
+
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
+pub struct PiImageSource {
+ #[serde(rename = "type")]
+ pub source_type: String, // "base64"
+ #[serde(rename = "mediaType")]
+ pub media_type: String, // e.g. "image/png"
+ pub data: String, // base64-encoded image data
+}
+
+/// Send a prompt to Pi, optionally with images
#[tauri::command]
#[specta::specta]
pub async fn pi_prompt(
state: State<'_, PiState>,
message: String,
+ images: Option<Vec<PiImageContent>>,
) -> Result<(), String> {
let mut manager = state.0.lock().await;
let m = manager.as_mut().ok_or("Pi not initialized")?;
@@ -502,11 +520,17 @@ pub async fn pi_prompt(
return Err("Pi is not running".to_string());
}
- let cmd = json!({
+ let mut cmd = json!({
"type": "prompt",
"message": message
});
+ if let Some(imgs) = images {
+ if !imgs.is_empty() {
+ cmd["images"] = serde_json::to_value(imgs).map_err(|e| e.to_string())?;
+ }
+ }
+
m.send_command(cmd)
}