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 app to v2.0.144
Louis Beaumont468aa8f75781
diff --git a/screenpipe-app-tauri/components/global-chat.tsx b/screenpipe-app-tauri/components/global-chat.tsxindex 3d2cc49c1..e44be3f2d 100644--- a/screenpipe-app-tauri/components/global-chat.tsx+++ b/screenpipe-app-tauri/components/global-chat.tsx@@ -435,11 +435,49 @@ EXAMPLES:},},},+ {+ type: "function",+ function: {+ name: "web_search",+ description: `Search the web for current, up-to-date information. Use this when:+- User asks about recent news, events, or current information+- User wants to verify or supplement screen data with web sources+- User asks about topics that need real-time data (stocks, weather, news)+- Combining screen context with external web information++This tool uses Google Search to ground responses in current web data and provides cited sources.++EXAMPLES:+- "What's the latest news about [topic from my screen]?"+- "Search the web for current ECB rates"+- "Find recent articles about [something I was researching]"`,+ parameters: {+ type: "object",+ properties: {+ query: {+ type: "string",+ description: "The search query. Be specific and include relevant context.",+ },+ },+ required: ["query"],+ },+ },+ },];-const SYSTEM_PROMPT = `You are a helpful AI assistant that can search through the user's Screenpipe data - their screen recordings, audio transcriptions, and UI interactions.+const SYSTEM_PROMPT = `You are a helpful AI assistant that can search through the user's Screenpipe data - their screen recordings, audio transcriptions, and UI interactions. You also have access to web search for current information.++CAPABILITIES:+1. **Screen/Audio Search** (search_content): Search user's captured screen text, audio transcriptions, UI elements+2. **Web Search** (web_search): Search the internet for current news, real-time data, and external information-CRITICAL SEARCH RULES (database has 600k+ entries - ALWAYS use time filters):+WHEN TO USE WEB SEARCH:+- User asks about current events, news, or real-time information+- User wants to combine screen context with external web data (e.g., "based on what I was looking at, search for...")+- Topics that need up-to-date information (stock prices, news, weather, recent developments)+- Verifying or supplementing information from screen captures++CRITICAL SCREEN SEARCH RULES (database has 600k+ entries - ALWAYS use time filters):1. ALWAYS include start_time in EVERY search - NEVER search without a time range2. Default time range: last 1-2 hours. Expand ONLY if no results found3. ALWAYS use app_name filter when user mentions ANY app@@ -455,7 +493,7 @@ Rules for showing videos/audio:- Do NOT use markdown links or multi-line code blocks for videos- Always show relevant video/audio when answering about what user saw/heard-Be concise. Cite timestamps when relevant.+Be concise. Cite timestamps when relevant. When using web search, always cite your sources.Current time: ${new Date().toISOString()}`;@@ -1280,6 +1318,29 @@ export function GlobalChat() {content: `Error parsing tool arguments: ${e}`,});}+ } else if (toolCall.function.name === "web_search") {+ // For Gemini models, web search is handled via Google Search grounding+ // The grounding results are automatically included in the response+ // For non-Gemini models, this would need an actual search API call+ const args = JSON.parse(toolCall.function.arguments || "{}");+ console.log("[Chat] Web search requested:", args.query);++ // Check if using Gemini (grounding is automatic)+ const isGemini = activePreset.model?.toLowerCase().includes("gemini");+ if (isGemini) {+ toolResults.push({+ role: "tool",+ tool_call_id: toolCall.id,+ content: `Web search for "${args.query}" is being performed via Google Search grounding. The results will be included in the response with citations.`,+ });+ } else {+ // For non-Gemini models, we don't have web search yet+ toolResults.push({+ role: "tool",+ tool_call_id: toolCall.id,+ content: `Web search is currently only available for Gemini models. Please use a Gemini model to enable web search functionality.`,+ });+ }}}@@ -1404,6 +1465,23 @@ export function GlobalChat() {content: `Error parsing tool arguments: ${e}`,});}+ } else if (toolCall.function.name === "web_search") {+ const args = JSON.parse(toolCall.function.arguments || "{}");+ console.log("[Chat] Web search requested (round " + toolRound + "):", args.query);+ const isGemini = activePreset.model?.toLowerCase().includes("gemini");+ if (isGemini) {+ additionalToolResults.push({+ role: "tool",+ tool_call_id: toolCall.id,+ content: `Web search for "${args.query}" is being performed via Google Search grounding.`,+ });+ } else {+ additionalToolResults.push({+ role: "tool",+ tool_call_id: toolCall.id,+ content: `Web search is currently only available for Gemini models.`,+ });+ }}}diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.tomlindex 8c69aa54f..fa212e343 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 = "2.0.143"+version = "2.0.144"description = "24/7 memory for your desktop. 100% local."authors = ["you"]license = ""diff --git a/screenpipe-js/ai-proxy/src/providers/gemini.ts b/screenpipe-js/ai-proxy/src/providers/gemini.tsindex c0a7f40cc..5364a549d 100644--- a/screenpipe-js/ai-proxy/src/providers/gemini.ts+++ b/screenpipe-js/ai-proxy/src/providers/gemini.ts@@ -13,23 +13,51 @@ export class GeminiProvider implements AIProvider {this.client = new GoogleGenerativeAI(apiKey);}+ // Check if web search is requested in tools+ private hasWebSearchTool(tools?: any[]): boolean {+ if (!tools) return false;+ return tools.some(tool =>+ tool.type === 'web_search' ||+ tool.type === 'google_search' ||+ tool.googleSearch !== undefined ||+ (tool.function?.name === 'web_search') ||+ (tool.function?.name === 'google_search')+ );+ }+private createGenerationConfig(body: RequestBody) {const config: any = {temperature: body.temperature,};-+if (body.response_format?.type === 'json_schema' && body.response_format.schema) {config.responseMimeType = 'application/json';config.responseSchema = body.response_format.schema;} else if (body.response_format?.type === 'json_object') {config.responseMimeType = 'application/json';}-+return config;- }+ }++ private createModelConfig(body: RequestBody) {+ const config: any = {+ model: body.model,+ generationConfig: this.createGenerationConfig(body),+ };++ // Add Google Search grounding if web_search tool is requested+ if (this.hasWebSearchTool(body.tools)) {+ console.log('[Gemini] Enabling Google Search grounding');+ config.tools = [{ googleSearch: {} }];+ }++ return config;+ }async createCompletion(body: RequestBody): Promise<Response> {- this.model = this.client.getGenerativeModel({ model: body.model, generationConfig: this.createGenerationConfig(body) });+ const modelConfig = this.createModelConfig(body);+ this.model = this.client.getGenerativeModel(modelConfig);const chat = this.model.startChat({history: this.formatMessages(body.messages),@@ -46,13 +74,14 @@ export class GeminiProvider implements AIProvider {const result = await chat.sendMessage(prompt);const response = await result.response;- return new Response(JSON.stringify(this.formatResponse(response)), {+ return new Response(JSON.stringify(this.formatResponse(response, this.hasWebSearchTool(body.tools))), {headers: { 'Content-Type': 'application/json' },});}async createStreamingCompletion(body: RequestBody): Promise<ReadableStream> {- this.model = this.client.getGenerativeModel({ model: body.model });+ const modelConfig = this.createModelConfig(body);+ this.model = this.client.getGenerativeModel(modelConfig);const chat = this.model.startChat({history: this.formatMessages(body.messages),@@ -62,6 +91,7 @@ export class GeminiProvider implements AIProvider {});const result = await chat.sendMessage(body.messages[body.messages.length - 1].content as string);+ const hasWebSearch = this.hasWebSearchTool(body.tools);return new ReadableStream({async start(controller) {@@ -69,9 +99,24 @@ export class GeminiProvider implements AIProvider {const response = await result.response;const text = response.text();+ // If web search was used, prepend sources info+ let sourcesText = '';+ if (hasWebSearch) {+ const groundingMetadata = (response as any).candidates?.[0]?.groundingMetadata;+ if (groundingMetadata?.groundingChunks?.length > 0) {+ sourcesText = '\n\n---\n**Sources:**\n';+ for (const chunk of groundingMetadata.groundingChunks) {+ if (chunk.web?.uri) {+ sourcesText += `- [${chunk.web.title || chunk.web.uri}](${chunk.web.uri})\n`;+ }+ }+ }+ }++ const fullText = text + sourcesText;const chunkSize = 20;- for (let i = 0; i < text.length; i += chunkSize) {- const chunk = text.slice(i, i + chunkSize);+ for (let i = 0; i < fullText.length; i += chunkSize) {+ const chunk = fullText.slice(i, i + chunkSize);controller.enqueue(new TextEncoder().encode(`data: ${JSON.stringify({@@ -123,17 +168,48 @@ export class GeminiProvider implements AIProvider {}}- formatResponse(response: any): any {- return {+ formatResponse(response: any, includeGrounding: boolean = false): any {+ let content = response.text();++ // If grounding was used, append sources+ if (includeGrounding) {+ const groundingMetadata = response.candidates?.[0]?.groundingMetadata;+ if (groundingMetadata?.groundingChunks?.length > 0) {+ content += '\n\n---\n**Sources:**\n';+ for (const chunk of groundingMetadata.groundingChunks) {+ if (chunk.web?.uri) {+ content += `- [${chunk.web.title || chunk.web.uri}](${chunk.web.uri})\n`;+ }+ }+ }+ }++ const result: any = {choices: [{message: {- content: response.text(),+ content,role: 'assistant',},},],};++ // Include grounding metadata in response for clients that want it+ if (includeGrounding) {+ const groundingMetadata = response.candidates?.[0]?.groundingMetadata;+ if (groundingMetadata) {+ result.grounding_metadata = {+ search_queries: groundingMetadata.webSearchQueries || [],+ sources: (groundingMetadata.groundingChunks || []).map((chunk: any) => ({+ title: chunk.web?.title,+ url: chunk.web?.uri,+ })),+ };+ }+ }++ return result;}async listModels(): Promise<{ id: string; name: string; provider: string }[]> {