ai-devkit
ai-devkit copied to clipboard
fix(agent-manager): agents installed under paths with spaces are not detected (executableBasename splits on whitespace)
Problem
executableBasename (packages/agent-manager/src/utils/process.ts) takes the executable by splitting the ps command line on whitespace:
const executable = command.trim().split(/\s+/)[0] || "";
If an agent binary is installed under a path with spaces, for example /Applications/Some App.app/Contents/Resources/codex, the extracted "executable" is /Applications/Some. The process then fails every adapter's processNames / canHandle check, so the agent isn't detected at all. This affects every adapter, because they all rely on executableBasename and filterByProcessNames.
Found while working on #259.
Proposed approach
- Get the executable path from a source that isn't ambiguous. On macOS and Linux,
ps -axo comm=gives the executable name or path, and combiningcommwith the fullcommandlets argv[0] be recovered even when it contains spaces. - Or, match known executable names against suffixes of space-joined prefixes of the command line (e.g. try
/Applications/Some App.app/.../codexbefore splitting the arguments). - Keep the snapshot to a single
pscall. A secondpscall per refresh isn't acceptable (see #266).
Acceptance criteria
- [ ] A process whose executable path contains spaces is recognised by the matching adapter (unit tests with realistic command lines for Claude, Codex and a
node-based adapter). - [ ] Commands without spaces in the path behave exactly as before (existing tests pass).
- [ ] Arguments containing spaces are still not treated as part of the executable path.
- [ ] Still one base
psinvocation per refresh.