export type Environment = 'mac' | 'windows' | 'ubuntu' | 'browser'; export type Button = 'left' | 'right' | 'wheel' | 'back' | 'forward'; import { Expand, SnakeToCamelCase } from './types/helpers'; import type { ComputerAction } from './types/protocol'; type Promisable = T | Promise; /** * Interface to implement for a computer environment to be used by the agent. */ interface ComputerBase { environment: Environment; dimensions: [number, number]; screenshot(): Promisable; click(x: number, y: number, button: Button): Promisable; doubleClick(x: number, y: number): Promisable; scroll( x: number, y: number, scrollX: number, scrollY: number, ): Promisable; type(text: string): Promisable; wait(): Promisable; move(x: number, y: number): Promisable; keypress(keys: string[]): Promisable; drag(path: [number, number][]): Promisable; } // This turns every snake_case string in the ComputerAction['type'] into a camelCase string type ActionNames = SnakeToCamelCase; /** * Interface representing a fully implemented computer environment. * Combines the base operations with a constraint that no extra * action names beyond those in `ComputerAction` are present. */ export type Computer = Expand< ComputerBase & Record, never> >;