@prettier-ai/dsh-client-ui-tool 0.1.2-alpha.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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +111 -0
  4. package/README.zh.md +111 -0
  5. package/lib/client.js +2111 -0
  6. package/lib/index.js +6 -0
  7. package/lib/invariant.js +23 -0
  8. package/lib/types/client/apply.d.ts +9 -0
  9. package/lib/types/client/contract/slots.d.ts +58 -0
  10. package/lib/types/client/index.d.ts +4 -0
  11. package/lib/types/client/locale.d.ts +3 -0
  12. package/lib/types/client/tool/ToolCallTree.d.ts +9 -0
  13. package/lib/types/client/tool/ToolDetails.d.ts +9 -0
  14. package/lib/types/client/tool/components/AskQuestionCard.d.ts +11 -0
  15. package/lib/types/client/tool/components/ToolRow.d.ts +55 -0
  16. package/lib/types/client/tool/models/ask-question-card-model.d.ts +22 -0
  17. package/lib/types/client/tool/models/diff-card-model.d.ts +37 -0
  18. package/lib/types/client/tool/models/primitive-labels.d.ts +36 -0
  19. package/lib/types/client/tool/models/raw-tool-call.d.ts +27 -0
  20. package/lib/types/client/tool/models/read-card-model.d.ts +31 -0
  21. package/lib/types/client/tool/models/search-card-model.d.ts +23 -0
  22. package/lib/types/client/tool/models/terminal-card-model.d.ts +81 -0
  23. package/lib/types/client/tool/models/tool-call-model.d.ts +75 -0
  24. package/lib/types/client/tool/models/web-card-model.d.ts +14 -0
  25. package/lib/types/client/tool/toolviews/GenericToolCard.d.ts +7 -0
  26. package/lib/types/client/tool/toolviews/ask-question-row.d.ts +14 -0
  27. package/lib/types/client/tool/toolviews/bash-sample.d.ts +14 -0
  28. package/lib/types/client/tool/toolviews/file-mutation-row.d.ts +16 -0
  29. package/lib/types/client/tool/toolviews/plan-summary.d.ts +48 -0
  30. package/lib/types/client/tool/toolviews/read-row.d.ts +16 -0
  31. package/lib/types/client/tool/toolviews/search-row.d.ts +14 -0
  32. package/lib/types/client/tool/toolviews/todo-row.d.ts +14 -0
  33. package/lib/types/client/tool/toolviews/web-row.d.ts +14 -0
  34. package/lib/types/index.d.ts +4 -0
  35. package/lib/types/invariant.d.ts +16 -0
  36. package/package.json +90 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/client/ui-tool/README.md
5
+ README.md: 773a93801ebc214e2d5c94d52864f5c5dd887100
6
+ README.zh.md: 88df08d7b5b7d5d3978d90fd4df4cbbb2efeb1fa
package/README.md ADDED
@@ -0,0 +1,111 @@
1
+ ---
2
+ description: "Client Tool presentation plugin for the dsh web client: whole-call tree composition, the keyed per-tool view slot, and the built-in atomic tool cards."
3
+ kind: "package-reference"
4
+ ---
5
+
6
+ # @deepseek-ai/dsh-client-ui-tool
7
+
8
+ English | [中文](README.zh.md)
9
+
10
+ ## Summary
11
+
12
+ `dsh-client-ui-tool` is the client Tool presentation plugin of the dsh web client: it renders every tool call in the conversation. `ui-conversation` dispatches each ordered `tool-call` Conversation Node through the matching key of `conversation.chat.node`; this package renders its root and Code Dispatch children, then dispatches every atomic call through the keyed `tool.call.toolview` slot. Unregistered Tool names use the generic card. Business UI packages register only their wire Tool names and atomic views — they do not pair Session events, rebuild the transcript, or own root/subcall topology, because the Runtime remains authoritative for call/result pairing, lifecycle, and recursive `subCalls` projection.
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
+ Tool calls appear in the conversation as cards: a root call tree with its nested subcalls, each atomic call rendered by its owning view. Users see running, successful, failed, and interrupted states that come only from the frozen call/result slice, and can open files or inspect calls through the Host callbacks.
29
+
30
+ ### Registering a business tool view
31
+
32
+ An owning business package registers its wire Tool name into `tool.call.toolview`:
33
+
34
+ ```text
35
+ ctx.slots.inject('tool.call.toolview', () =>
36
+ ctx.slots.register({
37
+ name: 'tool.call.toolview',
38
+ key: '<wire tool name>',
39
+ }, BusinessToolRow))
40
+ ```
41
+
42
+ The owner payload is `ToolCallOwnerProps`: `callId`, `toolName`, the frozen `block`, optional `cwd` and `home`, and plain `openFile`/`inspect` callbacks. A Code Dispatch block retains its event's `parentCallId`; a root Session call has no such field, so descendants keep the generic flattened form without another placement flag. 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.
43
+
44
+ ### Built-in views
45
+
46
+ This package owns the generic fallback and the built-in shell/pwsh, read, write/edit, running `str_replace_editor` `create`/`str_replace`, grep/glob, web, todo, question, and Code Dispatch presentations. Structured cards derive directly from first-party raw event fields; Host `presentCall` and `presentResult` values never enter the Client. Foreground one-shot shell results use terminal cards. Settled persistent-shell results use the expandable generic input/output card because reset and partial-output diagnostics do not always describe one process exit status; background acknowledgements remain collapsed. 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`.
47
+
48
+ -----
49
+
50
+ <a id="understand-the-implementation"></a>
51
+ ## Understand the implementation
52
+
53
+ <details>
54
+ <summary>Implementation internals — click to expand</summary>
55
+
56
+ The package realizes one dispatch rule: atomic Tool views are keyed by wire Tool name and registered by their owning business packages; this package only renders the tree and the fallback.
57
+
58
+ ### Rendering contract
59
+
60
+ `ToolCallTree` receives one root `ToolCallBlock` that already contains recursive `subCalls`, selection state, the session `cwd`, and Host callbacks for opening files and inspecting calls. It recursively walks the standard call blocks and sends the root and children at every depth through the same atomic dispatch path, without subscribing to a separate parent-to-children map. 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.
61
+
62
+ ### Details and cards
63
+
64
+ The package fills `conversation.details.tool` with `ToolDetails`. Row and Details renderers share one pure card model for each terminal, read, diff, search, and web card. These models validate raw call arguments, result content, failure state, persisted metadata, Code Dispatch `parentCallId`, and Session path facts. Unsupported or malformed inputs use flattened Tool result text. Card-specific limits and fallback rules remain in the owning [terminal](../../../.agents/notes/implemented/feature/2026-07-28-web-terminal-card.md), [diff](../../../.agents/notes/implemented/feature/2026-07-30-web-diff-card.md), [read](../../../.agents/notes/implemented/feature/2026-07-30-web-read-card-frontend.md), [search](../../../.agents/notes/implemented/feature/2026-07-30-web-search-card.md), [web](../../../.agents/notes/implemented/feature/2026-07-30-web-result-card-frontend.md), and [question](../../../.agents/notes/implemented/feature/2026-07-29-ask-question-web-presentation.md) notes.
65
+
66
+ </details>
67
+
68
+ -----
69
+
70
+ <a id="further-exploration"></a>
71
+ ## Further Exploration
72
+
73
+ These pages cover the conversation host, the view slots, and the card models.
74
+
75
+ - [ui-conversation](../ui-conversation/README.md) — the chat surface dispatching `tool-call` nodes to this package.
76
+ - [ui-primitives](../ui-primitives/README.md) — the output card atoms the built-in views compose.
77
+ - [ui-skill](../ui-skill/README.md) — a business-owned registration for the `skill` tool.
78
+ - [Conversation subsystem](../../../docs/subsystems/conversation.md) — how a business-owned feature registers a Conversation node.
79
+ - [Slot system standard](../../../.agents/notes/implemented/architecture/2026-07-22-slot-type-chain-implementation.md) — the composition model behind the keyed slot.
80
+
81
+ -----
82
+
83
+ <a id="model-experience"></a>
84
+ ## Model Experience
85
+
86
+ None, as the package is a browser-side tool presentation layer that renders logged calls without changing model context.
87
+
88
+ #### KV Cache effect
89
+
90
+ None; this package neither assembles nor sends a provider request.
91
+
92
+ ## Known Limitations and Deferred Work
93
+
94
+ <a id="known-limitations-and-deferred-work"></a>
95
+
96
+
97
+ These limits define the dispatch depth and the view ownership; they are current package constraints.
98
+
99
+ - **The Host excludes `run_code` from PTC mode program bindings** — production events produce one dispatch level; the recursive Runtime/UI contract supports nesting.
100
+ - **First-party Tool views are colocated here** — they can move to their owning business packages independently through the keyed slot.
101
+ - **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.
102
+
103
+ <a id="dev-note"></a>
104
+ ### Dev Note
105
+
106
+ <details>
107
+ <summary>Working context for maintainers — click to expand</summary>
108
+
109
+ None.
110
+
111
+ </details>
package/README.zh.md ADDED
@@ -0,0 +1,111 @@
1
+ ---
2
+ description: "dsh Web 客户端的 Client 工具展示插件:整次调用树组合、keyed 按工具视图 slot 与内置原子工具卡片。"
3
+ kind: "package-reference"
4
+ ---
5
+
6
+ # @deepseek-ai/dsh-client-ui-tool
7
+
8
+ [English](README.md) | 中文
9
+
10
+ ## 概述
11
+
12
+ `dsh-client-ui-tool` 是 dsh Web 客户端的 Client 工具展示插件:它渲染对话中的每一次工具调用。`ui-conversation` 通过 `conversation.chat.node` 的匹配 key 分发每个已排序的 `tool-call` Conversation Node;本包渲染其中的 root 及其 Code Dispatch 子调用,并把每个原子调用通过 keyed slot `tool.call.toolview` 分发。没有注册的工具名称使用通用卡片。业务 UI 包只注册 wire 工具名称和原子视图——它们不配对会话事件、不重建 transcript,也不拥有 root/subcall 拓扑,因为运行时仍对 call/result 配对、生命周期与递归 `subCalls` 投影拥有最终决定权。
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
+ 工具调用在对话中显示为卡片:一个根调用树带其嵌套子调用,每个原子调用由所属视图渲染。用户看到运行中、成功、失败与中断状态,这些状态只来自冻结的调用/结果切片,并可通过宿主回调打开文件或检查调用。
29
+
30
+ ### 注册业务工具视图
31
+
32
+ 拥有该视图的业务包将其 wire 工具名称注册进 `tool.call.toolview`:
33
+
34
+ ```text
35
+ ctx.slots.inject('tool.call.toolview', () =>
36
+ ctx.slots.register({
37
+ name: 'tool.call.toolview',
38
+ key: '<wire tool name>',
39
+ }, BusinessToolRow))
40
+ ```
41
+
42
+ owner 载荷为 `ToolCallOwnerProps`:`callId`、`toolName`、冻结的 `block`、可选 `cwd` 与 `home`,以及普通的 `openFile`/`inspect` 回调。Code Dispatch block 保留事件的 `parentCallId`;root Session call 没有该字段,因此 descendant 无需另一项 placement 标志即可保持 generic 压平形态。路径摘要先相对 Session cwd 缩短,再把剩余的 POSIX Host home 写成 `~`;`filePath` 与 Host 打开仍使用作者给出的文件系统路径。注册项会收到常规 Session slot runtime share,但不会收到 React node 或 runtime service。
43
+
44
+ ### 内置视图
45
+
46
+ 本包拥有 generic fallback,以及 shell/pwsh、read、write/edit、running `str_replace_editor` `create`/`str_replace`、grep/glob、web、todo、question 与 Code Dispatch 的内置展示。结构化卡片直接从第一方原始 event 字段派生;Host `presentCall` 与 `presentResult` 值不会进入 Client。前台一次性 shell 结果使用 terminal 卡片。已完成的持久 shell 结果使用可展开的 generic 输入/输出卡片,因为 reset 与部分输出诊断不一定描述单个进程的退出状态;后台启动回执保持折叠。成功的问题行按稳定 id 配对调用中的问题与结果中的回答,展开后显示可读的问答行。已取消或已中断的问题行显示其裁决与原始问题,不虚构回答。不受支持、格式错误或含糊的输入回退为压平的工具输入/结果文本。`ui-skill` 展示了业务包自行拥有的 `skill` 注册项。
47
+
48
+ -----
49
+
50
+ <a id="understand-the-implementation"></a>
51
+ ## 理解实现
52
+
53
+ <details>
54
+ <summary>实现细节——点击展开</summary>
55
+
56
+ 本包实现一条分派规则:原子工具视图按 wire 工具名称键控、由所属业务包注册;本包只渲染树与回退。
57
+
58
+ ### 渲染约定
59
+
60
+ `ToolCallTree` 接收一个已经包含递归 `subCalls` 的 root `ToolCallBlock`、selection 状态、会话 `cwd`,以及用于打开文件和检查调用的 Host 回调。它递归遍历标准调用块,让 root 与任意深度的 child 经过同一条原子分发路径,不订阅独立的 parent-to-children map。每个 root 和 child 包装层都保留 `data-chat-anchor-key="call:<id>"` 与 `data-chat-call-id` DOM 约定,供分页和 selection 使用。
61
+
62
+ ### 详情与卡片
63
+
64
+ 本包通过 `ToolDetails` 填充 `conversation.details.tool`。行 renderer 与 Details renderer 分别为 terminal、read、diff、search 和 web 卡片复用同一个纯 card model。这些 model 校验原始调用参数、结果内容、失败状态、持久 metadata、Code Dispatch `parentCallId` 与 Session 路径事实。不受支持或格式错误的输入使用压平的工具结果文本。各类卡片的上限与 fallback 规则仍由对应的 [terminal](../../../.agents/notes/implemented/feature/2026-07-28-web-terminal-card.zh.md)、[diff](../../../.agents/notes/implemented/feature/2026-07-30-web-diff-card.zh.md)、[read](../../../.agents/notes/implemented/feature/2026-07-30-web-read-card-frontend.zh.md)、[search](../../../.agents/notes/implemented/feature/2026-07-30-web-search-card.zh.md)、[web](../../../.agents/notes/implemented/feature/2026-07-30-web-result-card-frontend.zh.md) 与 [question](../../../.agents/notes/implemented/feature/2026-07-29-ask-question-web-presentation.zh.md) 笔记负责。
65
+
66
+ </details>
67
+
68
+ -----
69
+
70
+ <a id="further-exploration"></a>
71
+ ## 进一步探索
72
+
73
+ 以下页面覆盖对话宿主、视图 slot 与卡片模型。
74
+
75
+ - [ui-conversation](../ui-conversation/README.zh.md)——把 `tool-call` 节点分派给本包的聊天界面。
76
+ - [ui-primitives](../ui-primitives/README.zh.md)——内置视图所拼装的输出卡片原子组件。
77
+ - [ui-skill](../ui-skill/README.zh.md)——`skill` 工具的业务自有注册。
78
+ - [Conversation 子系统](../../../docs/subsystems/conversation.zh.md)——业务自有功能如何注册 Conversation node。
79
+ - [slot 系统标准](../../../.agents/notes/implemented/architecture/2026-07-22-slot-type-chain-implementation.zh.md)——keyed slot 背后的组合模型。
80
+
81
+ -----
82
+
83
+ <a id="model-experience"></a>
84
+ ## 模型体验
85
+
86
+ 无。该包是浏览器端工具展示层,只渲染已记录的工具调用,不改变模型上下文。
87
+
88
+ #### KV Cache 影响
89
+
90
+ 无;该包既不组装也不发送提供方请求。
91
+
92
+ ## 已知限制与延期工作
93
+
94
+ <a id="known-limitations-and-deferred-work"></a>
95
+
96
+
97
+ 这些限制定义分派深度与视图归属;它们是当前包约束。
98
+
99
+ - **Host 不把 `run_code` 暴露为 PTC mode 程序 binding**:生产事件只产生一层分发;递归的运行时/UI 约定支持嵌套。
100
+ - **第一方工具视图集中在本包**:它们可以通过 keyed slot 独立迁移到各自所属的业务包。
101
+ - **工具文案复用 `ui-conversation` locale namespace**:工具标题、行 chrome 与无 Cordis 的 primitive label 使用该字典;presenter model 保留 locale key 或数据,而不是已渲染文案。
102
+
103
+ <a id="dev-note"></a>
104
+ ### 开发备注
105
+
106
+ <details>
107
+ <summary>维护者的工作上下文——点击展开</summary>
108
+
109
+ 无。
110
+
111
+ </details>