Skip to content

API Reference parrot_tools.computer.toolkit

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.computer.toolkit

View source

ComputerInteractionToolkit — AbstractToolkit subclass for computer-use actions.

Exposes 13 predefined computer-use actions, screenshot/recording capabilities, and task/loop execution as agent-callable tools. Handles coordinate normalization (0-1000 → viewport pixels) and delegates all browser operations to AsyncComputerBackend.

Alias AsyncComputerBackend

Re-exported from parrot_tools.computer.backend.AsyncComputerBackend.

Class ComputerInteractionToolkit

AbstractToolkit for vision-based browser automation via computer-use.

Exposes all 13 Gemini computer-use predefined actions plus screenshot, recording, tracing, HAR, PDF, and task/loop execution as LLM-callable tools. Actions accept 0-1000 normalized coordinates and denormalize them to viewport pixels internally.

The browser is lazily started on the first tool call via _pre_execute.

Parameter Type Default Description
viewport tuple[int, int] (1280, 720) Browser viewport as (width, height) in pixels.
headless bool True Whether to run the browser in headless mode.
browser_type str 'chromium' Playwright browser engine.
initial_url str 'https://www.google.com' URL to open when the browser first starts.
search_engine_url str 'https://www.google.com' URL navigated to by the computer_search action.
**kwargs Any {} Forwarded to AbstractToolkit.

Attributes:

Attribute Type Description
tool_prefix str

Method ComputerInteractionToolkit.click_at

Click at normalized coordinates (x, y) on the page.

Coordinates are 0-1000 normalized (model output convention). They are automatically converted to viewport pixels before clicking.

click_at(x: int, y: int) -> dict

Parameter Type Default Description
x int Normalized horizontal coordinate (0–1000).
y int Normalized vertical coordinate (0–1000).

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.hover_at

Move the mouse to normalized coordinates (x, y) without clicking.

hover_at(x: int, y: int) -> dict

Parameter Type Default Description
x int Normalized horizontal coordinate (0–1000).
y int Normalized vertical coordinate (0–1000).

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.type_text

Type text into the currently focused element without clicking first.

type_text(text: str, press_enter: bool = False) -> dict

Parameter Type Default Description
text str Text to type.
press_enter bool False If True, presses Enter after typing.

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.type_text_at

Click at (x, y) and type text into the element.

type_text_at(x: int, y: int, text: str, press_enter: bool = False, clear_before_typing: bool = True) -> dict

Parameter Type Default Description
x int Normalized horizontal coordinate (0–1000).
y int Normalized vertical coordinate (0–1000).
text str Text to type.
press_enter bool False If True, presses Enter after typing.
clear_before_typing bool True If True, selects existing content before typing.

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.scroll_document

Scroll the entire document up or down.

scroll_document(direction: str) -> dict

Parameter Type Default Description
direction str "up" or "down".

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.scroll_at

Scroll at a specific position on the page.

scroll_at(x: int, y: int, direction: str, magnitude: int = 800) -> dict

Parameter Type Default Description
x int Normalized horizontal coordinate (0–1000).
y int Normalized vertical coordinate (0–1000).
direction str "up" or "down".
magnitude int 800 Scroll distance in pixels (before denormalization).

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.wait

Wait for a number of seconds without interacting with the page.

wait(seconds: int = 5) -> dict

Parameter Type Default Description
seconds int 5 Number of seconds to wait.

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.go_back

Navigate to the previous page in the browser history.

go_back() -> dict

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.go_forward

Navigate to the next page in the browser history.

go_forward() -> dict

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.search

Navigate to the configured search engine URL.

search() -> dict

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.navigate

Navigate to an absolute URL.

navigate(url: str) -> dict

Parameter Type Default Description
url str Fully qualified URL to navigate to (e.g. "https://example.com").

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.key_combination

Press a key combination.

Keys are provided as a comma-separated string (e.g. "control,c" or "shift,tab"). Each key name is normalized to Playwright format.

key_combination(keys: str) -> dict

Parameter Type Default Description
keys str Comma-separated list of key names.

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.drag_and_drop

Drag from (x, y) to (destination_x, destination_y).

All coordinates are 0-1000 normalized.

drag_and_drop(x: int, y: int, destination_x: int, destination_y: int) -> dict

Parameter Type Default Description
x int Source normalized horizontal coordinate.
y int Source normalized vertical coordinate.
destination_x int Destination normalized horizontal coordinate.
destination_y int Destination normalized vertical coordinate.

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.open_browser

Navigate to the initial URL (open a fresh browser session).

open_browser() -> dict

Returns: dict — Dict with url and screenshot_taken.

Method ComputerInteractionToolkit.screenshot

Capture a screenshot of the current viewport.

screenshot(full_page: bool = False) -> dict

Parameter Type Default Description
full_page bool False If True, captures the entire scrollable page.

Returns: dict — Dict with screenshot_bytes and url.

Method ComputerInteractionToolkit.screenshot_element

Capture a screenshot of a specific element.

screenshot_element(selector: str) -> dict

Parameter Type Default Description
selector str CSS selector identifying the element to screenshot.

Returns: dict — Dict with screenshot_bytes and selector.

Method ComputerInteractionToolkit.start_recording

Start video recording of the browser session.

start_recording(output_dir: str = './recordings') -> dict

Parameter Type Default Description
output_dir str './recordings' Directory where the recorded video will be saved.

Returns: dict — Dict confirming recording has started.

Method ComputerInteractionToolkit.stop_recording

Stop video recording and return the path to the video file.

stop_recording() -> dict

Returns: dict — Dict with video_path (or None if no video was recorded).

Method ComputerInteractionToolkit.start_tracing

Start Playwright tracing (includes screenshots and DOM snapshots).

start_tracing(screenshots: bool = True) -> dict

Parameter Type Default Description
screenshots bool True Whether to include screenshots in the trace.

Returns: dict — Dict confirming tracing has started.

Method ComputerInteractionToolkit.stop_tracing

Stop tracing and save the trace archive to the given path.

stop_tracing(output_path: str) -> dict

Parameter Type Default Description
output_path str File path for the trace archive (.zip).

Returns: dict — Dict with output_path.

Method ComputerInteractionToolkit.record_har

Begin recording a HAR (HTTP Archive) of all network requests.

record_har(output_path: str) -> dict

Parameter Type Default Description
output_path str File path for the HAR file.

Returns: dict — Dict confirming HAR recording has started.

Method ComputerInteractionToolkit.save_pdf

Export the current page as a PDF.

save_pdf(output_path: str) -> dict

Parameter Type Default Description
output_path str File path where the PDF will be saved.

Returns: dict — Dict with output_path.

Method ComputerInteractionToolkit.define_task

Define a reusable task consisting of natural-language steps.

Tasks can be referenced by name in run_task and run_loop.

define_task(name: str, description: str, steps: list[str]) -> dict

Parameter Type Default Description
name str Unique name for the task.
description str Human-readable description of the task's purpose.
steps list[str] Ordered list of natural-language instructions.

Returns: dict — Dict confirming the task was created.

Method ComputerInteractionToolkit.run_task

Return a structured plan of steps for the agent to execute.

This is a planning tool — the returned steps are intended to be actioned by the agent via individual computer_* tool calls (click_at, type_text_at, navigate, etc.). run_task does NOT directly perform the steps itself.

run_task(task: str, params: Optional[dict] = None) -> dict

Parameter Type Default Description
task str Name of the task to plan (must be defined via define_task).
params Optional[dict] None Optional parameters to substitute into step instructions (currently passed through but not applied to step text).

Returns: dict — Dict with task_name, success, steps, url, and screenshots.

Method ComputerInteractionToolkit.run_loop

Execute a task repeatedly in a loop.

Supports three loop modes:

  • Count-based: pass iterations=N to run exactly N times.
  • Condition-based: pass until="condition string" — the loop stops when the natural-language condition is considered met (relies on external model evaluation; falls back to max_iterations safety cap).
  • Data-driven: pass params_list=[{...}, {...}] — one iteration per param set.

The loop always respects max_iterations as a safety cap.

run_loop(task: str, iterations: Optional[int] = None, until: Optional[str] = None, params_list: Optional[list[dict]] = None, max_iterations: int = 100, collect_results: bool = True) -> dict

Parameter Type Default Description
task str Name of the task to loop.
iterations Optional[int] None Fixed number of iterations (count-based mode).
until Optional[str] None Natural-language stop condition (condition-based mode).
params_list Optional[list[dict]] None List of param dicts; one iteration per entry (data-driven mode).
max_iterations int 100 Hard cap on iterations regardless of mode.
collect_results bool True If True, collect per-iteration results.

Returns: dict — Dict with task_name, iterations_completed, stop_reason, results (if collect_results), and errors.

Method ComputerInteractionToolkit.abort_loop

Abort a currently running loop.

Sets an internal flag that is checked between iterations.

abort_loop() -> dict

Returns: dict — Dict confirming the abort signal was set.

Alias ComputerTask

Re-exported from parrot_tools.computer.models.ComputerTask.

Alias EnvState

Re-exported from parrot_tools.computer.models.EnvState.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally