来源: #679 分析 Windows 启动截断问题时发现
Context
While fixing #679 (runClient's shell:true truncated spaced client/-e paths), I audited every arg class the launcher passes to clients on Windows. One class cannot be transmitted through cmd.exe faithfully by ANY quoting scheme, and it is broken today already.
What happens
Default bili codex injects the native bili MCP tools inline (src/launcher.ts, buildCodexMcpArgs):
-c mcp_servers.bili.command=<JSON.stringify(process.execPath)>
When node lives under a spaced path (e.g. C:\Program Files\nodejs\node.exe — the stock Windows install location), this single argv token contains double quotes, backslashes AND spaces:
mcp_servers.bili.command="C:\\Program Files\\nodejs\\node.exe"
On Windows codex resolves to an npm .cmd shim, so the spawn goes through cmd.exe (before AND after the #679 fix — shims always need cmd). cmd.exe treats " purely as a quote-state toggle and has NO escape mechanism for a literal quote inside an argument. However the line is built, cmd strips the token's surrounding quotes before the shim sees it, so codex receives:
mcp_servers.bili.command=C:\Program Files\nodejs\node.exe
— an UNQUOTED TOML value containing spaces. That is not a valid TOML string.
Impact (needs Windows verification)
Unverified on real Windows which way codex fails: it either rejects the -c assignment (launch error) or drops/mis-parses the mcp_servers.bili entry (bili MCP server never registers → codex runs WITHOUT the compress tool → in plugin mode compression silently never activates — the same silent failure class as #679's second half). Either way: Windows users with node under a spaced path + default MCP mode are affected.
Note: this is independent of #679's fix — even with perfect per-token quoting, a token containing both quotes and whitespace cannot survive cmd.exe; no quoting scheme exists for it.
Suggested direction
Stop encoding absolute paths into inline -c values. Deliver the MCP server definition via a FILE instead (a temp config file if codex exposes an alternate-config/profile flag, or a temp profile/home dir) — analogous to claude's existing temp --mcp-config file approach (src/launcher.ts, injectMcp branch).
First step: verify actual codex behaviour on Windows (does it reject the -c, or start tool-less?) before choosing the fix.
来源: #679 分析 Windows 启动截断问题时发现
Context
While fixing #679 (runClient's shell:true truncated spaced client/-e paths), I audited every arg class the launcher passes to clients on Windows. One class cannot be transmitted through cmd.exe faithfully by ANY quoting scheme, and it is broken today already.
What happens
Default
bili codexinjects the native bili MCP tools inline (src/launcher.ts, buildCodexMcpArgs):When node lives under a spaced path (e.g.
C:\Program Files\nodejs\node.exe— the stock Windows install location), this single argv token contains double quotes, backslashes AND spaces:On Windows codex resolves to an npm
.cmdshim, so the spawn goes through cmd.exe (before AND after the #679 fix — shims always need cmd). cmd.exe treats"purely as a quote-state toggle and has NO escape mechanism for a literal quote inside an argument. However the line is built, cmd strips the token's surrounding quotes before the shim sees it, so codex receives:— an UNQUOTED TOML value containing spaces. That is not a valid TOML string.
Impact (needs Windows verification)
Unverified on real Windows which way codex fails: it either rejects the
-cassignment (launch error) or drops/mis-parses themcp_servers.bilientry (bili MCP server never registers → codex runs WITHOUT the compress tool → in plugin mode compression silently never activates — the same silent failure class as #679's second half). Either way: Windows users with node under a spaced path + default MCP mode are affected.Note: this is independent of #679's fix — even with perfect per-token quoting, a token containing both quotes and whitespace cannot survive cmd.exe; no quoting scheme exists for it.
Suggested direction
Stop encoding absolute paths into inline
-cvalues. Deliver the MCP server definition via a FILE instead (a temp config file if codex exposes an alternate-config/profile flag, or a temp profile/home dir) — analogous to claude's existing temp--mcp-configfile approach (src/launcher.ts, injectMcp branch).First step: verify actual codex behaviour on Windows (does it reject the
-c, or start tool-less?) before choosing the fix.