Add dashboard headless worker mode (CLI flag + worker loop + adapter spawn) - #5
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68096b52dd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const payload = JSON.parse(line); | ||
| if (payload && typeof payload === 'object') { | ||
| return String(payload.command ?? payload.input ?? payload.prompt ?? payload.text ?? '').trim(); |
There was a problem hiding this comment.
Preserve raw JSON prompts without envelope fields
When the dashboard sends a plain prompt that happens to be a JSON object, this branch parses it as a worker envelope and replaces it with only command/input/prompt/text. For inputs like {"scripts":{"test":"node --test"}} none of those fields exist, so this returns an empty string and runOne silently ignores the user request; objects containing a text or command property are also unintentionally truncated. Since sendCommand() writes raw user text, treat parsed JSON as an envelope only when one of the supported fields is actually present, otherwise fall back to the original line.
Useful? React with 👍 / 👎.
Motivation
LAUNCHED_BY_DASHBOARDenvironment handoff.Description
--dashboard-worker(alias--headless-worker) tosrc/cli/args_parser.jsand document it in the help text.bin/smallcode.js(runDashboardWorker) that accepts plain lines or JSON-lines, extracts a command/prompt, callsrunAgentLoop(input, config), captures output, and emits lifecycle markers such as[HARNESS] ready,[user] ...,[assistant] ...,[IPC] Run Complete, and[IPC] Error: ...to stdout.flags.dashboardWorkerinmain()and suppressing some human-facing output in worker mode.src/controlroom/harness_adapter.js:startTUI()to spawnnode bin/smallcode.js --dashboard-workerand remove theLAUNCHED_BY_DASHBOARDenv dependency.test/cli_args_parser.test.jsandtest/controlroom_harness_adapter.test.jsto validate argument parsing and spawn behavior.Testing
node --check bin/smallcode.jsto ensure file parses without syntax errors, and it succeeded.node --test test/cli_args_parser.test.js test/controlroom_harness_adapter.test.js, and both tests passed.node test/e2e_offline.jswhich failed in this environment due to a missing installed dependency (chalk) unrelated to the new worker logic; the failure prevented the full offline smoke checks but does not affect the new worker/unit tests.Codex Task