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(privacy): in-app toggle for cloud audio/video/image analysis

Louis Beaumont8916dcc9209d
diff --git a/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx b/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx
index a5ca57daa..87d14422d 100644
--- a/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx
+++ b/apps/screenpipe-app-tauri/components/settings/privacy-section.tsx
@@ -307,6 +307,56 @@ export function PrivacySection() {
handleSettingsChange({ usePiiRemoval: checked }, true);
};
+ // Cloud media analysis (Gemma 4 E4B inside our Tinfoil enclave) —
+ // toggling this also rewrites the screenpipe-api skill markdown so
+ // agents see the capability iff the toggle is on. Defaults to true.
+ const cloudMediaAnalysisEnabled =
+ settings.cloudMediaAnalysisEnabled ?? true;
+
+ const handleCloudMediaAnalysisChange = useCallback(
+ async (checked: boolean) => {
+ handleSettingsChange({ cloudMediaAnalysisEnabled: checked }, true);
+ try {
+ const { invoke } = await import("@tauri-apps/api/core");
+ await invoke("set_cloud_media_analysis_skill", { enabled: checked });
+ } catch (e) {
+ console.error("failed to sync cloud media analysis skill:", e);
+ // Don't block on the file mutation — setting still persisted in
+ // the UI store. Worst case Pi sees a stale block until next
+ // toggle or app restart.
+ }
+ },
+ [handleSettingsChange],
+ );
+
+ // On first hydrate sync the skill file with the (default-true) setting.
+ // Cheap idempotent file write; ensures fresh installs land with the
+ // block present, and that flipping settings.json from outside the app
+ // (e.g. importing a config) keeps the skill in sync.
+ useEffect(() => {
+ if (!settings) return;
+ let cancelled = false;
+ (async () => {
+ try {
+ const { invoke } = await import("@tauri-apps/api/core");
+ if (!cancelled) {
+ await invoke("set_cloud_media_analysis_skill", {
+ enabled: cloudMediaAnalysisEnabled,
+ });
+ }
+ } catch (e) {
+ console.error("cloud media analysis skill sync on hydrate failed:", e);
+ }
+ })();
+ return () => {
+ cancelled = true;
+ };
+ // Intentionally NOT depending on cloudMediaAnalysisEnabled — we want
+ // this to fire once on mount; subsequent changes flow through
+ // handleCloudMediaAnalysisChange which calls invoke directly.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
+
// "AI PII removal" — single user-facing toggle that flips both the
// text reconciliation worker AND the image redactor (rfdetr_v8) on
// or off together. The technical knobs (destructive vs sibling,
@@ -921,6 +971,34 @@ export function PrivacySection() {
)}
</CardContent>
</Card>
+
+ {/* Cloud media analysis — audio / video / image via Gemma 4 E4B
+ inside the same Tinfoil enclave. Toggle adds/removes the
+ section from ~/.claude/skills/screenpipe-api/SKILL.md so
+ agents literally don't see the capability when it's off. */}
+ <Card className="border-border bg-card">
+ <CardContent className="px-3 py-2.5">
+ <div className="flex items-center justify-between">
+ <div className="flex items-center space-x-2.5">
+ <Lock className="h-4 w-4 text-muted-foreground shrink-0" />
+ <div>
+ <h3 className="text-sm font-medium text-foreground flex items-center gap-1.5">
+ AI audio &amp; video analysis
+ <HelpTooltip text="Lets Pi and Claude Code call screenpipe's confidential enclave (Gemma 4 E4B inside a Tinfoil-attested AMD SEV-SNP container, encrypted in flight + at rest, no plaintext at the provider) to transcribe meetings, describe video clips, and analyze image frames from your screenpipe data. When off, the capability is stripped from the agent skill markdown so Pi won't try to use it." />
+ </h3>
+ <p className="text-xs text-muted-foreground">
+ Confidential enclave for transcription, video, and image understanding.
+ </p>
+ </div>
+ </div>
+ <Switch
+ id="cloudMediaAnalysisEnabled"
+ checked={cloudMediaAnalysisEnabled}
+ onCheckedChange={handleCloudMediaAnalysisChange}
+ />
+ </div>
+ </CardContent>
+ </Card>
</div>
</LockedSetting>
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index 4c99cf9d5..0653e07e0 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -209,6 +209,13 @@ export type Settings = SettingsStore & {
openaiCompatibleHeaders?: Record<string, string>;
/** Send raw WAV audio instead of MP3 to OpenAI-compatible endpoint */
openaiCompatibleRawAudio?: boolean;
+ /** Let Pi / Claude Code call the confidential cloud enclave
+ * (Gemma 4 E4B inside an attested Tinfoil CVM) to analyze audio,
+ * video frames, and images from screenpipe data. Default true. When
+ * false, the "Cloud audio + video + image analysis" section is
+ * stripped from `~/.claude/skills/screenpipe-api/SKILL.md` so agents
+ * literally cannot see the endpoint and won't try to call it. */
+ cloudMediaAnalysisEnabled?: boolean;
/** Filter music-dominant audio before transcription (reduces Spotify/YouTube music noise) */
filterMusic?: boolean;
/** Maximum batch transcription duration in seconds (0 = engine default: Deepgram 5000s, OpenAI 3000s, Whisper 600s) */
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/assets/cloud_media_analysis_block.md b/apps/screenpipe-app-tauri/src-tauri/src/assets/cloud_media_analysis_block.md
new file mode 100644
index 000000000..36df76b6b
--- /dev/null
+++ b/apps/screenpipe-app-tauri/src-tauri/src/assets/cloud_media_analysis_block.md
@@ -0,0 +1,41 @@
+<!-- BEGIN_CLOUD_MEDIA_ANALYSIS -->
+
+## Cloud audio + video + image analysis — `POST https://api.screenpi.pe/v1/chat/completions`
+
+Use this when the user asks about a meeting's audio, a video file, or any screen capture and you need actual multimodal understanding (not just OCR or tool-based retrieval). Runs Gemma 4 E4B inside an attested confidential enclave (Tinfoil on AMD SEV-SNP H200) — encrypted in flight, encrypted at rest, no plaintext at the provider.
+
+```bash
+curl -X POST https://api.screenpi.pe/v1/chat/completions \
+ -H "Authorization: Bearer $SCREENPIPE_API_KEY" \
+ -H "Content-Type: application/json" \
+ -d '{
+ "model": "gemma4-e4b",
+ "max_tokens": 400,
+ "messages": [{
+ "role": "user",
+ "content": [
+ {"type": "audio_url", "audio_url": {"url": "data:audio/wav;base64,..."}},
+ {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}},
+ {"type": "text", "text": "what is happening here?"}
+ ]
+ }]
+ }'
+```
+
+### When to use it
+- "transcribe this meeting / clip / voice memo" → `audio_url`
+- "what's in this screen recording" → ffmpeg-sample keyframes → `image_url[]`
+- "what did <speaker> say at <timestamp>" → grab `audio_chunk_id` via §6, send the file as `audio_url`
+- "analyze this video" → up to 4 keyframes per request via `image_url[]`
+
+### Limits & format
+- 1 audio + up to 4 images per request (vLLM `--limit-mm-per-prompt`)
+- Audio: 30 s max per clip (Gemma 4 spec); WAV/MP3 base64
+- Context: 128K tokens (model); `max_model_len` is 8192 in this deployment
+- Latency: ~5 s for 30 s audio, ~2 s for an image
+
+### When NOT to use it
+- For arbitrary text chat use the user's configured chat model (Claude, Gemini, etc.) — `gemma4-e4b` is for media.
+- If the user has explicitly asked for local-only / on-device processing, skip this and use local tools (whisper.cpp, ffmpeg, etc.).
+
+<!-- END_CLOUD_MEDIA_ANALYSIS -->
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
index 65f102184..a756e90d6 100644
--- a/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/commands.rs
@@ -338,6 +338,83 @@ 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`.
+///
+/// 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.
+#[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, "");
+ }
+
+ 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();
+ }
+ content.push('\n');
+ content.push('\n');
+ content.push_str(BLOCK.trim_end());
+ content.push('\n');
+ }
+
+ std::fs::write(&skill_path, content)
+ .map_err(|e| format!("write {}: {e}", skill_path.display()))?;
+ info!(
+ "cloud media analysis skill {} ({})",
+ if enabled { "enabled" } else { "disabled" },
+ skill_path.display()
+ );
+ Ok(())
+}
+
/// Read the enterprise license key from `enterprise.json`.
/// Checks in order:
/// 1. Next to executable (pushed via Intune/MDM to Program Files / .app bundle)
diff --git a/apps/screenpipe-app-tauri/src-tauri/src/main.rs b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
index f93a38f5a..9c1c76fc5 100755
--- a/apps/screenpipe-app-tauri/src-tauri/src/main.rs
+++ b/apps/screenpipe-app-tauri/src-tauri/src/main.rs
@@ -727,6 +727,7 @@ async fn main() {
recording::get_boot_phase,
// Commands from commands.rs
commands::is_enterprise_build_cmd,
+ commands::set_cloud_media_analysis_skill,
commands::get_enterprise_license_key,
commands::save_enterprise_license_key,
enterprise_policy::set_enterprise_policy,
@@ -988,6 +989,7 @@ async fn main() {
commands::get_local_api_config,
commands::regenerate_api_auth_key,
commands::set_api_auth_key,
+ commands::set_cloud_media_analysis_skill,
commands::get_enterprise_license_key,
enterprise_policy::set_enterprise_policy,
commands::save_enterprise_license_key,