Skip to main content

Simple, observable computer use - Remote desktop for AI agents

Project description

Valk: Computer Use made Simple

Valk is a Python library for empowering AI agents for computer use. This package provides a simple interface for programmatic control of mouse movements, keyboard input, and screen capture of a remote desktop environment.

Quick Start

Prequisites:

  1. Python 3.10+
  2. Docker (for running the computer server)
  3. Either:
    • Anthropic API key
    • OpenAI API key (with access to the beta computer-use-preview)

Step 1: Install the Valk library

uv add valk

Or with pip

pip install valk

Step 2: Run the Virtual Desktop

Valk uses a server component to handle interaction on remote computers. We provide a docker container of a linux desktop environent for you to easily get started.

# Pull the demo container
docker pull ghcr.io/ercbot/valk-chromium-demo:latest

# Run the demo environment (this starts a virtual display with Chromium)
docker run -p 8255:8255 -p 5900:5900 --name valk-computer ghcr.io/ercbot/valk-chromium-demo:latest

This will start:

  • Valk server on port 8255
  • VNC server on port 5900 (for optional visual debugging)

Step 3: Run the agent demo for your API provider

uv run examples/anthropic_quickstart.py

or

uv run examples/openai_quickstart.py

Step 4: Start Chatting with your agent

Once the example is running, it will open up a chat in the terminal with your agent of choice. Here are some example prompts:

  • "Go to the Anthropic website and find open roles for software engineers"
  • "Find a hotel in the marina district of San Francisco, make sure it has a waterfront view"
  • "Look for an cool photo of Yosemite National Park I can use as my desktop background"

Your agent will use the Valk infrastructure to control the browser, navigate websites, and report back what it sees.

Visual Debugging

For visual debugging and to see what your agent is doing in real-time:

  1. Use the built-in debug viewer by calling computer.start_debug_viewer(), this will start a local web page that will display the current screen and track actions being performed by the agent.
  2. Alternatively, connect to the VNC server at localhost:5900 using any VNC client, you will need to have a VNC client installed. Personally I use: https://www.tightvnc.com/

API

The Valk server provides a simple API for controlling the computer and getting information about the system.

  • GET /v1/system/info
    • Returns json body: { os_type: string, os_version: string, display_width: number, display_height: number }
  • POST /v1/action with { "action": { "type": "screenshot" } }
    • Returns json body: { data: { image: string } } (base64 encoded image)
  • POST /v1/action with { "action": { "type": "cursor_position" } }
    • Returns json body: { data: { x: number, y: number } }
  • POST /v1/action with { "action": { "type": "mouse_move", "input": { "x": number, "y": number } } }
  • POST /v1/action with { "action": { "type": "left_click" } }
  • POST /v1/action with { "action": { "type": "right_click" } }
  • POST /v1/action with { "action": { "type": "middle_click" } }
  • POST /v1/action with { "action": { "type": "double_click" } }
  • POST /v1/action with { "action": { "type": "left_click_drag", "input": { "x": number, "y": number } } }
  • POST /v1/action with { "action": { "type": "type_text", "input": { "text": string } } }
  • POST /v1/action with { "action": { "type": "key_press", "input": { "key": string } } }

You can call the API directly, or use the Valk Python library:

from valk import Computer

# Connect to a Valk server
computer = Computer("http://localhost:8255")

# Take a screenshot
screenshot = computer.screenshot()

# Get cursor position
x, y = computer.cursor_position()

# Move mouse and click
computer.move_mouse(100, 100).left_click()

# Type text
computer.type("Hello, World!")

# Press keyboard shortcuts
computer.key("ctrl+c")

License

MIT License

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

valk-0.1.0-py3-none-any.whl (91.9 kB view details)

Uploaded Python 3

File details

Details for the file valk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: valk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 91.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for valk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f55969afc2d81702a32d254c39e3f2dbe89ded6d6f79b214a775e3540913697
MD5 4b6e095f4acc3dfdbd832156cb8af7fd
BLAKE2b-256 8839524fc37e1f53913e997da2665ddfa33e0eae18be5582aa4be72d88c3ca29

See more details on using hashes here.

Provenance

The following attestation bundles were made for valk-0.1.0-py3-none-any.whl:

Publisher: release.yaml on ercbot/valk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page