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: bunx @screenpipe/create-pipe

Louis Beaumont5f7b9ee603bc
diff --git a/.cargo/config.toml b/.cargo/config.toml
index 5db3471d1..ad038201e 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -16,17 +16,6 @@ rustflags = [
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-Wl,--allow-multiple-definition"]
-# make this work :'( - atm dirty hack: cp screenpipe-vision/lib* /usr/local/lib
-# [env]
-# DYLD_LIBRARY_PATH = { value = "${CARGO_MANIFEST_DIR}/screenpipe-vision/lib", relative = true }
-
-# [target.'cfg(target_os = "macos")']
-# rustflags = [
-# "-C", "link-arg=-Wl,-rpath,@executable_path/screenpipe-vision/lib",
-# "-C", "link-arg=-Wl,-rpath,@loader_path/screenpipe-vision/lib",
-# "-C", "link-arg=-Wl,-rpath,${CARGO_MANIFEST_DIR}/screenpipe-vision/lib"
-# ]
-
[target.aarch64-apple-darwin]
rustflags = ["-L", "screenpipe-vision/lib"]
diff --git a/examples/create-pipe/.gitignore b/examples/create-pipe/.gitignore
new file mode 100644
index 000000000..9b1ee42e8
--- /dev/null
+++ b/examples/create-pipe/.gitignore
@@ -0,0 +1,175 @@
+# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
+
+# Logs
+
+logs
+_.log
+npm-debug.log_
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+.pnpm-debug.log*
+
+# Caches
+
+.cache
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+
+report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
+
+# Runtime data
+
+pids
+_.pid
+_.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+
+lib-cov
+
+# Coverage directory used by tools like istanbul
+
+coverage
+*.lcov
+
+# nyc test coverage
+
+.nyc_output
+
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
+
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+
+bower_components
+
+# node-waf configuration
+
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+
+build/Release
+
+# Dependency directories
+
+node_modules/
+jspm_packages/
+
+# Snowpack dependency directory (https://snowpack.dev/)
+
+web_modules/
+
+# TypeScript cache
+
+*.tsbuildinfo
+
+# Optional npm cache directory
+
+.npm
+
+# Optional eslint cache
+
+.eslintcache
+
+# Optional stylelint cache
+
+.stylelintcache
+
+# Microbundle cache
+
+.rpt2_cache/
+.rts2_cache_cjs/
+.rts2_cache_es/
+.rts2_cache_umd/
+
+# Optional REPL history
+
+.node_repl_history
+
+# Output of 'npm pack'
+
+*.tgz
+
+# Yarn Integrity file
+
+.yarn-integrity
+
+# dotenv environment variable files
+
+.env
+.env.development.local
+.env.test.local
+.env.production.local
+.env.local
+
+# parcel-bundler cache (https://parceljs.org/)
+
+.parcel-cache
+
+# Next.js build output
+
+.next
+out
+
+# Nuxt.js build / generate output
+
+.nuxt
+dist
+
+# Gatsby files
+
+# Comment in the public line in if your project uses Gatsby and not Next.js
+
+# https://nextjs.org/blog/next-9-1#public-directory-support
+
+# public
+
+# vuepress build output
+
+.vuepress/dist
+
+# vuepress v2.x temp and cache directory
+
+.temp
+
+# Docusaurus cache and generated files
+
+.docusaurus
+
+# Serverless directories
+
+.serverless/
+
+# FuseBox cache
+
+.fusebox/
+
+# DynamoDB Local files
+
+.dynamodb/
+
+# TernJS port file
+
+.tern-port
+
+# Stores VSCode versions used for testing VSCode extensions
+
+.vscode-test
+
+# yarn v2
+
+.yarn/cache
+.yarn/unplugged
+.yarn/build-state.yml
+.yarn/install-state.gz
+.pnp.*
+
+# IntelliJ based IDEs
+.idea
+
+# Finder (MacOS) folder config
+.DS_Store
diff --git a/examples/create-pipe/README.md b/examples/create-pipe/README.md
new file mode 100644
index 000000000..45f6033d2
--- /dev/null
+++ b/examples/create-pipe/README.md
@@ -0,0 +1,35 @@
+# create-pipe
+
+create a new screenpipe pipe with nextjs
+
+## usage
+
+with npm:
+```bash
+npx @screenpipe/[email protected]
+```
+
+with bun:
+```bash
+bunx @screenpipe/[email protected]
+```
+
+with pnpm:
+```bash
+pnpx @screenpipe/[email protected]
+```
+
+with yarn:
+```bash
+yarn add @screenpipe/[email protected]
+```
+
+## features
+
+- nextjs setup
+- typescript by default
+- tailwind/css modules option
+- ui/headless pipe options
+- import alias configuration
+- experimental ai customization
+
diff --git a/examples/create-pipe/bun.lockb b/examples/create-pipe/bun.lockb
new file mode 100755
index 000000000..466057786
Binary files /dev/null and b/examples/create-pipe/bun.lockb differ
diff --git a/examples/create-pipe/index.ts b/examples/create-pipe/index.ts
new file mode 100644
index 000000000..3cd4ec2ef
--- /dev/null
+++ b/examples/create-pipe/index.ts
@@ -0,0 +1,231 @@
+#!/usr/bin/env node
+import fs from "fs-extra";
+import path from "path";
+import { select, input } from "@inquirer/prompts";
+import chalk from "chalk";
+import ora from "ora";
+import https from "https";
+import { Extract } from "unzip-stream";
+
+const PIPE_ADDITIONS = {
+ dependencies: {
+ "@screenpipe/js": "latest",
+ },
+ devDependencies: {
+ "bun-types": "latest",
+ },
+};
+
+const PIPE_TYPE_OPTIONS = [
+ {
+ name: "ui - create a pipe with a user interface",
+ value: "ui",
+ },
+ {
+ name: "headless - create a pipe without ui",
+ value: "headless",
+ },
+];
+
+async function downloadAndExtractRepo(
+ owner: string,
+ repo: string,
+ branch: string,
+ subdir: string,
+ destPath: string
+): Promise<void> {
+ const url = `https://github.com/${owner}/${repo}/archive/refs/heads/${branch}.zip`;
+
+ // Create a temporary directory for extraction
+ const tempDir = path.join(destPath, "_temp");
+ await fs.ensureDir(tempDir);
+
+ return new Promise((resolve, reject) => {
+ const request = https
+ .get(url, (response) => {
+ if (response.statusCode === 302 || response.statusCode === 301) {
+ const redirectUrl = response.headers.location;
+ if (!redirectUrl) {
+ reject(new Error("Redirect location not found"));
+ return;
+ }
+
+ https
+ .get(redirectUrl, async (redirectResponse) => {
+ if (redirectResponse.statusCode !== 200) {
+ reject(
+ new Error(
+ `Failed to download: ${redirectResponse.statusCode}`
+ )
+ );
+ return;
+ }
+
+ const extractStream = Extract({ path: tempDir });
+
+ extractStream.on("finish", async () => {
+ try {
+ // Move files from the specific subdirectory to the final destination
+ const sourcePath = path.join(
+ tempDir,
+ `screenpipe-${branch}`,
+ subdir
+ );
+ await fs.copy(sourcePath, destPath);
+ // Clean up temp directory
+ await fs.remove(tempDir);
+ console.log("extraction completed");
+ resolve();
+ } catch (err) {
+ reject(err);
+ }
+ });
+
+ extractStream.on("error", async (err) => {
+ await fs.remove(tempDir).catch(console.error);
+ reject(err);
+ });
+
+ redirectResponse.pipe(extractStream);
+ })
+ .on("error", async (err) => {
+ await fs.remove(tempDir).catch(console.error);
+ reject(err);
+ });
+ } else {
+ reject(new Error(`Failed to download: ${response.statusCode}`));
+ }
+ })
+ .on("error", async (err) => {
+ await fs.remove(tempDir).catch(console.error);
+ reject(err);
+ });
+
+ request.end();
+ });
+}
+
+async function main() {
+ console.log(chalk.bold("\nwelcome to create-pipe! πŸš€\n"));
+ console.log("let's create a new screenpipe pipe.\n");
+ console.log(
+ "pipes are plugins that interact with captured screen and audio data."
+ );
+ console.log("build powerful agents, monetize it, etc.\n");
+
+ // get project name
+ const pipeName = await input({
+ message: "what is your pipe name?",
+ default: "my-screenpipe",
+ validate: (input) => {
+ if (input.trim().length === 0) return "pipe name is required";
+ return true;
+ },
+ });
+
+ // get directory
+ const directory = await input({
+ message: "where would you like to create your pipe?",
+ default: pipeName,
+ });
+
+ // get pipe type
+ const pipeType = await select({
+ message: "would you like to add a user interface to your pipe?",
+ choices: PIPE_TYPE_OPTIONS,
+ });
+
+ // ai customization confirmation
+ // const useAI = await confirm({
+ // message: "would you like to use ai to customize your pipe? (experimental)",
+ // default: false,
+ // });
+
+ const spinner = ora("creating your pipe...").start();
+
+ try {
+ // Download and extract the appropriate template
+ if (pipeType === "ui") {
+ await downloadAndExtractRepo(
+ "mediar-ai",
+ "screenpipe",
+ "main",
+ "examples/typescript/pipe-simple-nextjs",
+ directory
+ );
+
+ // Update package.json with the pipe name
+ const pkgPath = path.join(process.cwd(), directory, "package.json");
+ const pkg = await fs.readJson(pkgPath);
+
+ pkg.name = pipeName;
+ pkg.dependencies = {
+ ...pkg.dependencies,
+ ...PIPE_ADDITIONS.dependencies,
+ };
+ pkg.devDependencies = {
+ ...pkg.devDependencies,
+ ...PIPE_ADDITIONS.devDependencies,
+ };
+
+ await fs.writeJson(pkgPath, pkg, { spaces: 2 });
+ } else {
+ await downloadAndExtractRepo(
+ "mediar-ai",
+ "screenpipe",
+ "main",
+ "examples/typescript/pipe-obsidian-time-logs",
+ directory
+ );
+
+ // Update pipe.ts only for headless pipes
+ const pipePath = path.join(process.cwd(), directory, "pipe.ts");
+ let pipeContent = await fs.readFile(pipePath, "utf8");
+ pipeContent = pipeContent.replace(
+ /name: ["'].*["']/,
+ `name: "${pipeName}"`
+ );
+ await fs.writeFile(pipePath, pipeContent);
+ }
+
+ // if (useAI) {
+ // spinner.text = "customizing with ai...";
+ // // TODO: implement AI customization
+ // await new Promise((resolve) => setTimeout(resolve, 1000)); // placeholder
+ // }
+
+ spinner.succeed(chalk.green("pipe created successfully! πŸŽ‰"));
+
+ console.log("\nto get started:");
+ console.log(chalk.cyan(`cd ${directory}`));
+ console.log(chalk.cyan("bun install"));
+
+ if (pipeType === "ui") {
+ console.log(chalk.cyan("bun dev"));
+ } else {
+ // TODO make these shits non mandatory
+ console.log(
+ chalk.cyan(`export SCREENPIPE_DIR="$HOME/.screenpipe"
+export PIPE_ID="${pipeName}"
+export PIPE_FILE="pipe.ts"
+export PIPE_DIR="$SCREENPIPE_DIR/pipes/${pipeName}"
+
+bun run pipe.ts
+ `)
+ );
+ }
+
+ console.log(
+ "\nwhen you're ready, you can ship your pipe to the app by adding it to the pipe store using the UI and then send a PR to the main repo.\n"
+ );
+ } catch (error) {
+ spinner.fail("failed to create pipe");
+ console.error(error);
+ process.exit(1);
+ }
+}
+
+main().catch((err) => {
+ console.error("unexpected error:", err);
+ process.exit(1);
+});
diff --git a/examples/create-pipe/package.json b/examples/create-pipe/package.json
new file mode 100644
index 000000000..a292eadfe
--- /dev/null
+++ b/examples/create-pipe/package.json
@@ -0,0 +1,44 @@
+{
+ "name": "@screenpipe/create-pipe",
+ "version": "0.0.5",
+ "description": "create a new screenpipe pipe with nextjs",
+ "type": "module",
+ "bin": {
+ "create-pipe": "./dist/index.js"
+ },
+ "files": [
+ "dist"
+ ],
+ "scripts": {
+ "build": "tsc && bun build ./index.ts --outdir ./dist --target node",
+ "prepublishOnly": "npm run build",
+ "execute": "bun run build && bun ./dist/index.js"
+ },
+ "keywords": [
+ "screenpipe",
+ "create-pipe",
+ "nextjs",
+ "cli"
+ ],
+ "author": "louis030195",
+ "license": "MIT",
+ "dependencies": {
+ "@inquirer/prompts": "^3.3.0",
+ "chalk": "^5.3.0",
+ "fs-extra": "^11.2.0",
+ "ora": "^8.0.1",
+ "unzip-stream": "^0.3.1"
+ },
+ "devDependencies": {
+ "@types/fs-extra": "^11.0.4",
+ "@types/node": "^20.10.5",
+ "@types/unzip-stream": "^0.3.4",
+ "typescript": "^5.3.3"
+ },
+ "engines": {
+ "node": ">=18.0.0"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/examples/create-pipe/tsconfig.json b/examples/create-pipe/tsconfig.json
new file mode 100644
index 000000000..d5c212085
--- /dev/null
+++ b/examples/create-pipe/tsconfig.json
@@ -0,0 +1,25 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "module": "ES2020",
+ "moduleResolution": "node",
+ "esModuleInterop": true,
+ "outDir": "./dist",
+ "rootDir": ".",
+ "strict": true,
+ "skipLibCheck": true,
+ "declaration": true,
+ "typeRoots": [
+ "./node_modules/@types",
+ "./create-next-app.d.ts"
+ ],
+ },
+ "include": [
+ "index.ts",
+ "create-next-app.d.ts"
+ ],
+ "exclude": [
+ "node_modules",
+ "dist"
+ ]
+}
\ No newline at end of file
diff --git a/examples/typescript/pipe-meeting-summary-by-email/README.md b/examples/typescript/archive/pipe-meeting-summary-by-email/README.md
similarity index 100%
rename from examples/typescript/pipe-meeting-summary-by-email/README.md
rename to examples/typescript/archive/pipe-meeting-summary-by-email/README.md
diff --git a/examples/typescript/pipe-meeting-summary-by-email/pipe.json b/examples/typescript/archive/pipe-meeting-summary-by-email/pipe.json
similarity index 100%
rename from examples/typescript/pipe-meeting-summary-by-email/pipe.json
rename to examples/typescript/archive/pipe-meeting-summary-by-email/pipe.json
diff --git a/examples/typescript/pipe-meeting-summary-by-email/pipe.ts b/examples/typescript/archive/pipe-meeting-summary-by-email/pipe.ts
similarity index 100%
rename from examples/typescript/pipe-meeting-summary-by-email/pipe.ts
rename to examples/typescript/archive/pipe-meeting-summary-by-email/pipe.ts
diff --git a/examples/typescript/pipe-obsidian-time-logs/.gitignore b/examples/typescript/pipe-obsidian-time-logs/.gitignore
new file mode 100644
index 000000000..9b1ee42e8
--- /dev/null
+++ b/examples/typescript/pipe-obsidian-time-logs/.gitignore
@@ -0,0 +1,175 @@
+# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
+
+# Logs
+
+logs
+_.log
+npm-debug.log_
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+.pnpm-debug.log*
+
+# Caches
+
+.cache
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+
+report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
+
+# Runtime data
+
+pids
+_.pid
+_.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+
+lib-cov
+
+# Coverage directory used by tools like istanbul
+
+coverage
+*.lcov
+
+# nyc test coverage
+
+.nyc_output
+
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
+
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+
+bower_components
+
+# node-waf configuration
+
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+
+build/Release
+
+# Dependency directories
+
+node_modules/
+jspm_packages/
+
+# Snowpack dependency directory (https://snowpack.dev/)
+
+web_modules/
+
+# TypeScript cache
+
+*.tsbuildinfo
+
+# Optional npm cache directory
+
+.npm
+
+# Optional eslint cache
+
+.eslintcache
+
+# Optional stylelint cache
+
+.stylelintcache
+
+# Microbundle cache
+
+.rpt2_cache/
+.rts2_cache_cjs/
+.rts2_cache_es/
+.rts2_cache_umd/
+
+# Optional REPL history
+
+.node_repl_history
+
+# Output of 'npm pack'
+
+*.tgz
+
+# Yarn Integrity file
+
+.yarn-integrity
+
+# dotenv environment variable files
+
+.env
+.env.development.local
+.env.test.local
+.env.production.local
+.env.local
+
+# parcel-bundler cache (https://parceljs.org/)
+
+.parcel-cache
+
+# Next.js build output
+
+.next
+out
+
+# Nuxt.js build / generate output
+
+.nuxt
+dist
+
+# Gatsby files
+
+# Comment in the public line in if your project uses Gatsby and not Next.js
+
+# https://nextjs.org/blog/next-9-1#public-directory-support
+
+# public
+
+# vuepress build output
+
+.vuepress/dist
+
+# vuepress v2.x temp and cache directory
+
+.temp
+
+# Docusaurus cache and generated files
+
+.docusaurus
+
+# Serverless directories
+
+.serverless/
+
+# FuseBox cache
+
+.fusebox/
+
+# DynamoDB Local files
+
+.dynamodb/
+
+# TernJS port file
+
+.tern-port
+
+# Stores VSCode versions used for testing VSCode extensions
+
+.vscode-test
+
+# yarn v2
+
+.yarn/cache
+.yarn/unplugged
+.yarn/build-state.yml
+.yarn/install-state.gz
+.pnp.*
+
+# IntelliJ based IDEs
+.idea
+
+# Finder (MacOS) folder config
+.DS_Store
diff --git a/examples/typescript/pipe-obsidian-time-logs/bun.lockb b/examples/typescript/pipe-obsidian-time-logs/bun.lockb
new file mode 100755
index 000000000..84c949b80
Binary files /dev/null and b/examples/typescript/pipe-obsidian-time-logs/bun.lockb differ
diff --git a/examples/typescript/pipe-obsidian-time-logs/package.json b/examples/typescript/pipe-obsidian-time-logs/package.json
new file mode 100644
index 000000000..1635721da
--- /dev/null
+++ b/examples/typescript/pipe-obsidian-time-logs/package.json
@@ -0,0 +1,18 @@
+{
+ "name": "pipe-obsidian-time-logs",
+ "module": "pipe.ts",
+ "type": "module",
+ "dependencies": {
+ "zod": "^3.23.8",
+ "ai": "^4.0.9",
+ "ollama-ai-provider": "^0.1.0",
+ "@ai-sdk/openai": "^1.0.5",
+ "@screenpipe/js": "^0.1.1"
+ },
+ "devDependencies": {
+ "@types/bun": "latest"
+ },
+ "peerDependencies": {
+ "typescript": "^5.7.2"
+ }
+}
\ No newline at end of file
diff --git a/examples/typescript/pipe-obsidian-time-logs/tsconfig.json b/examples/typescript/pipe-obsidian-time-logs/tsconfig.json
new file mode 100644
index 000000000..238655f2c
--- /dev/null
+++ b/examples/typescript/pipe-obsidian-time-logs/tsconfig.json
@@ -0,0 +1,27 @@
+{
+ "compilerOptions": {
+ // Enable latest features
+ "lib": ["ESNext", "DOM"],
+ "target": "ESNext",
+ "module": "ESNext",
+ "moduleDetection": "force",
+ "jsx": "react-jsx",
+ "allowJs": true,
+
+ // Bundler mode
+ "moduleResolution": "bundler",
+ "allowImportingTsExtensions": true,
+ "verbatimModuleSyntax": true,
+ "noEmit": true,
+
+ // Best practices
+ "strict": true,
+ "skipLibCheck": true,
+ "noFallthroughCasesInSwitch": true,
+
+ // Some stricter flags (disabled by default)
+ "noUnusedLocals": false,
+ "noUnusedParameters": false,
+ "noPropertyAccessFromIndexSignature": false
+ }
+}
diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsx
index 09c952c10..c9e48eba5 100644
--- a/screenpipe-app-tauri/components/pipe-store.tsx
+++ b/screenpipe-app-tauri/components/pipe-store.tsx
@@ -136,14 +136,11 @@ const PipeDialog: React.FC = () => {
}
const dataDir = await getDataDir();
try {
- const response = await fetch("http://localhost:3030/pipes/list");
+ const cmd = Command.sidecar("screenpipe", ["pipe", "list", "-o", "json"]);
+ const output = await cmd.execute();
+ const data = JSON.parse(output.stdout).data;
- if (!response.ok) {
- throw new Error("failed to fetch installed pipes");
- }
- const data = (await response.json()).data;
for (const pipe of data) {
- // read the README.md file from disk and set the fullDescription
const pathToReadme = await join(dataDir, "pipes", pipe.id, "README.md");
try {
const readme = await readFile(pathToReadme);
@@ -155,7 +152,6 @@ const PipeDialog: React.FC = () => {
}
}
setPipes(data);
- // Update selectedPipe if it exists in the new data
if (selectedPipe) {
const updatedSelectedPipe = data.find(
(pipe: Pipe) => pipe.id === selectedPipe.id
@@ -180,23 +176,19 @@ const PipeDialog: React.FC = () => {
title: "downloading pipe",
description: "please wait...",
});
- const response = await fetch(`http://localhost:3030/pipes/download`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ url }),
- });
- if (!response.ok) {
- throw new Error("failed to download pipe");
- }
- const data = await response.json();
+
+ const cmd = Command.sidecar("screenpipe", [
+ "pipe",
+ "download",
+ url,
+ "-o",
+ "json",
+ ]);
+ await cmd.execute();
+
toast({
title: "pipe downloaded",
- // description: data.message,
});
- // Refresh the pipe list
- // await addCustomPipe(url);
await fetchInstalledPipes();
} catch (error) {
console.error("Failed to download pipe:", error);
@@ -214,35 +206,18 @@ const PipeDialog: React.FC = () => {
pipe_id: pipe.id,
enabled: !pipe.enabled,
});
- if (!pipe.enabled) {
- // Enable the pipe through API
- await fetch(`http://localhost:3030/pipes/enable`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ pipe_id: pipe.id }),
- });
- toast({
- title: "enabling pipe",
- description: "this may take a few moments...",
- });
- } else {
- // Disable the pipe through API
- await fetch(`http://localhost:3030/pipes/disable`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ pipe_id: pipe.id }),
- });
+ toast({
+ title: pipe.enabled ? "disabling pipe" : "enabling pipe",
+ description: "this may take a few moments...",
+ });
- toast({
- title: "disabling pipe",
- description: "this may take a few moments...",
- });
- }
+ const cmd = Command.sidecar("screenpipe", [
+ "pipe",
+ pipe.enabled ? "disable" : "enable",
+ pipe.id,
+ ]);
+ await cmd.execute();
await new Promise((resolve) => setTimeout(resolve, 1000));
@@ -252,7 +227,6 @@ const PipeDialog: React.FC = () => {
"screenpipe has been updated with the new configuration. please restart screenpipe now in status badge",
});
- // Update selectedPipe if it's the one being toggled
if (selectedPipe && selectedPipe.id === pipe.id) {
setSelectedPipe((prevPipe) =>
prevPipe ? { ...prevPipe, enabled: !prevPipe.enabled } : null
@@ -280,20 +254,19 @@ const PipeDialog: React.FC = () => {
title: "Adding custom pipe",
description: "Please wait...",
});
- // use /download endpoint to download the pipe
- const response = await fetch(`http://localhost:3030/pipes/download`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ url: newRepoUrl }),
- });
- if (!response.ok) {
- throw new Error("failed to download pipe");
- }
- const data = await response.json();
+
+ const cmd = Command.sidecar("screenpipe", [
+ "pipe",
+ "download",
+ newRepoUrl,
+ "-o",
+ "json",
+ ]);
+ await cmd.execute();
+
// refresh the pipe list
await fetchInstalledPipes();
+
toast({
title: "Custom pipe added",
description:
@@ -336,17 +309,28 @@ const PipeDialog: React.FC = () => {
const handleConfigSave = async (config: Record<string, any>) => {
if (selectedPipe) {
- fetch(`http://localhost:3030/pipes/update`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ pipe_id: selectedPipe.id, config }),
- });
- toast({
- title: "Configuration saved",
- description: "The pipe configuration has been updated.",
- });
+ try {
+ const cmd = Command.sidecar("screenpipe", [
+ "pipe",
+ "update",
+ selectedPipe.id,
+ JSON.stringify(config),
+ ]);
+ await cmd.execute();
+
+ toast({
+ title: "Configuration saved",
+ description: "The pipe configuration has been updated.",
+ });
+ } catch (error) {
+ console.error("Failed to save config:", error);
+ toast({
+ title: "error saving configuration",
+ description:
+ "please try again or check the logs for more information.",
+ variant: "destructive",
+ });
+ }
}
};
@@ -359,16 +343,15 @@ const PipeDialog: React.FC = () => {
title: "deleting pipe",
description: "please wait...",
});
- const response = await fetch(`http://localhost:3030/pipes/delete`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ pipe_id: pipe.id }),
- });
- if (!response.ok) {
- throw new Error("failed to delete pipe");
- }
+
+ const cmd = Command.sidecar("screenpipe", [
+ "pipe",
+ "delete",
+ pipe.id,
+ "-y",
+ ]);
+ await cmd.execute();
+
await fetchInstalledPipes();
setSelectedPipe(null);
toast({
@@ -635,21 +618,44 @@ const PipeDialog: React.FC = () => {
posthog.capture("refresh_pipe_from_disk", {
pipe_id: pipe.id,
});
+
+ // First disable the pipe if it's enabled
+ if (pipe.enabled) {
+ const disableCmd = Command.sidecar("screenpipe", [
+ "pipe",
+ "disable",
+ pipe.id,
+ ]);
+ await disableCmd.execute();
+ }
+
toast({
title: "refreshing pipe",
description: "please wait...",
});
- const response = await fetch(`http://localhost:3030/pipes/download`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- },
- body: JSON.stringify({ url: pipe.source }),
- });
- if (!response.ok) {
- throw new Error("failed to refresh pipe");
+
+ // Download/refresh the pipe
+ const downloadCmd = Command.sidecar("screenpipe", [
+ "pipe",
+ "download",
+ pipe.source,
+ "-o",
+ "json",
+ ]);
+ await downloadCmd.execute();
+
+ // Re-enable the pipe if it was enabled before
+ if (pipe.enabled) {
+ const enableCmd = Command.sidecar("screenpipe", [
+ "pipe",
+ "enable",
+ pipe.id,
+ ]);
+ await enableCmd.execute();
}
+
await fetchInstalledPipes();
+
toast({
title: "pipe refreshed",
description: "the pipe has been successfully refreshed from disk.",
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.lock b/screenpipe-app-tauri/src-tauri/Cargo.lock
index 6775d25a2..1ad18d365 100755
--- a/screenpipe-app-tauri/src-tauri/Cargo.lock
+++ b/screenpipe-app-tauri/src-tauri/Cargo.lock
@@ -4170,7 +4170,7 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "screenpipe-app"
-version = "0.14.6"
+version = "0.14.7"
dependencies = [
"anyhow",
"axum",
diff --git a/screenpipe-app-tauri/src-tauri/Cargo.toml b/screenpipe-app-tauri/src-tauri/Cargo.toml
index e854f4c36..7f84acd1e 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.14.7"
+version = "0.14.8"
description = ""
authors = ["you"]
license = ""