@deepseek-ai/dsh-tool-ask-user 0.1.1-rc.2 → 0.1.2-alpha.2

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.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # pnpm run verify-translation-pairing --write packages/interaction/tool-ask-user/README.md
5
- README.md: bf2ba369fca36c462c6155ed2354ab3d0e930dd0
6
- README.zh.md: 067235d84d70d2f3278fd39f5c01f130373d3ac2
5
+ README.md: ec123b206bb4f2d91680b09e5f5dd10efc4c3d0d
6
+ README.zh.md: e86e8cee1561d52af36dcba1dca3bfe14ec98da4
package/README.md CHANGED
@@ -1,26 +1,106 @@
1
+ ---
2
+ description: "The model-facing ask_user_question tool over the user-questions seam, for users and maintainers composing or debugging interactive agent surfaces."
3
+ kind: "package-reference"
4
+ ---
5
+
1
6
  # @deepseek-ai/dsh-tool-ask-user
2
7
 
3
8
  English | [中文](README.zh.md)
4
9
 
5
- Model-facing `ask_user_question` tool over `ctx.userQuestions`. It lets the model ask the human a concise question when it needs confirmation, a choice, or missing information before continuing.
10
+ ## Summary
11
+
12
+ `dsh-tool-ask-user` gives the model one tool — `ask_user_question` — for asking the human a concise question when it needs confirmation, a choice, or missing information before continuing. The tool pauses until the first scoped answerer accepts the request, then feeds that answer back into the agent loop as an ordinary tool result, so no loop mechanics change. The tool returns the canonical `{ answers: [...] }` shape, rendered as compact JSON text. It renders no UI itself and does not know how input is collected; the Web client contributes its answerer through Remote Events. A runtime-owned child agent cannot ask the user; it must include the unresolved question in its final result.
13
+
14
+ ## Table of Contents
15
+
16
+ - [Use this package](#use-this-package)
17
+ - [Understand the implementation](#understand-the-implementation)
18
+ - [Further Exploration](#further-exploration)
19
+ - [Model Experience](#model-experience)
20
+ - [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
21
+ - [Dev Note](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## Use this package
27
+
28
+ Compose this plugin wherever the model should be able to pause for a human decision: it provides the `ask_user_question` tool and needs the `ctx.userQuestions` seam with an answerer that accepts the scoped request. Without one, the tool call fails with an error instead of degrading.
29
+
30
+ ### When to call the tool
31
+
32
+ The model calls `ask_user_question` when it needs confirmation, a choice, or missing information before proceeding. Send one or more questions, each with a stable `id` that is echoed in the answer; a recommended option goes first with `(Recommended)` appended to its label.
33
+
34
+ ```json
35
+ {
36
+ "questions": [
37
+ {
38
+ "id": "cleanup",
39
+ "question": "Proceed with the destructive cleanup?",
40
+ "header": "Confirm",
41
+ "options": [
42
+ { "label": "Yes, delete them (Recommended)", "description": "Removes the three stale files." },
43
+ { "label": "No, keep them", "description": "Aborts the cleanup." }
44
+ ]
45
+ }
46
+ ]
47
+ }
48
+ ```
49
+
50
+ ### What the model gets back
51
+
52
+ The tool returns one answer object per question: `selected` holds the chosen option labels, and `custom` carries a free-form answer — supplementing `selected` for a multi-select question and overriding it for a single-select question. The Native renderer preserves the compact JSON text shape.
53
+
54
+ ```json
55
+ { "answers": [{ "id": "cleanup", "selected": ["Yes, delete them (Recommended)"] }] }
56
+ ```
57
+
58
+ ### When the call fails
59
+
60
+ The tool call blocks until the human answers and cancels only through the turn's signal. No accepting answerer, an aborted call, or a caller that is not the exact live runtime root each settles as an error the model sees in the tool result — most notably, a live child agent owned by another agent is rejected (`DELEGATED_CALLER`) and must include the unresolved question or decision in its final result.
61
+
62
+ -----
6
63
 
7
- ## Tool
64
+ <a id="understand-the-implementation"></a>
65
+ ## Understand the implementation
8
66
 
9
- `ask_user_question` accepts:
67
+ <details>
68
+ <summary>Implementation internals — click to expand</summary>
10
69
 
11
- - `questions` required non-empty array of question objects.
12
- - `id` — required stable id on each question, echoed in the answer.
13
- - `question` — required question text for each question.
14
- - `header` — optional short heading.
15
- - `options` — optional choices with `label` and `description`. If recommending a choice, put it first and append `(Recommended)` to that label.
16
- - `multi_select` — whether that question may return more than one selected option.
70
+ The observable behavior is covered in [Use this package](#use-this-package); this section explains the tool definition and its relationship to the seam.
17
71
 
18
- The tool calls `ctx.userQuestions.ask()` and returns canonical `{ answers: [{ id, selected, custom? }] }`. `selected` contains option labels; `custom` carries a free-form answer, supplementing `selected` for a multi-select question and overriding it for a single-select question. The Native renderer preserves the compact JSON text shape `{ "answers": [{ "id": "...", "selected": ["..."], "custom": "..." }] }`.
72
+ ### Source map
19
73
 
20
- ## Role
74
+ | File | Role |
75
+ |---|---|
76
+ | [`src/index.ts`](src/index.ts) | Tool registration: `ask_user_question` schema, execute path, result render |
77
+ | [`src/invariant.ts`](src/invariant.ts) | Invariant companion (no runtime invariant; the seam owns execution relations) |
21
78
 
22
- This is the Consumer package for the user-questions seam. It does not render UI and does not know how input is collected; it only translates model arguments into `AskUserQuestionRequest` and returns the human answer to the agent loop.
79
+ ### Consumer role
23
80
 
81
+ The plugin registers one `defineTool` entry on `ctx.tools` with injects `['tools', 'userQuestions']`. `execute` maps model arguments into an `AskUserQuestionRequest`, forwards the exact calling agent and the turn's signal, and maps the accepted answer back into the canonical `answers` array. The seam owns identity checks, intent validation, waterfall dispatch, and the error taxonomy; this package only translates.
82
+
83
+ ### Result rendering
84
+
85
+ The `render` output projects the structured value to a single text block via `JSON.stringify`, which is why the model-facing result is compact JSON rather than a richer content-block vocabulary.
86
+
87
+ </details>
88
+
89
+ -----
90
+
91
+ <a id="further-exploration"></a>
92
+ ## Further Exploration
93
+
94
+ Read these pages when the package-level contract is not enough. They move from the tool surface to the seam contract and its answerer waterfall.
95
+
96
+ - [User interaction subsystem reference](../../../docs/subsystems/user-questions.md) — the service contract, question vocabulary, and answerer waterfall behind this tool.
97
+ - [Tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-ask-user) — the generated `ask_user_question` schema.
98
+ - [user-questions package](../user-questions/README.md) — the seam this tool consumes.
99
+ - [Interaction group map](../README.md) — adjacent approval and command surfaces.
100
+
101
+ -----
102
+
103
+ <a id="model-experience"></a>
24
104
  ## Model Experience
25
105
 
26
106
  ### Tool schema
@@ -53,6 +133,21 @@ Append-only; newly visible content follows the reusable request prefix and does
53
133
 
54
134
  ## Known Limitations and Deferred Work
55
135
 
136
+ <a id="known-limitations-and-deferred-work"></a>
137
+
138
+
139
+ These limits define when the tool is a poor fit. They are current package constraints, not a UI backlog.
140
+
56
141
  - **A pending question blocks the tool call until the human answers** — the tool declares no `timeout-policy` budget; cancellation rides the turn's `exec.signal` only.
57
142
  - **Runtime-owned subagents cannot ask the user** — `ask_user_question` rejects a live child owned by another agent with `DELEGATED_CALLER`; the child must include the unresolved question or decision in its final result. Durable lineage does not decide this boundary, so a lineage-bearing session resumed as a runtime root may ask normally.
58
143
  - **Native answers render as JSON text** — the canonical value remains structured, but the model-facing result uses compact JSON rather than a richer content-block vocabulary.
144
+
145
+ <a id="dev-note"></a>
146
+ ### Dev Note
147
+
148
+ <details>
149
+ <summary>Working context for maintainers — click to expand</summary>
150
+
151
+ None.
152
+
153
+ </details>
package/README.zh.md CHANGED
@@ -1,33 +1,113 @@
1
+ ---
2
+ description: "基于用户交互 seam 的模型侧 ask_user_question 工具;供组合或排查交互式 agent 表面的用户与维护者阅读。"
3
+ kind: "package-reference"
4
+ ---
5
+
1
6
  # @deepseek-ai/dsh-tool-ask-user
2
7
 
3
8
  [English](README.md) | 中文
4
9
 
5
- 模型侧 `ask_user_question` 工具,基于 `ctx.userQuestions` 实现。当模型需要确认、选择结果或缺失的信息才能继续时,它可以借此向用户提出简明问题。
10
+ ## 概述
11
+
12
+ `dsh-tool-ask-user` 为模型提供一个工具——`ask_user_question`——用于在需要确认、选择结果或缺失的信息才能继续时,向用户提出简明问题。工具会暂停,直到首个作用域 answerer 接受请求,然后把回答作为普通工具结果送回 agent loop(智能体循环),因此循环机制没有任何变化。工具返回规范的 `{ answers: [...] }` 结构,并以紧凑的 JSON 文本形式呈现。它自身不渲染 UI,也不了解输入的收集方式;Web Client 通过 Remote Events 提供 answerer。运行时中归属于其他 agent 的子级不能向用户提问;它必须在最终结果中包含尚未解决的问题。
13
+
14
+ ## 目录
15
+
16
+ - [使用本包](#use-this-package)
17
+ - [理解实现](#understand-the-implementation)
18
+ - [进一步探索](#further-exploration)
19
+ - [模型体验](#model-experience)
20
+ - [已知限制与延期工作](#known-limitations-and-deferred-work)
21
+ - [开发备注](#dev-note)
22
+
23
+ -----
24
+
25
+ <a id="use-this-package"></a>
26
+ ## 使用本包
27
+
28
+ 凡模型应当能够暂停等待人类决定的场景,都可组合此插件:它提供 `ask_user_question` 工具,并且需要带有接受作用域请求的 answerer 的 `ctx.userQuestions` seam。没有 answerer 接受时,工具调用会以错误失败,而不是降级。
29
+
30
+ ### 何时调用该工具
31
+
32
+ 当模型需要确认、选择结果或缺失的信息才能继续时,调用 `ask_user_question`。发送一个或多个问题,每个问题携带稳定的 `id`(回答中会原样包含);推荐选项放在首位,并在标签末尾追加 `(Recommended)`。
33
+
34
+ ```json
35
+ {
36
+ "questions": [
37
+ {
38
+ "id": "cleanup",
39
+ "question": "Proceed with the destructive cleanup?",
40
+ "header": "Confirm",
41
+ "options": [
42
+ { "label": "Yes, delete them (Recommended)", "description": "Removes the three stale files." },
43
+ { "label": "No, keep them", "description": "Aborts the cleanup." }
44
+ ]
45
+ }
46
+ ]
47
+ }
48
+ ```
49
+
50
+ ### 模型得到什么
51
+
52
+ 工具为每个问题返回一个回答对象:`selected` 保存选中的选项标签,`custom` 携带自由填写的回答——对多选题补充 `selected`,对单选题覆盖它。Native 渲染器保留紧凑的 JSON 文本形式。
53
+
54
+ ```json
55
+ { "answers": [{ "id": "cleanup", "selected": ["Yes, delete them (Recommended)"] }] }
56
+ ```
57
+
58
+ ### 调用何时失败
59
+
60
+ 工具调用会阻塞到用户作答,并且只能通过当前轮次的信号取消。没有 answerer 接受、调用被中止、或调用方不是确切的存活运行时根,都会以模型在工具结果中看到的错误结算——最值得注意的是,归属于另一个 agent 的存活子级会被拒绝(`DELEGATED_CALLER`),必须在最终结果中包含尚未解决的问题或决定。
61
+
62
+ -----
6
63
 
7
- ## 工具
64
+ <a id="understand-the-implementation"></a>
65
+ ## 理解实现
8
66
 
9
- `ask_user_question` 接受以下参数:
67
+ <details>
68
+ <summary>实现细节——点击展开</summary>
10
69
 
11
- - `questions`:必填的非空问题对象数组。
12
- - `id`:每个问题必填的稳定 id,会原样包含在回答中。
13
- - `question`:每个问题必填的问题文本。
14
- - `header`:可选的简短标题。
15
- - `options`:可选选项,包含 `label` 和 `description`。如需推荐某个选项,请将其置于首位,并在该标签末尾追加 `(Recommended)`。
16
- - `multi_select`:该问题是否可以返回多个选中的选项。
70
+ 可观察行为已在[使用本包](#use-this-package)中说明;本节解释工具定义及其与 seam 的关系。
17
71
 
18
- 工具调用 `ctx.userQuestions.ask()`,并返回规范的 `{ answers: [{ id, selected, custom? }] }`。`selected` 包含选项标签;`custom` 携带自由填写的回答,对于多选题会补充 `selected`,对于单选题则会覆盖它。Native 渲染器会保留紧凑的 JSON 文本形式 `{ "answers": [{ "id": "...", "selected": ["..."], "custom": "..." }] }`。
72
+ ### 源码地图
19
73
 
20
- ## 职责
74
+ | 文件 | 职责 |
75
+ |---|---|
76
+ | [`src/index.ts`](src/index.ts) | 工具注册:`ask_user_question` schema、执行路径、结果渲染 |
77
+ | [`src/invariant.ts`](src/invariant.ts) | 不变式伴生插件(无运行时不变式;执行关系由 seam 拥有) |
21
78
 
22
- 此包是用户交互 seam 的Consumer 包。它不渲染 UI,也不了解输入的收集方式;它只将模型参数转换为 `AskUserQuestionRequest`,并把用户回答返回给 agent loop(智能体循环)。
79
+ ### Consumer 角色
23
80
 
81
+ 该插件以 `['tools', 'userQuestions']` 注入,在 `ctx.tools` 上注册一个 `defineTool` 条目。`execute` 把模型参数映射为 `AskUserQuestionRequest`,转发确切的调用 agent 与当前轮次的信号,并把接受的回答映射回规范的 `answers` 数组。身份检查、意图校验、waterfall 分派与错误分类由 seam 拥有;本包只做转换。
82
+
83
+ ### 结果渲染
84
+
85
+ `render` 输出把结构化值经 `JSON.stringify` 投影为单个文本块,因此模型侧结果是紧凑 JSON,而非更丰富的内容块词汇。
86
+
87
+ </details>
88
+
89
+ -----
90
+
91
+ <a id="further-exploration"></a>
92
+ ## 进一步探索
93
+
94
+ 当包级约定不够用时阅读以下页面。它们从工具表面逐步进入 seam 约定及其 answerer waterfall。
95
+
96
+ - [用户交互子系统参考](../../../docs/subsystems/user-questions.zh.md)——此工具背后的服务约定、问题词汇与 answerer waterfall。
97
+ - [工具目录](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-ask-user)——生成的 `ask_user_question` schema。
98
+ - [user-questions 包](../user-questions/README.zh.md)——本工具消费的 seam。
99
+ - [交互组映射](../README.zh.md)——相邻的审批与命令表面。
100
+
101
+ -----
102
+
103
+ <a id="model-experience"></a>
24
104
  ## 模型体验
25
105
 
26
106
  ### 工具 schema
27
107
 
28
108
  #### 模型看到的内容
29
109
 
30
- 模型会看到生成的 [`ask_user_question` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-ask-user),其中包含问题 id、提示语、标题、选项和多选标志。
110
+ 模型会看到生成的 [`ask_user_question` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-ask-user),其中包含问题 id、提示语、标题、选项与多选标志。
31
111
 
32
112
  #### Token 影响
33
113
 
@@ -49,10 +129,25 @@
49
129
 
50
130
  #### KV Cache 影响
51
131
 
52
- 仅追加;新可见内容位于可复用请求前缀之后,不会使现有 KV Cache 条目失效。
132
+ 仅追加;新出现的可见内容位于可复用请求前缀之后,不会使现有 KV Cache 条目失效。
133
+
134
+ ## 已知限制与延期工作
135
+
136
+ <a id="known-limitations-and-deferred-work"></a>
137
+
53
138
 
54
- ## 已知限制与暂缓事项
139
+ 这些限制说明该工具何时不合适。它们是当前包约束,不是 UI 积压事项。
55
140
 
56
141
  - **待处理问题会阻塞工具调用,直至用户作答**:该工具未声明 `timeout-policy` 预算;取消仅沿用当前轮次的 `exec.signal`。
57
- - **运行时中归属于其他 agent 的 subagent 不能向用户提问**:`ask_user_question` 会以 `DELEGATED_CALLER` 拒绝归属于另一个 agent 的存活子级;该子级必须在最终结果中包含尚未解决的问题或决策。持久谱系不能决定这一边界,因此带有谱系的会话恢复为运行时根后可以正常提问。
142
+ - **运行时中归属于其他 agent 的 subagent 不能向用户提问**:`ask_user_question` 会以 `DELEGATED_CALLER` 拒绝归属于另一个 agent 的存活子级;该子级必须在最终结果中包含尚未解决的问题或决定。持久谱系不能决定这一边界,因此带有谱系的会话恢复为运行时根后可以正常提问。
58
143
  - **Native 回答渲染为 JSON 文本**:规范值仍为结构化数据,但模型侧结果使用紧凑 JSON,而非更丰富的内容块词汇。
144
+
145
+ <a id="dev-note"></a>
146
+ ### 开发备注
147
+
148
+ <details>
149
+ <summary>维护者的工作上下文——点击展开</summary>
150
+
151
+ 无。
152
+
153
+ </details>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-tool-ask-user",
3
3
  "description": "Model-facing ask_user_question tool over the ctx.userQuestions seam",
4
- "version": "0.1.1-rc.2",
4
+ "version": "0.1.2-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -32,19 +32,19 @@
32
32
  ],
33
33
  "license": "MIT",
34
34
  "peerDependencies": {
35
- "@deepseek-ai/dsh-agent": "^0.1.1-rc.2",
36
- "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
37
- "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
38
- "@deepseek-ai/dsh-user-questions": "^0.1.1-rc.2",
39
- "@deepseek-ai/cordis": "^4.0.1"
35
+ "@deepseek-ai/dsh-agent": "^0.1.2-alpha.2",
36
+ "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
37
+ "@deepseek-ai/dsh-user-questions": "^0.1.2-alpha.2",
38
+ "@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
39
+ "@deepseek-ai/cordis": "^4.0.2"
40
40
  },
41
41
  "devDependencies": {
42
- "@deepseek-ai/dsh-agent": "^0.1.1-rc.2",
43
- "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
44
- "@deepseek-ai/dsh-llm": "^0.1.1-rc.2",
45
- "@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.2",
46
- "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
47
- "@deepseek-ai/dsh-user-questions": "^0.1.1-rc.2",
48
- "@deepseek-ai/cordis": "^4.0.1"
42
+ "@deepseek-ai/dsh-agent": "^0.1.2-alpha.2",
43
+ "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.2",
44
+ "@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
45
+ "@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
46
+ "@deepseek-ai/dsh-system-prompt": "^0.1.2-alpha.2",
47
+ "@deepseek-ai/dsh-user-questions": "^0.1.2-alpha.2",
48
+ "@deepseek-ai/cordis": "^4.0.2"
49
49
  }
50
50
  }