@roaming-ai/dsh-group-chat 0.2.0
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.md +56 -0
- package/cordis.patch.yml +12 -0
- package/lib/client.js +3308 -0
- package/lib/client.js.map +1 -0
- package/lib/index.js +2583 -0
- package/lib/types/client/Bubble.d.ts +10 -0
- package/lib/types/client/Glyph.d.ts +12 -0
- package/lib/types/client/GroupChatPanel.d.ts +10 -0
- package/lib/types/client/GroupChatPanel.old.d.ts +10 -0
- package/lib/types/client/GroupChatSettingsSection.d.ts +15 -0
- package/lib/types/client/PermissionSelect.d.ts +13 -0
- package/lib/types/client/RoleDrawer.d.ts +17 -0
- package/lib/types/client/ThinkRow.d.ts +9 -0
- package/lib/types/client/ToolRow.d.ts +9 -0
- package/lib/types/client/api.d.ts +8 -0
- package/lib/types/client/components/AsidePanel.d.ts +31 -0
- package/lib/types/client/components/Bubble.d.ts +19 -0
- package/lib/types/client/components/ChatPanel.d.ts +57 -0
- package/lib/types/client/components/Composer.d.ts +48 -0
- package/lib/types/client/components/Glyph.d.ts +12 -0
- package/lib/types/client/components/GroupChatSettingsSection.d.ts +15 -0
- package/lib/types/client/components/MessageFlow.d.ts +15 -0
- package/lib/types/client/components/NavPanel.d.ts +40 -0
- package/lib/types/client/components/PermissionSelect.d.ts +13 -0
- package/lib/types/client/components/RoleDrawer.d.ts +17 -0
- package/lib/types/client/components/ThinkRow.d.ts +9 -0
- package/lib/types/client/components/ToolRow.d.ts +9 -0
- package/lib/types/client/components/index.d.ts +9 -0
- package/lib/types/client/components.d.ts +22 -0
- package/lib/types/client/drawer.d.ts +17 -0
- package/lib/types/client/glyph.d.ts +12 -0
- package/lib/types/client/hooks/index.d.ts +6 -0
- package/lib/types/client/hooks/useComposer.d.ts +27 -0
- package/lib/types/client/hooks/useFileSearch.d.ts +19 -0
- package/lib/types/client/hooks/useGroupChatState.d.ts +95 -0
- package/lib/types/client/hooks/useMentionState.d.ts +27 -0
- package/lib/types/client/index.d.ts +52 -0
- package/lib/types/client/lib/api.d.ts +8 -0
- package/lib/types/client/lib/model.d.ts +80 -0
- package/lib/types/client/lib/styles.d.ts +10 -0
- package/lib/types/client/lib/ui.d.ts +17 -0
- package/lib/types/client/model.d.ts +78 -0
- package/lib/types/client/panel.d.ts +10 -0
- package/lib/types/client/settings.d.ts +15 -0
- package/lib/types/client/styles.d.ts +10 -0
- package/lib/types/client/ui.d.ts +17 -0
- package/lib/types/client/utils/utils.d.ts +29 -0
- package/lib/types/client/utils.d.ts +22 -0
- package/lib/types/core/json.d.ts +9 -0
- package/lib/types/core/status.d.ts +18 -0
- package/lib/types/core/tools.d.ts +59 -0
- package/lib/types/core/types.d.ts +256 -0
- package/lib/types/host/actions.d.ts +34 -0
- package/lib/types/host/api/actions.d.ts +36 -0
- package/lib/types/host/api/http.d.ts +16 -0
- package/lib/types/host/api/index.d.ts +7 -0
- package/lib/types/host/api/routes.d.ts +11 -0
- package/lib/types/host/broadcast.d.ts +20 -0
- package/lib/types/host/conversation.d.ts +25 -0
- package/lib/types/host/engine/conversation.d.ts +25 -0
- package/lib/types/host/engine/index.d.ts +7 -0
- package/lib/types/host/engine/retitle.d.ts +20 -0
- package/lib/types/host/http.d.ts +16 -0
- package/lib/types/host/index.d.ts +8 -0
- package/lib/types/host/materials/index.d.ts +6 -0
- package/lib/types/host/materials/materials.d.ts +40 -0
- package/lib/types/host/materials.d.ts +32 -0
- package/lib/types/host/persistence/index.d.ts +6 -0
- package/lib/types/host/persistence/persistence.d.ts +31 -0
- package/lib/types/host/persistence/store.d.ts +65 -0
- package/lib/types/host/persistence.d.ts +31 -0
- package/lib/types/host/routes.d.ts +11 -0
- package/lib/types/host/service.d.ts +28 -0
- package/lib/types/host/state.d.ts +45 -0
- package/lib/types/host/store.d.ts +65 -0
- package/lib/types/host/tools/index.d.ts +6 -0
- package/lib/types/host/tools/tools.d.ts +28 -0
- package/lib/types/host/tools.d.ts +28 -0
- package/lib/types/index.d.ts +41 -0
- package/lib/types/mount-once.d.ts +9 -0
- package/lib/types/shared/file-mention-grammar.d.ts +37 -0
- package/lib/types/shared/file-mention-grammar.test.d.ts +5 -0
- package/package.json +98 -0
- package/src/client/GroupChatPanel.tsx +385 -0
- package/src/client/components/AsidePanel.tsx +188 -0
- package/src/client/components/Bubble.tsx +76 -0
- package/src/client/components/ChatPanel.tsx +214 -0
- package/src/client/components/Composer.tsx +238 -0
- package/src/client/components/Glyph.tsx +27 -0
- package/src/client/components/GroupChatSettingsSection.tsx +74 -0
- package/src/client/components/MessageFlow.tsx +97 -0
- package/src/client/components/NavPanel.tsx +249 -0
- package/src/client/components/PermissionSelect.tsx +159 -0
- package/src/client/components/RoleDrawer.tsx +186 -0
- package/src/client/components/ThinkRow.tsx +32 -0
- package/src/client/components/ToolRow.tsx +51 -0
- package/src/client/components/index.ts +10 -0
- package/src/client/hooks/index.ts +7 -0
- package/src/client/hooks/useComposer.ts +272 -0
- package/src/client/hooks/useFileSearch.ts +115 -0
- package/src/client/hooks/useGroupChatState.ts +214 -0
- package/src/client/hooks/useMentionState.ts +56 -0
- package/src/client/index.ts +110 -0
- package/src/client/lib/api.ts +23 -0
- package/src/client/lib/model.ts +119 -0
- package/src/client/lib/styles.ts +317 -0
- package/src/client/lib/ui.ts +27 -0
- package/src/client/react-dom-shim.d.ts +13 -0
- package/src/client/utils/utils.ts +104 -0
- package/src/core/json.ts +28 -0
- package/src/core/status.ts +33 -0
- package/src/core/tools.ts +41 -0
- package/src/core/types.ts +222 -0
- package/src/host/api/actions.ts +335 -0
- package/src/host/api/http.ts +80 -0
- package/src/host/api/index.ts +8 -0
- package/src/host/api/routes.ts +95 -0
- package/src/host/broadcast.ts +65 -0
- package/src/host/engine/conversation.ts +331 -0
- package/src/host/engine/index.ts +8 -0
- package/src/host/engine/retitle.ts +135 -0
- package/src/host/index.ts +9 -0
- package/src/host/materials/index.ts +7 -0
- package/src/host/materials/materials.ts +193 -0
- package/src/host/persistence/index.ts +7 -0
- package/src/host/persistence/persistence.ts +311 -0
- package/src/host/persistence/store.ts +375 -0
- package/src/host/service.ts +78 -0
- package/src/host/state.ts +85 -0
- package/src/host/tools/index.ts +7 -0
- package/src/host/tools/tools.ts +194 -0
- package/src/index.ts +99 -0
- package/src/mount-once.ts +49 -0
- package/src/shared/file-mention-grammar.test.ts +77 -0
- package/src/shared/file-mention-grammar.ts +82 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 localSummer
|
|
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.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# dsh-group-chat
|
|
2
|
+
|
|
3
|
+
DSH Web GUI 的「模型群聊」插件:多模型角色群组对话面板。
|
|
4
|
+
|
|
5
|
+
## 功能
|
|
6
|
+
|
|
7
|
+
- **群组管理**:新建、重命名、删除(至少保留一个群组);左栏搜索框按群组名/会话名过滤
|
|
8
|
+
- **会话目录树**:每个群组内多个会话,左栏以「群组 → 会话」目录树呈现(展开/收起、新建、重命名、删除);消息挂在会话上,会话各有主题
|
|
9
|
+
- **角色-模型绑定**:群组内每个角色绑定一个 provider/model(可各不相同),配置人设、标识色、Temperature、深度思考开关;开启深度思考时可选**推理级别**(选项取自 DSH 当前模型设置的推理选项,未配置则用默认);角色为群组级,全会话共享;配置走右侧滑出抽屉
|
|
10
|
+
- **群内共享对话**:所有消息对全群共享;发言以「【角色名】内容」形式注入每个角色的上下文,流式显示
|
|
11
|
+
- **消息渲染**:角色发言以宿主同款 markdown 渲染(标题、列表、表格、代码块、公式);开启「深度思考」的角色发言带可折叠的思考行(折叠时显示摘要,展开看全文,流式时实时跟随)
|
|
12
|
+
- **多轮对话**:发送消息后选择参与角色按顺序自动多轮对话(1–10 轮),可随时停止
|
|
13
|
+
- **@点名**:裸 `@` 弹出成员候选(↑↓ 选择、Enter/Tab 插入);被 @ 的成员优先作为本轮参与角色。`@` 后继续键入则在群工作区内检索文件,插入 `@path` 芯片(只写入路径,不把文件正文再灌进 prompt)
|
|
14
|
+
- **三区工作台**:左栏导航(搜索 + 目录树);中栏会话流(色环头像 + 模型徽章 + 时间,贴底自动跟随、可回到底部);右栏上下文(角色卡 + 工作区目录),可一键收起,窄面板时覆盖式呈现
|
|
15
|
+
- **群组工作区目录**:每个群组指定一个目录(群级、全会话共享;无独立笔记或文件清单)。角色发言时自动读取目录**根下一层**文本文件(扩展名白名单、跳过隐藏项、最多 20 个;单文件 16k / 总量 48k 截断)注入全体角色 system 提示词的「共享资料」块;支持 `~`、绝对路径与相对 DSH 工作区根解析,右栏内置目录选择浏览器;未设置则不注入、不暴露工具
|
|
16
|
+
- **工具执行(docs/TOOLS.md)**:设置工作区后角色可调用 `read_file` / `list_dir` 主动查看工作区(realpath 硬边界,逃逸/软链越界一律拒绝);**权限档位**于消息输入框下方左下角芯片切换(对齐主会话 `/permission` 三档:仅可查看 / 工作区内修改 / 完全权限;默认仅可查看,按群组记忆持久化)——工作区内修改档角色可请求执行 shell 命令(cwd 固定为工作区、超时 120s),**每条命令在会话流内逐条确认**(允许 / 拒绝 / 停止,命令全文展示不截断);完全权限档免确认直接执行,切换时经主会话同款风险确认弹窗;工具调用以折叠行内嵌于角色消息(含耗时与状态),摘要注入后续发言上下文;不支持 tools 的模型自动降级为纯文本
|
|
17
|
+
- **设置启用**:设置页「模型群聊」分区提供启停开关(持久化于 settings.yaml);关闭时隐藏侧边栏入口并中止进行中的对话
|
|
18
|
+
|
|
19
|
+
## 架构
|
|
20
|
+
|
|
21
|
+
双平面插件(对齐 [dsh-web](https://github.com/zhu1090093659/dsh-web) 家族的 dsh-usage 包形状):
|
|
22
|
+
|
|
23
|
+
- **源码与构建**:TypeScript 源码于 `src/`(`core/` 纯逻辑、`host/` 宿主半、`client/` 浏览器半);`pnpm build` 先 `tsc` 产声明到 `lib/types/`,再 `tsdown`(`shared/tsdown.client.ts` 预设拷贝自 dsh-web)产出双半产物 `lib/index.js`(ESM)+ `lib/client.js`(闭包工厂)
|
|
24
|
+
- **Host 半**(`src/index.ts` + `src/host/`,host 进程组合插件):群组/会话/角色/工作区/消息内存状态机;群组与会话增删改;角色发言经 `llm` 服务按绑定路由流式生成,设置工作区后进入「生成⇄工具」循环(read_file/list_dir 自动执行,run_command 经 `confirmCommand` 逐条确认闸门);工作区文本文件经 `fs` 服务读取并注入;经 `webServer` 暴露:
|
|
25
|
+
- `GET /api/group-chat/state` — 全量快照
|
|
26
|
+
- `POST /api/group-chat/action` — `{kind: mutate|send|stop|confirmCommand|models|efforts|browse|fileSearch, ...}`(`efforts` 查询 provider/model 的推理级别选项,60s 缓存;`browse` 为右栏目录浏览器;`fileSearch` 为输入框 @ 文件检索)
|
|
27
|
+
- `GET /api/group-chat/events` — SSE,状态变化推送(120ms 节流)
|
|
28
|
+
- 路由带回环 + 同源信任栏(`src/host/http.ts`,语义对齐 dsh-web 家族的 loopback fence)
|
|
29
|
+
- **浏览器半**(`src/client/`,`dsh.client` 模块):侧边栏 `sidebar.panellist` 入口 + `main` 键面板 + `settings.section` 设置页;经 fetch/SSE 访问 Host API;UI 使用宿主 DSW 原语(`@deepseek-ai/dsh-client-ui-primitives`,shell 静态种子模块)——Button/Input/Switch/Tooltip/统一描边图标与 `MarkdownText` 渲染器
|
|
30
|
+
|
|
31
|
+
设计文档位于 `docs/`:`PRODUCT.md`(产品定义)、`DESIGN.md`(界面设计契约)、`PERSISTENCE.md`(持久化契约)、`TOOLS.md`(工具执行护栏)。
|
|
32
|
+
|
|
33
|
+
## 安装(本 profile)
|
|
34
|
+
|
|
35
|
+
`~/.dsh/profiles/web/package.json` 的 `dependencies` 已含 `"dsh-group-chat": "link:/home/.../plugins/dsh-group-chat"`,且 `dsh.profile.bundles` 已列 `dsh-group-chat`。本包改为 TS 源码 + 构建产物形态,修改源码后在本目录执行:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
cd ~/.dsh/profiles/web/plugins/dsh-group-chat && pnpm install && pnpm build
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
重启 `dsh web` 生效。开发辅助:`pnpm watch`(tsdown 增量构建)、`pnpm test`(core/store 冒烟测试)、`pnpm typecheck`。
|
|
42
|
+
|
|
43
|
+
## 数据与持久化
|
|
44
|
+
|
|
45
|
+
- 会话级文件隔离持久化于 `~/.dsh/storages/group-chat/`(设计详见 `docs/PERSISTENCE.md`;gitignore 已覆盖):
|
|
46
|
+
- `ledger.json` — 群组/会话清单(`schema: 2`,纯清单)
|
|
47
|
+
- `<group-id>/roles.json` — 群组角色定义(`schema: 1`)
|
|
48
|
+
- `<group-id>/workspaceDir` — 群组工作区目录设置(纯文本一行)
|
|
49
|
+
- `<group-id>/sessions/session-<uuid>.json` — 一个会话一个文件(自包含名称/主题/创建时间/消息)
|
|
50
|
+
- 事件驱动写:变更按文件标脏,同一 tick 内合并,流式 partial 不落盘
|
|
51
|
+
- 原子写(tmp + fsync + rename,每个实际发生 rename 的目录一次 fsync)、单实例 `.lock`(PID 存活检测,崩溃残留自动清理)
|
|
52
|
+
- 写失败保留脏标记,下次 flush 自动重试;插件卸载时同步最终 flush 后再释放锁
|
|
53
|
+
- 损坏处理:单会话文件坏仅丢该会话消息(隔离 `.corrupt-*`,每前缀保留最近 1 份);ledger 坏可扫描群组目录回收;行级校验丢弃孤儿条目
|
|
54
|
+
- v1 双文件布局(ledger.json + messages.json)首次启动自动迁移(幂等;旧 messages.json 归档为 `.migrated-*`,从不删除)
|
|
55
|
+
- 锁不可得(双进程)时降级为内存态运行并告警
|
|
56
|
+
- 设置页的 `enabled` 开关经 settings 服务持久化于 `settings.yaml`;进行中的对话运行态(run)不持久化
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# dsh-group-chat bundle layer: inserts the dual-face plugin row into the web
|
|
2
|
+
# profile roster. Applied when the profile lists this package in
|
|
3
|
+
# dsh.profile.bundles.
|
|
4
|
+
#
|
|
5
|
+
# The row is a bare plugin by package name: the node half (exports ".") runs
|
|
6
|
+
# in the host process (group state machine + llm calls + fs material reads +
|
|
7
|
+
# /api/group-chat HTTP API), and the `dsh.client` declaration in package.json
|
|
8
|
+
# makes the browser half (exports "./client", served at
|
|
9
|
+
# /plugins/<id>/client.js) load in the web GUI.
|
|
10
|
+
- insert:
|
|
11
|
+
- id: group-chat
|
|
12
|
+
name: @roaming-ai/dsh-group-chat
|