dsh-pve-vm 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,40 @@
1
+ # Changelog
2
+
3
+ All notable changes to this plugin are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versions follow [SemVer](https://semver.org/).
5
+
6
+ ## [0.1.0] — 2026-10-13
7
+
8
+ Initial public release.
9
+
10
+ ### Added
11
+
12
+ * **Console (VNC/RFB) tools** — `console_shot`, `console_move`, `console_click`, `console_drag`,
13
+ `console_scroll`, `console_type`, `console_key`, `console_paste`, `console_batch`,
14
+ `console_clipboard`, `console_release`. Frames come back as inline images with an attachment
15
+ reference; `region` and `scale` cut the cost of large desktops.
16
+ * **Guest agent tools** — `vm_exec`, `vm_file_read`, `vm_file_write`, `vm_type_text`, `vm_status`
17
+ through `qm guest exec` / `qm guest cmd`.
18
+ * **Transport** — a single ssh session to the Proxmox node; `qm vncproxy` bridges the VM's unix
19
+ VNC socket to the plugin's stdin/stdout, so no port, TLS or websocket is involved. The VNC
20
+ password travels as `LC_PVE_TICKET` via `SendEnv`, never in `argv`.
21
+ * **Reliable typing** — uppercase through Caps Lock (`qm monitor` → HMP `sendkey`), shifted
22
+ symbols through RFB keysyms with a settle delay; `inputChannel` selects `auto`, `hmp` or `vnc`.
23
+ * **Unicode text** — on Windows, a scheduled task running in the logged-in user session uses
24
+ `SendKeys`; on Linux guests, `xdotool` (X11) or `wtype` (Wayland) inside the active session.
25
+ * **Clipboard** — `console_paste` writes UTF-8 text into the guest clipboard over RFB
26
+ `ClientCutText`; `console_clipboard` reads it back through the extended VNC clipboard
27
+ (`VNC_ENCODING_CLIPBOARD_EXT`).
28
+ * **Settings card** — a client-side `settings.section` card (15 fields, English and Russian
29
+ labels) backed by `configForms`, writing to the profile patch layer.
30
+ * **Checks** — `tools/check-plugin.mjs` (schemas, tool set, layout contract) and
31
+ `tools/check-client.mjs` (browser bundle format), plus standalone probes
32
+ (`probe-rfb.mjs`, `live-test.mjs`, `clipboard-test.mjs`, `clipboard-read-test.mjs`).
33
+
34
+ ### Known limitations
35
+
36
+ * Proxmox VE only (`qm` CLI on the node); LXC containers are not supported.
37
+ * The node's `sshd` must accept `AcceptEnv LC_*`, otherwise the VNC password never reaches `qm`.
38
+ * Clipboard exchange needs `vga: <type>,clipboard=vnc` on the VM plus a SPICE agent in the guest,
39
+ and applies only after a full VM stop/start.
40
+ * Unicode typing in a Windows guest needs a logged-in interactive session.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Anton Veselov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,247 @@
1
- # Temporary Holding Version
1
+ # dsh-pve-vm
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Proxmox VE VM control for [DeepSeek Harness](https://github.com/deepseek-harness/deepseek-harness): see a VM's screen and click in its console over VNC, plus commands, files and typed text through the QEMU guest agent.**
4
+
5
+ Almost every computer-use plugin drives the desktop the agent itself runs on — and therefore needs
6
+ X11 or Wayland, a screenshot tool and an input injector on that host. This plugin does something
7
+ different: it drives **the console of a virtual machine on a Proxmox VE node**, over one ssh
8
+ connection. The host can be a headless server, a Wayland desktop or a laptop in another country;
9
+ the guest can be Windows, Linux with any GUI, or a machine that has not booted yet.
10
+
11
+ ```
12
+ agent ──► plugin ──► ssh ──► node: qm vncproxy ──► unix socket /var/run/qemu-server/<vmid>.vnc
13
+ └────► node: qm guest exec ──► qemu-guest-agent inside the VM
14
+ ```
15
+
16
+ ## What you get
17
+
18
+ * **Pixels** — `console_shot` returns the VM screen as an inline image (with `region` and `scale`
19
+ to keep the token cost sane), and mouse/keyboard tools operate in VM screen coordinates: move,
20
+ click, double click, drag, wheel, type, key combinations, and a batch runner that performs a
21
+ chain of actions and returns a single frame at the end.
22
+ * **Commands** — `vm_exec`, `vm_file_read`, `vm_file_write`, `vm_status` through the QEMU guest
23
+ agent. Deterministic and cheap: use pixels only where a GUI really is in the way.
24
+ * **Reliable input** — uppercase goes through Caps Lock (`qm monitor` → HMP `sendkey`), shifted
25
+ symbols through RFB keysyms with a settle delay. This is what makes typing a password on the
26
+ Windows login screen work instead of producing `xxXX` → `xxxX`.
27
+ * **Unicode text** — a Windows guest gets a scheduled task in the logged-in user's session
28
+ (`SendKeys`), a Linux guest gets `xdotool`/`wtype` through the guest agent. Layout and
29
+ modifiers stop mattering.
30
+ * **Clipboard** — `console_paste` writes UTF-8 text into the guest clipboard over RFB and presses
31
+ Ctrl+V; `console_clipboard` reads the guest clipboard back, so text can leave the VM without OCR.
32
+ * **A settings card** in the web UI (English and Russian labels), backed by the profile patch layer.
33
+ * **Zero runtime dependencies** — RFB, DES authentication, keysym tables and PNG encoding are
34
+ implemented in this package on top of `node:crypto` and `node:zlib`. There is nothing to install
35
+ on the host, and nothing to install on the node either.
36
+
37
+ Verified against `pve-manager 8.4.21` with Windows 11 / Windows Server 2025 and Linux guests, on
38
+ DeepSeek Harness `0.2.0-rc.2`.
39
+
40
+ ## Requirements
41
+
42
+ | What | Why |
43
+ |---|---|
44
+ | DeepSeek Harness **≥ 0.2.0-rc.2** | The plugin uses the 0.2.x plugin contract (`defineTool`, `ctx.tools`, `ctx.subprocess`, `ctx.attachments`, the `computerUse` slot, client-side `configForms`). It does not load on 0.1.x. |
45
+ | Node.js **≥ 22** | The harness runtime. |
46
+ | A **Proxmox VE** node with the `qm` CLI | `/usr/sbin/qm vncproxy`, `qm guest exec`, `qm monitor`. Containers (LXC) are not supported. |
47
+ | **SSH access to that node as `root`** (or an account that may run `qm`) | `qm` needs root on the node. Key-based access is expected (`BatchMode`, no password prompts). |
48
+ | **`AcceptEnv LC_*` in the node's `sshd_config`** | The VNC password is handed to `qm` as the `LC_PVE_TICKET` environment variable via `SendEnv`, so it never appears in `ps`. Without `AcceptEnv`, ssh silently drops it and the console cannot authenticate. |
49
+ | Host key already accepted | Connections run with `BatchMode=yes`; an unknown host key fails. Run `ssh <node>` once by hand, or add `StrictHostKeyChecking=accept-new` to `sshExtraOptions`. |
50
+ | `qemu-guest-agent` **inside the guest** (optional) | Only the `vm_*` tools need it. Console tools work without any agent at all. |
51
+
52
+ ## Install
53
+
54
+ ```bash
55
+ # 1. Add the bundle
56
+ dsh plugin --profile web add github:taxah92/dsh-pve-vm
57
+
58
+ # 2. Make sure the bundle is enabled in the profile: dsh.profile.bundles must list "dsh-pve-vm"
59
+ # (the plugin manager / market toggle does the same thing)
60
+
61
+ # 3. Restart the harness: the host half of a plugin is loaded once per process
62
+ ```
63
+
64
+ The plugin adds one row to the profile patch layer:
65
+
66
+ ```yaml
67
+ - id: pve-vm
68
+ name: dsh-pve-vm
69
+ ```
70
+
71
+ The row id `pve-vm` **is** the settings namespace — do not rename it, or the settings card and the
72
+ patch layer will stop finding each other.
73
+
74
+ ## Configure
75
+
76
+ Settings ▸ Plugins ▸ **Proxmox VE** in the web UI. Everything is written into the profile patch
77
+ layer, and the same values can be edited there by hand:
78
+
79
+ ```yaml
80
+ - id: pve-vm
81
+ name: dsh-pve-vm
82
+ config:
83
+ sshHost: proxmox # alias from ~/.ssh/config, or an address
84
+ sshUser: root
85
+ sshPort: 22
86
+ sshKeyPath: '' # empty — default keys
87
+ sshConfigFile: '' # like `ssh -F`
88
+ sshExtraOptions: [] # extra -o options, one per item
89
+ allowVmids: [100, 101] # VMs the plugin may touch; empty list forbids everything
90
+ enableConsole: true
91
+ enableGuest: true
92
+ inputChannel: auto # auto | hmp | vnc
93
+ sendkeyDelayMs: 80
94
+ consoleTimeoutMs: 20000
95
+ sessionIdleMs: 300000
96
+ guestTimeoutMs: 60000
97
+ guestTypeCommand: '' # script for typing non-ASCII text into a Linux guest
98
+ ```
99
+
100
+ **First run checklist**
101
+
102
+ 1. `allowVmids` is empty by default — **nothing is allowed until you list a VM id**. This is the
103
+ only gate the plugin has.
104
+ 2. `ssh <alias> 'qm status <vmid>'` should work from the host without a password prompt.
105
+ 3. `ssh <alias> sshd -T | grep -i acceptenv` must include `LC_*` (see Requirements).
106
+ 4. Call `vm_status` — it reports whether the VM is allowed, whether the guest agent answers, which
107
+ guest OS was detected, and whether a console session is open.
108
+
109
+ ## Tools
110
+
111
+ ### Console (VNC)
112
+
113
+ | Tool | Parameters | What it does |
114
+ |---|---|---|
115
+ | `console_shot` | `vmid`, `region?`, `scale?`, `drawCursor?`, `wake?` | Frame as an inline image. `scale` 1 / 0.5 / 0.25, `region` in VM pixels. Nearly uniform frames are flagged as `blank` (a blanked display or a locked screen). |
116
+ | `console_move` | `vmid`, `x`, `y`, `observe?`, `wake?`, `settleMs?`, `scale?`, `region?` | Move the pointer. |
117
+ | `console_click` | `vmid`, `x`, `y`, `button?`, `count?`, `observe?`, … | Click (2 = double click); returns a frame by default. |
118
+ | `console_drag` | `vmid`, `fromX`, `fromY`, `toX`, `toY`, `button?`, … | Drag — move a window, select a region. |
119
+ | `console_scroll` | `vmid`, `x`, `y`, `delta`, … | Wheel: positive scrolls up, negative down. |
120
+ | `console_type` | `vmid`, `text`, … | Printable ASCII only, `\n` presses Enter. Capitals go through Caps Lock, so expect ≈0.1 s per character. |
121
+ | `console_key` | `vmid`, `combo`, … | `enter`, `esc`, `tab`, `ctrl+alt+del`, `win+r`, `alt+f4`, `ctrl+shift+esc`, `f5`, and modifier-only combinations such as `alt+shift` (layout switch). |
122
+ | `console_paste` | `vmid`, `text`, `submit?`, … | Put any Unicode text into the guest clipboard and press Ctrl+V. Needs the clipboard-enabled VGA device and a SPICE agent. |
123
+ | `console_batch` | `vmid`, `actions[]`, `observe?`, … | A chain of actions (`move`, `click`, `drag`, `scroll`, `type`, `key`, `wait`) and one frame at the end. |
124
+ | `console_clipboard` | `vmid`, `timeoutMs?` | Read the guest text clipboard (extended VNC clipboard). Empty means "no text". |
125
+ | `console_release` | `vmid` | Close the console session (emergency brake: releases the ssh child and the QEMU connection). |
126
+
127
+ Every action tool accepts a common tail: `observe` (return a frame after the action, default true),
128
+ `wake` (Shift + pointer jitter to wake a blanked display), `settleMs`, `scale`, `region`.
129
+
130
+ ### Guest agent
131
+
132
+ | Tool | Parameters | What it does |
133
+ |---|---|---|
134
+ | `vm_exec` | `vmid`, `command` \| `argv`, `shell?`, `timeoutMs?` | Run a command in the guest (`cmd`/PowerShell on Windows, shell on Linux). Runs as root/SYSTEM and does not see the user's graphical session. |
135
+ | `vm_file_read` | `vmid`, `path`, `maxBytes?`, `encoding?` | Read a file (text, or base64 for binary) through the agent. |
136
+ | `vm_file_write` | `vmid`, `path`, `data` \| `dataBase64` | Write a file (up to 1 MB per call); parent directories are created. |
137
+ | `vm_type_text` | `vmid`, `text`, `settleMs?`, `observe?` | Type text through the best available channel: ASCII → console, non-ASCII → the user session on Windows / `xdotool`–`wtype` on Linux. |
138
+ | `vm_status` | `vmid?` | Is the VM allowed, does the agent answer, which OS, are there open console sessions. |
139
+
140
+ ## How it works
141
+
142
+ * **Transport.** A VM has no TCP VNC port: QEMU listens on the unix socket
143
+ `/var/run/qemu-server/<vmid>.vnc`, and `qm vncproxy` bridges it to its own stdin/stdout. The
144
+ plugin therefore speaks RFB *through an ssh child process* — no ports, no TLS, no websocket, and
145
+ the VNC password never lands in `argv`. `qm vncproxy` treats EOF on its stdin as "quit", so the
146
+ plugin keeps that pipe open (the bridge also drops idle sessions after 15 minutes; the plugin
147
+ closes its own session after `sessionIdleMs`, 5 minutes by default).
148
+ * **Input channels.** `inputChannel: auto` (default) mixes them: Caps Lock through the QEMU monitor
149
+ for uppercase, RFB keysyms for the rest. `hmp` sends everything through `qm monitor sendkey`
150
+ (faster, but QEMU occasionally loses modifiers below ~80 ms), `vnc` uses RFB only (uppercase is
151
+ unreliable — QEMU emulates Shift itself and our own Shift events desynchronize it).
152
+ * **Unicode.** Windows: the plugin drops a payload file and a PowerShell typer into the guest and
153
+ registers a scheduled task with `-LogonType Interactive`, so the text is typed *inside the user's
154
+ session* via `SendKeys` — layout and modifiers stop mattering, and the VM is not restarted. Linux:
155
+ `xdotool type` (X11) or `wtype` (Wayland) inside the active session; both paths run through the
156
+ guest agent in a single call.
157
+ * **Clipboard.** `ClientCutText` for writing, the extended clipboard pseudo-encoding
158
+ (`VNC_ENCODING_CLIPBOARD_EXT`) with `CAPS`/`REQUEST`/`PROVIDE` for reading. QEMU passes the bytes
159
+ to the guest through `qemu-vdagent`, so the VM needs `vga: <type>,clipboard=vnc` **and** a full
160
+ stop/start (device arguments are fixed at start-up), plus a SPICE agent in the guest.
161
+ * **Frames.** RFB Raw/CopyRect rectangles are composited into RGBA (QEMU leaves alpha at zero),
162
+ optionally cropped and downscaled, then encoded to PNG with `node:zlib`.
163
+
164
+ ## Troubleshooting
165
+
166
+ | Symptom | Cause and fix |
167
+ |---|---|
168
+ | `CONSOLE_FAILED` right after connecting, node reports nothing useful | The node's `sshd` does not accept `LC_*`, so `qm` never received the VNC password. Add `AcceptEnv LC_*` to `sshd_config` and reload sshd. |
169
+ | `Host key verification failed` | The node's key is not in `known_hosts` and the plugin runs in batch mode. Run `ssh <node>` once, or set `sshExtraOptions: ["StrictHostKeyChecking=accept-new"]`. |
170
+ | A frame comes back almost uniform (`blank: true`) | The guest blanked its display or is locked. The tools already send Shift + pointer jitter to wake it; a locked session needs a password (`console_type` + `console_key`). |
171
+ | `unable to connect to VM qmp socket — timeout after 51 retries` | Something else holds the VM's single QMP socket (a hung `qm monitor`/QMP client). Find and kill that client on the node; do not restart the VM. |
172
+ | Uppercase letters turn into garbage | You are on `inputChannel: vnc`, where QEMU's own Shift emulation fights our Shift events. Use `auto`. |
173
+ | Latin characters are not typed at all on a login screen | The guest layout is not Latin: `console_key` with `alt+shift`, then type. |
174
+ | `vm_*` tools report that the agent is not running | `qemu-guest-agent` is missing or wedged (`Restart-Service qemu-ga` on Windows, `systemctl restart qemu-guest-agent` on Linux). Console tools keep working. |
175
+ | Console dies after ~15 minutes of idling | That is the `qm vncproxy` bridge timeout. Any tool call reopens the session automatically. |
176
+
177
+ ## Security
178
+
179
+ This plugin gives an agent **root-level hands inside your VMs**. Be deliberate about it:
180
+
181
+ * **Every action is executed without an approval prompt.** The only gate is `allowVmids`, which is
182
+ empty by default; list only the VMs you are willing to let an agent touch, and keep the list
183
+ short.
184
+ * **`vm_exec` runs as root/SYSTEM in the guest**, `vm_file_write` can write anywhere the agent can,
185
+ and the console tools can drive a logged-in desktop. Treat an allowed VM as a compromised host:
186
+ do not keep long-lived secrets in it while the plugin is enabled.
187
+ * **Root SSH to the node is required** (`qm` needs it). Use a dedicated key, restrict it to the
188
+ nodes you need, and consider `from=`/`command=` restrictions in `authorized_keys` where possible.
189
+ The plugin passes the whole host environment to the ssh child, as any ssh call does.
190
+ * **`sshExtraOptions` accepts arbitrary `-o` options**, including `ProxyCommand` — it is a
191
+ privileged escape hatch for the person who configures the plugin, not for the model.
192
+ * **VNC passwords are generated per session** (8 printable ASCII characters) and handed to `qm`
193
+ through the environment via `SendEnv`, so they do not show up in `ps`. The QEMU password is
194
+ scoped to the VM and expires with the session.
195
+ * **The plugin talks only to your node.** No telemetry, no outbound connections of its own.
196
+
197
+ ## Limitations
198
+
199
+ * Proxmox VE only, QEMU VMs only — no LXC containers, no other hypervisors.
200
+ * Clipboard tools need `clipboard=vnc` on the VM's VGA device and a SPICE agent in the guest;
201
+ they move **text only** (no files, no images) and only inside a logged-in session.
202
+ * Unicode typing in Windows needs an interactive session; on the login screen only ASCII through
203
+ `console_type` works.
204
+ * One console session per VM id, serialized with a mutex; the session is closed on idle.
205
+ * The console tools do not work with a serial console (`vga: serialN`) — there is no framebuffer.
206
+ * Not yet verified: Proxmox VE 7 and 9, multi-node clusters, Linux guests with Wayland-only desktops.
207
+
208
+ ## Development
209
+
210
+ ```bash
211
+ npm run check # node --check on every runtime file (no harness needed)
212
+ node tools/check-client.mjs # browser bundle format (classic script, exports, inject)
213
+ node tools/check-plugin.mjs # settings schema, tool set, JSON schemas, layout contract
214
+ ```
215
+
216
+ `check-plugin.mjs` imports the plugin, and the plugin imports the harness packages
217
+ (`@deepseek-ai/dsh-tools`, `@deepseek-ai/schemastery`), so run it where those resolve — the
218
+ easiest way is to install the checkout into a profile with `link:` and run the script from there:
219
+
220
+ ```bash
221
+ dsh plugin --profile web add link:/path/to/dsh-pve-vm
222
+ cd /path/to/dsh-pve-vm && node tools/check-plugin.mjs
223
+ ```
224
+
225
+ For a bare checkout, point `DSH_PACKAGES` at the harness package directory
226
+ (`…/@deepseek-ai/dsh/node_modules/@deepseek-ai`) — the script uses it as a fallback for the
227
+ compiler it needs.
228
+
229
+ Live probes need node access only (no harness):
230
+
231
+ ```bash
232
+ node tools/probe-rfb.mjs --vmid 100 --ssh-config ~/.ssh/config --out /tmp/shot.png
233
+ node tools/probe-rfb.mjs --vmid 100 --click 640,400 --after /tmp/after.png
234
+ node tools/live-test.mjs --vmid 100 --ssh-config ~/.ssh/config --out probe-out
235
+ node tools/clipboard-test.mjs --vmid 100 --text "hello" --out /tmp/clipboard.png
236
+ ```
237
+
238
+ All of them talk to the node exactly like the plugin does (`qm vncproxy` over ssh), so they are the
239
+ fastest way to tell a plugin bug from a node-side problem.
240
+
241
+ ## License
242
+
243
+ MIT — see [LICENSE](LICENSE).
244
+
245
+ Proxmox® is a registered trademark of Proxmox Server Solutions GmbH. This project is an
246
+ independent plugin and is not affiliated with or endorsed by Proxmox Server Solutions GmbH or by
247
+ the DeepSeek Harness project.