Files
dsh-enhancements/docs/computer-use-PROGRESS.md
江晨 3e364d576d docs: 电脑操作模式进度存档(暂停待续)+ 调试脚本
- docs/computer-use-PROGRESS.md: 已完成/已知问题/关键机制踩坑记录
- tools/test-enum.ps1: EnumWindows 基准脚本(本机验证可用)
- PLAN.md 更新:阶段3进行中,因余额暂停
2026-08-17 12:10:32 +08:00

34 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 电脑操作模式 — 进度与踩坑记录(暂停待续)
> 用户因 API 余额不足暂停开发。本文件记录已完成的进展与未解决问题,便于续作。
## 已完成 ✅
- **dsh-computer 插件**comp-4/pkg-12host-only,已运行):8 个工具注册
- `screen_capture` — 全虚拟屏幕截图 → PNG(**实测成功**1707x1067
- `screen_vision` — MiniMax M3 视觉分析(node 直连 NVIDIA API,带 429 重试)
- `screen_move` / `screen_click` — user32 SetCursorPos + mouse_event
- `screen_type` / `screen_key` — SendKeys
- `screen_list_windows` / `screen_ui_tree` — EnumWindows + UI Automation
- **视觉链路验证**:mmx 脚本与直连 API 均可用(429 限流已恢复)
## 已知问题 🔧(续作时优先修)
1. **screen_vision 语法错误**:node 视觉脚本的一行式 IIFE 有括号问题(`[stdin]:12`)。
修复方案:改成多行格式化脚本(本仓库 tools/ 下有样例结构)。
2. **screen_list_windows 经插件调用返回空**:脚本本体与 LF-only stdin 均在本机 pwsh
验证正常(能列出真实窗口),但经宿主 ctx.shell 执行时 stdout 为空。
疑点:宿主 shell 执行器对含空格 command 的 stdin 管道处理(node 的 stdin 正常,
powershell 的不行);或 Add-Type 在 executor 环境下静默失败。
排查建议:让工具在 exitCode==0 时也返回 stderr;或改用 `pwsh -Command -`
或把 PS 脚本先落盘为 .ps1 文件再 `powershell -File` 执行。
3. **沙箱**:宿主 ctx.shell 默认 workspace-write 本机不可用 → 必须显式
`sandboxPolicy: danger-full-access`(已解决,见 plugins/*/host.js)。
## 验证过的关键机制(写插件必读)
- ShellExecRequest **没有 args 字段** → 脚本走 stdin、数据走 env 或 JS 字面量
- `res.stdout``CollectedOutput`(取 `.text`);结果字段 `res.exitCode`;工作目录 `workdir`
- `btoa` base64 曾引发中文乱码 → 数据用 `JSON.stringify(JSON.stringify(...))` 嵌入
- 本机 EnumWindows 脚本(tools/test-enum.ps1)输出真实窗口列表可作基准