dsh-rhine-lab-team 0.5.5 → 0.5.6
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.md +2 -2
- package/client.js +27 -23
- package/docs/RELEASE.md +3 -2
- package/host/chat-session.js +33 -0
- package/host/team-mode.js +24 -3
- package/host/tools.js +61 -11
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ dsh plugin add https://github.com/vioeveann/dsh-rhine-lab-team
|
|
|
50
50
|
- 不设 token 预算:任务卡会显示真实用量,但不会因为超预算自动停。需要控成本时用并发数、单任务超时和成员能力卡。
|
|
51
51
|
- 防作弊只防手改 JSON:签名密钥在本机文件里,能读到密钥并自己重签的人仍可绕过;它是防误改,不是防本机管理员。
|
|
52
52
|
- 界面目前只有中文;英文界面在计划中。
|
|
53
|
-
- 测试:
|
|
53
|
+
- 测试:338 条(`npm test`)+ 2 条浏览器冒烟测试(`test/e2e`)。
|
|
54
54
|
|
|
55
55
|
## 现状(2026-11-23)
|
|
56
56
|
|
|
@@ -86,7 +86,7 @@ dsh plugin add https://github.com/vioeveann/dsh-rhine-lab-team
|
|
|
86
86
|
- **成员组**:橙色锤子建组;每个组卡片最右边的锤子在组下面展开团队设置(同一个编辑器),顶部多一行「这个组」可以改名或删掉它
|
|
87
87
|
- **界面**:成员面板(分组折叠、卡片扳手改成员、组内招募、头像裁剪、点卡片开子会话、任务详情、成长与晋升、橙色锤子进团队设置)、皮肤 classic / aurora
|
|
88
88
|
- **子会话身份**:依赖 `dsh-avatar-frame`(声明为 `latest`,npm 上需 ≥ 0.15)时显示 Bot 自己的头像和 ID,点它进设置,语音关闭
|
|
89
|
-
- **测试**:
|
|
89
|
+
- **测试**:338 条(`npm test`)+ 2 条浏览器冒烟测试(`test/e2e`)
|
|
90
90
|
|
|
91
91
|
## 任务依赖
|
|
92
92
|
|
package/client.js
CHANGED
|
@@ -5532,36 +5532,40 @@ function createMembersPanel(React, host) {
|
|
|
5532
5532
|
}, [noSessionHint])
|
|
5533
5533
|
|
|
5534
5534
|
const openChat = async (member) => {
|
|
5535
|
-
|
|
5535
|
+
// 单聊一律交给宿主判断:旧会话的根还活着就复用,根停了就新开一条。
|
|
5536
|
+
// 面板拿到的 member.sessionId 可能来自昨天那个已经停掉的根会话,
|
|
5537
|
+
// 客户端自己拍板去开,就会走到「发消息不可用」。
|
|
5538
|
+
let sessionId = ''
|
|
5536
5539
|
// 刚开出来的会话,名册还没刷新,父会话 id 只能从开会话的返回值里拿。
|
|
5537
5540
|
let openedParent = ''
|
|
5538
5541
|
// 宿主连身份一起给:开页前写进头像映射,第一帧就是 Bot 自己。
|
|
5539
5542
|
let openedIdentity
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
}
|
|
5556
|
-
sessionId = data.sessionId
|
|
5557
|
-
openedParent = String(data.parentSessionId ?? '')
|
|
5558
|
-
openedIdentity = data.identity
|
|
5559
|
-
setNotice('')
|
|
5560
|
-
} catch (error) {
|
|
5561
|
-
setNotice(`开会话失败:${error?.message ?? error}`)
|
|
5543
|
+
setNoSessionHint(member?.id ?? null)
|
|
5544
|
+
setNotice(`正在打开 ${member?.name || member?.id} 的会话…`)
|
|
5545
|
+
try {
|
|
5546
|
+
const response = await fetch('/dsh-team/open', {
|
|
5547
|
+
method: 'POST',
|
|
5548
|
+
headers: { 'content-type': 'application/json' },
|
|
5549
|
+
body: JSON.stringify({
|
|
5550
|
+
bot: member?.id,
|
|
5551
|
+
sessionId: sessionForRoster,
|
|
5552
|
+
chatSessionId: member?.sessionId ?? '',
|
|
5553
|
+
}),
|
|
5554
|
+
})
|
|
5555
|
+
const data = await response.json()
|
|
5556
|
+
if (!data?.ok) {
|
|
5557
|
+
setNotice(data?.error ?? '开会话失败')
|
|
5562
5558
|
setNoSessionHint(null)
|
|
5563
5559
|
return
|
|
5564
5560
|
}
|
|
5561
|
+
sessionId = data.sessionId
|
|
5562
|
+
openedParent = String(data.parentSessionId ?? '')
|
|
5563
|
+
openedIdentity = data.identity
|
|
5564
|
+
setNotice('')
|
|
5565
|
+
} catch (error) {
|
|
5566
|
+
setNotice(`开会话失败:${error?.message ?? error}`)
|
|
5567
|
+
setNoSessionHint(null)
|
|
5568
|
+
return
|
|
5565
5569
|
}
|
|
5566
5570
|
setNoSessionHint(null)
|
|
5567
5571
|
const service = (name) => {
|
package/docs/RELEASE.md
CHANGED
|
@@ -41,7 +41,8 @@ dsh plugin add <包名或本地路径>
|
|
|
41
41
|
|
|
42
42
|
## 版本
|
|
43
43
|
|
|
44
|
-
- `0.5.
|
|
44
|
+
- `0.5.6`(当前):修单聊在根会话失效后发不出去。DSH 要求子会话的根会话在线,旧实现把单聊挂在当时的会话下,重启后根已停止,`sendMessage` 返回 `subagent/delivery-unavailable`。现在客户端一律走 `/dsh-team/open`:服务端先判断原单聊的根是否活着,活着复用,死了在当前会话新开一条;账本同时记 `parentSession` 与 `rootSession`。另补进程级路由撤单,避免热重载时 `identity-map` / `session-bot` 重复注册。
|
|
45
|
+
- `0.5.5`:修两处状态错位。①「待命」误判:成员卡原先只认账本里的 `running` 行,派活那次工具调用一旦被打断(用户在派活途中插话),账本被记成 `ready`,子会话却还在后台跑——面板显示「待命」、看门狗关机、干完也没有任何回报。现在成员繁忙状态同时看会话实际运行态(新增 `host/live-watch.js` 订阅子会话 `agent/status`);派活被打断时不再收 `ready`,任务保留 `running` 并标 `detached`,由后台接力每 3 秒查子会话是否真说完,拿到答复再收尾并广播 `task-done`。②热重载后新子会话头像回落主会话:`team-mode.js` 的 `dispose()` 漏撤 `identity-map` 与 `session-bot` 两条 exact 路由,重载时新实例撞 `duplicate exact route` 注册失败,`/dsh-team/identity-map` 一直由已卸载的旧实例供数、数据冻结在重载那一刻。现已补进撤单清单;客户端身份映射改为并行拉 `tasks`/`roster` 现拼,不再单依赖 `identity-map`。另:`host/runtime.js` 的 `tools.js`/`team-mode.js` 改成带版本参数的动态 import,翻开关即可热加载。
|
|
45
46
|
- `0.5.4`:任务依赖图(验收门、整链超时/取消、重启恢复)、强制审查链、成员信箱、窄版工作区、P1 三项、第 7 步文档;修复监考提醒被当成任务结果、晋升感言串段、窄面板名字截断。
|
|
46
47
|
- `0.5.3`:团队设置面板三处 —— 称谓框不再被限定成数字;「超时」改名「单任务最长运行(秒)」,卡住提醒的三个参数收进设置不再摆在面板上;新建组面板里还没建组时,导出/导入先提示「请先创建组」。交付目录说明更正为文档目录。
|
|
47
48
|
- `0.5.2`:0.5.1 的数据迁移清单补上 `.team-work/`(单聊与任务的工作目录)。用户自建的 Bot、分组、设置、知识库、账本全部随数据目录走,升级不再丢。
|
|
@@ -52,4 +53,4 @@ dsh plugin add <包名或本地路径>
|
|
|
52
53
|
- `0.2.0`:任务详情与重试、成本统计、能力卡与团队记忆编辑、Bot 交接、系统通知、模板、近实时刷新。
|
|
53
54
|
- `0.1.0`:派活、验收、产物收集、记忆快照、名册与面板。
|
|
54
55
|
|
|
55
|
-
`package.json` 现在是 `0.5.
|
|
56
|
+
`package.json` 现在是 `0.5.6`。发的时候跑一遍上面的检查。
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单聊会话的存活判断。
|
|
3
|
+
*
|
|
4
|
+
* DSH 只允许往「根会话还活着」的子会话里发消息;创建它的会话离线没关系。
|
|
5
|
+
* 单聊记录里存 rootSession(创建时所在的根),老记录没有就退回 parentSession。
|
|
6
|
+
*
|
|
7
|
+
* @param {object} entry 账本里的单聊行。
|
|
8
|
+
* @returns {string} 根会话 id;没有就空串。
|
|
9
|
+
*/
|
|
10
|
+
export function chatRootId(entry) {
|
|
11
|
+
return String(entry?.rootSession || entry?.parentSession || '')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 根会话是否还活着。
|
|
16
|
+
*
|
|
17
|
+
* 当前会话一定是活的;不在当前会话时,只有 agents.get 还能拿到这个根才算活。
|
|
18
|
+
* 拿不到 agent 就当作失效——宁可重开一条单聊,也不要让用户点开发不出去。
|
|
19
|
+
*
|
|
20
|
+
* @param {object} entry 账本里的单聊行。
|
|
21
|
+
* @param {{ currentSession?: string, getAgent?: (id: string) => unknown }} options
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export function chatRootAlive(entry, options = {}) {
|
|
25
|
+
const root = chatRootId(entry)
|
|
26
|
+
if (root === '') return false
|
|
27
|
+
if (options.currentSession && root === options.currentSession) return true
|
|
28
|
+
try {
|
|
29
|
+
return Boolean(options.getAgent?.(root))
|
|
30
|
+
} catch {
|
|
31
|
+
return false
|
|
32
|
+
}
|
|
33
|
+
}
|
package/host/team-mode.js
CHANGED
|
@@ -207,6 +207,15 @@ export function installTeamMode(ctx, options) {
|
|
|
207
207
|
const { root, debug, tasks, mailbox, getRoster, getSettings, saveSettings, api, persistTasks, getModels, getInstanceConflict } = options
|
|
208
208
|
const storeFile = join(root, '.state', 'team-mode.json')
|
|
209
209
|
|
|
210
|
+
// 热重载时旧模块的 disposer 可能没跑到,路由会撞 duplicate exact route。
|
|
211
|
+
// 在进程级留一个上一份安装的清理函数,新的一份安装前先撤旧的。
|
|
212
|
+
const ROUTE_OWNER = Symbol.for('dsh-rhine-lab-team.team-mode.dispose')
|
|
213
|
+
try {
|
|
214
|
+
globalThis[ROUTE_OWNER]?.()
|
|
215
|
+
} catch {
|
|
216
|
+
// 旧模块已经撤过或参数不兼容,继续装新的
|
|
217
|
+
}
|
|
218
|
+
|
|
210
219
|
/** 在线的 SSE 客户端。 */
|
|
211
220
|
const eventClients = new Set()
|
|
212
221
|
|
|
@@ -1117,6 +1126,7 @@ export function installTeamMode(ctx, options) {
|
|
|
1117
1126
|
const result = await api?.openChat?.({
|
|
1118
1127
|
botId: String(body.bot ?? ''),
|
|
1119
1128
|
parentSession: String(body.sessionId ?? ''),
|
|
1129
|
+
chatSessionId: String(body.chatSessionId ?? ''),
|
|
1120
1130
|
})
|
|
1121
1131
|
json(res, 200, result ?? { ok: false, error: '单聊接口没接上' })
|
|
1122
1132
|
} catch (error) {
|
|
@@ -1590,9 +1600,7 @@ export function installTeamMode(ctx, options) {
|
|
|
1590
1600
|
},
|
|
1591
1601
|
})
|
|
1592
1602
|
|
|
1593
|
-
|
|
1594
|
-
isEnabled: (sessionId) => state.get(String(sessionId)) === true,
|
|
1595
|
-
dispose: () => {
|
|
1603
|
+
const disposeAll = () => {
|
|
1596
1604
|
// 新加的路由也要撤;漏一个,下次重载就会撞「duplicate exact route」。
|
|
1597
1605
|
for (const dispose of [
|
|
1598
1606
|
disposeExportPack,
|
|
@@ -1641,6 +1649,19 @@ export function installTeamMode(ctx, options) {
|
|
|
1641
1649
|
disposeAvatar()
|
|
1642
1650
|
disposeMemoryRoute()
|
|
1643
1651
|
disposePersona()
|
|
1652
|
+
}
|
|
1653
|
+
globalThis[ROUTE_OWNER] = disposeAll
|
|
1654
|
+
return {
|
|
1655
|
+
isEnabled: (sessionId) => state.get(String(sessionId)) === true,
|
|
1656
|
+
dispose: () => {
|
|
1657
|
+
if (globalThis[ROUTE_OWNER] === disposeAll) {
|
|
1658
|
+
try {
|
|
1659
|
+
delete globalThis[ROUTE_OWNER]
|
|
1660
|
+
} catch {
|
|
1661
|
+
// 删不掉也不影响
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
disposeAll()
|
|
1644
1665
|
},
|
|
1645
1666
|
}
|
|
1646
1667
|
}
|
package/host/tools.js
CHANGED
|
@@ -33,6 +33,7 @@ import { confirmImprovement, promoteBot, savePromotionSpeech, updateGrowth } fro
|
|
|
33
33
|
import { growthDetail, growthSummary, promote, regrade, settleRepeat, settleTask, settleTeaching } from './growth.js'
|
|
34
34
|
import { taskGain } from './progress.js'
|
|
35
35
|
import { loadBots, stripSoulPlaceholder } from './bots.js'
|
|
36
|
+
import { chatRootAlive } from './chat-session.js'
|
|
36
37
|
import { formatMailPrompt } from './mailbox.js'
|
|
37
38
|
import { forgetChild, noteChildState } from './live-watch.js'
|
|
38
39
|
|
|
@@ -4031,18 +4032,73 @@ export function registerTeamTools(ctx, options) {
|
|
|
4031
4032
|
}
|
|
4032
4033
|
}
|
|
4033
4034
|
|
|
4034
|
-
//
|
|
4035
|
-
|
|
4035
|
+
// 给 Bot 开单聊;已有会话还活着的就复用,根会话死了就重开一条。
|
|
4036
|
+
//
|
|
4037
|
+
// DSH 的硬约束:往子会话发消息时,它的根会话必须活着;创建者可以离线。
|
|
4038
|
+
// 所以按根会话判断,不按 parentSession 判断——旧单聊的根一旦停了,
|
|
4039
|
+
// 这条会话就发不出消息,只能新开,并把旧账本留作记录。
|
|
4040
|
+
const chatIdentityOf = (bot) => ({
|
|
4041
|
+
id: bot.id,
|
|
4042
|
+
name: bot.name ?? bot.id,
|
|
4043
|
+
src: `/dsh-team/avatar?bot=${encodeURIComponent(bot.id)}&v=3`,
|
|
4044
|
+
onOpen: true,
|
|
4045
|
+
speech: false,
|
|
4046
|
+
})
|
|
4047
|
+
|
|
4048
|
+
options.api.openChat = async ({ botId, parentSession, chatSessionId }) => {
|
|
4036
4049
|
const bot = await readBot(root, String(botId ?? '').trim())
|
|
4037
4050
|
if (!bot) return { ok: false, error: '没有这个 Bot' }
|
|
4038
4051
|
if (bot.status === 'disabled') return { ok: false, error: '这个 Bot 已停用' }
|
|
4039
4052
|
const parent = String(parentSession ?? '').trim()
|
|
4040
4053
|
const parentAgent = parent === '' ? null : agents?.get?.(parent)
|
|
4041
4054
|
if (!parentAgent) return { ok: false, error: '拿不到当前会话' }
|
|
4055
|
+
|
|
4056
|
+
// 面板点的是已有单聊:先看它的根还活着没有。活着就复用,
|
|
4057
|
+
// 死了就走下面新开一条,用户不需要知道“为什么发不出去”。
|
|
4058
|
+
const requested = String(chatSessionId ?? '').trim()
|
|
4059
|
+
if (requested !== '') {
|
|
4060
|
+
const entry = [...tasks.values()].find(
|
|
4061
|
+
(row) => row.sessionId === requested && row.bot === bot.id,
|
|
4062
|
+
)
|
|
4063
|
+
const alive = entry
|
|
4064
|
+
? chatRootAlive(entry, {
|
|
4065
|
+
currentSession: parent,
|
|
4066
|
+
getAgent: (id) => agents?.get?.(id),
|
|
4067
|
+
})
|
|
4068
|
+
: false
|
|
4069
|
+
if (alive) {
|
|
4070
|
+
return {
|
|
4071
|
+
ok: true,
|
|
4072
|
+
sessionId: requested,
|
|
4073
|
+
parentSessionId: String(entry?.parentSession ?? parent),
|
|
4074
|
+
identity: chatIdentityOf(bot),
|
|
4075
|
+
bot: bot.id,
|
|
4076
|
+
reused: true,
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
if (entry) {
|
|
4080
|
+
await debug?.({
|
|
4081
|
+
event: 'chat-stale',
|
|
4082
|
+
bot: bot.id,
|
|
4083
|
+
sessionId: requested,
|
|
4084
|
+
root: String(entry.rootSession ?? entry.parentSession ?? ''),
|
|
4085
|
+
})
|
|
4086
|
+
}
|
|
4087
|
+
}
|
|
4088
|
+
|
|
4042
4089
|
const childId = `session-${randomUUID()}`
|
|
4043
4090
|
const dir = join(root, '.team-work', bot.id, `chat-${Date.now().toString(36)}`)
|
|
4044
4091
|
await mkdir(dir, { recursive: true })
|
|
4045
4092
|
pending.set(childId, { bot, taskDir: dir })
|
|
4093
|
+
// 记下创建时所在的根会话:以后判断这条单聊还能不能发消息,就看它。
|
|
4094
|
+
// 拿不到 rootOf 就退回当前会话;当前会话本身一定是活的。
|
|
4095
|
+
let rootSession = parent
|
|
4096
|
+
try {
|
|
4097
|
+
const rootAgent = subagents?.rootOf?.(parentAgent)
|
|
4098
|
+
rootSession = String(rootAgent?.session?.header?.id ?? rootAgent?.id ?? parent)
|
|
4099
|
+
} catch {
|
|
4100
|
+
rootSession = parent
|
|
4101
|
+
}
|
|
4046
4102
|
const prompt = `主动打开这个会话想和你说话,不是派任务:不要调用任何工具,不要写文件,也不要给自己派活。只回一句「在」,然后等${address()}开口。`
|
|
4047
4103
|
const base = {
|
|
4048
4104
|
provider: 'spawn',
|
|
@@ -4068,6 +4124,7 @@ export function registerTeamTools(ctx, options) {
|
|
|
4068
4124
|
taskId: chatId,
|
|
4069
4125
|
bot: bot.id,
|
|
4070
4126
|
parentSession: parent,
|
|
4127
|
+
rootSession,
|
|
4071
4128
|
cwd: dir,
|
|
4072
4129
|
startedAt: Date.now(),
|
|
4073
4130
|
// 这是「入口标记」,不是在跑的活:立刻收尾,免得名册一直显示忙。
|
|
@@ -4078,19 +4135,12 @@ export function registerTeamTools(ctx, options) {
|
|
|
4078
4135
|
})
|
|
4079
4136
|
void persistTasks?.()
|
|
4080
4137
|
options.api?.broadcast?.({ type: 'tasks' })
|
|
4081
|
-
await debug?.({ event: 'chat-open', bot: bot.id, sessionId: childId })
|
|
4138
|
+
await debug?.({ event: 'chat-open', bot: bot.id, sessionId: childId, rootSession })
|
|
4082
4139
|
// 父会话 id 一起回去:面板拿到就能直接开出「子会话」标签,
|
|
4083
4140
|
// 不用等名册刷新(等那一下,用户第一次点必然失败)。
|
|
4084
4141
|
// identity 也一起回去:面板拿它先写进头像映射,第一帧就不会顶着主会话的头像。
|
|
4085
4142
|
// 字段跟 `/dsh-team/identity-map` 那份保持一致,改的时候两边一起改。
|
|
4086
|
-
|
|
4087
|
-
id: bot.id,
|
|
4088
|
-
name: bot.name ?? bot.id,
|
|
4089
|
-
src: `/dsh-team/avatar?bot=${encodeURIComponent(bot.id)}&v=3`,
|
|
4090
|
-
onOpen: true,
|
|
4091
|
-
speech: false,
|
|
4092
|
-
}
|
|
4093
|
-
return { ok: true, sessionId: childId, parentSessionId: parent, identity, bot: bot.id }
|
|
4143
|
+
return { ok: true, sessionId: childId, parentSessionId: parent, identity: chatIdentityOf(bot), bot: bot.id }
|
|
4094
4144
|
} catch (error) {
|
|
4095
4145
|
pending.delete(childId)
|
|
4096
4146
|
return { ok: false, error: String(error?.message ?? error) }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-rhine-lab-team",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "给 DeepSeek Harness 配一个工作团队:每个 Bot 有自己的记忆、分工、头像和 ID;在你的指导下或自己干活,都能积累经验、升级成长,成为你最放心可靠的团队成员。灵感与 UI 参考《明日方舟》,与官方无关。",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"publishConfig": {
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"test": "node --test --experimental-test-isolation=none test/*.test.mjs",
|
|
21
|
+
"check": "node scripts/check.mjs",
|
|
22
|
+
"pack:check": "npm pack --dry-run"
|
|
23
|
+
},
|
|
19
24
|
"exports": {
|
|
20
25
|
".": "./index.js",
|
|
21
26
|
"./client": "./client.js",
|
|
@@ -67,10 +72,5 @@
|
|
|
67
72
|
],
|
|
68
73
|
"dependencies": {
|
|
69
74
|
"dsh-avatar-frame": "latest"
|
|
70
|
-
},
|
|
71
|
-
"scripts": {
|
|
72
|
-
"test": "node --test --experimental-test-isolation=none test/*.test.mjs",
|
|
73
|
-
"check": "node scripts/check.mjs",
|
|
74
|
-
"pack:check": "npm pack --dry-run"
|
|
75
75
|
}
|
|
76
|
-
}
|
|
76
|
+
}
|