bash call to a Vers VM — so the agent acts on a remote machine without knowing it.
What you’ll build
- An extension that registers
create_vm,vm_exec,vm_use,vm_local, and an overriddenbashtool - 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_KEYset in your environment sshandopensslon yourPATH
Step 1: Create the Extension
Create~/.pi/agent/extensions/my-vers.ts:
pi -e ~/.pi/agent/extensions/my-vers.ts. Pi should start with no errors.
Step 2: Add VM Creation
Add this inside themyVersExtension function:
/reload in the TUI). Ask the agent to create a VM — it calls your tool and returns a VM ID.
Step 3: Add SSH Execution
Vers VMs use SSH over TLS on port 443. Add the SSH helper and a tool:uname -a on it. You’ll see the VM’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 usevm_exec, override the built-in bash so normal commands route to the VM automatically:
- Ask the agent to create a VM
- Ask it to
vm_usethat VM - Ask it to install Node.js — it runs
apt-get install nodejsover SSH without the LLM knowing
bash as usual. Your extension decides where it runs.
Step 5: Add Status on Startup
Show the VM count in the footer when pi starts: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
API client as closure
TheversApi 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
Agent swarms tutorial
Orchestrate many agents across branched VMs — the pattern this extension makes ergonomic.
Full pi-v extension
Production version:
read/edit/write overrides, commits, branches, SCP.API reference
Every endpoint your extension can call.
Architecture
What the extension is actually talking to on the other end of the API.