Skip to content

fix: resolve npx acp agents from npm prefix#151

Merged
xintaofei merged 2 commits intoxintaofei:mainfrom
Kwensiu:fix/acp-npx-prefix-resolution
May 6, 2026
Merged

fix: resolve npx acp agents from npm prefix#151
xintaofei merged 2 commits intoxintaofei:mainfrom
Kwensiu:fix/acp-npx-prefix-resolution

Conversation

@Kwensiu
Copy link
Copy Markdown
Contributor

@Kwensiu Kwensiu commented May 5, 2026

Fixes #150

描述

在生产环境中,部分 npm 安装的 ACP 智能体命令可能不在应用进程的 PATH 中。

例如 Claude/Gemini 的 shim 实际位于 npm global prefix 下,但桌面应用启动时无法通过 PATH 找到
导致即使设置页显示已安装,新建对话页仍提示对应 CLI 未安装

通过截图:

Claude Gemini
Screenshot_2026-05-06_02-42-13 Screenshot_2026-05-06_02-42-42

改动

  1. NPX 智能体命令解析改为:先查 PATH,找不到就回退到 npm prefix -g 查看对应目录
  2. npm global prefix 解析增加超时和进程内缓存,避免状态/列表接口反复同步执行 npm
  3. 连接前检查、状态接口、列表接口和实际 spawn 统一使用相同的命令解析语义
  4. Unix 下额外校验 npm shim 是否可执行
  5. 补充相关单元测试,覆盖 npm prefix 解析、缓存失败重试和命令 shim 检测

不一定是最优解,当前 PR 仅提供思路和在我环境下可生效的实现方式,没有进行多个环境的验证

其他

一个截图
image

注意到这个提示,在当前修改后,会在每次新建对话时都会出现约 0.3s(当前搜索/回退所必须的耗时)。本身没有什么问题,但是我觉得可以后续为它添加一个 loading 状态/骨架,这样语义比较正确

@xintaofei
Copy link
Copy Markdown
Owner

谢佬pr,晚上我测试一下

@Kwensiu Kwensiu force-pushed the fix/acp-npx-prefix-resolution branch from 0526e97 to 979a539 Compare May 6, 2026 07:30
@Kwensiu
Copy link
Copy Markdown
Contributor Author

Kwensiu commented May 6, 2026

改成单次新对话 Agent 列表请求内,复用 npm global prefix 探测结果,避免重复执行 npm prefix -g,减少列表加载延迟

@xintaofei xintaofei merged commit bca5d95 into xintaofei:main May 6, 2026
xintaofei added a commit that referenced this pull request May 6, 2026
- feat(login): localize the web login page across all 10 supported languages.
- fix(acp): resolve `npx`-launched ACP agents from the npm prefix, and cache the resolution so agent listing no longer stalls on repeated lookups. Thanks to @Kwensiu for #151.
- fix(chat): resume the original ACP session after a reconnect on new-conversation tabs, instead of starting a fresh session.
- fix(chat): mark conversations as cancelled (not failed) when the user cancels a streaming turn, including the sidebar badge label.
- fix(chat): surface agent turn failures with an explicit error state instead of leaving the turn silently pending review.
- fix(chat): show the streaming thinking indicator while reasoning is in flight and hide the expand toggle when reasoning is empty.
- fix(chat): correct the Claude Code agent icon hover title.

-----------------------------
# 发布版本 0.11.7

- 功能(登录):Web 登录页已覆盖全部 10 种支持语言的本地化。
- 修复(ACP):通过 `npx` 启动的 ACP 代理改从 npm prefix 解析,并缓存解析结果,避免代理列表每次扫描时反复阻塞。感谢 @Kwensiu#151 中的贡献。
- 修复(聊天):在"新建会话"标签页上重连后,恢复到原始 ACP 会话,而非新开一个会话。
- 修复(聊天):用户取消正在流式输出的回合时,会话状态标记为"已取消"而非"失败",侧边栏徽标文案同步更正。
- 修复(聊天):代理回合失败时显式呈现错误状态,不再静默停留在待审阅。
- 修复(聊天):推理过程中显示流式 thinking 指示器;推理内容为空时隐藏展开按钮。
- 修复(聊天):修正 Claude Code 代理图标的悬浮标题。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 生产环境中 npx ACP 智能体实际已安装,但对话页提示未安装

2 participants