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

fix(privacy): gate the cloud-media skill at install time, not after

Louis Beaumont2c244fdbebb1
diff --git a/apps/screenpipe-app-tauri/lib/utils/tauri.ts b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
index 6e0d00097..ad05b0f35 100644
--- a/apps/screenpipe-app-tauri/lib/utils/tauri.ts
+++ b/apps/screenpipe-app-tauri/lib/utils/tauri.ts
@@ -255,6 +255,30 @@ async getBootPhase() : Promise<BootPhaseSnapshot> {
async isEnterpriseBuildCmd() : Promise<boolean> {
return await TAURI_INVOKE("is_enterprise_build_cmd");
},
+/**
+ * Add or remove the "Cloud audio + video + image analysis" section in
+ * `~/.claude/skills/screenpipe-api/SKILL.md`.
+ *
+ * The skill markdown IS the policy: when this section is present, Pi
+ * (and any Claude Code agent reading the skill) can call the
+ * confidential enclave endpoint; when it's absent, agents don't even
+ * know the capability exists, so privacy-strict users get a clean
+ * world view without conditional logic.
+ *
+ * Idempotent — repeated calls with the same value are no-ops. If the
+ * SKILL.md file doesn't exist (Claude Code not installed / skill not
+ * synced yet), the command silently returns Ok(()) — the user's
+ * setting is still persisted on the frontend side and will take
+ * effect once the skill file appears.
+ */
+async setCloudMediaAnalysisSkill(enabled: boolean) : Promise<Result<null, string>> {
+ try {
+ return { status: "ok", data: await TAURI_INVOKE("set_cloud_media_analysis_skill", { enabled }) };
+} catch (e) {
+ if(e instanceof Error) throw e;
+ else return { status: "error", error: e as any };
+}
+},
/**
* Read the enterprise license key from `enterprise.json`.
* Checks in order:
@@ -1475,11 +1499,11 @@ audioChunkDuration: number;
* Empty string or "default" means not configured.
* Kept as String (not Option) to match existing store.bin schema.
*/
-deepgramApiKey: string;
+deepgramApiKey: string;
/**
* Filter music-dominant audio before transcription using spectral analysis.
*/
-filterMusic: boolean;
+filterMusic: boolean;
/**
* Maximum batch duration in seconds for batch transcription.
* None = use engine-aware defaults (Deepgram=5000s, OpenAI=3000s, Whisper=600s).
@@ -1548,11 +1572,11 @@ disableClipboardCapture?: boolean;
* Continue recording audio when the screen is locked.
* Default: false (audio pauses when screen is locked to save resources).
*/
-recordWhileLocked?: boolean;
+recordWhileLocked?: boolean;
/**
* Languages for transcription (ISO 639-1 codes).
*/
-languages: string[];
+languages: string[];
/**
* Redact personally identifiable information from transcriptions.
*/
@@ -1659,12 +1683,12 @@ analyticsEnabled: boolean;
/**
* Persistent analytics ID (UUID, stable across sessions).
*/
-analyticsId: string;
+analyticsId: string;
/**
* Enable AI workflow event detection (cloud feature, requires subscription).
* When enabled, classifies desktop activity and triggers event-based pipes.
*/
-enableWorkflowEvents?: boolean;
+enableWorkflowEvents?: boolean;
/**
* Detected hardware tier ("high", "mid", "low").
* Set once on first launch; `None` for existing installs (treated as High).
@@ -1750,13 +1774,13 @@ showRestartNotifications?: boolean;
/**
* When true, apply macOS vibrancy effect to the sidebar for a translucent look.
*/
-translucentSidebar?: boolean;
+translucentSidebar?: boolean;
/**
* When true (default), hide model "thinking" reasoning blocks in the chat
* transcript. The model still emits them server-side; we just don't
* render the collapsible block in the UI.
*/
-hideThinkingBlocks?: boolean;
+hideThinkingBlocks?: boolean;
/**
* UI theme: "light", "dark", or "system".
*/
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index 1faa5eecc..686469b74 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.4.203"
+version = "2.4.204"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
index a756e90d6..e95c64ee0 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
@@ -338,79 +338,51 @@ pub async fn set_api_auth_key(key: String) -> Result<(), String> {
.map_err(|e| e.to_string())
}
-/// Add or remove the "Cloud audio + video + image analysis" section in
-/// `~/.claude/skills/screenpipe-api/SKILL.md`.
+/// Toggle the "Cloud audio + video + image analysis" capability
+/// in the screenpipe-api skill that Pi installs on every run.
///
-/// The skill markdown IS the policy: when this section is present, Pi
-/// (and any Claude Code agent reading the skill) can call the
-/// confidential enclave endpoint; when it's absent, agents don't even
-/// know the capability exists, so privacy-strict users get a clean
-/// world view without conditional logic.
+/// Mechanism: the screenpipe-core `Pi::ensure_screenpipe_skill` reads
+/// `~/.screenpipe/cloud_media_analysis.disabled` at install time and
+/// conditionally appends the Gemma 4 E4B confidential-enclave section
+/// to `<project>/.pi/skills/screenpipe-api/SKILL.md`. Default (no
+/// marker) = enabled. This command just creates or removes the marker.
///
-/// Idempotent — repeated calls with the same value are no-ops. If the
-/// SKILL.md file doesn't exist (Claude Code not installed / skill not
-/// synced yet), the command silently returns Ok(()) — the user's
-/// setting is still persisted on the frontend side and will take
-/// effect once the skill file appears.
+/// Why a marker file instead of editing the rendered skill: Pi rewrites
+/// the rendered skill from a compiled-in template on every run, so any
+/// post-install edits get overwritten on the next pipe execution. The
+/// only stable seam is at install time.
+///
+/// Idempotent. Effect takes hold on the next Pi run (next pipe
+/// execution or new pi-chat session).
#[tauri::command]
#[specta::specta]
pub fn set_cloud_media_analysis_skill(enabled: bool) -> Result<(), String> {
- const BEGIN: &str = "<!-- BEGIN_CLOUD_MEDIA_ANALYSIS -->";
- const END: &str = "<!-- END_CLOUD_MEDIA_ANALYSIS -->";
- const BLOCK: &str = include_str!("assets/cloud_media_analysis_block.md");
-
- let skill_path = match dirs::home_dir() {
- Some(home) => home.join(".claude/skills/screenpipe-api/SKILL.md"),
- None => return Err("no home directory".into()),
- };
-
- // If the skill file doesn't exist yet (e.g. Claude Code skill not
- // installed), persist the user's intent on the frontend but skip the
- // file write. Next time the skill lands the toggle re-applies.
- if !skill_path.exists() {
- debug!(
- "skill file not present at {}; toggle persisted in settings only",
- skill_path.display()
- );
- return Ok(());
- }
-
- let mut content = std::fs::read_to_string(&skill_path)
- .map_err(|e| format!("read {}: {e}", skill_path.display()))?;
-
- // Strip any existing block first — idempotent. Match BEGIN..=END
- // inclusive, plus a trailing newline if present, so we don't leave
- // double blank lines on toggle-off.
- if let (Some(begin), Some(end)) = (content.find(BEGIN), content.find(END)) {
- let end_inclusive = end + END.len();
- // Eat one trailing newline so toggle-off doesn't leave a hole.
- let end_eat = if content.as_bytes().get(end_inclusive) == Some(&b'\n') {
- end_inclusive + 1
- } else {
- end_inclusive
- };
- content.replace_range(begin..end_eat, "");
- }
+ let home = dirs::home_dir().ok_or_else(|| "no home directory".to_string())?;
+ let dir = home.join(".screenpipe");
+ let marker = dir.join("cloud_media_analysis.disabled");
if enabled {
- // Append with a guaranteed leading newline; trim any trailing
- // whitespace on the file first so we don't accumulate blanks
- // across repeated toggles.
- while content.ends_with(char::is_whitespace) {
- content.pop();
+ // Default = enabled. Remove any marker file from a prior opt-out.
+ if marker.exists() {
+ std::fs::remove_file(&marker)
+ .map_err(|e| format!("remove {}: {e}", marker.display()))?;
}
- content.push('\n');
- content.push('\n');
- content.push_str(BLOCK.trim_end());
- content.push('\n');
+ } else {
+ std::fs::create_dir_all(&dir)
+ .map_err(|e| format!("create {}: {e}", dir.display()))?;
+ std::fs::write(
+ &marker,
+ "Opt-out marker — Pi will install the screenpipe-api skill \
+ without the Gemma 4 E4B confidential-enclave block. \
+ Delete this file (or toggle in Settings → Privacy) to \
+ re-enable cloud audio/video/image analysis.\n",
+ )
+ .map_err(|e| format!("write {}: {e}", marker.display()))?;
}
-
- std::fs::write(&skill_path, content)
- .map_err(|e| format!("write {}: {e}", skill_path.display()))?;
info!(
- "cloud media analysis skill {} ({})",
+ "cloud media analysis {} (marker: {})",
if enabled { "enabled" } else { "disabled" },
- skill_path.display()
+ marker.display()
);
Ok(())
}
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/assets/cloud_media_analysis_block.md b/crates/screenpipe-core/assets/skills/screenpipe-api/cloud_media_analysis_block.md
similarity index 100%
rename from apps/screenpipe-app-tauri/src-tauri/src/assets/cloud_media_analysis_block.md
rename to crates/screenpipe-core/assets/skills/screenpipe-api/cloud_media_analysis_block.md
diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rs
index ab01db77c..1a8bbb7b4 100644
--- a/crates/screenpipe-core/src/agents/pi.rs
+++ b/crates/screenpipe-core/src/agents/pi.rs
@@ -138,13 +138,56 @@ impl PiExecutor {
self
}
+ /// User policy: when the marker file
+ /// `~/.screenpipe/cloud_media_analysis.disabled` exists, the
+ /// screenpipe-api skill is installed WITHOUT the Gemma 4 E4B
+ /// confidential-enclave block. Default (no marker) = enabled, so
+ /// fresh installs ship the capability documented and Pi knows to
+ /// call `api.screenpi.pe` with `model: "gemma4-e4b"` for audio /
+ /// video / image analysis.
+ ///
+ /// Gating happens at install time (here) rather than by mutating
+ /// the rendered SKILL.md after the fact — those copies get
+ /// overwritten on every Pi run, so post-install edits don't stick.
+ fn cloud_media_analysis_enabled() -> bool {
+ let home = match dirs::home_dir() {
+ Some(h) => h,
+ None => return true,
+ };
+ !home
+ .join(".screenpipe")
+ .join("cloud_media_analysis.disabled")
+ .exists()
+ }
+
+ fn render_screenpipe_api_skill() -> String {
+ let mut s = String::from(include_str!(
+ "../../assets/skills/screenpipe-api/SKILL.md"
+ ));
+ if Self::cloud_media_analysis_enabled() {
+ // Trim trailing whitespace before appending so we don't
+ // accumulate blank lines on rebuild.
+ while s.ends_with(char::is_whitespace) {
+ s.pop();
+ }
+ s.push('\n');
+ s.push('\n');
+ s.push_str(
+ include_str!(
+ "../../assets/skills/screenpipe-api/cloud_media_analysis_block.md"
+ )
+ .trim_end(),
+ );
+ s.push('\n');
+ }
+ s
+ }
+
/// Ensure screenpipe skills exist in `project_dir/.pi/skills/`.
pub fn ensure_screenpipe_skill(project_dir: &Path) -> Result<()> {
+ let api_skill = Self::render_screenpipe_api_skill();
let skills: &[(&str, &str)] = &[
- (
- "screenpipe-api",
- include_str!("../../assets/skills/screenpipe-api/SKILL.md"),
- ),
+ ("screenpipe-api", api_skill.as_str()),
(
"screenpipe-cli",
include_str!("../../assets/skills/screenpipe-cli/SKILL.md"),
@@ -221,11 +264,12 @@ impl PiExecutor {
use crate::pipes::permissions::PipePermissions;
let perms = PipePermissions::from_config(config);
+ let api_skill = Self::render_screenpipe_api_skill();
#[allow(clippy::type_complexity)]
let all_skills: &[(&str, &str, Box<dyn Fn(&PipePermissions) -> bool>)] = &[
(
"screenpipe-api",
- include_str!("../../assets/skills/screenpipe-api/SKILL.md"),
+ api_skill.as_str(),
Box::new(|_| true), // always installed — unified API skill
),
(
diff --git a/packages/ai-gateway/src/providers/index.ts b/packages/ai-gateway/src/providers/index.ts
index 8435f083f..8f2bc1c3b 100644
--- a/packages/ai-gateway/src/providers/index.ts
+++ b/packages/ai-gateway/src/providers/index.ts
@@ -86,12 +86,15 @@ export function createProvider(model: string, env: Env): AIProvider {
return new TinfoilProvider(env.TINFOIL_API_KEY);
}
// Screenpipe enclave — our own Tinfoil-hosted CVM serving Gemma 4 E4B
- // (audio + vision + chat) alongside the privacy-filter.
+ // (audio + vision + chat) alongside the privacy-filter. Tinfoil tokens
+ // are org-scoped so TINFOIL_API_KEY works against this shim too; we
+ // only require a dedicated SCREENPIPE_ENCLAVE_API_KEY if it's set.
if (isScreenpipeEnclaveModel(model)) {
- if (!env.SCREENPIPE_ENCLAVE_API_KEY) {
- throw new Error('Screenpipe enclave API key not configured');
+ const key = env.SCREENPIPE_ENCLAVE_API_KEY || env.TINFOIL_API_KEY;
+ if (!key) {
+ throw new Error('No Tinfoil API key configured (need SCREENPIPE_ENCLAVE_API_KEY or TINFOIL_API_KEY)');
}
- return new ScreenpipeEnclaveProvider(env.SCREENPIPE_ENCLAVE_API_KEY);
+ return new ScreenpipeEnclaveProvider(key);
}
if (isOpenRouterModel(model)) {
if (!env.OPENROUTER_API_KEY) {
diff --git a/packages/ai-gateway/src/types.ts b/packages/ai-gateway/src/types.ts
index a743f6ba6..df1cd27f7 100644
--- a/packages/ai-gateway/src/types.ts
+++ b/packages/ai-gateway/src/types.ts
@@ -160,10 +160,11 @@ export interface Env {
// Tinfoil — confidential inference in secure enclaves
TINFOIL_API_KEY: string;
// Screenpipe's own Tinfoil-hosted enclave (privacy-filter + Gemma 4 E4B
- // audio/vision/chat). Container at pii.screenpipe.containers.tinfoil.dev.
- // Different scope from TINFOIL_API_KEY — this token is issued by our org's
- // Tinfoil dashboard for routes the screenpipe enclave shim authenticates.
- SCREENPIPE_ENCLAVE_API_KEY: string;
+ // audio/vision/chat) at pii.screenpipe.containers.tinfoil.dev.
+ // Optional — Tinfoil tokens are org-scoped, so TINFOIL_API_KEY is the
+ // fallback. Set this separately only if you need to rotate it
+ // independently of the gemma4-31b path.
+ SCREENPIPE_ENCLAVE_API_KEY?: string;
// Admin API auth
ADMIN_SECRET: string;
// Transcription A/B/C test routing