fix(agent-manager): utils/agents.ts argv matchers split on whitespace and miss agents under paths with spaces
Problem
#280 fixed executable detection for install paths containing spaces in utils/process.ts (executablePath / executableBasename). The matchers in packages/agent-manager/src/utils/agents.ts still split the ps command line on whitespace:
const token = psCommand.trim().split(/\s+/)[0]; // matchArgv0 / matchArgv0Name
for (const token of psCommand.trim().split(/\s+/)) { ... } // matchAnyToken / matchAnyBasename
These are used by ManagedAgentRuntime (e.g. confirming the launched agent PID) and AgentReadiness. With an agent under a path like /Applications/Some App.app/Contents/Resources/codex, argv[0] reads as /Applications/Some. The managed runtime and readiness checks then fail to recognise the process, even though the adapters now detect it.
Proposed fix
Reuse executablePath() / executableBasename() from utils/process.ts for argv[0] matching. For the any-token matchers, resolve argv[0] first and then scan the remaining arguments, keeping the rule that arguments are never folded into the executable path.
Acceptance criteria
- [ ]
matchArgv0/matchArgv0Namerecognise executables under paths containing spaces (tests with real temp files, like the #280 tests). - [ ]
matchAnyToken/matchAnyBasenamebehave the same for commands without spaces (existing tests pass), and handle a spaced argv[0]. - [ ] Arguments containing spaces are still not treated as the executable, e.g.
/usr/bin/vim My Notes/claudedoesn't matchclaude. - [ ]
ManagedAgentRuntime/AgentReadinesstests pass; add a case with a spaced agent path.