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
feat: add timeline deep links for AI chat and MCP
Louis Beaumont096cb70b2976
diff --git a/.pi/skills/supabase-read/INDEX.md b/.pi/skills/supabase-read/INDEX.mdnew file mode 100644index 000000000..0bf2bf67a--- /dev/null+++ b/.pi/skills/supabase-read/INDEX.md@@ -0,0 +1,189 @@+# Supabase Read-Only Agent Skill - File Index++## π Skill Directory Structure++```+.pi/skills/supabase-read/+βββ SKILL.md β Main documentation (read this first)+βββ README.md β Overview and quick reference+βββ SETUP.md β Installation & troubleshooting+βββ supabase-agent.ts β Implementation (TypeScript)+βββ PROMPT_TEMPLATE.md β Prompts for skills using this agent+βββ INDEX.md β This file+βββ .gitignore β What not to commit (see root)+```++## π Reading Guide++### π€ If You're...++**A User/End User:**+1. Start with `README.md` (overview)+2. Follow `SETUP.md` (installation)+3. Jump to examples in `SKILL.md`++**A Skill Developer:**+1. Read `SKILL.md` entirely (schema & safety)+2. Check `supabase-agent.ts` for API+3. Use `PROMPT_TEMPLATE.md` for prompts in your skill+4. Reference `SKILL.md` "Safe Tables" when writing queries++**A Maintainer/Admin:**+1. Review `SKILL.md` (comprehensive documentation)+2. Check `supabase-agent.ts` (implementation)+3. Update "Safe Tables" or "Blocked Tables" sections as needed+4. Review `PROMPT_TEMPLATE.md` safety guardrails+5. Update `SETUP.md` if dependencies or steps change++**An AI/Agent:**+1. Load `PROMPT_TEMPLATE.md` for context+2. Reference `SKILL.md` for schema details+3. Use `supabase-agent.ts` as implementation guide+4. Follow safety guidelines in all files++## π― By Purpose++### Need to Query the Database?+β `SKILL.md` (Schema section) + `supabase-agent.ts` (Examples)++### Getting "Environment Variables" Error?+β `SETUP.md` (Step 2: Fetch Environment Variables)++### Writing a Skill That Uses This?+β `PROMPT_TEMPLATE.md` + `supabase-agent.ts`++### Understanding What's Safe/Unsafe?+β `SKILL.md` (Safe Tables vs Blocked Tables)++### Troubleshooting Errors?+β `SETUP.md` (Troubleshooting section)++### Rate Limiting Issues?+β `SKILL.md` (Rate Limiting section) + `PROMPT_TEMPLATE.md`++### Security Review?+β `SKILL.md` (Safety Guidelines) + `PROMPT_TEMPLATE.md` (Safety Guardrails)++## π File Purposes++| File | Purpose | Audience | Read Time |+|------|---------|----------|-----------|+| **SKILL.md** | Complete documentation: schema, safety, usage | Everyone | 15 min |+| **README.md** | Quick overview and reference | Everyone | 5 min |+| **SETUP.md** | Installation, environment, troubleshooting | Users, Devs | 8 min |+| **supabase-agent.ts** | Working implementation with examples | Devs | 10 min |+| **PROMPT_TEMPLATE.md** | Prompt patterns and error handling | Skill writers | 12 min |+| **INDEX.md** | This navigation guide | Everyone | 3 min |++## π Security Features++All files include safety information:++- **SKILL.md**: "Safety Guidelines" + "Unsafe Tables (Blocked)"+- **supabase-agent.ts**: Inline comments about what NOT to do+- **SETUP.md**: "Safety Checklist" section+- **PROMPT_TEMPLATE.md**: "Safety Guardrails in Prompts" + examples+- **README.md**: "What NOT to Do" vs "What to Do"++## π Quick Reference++### Setup (Copy-Paste Ready)++```bash+# 1. Pull environment+vercel env pull++# 2. Install package+bun add @supabase/supabase-js++# 3. Import in code+import { SupabaseReadAgent } from "./.pi/skills/supabase-read/supabase-agent"++# 4. Use it+const features = await SupabaseReadAgent.getActiveFeatures()+```++### Safe Tables (Always OK to Query)++```+β user_analytics (aggregate stats)+β features (feature flags)+β pricing_tiers (pricing info)+```++### Blocked Tables (RLS Prevents Access)++```+β users (personal data)+β sessions (auth tokens)+β api_keys (credentials)+β logs (internals)+β audit_trail (user tracking)+β payment_info (financial data)+β support_tickets (private messages)+β error_logs (system details)+```++## π Cross-References++From any file, you can jump to:++- **SKILL.md** β Schema definitions, safety guidelines, RLS explanation+- **SETUP.md** β Environment variables, installation, error solutions+- **supabase-agent.ts** β API functions, implementation details+- **PROMPT_TEMPLATE.md** β Prompt patterns, error messages, guardrails+- **README.md** β Overview, quick start, architecture++## β Checklist for Skill Writers++Before publishing a skill using this agent:++- [ ] Read `SKILL.md` completely+- [ ] Only query tables in "Safe Tables" list+- [ ] Review `PROMPT_TEMPLATE.md` for error handling+- [ ] Add safety disclaimers to your skill's docs+- [ ] Test with `SUPABASE_PUBLIC_KEY` (never private)+- [ ] Verify `.env.local` is `.gitignored`+- [ ] Document what tables you query+- [ ] Never hardcode any credentials+- [ ] Include "Rate Limiting" note if you do repeated queries+- [ ] Test error cases (network issues, missing env, invalid queries)++## π Help & Support++| Issue | Resource |+|-------|----------|+| Blank stare at Supabase? | Start with `README.md` |+| "How do I install?" | Follow `SETUP.md` |+| "What tables exist?" | Check `SKILL.md` schema section |+| "Is this table safe?" | See "Safe Tables" in `SKILL.md` |+| "How do I write prompts?" | Use `PROMPT_TEMPLATE.md` |+| "Getting errors?" | Troubleshoot in `SETUP.md` |+| "Is this operation allowed?" | Check safety in `SKILL.md` |+| "Need implementation example?" | Review `supabase-agent.ts` |++## π Notes++- **No secrets in files**: All code files use environment variables+- **All documentation public**: Safe to share on GitHub+- **Maintained by**: Screenpipe maintainers+- **Last updated**: February 3, 2026+- **Version**: Matches Supabase SDK @latest++## π How to Stay Current++If documentation changes:++1. Check git history: `git log -- .pi/skills/supabase-read/`+2. Review changes: `git diff HEAD~1 .pi/skills/supabase-read/`+3. Update local `.env.local` if needed: `vercel env pull`+4. Reinstall package if major version: `bun install @supabase/supabase-js@latest`++---++**TL;DR:**+- New here? Read `README.md` then `SETUP.md`+- Want schema? Go to `SKILL.md`+- Writing a skill? Use `PROMPT_TEMPLATE.md`+- Need code? Check `supabase-agent.ts`+- Got errors? See `SETUP.md` troubleshootingdiff --git a/.pi/skills/supabase-read/PROMPT_TEMPLATE.md b/.pi/skills/supabase-read/PROMPT_TEMPLATE.mdnew file mode 100644index 000000000..3cac6faea--- /dev/null+++ b/.pi/skills/supabase-read/PROMPT_TEMPLATE.md@@ -0,0 +1,356 @@+# Supabase Read-Only Agent - Prompt Template++Use this template when creating skills or agents that need to query the Screenpipe database.++## System Prompt for Supabase Queries++```+You are a read-only database assistant for the Screenpipe application.++Your responsibilities:+1. Query the public Supabase database for information+2. Only query documented public tables+3. Never attempt private operations+4. Explain what data you're retrieving and why++Available public tables:+- user_analytics: Anonymous event statistics+- features: Feature flag information+- pricing_tiers: Subscription pricing++Forbidden tables (RLS blocks these):+- users, sessions, api_keys, logs, audit_trail, payment_info, support_tickets, error_logs++When a user asks a question:+1. Identify if it requires database access+2. Check if the required data exists in public tables+3. If yes: Query using the SupabaseReadAgent+4. If no: Explain what data is unavailable and why++Always be transparent about:+- What data you're accessing+- Which tables you're querying+- Whether the query succeeded or failed+- If data is incomplete or missing+```++## Prompt Examples++### Example 1: Feature Status Query++**User:** "Is the OCR beta feature available yet?"++**Agent Response:**+```+I'll check the feature status for you.++Querying: features table for "ocr_beta"+Result: ocr_beta is currently [ENABLED/DISABLED] as of [date]++The OCR beta feature...+```++### Example 2: Pricing Information++**User:** "What are the current pricing tiers?"++**Agent Response:**+```+I'll retrieve the current pricing information.++Querying: pricing_tiers table+Found 3 tiers:++1. Free - $0/month+ - Features: [list]+ - Storage: 1 GB+ - API calls: 1,000/month++2. Pro - $29/month+ - Features: [list]+ - Storage: 100 GB+ - API calls: 100,000/month++3. Enterprise - Custom pricing+ - Features: [list]+ - Storage: Unlimited+ - API calls: Unlimited+```++### Example 3: Analytics Query++**User:** "How many people used the capture feature last month?"++**Agent Response:**+```+I'll check the analytics for capture events.++Querying: user_analytics table+Filter: event_type = 'capture', date >= [30 days ago]+Result: 15,432 capture events recorded++This represents [X] unique users engaging with the capture feature.+Note: This is aggregated, anonymous data - no individual users identified.+```++## Error Handling Template++When queries fail, use this template:++```+Query failed: [table name]+Reason: [error details]++Possible causes:+1. [cause 1]+2. [cause 2]+3. [cause 3]++What to try:+- [suggestion 1]+- [suggestion 2]+- [suggestion 3]+```++### Common Errors++**"403 Forbidden"**+```+This table is not accessible via the public API key.++Tables you CAN query:+- user_analytics (aggregate event data)+- features (feature status)+- pricing_tiers (subscription info)++If you need different data, please clarify what you're looking for.+```++**"401 Unauthorized"**+```+The API key is invalid or expired.++Try refreshing the environment:+1. Run: vercel env pull+2. Restart the application++If the problem persists, contact the maintainers.+```++**"Column not found"**+```+That column doesn't exist in the table schema.++Available columns in [table]:+- [column 1]+- [column 2]+- [column 3]++Which column did you want to access?+```++## Integration with Skills++When writing a skill that uses this agent:++```markdown+---+name: my-feature-skill+description: "Query Screenpipe feature status from the database"+allowed-tools: Read, Write+---++# My Feature Skill++This skill queries the read-only Screenpipe Supabase database.++## What It Can Do++- Check feature availability+- Retrieve pricing information+- View usage statistics (anonymized)+- Search public announcements++## What It CANNOT Do++- Access user information+- View debug logs or error traces+- Modify pricing or features+- Access API keys or sessions+- Query private user data++## Example Usage++"What features are currently enabled?"+β Queries `features` table, returns enabled features++"How much does the Pro tier cost?"+β Queries `pricing_tiers` table, returns pricing++"Show me capture event statistics"+β Queries `user_analytics` table, returns aggregated counts+```++## Safety Guardrails in Prompts++Always include these safety notes:++```+IMPORTANT SAFETY GUIDELINES:++1. Only query documented public tables+2. Never attempt to access user data+3. All queries are read-only+4. Don't share raw API keys+5. Respect user privacy+6. Report suspicious queries to maintainers+7. Cache results to respect rate limits+8. Never hardcode credentials+```++## Data Anonymization Template++When discussing query results:++```+The database provides [X] records.++I can tell you:+β Aggregate counts (e.g., "500 events total")+β Feature status (e.g., "OCR beta is enabled")+β Pricing info (e.g., "Pro tier costs $29/month")++I cannot tell you:+β Who used what features+β Individual user activities+β Private user information+β System internals or debug data+β API credentials or secrets+```++## Rejection Template++For requests that violate safety guidelines:++```+I can't help with that request.++Reason: [specific reason]++What I can help with instead:+1. [alternative 1]+2. [alternative 2]+3. [alternative 3]++If you believe this restriction is incorrect, please contact the maintainers.+```++### Examples++```+Request: "Show me user sessions for [email protected]"+Response:+"I can't help with that request.++Reason: The sessions table contains private authentication data and is not accessible.++What I can help with instead:+1. Feature availability information+2. Pricing tier details+3. Aggregate usage statistics (anonymized)+4. Feature status and rollout dates++If you need user-specific information, please contact support directly."+```++```+Request: "Get all error logs for debugging"+Response:+"I can't help with that request.++Reason: Error logs contain system internals and are restricted to administrators.++What I can help with instead:+1. Check feature status+2. View aggregate analytics+3. Review pricing information+4. Check feature availability++For debugging access, contact the technical team."+```++## Rate Limiting Messaging++When approaching rate limits:++```+β οΈ Approaching rate limit++Your queries are being cached to respect Supabase limits (100 req/min).++Recent queries cached:+- Features list (expires in 55 min)+- Pricing tiers (expires in 58 min)+- Analytics summary (expires in 45 min)++To see fresh data, wait for cache expiration or ask a new question.+```++## Debugging Template (for developers)++```+[DEBUG: Query execution]+Table: [table_name]+Filters: [filter_conditions]+Selected columns: [col1, col2, col3]+Limit: [number]++Query execution time: [ms]+Rows returned: [number]+Cache: [HIT/MISS]+```++---++## Reference: Safe vs Unsafe Operations++### β SAFE Queries++```typescript+// Query feature status+await supabase.from("features")+ .select("name, enabled, description")+ .eq("enabled", true);++// Get pricing+await supabase.from("pricing_tiers")+ .select("name, monthly_price, features");++// Analytics aggregates+await supabase.from("user_analytics")+ .select("event_type, COUNT(*) as count")+ .group_by("event_type");+```++### β UNSAFE Queries++```typescript+// Accessing user data+await supabase.from("users").select("*");++// Viewing sessions/auth+await supabase.from("sessions").select("*");++// Accessing logs+await supabase.from("logs").select("error, stack_trace");++// Accessing credentials+await supabase.from("api_keys").select("secret");++// Modifying data+await supabase.from("features").update({ enabled: false });++// Deleting data+await supabase.from("pricing_tiers").delete().eq("id", "xxx");+```+diff --git a/.pi/skills/supabase-read/README.md b/.pi/skills/supabase-read/README.mdnew file mode 100644index 000000000..4b7ffcc04--- /dev/null+++ b/.pi/skills/supabase-read/README.md@@ -0,0 +1,267 @@+# Supabase Read-Only Agent Skill++Safe, read-only access to the Screenpipe Supabase database for skills and agents.++## π What's Here++| File | Purpose |+|------|---------|+| **SKILL.md** | Main skill documentation - schema, safety guidelines, and usage |+| **SETUP.md** | Quick start guide and troubleshooting |+| **supabase-agent.ts** | Ready-to-use TypeScript/JavaScript agent implementation |+| **PROMPT_TEMPLATE.md** | Prompt templates for skills that use this agent |+| **README.md** | This file |++## π Quick Start++```bash+# 1. Pull environment variables (never hardcode!)+vercel env pull++# 2. Install dependency+bun add @supabase/supabase-js++# 3. Use in your code+import { SupabaseReadAgent } from "./.pi/skills/supabase-read/supabase-agent"++const features = await SupabaseReadAgent.getActiveFeatures()+```++## π Safety First++This skill is designed with security in mind:++- **Read-only access** - no writes, deletes, or modifications+- **Public key only** - private keys never in code+- **RLS protection** - blocked tables can't be accessed even with public key+- **Schema documentation** - clear what's safe to query+- **No hardcoded secrets** - uses Vercel CLI or environment variables+- **Rate limiting** - respects Supabase API limits++## ποΈ Safe Tables++```+user_analytics β Anonymous event statistics+features β Feature flag status+pricing_tiers β Subscription information+```++## π« Blocked Tables++These tables are protected by Supabase Row-Level Security:++```+users, sessions, api_keys, logs, audit_trail+payment_info, support_tickets, error_logs+```++Even if attempted, RLS policies will deny access.++## π Documentation++### For End Users+- Start with **SETUP.md** for installation+- Read **SKILL.md** for what tables exist and how to query them++### For Skill Developers+- Use **supabase-agent.ts** as a reference implementation+- Check **PROMPT_TEMPLATE.md** for how to write prompts+- Review **SKILL.md** for safety guidelines++### For Maintainers+- All three main sections (Setup, Schema, Troubleshooting) in **SKILL.md**+- Add new safe tables in "Safe Tables for Querying" section+- Update blocked tables list if access changes++## π‘ Example Usage++### Get Active Features+```typescript+const agent = SupabaseReadAgent+const features = await agent.getActiveFeatures()++// Output:+// [+// { id: "uuid", name: "ocr_beta", enabled: true, ... },+// { id: "uuid", name: "advanced_search", enabled: false, ... }+// ]+```++### Check Feature Status+```typescript+const isEnabled = await agent.getFeatureStatus("ocr_beta")+console.log(`OCR Beta: ${isEnabled ? "enabled" : "disabled"}`)+```++### Get Pricing Information+```typescript+const tiers = await agent.getPricingTiers()+tiers.forEach(tier => {+ console.log(`${tier.name}: $${tier.monthly_price / 100}/month`)+})+```++### Query Analytics with Filters+```typescript+const events = await agent.queryPublicAnalytics({+ eventType: "capture",+ startDate: new Date("2025-01-01"),+ endDate: new Date("2025-02-01"),+ limit: 100+})+```++## π Environment Variables++The agent reads from `.env.local` (never committed):++```env+SUPABASE_URL=https://[project-id].supabase.co+SUPABASE_PUBLIC_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...+```++**To get these:**+```bash+vercel env pull+```++## βοΈ How It Works++1. **Public Key Only** - The agent uses only the Supabase public key+2. **RLS Policies** - Supabase database enforces row-level security+3. **Limited Tables** - Public key can only access documented tables+4. **Read-Only** - Supabase policies block writes/deletes+5. **Rate Limited** - 100 req/min per IP, 10k/day per project++```+βββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β Your Agent/Skill β+ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ+ β+ β (read-only query)+ βΌ+βββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β SupabaseReadAgent (public key only) β+ββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ+ β+ β (public_key + SELECT query)+ βΌ+βββββββββββββββββββββββββββββββββββββββββββββββββββββββ+β Supabase (eu.i.posthog.com) β+β βββββββββββββββββββββββββββββββββββββββββββββββββββ β+β β Row-Level Security β β+β β β Allow: SELECT from user_analytics β β+β β β Allow: SELECT from features β β+β β β Allow: SELECT from pricing_tiers β β+β β β Block: users, sessions, logs, api_keys β β+β β β Block: Any write/delete operations β β+β βββββββββββββββββββββββββββββββββββββββββββββββββββ β+βββββββββββββββββββββββββββββββββββββββββββββββββββββββ+```++## π¨ What NOT to Do++```typescript+// β Never hardcode keys+const client = createClient(+ "https://...",+ "eyJ...hardcoded"+)++// β Never commit .env.local+git add .env.local // NO! It's .gitignored++// β Never query blocked tables+await supabase.from("users").select("*")+await supabase.from("sessions").select("*")+await supabase.from("logs").select("*")++// β Never attempt writes+await supabase.from("features").insert({ ... })+await supabase.from("pricing_tiers").update({ ... })+```++## β What to Do++```typescript+// β Use environment variables+const client = createClient(+ process.env.SUPABASE_URL!,+ process.env.SUPABASE_PUBLIC_KEY!+)++// β Keep .env.local in .gitignore+// (It already is - verified in root .gitignore)++// β Only query safe tables+await supabase.from("features").select("name, enabled")+await supabase.from("pricing_tiers").select("name, price")++// β Read-only operations only+// (Supabase RLS blocks writes automatically)+```++## π Troubleshooting++| Problem | Solution |+|---------|----------|+| "Missing Supabase environment variables" | Run `vercel env pull` |+| "401 Unauthorized" | Check public key is correct (not private) |+| "403 Forbidden" | Table is blocked by RLS - check SKILL.md |+| "Column not found" | Verify column exists in schema |+| "Rate limit exceeded" | Cache results, wait 1 minute, try again |++See **SETUP.md** for detailed troubleshooting.++## π Related Resources++- **Supabase Docs:** https://supabase.com/docs+- **Row-Level Security:** https://supabase.com/docs/guides/auth/row-level-security+- **API Limits:** https://supabase.com/docs/guides/platform/api-limits+- **Main skill file:** See `SKILL.md` in this directory++## π For Skill Writers++Want to create a skill that uses this agent?++1. Read `SKILL.md` to understand the schema+2. Import `SupabaseReadAgent` from `supabase-agent.ts`+3. Use `PROMPT_TEMPLATE.md` for your prompts+4. Document what tables you're querying and why+5. Include safety notes in your skill docs++Example skill header:+```markdown+---+name: my-skill+description: "Query Screenpipe feature availability"+allowed-tools: Read, Write+---++This skill queries read-only Supabase tables:+- features (feature status)+- pricing_tiers (pricing information)++No private data is accessed.+```++## π License & Privacy++- **Code:** Licensed under Screenpipe project license+- **Data:** Only public, anonymized data is accessible+- **Privacy:** User data is never exposed via this agent+- **Transparency:** All tables and columns are documented++## β Questions?++If you need to:+- Query a different table+- Access currently blocked data+- Understand a specific column+- Add new tables++Contact the maintainers with a clear use case.++---++**Remember:** With great data access comes great responsibility. Use this agent wisely and respect user privacy. πdiff --git a/.pi/skills/supabase-read/SETUP.md b/.pi/skills/supabase-read/SETUP.mdnew file mode 100644index 000000000..44753f5cf--- /dev/null+++ b/.pi/skills/supabase-read/SETUP.md@@ -0,0 +1,197 @@+# Supabase Read-Only Agent - Setup Guide++## Quick Start++### 1. Install Dependencies++```bash+# In your project root+bun add @supabase/supabase-js+```++### 2. Fetch Environment Variables (Secure)++```bash+# Install Vercel CLI if you don't have it+npm i -g vercel++# Pull environment from Vercel (never commit .env.local!)+vercel env pull++# Verify keys are loaded+cat .env.local | grep SUPABASE+```++Your `.env.local` should now have:+```env+SUPABASE_URL=https://[project-id].supabase.co+SUPABASE_PUBLIC_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...+```++### 3. Use the Agent++```typescript+import { SupabaseReadAgent } from "./.pi/skills/supabase-read/supabase-agent";++async function example() {+ // List active features+ const features = await SupabaseReadAgent.getActiveFeatures();+ console.log("Features:", features);++ // Check pricing+ const pricing = await SupabaseReadAgent.getPricingTiers();+ console.log("Pricing tiers:", pricing);++ // Query analytics with filters+ const analytics = await SupabaseReadAgent.queryPublicAnalytics({+ eventType: "capture",+ startDate: new Date("2025-01-01"),+ limit: 100,+ });+ console.log("Events:", analytics);+}++example().catch(console.error);+```++## Safety Checklist++- [ ] Using **public key** only (never private keys)+- [ ] `.env.local` is in `.gitignore` (never commit secrets)+- [ ] Only querying tables in the documented schema+- [ ] Not attempting to modify/delete data (read-only)+- [ ] Not trying to access blocked tables (users, sessions, logs, etc.)+- [ ] Caching results to respect rate limits (100 req/min)++## Troubleshooting++### "Missing Supabase environment variables"++```bash+# Re-pull environment+vercel env pull++# Or manually set (temporary only!)+export SUPABASE_URL=https://[project-id].supabase.co+export SUPABASE_PUBLIC_KEY=your_public_key+```++### "401 Unauthorized"++Your key is invalid or expired:+```bash+# Get fresh key from Vercel+vercel env pull --force++# Verify it's the PUBLIC key, not private+grep SUPABASE_PUBLIC_KEY .env.local+```++### "403 Forbidden"++RLS policy blocks this table for your key:+- Check the table is in the "Safe Tables" section of `SKILL.md`+- Contact maintainers if you need access to a public table++### "Column not found"++Verify the column exists in the schema:+- Check `SKILL.md` for the table definition+- Use specific columns: `.select("id, name")` instead of `.select("*")`++## Integration with Pi Skills++In your Pi skill that uses Supabase:++```markdown+---+name: my-custom-skill+description: "My skill that queries Supabase public data"+allowed-tools: Read, Bash, Write+---++# My Custom Skill++This skill integrates with the Supabase read-only agent...++## Usage++When this skill runs, it reads from public Supabase tables:+- `user_analytics` - Feature usage statistics+- `features` - Feature availability+- `pricing_tiers` - Pricing information++No private data is accessed.+```++## Rate Limiting++Supabase public key has limits:+- **100 requests/minute** per IP+- **10,000 requests/day** per project++**Optimization tips:**+1. Cache frequently accessed data+2. Batch multiple queries+3. Use pagination: `.range(0, 99)`+4. Filter early: `.eq("event_type", "capture")`++## Never Do This++```typescript+// β WRONG: Hardcoding keys+const client = createClient(+ "https://project.supabase.co",+ "eyJ...hardcoded_key"+);++// β WRONG: Committing .env.local+git add .env.local // No! It's in .gitignore for a reason++// β WRONG: Fetching private tables+await supabase.from("users").select("*");+await supabase.from("api_keys").select("*");+await supabase.from("sessions").select("*");++// β WRONG: Attempting writes+await supabase.from("features").insert({ name: "test" });+await supabase.from("pricing_tiers").update({ price: 99 });+```++## Always Do This++```typescript+// β RIGHT: Use environment variables+const client = createClient(+ process.env.SUPABASE_URL!,+ process.env.SUPABASE_PUBLIC_KEY!+);++// β RIGHT: Keep .env.local in .gitignore+// Verified in .gitignore - never commit secrets++// β RIGHT: Only query documented public tables+await supabase.from("features").select("name, enabled");+await supabase.from("pricing_tiers").select("name, monthly_price");++// β RIGHT: Read-only operations only+// Supabase RLS blocks writes via public key automatically+```++## References++- **Supabase Docs:** https://supabase.com/docs+- **Row-Level Security:** https://supabase.com/docs/guides/auth/row-level-security+- **Public Keys:** Never expose private keys, only public keys are safe to share+- **Rate Limits:** https://supabase.com/docs/guides/platform/api-limits++## Questions?++If you need to query a different table or require different permissions, check:+1. Is the table in the "Safe Tables" section of `SKILL.md`?+2. Do you need data that's currently blocked (users, logs, etc.)?+3. Contact maintainers for approval before expanding access++---++**Remember:** Public β Unsafe. Just because we can query a table doesn't mean we should. Always respect user privacy.diff --git a/.pi/skills/supabase-read/SKILL.md b/.pi/skills/supabase-read/SKILL.mdnew file mode 100644index 000000000..b71276ee4--- /dev/null+++ b/.pi/skills/supabase-read/SKILL.md@@ -0,0 +1,313 @@+---+name: supabase-read+description: "Read-only Supabase agent. Query public database tables with schema documentation. Secure key retrieval via Vercel CLI."+allowed-tools: Bash, Read, Write+---++# Screenpipe Supabase Read-Only Agent++Safe, read-only access to the Screenpipe Supabase database for querying public data.++## Overview++This agent provides:+- **Read-only database queries** - no writes, deletes, or admin operations+- **Secure key management** - retrieves API key from Vercel CLI (never hardcoded)+- **Schema documentation** - public table structures without operational details+- **Safety guardrails** - blocks dangerous operations and sensitive data access++## Database Schema (Public)++### Safe Tables for Querying++#### `user_analytics` (Public Aggregate Data)+Purpose: User engagement metrics (anonymized)++```sql+-- Public columns only+id UUID PRIMARY KEY+user_id UUID (hashed/anonymized in public view)+event_type TEXT 'capture', 'query', 'export'+event_count INT Daily aggregate count+date DATE Event date+created_at TIMESTAMP Record creation+```++**Allowed Queries:**+- Count events by type+- Trending event types over time+- Regional statistics (if available)+- Feature adoption rates++**Forbidden:**+- User identification+- Session logs+- Debug/error information+- Performance metrics that expose infrastructure++---++#### `features` (Public Feature Metadata)+Purpose: Feature flags and availability++```sql+id UUID PRIMARY KEY+name TEXT Feature name (e.g., 'ocr_beta')+enabled BOOLEAN Active/inactive+description TEXT Feature description+created_at TIMESTAMP Creation date+updated_at TIMESTAMP Last update+```++**Allowed Queries:**+- List active features+- Feature availability status+- Feature rollout dates++---++#### `pricing_tiers` (Public Pricing Info)+Purpose: Subscription tier definitions++```sql+id UUID PRIMARY KEY+name TEXT 'free', 'pro', 'enterprise'+monthly_price INT Price in cents USD+features JSONB Feature set included+storage_gb INT Storage limit+api_calls_month INT API quota+created_at TIMESTAMP Tier creation date+```++**Allowed Queries:**+- Current pricing information+- Tier comparisons+- Feature availability by tier++---++## Unsafe Tables (Blocked)++**NEVER query these tables:**++| Table | Reason |+|-------|--------|+| `users` | Contains personal identifiable information |+| `sessions` | Session tokens, authentication data |+| `api_keys` | Private credentials |+| `logs` | System internals, debug information |+| `audit_trail` | User behavior history (privacy violation) |+| `payment_info` | Financial records |+| `support_tickets` | Private user communications |+| `error_logs` | Stack traces, configuration details |++---++## Environment Setup++### Getting the Supabase Key++**DO NOT** commit the key to git. Retrieve it securely:++```bash+# Using Vercel CLI (recommended)+vercel env pull++# This reads from Vercel project environment and creates .env.local+# Then fetch the public key:+grep SUPABASE_PUBLIC_KEY .env.local+```++If you don't have Vercel CLI:+```bash+# Install it+npm i -g vercel++# Login+vercel login++# Pull environment+vercel env pull++# View key (it's public, safe to share)+cat .env.local | grep SUPABASE_PUBLIC_KEY+```++### .env.local (GitIgnored)++Add to `.env.local` (never commit):++```env+SUPABASE_URL=https://[project-id].supabase.co+SUPABASE_PUBLIC_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...+```++The **public key** is safe to use in queries. Private keys should NEVER be in repos.++---++## Query Examples++### TypeScript/JavaScript Agent++```typescript+// supabase-agent.ts+import { createClient } from "@supabase/supabase-js";++const supabase = createClient(+ process.env.SUPABASE_URL!,+ process.env.SUPABASE_PUBLIC_KEY!+);++// β SAFE: Query public analytics+async function getEventStats() {+ const { data, error } = await supabase+ .from("user_analytics")+ .select("event_type, event_count, date")+ .gte("date", new Date(Date.now() - 30 * 24 * 60 * 60 * 1000)); // Last 30 days++ if (error) throw error;+ return data;+}++// β SAFE: List features+async function getActiveFeatures() {+ const { data, error } = await supabase+ .from("features")+ .select("name, description, enabled")+ .eq("enabled", true);++ if (error) throw error;+ return data;+}++// β BLOCKED: Don't query user sessions+// async function getUserSessions(userId) {+// // This will fail - table access denied+// const { data } = await supabase+// .from("sessions")+// .select("*")+// .eq("user_id", userId);+// }++// β BLOCKED: Don't fetch private API keys+// async function getApiKeys() {+// // This will fail - table access denied+// const { data } = await supabase.from("api_keys").select("*");+// }+```++### Row-Level Security (RLS)++All tables have RLS policies enforced:++```sql+-- Public tables only allow SELECT+CREATE POLICY "public_read_only" ON user_analytics+ FOR SELECT+ USING (true);++-- Private tables deny all access via public key+CREATE POLICY "deny_public_access" ON users+ FOR ALL+ USING (false);+```++The Supabase public key is restricted to these policies at the database level.++---++## Safety Guidelines++### β DO++- Query only documented public tables+- Use `.select("col1, col2")` to specify columns+- Filter data with `.eq()`, `.gte()`, `.lte()`+- Aggregate with COUNT, SUM (computed)+- Cache results to reduce queries+- Document why you're querying++### β DON'T++- Try to query undocumented tables+- Select `*` without knowing the schema+- Use `.select("*")` from unknown sources+- Attempt to bypass RLS policies+- Include raw SQL with `rpc()` calls+- Store or expose API keys in code+- Log sensitive data from responses++---++## Rate Limiting++Supabase has rate limits on public key access:+- 100 requests/minute per IP+- 10,000 requests/day per project++**Mitigation:**+- Batch queries where possible+- Cache frequently accessed data+- Use pagination for large result sets++---++## Usage in Skills/Agents++When writing agents that use this skill:++```typescript+import { createClient } from "@supabase/supabase-js";++interface SupabaseAgent {+ queryPublicAnalytics(filters: {+ eventType?: string;+ startDate?: Date;+ endDate?: Date;+ }): Promise<any[]>;++ getFeatureStatus(featureName: string): Promise<boolean>;++ getPricingTiers(): Promise<any[]>;+}+```++Document:+- What tables you're querying+- Why you need the data+- What you do with the results+- Any caching strategy++---++## Troubleshooting++### "401 Unauthorized"+- Check `SUPABASE_PUBLIC_KEY` is set correctly+- Verify key hasn't expired+- Confirm key is the **public** key, not private++### "403 Forbidden"+- Table has RLS policies that deny your key+- Check if table is in the "Unsafe Tables" list+- Contact maintainers if you need access to a public table++### "Connection timeout"+- Check network connectivity+- Verify `SUPABASE_URL` is correct+- Check rate limiting (100 req/min)++### "Column not found"+- Verify column name matches schema+- Use `.select("col1, col2")` to list available columns+- Check if column exists in the Supabase dashboard++---++## Related Files++- **Supabase Dashboard:** https://supabase.com/dashboard+- **Project ID:** Check `.env.local` or Vercel project settings+- **Row-Level Security:** Supabase console β Authentication β Policies+- **API Limits:** Supabase console β Settings β APIdiff --git a/.pi/skills/supabase-read/supabase-agent.ts b/.pi/skills/supabase-read/supabase-agent.tsnew file mode 100644index 000000000..578169220--- /dev/null+++ b/.pi/skills/supabase-read/supabase-agent.ts@@ -0,0 +1,266 @@+/**+ * Screenpipe Supabase Read-Only Agent+ *+ * Safe database queries for public data only.+ * Never commit API keys - use Vercel CLI to pull .env.local+ *+ * Usage:+ * vercel env pull+ * const agent = new SupabaseAgent()+ * await agent.getActiveFeatures()+ */++import { createClient } from "@supabase/supabase-js";++interface SupabaseAgent {+ queryPublicAnalytics(filters: {+ eventType?: string;+ startDate?: Date;+ endDate?: Date;+ limit?: number;+ }): Promise<any[]>;++ getActiveFeatures(): Promise<Feature[]>;++ getPricingTiers(): Promise<PricingTier[]>;++ getFeatureStatus(featureName: string): Promise<boolean>;+}++interface Feature {+ id: string;+ name: string;+ enabled: boolean;+ description: string;+ created_at: string;+ updated_at: string;+}++interface PricingTier {+ id: string;+ name: string;+ monthly_price: number;+ features: Record<string, boolean>;+ storage_gb: number;+ api_calls_month: number;+ created_at: string;+}++interface AnalyticsEvent {+ id: string;+ event_type: string;+ event_count: number;+ date: string;+ created_at: string;+}++/**+ * Initialize Supabase client with public key only.+ * Private keys should NEVER be used in agents/published code.+ */+function getSupabaseClient() {+ const url = process.env.SUPABASE_URL;+ const publicKey = process.env.SUPABASE_PUBLIC_KEY;++ if (!url || !publicKey) {+ throw new Error(+ "Missing Supabase environment variables. Run: vercel env pull"+ );+ }++ return createClient(url, publicKey);+}++/**+ * Query public analytics data with optional filters.+ *+ * Safe example usage:+ * ```+ * const agent = new SupabaseReadAgent()+ * const stats = await agent.queryPublicAnalytics({+ * eventType: 'capture',+ * startDate: new Date('2025-01-01'),+ * endDate: new Date('2025-02-01'),+ * limit: 100+ * })+ * ```+ */+async function queryPublicAnalytics(filters: {+ eventType?: string;+ startDate?: Date;+ endDate?: Date;+ limit?: number;+}): Promise<AnalyticsEvent[]> {+ const supabase = getSupabaseClient();++ let query = supabase+ .from("user_analytics")+ .select("id, event_type, event_count, date, created_at");++ // Build filter conditions+ if (filters.eventType) {+ query = query.eq("event_type", filters.eventType);+ }++ if (filters.startDate) {+ query = query.gte("date", filters.startDate.toISOString().split("T")[0]);+ }++ if (filters.endDate) {+ query = query.lte("date", filters.endDate.toISOString().split("T")[0]);+ }++ // Limit results (default 100, max 1000)+ const limit = Math.min(filters.limit || 100, 1000);+ query = query.limit(limit);++ const { data, error } = await query;++ if (error) {+ console.error("Supabase query error:", error.message);+ throw new Error(`Failed to fetch analytics: ${error.message}`);+ }++ return data || [];+}++/**+ * Get all active features.+ *+ * Safe example:+ * ```+ * const features = await agent.getActiveFeatures()+ * features.forEach(f => console.log(`${f.name}: ${f.description}`))+ * ```+ */+async function getActiveFeatures(): Promise<Feature[]> {+ const supabase = getSupabaseClient();++ const { data, error } = await supabase+ .from("features")+ .select("id, name, enabled, description, created_at, updated_at")+ .eq("enabled", true)+ .order("created_at", { ascending: false });++ if (error) {+ console.error("Supabase query error:", error.message);+ throw new Error(`Failed to fetch features: ${error.message}`);+ }++ return data || [];+}++/**+ * Get all pricing tiers.+ *+ * Safe example:+ * ```+ * const tiers = await agent.getPricingTiers()+ * tiers.forEach(t => console.log(`${t.name}: $${t.monthly_price / 100}`))+ * ```+ */+async function getPricingTiers(): Promise<PricingTier[]> {+ const supabase = getSupabaseClient();++ const { data, error } = await supabase+ .from("pricing_tiers")+ .select(+ "id, name, monthly_price, features, storage_gb, api_calls_month, created_at"+ )+ .order("monthly_price", { ascending: true });++ if (error) {+ console.error("Supabase query error:", error.message);+ throw new Error(`Failed to fetch pricing: ${error.message}`);+ }++ return data || [];+}++/**+ * Check if a specific feature is enabled.+ *+ * Safe example:+ * ```+ * const isOcrBetaEnabled = await agent.getFeatureStatus('ocr_beta')+ * if (isOcrBetaEnabled) { console.log('OCR beta is available') }+ * ```+ */+async function getFeatureStatus(featureName: string): Promise<boolean> {+ const supabase = getSupabaseClient();++ const { data, error } = await supabase+ .from("features")+ .select("enabled")+ .eq("name", featureName)+ .single();++ if (error) {+ console.warn(`Feature "${featureName}" not found`);+ return false;+ }++ return data?.enabled ?? false;+}++/**+ * β BLOCKED: Example of what NOT to do+ *+ * These operations will FAIL due to Row-Level Security policies:+ */++// β Attempting to query user sessions (private data)+// async function getUserSessions(userId: string) {+// const supabase = getSupabaseClient()+// const { data, error } = await supabase+// .from('sessions')+// .select('*')+// .eq('user_id', userId)+// // Result: 403 Forbidden - RLS policy blocks access+// }++// β Attempting to access API keys+// async function getApiKeys() {+// const supabase = getSupabaseClient()+// const { data, error } = await supabase.from('api_keys').select('*')+// // Result: 403 Forbidden - RLS policy blocks access+// }++// β Attempting to fetch user logs+// async function getUserLogs(userId: string) {+// const supabase = getSupabaseClient()+// const { data, error } = await supabase+// .from('logs')+// .select('*')+// .eq('user_id', userId)+// // Result: 403 Forbidden - RLS policy blocks access+// }++export const SupabaseReadAgent = {+ queryPublicAnalytics,+ getActiveFeatures,+ getPricingTiers,+ getFeatureStatus,+};++// Example usage (comment out in production)+if (require.main === module) {+ (async () => {+ console.log("Supabase Read-Only Agent\n");++ try {+ const features = await getActiveFeatures();+ console.log("Active features:", features.length);+ features.slice(0, 3).forEach((f) => console.log(` - ${f.name}`));++ const tiers = await getPricingTiers();+ console.log("\nPricing tiers:", tiers.length);+ tiers.forEach((t) => console.log(` - ${t.name}: $${t.monthly_price / 100}`));++ const analytics = await queryPublicAnalytics({ limit: 5 });+ console.log("\nRecent analytics:", analytics.length, "records");+ } catch (error) {+ console.error("Error:", (error as Error).message);+ }+ })();+}diff --git a/apps/screenpipe-app-tauri/components/deeplink-handler.tsx b/apps/screenpipe-app-tauri/components/deeplink-handler.tsxindex ccaf54425..656ad623a 100644--- a/apps/screenpipe-app-tauri/components/deeplink-handler.tsx+++ b/apps/screenpipe-app-tauri/components/deeplink-handler.tsx@@ -6,7 +6,7 @@ import { useChangelogDialog } from "@/lib/hooks/use-changelog-dialog";import { useStatusDialog } from "@/lib/hooks/use-status-dialog";import { useSettings } from "@/lib/hooks/use-settings";import { commands } from "@/lib/utils/tauri";-import { listen } from "@tauri-apps/api/event";+import { listen, emit } from "@tauri-apps/api/event";import { onOpenUrl } from "@tauri-apps/plugin-deep-link";import { openSettingsWindow } from "@/lib/utils/window";@@ -63,6 +63,36 @@ export function DeeplinkHandler() {if (url.includes("status")) {openStatusDialog();}++ // Handle timeline deep links: screenpipe://timeline?timestamp=ISO8601+ if (parsedUrl.pathname === "timeline" || parsedUrl.host === "timeline") {+ const timestamp = parsedUrl.searchParams.get("timestamp");+ if (timestamp) {+ try {+ // Validate timestamp format+ const date = new Date(timestamp);+ if (!isNaN(date.getTime())) {+ // Show the main window first+ await commands.showWindow("Main");+ // Emit the navigate event to timeline+ await emit("navigate-to-timestamp", timestamp);+ toast({+ title: "navigating to timestamp",+ description: `jumping to ${date.toLocaleString()}`,+ });+ } else {+ throw new Error("Invalid date");+ }+ } catch (error) {+ console.error("Failed to parse timeline timestamp:", error);+ toast({+ title: "invalid timestamp",+ description: "could not parse the timeline link",+ variant: "destructive",+ });+ }+ }+ }}});return unsubscribeDeepLink;diff --git a/apps/screenpipe-app-tauri/components/global-chat.tsx b/apps/screenpipe-app-tauri/components/global-chat.tsxindex c85981ff2..458c10831 100644--- a/apps/screenpipe-app-tauri/components/global-chat.tsx+++ b/apps/screenpipe-app-tauri/components/global-chat.tsx@@ -3,7 +3,7 @@import * as React from "react";import { useState, useRef, useEffect } from "react";import { usePathname } from "next/navigation";-import { listen } from "@tauri-apps/api/event";+import { listen, emit } from "@tauri-apps/api/event";import { Dialog, DialogTitle } from "@/components/ui/dialog";import { Input } from "@/components/ui/input";import { Button } from "@/components/ui/button";@@ -2455,6 +2455,46 @@ export function GlobalChat() {if (isMediaLink && href) {return <VideoComponent filePath={href} className="my-2" />;}++ // Handle screenpipe:// timeline deep links in-app+ if (href?.startsWith("screenpipe://timeline")) {+ const handleTimelineClick = async (e: React.MouseEvent) => {+ e.preventDefault();+ try {+ const url = new URL(href);+ const timestamp = url.searchParams.get("timestamp");+ if (timestamp) {+ const date = new Date(timestamp);+ if (!isNaN(date.getTime())) {+ await commands.showWindow("Main");+ await emit("navigate-to-timestamp", timestamp);+ toast({+ title: "navigating to timestamp",+ description: `jumping to ${date.toLocaleString()}`,+ });+ }+ }+ } catch (error) {+ console.error("Failed to navigate to timeline:", error);+ toast({+ title: "navigation failed",+ description: "could not navigate to the timeline",+ variant: "destructive",+ });+ }+ };++ return (+ <button+ onClick={handleTimelineClick}+ className="underline underline-offset-2 text-blue-500 hover:text-blue-400 cursor-pointer inline"+ {...props}+ >+ {children}+ </button>+ );+ }+return (<a href={href} target="_blank" rel="noopener noreferrer" className="underline underline-offset-2" {...props}>{children}diff --git a/apps/screenpipe-app-tauri/components/rewind/chat-message.tsx b/apps/screenpipe-app-tauri/components/rewind/chat-message.tsxindex f72792dae..2c49bac68 100644--- a/apps/screenpipe-app-tauri/components/rewind/chat-message.tsx+++ b/apps/screenpipe-app-tauri/components/rewind/chat-message.tsx@@ -2,6 +2,7 @@ import { Message } from "ai";import remarkGfm from "remark-gfm";import remarkMath from "remark-math";import { useState, useEffect, useRef } from "react";+import { emit } from "@tauri-apps/api/event";import { cn } from "@/lib/utils";import { CodeBlock } from "@/components/ui/codeblock";@@ -17,6 +18,8 @@ import { useSettings } from "@/lib/hooks/use-settings";import { VideoComponent } from "./video";import { MermaidDiagram } from "./mermaid-diagram";import { ChevronDown } from "lucide-react";+import { commands } from "@/lib/utils/tauri";+import { toast } from "@/components/ui/use-toast";export interface ChatMessageProps {message: Message;@@ -163,6 +166,46 @@ export function ChatMessage({ message, ...props }: ChatMessageProps) {if (isMP4Link && href) {return <VideoComponent filePath={href} />;}++ // Handle screenpipe:// timeline deep links in-app+ if (href?.startsWith("screenpipe://timeline")) {+ const handleTimelineClick = async (e: React.MouseEvent) => {+ e.preventDefault();+ try {+ const url = new URL(href);+ const timestamp = url.searchParams.get("timestamp");+ if (timestamp) {+ const date = new Date(timestamp);+ if (!isNaN(date.getTime())) {+ await commands.showWindow("Main");+ await emit("navigate-to-timestamp", timestamp);+ toast({+ title: "navigating to timestamp",+ description: `jumping to ${date.toLocaleString()}`,+ });+ }+ }+ } catch (error) {+ console.error("Failed to navigate to timeline:", error);+ toast({+ title: "navigation failed",+ description: "could not navigate to the timeline",+ variant: "destructive",+ });+ }+ };++ return (+ <button+ onClick={handleTimelineClick}+ className="underline underline-offset-2 text-blue-500 hover:text-blue-400 cursor-pointer inline"+ {...props}+ >+ {children}+ </button>+ );+ }+return (<ahref={href}diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsxindex f84613e9b..9fd3fa838 100644--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx@@ -20,6 +20,7 @@ import remarkGfm from "remark-gfm";import OpenAI from "openai";import { ChatCompletionTool } from "openai/resources/chat/completions";import { open as openUrl } from "@tauri-apps/plugin-shell";+import { emit } from "@tauri-apps/api/event";import { getCurrentWindow } from "@tauri-apps/api/window";import { usePlatform } from "@/lib/hooks/use-platform";import { useSqlAutocomplete } from "@/lib/hooks/use-sql-autocomplete";@@ -126,6 +127,14 @@ graph TD\`\`\`Use flowcharts (graph TD/LR), sequence diagrams, pie charts, etc. as appropriate.+TIMELINE DEEP LINKS:+When referencing specific moments from search results, create clickable links so users can jump to that point in their timeline.+Format: [readable time](screenpipe://timeline?timestamp=ISO8601_TIMESTAMP)+Examples:+- [10:30 AM](screenpipe://timeline?timestamp=2024-01-15T18:30:00Z)+- [yesterday at 3pm](screenpipe://timeline?timestamp=2024-01-14T15:00:00Z)+Always use the exact timestamp from search results. Users can click these to navigate directly to that moment.+Current time: ${now.toISOString()}User's timezone: ${timezone} (UTC${offsetStr})User's local time: ${now.toLocaleString()}`;@@ -1432,6 +1441,46 @@ export function StandaloneChat() {if (isMediaLink && href) {return <VideoComponent filePath={href} className="my-2" />;}++ // Handle screenpipe:// timeline deep links in-app+ if (href?.startsWith("screenpipe://timeline")) {+ const handleTimelineClick = async (e: React.MouseEvent) => {+ e.preventDefault();+ try {+ const url = new URL(href);+ const timestamp = url.searchParams.get("timestamp");+ if (timestamp) {+ const date = new Date(timestamp);+ if (!isNaN(date.getTime())) {+ await commands.showWindow("Main");+ await emit("navigate-to-timestamp", timestamp);+ toast({+ title: "navigating to timestamp",+ description: `jumping to ${date.toLocaleString()}`,+ });+ }+ }+ } catch (error) {+ console.error("Failed to navigate to timeline:", error);+ toast({+ title: "navigation failed",+ description: "could not navigate to the timeline",+ variant: "destructive",+ });+ }+ };++ return (+ <button+ onClick={handleTimelineClick}+ className="underline underline-offset-2 text-blue-500 hover:text-blue-400 cursor-pointer inline"+ {...props}+ >+ {children}+ </button>+ );+ }+return (<a href={href} target="_blank" rel="noopener noreferrer" className="underline underline-offset-2" {...props}>{children}diff --git a/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts b/crates/screenpipe-integrations/screenpipe-mcp/src/index.tsindex 576aa626c..2389d691b 100644--- a/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts+++ b/crates/screenpipe-integrations/screenpipe-mcp/src/index.ts@@ -64,7 +64,11 @@ const BASE_TOOLS: Tool[] = ["Search screenpipe's recorded content: screen text (OCR), audio transcriptions, and UI elements. " +"Returns timestamped results with app context. " +"Call with no parameters to get recent activity. " +- "Use the 'screenpipe://context' resource for current time when building time-based queries.",+ "Use the 'screenpipe://context' resource for current time when building time-based queries.\n\n" ++ "DEEP LINKS: When referencing specific moments in results, create clickable timeline links:\n" ++ "Format: [readable time](screenpipe://timeline?timestamp=ISO8601_TIMESTAMP)\n" ++ "Example: [10:30 AM](screenpipe://timeline?timestamp=2024-01-15T18:30:00Z)\n" ++ "Users can click these links to jump directly to that moment in their timeline.",annotations: {title: "Search Content",readOnlyHint: true,@@ -369,7 +373,19 @@ Screenpipe captures three types of data:1. Read screenpipe://context first to get current timestamps2. Use search-ui-events for "what did I type?" queries3. Use get-ui-event-stats to understand app usage patterns-4. Combine search-content (what was on screen) with search-ui-events (what was done)`,+4. Combine search-content (what was on screen) with search-ui-events (what was done)++## Timeline Deep Links+When showing search results to users, create clickable links to specific moments:++**Format:** \`[readable time](screenpipe://timeline?timestamp=ISO8601_TIMESTAMP)\`++**Examples:**+- \`[10:30 AM](screenpipe://timeline?timestamp=2024-01-15T18:30:00Z)\`+- \`[yesterday at 3pm](screenpipe://timeline?timestamp=2024-01-14T15:00:00Z)\`++Users can click these links to jump directly to that moment in their screenpipe timeline.+Always use the exact timestamp from search results when creating these links.`,},],};