修复: Windows host 模式下路径兼容#570
Open
paroquet wants to merge 1 commit into
Open
Conversation
agent-runner 本为 Linux 容器编写,在 Windows host 模式下暴露多处 POSIX 假设: - index.ts: PROMPTS_DIR 用 new URL(import.meta.url).pathname 在 Windows 返回 /E:/... 带前导斜杠+盘符,path.join 后丢盘符变 \E:\... 被按当前盘根解析成 E:\E:\... ENOENT。改用 fileURLToPath。 - index.ts: which claude 在 Windows 找不到、fallback 全是 Linux 路径,导致 pathToClaudeCodeExecutable 为空、SDK 自找漏 .exe 报 native binary not found。win32 下直接解析 SDK 自带 claude-agent-sdk-win32-x64\claude.exe(Linux 容器仍走 which,那里平台包是空包)。 - container-runner.ts: hostEnv PATH 拼接硬编码 : 分隔符,Windows 上把盘符 E: 也当分隔符拼烂 PATH。改用 path.delimiter。 - container-runner.ts: mount allowlist ~ 展开 fallback 到 macOS 风格 /Users/user。改用 os.homedir()。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题描述
agent-runner最初为 Linux 容器编写,在 Windows host 模式下暴露多处 POSIX 假设,导致 host 模式无法启动 agent。修复方案
container/agent-runner/src/index.tsnew URL(import.meta.url).pathname在 Windows 上返回/E:/.../index.js(带前导斜杠 + 盘符),path.join后丢盘符变成\E:\...,再被 Node 按当前盘根解析成E:\E:\...导致 ENOENT。改用fileURLToPath,Linux 容器与 Windows host 下都返回正确本地路径。which claude在 Windows 上多半找不到,fallback 全是 Linux 路径,导致pathToClaudeCodeExecutable为空、SDK 自找漏.exe报 "native binary not found"。win32 下直接解析 SDK 自带的@anthropic-ai/claude-agent-sdk-win32-x64/claude.exe(与agent-capabilities.ts主进程侧解析逻辑一致);Linux 容器里这些 optionalDependencies 是空包,仍走原which分支。src/container-runner.tshostEnv['PATH']拼接硬编码:,Windows 上会把盘符(E:)也当分隔符拼烂 PATH。改用path.delimiter(Windows;/ POSIX:)。~展开 fallback 到 macOS 风格/Users/user。改用os.homedir()。验证
make typecheck全量通过🤖 Generated with Claude Code