Replies: 1 comment 2 replies
|
Thanks for the three-arm control — the fact that minimal ×
npm install @argszero/cordis-plugin-sandbox-grant-advisorMount it as a patch row ( What it does. One listener on the public
So the model stops spending turns on a retry that cannot succeed, and the user gets your arm-3 remedy (the non-PTY one-shot path) without the model having to invent it. Three decisions worth stating, because each one is a way this could have been wrong:
Honest limits. The core-side asks remain open: ideal is still (1) minimal working under confinement, and (3) a backend fallback to a non-PTY shell when the sandbox is on. This plugin only makes the failure legible in the meantime; it changes no preset, no mode, and no backend. It was built and tested on macOS, so the Windows path itself is not witnessed here — what is tested is the decision layer (classification, the mode gate and its fail-closed paths, once-per-agent delivery, the wiring to a real cordis context and the real One thing this does not fix, which your report is right to flag: the backend still logs nothing about the PTY spawn failure, so |
Uh oh!
There was an error while loading. Please reload this page.
Summary
在 Windows 上,
minimal(极简模式)预设挂载的是持久 PTY shell(
dsh-tool-pwsh-persistent+dsh-terminal-bash,shellDialect: pwsh)。当权限预设的沙箱不是
danger-full-access(即workspace-write/read-only)时,任何 shell 调用都会立即失败:
同一台机器、同样带沙箱的情况下,
standard(标准模式)预设的pwsh工具完全正常——因为它用的是
dsh-tool-pwsh(一次性子进程),不经过 ConPTY。影响:用户只要选择「极简模式 + 任意带沙箱的权限预设」,命令行能力就完全不可用,
而且错误信息不指向真正的原因(看起来像 shell 坏了,实际是 PTY 建不起来),
排查成本很高——我自己追查这个问题花了很久,中途还被"会话档案损坏"等无关线索带偏。
Reproduction
前置条件
Windows,且未安装 PowerShell 7(
C:\Program Files\PowerShell\7\pwsh.exe不存在)——此时
resolvePwshPath()按设计兜底到%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe(5.1)。该 shell 本身完全可用(标准模式下正常工作)。
最小复现(经 DSH)
minimal(极简模式)workspace-write(或任何sandbox !== danger-full-access的预设)pwsh工具执行任意命令(例如echo test)Error: PTY shell exited during startup,重试无效对照实验(三次,均在同一台机器上)
第 2 行与第 1 行只差沙箱模式 → 沙箱是判别条件。
第 3 行证明:带沙箱 + 标准模式没问题 → 问题只在「持久 PTY × 沙箱」这个组合。
更底层的最小复现(绕开 DSH,直接用 node-pty)
在 DSH 沙箱(
workspace-write)下用一次性 pwsh 工具执行:Current behavior
报错位置
dsh-terminal-bash/lib/index.js:440:即
waitReason === "session_exit"(顶层 shell 已退出),而非启动超时。主机日志没有记录真正的失败
%APPDATA%\DSH Desktop\logs\host\下只有良性警告,没有 PTY spawn 失败的记录:这使得用户/维护者无法从日志定位问题。
统计证据
对一份 46 轮的完整会话日志,按调用时生效的沙箱模式分组统计
pwsh工具结果:pwsh结果danger-full-accessworkspace-write与第三方插件无关
排查中一度怀疑是第三方审批插件,已排除:上面的对照组第 3 行就是
workspace-write沙箱 + 该审批插件同时启用,工作正常。Expected behavior
按优先级,以下任一即可:
workspace-write下pwsh能正常工作(首选);明确指出"当前沙箱模式与 PTY 后端不兼容",而不是笼统的
shell exited during startup;(
dsh-tool-pwsh已经证明该路径在沙箱下可用)。Environment
0.1.5-rc.2dsh-plugin-desktop 2.0.13resolvePwshPath()设计行为)1.2.0-beta.15(随 DSH 分发),win32-x64 prebuild,仅含 conpty,无 winpty 回退dsh-terminal-bash/dsh-pwsh-local/dsh-tool-pwsh-persistent/dsh-tool-pwsh/dsh-agent-presets,均为0.1.5-rc.2预设差异(关键)
dsh-agent-presets/presets/minimal/agent.cordis.yml:dsh-agent-presets/presets/standard/agent.cordis.yml:PTY shell exited during startup这句错误只出自dsh-terminal-bash,而只有 minimal 会加载它。
一点未经证实的推测(仅供定位参考,请勿当作结论)
猜测方向:Windows 沙箱可能使用受限令牌(restricting SID)+ Job 对象,
导致 ConPTY 的助手进程(
OpenConsole.exe)无法创建。我没有直接证实这一点——我能证实的是"沙箱模式是判别条件"
附:可用的规避方式
standard(标准模式)——命令行可用,同时保留沙箱;dsh-tool-pwsh(与 standard 相同),放在
<DSH_HOME>/.agent-presets/<id>/下即可,无需改动安装目录、升级不会被覆盖;All reactions