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

refactor: single source of truth for API auth — skill file only

Louis Beaumontcc5fac8548d4
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
index e95f98a40..831f45e1c 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs
@@ -1213,29 +1213,6 @@ pub async fn pi_start_inner(
}
}
- // For local/small models, inject minimal screenpipe API context directly into the system prompt
- // so they don't need to discover and read the skill file (which they often skip)
- let is_local_model = matches!(pi_provider.as_str(), "ollama" | "custom");
- if is_local_model {
- let api_hint = concat!(
- "You are a screen activity assistant. The user has screenpipe running locally.\n",
- "IMPORTANT: ALL API requests MUST include the auth header: -H \"Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY\"\n",
- "Search their data with: curl -H \"Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY\" \"http://localhost:3030/search?q=QUERY&content_type=all&limit=10&start_time=ISO8601\"\n",
- "Parameters: q (keywords), content_type (all|ocr|audio), limit (1-20), start_time (ISO 8601, REQUIRED), end_time, app_name, window_name\n",
- "ALWAYS include start_time. Use date -u for UTC. Example:\n",
- "curl -H \"Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY\" \"http://localhost:3030/search?content_type=all&limit=5&start_time=$(date -u -v-5M +%Y-%m-%dT%H:%M:%SZ)\"\n",
- "For Linux use: date -u -d '5 minutes ago' +%Y-%m-%dT%H:%M:%SZ\n",
- "Response is JSON with data[] array containing type (OCR/Audio/UI) and content with text/transcription, timestamp, app_name."
- );
- cmd.args(["--append-system-prompt", api_hint]);
- }
-
- // Always inject auth reminder into the system prompt so all models know to authenticate
- {
- let auth_hint = "CRITICAL: You MUST add -H \"Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY\" to EVERY curl request to the Screenpipe API (localhost:3030). Without it, you will get 403 unauthorized. The $SCREENPIPE_LOCAL_API_KEY env var is already set in your environment.";
- cmd.args(["--append-system-prompt", auth_hint]);
- }
-
// Append the user's AI preset system prompt (enables Anthropic prompt caching —
// Pi's built-in system prompt + this text form the cached prefix, reducing
// input costs by 90% on subsequent messages in the same conversation)
diff --git a/crates/screenpipe-core/assets/skills/screenpipe-api/SKILL.md b/crates/screenpipe-core/assets/skills/screenpipe-api/SKILL.md
index 316a295ea..33528ed01 100644
--- a/crates/screenpipe-core/assets/skills/screenpipe-api/SKILL.md
+++ b/crates/screenpipe-core/assets/skills/screenpipe-api/SKILL.md
@@ -7,6 +7,16 @@ description: Query the user's screen recordings, audio, UI elements, and usage a
Local REST API at `http://localhost:3030`. Full reference (60+ endpoints): https://docs.screenpi.pe/llms-full.txt
+## Authentication
+
+**ALL requests require authentication.** Add the auth header to every curl call:
+
+```bash
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/..."
+```
+
+The `$SCREENPIPE_LOCAL_API_KEY` env var is already set in your environment. Without it you get 403. The only exception is `/health` (no auth needed).
+
## Context Window Protection
API responses can be large. Always write curl output to a file first (`curl ... -o /tmp/sp_result.json`), check size (`wc -c /tmp/sp_result.json`), and if over 5KB read only the first 50-100 lines. Extract what you need with `jq`. NEVER dump full large responses into context.
@@ -16,7 +26,7 @@ API responses can be large. Always write curl output to a file first (`curl ...
## 1. Search — `GET /search`
```bash
-curl "http://localhost:3030/search?q=QUERY&content_type=all&limit=10&start_time=1h%20ago"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/search?q=QUERY&content_type=all&limit=10&start_time=1h%20ago"
```
### Parameters
@@ -84,7 +94,7 @@ Decision tree:
## 2. Activity Summary — `GET /activity-summary`
```bash
-curl "http://localhost:3030/activity-summary?start_time=1h%20ago&end_time=now"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/activity-summary?start_time=1h%20ago&end_time=now"
```
Returns a rich overview with:
@@ -102,7 +112,7 @@ This is usually enough to answer "what was I doing?" without further searches. O
Lightweight FTS search across UI elements (~100-500 bytes each vs 5-20KB from `/search`).
```bash
-curl "http://localhost:3030/elements?q=Submit&start_time=1h%20ago&limit=10"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/elements?q=Submit&start_time=1h%20ago&limit=10"
```
Parameters: `q`, `frame_id`, `source` (`accessibility`|`ocr`), `role`, `start_time`, `end_time`, `app_name`, `limit`, `offset`.
@@ -112,7 +122,7 @@ Parameters: `q`, `frame_id`, `source` (`accessibility`|`ocr`), `role`, `start_ti
Returns accessibility text, parsed nodes, and extracted URLs for a frame.
```bash
-curl "http://localhost:3030/frames/6789/context"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/frames/6789/context"
```
### Common Roles (platform-specific)
@@ -274,8 +284,8 @@ If not connected, tell user to set up in Settings > Connections.
## 9. Meetings — `GET /meetings`
```bash
-curl "http://localhost:3030/meetings?start_time=1d%20ago&end_time=now&limit=10&offset=0"
-curl "http://localhost:3030/meetings/42"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/meetings?start_time=1d%20ago&end_time=now&limit=10&offset=0"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/meetings/42"
```
Returns detected meetings (from calendar, app detection, window titles, UI elements, multi-speaker audio).
@@ -298,13 +308,13 @@ Also available via raw SQL: `SELECT * FROM meetings WHERE meeting_start > dateti
```bash
# Search speakers by name
-curl "http://localhost:3030/speakers/search?name=John"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/speakers/search?name=John"
# Get unnamed speakers (for labeling)
-curl "http://localhost:3030/speakers/unnamed?limit=20&offset=0"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/speakers/unnamed?limit=20&offset=0"
# Get speakers similar to a given speaker (by voice embedding)
-curl "http://localhost:3030/speakers/similar?speaker_id=29&limit=5"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/speakers/similar?speaker_id=29&limit=5"
# Update speaker name/metadata
curl -X POST http://localhost:3030/speakers/update \
@@ -366,13 +376,13 @@ When the user says "that was actually Jordan, not Karishma":
```bash
# Search memories (FTS) — do this often!
-curl "http://localhost:3030/memories?q=preference&limit=20"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/memories?q=preference&limit=20"
# List recent memories (high importance first)
-curl "http://localhost:3030/memories?min_importance=0.5&limit=20"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/memories?min_importance=0.5&limit=20"
# Filter by source or tags
-curl "http://localhost:3030/memories?source=user&tags=project&limit=20"
+curl -H "Authorization: Bearer $SCREENPIPE_LOCAL_API_KEY" "http://localhost:3030/memories?source=user&tags=project&limit=20"
# Create a memory
curl -X POST http://localhost:3030/memories \