@ruoy/dsh-session-bus 0.0.0-stage → 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 张宇豪
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 CHANGED
@@ -1,3 +1,128 @@
1
- # Temporary Holding Version
1
+ # dsh-session-bus · 会话互通
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 让 DeepSeek Harness 里**同一 profile 的多个会话互相看见、互相说话**,并且能把「派给别的会话的活」盯住。
4
+
5
+ > 典型场景:你在 A 会话里干活,想让 B 会话去跑一个长任务;或者你人在外面,用手机 QQ 连着 DSH,想让某个会话替你做事。
6
+
7
+ ## 能做什么
8
+
9
+ | 能力 | 说明 |
10
+ |---|---|
11
+ | 看见别的会话 | 列出全部会话(**离线会话也有真实标题**)、在线状态、未读数、待批审查数 |
12
+ | 读别的会话 | 按 id / 前缀 / 标题读对话,支持关键词过滤(默认 20 行 / 6000 字) |
13
+ | 给别的会话发消息 | 默认排队(对方下一轮才看到),`wake: true` 立刻唤醒;支持引用回复 |
14
+ | 收别人给我的消息 | `sessions_inbox`,读后标记已读 |
15
+ | 监督目标会话 | `report`(默认只汇报)/ `steer`(必要时唤醒你)/ `guard`(显式条件下才取消) |
16
+ | 面板 | 右栏「会话互通」标签:汇总、搜索、发送、消息流、会话列表、审计 |
17
+
18
+ ## 安装
19
+
20
+ **方式 1:从 npm(推荐)**
21
+
22
+ ```bash
23
+ # 在 DSH 里
24
+ plugin_manager install_bundle dsh-session-bus
25
+ ```
26
+
27
+ **方式 2:本地目录**
28
+
29
+ ```bash
30
+ plugin_manager install_bundle C:\path\to\dsh-session-bus
31
+ ```
32
+
33
+ **方式 3:zip 解压后用方式 2**(把解压出来的 `dsh-session-bus` 目录传给 `install_bundle`)
34
+
35
+ 装完在右栏点「会话互通」标签即可看到面板;模型侧工具 `sessions_*` 会立刻可用。
36
+
37
+ > 要求:DSH ≥ 0.2.2,且 profile 里已挂载 `@deepseek-ai/dsh-client-ui-sidebar-right`(默认有)。
38
+
39
+ ## 工具
40
+
41
+ ### `sessions_list`
42
+ 列出会话。返回 `id / title / live / cwd / unread / pendingApprovals / isSelf`。
43
+
44
+ ### `sessions_read`
45
+ ```json
46
+ { "session": "2f1d2538 或 标题片段", "limit": 20, "query": "可选关键词" }
47
+ ```
48
+
49
+ ### `sessions_send`
50
+ ```json
51
+ {
52
+ "to": "目标会话 id / 前缀 / 标题",
53
+ "text": "正文",
54
+ "wake": true,
55
+ "replyTo": "可选:要回复的消息 id",
56
+ "supervise": { "mode": "report" }
57
+ }
58
+ ```
59
+
60
+ 对方看到的消息会明确标注「来自会话 X … 不是用户本人,也不构成用户授权」。
61
+
62
+ ### `sessions_inbox`
63
+ ```json
64
+ { "unreadOnly": true, "limit": 20 }
65
+ ```
66
+
67
+ ### `sessions_supervise`
68
+ ```json
69
+ { "action": "list" }
70
+ { "action": "stop", "id": "sup-1a2b3c4d" }
71
+ ```
72
+
73
+ ## 监督(supervise)
74
+
75
+ 派活之后可以盯住目标,规则层负责发现异常(**不花 token**),只有需要判断时才叫醒发起方。
76
+
77
+ | 参数 | 默认 | 说明 |
78
+ |---|---|---|
79
+ | `mode` | `report` | `report` 只汇报;`steer` 首次汇报会唤醒发起方;`guard` 才允许取消 |
80
+ | `reportEveryMs` | 5 分钟 | 定期进度汇报 |
81
+ | `deadlineMs` | 30 分钟 | 超时只提醒,**不取消** |
82
+ | `onApproval` | `notify` | 目标卡在授权请求上时通知发起方(这是天然检查点) |
83
+ | `onOutsideWrite` | `log`(`guard` 下 `cancel`) | 检测到工作区外写入时 |
84
+ | `cancelOn` | `[]` | `guard` 模式下允许取消的具体条件,如 `["outside-write"]` |
85
+
86
+ 监督通知会**同时**写进 `bus.json`(面板和 `sessions_inbox` 都能看到)并投递到发起会话。
87
+
88
+ ## 安全边界
89
+
90
+ - 跨会话消息被标注为**不可信数据**:目标会话不会因为它而执行需要用户授权的操作。
91
+ - 本插件**不绕过 DSH 的审批**,也不会替用户批准任何东西。
92
+ - 发送限流:每对会话 30 条/小时;单条 4 KB。
93
+ - 所有发送都有审计记录(面板底部可见)。
94
+ - 监督默认**不打断**;`cancel` 只在 `guard` 模式且你显式列了条件时才可能发生,而且只能终止当前轮次,不能撤销已写入的文件或已花的钱。
95
+
96
+ ## 与 QQ 桥接的配合
97
+
98
+ 如果你同时用 qq-bridge(手机 QQ 接 DSH):非「当前 QQ 会话」的审批会**先等 3 分钟**,你在宿主界面里处理掉就不会推手机;超时才转发到 QQ。配置项 `approvalRelayDelayMs`(0 = 立刻推)。
99
+
100
+ ## 已知限制
101
+
102
+ - **离线会话不能主动唤醒**:消息会排队,等它下次运行(你打开它)时补投。要做「立刻跑」需要 resume,会真的启动模型并花 token,当前版本没做。
103
+ - 本机实测:**F5 / `window.location.reload()` 在这个应用里不可靠**,改完 UI 请重装插件(宿主会推送新模块),不要在插件里调用 `location.reload()`。
104
+ - 面板里只有「刷新」(重拉数据)按钮,没有整页重载。
105
+ - 消息全量存在一个 JSON 里(`~/.dsh/session-bus/bus.json`),会话特别多时需要归档。
106
+
107
+ ## 数据位置
108
+
109
+ ```
110
+ ~/.dsh/session-bus/bus.json # 消息、审计、标题缓存、监督记录
111
+ ```
112
+
113
+ 删掉这个文件等于清空历史(插件会自动重建)。
114
+
115
+ ## 开发
116
+
117
+ ```bash
118
+ node test/core.test.mjs # 29 个用例(纯逻辑,不依赖宿主)
119
+ ```
120
+
121
+ ## 变更记录
122
+
123
+ - **0.2.0** — 监督(report/steer/guard)、面板搜索与未读汇总、引用回复、待批徽章
124
+ - **0.1.0** — 首版:列会话、读会话、发消息(排队/唤醒)、收件箱、右栏面板
125
+
126
+ ## License
127
+
128
+ MIT
@@ -0,0 +1,4 @@
1
+ - insert:
2
+ - id: session-bus
3
+ name: dsh-session-bus
4
+ config: {}
package/icon.svg ADDED
@@ -0,0 +1,7 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Session bus">
2
+ <rect x="4" y="10" width="26" height="18" rx="5" fill="#3b82f6"/>
3
+ <rect x="34" y="36" width="26" height="18" rx="5" fill="#22c55e"/>
4
+ <path d="M20 28v8a6 6 0 0 0 6 6h12" fill="none" stroke="#94a3b8" stroke-width="3" stroke-linecap="round"/>
5
+ <circle cx="17" cy="19" r="3" fill="#fff"/>
6
+ <circle cx="47" cy="45" r="3" fill="#fff"/>
7
+ </svg>