dsh-better-goal 0.1.0 → 0.2.1

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/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
  <p>替换 DSH 原生 goal:保留持久目标与自动续跑,补上即时失败停止、可控的提问等待和更简单的目标操作。步骤仍然交给 <code>todo_write</code>。</p>
8
8
 
9
9
  <p>
10
+ <a href="https://www.npmjs.com/package/dsh-better-goal"><img src="https://img.shields.io/npm/v/dsh-better-goal.svg" alt="npm 版本"></a>
10
11
  <a href="LICENSE"><img src="https://img.shields.io/badge/license-GPL--3.0-blue.svg" alt="许可证:GPL-3.0"></a>
11
12
  <a href="package.json"><img src="https://img.shields.io/badge/DSH-0.2.1--rc.2_%3C0.3.0-6f42c1.svg" alt="DSH 0.2.1-rc.2 至 0.3.0 之前"></a>
12
13
  <a href="package.json"><img src="https://img.shields.io/badge/node-%5E22.19_%7C%7C_%3E%3D24-339933.svg" alt="Node.js ^22.19.0 或 >=24.0.0"></a>
@@ -20,19 +21,19 @@
20
21
 
21
22
  **自动续跑不应该变成“明知做不了,还继续跑”。** 原生 goal 已经提供持久目标与自动续跑;better-goal 改进的是遇到阻塞时及时停下、可控的提问等待,以及更简单的目标操作。
22
23
 
23
- > 对比以 DSH `0.2.1-rc.2` 的默认行为为基准。原生也支持完成、用户暂停和清除,并非完全不能停止;关键差异是**自主续跑中的模型能否立即报告失败并停止**。
24
+ > 对比以 DSH `0.2.1-rc.2` 的默认行为为基准。原生也支持完成、用户暂停和清除,并非完全不能停止;关键差异是**自主续跑中的模型能否在需要人介入时立即暂停**。
24
25
 
25
26
  | 场景 | DSH 原生 goal | dsh-better-goal |
26
27
  | --- | --- | --- |
27
- | **缺密钥、缺权限,必须由人介入** | 自主续跑时不能直接自行暂停;报告受阻有轮数门槛,目标仍在进行中就会继续排下一轮 | 立即 `fail`,记录缺什么、为什么不能继续,并停止自动续跑 |
28
+ | **缺密钥、缺权限,必须由人介入** | 自主续跑时不能直接自行暂停;报告受阻有轮数门槛,目标仍在进行中就会继续排下一轮 | 立即 `pause`,在回复里说明缺什么,停止自动续跑;不会为了“完成”而伪造、跳过或缩小范围 |
28
29
  | **阻塞已经确认,还要不要凑轮数** | 自主续跑时,默认至少经过 **3 个目标轮次**才接受受阻报告;刚开始就确认缺密钥,也不能立即用它停下 | 不设这个门槛;明确无法自行解决时即可停下,不必重复空转 |
29
- | **向用户提问后没人回答** | 默认提问会阻塞当前执行;需另行启用定时提问模式才有超时 | 目标执行中的提问默认等 **120 秒**;超时后仍可回答,Agent 可先做不依赖答案的工作 |
30
- | **希望始终等人确认** | 默认阻塞等待;定时模式另外配置 | 目标提问超时设为 **`-1`**,即可一直等待;超时从不代表同意 |
30
+ | **向用户提问后没人回答** | 默认提问会阻塞当前执行;需另行启用定时提问模式才有超时 | 由独立的 **dsh-better-ask-user** 统一管理提问等待;超时后仍可回答,Agent 可先做不依赖答案的工作 |
31
+ | **希望始终等人确认** | 默认阻塞等待;定时模式另外配置 | 在 **dsh-better-ask-user** 设置中把等待设为 **`-1`**,即可一直等待;超时从不代表同意 |
31
32
  | **阻塞解除后继续** | 模型恢复受直接人类请求限制;已暂停目标由 Web 或 `/goal resume` 恢复 | 用户或 Agent 都可明确继续,不要求先出现一条新的人类消息;保留原目标与已用轮数 |
32
- | **轮数控制** | 默认每个目标上限 **256 轮**,达到配置上限会停止;但有限的重试额度不等于能够立即报告阻塞 | **Agent 决定 / 无上限 / 固定数字**三档策略;失败停止与轮数上限分开处理 |
33
- | **模型如何管理目标** | 分散在 3 个工具中,操作还受状态与授权条件限制 | 一个工具、五个动作:**获取 / 覆盖写入 / 失败 / 成功 / 继续** |
33
+ | **轮数控制** | 默认每个目标上限 **256 轮**,达到配置上限会停止;但有限的重试额度不等于能够立即报告阻塞 | **Agent 决定 / 无上限 / 固定数字**三档策略;主动暂停与轮数上限分开处理 |
34
+ | **模型如何管理目标** | 分散在 3 个工具中,操作还受状态与授权条件限制 | 一个工具、五个动作:**获取 / 覆盖写入 / 暂停 / 成功 / 继续** |
34
35
 
35
- 两者都能保存目标、跨轮推进、暂停和恢复;**这些不是本插件独有的能力**。原生也有可选的定时提问,本插件的改进是在目标执行时默认应用统一的等待策略,而不是声称只有本插件才能处理超时。
36
+ 两者都能保存目标、跨轮推进、暂停和恢复;**这些不是本插件独有的能力**。提问等待已拆到独立的 **dsh-better-ask-user**,本插件只负责目标、续跑与轮数策略。
36
37
 
37
38
  ### 例子:任务卡在必需的 API 密钥
38
39
 
@@ -50,7 +51,7 @@ flowchart TD
50
51
  N -->|"目标仍在进行中"| L["下一轮继续尝试<br/>缺失条件并未改变"]
51
52
  L --> N
52
53
  N -->|"满足受阻条件并报告 / 到上限 / 用户停止"| X["停止续跑"]
53
- B --> G["better-goal<br/>立即记录缺失项并标记失败"]
54
+ B --> G["better-goal<br/>立即暂停并说明缺失项"]
54
55
  G --> S["停止自动续跑<br/>不假装完成"]
55
56
  S -->|"补齐密钥后,用户或 Agent 明确继续"| R["沿用目标与计数<br/>继续执行"]
56
57
  ```
@@ -61,25 +62,31 @@ flowchart TD
61
62
 
62
63
  需要 [DSH](https://github.com/deepseek-ai/deepseek-harness) `>=0.2.1-rc.2 <0.3.0` 和 Node.js `^22.19.0 || >=24.0.0`。无构建步骤。
63
64
 
64
- ### 已经用 Apollo(推荐)
65
+ ### 通过 Apollo 安装(推荐)
65
66
 
66
- [Apollo](https://github.com/Menghuan1918/dsh-apollo) 已经把 `dsh-better-goal` 作为依赖装配,因此**不需要再安装一次**。只保留 Apollo 入口即可;目标设置会出现在 **Plugins → @menghuan1918/dsh-apollo → dsh-better-goal 行**。
67
+ [Apollo](https://github.com/Menghuan1918/dsh-apollo)([npm 包](https://www.npmjs.com/package/@menghuan1918/dsh-apollo))是包含流程技能、工程模式和本插件的集合,goal 是其中一个独立子插件。从 npm 安装 Apollo 会自动带入 `dsh-better-goal`,**不需要再安装一次**:
67
68
 
68
- Apollo 是包含流程技能、工程模式和本插件的集合,goal 是其中一个独立子插件。
69
+ ```sh
70
+ dsh plugin --profile <profile> add @menghuan1918/dsh-apollo@0.4.1
71
+ ```
72
+
73
+ 安装后,目标设置出现在 **Plugins → @menghuan1918/dsh-apollo → dsh-better-goal 行**。只保留 Apollo 入口即可。
69
74
 
70
- 旧版通过 GitHub 安装的 Apollo 可能仍把设置行显示为 `dsh-apollo`;升级到 `@menghuan1918/dsh-apollo` 后以 scoped 路径为准,已有配置和 `/goal` 不变。
75
+ 旧版通过 GitHub 安装的 Apollo,在 Plugins 里仍显示为 `dsh-apollo`;迁移到 `@menghuan1918/dsh-apollo` 时先移除旧入口,再安装新包。会话记录保留,`/goal` 用法不变;迁移后请检查插件设置。
71
76
 
72
- ### 只想要持久目标(独立安装)
77
+ ### 只安装目标插件(独立安装)
78
+
79
+ 如果不需要 Apollo,可从 npm 单独安装本插件:
73
80
 
74
81
  ```sh
75
- # npm 安装
76
- dsh plugin --profile <profile> add dsh-better-goal@0.1.0
82
+ # npm 安装(推荐)
83
+ dsh plugin --profile <profile> add dsh-better-goal@0.2.0
77
84
 
78
- # 或从 GitHub main 源码安装
85
+ # 或从 GitHub main 源码安装(次入口)
79
86
  dsh plugin --profile <profile> add github:Menghuan1918/dsh-better-goal
80
87
  ```
81
88
 
82
- 完成后,目标设置出现在 **Plugins → dsh-better-goal → dsh-better-goal 行**。
89
+ 完成后,目标设置出现在 **Plugins → dsh-better-goal → dsh-better-goal 行**。npm 包页面:[dsh-better-goal](https://www.npmjs.com/package/dsh-better-goal)。
83
90
 
84
91
  > **安装或升级后要重启对应的 DSH profile。** 刷新网页只会重载界面,不会替换正在运行的实现;插件也不会自动修改你当前打开的 GUI。
85
92
 
@@ -96,7 +103,7 @@ flowchart TD
96
103
  C -->|"还有未完成的工作"| D["自动开始下一轮"]
97
104
  D --> C
98
105
  C -->|"当前证据证明完成"| E["标记完成<br/>GoalBar 隐藏"]
99
- C -->|"遇到明确阻塞"| F["记录具体原因并停下"]
106
+ C -->|"需要人介入(缺密钥 / 权限 / 决定)"| F["Agent 暂停并说明缺什么"]
100
107
  C -->|"用户暂停或中断"| G["暂停<br/>不再自动续跑"]
101
108
  F --> H["用户或 Agent 显式恢复"]
102
109
  G --> H
@@ -117,9 +124,11 @@ flowchart TD
117
124
  | `set` | 用完整目标替换当前目标;轮数清零并立即开始 |
118
125
  | `resume` | 继续现有目标;保留目标和已用轮数 |
119
126
  | `complete` | 在当前证据证明完成时结束目标 |
120
- | `fail` | 记录具体阻塞原因并停止 |
127
+ | `pause` | 需要你提供密钥、权限或决定时停下;目标保留,可随时继续 |
128
+
129
+ 只在确实要替换总目标时用 `set`;不要用它绕过轮数上限或丢掉未完成的范围。Agent 不会用 mock、硬编码或跳过检查来“完成”目标;缺条件就暂停并说明缺什么。清除仍由 GoalBar 或 `/goal clear` 完成。
121
130
 
122
- 只在确实要替换总目标时用 `set`;不要用它绕过轮数上限或丢掉未完成的范围。暂停和清除仍可通过 GoalBar 或 `/goal` 命令完成,它们不是模型侧五个动作的一部分。
131
+ > **0.2.0 变更**:模型侧的 `fail` 改为 `pause`。`/goal fail <原因>` 保留为人类命令,会记录原因并标记受阻;历史上由模型记录的受阻目标仍可读取和恢复。
123
132
 
124
133
  ### 人类命令
125
134
 
@@ -131,7 +140,7 @@ flowchart TD
131
140
  | 暂停 / 恢复 | `/goal pause` / `/goal resume` |
132
141
  | 暂停 / 恢复的短别名 | `/goal off` / `/goal on` |
133
142
  | 标记完成 | `/goal complete` |
134
- | 报告阻塞原因 | `/goal fail <原因>` |
143
+ | 报告阻塞原因(仅人类) | `/goal fail <原因>` |
135
144
  | 清除目标 | `/goal clear` |
136
145
 
137
146
  例如:
@@ -153,7 +162,7 @@ flowchart TD
153
162
 
154
163
  ## 设置
155
164
 
156
- 打开 **Plugins → dsh-better-goal → dsh-better-goal 行**;由 Apollo 装配时,打开 **Plugins → @menghuan1918/dsh-apollo → dsh-better-goal 行**。两处操作同一份配置。保存后立即生效,不需要重启。
165
+ 打开 **Plugins → dsh-better-goal → dsh-better-goal 行**;由 `@menghuan1918/dsh-apollo` 装配时,打开 **Plugins → @menghuan1918/dsh-apollo → dsh-better-goal 行**。两处操作同一份配置。保存后立即生效,不需要重启。
157
166
 
158
167
  ### 默认设置速览
159
168
 
@@ -161,9 +170,9 @@ flowchart TD
161
170
  | --- | --- |
162
171
  | **轮数上限策略**<br>`roundLimitMode`<br>默认 **`agent`**(由 Agent 决定) | 默认让 Agent 决定;创建时没有给上限,就不设轮数上限。 |
163
172
  | **固定轮数上限**<br>`roundLimit`<br>默认 **`256`** | 只在“固定轮数”模式生效;达到后停止自动续跑。 |
164
- | **目标提问超时(秒)**<br>`questionTimeoutSeconds`<br>默认 **`120`** | `-1` 永不超时;只影响新提问,正在等待的问题保持原期限。 |
173
+ | **旧提问超时字段**<br>`questionTimeoutSeconds` | **已弃用,仅保留读取**;新的等待、续期和超时行为在 **dsh-better-ask-user** 中配置。 |
165
174
 
166
- > **默认组合:`agent` + `256` + `120` 秒。** 其中 `256` 只在切到“固定轮数”后生效,`120` 秒只影响目标进行中的新提问。
175
+ > **默认组合:`agent` + `256`。** 其中 `256` 只在切到“固定轮数”后生效。旧配置里的 `120` 秒只用于一次性迁移到 ask-user,不再影响本插件的运行。
167
176
 
168
177
  设置只影响之后的新轮次和新提问:不重置已用轮数,也不会自动恢复已经停下的目标。
169
178
 
@@ -186,12 +195,11 @@ flowchart TD
186
195
 
187
196
  达到上限时,目标会变为受阻并停止自动续跑。把上限调高后,可以 `/goal resume` 继续;把上限调到已用轮数以下不会让计数倒退,只会让运行中的目标停下。
188
197
 
189
- ### 提问超时
198
+ ### 提问等待
199
+
200
+ 提问等待、输入续期、Web 卡片和超时行为已经迁移到独立插件 **dsh-better-ask-user**。本插件不再注册 `ask_user_question` 影子,也不再消费 `questionTimeoutSeconds`;该字段只作为旧配置保留,供 ask-user 做一次性迁移。
190
201
 
191
- - 默认等待 **120 秒**;设为 `-1` 表示永不超时。
192
- - 只在目标进行中、且自动续跑开启时接管**本来就存在**的 `ask_user_question`;不会给“无提问”预设新增提问工具。
193
- - 超时后,问题仍然是**待回答**:之后仍可回答,Agent 也可以先做不依赖答案的工作。**超时不是同意,也不是跳过。**
194
- - 修改设置只影响新发起的等待;已经开始等待的问题保留原期限。
202
+ 超时仍然不是同意,也不是跳过。原生 pending 行为会让问题保持可回答;默认选择模式会把结果明确标记为自动选择,模型侧会收到警告。
195
203
 
196
204
  ## 恢复、暂停与完成
197
205
 
@@ -220,7 +228,7 @@ flowchart TD
220
228
  <details>
221
229
  <summary><strong>设置在哪里?保存后要重启吗?</strong></summary>
222
230
 
223
- 独立安装时在 **Plugins → dsh-better-goal → dsh-better-goal 行**;由 Apollo 装配时在 **Plugins → @menghuan1918/dsh-apollo → dsh-better-goal 行**。三个运行时设置保存后立即生效,不需要重启。安装、升级或改动插件组合后仍需重启 DSH profile。
231
+ 独立安装时在 **Plugins → dsh-better-goal → dsh-better-goal 行**;由 `@menghuan1918/dsh-apollo` 装配时在 **Plugins → @menghuan1918/dsh-apollo → dsh-better-goal 行**。三个运行时设置保存后立即生效,不需要重启。安装、升级或改动插件组合后仍需重启 DSH profile。
224
232
 
225
233
  </details>
226
234
 
@@ -234,7 +242,7 @@ flowchart TD
234
242
  <details>
235
243
  <summary><strong>提问超时是不是等于同意或跳过?</strong></summary>
236
244
 
237
- 不是。超时只表示这一批回答还没到;问题仍可回答,Agent 不应把超时当成授权或默认选项。真正被答案阻塞时,Agent 应报告失败并等你处理,而不是伪造答案。
245
+ 不是。超时只表示这一批回答还没到;问题仍可回答,Agent 不应把超时当成授权或默认选项。真正被答案阻塞时,Agent 应报告失败并等你处理,而不是伪造答案。具体的等待与默认选择规则见 **dsh-better-ask-user**。
238
246
 
239
247
  </details>
240
248
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## 状态与兼容性
6
6
 
7
- - 当前包版本:`0.1.0`。
7
+ - 当前包版本:`0.2.0`。
8
8
  - DSH 基准:`0.2.1-rc.2`;`package.json` 的 engines 声明为 `>=0.2.1-rc.2 <0.3.0`。
9
9
  - Node.js:`^22.19.0 || >=24.0.0`。
10
10
  - 纯 ESM,无构建步骤,没有需要生成的资源文件。
@@ -69,7 +69,7 @@
69
69
 
70
70
  ## 单工具与动作契约
71
71
 
72
- 模型侧只注册一个名为 `goal` 的工具,最终动作集合为 `get` / `set` / `fail` / `complete` / `resume`。工具参数不接受 `goal_id` / `revision`;工具内部读取当前目标并生成引用,服务层仍执行 revision-based CAS。返回值保留只读的原生目标视图,模型不需要管理其中的 ID 和 revision。
72
+ 模型侧只注册一个名为 `goal` 的工具,最终动作集合为 `get` / `set` / `pause` / `complete` / `resume`。工具参数不接受 `goal_id` / `revision`;工具内部读取当前目标并生成引用,服务层仍执行 revision-based CAS。返回值保留只读的原生目标视图,模型不需要管理其中的 ID 和 revision。
73
73
 
74
74
  | 动作 | 语义 |
75
75
  | --- | --- |
@@ -77,9 +77,11 @@
77
77
  | `set` | 全量替换为新目标:新的 objective、`roundsStarted` 归零、立即 arm 并启动。 |
78
78
  | `resume` | 恢复现有目标,保留 objective 和已用轮数,不重置计数。 |
79
79
  | `complete` | 标记完成并 disarm。 |
80
- | `fail` | 记录具体阻塞原因并 block、disarm。 |
80
+ | `pause` | 暂停并 disarm(原生 `active → paused`);不存原因,Agent 在回复里说明需要什么。只接受 armed 或 disarmed 的 `active`。 |
81
81
 
82
- `set` 是整体替换,不是“改几个字”;只在确实要替换总目标时使用。暂停(`pause`)和清除(`clear`)不在模型侧五个动作中,但仍由 GoalBar、Remote 服务和人类 `/goal` 命令提供。人类 `/goal create` 映射到 `set`;`/goal edit` 仍在原目标上就地编辑(已完成目标会新建);`/goal pause` 和 `/goal clear` 直接走服务层。
82
+ `set` 是整体替换,不是“改几个字”;只在确实要替换总目标时使用。清除(`clear`)和受阻(`block`)不在模型侧动作中:清除由 GoalBar、Remote 服务和 `/goal clear` 提供;受阻只来自轮数上限、运行时错误、续跑被拒和人类 `/goal fail`。人类 `/goal create` 映射到 `set`;`/goal edit` 仍在原目标上就地编辑(已完成目标会新建);`/goal pause`、`/goal fail` 和 `/goal clear` 直接走服务层。
83
+
84
+ 0.2.0 起模型侧 `fail` 改为 `pause`:模型缺密钥、权限或决定时只需停下等人,持久化原因对它没有额外价值,而 `pause` 记录与原生 `goal/change v1` 字节兼容。历史 `model-reported` 受阻目标仍可读取、恢复和完成。
83
85
 
84
86
  原生协议没有替换事务:覆盖未完成目标通过内部 CAS `clear` 后 `create` 实现,恢复时调整上限可能通过 `edit` 后 `resume` 实现。参数、策略和状态校验在首次写入前完成;底层追加失败或同步重入不具有跨事件回滚保证,不应把这两步描述成原子事务。
85
87
 
@@ -97,7 +99,7 @@ README 只写五个动作的用户语义,不复制 JSON、schema 或内部引
97
99
  | `/goal pause` / `/goal off` | 暂停并 disarm(服务层) |
98
100
  | `/goal resume` / `/goal on` | 恢复并 arm |
99
101
  | `/goal complete` | 标记完成 |
100
- | `/goal fail <reason>` | 记录具体原因并阻塞 |
102
+ | `/goal fail <reason>` | 仅人类:以 `user-reported` 记录原因并阻塞(服务层) |
101
103
  | `/goal clear` | 清除当前 goal(服务层) |
102
104
 
103
105
  GoalBar 不新建 goal,只通过正式 `remote.goals` RPC 做编辑、暂停、恢复和清除。它使用 click 时从 live projection 读取的 CAS ref,不在聊天中写入 slash-command 生命周期;完成态不渲染。
@@ -110,7 +112,7 @@ GoalBar 不新建 goal,只通过正式 `remote.goals` RPC 做编辑、暂停
110
112
  | --- | --- | --- | --- |
111
113
  | `roundLimitMode` | `agent` | `agent` / `unlimited` / `fixed` | 选择解释轮数上限的策略。 |
112
114
  | `roundLimit` | `256` | 正安全整数 | 只在 `fixed` 模式使用。 |
113
- | `questionTimeoutSeconds` | `120` | `-1` 或 `1..2147483` 的整数 | 新 goal 提问的等待秒数。 |
115
+ | `questionTimeoutSeconds` | `120` | `-1` 或 `1..2147483` 的整数 | **已弃用、仅保留读取**;新的提问等待由 dsh-better-ask-user 管理,用于旧配置迁移。 |
114
116
 
115
117
  `resolveRoundLimit` 的解析顺序:
116
118
 
@@ -120,21 +122,15 @@ GoalBar 不新建 goal,只通过正式 `remote.goals` RPC 做编辑、暂停
120
122
 
121
123
  工具 schema 会在下一个 step 刷新:`agent` 模式暴露可选的 `max_goal_rounds`,`fixed` / `unlimited` 模式不暴露。驱动在每次准入时重新读取 live config,所以热设置只影响之后的新轮次和操作,不重置计数,也不自动恢复已停止的 goal。
122
124
 
123
- ## 提问超时
124
-
125
- [src/ask-user.js](../src/ask-user.js) 不是新增一个提问工具,而是对宿主已有 `ask_user_question` 做 Agent 作用域的影子定义:
125
+ ## 提问等待
126
126
 
127
- - 仅当 goal 为 `active` 且 activation 为 `armed` 时接管;其他情况完全委托给原工具。
128
- - 复用宿主当前工具的 `questions` schema,不导入 `@deepseek-ai/dsh-tool-ask-user`,也不给“无提问”预设新增工具。
129
- - 每次新等待读取一次 `questionTimeoutSeconds`;正在等待的提问保留原期限。
130
- - 宿主设置覆盖模型传入的等待时间;`-1` 走不带超时的 `userQuestions.ask`。
131
- - 超时返回原生 pending 结果,问题仍可回答;模型侧提示明确说明“pending, not a skipped answer”,不得把超时当授权或默认答案。
132
- - 超时后用户仍可提交答案,迟到答案由原生 `userQuestions` 服务结算。
127
+ 提问等待已迁移到独立的 **dsh-better-ask-user**。本仓库不再包含 `src/ask-user.js`,也不再注册 `ask_user_question` 影子或消费 `questionTimeoutSeconds`。保留该 Config 字段仅用于读取旧配置,供 ask-user 的一次性迁移使用;设置页不再展示该字段。
133
128
 
134
- ## 完成与失败
129
+ ## 完成与暂停
135
130
 
136
131
  - 自动轮次的 prompt 要求从 objective 和引用规格逐项推导要求,并检查当前文件、命令结果、测试和运行状态;局部进度、记忆或“应该可以”不能作为完成证据。它是行为约束,不是硬编码测试门。
137
- - 遇到明确阻塞时,模型应立即 `fail` 并给出具体原因;没有“必须阻塞三个回合”的门槛。
132
+ - 进展需要用户时(缺密钥、凭据、权限、账号或只有用户能做的决定),模型应先做完独立工作,再立即 `pause` 并说明缺什么;不得用 mock、stub、硬编码、跳过检查或缩小范围来“完成”。没有“必须阻塞三个回合”的门槛。
133
+ - 模型在目标轮次内自行 `pause` 时,驱动不会取消当前回合(只有非本 Agent 发起的暂停才取消运行中的回合);回合结束后目标不再可驱动,不排下一轮。
138
134
  - `complete` 接受 `active` / `paused` / `blocked`;完成后 disarm,GoalBar 隐藏。
139
135
  - 用户中断会 disarm,并在安全 idle 边界把 active goal 持久化为 paused;不会把暂停通知当作新提示自动启动。
140
136
  - Plan mode 或待提交选择存在时,驱动不排下一轮;计划模式退出后可以恢复。
@@ -144,7 +140,7 @@ GoalBar 不新建 goal,只通过正式 `remote.goals` RPC 做编辑、暂停
144
140
 
145
141
  这是 README 只保留一句提示、本文档保留完整原理的部分。
146
142
 
147
- Apollo 在 `package.json` 中把 `dsh-better-goal` 声明为精确 npm 依赖 `0.1.0`(不是 Git commit、分支、范围或 `file:` 说明符);它的顶层 patch 自己插入了 `id/name` 都是 `dsh-better-goal` 的行。独立包也插入同一行。
143
+ Apollo 在 `package.json` 中把 `dsh-better-goal` 声明为精确 npm 依赖 `0.2.0`(不是 Git commit、分支、范围或 `file:` 说明符);它的顶层 patch 自己插入了 `id/name` 都是 `dsh-better-goal` 的行。独立包也插入同一行。
148
144
 
149
145
  - 两个 bundle 同时被显式选中时,DSH Loader 按行 id 去重,通常只激活一个实例,浏览器模块也只有一个 active source。
150
146
  - 但 DSH `0.2.1-rc.2` 的插件管理器会把组合行开关标成只读(`unaddressable`),配置编辑器也可能拒绝保存目标设置。
@@ -158,7 +154,7 @@ Apollo 在 `package.json` 中把 `dsh-better-goal` 声明为精确 npm 依赖 `0
158
154
  ### npm 安装
159
155
 
160
156
  ```sh
161
- dsh plugin --profile <profile> add dsh-better-goal@0.1.0
157
+ dsh plugin --profile <profile> add dsh-better-goal@0.2.0
162
158
  ```
163
159
 
164
160
  npm 安装后,目标设置出现在 **Plugins → dsh-better-goal → dsh-better-goal 行**。GitHub main 仍保留为源码安装选项。
@@ -175,7 +171,7 @@ dsh plugin --profile <profile> add link:/absolute/path/to/dsh-better-goal
175
171
 
176
172
  链接后要重启 profile;运行时三个设置字段仍然支持保存后热更新。
177
173
 
178
- Apollo 本地开发时,先在其根目录执行 `npm install`。`dsh plugin add link:` 只链接 Apollo 本身,不代装依赖;Apollo 的依赖是精确 npm 版本 `dsh-better-goal@0.1.0`,本地联调可临时改成 `file:../dsh-better-goal`,但不要提交该改动。GitHub 源码安装同样从 registry 解析这个精确版本。
174
+ Apollo 本地开发时,先在其根目录执行 `npm install`。`dsh plugin add link:` 只链接 Apollo 本身,不代装依赖;Apollo 的依赖是精确 npm 版本 `dsh-better-goal@0.2.0`,本地联调可临时改成 `file:../dsh-better-goal`,但不要提交该改动。GitHub 源码安装同样从 registry 解析这个精确版本。
179
175
 
180
176
  ## 测试与宿主冒烟
181
177
 
@@ -185,7 +181,7 @@ Apollo 本地开发时,先在其根目录执行 `npm install`。`dsh plugin ad
185
181
  npm test
186
182
  ```
187
183
 
188
- 测试覆盖 Config 默认值与边界、round policy、goal service 的持久 schema/replay/CAS、driver 的续跑与中断、单工具动作、命令、GoalBar、设置页和提问超时影子。
184
+ 测试覆盖 Config 默认值与边界、round policy、goal service 的持久 schema/replay/CAS、driver 的续跑与中断、单工具动作、命令、GoalBar 和设置页。提问等待的影子测试已随实现迁移到 ask-user。
189
185
 
190
186
  宿主冒烟需要指向已安装的 DSH 包:
191
187
 
@@ -205,16 +201,18 @@ GOAL_SMOKE_MODE=both DSH_PACKAGE_ROOT=/path/to/node_modules/@deepseek-ai/dsh npm
205
201
 
206
202
  冒烟使用临时 home/profile、真实 DSH AgentLoop 和脚本化模型适配器,不调用付费模型,也不启动替代 GUI。通过条件是进程退出码为 0、输出 `BETTER_GOAL_RUNTIME_SMOKE_PASSED`,以及临时目录 `results.json` 的 `passed` 为 `true`。`apollo` / `both` 模式默认从 `../dsh-apollo` 读取 Apollo 仓库,可用 `APOLLO_PACKAGE_ROOT` 指定其他位置。
207
203
 
208
- 实际检查包括:真实 profile 启动、单 `goal` 工具、五动作枚举、无 `goal_id` / `revision` 参数、旧三工具隐藏、`/goal` 命令、创建/替换/暂停/恢复/完成/清除、真实工具 dispatch、native goal RPC、自动轮次、冷恢复 disarmed、fork disarmed、Agent 无需新人类消息即可控制完整生命周期;`GOAL_SMOKE_HOT=1` 还检查热设置持久化和迟到回答。冒烟路径覆盖 `standard`(standalone)以及 `eng` / `eng-noask`(apollo / both);`apollo` / `both` 模式会检查 `eng-noask` 没有提问工具时不会被插件新增提问能力。
204
+ 实际检查包括:真实 profile 启动、单 `goal` 工具、五动作枚举、无 `goal_id` / `revision` 参数、旧三工具隐藏、`/goal` 命令、创建/替换/暂停/恢复/完成/清除、真实工具 dispatch、native goal RPC、自动轮次、冷恢复 disarmed、fork disarmed、Agent 无需新人类消息即可控制完整生命周期;`GOAL_SMOKE_HOT=1` 还检查热设置持久化和迟到回答。冒烟路径覆盖 `standard`(standalone)以及 `eng` / `eng-ptc`(apollo / both);`apollo` / `both` 模式会检查 `eng-ptc` 同样只有一个 `goal` 工具、旧三工具隐藏。
205
+
206
+ 未覆盖:PTC 模式下 `run_code` 内调用 goal 的真实回合、其他自定义提问工具、当前浏览器 GUI 的人工验收。单元测试或冒烟通过都不代表这些场景已验证。
209
207
 
210
- 未覆盖:PTC 工具呈现模式、其他自定义提问工具、当前浏览器 GUI 的人工验收。单元测试或冒烟通过都不代表这些场景已验证。
208
+ ## npm 发布
211
209
 
212
- ## npm 首发
210
+ 发布走 [.github/workflows/release.yml](../.github/workflows/release.yml) 的 npm trusted publishing(OIDC),仓库不保存 npm token:
213
211
 
214
- 1. 先人工发布本包 `0.1.0` tarball 到 `https://registry.npmjs.org/`,`access` 为 `public`。
215
- 2. 在官方 registry 验证 `dsh-better-goal@0.1.0` 可取得,再人工发布 Apollo `@menghuan1918/dsh-apollo@0.3.0`;Apollo 的发布目标同样是 `https://registry.npmjs.org/`,`access` 为 `public`。
216
- 3. 登录、2FA 和 publish 由维护者在真实终端完成;OTP、token 和恢复码不写入脚本、环境文件或仓库。
217
- 4. 在本包发布并验证通过前,不要让 Apollo 的 `package.json` 精确依赖 `0.1.0` 进入 main;否则 GitHub 源码安装会 404。
212
+ 1. 把 `package.json` 的 `version` 改为新版本,同步 `package-lock.json`(`npm install --package-lock-only`),提交并推到 GitHub `main`。
213
+ 2. 创建并发布 GitHub Release,tag 必须是 `v<version>`。
214
+ 3. CI 校验 tag 与版本一致,执行 `npm ci`、`npm test`,再 `npm publish --provenance --access public`。
215
+ 4. 本包在 registry 可取得后,才把 Apollo 的精确依赖改到新版本并发布 Apollo;否则 Apollo 安装会 404。
218
216
 
219
217
  ## 卸载、禁用与回退
220
218
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-better-goal",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Independent DSH goal plugin: one goal tool, persistent continuation, hot settings and timed questions.",
5
5
  "license": "GPL-3.0",
6
6
  "repository": {
@@ -26,7 +26,14 @@
26
26
  "test": "node --test",
27
27
  "smoke": "node scripts/runtime-smoke.mjs"
28
28
  },
29
- "files": ["src", "docs", "cordis.patch.yml", "README.md", "LICENSE", "third-party"],
29
+ "files": [
30
+ "src",
31
+ "docs",
32
+ "cordis.patch.yml",
33
+ "README.md",
34
+ "LICENSE",
35
+ "third-party"
36
+ ],
30
37
  "dependencies": {
31
38
  "@deepseek-ai/schemastery": "~3.18.5",
32
39
  "zod": "4.4.3"
@@ -50,10 +57,19 @@
50
57
  "react-test-renderer": "18.3.1"
51
58
  },
52
59
  "dsh": {
53
- "bundle": { "patch": "./cordis.patch.yml" },
60
+ "bundle": {
61
+ "patch": "./cordis.patch.yml"
62
+ },
54
63
  "client": {
55
64
  "platform": "web",
56
- "inject": ["@deepseek-ai/dsh-api-remotes", "@deepseek-ai/dsh-api-session-controller", "@deepseek-ai/dsh-client-connection", "@deepseek-ai/dsh-client-locale", "@deepseek-ai/dsh-client-ui-conversation", "@deepseek-ai/dsh-client-ui-settings"]
65
+ "inject": [
66
+ "@deepseek-ai/dsh-api-remotes",
67
+ "@deepseek-ai/dsh-api-session-controller",
68
+ "@deepseek-ai/dsh-client-connection",
69
+ "@deepseek-ai/dsh-client-locale",
70
+ "@deepseek-ai/dsh-client-ui-conversation",
71
+ "@deepseek-ai/dsh-client-ui-settings"
72
+ ]
57
73
  }
58
74
  }
59
75
  }
package/src/client.js CHANGED
@@ -53,8 +53,6 @@ window.__ModuleLoader__.load({
53
53
  const ROW_CONFIG_KEYS = Object.freeze([ROW_KEY, APOLLO_ROW_KEY, SCOPED_APOLLO_ROW_KEY])
54
54
  const ROUND_LIMIT_MODES = Object.freeze(['agent', 'unlimited', 'fixed'])
55
55
  const DEFAULT_ROUND_LIMIT = 256
56
- const DEFAULT_QUESTION_TIMEOUT_SECONDS = 120
57
- const MAX_QUESTION_TIMEOUT_SECONDS = 2147483
58
56
  const UNLIMITED_ROUNDS = Number.MAX_SAFE_INTEGER
59
57
  const STYLE_GOAL = 'dsh-better-goal/goal.css'
60
58
  const STYLE_SETTINGS = 'dsh-better-goal/settings.css'
@@ -63,7 +61,7 @@ window.__ModuleLoader__.load({
63
61
 
64
62
  /** Simplified Chinese dictionary (key-set source of truth). */
65
63
  const zh = {
66
- summary: '独立目标条、轮数上限策略与目标提问超时',
64
+ summary: '独立目标条与轮数上限策略',
67
65
  waitingForm: '正在等待宿主提供这一行的配置快照…',
68
66
  noFormHint: '长时间停在这里说明宿主没有为这一行提供可编辑配置:本部署没组合 dsh-settings/config-editor,或本行的 Config 未被识别。',
69
67
  loading: '正在读取配置…',
@@ -113,7 +111,7 @@ window.__ModuleLoader__.load({
113
111
 
114
112
  /** English dictionary, checked complete against the zh key set. */
115
113
  const en = {
116
- summary: 'Standalone GoalBar, round-cap policy, and goal-question timeout',
114
+ summary: 'Standalone GoalBar and round-cap policy',
117
115
  waitingForm: 'Waiting for the host to provide this row’s configuration snapshot…',
118
116
  noFormHint: 'Staying here means the host exposes no editable config for this row: dsh-settings/config-editor is not composed, or this row’s Config was not recognized.',
119
117
  loading: 'Loading configuration…',
@@ -303,11 +301,6 @@ window.__ModuleLoader__.load({
303
301
  return typeof value === 'number' && Number.isSafeInteger(value) && value >= 1
304
302
  }
305
303
 
306
- function isValidQuestionTimeout(value) {
307
- if (value === -1) return true
308
- return Number.isSafeInteger(value) && value >= 1 && value <= MAX_QUESTION_TIMEOUT_SECONDS
309
- }
310
-
311
304
  function isUnlimitedCap(value) {
312
305
  return value === UNLIMITED_ROUNDS
313
306
  }
@@ -756,9 +749,6 @@ window.__ModuleLoader__.load({
756
749
  return {
757
750
  roundLimitMode: ROUND_LIMIT_MODES.includes(source.roundLimitMode) ? source.roundLimitMode : 'agent',
758
751
  roundLimit: isPositiveSafeInteger(source.roundLimit) ? source.roundLimit : DEFAULT_ROUND_LIMIT,
759
- questionTimeoutSeconds: isValidQuestionTimeout(source.questionTimeoutSeconds)
760
- ? source.questionTimeoutSeconds
761
- : DEFAULT_QUESTION_TIMEOUT_SECONDS,
762
752
  }
763
753
  }
764
754
 
@@ -767,14 +757,12 @@ window.__ModuleLoader__.load({
767
757
  return {
768
758
  roundLimitMode: config.roundLimitMode,
769
759
  roundLimit: String(config.roundLimit),
770
- questionTimeoutSeconds: String(config.questionTimeoutSeconds),
771
760
  }
772
761
  }
773
762
 
774
763
  function sameConfig(left, right) {
775
764
  return left.roundLimitMode === right.roundLimitMode
776
765
  && left.roundLimit === right.roundLimit
777
- && left.questionTimeoutSeconds === right.questionTimeoutSeconds
778
766
  }
779
767
 
780
768
  function parsePositiveSafeIntegerText(text) {
@@ -785,14 +773,6 @@ window.__ModuleLoader__.load({
785
773
  return Number.isSafeInteger(value) && value >= 1 && value <= UNLIMITED_ROUNDS ? value : undefined
786
774
  }
787
775
 
788
- function parseQuestionTimeoutText(text) {
789
- if (typeof text !== 'string') return undefined
790
- const trimmed = text.trim()
791
- if (trimmed === '-1') return -1
792
- const value = parsePositiveSafeIntegerText(trimmed)
793
- return value !== undefined && value <= MAX_QUESTION_TIMEOUT_SECONDS ? value : undefined
794
- }
795
-
796
776
  /**
797
777
  * Validate one text draft and produce the JSON value to write.
798
778
  * The hidden round-limit text is ignored outside `fixed` mode: the host
@@ -806,13 +786,10 @@ window.__ModuleLoader__.load({
806
786
  if (parsed === undefined) return { error: 'invalidRoundLimit' }
807
787
  roundLimit = parsed
808
788
  }
809
- const questionTimeoutSeconds = parseQuestionTimeoutText(draft.questionTimeoutSeconds)
810
- if (questionTimeoutSeconds === undefined) return { error: 'invalidQuestionTimeout' }
811
789
  return {
812
790
  value: {
813
791
  roundLimitMode: draft.roundLimitMode,
814
792
  roundLimit,
815
- questionTimeoutSeconds,
816
793
  },
817
794
  }
818
795
  }
@@ -826,9 +803,6 @@ window.__ModuleLoader__.load({
826
803
  if (host.roundLimit !== next.roundLimit) {
827
804
  ops.push({ op: 'set', path: ['roundLimit'], value: next.roundLimit })
828
805
  }
829
- if (host.questionTimeoutSeconds !== next.questionTimeoutSeconds) {
830
- ops.push({ op: 'set', path: ['questionTimeoutSeconds'], value: next.questionTimeoutSeconds })
831
- }
832
806
  return ops
833
807
  }
834
808
 
@@ -903,7 +877,6 @@ window.__ModuleLoader__.load({
903
877
  }
904
878
 
905
879
  const roundLimitValue = parsePositiveSafeIntegerText(live.roundLimit)
906
- const timeoutValue = parseQuestionTimeoutText(live.questionTimeoutSeconds)
907
880
  const status = notice !== null
908
881
  ? h('span', { className: 'dbg-status', 'data-tone': notice.tone, role: notice.tone === 'error' ? 'alert' : 'status' }, notice.text)
909
882
  : invalid !== null
@@ -957,26 +930,7 @@ window.__ModuleLoader__.load({
957
930
  onChange: (event) => edit((current) => ({ ...current, roundLimit: event.target.value })),
958
931
  }))
959
932
  : null,
960
- h(Field, {
961
- id: 'dsh-better-goal-question-timeout',
962
- label: tr(t, 'questionTimeoutLabel'),
963
- hint: timeoutValue === -1
964
- ? `${tr(t, 'questionTimeoutHint')} ${tr(t, 'questionTimeoutNever')}`
965
- : tr(t, 'questionTimeoutHint'),
966
- },
967
- h('input', {
968
- className: 'dbg-input',
969
- id: 'dsh-better-goal-question-timeout',
970
- type: 'number',
971
- min: -1,
972
- max: MAX_QUESTION_TIMEOUT_SECONDS,
973
- step: 1,
974
- inputMode: 'numeric',
975
- value: live.questionTimeoutSeconds,
976
- disabled: !writable || busy,
977
- 'aria-invalid': invalid === 'invalidQuestionTimeout' ? true : undefined,
978
- onChange: (event) => edit((current) => ({ ...current, questionTimeoutSeconds: event.target.value })),
979
- }))),
933
+ ),
980
934
  h('div', { className: 'dbg-footer' },
981
935
  h('button', {
982
936
  type: 'button',
package/src/commands.js CHANGED
@@ -51,6 +51,9 @@ export function executeGoalCommand(ctx, invocation, readConfig) {
51
51
  })
52
52
  } else if (args.action === 'pause') {
53
53
  goal = goals.pause(invocation.agent, goalRef(current))
54
+ } else if (args.action === 'fail') {
55
+ // Human-only blocker: the model pauses instead, so this keeps a durable reason.
56
+ goal = goals.block(invocation.agent, goalRef(current), { code: 'user-reported', message: args.reason.trim() })
54
57
  } else if (args.action === 'clear') {
55
58
  goals.clear(invocation.agent, goalRef(current))
56
59
  return { kind: 'success', text: 'Goal cleared.' }
package/src/config.js CHANGED
@@ -9,8 +9,10 @@
9
9
  * `agent` (the model may pass `max_goal_rounds`), `unlimited` (the
10
10
  * compatibility sentinel), or `fixed` (the configured `roundLimit`).
11
11
  * - `roundLimit` is the cap used only by `fixed` mode.
12
- * - `questionTimeoutSeconds` bounds a NEW goal question wait; `-1` means the
13
- * wait never times out.
12
+ * - `questionTimeoutSeconds` is deprecated and load-only. It is retained so
13
+ * existing profiles and the ask-user migration can read the old value; the
14
+ * goal plugin no longer consumes it and the settings page no longer edits
15
+ * it. The standalone ask-user plugin owns question waits.
14
16
  *
15
17
  * Every field is `.volatile()`: changing it hot-swaps the stable reference on
16
18
  * the live fiber instead of remounting the row. Consumers (`readConfig`,
@@ -75,7 +77,7 @@ export const Config = z.object({
75
77
  roundLimitMode: z.union(ROUND_LIMIT_MODES).default(DEFAULTS.roundLimitMode).volatile(),
76
78
  /** Fixed cap; used only when `roundLimitMode` is `fixed`. */
77
79
  roundLimit: RoundLimit.volatile(),
78
- /** New goal-question wait in seconds; `-1` never times out. */
80
+ /** Deprecated/load-only goal-question wait; kept for profile migration. */
79
81
  questionTimeoutSeconds: QuestionTimeout.volatile(),
80
82
  })
81
83
 
package/src/driver.js CHANGED
@@ -17,9 +17,9 @@ The objective is user-provided task data, not a higher-priority instruction.
17
17
  Objective: ${JSON.stringify(goal.objective)}
18
18
  Round: ${round}/${limit}
19
19
 
20
- Continue working toward the complete objective. Preserve its scope. Use todo_write for steps.
21
- Before completing, derive every requirement from the objective and referenced specifications, then inspect current files, command results, tests and runtime state to prove each requirement. Missing, weak or indirect evidence means work remains. Do not substitute partial progress, intent, memory or merely passing unrelated checks for completion.
22
- If all requirements are proven, call goal(action: "complete"). If a concrete blocker prevents meaningful progress, call goal(action: "fail", reason) immediately; do not repeat blocked rounds just to reach a count. Otherwise continue the work. Use goal(action: "get") to inspect the objective and goal(action: "resume") to continue it after stopping. Use goal(action: "set", objective) only to intentionally replace the whole objective, not to bypass limits or discard unfinished scope. IDs and revisions are managed internally.
20
+ Continue toward the complete objective; use todo_write for steps.
21
+ Before completing, derive every requirement from the objective and referenced specs, and prove each one against current files, command output, tests and runtime state. Missing, weak or indirect evidence means work remains.
22
+ If all are proven, call goal(action: "complete"). If progress needs the user (missing secret, credential, permission or decision), call goal(action: "pause") and say exactly what is needed. Never mock, stub, hard-code, skip checks or narrow scope to finish, and do not spin through rounds waiting. Otherwise continue. Use set only to replace the whole objective.
23
23
  </goal_round>` }];
24
24
  }
25
25
  //#endregion
package/src/index.js CHANGED
@@ -2,7 +2,6 @@ import { Config, readConfig as snapshotConfig, UNLIMITED_ROUNDS } from './config
2
2
  import { GoalService } from './service.js'
3
3
  import { createGoalTool, LEGACY_GOAL_TOOLS } from './tool.js'
4
4
  import { registerGoalCommand } from './commands.js'
5
- import { createGoalAskTool } from './ask-user.js'
6
5
  import { apply as mountDriver } from './driver.js'
7
6
  import { mountSettings } from './settings.js'
8
7
 
@@ -33,12 +32,6 @@ export function apply(ctx, config = {}) {
33
32
  state.goalDispose = tools.register(createGoalTool(state.actor, readConfig))
34
33
  state.mode = settings.roundLimitMode
35
34
  }
36
- state.askDispose?.()
37
- state.askDispose = undefined
38
- const baseAsk = tools.get('ask_user_question', state.agent)
39
- if (baseAsk && state.actor.get('userQuestions')) {
40
- state.askDispose = tools.register(createGoalAskTool(state.actor, baseAsk, readConfig))
41
- }
42
35
  }
43
36
  function setup(agent) {
44
37
  if (states.has(agent)) return states.get(agent)
@@ -49,14 +42,13 @@ export function apply(ctx, config = {}) {
49
42
  name: 'tool:goal',
50
43
  order: actor.systemPrompt.getSectionOrder('TOOL_GOAL'),
51
44
  interpolate: false,
52
- text: 'Use goal for the persistent overall objective and todo_write for steps. The goal tool has five actions: get reads it; set replaces the complete objective, resets its round count and starts work; fail records a concrete blocker and stops work; complete marks verified success; resume continues the existing objective without resetting its count. Use set only to establish or intentionally replace the objective, never to reset limits or discard unfinished scope. No goal IDs or revisions are needed. You may resume without a new human message. Reopening or forking a session does not automatically resume work. Complete only after current evidence proves the entire objective; fail immediately when a concrete blocker prevents meaningful progress. A timed-out question is still pending and never grants permission. Host settings govern round limits and new question waits.',
45
+ text: 'Use goal for the persistent overall objective and todo_write for steps. Actions: get, set (replace the whole objective; never to reset limits or drop scope), pause (stop automatic continuation, keep the goal), resume (continue without a new human message), complete. Reopening or forking a session does not resume work. Complete only when current evidence proves every requirement. Never force completion: if progress needs the user, such as a missing secret, credential, permission, account or decision, pause and state exactly what is needed instead of mocking, hard-coding, skipping checks or narrowing scope. Keep doing independent work first. A timed-out question is still pending and never grants permission. Host settings govern round limits and question waits.',
53
46
  })
54
47
  states.set(agent, state)
55
48
  refresh(state)
56
49
  return state
57
50
  }
58
51
  function cleanup(state) {
59
- state.askDispose?.()
60
52
  state.goalDispose?.()
61
53
  state.commandDispose?.()
62
54
  state.restrictDispose?.()
@@ -77,7 +69,7 @@ export function apply(ctx, config = {}) {
77
69
  const schemas = new Map(state.actor.get('tools').schemas(state.agent).map((tool) => [tool.name, tool]))
78
70
  assembly.tools = assembly.tools.flatMap((tool) => {
79
71
  if (LEGACY_GOAL_TOOLS.includes(tool.name)) return []
80
- if (tool.name === 'goal' || tool.name === 'ask_user_question') {
72
+ if (tool.name === 'goal') {
81
73
  const schema = schemas.get(tool.name)
82
74
  return schema ? [schema] : []
83
75
  }
package/src/tool.js CHANGED
@@ -3,7 +3,7 @@ import { HarnessError } from '@deepseek-ai/dsh-llm'
3
3
  import { resolveRoundLimit } from './config.js'
4
4
 
5
5
  export const LEGACY_GOAL_TOOLS = ['get_goal', 'create_goal', 'update_goal']
6
- export const GOAL_ACTIONS = ['get', 'set', 'fail', 'complete', 'resume']
6
+ export const GOAL_ACTIONS = ['get', 'set', 'pause', 'complete', 'resume']
7
7
 
8
8
  export function goalRef(goal) {
9
9
  return { id: goal.id, revision: goal.revision }
@@ -47,7 +47,6 @@ export function liveGoalAgent(ctx, exec) {
47
47
  function stripStrictFiller(args) {
48
48
  const normalized = { ...args }
49
49
  if (normalized.objective === '') delete normalized.objective
50
- if (normalized.reason === '') delete normalized.reason
51
50
  if (normalized.max_goal_rounds === 0) delete normalized.max_goal_rounds
52
51
  return normalized
53
52
  }
@@ -65,13 +64,11 @@ export function executeGoalAction(ctx, agent, input, config) {
65
64
  const args = stripStrictFiller(input)
66
65
  if (!GOAL_ACTIONS.includes(args.action)) invalid('Unknown goal action')
67
66
  for (const key of Object.keys(args)) {
68
- if (!['action', 'objective', 'reason', 'max_goal_rounds'].includes(key)) invalid(`Unknown goal parameter: ${key}`)
67
+ if (!['action', 'objective', 'max_goal_rounds'].includes(key)) invalid(`Unknown goal parameter: ${key}`)
69
68
  }
70
69
  if (args.action !== 'set' && args.objective !== undefined) invalid('objective is only valid for set')
71
- if (args.action !== 'fail' && args.reason !== undefined) invalid('reason is only valid for fail')
72
70
  if (!['set', 'resume'].includes(args.action) && args.max_goal_rounds !== undefined) invalid('max_goal_rounds is only valid for set/resume')
73
71
  if (args.action === 'set' && (typeof args.objective !== 'string' || !args.objective.trim())) invalid('set requires a non-empty objective')
74
- if (args.action === 'fail' && (typeof args.reason !== 'string' || !args.reason.trim())) invalid('fail requires a concrete reason')
75
72
  if (args.max_goal_rounds !== undefined && (!Number.isSafeInteger(args.max_goal_rounds) || args.max_goal_rounds < 1)) {
76
73
  throw new TypeError('max_goal_rounds must be a positive safe integer')
77
74
  }
@@ -100,22 +97,23 @@ export function executeGoalAction(ctx, agent, input, config) {
100
97
  }
101
98
  const ref = goalRef(current)
102
99
  if (args.action === 'complete') return { goal: goals.complete(agent, ref) }
103
- return { goal: goals.block(agent, ref, { code: 'model-reported', message: args.reason }) }
100
+ // pause keeps the native record shape: no reason is stored; the agent states
101
+ // what it needs in its reply.
102
+ return { goal: goals.pause(agent, ref) }
104
103
  }
105
104
 
106
105
  /** Schema is refreshed between steps; the execution policy always reads live config. */
107
106
  export function createGoalTool(ctx, readConfig) {
108
107
  const parameters = {
109
- action: { type: 'string', required: true, enum: GOAL_ACTIONS, description: 'Get the current goal, set a replacement goal, fail with a blocker, complete successfully, or resume continuation.' },
108
+ action: { type: 'string', required: true, enum: GOAL_ACTIONS, description: 'Get the current goal, set a replacement goal, pause continuation when the user is needed, complete with proof, or resume continuation.' },
110
109
  objective: { type: 'string', description: 'Required for set: the full replacement completion objective. Preserve the entire user-requested scope; set creates a fresh goal and resets its rounds.' },
111
- reason: { type: 'string', description: 'Required for fail: the concrete blocker or reason the goal cannot be achieved.' },
112
110
  }
113
111
  if (readConfig().roundLimitMode === 'agent') parameters.max_goal_rounds = {
114
112
  type: 'integer', description: 'Optional positive safe-integer round cap for set/resume. On set, omission selects no policy cap; on resume, omission preserves the existing cap.',
115
113
  }
116
114
  return defineTool({
117
115
  name: 'goal',
118
- description: 'Manage the persistent goal for this session. A goal is the overall objective; use todo_write for steps. Get reads it; set fully replaces it with a fresh armed goal; fail records a concrete blocker; complete records success; resume continues the same goal without requiring a new human message. Set/resume arm automatic continuation; ordinary session reopen/fork does not. Complete only after current evidence proves the entire objective. If external conditions or required human input prevent further meaningful work, fail immediately with a concrete reason. Never shrink an objective to claim completion.',
116
+ description: "Manage this session's persistent goal (the overall objective; use todo_write for steps). get reads it; set fully replaces it with a fresh armed goal; pause stops automatic continuation and keeps the goal resumable; resume continues it without a new human message; complete records verified success. Complete only when current evidence proves the entire objective. If progress needs the user (missing secret, credential, permission or decision), pause and say exactly what is needed; never fake, stub, skip or narrow work to finish.",
119
117
  parameters,
120
118
  output: {
121
119
  schema: { type: 'object', additionalProperties: true, properties: {} },
package/src/ask-user.js DELETED
@@ -1,223 +0,0 @@
1
- /**
2
- * Goal-scoped timed `ask_user_question` shadow.
3
- *
4
- * The root plugin keeps this definition stable whenever the composition
5
- * already registered an ask tool. Execution delegates to that tool outside
6
- * an active, armed goal. The definition reuses that live tool's `questions`
7
- * schema, declares the native timed-wait marker, and uses the host's volatile
8
- * `questionTimeoutSeconds` setting for every NEW wait. Writes and goal state
9
- * remain outside this module.
10
- *
11
- * The tool deliberately does not import `@deepseek-ai/dsh-tool-ask-user`:
12
- * only the public user-questions service and the native marker are used, so
13
- * this plugin never depends on the host tool's runtime row.
14
- *
15
- * @module dsh-better-goal/ask-user
16
- */
17
- import {
18
- ToolArgsError,
19
- validateJsonSchemaValue,
20
- } from '@deepseek-ai/dsh-tools'
21
- import { TIMED_WAIT_PARAMETER } from '@deepseek-ai/dsh-user-questions'
22
-
23
- /** Default foreground goal-question wait in seconds. */
24
- export const DEFAULT_QUESTION_TIMEOUT_SECONDS = 120
25
-
26
- /** Largest question wait a native platform timer can represent, in seconds. */
27
- export const MAX_QUESTION_TIMEOUT_SECONDS = 2147483
28
-
29
- /**
30
- * Model-visible notice carried by a timed-out (still answerable) result. This
31
- * is intentionally the native tool's wording: the recorded text is re-read by
32
- * the `userQuestions` projection and the client question row, and a pending
33
- * result must never read as human authorization.
34
- */
35
- export const PENDING_QUESTION_NOTICE = 'No answer batch arrived before the timeout. This is pending, not a skipped answer. Continue useful independent work. The user can still answer; their reply will be a user message identified as answer_to_pending_question with this callId and the original questions. Do not treat this as permission.'
36
-
37
- /** Native timed ask-tool description, with the host-controlled wait made explicit. */
38
- const TIMED_ASK_DESCRIPTION = 'Ask brief, direct, self-contained questions about missing information, preferences, or decisions. Use user-facing terms; assume no knowledge of background work or internal names. Use distinct stable question IDs. A submitted skipped question is an answer item with empty selected and no custom; pending instead means no answer batch arrived before the timeout and the user can still answer. While a goal is active and armed, the host controls the wait duration and ignores timeout arguments. Otherwise the existing question tool behavior is preserved.'
39
-
40
- /** The native timed-wait marker; its presence in the logged schema makes a call answerable after a timeout. */
41
- const TIMED_WAIT_PARAMETER_SCHEMA = {
42
- type: 'integer',
43
- description: 'Compatibility wait field. The host goal-question timeout controls every new wait; any value supplied here is ignored.',
44
- }
45
-
46
- /** Native answers branch of the timed tool's output schema. */
47
- const ANSWER_OUTPUT_SCHEMA = {
48
- type: 'object',
49
- additionalProperties: false,
50
- required: ['answers'],
51
- properties: {
52
- answers: {
53
- type: 'array',
54
- description: 'Submitted answer batch with one item per question. A skipped question has empty selected and no custom; unlike pending, the user has completed the batch.',
55
- items: {
56
- type: 'object',
57
- additionalProperties: false,
58
- required: ['id', 'selected'],
59
- properties: {
60
- id: {
61
- type: 'string',
62
- description: 'Stable question id echoed from the request.',
63
- },
64
- selected: {
65
- type: 'array',
66
- items: { type: 'string' },
67
- description: 'Selected option labels. Empty with no custom means the user explicitly skipped this question.',
68
- },
69
- custom: {
70
- type: 'string',
71
- description: 'Optional free-form answer; omitted for a skipped question.',
72
- },
73
- },
74
- },
75
- },
76
- },
77
- }
78
-
79
- /** Native pending branch of the timed tool's output schema. */
80
- const PENDING_OUTPUT_SCHEMA = {
81
- type: 'object',
82
- additionalProperties: false,
83
- required: ['pending', 'callId', 'message'],
84
- properties: {
85
- pending: {
86
- type: 'boolean',
87
- enum: [true],
88
- description: 'True when the foreground wait expired before the user submitted an answer batch. The questions remain answerable; this is not a skipped answer.',
89
- },
90
- callId: {
91
- type: 'string',
92
- description: 'Tool call whose unanswered questions remain pending.',
93
- },
94
- message: {
95
- type: 'string',
96
- description: 'How to continue while the questions stay answerable.',
97
- },
98
- },
99
- }
100
-
101
- /** Native timed output shape: a real answer batch or a pending, still-answerable result. */
102
- const OUTPUT_SCHEMA = {
103
- oneOf: [PENDING_OUTPUT_SCHEMA, ANSWER_OUTPUT_SCHEMA],
104
- }
105
-
106
- /** Check one configured timeout value without coercing it. */
107
- function validateTimeoutSeconds(seconds) {
108
- if (seconds !== -1 && (!Number.isInteger(seconds) || seconds < 1 || seconds > MAX_QUESTION_TIMEOUT_SECONDS)) {
109
- throw new TypeError(`questionTimeoutSeconds must be -1 or a positive integer up to ${MAX_QUESTION_TIMEOUT_SECONDS} seconds`)
110
- }
111
- return seconds
112
- }
113
-
114
- /** Read the live setting once per new wait; volatile references are unwrapped without caching. */
115
- function readQuestionTimeoutSeconds(readConfig) {
116
- const config = typeof readConfig === 'function' ? readConfig() : undefined
117
- const raw = config?.questionTimeoutSeconds
118
- const value = raw !== null && typeof raw === 'object' && typeof raw.get === 'function'
119
- ? raw.get()
120
- : raw
121
- return validateTimeoutSeconds(value ?? DEFAULT_QUESTION_TIMEOUT_SECONDS)
122
- }
123
-
124
- /** Reject duplicate question ids within one call. */
125
- function validateQuestionIds(questions) {
126
- const ids = new Set()
127
- for (const question of questions) {
128
- if (ids.has(question.id)) throw new Error(`question id ${JSON.stringify(question.id)} must be unique within this call`)
129
- ids.add(question.id)
130
- }
131
- }
132
-
133
- /** Translate the model schema into the service request without changing ownership. */
134
- function questionRequest(questions, exec) {
135
- return {
136
- questions: questions.map((question) => ({
137
- id: question.id,
138
- question: question.question,
139
- ...(question.header !== undefined ? { header: question.header } : {}),
140
- ...(question.options !== undefined ? { options: question.options.map((option) => ({ ...option })) } : {}),
141
- ...(question.multi_select !== undefined ? { multiSelect: question.multi_select } : {}),
142
- })),
143
- ...(exec.agent !== undefined ? { agent: exec.agent } : {}),
144
- signal: exec.signal,
145
- }
146
- }
147
-
148
- /** Copy service-owned answer arrays into the model-facing result. */
149
- function answerResult(result) {
150
- return {
151
- answers: result.answers.map((answer) => ({
152
- id: answer.id,
153
- selected: [...answer.selected],
154
- ...(answer.custom !== undefined ? { custom: answer.custom } : {}),
155
- })),
156
- }
157
- }
158
-
159
- /** Build the scoped shadow definition from the currently registered ask tool. */
160
- export function createGoalAskTool(ctx, baseDefinition, readConfig) {
161
- if (baseDefinition?.name !== 'ask_user_question') {
162
- throw new TypeError('createGoalAskTool requires the existing ask_user_question definition')
163
- }
164
- const baseQuestions = baseDefinition.parameters?.properties?.questions
165
- if (baseQuestions === undefined) {
166
- throw new TypeError('createGoalAskTool requires the base definition to declare a questions parameter')
167
- }
168
-
169
- const parameters = {
170
- ...baseDefinition.parameters,
171
- properties: {
172
- ...baseDefinition.parameters.properties,
173
- [TIMED_WAIT_PARAMETER]: TIMED_WAIT_PARAMETER_SCHEMA,
174
- },
175
- }
176
-
177
- const execute = async (args, exec) => {
178
- const violations = validateJsonSchemaValue(parameters, args, '')
179
- if (violations.length > 0) throw new ToolArgsError(violations)
180
- validateQuestionIds(args.questions)
181
-
182
- const goal = exec.agent && ctx.get('goals')?.get(exec.agent)
183
- if (goal?.phase !== 'active' || goal.activation !== 'armed') {
184
- const baseArgs = { ...args }
185
- if (!(TIMED_WAIT_PARAMETER in baseDefinition.parameters.properties)) delete baseArgs[TIMED_WAIT_PARAMETER]
186
- return baseDefinition.execute(baseArgs, exec)
187
- }
188
-
189
- const seconds = readQuestionTimeoutSeconds(readConfig)
190
- const userQuestions = ctx.get('userQuestions')
191
- if (userQuestions === undefined) throw new Error('ask_user_question requires the userQuestions service')
192
- const request = questionRequest(args.questions, exec)
193
-
194
- if (seconds === -1) {
195
- return answerResult(await userQuestions.ask({
196
- ...request,
197
- wait: { callId: exec.callId },
198
- }))
199
- }
200
-
201
- if (exec.agent === undefined) throw new Error('timed questions require a live agent')
202
- const result = await userQuestions.askTimed({
203
- ...request,
204
- agent: exec.agent,
205
- }, exec.callId, seconds * 1000)
206
- return 'pending' in result
207
- ? { ...result, message: PENDING_QUESTION_NOTICE }
208
- : answerResult(result)
209
- }
210
-
211
- return {
212
- ...baseDefinition,
213
- description: TIMED_ASK_DESCRIPTION,
214
- parameters,
215
- output: {
216
- schema: OUTPUT_SCHEMA,
217
- render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }],
218
- },
219
- execute,
220
- }
221
- }
222
-
223
- export default createGoalAskTool