ADK for TypeScript: API Reference
    Preparing search index...

    Class BaseComputerAbstract

    Defines an interface for computer environments.

    This abstract base class defines the standard interface for controlling computer environments, including web browsers and other interactive systems. Coordinates passed to the action methods are absolute pixel values, scaled to the width and height returned by screenSize.

    The optional methods (doubleClick, tripleClick, middleClick, rightClick, mouseDown, mouseUp, keyDown and keyUp) are exposed to the model only when a subclass implements them.

    The Gemini 3.x actions click, move, type, scroll, take_screenshot, press_key and hotkey are always exposed. Each one calls the subclass method of the same name (click, move, type, scroll, takeScreenshot, pressKey, hotkey) when it is defined, and otherwise calls the matching predefined method.

    "[BASE_COMPUTER_SIGNATURE_SYMBOL]": true

    A unique symbol to identify ADK base computer class.

    • Drags an element from an x, y coordinate and drops it at a destination coordinate.

      Parameters

      • x: number

        The x-coordinate to start dragging from.

      • y: number

        The y-coordinate to start dragging from.

      • destinationX: number

        The x-coordinate to drop at.

      • destinationY: number

        The y-coordinate to drop at.

      Returns Promise<ComputerState>

      The current state after drag and drop.

    • Hovers at a specific x, y coordinate on the webpage.

      May be used to explore sub-menus that appear on hover.

      Parameters

      • x: number

        The x-coordinate to hover at.

      • y: number

        The y-coordinate to hover at.

      Returns Promise<ComputerState>

      The current state after hovering.

    • Called before each tool invocation to prepare resources.

      Override this to set up session-level resources (a sandbox, tokens, and so on), using the state of toolContext for persistence across invocations.

      Parameters

      • _toolContext: Context

        The tool context with session state access.

      Returns Promise<void>

    • Types text into the currently focused element.

      By default, this calls keyCombination once per character in text (and once for "Enter" when pressEnter is true). Because keyCombination is designed for key names and typically captures a new screenshot on every call, this fallback costs one round trip and screenshot per character, and relies on the backend accepting single characters in keyCombination. Subclasses should override this method to use native bulk text input.

      Parameters

      • text: string

        The text to type.

      • pressEnter: boolean = false

        Whether to press ENTER after typing.

      Returns Promise<ComputerState>

      The current state after typing.

    • Types text at a specific x, y coordinate.

      Parameters

      • x: number

        The x-coordinate to type at.

      • y: number

        The y-coordinate to type at.

      • text: string

        The text to type.

      • OptionalpressEnter: boolean

        Whether to press ENTER after typing. The toolset passes true when the model does not say.

      • OptionalclearBeforeTyping: boolean

        Whether to clear existing content before typing. The toolset passes true when the model does not say.

      Returns Promise<ComputerState>

      The current state after typing.