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(screenpipe-team skill): use enterprise API token, not cloud auth

Louis Beaumont436e58db7527
diff --git a/crates/screenpipe-core/assets/skills/screenpipe-team/SKILL.md b/crates/screenpipe-core/assets/skills/screenpipe-team/SKILL.md
index 1e7927c95..d84825431 100644
--- a/crates/screenpipe-core/assets/skills/screenpipe-team/SKILL.md
+++ b/crates/screenpipe-core/assets/skills/screenpipe-team/SKILL.md
@@ -9,23 +9,25 @@ Query the customer's team telemetry. Data lives in the customer's own Azure Blob
## Auth
-Two pieces, both already on disk — no separate token to paste:
-
-- **Cloud session JWT** from `~/.screenpipe/auth.json` (`.token`) — the same signed-in identity that powers cloud transcription and the chat proxy. The server validates this via Clerk; only admins of the license get past the check, non-admins get 403.
-- **License key** from `~/.screenpipe/enterprise.json` (`.license_key`) — tells the server which org the admin wants to query (one user can admin multiple).
-
-Pull both once per session into shell vars so you don't `jq` the files on every call:
+The skill uses an **enterprise API token** (format `sk_ent_…`) which the admin mints once on `https://screenpi.pe/enterprise?tab=tokens` with the `read:devices`, `read:search`, and `read:records` scopes. It's stored in `~/.screenpipe/enterprise.json` under the `team_api_token` key.
```bash
-CLOUD_TOKEN=$(jq -r .token ~/.screenpipe/auth.json)
-LICENSE_KEY=$(jq -r .license_key ~/.screenpipe/enterprise.json)
+TEAM_TOKEN=$(jq -r .team_api_token ~/.screenpipe/enterprise.json)
SP_URL="https://screenpi.pe/api/enterprise/v1"
-AUTH_HEADERS=(-H "Authorization: Bearer $CLOUD_TOKEN" -H "X-License-Key: $LICENSE_KEY")
+AUTH_HEADERS=(-H "Authorization: Bearer $TEAM_TOKEN")
```
-If either is empty / null, tell the user: "I need you to be signed in to screenpipe cloud AND have an active enterprise license. Open the app's enterprise settings to check." Don't proceed.
+If `team_api_token` is null or empty, tell the user verbatim:
+
+> I need an enterprise API token to query team data. Open
+> https://screenpi.pe/enterprise?tab=tokens, create a token with the
+> `read:devices`, `read:search`, `read:records` scopes, then either
+> paste it into Settings → Enterprise → Team API token in the desktop
+> app, or add it to `~/.screenpipe/enterprise.json` as `"team_api_token": "sk_ent_…"`.
+
+Then stop. Don't try to call the endpoints — they'll 401.
-If the server returns 403 ("not an admin of this license"): tell the user "you're not listed as an admin on this license — ask whoever owns the license to add your email under enterprise → members".
+If the server returns 401 the token is invalid or revoked; tell the user to mint a new one. If it returns 403, the token is missing the required scope — same dashboard, regenerate with the right scopes.
## Context window protection
diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rs
index 6c2e35c4d..df841fed9 100644
--- a/crates/screenpipe-core/src/agents/pi.rs
+++ b/crates/screenpipe-core/src/agents/pi.rs
@@ -259,17 +259,20 @@ impl PiExecutor {
.map(|s| !s.is_empty())
.unwrap_or(false);
- // The skill needs the cloud session JWT (auth.json) to talk to
- // screenpi.pe — no token means no session, means no admin.
- let auth_path = home.join(".screenpipe").join("auth.json");
- let cloud_signed_in = std::fs::read_to_string(&auth_path)
- .ok()
- .and_then(|raw| serde_json::from_str::<serde_json::Value>(&raw).ok())
- .and_then(|v| v.get("token").and_then(|t| t.as_str()).map(String::from))
+ // The skill needs an enterprise API token (sk_ent_…, format
+ // accepted by `withApiAuth` on the v1 endpoints). Admins mint
+ // one on screenpi.pe/enterprise?tab=tokens and paste it into
+ // enterprise.json. We previously tried using the cloud session
+ // token from auth.json but that's an `sp-…` value the v1 auth
+ // layer doesn't validate; the team-token path is the one that
+ // currently works end-to-end.
+ let team_token_present = parsed
+ .get("team_api_token")
+ .and_then(|v| v.as_str())
.map(|s| !s.is_empty())
.unwrap_or(false);
- is_admin && license_active && license_key_present && cloud_signed_in
+ is_admin && license_active && license_key_present && team_token_present
}
/// Ensure screenpipe skills exist in `project_dir/.pi/skills/`.