dsh-todo-float-ball 0.14.4 → 0.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/lib/index.js +28 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.5 — 2026-10-18
|
|
4
|
+
|
|
5
|
+
### 修复:首工具判定 gate 的三处缺陷(合并社区 PR #1,作者 @WanchengWildMan)
|
|
6
|
+
|
|
7
|
+
本次为**宿主侧纯 bug 修复**,客户端 `lib/client.js` 与上一版逐字节一致(悬浮球与数据同步逻辑未变)。
|
|
8
|
+
|
|
9
|
+
- **缺陷① 计数卡死导致整个 turn 死锁(最严重)**
|
|
10
|
+
旧判据 `toolCallsThisTurn === 1` 命中即 `deny`,而被基准拒绝的调用**不会**回写事件流,计数永久停在 1 → 本 turn 之后**每一个**工具调用都被拒。社区实测被拒 74 次,只能新开一轮才能恢复。
|
|
11
|
+
修复:改用 `dispatchedThisTurn > 1`(只统计**已实际发出**的调用),并在检测到 `todo_write` 后立即置 `hasTodoWriteThisTurn`,补写 todo 后立刻放行。
|
|
12
|
+
|
|
13
|
+
- **缺陷② `run_code` 包装调用无法识别**
|
|
14
|
+
旧代码只认 `exec.name === "todo_write"`。当 `todo_write` 被 `run_code` 包裹执行时,`exec.name` 是 `run_code`,判定必然失败。
|
|
15
|
+
修复:新增 `callArgs.indexOf("todo_write") !== -1` 兜底,脚本内调用 `todo_write` 也能识别。
|
|
16
|
+
|
|
17
|
+
- **缺陷③ 并行批次时序不保证**
|
|
18
|
+
旧判据依赖"本 turn 已有几个 `tool/call`"的顺序,并行批次的事件到达顺序不受保证。
|
|
19
|
+
修复:判定改为"已发出 > 1 且见过工具名 且 未见 todo_write",不再依赖到达顺序。
|
|
20
|
+
|
|
21
|
+
- **新增 fail-open 保护**:本 turn 有调用但一个 `name` 都读不到(宿主事件结构变更)时**放行**,宁可漏拦也不阻塞会话。
|
|
22
|
+
|
|
23
|
+
### 实测验证(2026-10-18)
|
|
24
|
+
|
|
25
|
+
`~/.dsh/logs/desktop-next.log` 中本次运行仅出现 **1 次** deny,补写 `todo_write` 后全部后续调用正常执行;旧版为"永久卡死"。
|
|
26
|
+
|
|
27
|
+
### Fix: three defects in the first-tool gate (merges community PR #1 by @WanchengWildMan)
|
|
28
|
+
|
|
29
|
+
Host-half bug fix only — `lib/client.js` is byte-identical to the previous version.
|
|
30
|
+
|
|
31
|
+
- **Defect 1 — counter deadlock (most severe)**: `toolCallsThisTurn === 1` denied a call that never got appended back, freezing the counter at 1 and rejecting every following call in the turn (74 rejections in the reported case). Now `dispatchedThisTurn > 1` counts only calls already dispatched, and `hasTodoWriteThisTurn` unblocks as soon as a `todo_write` appears.
|
|
32
|
+
- **Defect 2 — `run_code` wrapper not recognised**: only `exec.name === "todo_write"` was matched, so a wrapped call never qualified. Now `callArgs.indexOf("todo_write") !== -1` is checked as a fallback.
|
|
33
|
+
- **Defect 3 — parallel batch ordering**: the old rule depended on arrival order of `tool/call` events, which parallel batches do not guarantee. The new rule is order-independent.
|
|
34
|
+
- **Fail-open guard added**: when a turn has calls but no readable `name` (host event shape changed), the gate allows the call instead of blocking the session.
|
|
35
|
+
|
|
3
36
|
## 0.14.4 — 2026-10-14
|
|
4
37
|
|
|
5
38
|
### 合规性改进(无功能改动)
|
package/lib/index.js
CHANGED
|
@@ -129,14 +129,37 @@ export function apply(ctx, config) {
|
|
|
129
129
|
if (!session || typeof session.snapshotEvents !== "function") return next();
|
|
130
130
|
var events = session.snapshotEvents();
|
|
131
131
|
if (!events || typeof events[Symbol.iterator] !== "function") return next();
|
|
132
|
-
|
|
132
|
+
// v0.13.2 修复(2026-10-10):并行竞态 + run_code 包装 + 计数卡死。
|
|
133
|
+
// 原判定 toolCallsThisTurn === 1 有三个致命问题:
|
|
134
|
+
// 1) append 时序假设相反:第一个调用到达 gate 时计数为 0(放行),放行后计数变 1,
|
|
135
|
+
// 而被拒的调用不 append——计数永久卡在 1,此后每个调用都命中 "=== 1" 被拒 → 死循环锁死;
|
|
136
|
+
// 2) AI 常用 run_code 包装调用(await tools.todo_write(...)),exec.name 是 run_code,
|
|
137
|
+
// 原 name 检查认不出,包装的 todo_write 永远触发不了放行分支;
|
|
138
|
+
// 3) 并行批次 append/dispatch 顺序不保证。
|
|
139
|
+
// 新判定:本 turn 第一个调用一律放行(给 todo_write 执行机会);从第二个起,
|
|
140
|
+
// 用「本 turn 是否已有 todo/write 会话事件」判断(无论直接调用还是 run_code 包装,
|
|
141
|
+
// todo_write 真正执行过必有该事件,比检查调用名可靠),辅以调用名/参数兜底识别。
|
|
142
|
+
var dispatchedThisTurn = 0;
|
|
143
|
+
var hasTodoWriteThisTurn = false;
|
|
144
|
+
var sawToolName = false;
|
|
133
145
|
for (var ev of events) {
|
|
134
146
|
var type = ev && ev.type;
|
|
135
|
-
if (type === "turn/start")
|
|
136
|
-
else if (type === "
|
|
147
|
+
if (type === "turn/start") { dispatchedThisTurn = 0; hasTodoWriteThisTurn = false; sawToolName = false; }
|
|
148
|
+
else if (type === "todo/write") { hasTodoWriteThisTurn = true; }
|
|
149
|
+
else if (type === "tool/call") {
|
|
150
|
+
dispatchedThisTurn++;
|
|
151
|
+
var callName = (ev.data && ev.data.name) || ev.name;
|
|
152
|
+
if (typeof callName === "string" && callName) {
|
|
153
|
+
sawToolName = true;
|
|
154
|
+
if (callName === "todo_write") hasTodoWriteThisTurn = true;
|
|
155
|
+
var callArgs = (ev.data && ev.data.arguments) || ev.arguments;
|
|
156
|
+
if (typeof callArgs === "string" && callArgs.indexOf("todo_write") !== -1) hasTodoWriteThisTurn = true;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
137
159
|
}
|
|
138
|
-
|
|
139
|
-
|
|
160
|
+
// fail-open:本 turn 有调用但一个 name 都读不到(事件结构不符)→ 放行,绝不阻塞
|
|
161
|
+
if (dispatchedThisTurn > 1 && sawToolName && !hasTodoWriteThisTurn) {
|
|
162
|
+
ctx.logger.info("dsh-todo-float-ball: GATE denied \"" + String(exec.name) + "\" (no todo_write in this turn yet)");
|
|
140
163
|
return {
|
|
141
164
|
kind: "deny",
|
|
142
165
|
reason: "【todo 进度表纪律·硬约束】每个回复 turn 的第一个工具调用必须是 todo_write(覆盖式写回完整清单:已完成的保留并标 completed、只增不减、进行中项带进度数字)。本轮你还没有写 todo 清单。请先用 todo_write 写回完整清单,再执行其它工具调用。"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-todo-float-ball",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.5",
|
|
4
4
|
"description": "DSH todo 悬浮球:常驻可拖动悬浮球实时显示当前会话 todo_write 任务清单进度(总数/完成数/进行中),Shadow DOM 样式隔离,点击折叠/展开完整清单,状态颜色(待办灰/进行中橙脉动/完成绿)。数据双路同步:MutationObserver 抓官方 todo 面板为主 + 拦截会话投影帧为辅。双端可用(Desktop 桌面端 + Web 网页端)。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|