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: add option to add custom pipe from url

Louis Beaumont480813bebf58
diff --git a/examples/apps/screenpipe-app-tauri/components/feature-request-link.tsx b/examples/apps/screenpipe-app-tauri/components/feature-request-link.tsx
new file mode 100644
index 000000000..d30887d1c
--- /dev/null
+++ b/examples/apps/screenpipe-app-tauri/components/feature-request-link.tsx
@@ -0,0 +1,28 @@
+import { PrettyLink } from "./pretty-link";
+
+export const FeatureRequestLink: React.FC<{ className?: string }> = ({
+ className,
+}) => (
+ <PrettyLink
+ className={className}
+ variant="outline"
+ href="mailto:[email protected]?subject=Screenpipe%20Pipe%20Store%20Feature&body=yo%20louis%2C%0A%0Ai'd%20like%20to%20be%20featured%20in%20the%20Pipe%20Store.%20I've%20got%20an%20awesome%20product%20that%20use%20screenpipe%20and%20would%20get%20some%20more%20users%20by%20being%20listed%20here.%0A%0A%3Cmy%20product%20does%20x%2C%20y%2C%20z%3E%0A%3Cthis%20is%20my%20twitter%20tag%20or%20linkedin%3E%20-%3C%20will%20interact%20with%20your%20post%20for%20maximum%20cross%20marketing%0A%0Alet's%20chat%20about%20how%20we%20can%20collaborate%0A%0Alooking%20forward%20to%20connecting!%0A%0A%3Cps%20book%20call%20here%20https%3A%2F%2Fcal.com%2Flouis030195%2Fscreenpipe%3E"
+ >
+ <span className="mr-2">want to be featured here? reach out</span>
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="16"
+ height="16"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ >
+ <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
+ <polyline points="15 3 21 3 21 9" />
+ <line x1="10" y1="14" x2="21" y2="3" />
+ </svg>
+ </PrettyLink>
+);
diff --git a/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx b/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx
index b6ceca5ab..0834de7c3 100644
--- a/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx
+++ b/examples/apps/screenpipe-app-tauri/components/pipe-store.tsx
@@ -23,6 +23,9 @@ import { useSettings } from "@/lib/hooks/use-settings";
import { open } from "@tauri-apps/plugin-shell";
import { invoke } from "@tauri-apps/api/core";
import { toast } from "./ui/use-toast";
+import { Input } from "./ui/input";
+import { Plus } from "lucide-react";
+import { FeatureRequestLink } from "./feature-request-link";
const formatDate = (dateString: string) => {
const date = new Date(dateString);
return date.toLocaleDateString("en-US", {
@@ -32,41 +35,40 @@ const formatDate = (dateString: string) => {
});
};
-const FeatureRequestLink: React.FC<{ className?: string }> = ({
- className,
-}) => (
- <PrettyLink
- className={className}
- variant="outline"
- href="mailto:[email protected]?subject=Screenpipe%20Pipe%20Store%20Feature&body=yo%20louis%2C%0A%0Ai'd%20like%20to%20be%20featured%20in%20the%20Pipe%20Store.%20I've%20got%20an%20awesome%20product%20that%20use%20screenpipe%20and%20would%20get%20some%20more%20users%20by%20being%20listed%20here.%0A%0A%3Cmy%20product%20does%20x%2C%20y%2C%20z%3E%0A%3Cthis%20is%20my%20twitter%20tag%20or%20linkedin%3E%20-%3C%20will%20interact%20with%20your%20post%20for%20maximum%20cross%20marketing%0A%0Alet's%20chat%20about%20how%20we%20can%20collaborate%0A%0Alooking%20forward%20to%20connecting!%0A%0A%3Cps%20book%20call%20here%20https%3A%2F%2Fcal.com%2Flouis030195%2Fscreenpipe%3E"
- >
- <span className="mr-2">want to be featured here? reach out</span>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="16"
- height="16"
- viewBox="0 0 24 24"
- fill="none"
- stroke="currentColor"
- strokeWidth="2"
- strokeLinecap="round"
- strokeLinejoin="round"
- >
- <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" />
- <polyline points="15 3 21 3 21 9" />
- <line x1="10" y1="14" x2="21" y2="3" />
- </svg>
- </PrettyLink>
-);
-
const PipeDialog: React.FC = () => {
- const { pipes, loading, error } = usePipes([
- "https://github.com/different-ai/file-organizer-2000",
+ const [newRepoUrl, setNewRepoUrl] = useState("");
+ const { pipes, loading, error, addCustomPipe } = usePipes([
+ // "https://github.com/different-ai/file-organizer-2000",
"https://github.com/mediar-ai/screenpipe/tree/main/examples/typescript/pipe-tagging-activity",
]);
const [selectedPipe, setSelectedPipe] = useState<Pipe | null>(null);
const { settings, updateSettings } = useSettings();
+ const handleAddOwnPipe = async () => {
+ if (newRepoUrl) {
+ try {
+ toast({
+ title: "Adding custom pipe",
+ description: "Please wait...",
+ });
+ await addCustomPipe(newRepoUrl);
+ setNewRepoUrl("");
+ toast({
+ title: "Custom pipe added",
+ description:
+ "Your pipe has been successfully added. Screenpipe will restart with the new pipe.",
+ });
+ } catch (error) {
+ console.error("Failed to add custom pipe:", error);
+ toast({
+ title: "Error adding custom pipe",
+ description: "Please check the URL and try again.",
+ variant: "destructive",
+ });
+ }
+ }
+ };
+
const formatUpdatedTime = (date: string) => {
const now = new Date();
const updated = new Date(date);
@@ -319,7 +321,7 @@ const PipeDialog: React.FC = () => {
</DialogHeader>
<div className="flex h-[500px]">
<div className="w-1/3 pr-4 overflow-y-auto">
- {loading &&
+ {pipes.length === 0 &&
Array(5)
.fill(0)
.map((_, index) => (
@@ -327,7 +329,6 @@ const PipeDialog: React.FC = () => {
<Skeleton className="h-24 w-full" />
</div>
))}
- {error && <p>error: {error}</p>}
{pipes.map((pipe: Pipe) => (
<Card
key={pipe.name}
@@ -363,6 +364,21 @@ const PipeDialog: React.FC = () => {
</p>
</Card>
))}
+ <Card className="mb-2 p-2">
+ <Input
+ placeholder="Enter repo URL"
+ value={newRepoUrl}
+ onChange={(e) => setNewRepoUrl(e.target.value)}
+ />
+ <Button
+ className="mt-2 w-full"
+ onClick={handleAddOwnPipe}
+ disabled={!newRepoUrl}
+ >
+ <Plus className="mr-2" size={16} />
+ Add Your Own Pipe
+ </Button>
+ </Card>
</div>
<div className="w-full pl-4 border-l overflow-y-auto">
{renderPipeContent()}
diff --git a/examples/apps/screenpipe-app-tauri/lib/hooks/use-health-check.tsx b/examples/apps/screenpipe-app-tauri/lib/hooks/use-health-check.tsx
index 54b448a22..5b3ac3cb2 100644
--- a/examples/apps/screenpipe-app-tauri/lib/hooks/use-health-check.tsx
+++ b/examples/apps/screenpipe-app-tauri/lib/hooks/use-health-check.tsx
@@ -30,7 +30,7 @@ export function useHealthCheck() {
) {
return;
}
- console.log("setting health", data);
+ // console.log("setting health", data);
setHealth(data);
} catch (error) {
console.error("Failed to fetch health status:", error);
diff --git a/examples/apps/screenpipe-app-tauri/lib/hooks/use-pipes.tsx b/examples/apps/screenpipe-app-tauri/lib/hooks/use-pipes.tsx
index 6ff19a44e..97c67e832 100644
--- a/examples/apps/screenpipe-app-tauri/lib/hooks/use-pipes.tsx
+++ b/examples/apps/screenpipe-app-tauri/lib/hooks/use-pipes.tsx
@@ -116,10 +116,100 @@ const fetchFileContent = async (
}
};
-export const usePipes = (repoUrls: string[]) => {
+export const usePipes = (initialRepoUrls: string[]) => {
const [pipes, setPipes] = useState<Pipe[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
+ const [repoUrls, setRepoUrls] = useState<string[]>(initialRepoUrls);
+
+ const fetchPipeData = async (repoUrl: string): Promise<Pipe | null> => {
+ try {
+ const urlParts = repoUrl.split("/");
+ const isSubdir = urlParts.length > 5;
+ const repoOwner = urlParts[3];
+ const repoName = urlParts[4];
+ const repoFullName = `${repoOwner}/${repoName}`;
+ const branch = isSubdir ? urlParts[6] : "main";
+ const subDir = isSubdir ? urlParts.slice(7).join("/") : "";
+
+ console.log(`Fetching repo data for ${repoFullName}`);
+ const repoData = await fetchWithCache(
+ `https://api.github.com/repos/${repoFullName}`
+ );
+
+ if (isSubdir) {
+ console.log(
+ `Fetching subdirectory contents for ${repoFullName}/${subDir}`
+ );
+ const contents = await fetchSubdirContents(
+ repoFullName,
+ branch,
+ subDir
+ );
+ if (!contents || !Array.isArray(contents)) return null;
+
+ const jsFiles = contents.filter((file: any) =>
+ file.name.endsWith(".js")
+ );
+ const hasJsFile = jsFiles.length > 0;
+ const readmeFile = contents.find(
+ (file: any) => file.name.toLowerCase() === "readme.md"
+ );
+
+ if (!hasJsFile || !readmeFile) return null;
+ console.log(`Fetching README content for ${repoFullName}/${subDir}`);
+ const readmeContent = await fetchFileContent(
+ repoFullName,
+ branch,
+ `${subDir}/${readmeFile.name}`
+ );
+
+ const mainFile =
+ jsFiles.find((file: any) => file.name === "index.js") || jsFiles[0];
+ const mainFileUrl = mainFile
+ ? `https://raw.githubusercontent.com/${repoFullName}/${branch}/${subDir}/${mainFile.name}`
+ : undefined;
+
+ console.log(`Fetching latest release for ${repoFullName}`);
+
+ return {
+ name: subDir.split("/").pop() || repoData.name,
+ downloads: repoData.stargazers_count,
+ version: await fetchLatestRelease(repoFullName),
+ author: repoData.owner.login,
+ authorLink: repoData.owner.html_url,
+ repository: `${repoData.html_url}/tree/${branch}/${subDir}`,
+ lastUpdate: repoData.updated_at,
+ description: repoData.description,
+ fullDescription: readmeContent
+ ? convertHtmlToMarkdown(readmeContent)
+ : "",
+ mainFile: mainFileUrl,
+ };
+ } else {
+ console.log(`Fetching README for ${repoFullName}`);
+ const fullDescription = await fetchReadme(repoFullName);
+
+ console.log(`Fetching latest release for ${repoFullName}`);
+ const version = await fetchLatestRelease(repoFullName);
+
+ return {
+ name: repoData.name,
+ downloads: repoData.stargazers_count,
+ version,
+ author: repoData.owner.login,
+ authorLink: repoData.owner.html_url,
+ repository: repoData.html_url,
+ lastUpdate: repoData.updated_at,
+ description: repoData.description,
+ fullDescription,
+ };
+ }
+ } catch (error) {
+ console.error(`Error processing ${repoUrl}:`, error);
+ return null;
+ }
+ };
useEffect(() => {
let isMounted = true;
@@ -131,95 +221,7 @@ export const usePipes = (repoUrls: string[]) => {
setError(null);
try {
- const pipePromises = repoUrls.map(async (repoUrl) => {
- try {
- const urlParts = repoUrl.split("/");
- const isSubdir = urlParts.length > 5; // github.com/owner/repo/tree/branch/subdir
- const repoOwner = urlParts[3];
- const repoName = urlParts[4];
- const repoFullName = `${repoOwner}/${repoName}`;
- const branch = isSubdir ? urlParts[6] : "main"; // Assume 'main' if not specified
- const subDir = isSubdir ? urlParts.slice(7).join("/") : "";
-
- const repoData = await fetchWithCache(
- `https://api.github.com/repos/${repoFullName}`
- );
-
- if (isSubdir) {
- try {
- const contents = await fetchSubdirContents(
- repoFullName,
- branch,
- subDir
- );
- if (!contents || !Array.isArray(contents)) return null;
-
- const jsFiles = contents.filter((file: any) =>
- file.name.endsWith(".js")
- );
- const hasJsFile = jsFiles.length > 0;
- const readmeFile = contents.find(
- (file: any) => file.name.toLowerCase() === "readme.md"
- );
-
- if (!hasJsFile || !readmeFile) return null;
-
- const readmeContent = await fetchFileContent(
- repoFullName,
- branch,
- `${subDir}/${readmeFile.name}`
- );
-
- // Find the main JavaScript file (prefer index.js if it exists)
- const mainFile =
- jsFiles.find((file: any) => file.name === "index.js") ||
- jsFiles[0];
-
- const mainFileUrl = mainFile
- ? `https://raw.githubusercontent.com/${repoFullName}/${branch}/${subDir}/${mainFile.name}`
- : undefined;
-
- return {
- name: subDir.split("/").pop() || repoData.name,
- downloads: repoData.stargazers_count,
- version: await fetchLatestRelease(repoFullName),
- author: repoData.owner.login,
- authorLink: repoData.owner.html_url,
- repository: `${repoData.html_url}/tree/${branch}/${subDir}`,
- lastUpdate: repoData.updated_at,
- description: repoData.description,
- fullDescription: readmeContent
- ? convertHtmlToMarkdown(readmeContent)
- : "",
- mainFile: mainFileUrl,
- };
- } catch (subdirError) {
- console.error(
- `Error processing subdirectory ${repoUrl}:`,
- subdirError
- );
- return null; // Skip this subdirectory if there's an error
- }
- } else {
- // Original behavior for root repos
- return {
- name: repoData.name,
- downloads: repoData.stargazers_count,
- version: await fetchLatestRelease(repoFullName),
- author: repoData.owner.login,
- authorLink: repoData.owner.html_url,
- repository: repoData.html_url,
- lastUpdate: repoData.updated_at,
- description: repoData.description,
- fullDescription: await fetchReadme(repoFullName),
- };
- }
- } catch (error) {
- console.error(`Error processing ${repoUrl}:`, error);
- return null;
- }
- });
-
+ const pipePromises = repoUrls.map(fetchPipeData);
const fetchedPipes = (await Promise.all(pipePromises)).filter(
Boolean
) as Pipe[];
@@ -244,7 +246,38 @@ export const usePipes = (repoUrls: string[]) => {
return () => {
isMounted = false;
};
- }, []);
+ }, [repoUrls]);
+
+ const addCustomPipe = async (newRepoUrl: string) => {
+ setError(null);
+
+ // Check if the URL already exists
+ if (repoUrls.includes(newRepoUrl)) {
+ setError("This pipe is already in the list.");
+ return;
+ }
+
+ try {
+ const newPipe = await fetchPipeData(newRepoUrl);
+ if (newPipe) {
+ // Check if a pipe with the same name already exists
+ if (pipes.some((pipe) => pipe.name === newPipe.name)) {
+ setError("A pipe with this name already exists.");
+ return;
+ }
+
+ setRepoUrls((prevUrls) => [...prevUrls, newRepoUrl]);
+ setPipes((prevPipes) => [...prevPipes, newPipe]);
+ } else {
+ throw new Error("Failed to fetch pipe data");
+ }
+ } catch (error) {
+ console.error("Error adding custom pipe:", error);
+ setError(
+ error instanceof Error ? error.message : "Failed to add custom pipe"
+ );
+ }
+ };
- return { pipes, loading, error };
+ return { pipes, loading, error, addCustomPipe };
};
diff --git a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index 170972fbc..1eca6112b 100644
--- a/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "0.1.72"
+version = "0.1.73"
description = ""
authors = ["you"]
license = ""
diff --git a/examples/typescript/pipe-activity-topic-tracker/README.md b/examples/typescript/pipe-activity-topic-tracker/README.md
index f0351b7ed..73fc7461a 100644
--- a/examples/typescript/pipe-activity-topic-tracker/README.md
+++ b/examples/typescript/pipe-activity-topic-tracker/README.md
@@ -1,12 +1,84 @@
+![Screenpipe Pipe Store json](https://github.com/user-attachments/assets/6c074beb-5b0f-4829-8a07-52805a78e80c)
+
+in screenpipe we have a plugin system called "pipe store" or "pipes"
+
+think of it like this:
+
+screenpipe data -> your pipe like "AI annotate" or "send to salesforce"
+
+a more dev-friendly explanation:
+
+screenpipe | AI tag | notion update
+
+or
+
+screenpipe | AI tag | slack send report
+
+or
+
+screenpipe | fill salesforce
+
+or
+
+screenpipe | logs daily
+
+basically it would read, process, annotate, analyse, summarize, send, your data customisable to your desire, effortlessly
+
+### pipe-activity-topic-tracker
+
+this is an experimental, but official pipe, that will use ollama + phi3.5 to track your activities and generate summaries every 1 min
+
+soon we'll make it easier to search through these summaries but in the meantime you can use it to enrich your data
+
+and AI will be able to provide you more relevant answers about your activities
+this is how you run it through the app:
-usage (will run 24/7 on your computer and update a local json file)
+```bash
+ollama run phi3.5
+```
+
+add the url of this pipe in the input and click "add" and install
+
+`https://github.com/mediar-ai/screenpipe/tree/main/examples/typescript/pipe-activity-topic-tracker`
+
+wait a few minutes then look at the json file
+
+### tech details
+we run deno runtime (a JS/TS engine) within the rust code, which host your pipes, its 99.9% similar to normal JS code
+
+### dev mode
+
+if you're in dev mode you can run the cli like this:
+
+```bash
+screenpipe --pipe https://github.com/mediar-ai/screenpipe/edit/main/examples/typescript/pipe-activity-topic-tracker/main.js
```
-ollama run mistral-nemo
-cargo build --release --features pipes
-./target/release/screenpipe --pipe examples/typescript/pipe-activity-topic-tracker/main.js
+
+or dev your own pipe:
+
+```bash
+screenpipe --pipe myPipe.js
```
-![Screenpipe Pipe Store json](https://github.com/user-attachments/assets/6c074beb-5b0f-4829-8a07-52805a78e80c)
+please look at the code, it's 99% normal JS but there are limitations currently:
+- you cannot use dependencies (yet)
+- untested with typescript (but will make pipes TS first soon)
+
+i recommend you copy paste the current main.js file into AI and ask some changes for whatever you want to do, make sure to run an infinite loop also
+
+get featured in the pipe store:
+
+<img width="1312" alt="Screenshot 2024-08-27 at 17 06 45" src="https://github.com/user-attachments/assets/b6856bf4-2cfd-4888-be11-ee7baae6b84b">
+
+just ask @louis030195
+
+### what's next for pipes
+
+- use dependencies (like vercel/ai so cool)
+- TS
+- access to screenpipe desktop api (e.g. trigger notifications, customise what cursor-like @ are in the chat, etc.)
+- easier to publish your pipes (like obsidian store)
+- everything frictionless, effortless, and maximize the value you get out of screenpipe
diff --git a/examples/typescript/pipe-activity-topic-tracker/main.js b/examples/typescript/pipe-activity-topic-tracker/main.js
index 5fcb113ff..9311b202c 100644
--- a/examples/typescript/pipe-activity-topic-tracker/main.js
+++ b/examples/typescript/pipe-activity-topic-tracker/main.js
@@ -138,7 +138,6 @@ async function runActivityTracker() {
(async () => {
try {
await runActivityTracker();
- return "hi";
} catch (error) {
console.error("Fatal error in Activity Topic Tracker:");
if (error instanceof Error) {
diff --git a/examples/typescript/pipe-stream-ocr-text/README.md b/examples/typescript/pipe-stream-ocr-text/README.md
new file mode 100644
index 000000000..eee41b780
--- /dev/null
+++ b/examples/typescript/pipe-stream-ocr-text/README.md
@@ -0,0 +1,75 @@
+
+
+in screenpipe we have a plugin system called "pipe store" or "pipes"
+
+think of it like this:
+
+screenpipe data -> your pipe like "AI annotate" or "send to salesforce"
+
+a more dev-friendly explanation:
+
+screenpipe | AI tag | notion update
+
+or
+
+screenpipe | AI tag | slack send report
+
+or
+
+screenpipe | fill salesforce
+
+or
+
+screenpipe | logs daily
+
+basically it would read, process, annotate, analyse, summarize, send, your data customisable to your desire, effortlessly
+
+### pipe-stream-ocr-text
+
+this is an experimental, but official pipe, that will stream OCR text from your screen data every 1 min
+
+this is how you run it through the app:
+
+add the url of this pipe in the input and click "add" and install
+
+`https://github.com/mediar-ai/screenpipe/tree/main/examples/typescript/pipe-stream-ocr-text`
+
+wait a few minutes then look at the markdown file
+
+### tech details
+
+we run deno runtime (a JS/TS engine) within the rust code, which host your pipes, its 99.9% similar to normal JS code
+
+### dev mode
+
+if you're in dev mode you can run the cli like this:
+
+```bash
+screenpipe --pipe https://github.com/mediar-ai/screenpipe/edit/main/examples/typescript/pipe-stream-ocr-text/main.js
+```
+
+or dev your own pipe:
+
+```bash
+screenpipe --pipe myPipe.js
+```
+
+please look at the code, it's 99% normal JS but there are limitations currently:
+- you cannot use dependencies (yet)
+- untested with typescript (but will make pipes TS first soon)
+
+i recommend you copy paste the current main.js file into AI and ask some changes for whatever you want to do, make sure to run an infinite loop also
+
+get featured in the pipe store:
+
+<img width="1312" alt="Screenshot 2024-08-27 at 17 06 45" src="https://github.com/user-attachments/assets/b6856bf4-2cfd-4888-be11-ee7baae6b84b">
+
+just ask @louis030195
+
+### what's next for pipes
+
+- use dependencies (like vercel/ai so cool)
+- TS
+- access to screenpipe desktop api (e.g. trigger notifications, customise what cursor-like @ are in the chat, etc.)
+- easier to publish your pipes (like obsidian store)
+- everything frictionless, effortless, and maximize the value you get out of screenpipe
diff --git a/examples/typescript/pipe-stream-ocr-text/main.js b/examples/typescript/pipe-stream-ocr-text/main.js
new file mode 100644
index 000000000..f9c8e43be
--- /dev/null
+++ b/examples/typescript/pipe-stream-ocr-text/main.js
@@ -0,0 +1,49 @@
+const INTERVAL = 1 * 60 * 1000; // 1 minute in milliseconds
+
+async function queryScreenpipe() {
+ try {
+ const now = new Date();
+ const oneMinuteAgo = new Date(now.getTime() - INTERVAL);
+
+ const queryParams = `start_time=${oneMinuteAgo.toISOString()}&end_time=${now.toISOString()}&limit=50&content_type=ocr`;
+
+ const result = await pipe.get(`http://localhost:3030/search?${queryParams}`);
+ console.log("Retrieved", result.data.length, "items from screenpipe");
+ return result.data;
+ } catch (error) {
+ console.error("Error querying screenpipe:", error);
+ return [];
+ }
+}
+
+async function writeToMarkdown(data) {
+ console.log("Writing to markdown", JSON.stringify(data));
+ const fileName = `screen-ocr-${new Date().toISOString().replace(/[:.]/g, '-')}.md`;
+ const content = data.map(item => `## ${item.content.timestamp}\n\n${item.content.text}\n\n---\n`).join('\n');
+
+ await pipe.writeFile(fileName, content);
+ console.log(`Written OCR data to ${fileName}`);
+}
+
+async function runOCRTracker() {
+ console.log("Starting OCR Tracker");
+
+ while (true) {
+ try {
+ const screenData = await queryScreenpipe();
+ await writeToMarkdown(screenData);
+ } catch (error) {
+ console.error("Error in OCR tracking:", error);
+ }
+ await new Promise(resolve => setTimeout(resolve, INTERVAL));
+ }
+}
+
+// Self-invoking async function to run the OCR tracker
+(async () => {
+ try {
+ await runOCRTracker();
+ } catch (error) {
+ console.error("Fatal error in OCR Tracker:", error);
+ }
+})();
\ No newline at end of file