GeezerVison is showing adk.dev — BaseComputer | ADK for TypeScript: API Reference - v2.5.0
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.
Constructors
constructor
-
new BaseComputer(): BaseComputer
Properties
Readonly[BASE_COMPUTER_SIGNATURE_SYMBOL]
"[BASE_COMPUTER_SIGNATURE_SYMBOL]": true
A unique symbol to identify ADK base computer class.
Methods
Optionalclick
-
click?(x: number, y: number, button?: string): Promise<ComputerState>
Clicks at a specific x, y coordinate with the given mouse button.
When defined, the click action calls this instead of clickAt
and passes the model's button.
Parameters
- x: number
- y: number
Optionalbutton: string
AbstractclickAt
-
Clicks at a specific x, y coordinate on the webpage.
Parameters
- x: number
The x-coordinate to click at.
- y: number
The y-coordinate to click at.
The current state after clicking.
close
-
Cleans up the resources of the computer.
Returns Promise<void>
AbstractcurrentState
-
Returns the current state of the current webpage.
The current environment state.
OptionaldoubleClick
-
doubleClick?(x: number, y: number, button?: string): Promise<ComputerState>
Double-clicks at a specific x, y coordinate.
Parameters
- x: number
- y: number
Optionalbutton: string
AbstractdragAndDrop
-
dragAndDrop( x: number, y: number, destinationX: number, destinationY: number,): Promise<ComputerState>
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.
The current state after drag and drop.
Abstractenvironment
-
Returns the environment of the computer.
AbstractgoBack
-
Navigates back to the previous webpage in the browser history.
The current state after navigating back.
AbstractgoForward
-
Navigates forward to the next webpage in the browser history.
The current state after navigating forward.
Optionalhotkey
-
Presses a combination of keyboard keys simultaneously.
When defined, the hotkey action calls this instead of
keyCombination.
AbstracthoverAt
-
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.
The current state after hovering.
initialize
-
initialize(): Promise<void>
Initializes the computer.
Returns Promise<void>
AbstractkeyCombination
-
Presses keyboard keys and combinations, such as "control+c" or "enter".
Parameters
- keys: string[]
The keys to press in combination.
The current state after the key press.
OptionalkeyDown
-
Presses a keyboard key down and holds it.
OptionalmiddleClick
-
middleClick?(x: number, y: number, button?: string): Promise<ComputerState>
Clicks the middle mouse button at a specific x, y coordinate.
Parameters
- x: number
- y: number
Optionalbutton: string
OptionalmouseDown
-
mouseDown?(x: number, y: number, button?: string): Promise<ComputerState>
Presses a mouse button down at a specific x, y coordinate.
Parameters
- x: number
- y: number
Optionalbutton: string
OptionalmouseUp
-
mouseUp?(x: number, y: number, button?: string): Promise<ComputerState>
Releases a mouse button at a specific x, y coordinate.
Parameters
- x: number
- y: number
Optionalbutton: string
Optionalmove
-
Moves the cursor to a specific x, y coordinate.
When defined, the move action calls this instead of hoverAt.
Abstractnavigate
-
Navigates directly to a specified URL.
The current state after navigation.
AbstractopenWebBrowser
-
The current state after opening the browser.
prepare
-
prepare(_toolContext: Context): Promise<void>
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>
OptionalpressKey
-
Presses a single keyboard key.
When defined, the press_key action calls this instead of
keyCombination.
OptionalrightClick
-
rightClick?(x: number, y: number, button?: string): Promise<ComputerState>
Clicks the right mouse button at a specific x, y coordinate.
Parameters
- x: number
- y: number
Optionalbutton: string
AbstractscreenSize
-
screenSize(): Promise<[number, number]>
Returns the screen size of the environment.
Returns Promise<[number, number]>A tuple of (width, height) in pixels.
Optionalscroll
-
Scrolls at a specific x, y coordinate by a number of pixels.
When defined, the scroll action calls this instead of scrollAt.
magnitudeInPixels is undefined when the model does not say.
Parameters
- x: number
- y: number
- direction: ScrollDirection
OptionalmagnitudeInPixels: number
AbstractscrollAt
-
Scrolls up, down, right, or left at an x, y coordinate by magnitude.
Parameters
- x: number
The x-coordinate to scroll at.
- y: number
The y-coordinate to scroll at.
- direction: ScrollDirection
- magnitude: number
The current state after scrolling.
AbstractscrollDocument
-
Scrolls the entire webpage up, down, left or right.
The current state after scrolling.
Abstractsearch
-
Directly jumps to a search engine home page.
Used when you need to start with a search, for example because the current
website doesn't have the information needed or a new task is being
started.
The current state after navigating to search.
OptionaltakeScreenshot
-
Takes a screenshot of the current state.
When defined, the take_screenshot action calls this instead of
currentState.
OptionaltripleClick
-
tripleClick?(x: number, y: number, button?: string): Promise<ComputerState>
Triple-clicks at a specific x, y coordinate.
Parameters
- x: number
- y: number
Optionalbutton: string
Optionaltype
-
type?(text: string, pressEnter?: boolean): Promise<ComputerState>
Types text into the currently focused element.
When defined, the type action calls this instead of typeText.
pressEnter is undefined when the model does not say.
Parameters
- text: string
OptionalpressEnter: boolean
typeText
-
typeText(text: string, pressEnter?: boolean): Promise<ComputerState>
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
- pressEnter: boolean = false
Whether to press ENTER after typing.
The current state after typing.
AbstracttypeTextAt
-
typeTextAt( x: number, y: number, text: string, pressEnter?: boolean, clearBeforeTyping?: boolean,): Promise<ComputerState>
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
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.
The current state after typing.
Abstractwait
-
Waits for n seconds to allow unfinished webpage processes to complete.
Parameters
- seconds: number
The number of seconds to wait.
The current state after waiting.
Constructors
Properties
Methods
|