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

fix(agent-manager): utils/agents.ts argv matchers split on whitespace and miss agents under paths with spaces

Open codeaholicguy opened this issue 2 months ago • 0 comments

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 / matchArgv0Name recognise executables under paths containing spaces (tests with real temp files, like the #280 tests).
  • [ ] matchAnyToken / matchAnyBasename behave 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/claude doesn't match claude.
  • [ ] ManagedAgentRuntime / AgentReadiness tests pass; add a case with a spaced agent path.

codeaholicguy avatar Sep 29 '26 13:09 codeaholicguy