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
finish hello-world-computer-use basic mvp that works - need to add some onboarding / text / description next
Louis Beaumont8867c830c1fc
diff --git a/pipes/hello-world-computer-use/bun.lockb b/pipes/hello-world-computer-use/bun.lockbindex 9bbcb792a..eb7925ad0 100755Binary files a/pipes/hello-world-computer-use/bun.lockb and b/pipes/hello-world-computer-use/bun.lockb differdiff --git a/pipes/hello-world-computer-use/components/chat.tsx b/pipes/hello-world-computer-use/components/chat.tsxindex 3d5688e34..793cf2482 100644--- a/pipes/hello-world-computer-use/components/chat.tsx+++ b/pipes/hello-world-computer-use/components/chat.tsx@@ -6,10 +6,13 @@ import { convertToCoreMessages, Message, streamText } from "ai";import { useSettings } from "@/lib/hooks/use-settings";import { usePipeSettings } from "@/lib/hooks/use-pipe-settings";import { toast } from "sonner";-import { openai } from "@ai-sdk/openai";+import { createOpenAI, openai } from "@ai-sdk/openai";import { ollama } from "ollama-ai-provider";-import { pipe } from "@screenpipe/browser";+import { ElementInfo, pipe } from "@screenpipe/browser";import { z } from "zod";+import { Input } from "@/components/ui/input";+import { Button } from "@/components/ui/button";+export const Chat = () => {const [input, setInput] = useState("");const [messages, setMessages] = useState<Message[]>([]);@@ -17,6 +20,25 @@ export const Chat = () => {const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {e.preventDefault();++ // Add the user message immediately+ const userMessage = {+ id: Date.now().toString(),+ role: "user" as const,+ content: input,+ };++ setMessages((prev) => [...prev, userMessage]);+ setInput(""); // Clear input after sending++ // Create AI message placeholder+ const aiMessage = {+ id: (Date.now() + 1).toString(),+ role: "assistant" as const,+ content: "",+ };+ setMessages((prev) => [...prev, aiMessage]);+const preset = getPreset();console.log("preset", preset);@@ -38,10 +60,14 @@ export const Chat = () => {const model =preset.provider === "openai"- ? openai(preset.model)+ ? createOpenAI({+ apiKey: apiKey,+ })(preset.model): preset.provider === "native-ollama"? ollama(preset.model)- : openai(preset.model);+ : createOpenAI({+ apiKey: apiKey,+ })(preset.model);console.log("model", model);const messages = [@@ -52,10 +78,69 @@ export const Chat = () => {},];+ let currentSelectedElement: ElementInfo | null = null;+const result = streamText({model,// @ts-ignoremessages: convertToCoreMessages(messages),+ system: `You are an assistant that help the user use the operator api of screenpipe to interact with desktop computer+ If a tool returns no result or fail you should try again with different parameters.++ Make sure to understand the difference between role and id:+ - role is the role of the element (e.g. button, input, or MacOS Accessibility roles such as AXButton, AXTextField, AXCheckbox, etc.)+ - id is the id of the element (e.g. 1234567890)+++ // Some examples of how to map generic roles to MacOS Accessibility roles:+ fn map_generic_role_to_macos_roles(role: &str) -> Vec<String> {+ match role.to_lowercase().as_str() {+ "window" => vec!["AXWindow".to_string()],+ "button" => vec![+ "AXButton".to_string(),+ "AXMenuItem".to_string(),+ "AXMenuBarItem".to_string(),+ "AXStaticText".to_string(), // Some text might be clickable buttons+ "AXImage".to_string(), // Some images might be clickable buttons+ ], // Button can be any of these+ "checkbox" => vec!["AXCheckBox".to_string()],+ "menu" => vec!["AXMenu".to_string()],+ "menuitem" => vec!["AXMenuItem".to_string(), "AXMenuBarItem".to_string()], // Include both types+ "dialog" => vec!["AXSheet".to_string(), "AXDialog".to_string()], // macOS often uses Sheet or Dialog+ "text" | "textfield" | "input" | "textbox" => vec![+ "AXTextField".to_string(),+ "AXTextArea".to_string(),+ "AXText".to_string(),+ "AXComboBox".to_string(),+ "AXTextEdit".to_string(),+ "AXSearchField".to_string(),+ "AXWebArea".to_string(), // Web content might contain inputs+ "AXGroup".to_string(), // Twitter uses groups that contain editable content+ "AXGenericElement".to_string(), // Generic elements that might be inputs+ "AXURIField".to_string(), // Explicit URL field type+ "AXAddressField".to_string(), // Another common name for URL fields+ "AXStaticText".to_string(), // Static text fields+ ],+ // Add specific support for URL fields+ "url" | "urlfield" => vec![+ "AXTextField".to_string(), // URL fields are often text fields+ "AXURIField".to_string(), // Explicit URL field type+ "AXAddressField".to_string(), // Another common name for URL fields+ ],+ "list" => vec!["AXList".to_string()],+ "listitem" => vec!["AXCell".to_string()], // List items are often cells in macOS+ "combobox" => vec!["AXPopUpButton".to_string(), "AXComboBox".to_string()],+ "tab" => vec!["AXTabGroup".to_string()],+ "tabitem" => vec!["AXRadioButton".to_string()], // Tab items are sometimes radio buttons+ "toolbar" => vec!["AXToolbar".to_string()],++ _ => vec![role.to_string()], // Keep as-is for unknown roles+ }+ }++ Be as specific as possible when selecting elements by role. If a role does not work, try a different role.++ `,onChunk: (chunk) => {console.log(chunk);},@@ -63,27 +148,102 @@ export const Chat = () => {console.log(JSON.stringify(error, null, 2));},tools: {+ // click: {+ // description: "Click an element in an application",+ // parameters: z.object({+ // app: z.string().describe("The name of the application"),+ // window: z.string().optional().describe("Optional window name"),+ // text: z+ // .string()+ // .optional()+ // .describe("Text content of the element to click"),+ // role: z.string().optional().describe("Role of the element"),+ // label: z+ // .string()+ // .optional()+ // .describe("Accessibility label of the element"),+ // }),+ // execute: async ({ app, window, text, role, label }) => {+ // console.log("[tool:click] params:", {+ // app,+ // window,+ // text,+ // role,+ // label,+ // });+ // try {+ // const result = await pipe.operator.click({+ // app,+ // window,+ // role,+ // });+ // console.log("[tool:click] result:", result);+ // return `Successfully clicked element using ${result.method}`;+ // } catch (error) {+ // console.error("[tool:click] error:", error);+ // throw new Error(`Failed to click element: ${error}`);+ // }+ // },+ // },++ fill: {+ description: "Fill text in a form field",+ parameters: z.object({+ id: z.string().describe("The id of the element"),+ app: z.string().describe("The name of the application"),+ value: z.string().describe("The text to type into the field"),+ }),+ execute: async ({ id, app, value }) => {+ console.log("[tool:fill] params:", {+ id,+ app,+ value,+ });+ try {+ const success = await pipe.operator+ .fill({+ value,+ app,+ id,+ });+ // const success = await pipe.operator+ // .getById(id, { app })+ // .fill(value);+ console.log("[tool:fill] result:", success);+ return success+ ? `Successfully entered text`+ : `Failed to enter text`;+ } catch (error) {+ console.error("[tool:fill] error:", error);+ throw new Error(`Failed to fill text field: ${error}`);+ }+ },+ },++ open_application: {+ description: "Open an application",+ parameters: z.object({+ appName: z.string().describe("The name of the application to open"),+ }),+ execute: async ({ appName }) => {+ try {+ const success = await pipe.operator.openApplication(appName);+ return success+ ? `Successfully opened application '${appName}'`+ : `Failed to open application '${appName}'`;+ } catch (error) {+ throw new Error(`Failed to open application: ${error}`);+ }+ },+ },+open_url: {description: "Open a URL in a browser",parameters: z.object({url: z.string().describe("The URL to open"),- browser: z- .string()- .optional()- .describe(- "The browser to use (e.g., 'Chrome', 'Firefox'). If not specified, uses the default browser."- ),+ browser: z.string().optional().describe("The browser to use"),}),- execute: async ({- url,- browser,- }: {- url: string;- browser?: string;- }) => {- console.log(- `executing open_url: ${url}${browser ? ` in ${browser}` : ""}`- );+ execute: async ({ url, browser }) => {try {const success = await pipe.operator.openUrl(url, browser);return success@@ -92,41 +252,95 @@ export const Chat = () => {}`: `Failed to open URL '${url}'`;} catch (error) {- console.error("error in open_url:", error);throw new Error(`Failed to open URL: ${error}`);}},},++ find_by_role: {+ description:+ "Find elements with a specific role",+ parameters: z.object({+ app: z+ .string()+ .describe(+ "The application name (e.g., 'Chrome', 'Firefox', 'Arc')"+ ),+ role: z+ .string()+ .describe("The role to search for"),+ maxResults: z+ .number()+ .optional()+ .describe("Maximum number of elements to return"),+ }),+ execute: async ({ app, role, maxResults }) => {+ console.log("[tool:find_by_role] params:", {+ app,+ role,+ maxResults,+ });+ try {+ const elements = await pipe.operator+ .getByRole(role, { app })+ .all(maxResults);+ console.log("[tool:find_by_role] found elements:", elements);+ currentSelectedElement = elements[0];+ return JSON.stringify(elements);+ } catch (error) {+ console.error("[tool:find_by_role] error:", error);+ throw new Error(`Failed to find elements by role: ${error}`);+ }+ },+ },},toolCallStreaming: true,maxSteps: 5,});for await (const chunk of result.textStream) {- // setMessages((prev) => [...prev, chunk]);- console.log(chunk);+ setMessages((prev) =>+ prev.map((msg) =>+ msg.id === aiMessage.id+ ? { ...msg, content: msg.content + chunk }+ : msg+ )+ );}};return (- <>+ <div className="flex flex-col gap-4 p-4 max-w-3xl mx-auto"><AIPresetsSelector pipeName="hello-world-computer-use" />- {messages.map((message) => (- <div key={message.id}>- {message.role === "user" ? "User: " : "AI: "}- {message.content}- </div>- ))}+ <div className="flex flex-col gap-3">+ {messages.map((message) => (+ <div+ key={message.id}+ className={`p-4 rounded-lg ${+ message.role === "user"+ ? "bg-primary/10 ml-auto"+ : "bg-muted mr-auto"+ }`}+ >+ <p className="text-sm">{message.role === "user" ? "you" : "ai"}</p>+ <p className="mt-1">{message.content}</p>+ </div>+ ))}+ </div>- <form onSubmit={handleSubmit}>- <input+ <form onSubmit={handleSubmit} className="flex gap-2">+ <Inputname="prompt"value={input}onChange={(e) => setInput(e.target.value)}+ placeholder="type your message..."+ className="flex-1"/>- <button type="submit">Submit</button>+ <Button type="submit" size="sm">+ send+ </Button></form>- </>+ </div>);};diff --git a/pipes/hello-world-computer-use/package.json b/pipes/hello-world-computer-use/package.jsonindex 653e1c790..98eb28290 100644--- a/pipes/hello-world-computer-use/package.json+++ b/pipes/hello-world-computer-use/package.json@@ -29,8 +29,8 @@"@radix-ui/react-tabs": "^1.1.3","@radix-ui/react-toast": "^1.2.1","@radix-ui/react-tooltip": "^1.1.8",- "@screenpipe/browser": "^0.1.38-beta.3",- "@screenpipe/js": "^1.0.19-beta.7",+ "@screenpipe/browser": "^0.1.38-beta.7",+ "@screenpipe/js": "^1.0.19-beta.8","@types/express": "^5.0.1","@types/lodash": "^4.17.16","@types/nodemailer": "^6.4.17",diff --git a/screenpipe-js/browser-sdk/package.json b/screenpipe-js/browser-sdk/package.jsonindex 0fa2a8a64..c0680e712 100644--- a/screenpipe-js/browser-sdk/package.json+++ b/screenpipe-js/browser-sdk/package.json@@ -1,6 +1,6 @@{"name": "@screenpipe/browser",- "version": "0.1.38-beta.3",+ "version": "0.1.38-beta.7","type": "module","main": "./dist/index.cjs","module": "./dist/index.js",diff --git a/screenpipe-js/common/Operator.ts b/screenpipe-js/common/Operator.tsindex 26ef4b950..f60867711 100644--- a/screenpipe-js/common/Operator.ts+++ b/screenpipe-js/common/Operator.ts@@ -77,34 +77,33 @@ export class Operator {* role: "button"* }).all();*+ * You can also use MacOS accessibility roles (eg. "AXButton", "AXTextField", "AXCheckbox", etc.), check MacOS Accessibility App to see the list of roles+ ** @example- * // Find a specific text field by label- * const emailField = await pipe.operator.locator({- * app: "Firefox",- * label: "Email"+ * // Find a specific element by id+ * const element = await pipe.operator.locator({+ * app: "WhatsApp",+ * id: "1234"* }).first();*/locator(options: {app: string;window?: string;role?: string;- text?: string;- label?: string;- description?: string;id?: string;- index?: number;useBackgroundApps?: boolean;activateApp?: boolean;}) {+ if (options.role && options.id) {+ throw new Error(+ "only one of 'role' or 'id' can be specified. need both? dm us!"+ );+ }+const selector: ElementSelector = {app_name: options.app,window_name: options.window,- locator: options.role || "",- index: options.index,- text: options.text,- label: options.label,- description: options.description,- element_id: options.id,+ locator: options.role || (options.id ? `#${options.id}` : ""),use_background_apps: options.useBackgroundApps,activate_app: options.activateApp,};@@ -121,31 +120,21 @@ export class Operator {* // Click a button with text "Submit" and get details about how it was clicked* const result = await pipe.operator.click({* app: "Chrome",- * text: "Submit"+ * id: "1234"* });* console.log(`Click method: ${result.method}, Details: ${result.details}`);*/async click(options: {+ id: string;app: string;window?: string;- role?: string;- text?: string;- label?: string;- description?: string;- id?: string;- index?: number;useBackgroundApps?: boolean;activateApp?: boolean;}): Promise<ClickResult> {const selector: ElementSelector = {app_name: options.app,window_name: options.window,- locator: options.role || "",- index: options.index,- text: options.text,- label: options.label,- description: options.description,- element_id: options.id,+ locator: `#${options.id}`,use_background_apps: options.useBackgroundApps,activate_app: options.activateApp !== false,};@@ -215,35 +204,23 @@ export class Operator {* Find an element and type text into it** @example- * // Type "[email protected]" into the email field+ * // Type "hi darling" into the message field* await pipe.operator.fill({- * app: "Firefox",- * label: "Email",- * text: "[email protected]"+ * app: "WhatsApp",+ * id: "1234",+ * value: "hi darling"* });*/async fill(options: {app: string;- window?: string;- role?: string;- text?: string;- label?: string;- description?: string;id?: string;- index?: number;useBackgroundApps?: boolean;activateApp?: boolean;value: string;}) {const selector: ElementSelector = {app_name: options.app,- window_name: options.window,- locator: options.role || "",- index: options.index,- text: options.text,- label: options.label,- description: options.description,- element_id: options.id,+ locator: `#${options.id}`,use_background_apps: options.useBackgroundApps,activate_app: options.activateApp !== false,};@@ -282,35 +259,11 @@ export class Operator {}/**- * Get locator for an element in a specific app (by app name)- *- * @example- * // Get and click a button in Chrome- * await pipe.operator.getByAppName('Chrome').getByRole('button').click();- */- getByAppName(appName: string): ElementLocator {- return this.locator({ app: appName });- }-- /**- * Get locator for an element in a specific window+ * Get locator for elements with the specified role (eg. "button", "textfield", "checkbox", etc.)+ * You can also use MacOS accessibility roles (eg. "AXButton", "AXTextField", "AXCheckbox", etc.), check MacOS Accessibility App to see the list of roles** @example- * // Get elements in Chrome's settings window- * await pipe.operator.getByWindowName('Settings').getByText('Privacy').click();- */- getByWindowName(- windowName: string,- options?: { app?: string }- ): ElementLocator {- return this.locator({ app: options?.app || "", window: windowName });- }-- /**- * Get locator for elements with the specified role- *- * @example- * // Find all buttons in Chrome+ * // Find element(s) with role "button" in Chrome* const buttons = await pipe.operator.getByRole('button', { app: 'Chrome' });*/getByRole(@@ -324,66 +277,12 @@ export class Operator {});}- /**- * Get locator for elements with the specified text- *- * @example- * // Find and click on text in Chrome- * await pipe.operator.getByText('Submit', { app: 'Chrome' }).click();- */- getByText(- text: string,- options?: { app?: string; window?: string }- ): ElementLocator {- return this.locator({- app: options?.app || "",- window: options?.window,- text,- });- }-- /**- * Get locator for elements with the specified label- *- * @example- * // Find and fill a field with a specific label in Chrome- * await pipe.operator.getByLabel('Username', { app: 'Chrome' }).fill('john');- */- getByLabel(- label: string,- options?: { app?: string; window?: string }- ): ElementLocator {- return this.locator({- app: options?.app || "",- window: options?.window,- label,- });- }-- /**- * Get locator for elements with the specified description- *- * @example- * // Find and click an element with a specific description- * await pipe.operator.getByDescription('Settings button', { app: 'Chrome' }).click();- */- getByDescription(- description: string,- options?: { app?: string; window?: string }- ): ElementLocator {- return this.locator({- app: options?.app || "",- window: options?.window,- description,- });- }-/*** Get locator for elements with the specified id** @example- * // Find and click an element with a specific ID- * await pipe.operator.getById('submit-button', { app: 'Chrome' }).click();+ * // Find an element with a specific ID+ * await pipe.operator.getById('submit-button', { app: 'Chrome' })*/getById(id: string,@@ -392,71 +291,9 @@ export class Operator {return this.locator({app: options?.app || "",window: options?.window,- id,});}- /**- * Take a screenshot of the specified app window- *- * @example- * // Take a screenshot of the active Chrome window- * const screenshot = await pipe.operator.screenshot({- * app: "Chrome"- * });- */- async screenshot(options: {- app: string;- window?: string;- activateApp?: boolean;- }): Promise<string> {- // TODO: Implement when screenshot API is available- throw new Error("screenshot API not yet implemented");- }-- /**- * Wait for a specific element to appear- *- * @example- * // Wait for a success message to appear- * await pipe.operator.waitFor({- * app: "Chrome",- * text: "Success!",- * timeout: 5000- * });- */- async waitFor(options: {- app: string;- window?: string;- role?: string;- text?: string;- label?: string;- description?: string;- id?: string;- index?: number;- useBackgroundApps?: boolean;- timeout?: number;- }): Promise<ElementInfo | null> {- const startTime = Date.now();- const timeout = options.timeout || 30000;-- while (Date.now() - startTime < timeout) {- try {- const element = await this.locator(options).first();- if (element) {- return element;- }- } catch (error) {- // Element not found, try again- }-- // Wait before retrying- await new Promise((resolve) => setTimeout(resolve, 100));- }-- return null;- }-/*** get text on the screen*@@ -709,12 +546,7 @@ export class Operator {async pressKey(options: {app: string;window?: string;- role?: string;- text?: string;- label?: string;- description?: string;id?: string;- index?: number;useBackgroundApps?: boolean;activateApp?: boolean;key: string;@@ -722,12 +554,7 @@ export class Operator {const selector: ElementSelector = {app_name: options.app,window_name: options.window,- locator: options.role || "",- index: options.index,- text: options.text,- label: options.label,- description: options.description,- element_id: options.id,+ locator: `#${options.id}`,use_background_apps: options.useBackgroundApps,activate_app: options.activateApp !== false,};diff --git a/screenpipe-js/common/types.ts b/screenpipe-js/common/types.tsindex 032ff1bc8..d632f7267 100644--- a/screenpipe-js/common/types.ts+++ b/screenpipe-js/common/types.ts@@ -344,11 +344,6 @@ export interface ElementSelector {app_name: string;window_name?: string;locator: string;- index?: number;- text?: string;- label?: string;- description?: string;- element_id?: string;use_background_apps?: boolean;activate_app?: boolean;}@@ -375,11 +370,11 @@ export interface ElementInfo {}export interface ElementStats {- total: number,- definitely_interactable: number,- sometimes_interactable: number,- non_interactable: number,- by_role: { [key: string]: number }+ total: number;+ definitely_interactable: number;+ sometimes_interactable: number;+ non_interactable: number;+ by_role: { [key: string]: number };}export interface FindElementsRequest {diff --git a/screenpipe-js/node-sdk/package.json b/screenpipe-js/node-sdk/package.jsonindex ae79acbbe..14b7bac70 100644--- a/screenpipe-js/node-sdk/package.json+++ b/screenpipe-js/node-sdk/package.json@@ -1,6 +1,6 @@{"name": "@screenpipe/js",- "version": "1.0.19-beta.7",+ "version": "1.0.19-beta.8","type": "module","main": "./dist/index.cjs","module": "./dist/index.js",diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rsindex 4a9b21fa0..d16ba3022 100644--- a/screenpipe-server/src/server.rs+++ b/screenpipe-server/src/server.rs@@ -3104,11 +3104,6 @@ pub struct ElementSelector {app_name: String,window_name: Option<String>,locator: String,- index: Option<usize>,- text: Option<String>,- label: Option<String>,- description: Option<String>,- element_id: Option<String>,use_background_apps: Option<bool>,/// If true, the app will be activated before finding elements (this is useful to refresh the tree or clicking on elements)activate_app: Option<bool>,