Verify system monitoring against an explicit hosted OpenCode server
This commit is contained in:
@@ -105,6 +105,16 @@ the configuration used by Desktop plugins. On Windows, a path such as
|
||||
OpenCode reloads configuration automatically. Run **`/system`** to open the dashboard. If the command has
|
||||
not appeared yet, use **Settings → Extensions → Plugins → Reload** for this plugin.
|
||||
|
||||
### Hosted OpenCode (Docker / Portainer)
|
||||
|
||||
Register the built plugin in the **server's persistent global config**. Use a package directory the running
|
||||
OpenCode process can read, containing `package.json`, `dist/`, and the installed runtime dependencies.
|
||||
For a container with an isolated filesystem, mount that directory read-only and use its **container path**
|
||||
in `plugins`. For a runtime that starts in the host filesystem, use the host path directly.
|
||||
|
||||
In the hosted web composer, select `/system_status` and send it to see the server's readings. It works without
|
||||
a model request. The `/system` graphical dashboard is available in Desktop only.
|
||||
|
||||
### Update
|
||||
|
||||
From the cloned directory:
|
||||
@@ -231,11 +241,12 @@ The ordinary smoke check validates CPU, RAM and disks, and reports whether GPU t
|
||||
| --- | --- |
|
||||
| Windows, Node 26.13 | Type-check/build, 24 tests, real CPU/RAM/disk/Intel GPU readings, installed OpenCode RPC and text command |
|
||||
| Ubuntu 24.04 under WSL2, Node 22.23.5 | Clean dependency install, type-check/build, all 26 tests, real CPU/RAM/disk readings as an unprivileged user |
|
||||
| Native Linux, Minisforum Ryzen 9 PRO 8945HS / Radeon 780M, hosted OpenCode 2.3.2 | All 26 tests, GPU-required smoke check, live snapshot RPC and agent tool, and `/system_status` in the authenticated web composer. RAM and VRAM totals matched procfs/sysfs. |
|
||||
|
||||
The two Linux-only process tests verify that Intel sampling exits cleanly and is forcibly terminated if it ignores
|
||||
the interrupt. Linux GPU parsing, adapter selection, permissions/missing-tool behavior, and AMD sysfs collection are
|
||||
covered by fixtures. **Native Linux Intel/AMD hardware telemetry has not yet been verified on a physical Linux host**;
|
||||
WSL on the test machine did not expose the required counters.
|
||||
covered by fixtures. Native AMD utilization and VRAM were also verified on the physical Minisforum.
|
||||
Native Intel hardware telemetry on Linux remains fixture-tested; WSL on the test machine did not expose the required counters.
|
||||
|
||||
### Build and test
|
||||
|
||||
@@ -271,6 +282,13 @@ On Windows, pass the path to `opencode-cli.exe`. This checks plugin registration
|
||||
disk readings, and the `/system_status` command.
|
||||
It creates a temporary test session and removes it afterwards.
|
||||
|
||||
For a hosted service, pass its endpoint explicitly to avoid local service discovery. Set `OPENCODE_PASSWORD`
|
||||
in the test environment if the server requires authentication. Use the absolute project directory **on the server**:
|
||||
|
||||
```bash
|
||||
node scripts/integration.mjs /path/to/opencode --server https://opencode.example.com --directory /srv/projects/example --require-gpu
|
||||
```
|
||||
|
||||
### Project layout
|
||||
|
||||
```text
|
||||
|
||||
+17
-7
@@ -1,31 +1,41 @@
|
||||
import assert from "node:assert/strict"
|
||||
import { execFileSync } from "node:child_process"
|
||||
import { parseArgs } from "node:util"
|
||||
|
||||
const cli = process.argv[2]
|
||||
const { positionals: [cli], values } = parseArgs({
|
||||
allowPositionals: true,
|
||||
options: { server: { type: "string" }, directory: { type: "string" }, "require-gpu": { type: "boolean" } },
|
||||
})
|
||||
if (!cli) throw new Error("Pass the OpenCode CLI executable path")
|
||||
const location = values.directory ? { directory: values.directory } : undefined
|
||||
const query = location ? `?${new URLSearchParams({ "location[directory]": location.directory })}` : ""
|
||||
function api(method, route, body) {
|
||||
const args = ["api", method, route]
|
||||
if (values.server) args.unshift("--server", values.server)
|
||||
if (body !== undefined) args.push("--data", JSON.stringify(body))
|
||||
const result = execFileSync(cli, args, { encoding: "utf8", windowsHide: true, timeout: 20000 })
|
||||
return result.trim() ? JSON.parse(result) : undefined
|
||||
}
|
||||
|
||||
const plugins = api("get", "/api/plugin").data
|
||||
const plugins = api("get", "/api/plugin" + query).data
|
||||
const plugin = plugins.find(item => item.id === "local-system-monitor")
|
||||
assert.equal(plugin?.state.status, "active")
|
||||
assert.equal(plugin.features.gui, true)
|
||||
assert.equal(plugin.features.rpc, true)
|
||||
const snapshot = api("post", "/api/rpc/local-system-monitor/snapshot", { input: {} }).output
|
||||
if (process.argv.includes("--require-gpu")) {
|
||||
const snapshot = api("post", "/api/rpc/local-system-monitor/snapshot" + query, { input: {} }).output
|
||||
assert.ok(Number.isFinite(snapshot.cpu.percent) && snapshot.cpu.percent >= 0 && snapshot.cpu.percent <= 100)
|
||||
assert.ok(snapshot.ram.total > 0 && snapshot.ram.used + snapshot.ram.free === snapshot.ram.total)
|
||||
if (values["require-gpu"]) {
|
||||
assert.equal(snapshot.gpu.error, null)
|
||||
assert.ok(snapshot.gpu.adapter?.percent != null)
|
||||
const percent = snapshot.gpu.adapter?.percent
|
||||
assert.ok(Number.isFinite(percent) && percent >= 0 && percent <= 100)
|
||||
}
|
||||
assert.ok(snapshot.disks.items.length > 0)
|
||||
console.log("Installed plugin, GUI feature, RPC, and disk readings: passed")
|
||||
console.log("Installed plugin, GUI feature, RPC, and CPU/RAM/disk readings: passed")
|
||||
|
||||
let sessionID
|
||||
try {
|
||||
const result = api("post", "/api/session", { title: "System Monitor self-test" })
|
||||
const result = api("post", "/api/session", { title: "System Monitor self-test", location })
|
||||
sessionID = (result.data ?? result).id
|
||||
assert.ok(sessionID)
|
||||
api("post", `/api/session/${sessionID}/command`, { name: "system_status", text: "" })
|
||||
|
||||
Reference in New Issue
Block a user