@deepseek-ai/dsh-client-ui-tool 0.1.7-alpha.2 → 0.1.7-rc.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 +48 -5
- package/README.md +12 -4
- package/README.zh.md +12 -4
- package/lib/client.js +291 -87
- package/lib/types/client/contract/slots.d.ts +43 -20
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/tool/components/PreparingToolRow.d.ts +19 -0
- package/lib/types/client/tool/components/ToolRow.d.ts +4 -1
- package/lib/types/client/tool/models/raw-tool-call.d.ts +4 -3
- package/lib/types/client/tool/models/todo-diff-model.d.ts +1 -1
- package/lib/types/client/tool/models/tool-call-model.d.ts +10 -3
- package/lib/types/client/tool/models/web-card-model.d.ts +6 -0
- package/lib/types/client/tool/tool-call-arguments-partial.d.ts +9 -0
- package/lib/types/client/tool/toolviews/GenericToolCard.d.ts +3 -2
- package/lib/types/client/tool/toolviews/bash-sample.d.ts +1 -1
- package/lib/types/client/tool/toolviews/details-row.d.ts +3 -1
- package/lib/types/client/tool/toolviews/file-mutation-row.d.ts +1 -1
- package/package.json +26 -26
package/README.i18n.yaml
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
|
-
# Bilingual-pair consistency record (docs/i18n/README.md):
|
|
2
|
-
#
|
|
3
|
-
#
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/client/ui-tool/README.md
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/:
|
|
6
|
+
en: d5ef8fa5a5ebfbc2
|
|
7
|
+
zh: 9870b3f207a248cc
|
|
8
|
+
/deepseek-ai-dsh-client-ui-tool:
|
|
9
|
+
en: 03bfcfbf7f1cea76
|
|
10
|
+
zh: 142abbf07affee63
|
|
11
|
+
/deepseek-ai-dsh-client-ui-tool/summary:
|
|
12
|
+
en: e7ef510d1764f9b2
|
|
13
|
+
zh: 236bc66607211f0f
|
|
14
|
+
/deepseek-ai-dsh-client-ui-tool/table-of-contents:
|
|
15
|
+
en: d152484eb41ac6b4
|
|
16
|
+
zh: 09388d293f9be9cb
|
|
17
|
+
/deepseek-ai-dsh-client-ui-tool/use-this-package:
|
|
18
|
+
en: be2bc859e0d64fe5
|
|
19
|
+
zh: d51a35fb36675dd3
|
|
20
|
+
/deepseek-ai-dsh-client-ui-tool/use-this-package/registering-a-business-tool-view:
|
|
21
|
+
en: 5332d87e76037f07
|
|
22
|
+
zh: db5d06e7e46b8429
|
|
23
|
+
/deepseek-ai-dsh-client-ui-tool/use-this-package/built-in-views:
|
|
24
|
+
en: 4b69e36952574494
|
|
25
|
+
zh: 1f9842b40931adb6
|
|
26
|
+
/deepseek-ai-dsh-client-ui-tool/understand-the-implementation:
|
|
27
|
+
en: 00bc7b0c84edc603
|
|
28
|
+
zh: 1cfcf5b435248a91
|
|
29
|
+
/deepseek-ai-dsh-client-ui-tool/understand-the-implementation/rendering-contract:
|
|
30
|
+
en: 2959b10b01e08a7b
|
|
31
|
+
zh: 7084ca22650cbb5b
|
|
32
|
+
/deepseek-ai-dsh-client-ui-tool/understand-the-implementation/cards:
|
|
33
|
+
en: 401a0118de2dba33
|
|
34
|
+
zh: 9efe590dd485c336
|
|
35
|
+
/deepseek-ai-dsh-client-ui-tool/further-exploration:
|
|
36
|
+
en: 886059e6bd594ebf
|
|
37
|
+
zh: 94cfe8d0a789f413
|
|
38
|
+
/deepseek-ai-dsh-client-ui-tool/model-experience:
|
|
39
|
+
en: 1e5e72dd269855d5
|
|
40
|
+
zh: 81a4756d460e3af9
|
|
41
|
+
/deepseek-ai-dsh-client-ui-tool/model-experience/kv-cache-effect:
|
|
42
|
+
en: ca75c51c89c2c9b0
|
|
43
|
+
zh: de54f3467ef3b9be
|
|
44
|
+
/deepseek-ai-dsh-client-ui-tool/known-limitations-and-deferred-work:
|
|
45
|
+
en: 7475317a656f1d11
|
|
46
|
+
zh: 787f10cc0f2c586e
|
|
47
|
+
/deepseek-ai-dsh-client-ui-tool/known-limitations-and-deferred-work/dev-note:
|
|
48
|
+
en: 0fdeab2e4db0261f
|
|
49
|
+
zh: 156d2b2952cf112e
|
package/README.md
CHANGED
|
@@ -25,10 +25,12 @@ English | [中文](README.zh.md)
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## Use this package
|
|
27
27
|
|
|
28
|
-
Tool calls appear in the conversation as cards: a root call tree with its nested subcalls, each atomic call rendered by its owning view. Every lifecycle state retains the tool's ordinary business glyph; failure and interruption remain explicit through the frozen call/result state, accessible status text, and failure summary. Users can open files or inspect calls through the Host callbacks.
|
|
28
|
+
Tool calls appear in the conversation as cards: a root call tree with its nested subcalls, each atomic call rendered by its owning view. Every lifecycle state retains the tool's ordinary business glyph; failure and interruption remain explicit through the frozen call/result state, accessible status text, and failure summary. Users can open files or inspect calls through the Host callbacks. A collapsed `web_fetch` row links its http(s) URL, which opens in a new browser tab.
|
|
29
29
|
|
|
30
30
|
Shared Tool rows and Bash rows retain error and warning colors for failed and stopped summaries, including on hover. Hover darkens only summaries without those states.
|
|
31
31
|
|
|
32
|
+
Before dispatch, a named model call appears as one non-expandable row with its tool-owned icon and title. A generic row shows `Tool call · <tool name>`. Preparation exposes no complete arguments, file link, result, or parameter-dependent interaction. Write/edit show `Preparing content NKB` in the summary; N is `Math.ceil(raw.length / 1024)`, an integer estimate of the raw argument string length, not the file's byte size. `tool/call` enables the existing call presentation; completing an argument block alone does not start execution.
|
|
33
|
+
|
|
32
34
|
### Registering a business tool view
|
|
33
35
|
|
|
34
36
|
An owning business package registers its wire Tool name into `tool.call.toolview`:
|
|
@@ -41,10 +43,12 @@ ctx.slots.inject('tool.call.toolview', () =>
|
|
|
41
43
|
}, BusinessToolRow))
|
|
42
44
|
```
|
|
43
45
|
|
|
44
|
-
The owner payload is `ToolCallOwnerProps`: `callId`, `toolName`, the frozen `block`, optional `cwd` and `home`, the session-authorized `loadImage` loader (for a view whose result carries durable images), and plain `openFile`/`inspect` callbacks. A PTC dispatch block retains its event's `parentCallId`; a root Session call has no such field, so descendants route through the same keyed dispatch — a registered view such as `read_image` renders its card there, and unregistered descendants keep the generic flattened form. Path summaries relativize to the Session cwd first, then replace a leftover POSIX Host home with `~`; `filePath` and Host open keep the authored filesystem path. The registration receives the normal Session slot runtime share but no React node or Runtime service.
|
|
46
|
+
The owner payload is `ToolCallOwnerProps`: `callId`, `toolName`, the `phase` discriminant and its frozen stage-specific `block`, optional `cwd` and `home`, the session-authorized `loadImage` loader (for a view whose result carries durable images), and plain `openFile`/`inspect` callbacks. A PTC dispatch block retains its event's `parentCallId`; a root Session call has no such field, so descendants route through the same keyed dispatch — a registered view such as `read_image` renders its card there, and unregistered descendants keep the generic flattened form. Path summaries relativize to the Session cwd first, then replace a leftover POSIX Host home with `~`; `filePath` and Host open keep the authored filesystem path. The registration receives the normal Session slot runtime share but no React node or Runtime service.
|
|
45
47
|
|
|
46
48
|
### Built-in views
|
|
47
49
|
|
|
50
|
+
Every registered view receives the explicit `preparing`, `start`, and `result` props declared in [the Tool slot types](src/client/contract/slots.ts). Shared rows use the same `ToolRow` in all stages. Their row model selects the title and combines any generic tool-name prefix with the available argument summary independently of lifecycle state. Tool-owned titles omit the English name. The shared argument parser returns no call during preparation and does not parse partial JSON. Write/edit use separate preparing and dispatched components, so only the preparing component invokes `useToolCallArgumentsPartial`; start and result share the dispatched component. Custom renderers such as Bash, Skill, and Cordis handle preparation separately; their argument-dependent components accept `StartedToolCallViewProps`.
|
|
51
|
+
|
|
48
52
|
This package owns the generic fallback and the built-in shell/pwsh, read, read_image, write/edit, running `str_replace_editor` `create`/`str_replace`, grep/glob, web, todo, question, and PTC dispatch presentations. Structured cards derive directly from first-party raw event fields; Host `presentCall` and `presentResult` values never enter the Client. Running and settled foreground standard `bash`/`pwsh` and `terminal_send` calls use terminal cards at the root and in PTC dispatch children, subject to the same argument, result, and error checks. Persistent `bash`/`pwsh` calls use terminal cards only while running. Shell output ending in a recognized spill-policy notice uses expandable generic output in shell rows and generic output in Details; a displaced or omitted exit marker cannot establish success. Settled persistent-shell results stay generic because reset and partial-output diagnostics do not always describe one process exit status; root persistent results are expandable, while background acknowledgements remain collapsed. A native or PTC dispatch failure carrying `AUTO_REVIEW_DENIED` shows the Auto review verdict in its collapsed row and one normalized not-executed reason when expanded; a missing or whitespace-only reason uses localized fallback text. A successful question row pairs call questions with result answers by their stable ids and shows readable question/answer lines when expanded. A cancelled or interrupted row shows its verdict and original questions without inventing answers. Unsupported, malformed, or ambiguous inputs fall back to flattened Tool input/result text. `ui-skill` demonstrates a business-owned registration for `skill`.
|
|
49
53
|
|
|
50
54
|
-----
|
|
@@ -59,10 +63,13 @@ The package realizes one dispatch rule: atomic Tool views are keyed by wire Tool
|
|
|
59
63
|
|
|
60
64
|
### Rendering contract
|
|
61
65
|
|
|
62
|
-
`ToolCallTree` receives one
|
|
66
|
+
`ToolCallTree` receives one Tool node, Session `cwd`, and navigation callbacks. Each branch receives a stable block and memoizes its explicit phase props, so changing one subcall leaves unchanged sibling branches unrendered. It dispatches each tool by name through `tool.call.toolview`. Dispatched roots retain their recursive `subCalls`; preparation has no children. Each root and child wrapper preserves the `data-chat-anchor-key="call:<id>"` and `data-chat-call-id` DOM contract used for paging and selection. The Tool node keeps the same callId across all three stages.
|
|
63
67
|
|
|
64
68
|
Tool owner props forward Chat's stable `useDisclosure` Hook through root and nested calls. Rows invoke it where they own their expanded bodies; intermediate renderers do not subscribe. Each invocation has independent open state that resets when the enclosing Turn collapses, without replacing React identity. Presentation-mode switches preserve it.
|
|
65
69
|
|
|
70
|
+
|
|
71
|
+
The slot-injected `useToolCallArgumentsPartial` Hook lazily subscribes to the owning Step's `assistant-step` source and selects this callId's raw argument prefix. Missing sources or calls return an empty string. Other calls in the same Step may trigger a snapshot check, but an unchanged selected string does not refresh the consumer. Tools that do not invoke the Hook add no subscription; dispatched calls have no argument-prefix source.
|
|
72
|
+
|
|
66
73
|
### Cards
|
|
67
74
|
|
|
68
75
|
|
|
@@ -98,7 +105,7 @@ These pages cover the conversation host, the view slots, and the card models.
|
|
|
98
105
|
<a id="model-experience"></a>
|
|
99
106
|
## Model Experience
|
|
100
107
|
|
|
101
|
-
None, as the package
|
|
108
|
+
None, as the package renders streamed tool identities and logged calls without changing model context.
|
|
102
109
|
|
|
103
110
|
#### KV Cache effect
|
|
104
111
|
|
|
@@ -113,6 +120,7 @@ These limits define the dispatch depth and the view ownership; they are current
|
|
|
113
120
|
|
|
114
121
|
- **The Host excludes `run_code` from PTC mode program bindings** — production events produce one dispatch level; the recursive Runtime/UI contract supports nesting.
|
|
115
122
|
- **First-party Tool views are colocated here** — they can move to their owning business packages independently through the keyed slot.
|
|
123
|
+
- **Web tool links always open a new tab** — the collapsed `web_fetch` URL and the expanded web card links ignore the `ui-chat` link-opening setting because Tool views receive no external-link callback.
|
|
116
124
|
- **Tool copy reuses the `ui-conversation` locale namespace** — tool titles, row chrome, and Cordis-free primitive labels use that dictionary; presenter models retain locale keys or data rather than rendered wording.
|
|
117
125
|
|
|
118
126
|
<a id="dev-note"></a>
|
package/README.zh.md
CHANGED
|
@@ -25,10 +25,12 @@ kind: "package-reference"
|
|
|
25
25
|
<a id="use-this-package"></a>
|
|
26
26
|
## 使用本包
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
工具调用在对话中显示为卡片:一个根调用树带其嵌套子调用,每个原子调用由所属视图渲染。所有生命周期状态都保留工具的普通业务图标;失败与中断仍通过冻结调用/结果状态、无障碍状态文本和失败摘要明确表达。用户可通过宿主回调打开文件或检查调用。折叠的 `web_fetch` 行把其 http(s) URL 显示为链接,在新浏览器标签页中打开。
|
|
29
29
|
|
|
30
30
|
共享工具行和 Bash 行的失败、停止摘要在悬停时仍保留错误色和警告色;只有不处于这两种状态的摘要会在悬停时加深。
|
|
31
31
|
|
|
32
|
+
派发前,模型已给出名称的调用显示为不可展开的一行,使用工具自己的图标与标题。通用行显示为`工具调用 · <工具名>`。准备阶段不提供完整参数、文件链接、结果或依赖参数的交互。write/edit 的摘要显示「正在准备内容 NKB」;N 为 `Math.ceil(raw.length / 1024)`,是原始参数字符串长度的整数近似值,不是文件字节数。`tool/call` 才启用既有调用展示;参数块结束本身不代表开始执行。
|
|
33
|
+
|
|
32
34
|
### 注册业务工具视图
|
|
33
35
|
|
|
34
36
|
拥有该视图的业务包将其 wire 工具名称注册进 `tool.call.toolview`:
|
|
@@ -41,10 +43,12 @@ ctx.slots.inject('tool.call.toolview', () =>
|
|
|
41
43
|
}, BusinessToolRow))
|
|
42
44
|
```
|
|
43
45
|
|
|
44
|
-
owner 载荷为 `ToolCallOwnerProps`:`callId`、`toolName
|
|
46
|
+
owner 载荷为 `ToolCallOwnerProps`:`callId`、`toolName`、`phase` 判别字段及对应阶段的冻结 `block`、可选 `cwd` 与 `home`、会话授权的 `loadImage` loader(供结果携带持久图像的视图使用),以及普通的 `openFile`/`inspect` 回调。PTC dispatch 块保留事件的 `parentCallId`;根会话调用没有该字段,因此后代调用都走同一条按 key 分发路径:已注册视图的调用(如 `read_image`)也会在嵌套处渲染对应卡片,未注册的后代调用则保持通用压平形式。路径摘要先相对会话 cwd 缩短,再把剩余的 POSIX Host home 写成 `~`;`filePath` 与 Host 打开仍使用作者给出的文件系统路径。注册项会收到常规的会话 slot 运行时共享数据,但不会收到 React 节点或运行时服务。
|
|
45
47
|
|
|
46
48
|
### 内置视图
|
|
47
49
|
|
|
50
|
+
每个注册视图都接收[工具 slot 类型](src/client/contract/slots.ts)声明的显式 `preparing`、`start` 和 `result` props。通用行在三个阶段使用同一个 `ToolRow`。行模型统一选择标题,并组合通用工具名前缀与已有参数摘要,不按生命周期阶段改变前缀;专用标题不附带英文名。准备阶段的共享参数解析入口直接返回无调用,不解析部分 JSON。write/edit 将准备态和派发后阶段拆成两个组件,只有准备态组件调用 `useToolCallArgumentsPartial`,start 与 result 共用派发后组件。Bash、Skill、Cordis 等自定义 renderer 分别处理准备态,其依赖参数的组件接收 `StartedToolCallViewProps`。
|
|
51
|
+
|
|
48
52
|
本包拥有 generic fallback,以及 shell/pwsh、read、read_image、write/edit、运行中的 `str_replace_editor` `create`/`str_replace`、grep/glob、web、todo、question 与 PTC dispatch 的内置展示。结构化卡片直接从第一方原始 event 字段派生;Host `presentCall` 与 `presentResult` 值不会进入 Client。运行中与已完成的前台标准 `bash`/`pwsh` 和 `terminal_send` 调用,无论位于根还是 PTC dispatch 子调用中,都在通过相同的参数、结果和错误检查后使用 terminal 卡片。持久 `bash`/`pwsh` 调用仅在运行中使用 terminal 卡片。以已识别的 spill 策略提示结尾的 shell 输出,在 shell 行中使用可展开的 generic 输出,在 Details 中使用 generic 输出;位置被改变或被省略的退出标记无法证明成功。已完成的持久 shell 结果保持 generic 展示,因为 reset 与部分输出诊断不一定描述单个进程的退出状态;根调用的持久 shell 结果可展开,后台启动回执则保持折叠。带有 `AUTO_REVIEW_DENIED` 的原生或 PTC dispatch 失败会在折叠行显示 Auto review 裁决,展开时显示一行归一化后的“未执行”原因;原因缺失或只有空白时使用本地化 fallback 文案。成功的问题行按稳定 id 配对调用中的问题与结果中的回答,展开后显示可读的问答行。已取消或已中断的问题行显示其裁决与原始问题,不虚构回答。不受支持、格式错误或含糊的输入回退为压平的工具输入/结果文本。`ui-skill` 展示了业务包自行拥有的 `skill` 注册项。
|
|
49
53
|
|
|
50
54
|
-----
|
|
@@ -59,10 +63,13 @@ owner 载荷为 `ToolCallOwnerProps`:`callId`、`toolName`、冻结的 `block`
|
|
|
59
63
|
|
|
60
64
|
### 渲染约定
|
|
61
65
|
|
|
62
|
-
`ToolCallTree`
|
|
66
|
+
`ToolCallTree` 接收一个 Tool 节点、会话 `cwd` 和导航回调。每个分支接收稳定的 block,并缓存显式阶段 props,因此一个子调用变化不会重渲染未变化的兄弟分支。它通过 `tool.call.toolview` 按工具名分发。已派发的根调用保留递归 `subCalls`,准备阶段没有子调用。每个根调用和子调用包装层都保留 `data-chat-anchor-key="call:<id>"` 与 `data-chat-call-id` DOM 约定,供分页和选择使用。Tool 节点在三个阶段保持同一个 callId。
|
|
63
67
|
|
|
64
68
|
Tool 所有者属性将 Chat 注入的稳定 `useDisclosure` 钩子传给根调用及嵌套调用。工具行在拥有展开正文的位置调用它,中间 renderer 不订阅。每次调用拥有独立展开状态,外层轮次收起时重置该状态,不替换 React 身份;展示模式切换保留该状态。
|
|
65
69
|
|
|
70
|
+
|
|
71
|
+
slot 注入的 `useToolCallArgumentsPartial` 钩子按需订阅所属 Step 的 `assistant-step` 来源,并选取当前 callId 的原始参数前缀。来源或调用不存在时返回空字符串。同一步骤中的其他调用可能触发快照检查,但选中的字符串未变时不会刷新使用方。不调用钩子的工具不新增订阅,已派发的调用不再提供参数前缀来源。
|
|
72
|
+
|
|
66
73
|
### 卡片
|
|
67
74
|
|
|
68
75
|
|
|
@@ -98,7 +105,7 @@ terminal model 使用浏览器安全入口 `@deepseek-ai/dsh-spill-policy/notice
|
|
|
98
105
|
<a id="model-experience"></a>
|
|
99
106
|
## 模型体验
|
|
100
107
|
|
|
101
|
-
|
|
108
|
+
无。该包渲染流式工具身份与已记录调用,不改变模型上下文。
|
|
102
109
|
|
|
103
110
|
#### KV Cache 影响
|
|
104
111
|
|
|
@@ -113,6 +120,7 @@ terminal model 使用浏览器安全入口 `@deepseek-ai/dsh-spill-policy/notice
|
|
|
113
120
|
|
|
114
121
|
- **Host 不把 `run_code` 暴露为 PTC mode 程序 binding**:生产事件只产生一层分发;递归的运行时/UI 约定支持嵌套。
|
|
115
122
|
- **第一方工具视图集中在本包**:它们可以通过 keyed slot 独立迁移到各自所属的业务包。
|
|
123
|
+
- **Web 工具链接总是打开新标签页**:折叠的 `web_fetch` URL 与展开的 web 卡片链接不遵循 `ui-chat` 的链接打开方式设置,因为工具视图没有外部链接回调。
|
|
116
124
|
- **工具文案复用 `ui-conversation` locale namespace**:工具标题、行 chrome 与无 Cordis 的 primitive label 使用该字典;展示转换器模型保留 locale key 或数据,而不是已渲染文案。
|
|
117
125
|
|
|
118
126
|
<a id="dev-note"></a>
|