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
stuff
Louis Beaumontcdbd9ab07096
diff --git a/examples/typescript/pipe-digital-clone/pipe.json b/examples/typescript/pipe-digital-clone/pipe.jsonnew file mode 100644index 000000000..19004b454--- /dev/null+++ b/examples/typescript/pipe-digital-clone/pipe.json@@ -0,0 +1,40 @@+{+ "fields": [+ {+ "name": "authtoken",+ "type": "string",+ "default": "",+ "description": "your ngrok authtoken from https://dashboard.ngrok.com/get-started/your-authtoken"+ },+ {+ "name": "domain",+ "type": "string",+ "default": "",+ "description": "optional: your custom domain if you have one"+ },+ {+ "name": "gptModel",+ "type": "string",+ "default": "gpt-4o",+ "description": "OpenAI GPT model to use (e.g. gpt-4). If provided with openaiApiKey, OpenAI will be used instead of Ollama"+ },+ {+ "name": "openaiApiKey",+ "type": "string",+ "default": "",+ "description": "OpenAI API key. If provided with gptModel, OpenAI will be used instead of Ollama"+ },+ {+ "name": "ollamaApiUrl",+ "type": "string",+ "default": "http://localhost:11434/api",+ "description": "Ollama API URL. Used if openaiApiKey is not provided"+ },+ {+ "name": "ollamaModel",+ "type": "string",+ "default": "llama3.2:3b-instruct-q4_K_M",+ "description": "Ollama Model. Used if openaiApiKey is not provided"+ }+ ]+}\ No newline at end of filediff --git a/examples/typescript/pipe-digital-clone/pipe.ts b/examples/typescript/pipe-digital-clone/pipe.tsnew file mode 100644index 000000000..2168efae5--- /dev/null+++ b/examples/typescript/pipe-digital-clone/pipe.ts@@ -0,0 +1,164 @@+import ngrok from "@ngrok/ngrok";+// import { pipe } from "@screenpipe/js";+import { pipe } from "/Users/louisbeaumont/Documents/screen-pipe/screenpipe-js/main.ts";+import { z } from "zod";+import { generateObject } from "ai";+import { createOllama } from "ollama-ai-provider";+import { createOpenAI } from "@ai-sdk/openai";+import express from "express";+++++async function startServer(config: any): Promise<express.Express> {+ const app = express();+ app.use(express.json());++ app.post("/api/query", async (req, res) => {+ const { query } = req.body;++ try {+ console.log("query:", query);++ const q = {+ contentType: "audio",+ limit: 1000045,+ offset: 0,+ minLength: 1,+ maxLength: 10000,+ startTime: "2024-10-24T23:23:08.504Z",+ endTime: "2024-11-23T23:23:08.504Z",+ };+ console.log(+ "querying screenpipe with params:",+ JSON.stringify(q, null, 2)+ );+ // Query screenpipe with AI-generated parameters+ // @ts-ignore+ const results = await pipe.queryScreenpipe(q);++ // Ask for permission to share these specific results+ // const allowed = true; // temporarily allow all requests+ const allowed = await new Promise((resolve) => {+ pipe.inbox.send({+ title: "incoming api request",+ body: `allow sharing results for query: "${query}"?++search parameters:+${JSON.stringify(q, null, 2)}+++ `,+ actions: [+ { label: "allow", callback: async () => resolve(true) },+ { label: "deny", callback: async () => resolve(false) },+ ],+ });+ });++ // raw results:+// \`\`\`json+// ${JSON.stringify(results, null, 2)}+// \`\`\`+ if (!allowed) {+ return res.status(403).json({ error: "access denied by user" });+ }++ // Return raw results if allowed+ res.json(results);+ } catch (error) {+ console.error("api error:", error);+ res.status(500).json({ error: "internal server error" });+ }+ });++ return app;+}++async function startNgrokTunnel(): Promise<void> {+ try {+ const config = pipe.loadPipeConfig();++ const app = await startServer(config);++ // Start express on a random port+ const port = await new Promise<number>((resolve) => {+ const server = app.listen(0, () => {+ const addr = server.address();+ resolve(typeof addr === "object" ? addr!.port : 0);+ });+ });++ console.log("starting ngrok tunnel to api server");++ const listener = await ngrok.connect({+ addr: port,+ authtoken: config.authtoken,+ domain: config.domain || undefined,+ });++ const tunnelUrl = listener.url();+ console.log(`tunnel established: ${tunnelUrl}`);++ await pipe.inbox.send({+ title: "ngrok tunnel started",+ body: `api is now accessible at: ${tunnelUrl}/api/query`,+ });++ process.on("SIGINT", async () => {+ console.log("shutting down ngrok tunnel");+ await listener.close();+ process.exit(0);+ });+ } catch (error) {+ console.error("error starting ngrok tunnel:", error);+ }+}++startNgrokTunnel();++/*++Instructions to run this pipe:++1. install screenpipe and git clone this repo+ ```+ git clone https://github.com/mediar-ai/screenpipe.git+ cd screenpipe+ ```++2. set up ngrok:+ - create an account at https://ngrok.com+ - get your authtoken from https://dashboard.ngrok.com/get-started/your-authtoken+ - set environment variables:+ ```+ export NGROK_AUTHTOKEN=your_authtoken+ # optional: set a custom domain if you have one+ export NGROK_DOMAIN=your-custom-domain+ ```++3. run the pipe:+ ```+ screenpipe pipe download ./examples/typescript/pipe-ngrok+ screenpipe pipe enable pipe-ngrok+ screenpipe+ ```++For development, you can run:+```+# these are mandatory env variables+export SCREENPIPE_DIR="$HOME/.screenpipe"+export PIPE_ID="pipe-digital-clone"+export PIPE_FILE="pipe.ts"+export PIPE_DIR="$SCREENPIPE_DIR/pipes/pipe-digital-clone"++bun run examples/typescript/pipe-digital-clone/pipe.ts+```++# Using curl+curl -X POST \+ https://select-merely-gelding.ngrok-free.app/api/query \+ -H "Content-Type: application/json" \+ -d '{"query": "find my recent chrome windows about AI"}'++*/diff --git a/examples/typescript/pipe-obsidian-time-logs/pipe.json b/examples/typescript/pipe-obsidian-time-logs/pipe.jsonindex 213198b6b..797290b76 100644--- a/examples/typescript/pipe-obsidian-time-logs/pipe.json+++ b/examples/typescript/pipe-obsidian-time-logs/pipe.json@@ -21,7 +21,7 @@{"name": "gptModel","type": "string",- "default": "",+ "default": "gpt-4o","description": "OpenAI GPT model to use (e.g. gpt-4). If provided with openaiApiKey, OpenAI will be used instead of Ollama"},{diff --git a/examples/typescript/pipe-obsidian-time-logs/pipe.ts b/examples/typescript/pipe-obsidian-time-logs/pipe.tsindex 33c04af62..c795f5b8d 100644--- a/examples/typescript/pipe-obsidian-time-logs/pipe.ts+++ b/examples/typescript/pipe-obsidian-time-logs/pipe.ts@@ -64,25 +64,18 @@ async function syncLogToObsidian(try {console.log("syncLogToObsidian", logEntry);- // Create the daily note filename in format YYYY-MM-DD.mdconst today = new Date();- const filename = `${today.getFullYear()}-${String(- today.getMonth() + 1- ).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}.md`;+ const filename = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}.md`;const filePath = path.join(obsidianPath, filename);- // Create markdown table row for the entryconst tableRow = `| ${logEntry.title} | ${logEntry.description} | ${logEntry.tags.join(", ")} | ${logEntry.timeSpent} min |\n`;try {- // Try to read existing fileawait fs.access(filePath);- // File exists, append to itawait fs.appendFile(filePath, tableRow, "utf8");} catch {- // File doesn't exist, create it with header and first rowconst content = `| Title | Description | Tags | Time Spent |\n|-------|-------------|------|------------|\n${tableRow}`;await fs.writeFile(filePath, content, "utf8");}@@ -91,13 +84,13 @@ async function syncLogToObsidian(await pipe.inbox.send({title: "work log synced",- body: `new work log entry synced to Obsidian: ${filename}`,+ body: `new work log entry synced to: ${filePath}`,});} catch (error) {console.error("error syncing work log to obsidian:", error);await pipe.inbox.send({title: "work log error",- body: `error syncing work log to obsidian: ${error}`,+ body: `error syncing work log to: ${obsidianPath}\nerror: ${error}`,});}}@@ -109,7 +102,7 @@ function streamWorkLogs(): void {console.log("loaded config:", JSON.stringify(config, null, 2));let successfulLogsCount = 0;- const NOTIFICATION_THRESHOLD = 5; // Send notification every 5 successful logs+ const NOTIFICATION_THRESHOLD = 5;const interval = config.interval * 1000;const obsidianPath = config.obsidianPath;@@ -148,11 +141,12 @@ function streamWorkLogs(): void {successfulLogsCount++;if (successfulLogsCount >= NOTIFICATION_THRESHOLD) {+ const filePath = path.join(obsidianPath, `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}.md`);await pipe.inbox.send({title: "work logs batch synced",- body: `synced ${NOTIFICATION_THRESHOLD} work log entries to obsidian`,+ body: `synced ${NOTIFICATION_THRESHOLD} work log entries to: ${filePath}`,});- successfulLogsCount = 0; // Reset counter+ successfulLogsCount = 0;}} else {console.log("no relevant activity detected in the last interval");diff --git a/screenpipe-app-tauri/components/search-chat.tsx b/screenpipe-app-tauri/components/search-chat.tsxindex af0a71c7b..952e43299 100644--- a/screenpipe-app-tauri/components/search-chat.tsx+++ b/screenpipe-app-tauri/components/search-chat.tsx@@ -1395,8 +1395,8 @@ export function SearchChat({value={[limit]}onValueChange={(value: number[]) => setLimit(value[0])}min={10}- max={150}- step={5}+ max={15000}+ step={10}className="flex-grow"/><TooltipProvider>diff --git a/screenpipe-js/main.ts b/screenpipe-js/main.tsindex 4026a0937..e55b2173c 100644--- a/screenpipe-js/main.ts+++ b/screenpipe-js/main.ts@@ -199,7 +199,21 @@ export async function queryScreenpipe(try {const response = await fetch(url);if (!response.ok) {- throw new Error(`HTTP error! status: ${response.status}`);+ const errorText = await response.text();+ let errorJson;+ try {+ errorJson = JSON.parse(errorText);+ console.error("screenpipe api error:", {+ status: response.status,+ error: errorJson,+ });+ } catch {+ console.error("screenpipe api error:", {+ status: response.status,+ error: errorText,+ });+ }+ throw new Error(`http error! status: ${response.status}`);}const data = await response.json();return convertToCamelCase(data) as ScreenpipeResponse;