Repository navigation
Description
Purpose
Follow-up to #105 (plugin 0.8.0: the vendor runtime launches on the first js). A runtime that was launched stays for the life of the connection, so a session that used cua once at the start of a day keeps its stack (cua_node ×2, node_repl ×2, codex sandbox, app-server) for the day. The owner (2026-10-10) wants an idle shutdown: after no tool call for a while, cua serve stops the runtime it launched; the next call that needs one relaunches it.
Behaviour:
- Idle = no tool call (
js,js_reset,end_task,profiles_list's live part) forCUA_RUNTIME_IDLE_MS(default 15 minutes;0disables). The timer arms when a call completes and is cleared by the next call; a call still running never counts as idle. - On idle: stop the runtime through the same path
end_task/connection close use for the vendor processes (no leftover inrun/, attachments detached so MAWS and Chrome leases release as on a normal end), keep the MCP connection and the MAWS socket dial, log one diagnostics line (runtime stopped after N min idle). - On the next
js/js_resetafter an idle stop: relaunch (the lazy path from cua serve launches the vendor runtime lazily, on the first call that needs it #105) and tell the model, in that call's result, that the runtime restarted after idling and its REPL state (variables, app handles, tabs) is gone, so it must rebind; the first-call API document is returned as on any fresh runtime.end_taskafter an idle stop with no task open answers as today's no-taskend_task. - The handshake record,
secrets_list,devices_*and the registry part ofprofiles_listare untouched. The HTTP agent's sessions get the same timer. - No change to the vendor runtime (D-1-like: unmodified).
Verify: unit tests with a counting prepareLaunch double and a fake clock: the timer arms only after a completed call; a call during the window resets it; the stop runs the normal cleanup; the relaunch counts one launch and the result carries the restart notice; 0 disables; a call racing the stop (arrives during teardown) waits and gets a fresh runtime, never an error from the dying one. HOME=<scratch> npm test, npm run test:mods, claude plugin validate . green. README: the footprint note gains the idle rule and the env variable. Plugin 0.8.0 → 0.9.0. Repository SSFSKIM/cua, branch off main in a worktree; no attribution footers.
Activity
SSFSKIM commentedon Oct 10, 2026
[board] in-progress: Worker dispatched (opus) in cua worktree cua-wt-idle on branch feat/idle-runtime.
SSFSKIM commentedon Oct 10, 2026
[board] done: PR #108 merged at 3fceddd (plugin 0.9.0). A launched runtime stops after CUA_RUNTIME_IDLE_MS (default 15 min, 0 disables, max 2147483647) with no js/js_reset/end_task/profiles_list live call; the stop takes the normal end path (open task completed, teardown within budget, run/ dir removed, one diagnostics line); the next js/js_reset relaunches lazily and its result opens with a restart notice. Calls racing the stop wait for it. cua agent install carries the variable into the launchd/systemd job. Review: reviewer-medium (opus) found one P2 (setTimeout overflow above 2^31-1 ms → refused as invalid_setting) and two P3 (waiting call counted as open local task; leftover run dir reused), all fixed with regression tests. Gates: npm test 1094 pass/1 Linux-only skip, test:mods 32/32, plugin validate ok. Live check with a 4 s setting: stop after 4 s, relaunch in 457 ms with the notice. Left out: idle stops do not apply to remote devices (their agent runs its own timer); the leftover-dir test fakes the failed removal. Installed plugin updated to 0.9.0 (restart to apply).