WeKnora
Tencent
Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:beijingwahw/dsh-computer-use-plugin
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
中文 | English
基于 DeepSeek Harness (DSH) 构建的 Computer Use 插件。完全摒弃底层 UI 树依赖,采用纯视觉 Grounding 架构,让 AI 像人类一样通过"看"屏幕截图来理解和操作电脑。
llm/pre-request 注入,无论截多少图,模型永远只看到最新 N 张 + 历史文字占位符{status, state_anchor, next_step} 三段式结构化反馈,MANDATORY 指令强制 ReAct 验证闭环start_complex_task 元工具自动将长程任务拆解为原子操作并逐步执行,子任务失败即 fail-fast针对纯视觉 CUA Agent 的四个真实失败模式,各以一个引擎对症击破:
| 失败模式 | 引擎 | 机制 |
|---|---|---|
| 盲点:点击落空却以为成功 | 行为效果验证(perceptualHash + actionVerifier) |
动作前后各取一次整屏 dHash 指纹,汉明距离对比;相似度 > 0.97 判定疑似无效操作,锚点直接告警并引导 zoom_inspect 复位 |
| 坐标幻觉:全屏估坐标误差大 | 二阶段定位(zoom_inspect) |
裁剪目标邻域放大重绘 2 倍密度细网格,锚点附带 crop_bounds 与映射公式 full_x = x0 + fx*(x1-x0),微观定位精确映射回全屏 |
| 无跨会话记忆:每次从零找按钮 | 场景式 UI 记忆(remember_ui / recall_ui) |
验证生效的点击自动沉淀为 landmark;自然语言召回(中英混合分词 + 重合系数 + 成功次数加成 + 时间衰减),召回值仅作先验、强制截图复核 |
| 不可复现:成功路径无法固化 | 行动日志与重放(journal + replay_actions) |
post-execute 观察者记录全部动作 JSONL(可落盘);replay_actions 按 confirm 显式确认后逐步重放,成功操作序列即刻变成可执行宏 |
配套增强:
dryRun: true):动作类系统调用只记录不执行、截图保持真实 —— 提示词调试与演示的零风险沙箱click_mouse.confidence < 0.6 时主动建议先 zoom_inspect,把模型的不确定性显式化四大引擎各自工作后,暴露出四个新的系统性损耗点,本轮以「指纹驱动」统一击破:
| 损耗点 | 机制 | 收益 |
|---|---|---|
| 重复截图:屏幕没变也全管线跑一遍 | 变化门控(change-gated screenshots):截屏后先算 dHash,与窗口内最新指纹距离 ≤ 3 ⇒ 跳过压缩/入窗,返回 unchanged 锚点引用旧图(force:true 可强制刷新) |
稳态场景 Token 与 CPU 双降;模型被明确告知"屏幕未变,勿重截" |
| 动画期误判:固定 400ms 后验证,把"还在动"当成"生效了" | 自适应稳定等待:轮询整屏指纹直到相邻两次距离 ≤ 1(屏幕稳定)或超时 settleMs×4 | 验证窗口自动对齐 UI 真实节奏,快页面提前返回,慢页面等够 |
| 原样重试死循环:失败后同坐标再点、同文本再输 | 防死循环守卫:上次同签名动作已验证无效 ⇒ 立即拦截并注入换策略指引(zoom / recall / 键盘导航 / 滚动);无效果信息时第 3 次重复拦截 | 幂等重试留余地,盲目复读必拦截 |
| 记忆跨场景误召回:登录页记住的坐标被召回给设置页 | 场景指纹加成:landmark 记录形成时的整屏指纹;recall_ui 用当前窗口指纹做匹配,同场景(相似度 ≥ 0.9)+0.3 强加成 |
"还是那个界面"时历史坐标才最可信,记忆从"迷信"变"情境化" |
配套:Token 仪表盘 —— 每张截图锚点携带 context_images: n/limit,模型随时知道图片预算余量。
前两轮的全屏指纹验证存在一个被掩盖的缺陷:全屏 dHash 对局部小变化不敏感——输入框出现光标、短文本上屏这类元素级反馈,在 64 位全屏指纹里只翻转几位,相似度仍 >0.99,会被误判为盲点。本轮以三个机制补全感知维度:
| 机制 | 设计 | 解决的问题 |
|---|---|---|
| 双尺度验证 | regionDhash:以动作点为中心裁剪邻域单独取指纹。判定矩阵:全屏变 = page-level;仅区域变 = element-level(光标/高亮/文字);都没变 = 盲点 |
局部反馈的误判:点击确实生效但画面只变了一小块 → 不再误报"点空了" |
焦点追踪(focusTracker) |
点击/拖拽终点自动登记焦点(带 30s 过期);type_text 无需模型传坐标,自动围绕焦点区域验证 |
工具间隐式上下文:输入的位置几乎总是上次点击的位置,文字上屏这类最微弱的变化获得专属放大器 |
预期锚定(expected_change) |
click_mouse/type_text 新参数:行动前声明预期视觉变化;锚点回显预期,next_step 强制要求截图核对,不符即视为部分失败 |
验证从"有没有变化"升级为"变化是否符合预期"——把模型的世界模型(world model)显式化并置于可核对地位 |
| 预算感知编排 | start_complex_task 新参数 time_budget_sec:子任务边界检查时钟,超时优雅中止并返回 [TIMEOUT] + 部分轨迹 |
长任务的无限烧钱问题:降级而非失控 |
锚点效果块示例(第三代):
"effect": {
"detected": true,
"scale": "element-level",
"screen_similarity_pct": 99.8,
"region_similarity_pct": 71.2
}
全屏几乎没变(99.8% 相似)但焦点区域剧变(71.2%)——典型的一次成功聚焦输入,旧版会误报盲点,新版精确识别为元素级效果。
前三轮的验证停在像素层——"变化是否符合预期"最终仍靠模型看图自判。本轮装上文字感知(本地 OCR)与变化定位(视觉差分),把验证推到语义层:系统直接确认"预期的内容出现了没有"。
| 机制 | 设计 | 解决的问题 |
|---|---|---|
find_text:文字→坐标定位 |
截干净屏(无网格叠加)→ 本地 OCR → 每个命中文词返回精确中心坐标 | 带文字标签的元素不再靠坐标估算——坐标幻觉的最大来源被彻底消灭 |
read_text:区域文字读取 |
区域裁剪 + 放大 + OCR,返回纯文本 | 只需文字内容时用文本替代截图,Token 数量级下降 |
diff_view:视觉差分 |
最近两张截图逐像素差 → 分块聚合 → 连通域合并 → 红框差分图 + 变化区域坐标清单 | "动作到底改变了什么"由系统算出并画出来,模型不再肉眼对比两张整屏 |
| 语义自证(type_text) | 输入后自动 OCR 焦点邻域,核对输入的文字真的上屏了(无需参数) | "打进了错误的框 / 输入法吞字 / 焦点丢失"三类隐形事故现形 |
expected_text(click_mouse) |
点击后 OCR 点击点邻域,核对预期文字 | 像素变化 + 语义命中 = 双重确认;语义不符即使像素变了也判失败 |
OCR 按需启用(enableOcr: true,语言包首次使用联网下载,默认 eng,中文 chi_sim+eng);OCR 不可用时所有语义特性优雅降级,其余功能不受影响。diff_view 纯 sharp 实现,零额外依赖。
验证栈最终形态(四层):
L1 像素 dHash 双尺度 —— 有没有变化?在哪一级(页面/元素)?
L2 定位 visualDiff —— 变化的精确边界与中心坐标
L3 语义 OCR 核对 —— 变化是否包含预期的文字内容?
L4 预期 expected_* —— 与模型行动前声明的预期对照
前四轮都在改进「单次执行的质量」;本轮解决两个更高维的问题:成功经验无法沉淀(同一个工作流每次从零探索)与凭据安全(Agent 不该替人输密码)。
| 环节 | 机制 |
|---|---|
| 归纳 | 复杂任务成功后自动把本次轨迹(markTaskStart 以来的可重放动作)固化为技能:触发描述 + 步骤序列 + 入口场景指纹;save_skill 供手动沉淀任意日志片段 |
| 去重强化 | 完全相同的步骤序列不重复建卡——同一工作流做三遍 = 一个技能验证三次(可靠度 3/3),而非三张孤儿卡 |
| 持久化 | skillLibraryPath 配置后技能跨会话存活:上一个会话学会的工作流,下一个会话开箱即用 |
| 匹配 | match_skill:文本重合 + Laplace 平滑可靠度 + 入口场景同屏加成(dHash ≥ 0.9)+ 新近度;技能是先验不是保证,锚点仍要求事后验证 |
| 闭环校准 | run_skill 的每次成败回写 successCount/attemptCount —— UI 演化导致技能失效时可靠度自然衰减,匹配排序自动降级;失败提示引导手动修复并重新 save_skill |
世界级 CUA 的安全共识(如 Operator):凭据类输入交还用户。本实现为两段式,全部复用既有基础设施:
click_mouse 的 target_description 命中风险词(密码/验证码/2FA/OTP/API key…,可配置)⇒ focusTracker 将焦点标记为敏感,锚点携带 sensitive_focus 并预警type_text 到敏感焦点(或文本自身命中风险语义)⇒ 返回 ACTION_REQUIRED,要求暂停并请用户亲自输入;待输内容绝不回显([REDACTED])前五轮堆出了 32 个数学引擎与 D-1~D-7 器官方阵;本轮停止加-feature,把整个器官群焊牢:四条主链致命修复(Python 服务真实点击此前 100% TypeError、shm 传输生命周期注册表单主、降级排练不再误锁主机执行、D-4 判决三方言配对令 rejected 否决权首次可达)、审批协议改为"请求 ≠ 同意"(grant_approval 是执行前置)、安全面(AppleScript 注入序、中间件洋葱序、nonce 双解码)与数十项中危修复。287 测试全绿起步。
| 留白 | 落成 |
|---|---|
排练永远 degraded(无验证层) |
虚拟屏模拟器(sandbox/virtualScreen.ts):确定性控件世界,命中测试产 L1 证据、焦点输入产 L4 证据(expectedText 核对)——历史性一刻:passed 首次可达,肌肉记忆固化真实触发 |
| Windows 环境塑形缺席 | WindowsAdapter:PowerShell + Win32 P/Invoke(raise/maximize/move/set_zoom),几何快照 undo,PS 单引号转译封死标题注入面 |
| Actor 无真实后端 | 双通道:DSH agents 服务在场走服务;缺席走技能回放(可靠度 > 0.5)并回写结局;双缺席诚实 [FAILED] |
| 会诊只有规则表 | 贝叶斯皮层:六症候群 × 五信号 CPT,log-sum-exp 精确枚举;规则为主、信念侧写随报告附体 |
| 统计兵器缺口 | SSD 二阶随机占优(FSD 交叉时按下偏矩不等式裁决)、同形字归一化(西里尔/希腊/全角三层混淆仍命中风险词)、噪声容忍环检测(汉明容差 6) |
| 无科学基准 | 基准套件(npm run bench):消融/标定/参数消融/联合标定四件套,首跑全绿 |
法条:仓内天然属主自荐,宿主裁决总线。 D-5 apply() 经可选 ctx.set? 面自荐 dsh.sandbox 引擎视图;D-7 自荐 dsh.knowledge-pipeline;宿主无 set 面 ⇒ 既有诚实降级一字不动。同时把三处"死导出"契约占位符激活为执法面(hasVerificationLayer 进审计面、SandboxDoctorView 得真实门面适配器、intent 铸造走 IdGenerator 三重防碰撞)。
set_contrast:SystemParametersInfo 官方 API(SPI_GETHIGHCONTRAST 快照 → SPI_SETHIGHCONTRAST 置位,undo 还原原 flags)calibrateCptFromRules):32 信号组合全枚举 + 共现计数 + Beta(1,1) 平滑 + 专家收缩;与规则首判一致率 0.484 本身即量化数据,真遥测接入 = 换 oracle 接口不变token.pid == peer_pid(非 Linux 优雅回退)swarm 跨会话重复入账以持久化消费水位根除(restore 后跳过已消费前缀);审批盲区硬前置根除——闸门开启时双描述通道皆沉默的点击返回 ACTION_REQUIRED 而非透明放行(合规是零成本的:带描述重发即可);虚拟屏 drag 命中证据与 switch_window 标题匹配焦点证据补齐。套件 325/318/0 败。
七轮战役后的全量待完善清单,按推荐执行序 28 项逐一兑现(test/epochO.test.ts 逐项执法):
环境与真机:Windows 真机基准落地(test/realMachineWin.bench.ts 四实验全绿 —— D-5 服务真截屏 → tesseract.js 离线 OCR → 真 pyautogui 物理点击 → tkinter 世界状态翻转;E1b 陷阱改道与 E3 学习曲线在真机上复现);POSIX shm 跨进程往返测试 + Linux CI workflow(/.github/workflows/ci.yml);sharp/tesseract.js 入库后 7 项环境闸全绿。
潜伏 bug 群根除(真机执法的战果):① Windows set_contrast 的三只(apply 误要求窗口句柄 / PS \" 转义非法 / pvParam 须为 HIGHCONTRAST 结构体)—— 真机往返 126→127→126 VERIFIED;② screen.py JPEG 闭包 UnboundLocalError(任何平台必炸);③ GPD 矩估计反演代数错误((k−1)/(2k−1) → (k−1)/(2k),双估计器上线后现形);④ contextManager id 时钟回拨。
数学器官:GPD PWM 第二估计器 + 一致性检验(主估计权归 PWM);双边 CUSUM + 环前终身基线(基线不再随环翻转,痊愈臂 = RECOVERY 洞见);W₁ 信息熵加权(w1Info/infoRatio 双视图显形掩蔽);I-4 相干瞬移场(≥2 特征同矢量共移 = 刚体重排证据,单候选诚实瞬态);LTLf 性质挖掘器(有界响应/先序/防重三族自动立法,支持度≥3 零反例才立);A² 临界值 MC 自举表 + Kalman Q/R / Schmitt / NCD 阈标定回路(src/calibration.ts)。
架构补全:dsh.vision.structured/traditional 服务自荐(单属主铁律);worldModel run 级快照(fork/merge 重放,并发同号类型重铸);restore 悬空引用三重校验;沙箱 L3 场景 OCR(sceneOcr 点燃休眠的 L3-semantic 层);switch_tab 标签页栈模型(role='tab' 循环指针);SO_PEERCRED Node 客户端半(undici UDS dispatcher + 桥注入);token 真实消耗计量(工位自报回路 tokenUsageReported);审批根除的模型侧协议强制(target_description schema 必填);首轮知识检索串行化选项;homoglyph Unicode confusables 全表(1665 条蒸馏,~22MB/s)。
对全库(TS 13 文件深审 + Python 3 文件 + 机械扫描)猎杀潜伏 bug,共根除 7 只,并把每类虫型铸成永久免疫:
auth_middleware 顺序倒置:peer-PID 比对在令牌解析之前执行——UDS+Linux+peercred 路径(M 纪元 SO_PEERCRED 服务端半)落地即 UnboundLocalError 崩溃。M-4 源级执法从未运行故未现形。calibration.ts 的 GPD CDF 用了与采样器相反的 ξ 符号约定——MC 临界表在错误分布下计算(分位 78–160 vs 文献 ~0.5–1.1)。calibrateNcdThreshold 被毒化后仍返回貌似合法的标定;calibrateKalmanQR 的 predicted 字段从未被使用(API 谎言)——修为真互补滤波。recombine 去重强化路径漏 save()(崩溃窗口内计数丢失)。verify 的 V2c 环境假设(pyautogui 装机后"无显示"模拟失效——改毒性模块注入,任何机器确定性执法)。免疫机制(创世):scripts/bug_class_lint.py —— Bug 类注册表(BCR):每类历史虫型(PS 引号律/闭包重赋值/时钟单调假设)铸成机械检测器,全库扫描签名形状,接入 npm run verify 构建闸;test/epochP.test.ts —— 属性测试炮台:全部统计引擎过「已知参数恢复 + 闭式对齐 + 不变量」关(Hurst iid→0.5、置换检验对 Fisher 闭式、贝叶斯归一、NCD 对称、A² 文献带、Kalman 对 DARE 闭式、汉明度量律、LTLf 有限迹语义)。示例断言抓不住约定错配——参数恢复能。
对全部模块簇的一次创世级升级——每簇一件真正的新数学器官(test/epochQ.test.ts 逐件执法):
src/proof.ts(新器官):Merkle Mountain Range——追加型证据流的 O(log n) 包含证明(叶数为 2 的幂的山峰二进制分解 + 峰袋根)。journal 与 sandbox 链双双接线:审计者凭单根 + 单证明核验单条记录在册,免整链重放;篡改任一叶 ⇒ 全部旧证明失效(Q-1 执法 1..1000 全尺寸 + 全篡改检出)。dualSimilarity 保守融合(min);actionVerifier 判决携带 phashCorroborates 独立第二意见。entropyBits(平滑预测熵——「点了之后世界去哪」的主张强度,L3 付费观看的正当性可量化)与 posteriorConcentration(可信的不确定性 vs 廉价的均匀无知)。parents/generation——合成技能登记基因供体谱系;lineage(id) 祖先链回溯(环守卫诚实截断);容量驱逐感知谱系存续(活跃祖先 ×1.5 加成——基因仍在后代中表达的技能不死)。cohensH(反正弦效应量——比例近 0/1 域不虚胀)+ mannWhitney(非参秩检验,并列校正 + 连续性修正;延迟是重尾——GPD 纪元的教训,A/B 对照配秩检验不配 t 检验)。「主张要有数字」升格为「数字要有效应量与检验」。predicted() 外推长延迟后的焦点位置(钳半屏);证据不足诚实回退原点。对 Q 纪元未触及的六个模块簇各铸一件新器官(test/epochR.test.ts 逐件执法):
src/fuzzy.ts(新器官):子串编辑距离近似匹配(Wagner–Fischer 行进形;Myers 位向量的渐近界备案、审计性优先选经典 DP)——OCR 把 l 读成 1、O 读成 0、吞空格时,expected_text 的逐字节对照在真机必然漏判;容错 ≤⌈m/6⌉ 判决接入 textReader 语义核对。click_element 的"点 3 号"不再每帧语义漂移。score2。给仍未触及的模块簇铸六件,并把前世代的环闭环(test/epochS.test.ts 逐件执法):
EVIDENCE ANCHOR MISMATCH 置顶报告(R-4 的另一半,快照-证据一致性从"可锚"到"可验")。0.05·min(s,6) 升格 (s+1)/(s+2) 贝叶斯曲率——一次成功不配满信任、渐近饱和、零成功留先验底。enforceMinedProperties —— R/Q 纪元挖掘的性质在新迹上逐位执法(bounded-response 破缺/抢跑/连击定位),性质库从描述统计升格为在线规约(mine→enforce 闭环)。主题:给只有正半边的机制补对称、把已立器官传播到残余模块(test/epochT.test.ts 逐件执法):
uniform(0, base·2^n) 取代定值退避(AWS 经典形态)——并发等待者重试相位解相关,惊群免疫。GUARD_BLOCKED 标记种类——每次守卫拦截都是防篡改链上的政策裁决事实(proof 器官闭环到守卫层,拦截不可抵赖)。src/organCensus.ts):七纪元 33 件数学器官登记入册(层/数学根基/自检 λ),quality_checkup 自省段逐件点名——genesis 的 "premature-impl" 规则至此有了对称面:impl 之后的 operational census。给七纪元铸的器官上科学法庭:test/organAblation.bench.ts 八项微基准(确定性、可复现),每件器官的贡献由数字判决(test/reports/organ-ablation-report.md 全表):
| 器官 | 审判数字 |
|---|---|
| 模糊匹配 | OCR 变体恢复率 100% vs 逐字节基线 0% |
| 三指纹 | 同/异图双指 100%;90° 旋转环指捕获 100% vs 双指 0%(正交性实证) |
| BM25 | 稀有词查询 MRR 0.583 vs 二值基线 0.250 |
| 通道仲裁 | 劣质主通道场景 EMA 收益 226/300 vs always-agents 104,逼近预言机 234 的 96.6% |
| 蓄水库分位 | 三分布(均匀/重尾/双峰)ΔP50=ΔP95=0.0%(m=512, n=2000) |
| MMR | 千叶证明长度 ≤ log₂(n)+1(实测 6/9) |
| RRF | 通道重标定(×10)排名稳定 100% vs 加权和 0% |
| LTLf 执法 | 三型注入违例逐位全中(响应@1/抢跑@0/连击@5) |
审判日的真实战果:仿真抓到 S-3 乘性权重的复辟缺陷(对称底权触底后回到平权 ⇒ 劣质通道周期性复辟,151/300)——裁决升格为 EMA 成功率仲裁(只更新被选通道,未选冻结),回写实现后逼近预言机。另裁决两例测试前提不成立(加权 0.3 律在合成域不真输、倒序非 OCR 域变异)——法庭对自己一样诚实。
approval 审批簿记、orchestrator 通道 EMA——V 日泄漏源),执法矩阵:脏化 → reset → 必须回到初值。| 工具名称 | 描述 | 核心参数 |
|---|---|---|
take_screenshot |
截屏 + SoM 叠加 + 压缩 + 滑动窗口 + 弹窗传感 + 变化门控 | region, force? |
click_mouse |
归一化坐标点击,内置 dHash 效果验证 + 自动记忆 | x, y, button, confidence?, target_description? |
type_text |
焦点处输入文本,支持跨平台一键清空 | text, clearFirst |
scroll_page |
四方向滚动 | direction, amount |
press_hotkey |
组合键(键位白名单,防注入) | keys (数组) |
drag_mouse |
拖拽(四拍时序:移→按→移→放) | startX/Y, endX/Y |
dismiss_popup |
零副作用元工具:强制 ReAct 重新分析 | 无 |
switch_tab / switch_window |
标签页 / 窗口切换(含降级路径) | direction / titleKeyword |
click_element |
按 ID 点击(需开启元素模式,短时缓存防 ID 漂移) | id |
extract_ui_vision |
本地视觉模型精确提取(可选) | 无 |
start_complex_task |
Planner-Actor 编排引擎 | userRequest |
zoom_inspect |
区域裁剪放大 + 细网格,二阶段精定位 | x, y, half_size? |
find_text / read_text |
文字→精确坐标 / 区域文字读取(需 enableOcr) |
keyword / x?,y?,half_size? |
diff_view |
最近两截图的视觉差分:红框变化图 + 区域坐标清单 | 无 |
remember_ui / recall_ui |
场景式 UI 记忆写入 / 自然语言召回 | description,x,y / query |
replay_actions |
重放日志中的动作序列(宏) | confirm, from_step?, to_step? |
save_skill / match_skill / run_skill |
技能沉淀 / 可靠度匹配 / 一键执行(成败回写可靠度) | description / query / id,confirm |
Node.js >= 18(推荐 22)与 pnpm。原生依赖(sharp / @nut-tree/nut-js / screenshot-desktop / tesseract.js)随插件自动安装。
推荐的安装方式:
dsh plugin add beijingwahw/dsh-computer-use-plugin --profile web
以 pnpm 为例安装(git 依赖):
pnpm add dsh-computer-use-plugin@github:beijingwahw/dsh-computer-use-plugin
或直接写入 package.json 依赖后 pnpm install:
{
"dependencies": {
"dsh-computer-use-plugin": "github:beijingwahw/dsh-computer-use-plugin"
}
}
安装即用:
dist/ 随仓库分发),安装时不执行任何构建脚本(无 prepare/postinstall),main 直指 dist/index.js@deepseek-ai/cordis / dsh-tools / schemastery),由 DSH 宿主提供dsh.bundle 指向 cordis.patch.yml,插件随安装自动注册激活pnpm dsh web
需要覆盖默认配置时,把包内 cordis.patch.yml 的 insert 条目并入你自己的 patch(已安装场景 name 直接用包名解析,无需绝对路径):
- insert:
- id: dsh-computer-use-plugin
name: 'dsh-computer-use-plugin'
config:
mouseSpeed: 1500
compressWidth: 1440
jpegQuality: 75
# ……全部字段均有代码默认值,可按部署裁剪
git clone https://github.com/beijingwahw/dsh-computer-use-plugin
cd dsh-computer-use-plugin
pnpm install # 安装 devDependencies(typescript 等)
npm run build # 重新生成 dist/(改代码后必须重跑并提交)
npm test
源码直载调试时,patch 条目的 name 写入口文件绝对路径(如 /你的路径/dsh-computer-use-plugin/dist/index.js)。
index.ts (apply)
├─ systemPrompt 三正交段注入(定位规范 / ReAct 工作流 / 弹窗处理)
├─ buildAllTools(config) 工具工厂(混合模式按配置启用)
├─ start_complex_task Planner-Actor 元工具
├─ registerAllGuards 边界 / 熔断 / 审计 / 弹窗联动
├─ onLlmPreRequest 滑动窗口图片注入模型请求
└─ ctx.effect 生命周期清理
截图管线:captureScreen → 多屏感知 → SoM 叠加 → sharp 压缩 → 滑动窗口 → 弹窗传感 → 状态锚点
[SUCCESS]/[FAILED] 字符串协议 + fail-fasttools/pre-execute 等)已集中在 src/guards/hooks.ts 单点收口,换版本只需改一处MIT
Give DeepSeek Harness real "eyes" and "hands"! 赋予 DeepSeek Harness 真正的"眼睛"和"双手"!
中文(顶部) | English
A Computer Use plugin for DeepSeek Harness (DSH). It completely abandons the underlying UI-tree dependency and adopts a Vision-Only Grounding architecture, letting the AI understand and operate a computer by "looking" at screenshots — just like a human.
llm/pre-request injection — however many screenshots you take, the model only ever sees the latest N images plus historical text placeholders{status, state_anchor, next_step} triple; MANDATORY directives enforce the ReAct verification loopstart_complex_task meta-tool decomposes long-horizon tasks into atomic actions and executes them step by step, failing fast on subtask failureFour engines targeting the four real failure modes of vision-only CUA agents:
| Failure mode | Engine | Mechanism |
|---|---|---|
| Blind spot: click misses but agent believes it succeeded | Effect verification (perceptualHash + actionVerifier) |
Take a full-screen dHash fingerprint before and after each action and compare Hamming distance; similarity > 0.97 flags a suspected no-op — the anchor warns and guides zoom_inspect recovery |
| Coordinate hallucination: full-screen estimation is imprecise | Two-stage grounding (zoom_inspect) |
Crop the target neighborhood, enlarge, redraw a 2×-density fine grid; the anchor carries crop_bounds and the mapping full_x = x0 + fx*(x1-x0) for exact back-mapping |
| No cross-session memory: re-finding the same button from scratch every time | Scene-based UI memory (remember_ui / recall_ui) |
Verified clicks are automatically persisted as landmarks; natural-language recall (mixed CJK/EN tokenization + overlap coefficient + success bonus + time decay); recalled values are priors only — screenshot re-verification is enforced |
| Non-reproducible: successful paths cannot be persisted | Action journal & replay (journal + replay_actions) |
A post-execute observer records every action as JSONL (optionally persisted); replay_actions replays step by step after explicit confirm — a successful sequence instantly becomes an executable macro |
Companion enhancements:
dryRun: true): action syscalls are recorded but not executed; screenshots stay real — a zero-risk sandbox for prompt tuning and demosclick_mouse.confidence < 0.6 proactively suggests zoom_inspect first, making model uncertainty explicitWith the four engines working, four new systemic losses surfaced. This round unifies them under "fingerprint-driven" control:
| Loss point | Mechanism | Gain |
|---|---|---|
| Redundant screenshots: full pipeline re-run even when the screen didn't change | Change-gated screenshots: after capture, compute dHash; distance ≤ 3 vs the newest fingerprint in window ⇒ skip compression/insertion, return an unchanged anchor referencing the old image (force:true bypasses) |
Token & CPU drop in steady state; the model is explicitly told "screen unchanged, don't re-capture" |
| Animation misjudgment: verifying at a fixed 400ms reads "still animating" as "took effect" | Adaptive settle: poll the full-screen fingerprint until two adjacent frames differ by ≤ 1 (stable) or settleMs×4 timeout | The verification window auto-aligns to real UI rhythm — fast pages return early, slow pages wait it out |
| Blind-retry loops: re-clicking the same coordinate after failure | Anti-loop guard: last same-signature action already verified ineffective ⇒ intercept immediately and inject strategy-switch guidance (zoom / recall / keyboard nav / scroll); with no effect info, the 3rd repeat is intercepted | Idempotent retries get leeway; blind repetition gets cut |
| Cross-scene memory false recall: login-page coordinates recalled for a settings page | Scene-fingerprint bonus: landmarks record the full-screen fingerprint at formation; recall_ui matches against the current window fingerprint — same scene (similarity ≥ 0.9) gets a +0.3 strong bonus |
Historical coordinates are most trustworthy only when "it's the same screen again" — memory goes from superstition to context-awareness |
Companion: Token dashboard — every screenshot anchor carries context_images: n/limit so the model always knows its image budget.
Full-screen fingerprinting hides a flaw: it is insensitive to small local changes (a caret appearing, short text landing) — a 64-bit full-screen hash flips only a few bits and still reads >0.99 similarity, misjudging real effects as blind spots. Three mechanisms complete the perception stack:
| Mechanism | Design | Problem solved |
|---|---|---|
| Dual-scale verification | regionDhash: fingerprint the neighborhood around the action point separately. Decision matrix: full screen changed = page-level; region only = element-level (caret/highlight/text); neither = blind spot |
Local-feedback misjudgment: the click did land but only a small patch changed → no more false "missed it" reports |
Focus tracking (focusTracker) |
Click/drag endpoints auto-register a focus (30s expiry); type_text needs no coordinates from the model — verification centers on the focus region |
Implicit inter-tool context: you almost always type where you last clicked; the faintest change (text landing) gets its own amplifier |
Expectation anchoring (expected_change) |
New click_mouse/type_text parameter: declare the expected visual change before acting; the anchor echoes it, next_step mandates a verification screenshot, mismatch = partial failure |
Upgrades verification from "did anything change" to "did the expected change happen" — the model's world model made explicit and checkable |
| Budget-aware orchestration | start_complex_task gains time_budget_sec: subtask boundary clock checks; on expiry, gracefully abort with [TIMEOUT] + partial trajectory |
The infinite-money-burning problem of long tasks: degrade instead of runaway |
Third-generation anchor effect block:
"effect": {
"detected": true,
"scale": "element-level",
"screen_similarity_pct": 99.8,
"region_similarity_pct": 71.2
}
Full screen barely changed (99.8% similar) while the focus region changed dramatically (71.2%) — a textbook successful focus into an input box. The old version would falsely report a blind spot; the new one precisely identifies an element-level effect.
The first three rounds stopped at the pixel layer — "did the change match the expectation" still relied on the model eyeballing images. This round installs text perception (local OCR) and change localization (visual diff), pushing verification to the semantic layer: the system directly confirms "did the expected content actually appear".
| Mechanism | Design | Problem solved |
|---|---|---|
find_text: text → coordinates |
Capture a clean screen (no grid overlay) → local OCR → return the exact center coordinates of every hit | Elements with text labels no longer rely on coordinate estimation — the biggest source of coordinate hallucination is eliminated |
read_text: region text read |
Region crop + enlarge + OCR, returns plain text | Use text instead of screenshots when only content matters — order-of-magnitude Token savings |
diff_view: visual diff |
Last two screenshots, pixel-wise diff → block aggregation → connected-component merge → red-boxed diff image + list of changed-region coordinates | "What did the action actually change" is computed and drawn by the system; the model no longer compares two full screens by eye |
| Semantic self-check (type_text) | After typing, automatically OCR the focus neighborhood to verify the typed text really landed (no parameters) | Three invisible accidents exposed: typed into the wrong box / IME swallowed characters / focus lost |
expected_text (click_mouse) |
After clicking, OCR the click neighborhood and check the expected text | Pixel change + semantic hit = double confirmation; semantic mismatch fails even if pixels changed |
OCR is opt-in (enableOcr: true; language packs download once on first use — default eng, Chinese chi_sim+eng). All semantic features degrade gracefully when OCR is unavailable; everything else keeps working. diff_view is pure sharp — zero extra dependencies.
The final verification stack (four layers):
L1 Pixel dual-scale dHash — did anything change? at which level (page/element)?
L2 Locating visualDiff — exact bounds & center of the change
L3 Semantic OCR check — does the change contain the expected text?
L4 Expectation expected_* — against what the model declared before acting
Rounds 1–4 improved single-execution quality. This round tackles two higher-order problems: successful experience cannot be persisted (the same workflow re-explored from zero every time) and credential safety (an agent must not type passwords for humans).
| Stage | Mechanism |
|---|---|
| Induction | After a complex task succeeds, automatically solidify the trajectory (replayable actions since markTaskStart) into a skill: trigger description + step sequence + entry-scene fingerprint; save_skill persists arbitrary journal fragments manually |
| Dedup reinforcement | Identical step sequences don't create duplicate cards — doing the same workflow three times = one skill verified three times (reliability 3/3), not three orphan cards |
| Persistence | With skillLibraryPath configured, skills survive across sessions: what the last session learned, the next one uses out of the box |
| Matching | match_skill: text overlap + Laplace-smoothed reliability + same-screen entry bonus (dHash ≥ 0.9) + recency; a skill is a prior, not a guarantee — anchors still require post-hoc verification |
| Closed-loop calibration | Every run_skill outcome writes back successCount/attemptCount — as the UI evolves and a skill breaks, its reliability decays naturally and its match rank drops; failure hints guide manual repair and re-save_skill |
World-class CUA consensus (e.g. Operator): credential input belongs to the human. Implemented in two stages, reusing existing infrastructure:
click_mouse's target_description hits a risk keyword (password / verification code / 2FA / OTP / API key…, configurable) ⇒ focusTracker marks the focus sensitive; the anchor carries sensitive_focus and warnstype_text into a sensitive focus (or text that itself hits risk semantics) ⇒ returns ACTION_REQUIRED, pausing for the human to type personally; the pending content is never echoed ([REDACTED])GENESIS.md): every organ on one line — mathematical root, enforcement test, judgment number.Eight deterministic micro-benchmarks (test/organAblation.bench.ts) put the organs on trial with numbers: fuzzy recovery 100% vs 0% baseline; ring-hash catches 90° rotations at 100% while the dual fingerprint is at 0% (orthogonality proven); BM25 MRR 0.583 vs 0.250; EMA channel arbitration reaches 226/300 versus the always-agents 104, within 3.4% of the oracle; reservoir quantiles exact to 0.0% across three distributions; MMR proofs within the log bound; RRF 100% stable under channel rescaling where the weighted sum collapses to 0%; LTLf enforcement pinpoints all three injected violation types. The trial itself caught a real defect (S-3's multiplicative weights let a degraded channel periodically revive) — the verdict, EMA arbitration, was written back into the implementation.
GUARD_BLOCKED chain markers — every guard interception becomes a tamper-evident policy fact.src/organCensus.ts): 33 mathematical organs registered with self-checks, surfaced in quality_checkup.src/fuzzy.ts (new organ): approximate substring edit-distance matching (OCR-tolerant expected_text verification; the Myers bit-vector bound is documented, classic DP chosen for auditability).score2).src/proof.ts (new organ): a Merkle Mountain Range giving O(log n) inclusion proofs over append-only evidence streams; wired into both the journal and sandbox chains — a single root plus a single proof now certifies one record without replaying the chain (tamper-evident across all sizes 1..1000).dualSimilarity fuses conservatively and actionVerifier carries a phashCorroborates second opinion.entropyBits (how uninformed the model is about where the world goes next — quantified justification for paid L3 looks) and posteriorConcentration.parents/generation; lineage() walks ancestry with cycle guards; capacity eviction grants survival bonuses to ancestors of living lineages.Seven more latent bugs eradicated across a full-repo audit (13 TS files line-by-line + 3 Python files + mechanical scans), headlined by: the auth_middleware ordering bug that made the M-era SO_PEERCRED server half dead on arrival (peer-PID compare before token parse → UnboundLocalError); an opposite-sign CDF convention silently corrupting the Monte-Carlo A² critical table; and a two-part swarm watermark defect that both voided the N-era cross-session fix and permanently stopped experience accumulation once the journal's sliding window saturated. Plus the immunity machinery: a Bug Class Registry (scripts/bug_class_lint.py) turning every historical bug class into a mechanical detector wired into npm run verify, and a property-test battery (test/epochP.test.ts) verifying every statistical engine by known-parameter recovery against closed forms — the kind of check example-based tests cannot provide.
Every remaining item from the post-campaign ledger, delivered in recommended order and enforced one-by-one (test/epochO.test.ts):
test/realMachineWin.bench.ts, 4/4 green): real service screenshots → offline tesseract.js OCR → real pyautogui physical clicks → tkinter world-state flips; trap-rerouting and the learning curve reproduce on real hardware. Plus a Linux CI workflow with a live POSIX-shm cross-process round-trip test.set_contrast bugs (window-handle requirement / illegal PS \" escaping / pvParam must be a HIGHCONTRAST struct) — live round trip 126→127→126 VERIFIED; a JPEG-closure UnboundLocalError in screen.py; the GPD moment-inversion algebra error; the contextManager clock-rollback hazard.w1Info/infoRatio); coherent-teleport fields for I-4; an LTLf property miner (bounded-response/precedence/repeat-guard); a Monte-Carlo A² critical table plus Kalman/Schmitt/NCD calibration loops (src/calibration.ts).dsh.vision.* service self-registration (single-owner law); worldModel run-level snapshots (fork/merge replay); dangling-ref validation on restore; sandbox scene-OCR lighting up the dormant L3-semantic layer; a switch_tab tab-stack model; the SO_PEERCRED Node client half (undici UDS dispatcher); station-reported token metering (tokenUsageReported); target_description as a REQUIRED protocol field; first-round serial knowledge retrieval option; the full Unicode confusables table (1665 distilled entries).rejected veto became reachable for the first time). Approval protocol upgraded to request ≠ consent — grant_approval is now a precondition for execution. Security surface hardened (AppleScript injection order, middleware onion order, nonce double-decode).passed verdict and muscle-memory consolidation became reachable for the first time); a WindowsAdapter (PowerShell + Win32 P/Invoke with geometry-snapshot undo); Actor dual-channel (DSH agents service → skill replay → honest [FAILED]); a Bayesian cortex (6-syndrome × 5-signal CPT, exact log-sum-exp enumeration); SSD second-order stochastic dominance; homoglyph normalization; noise-tolerant cycle detection; and the scientific benchmark suite (npm run bench) — first run all green.ctx.set? surface (D-5 → dsh.sandbox, D-7 → dsh.knowledge-pipeline); hosts without set keep the existing honest degradation. Contract placeholders promoted from dead exports to enforced surfaces.set_contrast via SystemParametersInfo (snapshot + undo); homoglyph arithmetic full table (mathematical alphabets generated from codepoint arithmetic — zero data files); calibrateCptFromRules() CPT distillation (32-combination enumeration + Beta smoothing + expert shrinkage); SO_PEERCRED server half (UDS peer-PID capture, token.pid == peer_pid enforced).ACTION_REQUIRED, not a pass-through); virtual-screen drag/switch-window evidence delivered. Suite: 325 tests / 318 pass / 0 fail.| Tool | Description | Key parameters |
|---|---|---|
take_screenshot |
Capture + SoM overlay + compression + sliding window + popup sensing + change gating | region, force? |
click_mouse |
Normalized-coordinate click with built-in dHash effect verification + auto memory | x, y, button, confidence?, target_description? |
type_text |
Type text at the focus; cross-platform clear-first | text, clearFirst |
scroll_page |
Four-direction scrolling | direction, amount |
press_hotkey |
Key combos (whitelisted, injection-proof) | keys (array) |
drag_mouse |
Drag (four-beat sequence: move → press → move → release) | startX/Y, endX/Y |
dismiss_popup |
Zero-side-effect meta tool: force a ReAct re-analysis | none |
switch_tab / switch_window |
Tab / window switching (with fallback paths) | direction / titleKeyword |
click_element |
Click by ID (element mode, short cache against ID drift) | id |
extract_ui_vision |
Precise extraction via local vision model (optional) | none |
start_complex_task |
Planner–Actor orchestration engine | userRequest |
zoom_inspect |
Region crop + enlarge + fine grid, two-stage precise grounding | x, y, half_size? |
find_text / read_text |
Text → exact coordinates / region text read (needs enableOcr) |
keyword / x?, y?, half_size? |
diff_view |
Visual diff of the last two screenshots: red-box diff image + changed-region list | none |
remember_ui / recall_ui |
Scene-based UI memory write / natural-language recall | description, x, y / query |
replay_actions |
Replay an action sequence from the journal (macro) | confirm, from_step?, to_step? |
save_skill / match_skill / run_skill |
Skill persistence / reliability matching / one-click execution (outcomes write back reliability) | description / query / id, confirm |
Node.js >= 18 (22 recommended) and pnpm. Native dependencies (sharp / @nut-tree/nut-js / screenshot-desktop / tesseract.js) install automatically with the plugin.
DSH plugin source (name + origin):
dsh-computer-use-plugin github:beijingwahw/dsh-computer-use-plugin
Install with pnpm (git dependency):
pnpm add dsh-computer-use-plugin@github:beijingwahw/dsh-computer-use-plugin
Or add to package.json and pnpm install:
{
"dependencies": {
"dsh-computer-use-plugin": "github:beijingwahw/dsh-computer-use-plugin"
}
}
Install-and-run:
dist/ ships with the repo) — no build scripts run at install time (no prepare/postinstall); main points straight at dist/index.js@deepseek-ai/cordis / dsh-tools / schemastery), provided by the DSH hostdsh.bundle points to cordis.patch.yml — the plugin registers and activates automatically on installpnpm dsh web
To override defaults, merge the insert entry from the bundled cordis.patch.yml into your own patch (when installed, name resolves via the package name — no absolute path needed):
- insert:
- id: dsh-computer-use-plugin
name: 'dsh-computer-use-plugin'
config:
mouseSpeed: 1500
compressWidth: 1440
jpegQuality: 75
# ... every field has a code default; trim per deployment
git clone https://github.com/beijingwahw/dsh-computer-use-plugin
cd dsh-computer-use-plugin
pnpm install # devDependencies (typescript etc.)
npm run build # regenerate dist/ (must re-run and commit after code changes)
npm test
When loading directly from source, set the patch entry's name to the entry file's absolute path (e.g. /your/path/dsh-computer-use-plugin/dist/index.js).
index.ts (apply)
├─ systemPrompt three orthogonal segments (grounding rules / ReAct workflow / popup handling)
├─ buildAllTools(config) tool factory (hybrid mode toggled by config)
├─ start_complex_task Planner–Actor meta tool
├─ registerAllGuards boundary / breaker / audit / popup interlock
├─ onLlmPreRequest sliding-window image injection into model requests
└─ ctx.effect lifecycle cleanup
Screenshot pipeline: captureScreen → multi-screen awareness → SoM overlay → sharp compression → sliding window → popup sensing → state anchor
[SUCCESS]/[FAILED] string protocol + fail-fasttools/pre-execute etc.) are single-sourced in src/guards/hooks.ts — version migrations touch one placeMIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: ocr、vision-agent。