Repository navigation
fix(hooks): check the command line of Linux node processes named MainThread - #1051
Merged
Merged
Conversation
…Thread createPidResolver runs an adapter's agentCmdlineCheck only for ancestors whose process name is in agentCmdlineNames, and the default was node / node.exe. Node names its main thread "MainThread" from 23.8 (nodejs/node#56416, so all of 24.x) and "node-MainThread" from 25.5 (nodejs/node#61307), and on Linux `ps -o comm=` reports the main thread's name. So on Linux with current Node, an agent running as a node process that never set process.title was never checked, and adapters relying on the default got no agent pid there. - Export the default as DEFAULT_AGENT_CMDLINE_NAMES: node, node.exe, mainthread, node-mainthread. - ZCode spreads it into its own list. WorkBuddy keeps its electron-only probe, which only matches the bundled macOS .app task runner. - Tests: the default names, a mocked Linux walk for each name, a real node child that never set process.title (so Linux CI notices a future rename), and a scan that fails when a hook passes its own list without spreading the default.
DEFAULT_AGENT_CMDLINE_NAMES now covers Node's Linux main-thread names, so MiniMax's own AGENT_CMDLINE_NAMES (the same four names) is a hand copy, and the agentCmdlineNames scan rejects it. Drop it and let MiniMax follow the shared default. Its test now asserts that the resolver options carry no list of their own and still wire isMinimaxAgentCommandLine; the node-named mcode end-to-end test keeps covering the real behavior on Linux CI.
…ineNames
The scan split the Set's contents on every comma, so a spread inside a
call argument, as in new Set([String("zcode", ...DEFAULT_AGENT_CMDLINE_NAMES,
"x")]), read as an element of its own and passed although the Set then
held only "zcode". Accept one shape instead: the brackets may hold plain
string literals and ...DEFAULT_AGENT_CMDLINE_NAMES itself, nothing else.
Also stop claiming that every mention in a comment is reported; a mention
is reported whenever its text is not in that shape.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createPidResolver()inhooks/shared-process.jsruns an adapter'sagentCmdlineCheckonly on ancestors whose process name is inagentCmdlineNames, and the default wasnode/node.exe. Node names its main threadMainThreadfrom 23.8 (src,lib: use uv_thread_setname to a better multi-thread debugging nodejs/node#56416, so all of 24.x) andnode-MainThreadfrom 25.5 (src: usenode-prefix on thread names nodejs/node#61307), and on Linuxps -o comm=reports the main thread's name. On Linux with current Node, an agent running as a node process that never setprocess.titlewas therefore never checked and got no agent pid. fix(minimax): #1038 follow-ups — ownership marker, staged install, honest uninstall, CLI agent pid #1049's Linux CI hit this for MiniMax.DEFAULT_AGENT_CMDLINE_NAMES:node,node.exe,mainthread,node-mainthread. The adapters that rely on the default get it with no change: Claude, Copilot, Gemini, Kimi, Qwen Code, QwenWork, Qoder, QoderWork and Antigravity.electron-only probe, because its check only matches the bundled macOS.apptask runner.agentCmdlineNamesmust writeagentCmdlineNames: new Set([..., ...DEFAULT_AGENT_CMDLINE_NAMES]), with only plain string literals and the spread itself inside the brackets. A test scanshooks/*.jsand fails on any other form, such as a hand-written, trimmed or shorthand list.AGENTS.mddocuments the rule.main,67f9fe32drops that copy so MiniMax uses the shared default. Its test now asserts that the resolver options carry no list of their own and still wireisMinimaxAgentCommandLine.ps -o comm=reports the executable path and Win32_Process reports the image name.Validation
main)main(fix(minimax): #1038 follow-ups — ownership marker, staged install, honest uninstall, CLI agent pid #1049 merged): the same 38 files pass 1,161 tests with 0 failed;npm testgives 11,154 tests, 11,108 passed, 46 skipped, 0 failed (mainat28b09e8c: 11,145 tests, 0 failed, 46 skipped)agentCmdlineCheck, and keepCOLUMNSunder a procps-likeps. Three controls for legitimate list forms pass.MainThread; v25.5.0 and v26.10.0 setnode-MainThread. libuv's Linux thread-name buffer is 16 bytes, so the 15-character name is not truncated.main. The final commit (015b7aaa), which narrows the list scan to string literals plus the spread, was not re-reviewed.nodechild that never setprocess.titlethrough the realps. On ubuntu-latest with Node 24.18.0 it passed at67f9fe32, as did MiniMax's node-namedmcodeend-to-end test. No real agent was run on a Linux desktop, andnode-MainThread(Node ≥ 25.5) is checked only against Node's source and mocked tests.Known limitations and follow-ups
includes("kimi")) is loose, so a nearer unrelated node process whose command line contains "kimi" can take the agent pid. That was already true on macOS and Windows, and Kimi Code's own hook runner has no such intermediate process. Tightening it is a separate task, along with two other Kimi name issues: Kimi Code retitles itselfkimi-code, which is not in Kimi's name list, and the mixed-caseKimi Codeentry can never match.ps -o command=. procps applies an exportedCOLUMNSas the width of piped output, so a hook environment withCOLUMNSset can truncate a long command line. This predates the change and is not addressed here.Refs #1049