Repository navigation
Description
Purpose
Every Claude Code session starts its plugin MCP servers at launch, and cua serve launches the vendor runtime (cua_node, node_repl, the codex sandbox and app-server) in openConnection before any tool call (src/mcp/server.mjs serve → src/mcp/connection.mjs openConnection → buildLaunch). On the owner's Mac on 2026-10-10 that was 23 live cua serve processes with 39 node_repl and 43 cua_node children, one stack per open session whether or not the session ever uses cua. Idle CPU is near zero and each process is small, but every new session and resumed terminal pays a runtime launch and holds a stack for days.
Change (owner-approved 2026-10-10): the vendor runtime starts lazily. cua serve answers the MCP handshake and lists its tools at once with no runtime; the runtime is launched on the first call that needs it (js, js_reset, end_task when a runtime exists, and profiles_list only for the live readiness listing it already launches) and stays for the life of the connection as today. Calls that need no runtime (secrets_list, devices_list, devices_use, profiles_list's registry part) must not start one. The first js call's response is unchanged apart from the launch latency it now carries (the API document). The MAWS client-mode backends (startClientBackends, the hello wait) keep their timing relative to the first launch, not to serve start: the socket dial may stay eager (it is cheap) but the hello wait moves to the launch. end_task and signal handling must behave the same whether or not a runtime was ever launched (a connection with no runtime closes clean, no leftover processes, no listingLeftover). Idle shutdown of a running runtime is explicitly out of scope (a later ticket).
Verify: unit tests in test/ (scratch HOME) that serve lists tools with zero spawned launches, that the first js spawns exactly one, that a second js spawns none, that secrets_list/devices_list spawn none, that closing an unlaunched connection leaves nothing and exits 0; the existing suites (npm test, npm run test:mods) green; the native acceptance script's relevant items still pass. Repository: SSFSKIM/cua, worktree on a branch off main; the plugin version bumps by one minor over whatever main carries at rebase time (cua PR #104 may land 0.7.0 first). README's description of the first call and the "process footprint" note updated. No attribution footers.
Activity
SSFSKIM commentedon Oct 10, 2026
[board] in-progress: Worker dispatched (opus) in cua worktree cua-wt-lazy on branch feat/lazy-runtime.
README and spec: the lazy runtime launch and the process footprint
Merge pull request #106 from SSFSKIM/feat/lazy-runtime
SSFSKIM commentedon Oct 10, 2026
[board] done: Merged #106 (plugin 0.8.0) after a medium review and fix wave; the runtime launches on the first js/js_reset; handshake answers replayed from a per-release record (the first connection per release still launches once). Idle shutdown and install-time pre-recording left as follow-ups.