ai-devkit icon indicating copy to clipboard operation
ai-devkit copied to clipboard

fix(agent-manager): agents installed under paths with spaces are not detected (executableBasename splits on whitespace)

Open codeaholicguy opened this issue 2 months ago • 0 comments

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 combining comm with the full command lets 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/.../codex before splitting the arguments).
  • Keep the snapshot to a single ps call. A second ps call 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 ps invocation per refresh.

codeaholicguy avatar Sep 28 '26 11:09 codeaholicguy