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:
- Python 3.10+
- Docker (for running the computer server)
- 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:
- 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. - Alternatively, connect to the VNC server at
localhost:5900using 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 }
- Returns json body:
- POST
/v1/actionwith{ "action": { "type": "screenshot" } }- Returns json body:
{ data: { image: string } }(base64 encoded image)
- Returns json body:
- POST
/v1/actionwith{ "action": { "type": "cursor_position" } }- Returns json body:
{ data: { x: number, y: number } }
- Returns json body:
- POST
/v1/actionwith{ "action": { "type": "mouse_move", "input": { "x": number, "y": number } } } - POST
/v1/actionwith{ "action": { "type": "left_click" } } - POST
/v1/actionwith{ "action": { "type": "right_click" } } - POST
/v1/actionwith{ "action": { "type": "middle_click" } } - POST
/v1/actionwith{ "action": { "type": "double_click" } } - POST
/v1/actionwith{ "action": { "type": "left_click_drag", "input": { "x": number, "y": number } } } - POST
/v1/actionwith{ "action": { "type": "type_text", "input": { "text": string } } } - POST
/v1/actionwith{ "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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f55969afc2d81702a32d254c39e3f2dbe89ded6d6f79b214a775e3540913697
|
|
| MD5 |
4b6e095f4acc3dfdbd832156cb8af7fd
|
|
| BLAKE2b-256 |
8839524fc37e1f53913e997da2665ddfa33e0eae18be5582aa4be72d88c3ca29
|
Provenance
The following attestation bundles were made for valk-0.1.0-py3-none-any.whl:
Publisher:
release.yaml on ercbot/valk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
valk-0.1.0-py3-none-any.whl -
Subject digest:
1f55969afc2d81702a32d254c39e3f2dbe89ded6d6f79b214a775e3540913697 - Sigstore transparency entry: 183760520
- Sigstore integration time:
-
Permalink:
ercbot/valk@57bbc2453e1db54a1517d6fcaf34c95ad8ef095d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ercbot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@57bbc2453e1db54a1517d6fcaf34c95ad8ef095d -
Trigger Event:
workflow_dispatch
-
Statement type: