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
bump pipe
Louis Beaumontd680936145cb
diff --git a/examples/typescript/pipe-email-daily-log/pipe.ts b/examples/typescript/pipe-email-daily-log/pipe.tsindex 1ff8de48c..8506409d0 100644--- a/examples/typescript/pipe-email-daily-log/pipe.ts+++ b/examples/typescript/pipe-email-daily-log/pipe.ts@@ -1,12 +1,3 @@-interface ScreenData {- data: {- content: {- timestamp: string;- text: string;- };- }[];-}-interface DailyLog {activity: string;category: string;@@ -14,50 +5,8 @@ interface DailyLog {timestamp: string;}-function encodeQueryData(data: Record<string, string>): string {- return Object.keys(data)- .map((key) => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`)- .join("&");-}--async function queryScreenpipe(- startTime: string,- endTime: string,- windowName: string,- pageSize: number,- contentType: string-): Promise<ScreenData> {- try {- const params: Record<string, string> = {- content_type: contentType,- limit: pageSize.toString(),- offset: "0",- start_time: startTime,- end_time: endTime,- };-- if (windowName) {- params.window_name = windowName;- }-- const queryString = encodeQueryData(params);- const url = `http://localhost:3030/search?${queryString}`;- console.log("query url:", url);-- const response = await fetch(url);- if (!response.ok) {- console.log("screenpipe response:", await response.text());- throw new Error(`http error! status: ${response.status}`);- }- return await response.json();- } catch (error) {- console.warn("error querying screenpipe:", error);- return { data: [] };- }-}-async function generateDailyLog(- screenData: ScreenData,+ screenData: ContentItem[],customPrompt: string,ollamaModel: string,ollamaApiUrl: string@@ -264,7 +213,7 @@ async function dailyLogPipeline(): Promise<void> {const ollamaApiUrl = config.ollamaApiUrl;const windowName = config.windowName || "";const pageSize = config.pageSize;- const contentType = config.contentType || 'ocr'; // Default to 'ocr' if not specified+ const contentType = config.contentType || "ocr"; // Default to 'ocr' if not specifiedconsole.log("creating logs dir");const logsDir = `${process.env.PIPE_DIR}/logs`;@@ -299,17 +248,17 @@ async function dailyLogPipeline(): Promise<void> {const now = new Date();const oneMinuteAgo = new Date(now.getTime() - interval);- const screenData = await queryScreenpipe(- oneMinuteAgo.toISOString(),- now.toISOString(),- windowName,- pageSize,- contentType- );+ const screenData = await pipe.queryScreenpipe({+ start_time: oneMinuteAgo.toISOString(),+ end_time: now.toISOString(),+ window_name: windowName,+ limit: pageSize,+ content_type: contentType,+ });- if (screenData.data && screenData.data.length > 0) {+ if (screenData && screenData.data && screenData.data.length > 0) {const logEntry = await generateDailyLog(- screenData,+ screenData.data,customPrompt,ollamaModel,ollamaApiUrldiff --git a/examples/typescript/pipe-email-daily-log/screenpipe.d.ts b/examples/typescript/pipe-email-daily-log/screenpipe.d.tsindex a52563c41..820e1a2d0 100644--- a/examples/typescript/pipe-email-daily-log/screenpipe.d.ts+++ b/examples/typescript/pipe-email-daily-log/screenpipe.d.ts@@ -1,20 +1,83 @@declare global {const pipe: {+ /**+ * Reads the contents of a file.+ * @param path - The path to the file to be read.+ * @returns A promise that resolves with the file contents as a string.+ */readFile: (path: string) => Promise<string>;++ /**+ * Writes content to a file.+ * @param path - The path to the file to be written.+ * @param contents - The content to write to the file.+ * @returns A promise that resolves when the write operation is complete.+ */writeFile: (path: string, contents: string) => Promise<void>;++ /**+ * Removes a file.+ * @param path - The path to the file to be removed.+ * @returns A promise that resolves when the file is removed.+ */removeFile: (path: string) => Promise<void>;++ /**+ * Performs a GET request to the specified URL.+ * @param url - The URL to send the GET request to.+ * @returns A promise that resolves with the response data.+ */get: (url: string) => Promise<any>;++ /**+ * Performs a POST request to the specified URL.+ * @param url - The URL to send the POST request to.+ * @param body - The body of the POST request.+ * @returns A promise that resolves with the response data.+ */post: (url: string, body: string) => Promise<any>;++ /**+ * Performs a fetch request.+ * @param url - The URL to fetch.+ * @param options - Optional fetch options.+ * @returns A promise that resolves with the fetch response.+ */fetch: (url: string, options?: RequestInit) => Promise<Response>;++ /**+ * Sends a notification.+ * @param options - The notification options.+ * @returns A promise that resolves when the notification is sent.+ */sendNotification: (options: {title: string;body: string;}) => Promise<any>;++ /**+ * Loads the configuration for the pipe.+ * @returns A promise that resolves with the configuration object.+ */loadConfig: () => Promise<Record<string, any>>;++ /**+ * The current configuration of the pipe.+ */config: Record<string, any>;++ /**+ * Metadata about the current pipe.+ */metadata: {id: string;};++ /**+ * Sends an email.+ * @param options - The email options.+ * @returns A promise that resolves to true if the email was sent successfully, false otherwise.+ */sendEmail: (options: {to: string;from: string;@@ -22,16 +85,54 @@ declare global {subject: string;body: string;}) => Promise<boolean>;++ /**+ * Queries the Screenpipe database.+ * @param params - The query parameters.+ * @returns A promise that resolves with the query results or null if an error occurred.+ */+ queryScreenpipe: (+ params: ScreenpipeQueryParams+ ) => Promise<ScreenpipeResponse | null>;};const fs: {+ /**+ * Reads the contents of a file.+ * @param path - The path to the file to be read.+ * @returns A promise that resolves with the file contents as a string.+ */readFile: (path: string) => Promise<string>;++ /**+ * Writes content to a file.+ * @param path - The path to the file to be written.+ * @param contents - The content to write to the file.+ * @returns A promise that resolves when the write operation is complete.+ */writeFile: (path: string, contents: string) => Promise<void>;++ /**+ * Reads the contents of a directory.+ * @param path - The path to the directory to be read.+ * @returns A promise that resolves with an array of file names in the directory.+ */readdir: (path: string) => Promise<string[]>;++ /**+ * Creates a new directory.+ * @param path - The path of the directory to be created.+ * @returns A promise that resolves when the directory is created.+ */mkdir: (path: string) => Promise<void>;};const path: {+ /**+ * Joins multiple path segments into a single path.+ * @param paths - The path segments to join.+ * @returns The joined path string.+ */join: (...paths: string[]) => string;};@@ -48,6 +149,97 @@ declare global {const process: {env: NodeJS.ProcessEnv;};++ /**+ * Types of content that can be queried in Screenpipe.+ */+ type ContentType = "ocr" | "audio" | "all";++ /**+ * Parameters for querying Screenpipe.+ */+ interface ScreenpipeQueryParams {+ q?: string;+ content_type?: ContentType;+ limit?: number;+ offset?: number;+ start_time?: string;+ end_time?: string;+ app_name?: string;+ window_name?: string;+ include_frames?: boolean;+ min_length?: number;+ max_length?: number;+ }++ /**+ * Structure of OCR (Optical Character Recognition) content.+ */+ interface OCRContent {+ frame_id: number;+ text: string;+ timestamp: string;+ file_path: string;+ offset_index: number;+ app_name: string;+ window_name: string;+ tags: string[];+ frame?: string;+ }++ /**+ * Structure of audio content.+ */+ interface AudioContent {+ chunk_id: number;+ transcription: string;+ timestamp: string;+ file_path: string;+ offset_index: number;+ tags: string[];+ device_name: string;+ device_type: string;+ }++ /**+ * Structure of Full Text Search content.+ */+ interface FTSContent {+ text_id: number;+ matched_text: string;+ frame_id: number;+ timestamp: string;+ app_name: string;+ window_name: string;+ file_path: string;+ original_frame_text?: string;+ tags: string[];+ }++ /**+ * Union type for different types of content items.+ */+ type ContentItem =+ | { type: "OCR"; content: OCRContent }+ | { type: "Audio"; content: AudioContent }+ | { type: "FTS"; content: FTSContent };++ /**+ * Pagination information for search results.+ */+ interface PaginationInfo {+ limit: number;+ offset: number;+ total: number;+ }++ /**+ * Structure of the response from a Screenpipe query.+ */+ interface ScreenpipeResponse {+ data: ContentItem[];+ pagination: PaginationInfo;+ }}export {};diff --git a/examples/typescript/pipe-meeting-summary-by-email/README.md b/examples/typescript/pipe-meeting-summary-by-email/README.mdnew file mode 100644index 000000000..3ebc600e3--- /dev/null+++ b/examples/typescript/pipe-meeting-summary-by-email/README.md@@ -0,0 +1,109 @@+### pipe-email-daily-log++<img width="988" alt="Screenshot 2024-09-25 at 17 56 00" src="https://github.com/user-attachments/assets/f9d604af-b098-4f93-b923-b2fc455a6172">++++https://github.com/user-attachments/assets/a81963c9-54ee-4587-aac1-2eba0df4a5fc++++llama3.2 looks at your screen 24/7 and send you emails summarizing your activity or action items (e.g. follow up on this lead, or anything, you can customise the prompt and windows/tabs/apps being used as prompt)++#### quick setup++1. run ollama:+ ```+ ollama run phi3.5:3.8b-mini-instruct-q4_K_M+ ```++2. [create app specific password](https://support.google.com/accounts/answer/185833?hl=en) in your google account that will be used to send yourself emails++3. configure pipe in the app ui, save, enable, restart screenpipe recording (you can config to either receive a mail a day or several every x hours)++<img width="1312" alt="Screenshot 2024-09-25 at 18 16 54" src="https://github.com/user-attachments/assets/9669b2f1-c67d-4055-9e03-067c67fb51f8">++boom!++wanna tweak it? check `pipe.ts`.++can be used through CLI also, you can tweak the `pipe.json` to your needs, mine looks like this:++```json+{+ "fields": [+ {+ "name": "interval",+ "type": "number",+ "default": 60,+ "description": "Interval in seconds to read your screen data"+ },+ {+ "name": "summaryFrequency",+ "type": "string",+ "default": "daily",+ "description": "Frequency of summary emails: 'daily' for once a day at emailTime, or 'hourly:X' for every X hours (e.g., 'hourly:4' for every 4 hours)",+ "value": "hourly:1"+ },+ {+ "name": "emailTime",+ "type": "time",+ "default": "11:00",+ "description": "Time to send daily summary email (used only if summaryFrequency is 'daily')"+ },+ {+ "name": "emailAddress",+ "type": "string",+ "default": "<fill your email address here>",+ "description": "Email Address",+ "value": "[email protected]"+ },+ {+ "name": "emailPassword",+ "type": "string",+ "default": "<fill your email password here>",+ "description": "Email Password https://support.google.com/accounts/answer/185833?hl=en",+ "value": "mypassword"+ },+ {+ "name": "ollamaApiUrl",+ "type": "string",+ "default": "http://localhost:11434/api",+ "description": "Ollama API URL"+ },+ {+ "name": "ollamaModel",+ "type": "string",+ "default": "llama3.2:3b-instruct-q4_K_M",+ "description": "Ollama Model"+ },+ {+ "name": "pageSize",+ "type": "number",+ "default": 100,+ "description": "Number of records to retrieve from screenpipe per page, keep in mind LLMs have a context window limit"+ },+ {+ "name": "customPrompt",+ "type": "string",+ "default": "You are an AI assistant tasked with extracting structured information from screen data (OCR). Analyze the following screen data and extract relevant information about my daily activity.",+ "description": "Custom prompt for the AI assistant"+ },+ {+ "name": "summaryPrompt",+ "type": "string",+ "default": "You are an AI assistant tasked with summarizing information that has previously been extracted from screen data (OCR) by another AI assistant. Analyze the following structured data extracted from my screen data and summarize my daily activity, this will be send as a mail to my email address.",+ "description": "Summary prompt for the AI assistant"+ },+ {+ "name": "windowName",+ "type": "window",+ "default": "",+ "description": "Specific window name to filter the screen data, for example 'gmail', 'john', 'slack', 'myCodeFile.tsx', etc.",+ "value": "matt"+ }+ ],+ "source": "https://github.com/mediar-ai/screenpipe/tree/main/examples/typescript/pipe-email-daily-log",+ "enabled": true+}+```diff --git a/examples/typescript/pipe-meeting-summary-by-email/pipe.json b/examples/typescript/pipe-meeting-summary-by-email/pipe.jsonnew file mode 100644index 000000000..82ee98a8b--- /dev/null+++ b/examples/typescript/pipe-meeting-summary-by-email/pipe.json@@ -0,0 +1,40 @@+{+ "fields": [+ {+ "name": "pollingInterval",+ "type": "number",+ "default": 3600000,+ "description": "interval in milliseconds to poll audio content (default: 1 hour)"+ },+ {+ "name": "emailAddress",+ "type": "string",+ "default": "<fill your email address here>",+ "description": "email address to send the meeting summary to"+ },+ {+ "name": "emailPassword",+ "type": "string",+ "default": "<fill your email password here>",+ "description": "app specific password for your gmail account, https://support.google.com/accounts/answer/185833?hl=en"+ },+ {+ "name": "aiApiUrl",+ "type": "string",+ "default": "http://localhost:11434/api",+ "description": "ai api url, can be ollama, openai, any openai compatible api"+ },+ {+ "name": "aiModel",+ "type": "string",+ "default": "llama3.2:3b-instruct-q4_K_M",+ "description": "ai model"+ },+ {+ "name": "summaryPrompt",+ "type": "string",+ "default": "summarize the following meeting transcript, focusing on key points, action items, and decisions made:",+ "description": "custom prompt for summarizing the meeting"+ }+ ]+}\ No newline at end of filediff --git a/examples/typescript/pipe-meeting-summary-by-email/pipe.ts b/examples/typescript/pipe-meeting-summary-by-email/pipe.tsnew file mode 100644index 000000000..ab2ae99f1--- /dev/null+++ b/examples/typescript/pipe-meeting-summary-by-email/pipe.ts@@ -0,0 +1,100 @@+async function summarizeAudio(+ audioData: ContentItem[],+ aiApiUrl: string,+ aiModel: string+): Promise<string> {+ const prompt = `summarize the following meeting transcript:++ ${JSON.stringify(audioData)}++ provide a concise summary of the key points discussed in the meeting.`;++ const response = await fetch(`${aiApiUrl}/chat`, {+ method: "POST",+ body: JSON.stringify({+ model: aiModel,+ messages: [{ role: "user", content: prompt }],+ stream: false,+ }),+ });++ if (!response.ok) {+ throw new Error(`http error! status: ${response.status}`);+ }++ const result = await response.json();+ return result.message.content;+}++async function sendEmail(+ to: string,+ password: string,+ subject: string,+ body: string+): Promise<void> {+ const from = to;+ const result = await pipe.sendEmail({+ to,+ from,+ password,+ subject,+ body,+ });+ if (!result) {+ throw new Error("failed to send email");+ }+ console.log(`email sent to ${to} with subject: ${subject}`);+}++async function meetingSummaryPipeline(): Promise<void> {+ console.log("starting meeting summary pipeline");++ const config = await pipe.loadConfig();+ console.log("loaded config:", JSON.stringify(config, null, 2));++ const { pollingInterval, emailAddress, emailPassword, aiApiUrl, aiModel } =+ config;++ console.log("pollingInterval:", pollingInterval);+ console.log("emailAddress:", emailAddress);+ console.log("emailPassword:", emailPassword);+ console.log("aiApiUrl:", aiApiUrl);+ console.log("aiModel:", aiModel);++ while (true) {+ try {+ const now = new Date();+ const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000);+ console.log("oneHourAgo:", oneHourAgo);+ console.log("now:", now);++ const audioData = await pipe.queryScreenpipe({+ start_time: oneHourAgo.toISOString(),+ end_time: now.toISOString(),+ content_type: "audio",+ limit: 10_000,+ });++ console.log("audioData:", audioData);++ if (audioData && audioData.data && audioData.data.length > 0) {+ console.log("audioData.data:", audioData.data);+ const summary = await summarizeAudio(audioData.data, aiApiUrl, aiModel);+ console.log("summary:", summary);++ await sendEmail(+ emailAddress,+ emailPassword,+ "meeting summary",+ summary+ );+ }+ } catch (error) {+ console.warn("error in meeting summary pipeline:", error);+ }+ console.log("sleeping for", pollingInterval, "ms");+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));+ }+}++meetingSummaryPipeline();diff --git a/examples/typescript/pipe-meeting-summary-by-email/screenpipe.d.ts b/examples/typescript/pipe-meeting-summary-by-email/screenpipe.d.tsnew file mode 100644index 000000000..820e1a2d0--- /dev/null+++ b/examples/typescript/pipe-meeting-summary-by-email/screenpipe.d.ts@@ -0,0 +1,245 @@+declare global {+ const pipe: {+ /**+ * Reads the contents of a file.+ * @param path - The path to the file to be read.+ * @returns A promise that resolves with the file contents as a string.+ */+ readFile: (path: string) => Promise<string>;++ /**+ * Writes content to a file.+ * @param path - The path to the file to be written.+ * @param contents - The content to write to the file.+ * @returns A promise that resolves when the write operation is complete.+ */+ writeFile: (path: string, contents: string) => Promise<void>;++ /**+ * Removes a file.+ * @param path - The path to the file to be removed.+ * @returns A promise that resolves when the file is removed.+ */+ removeFile: (path: string) => Promise<void>;++ /**+ * Performs a GET request to the specified URL.+ * @param url - The URL to send the GET request to.+ * @returns A promise that resolves with the response data.+ */+ get: (url: string) => Promise<any>;++ /**+ * Performs a POST request to the specified URL.+ * @param url - The URL to send the POST request to.+ * @param body - The body of the POST request.+ * @returns A promise that resolves with the response data.+ */+ post: (url: string, body: string) => Promise<any>;++ /**+ * Performs a fetch request.+ * @param url - The URL to fetch.+ * @param options - Optional fetch options.+ * @returns A promise that resolves with the fetch response.+ */+ fetch: (url: string, options?: RequestInit) => Promise<Response>;++ /**+ * Sends a notification.+ * @param options - The notification options.+ * @returns A promise that resolves when the notification is sent.+ */+ sendNotification: (options: {+ title: string;+ body: string;+ }) => Promise<any>;++ /**+ * Loads the configuration for the pipe.+ * @returns A promise that resolves with the configuration object.+ */+ loadConfig: () => Promise<Record<string, any>>;++ /**+ * The current configuration of the pipe.+ */+ config: Record<string, any>;++ /**+ * Metadata about the current pipe.+ */+ metadata: {+ id: string;+ };++ /**+ * Sends an email.+ * @param options - The email options.+ * @returns A promise that resolves to true if the email was sent successfully, false otherwise.+ */+ sendEmail: (options: {+ to: string;+ from: string;+ password: string;+ subject: string;+ body: string;+ }) => Promise<boolean>;++ /**+ * Queries the Screenpipe database.+ * @param params - The query parameters.+ * @returns A promise that resolves with the query results or null if an error occurred.+ */+ queryScreenpipe: (+ params: ScreenpipeQueryParams+ ) => Promise<ScreenpipeResponse | null>;+ };++ const fs: {+ /**+ * Reads the contents of a file.+ * @param path - The path to the file to be read.+ * @returns A promise that resolves with the file contents as a string.+ */+ readFile: (path: string) => Promise<string>;++ /**+ * Writes content to a file.+ * @param path - The path to the file to be written.+ * @param contents - The content to write to the file.+ * @returns A promise that resolves when the write operation is complete.+ */+ writeFile: (path: string, contents: string) => Promise<void>;++ /**+ * Reads the contents of a directory.+ * @param path - The path to the directory to be read.+ * @returns A promise that resolves with an array of file names in the directory.+ */+ readdir: (path: string) => Promise<string[]>;++ /**+ * Creates a new directory.+ * @param path - The path of the directory to be created.+ * @returns A promise that resolves when the directory is created.+ */+ mkdir: (path: string) => Promise<void>;+ };++ const path: {+ /**+ * Joins multiple path segments into a single path.+ * @param paths - The path segments to join.+ * @returns The joined path string.+ */+ join: (...paths: string[]) => string;+ };++ namespace NodeJS {+ interface ProcessEnv {+ SCREENPIPE_DIR: string;+ SCREENPIPE_LOG_API_URL?: string;+ SCREENPIPE_SERVER_URL?: string;+ PIPE_DIR: string;+ NOTION_DATABASE_ID: string;+ NOTION_API_KEY: string;+ }+ }+ const process: {+ env: NodeJS.ProcessEnv;+ };++ /**+ * Types of content that can be queried in Screenpipe.+ */+ type ContentType = "ocr" | "audio" | "all";++ /**+ * Parameters for querying Screenpipe.+ */+ interface ScreenpipeQueryParams {+ q?: string;+ content_type?: ContentType;+ limit?: number;+ offset?: number;+ start_time?: string;+ end_time?: string;+ app_name?: string;+ window_name?: string;+ include_frames?: boolean;+ min_length?: number;+ max_length?: number;+ }++ /**+ * Structure of OCR (Optical Character Recognition) content.+ */+ interface OCRContent {+ frame_id: number;+ text: string;+ timestamp: string;+ file_path: string;+ offset_index: number;+ app_name: string;+ window_name: string;+ tags: string[];+ frame?: string;+ }++ /**+ * Structure of audio content.+ */+ interface AudioContent {+ chunk_id: number;+ transcription: string;+ timestamp: string;+ file_path: string;+ offset_index: number;+ tags: string[];+ device_name: string;+ device_type: string;+ }++ /**+ * Structure of Full Text Search content.+ */+ interface FTSContent {+ text_id: number;+ matched_text: string;+ frame_id: number;+ timestamp: string;+ app_name: string;+ window_name: string;+ file_path: string;+ original_frame_text?: string;+ tags: string[];+ }++ /**+ * Union type for different types of content items.+ */+ type ContentItem =+ | { type: "OCR"; content: OCRContent }+ | { type: "Audio"; content: AudioContent }+ | { type: "FTS"; content: FTSContent };++ /**+ * Pagination information for search results.+ */+ interface PaginationInfo {+ limit: number;+ offset: number;+ total: number;+ }++ /**+ * Structure of the response from a Screenpipe query.+ */+ interface ScreenpipeResponse {+ data: ContentItem[];+ pagination: PaginationInfo;+ }+}++export {};diff --git a/examples/typescript/pipe-meeting-summary-by-email/tsconfig.json b/examples/typescript/pipe-meeting-summary-by-email/tsconfig.jsonnew file mode 100644index 000000000..c4e6dfdd7--- /dev/null+++ b/examples/typescript/pipe-meeting-summary-by-email/tsconfig.json@@ -0,0 +1,17 @@+{+ "compilerOptions": {+ "target": "es2018",+ "module": "esnext",+ "moduleResolution": "node",+ "outDir": "./",+ "rootDir": "./",+ "strict": true,+ "esModuleInterop": true+ },+ "include": [+ "./**/*.ts"+ ],+ "exclude": [+ "node_modules"+ ]+}\ No newline at end of filediff --git a/screenpipe-app-tauri/components/pipe-config-form.tsx b/screenpipe-app-tauri/components/pipe-config-form.tsxindex ea4d65d46..f70a441b8 100644--- a/screenpipe-app-tauri/components/pipe-config-form.tsx+++ b/screenpipe-app-tauri/components/pipe-config-form.tsx@@ -294,7 +294,7 @@ export const PipeConfigForm: React.FC<PipeConfigFormProps> = ({return (<form onSubmit={handleSubmit} className="space-y-6">- <h3 className="text-lg font-semibold">Pipe Configuration</h3>+ <h3 className="text-lg font-semibold">pipe configuration</h3>{config?.fields.map((field: FieldConfig) => (<div key={field.name} className="space-y-2"><Label htmlFor={field.name} className="font-medium">@@ -304,7 +304,7 @@ export const PipeConfigForm: React.FC<PipeConfigFormProps> = ({<p className="text-sm text-gray-500">{field.description}</p></div>))}- <Button type="submit">Save Configuration</Button>+ <Button type="submit">save configuration</Button></form>);};diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsxindex ff19e2771..4a3f56a7c 100644--- a/screenpipe-app-tauri/components/pipe-store.tsx+++ b/screenpipe-app-tauri/components/pipe-store.tsx@@ -85,7 +85,6 @@ const PipeDialog: React.FC = () => {const [newRepoUrl, setNewRepoUrl] = useState("");const [selectedPipe, setSelectedPipe] = useState<Pipe | null>(null);const [pipes, setPipes] = useState<Pipe[]>([]);- const { settings, updateSettings } = useSettings();const { health } = useHealthCheck();const [isLogOpen, setIsLogOpen] = useState(false);@@ -95,10 +94,6 @@ const PipeDialog: React.FC = () => {const handleResetAllPipes = async () => {try {- // stop screenpipe- if (!settings?.devMode) {- await invoke("kill_all_sreenpipes");- }// reset pipesawait invoke("reset_all_pipes");await new Promise((resolve) => setTimeout(resolve, 1000));@@ -119,10 +114,6 @@ const PipeDialog: React.FC = () => {} finally {setSelectedPipe(null);setPipes([]);- // start screenpipe- if (!settings?.devMode) {- await invoke("spawn_screenpipe");- }}};// console.log("pipes", pipes);diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex d01929c4a..5ad6c7d51 100644--- a/screenpipe-app-tauri/src-tauri/Cargo.toml+++ b/screenpipe-app-tauri/src-tauri/Cargo.toml@@ -1,6 +1,6 @@[package]name = "screenpipe-app"-version = "0.2.69"+version = "0.2.70"description = ""authors = ["you"]license = ""diff --git a/screenpipe-core/src/deno/runtime.js b/screenpipe-core/src/deno/runtime.jsindex 8389c642f..0da7ac047 100644--- a/screenpipe-core/src/deno/runtime.js+++ b/screenpipe-core/src/deno/runtime.js@@ -146,9 +146,9 @@ const pipe = {return {};}},- sendEmail: async ({ to, from, password, subject, body }) => {+ sendEmail: async ({ to, from, password, subject, body, contentType = 'text/plain' }) => {try {- await ops.op_send_email(to, from, password, subject, body);+ await ops.op_send_email(to, from, password, subject, body, contentType);return true;} catch (error) {console.error("Error sending email:", error);@@ -160,6 +160,45 @@ const pipe = {// }};+function encodeQueryData(data) {+ return Object.keys(data)+ .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`)+ .join('&');+}++pipe.queryScreenpipe = async (params) => {+ try {+ const queryParams = {+ content_type: params.content_type || 'all',+ limit: params.limit || 50,+ offset: params.offset || 0,+ start_time: params.start_time || new Date(Date.now() - 3600000).toISOString(),+ end_time: params.end_time || new Date().toISOString(),+ min_length: params.min_length || 50,+ max_length: params.max_length || 10000,+ include_frames: params.include_frames || false,+ };++ if (params.q) queryParams.q = params.q;+ if (params.app_name) queryParams.app_name = params.app_name;+ if (params.window_name) queryParams.window_name = params.window_name;++ const queryString = encodeQueryData(queryParams);+ const url = `http://localhost:3030/search?${queryString}`;+ console.log("calling screenpipe", url);++ const response = await pipe.fetch(url);+ if (!response.ok) {+ const text = await response.text();+ throw new Error(`http error! status: ${response.status} ${text}`);+ }+ return await response.json();+ } catch (error) {+ console.error("error querying screenpipe:", error);+ return null;+ }+};+const fs = {readFile: async (path) => {return await ops.op_read_file(path);diff --git a/screenpipe-core/src/pipes.rs b/screenpipe-core/src/pipes.rsindex e03545e0f..dff8d6573 100644--- a/screenpipe-core/src/pipes.rs+++ b/screenpipe-core/src/pipes.rs@@ -9,6 +9,7 @@ mod pipes {use deno_core::op2;use deno_core::ModuleLoadResponse;use deno_core::ModuleSourceCode;+ use lettre::message::header::ContentType;use regex::Regex;use reqwest::header::HeaderMap;use reqwest::header::HeaderValue;@@ -208,11 +209,13 @@ mod pipes {#[string] password: String,#[string] subject: String,#[string] body: String,+ #[string] content_type: String,) -> anyhow::Result<String, AnyError> {let email = Message::builder().from(from.parse()?).to(to.parse()?).subject(subject)+ .header(ContentType::parse(content_type.as_str())?).body(body)?;let creds = Credentials::new(from.clone(), password);@@ -317,7 +320,7 @@ mod pipes {op_remove_file,op_readdir,op_create_dir,-+op_fetch_get,op_fetch_post,op_set_timeout,diff --git a/screenpipe-core/tests/pipes_test.rs b/screenpipe-core/tests/pipes_test.rsindex 0a8766012..10bad2fba 100644--- a/screenpipe-core/tests/pipes_test.rs+++ b/screenpipe-core/tests/pipes_test.rs@@ -239,55 +239,74 @@ mod tests {let temp_dir = TempDir::new().unwrap();let screenpipe_dir = temp_dir.path().to_path_buf();let to = std::env::var("EMAIL_TO").expect("EMAIL_TO not set");- let from = std::env::var("EMAIL_TO").expect("EMAIL_TO not set");+ let from = std::env::var("EMAIL_FROM").expect("EMAIL_FROM not set");let password = std::env::var("EMAIL_PASSWORD").expect("EMAIL_PASSWORD not set");println!("to: {}", to);println!("from: {}", from);println!("password: {}", password);- let code = format!(++ // Test plain text email+ let plain_text_code = format!(r#"(async () => {{const result = await pipe.sendEmail({{to: "{to}",from: "{from}",password: "{password}",- subject: "bro - got some good stuff from screenpipe",- body: `-yo louis, you absolute madlad!--here's the lowdown on your day, you productivity ninja:--- absolutely demolished that 2-hour coding sesh on the new feature. the keyboard is still smoking, bro!-- crushed 3 client calls like a boss. they're probably writing love letters to you as we speak, make sure to close john tomorrow 8.00 am according to our notes, let the cash flow in!-- spent 45 mins on slack. 90% memes, 10% actual work. perfectly balanced, as all things should be-- watched a rust tutorial. way to flex those brain muscles, you nerd!--overall, you're killing it! 80% of your time on high-value tasks. the other 20%? probably spent admiring your own reflection, you handsome devil.--PS: seriously, quit tiktok. your FBI agent is getting bored watching you scroll endlessly.--what's the plan for tomorrow? more coding? more memes? world domination?--generated by your screenpipe ai assistant (who's definitely not planning to take over the world... yet)-`+ subject: "screenpipe test - plain text",+ body: "yo louis, this is a plain text email test!",+ contentType: "text/plain"}});- console.log("Email sent:", result);+ console.log("Plain text email result:", result);if (!result) {{- throw new Error("Failed to send email");+ throw new Error("Failed to send plain text email");}}}})();- "#+ "#);- println!("code: {}", code);- let pipe_dir = setup_test_pipe(&temp_dir, "email_test_pipe", &code).await;+ // Test HTML email+ let html_code = format!(+ r#"+ (async () => {{+ const result = await pipe.sendEmail({{+ to: "{to}",+ from: "{from}",+ password: "{password}",+ subject: "screenpipe test - html",+ body: `+ <html>+ <body>+ <h1>yo louis, you absolute madlad!</h1>+ <p>this is an <strong>html</strong> email test from screenpipe.</p>+ <ul>+ <li>item 1</li>+ <li>item 2</li>+ <li>item 3</li>+ </ul>+ </body>+ </html>+ `,+ contentType: "text/html"+ }});+ console.log("HTML email result:", result);+ if (!result) {{+ throw new Error("Failed to send HTML email");+ }}+ }})();+ "#+ );- // Change the working directory to the pipe directory+ let pipe_dir = setup_test_pipe(&temp_dir, "email_test_pipe_plain", &plain_text_code).await;std::env::set_current_dir(&pipe_dir).unwrap();+ let result = run_pipe(pipe_dir.to_string_lossy().to_string(), screenpipe_dir.clone()).await;+ assert!(result.is_ok(), "Plain text email test failed: {:?}", result);+ let pipe_dir = setup_test_pipe(&temp_dir, "email_test_pipe_html", &html_code).await;+ std::env::set_current_dir(&pipe_dir).unwrap();let result = run_pipe(pipe_dir.to_string_lossy().to_string(), screenpipe_dir).await;- assert!(result.is_ok(), "Pipe execution failed: {:?}", result);+ assert!(result.is_ok(), "HTML email test failed: {:?}", result);}#[tokio::test]