YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
refactor sp cloud etc
Louis Beaumont9e984cbb1c3c
diff --git a/screenpipe-actions/ai-proxy/src/index.ts b/screenpipe-actions/ai-proxy/src/index.tsindex 7c04ace20..312e98800 100644--- a/screenpipe-actions/ai-proxy/src/index.ts+++ b/screenpipe-actions/ai-proxy/src/index.ts@@ -66,6 +66,18 @@ async function validateSubscription(env: Env, userId: string): Promise<boolean>}}+async function verifyClerkToken(env: Env, token: string): Promise<string | null> {+ try {+ const payload = await verifyToken(token, {+ secretKey: env.CLERK_SECRET_KEY,+ });+ return payload.sub || null;+ } catch (error) {+ console.error('clerk verification failed:', error);+ return null;+ }+}+export class RateLimiter {private state: DurableObjectState;private requests: Map<string, { count: number; lastReset: number }>;@@ -195,8 +207,17 @@ export default Sentry.withSentry(});}- const userId = authHeader.split(' ')[1];- const isValid = await validateSubscription(env, userId);+ const token = authHeader.split(' ')[1];+ // First try to validate as a user ID with subscription+ let isValid = await validateSubscription(env, token);++ // If not valid, try to verify as a Clerk token+ if (!isValid) {+ const clerkUserId = await verifyClerkToken(env, token);+ if (clerkUserId) {+ isValid = await validateSubscription(env, clerkUserId);+ }+ }if (!isValid) {return new Response(JSON.stringify({ error: 'invalid subscription' }), {@@ -540,6 +561,7 @@ interface Env {NODE_ENV?: string;SUPABASE_URL: string;SUPABASE_ANON_KEY: string;+ CLERK_SECRET_KEY: string;}/*diff --git a/screenpipe-app-tauri/components/pipe-store.tsx b/screenpipe-app-tauri/components/pipe-store.tsxindex ff23f8618..1ac8852d8 100644--- a/screenpipe-app-tauri/components/pipe-store.tsx+++ b/screenpipe-app-tauri/components/pipe-store.tsx@@ -12,7 +12,7 @@ import {PurchaseHistoryItem,} from "@/lib/api/store";import { open as openUrl } from "@tauri-apps/plugin-shell";-import { BrokenPipe, InstalledPipe, PipeWithStatus } from "./pipe-store/types";+import { InstalledPipe, PipeWithStatus } from "./pipe-store/types";import { PipeDetails } from "./pipe-store/pipe-details";import { PipeCard } from "./pipe-store/pipe-card";import { AddPipeForm } from "./pipe-store/add-pipe-form";@@ -24,10 +24,7 @@ import { LoginDialog, useLoginCheck } from "./login-dialog";import { onOpenUrl } from "@tauri-apps/plugin-deep-link";import { useStatusDialog } from "@/lib/hooks/use-status-dialog";-const corePipes: string[] = [- // "data-table",- "search",-];+const corePipes: string[] = ["data-table", "search"];export const PipeStore: React.FC = () => {const { health } = useHealthCheck();@@ -69,7 +66,7 @@ export const PipeStore: React.FC = () => {is_installed: installedPipes.some((p) => p.config?.id === plugin.id),installed_config: installedPipes.find((p) => p.config?.id === plugin.id)?.config,- has_purchased: purchaseHistory.some((p) => p.plugins.id === plugin.id),+ has_purchased: purchaseHistory.some((p) => p.plugin_id === plugin.id),is_core_pipe: corePipes.includes(plugin.name),}));@@ -116,8 +113,6 @@ export const PipeStore: React.FC = () => {setPurchaseHistory(purchaseHistory);};--const handlePurchasePipe = async (pipe: PipeWithStatus,onComplete?: () => void@@ -237,6 +232,8 @@ export const PipeStore: React.FC = () => {onComplete?: () => void) => {try {+ console.log("user", settings.user);+if (!checkLogin(settings.user)) return;// Keep the pipe in its current position by updating its status@@ -729,38 +726,11 @@ export const PipeStore: React.FC = () => {description: "installing your new pipe...",});- // refresh store data first-- const pipeApi = await PipeApi.create(settings.user?.token!);- const plugins = await pipeApi.listStorePlugins();+ await new Promise((resolve) => setTimeout(resolve, 1000));- // find the pipe in the store- const pipe = plugins.find((p) => p.id === pipeId);- if (!pipe) {- console.error("pipe not found:", pipeId);- toast({- title: "error installing pipe",- description: "pipe not found in store",- variant: "destructive",- });- return;- }+ fetchPurchaseHistory();- // install the pipe- await handleInstallPipe(- {- ...pipe,- is_installed: false,- has_purchased: true,- is_core_pipe: false,- },- () => {- toast({- title: "installation complete",- description: `${pipe.name} is ready to use`,- });- }- );+ console.log("pipes", pipes);}}});diff --git a/screenpipe-app-tauri/components/recording-settings.tsx b/screenpipe-app-tauri/components/recording-settings.tsxindex 6bcb5acd0..da80fbe50 100644--- a/screenpipe-app-tauri/components/recording-settings.tsx+++ b/screenpipe-app-tauri/components/recording-settings.tsx@@ -388,8 +388,8 @@ export function RecordingSettings() {};const handleAudioTranscriptionModelChange = (value: string) => {- if (value === "screenpipe-cloud" && !credits?.amount) {- openUrl("https://buy.stripe.com/5kA6p79qefweacg5kJ");+ if (value === "screenpipe-cloud" && !settings.user?.cloud_subscribed) {+ openUrl("https://buy.stripe.com/7sIdRzbym4RA98c7sX");return;}@@ -1090,9 +1090,9 @@ export function RecordingSettings() {<span>screenpipe cloud</span><div className="flex items-center gap-2"><Badge variant="secondary">cloud</Badge>- {!credits?.amount && (+ {!settings.user?.cloud_subscribed && (<Badge variant="outline" className="text-xs">- get credits+ get screenpipe cloud</Badge>)}</div>@@ -1130,9 +1130,9 @@ export function RecordingSettings() {<span>screenpipe cloud</span><div className="flex items-center gap-2"><Badge variant="secondary">cloud</Badge>- {!credits?.amount && (+ {!settings.user?.cloud_subscribed && (<Badge variant="outline" className="text-xs">- get credits+ get screenpipe cloud</Badge>)}</div>diff --git a/screenpipe-app-tauri/components/settings/account-section.tsx b/screenpipe-app-tauri/components/settings/account-section.tsxindex 1f16dccce..222d6e1a6 100644--- a/screenpipe-app-tauri/components/settings/account-section.tsx+++ b/screenpipe-app-tauri/components/settings/account-section.tsx@@ -40,7 +40,7 @@ function PlanCard({}: {title: string;price: string;- features: string[];+ features: (string | JSX.Element)[];isActive?: boolean;isSelected?: boolean;onSelect?: () => void;@@ -84,6 +84,12 @@ export function AccountSection() {const [isConnectingStripe, setIsConnectingStripe] = useState(false);const [showApiKey, setShowApiKey] = useState(false);const [isAnnual, setIsAnnual] = useState(true);+ const [profileForm, setProfileForm] = useState({+ bio: "",+ github_username: "",+ website: "",+ contact: "",+ });useEffect(() => {const setupDeepLink = async () => {@@ -148,13 +154,41 @@ export function AccountSection() {const plans = [{- title: "subscription",- price: isAnnual ? "$200/year" : "$20/mo",- features: [- "unlimited screenpipe cloud",- "priority support",- isAnnual ? "17% discount applied" : "switch to annual for 17% off",- ],+ title: settings.user?.cloud_subscribed+ ? "your subscription"+ : "subscription",+ price: settings.user?.cloud_subscribed+ ? "active"+ : isAnnual+ ? "$200/year"+ : "$20/mo",+ features: settings.user?.cloud_subscribed+ ? [+ "unlimited screenpipe cloud",+ "priority support",+ <a+ key="portal"+ href={`https://billing.stripe.com/p/login/3cs6pT8Qbd846yc9AA?email=${encodeURIComponent(+ settings.user?.email || ""+ )}`}+ className="text-primary hover:underline cursor-pointer"+ onClick={(e) => {+ e.preventDefault();+ openUrl(+ `https://billing.stripe.com/p/login/3cs6pT8Qbd846yc9AA?email=${encodeURIComponent(+ settings.user?.email || ""+ )}`+ );+ }}+ >+ manage subscription+ </a>,+ ]+ : [+ "unlimited screenpipe cloud",+ "priority support",+ isAnnual ? "17% discount applied" : "switch to annual for 17% off",+ ],url: isAnnual? "https://buy.stripe.com/eVadRzfOCgAi5W0fZu" +`?client_reference_id=${clientRefId}`@@ -207,8 +241,6 @@ export function AccountSection() {};useEffect(() => {- console.log("document visibility state:", document.visibilityState);-const updatedUser = { ...settings.user, stripe_connected: true };updateSettings({ user: updatedUser });}, []);@@ -240,6 +272,24 @@ export function AccountSection() {}};+ useEffect(() => {+ const interval = setInterval(() => {+ loadUser(settings.user?.token!);+ }, 1000);+ return () => clearInterval(interval);+ }, [settings]);++ useEffect(() => {+ if (settings.user) {+ setProfileForm({+ bio: settings.user.bio || "",+ github_username: settings.user.github_username || "",+ website: settings.user.website || "",+ contact: settings.user.contact || "",+ });+ }+ }, []);+return (<div className="w-full space-y-6 py-4"><div className="flex items-center justify-between">@@ -290,7 +340,9 @@ export function AccountSection() {});return;}- openUrl(plan.url);+ if (!settings.user?.cloud_subscribed) {+ openUrl(plan.url);+ }}}/>))}@@ -494,18 +546,14 @@ export function AccountSection() {placeholder="tell us about yourself..."className="resize-none"rows={3}- value={settings.user?.bio || ""}+ value={profileForm.bio}disabled={!settings.user?.api_key}- onChange={(e) => {- if (settings.user) {- const updatedUser = {- ...settings.user,- bio: e.target.value,- };- updateSettings({ user: updatedUser });- updateProfile({ bio: e.target.value });- }- }}+ onChange={(e) =>+ setProfileForm((prev) => ({ ...prev, bio: e.target.value }))+ }+ autoCorrect="off"+ autoComplete="off"+ autoCapitalize="off"/></div>@@ -515,17 +563,16 @@ export function AccountSection() {id="github"placeholder="username"disabled={!settings.user?.api_key}- value={settings.user?.github_username || ""}- onChange={(e) => {- if (settings.user) {- const updatedUser = {- ...settings.user,- github_username: e.target.value,- };- updateSettings({ user: updatedUser });- updateProfile({ github_username: e.target.value });- }- }}+ value={profileForm.github_username}+ onChange={(e) =>+ setProfileForm((prev) => ({+ ...prev,+ github_username: e.target.value,+ }))+ }+ autoCorrect="off"+ autoComplete="off"+ autoCapitalize="off"/></div>@@ -535,18 +582,17 @@ export function AccountSection() {id="website"type="url"placeholder="https://..."- value={settings.user?.website || ""}+ value={profileForm.website}disabled={!settings.user?.api_key}- onChange={(e) => {- if (settings.user) {- const updatedUser = {- ...settings.user,- website: e.target.value,- };- updateSettings({ user: updatedUser });- updateProfile({ website: e.target.value });- }- }}+ onChange={(e) =>+ setProfileForm((prev) => ({+ ...prev,+ website: e.target.value,+ }))+ }+ autoCorrect="off"+ autoComplete="off"+ autoCapitalize="off"/></div>@@ -555,19 +601,46 @@ export function AccountSection() {<Inputid="contact"placeholder="discord, twitter, etc..."- value={settings.user?.contact || ""}+ value={profileForm.contact}+ disabled={!settings.user?.api_key}+ onChange={(e) =>+ setProfileForm((prev) => ({+ ...prev,+ contact: e.target.value,+ }))+ }+ autoCorrect="off"+ autoComplete="off"+ autoCapitalize="off"+ />+ </div>++ <div className="flex justify-end">+ <Button+ className="w-full"disabled={!settings.user?.api_key}- onChange={(e) => {+ onClick={async () => {+ if (!settings.user) return;++ await updateProfile(profileForm);++ // Update the main settings after successful profile updateif (settings.user) {const updatedUser = {...settings.user,- contact: e.target.value,+ ...profileForm,};updateSettings({ user: updatedUser });- updateProfile({ contact: e.target.value });}++ toast({+ title: "profile updated",+ description: "your developer profile has been saved",+ });}}- />+ >+ save changes+ </Button></div></div></div>diff --git a/screenpipe-app-tauri/lib/api/store/index.ts b/screenpipe-app-tauri/lib/api/store/index.tsindex 7452e9702..f9803980e 100644--- a/screenpipe-app-tauri/lib/api/store/index.ts+++ b/screenpipe-app-tauri/lib/api/store/index.ts@@ -35,16 +35,10 @@ export interface PurchaseHistoryItem {currency: string;stripe_payment_status: string;created_at: string;- refunded_at: null;- plugins: Plugins;-}-interface Plugins {- id: string;- name: string;- description: string;- developer_accounts: Developer_accounts;-}-interface Developer_accounts {+ refunded_at: string | null;+ plugin_id: string;+ plugin_name: string;+ plugin_description: string;developer_name: string;}diff --git a/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/screenpipe-app-tauri/lib/hooks/use-settings.tsxindex 72fa8764e..a7b725fb6 100644--- a/screenpipe-app-tauri/lib/hooks/use-settings.tsx+++ b/screenpipe-app-tauri/lib/hooks/use-settings.tsx@@ -51,6 +51,7 @@ export type User = {bio?: string;website?: string;contact?: string;+ cloud_subscribed?: boolean;};export type Settings = {@@ -353,7 +354,7 @@ export function useSettings() {(await invoke("get_env", { name: "BASE_URL_PRIVATE" })) ??"https://screenpi.pe";- const response = await fetch(`https://screenpi.pe/api/tauri`, {+ const response = await fetch(`https://screenpi.pe/api/user`, {method: "POST",headers: {"Content-Type": "application/json",@@ -366,6 +367,7 @@ export function useSettings() {}const data = await response.json();+ console.log("data", data);const userData = {api_key: settings.user.api_key,...data.user,diff --git a/screenpipe-app-tauri/src-tauri/src/sidecar.rs b/screenpipe-app-tauri/src-tauri/src/sidecar.rsindex 6e331db3a..e2f54b0f6 100644--- a/screenpipe-app-tauri/src-tauri/src/sidecar.rs+++ b/screenpipe-app-tauri/src-tauri/src/sidecar.rs@@ -38,6 +38,8 @@ pub struct User {pub clerk_id: Option<String>,#[serde(default)]pub credits: Option<UserCredits>,+ #[serde(rename = "user.cloud_subscribed", default)]+ pub cloud_subscribed: Option<bool>,}impl User {@@ -70,6 +72,9 @@ impl User {.get("user.credits.created_at").and_then(|v| v.as_str().map(String::from)),}),+ cloud_subscribed: store+ .get("user.cloud_subscribed")+ .and_then(|v| v.as_bool()),}}}@@ -389,14 +394,14 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {}// if a user with credits is provided, add the AI proxy env var api url for deepgram as env var https://ai-proxy.i-f9f.workers.dev/v1/listen- if user.credits.is_some() {+ if user.cloud_subscribed.is_some() {c = c.env("DEEPGRAM_API_URL","https://ai-proxy.i-f9f.workers.dev/v1/listen",);// Add token if screenpipe-cloud is selected and user has a token- if user.token.is_some() {- c = c.env("CUSTOM_DEEPGRAM_API_TOKEN", user.token.as_ref().unwrap());+ if user.id.is_some() {+ c = c.env("CUSTOM_DEEPGRAM_API_TOKEN", user.id.as_ref().unwrap());}}@@ -419,14 +424,14 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {}// if a user with credits is provided, add the AI proxy env var api url for deepgram as env var https://ai-proxy.i-f9f.workers.dev/v1/listen- if user.credits.is_some() {+ if user.cloud_subscribed.is_some() {c = c.env("DEEPGRAM_API_URL","https://ai-proxy.i-f9f.workers.dev/v1/listen",);// Add token if screenpipe-cloud is selected and user has a token- if user.token.is_some() {- c = c.env("CUSTOM_DEEPGRAM_API_TOKEN", user.token.as_ref().unwrap());+ if user.id.is_some() {+ c = c.env("CUSTOM_DEEPGRAM_API_TOKEN", user.id.as_ref().unwrap());}}