Skip to main content
Build a pi extension that gives the agent computer-management tools and transparently routes every bash call to a Vers computer — so the agent acts on a remote machine without knowing it.
This direct API example uses retained v1 wire names such as /vm, vm_id, and vm_exec. Those are protocol and example identifiers; the product resource is called a computer.

What you’ll build

  • An extension that registers create_vm, vm_exec, vm_use, vm_local, and an overridden bash tool
  • A transparent routing pattern that generalizes to containers, cloud VMs, SSH hosts, or any remote execution target
  • Time: ~20 minutes — mostly reading, ~80 lines to write

Prerequisites

  • pi coding agent installed
  • Vers account with VERS_API_KEY set in your environment
  • ssh and openssl on your PATH

Step 1: Create the Extension

Create ~/.pi/agent/extensions/my-vers.ts:
Test it loads: run pi -e ~/.pi/agent/extensions/my-vers.ts. Pi should start with no errors.

Step 2: Add Computer Creation

Add this inside the myVersExtension function:
Reload pi (/reload in the TUI). Ask the agent to create a computer — it calls your tool and returns a computer ID.

Step 3: Add SSH Execution

Vers computers use SSH over TLS on port 443. Add the SSH helper and a tool:
Reload. Ask the agent to create a computer then run uname -a on it. You’ll see the computer’s kernel info.
The SSH connection uses openssl s_client as a ProxyCommand to tunnel through TLS on port 443. This is how Vers exposes SSH without opening additional ports.

Step 4: Override bash for Transparent Routing

This is the key pattern. Instead of making the LLM use vm_exec, override the built-in bash so normal commands route to the computer automatically:
Reload. Now:
  1. Ask the agent to create a computer
  2. Ask it to vm_use that computer
  3. Ask it to install Node.js — it runs apt-get install nodejs over SSH without the LLM knowing
The LLM calls bash as usual. Your extension decides where it runs.

Step 5: Add Status on Startup

Show the computer count in the footer when pi starts:
Reload. You’ll see “vers: N computer(s)” in the footer.

The Complete Extension

The full file is ~80 lines of logic. Copy it from the assembled steps above, or see the production version with all four tool overrides (bash, read, edit, write) plus branching, commits, and SCP at hdresearch/pi-v.

Key Patterns

Tool override routing

The LLM doesn’t need to know about routing. It calls the same tools regardless. This pattern works for any remote execution target — containers, cloud VMs, SSH hosts.

API client as closure

The versApi function, activeVmId state, and SSH helpers all live in the extension’s closure. Multiple tools share them. No global state, no classes — just functions and variables scoped to the extension.

Status feedback

ctx.ui.setStatus shows persistent info in the footer. ctx.ui.setWidget shows multi-line info above the editor. Use these to keep the user informed without interrupting the agent.

What’s next

Vers CLI

The supported command-line surface for remote computers.

Full pi-v extension

Production version: read/edit/write overrides, commits, branches, SCP.

Shell authentication

Create an API key through the terminal-oriented authentication flow.

Vers overview

The product model behind the API.