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: notion pipe (#1282)

shaik-zeeshan7a6ea29ff808
diff --git a/pipes/notion/.gitignore b/pipes/notion/.gitignore
new file mode 100644
index 000000000..9dcdc6299
--- /dev/null
+++ b/pipes/notion/.gitignore
@@ -0,0 +1,44 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.*
+.yarn/*
+!.yarn/patches
+!.yarn/plugins
+!.yarn/releases
+!.yarn/versions
+
+# testing
+/coverage
+
+# next.js
+/.next/
+/out/
+
+# production
+/build
+
+# misc
+.DS_Store
+*.pem
+
+# debug
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+.pnpm-debug.log*
+
+# env files (can opt-in for committing if needed)
+.env*
+
+# vercel
+.vercel
+
+# typescript
+*.tsbuildinfo
+next-env.d.ts
+
+# browser context
+.notion-storage
diff --git a/pipes/notion/README.md b/pipes/notion/README.md
new file mode 100644
index 000000000..b9ec9f98d
--- /dev/null
+++ b/pipes/notion/README.md
@@ -0,0 +1,12 @@
+
+turn your screen into a living knowledge base with ai
+
+analyse your screen/mic activity in real time and write logs, to build a CRM, market research, ideas, user personas, etc.
+
+local LLM first
+
+https://github.com/user-attachments/assets/e4c115d9-51cf-4870-aec4-4df4743d2d02
+
+
+
+<img width="1312" alt="Screenshot 2024-12-21 at 4 39 29 PM" src="https://github.com/user-attachments/assets/2e395762-198f-43e6-9e5a-2974b8e71fcf" />
diff --git a/pipes/notion/bun.lockb b/pipes/notion/bun.lockb
new file mode 100755
index 000000000..e4d3e7d8c
Binary files /dev/null and b/pipes/notion/bun.lockb differ
diff --git a/pipes/notion/components.json b/pipes/notion/components.json
new file mode 100644
index 000000000..d710b4962
--- /dev/null
+++ b/pipes/notion/components.json
@@ -0,0 +1,21 @@
+{
+ "$schema": "https://ui.shadcn.com/schema.json",
+ "style": "default",
+ "rsc": true,
+ "tsx": true,
+ "tailwind": {
+ "config": "tailwind.config.ts",
+ "css": "src/app/globals.css",
+ "baseColor": "neutral",
+ "cssVariables": true,
+ "prefix": ""
+ },
+ "aliases": {
+ "components": "@/components",
+ "utils": "@/lib/utils",
+ "ui": "@/components/ui",
+ "lib": "@/lib",
+ "hooks": "@/hooks"
+ },
+ "iconLibrary": "lucide"
+}
\ No newline at end of file
diff --git a/pipes/notion/eslint.config.mjs b/pipes/notion/eslint.config.mjs
new file mode 100644
index 000000000..c85fb67c4
--- /dev/null
+++ b/pipes/notion/eslint.config.mjs
@@ -0,0 +1,16 @@
+import { dirname } from "path";
+import { fileURLToPath } from "url";
+import { FlatCompat } from "@eslint/eslintrc";
+
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = dirname(__filename);
+
+const compat = new FlatCompat({
+ baseDirectory: __dirname,
+});
+
+const eslintConfig = [
+ ...compat.extends("next/core-web-vitals", "next/typescript"),
+];
+
+export default eslintConfig;
diff --git a/pipes/notion/next.config.ts b/pipes/notion/next.config.ts
new file mode 100644
index 000000000..b6d621fe0
--- /dev/null
+++ b/pipes/notion/next.config.ts
@@ -0,0 +1,14 @@
+import type { NextConfig } from "next";
+
+const nextConfig: NextConfig = {
+ transpilePackages: ["@screenpipe/js"],
+ webpack: (config, { }) => {
+ return config;
+ },
+ devIndicators: {
+ buildActivity: false,
+ appIsrStatus: false
+ }
+};
+
+export default nextConfig;
diff --git a/pipes/notion/package.json b/pipes/notion/package.json
new file mode 100644
index 000000000..493f98cde
--- /dev/null
+++ b/pipes/notion/package.json
@@ -0,0 +1,74 @@
+{
+ "name": "notion",
+ "version": "0.1.11",
+ "private": true,
+ "scripts": {
+ "dev": "next dev --turbopack",
+ "build": "next build --no-lint",
+ "start": "next start",
+ "lint": "next lint"
+ },
+ "dependencies": {
+ "@notionhq/client": "^2.2.15",
+ "@radix-ui/react-accordion": "^1.2.2",
+ "@radix-ui/react-checkbox": "^1.1.3",
+ "@radix-ui/react-dialog": "^1.1.4",
+ "@radix-ui/react-dropdown-menu": "^2.1.6",
+ "@radix-ui/react-label": "^2.1.1",
+ "@radix-ui/react-popover": "^1.1.3",
+ "@radix-ui/react-progress": "^1.1.1",
+ "@radix-ui/react-select": "^2.1.3",
+ "@radix-ui/react-separator": "^1.1.1",
+ "@radix-ui/react-slider": "^1.2.2",
+ "@radix-ui/react-slot": "^1.1.1",
+ "@radix-ui/react-switch": "^1.1.2",
+ "@radix-ui/react-tabs": "^1.1.2",
+ "@radix-ui/react-toast": "^1.2.4",
+ "@radix-ui/react-tooltip": "^1.1.5",
+ "@screenpipe/browser": "0.1.26",
+ "@screenpipe/js": "1.0.9",
+ "@shadcn/ui": "^0.0.4",
+ "@tanstack/react-query": "^5.62.7",
+ "@types/js-levenshtein": "^1.1.3",
+ "@types/lodash": "^4.17.13",
+ "@types/react-syntax-highlighter": "^15.5.13",
+ "ai": "^4.0.18",
+ "class-variance-authority": "^0.7.1",
+ "clsx": "^2.1.1",
+ "cmdk": "1.0.4",
+ "framer-motion": "^11.14.4",
+ "install": "^0.13.0",
+ "js-levenshtein": "^1.1.6",
+ "localforage": "^1.10.0",
+ "lodash": "^4.17.21",
+ "lucide-react": "^0.468.0",
+ "magic-ui": "^0.1.0",
+ "next": "15.1.0",
+ "notion-to-md": "^3.1.4",
+ "npm": "^10.9.2",
+ "ollama-ai-provider": "^1.1.0",
+ "openai": "^4.76.3",
+ "playwright": "^1.50.1",
+ "react": "^19.0.0",
+ "react-day-picker": "8.10.1",
+ "react-dom": "^19.0.0",
+ "react-markdown": "^9.0.1",
+ "react-syntax-highlighter": "^15.6.1",
+ "remark-gfm": "^4.0.0",
+ "remark-math": "^6.0.0",
+ "tailwind-merge": "^2.5.5",
+ "tailwindcss-animate": "^1.0.7"
+ },
+ "devDependencies": {
+ "@eslint/eslintrc": "^3",
+ "@types/node": "^22.10.2",
+ "@types/react": "^19",
+ "@types/react-dom": "^19",
+ "autoprefixer": "^10.4.20",
+ "eslint": "^9",
+ "eslint-config-next": "15.1.0",
+ "postcss": "^8.4.49",
+ "tailwindcss": "^3.4.16",
+ "typescript": "^5"
+ }
+}
diff --git a/pipes/notion/pipe.json b/pipes/notion/pipe.json
new file mode 100644
index 000000000..ac68e4dce
--- /dev/null
+++ b/pipes/notion/pipe.json
@@ -0,0 +1,12 @@
+{
+ "crons": [
+ {
+ "path": "/api/log",
+ "schedule": "0 */5 * * * *"
+ },
+ {
+ "path": "/api/intelligence",
+ "schedule": "0 0 */1 * * *"
+ }
+ ]
+}
diff --git a/pipes/notion/postcss.config.mjs b/pipes/notion/postcss.config.mjs
new file mode 100644
index 000000000..1a69fd2a4
--- /dev/null
+++ b/pipes/notion/postcss.config.mjs
@@ -0,0 +1,8 @@
+/** @type {import('postcss-load-config').Config} */
+const config = {
+ plugins: {
+ tailwindcss: {},
+ },
+};
+
+export default config;
diff --git a/pipes/notion/public/file.svg b/pipes/notion/public/file.svg
new file mode 100644
index 000000000..004145cdd
--- /dev/null
+++ b/pipes/notion/public/file.svg
@@ -0,0 +1 @@
+<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
\ No newline at end of file
diff --git a/pipes/notion/public/globe.svg b/pipes/notion/public/globe.svg
new file mode 100644
index 000000000..567f17b0d
--- /dev/null
+++ b/pipes/notion/public/globe.svg
@@ -0,0 +1 @@
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
\ No newline at end of file
diff --git a/pipes/notion/public/next.svg b/pipes/notion/public/next.svg
new file mode 100644
index 000000000..5174b28c5
--- /dev/null
+++ b/pipes/notion/public/next.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.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.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
\ No newline at end of file
diff --git a/pipes/notion/public/vercel.svg b/pipes/notion/public/vercel.svg
new file mode 100644
index 000000000..770539603
--- /dev/null
+++ b/pipes/notion/public/vercel.svg
@@ -0,0 +1 @@
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
\ No newline at end of file
diff --git a/pipes/notion/public/window.svg b/pipes/notion/public/window.svg
new file mode 100644
index 000000000..b2b2a44f6
--- /dev/null
+++ b/pipes/notion/public/window.svg
@@ -0,0 +1 @@
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
\ No newline at end of file
diff --git a/pipes/notion/src/app/api/intelligence/route.ts b/pipes/notion/src/app/api/intelligence/route.ts
new file mode 100644
index 000000000..b7f328dfc
--- /dev/null
+++ b/pipes/notion/src/app/api/intelligence/route.ts
@@ -0,0 +1,183 @@
+import { NextResponse } from "next/server";
+import { z } from "zod";
+import { generateObject } from "ai";
+import { ollama } from "ollama-ai-provider";
+import { Client } from "@notionhq/client";
+import { NotionClient } from "@/lib/notion/client";
+import { getNotionSettings } from "@/lib/actions/namespace-settings";
+
+// rich schema for relationship intelligence
+const contactSchema = z.object({
+ name: z.string(),
+ company: z.string().optional(),
+ lastInteraction: z.string(),
+ sentiment: z.number(), // -1 to 1
+ topics: z.array(z.string()),
+ nextSteps: z.array(z.string()),
+});
+
+const relationshipIntelligence = z.object({
+ contacts: z.array(contactSchema),
+ insights: z.object({
+ followUps: z.array(z.string()),
+ opportunities: z.array(z.string()),
+ }),
+});
+
+async function analyzeRelationships(
+ recentLogs: string,
+ model: string,
+): Promise<z.infer<typeof relationshipIntelligence>> {
+ const prompt = `analyze these work logs and create a comprehensive relationship intelligence report.
+ focus on:
+ - identifying key people and their roles
+ - tracking interaction patterns and sentiment
+ - spotting business opportunities
+ - suggesting follow-ups and introductions
+ - finding patterns in topics discussed
+
+ recent logs: ${recentLogs}
+
+ todays date: ${new Date().toISOString().split("T")[0]}
+ local time: ${new Date().toLocaleTimeString()}
+ timezone: ${Intl.DateTimeFormat().resolvedOptions().timeZone}
+
+ return a detailed json object following this structure for relationship intelligence.
+
+ example response from you:
+
+ {
+ "contacts": [
+ {
+ "name": "John Doe",
+ "company": "Acme Inc.",
+ "lastInteraction": "2024-01-01",
+ "sentiment": 0.8,
+ "topics": ["sales", "marketing"],
+ "nextSteps": ["schedule a call", "send a follow-up email"]
+ }
+ ],
+ "insights": {
+ "followUps": ["schedule a call", "send a follow-up email"],
+ "opportunities": ["schedule a call", "send a follow-up email"]
+ }
+ }
+
+ of course adapt the example response to the actual data you have, do not use John Doe in your example response, use the names and companies of the people you see in the logs.
+ `;
+
+ const provider = ollama(model);
+ console.log("prompt", prompt);
+ const response = await generateObject({
+ model: provider,
+ messages: [{ role: "user", content: prompt }],
+ schema: relationshipIntelligence,
+ maxRetries: 5,
+ });
+
+ console.log(response.object);
+ return response.object;
+}
+
+async function readRecentLogs(
+ client: Client,
+ databaseId: string,
+ since: Date,
+): Promise<string> {
+ try {
+ const response = await client.databases.query({
+ database_id: databaseId,
+ filter: {
+ and: [
+ {
+ property: "Date",
+ date: {
+ on_or_after: since.toISOString().split("T")[0],
+ },
+ },
+ ],
+ },
+ sorts: [
+ {
+ property: "Date",
+ direction: "ascending",
+ },
+ ],
+ });
+
+ return response.results
+ .map((page: any) => {
+ const title = page.properties.Title?.title[0]?.text?.content || "";
+ const description =
+ page.properties.Description?.rich_text[0]?.text?.content || "";
+ return `${title}\n${description}`;
+ })
+ .join("\n\n");
+ } catch (error) {
+ console.error("Failed to read logs:", error);
+ return "";
+ }
+}
+
+export async function GET() {
+ try {
+ const settings = await getNotionSettings();
+
+ if (
+ !settings?.notion?.accessToken ||
+ !settings?.notion?.databaseId ||
+ !settings?.notion?.intelligenceDbId
+ ) {
+ return NextResponse.json(
+ { error: "notion not configured" },
+ { status: 400 },
+ );
+ }
+
+ const client = new Client({ auth: settings.notion.accessToken });
+
+ // Get last 24 hours of logs
+ const today = new Date();
+ const yesterday = new Date(today.getTime() - 24 * 60 * 60 * 1000);
+
+ const recentLogs = await readRecentLogs(
+ client,
+ settings.notion.databaseId,
+ yesterday,
+ );
+
+ if (!recentLogs) {
+ return NextResponse.json(
+ { message: "no logs found for analysis" },
+ { status: 404 },
+ );
+ }
+
+ const intelligence = await analyzeRelationships(
+ recentLogs,
+ settings.aiModel || "mistral",
+ );
+
+ const notion = new NotionClient(settings.notion);
+
+ const deepLink = await notion.createIntelligence(intelligence);
+
+ return NextResponse.json({
+ message: "relationship intelligence updated",
+ intelligence,
+ deepLink,
+ summary: {
+ contacts: intelligence.contacts.length,
+ opportunities: intelligence.insights.opportunities.length,
+ needsFollowUp: intelligence.insights.followUps.length,
+ logsAnalyzed: recentLogs.length,
+ },
+ });
+ } catch (error) {
+ console.error("error in intelligence api:", error);
+ return NextResponse.json(
+ { error: `failed to process intelligence: ${error}` },
+ { status: 500 },
+ );
+ }
+}
diff --git a/pipes/notion/src/app/api/log/route.ts b/pipes/notion/src/app/api/log/route.ts
new file mode 100644
index 000000000..71f8ee2b2
--- /dev/null
+++ b/pipes/notion/src/app/api/log/route.ts
@@ -0,0 +1,75 @@
+import { NextResponse } from "next/server";
+import { pipe } from "@screenpipe/js";
+import { generateWorkLog } from "@/lib/helpers";
+import { NotionClient } from "@/lib/notion/client";
+import { getNotionSettings } from "@/lib/actions/namespace-settings";
+
+const minute = (min: number) => min * 60 * 1000;
+
+export async function GET() {
+ try {
+ const settings = await getNotionSettings();
+
+ const model = settings?.aiModel;
+ const pageSize = settings?.pageSize || 50;
+ const customPrompt = settings?.prompt;
+ const interval = settings?.interval ? minute(settings.interval) : 3600000;
+
+ if (!model) {
+ return NextResponse.json(
+ { error: "model not selected" },
+ { status: 401 },
+ );
+ }
+
+ if (!settings?.notion?.accessToken || !settings?.notion?.databaseId) {
+ return NextResponse.json(
+ { error: "notion not configured" },
+ { status: 400 },
+ );
+ }
+
+ const now = new Date();
+ const oneHourAgo = new Date(now.getTime() - interval);
+
+ const screenData = await pipe.queryScreenpipe({
+ startTime: oneHourAgo.toISOString(),
+ endTime: now.toISOString(),
+ limit: pageSize,
+ contentType: "all",
+ });
+
+ console.log(screenData);
+ if (!screenData || screenData.data.length === 0) {
+ return NextResponse.json(
+ { message: "no screen data found" },
+ { status: 404 },
+ );
+ }
+
+ const logEntry = await generateWorkLog(
+ screenData.data,
+ model,
+ oneHourAgo,
+ now,
+ customPrompt,
+ );
+
+ console.log(logEntry);
+
+ const notionClient = new NotionClient(settings.notion);
+ const deepLink = await notionClient.createLog(logEntry);
+
+ return NextResponse.json({
+ message: "work log synced successfully",
+ logEntry,
+ deepLink: deepLink,
+ });
+ } catch (error) {
+ console.error("error in work log api:", error);
+ return NextResponse.json(
+ { error: `failed to process work log: ${error}` },
+ { status: 500 },
+ );
+ }
+}
diff --git a/pipes/notion/src/app/api/notion/pages/route.ts b/pipes/notion/src/app/api/notion/pages/route.ts
new file mode 100644
index 000000000..d47ba4138
--- /dev/null
+++ b/pipes/notion/src/app/api/notion/pages/route.ts
@@ -0,0 +1,57 @@
+import { NextResponse } from "next/server";
+import { Client } from "@notionhq/client";
+import { getNotionSettings } from "@/lib/actions/namespace-settings";
+
+export async function GET(request: Request) {
+ try {
+ const { searchParams } = new URL(request.url);
+ const query = searchParams.get("q");
+
+ const settings = await getNotionSettings();
+
+ if (!settings?.notion?.accessToken) {
+ return NextResponse.json(
+ { error: "notion not configured" },
+ { status: 400 },
+ );
+ }
+
+ const client = new Client({ auth: settings.notion.accessToken });
+
+ const response = await client.search({
+ filter: {
+ property: "object",
+ value: "page",
+ },
+ sort: {
+ direction: "descending",
+ timestamp: "last_edited_time",
+ },
+ ...(query && { query }),
+ });
+
+ const pages = response.results.map((page: any) => ({
+ id: page.id,
+ title: page.properties?.title?.title?.[0]?.plain_text || "Untitled",
+ lastEdited: page.last_edited_time,
+ url: page.url,
+ icon: page.icon,
+ parent: {
+ type: page.parent.type,
+ id: page.parent.database_id || page.parent.page_id,
+ },
+ }));
+
+ return NextResponse.json({
+ pages,
+ next_cursor: response.next_cursor,
+ has_more: response.has_more,
+ });
+ } catch (error) {
+ console.error("error fetching pages:", error);
+ return NextResponse.json(
+ { error: "Failed to fetch pages" },
+ { status: 500 },
+ );
+ }
+}
diff --git a/pipes/notion/src/app/api/settings/route.ts b/pipes/notion/src/app/api/settings/route.ts
new file mode 100644
index 000000000..287fba333
--- /dev/null
+++ b/pipes/notion/src/app/api/settings/route.ts
@@ -0,0 +1,109 @@
+import { pipe } from "@screenpipe/js";
+import { NextResponse } from "next/server";
+import { promises as fs } from "fs";
+import path from "path";
+
+export const runtime = "nodejs";
+export const dynamic = "force-dynamic";
+
+export async function GET() {
+ try {
+ const settingsManager = pipe.settings;
+ if (!settingsManager) {
+ throw new Error("settingsManager not found");
+ }
+
+ // Load persisted settings if they exist
+ const screenpipeDir = process.env.SCREENPIPE_DIR || process.cwd();
+ const settingsPath = path.join(
+ screenpipeDir,
+ "pipes",
+ "notion",
+ "pipe.json",
+ );
+
+ try {
+ const settingsContent = await fs.readFile(settingsPath, "utf8");
+ const persistedSettings = JSON.parse(settingsContent);
+
+ // Merge with current settings
+ const rawSettings = await settingsManager.getAll();
+ return NextResponse.json({
+ ...rawSettings,
+ customSettings: {
+ ...rawSettings.customSettings,
+ ["notion"]: {
+ ...(rawSettings.customSettings?.["notion"] || {}),
+ ...persistedSettings,
+ },
+ },
+ });
+ } catch (err) {
+ // If no persisted settings, return normal settings
+ const rawSettings = await settingsManager.getAll();
+ return NextResponse.json(rawSettings);
+ }
+ } catch (error) {
+ console.error("failed to get settings:", error);
+ return NextResponse.json(
+ { error: "failed to get settings" },
+ { status: 500 },
+ );
+ }
+}
+
+export async function PUT(request: Request) {
+ try {
+ const settingsManager = pipe.settings;
+ if (!settingsManager) {
+ throw new Error("settingsManager not found");
+ }
+
+ const body = await request.json();
+ const { key, value, isPartialUpdate, reset, namespace } = body;
+
+ if (reset) {
+ if (namespace) {
+ if (key) {
+ await settingsManager.setCustomSetting(namespace, key, undefined);
+ } else {
+ await settingsManager.updateNamespaceSettings(namespace, {});
+ }
+ } else {
+ if (key) {
+ await settingsManager.resetKey(key);
+ } else {
+ await settingsManager.reset();
+ }
+ }
+ return NextResponse.json({ success: true });
+ }
+
+ if (namespace) {
+ if (isPartialUpdate) {
+ const currentSettings =
+ (await settingsManager.getNamespaceSettings(namespace)) || {};
+ await settingsManager.updateNamespaceSettings(namespace, {
+ ...currentSettings,
+ ...value,
+ });
+ } else {
+ await settingsManager.setCustomSetting(namespace, key, value);
+ }
+ } else if (isPartialUpdate) {
+ const serializedSettings = JSON.parse(JSON.stringify(value));
+ await settingsManager.update(serializedSettings);
+ } else {
+ const serializedValue = JSON.parse(JSON.stringify(value));
+ await settingsManager.set(key, serializedValue);
+ }
+
+ return NextResponse.json({ success: true });
+ } catch (error) {
+ console.error("failed to update settings:", error);
+ return NextResponse.json(
+ { error: "failed to update settings" },
+ { status: 500 },
+ );
+ }
+}
diff --git a/pipes/notion/src/app/api/setup/route.ts b/pipes/notion/src/app/api/setup/route.ts
new file mode 100644
index 000000000..54181e732
--- /dev/null
+++ b/pipes/notion/src/app/api/setup/route.ts
@@ -0,0 +1,18 @@
+import { NextResponse } from "next/server";
+import { automateNotionSetup } from "@/lib/notion/setup";
+import { Settings } from "@/lib/types";
+import { getNotionSettings } from "@/lib/actions/namespace-settings";
+
+export async function GET() {
+ try {
+ const settings = (await getNotionSettings()) as Settings;
+ const credentials = await automateNotionSetup(settings.workspace);
+ return NextResponse.json(credentials);
+ } catch (error) {
+ console.log(error);
+ return NextResponse.json(
+ { error: "Failed to setup Notion" },
+ { status: 500 },
+ );
+ }
+}
diff --git a/pipes/notion/src/app/favicon.ico b/pipes/notion/src/app/favicon.ico
new file mode 100644
index 000000000..5be4ba27a
Binary files /dev/null and b/pipes/notion/src/app/favicon.ico differ
diff --git a/pipes/notion/src/app/globals.css b/pipes/notion/src/app/globals.css
new file mode 100644
index 000000000..ff005b73a
--- /dev/null
+++ b/pipes/notion/src/app/globals.css
@@ -0,0 +1,72 @@
+@tailwind base;
+@tailwind components;
+@tailwind utilities;
+
+body {
+ font-family: Arial, Helvetica, sans-serif;
+}
+
+@layer base {
+ :root {
+ --background: 0 0% 100%;
+ --foreground: 0 0% 3.9%;
+ --card: 0 0% 100%;
+ --card-foreground: 0 0% 3.9%;
+ --popover: 0 0% 100%;
+ --popover-foreground: 0 0% 3.9%;
+ --primary: 0 0% 9%;
+ --primary-foreground: 0 0% 98%;
+ --secondary: 0 0% 96.1%;
+ --secondary-foreground: 0 0% 9%;
+ --muted: 0 0% 96.1%;
+ --muted-foreground: 0 0% 45.1%;
+ --accent: 0 0% 96.1%;
+ --accent-foreground: 0 0% 9%;
+ --destructive: 0 84.2% 60.2%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 0 0% 89.8%;
+ --input: 0 0% 89.8%;
+ --ring: 0 0% 3.9%;
+ --chart-1: 12 76% 61%;
+ --chart-2: 173 58% 39%;
+ --chart-3: 197 37% 24%;
+ --chart-4: 43 74% 66%;
+ --chart-5: 27 87% 67%;
+ --radius: 0.5rem;
+ }
+ .dark {
+ --background: 0 0% 3.9%;
+ --foreground: 0 0% 98%;
+ --card: 0 0% 3.9%;
+ --card-foreground: 0 0% 98%;
+ --popover: 0 0% 3.9%;
+ --popover-foreground: 0 0% 98%;
+ --primary: 0 0% 98%;
+ --primary-foreground: 0 0% 9%;
+ --secondary: 0 0% 14.9%;
+ --secondary-foreground: 0 0% 98%;
+ --muted: 0 0% 14.9%;
+ --muted-foreground: 0 0% 63.9%;
+ --accent: 0 0% 14.9%;
+ --accent-foreground: 0 0% 98%;
+ --destructive: 0 62.8% 30.6%;
+ --destructive-foreground: 0 0% 98%;
+ --border: 0 0% 14.9%;
+ --input: 0 0% 14.9%;
+ --ring: 0 0% 83.1%;
+ --chart-1: 220 70% 50%;
+ --chart-2: 160 60% 45%;
+ --chart-3: 30 80% 55%;
+ --chart-4: 280 65% 60%;
+ --chart-5: 340 75% 55%;
+ }
+}
+
+@layer base {
+ * {
+ @apply border-border;
+ }
+ body {
+ @apply bg-background text-foreground !pointer-events-auto;
+ }
+}
diff --git a/pipes/notion/src/app/layout.tsx b/pipes/notion/src/app/layout.tsx
new file mode 100644
index 000000000..a5087c4ce
--- /dev/null
+++ b/pipes/notion/src/app/layout.tsx
@@ -0,0 +1,36 @@
+import type { Metadata } from "next";
+import { Geist, Geist_Mono } from "next/font/google";
+import "./globals.css";
+import { Toaster } from "@/components/ui/toaster";
+
+const geistSans = Geist({
+ variable: "--font-sans",
+ subsets: ["latin"],
+});
+
+const geistMono = Geist_Mono({
+ variable: "--font-mono",
+ subsets: ["latin"],
+});
+
+export const metadata: Metadata = {
+ title: "Notion • Screenpipe",
+ description: "Turn your screen time into a living knowledge base with AI",
+};
+
+export default function RootLayout({
+ children,
+}: Readonly<{
+ children: React.ReactNode;
+}>) {
+ return (
+ <html lang="en">
+ <body
+ className={`${geistSans.variable} ${geistMono.variable} antialiased`}
+ >
+ {children}
+ <Toaster />
+ </body>
+ </html>
+ );
+}
diff --git a/pipes/notion/src/app/page.tsx b/pipes/notion/src/app/page.tsx
new file mode 100644
index 000000000..d0b654947
--- /dev/null
+++ b/pipes/notion/src/app/page.tsx
@@ -0,0 +1,10 @@
+import { NotionSettings } from "@/components/notion-settings";
+
+export default function Page() {
+ return (
+ <div className="flex flex-col gap-4 items-center justify-center h-full mt-12">
+ <p className="text-xl font-bold">Your knowledge base on autopilot</p>
+ <NotionSettings />
+ </div>
+ );
+}
diff --git a/pipes/notion/src/components/file-suggest-textarea.tsx b/pipes/notion/src/components/file-suggest-textarea.tsx
new file mode 100644
index 000000000..ec0074956
--- /dev/null
+++ b/pipes/notion/src/components/file-suggest-textarea.tsx
@@ -0,0 +1,226 @@
+"use client";
+
+import { useState, useRef, useCallback, useEffect } from "react";
+import { Command } from "cmdk";
+import React from "react";
+
+interface FileSuggestTextareaProps {
+ value: string;
+ setValue: (value: string) => void;
+ className?: string;
+ placeholder?: string;
+ disabled?: boolean;
+}
+
+function highlightMatch(text: string, search: string) {
+ if (!search) return text;
+ const index = text.toLowerCase().indexOf(search.toLowerCase());
+ if (index === -1) return text;
+
+ return (
+ <>
+ {text.slice(0, index)}
+ <span className="bg-yellow-200 dark:bg-yellow-800">
+ {text.slice(index, index + search.length)}
+ </span>
+ {text.slice(index + search.length)}
+ </>
+ );
+}
+
+interface NotionPage {
+ id: number;
+ title: string;
+}
+
+export function FileSuggestTextarea({
+ value,
+ setValue,
+ className = "",
+ placeholder,
+ disabled = false,
+}: FileSuggestTextareaProps) {
+ const [showSuggestions, setShowSuggestions] = useState(false);
+ const [searchTerm, setSearchTerm] = useState("");
+ const [cursorCoords, setCursorCoords] = useState({ x: 0, y: 0 });
+ const [files, setFiles] = useState<NotionPage[]>([]);
+ const textareaRef = useRef<HTMLTextAreaElement>(null);
+ const searchTimeout = useRef<NodeJS.Timeout | undefined>(undefined);
+ const cursorPosRef = useRef<number | null>(null);
+
+ // Optimized debounce with cleanup
+ const debouncedFetch = useCallback((search: string) => {
+ if (searchTimeout.current) {
+ clearTimeout(searchTimeout.current);
+ }
+
+ if (search.length < 2) {
+ setFiles([]);
+ return;
+ }
+
+ searchTimeout.current = setTimeout(async () => {
+ try {
+ const res = await fetch(
+ `/api/notion/pages?q=${encodeURIComponent(search)}`,
+ );
+ const data = await res.json();
+ setFiles(data.pages ?? []);
+ } catch (err) {
+ console.error("failed to fetch files:", err);
+ setFiles([]);
+ }
+ }, 150); // Reduced debounce time
+ }, []);
+
+ const getCursorCoordinates = () => {
+ const textarea = textareaRef.current;
+ if (!textarea) return;
+
+ const { selectionStart, value } = textarea;
+ const textBeforeCursor = value.slice(0, selectionStart);
+
+ const div = document.createElement("div");
+ div.style.position = "absolute";
+ div.style.visibility = "hidden";
+ div.style.whiteSpace = "pre-wrap";
+ div.style.wordWrap = "break-word";
+ div.style.width = getComputedStyle(textarea).width;
+ div.style.font = getComputedStyle(textarea).font;
+ div.style.padding = getComputedStyle(textarea).padding;
+ div.style.border = getComputedStyle(textarea).border;
+
+ div.innerHTML = textBeforeCursor.replace(/\n/g, "<br>");
+ document.body.appendChild(div);
+
+ const rect = textarea.getBoundingClientRect();
+ const divRect = div.getBoundingClientRect();
+ const scrollTop = textarea.scrollTop;
+
+ document.body.removeChild(div);
+
+ return {
+ x: rect.left + (divRect.width % rect.width),
+ y: rect.top + divRect.height - scrollTop,
+ };
+ };
+
+ const handleTextareaChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
+ if (disabled) return;
+ const newValue = e.target.value;
+ const cursorPos = e.target.selectionStart;
+
+ // Update value first
+ setValue(newValue);
+
+ const textBeforeCursor = newValue.slice(0, cursorPos);
+ const match = textBeforeCursor.match(/@([^@\n\[\](){}<>]*?)$/);
+
+ if (match) {
+ const newSearchTerm = match[1].trim();
+ setSearchTerm(newSearchTerm);
+ setShowSuggestions(true);
+ const coords = getCursorCoordinates();
+ if (coords) {
+ setCursorCoords(coords);
+ }
+ debouncedFetch(newSearchTerm);
+ } else {
+ setShowSuggestions(false);
+ setFiles([]);
+ }
+ };
+
+ const handleSuggestionSelect = (file: NotionPage) => {
+ if (!textareaRef.current) return;
+
+ const cursorPos = textareaRef.current.selectionStart;
+ const textBeforeCursor = value.slice(0, cursorPos);
+ const textAfterCursor = value.slice(cursorPos);
+ const lastAtPos = textBeforeCursor.lastIndexOf("@");
+
+ const insertText = `@[[${file.id}]] `;
+ const newValue =
+ textBeforeCursor.slice(0, lastAtPos) + insertText + textAfterCursor;
+
+ // Calculate new cursor position after the inserted text
+ const newCursorPos = lastAtPos + insertText.length;
+ cursorPosRef.current = newCursorPos;
+
+ setValue(newValue);
+ setShowSuggestions(false);
+
+ // Ensure focus remains on textarea
+ setTimeout(() => {
+ if (textareaRef.current) {
+ textareaRef.current.focus();
+ textareaRef.current.selectionStart = newCursorPos;
+ textareaRef.current.selectionEnd = newCursorPos;
+ }
+ }, 0);
+ };
+
+ // Cleanup on unmount
+ useEffect(() => {
+ return () => {
+ if (searchTimeout.current) {
+ clearTimeout(searchTimeout.current);
+ }
+ };
+ }, []);
+
+ // Remove the cursor position effect as it's causing the double typing
+ useEffect(() => {
+ if (textareaRef.current) {
+ textareaRef.current.focus();
+ }
+ }, [value]);
+
+ return (
+ <div className="relative">
+ <textarea
+ ref={textareaRef}
+ value={value}
+ onChange={handleTextareaChange}
+ className={`w-full min-h-[100px] p-2 rounded-md border bg-background ${disabled ? "opacity-50 cursor-not-allowed" : ""
+ } ${className}`}
+ placeholder={placeholder}
+ rows={10}
+ disabled={disabled}
+ />
+
+ {showSuggestions && !disabled && (
+ <div
+ className="fixed z-50 w-[400px] max-h-48 overflow-y-auto bg-background border rounded-md shadow-lg"
+ style={{
+ top: `${cursorCoords.y + 5}px`,
+ left: `${cursorCoords.x}px`,
+ }}
+ >
+ <Command>
+ <Command.List>
+ {files.map((file) => {
+ return (
+ <Command.Item
+ key={file.id}
+ onSelect={() => handleSuggestionSelect(file)}
+ className="px-2 py-1 hover:bg-accent cursor-pointer flex flex-col gap-0.5"
+ >
+ <span className="text-sm text-blue-500 font-medium">
+ {highlightMatch(file.title, searchTerm)}
+ </span>
+ </Command.Item>
+ );
+ })}
+ {files.length === 0 && (
+ <div className="px-2 py-1 text-muted-foreground">
+ no matching files
+ </div>
+ )}
+ </Command.List>
+ </Command>
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/pipes/notion/src/components/notion-settings.tsx b/pipes/notion/src/components/notion-settings.tsx
new file mode 100644
index 000000000..093ca7b88
--- /dev/null
+++ b/pipes/notion/src/components/notion-settings.tsx
@@ -0,0 +1,468 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { Button } from "@/components/ui/button";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card";
+import { OllamaModelsList } from "./ollama-models-list";
+import { validateCredentials } from "@/lib/notion/notion";
+import { toast } from "@/hooks/use-toast";
+import { useNotionSettings } from "@/lib/hooks/use-notion-settings";
+import { ChevronDown, Loader2 } from "lucide-react";
+import { NotionCredentials, Settings } from "@/lib/types";
+import { updatePipeConfig } from "@/lib/actions/update-pipe-config";
+import { FileSuggestTextarea } from "./file-suggest-textarea";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "./ui/tooltip";
+import { NotionIdInput } from "./notion-url-to-input";
+import { INTEGRATION_NAME } from "@/lib/utils";
+
+export function NotionSettings() {
+ const { settings, updateSettings, loading } = useNotionSettings();
+ const [isSettingUp, setIsSettingUp] = useState(false);
+ const [credentials, setCredentials] = useState<NotionCredentials>({
+ accessToken: "",
+ databaseId: "",
+ intelligenceDbId: "",
+ });
+ const [testingLog, setTestingLog] = useState(false);
+ const [testingIntelligence, setTestingIntelligence] = useState(false);
+ const [localSettings, setLocalSettings] = useState<Partial<Settings> | null>(
+ {},
+ );
+
+ useEffect(() => {
+ setCredentials({
+ accessToken: settings?.notion?.accessToken || "",
+ databaseId: settings?.notion?.databaseId || "",
+ intelligenceDbId: settings?.notion?.intelligenceDbId || "",
+ });
+
+ setLocalSettings({
+ ...settings,
+ });
+ }, [settings]);
+
+ const handleValidate = async () => {
+ setIsSettingUp(true);
+ try {
+ const isValid = await validateCredentials(credentials);
+ if (!isValid) {
+ throw new Error("Invalid credentials");
+ }
+
+ await updateSettings({
+ ...settings!,
+ notion: credentials,
+ });
+
+ toast({
+ title: "Success",
+ description: "Notion connected successfully",
+ });
+ } catch (_error) {
+ toast({
+ title: "Error",
+ description:
+ "Failed to connect to Notion, make sure your integration have to databases",
+ variant: "destructive",
+ });
+ } finally {
+ setIsSettingUp(false);
+ }
+ };
+
+ const handleSetup = async () => {
+ setIsSettingUp(true);
+ try {
+ const response = await fetch("/api/setup");
+ const credentials = await response.json();
+
+ if (!response.ok) throw new Error(credentials.error);
+
+ const notionCreds = {
+ accessToken: credentials.accessToken,
+ databaseId: credentials.databaseId,
+ intelligenceDbId: credentials.intelligenceDbId,
+ };
+
+ const isValid = await validateCredentials(notionCreds);
+ if (!isValid) {
+ throw new Error("Invalid credentials");
+ }
+
+ console.log(isValid, "done");
+
+ await updateSettings({
+ ...settings!,
+ notion: notionCreds,
+ });
+
+ toast({
+ title: "Success",
+ description: "Notion connected successfully",
+ });
+ } catch (_error) {
+ toast({
+ title: "Error",
+ description: "Failed to connect to Notion",
+ variant: "destructive",
+ });
+ } finally {
+ setIsSettingUp(false);
+ }
+ };
+
+ const handleTestLog = async () => {
+ setTestingLog(true);
+ try {
+ const response = await fetch("/api/log");
+
+ const data = await response.json();
+
+ console.log(data);
+ if (!response.ok) throw new Error(data.message);
+
+ toast({
+ title: "Success",
+ description: `Log created successfully. View at: ${data.deepLink}`,
+ });
+ } catch (error) {
+ toast({
+ title: "Error",
+ description:
+ error instanceof Error ? error.message : "Failed to create log",
+ variant: "destructive",
+ });
+ } finally {
+ setTestingLog(false);
+ }
+ };
+
+ const handleTestIntelligence = async () => {
+ setTestingIntelligence(true);
+ try {
+ const response = await fetch("/api/intelligence");
+ const data = await response.json();
+
+ if (!response.ok) throw new Error(data.error);
+
+ toast({
+ title: "Success",
+ description: `Intelligence generated with ${data.summary.contacts} contacts`,
+ });
+ } catch (error) {
+ toast({
+ title: "Error",
+ description:
+ error instanceof Error
+ ? error.message
+ : "Failed to generate intelligence",
+ variant: "destructive",
+ });
+ } finally {
+ setTestingIntelligence(false);
+ }
+ };
+
+ const handleSaveSettings = async () => {
+ try {
+ await updateSettings({
+ ...settings!,
+ aiModel: localSettings?.aiModel || settings?.aiModel,
+ prompt: localSettings?.prompt || settings?.prompt,
+ interval: localSettings?.interval || settings?.interval,
+ pageSize: localSettings?.pageSize || settings?.pageSize,
+ });
+
+ if (localSettings?.interval !== settings?.interval) {
+ await updatePipeConfig(localSettings?.interval || 5);
+ }
+
+ toast({
+ title: "Success",
+ description: "Settings saved successfully",
+ });
+ } catch (error) {
+ toast({
+ title: "Error",
+ description: "Failed to save settings",
+ variant: "destructive",
+ });
+ }
+ };
+
+ return (
+ <Card className="w-full max-w-4xl ">
+ <CardHeader>
+ <CardTitle>Notion Settings</CardTitle>
+ <CardDescription>
+ please have chrome install for connecting with notion automatically{" "}
+ <br />
+ otherwise you can set it up manually, then click on manual button in
+ Connect Notion Dropdown menu if you have setup automatically then the
+ integration will be {INTEGRATION_NAME}
+ </CardDescription>
+ </CardHeader>
+ <CardContent>
+ <div className="space-y-6">
+ <div className="space-y-4">
+ <div>
+ <Label>AI Model</Label>
+ <OllamaModelsList
+ defaultValue={settings?.aiModel || ""}
+ onChange={(model) => {
+ setLocalSettings({ ...localSettings!, aiModel: model });
+ }}
+ disabled={loading}
+ />
+ </div>
+
+ <div className="space-y-2">
+ <Label>Custom Prompt</Label>
+ <FileSuggestTextarea
+ value={localSettings?.prompt || settings?.prompt || ""}
+ setValue={(value) => {
+ setLocalSettings({ ...localSettings!, prompt: value });
+ }}
+ disabled={loading}
+ />
+ <p className="text-xs text-muted-foreground">
+ make sure to keep the prompt within llm context window size.
+ <br />
+ protip: use the @mention feature to link to other pages in your
+ notion as context.(make sure the page is shared with
+ integration)
+ <br />
+ if you have connected with notion automatically, then your
+ integration name will{" "}
+ <span className="text-red-400">{INTEGRATION_NAME}</span>
+ </p>
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="interval">sync interval (minutes)</Label>
+ <Input
+ id="interval"
+ name="interval"
+ type="number"
+ min="1"
+ step="1"
+ max="60"
+ defaultValue={settings?.interval ? settings?.interval : 5}
+ onChange={(e) => {
+ setLocalSettings({
+ ...localSettings!,
+ interval: parseInt(e.target.value),
+ });
+ }}
+ />
+ </div>
+ <div className="space-y-2">
+ <Label>Workspace Name</Label>
+ <Input
+ type="text"
+ placeholder="Required"
+ value={settings?.workspace || ""}
+ onChange={(e) =>
+ updateSettings({ ...settings!, workspace: e.target.value })
+ }
+ />
+ <p className="text-xs text-muted-foreground">
+ this is required when you are connecting automatically
+ </p>
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="pageSize">Page size</Label>
+ <Input
+ id="pageSize"
+ name="pageSize"
+ type="number"
+ defaultValue={settings?.pageSize || 50}
+ onChange={(e) =>
+ setLocalSettings({
+ ...localSettings!,
+ pageSize: parseInt(e.target.value),
+ })
+ }
+ />
+ </div>
+
+ <div className="space-y-2">
+ <Label>
+ Access Token{" "}
+ <span className="text-xs text-muted-foreground">
+ (found in your integration page)
+ </span>
+ </Label>
+ <Input
+ placeholder="Access Token"
+ value={credentials.accessToken}
+ onChange={(e) =>
+ setCredentials((prev) => ({
+ ...prev,
+ accessToken: e.target.value,
+ }))
+ }
+ />
+ <p className="text-xs text-muted-foreground">
+ you can create integration{" "}
+ <a
+ href="https://www.notion.so/my-integrations"
+ target="_blank"
+ className="text-blue-400 underline"
+ >
+ {" "}
+ here
+ </a>{" "}
+ if you want to do it manually
+ </p>
+ </div>
+ <div className="space-y-2">
+ <NotionIdInput
+ label="Database ID"
+ value={credentials.databaseId}
+ onChange={(value) =>
+ setCredentials((prev) => ({ ...prev, databaseId: value }))
+ }
+ dialogTitle="Extract Database ID from URL"
+ />
+ </div>
+ <div className="space-y-2">
+ <NotionIdInput
+ label="Intelligence ID"
+ value={credentials.intelligenceDbId}
+ onChange={(value) =>
+ setCredentials((prev) => ({
+ ...prev,
+ intelligenceDbId: value,
+ }))
+ }
+ dialogTitle="Extract Intelligence Database ID from URL"
+ />
+ </div>
+
+ <div className="flex justify-between items-center">
+ <div className="flex gap-5 items-center">
+ <NotionConnectButton
+ isAutoDisabled={isSettingUp || !settings?.workspace}
+ isManualDisabled={
+ isSettingUp ||
+ !credentials.accessToken ||
+ !credentials.databaseId ||
+ !credentials.intelligenceDbId
+ }
+ handleAuto={handleSetup}
+ handleManual={handleValidate}
+ isLoading={isSettingUp}
+ />
+ </div>
+ {settings?.notion && (
+ <div className="flex gap-2 mt-4">
+ <Button
+ onClick={handleTestLog}
+ disabled={testingLog}
+ variant="secondary"
+ >
+ {testingLog ? (
+ <>
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ Testing Log
+ </>
+ ) : (
+ "Test Log"
+ )}
+ </Button>
+
+ <Button
+ onClick={handleTestIntelligence}
+ disabled={testingIntelligence}
+ variant="secondary"
+ >
+ {testingIntelligence ? (
+ <>
+ <Loader2 className="mr-2 h-4 w-4 animate-spin" />
+ Analyzing
+ </>
+ ) : (
+ "Test Intelligence"
+ )}
+ </Button>
+ </div>
+ )}
+
+ <TooltipProvider>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ onClick={handleSaveSettings}
+ disabled={loading}
+ variant="outline"
+ >
+ Save Settings
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p>
+ Saves AI model, prompt, interval, and page size settings
+ only
+ </p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ </div>
+ </div>
+ </div>
+ </CardContent>
+ </Card>
+ );
+}
+
+const NotionConnectButton = ({
+ isAutoDisabled,
+ isManualDisabled,
+ isLoading,
+ handleAuto,
+ handleManual,
+}: {
+ isAutoDisabled: boolean;
+ isManualDisabled: boolean;
+ handleAuto: () => void;
+ handleManual: () => void;
+ isLoading: boolean;
+}) => {
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button disabled={isLoading} className="group">
+ {isLoading ? "Connecting..." : "Connect Notion"}
+ <ChevronDown className="group-aria-expanded:rotate-180 transition duration-200" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuItem onClick={handleAuto} disabled={isAutoDisabled}>
+ Automatic
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={handleManual} disabled={isManualDisabled}>
+ Manual
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+};
diff --git a/pipes/notion/src/components/notion-url-to-input.tsx b/pipes/notion/src/components/notion-url-to-input.tsx
new file mode 100644
index 000000000..a429c0060
--- /dev/null
+++ b/pipes/notion/src/components/notion-url-to-input.tsx
@@ -0,0 +1,97 @@
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import { Button } from "@/components/ui/button";
+import { toast } from "@/hooks/use-toast";
+import { useState } from "react";
+
+interface NotionIdInputProps {
+ label: string;
+ value: string;
+ onChange: (value: string) => void;
+ dialogTitle: string;
+}
+
+export function NotionIdInput({
+ label,
+ value,
+ onChange,
+ dialogTitle,
+}: NotionIdInputProps) {
+ const [isDialogOpen, setIsDialogOpen] = useState(false);
+
+ const extractIdFromUrl = (url: string) => {
+ try {
+ const match = url.match(/notion\.so\/(?:[^-]*-)?([a-zA-Z0-9]{32})/);
+ return match ? match[1] : null;
+ } catch (error) {
+ return null;
+ }
+ };
+
+ const handleUrlSubmit = (url: string) => {
+ const id = extractIdFromUrl(url);
+ if (id) {
+ onChange(id);
+ setIsDialogOpen(false);
+ } else {
+ toast({
+ title: "Error",
+ description: "Invalid Notion URL",
+ variant: "destructive",
+ });
+ }
+ };
+
+ return (
+ <div className="space-y-2">
+ <Label>{label}</Label>
+ <div className="flex gap-2">
+ <Input
+ placeholder={label}
+ value={value}
+ onChange={(e) => onChange(e.target.value)}
+ />
+ <Button variant="outline" onClick={() => setIsDialogOpen(true)}>
+ Get ID from URL
+ </Button>
+ </div>
+
+ <Dialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>{dialogTitle}</DialogTitle>
+ </DialogHeader>
+ <div className="space-y-4">
+ <div className="space-y-2">
+ <Label>Notion Database URL</Label>
+ <Input
+ placeholder="https://www.notion.so/..."
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ handleUrlSubmit(e.currentTarget.value);
+ }
+ }}
+ />
+ </div>
+ <Button
+ className="w-full"
+ onClick={(e) => {
+ const input =
+ e.currentTarget.parentElement?.querySelector("input");
+ if (input) handleUrlSubmit(input.value);
+ }}
+ >
+ Extract ID
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
diff --git a/pipes/notion/src/components/ollama-models-list.tsx b/pipes/notion/src/components/ollama-models-list.tsx
new file mode 100644
index 000000000..f86d48a46
--- /dev/null
+++ b/pipes/notion/src/components/ollama-models-list.tsx
@@ -0,0 +1,132 @@
+import { useState, useEffect } from "react";
+import { Loader2, ChevronsUpDown } from "lucide-react";
+import { Button } from "@/components/ui/button";
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+} from "@/components/ui/command";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
+
+interface OllamaModel {
+ name: string;
+ size: number;
+ digest: string;
+ modified_at: string;
+}
+
+interface Props {
+ defaultValue: string;
+ onChange?: (value: string) => void;
+ disabled?: boolean;
+}
+
+export function OllamaModelsList({ defaultValue, onChange, disabled }: Props) {
+ const [open, setOpen] = useState(false);
+ const [ollamaModels, setOllamaModels] = useState<OllamaModel[]>([]);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState<string | null>(null);
+ const [value, setValue] = useState(defaultValue);
+
+ useEffect(() => {
+ const fetchOllamaModels = async () => {
+ try {
+ const response = await fetch("http://localhost:11434/api/tags");
+ if (!response.ok) throw new Error("failed to fetch ollama models");
+ const data = (await response.json()) as { models: OllamaModel[] };
+ setOllamaModels(data.models || []);
+ setError(null);
+ } catch (error) {
+ console.error("failed to fetch ollama models:", error);
+ setError("failed to connect to ollama");
+ setOllamaModels([]);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ fetchOllamaModels();
+ }, []);
+
+ if (loading) {
+ return (
+ <div className="flex items-center gap-2 h-10 px-3 border rounded-md">
+ <Loader2 className="h-4 w-4 animate-spin" />
+ <span className="text-muted-foreground">loading models...</span>
+ </div>
+ );
+ }
+
+ if (error) {
+ return (
+ <div className="text-center p-4 text-muted-foreground">
+ <p>{error}</p>
+ </div>
+ );
+ }
+
+ return (
+ <Popover
+ open={open}
+ onOpenChange={(isOpen) => {
+ if (!disabled) {
+ setOpen(isOpen);
+ }
+ }}
+ >
+ <PopoverTrigger asChild>
+ <Button
+ variant="outline"
+ role="combobox"
+ className="w-full justify-between"
+ disabled={disabled}
+ >
+ <input type="hidden" name="aiModel" value={value || defaultValue} />
+ {value || defaultValue || "select model..."}
+ <ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
+ </Button>
+ </PopoverTrigger>
+ <PopoverContent className="w-full p-0">
+ <Command>
+ <CommandInput placeholder="search models..." />
+ <CommandList>
+ <CommandEmpty>no models found</CommandEmpty>
+ <CommandGroup>
+ {ollamaModels.map((model) => (
+ <CommandItem
+ key={model.digest}
+ value={model.name}
+ onSelect={(currentValue) => {
+ setValue(currentValue);
+ setOpen(false);
+ if (onChange) {
+ onChange(currentValue);
+ }
+ const input = document.querySelector(
+ 'input[name="aiModel"]',
+ ) as HTMLInputElement;
+ if (input) input.value = currentValue;
+ }}
+ >
+ <div className="flex items-center justify-between w-full">
+ <span>{model.name}</span>
+ <span className="text-sm text-muted-foreground">
+ {(model.size / 1024 / 1024 / 1024).toFixed(2)} GB
+ </span>
+ </div>
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ );
+}
diff --git a/pipes/notion/src/components/ui/accordion.tsx b/pipes/notion/src/components/ui/accordion.tsx
new file mode 100644
index 000000000..24c788c2c
--- /dev/null
+++ b/pipes/notion/src/components/ui/accordion.tsx
@@ -0,0 +1,58 @@
+"use client"
+
+import * as React from "react"
+import * as AccordionPrimitive from "@radix-ui/react-accordion"
+import { ChevronDown } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Accordion = AccordionPrimitive.Root
+
+const AccordionItem = React.forwardRef<
+ React.ElementRef<typeof AccordionPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
+>(({ className, ...props }, ref) => (
+ <AccordionPrimitive.Item
+ ref={ref}
+ className={cn("border-b", className)}
+ {...props}
+ />
+))
+AccordionItem.displayName = "AccordionItem"
+
+const AccordionTrigger = React.forwardRef<
+ React.ElementRef<typeof AccordionPrimitive.Trigger>,
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
+>(({ className, children, ...props }, ref) => (
+ <AccordionPrimitive.Header className="flex">
+ <AccordionPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ "flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
+ </AccordionPrimitive.Trigger>
+ </AccordionPrimitive.Header>
+))
+AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
+
+const AccordionContent = React.forwardRef<
+ React.ElementRef<typeof AccordionPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
+>(({ className, children, ...props }, ref) => (
+ <AccordionPrimitive.Content
+ ref={ref}
+ className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
+ {...props}
+ >
+ <div className={cn("pb-4 pt-0", className)}>{children}</div>
+ </AccordionPrimitive.Content>
+))
+
+AccordionContent.displayName = AccordionPrimitive.Content.displayName
+
+export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
diff --git a/pipes/notion/src/components/ui/badge.tsx b/pipes/notion/src/components/ui/badge.tsx
new file mode 100644
index 000000000..f000e3ef5
--- /dev/null
+++ b/pipes/notion/src/components/ui/badge.tsx
@@ -0,0 +1,36 @@
+import * as React from "react"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const badgeVariants = cva(
+ "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
+ {
+ variants: {
+ variant: {
+ default:
+ "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
+ secondary:
+ "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
+ destructive:
+ "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
+ outline: "text-foreground",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ }
+)
+
+export interface BadgeProps
+ extends React.HTMLAttributes<HTMLDivElement>,
+ VariantProps<typeof badgeVariants> {}
+
+function Badge({ className, variant, ...props }: BadgeProps) {
+ return (
+ <div className={cn(badgeVariants({ variant }), className)} {...props} />
+ )
+}
+
+export { Badge, badgeVariants }
diff --git a/pipes/notion/src/components/ui/button.tsx b/pipes/notion/src/components/ui/button.tsx
new file mode 100644
index 000000000..36496a287
--- /dev/null
+++ b/pipes/notion/src/components/ui/button.tsx
@@ -0,0 +1,56 @@
+import * as React from "react"
+import { Slot } from "@radix-ui/react-slot"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const buttonVariants = cva(
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
+ {
+ variants: {
+ variant: {
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
+ destructive:
+ "bg-destructive text-destructive-foreground hover:bg-destructive/90",
+ outline:
+ "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
+ secondary:
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
+ ghost: "hover:bg-accent hover:text-accent-foreground",
+ link: "text-primary underline-offset-4 hover:underline",
+ },
+ size: {
+ default: "h-10 px-4 py-2",
+ sm: "h-9 rounded-md px-3",
+ lg: "h-11 rounded-md px-8",
+ icon: "h-10 w-10",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ size: "default",
+ },
+ }
+)
+
+export interface ButtonProps
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
+ VariantProps<typeof buttonVariants> {
+ asChild?: boolean
+}
+
+const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
+ const Comp = asChild ? Slot : "button"
+ return (
+ <Comp
+ className={cn(buttonVariants({ variant, size, className }))}
+ ref={ref}
+ {...props}
+ />
+ )
+ }
+)
+Button.displayName = "Button"
+
+export { Button, buttonVariants }
diff --git a/pipes/notion/src/components/ui/calendar.tsx b/pipes/notion/src/components/ui/calendar.tsx
new file mode 100644
index 000000000..61d2b451e
--- /dev/null
+++ b/pipes/notion/src/components/ui/calendar.tsx
@@ -0,0 +1,66 @@
+"use client"
+
+import * as React from "react"
+import { ChevronLeft, ChevronRight } from "lucide-react"
+import { DayPicker } from "react-day-picker"
+
+import { cn } from "@/lib/utils"
+import { buttonVariants } from "@/components/ui/button"
+
+export type CalendarProps = React.ComponentProps<typeof DayPicker>
+
+function Calendar({
+ className,
+ classNames,
+ showOutsideDays = true,
+ ...props
+}: CalendarProps) {
+ return (
+ <DayPicker
+ showOutsideDays={showOutsideDays}
+ className={cn("p-3", className)}
+ classNames={{
+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
+ month: "space-y-4",
+ caption: "flex justify-center pt-1 relative items-center",
+ caption_label: "text-sm font-medium",
+ nav: "space-x-1 flex items-center",
+ nav_button: cn(
+ buttonVariants({ variant: "outline" }),
+ "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
+ ),
+ nav_button_previous: "absolute left-1",
+ nav_button_next: "absolute right-1",
+ table: "w-full border-collapse space-y-1",
+ head_row: "flex",
+ head_cell:
+ "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
+ row: "flex w-full mt-2",
+ cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
+ day: cn(
+ buttonVariants({ variant: "ghost" }),
+ "h-9 w-9 p-0 font-normal aria-selected:opacity-100"
+ ),
+ day_range_end: "day-range-end",
+ day_selected:
+ "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
+ day_today: "bg-accent text-accent-foreground",
+ day_outside:
+ "day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",
+ day_disabled: "text-muted-foreground opacity-50",
+ day_range_middle:
+ "aria-selected:bg-accent aria-selected:text-accent-foreground",
+ day_hidden: "invisible",
+ ...classNames,
+ }}
+ components={{
+ IconLeft: ({ ...props }) => <ChevronLeft className="h-4 w-4" />,
+ IconRight: ({ ...props }) => <ChevronRight className="h-4 w-4" />,
+ }}
+ {...props}
+ />
+ )
+}
+Calendar.displayName = "Calendar"
+
+export { Calendar }
diff --git a/pipes/notion/src/components/ui/card.tsx b/pipes/notion/src/components/ui/card.tsx
new file mode 100644
index 000000000..f62edea57
--- /dev/null
+++ b/pipes/notion/src/components/ui/card.tsx
@@ -0,0 +1,79 @@
+import * as React from "react"
+
+import { cn } from "@/lib/utils"
+
+const Card = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn(
+ "rounded-lg border bg-card text-card-foreground shadow-sm",
+ className
+ )}
+ {...props}
+ />
+))
+Card.displayName = "Card"
+
+const CardHeader = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn("flex flex-col space-y-1.5 p-6", className)}
+ {...props}
+ />
+))
+CardHeader.displayName = "CardHeader"
+
+const CardTitle = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn(
+ "text-2xl font-semibold leading-none tracking-tight",
+ className
+ )}
+ {...props}
+ />
+))
+CardTitle.displayName = "CardTitle"
+
+const CardDescription = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn("text-sm text-muted-foreground", className)}
+ {...props}
+ />
+))
+CardDescription.displayName = "CardDescription"
+
+const CardContent = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
+))
+CardContent.displayName = "CardContent"
+
+const CardFooter = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn("flex items-center p-6 pt-0", className)}
+ {...props}
+ />
+))
+CardFooter.displayName = "CardFooter"
+
+export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
diff --git a/pipes/notion/src/components/ui/checkbox.tsx b/pipes/notion/src/components/ui/checkbox.tsx
new file mode 100644
index 000000000..df61a1388
--- /dev/null
+++ b/pipes/notion/src/components/ui/checkbox.tsx
@@ -0,0 +1,30 @@
+"use client"
+
+import * as React from "react"
+import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
+import { Check } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Checkbox = React.forwardRef<
+ React.ElementRef<typeof CheckboxPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
+>(({ className, ...props }, ref) => (
+ <CheckboxPrimitive.Root
+ ref={ref}
+ className={cn(
+ "peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
+ className
+ )}
+ {...props}
+ >
+ <CheckboxPrimitive.Indicator
+ className={cn("flex items-center justify-center text-current")}
+ >
+ <Check className="h-4 w-4" />
+ </CheckboxPrimitive.Indicator>
+ </CheckboxPrimitive.Root>
+))
+Checkbox.displayName = CheckboxPrimitive.Root.displayName
+
+export { Checkbox }
diff --git a/pipes/notion/src/components/ui/codeblock.tsx b/pipes/notion/src/components/ui/codeblock.tsx
new file mode 100644
index 000000000..e52893032
--- /dev/null
+++ b/pipes/notion/src/components/ui/codeblock.tsx
@@ -0,0 +1,148 @@
+// Inspired by Chatbot-UI and modified to fit the needs of this project
+// @see https://github.com/mckaywrigley/chatbot-ui/blob/main/components/Markdown/CodeBlock.tsx
+
+"use client";
+
+import { FC, memo } from "react";
+import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
+import { coldarkDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
+
+import { useCopyToClipboard } from "@/lib/hooks/use-copy-to-clipboard";
+import { IconCheck, IconCopy, IconDownload } from "@/components/ui/icons";
+import { Button } from "@/components/ui/button";
+
+interface Props {
+ language: string;
+ value: string;
+}
+
+interface languageMap {
+ [key: string]: string | undefined;
+}
+
+export const programmingLanguages: languageMap = {
+ javascript: ".js",
+ python: ".py",
+ java: ".java",
+ c: ".c",
+ cpp: ".cpp",
+ "c++": ".cpp",
+ "c#": ".cs",
+ ruby: ".rb",
+ php: ".php",
+ swift: ".swift",
+ "objective-c": ".m",
+ kotlin: ".kt",
+ typescript: ".ts",
+ go: ".go",
+ perl: ".pl",
+ rust: ".rs",
+ scala: ".scala",
+ haskell: ".hs",
+ lua: ".lua",
+ shell: ".sh",
+ sql: ".sql",
+ html: ".html",
+ css: ".css",
+ // add more file extensions here, make sure the key is same as language prop in CodeBlock.tsx component
+};
+
+export const generateRandomString = (length: number, lowercase = false) => {
+ const chars = "ABCDEFGHJKLMNPQRSTUVWXY3456789"; // excluding similar looking characters like Z, 2, I, 1, O, 0
+ let result = "";
+ for (let i = 0; i < length; i++) {
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
+ }
+ return lowercase ? result.toLowerCase() : result;
+};
+
+const CodeBlock: FC<Props> = memo(({ language, value }) => {
+ const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 });
+
+ const downloadAsFile = () => {
+ if (typeof window === "undefined") {
+ return;
+ }
+ const fileExtension = programmingLanguages[language] || ".file";
+ const suggestedFileName = `file-${generateRandomString(
+ 3,
+ true
+ )}${fileExtension}`;
+ const fileName = window.prompt("Enter file name", suggestedFileName);
+
+ if (!fileName) {
+ // User pressed cancel on prompt.
+ return;
+ }
+
+ const blob = new Blob([value], { type: "text/plain" });
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement("a");
+ link.download = fileName;
+ link.href = url;
+ link.style.display = "none";
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ URL.revokeObjectURL(url);
+ };
+
+ const onCopy = () => {
+ if (isCopied) return;
+ copyToClipboard(value);
+ };
+
+ return (
+ <div className="relative w-full font-sans codeblock bg-zinc-950">
+ <div className="flex items-center justify-between w-full px-6 py-2 pr-4 bg-zinc-800 text-zinc-100">
+ <span className="text-xs lowercase">{language}</span>
+ <div className="flex items-center space-x-1">
+ <Button
+ variant="ghost"
+ className="hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0"
+ onClick={downloadAsFile}
+ size="icon"
+ >
+ <IconDownload />
+ <span className="sr-only">Download</span>
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="text-xs hover:bg-zinc-800 focus-visible:ring-1 focus-visible:ring-slate-700 focus-visible:ring-offset-0"
+ onClick={onCopy}
+ >
+ {isCopied ? <IconCheck /> : <IconCopy />}
+ <span className="sr-only">Copy code</span>
+ </Button>
+ </div>
+ </div>
+ <SyntaxHighlighter
+ language={language}
+ style={coldarkDark}
+ PreTag="div"
+ showLineNumbers
+ customStyle={{
+ margin: 0,
+ width: "100%",
+ background: "transparent",
+ padding: "1.5rem 1rem",
+ }}
+ lineNumberStyle={{
+ userSelect: "none",
+ }}
+ codeTagProps={{
+ style: {
+ fontSize: "0.9rem",
+ fontFamily: "var(--font-mono)",
+ },
+ }}
+ >
+ {value}
+ </SyntaxHighlighter>
+ </div>
+ );
+});
+CodeBlock.displayName = "CodeBlock";
+
+export { CodeBlock };
diff --git a/pipes/notion/src/components/ui/command.tsx b/pipes/notion/src/components/ui/command.tsx
new file mode 100644
index 000000000..fe02572a4
--- /dev/null
+++ b/pipes/notion/src/components/ui/command.tsx
@@ -0,0 +1,153 @@
+"use client";
+
+import * as React from "react";
+import { type DialogProps } from "@radix-ui/react-dialog";
+import { Command as CommandPrimitive } from "cmdk";
+import { Search } from "lucide-react";
+
+import { cn } from "@/lib/utils";
+import { Dialog, DialogContent } from "@/components/ui/dialog";
+
+const Command = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive
+ ref={ref}
+ className={cn(
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
+ className
+ )}
+ {...props}
+ />
+));
+Command.displayName = CommandPrimitive.displayName;
+
+const CommandDialog = ({ children, ...props }: DialogProps) => {
+ return (
+ <Dialog {...props}>
+ <DialogContent className="overflow-hidden p-0 shadow-lg">
+ <Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5">
+ {children}
+ </Command>
+ </DialogContent>
+ </Dialog>
+ );
+};
+
+const CommandInput = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Input>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
+>(({ className, ...props }, ref) => (
+ <div className="flex items-center border-b px-3" cmdk-input-wrapper="">
+ <Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
+ <CommandPrimitive.Input
+ ref={ref}
+ className={cn(
+ "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",
+ className
+ )}
+ {...props}
+ />
+ </div>
+));
+
+CommandInput.displayName = CommandPrimitive.Input.displayName;
+
+const CommandList = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.List>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive.List
+ ref={ref}
+ className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)}
+ {...props}
+ />
+));
+
+CommandList.displayName = CommandPrimitive.List.displayName;
+
+const CommandEmpty = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Empty>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
+>((props, ref) => (
+ <CommandPrimitive.Empty
+ ref={ref}
+ className="py-6 text-center text-sm"
+ {...props}
+ />
+));
+
+CommandEmpty.displayName = CommandPrimitive.Empty.displayName;
+
+const CommandGroup = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Group>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive.Group
+ ref={ref}
+ className={cn(
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
+ className
+ )}
+ {...props}
+ />
+));
+
+CommandGroup.displayName = CommandPrimitive.Group.displayName;
+
+const CommandSeparator = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Separator>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive.Separator
+ ref={ref}
+ className={cn("-mx-1 h-px bg-border", className)}
+ {...props}
+ />
+));
+CommandSeparator.displayName = CommandPrimitive.Separator.displayName;
+
+const CommandItem = React.forwardRef<
+ React.ElementRef<typeof CommandPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
+>(({ className, ...props }, ref) => (
+ <CommandPrimitive.Item
+ ref={ref}
+ className={cn(
+ "relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
+ className
+ )}
+ {...props}
+ />
+));
+
+CommandItem.displayName = CommandPrimitive.Item.displayName;
+
+const CommandShortcut = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLSpanElement>) => {
+ return (
+ <span
+ className={cn(
+ "ml-auto text-xs tracking-widest text-muted-foreground",
+ className
+ )}
+ {...props}
+ />
+ );
+};
+CommandShortcut.displayName = "CommandShortcut";
+
+export {
+ Command,
+ CommandDialog,
+ CommandInput,
+ CommandList,
+ CommandEmpty,
+ CommandGroup,
+ CommandItem,
+ CommandShortcut,
+ CommandSeparator,
+};
diff --git a/pipes/notion/src/components/ui/dialog.tsx b/pipes/notion/src/components/ui/dialog.tsx
new file mode 100644
index 000000000..01ff19c7e
--- /dev/null
+++ b/pipes/notion/src/components/ui/dialog.tsx
@@ -0,0 +1,122 @@
+"use client"
+
+import * as React from "react"
+import * as DialogPrimitive from "@radix-ui/react-dialog"
+import { X } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Dialog = DialogPrimitive.Root
+
+const DialogTrigger = DialogPrimitive.Trigger
+
+const DialogPortal = DialogPrimitive.Portal
+
+const DialogClose = DialogPrimitive.Close
+
+const DialogOverlay = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Overlay>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Overlay
+ ref={ref}
+ className={cn(
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
+ className
+ )}
+ {...props}
+ />
+))
+DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
+
+const DialogContent = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
+>(({ className, children, ...props }, ref) => (
+ <DialogPortal>
+ <DialogOverlay />
+ <DialogPrimitive.Content
+ ref={ref}
+ className={cn(
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
+ <X className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </DialogPrimitive.Close>
+ </DialogPrimitive.Content>
+ </DialogPortal>
+))
+DialogContent.displayName = DialogPrimitive.Content.displayName
+
+const DialogHeader = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col space-y-1.5 text-center sm:text-left",
+ className
+ )}
+ {...props}
+ />
+)
+DialogHeader.displayName = "DialogHeader"
+
+const DialogFooter = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) => (
+ <div
+ className={cn(
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
+ className
+ )}
+ {...props}
+ />
+)
+DialogFooter.displayName = "DialogFooter"
+
+const DialogTitle = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Title>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Title
+ ref={ref}
+ className={cn(
+ "text-lg font-semibold leading-none tracking-tight",
+ className
+ )}
+ {...props}
+ />
+))
+DialogTitle.displayName = DialogPrimitive.Title.displayName
+
+const DialogDescription = React.forwardRef<
+ React.ElementRef<typeof DialogPrimitive.Description>,
+ React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
+>(({ className, ...props }, ref) => (
+ <DialogPrimitive.Description
+ ref={ref}
+ className={cn("text-sm text-muted-foreground", className)}
+ {...props}
+ />
+))
+DialogDescription.displayName = DialogPrimitive.Description.displayName
+
+export {
+ Dialog,
+ DialogPortal,
+ DialogOverlay,
+ DialogClose,
+ DialogTrigger,
+ DialogContent,
+ DialogHeader,
+ DialogFooter,
+ DialogTitle,
+ DialogDescription,
+}
diff --git a/pipes/notion/src/components/ui/dropdown-menu.tsx b/pipes/notion/src/components/ui/dropdown-menu.tsx
new file mode 100644
index 000000000..0fc4c0e07
--- /dev/null
+++ b/pipes/notion/src/components/ui/dropdown-menu.tsx
@@ -0,0 +1,200 @@
+"use client"
+
+import * as React from "react"
+import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"
+import { Check, ChevronRight, Circle } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const DropdownMenu = DropdownMenuPrimitive.Root
+
+const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
+
+const DropdownMenuGroup = DropdownMenuPrimitive.Group
+
+const DropdownMenuPortal = DropdownMenuPrimitive.Portal
+
+const DropdownMenuSub = DropdownMenuPrimitive.Sub
+
+const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup
+
+const DropdownMenuSubTrigger = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
+ inset?: boolean
+ }
+>(({ className, inset, children, ...props }, ref) => (
+ <DropdownMenuPrimitive.SubTrigger
+ ref={ref}
+ className={cn(
+ "flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
+ inset && "pl-8",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <ChevronRight className="ml-auto" />
+ </DropdownMenuPrimitive.SubTrigger>
+))
+DropdownMenuSubTrigger.displayName =
+ DropdownMenuPrimitive.SubTrigger.displayName
+
+const DropdownMenuSubContent = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
+>(({ className, ...props }, ref) => (
+ <DropdownMenuPrimitive.SubContent
+ ref={ref}
+ className={cn(
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ className
+ )}
+ {...props}
+ />
+))
+DropdownMenuSubContent.displayName =
+ DropdownMenuPrimitive.SubContent.displayName
+
+const DropdownMenuContent = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
+>(({ className, sideOffset = 4, ...props }, ref) => (
+ <DropdownMenuPrimitive.Portal>
+ <DropdownMenuPrimitive.Content
+ ref={ref}
+ sideOffset={sideOffset}
+ className={cn(
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ className
+ )}
+ {...props}
+ />
+ </DropdownMenuPrimitive.Portal>
+))
+DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName
+
+const DropdownMenuItem = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
+ inset?: boolean
+ }
+>(({ className, inset, ...props }, ref) => (
+ <DropdownMenuPrimitive.Item
+ ref={ref}
+ className={cn(
+ "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
+ inset && "pl-8",
+ className
+ )}
+ {...props}
+ />
+))
+DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName
+
+const DropdownMenuCheckboxItem = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
+>(({ className, children, checked, ...props }, ref) => (
+ <DropdownMenuPrimitive.CheckboxItem
+ ref={ref}
+ className={cn(
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ className
+ )}
+ checked={checked}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <DropdownMenuPrimitive.ItemIndicator>
+ <Check className="h-4 w-4" />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.CheckboxItem>
+))
+DropdownMenuCheckboxItem.displayName =
+ DropdownMenuPrimitive.CheckboxItem.displayName
+
+const DropdownMenuRadioItem = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
+>(({ className, children, ...props }, ref) => (
+ <DropdownMenuPrimitive.RadioItem
+ ref={ref}
+ className={cn(
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ className
+ )}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <DropdownMenuPrimitive.ItemIndicator>
+ <Circle className="h-2 w-2 fill-current" />
+ </DropdownMenuPrimitive.ItemIndicator>
+ </span>
+ {children}
+ </DropdownMenuPrimitive.RadioItem>
+))
+DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName
+
+const DropdownMenuLabel = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Label>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
+ inset?: boolean
+ }
+>(({ className, inset, ...props }, ref) => (
+ <DropdownMenuPrimitive.Label
+ ref={ref}
+ className={cn(
+ "px-2 py-1.5 text-sm font-semibold",
+ inset && "pl-8",
+ className
+ )}
+ {...props}
+ />
+))
+DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName
+
+const DropdownMenuSeparator = React.forwardRef<
+ React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
+>(({ className, ...props }, ref) => (
+ <DropdownMenuPrimitive.Separator
+ ref={ref}
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
+ {...props}
+ />
+))
+DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName
+
+const DropdownMenuShortcut = ({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLSpanElement>) => {
+ return (
+ <span
+ className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
+ {...props}
+ />
+ )
+}
+DropdownMenuShortcut.displayName = "DropdownMenuShortcut"
+
+export {
+ DropdownMenu,
+ DropdownMenuTrigger,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuCheckboxItem,
+ DropdownMenuRadioItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuShortcut,
+ DropdownMenuGroup,
+ DropdownMenuPortal,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ DropdownMenuRadioGroup,
+}
diff --git a/pipes/notion/src/components/ui/icons.tsx b/pipes/notion/src/components/ui/icons.tsx
new file mode 100644
index 000000000..bc01aabac
--- /dev/null
+++ b/pipes/notion/src/components/ui/icons.tsx
@@ -0,0 +1,611 @@
+"use client";
+
+import * as React from "react";
+
+import { cn } from "@/lib/utils";
+
+function IconNextChat({
+ className,
+ inverted,
+ ...props
+}: React.ComponentProps<"svg"> & { inverted?: boolean }) {
+ const id = React.useId();
+
+ return (
+ <svg
+ viewBox="0 0 17 17"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <defs>
+ <linearGradient
+ id={`gradient-${id}-1`}
+ x1="10.6889"
+ y1="10.3556"
+ x2="13.8445"
+ y2="14.2667"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop stopColor={inverted ? "white" : "black"} />
+ <stop
+ offset={1}
+ stopColor={inverted ? "white" : "black"}
+ stopOpacity={0}
+ />
+ </linearGradient>
+ <linearGradient
+ id={`gradient-${id}-2`}
+ x1="11.7555"
+ y1="4.8"
+ x2="11.7376"
+ y2="9.50002"
+ gradientUnits="userSpaceOnUse"
+ >
+ <stop stopColor={inverted ? "white" : "black"} />
+ <stop
+ offset={1}
+ stopColor={inverted ? "white" : "black"}
+ stopOpacity={0}
+ />
+ </linearGradient>
+ </defs>
+ <path
+ d="M1 16L2.58314 11.2506C1.83084 9.74642 1.63835 8.02363 2.04013 6.39052C2.4419 4.75741 3.41171 3.32057 4.776 2.33712C6.1403 1.35367 7.81003 0.887808 9.4864 1.02289C11.1628 1.15798 12.7364 1.8852 13.9256 3.07442C15.1148 4.26363 15.842 5.83723 15.9771 7.5136C16.1122 9.18997 15.6463 10.8597 14.6629 12.224C13.6794 13.5883 12.2426 14.5581 10.6095 14.9599C8.97637 15.3616 7.25358 15.1692 5.74942 14.4169L1 16Z"
+ fill={inverted ? "black" : "white"}
+ stroke={inverted ? "black" : "white"}
+ strokeWidth={2}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ <mask
+ id="mask0_91_2047"
+ style={{ maskType: "alpha" }}
+ maskUnits="userSpaceOnUse"
+ x={1}
+ y={0}
+ width={16}
+ height={16}
+ >
+ <circle cx={9} cy={8} r={8} fill={inverted ? "black" : "white"} />
+ </mask>
+ <g mask="url(#mask0_91_2047)">
+ <circle cx={9} cy={8} r={8} fill={inverted ? "black" : "white"} />
+ <path
+ d="M14.2896 14.0018L7.146 4.8H5.80005V11.1973H6.87681V6.16743L13.4444 14.6529C13.7407 14.4545 14.0231 14.2369 14.2896 14.0018Z"
+ fill={`url(#gradient-${id}-1)`}
+ />
+ <rect
+ x="11.2222"
+ y="4.8"
+ width="1.06667"
+ height="6.4"
+ fill={`url(#gradient-${id}-2)`}
+ />
+ </g>
+ </svg>
+ );
+}
+
+function IconOpenAI({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ fill="currentColor"
+ viewBox="0 0 24 24"
+ role="img"
+ xmlns="http://www.w3.org/2000/svg"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <title>OpenAI icon</title>
+ <path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z" />
+ </svg>
+ );
+}
+
+function IconClaude({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ fill="currentColor"
+ viewBox="0 0 24 24"
+ role="img"
+ xmlns="http://www.w3.org/2000/svg"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <title>Claude icon</title>
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z" />
+ <circle cx="12" cy="12" r="3" />
+ </svg>
+ );
+}
+
+function IconVercel({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ aria-label="Vercel logomark"
+ role="img"
+ viewBox="0 0 74 64"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path
+ d="M37.5896 0.25L74.5396 64.25H0.639648L37.5896 0.25Z"
+ fill="currentColor"
+ ></path>
+ </svg>
+ );
+}
+
+function IconGitHub({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ role="img"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <title>GitHub</title>
+ <path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />
+ </svg>
+ );
+}
+
+function IconSeparator({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ fill="none"
+ shapeRendering="geometricPrecision"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="1"
+ viewBox="0 0 24 24"
+ aria-hidden="true"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M16.88 3.549L7.12 20.451"></path>
+ </svg>
+ );
+}
+
+function IconArrowDown({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="m205.66 149.66-72 72a8 8 0 0 1-11.32 0l-72-72a8 8 0 0 1 11.32-11.32L120 196.69V40a8 8 0 0 1 16 0v156.69l58.34-58.35a8 8 0 0 1 11.32 11.32Z" />
+ </svg>
+ );
+}
+
+function IconArrowRight({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="m221.66 133.66-72 72a8 8 0 0 1-11.32-11.32L196.69 136H40a8 8 0 0 1 0-16h156.69l-58.35-58.34a8 8 0 0 1 11.32-11.32l72 72a8 8 0 0 1 0 11.32Z" />
+ </svg>
+ );
+}
+
+function IconUser({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M230.92 212c-15.23-26.33-38.7-45.21-66.09-54.16a72 72 0 1 0-73.66 0c-27.39 8.94-50.86 27.82-66.09 54.16a8 8 0 1 0 13.85 8c18.84-32.56 52.14-52 89.07-52s70.23 19.44 89.07 52a8 8 0 1 0 13.85-8ZM72 96a56 56 0 1 1 56 56 56.06 56.06 0 0 1-56-56Z" />
+ </svg>
+ );
+}
+
+function IconPlus({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M224 128a8 8 0 0 1-8 8h-80v80a8 8 0 0 1-16 0v-80H40a8 8 0 0 1 0-16h80V40a8 8 0 0 1 16 0v80h80a8 8 0 0 1 8 8Z" />
+ </svg>
+ );
+}
+
+function IconArrowElbow({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M200 32v144a8 8 0 0 1-8 8H67.31l34.35 34.34a8 8 0 0 1-11.32 11.32l-48-48a8 8 0 0 1 0-11.32l48-48a8 8 0 0 1 11.32 11.32L67.31 168H184V32a8 8 0 0 1 16 0Z" />
+ </svg>
+ );
+}
+
+function IconSpinner({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4 animate-spin", className)}
+ {...props}
+ >
+ <path d="M232 128a104 104 0 0 1-208 0c0-41 23.81-78.36 60.66-95.27a8 8 0 0 1 6.68 14.54C60.15 61.59 40 93.27 40 128a88 88 0 0 0 176 0c0-34.73-20.15-66.41-51.34-80.73a8 8 0 0 1 6.68-14.54C208.19 49.64 232 87 232 128Z" />
+ </svg>
+ );
+}
+
+function IconMessage({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M216 48H40a16 16 0 0 0-16 16v160a15.84 15.84 0 0 0 9.25 14.5A16.05 16.05 0 0 0 40 240a15.89 15.89 0 0 0 10.25-3.78.69.69 0 0 0 .13-.11L82.5 208H216a16 16 0 0 0 16-16V64a16 16 0 0 0-16-16ZM40 224Zm176-32H82.5a16 16 0 0 0-10.3 3.75l-.12.11L40 224V64h176Z" />
+ </svg>
+ );
+}
+
+function IconTrash({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M216 48h-40v-8a24 24 0 0 0-24-24h-48a24 24 0 0 0-24 24v8H40a8 8 0 0 0 0 16h8v144a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16V64h8a8 8 0 0 0 0-16ZM96 40a8 8 0 0 1 8-8h48a8 8 0 0 1 8 8v8H96Zm96 168H64V64h128Zm-80-104v64a8 8 0 0 1-16 0v-64a8 8 0 0 1 16 0Zm48 0v64a8 8 0 0 1-16 0v-64a8 8 0 0 1 16 0Z" />
+ </svg>
+ );
+}
+
+function IconRefresh({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M197.67 186.37a8 8 0 0 1 0 11.29C196.58 198.73 170.82 224 128 224c-37.39 0-64.53-22.4-80-39.85V208a8 8 0 0 1-16 0v-48a8 8 0 0 1 8-8h48a8 8 0 0 1 0 16H55.44C67.76 183.35 93 208 128 208c36 0 58.14-21.46 58.36-21.68a8 8 0 0 1 11.31.05ZM216 40a8 8 0 0 0-8 8v23.85C192.53 54.4 165.39 32 128 32c-42.82 0-68.58 25.27-69.66 26.34a8 8 0 0 0 11.3 11.34C69.86 69.46 92 48 128 48c35 0 60.24 24.65 72.56 40H168a8 8 0 0 0 0 16h48a8 8 0 0 0 8-8V48a8 8 0 0 0-8-8Z" />
+ </svg>
+ );
+}
+
+function IconStop({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M128 24a104 104 0 1 0 104 104A104.11 104.11 0 0 0 128 24Zm0 192a88 88 0 1 1 88-88 88.1 88.1 0 0 1-88 88Zm24-120h-48a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h48a8 8 0 0 0 8-8v-48a8 8 0 0 0-8-8Zm-8 48h-32v-32h32Z" />
+ </svg>
+ );
+}
+
+function IconSidebar({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M216 40H40a16 16 0 0 0-16 16v144a16 16 0 0 0 16 16h176a16 16 0 0 0 16-16V56a16 16 0 0 0-16-16ZM40 56h40v144H40Zm176 144H96V56h120v144Z" />
+ </svg>
+ );
+}
+
+function IconMoon({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M233.54 142.23a8 8 0 0 0-8-2 88.08 88.08 0 0 1-109.8-109.8 8 8 0 0 0-10-10 104.84 104.84 0 0 0-52.91 37A104 104 0 0 0 136 224a103.09 103.09 0 0 0 62.52-20.88 104.84 104.84 0 0 0 37-52.91 8 8 0 0 0-1.98-7.98Zm-44.64 48.11A88 88 0 0 1 65.66 67.11a89 89 0 0 1 31.4-26A106 106 0 0 0 96 56a104.11 104.11 0 0 0 104 104 106 106 0 0 0 14.92-1.06 89 89 0 0 1-26.02 31.4Z" />
+ </svg>
+ );
+}
+
+function IconSun({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M120 40V16a8 8 0 0 1 16 0v24a8 8 0 0 1-16 0Zm72 88a64 64 0 1 1-64-64 64.07 64.07 0 0 1 64 64Zm-16 0a48 48 0 1 0-48 48 48.05 48.05 0 0 0 48-48ZM58.34 69.66a8 8 0 0 0 11.32-11.32l-16-16a8 8 0 0 0-11.32 11.32Zm0 116.68-16 16a8 8 0 0 0 11.32 11.32l16-16a8 8 0 0 0-11.32-11.32ZM192 72a8 8 0 0 0 5.66-2.34l16-16a8 8 0 0 0-11.32-11.32l-16 16A8 8 0 0 0 192 72Zm5.66 114.34a8 8 0 0 0-11.32 11.32l16 16a8 8 0 0 0 11.32-11.32ZM48 128a8 8 0 0 0-8-8H16a8 8 0 0 0 0 16h24a8 8 0 0 0 8-8Zm80 80a8 8 0 0 0-8 8v24a8 8 0 0 0 16 0v-24a8 8 0 0 0-8-8Zm112-88h-24a8 8 0 0 0 0 16h24a8 8 0 0 0 0-16Z" />
+ </svg>
+ );
+}
+
+function IconCopy({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M216 32H88a8 8 0 0 0-8 8v40H40a8 8 0 0 0-8 8v128a8 8 0 0 0 8 8h128a8 8 0 0 0 8-8v-40h40a8 8 0 0 0 8-8V40a8 8 0 0 0-8-8Zm-56 176H48V96h112Zm48-48h-32V88a8 8 0 0 0-8-8H96V48h112Z" />
+ </svg>
+ );
+}
+
+function IconCheck({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="m229.66 77.66-128 128a8 8 0 0 1-11.32 0l-56-56a8 8 0 0 1 11.32-11.32L96 188.69 218.34 66.34a8 8 0 0 1 11.32 11.32Z" />
+ </svg>
+ );
+}
+
+function IconDownload({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M224 152v56a16 16 0 0 1-16 16H48a16 16 0 0 1-16-16v-56a8 8 0 0 1 16 0v56h160v-56a8 8 0 0 1 16 0Zm-101.66 5.66a8 8 0 0 0 11.32 0l40-40a8 8 0 0 0-11.32-11.32L136 132.69V40a8 8 0 0 0-16 0v92.69l-26.34-26.35a8 8 0 0 0-11.32 11.32Z" />
+ </svg>
+ );
+}
+
+function IconClose({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 256 256"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path d="M205.66 194.34a8 8 0 0 1-11.32 11.32L128 139.31l-66.34 66.35a8 8 0 0 1-11.32-11.32L116.69 128 50.34 61.66a8 8 0 0 1 11.32-11.32L128 116.69l66.34-66.35a8 8 0 0 1 11.32 11.32L139.31 128Z" />
+ </svg>
+ );
+}
+
+function IconEdit({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="none"
+ viewBox="0 0 24 24"
+ strokeWidth={1.5}
+ stroke="currentColor"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.932-8.931zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10"
+ />
+ </svg>
+ );
+}
+
+function IconShare({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ viewBox="0 0 256 256"
+ {...props}
+ >
+ <path d="m237.66 106.35-80-80A8 8 0 0 0 144 32v40.35c-25.94 2.22-54.59 14.92-78.16 34.91-28.38 24.08-46.05 55.11-49.76 87.37a12 12 0 0 0 20.68 9.58c11-11.71 50.14-48.74 107.24-52V192a8 8 0 0 0 13.66 5.65l80-80a8 8 0 0 0 0-11.3ZM160 172.69V144a8 8 0 0 0-8-8c-28.08 0-55.43 7.33-81.29 21.8a196.17 196.17 0 0 0-36.57 26.52c5.8-23.84 20.42-46.51 42.05-64.86C99.41 99.77 127.75 88 152 88a8 8 0 0 0 8-8V51.32L220.69 112Z" />
+ </svg>
+ );
+}
+
+function IconUsers({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ viewBox="0 0 256 256"
+ {...props}
+ >
+ <path d="M117.25 157.92a60 60 0 1 0-66.5 0 95.83 95.83 0 0 0-47.22 37.71 8 8 0 1 0 13.4 8.74 80 80 0 0 1 134.14 0 8 8 0 0 0 13.4-8.74 95.83 95.83 0 0 0-47.22-37.71ZM40 108a44 44 0 1 1 44 44 44.05 44.05 0 0 1-44-44Zm210.14 98.7a8 8 0 0 1-11.07-2.33A79.83 79.83 0 0 0 172 168a8 8 0 0 1 0-16 44 44 0 1 0-16.34-84.87 8 8 0 1 1-5.94-14.85 60 60 0 0 1 55.53 105.64 95.83 95.83 0 0 1 47.22 37.71 8 8 0 0 1-2.33 11.07Z" />
+ </svg>
+ );
+}
+
+function IconExternalLink({
+ className,
+ ...props
+}: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ viewBox="0 0 256 256"
+ {...props}
+ >
+ <path d="M224 104a8 8 0 0 1-16 0V59.32l-66.33 66.34a8 8 0 0 1-11.32-11.32L196.68 48H152a8 8 0 0 1 0-16h64a8 8 0 0 1 8 8Zm-40 24a8 8 0 0 0-8 8v72H48V80h72a8 8 0 0 0 0-16H48a16 16 0 0 0-16 16v128a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-72a8 8 0 0 0-8-8Z" />
+ </svg>
+ );
+}
+
+function IconChevronUpDown({
+ className,
+ ...props
+}: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ fill="currentColor"
+ className={cn("size-4", className)}
+ viewBox="0 0 256 256"
+ {...props}
+ >
+ <path d="M181.66 170.34a8 8 0 0 1 0 11.32l-48 48a8 8 0 0 1-11.32 0l-48-48a8 8 0 0 1 11.32-11.32L128 212.69l42.34-42.35a8 8 0 0 1 11.32 0Zm-96-84.68L128 43.31l42.34 42.35a8 8 0 0 0 11.32-11.32l-48-48a8 8 0 0 0-11.32 0l-48 48a8 8 0 0 0 11.32 11.32Z" />
+ </svg>
+ );
+}
+
+function IconLlama({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ fill="currentColor"
+ viewBox="0 0 24 24"
+ role="img"
+ xmlns="http://www.w3.org/2000/svg"
+ className={cn("size-4", className)}
+ {...props}
+ >
+ <title>Llama3 icon</title>
+ <circle
+ cx="12"
+ cy="12"
+ r="10"
+ stroke="currentColor"
+ strokeWidth="2"
+ fill="none"
+ />
+ <path
+ d="M6 9l6 6 6-6"
+ stroke="currentColor"
+ strokeWidth="2"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ );
+}
+
+function IconCode({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ width="15"
+ height="15"
+ viewBox="0 0 15 15"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M9.96424 2.68571C10.0668 2.42931 9.94209 2.13833 9.6857 2.03577C9.4293 1.93322 9.13832 2.05792 9.03576 2.31432L5.03576 12.3143C4.9332 12.5707 5.05791 12.8617 5.3143 12.9642C5.5707 13.0668 5.86168 12.9421 5.96424 12.6857L9.96424 2.68571ZM3.85355 5.14646C4.04882 5.34172 4.04882 5.6583 3.85355 5.85356L2.20711 7.50001L3.85355 9.14646C4.04882 9.34172 4.04882 9.6583 3.85355 9.85356C3.65829 10.0488 3.34171 10.0488 3.14645 9.85356L1.14645 7.85356C0.951184 7.6583 0.951184 7.34172 1.14645 7.14646L3.14645 5.14646C3.34171 4.9512 3.65829 4.9512 3.85355 5.14646ZM11.1464 5.14646C11.3417 4.9512 11.6583 4.9512 11.8536 5.14646L13.8536 7.14646C14.0488 7.34172 14.0488 7.6583 13.8536 7.85356L11.8536 9.85356C11.6583 10.0488 11.3417 10.0488 11.1464 9.85356C10.9512 9.6583 10.9512 9.34172 11.1464 9.14646L12.7929 7.50001L11.1464 5.85356C10.9512 5.6583 10.9512 5.34172 11.1464 5.14646Z"
+ fill="currentColor"
+ fillRule="evenodd"
+ clipRule="evenodd"
+ ></path>
+ </svg>
+ );
+}
+
+function IconOllama({ className, ...props }: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ width="133"
+ height="185"
+ viewBox="0 0 133 185"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlnsXlink="http://www.w3.org/1999/xlink"
+ >
+ <rect width="133" height="185" fill="url(#pattern0)" />
+ <defs>
+ <pattern
+ id="pattern0"
+ patternContentUnits="objectBoundingBox"
+ width="1"
+ height="1"
+ >
+ <use
+ xlinkHref="#image0_406_1657"
+ transform="matrix(0.00552486 0 0 0.00397193 0 -0.00840675)"
+ />
+ </pattern>
+ <image
+ id="image0_406_1657"
+ width="181"
+ height="256"
+ xlinkHref="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALUAAAEACAYAAAD1IzfbAAAMQGlDQ1BJQ0MgUHJvZmlsZQAASImVVwdYU8kWnluSkEBoAQSkhN4EkRpASggt9I5gIyQBQokxEFTsyKKCa0FFBGzoqoiCFRA7YmdR7H2xoKKsiwW78iYFdN1XvjffN3f++8+Z/5w5d+beOwCoHeeIRDmoOgC5wnxxbLA/fVxyCp30FJAAARCBOjDncPNEzOjocADLUPv38u46QKTtFXup1j/7/2vR4PHzuAAg0RCn8fK4uRDvBwCv4YrE+QAQpbzZtHyRFMMKtMQwQIgXSXGGHNdIcZoc75bZxMeyIG4HQEmFwxFnAKB6CfL0Am4G1FDth9hRyBMIAVCjQ+yTmzuFB3EqxNbQRgSxVJ+R9oNOxt8004Y1OZyMYSyfi6woBQjyRDmcGf9nOv53yc2RDP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export {
+ IconOllama,
+ IconEdit,
+ IconNextChat,
+ IconOpenAI,
+ IconVercel,
+ IconGitHub,
+ IconSeparator,
+ IconArrowDown,
+ IconArrowRight,
+ IconUser,
+ IconPlus,
+ IconArrowElbow,
+ IconSpinner,
+ IconMessage,
+ IconTrash,
+ IconRefresh,
+ IconStop,
+ IconSidebar,
+ IconMoon,
+ IconSun,
+ IconCopy,
+ IconCheck,
+ IconDownload,
+ IconClose,
+ IconShare,
+ IconUsers,
+ IconExternalLink,
+ IconChevronUpDown,
+ IconLlama,
+ IconCode,
+ IconClaude,
+};
diff --git a/pipes/notion/src/components/ui/input.tsx b/pipes/notion/src/components/ui/input.tsx
new file mode 100644
index 000000000..68551b927
--- /dev/null
+++ b/pipes/notion/src/components/ui/input.tsx
@@ -0,0 +1,22 @@
+import * as React from "react"
+
+import { cn } from "@/lib/utils"
+
+const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
+ ({ className, type, ...props }, ref) => {
+ return (
+ <input
+ type={type}
+ className={cn(
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
+ className
+ )}
+ ref={ref}
+ {...props}
+ />
+ )
+ }
+)
+Input.displayName = "Input"
+
+export { Input }
diff --git a/pipes/notion/src/components/ui/label.tsx b/pipes/notion/src/components/ui/label.tsx
new file mode 100644
index 000000000..534182176
--- /dev/null
+++ b/pipes/notion/src/components/ui/label.tsx
@@ -0,0 +1,26 @@
+"use client"
+
+import * as React from "react"
+import * as LabelPrimitive from "@radix-ui/react-label"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const labelVariants = cva(
+ "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
+)
+
+const Label = React.forwardRef<
+ React.ElementRef<typeof LabelPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
+ VariantProps<typeof labelVariants>
+>(({ className, ...props }, ref) => (
+ <LabelPrimitive.Root
+ ref={ref}
+ className={cn(labelVariants(), className)}
+ {...props}
+ />
+))
+Label.displayName = LabelPrimitive.Root.displayName
+
+export { Label }
diff --git a/pipes/notion/src/components/ui/popover.tsx b/pipes/notion/src/components/ui/popover.tsx
new file mode 100644
index 000000000..a0ec48bee
--- /dev/null
+++ b/pipes/notion/src/components/ui/popover.tsx
@@ -0,0 +1,31 @@
+"use client"
+
+import * as React from "react"
+import * as PopoverPrimitive from "@radix-ui/react-popover"
+
+import { cn } from "@/lib/utils"
+
+const Popover = PopoverPrimitive.Root
+
+const PopoverTrigger = PopoverPrimitive.Trigger
+
+const PopoverContent = React.forwardRef<
+ React.ElementRef<typeof PopoverPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
+>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
+ <PopoverPrimitive.Portal>
+ <PopoverPrimitive.Content
+ ref={ref}
+ align={align}
+ sideOffset={sideOffset}
+ className={cn(
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ className
+ )}
+ {...props}
+ />
+ </PopoverPrimitive.Portal>
+))
+PopoverContent.displayName = PopoverPrimitive.Content.displayName
+
+export { Popover, PopoverTrigger, PopoverContent }
diff --git a/pipes/notion/src/components/ui/progress.tsx b/pipes/notion/src/components/ui/progress.tsx
new file mode 100644
index 000000000..5c87ea486
--- /dev/null
+++ b/pipes/notion/src/components/ui/progress.tsx
@@ -0,0 +1,28 @@
+"use client"
+
+import * as React from "react"
+import * as ProgressPrimitive from "@radix-ui/react-progress"
+
+import { cn } from "@/lib/utils"
+
+const Progress = React.forwardRef<
+ React.ElementRef<typeof ProgressPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>
+>(({ className, value, ...props }, ref) => (
+ <ProgressPrimitive.Root
+ ref={ref}
+ className={cn(
+ "relative h-4 w-full overflow-hidden rounded-full bg-secondary",
+ className
+ )}
+ {...props}
+ >
+ <ProgressPrimitive.Indicator
+ className="h-full w-full flex-1 bg-primary transition-all"
+ style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
+ />
+ </ProgressPrimitive.Root>
+))
+Progress.displayName = ProgressPrimitive.Root.displayName
+
+export { Progress }
diff --git a/pipes/notion/src/components/ui/select.tsx b/pipes/notion/src/components/ui/select.tsx
new file mode 100644
index 000000000..cbe5a36b6
--- /dev/null
+++ b/pipes/notion/src/components/ui/select.tsx
@@ -0,0 +1,160 @@
+"use client"
+
+import * as React from "react"
+import * as SelectPrimitive from "@radix-ui/react-select"
+import { Check, ChevronDown, ChevronUp } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Select = SelectPrimitive.Root
+
+const SelectGroup = SelectPrimitive.Group
+
+const SelectValue = SelectPrimitive.Value
+
+const SelectTrigger = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Trigger>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
+>(({ className, children, ...props }, ref) => (
+ <SelectPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <SelectPrimitive.Icon asChild>
+ <ChevronDown className="h-4 w-4 opacity-50" />
+ </SelectPrimitive.Icon>
+ </SelectPrimitive.Trigger>
+))
+SelectTrigger.displayName = SelectPrimitive.Trigger.displayName
+
+const SelectScrollUpButton = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.ScrollUpButton
+ ref={ref}
+ className={cn(
+ "flex cursor-default items-center justify-center py-1",
+ className
+ )}
+ {...props}
+ >
+ <ChevronUp className="h-4 w-4" />
+ </SelectPrimitive.ScrollUpButton>
+))
+SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName
+
+const SelectScrollDownButton = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.ScrollDownButton
+ ref={ref}
+ className={cn(
+ "flex cursor-default items-center justify-center py-1",
+ className
+ )}
+ {...props}
+ >
+ <ChevronDown className="h-4 w-4" />
+ </SelectPrimitive.ScrollDownButton>
+))
+SelectScrollDownButton.displayName =
+ SelectPrimitive.ScrollDownButton.displayName
+
+const SelectContent = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
+>(({ className, children, position = "popper", ...props }, ref) => (
+ <SelectPrimitive.Portal>
+ <SelectPrimitive.Content
+ ref={ref}
+ className={cn(
+ "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ position === "popper" &&
+ "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
+ className
+ )}
+ position={position}
+ {...props}
+ >
+ <SelectScrollUpButton />
+ <SelectPrimitive.Viewport
+ className={cn(
+ "p-1",
+ position === "popper" &&
+ "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"
+ )}
+ >
+ {children}
+ </SelectPrimitive.Viewport>
+ <SelectScrollDownButton />
+ </SelectPrimitive.Content>
+ </SelectPrimitive.Portal>
+))
+SelectContent.displayName = SelectPrimitive.Content.displayName
+
+const SelectLabel = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Label>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.Label
+ ref={ref}
+ className={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
+ {...props}
+ />
+))
+SelectLabel.displayName = SelectPrimitive.Label.displayName
+
+const SelectItem = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Item>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
+>(({ className, children, ...props }, ref) => (
+ <SelectPrimitive.Item
+ ref={ref}
+ className={cn(
+ "relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
+ className
+ )}
+ {...props}
+ >
+ <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
+ <SelectPrimitive.ItemIndicator>
+ <Check className="h-4 w-4" />
+ </SelectPrimitive.ItemIndicator>
+ </span>
+
+ <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
+ </SelectPrimitive.Item>
+))
+SelectItem.displayName = SelectPrimitive.Item.displayName
+
+const SelectSeparator = React.forwardRef<
+ React.ElementRef<typeof SelectPrimitive.Separator>,
+ React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
+>(({ className, ...props }, ref) => (
+ <SelectPrimitive.Separator
+ ref={ref}
+ className={cn("-mx-1 my-1 h-px bg-muted", className)}
+ {...props}
+ />
+))
+SelectSeparator.displayName = SelectPrimitive.Separator.displayName
+
+export {
+ Select,
+ SelectGroup,
+ SelectValue,
+ SelectTrigger,
+ SelectContent,
+ SelectLabel,
+ SelectItem,
+ SelectSeparator,
+ SelectScrollUpButton,
+ SelectScrollDownButton,
+}
diff --git a/pipes/notion/src/components/ui/separator.tsx b/pipes/notion/src/components/ui/separator.tsx
new file mode 100644
index 000000000..12d81c4a8
--- /dev/null
+++ b/pipes/notion/src/components/ui/separator.tsx
@@ -0,0 +1,31 @@
+"use client"
+
+import * as React from "react"
+import * as SeparatorPrimitive from "@radix-ui/react-separator"
+
+import { cn } from "@/lib/utils"
+
+const Separator = React.forwardRef<
+ React.ElementRef<typeof SeparatorPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
+>(
+ (
+ { className, orientation = "horizontal", decorative = true, ...props },
+ ref
+ ) => (
+ <SeparatorPrimitive.Root
+ ref={ref}
+ decorative={decorative}
+ orientation={orientation}
+ className={cn(
+ "shrink-0 bg-border",
+ orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
+ className
+ )}
+ {...props}
+ />
+ )
+)
+Separator.displayName = SeparatorPrimitive.Root.displayName
+
+export { Separator }
diff --git a/pipes/notion/src/components/ui/skeleton.tsx b/pipes/notion/src/components/ui/skeleton.tsx
new file mode 100644
index 000000000..01b8b6d4f
--- /dev/null
+++ b/pipes/notion/src/components/ui/skeleton.tsx
@@ -0,0 +1,15 @@
+import { cn } from "@/lib/utils"
+
+function Skeleton({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) {
+ return (
+ <div
+ className={cn("animate-pulse rounded-md bg-muted", className)}
+ {...props}
+ />
+ )
+}
+
+export { Skeleton }
diff --git a/pipes/notion/src/components/ui/slider.tsx b/pipes/notion/src/components/ui/slider.tsx
new file mode 100644
index 000000000..c31c2b3bc
--- /dev/null
+++ b/pipes/notion/src/components/ui/slider.tsx
@@ -0,0 +1,28 @@
+"use client"
+
+import * as React from "react"
+import * as SliderPrimitive from "@radix-ui/react-slider"
+
+import { cn } from "@/lib/utils"
+
+const Slider = React.forwardRef<
+ React.ElementRef<typeof SliderPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
+>(({ className, ...props }, ref) => (
+ <SliderPrimitive.Root
+ ref={ref}
+ className={cn(
+ "relative flex w-full touch-none select-none items-center",
+ className
+ )}
+ {...props}
+ >
+ <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-secondary">
+ <SliderPrimitive.Range className="absolute h-full bg-primary" />
+ </SliderPrimitive.Track>
+ <SliderPrimitive.Thumb className="block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50" />
+ </SliderPrimitive.Root>
+))
+Slider.displayName = SliderPrimitive.Root.displayName
+
+export { Slider }
diff --git a/pipes/notion/src/components/ui/switch.tsx b/pipes/notion/src/components/ui/switch.tsx
new file mode 100644
index 000000000..bc69cf2db
--- /dev/null
+++ b/pipes/notion/src/components/ui/switch.tsx
@@ -0,0 +1,29 @@
+"use client"
+
+import * as React from "react"
+import * as SwitchPrimitives from "@radix-ui/react-switch"
+
+import { cn } from "@/lib/utils"
+
+const Switch = React.forwardRef<
+ React.ElementRef<typeof SwitchPrimitives.Root>,
+ React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
+>(({ className, ...props }, ref) => (
+ <SwitchPrimitives.Root
+ className={cn(
+ "peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
+ className
+ )}
+ {...props}
+ ref={ref}
+ >
+ <SwitchPrimitives.Thumb
+ className={cn(
+ "pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0"
+ )}
+ />
+ </SwitchPrimitives.Root>
+))
+Switch.displayName = SwitchPrimitives.Root.displayName
+
+export { Switch }
diff --git a/pipes/notion/src/components/ui/tabs.tsx b/pipes/notion/src/components/ui/tabs.tsx
new file mode 100644
index 000000000..26eb10912
--- /dev/null
+++ b/pipes/notion/src/components/ui/tabs.tsx
@@ -0,0 +1,55 @@
+"use client"
+
+import * as React from "react"
+import * as TabsPrimitive from "@radix-ui/react-tabs"
+
+import { cn } from "@/lib/utils"
+
+const Tabs = TabsPrimitive.Root
+
+const TabsList = React.forwardRef<
+ React.ElementRef<typeof TabsPrimitive.List>,
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
+>(({ className, ...props }, ref) => (
+ <TabsPrimitive.List
+ ref={ref}
+ className={cn(
+ "inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
+ className
+ )}
+ {...props}
+ />
+))
+TabsList.displayName = TabsPrimitive.List.displayName
+
+const TabsTrigger = React.forwardRef<
+ React.ElementRef<typeof TabsPrimitive.Trigger>,
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
+>(({ className, ...props }, ref) => (
+ <TabsPrimitive.Trigger
+ ref={ref}
+ className={cn(
+ "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
+ className
+ )}
+ {...props}
+ />
+))
+TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
+
+const TabsContent = React.forwardRef<
+ React.ElementRef<typeof TabsPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
+>(({ className, ...props }, ref) => (
+ <TabsPrimitive.Content
+ ref={ref}
+ className={cn(
+ "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
+ className
+ )}
+ {...props}
+ />
+))
+TabsContent.displayName = TabsPrimitive.Content.displayName
+
+export { Tabs, TabsList, TabsTrigger, TabsContent }
diff --git a/pipes/notion/src/components/ui/textarea.tsx b/pipes/notion/src/components/ui/textarea.tsx
new file mode 100644
index 000000000..4d858bb6b
--- /dev/null
+++ b/pipes/notion/src/components/ui/textarea.tsx
@@ -0,0 +1,22 @@
+import * as React from "react"
+
+import { cn } from "@/lib/utils"
+
+const Textarea = React.forwardRef<
+ HTMLTextAreaElement,
+ React.ComponentProps<"textarea">
+>(({ className, ...props }, ref) => {
+ return (
+ <textarea
+ className={cn(
+ "flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
+ className
+ )}
+ ref={ref}
+ {...props}
+ />
+ )
+})
+Textarea.displayName = "Textarea"
+
+export { Textarea }
diff --git a/pipes/notion/src/components/ui/toast.tsx b/pipes/notion/src/components/ui/toast.tsx
new file mode 100644
index 000000000..521b94b07
--- /dev/null
+++ b/pipes/notion/src/components/ui/toast.tsx
@@ -0,0 +1,129 @@
+"use client"
+
+import * as React from "react"
+import * as ToastPrimitives from "@radix-ui/react-toast"
+import { cva, type VariantProps } from "class-variance-authority"
+import { X } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const ToastProvider = ToastPrimitives.Provider
+
+const ToastViewport = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Viewport>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Viewport
+ ref={ref}
+ className={cn(
+ "fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
+ className
+ )}
+ {...props}
+ />
+))
+ToastViewport.displayName = ToastPrimitives.Viewport.displayName
+
+const toastVariants = cva(
+ "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
+ {
+ variants: {
+ variant: {
+ default: "border bg-background text-foreground",
+ destructive:
+ "destructive group border-destructive bg-destructive text-destructive-foreground",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ }
+)
+
+const Toast = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Root>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
+ VariantProps<typeof toastVariants>
+>(({ className, variant, ...props }, ref) => {
+ return (
+ <ToastPrimitives.Root
+ ref={ref}
+ className={cn(toastVariants({ variant }), className)}
+ {...props}
+ />
+ )
+})
+Toast.displayName = ToastPrimitives.Root.displayName
+
+const ToastAction = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Action>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Action
+ ref={ref}
+ className={cn(
+ "inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
+ className
+ )}
+ {...props}
+ />
+))
+ToastAction.displayName = ToastPrimitives.Action.displayName
+
+const ToastClose = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Close>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Close
+ ref={ref}
+ className={cn(
+ "absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
+ className
+ )}
+ toast-close=""
+ {...props}
+ >
+ <X className="h-4 w-4" />
+ </ToastPrimitives.Close>
+))
+ToastClose.displayName = ToastPrimitives.Close.displayName
+
+const ToastTitle = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Title>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Title
+ ref={ref}
+ className={cn("text-sm font-semibold", className)}
+ {...props}
+ />
+))
+ToastTitle.displayName = ToastPrimitives.Title.displayName
+
+const ToastDescription = React.forwardRef<
+ React.ElementRef<typeof ToastPrimitives.Description>,
+ React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
+>(({ className, ...props }, ref) => (
+ <ToastPrimitives.Description
+ ref={ref}
+ className={cn("text-sm opacity-90", className)}
+ {...props}
+ />
+))
+ToastDescription.displayName = ToastPrimitives.Description.displayName
+
+type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>
+
+type ToastActionElement = React.ReactElement<typeof ToastAction>
+
+export {
+ type ToastProps,
+ type ToastActionElement,
+ ToastProvider,
+ ToastViewport,
+ Toast,
+ ToastTitle,
+ ToastDescription,
+ ToastClose,
+ ToastAction,
+}
diff --git a/pipes/notion/src/components/ui/toaster.tsx b/pipes/notion/src/components/ui/toaster.tsx
new file mode 100644
index 000000000..171beb46d
--- /dev/null
+++ b/pipes/notion/src/components/ui/toaster.tsx
@@ -0,0 +1,35 @@
+"use client"
+
+import { useToast } from "@/hooks/use-toast"
+import {
+ Toast,
+ ToastClose,
+ ToastDescription,
+ ToastProvider,
+ ToastTitle,
+ ToastViewport,
+} from "@/components/ui/toast"
+
+export function Toaster() {
+ const { toasts } = useToast()
+
+ return (
+ <ToastProvider>
+ {toasts.map(function ({ id, title, description, action, ...props }) {
+ return (
+ <Toast key={id} {...props}>
+ <div className="grid gap-1">
+ {title && <ToastTitle>{title}</ToastTitle>}
+ {description && (
+ <ToastDescription>{description}</ToastDescription>
+ )}
+ </div>
+ {action}
+ <ToastClose />
+ </Toast>
+ )
+ })}
+ <ToastViewport />
+ </ToastProvider>
+ )
+}
diff --git a/pipes/notion/src/components/ui/tooltip.tsx b/pipes/notion/src/components/ui/tooltip.tsx
new file mode 100644
index 000000000..30fc44d90
--- /dev/null
+++ b/pipes/notion/src/components/ui/tooltip.tsx
@@ -0,0 +1,30 @@
+"use client"
+
+import * as React from "react"
+import * as TooltipPrimitive from "@radix-ui/react-tooltip"
+
+import { cn } from "@/lib/utils"
+
+const TooltipProvider = TooltipPrimitive.Provider
+
+const Tooltip = TooltipPrimitive.Root
+
+const TooltipTrigger = TooltipPrimitive.Trigger
+
+const TooltipContent = React.forwardRef<
+ React.ElementRef<typeof TooltipPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
+>(({ className, sideOffset = 4, ...props }, ref) => (
+ <TooltipPrimitive.Content
+ ref={ref}
+ sideOffset={sideOffset}
+ className={cn(
+ "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ className
+ )}
+ {...props}
+ />
+))
+TooltipContent.displayName = TooltipPrimitive.Content.displayName
+
+export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
diff --git a/pipes/notion/src/components/ui/use-toast.ts b/pipes/notion/src/components/ui/use-toast.ts
new file mode 100644
index 000000000..02e111d81
--- /dev/null
+++ b/pipes/notion/src/components/ui/use-toast.ts
@@ -0,0 +1,194 @@
+"use client"
+
+// Inspired by react-hot-toast library
+import * as React from "react"
+
+import type {
+ ToastActionElement,
+ ToastProps,
+} from "@/components/ui/toast"
+
+const TOAST_LIMIT = 1
+const TOAST_REMOVE_DELAY = 1000000
+
+type ToasterToast = ToastProps & {
+ id: string
+ title?: React.ReactNode
+ description?: React.ReactNode
+ action?: ToastActionElement
+}
+
+const actionTypes = {
+ ADD_TOAST: "ADD_TOAST",
+ UPDATE_TOAST: "UPDATE_TOAST",
+ DISMISS_TOAST: "DISMISS_TOAST",
+ REMOVE_TOAST: "REMOVE_TOAST",
+} as const
+
+let count = 0
+
+function genId() {
+ count = (count + 1) % Number.MAX_SAFE_INTEGER
+ return count.toString()
+}
+
+type ActionType = typeof actionTypes
+
+type Action =
+ | {
+ type: ActionType["ADD_TOAST"]
+ toast: ToasterToast
+ }
+ | {
+ type: ActionType["UPDATE_TOAST"]
+ toast: Partial<ToasterToast>
+ }
+ | {
+ type: ActionType["DISMISS_TOAST"]
+ toastId?: ToasterToast["id"]
+ }
+ | {
+ type: ActionType["REMOVE_TOAST"]
+ toastId?: ToasterToast["id"]
+ }
+
+interface State {
+ toasts: ToasterToast[]
+}
+
+const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()
+
+const addToRemoveQueue = (toastId: string) => {
+ if (toastTimeouts.has(toastId)) {
+ return
+ }
+
+ const timeout = setTimeout(() => {
+ toastTimeouts.delete(toastId)
+ dispatch({
+ type: "REMOVE_TOAST",
+ toastId: toastId,
+ })
+ }, TOAST_REMOVE_DELAY)
+
+ toastTimeouts.set(toastId, timeout)
+}
+
+export const reducer = (state: State, action: Action): State => {
+ switch (action.type) {
+ case "ADD_TOAST":
+ return {
+ ...state,
+ toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
+ }
+
+ case "UPDATE_TOAST":
+ return {
+ ...state,
+ toasts: state.toasts.map((t) =>
+ t.id === action.toast.id ? { ...t, ...action.toast } : t
+ ),
+ }
+
+ case "DISMISS_TOAST": {
+ const { toastId } = action
+
+ // ! Side effects ! - This could be extracted into a dismissToast() action,
+ // but I'll keep it here for simplicity
+ if (toastId) {
+ addToRemoveQueue(toastId)
+ } else {
+ state.toasts.forEach((toast) => {
+ addToRemoveQueue(toast.id)
+ })
+ }
+
+ return {
+ ...state,
+ toasts: state.toasts.map((t) =>
+ t.id === toastId || toastId === undefined
+ ? {
+ ...t,
+ open: false,
+ }
+ : t
+ ),
+ }
+ }
+ case "REMOVE_TOAST":
+ if (action.toastId === undefined) {
+ return {
+ ...state,
+ toasts: [],
+ }
+ }
+ return {
+ ...state,
+ toasts: state.toasts.filter((t) => t.id !== action.toastId),
+ }
+ }
+}
+
+const listeners: Array<(state: State) => void> = []
+
+let memoryState: State = { toasts: [] }
+
+function dispatch(action: Action) {
+ memoryState = reducer(memoryState, action)
+ listeners.forEach((listener) => {
+ listener(memoryState)
+ })
+}
+
+type Toast = Omit<ToasterToast, "id">
+
+function toast({ ...props }: Toast) {
+ const id = genId()
+
+ const update = (props: ToasterToast) =>
+ dispatch({
+ type: "UPDATE_TOAST",
+ toast: { ...props, id },
+ })
+ const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id })
+
+ dispatch({
+ type: "ADD_TOAST",
+ toast: {
+ ...props,
+ id,
+ open: true,
+ onOpenChange: (open) => {
+ if (!open) dismiss()
+ },
+ },
+ })
+
+ return {
+ id: id,
+ dismiss,
+ update,
+ }
+}
+
+function useToast() {
+ const [state, setState] = React.useState<State>(memoryState)
+
+ React.useEffect(() => {
+ listeners.push(setState)
+ return () => {
+ const index = listeners.indexOf(setState)
+ if (index > -1) {
+ listeners.splice(index, 1)
+ }
+ }
+ }, [state])
+
+ return {
+ ...state,
+ toast,
+ dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
+ }
+}
+
+export { useToast, toast }
diff --git a/pipes/notion/src/hooks/use-toast.ts b/pipes/notion/src/hooks/use-toast.ts
new file mode 100644
index 000000000..02e111d81
--- /dev/null
+++ b/pipes/notion/src/hooks/use-toast.ts
@@ -0,0 +1,194 @@
+"use client"
+
+// Inspired by react-hot-toast library
+import * as React from "react"
+
+import type {
+ ToastActionElement,
+ ToastProps,
+} from "@/components/ui/toast"
+
+const TOAST_LIMIT = 1
+const TOAST_REMOVE_DELAY = 1000000
+
+type ToasterToast = ToastProps & {
+ id: string
+ title?: React.ReactNode
+ description?: React.ReactNode
+ action?: ToastActionElement
+}
+
+const actionTypes = {
+ ADD_TOAST: "ADD_TOAST",
+ UPDATE_TOAST: "UPDATE_TOAST",
+ DISMISS_TOAST: "DISMISS_TOAST",
+ REMOVE_TOAST: "REMOVE_TOAST",
+} as const
+
+let count = 0
+
+function genId() {
+ count = (count + 1) % Number.MAX_SAFE_INTEGER
+ return count.toString()
+}
+
+type ActionType = typeof actionTypes
+
+type Action =
+ | {
+ type: ActionType["ADD_TOAST"]
+ toast: ToasterToast
+ }
+ | {
+ type: ActionType["UPDATE_TOAST"]
+ toast: Partial<ToasterToast>
+ }
+ | {
+ type: ActionType["DISMISS_TOAST"]
+ toastId?: ToasterToast["id"]
+ }
+ | {
+ type: ActionType["REMOVE_TOAST"]
+ toastId?: ToasterToast["id"]
+ }
+
+interface State {
+ toasts: ToasterToast[]
+}
+
+const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>()
+
+const addToRemoveQueue = (toastId: string) => {
+ if (toastTimeouts.has(toastId)) {
+ return
+ }
+
+ const timeout = setTimeout(() => {
+ toastTimeouts.delete(toastId)
+ dispatch({
+ type: "REMOVE_TOAST",
+ toastId: toastId,
+ })
+ }, TOAST_REMOVE_DELAY)
+
+ toastTimeouts.set(toastId, timeout)
+}
+
+export const reducer = (state: State, action: Action): State => {
+ switch (action.type) {
+ case "ADD_TOAST":
+ return {
+ ...state,
+ toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
+ }
+
+ case "UPDATE_TOAST":
+ return {
+ ...state,
+ toasts: state.toasts.map((t) =>
+ t.id === action.toast.id ? { ...t, ...action.toast } : t
+ ),
+ }
+
+ case "DISMISS_TOAST": {
+ const { toastId } = action
+
+ // ! Side effects ! - This could be extracted into a dismissToast() action,
+ // but I'll keep it here for simplicity
+ if (toastId) {
+ addToRemoveQueue(toastId)
+ } else {
+ state.toasts.forEach((toast) => {
+ addToRemoveQueue(toast.id)
+ })
+ }
+
+ return {
+ ...state,
+ toasts: state.toasts.map((t) =>
+ t.id === toastId || toastId === undefined
+ ? {
+ ...t,
+ open: false,
+ }
+ : t
+ ),
+ }
+ }
+ case "REMOVE_TOAST":
+ if (action.toastId === undefined) {
+ return {
+ ...state,
+ toasts: [],
+ }
+ }
+ return {
+ ...state,
+ toasts: state.toasts.filter((t) => t.id !== action.toastId),
+ }
+ }
+}
+
+const listeners: Array<(state: State) => void> = []
+
+let memoryState: State = { toasts: [] }
+
+function dispatch(action: Action) {
+ memoryState = reducer(memoryState, action)
+ listeners.forEach((listener) => {
+ listener(memoryState)
+ })
+}
+
+type Toast = Omit<ToasterToast, "id">
+
+function toast({ ...props }: Toast) {
+ const id = genId()
+
+ const update = (props: ToasterToast) =>
+ dispatch({
+ type: "UPDATE_TOAST",
+ toast: { ...props, id },
+ })
+ const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id })
+
+ dispatch({
+ type: "ADD_TOAST",
+ toast: {
+ ...props,
+ id,
+ open: true,
+ onOpenChange: (open) => {
+ if (!open) dismiss()
+ },
+ },
+ })
+
+ return {
+ id: id,
+ dismiss,
+ update,
+ }
+}
+
+function useToast() {
+ const [state, setState] = React.useState<State>(memoryState)
+
+ React.useEffect(() => {
+ listeners.push(setState)
+ return () => {
+ const index = listeners.indexOf(setState)
+ if (index > -1) {
+ listeners.splice(index, 1)
+ }
+ }
+ }, [state])
+
+ return {
+ ...state,
+ toast,
+ dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
+ }
+}
+
+export { useToast, toast }
diff --git a/pipes/notion/src/lib/actions/namespace-settings.ts b/pipes/notion/src/lib/actions/namespace-settings.ts
new file mode 100644
index 000000000..7bec856dc
--- /dev/null
+++ b/pipes/notion/src/lib/actions/namespace-settings.ts
@@ -0,0 +1,14 @@
+"use server";
+
+import { pipe } from "@screenpipe/js";
+import { Settings } from "../types";
+
+export async function getNotionSettings() {
+ return (await pipe.settings.getAll())["customSettings"]![
+ "notion"
+ ] as Partial<Settings>;
+}
+
+export async function updateNotionSettings(newSettings: Partial<Settings>) {
+ return await pipe.settings.updateNamespaceSettings("notion", newSettings);
+}
diff --git a/pipes/notion/src/lib/actions/update-pipe-config.ts b/pipes/notion/src/lib/actions/update-pipe-config.ts
new file mode 100644
index 000000000..aab43f41e
--- /dev/null
+++ b/pipes/notion/src/lib/actions/update-pipe-config.ts
@@ -0,0 +1,52 @@
+"use server";
+import { promises as fs } from "fs";
+import path from "path";
+
+export async function updatePipeConfig(intervalMinutes: number) {
+ try {
+ const screenpipeDir = process.env.SCREENPIPE_DIR || process.cwd();
+ const pipeConfigPath = path.join(
+ screenpipeDir,
+ "pipes",
+ "notion",
+ "pipe.json",
+ );
+
+ console.log(`updating cron schedule at: ${pipeConfigPath}`);
+
+ // Load or initialize both configs
+ let config: any = {};
+
+ try {
+ const content = await fs.readFile(pipeConfigPath, "utf8");
+ config = JSON.parse(content);
+ } catch (err) {
+ console.log(
+ `no existing config found, creating new one at ${pipeConfigPath}`,
+ );
+ config = { crons: [] };
+ }
+
+ // Update cron config
+ config.crons = [
+ {
+ path: "/api/log",
+ schedule: `0 */${intervalMinutes} * * * *`,
+ },
+ {
+ path: "/api/intelligence",
+ schedule: "0 0 */1 * * *",
+ },
+ ];
+ config.enabled = config.enabled ?? true;
+ config.is_nextjs = config.is_nextjs ?? true;
+
+ await fs.writeFile(pipeConfigPath, JSON.stringify(config, null, 2));
+ console.log(
+ `updated cron schedule to run every ${intervalMinutes} minutes`,
+ );
+ } catch (err) {
+ console.error("failed to update cron schedule:", err);
+ throw err;
+ }
+}
diff --git a/pipes/notion/src/lib/actions/video-actions.ts b/pipes/notion/src/lib/actions/video-actions.ts
new file mode 100644
index 000000000..9238c9e96
--- /dev/null
+++ b/pipes/notion/src/lib/actions/video-actions.ts
@@ -0,0 +1,35 @@
+'use server'
+
+import { readFile } from 'node:fs/promises'
+import { resolve } from 'node:path'
+
+export async function getMediaFile(filePath: string): Promise<{ data: string; mimeType: string }> {
+ try {
+ const absolutePath = resolve(filePath)
+ const buffer = await readFile(absolutePath)
+ // convert to base64
+ const data = buffer.toString('base64')
+
+ const getMimeType = (path: string): string => {
+ const ext = path.split('.').pop()?.toLowerCase()
+ const isAudio = path.toLowerCase().includes('input') || path.toLowerCase().includes('output')
+
+ switch (ext) {
+ case 'mp4': return 'video/mp4'
+ case 'webm': return 'video/webm'
+ case 'ogg': return 'video/ogg'
+ case 'mp3': return 'audio/mpeg'
+ case 'wav': return 'audio/wav'
+ default: return isAudio ? 'audio/mpeg' : 'video/mp4'
+ }
+ }
+
+ return {
+ data,
+ mimeType: getMimeType(filePath)
+ }
+ } catch (error) {
+ console.error('failed to read media file:', error)
+ throw new Error(`failed to read media file: ${error instanceof Error ? error.message : 'unknown error'}`)
+ }
+}
diff --git a/pipes/notion/src/lib/helpers.ts b/pipes/notion/src/lib/helpers.ts
new file mode 100644
index 000000000..64806816e
--- /dev/null
+++ b/pipes/notion/src/lib/helpers.ts
@@ -0,0 +1,104 @@
+import { ContentItem } from "@screenpipe/js";
+import { WorkLog } from "./types";
+import { generateObject } from "ai";
+import { ollama } from "ollama-ai-provider";
+import { z } from "zod";
+import { getNotionSettings } from "./actions/namespace-settings";
+import { Client } from "@notionhq/client";
+import { NotionToMarkdown } from "notion-to-md";
+
+export const workLog = z.object({
+ title: z.string(),
+ description: z.string(),
+ tags: z.array(z.string()),
+});
+
+async function extractLinkedContent(prompt: string): Promise<string> {
+ try {
+ // Match @[[file]] or @[[folder/file]] patterns
+ const linkRegex = /@\[\[(.*?)\]\]/g;
+ const matches = [...prompt.matchAll(linkRegex)];
+ const settings = await getNotionSettings();
+ let enrichedPrompt = prompt;
+
+ const notion = new Client({ auth: settings?.notion?.accessToken });
+
+ const n2m = new NotionToMarkdown({ notionClient: notion });
+ for (const match of matches) {
+ const pageId = match[1];
+
+ try {
+ const mdblocks = await n2m.pageToMarkdown(pageId);
+ const mdString = n2m.toMarkdownString(mdblocks);
+
+ enrichedPrompt = enrichedPrompt.replace(
+ match[0],
+ `\n--- Content of ${pageId} ---\n${mdString.parent}\n---\n`,
+ );
+ } catch (error) {
+ console.error(error, `of ${pageId}`);
+ }
+ }
+ return enrichedPrompt;
+ } catch (e) {
+ console.error("not able to connect to notion", e);
+ return prompt;
+ }
+}
+
+export async function generateWorkLog(
+ screenData: ContentItem[],
+ model: string,
+ startTime: Date,
+ endTime: Date,
+ customPrompt?: string,
+): Promise<WorkLog> {
+ let enrichedPrompt = customPrompt || "";
+
+ if (customPrompt) {
+ enrichedPrompt = await extractLinkedContent(customPrompt);
+ }
+
+ const defaultPrompt = `Based on the following screen data, generate a concise work activity log entry.
+ Rules:
+ - use the screen data to generate the log entry
+ - focus on describing the activity and tags
+ - use the following context to better understand the user's goals and priorities:
+
+ ${enrichedPrompt}
+
+ Screen data: ${JSON.stringify(screenData)}
+
+ Return a JSON object with:
+ {
+ "title": "Brief title of the activity",
+ "description": "Concise description of what was done",
+ "tags": ["#tag1", "#tag2", "#tag3"]
+ }`;
+
+ console.log("enrichedPrompt prompt:", enrichedPrompt);
+
+ const provider = ollama(model);
+ const response = await generateObject({
+ model: provider,
+ messages: [{ role: "user", content: defaultPrompt }],
+ schema: workLog,
+ });
+
+ const formatDate = (date: Date) => {
+ return date.toLocaleString("en-US", {
+ year: "numeric",
+ month: "2-digit",
+ day: "2-digit",
+ hour: "2-digit",
+ minute: "2-digit",
+ hour12: false,
+ });
+ };
+
+ return {
+ ...response.object,
+ startTime: formatDate(startTime),
+ endTime: formatDate(endTime),
+ };
+}
diff --git a/pipes/notion/src/lib/hooks/use-copy-to-clipboard.tsx b/pipes/notion/src/lib/hooks/use-copy-to-clipboard.tsx
new file mode 100644
index 000000000..7249b0751
--- /dev/null
+++ b/pipes/notion/src/lib/hooks/use-copy-to-clipboard.tsx
@@ -0,0 +1,33 @@
+"use client";
+
+import * as React from "react";
+
+export interface useCopyToClipboardProps {
+ timeout?: number;
+}
+
+export function useCopyToClipboard({
+ timeout = 2000,
+}: useCopyToClipboardProps) {
+ const [isCopied, setIsCopied] = React.useState<boolean>(false);
+
+ const copyToClipboard = (value: string) => {
+ if (typeof window === "undefined" || !navigator.clipboard?.writeText) {
+ return;
+ }
+
+ if (!value) {
+ return;
+ }
+
+ navigator.clipboard.writeText(value).then(() => {
+ setIsCopied(true);
+
+ setTimeout(() => {
+ setIsCopied(false);
+ }, timeout);
+ });
+ };
+
+ return { isCopied, copyToClipboard };
+}
diff --git a/pipes/notion/src/lib/hooks/use-debounce.tsx b/pipes/notion/src/lib/hooks/use-debounce.tsx
new file mode 100644
index 000000000..ba49720b5
--- /dev/null
+++ b/pipes/notion/src/lib/hooks/use-debounce.tsx
@@ -0,0 +1,17 @@
+import { useState, useEffect } from "react";
+
+export function useDebounce<T>(value: T, delay: number): T {
+ const [debouncedValue, setDebouncedValue] = useState<T>(value);
+
+ useEffect(() => {
+ const handler = setTimeout(() => {
+ setDebouncedValue(value);
+ }, delay);
+
+ return () => {
+ clearTimeout(handler);
+ };
+ }, [value, delay]);
+
+ return debouncedValue;
+}
diff --git a/pipes/notion/src/lib/hooks/use-health-check.tsx b/pipes/notion/src/lib/hooks/use-health-check.tsx
new file mode 100644
index 000000000..8d32570d0
--- /dev/null
+++ b/pipes/notion/src/lib/hooks/use-health-check.tsx
@@ -0,0 +1,131 @@
+import { useState, useEffect, useCallback, useRef } from "react";
+
+import { debounce } from "lodash";
+
+
+interface HealthCheckResponse {
+ status: string;
+ status_code: number;
+ last_frame_timestamp: string | null;
+ last_audio_timestamp: string | null;
+ last_ui_timestamp: string | null;
+ frame_status: string;
+ audio_status: string;
+ ui_status: string;
+ message: string;
+}
+
+function isHealthChanged(
+ oldHealth: HealthCheckResponse | null,
+ newHealth: HealthCheckResponse
+): boolean {
+ if (!oldHealth) return true;
+ return (
+ oldHealth.status !== newHealth.status ||
+ oldHealth.status_code !== newHealth.status_code ||
+ oldHealth.last_frame_timestamp !== newHealth.last_frame_timestamp ||
+ oldHealth.last_audio_timestamp !== newHealth.last_audio_timestamp ||
+ oldHealth.last_ui_timestamp !== newHealth.last_ui_timestamp ||
+ oldHealth.frame_status !== newHealth.frame_status ||
+ oldHealth.audio_status !== newHealth.audio_status ||
+ oldHealth.ui_status !== newHealth.ui_status ||
+ oldHealth.message !== newHealth.message
+ );
+}
+
+interface HealthCheckHook {
+ health: HealthCheckResponse | null;
+ isServerDown: boolean;
+ isLoading: boolean;
+ fetchHealth: () => Promise<void>;
+ debouncedFetchHealth: () => Promise<void>;
+}
+
+export function useHealthCheck() {
+ const [health, setHealth] = useState<HealthCheckResponse | null>(null);
+ const [isServerDown, setIsServerDown] = useState(false);
+ const [isLoading, setIsLoading] = useState(false);
+ const abortControllerRef = useRef<AbortController | null>(null);
+ const healthRef = useRef(health);
+
+ const fetchHealth = useCallback(async () => {
+ if (abortControllerRef.current) {
+ abortControllerRef.current.abort();
+ }
+
+ abortControllerRef.current = new AbortController();
+
+ try {
+ setIsLoading(true);
+ const response = await fetch("http://localhost:3030/health", {
+ cache: "no-store",
+ signal: abortControllerRef.current.signal,
+ headers: {
+ "Cache-Control": "no-cache",
+ Pragma: "no-cache",
+ },
+ });
+
+ if (!response.ok) {
+ throw new Error(`HTTP error! status: ${response.status}`);
+ }
+
+ const data: HealthCheckResponse = await response.json();
+
+ if (isHealthChanged(healthRef.current, data)) {
+ setHealth(data);
+ healthRef.current = data;
+ }
+
+ setIsServerDown(false);
+ } catch (error) {
+ if (error instanceof Error && error.name === "AbortError") {
+ return;
+ }
+
+ // console.error("Health check error:", error);
+ if (!isServerDown) {
+ setIsServerDown(true);
+ const errorHealth: HealthCheckResponse = {
+ last_frame_timestamp: null,
+ last_audio_timestamp: null,
+ last_ui_timestamp: null,
+ frame_status: "error",
+ audio_status: "error",
+ ui_status: "error",
+ status: "error",
+ status_code: 500,
+ message: "Failed to fetch health status. Server might be down.",
+ };
+ setHealth(errorHealth);
+ healthRef.current = errorHealth;
+ }
+ } finally {
+ setIsLoading(false);
+ }
+ }, [isServerDown, setIsLoading]);
+
+ const debouncedFetchHealth = useCallback(debounce(fetchHealth, 200), [
+ fetchHealth,
+ ]);
+
+ useEffect(() => {
+ fetchHealth();
+ const interval = setInterval(fetchHealth, 1000);
+
+ return () => {
+ clearInterval(interval);
+ if (abortControllerRef.current) {
+ abortControllerRef.current.abort();
+ }
+ };
+ }, [fetchHealth]);
+
+ return {
+ health,
+ isServerDown,
+ isLoading,
+ fetchHealth,
+ debouncedFetchHealth,
+ } as HealthCheckHook;
+}
diff --git a/pipes/notion/src/lib/hooks/use-notion-settings.tsx b/pipes/notion/src/lib/hooks/use-notion-settings.tsx
new file mode 100644
index 000000000..dd0876719
--- /dev/null
+++ b/pipes/notion/src/lib/hooks/use-notion-settings.tsx
@@ -0,0 +1,67 @@
+import { useState, useEffect } from "react";
+import { Settings } from "@/lib/types";
+import {
+ getNotionSettings,
+ updateNotionSettings,
+} from "../actions/namespace-settings";
+
+const DEFAULT_SETTINGS: Partial<Settings> = {
+ prompt: `yo, you're my personal data detective! 🕵
+
+rules for the investigation:
+- extract names of people i interact with and what we discussed, when i encounter a person, make sure to extract their name like this [[John Doe]] so it's linked in my notes
+- identify recurring topics/themes in my convos, use tags or [[Link them]] to my notes
+- spot any promises or commitments made (by me or others)
+- catch interesting ideas or insights dropped in casual chat
+- note emotional vibes and energy levels in conversations
+- highlight potential opportunities or connections
+- track project progress and blockers mentioned
+
+style rules:
+- keep it real and conversational
+- use bullet points for clarity
+- include relevant timestamps
+- group related info together
+- max 4 lines per insight
+- no corporate speak, keep it human
+- for tags use hyphen between words, no spaces, eg: #my-tag not #my tag nor #myTag nor #my_tag
+
+remember: you're analyzing screen ocr text & audio, etc. from my computer, so focus on actual interactions and content!`,
+};
+
+export function useNotionSettings() {
+ const [settings, setSettings] = useState<Partial<Settings> | null>(null);
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ loadSettings();
+ }, []);
+
+ const loadSettings = async () => {
+ try {
+ const data = await getNotionSettings();
+ console.log(data);
+ setSettings(
+ data ? { ...DEFAULT_SETTINGS, ...data } : { ...DEFAULT_SETTINGS },
+ );
+ } catch (error) {
+ console.error("Failed to load settings:", error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const updateSettings = async (newSettings: Partial<Settings>) => {
+ try {
+ const mergedSettings = { ...DEFAULT_SETTINGS, ...newSettings };
+ await updateNotionSettings(mergedSettings);
+ setSettings(mergedSettings);
+ return true;
+ } catch (error) {
+ console.error("Failed to update settings:", error);
+ return false;
+ }
+ };
+
+ return { settings, updateSettings, loading };
+}
diff --git a/pipes/notion/src/lib/hooks/use-settings.tsx b/pipes/notion/src/lib/hooks/use-settings.tsx
new file mode 100644
index 000000000..d9d8ec400
--- /dev/null
+++ b/pipes/notion/src/lib/hooks/use-settings.tsx
@@ -0,0 +1,210 @@
+"use client";
+
+import { useState, useEffect } from "react";
+import { getDefaultSettings, type Settings } from "@screenpipe/browser";
+
+export function useSettings() {
+ const defaultSettings = getDefaultSettings();
+
+ defaultSettings.customSettings = {
+ ...(defaultSettings.customSettings || {}),
+ notion: {
+ prompt: `yo, you're my personal data detective! 🕵
+
+rules for the investigation:
+- extract names of people i interact with and what we discussed, when i encounter a person, make sure to extract their name like this [[John Doe]] so it's linked in my notes
+- identify recurring topics/themes in my convos, use tags or [[Link them]] to my notes
+- spot any promises or commitments made (by me or others)
+- catch interesting ideas or insights dropped in casual chat
+- note emotional vibes and energy levels in conversations
+- highlight potential opportunities or connections
+- track project progress and blockers mentioned
+
+style rules:
+- keep it real and conversational
+- use bullet points for clarity
+- include relevant timestamps
+- group related info together
+- max 4 lines per insight
+- no corporate speak, keep it human
+- for tags use hyphen between words, no spaces, eg: #my-tag not #my tag nor #myTag nor #my_tag
+
+remember: you're analyzing screen ocr text & audio, etc. from my computer, so focus on actual interactions and content!`,
+ },
+ };
+
+ const [settings, setSettings] = useState<Settings | null>(null);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState<Error | null>(null);
+
+ useEffect(() => {
+ const loadSettings = async () => {
+ if (!loading) setLoading(true);
+ try {
+ const response = await fetch("/api/settings");
+ const data = await response.json();
+ setSettings({ ...defaultSettings, ...data });
+ } catch (err) {
+ console.error("failed to load settings:", err);
+ setSettings(defaultSettings);
+ setError(err as Error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ // Initial load
+ loadSettings();
+
+ // Refresh on window focus
+ const onFocus = () => loadSettings();
+ window.addEventListener("focus", onFocus);
+
+ // Optional: periodic refresh every 30s
+ const interval = setInterval(loadSettings, 2000);
+
+ return () => {
+ window.removeEventListener("focus", onFocus);
+ clearInterval(interval);
+ };
+ }, []);
+
+ const updateSetting = async <T extends keyof Settings>(
+ key: T,
+ value: Settings[T],
+ namespace?: string,
+ ) => {
+ if (!settings) return;
+ try {
+ await fetch("/api/settings", {
+ method: "PUT",
+ body: JSON.stringify({ key, value, namespace }),
+ });
+
+ if (namespace) {
+ setSettings((prev) => {
+ if (!prev) return defaultSettings;
+ return {
+ ...prev,
+ customSettings: {
+ ...prev.customSettings,
+ [namespace]: {
+ ...(prev.customSettings?.[namespace] || {}),
+ [key]: value,
+ },
+ },
+ };
+ });
+ } else {
+ setSettings((prev) => {
+ if (!prev) return defaultSettings;
+ return { ...prev, [key]: value };
+ });
+ }
+ } catch (err) {
+ setError(err as Error);
+ }
+ };
+
+ const updateSettings = async (
+ newSettings: Partial<Settings>,
+ namespace?: string,
+ ) => {
+ if (!settings) return;
+ try {
+ await fetch("/api/settings", {
+ method: "PUT",
+ body: JSON.stringify({
+ value: newSettings,
+ isPartialUpdate: true,
+ namespace,
+ }),
+ });
+
+ if (namespace) {
+ setSettings((prev) => {
+ if (!prev) return defaultSettings;
+ return {
+ ...prev,
+ customSettings: {
+ ...prev.customSettings,
+ [namespace]: {
+ ...(prev.customSettings?.[namespace] || {}),
+ ...newSettings,
+ },
+ },
+ };
+ });
+ } else {
+ setSettings((prev) => {
+ if (!prev) return defaultSettings;
+ return { ...prev, ...newSettings };
+ });
+ }
+ } catch (err) {
+ setError(err as Error);
+ }
+ };
+
+ const resetSettings = async (
+ settingKey?: keyof Settings,
+ namespace?: string,
+ ) => {
+ if (!settings) return;
+ try {
+ await fetch("/api/settings", {
+ method: "PUT",
+ body: JSON.stringify({ reset: true, key: settingKey, namespace }),
+ });
+
+ if (namespace) {
+ setSettings((prev) => {
+ if (!prev) return defaultSettings;
+ if (settingKey) {
+ return {
+ ...prev,
+ customSettings: {
+ ...prev.customSettings,
+ [namespace]: {
+ ...(prev.customSettings?.[namespace] || {}),
+ [settingKey]: undefined,
+ },
+ },
+ };
+ } else {
+ return {
+ ...prev,
+ customSettings: {
+ ...prev.customSettings,
+ [namespace]: {},
+ },
+ };
+ }
+ });
+ } else {
+ if (settingKey) {
+ setSettings((prev) => {
+ if (!prev) return defaultSettings;
+ return {
+ ...prev,
+ [settingKey]: defaultSettings[settingKey],
+ };
+ });
+ } else {
+ setSettings(defaultSettings);
+ }
+ }
+ } catch (err) {
+ setError(err as Error);
+ }
+ };
+
+ return {
+ settings: settings || defaultSettings,
+ loading,
+ error,
+ updateSetting,
+ updateSettings,
+ resetSettings,
+ };
+}
diff --git a/pipes/notion/src/lib/hooks/use-sql-autocomplete.tsx b/pipes/notion/src/lib/hooks/use-sql-autocomplete.tsx
new file mode 100644
index 000000000..7db3de855
--- /dev/null
+++ b/pipes/notion/src/lib/hooks/use-sql-autocomplete.tsx
@@ -0,0 +1,61 @@
+import { useState, useEffect, useCallback } from "react";
+
+interface AutocompleteItem {
+ name: string;
+ count: number;
+}
+
+const CACHE_DURATION = 5 * 60 * 1000; // 5 minutes
+
+const cache: Record<string, { data: AutocompleteItem[]; timestamp: number }> =
+ {};
+
+export function useSqlAutocomplete(type: "app" | "window") {
+ const [items, setItems] = useState<AutocompleteItem[]>([]);
+ const [isLoading, setIsLoading] = useState(false);
+
+ const fetchItems = useCallback(async () => {
+ setIsLoading(true);
+ try {
+ const cachedData = cache[type];
+ if (cachedData && Date.now() - cachedData.timestamp < CACHE_DURATION) {
+ setItems(cachedData.data);
+ } else {
+ const query = `
+ SELECT ${
+ type === "app" ? "ocr.app_name" : "ocr.window_name"
+ } as name, COUNT(*) as count
+ FROM ocr_text ocr
+ JOIN frames f ON ocr.frame_id = f.id
+ WHERE f.timestamp > datetime('now', '-7 days')
+ GROUP BY ${type === "app" ? "ocr.app_name" : "ocr.window_name"}
+ ORDER BY count DESC
+ LIMIT 100
+ `;
+ const response = await fetch("http://localhost:3030/raw_sql", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({ query }),
+ });
+ if (!response.ok) {
+ throw new Error(`HTTP error! status: ${response.status}`);
+ }
+ const result = await response.json();
+ setItems(result);
+ cache[type] = { data: result, timestamp: Date.now() };
+ }
+ } catch (error) {
+ console.error("failed to fetch items:", error);
+ } finally {
+ setIsLoading(false);
+ }
+ }, [type]);
+
+ useEffect(() => {
+ fetchItems();
+ }, [fetchItems]);
+
+ return { items, isLoading };
+}
diff --git a/pipes/notion/src/lib/notion/client.ts b/pipes/notion/src/lib/notion/client.ts
new file mode 100644
index 000000000..c84f36f04
--- /dev/null
+++ b/pipes/notion/src/lib/notion/client.ts
@@ -0,0 +1,30 @@
+import {
+ WorkLog,
+ Intelligence,
+ NotionCredentials,
+} from "@/lib/types";
+import {
+ validateCredentials,
+ syncWorkLog,
+ syncIntelligence,
+} from "./notion";
+
+export class NotionClient {
+ private credentials: NotionCredentials;
+
+ constructor(credentials: NotionCredentials) {
+ this.credentials = credentials;
+ }
+
+ static async validate(credentials: NotionCredentials): Promise<boolean> {
+ return await validateCredentials(credentials);
+ }
+
+ async createLog(logEntry: WorkLog): Promise<string> {
+ return await syncWorkLog(this.credentials, logEntry);
+ }
+
+ async createIntelligence(intelligence: Intelligence): Promise<string> {
+ return await syncIntelligence(this.credentials, intelligence);
+ }
+}
diff --git a/pipes/notion/src/lib/notion/notion.ts b/pipes/notion/src/lib/notion/notion.ts
new file mode 100644
index 000000000..81abe27ba
--- /dev/null
+++ b/pipes/notion/src/lib/notion/notion.ts
@@ -0,0 +1,295 @@
+"use server";
+
+import { Client } from "@notionhq/client";
+import { WorkLog, Intelligence, NotionCredentials } from "@/lib/types";
+import { BlockObjectRequest } from "@notionhq/client/build/src/api-endpoints";
+
+export async function validateCredentials(
+ credentials: NotionCredentials,
+): Promise<boolean> {
+ try {
+ const client = new Client({ auth: credentials.accessToken });
+ await client.databases.retrieve({
+ database_id: credentials.databaseId,
+ });
+
+ await client.databases.retrieve({
+ database_id: credentials.intelligenceDbId,
+ });
+
+ // Reset logs database properties
+ await client.databases.update({
+ database_id: credentials.databaseId,
+ title: [{ text: { content: "Activity Logs" } }],
+ properties: {
+ Description: { rich_text: {} },
+ Tags: { multi_select: {} },
+ Date: { date: {} },
+ StartTime: { date: {} },
+ EndTime: { date: {} },
+ Summary: { rich_text: {} },
+ },
+ });
+
+ await client.databases.update({
+ database_id: credentials.intelligenceDbId,
+ title: [{ text: { content: "Relationship Intelligence" } }],
+ properties: {
+ Date: { date: {} },
+ Summary: { rich_text: {} },
+ },
+ });
+
+ return true;
+ } catch (error) {
+ console.error("Failed to validate/update database:", error);
+ return false;
+ }
+}
+
+export async function syncWorkLog(
+ credentials: NotionCredentials,
+ logEntry: WorkLog,
+): Promise<string> {
+ const client = new Client({ auth: credentials.accessToken });
+ const today = new Date();
+
+ await client.pages.create({
+ parent: { database_id: credentials.databaseId },
+ properties: {
+ Name: { title: [{ text: { content: logEntry.title } }] },
+ Description: { rich_text: [{ text: { content: logEntry.description } }] },
+ Tags: { multi_select: logEntry.tags.map((tag) => ({ name: tag })) },
+ Date: { date: { start: today.toISOString().split("T")[0] } },
+ StartTime: {
+ date: { start: new Date(logEntry.startTime).toISOString() },
+ },
+ EndTime: { date: { start: new Date(logEntry.endTime).toISOString() } },
+ Summary: {
+ rich_text: [
+ {
+ text: {
+ content: `Activity logged at ${new Date().toLocaleTimeString()}`,
+ },
+ },
+ ],
+ },
+ },
+ });
+
+ return `https://notion.so/${credentials.databaseId}`;
+}
+export async function syncIntelligence(
+ credentials: NotionCredentials,
+ intelligence: Intelligence,
+): Promise<string> {
+ const client = new Client({ auth: credentials.accessToken });
+ const today = new Date().toISOString().split("T")[0];
+
+ // Check for existing intelligence report for today
+ const existingReports = await client.databases.query({
+ database_id: credentials.intelligenceDbId,
+ filter: {
+ property: "Date",
+ date: {
+ equals: today,
+ },
+ },
+ });
+
+ const properties = {
+ Name: {
+ title: [{ text: { content: `Intelligence Report for ${today}` } }],
+ },
+ Date: { date: { start: today } },
+ Summary: {
+ rich_text: [
+ {
+ text: {
+ content: `Generated: ${new Date().toLocaleString()}\nContacts: ${intelligence.contacts.length}\nOpportunities: ${intelligence.insights.opportunities.length}\nFollow-ups: ${intelligence.insights.followUps.length}`,
+ },
+ },
+ ],
+ },
+ };
+
+ const children: BlockObjectRequest[] = [
+ {
+ type: "code",
+ code: {
+ rich_text: [
+ {
+ text: {
+ content: generateMermaidGraph(intelligence.contacts),
+ },
+ },
+ ],
+ language: "mermaid",
+ },
+ },
+ ...generateContactsSection(intelligence.contacts),
+ ...generateInsightsSection(intelligence.insights),
+ ];
+
+ let pageId: string;
+
+ if (existingReports.results.length > 0) {
+ // Update existing report
+ pageId = existingReports.results[0].id;
+ await client.pages.update({
+ page_id: pageId,
+ properties,
+ });
+
+ // Delete existing blocks
+ const existingBlocks = await client.blocks.children.list({
+ block_id: pageId,
+ });
+
+ for (const block of existingBlocks.results) {
+ await client.blocks.delete({
+ block_id: block.id,
+ });
+ }
+
+ // Add new blocks
+ await client.blocks.children.append({
+ block_id: pageId,
+ children,
+ });
+ } else {
+ // Create new report
+ const newPage = await client.pages.create({
+ parent: { database_id: credentials.intelligenceDbId },
+ properties,
+ children,
+ });
+ pageId = newPage.id;
+ }
+
+ return `https://notion.so/${credentials.intelligenceDbId}`;
+}
+
+function generateMermaidGraph(contacts: Intelligence["contacts"]): string {
+ let mermaidGraph = "graph TD\n";
+ contacts.forEach((contact) => {
+ mermaidGraph += ` ${contact.name.replace(/\s+/g, "_")}["${contact.name}\n${contact.company || ""}"]\n`;
+ });
+
+ return mermaidGraph;
+ //return `\`\`\`mermaid\n${mermaidGraph}\`\`\``;
+}
+
+function generateContactsSection(
+ contacts: Intelligence["contacts"],
+): BlockObjectRequest[] {
+ const blocks: BlockObjectRequest[] = [
+ {
+ type: "heading_2",
+ heading_2: {
+ rich_text: [{ type: "text", text: { content: "Key Contacts" } }],
+ },
+ },
+ ];
+
+ contacts.forEach((contact) => {
+ blocks.push(
+ {
+ type: "heading_3",
+ heading_3: {
+ rich_text: [{ type: "text", text: { content: contact.name } }],
+ },
+ },
+ {
+ type: "bulleted_list_item",
+ bulleted_list_item: {
+ rich_text: [
+ { text: { content: `Company: ${contact.company || "N/A"}` } },
+ ],
+ },
+ },
+ {
+ type: "bulleted_list_item",
+ bulleted_list_item: {
+ rich_text: [
+ {
+ text: { content: `Last Interaction: ${contact.lastInteraction}` },
+ },
+ ],
+ },
+ },
+ {
+ type: "bulleted_list_item",
+ bulleted_list_item: {
+ rich_text: [{ text: { content: `Sentiment: ${contact.sentiment}` } }],
+ },
+ },
+ {
+ type: "bulleted_list_item",
+ bulleted_list_item: {
+ rich_text: [
+ { text: { content: `Topics: ${contact.topics.join(", ")}` } },
+ ],
+ },
+ },
+ {
+ type: "bulleted_list_item",
+ bulleted_list_item: {
+ rich_text: [
+ {
+ text: { content: `Next Steps: ${contact.nextSteps.join(", ")}` },
+ },
+ ],
+ },
+ },
+ );
+ });
+
+ return blocks;
+}
+
+function generateInsightsSection(
+ insights: Intelligence["insights"],
+): BlockObjectRequest[] {
+ const blocks: BlockObjectRequest[] = [
+ {
+ type: "heading_2",
+ heading_2: {
+ rich_text: [{ type: "text", text: { content: "Insights" } }],
+ },
+ },
+ {
+ type: "heading_3",
+ heading_3: {
+ rich_text: [{ type: "text", text: { content: "Follow-ups Needed" } }],
+ },
+ },
+ ];
+
+ insights.followUps.forEach((followUp) => {
+ blocks.push({
+ type: "bulleted_list_item",
+ bulleted_list_item: {
+ rich_text: [{ text: { content: followUp } }],
+ },
+ });
+ });
+
+ blocks.push({
+ type: "heading_3",
+ heading_3: {
+ rich_text: [{ type: "text", text: { content: "Opportunities" } }],
+ },
+ });
+
+ insights.opportunities.forEach((opportunity) => {
+ blocks.push({
+ type: "bulleted_list_item",
+ bulleted_list_item: {
+ rich_text: [{ text: { content: opportunity } }],
+ },
+ });
+ });
+
+ return blocks;
+}
diff --git a/pipes/notion/src/lib/notion/setup.ts b/pipes/notion/src/lib/notion/setup.ts
new file mode 100644
index 000000000..12908d6b9
--- /dev/null
+++ b/pipes/notion/src/lib/notion/setup.ts
@@ -0,0 +1,223 @@
+import { chromium, Page } from "playwright";
+import { NotionCredentials } from "@/lib/types";
+import { INTEGRATION_NAME } from "../utils";
+
+// Integration Name
+
+// Button Click
+async function buttonClick(page: Page, selector: string) {
+ const element = page.locator(selector);
+ console.log(element);
+ await element?.click({ force: true });
+}
+
+// Create Table in Notion
+async function createTable(page: Page, nameDB: string) {
+ await page.goto("https://www.notion.so");
+
+ await page.getByRole("button").getByLabel("New page").click();
+
+ await page.getByRole("menu").getByText("Table").click();
+
+ await page.click('h1[placeholder="Untitled"]');
+
+ await page
+ .locator('h1[placeholder="Untitled"]')
+ .pressSequentially(` ${nameDB}`);
+
+ await page.keyboard.press("Enter");
+
+ await page
+ .locator("div.notion-topbar")
+ .locator('div[aria-label="Actions"]')
+ .click();
+
+ await page.click("text=Connections");
+
+ await page
+ .getByPlaceholder("Search for connections...")
+ .fill(INTEGRATION_NAME);
+
+ await page.click(`text=${INTEGRATION_NAME}`);
+
+ await page.click("text=Confirm");
+
+ await page.waitForTimeout(2000);
+
+ const dburl = page.url().replaceAll("https://www.notion.so/", "");
+ const dbId = dburl.split("-").pop()?.split("?")[0];
+
+ return dbId;
+}
+
+// Create Integration in Notion
+async function createIntegration(page: Page, workspace: string) {
+ // Create integration
+
+ await page.goto(
+ "https://www.notion.so/profile/integrations/form/new-integration",
+ {
+ waitUntil: "domcontentloaded",
+ },
+ );
+ await page.getByPlaceholder("Add integration name").fill(INTEGRATION_NAME);
+ // await page.fill('input[id="integrationName"]', INTEGRATION_NAME);
+
+ await page
+ .locator(
+ "#notion-app > div > div:nth-child(1) > div > section > section:nth-child(2) > form > div:nth-child(3) > div",
+ )
+ .getByRole("button", { expanded: false })
+ .click();
+
+ await page.click(`text=${workspace}`);
+
+ await page.click("text=Save", { delay: 1000 });
+ await page.waitForTimeout(2000);
+
+ const accessToken = await getAccessToken(page);
+ console.log("accessToken", accessToken);
+
+ return accessToken;
+}
+
+async function getAccessToken(page: Page) {
+ await page.goto("https://www.notion.so/profile/integrations");
+
+ await page.click(`text=${INTEGRATION_NAME}`);
+
+ await buttonClick(
+ page,
+ "#notion-app > div > div:nth-child(1) > div > section > section:nth-child(2) > main > form > div:nth-child(6) > div > div.notion-focusable-within > div > div > div:nth-child(3)",
+ );
+
+ const accessToken = await page
+ .locator('input[type="text"][disabled]')
+ .inputValue();
+
+ return accessToken;
+}
+
+// switch to workspace
+async function switchWorkspace(page: Page, workspace: string) {
+ await page.goto("https://www.notion.so");
+
+ const sidebar = page.locator("div.notion-sidebar-switcher");
+ await sidebar.click();
+
+ console.log(workspace, "workspace");
+
+ const workspaceItem = page.locator(`div[role="menuitem"]`, {
+ has: page.getByText(workspace),
+ });
+
+ await workspaceItem.click({ delay: 1000 });
+ // await page.click(`text=${workspace}`, { delay: 1000 });
+}
+
+// const STORAGE_PATH = path.join(process.cwd(), ".notion-storage");
+
+// Automate the process of creating integration and tables
+export async function automateNotionSetup(
+ workspace: string,
+): Promise<NotionCredentials> {
+ let loginBrowser, setupBrowser;
+
+ try {
+ //await loginUser(page, email, password);
+ loginBrowser = await chromium.launch({
+ headless: false,
+ channel: "chrome",
+ slowMo: 1000,
+ });
+
+ const loginContext = await loginBrowser.newContext({
+ viewport: null,
+ });
+
+ const loginPage = await loginContext.newPage();
+
+ await loginPage.goto("https://www.notion.so/my-integrations");
+ console.log("Please log in to Notion in the browser window...");
+ await loginPage.waitForURL("https://www.notion.so/profile/integrations", {
+ timeout: 120000,
+ });
+ console.log("Login detected, proceeding with setup...");
+
+ const authState = await loginContext.storageState();
+ await loginBrowser.close();
+
+ // Second browser instance for creation tasks
+ setupBrowser = await chromium.launch({
+ headless: true,
+ channel: "chrome",
+ });
+
+ // Create new context with stored auth state
+ const setupContext = await setupBrowser.newContext({
+ viewport: null,
+ storageState: authState,
+ });
+
+ const setupPage = await setupContext.newPage();
+
+ await setupPage.goto("https://www.notion.so/my-integrations");
+
+ await setupPage.waitForURL("https://www.notion.so/profile/integrations", {
+ waitUntil: "domcontentloaded",
+ timeout: 12000,
+ });
+
+ let isIntegrationPresent;
+
+ try {
+ await setupPage.locator(`text=${INTEGRATION_NAME}`).first().waitFor();
+
+ isIntegrationPresent = await setupPage
+ .locator(`text=${INTEGRATION_NAME}`)
+ .first()
+ .isVisible({ timeout: 1000 });
+ } catch (_error) {
+ isIntegrationPresent = false;
+ }
+
+ console.log(`integrations ${INTEGRATION_NAME}`, isIntegrationPresent);
+
+ let accessToken: string;
+
+ if (isIntegrationPresent) {
+ accessToken = await getAccessToken(setupPage);
+ } else {
+ accessToken = await createIntegration(setupPage, workspace);
+ }
+
+ await switchWorkspace(setupPage, workspace);
+
+ const logsDbId = await createTable(setupPage, "Activity Logs");
+
+ const intelligenceDbId = await createTable(
+ setupPage,
+ "Relationship Intelligence",
+ );
+
+ await setupPage.waitForTimeout(1000);
+
+ console.log(accessToken, logsDbId, intelligenceDbId);
+ if (!accessToken || !logsDbId || !intelligenceDbId) {
+ throw new Error("Failed to get credentials");
+ }
+
+ await setupPage.close();
+
+ return {
+ accessToken,
+ databaseId: logsDbId,
+ intelligenceDbId,
+ };
+ } catch (error) {
+ console.log(error);
+ await loginBrowser?.close();
+ await setupBrowser?.close();
+ throw error;
+ }
+}
diff --git a/pipes/notion/src/lib/types.ts b/pipes/notion/src/lib/types.ts
new file mode 100644
index 000000000..510e43a81
--- /dev/null
+++ b/pipes/notion/src/lib/types.ts
@@ -0,0 +1,46 @@
+export interface NotionCredentials {
+ accessToken: string;
+ databaseId: string;
+ logsDbId?: string;
+ intelligenceDbId: string;
+}
+
+export interface NotionAdminSetup {
+ adminKey: string;
+ workspaceName: string;
+}
+
+export interface WorkLog {
+ title: string;
+ description: string;
+ tags: string[];
+ startTime: string;
+ endTime: string;
+}
+
+export interface Contact {
+ name: string;
+ company?: string;
+ lastInteraction: string;
+ sentiment: number;
+ topics: string[];
+ nextSteps: string[];
+}
+
+export interface Intelligence {
+ contacts: Contact[];
+ insights: {
+ followUps: string[];
+ opportunities: string[];
+ };
+}
+
+export interface Settings {
+ interval: number;
+ pageSize: number;
+ aiModel: string;
+ workspace: string;
+ backend: "notion";
+ notion: NotionCredentials;
+ prompt: string;
+}
diff --git a/pipes/notion/src/lib/utils.ts b/pipes/notion/src/lib/utils.ts
new file mode 100644
index 000000000..a4e1490c9
--- /dev/null
+++ b/pipes/notion/src/lib/utils.ts
@@ -0,0 +1,49 @@
+import { ContentItem } from "@screenpipe/js";
+import { clsx, type ClassValue } from "clsx";
+import { twMerge } from "tailwind-merge";
+import levenshtein from "js-levenshtein";
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs));
+}
+
+export const removeDuplicateSelections = (
+ results: ContentItem[],
+ selectedResults: Set<number>,
+ similarityThreshold: number = 0.9,
+): Set<number> => {
+ const newSelectedResults = new Set<number>();
+ const seenContents: string[] = [];
+
+ const getSimilarity = (str1: string, str2: string): number => {
+ const maxLength = Math.max(str1.length, str2.length);
+ const distance = levenshtein(str1, str2);
+ return 1 - distance / maxLength;
+ };
+
+ const isDuplicate = (content: string): boolean => {
+ return seenContents.some(
+ (seenContent) =>
+ getSimilarity(content, seenContent) >= similarityThreshold,
+ );
+ };
+
+ Array.from(selectedResults).forEach((index) => {
+ const item = results[index];
+ if (!item || !item.type) return;
+
+ let content = "";
+ if (item.type === "OCR") content = item.content.text;
+ else if (item.type === "Audio") content = item.content.transcription;
+ else if (item.type === "UI") content = item.content.text;
+
+ if (!isDuplicate(content)) {
+ seenContents.push(content);
+ newSelectedResults.add(index);
+ }
+ });
+
+ return newSelectedResults;
+};
+
+export const INTEGRATION_NAME = "Screenpipe Logger";
diff --git a/pipes/notion/tailwind.config.ts b/pipes/notion/tailwind.config.ts
new file mode 100644
index 000000000..9a58f7ad4
--- /dev/null
+++ b/pipes/notion/tailwind.config.ts
@@ -0,0 +1,84 @@
+import type { Config } from "tailwindcss";
+
+export default {
+ darkMode: ["class"],
+ content: [
+ "./src/pages/**/*.{js,ts,jsx,tsx,mdx}",
+ "./src/components/**/*.{js,ts,jsx,tsx,mdx}",
+ "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
+ ],
+ theme: {
+ extend: {
+ colors: {
+ background: 'hsl(var(--background))',
+ foreground: 'hsl(var(--foreground))',
+ card: {
+ DEFAULT: 'hsl(var(--card))',
+ foreground: 'hsl(var(--card-foreground))'
+ },
+ popover: {
+ DEFAULT: 'hsl(var(--popover))',
+ foreground: 'hsl(var(--popover-foreground))'
+ },
+ primary: {
+ DEFAULT: 'hsl(var(--primary))',
+ foreground: 'hsl(var(--primary-foreground))'
+ },
+ secondary: {
+ DEFAULT: 'hsl(var(--secondary))',
+ foreground: 'hsl(var(--secondary-foreground))'
+ },
+ muted: {
+ DEFAULT: 'hsl(var(--muted))',
+ foreground: 'hsl(var(--muted-foreground))'
+ },
+ accent: {
+ DEFAULT: 'hsl(var(--accent))',
+ foreground: 'hsl(var(--accent-foreground))'
+ },
+ destructive: {
+ DEFAULT: 'hsl(var(--destructive))',
+ foreground: 'hsl(var(--destructive-foreground))'
+ },
+ border: 'hsl(var(--border))',
+ input: 'hsl(var(--input))',
+ ring: 'hsl(var(--ring))',
+ chart: {
+ '1': 'hsl(var(--chart-1))',
+ '2': 'hsl(var(--chart-2))',
+ '3': 'hsl(var(--chart-3))',
+ '4': 'hsl(var(--chart-4))',
+ '5': 'hsl(var(--chart-5))'
+ }
+ },
+ borderRadius: {
+ lg: 'var(--radius)',
+ md: 'calc(var(--radius) - 2px)',
+ sm: 'calc(var(--radius) - 4px)'
+ },
+ keyframes: {
+ 'accordion-down': {
+ from: {
+ height: '0'
+ },
+ to: {
+ height: 'var(--radix-accordion-content-height)'
+ }
+ },
+ 'accordion-up': {
+ from: {
+ height: 'var(--radix-accordion-content-height)'
+ },
+ to: {
+ height: '0'
+ }
+ }
+ },
+ animation: {
+ 'accordion-down': 'accordion-down 0.2s ease-out',
+ 'accordion-up': 'accordion-up 0.2s ease-out'
+ }
+ }
+ },
+ plugins: [require("tailwindcss-animate")],
+} satisfies Config;
diff --git a/pipes/notion/tsconfig.json b/pipes/notion/tsconfig.json
new file mode 100644
index 000000000..c1334095f
--- /dev/null
+++ b/pipes/notion/tsconfig.json
@@ -0,0 +1,27 @@
+{
+ "compilerOptions": {
+ "target": "ES2017",
+ "lib": ["dom", "dom.iterable", "esnext"],
+ "allowJs": true,
+ "skipLibCheck": true,
+ "strict": true,
+ "noEmit": true,
+ "esModuleInterop": true,
+ "module": "esnext",
+ "moduleResolution": "bundler",
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "jsx": "preserve",
+ "incremental": true,
+ "plugins": [
+ {
+ "name": "next"
+ }
+ ],
+ "paths": {
+ "@/*": ["./src/*"]
+ }
+ },
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
+ "exclude": ["node_modules"]
+}