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

feat: introduce a pipe update version endpoint to avoid losing configuration on update and smoother updates, fix search was not working with custom ai provider without api key (eg lmstudio for example), document lmstudio and ollama usage in docs, fix hydration errors, reduce auto destruct polling which was too long for windows updates

Louis Beaumonte61b74e33393
diff --git a/content/docs/pages/docs/getting-started.mdx b/content/docs/pages/docs/getting-started.mdx
index d48d8f229..5b0d43443 100644
--- a/content/docs/pages/docs/getting-started.mdx
+++ b/content/docs/pages/docs/getting-started.mdx
@@ -50,6 +50,41 @@ now download the [desktop app](https://screenpi.pe) and use pipes (plugins) to a
</MotionDiv>
+### connect to AI providers
+
+<MotionDiv>
+screenpipe can connect to various AI providers to process your data. here's how to set up popular local AI providers:
+
+<Tabs items={['ollama', 'lmstudio']}>
+ <Tab>
+ 1. install ollama from [ollama.ai](https://ollama.ai) and run your preferred model
+ ```bash copy
+ # start ollama with your preferred model
+ ollama run phi4:14b-q4_K_M
+ ```
+ 2. then configure screenpipe to use ollama in your settings with model phi4:14b-q4_K_M
+
+ that's it! screenpipe will now use ollama for AI like search, rewind, and more. you can change the model in settings.
+ </Tab>
+ <Tab>
+ to use LMStudio:
+
+ 1. download and install [LMStudio](https://lmstudio.ai)
+ 2. select your preferred model
+ 3. start the local server
+
+ ![select model](./lmstudio2.png)
+ ![start server](./lmstudio3.png)
+ ![lmstudio setup](./lmstudio1.png)
+
+x
+ </Tab>
+</Tabs>
+
+verify your ai provider using any pipe in the store!
+
+</MotionDiv>
+
### for developers
if you're interested in building from source or contributing to screenpipe, please check our [contributing guide](https://github.com/mediar-ai/screenpipe/blob/main/CONTRIBUTING.md).
diff --git a/content/docs/public/lmstudio1.png b/content/docs/public/lmstudio1.png
new file mode 100644
index 000000000..16b731ddd
Binary files /dev/null and b/content/docs/public/lmstudio1.png differ
diff --git a/content/docs/public/lmstudio2.png b/content/docs/public/lmstudio2.png
new file mode 100644
index 000000000..36ede0422
Binary files /dev/null and b/content/docs/public/lmstudio2.png differ
diff --git a/content/docs/public/lmstudio3.png b/content/docs/public/lmstudio3.png
new file mode 100644
index 000000000..f14f59ba9
Binary files /dev/null and b/content/docs/public/lmstudio3.png differ
diff --git a/pipes/obsidian/package.json b/pipes/obsidian/package.json
index a66435262..d44ac6167 100644
--- a/pipes/obsidian/package.json
+++ b/pipes/obsidian/package.json
@@ -1,6 +1,6 @@
{
"name": "obsidian",
- "version": "0.1.15",
+ "version": "0.1.16",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
diff --git a/pipes/obsidian/src/app/api/intelligence/route.ts b/pipes/obsidian/src/app/api/intelligence/route.ts
index c2560c0f7..9b25b8b65 100644
--- a/pipes/obsidian/src/app/api/intelligence/route.ts
+++ b/pipes/obsidian/src/app/api/intelligence/route.ts
@@ -194,7 +194,7 @@ async function readRecentLogs(
export async function GET() {
try {
const settings = await pipe.settings.getNamespaceSettings("obsidian");
- const obsidianPath = settings?.path;
+ const obsidianPath = settings?.vaultPath;
const model = settings?.aiModel;
if (!obsidianPath) {
diff --git a/pipes/obsidian/src/app/api/log/route.ts b/pipes/obsidian/src/app/api/log/route.ts
index 5c63581c2..649a14fac 100644
--- a/pipes/obsidian/src/app/api/log/route.ts
+++ b/pipes/obsidian/src/app/api/log/route.ts
@@ -181,7 +181,7 @@ export async function GET() {
try {
const settings = await pipe.settings.getNamespaceSettings("obsidian");
const interval = settings?.interval || 3600000;
- const obsidianPath = settings?.path;
+ const obsidianPath = settings?.vaultPath;
const customPrompt = settings?.prompt;
const pageSize = settings?.pageSize || 100;
const model = settings?.aiModel;
diff --git a/pipes/search/package.json b/pipes/search/package.json
index 3368e6f24..eccf80d14 100644
--- a/pipes/search/package.json
+++ b/pipes/search/package.json
@@ -1,6 +1,6 @@
{
"name": "search",
- "version": "0.1.10",
+ "version": "0.1.13",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
diff --git a/pipes/search/src/lib/hooks/use-ai-provider.tsx b/pipes/search/src/lib/hooks/use-ai-provider.tsx
index 97ead8f20..d784a47be 100644
--- a/pipes/search/src/lib/hooks/use-ai-provider.tsx
+++ b/pipes/search/src/lib/hooks/use-ai-provider.tsx
@@ -54,7 +54,7 @@ export function useAiProvider(settings: Settings): AIProviderStatus {
break;
case "custom":
- if (!settings.aiUrl || !settings.openaiApiKey) {
+ if (!settings.aiUrl) {
setStatus({
isAvailable: false,
error: "custom ai url not configured",
diff --git a/screenpipe-app-tauri/app/page.tsx b/screenpipe-app-tauri/app/page.tsx
index 00a02542f..8b8d49157 100644
--- a/screenpipe-app-tauri/app/page.tsx
+++ b/screenpipe-app-tauri/app/page.tsx
@@ -5,7 +5,6 @@ import { getStore, useSettings } from "@/lib/hooks/use-settings";
import React, { useEffect } from "react";
import NotificationHandler from "@/components/notification-handler";
import Header from "@/components/header";
-import { usePostHog } from "posthog-js/react";
import { useToast } from "@/components/ui/use-toast";
import Onboarding from "@/components/onboarding";
import { useOnboarding } from "@/lib/hooks/use-onboarding";
@@ -15,7 +14,6 @@ import { useChangelogDialog } from "@/lib/hooks/use-changelog-dialog";
import { useStatusDialog } from "@/lib/hooks/use-status-dialog";
import { useSettingsDialog } from "@/lib/hooks/use-settings-dialog";
-import { platform } from "@tauri-apps/plugin-os";
import { PipeStore } from "@/components/pipe-store";
import { invoke } from "@tauri-apps/api/core";
import { listen } from "@tauri-apps/api/event";
@@ -26,9 +24,8 @@ import localforage from "localforage";
import { onOpenUrl } from "@tauri-apps/plugin-deep-link";
export default function Home() {
- const { settings, updateSettings } = useSettings();
+ const { settings, updateSettings, loadUser } = useSettings();
const { setActiveProfile } = useProfiles();
- const posthog = usePostHog();
const { toast } = useToast();
const { showOnboarding, setShowOnboarding } = useOnboarding();
const { setShowChangelogDialog } = useChangelogDialog();
@@ -36,6 +33,13 @@ export default function Home() {
const { setIsOpen: setSettingsOpen } = useSettingsDialog();
const isProcessingRef = React.useRef(false);
+ useEffect(() => {
+ const interval = setInterval(() => {
+ loadUser(settings.user?.token!);
+ }, 1000);
+ return () => clearInterval(interval);
+ }, [settings]);
+
useEffect(() => {
const getAudioDevices = async () => {
const store = await getStore();
@@ -197,14 +201,6 @@ export default function Home() {
};
}, [setSettingsOpen]);
- useEffect(() => {
- if (settings.userId) {
- posthog?.identify(settings.userId, {
- os: platform(),
- });
- }
- }, [settings.userId, posthog]);
-
useEffect(() => {
const checkScreenPermissionRestart = async () => {
const restartPending = await localforage.getItem(
diff --git a/screenpipe-app-tauri/app/providers.tsx b/screenpipe-app-tauri/app/providers.tsx
index 4566a570e..1954cbe49 100644
--- a/screenpipe-app-tauri/app/providers.tsx
+++ b/screenpipe-app-tauri/app/providers.tsx
@@ -6,7 +6,7 @@ import { useEffect } from "react";
import { OnboardingProvider } from "@/lib/hooks/use-onboarding";
import { ChangelogDialogProvider } from "@/lib/hooks/use-changelog-dialog";
import { forwardRef } from "react";
-import { store as SettingsStore } from "@/lib/hooks/use-settings";
+import { store as SettingsStore, useSettings } from "@/lib/hooks/use-settings";
import { profilesStore as ProfilesStore } from "@/lib/hooks/use-profiles";
export const Providers = forwardRef<
diff --git a/screenpipe-app-tauri/components/pipe-store-markdown.tsx b/screenpipe-app-tauri/components/pipe-store-markdown.tsx
index ef10a77ed..4b02e8ad4 100644
--- a/screenpipe-app-tauri/components/pipe-store-markdown.tsx
+++ b/screenpipe-app-tauri/components/pipe-store-markdown.tsx
@@ -28,29 +28,25 @@ export function PipeStoreMarkdown({
remarkPlugins={[remarkGfm, remarkMath]}
components={{
p({ children }) {
- return <p className="mb-2 last:mb-0">{children}</p>;
+ return <span className="mb-2 last:mb-0">{children}</span>;
},
code({ node, className, children, ...props }) {
const content = String(children).replace(/\n$/, "");
const match = /language-(\w+)/.exec(className || "");
return match ? (
- <div className="relative group">
- <CodeBlock
- key={Math.random()}
- language={(match && match[1]) || ""}
- value={content}
- {...props}
- />
- </div>
+ <CodeBlock
+ key={Math.random()}
+ language={(match && match[1]) || ""}
+ value={content}
+ {...props}
+ />
) : (
- <span className="relative group inline-block">
- <code
- className="py-0.5 px-1 rounded-sm font-mono text-sm text-grey-900"
- {...props}
- >
- {content}
- </code>
+ <code
+ className="relative group py-0.5 px-1 rounded-sm font-mono text-sm text-grey-900 inline-block"
+ {...props}
+ >
+ {content}
<Button
size="icon"
variant="ghost"
@@ -63,7 +59,7 @@ export function PipeStoreMarkdown({
<Copy className="h-3 w-3" />
)}
</Button>
- </span>
+ </code>
);
},
a({ href, children }) {
@@ -74,22 +70,28 @@ export function PipeStoreMarkdown({
/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/
);
- if (isDirectVideo) {
+ if (isDirectVideo || youtubeMatch) {
return (
- <RetryableVideo src={href} maxRetries={3} retryDelay={1000} />
- );
- } else if (youtubeMatch) {
- return (
- <iframe
- width="100%"
- height="315"
- src={`https://www.youtube.com/embed/${youtubeMatch[1]}`}
- frameBorder="0"
- allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
- allowFullScreen
- className="max-w-full"
- style={{ maxHeight: "400px" }}
- />
+ <span className="block">
+ {isDirectVideo ? (
+ <RetryableVideo
+ src={href}
+ maxRetries={3}
+ retryDelay={1000}
+ />
+ ) : (
+ <iframe
+ width="100%"
+ height="315"
+ src={`https://www.youtube.com/embed/${youtubeMatch![1]}`}
+ frameBorder="0"
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
+ allowFullScreen
+ className="max-w-full"
+ style={{ maxHeight: "400px" }}
+ />
+ )}
+ </span>
);
}
diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsx
index f23209ae3..e33dee9c6 100644
--- a/screenpipe-app-tauri/components/pipe-store.tsx
+++ b/screenpipe-app-tauri/components/pipe-store.tsx
@@ -36,7 +36,7 @@ const corePipes: string[] = ["data-table", "search"];
export const PipeStore: React.FC = () => {
const { health } = useHealthCheck();
const [selectedPipe, setSelectedPipe] = useState<PipeWithStatus | null>(null);
- const { settings } = useSettings();
+ const { settings, loadUser } = useSettings();
const [pipes, setPipes] = useState<PipeWithStatus[]>([]);
const [installedPipes, setInstalledPipes] = useState<InstalledPipe[]>([]);
const [searchQuery, setSearchQuery] = useState("");
@@ -80,37 +80,10 @@ export const PipeStore: React.FC = () => {
const unsubscribePromise = listen("update-all-pipes", async () => {
// not sure this is a good idea ... basically pipes will break in the hand of users when update will happen
if (!checkLogin(settings.user, false)) return;
- console.log("updating all pipes");
for (const pipe of pipes) {
- const currentVersion = pipe.installed_config?.version!;
- const storeApi = await PipeApi.create(settings.user!.token!);
- const update = await storeApi.checkUpdate(pipe.id, currentVersion);
- if (!update.has_update) {
- continue;
- }
-
- // First delete the pipe
- await handleDeletePipe(pipe);
-
// Then download the new version
- if (pipe.installed_config?.source) {
- await handleInstallPipe(pipe);
-
- // Enable the pipe after installation
- const response = await fetch(`http://localhost:3030/pipes/enable`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ pipe_id: pipe.name }),
- });
-
- const data = await response.json();
- if (!data.success) {
- console.warn("failed to enable pipe:", data.error);
- }
- }
+ await handleUpdatePipe(pipe);
}
// Refresh the pipe list
@@ -510,8 +483,6 @@ export const PipeStore: React.FC = () => {
let t;
if (!delayToast) {
- posthog.capture("update_all_pipes", {});
-
t = toast({
title: "checking for updates",
description: (
@@ -613,11 +584,6 @@ export const PipeStore: React.FC = () => {
onComplete: () => void
) => {
try {
- posthog.capture("toggle_pipe", {
- pipe_id: pipe.id,
- enabled: !pipe.installed_config?.enabled,
- });
-
const t = toast({
title: "loading pipe",
description: "please wait...",
@@ -747,9 +713,6 @@ export const PipeStore: React.FC = () => {
};
const handleDeletePipe = async (pipe: PipeWithStatus) => {
try {
- posthog.capture("delete_pipe", {
- pipe_id: pipe.id,
- });
toast({
title: "deleting pipe",
description: "please wait...",
@@ -790,10 +753,6 @@ export const PipeStore: React.FC = () => {
const handleRefreshFromDisk = async (pipe: PipeWithStatus) => {
try {
- posthog.capture("refresh_pipe_from_disk", {
- pipe_id: pipe.name,
- });
-
toast({
title: "refreshing pipe",
description: "please wait...",
@@ -831,10 +790,6 @@ export const PipeStore: React.FC = () => {
try {
if (!checkLogin(settings.user)) return;
- posthog.capture("update_pipe", {
- pipe_id: pipe.name,
- });
-
const currentVersion = pipe.installed_config?.version!;
const storeApi = await PipeApi.create(settings.user!.token!);
const update = await storeApi.checkUpdate(pipe.id, currentVersion);
@@ -846,52 +801,61 @@ export const PipeStore: React.FC = () => {
return;
}
- // Create initial toast with progress bar
const t = toast({
title: "updating pipe",
description: (
<div className="space-y-2">
- <Progress value={0} className="h-1" />
- <p className="text-xs">deleting old version...</p>
+ <Progress value={25} className="h-1" />
+ <p className="text-xs">checking for updates...</p>
</div>
),
duration: 100000,
});
- // First delete the pipe
- await handleDeletePipe(pipe);
+ // Update progress for download start
+ t.update({
+ id: t.id,
+ description: (
+ <div className="space-y-2">
+ <Progress value={50} className="h-1" />
+ <p className="text-xs">downloading update...</p>
+ </div>
+ ),
+ });
- // Then download the new version
- if (pipe.installed_config?.source) {
- t.update({
- id: t.id,
- title: "updating pipe",
- description: (
- <div className="space-y-2">
- <Progress value={50} className="h-1" />
- <p className="text-xs">downloading new version...</p>
- </div>
- ),
- duration: 100000,
- });
+ const responseDownload = await storeApi.downloadPipe(pipe.id);
- await handleInstallPipe(pipe);
+ // Update progress for installation
+ t.update({
+ id: t.id,
+ description: (
+ <div className="space-y-2">
+ <Progress value={75} className="h-1" />
+ <p className="text-xs">installing update...</p>
+ </div>
+ ),
+ });
- // Enable the pipe after installation
- const response = await fetch(`http://localhost:3030/pipes/enable`, {
+ const response = await fetch(
+ `http://localhost:3030/pipes/update-version`,
+ {
method: "POST",
headers: {
"Content-Type": "application/json",
},
- body: JSON.stringify({ pipe_id: pipe.name }),
- });
-
- const data = await response.json();
- if (!data.success) {
- console.warn("failed to enable pipe:", data.error);
+ body: JSON.stringify({
+ pipe_id: pipe.name,
+ source: responseDownload.download_url,
+ }),
}
+ );
+
+ const data = await response.json();
+ if (!data.success) {
+ throw new Error(data.error);
}
+ // Update progress for completion
t.update({
id: t.id,
title: "pipe updated",
@@ -904,9 +868,7 @@ export const PipeStore: React.FC = () => {
duration: 2000,
});
- // Refresh the pipe list
await fetchInstalledPipes();
-
t.dismiss();
} catch (error) {
console.error("failed to update pipe:", error);
diff --git a/screenpipe-app-tauri/components/settings/account-section.tsx b/screenpipe-app-tauri/components/settings/account-section.tsx
index 54402e73d..f8eafa2e7 100644
--- a/screenpipe-app-tauri/components/settings/account-section.tsx
+++ b/screenpipe-app-tauri/components/settings/account-section.tsx
@@ -213,9 +213,6 @@ export function AccountSection() {
const handleConnectStripe = async () => {
setIsConnectingStripe(true);
try {
- const BASE_URL =
- (await invoke("get_env", { name: "BASE_URL_PRIVATE" })) ??
- "https://screenpi.pe";
// const host = `${BASE_URL}/api/dev-stripe`;
const host = `https://screenpi.pe/api/dev/stripe-connect`;
const response = await fetch(host, {
@@ -285,13 +282,6 @@ export function AccountSection() {
}
}, [settings.user]); // Only run when settings.user changes
- useEffect(() => {
- const interval = setInterval(() => {
- loadUser(settings.user?.token!);
- }, 1000);
- return () => clearInterval(interval);
- }, [settings]);
-
return (
<div className="w-full space-y-6 py-4">
<div className="flex items-center justify-between">
diff --git a/screenpipe-app-tauri/components/settings/ai-section.tsx b/screenpipe-app-tauri/components/settings/ai-section.tsx
index 41dd28ca6..163241dec 100644
--- a/screenpipe-app-tauri/components/settings/ai-section.tsx
+++ b/screenpipe-app-tauri/components/settings/ai-section.tsx
@@ -15,21 +15,13 @@ import {
EyeOff,
Eye,
RefreshCw,
- Check,
- X,
- Play,
Loader2,
ChevronsUpDown,
- Cpu,
} from "lucide-react";
import { Badge } from "@/components/ui/badge";
import React, { useState, useEffect } from "react";
-import { LogFileButton } from "../log-file-button";
import { Input } from "../ui/input";
import { Textarea } from "../ui/textarea";
-import { toast } from "../ui/use-toast";
-import { invoke } from "@tauri-apps/api/core";
-import { open as openUrl } from "@tauri-apps/plugin-shell";
import { Button } from "../ui/button";
import { cn } from "@/lib/utils";
import { Card, CardContent } from "../ui/card";
@@ -180,6 +172,7 @@ const AISection = () => {
const fetchModels = async () => {
setIsLoadingModels(true);
+ console.log(settings.aiProviderType, settings.openaiApiKey, settings.aiUrl);
try {
switch (settings.aiProviderType) {
case "screenpipe-cloud":
@@ -219,6 +212,33 @@ const AISection = () => {
]);
break;
+ case "custom":
+ try {
+ const customResponse = await fetch(`${settings.aiUrl}/models`, {
+ headers: settings.openaiApiKey
+ ? { Authorization: `Bearer ${settings.openaiApiKey}` }
+ : {},
+ });
+ if (!customResponse.ok)
+ throw new Error("Failed to fetch custom models");
+ const customData = await customResponse.json();
+ console.log(customData);
+ setModels(
+ (customData.data || []).map((model: { id: string }) => ({
+ id: model.id,
+ name: model.id,
+ provider: "custom",
+ }))
+ );
+ } catch (error) {
+ console.error(
+ "Failed to fetch custom models, allowing manual input:",
+ error
+ );
+ setModels([]);
+ }
+ break;
+
default:
setModels([]);
}
@@ -235,7 +255,7 @@ const AISection = () => {
useEffect(() => {
fetchModels();
- }, [settings.aiProviderType]);
+ }, [settings.aiProviderType, settings.openaiApiKey, settings.aiUrl]);
return (
<div className="w-full space-y-6 py-4">
diff --git a/screenpipe-app-tauri/lib/api/store/index.ts b/screenpipe-app-tauri/lib/api/store/index.ts
index 347f8c9ab..8c4298db6 100644
--- a/screenpipe-app-tauri/lib/api/store/index.ts
+++ b/screenpipe-app-tauri/lib/api/store/index.ts
@@ -103,7 +103,6 @@ export class PipeApi {
}
const data = (await response.json()) as PurchaseHistoryResponse;
- console.log("purchase history data", data);
return data;
} catch (error) {
console.error("error getting purchase history:", error);
diff --git a/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index f976781a4..be7678199 100644
--- a/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -367,10 +367,6 @@ export function useSettings() {
const loadUser = async (token: string) => {
try {
- const BASE_URL =
- (await invoke("get_env", { name: "BASE_URL_PRIVATE" })) ??
- "https://screenpi.pe";
-
const response = await fetch(`https://screenpi.pe/api/user`, {
method: "POST",
headers: {
@@ -384,7 +380,6 @@ export function useSettings() {
}
const data = await response.json();
- console.log("data", data);
const userData = {
...data.user,
} as User;
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lock
index af8eef906..a89a1c6a0 100755
--- a/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -5289,7 +5289,7 @@ dependencies = [
[[package]]
name = "screenpipe-app"
-version = "0.32.7"
+version = "0.32.9"
dependencies = [
"anyhow",
"async-stream",
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index 690b83f28..f47cdc724 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.32.9"
+version = "0.32.10"
description = ""
authors = ["you"]
license = ""
diff --git a/screenpipe-app-tauri/src-tauri/src/analytics.rs b/screenpipe-app-tauri/src-tauri/src/analytics.rs
index 69421366e..b984281ca 100755
--- a/screenpipe-app-tauri/src-tauri/src/analytics.rs
+++ b/screenpipe-app-tauri/src-tauri/src/analytics.rs
@@ -1,4 +1,4 @@
-use log::{error, info, warn};
+use log::{error, warn};
use reqwest::Client;
use serde_derive::Deserialize;
use serde_json::json;
diff --git a/screenpipe-app-tauri/src-tauri/src/updates.rs b/screenpipe-app-tauri/src-tauri/src/updates.rs
index dd9c4a9b3..cfda7b470 100644
--- a/screenpipe-app-tauri/src-tauri/src/updates.rs
+++ b/screenpipe-app-tauri/src-tauri/src/updates.rs
@@ -44,6 +44,10 @@ impl UpdatesManager {
return Result::Ok(false);
}
}
+ if cfg!(debug_assertions) {
+ println!("dev mode is enabled, skipping update check");
+ return Result::Ok(false);
+ }
if let Err(err) = self.app.emit("update-all-pipes", ()) {
error!("Failed to update all pipes: {}", err);
diff --git a/screenpipe-js/cli/src/hooks/use-ai-provider.tsx b/screenpipe-js/cli/src/hooks/use-ai-provider.tsx
index 97ead8f20..d784a47be 100644
--- a/screenpipe-js/cli/src/hooks/use-ai-provider.tsx
+++ b/screenpipe-js/cli/src/hooks/use-ai-provider.tsx
@@ -54,7 +54,7 @@ export function useAiProvider(settings: Settings): AIProviderStatus {
break;
case "custom":
- if (!settings.aiUrl || !settings.openaiApiKey) {
+ if (!settings.aiUrl) {
setStatus({
isAvailable: false,
error: "custom ai url not configured",
diff --git a/screenpipe-server/src/bin/screenpipe-server.rs b/screenpipe-server/src/bin/screenpipe-server.rs
index 5336b5369..61a039ad0 100644
--- a/screenpipe-server/src/bin/screenpipe-server.rs
+++ b/screenpipe-server/src/bin/screenpipe-server.rs
@@ -1167,8 +1167,8 @@ async fn main() -> anyhow::Result<()> {
let shutdown_tx_clone = shutdown_tx.clone();
let pipe_manager = pipe_manager.clone();
tokio::spawn(async move {
- // sleep for 5 seconds
- tokio::time::sleep(std::time::Duration::from_secs(5)).await;
+ // sleep for 1 seconds
+ tokio::time::sleep(std::time::Duration::from_secs(1)).await;
if watch_pid(pid).await {
info!("Watched pid ({}) has stopped, initiating shutdown", pid);
diff --git a/screenpipe-server/src/pipe_manager.rs b/screenpipe-server/src/pipe_manager.rs
index 90d59897a..8d8006e23 100644
--- a/screenpipe-server/src/pipe_manager.rs
+++ b/screenpipe-server/src/pipe_manager.rs
@@ -7,13 +7,13 @@ use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
use std::future::Future;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::sync::Arc;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
use tokio::sync::mpsc::{self, Sender};
use tokio::sync::RwLock;
-use tracing::{debug, info, warn};
+use tracing::{debug, error, info, warn};
#[derive(Clone, Serialize, Deserialize, Debug)]
pub struct PipeInfo {
@@ -432,4 +432,153 @@ impl PipeManager {
}
})
}
+
+ pub async fn update_pipe_version(&self, id: &str, source: &str) -> Result<()> {
+ debug!("updating pipe: {}", id);
+ let pipe_dir = self.screenpipe_dir.join("pipes").join(id);
+
+ // 1. Get source URL from existing config
+ let pipe_json_path = pipe_dir.join("pipe.json");
+ let config = tokio::fs::read_to_string(&pipe_json_path).await?;
+ let mut config: Value = serde_json::from_str(&config)?;
+
+ // Create temp directory outside of pipes dir
+ let tmp_dir = std::env::temp_dir().join(format!("screenpipe_update_{}", id));
+ tokio::fs::create_dir_all(&tmp_dir).await?;
+ debug!("created temp dir: {:?}", tmp_dir);
+
+ // Download new version to temp directory
+ let tmp_pipe_dir = download_pipe_private(id, source, tmp_dir.clone()).await?;
+ debug!("downloaded new version to temp dir: {:?}", tmp_pipe_dir);
+
+ // Verify temp directory exists and contains the pipe files
+ if !tmp_pipe_dir.exists() {
+ error!("temp pipe directory not found: {:?}", tmp_pipe_dir);
+ return Err(anyhow::anyhow!(
+ "temp pipe directory not found: {:?}",
+ tmp_pipe_dir
+ ));
+ }
+
+ // Get version from new pipe.json in temp dir
+ let new_pipe_package_json_path = tmp_pipe_dir.join("package.json");
+ let new_config = tokio::fs::read_to_string(&new_pipe_package_json_path)
+ .await
+ .map_err(|e| anyhow::anyhow!("failed to read new package.json: {}", e))?;
+ let new_config: Value = serde_json::from_str(&new_config)
+ .map_err(|e| anyhow::anyhow!("failed to parse new package.json: {}", e))?;
+
+ // Update version in existing config
+ if let Some(new_version) = new_config.get("version").and_then(Value::as_str) {
+ if let Some(obj) = config.as_object_mut() {
+ obj.insert(
+ "version".to_string(),
+ Value::String(new_version.to_string()),
+ );
+ // Write updated config back to file
+ let updated_config = serde_json::to_string_pretty(&config)
+ .map_err(|e| anyhow::anyhow!("failed to serialize updated config: {}", e))?;
+ tokio::fs::write(&pipe_json_path, updated_config)
+ .await
+ .map_err(|e| anyhow::anyhow!("failed to write updated config: {}", e))?;
+ debug!("updated version in pipe.json to: {}", new_version);
+ }
+ }
+
+ // 2. Stop current pipe if running
+ self.stop_pipe(id)
+ .await
+ .map_err(|e| anyhow::anyhow!("failed to stop pipe: {}", e))?;
+ debug!("stopped running pipe");
+
+ // 3. Remove old files
+ let files_to_remove = ["node_modules", "bun.lockb", "package.json"];
+ for file in files_to_remove {
+ let path = pipe_dir.join(file);
+ if path.exists() {
+ if path.is_dir() {
+ tokio::fs::remove_dir_all(&path).await?;
+ } else {
+ tokio::fs::remove_file(&path).await?;
+ }
+ debug!("removed: {}", file);
+ }
+ }
+
+ debug!("moved old files to trash");
+
+ // 4. Move new files from temp to pipe dir
+ let mut entries = tokio::fs::read_dir(&tmp_pipe_dir).await?;
+ while let Some(entry) = entries.next_entry().await? {
+ let file_name = entry.file_name();
+ let src_path = entry.path();
+ let dst_path = pipe_dir.join(&file_name);
+
+ // Skip pipe.json to preserve configuration
+ if file_name == "pipe.json" {
+ continue;
+ }
+
+ if src_path.is_dir() {
+ if dst_path.exists() {
+ debug!("removing old dir: {:?}", dst_path);
+ tokio::fs::remove_dir_all(&dst_path).await?;
+ }
+ debug!("creating new dir: {:?}", dst_path);
+ tokio::fs::create_dir_all(&dst_path).await?;
+ debug!("copying new files: {:?}", src_path);
+ copy_dir_all(&src_path, &dst_path).await?;
+ } else {
+ debug!("copying new file: {:?}", src_path);
+ tokio::fs::copy(&src_path, &dst_path).await?;
+ }
+ debug!("moved: {:?}", file_name);
+ }
+
+ // Clean up temp directory
+ tokio::fs::remove_dir_all(&tmp_dir).await?;
+ debug!("cleaned up temp dir");
+
+ // 5. Restart pipe if it was enabled
+ if config
+ .get("enabled")
+ .and_then(Value::as_bool)
+ .unwrap_or(false)
+ {
+ let future = self.start_pipe_task(id.to_string()).await?;
+ tokio::spawn(future);
+ debug!("restarted pipe");
+ }
+
+ info!("pipe {} updated successfully", id);
+ Ok(())
+ }
+}
+
+// Helper function to recursively copy directories
+async fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<()> {
+ let src = src.as_ref();
+ let dst = dst.as_ref();
+
+ // Create a queue of directories to process
+ let mut dirs_to_process = vec![(src.to_path_buf(), dst.to_path_buf())];
+
+ while let Some((current_src, current_dst)) = dirs_to_process.pop() {
+ tokio::fs::create_dir_all(&current_dst).await?;
+
+ let mut entries = tokio::fs::read_dir(&current_src).await?;
+ while let Some(entry) = entries.next_entry().await? {
+ let ty = entry.file_type().await?;
+ let src_path = entry.path();
+ let dst_path = current_dst.join(entry.file_name());
+
+ if ty.is_dir() {
+ dirs_to_process.push((src_path, dst_path));
+ } else {
+ tokio::fs::copy(&src_path, &dst_path).await?;
+ }
+ }
+ }
+
+ Ok(())
}
diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rs
index 7ac128a44..ac382d164 100644
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@ -674,6 +674,12 @@ struct UpdatePipeConfigRequest {
config: serde_json::Value,
}
+#[derive(Deserialize)]
+struct UpdatePipeVersionRequest {
+ pipe_id: String,
+ source: String,
+}
+
// Handler functions
async fn download_pipe_handler(
State(state): State<Arc<AppState>>,
@@ -822,6 +828,33 @@ async fn update_pipe_config_handler(
}
}
+async fn update_pipe_version_handler(
+ State(state): State<Arc<AppState>>,
+ JsonResponse(payload): JsonResponse<UpdatePipeVersionRequest>,
+) -> Result<JsonResponse<Value>, (StatusCode, JsonResponse<Value>)> {
+ debug!("Updating pipe version for: {}", payload.pipe_id);
+ match state
+ .pipe_manager
+ .update_pipe_version(&payload.pipe_id, &payload.source)
+ .await
+ {
+ Ok(_) => Ok(JsonResponse(json!({
+ "data": {
+ "pipe_id": payload.pipe_id,
+ "message": "pipe version updated"
+ },
+ "success": true
+ }))),
+ Err(e) => Err((
+ StatusCode::BAD_REQUEST,
+ JsonResponse(json!({
+ "error": format!("failed to update pipe version: {}", e),
+ "success": false
+ })),
+ )),
+ }
+}
+
async fn get_pipe_info_handler(
State(state): State<Arc<AppState>>,
Path(pipe_id): Path<String>,
@@ -1989,6 +2022,7 @@ pub fn create_router() -> Router<Arc<AppState>> {
.route("/pipes/enable", post(run_pipe_handler))
.route("/pipes/disable", post(stop_pipe_handler))
.route("/pipes/update", post(update_pipe_config_handler))
+ .route("/pipes/update-version", post(update_pipe_version_handler))
.route("/pipes/delete", post(delete_pipe_handler))
.route("/health", get(health_check))
.route("/ws/health", get(ws_health_handler))