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
fix(chat): load pi project extensions under 0.80 trust gating, teach connection gate about composio (#5333)
Ansh Grover3fc1e8e1406c
diff --git a/apps/screenpipe-app-tauri/src-tauri/assets/extensions/connection-gate.ts b/apps/screenpipe-app-tauri/src-tauri/assets/extensions/connection-gate.tsindex 359a583fb..41ab4b1b4 100644--- a/apps/screenpipe-app-tauri/src-tauri/assets/extensions/connection-gate.ts+++ b/apps/screenpipe-app-tauri/src-tauri/assets/extensions/connection-gate.ts@@ -104,6 +104,8 @@ async function findMcpProviderServer(}async function enrichConnection(connection: ConnectionItem, signal?: AbortSignal): Promise<ConnectionItem> {+ const composio = await composioEnrichment(connection.id, signal);+ if (composio) return { ...connection, ...composio };const server = await findMcpProviderServer(connection.id, signal);if (!server) return connection;return {@@ -114,6 +116,51 @@ async function enrichConnection(connection: ConnectionItem, signal?: AbortSignal};}+// Gmail and Zoom connect through Composio's managed auth: the desktop app+// registers one shared MCP server whose URL points at screenpipe.com's+// passthrough. That server only exists after a successful connect, so its+// presence IS the connected signal. Gmail has no /connections entry at all+// (it is a frontend-only tile), so without this the gate tells the model+// Gmail doesn't exist even though the tools are one sp_mcp_call away.+const COMPOSIO_TOOLKIT_IDS = new Set(["gmail", "zoom"]);+const COMPOSIO_URL_RE = /^https:\/\/(www\.)?(screenpipe\.com|screenpi\.pe)\/api\/composio\/mcp\/?$/;++async function findComposioServer(signal?: AbortSignal): Promise<McpServerItem | null> {+ const servers = await fetchMcpServers(signal).catch(() => []);+ return (+ servers.find(+ (item) => item.enabled !== false && COMPOSIO_URL_RE.test(normalizeUrl(item.url || ""))+ ) ?? null+ );+}++async function composioEnrichment(+ connectionId: string,+ signal?: AbortSignal+): Promise<Partial<ConnectionItem> | null> {+ if (!COMPOSIO_TOOLKIT_IDS.has(connectionId)) return null;+ const server = await findComposioServer(signal);+ if (!server) return null;+ return {+ connected: true,+ mcp: true,+ mcp_server_id: server.id,+ };+}++function composioSyntheticConnection(id: string, serverId: string): ConnectionItem {+ const name = id === "gmail" ? "Gmail" : "Zoom";+ return {+ id,+ name,+ connected: true,+ mcp: true,+ mcp_server_id: serverId,+ category: id === "gmail" ? "Communication" : "Meetings",+ description: `${name} via Composio managed auth. Discover tools with sp_mcp_list_tools (server_id "${serverId}"), then call them with sp_mcp_call — e.g. GMAIL_* / ZOOM_* tools through COMPOSIO_SEARCH_TOOLS and COMPOSIO_MULTI_EXECUTE_TOOL.`,+ };+}+function connectionPayload(connection: ConnectionItem, id: string) {const name = connectionLabel(connection, id);const viaMcp = connection.mcp === true;@@ -179,6 +226,17 @@ export default function (pi: ExtensionAPI) {const enrichedConnections = await Promise.all(connections.map((connection) => enrichConnection(connection, signal)));+ // Gmail (and Zoom, if its legacy integration ever goes away) exists+ // only as a Composio-backed frontend tile — synthesize entries so the+ // model learns they are reachable through the Composio MCP server.+ const composioServer = await findComposioServer(signal);+ if (composioServer) {+ for (const id of COMPOSIO_TOOLKIT_IDS) {+ if (!enrichedConnections.some((connection) => connection.id === id)) {+ enrichedConnections.push(composioSyntheticConnection(id, composioServer.id));+ }+ }+ }const visible = enrichedConnections.filter((connection) => connection.id !== "owned-default").map((connection) => connectionPayload(connection, connection.id));@@ -239,9 +297,16 @@ export default function (pi: ExtensionAPI) {try {const connections = await fetchConnections(signal).catch(() => []);const rawConnection = connections.find((item) => item.id === connectionId);- const connection = rawConnection+ let connection = rawConnection? await enrichConnection(rawConnection, signal): undefined;+ // Gmail has no /connections entry — resolve it via the Composio server.+ if (!connection && COMPOSIO_TOOLKIT_IDS.has(connectionId)) {+ const composioServer = await findComposioServer(signal);+ if (composioServer) {+ connection = composioSyntheticConnection(connectionId, composioServer.id);+ }+ }name = connectionLabel(connection, connectionId);if (connection?.connected === true) {const payload = connectionPayload(connection, connectionId);diff --git a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs b/apps/screenpipe-app-tauri/src-tauri/src/pi.rsindex 408c887fc..adc8cac22 100644--- a/apps/screenpipe-app-tauri/src-tauri/src/pi.rs+++ b/apps/screenpipe-app-tauri/src-tauri/src/pi.rs@@ -1884,6 +1884,11 @@ pub async fn pi_start_inner(cmd.current_dir(&project_dir).args(["--mode","rpc",+ // pi 0.80 gates project-dir .pi/extensions behind a trust prompt that+ // rpc mode can never answer — without --approve, mcp-bridge and+ // connection-gate silently don't load. The project dir is created and+ // populated exclusively by screenpipe, so it is trusted by definition.+ "--approve","--provider",&pi_provider,"--model",@@ -4332,10 +4337,12 @@ error: InstallFailed extracting tarball"#;} else {Command::new(&pi_path)};- cmd.args(["--mode", "rpc", "--provider", provider, "--model", model])- .stdin(Stdio::piped())- .stdout(Stdio::piped())- .stderr(Stdio::piped());+ cmd.args([+ "--mode", "rpc", "--approve", "--provider", provider, "--model", model,+ ])+ .stdin(Stdio::piped())+ .stdout(Stdio::piped())+ .stderr(Stdio::piped());cmd.spawn().ok()}diff --git a/crates/screenpipe-core/src/agents/pi.rs b/crates/screenpipe-core/src/agents/pi.rsindex 544cd5df0..c0b61b084 100644--- a/crates/screenpipe-core/src/agents/pi.rs+++ b/crates/screenpipe-core/src/agents/pi.rs@@ -1425,6 +1425,12 @@ impl PiExecutor {// as a single string, and the long prompt text can break arg parsing// if flags come after it.cmd.arg("--mode").arg("json");+ // pi 0.80 gates project-dir resources (.pi/extensions — mcp-bridge,+ // connection-gate, …) behind a project-trust prompt that can never be+ // answered in non-interactive mode, so without this flag every project+ // extension is silently skipped. The working dir is created and+ // populated exclusively by screenpipe, so it is trusted by definition.+ cmd.arg("--approve");if continue_session {cmd.arg("--continue");} else {