@prettier-ai/dsh-client-ui-chat 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.
- package/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +69 -0
- package/README.zh.md +69 -0
- package/lib/client.js +7588 -0
- package/lib/index.js +25 -0
- package/lib/invariant.js +16 -0
- package/lib/types/chat-settings.d.ts +20 -0
- package/lib/types/client/apply.d.ts +10 -0
- package/lib/types/client/chat/ApprovalCommand.d.ts +20 -0
- package/lib/types/client/chat/AssistantMarkdown.d.ts +22 -0
- package/lib/types/client/chat/AssistantNodeView.d.ts +4 -0
- package/lib/types/client/chat/ChatNodeSeat.d.ts +15 -0
- package/lib/types/client/chat/ChatView.d.ts +7 -0
- package/lib/types/client/chat/CommandNodeView.d.ts +9 -0
- package/lib/types/client/chat/CompactionCommandCard.d.ts +8 -0
- package/lib/types/client/chat/CompactionItem.d.ts +19 -0
- package/lib/types/client/chat/ContextBody.d.ts +131 -0
- package/lib/types/client/chat/ContextInjectionRow.d.ts +26 -0
- package/lib/types/client/chat/GenericCommandCard.d.ts +9 -0
- package/lib/types/client/chat/MessageIconActions.d.ts +36 -0
- package/lib/types/client/chat/MessageItem.d.ts +42 -0
- package/lib/types/client/chat/ReasoningRow.d.ts +14 -0
- package/lib/types/client/chat/StatsLine.d.ts +64 -0
- package/lib/types/client/chat/SystemPromptRow.d.ts +19 -0
- package/lib/types/client/chat/TurnNavigator.d.ts +21 -0
- package/lib/types/client/chat/TurnProcessNodeView.d.ts +4 -0
- package/lib/types/client/chat/TurnTailNodeView.d.ts +7 -0
- package/lib/types/client/chat/TurnUsageDisclosure.d.ts +9 -0
- package/lib/types/client/chat/message-chrome.d.ts +49 -0
- package/lib/types/client/chat/register-node-renderers.d.ts +7 -0
- package/lib/types/client/chat/searchable-hidden.d.ts +9 -0
- package/lib/types/client/chat/token-format.d.ts +25 -0
- package/lib/types/client/chat/turn-assistant.d.ts +8 -0
- package/lib/types/client/chat/use-calendar-day.d.ts +6 -0
- package/lib/types/client/chat/use-throttled-visual-update.d.ts +8 -0
- package/lib/types/client/contract/assistant-content.d.ts +9 -0
- package/lib/types/client/contract/chat-nodes.d.ts +110 -0
- package/lib/types/client/contract/slots.d.ts +195 -0
- package/lib/types/client/contract/snapshot.d.ts +65 -0
- package/lib/types/client/contract/store.d.ts +22 -0
- package/lib/types/client/contract/turn-metrics.d.ts +38 -0
- package/lib/types/client/contract/turn-process.d.ts +48 -0
- package/lib/types/client/conversation-nodes/assistant.d.ts +37 -0
- package/lib/types/client/conversation-nodes/chat-snapshot-builder.d.ts +42 -0
- package/lib/types/client/conversation-nodes/command.d.ts +54 -0
- package/lib/types/client/conversation-nodes/common.d.ts +41 -0
- package/lib/types/client/conversation-nodes/compaction.d.ts +22 -0
- package/lib/types/client/conversation-nodes/event-projection.d.ts +57 -0
- package/lib/types/client/conversation-nodes/fallback.d.ts +17 -0
- package/lib/types/client/conversation-nodes/inbox.d.ts +21 -0
- package/lib/types/client/conversation-nodes/message.d.ts +31 -0
- package/lib/types/client/conversation-nodes/partial.d.ts +34 -0
- package/lib/types/client/conversation-nodes/register.d.ts +7 -0
- package/lib/types/client/conversation-nodes/request-prompt.d.ts +30 -0
- package/lib/types/client/conversation-nodes/retry.d.ts +23 -0
- package/lib/types/client/conversation-nodes/tool.d.ts +23 -0
- package/lib/types/client/conversation-nodes/turn-error.d.ts +31 -0
- package/lib/types/client/conversation-nodes/turn-max-tokens.d.ts +23 -0
- package/lib/types/client/conversation-nodes/turn-navigation.d.ts +17 -0
- package/lib/types/client/conversation-nodes/turn-process.d.ts +32 -0
- package/lib/types/client/conversation-nodes/turn-tail.d.ts +28 -0
- package/lib/types/client/details/DetailsPanel.d.ts +4 -0
- package/lib/types/client/details/tool-node-reader.d.ts +9 -0
- package/lib/types/client/index.d.ts +36 -0
- package/lib/types/client/locale.d.ts +224 -0
- package/lib/types/client/markdown-labels.d.ts +10 -0
- package/lib/types/client/model/conversation-context.d.ts +22 -0
- package/lib/types/client/model/steering-history.d.ts +23 -0
- package/lib/types/client/model/tool-call-tree.d.ts +45 -0
- package/lib/types/client/settings/TranscriptViewRow.d.ts +22 -0
- package/lib/types/client/stores.d.ts +22 -0
- package/lib/types/client/transcript-view.d.ts +22 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/invariant.d.ts +13 -0
- package/package.json +121 -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.
|
package/README.i18n.yaml
ADDED
|
@@ -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-chat/README.md
|
|
5
|
+
README.md: 5c7549da07e8101c6b08b4cad57afd5158980b7f
|
|
6
|
+
README.zh.md: a558bf94f5436eebdf035ca7507ecd25ec3c8d8a
|
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Browser Chat target that renders Session conversation nodes, details, historical images, actions, localization, and scroll state."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
# @deepseek-ai/dsh-client-ui-chat
|
|
6
|
+
|
|
7
|
+
English | [中文](README.zh.md)
|
|
8
|
+
|
|
9
|
+
## Summary
|
|
10
|
+
|
|
11
|
+
The browser Chat target for Conversation assembly. It registers Chat event definitions and snapshot construction, supplies `useChat`, renders transcript nodes and details, and owns Chat-specific stores, actions, localization, and scroll restoration; historical image URLs resolve through the Conversation-owned per-session cache (`ctx.uiConversation.imageUrl`). Its Assistant and Turn Tail definitions fold packed historical Assistant runs without expanding their members. The flow tail renders the session's local submission echoes (`SessionSnapshot.pendingSubmissions`) with the same bubble as their eventual durable user nodes, hidden per render once a user/steering node or queue occurrence carries the echo's prompt `rpcId`, so the echo-to-durable swap is atomic.
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [System prompt row](#system-prompt-row)
|
|
16
|
+
- [Turn token usage](#turn-token-usage)
|
|
17
|
+
- [Turn Process Folding](#turn-process-folding)
|
|
18
|
+
- [Model Experience](#model-experience)
|
|
19
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
20
|
+
- [Dev Note](#dev-note)
|
|
21
|
+
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
<a id="system-prompt-row"></a>
|
|
25
|
+
## System prompt row
|
|
26
|
+
|
|
27
|
+
Chat shows a collapsed `System prompt` row for each non-empty initial or resumed request, explicit message-series start, or real system-field change. It does not repeat the row for same-series config-only or tool-only changes, tool steps, or retries. The row appears before that request's user messages, matching the provider envelope, and expands to the exact model-visible text with its original line breaks. A partial history window renders a non-initial header conservatively until the preceding page arrives; a header without a system prompt creates no row.
|
|
28
|
+
|
|
29
|
+
-----
|
|
30
|
+
|
|
31
|
+
<a id="turn-token-usage"></a>
|
|
32
|
+
## Turn token usage
|
|
33
|
+
|
|
34
|
+
A completed Turn shows an expandable usage row only when the loaded window includes `turn/start` and every started model attempt reports safe, exact usage. The row omits unavailable optional buckets. Incomplete or contradictory accounting hides the complete disclosure instead of presenting a partial total.
|
|
35
|
+
|
|
36
|
+
-----
|
|
37
|
+
|
|
38
|
+
<a id="turn-process-folding"></a>
|
|
39
|
+
## Turn Process Folding
|
|
40
|
+
|
|
41
|
+
Settings → General exposes a persisted `Normal` / `Compact` conversation-display preference in the `ui-chat` namespace; `Compact` is the default. Normal leaves process rows visible and renders no Turn-process control. In Compact mode, the System prompt remains independently visible before the opening User throughout the Turn. Context injection, reasoning, Assistant material, Tool rows, and Retry rows remain expanded while a Turn is open. At `turn/end`, its latest Step becomes the final-answer boundary only when it contains non-blank text, an image, or an unknown visible block—and no Tool-call block; preceding Context injection, reasoning, earlier Assistant material, Tool rows, and Retry rows then collapse by default. The control reports Turn-wide durable counts for non-subagent Tool calls, reply-bearing Assistant messages before the final answer, and subagent delegation calls; zero-valued segments are omitted, the Tool and subagent figures are mutually exclusive, and neither System prompt nor Context injection contributes a count. When all three counts are zero, the process still folds and the control reads `Thought for a while`. A full-width divider below the summary separates it from the answer or expanded process rows. User and steering messages, System prompt, error, max-token, and turn-tail rows stay outside, and a closed Turn with no final answer keeps all process evidence visible. A newly available process control is inserted without changing the relative order of existing rows: opening human input precedes the control and process rows from their first projection, while System prompt remains above that input. While older history remains available through Load earlier, process controls stay absent and no members are hidden; once history is complete, every eligible closed Turn uses the collapsed default immediately. Stable Chat Node Seats keep every renderer mounted, hidden members add no flow spacing, and a closed control sits 8px above its answer only when no independent input intervenes. Completion collapse does not depend on tail-follow position, so a reader above the tail may see the transcript reflow. An automatic collapse that would hide keyboard focus keeps the group open and leaves focus in place; a manual close focuses the process control before hiding its members. The session-scoped store records only manually expanded Turn-and-answer-Step generations; a different answer generation starts collapsed ([folding decision](../../../.agents/notes/implemented/feature/2026-08-14-web-turn-process-folding.md), [ordering decision](../../../.agents/notes/implemented/bug-fix/2026-08-26-stable-turn-process-order.md)).
|
|
42
|
+
|
|
43
|
+
-----
|
|
44
|
+
|
|
45
|
+
<a id="model-experience"></a>
|
|
46
|
+
## Model Experience
|
|
47
|
+
|
|
48
|
+
None, as this package renders logged conversation state in the browser and registers nothing model-facing.
|
|
49
|
+
|
|
50
|
+
#### KV Cache effect
|
|
51
|
+
|
|
52
|
+
None; Chat presentation does not assemble or mutate provider requests.
|
|
53
|
+
|
|
54
|
+
## Known Limitations and Deferred Work
|
|
55
|
+
|
|
56
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
57
|
+
|
|
58
|
+
- **The view reflects the loaded Session window** — older transcript nodes become available only after Session Controller loads the preceding event page. Turn navigation likewise represents only loaded Turns; loading an earlier page preserves existing Turn marks and redistributes the complete loaded set in a compact rail without an unloaded-history placeholder. Marks stay 10px apart until the loaded set exceeds the available height, then compress to fit.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
<a id="dev-note"></a>
|
|
62
|
+
### Dev Note
|
|
63
|
+
|
|
64
|
+
<details>
|
|
65
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
66
|
+
|
|
67
|
+
None.
|
|
68
|
+
|
|
69
|
+
</details>
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "渲染 Session 对话节点、详情、历史图片、操作、本地化和滚动状态的浏览器 Chat target。"
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
# @deepseek-ai/dsh-client-ui-chat
|
|
6
|
+
|
|
7
|
+
[English](README.md) | 中文
|
|
8
|
+
|
|
9
|
+
## 概述
|
|
10
|
+
|
|
11
|
+
Conversation 组装的浏览器 Chat target。本包注册 Chat event definition 与 snapshot 构造、提供 `useChat`、渲染 transcript node 和详情,并拥有 Chat 专属 store、action、本地化与滚动位置恢复;历史图片 URL 通过 Conversation 持有的按会话缓存(`ctx.uiConversation.imageUrl`)解析。其中 Assistant 与 Turn Tail definition 会直接 fold packed Assistant 历史 run,不展开其成员。消息流尾部渲染 session 的本地提交回显(`SessionSnapshot.pendingSubmissions`),气泡与其最终的 durable user 节点一致;一旦某个 user/steering 节点或 queue occurrence 携带回显的 prompt `rpcId`,该回显即在同一渲染中隐藏,因此回显到 durable 的替换是原子的。
|
|
12
|
+
|
|
13
|
+
## 目录
|
|
14
|
+
|
|
15
|
+
- [系统提示词行](#system-prompt-row)
|
|
16
|
+
- [轮次 token 用量](#turn-token-usage)
|
|
17
|
+
- [轮次过程折叠](#turn-process-folding)
|
|
18
|
+
- [模型体验](#model-experience)
|
|
19
|
+
- [已知限制与暂缓事项](#known-limitations-and-deferred-work)
|
|
20
|
+
- [开发备注](#dev-note)
|
|
21
|
+
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
<a id="system-prompt-row"></a>
|
|
25
|
+
## 系统提示词行
|
|
26
|
+
|
|
27
|
+
Chat 会为每个非空的初始或恢复请求、显式消息序列起点或真实 system 字段变化显示一行默认折叠的`系统提示词`。同一序列内仅配置或仅工具变化、工具步骤与重试不会重复该行。该行位于请求的用户消息之前,与提供方 envelope 顺序一致;展开后显示保留原始换行的精确模型可见文本。历史窗口不完整时,非初始 header 会保守显示,直到前一页到达;没有系统提示词的 header 不创建该行。
|
|
28
|
+
|
|
29
|
+
-----
|
|
30
|
+
|
|
31
|
+
<a id="turn-token-usage"></a>
|
|
32
|
+
## 轮次 token 用量
|
|
33
|
+
|
|
34
|
+
只有当已加载窗口包含 `turn/start`,且每次已启动的模型尝试都报告安全、精确的用量时,已完成 Turn 才显示可展开的用量行。该行会省略不可用的可选用量桶。记账不完整或相互矛盾时,整个详情都不显示,避免把部分总量冒充完整结果。
|
|
35
|
+
|
|
36
|
+
-----
|
|
37
|
+
|
|
38
|
+
<a id="turn-process-folding"></a>
|
|
39
|
+
## 轮次过程折叠
|
|
40
|
+
|
|
41
|
+
「设置 → 通用设置」提供持久化到 `ui-chat` 命名空间的 `Normal` / `Compact` 对话显示偏好,默认使用 `Compact`。Normal 保持所有过程行可见且不渲染轮次过程控件。Compact 模式下,系统提示词在整个轮次中始终独立显示于开场 User 上方。轮次打开期间,上下文注入、推理、Assistant 内容、工具行与重试行始终展开。到 `turn/end` 时,最后一个步骤只有在包含非空文本、图片或未知可见块且不含工具调用块时才成为最终正文边界;边界之前的上下文注入、推理、较早 Assistant 内容、工具行与重试行随后默认收起。控件展示覆盖整个轮次的非 subagent 工具调用数、最终正文之前带回复内容的 Assistant 消息数和 subagent 委派数;值为 0 的分段省略,工具调用与 subagent 两项互斥,系统提示词与上下文注入都不增加计数。三项全为 0 时过程仍会收起,控件标题显示「已思考」(英文为 `Thought for a while`)。摘要下方的通栏分隔线将其与正文或展开后的过程行隔开。用户与 steering 消息、系统提示词、错误、最大 token 与 turn-tail 行留在过程组外;关闭时没有最终正文的轮次保留全部过程证据。新的过程控件插入时不会改变既有行的相对顺序:开场人工输入从首次投影起便位于控件和过程行之前,系统提示词则始终位于该输入上方。只要仍可通过「加载更早」获取历史,过程控件就不出现,也不会隐藏任何成员;历史加载完整后,每个合格的已关闭轮次立即使用默认收起状态。稳定 Chat Node Seat 会让每个 renderer 保持挂载,隐藏成员不产生消息流间距;只有中间没有独立输入时,收起控件才与正文相隔 8px。完成后的收起不依赖是否跟随尾部,因此正在上方阅读的用户可能看到 transcript 高度变化。若自动收起会隐藏当前键盘焦点,则过程组保持展开且焦点留在原处;手动收起会先把焦点移到过程控件,再隐藏成员。会话作用域 store 只记录用户手动展开的「轮次 + 正文步骤」generation;不同正文 generation 默认收起([折叠决策](../../../.agents/notes/implemented/feature/2026-08-14-web-turn-process-folding.zh.md),[排序决策](../../../.agents/notes/implemented/bug-fix/2026-08-26-stable-turn-process-order.zh.md))。
|
|
42
|
+
|
|
43
|
+
-----
|
|
44
|
+
|
|
45
|
+
<a id="model-experience"></a>
|
|
46
|
+
## 模型体验
|
|
47
|
+
|
|
48
|
+
无,因为本包在浏览器中渲染已记录的对话状态,不注册任何面向模型的内容。
|
|
49
|
+
|
|
50
|
+
#### KV Cache 影响
|
|
51
|
+
|
|
52
|
+
无;Chat 呈现不会组装或修改提供方请求。
|
|
53
|
+
|
|
54
|
+
## 已知限制与暂缓事项
|
|
55
|
+
|
|
56
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
57
|
+
|
|
58
|
+
- **视图只反映已加载的 Session 窗口**——只有 Session Controller 加载前一页 event 后,更早的 transcript node 才会出现。轮次导航同样只表示已加载的 Turn;加载更早一页时,已有 Turn 刻度保持身份不变,完整的已加载集合在紧凑轨道中重新排布,不显示未加载历史占位。刻度默认相隔 10px,仅在已加载集合超过可用高度时压缩间距。
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
<a id="dev-note"></a>
|
|
62
|
+
### 开发备注
|
|
63
|
+
|
|
64
|
+
<details>
|
|
65
|
+
<summary>维护者工作上下文——点击展开</summary>
|
|
66
|
+
|
|
67
|
+
无。
|
|
68
|
+
|
|
69
|
+
</details>
|