/** * Computer Use Integration * * Provides interfaces for computer use capabilities (browser/desktop control). * By default, tools are safe no-ops that require explicit implementation. */ export interface ComputerUseConfig { /** Enable browser control */ browser?: boolean; /** Enable desktop control */ desktop?: boolean; /** Require human approval for actions (default: true) */ requireApproval?: boolean; /** Screenshot directory */ screenshotDir?: string; /** Action timeout in ms (default: 30000) */ timeout?: number; /** Custom tool implementations */ tools?: Partial; } export interface ComputerUseTools { /** Take a screenshot */ screenshot: () => Promise; /** Click at coordinates */ click: (x: number, y: number, button?: 'left' | 'right' | 'middle') => Promise; /** Double click at coordinates */ doubleClick: (x: number, y: number) => Promise; /** Type text */ type: (text: string) => Promise; /** Press a key or key combination */ key: (key: string) => Promise; /** Move mouse to coordinates */ moveMouse: (x: number, y: number) => Promise; /** Scroll */ scroll: (direction: 'up' | 'down' | 'left' | 'right', amount?: number) => Promise; /** Get screen size */ getScreenSize: () => Promise<{ width: number; height: number; }>; /** Wait for a duration */ wait: (ms: number) => Promise; /** Execute a shell command (with approval) */ execute: (command: string) => Promise; } export interface ScreenshotResult { /** Base64-encoded image */ base64: string; /** Image width */ width: number; /** Image height */ height: number; /** File path if saved */ path?: string; } export interface ComputerAction { type: 'screenshot' | 'click' | 'doubleClick' | 'type' | 'key' | 'moveMouse' | 'scroll' | 'wait' | 'execute'; params?: any; requiresApproval?: boolean; } /** * Create a Computer Use agent with safe defaults. * * @example Basic usage (safe mode - no-op tools) * ```typescript * import { createComputerUse } from 'praisonai/integrations/computer-use'; * * const computer = createComputerUse({ * requireApproval: true * }); * * // Get tools for use with an agent * const tools = computer.getTools(); * ``` * * @example With Playwright browser control * ```typescript * import { chromium } from 'playwright'; * import { createComputerUse } from 'praisonai/integrations/computer-use'; * * const browser = await chromium.launch(); * const page = await browser.newPage(); * * const computer = createComputerUse({ * browser: true, * tools: { * screenshot: async () => { * const buffer = await page.screenshot(); * return { * base64: buffer.toString('base64'), * width: 1920, * height: 1080 * }; * }, * click: async (x, y) => { * await page.mouse.click(x, y); * }, * type: async (text) => { * await page.keyboard.type(text); * } * } * }); * ``` */ export declare function createComputerUse(config?: ComputerUseConfig): ComputerUseClient; export declare class ComputerUseClient { private config; private tools; private approvalCallback?; constructor(config?: ComputerUseConfig); /** * Set the approval callback for actions. */ onApproval(callback: (action: ComputerAction) => Promise): this; /** * No-op screenshot implementation. */ private noOpScreenshot; /** * No-op action implementation. */ private noOpAction; /** * No-op execute implementation. */ private noOpExecute; /** * Request approval for an action. */ private requestApproval; /** * Take a screenshot. */ screenshot(): Promise; /** * Click at coordinates. */ click(x: number, y: number, button?: 'left' | 'right' | 'middle'): Promise; /** * Type text. */ type(text: string): Promise; /** * Press a key. */ key(key: string): Promise; /** * Execute a command. */ execute(command: string): Promise; /** * Get tools for use with an agent. */ getTools(): Record; } /** * Create a simple approval prompt for CLI usage. */ export declare function createCLIApprovalPrompt(): (action: ComputerAction) => Promise; /** * Create a Computer Use agent with human-in-the-loop approval. * * @example * ```typescript * import { Agent } from 'praisonai'; * import { createComputerUseAgent } from 'praisonai/integrations/computer-use'; * * const agent = await createComputerUseAgent({ * instructions: 'You can control the computer to help the user', * approvalMode: 'cli' // or 'auto' for no approval * }); * * await agent.chat('Open a browser and search for AI news'); * ``` */ export declare function createComputerUseAgent(options: { instructions?: string; model?: string; approvalMode?: 'cli' | 'auto' | 'custom'; onApproval?: (action: ComputerAction) => Promise; tools?: Partial; }): Promise;