Add procfs memory and mount-aware disk collectors, Intel and AMD GPU backends, bounded Intel sampling, portable validation tools, and Linux setup documentation. Bump to 0.2.0 and verify on Windows and Ubuntu 24.04 under WSL2.
42 lines
1.8 KiB
JavaScript
42 lines
1.8 KiB
JavaScript
import assert from "node:assert/strict"
|
|
import { execFileSync } from "node:child_process"
|
|
|
|
const cli = process.argv[2]
|
|
if (!cli) throw new Error("Pass the OpenCode CLI executable path")
|
|
function api(method, route, body) {
|
|
const args = ["api", method, route]
|
|
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 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")) {
|
|
assert.equal(snapshot.gpu.error, null)
|
|
assert.ok(snapshot.gpu.adapter?.percent != null)
|
|
}
|
|
assert.ok(snapshot.disks.items.length > 0)
|
|
console.log("Installed plugin, GUI feature, RPC, and disk readings: passed")
|
|
|
|
let sessionID
|
|
try {
|
|
const result = api("post", "/api/session", { title: "System Monitor self-test" })
|
|
sessionID = (result.data ?? result).id
|
|
assert.ok(sessionID)
|
|
api("post", `/api/session/${sessionID}/command`, { name: "system_status", text: "" })
|
|
const inbox = api("get", `/api/session/${sessionID}/inbox`)
|
|
const text = JSON.stringify(inbox)
|
|
assert.match(text, /local-system-monitor.report/)
|
|
assert.match(text, /\*\*GPU:\*\*/)
|
|
const messages = api("get", `/api/session/${sessionID}/message`)
|
|
assert.doesNotMatch(JSON.stringify(messages), /"type":"assistant"/)
|
|
console.log("/system_status posts a report without starting a model turn: passed")
|
|
} finally {
|
|
if (sessionID) api("delete", `/api/session/${sessionID}`)
|
|
}
|