dsh-device-fleet 0.1.0-dev.19 → 0.1.0-dev.20

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/client.js CHANGED
@@ -1081,6 +1081,67 @@ window.__ModuleLoader__.load({
1081
1081
  )
1082
1082
  }
1083
1083
 
1084
+ // Room is a normal Session with participants. This dock keeps the member
1085
+ // strip inside the conversation instead of a separate dashboard.
1086
+ function RoomDock({ sessionId }) {
1087
+ const [room, setRoom] = useState(null);
1088
+ const [missing, setMissing] = useState(false);
1089
+ const [status, setStatus] = useState('');
1090
+
1091
+ const load = async () => {
1092
+ if (!sessionId) return;
1093
+ try {
1094
+ const response = await fetch('/device-fleet/room?id=' + encodeURIComponent(sessionId), { headers: { accept: 'application/json' } });
1095
+ if (response.status === 404) {
1096
+ setRoom(null);
1097
+ setMissing(true);
1098
+ return;
1099
+ }
1100
+ if (!response.ok) throw new Error('HTTP ' + response.status);
1101
+ const data = await response.json();
1102
+ setRoom(data.room ?? null);
1103
+ setMissing(false);
1104
+ } catch {
1105
+ setRoom(null);
1106
+ }
1107
+ };
1108
+
1109
+ useEffect(() => {
1110
+ void load();
1111
+ const timer = setInterval(load, 4000);
1112
+ return () => clearInterval(timer);
1113
+ }, [sessionId]);
1114
+
1115
+ if (!sessionId) return null;
1116
+ const upgrade = async () => {
1117
+ setStatus('升级中…');
1118
+ try {
1119
+ await postJson('/device-fleet/room/upgrade', { sessionId });
1120
+ setStatus('');
1121
+ await load();
1122
+ } catch (problem) {
1123
+ setStatus('升级失败:' + String(problem.message ?? problem));
1124
+ }
1125
+ };
1126
+
1127
+ if (missing) {
1128
+ return h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, fontSize: 11, opacity: 0.75, padding: '2px 2px 0' } },
1129
+ h('span', null, '普通会话'),
1130
+ status ? h('span', null, status) : null,
1131
+ smallButton('升级为 Room', () => void upgrade(), 'normal'),
1132
+ );
1133
+ }
1134
+ if (!room) return null;
1135
+ const names = room.members.filter((member) => member.role !== 'host').map((member) => member.name);
1136
+ return h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, fontSize: 11, opacity: 0.8, padding: '2px 2px 0', flexWrap: 'wrap' } },
1137
+ pill('Room', 'ok'),
1138
+ h('span', null, room.members.length + ' 名成员'),
1139
+ names.length > 0 ? h('span', null, '· ' + names.join(', ')) : h('span', null, '· 仅 host'),
1140
+ h('span', { style: { flex: 1 } }),
1141
+ h('span', { style: { opacity: 0.55 } }, '房间消息会同步到参与者'),
1142
+ );
1143
+ }
1144
+
1084
1145
  return {
1085
1146
  inject: ['slots'],
1086
1147
  apply(ctx) {
@@ -1097,6 +1158,11 @@ window.__ModuleLoader__.load({
1097
1158
  ctx.slots.register({ name: 'sidebar.panellist', id: 'fleet', order: 20, label: '设备联邦' }, FleetIcon),
1098
1159
  );
1099
1160
  ctx.slots.register({ name: 'main', key: 'fleet' }, FleetConsole);
1161
+ // Session-native Room: member strip below the composer; the normal Chat
1162
+ // stream carries the conversation.
1163
+ ctx.slots.inject('conversation.composer.dock', () =>
1164
+ ctx.slots.register({ name: 'conversation.composer.dock', id: 'fleet-room', order: 10 }, RoomDock),
1165
+ );
1100
1166
  // Configuration page: Settings → Plugins → Device Fleet (row + bundle).
1101
1167
  ctx.slots.inject('plugins.row.config', () =>
1102
1168
  ctx.slots.register({ name: 'plugins.row.config', key: 'dsh-device-fleet#device-fleet' }, FleetConfig),
@@ -39,19 +39,19 @@ dsh plugin --profile desktop add dsh-device-fleet@dev
39
39
  - 邀请里新增 `endpoints`(创建者的局域网/热点 IPv4 + direct 端口),加入方重启后自动向这些地址回连,绕开组播发现失败;
40
40
  - 新增 `fleet_status`(deviceId/直连端口/发现/连接/roster/hints)与 `fleet_connect(host, port)`(手动直连,成功后会从握手学到对端 deviceId);
41
41
  - `fleet_list` 仍是本地视图;配对成功后双方 roster 会自动固定对端公钥。
42
- ## 0.1.0-dev.18(稳定化)
42
+ ## 0.1.0-dev.19(稳定化)
43
43
 
44
44
  - 直连端口可固定(profile `direct.port`),插件重载不再换端口;
45
45
  - 连接断开后自动重试已知地址(不再只在启动时试一次);
46
46
  - `fleet_connect` 手动地址会持久化到 `peer-hints.json`,重启后继续回连;
47
47
  - 新增 `fleet_delegate`(dev.5):目标设备用 `SubagentProvider` + `delivery:'caller'` 跑 agent 并返回最终结果。
48
- ## 0.1.0-dev.18(审批收件箱,逻辑层)
48
+ ## 0.1.0-dev.19(审批收件箱,逻辑层)
49
49
 
50
50
  - 新增 `ApprovalInbox`:ask 档请求排队、超时 fail-closed、approve(once/ttl)/deny、关闭时全部失败关闭;
51
51
  - 直调与委派的 ask 档改为等待本机收件箱结果(不再一律拒绝);
52
52
  - 新工具:`fleet_approvals` / `fleet_approve` / `fleet_deny`;`fleet_simulate_request`(仅 `approvals.simulation: true`)用于本机无第二台设备时演练流程;
53
53
  - 审批面板(Client UI)与通知尚未实现,当前通过工具/后续 UI 应答。
54
- ## 0.1.0-dev.18(Room 逻辑层,本机模拟)
54
+ ## 0.1.0-dev.19(Room 逻辑层,本机模拟)
55
55
 
56
56
  - `RoomService`:当前会话升级为 Room Host;本地模拟参与者(真实 DSH session/agent);
57
57
  - 寻址消息:`room_send` 只唤醒被点名成员,Host 会话写权威 `room/message` 事件;
@@ -59,48 +59,53 @@ dsh plugin --profile desktop add dsh-device-fleet@dev
59
59
  - Room Board:`room_task_add/update/list`,`dependsOn` 串行交接(前置完成时唤醒下一个 owner),无依赖任务并行不受影响;
60
60
  - 工具:`room_create / room_add_local / room_remove_member / room_send / room_messages / room_status / room_task_* / room_close`;
61
61
  - 远程参与者传输与 Client UI 未做(下一步)。
62
- ## 0.1.0-dev.18(审批面板 UI,第一版)
62
+ ## 0.1.0-dev.19(审批面板 UI,第一版)
63
63
 
64
64
  - Host 新增本地 HTTP 数据面:GET `/device-fleet/approvals`、POST `/device-fleet/approvals/decide`(仅本机 web 载体,决策仍走 ApprovalInbox);
65
65
  - Client half:`client.js` 闭包工厂,注册 `shell.overlay` 浮动「Fleet 审批」按钮 + 面板,轮询待审批列表,支持允许一次 / 允许 15 分钟 / 拒绝;
66
66
  - package.json 增加 `dsh.client` 与 `./client` 导出;`files` 增加 client.js;
67
67
  - Client 视觉验证需要刷新页面;当前无浏览器控制,仅验证了 bundle 语法与 Host 路由注册。
68
- ## 0.1.0-dev.18(审批入口不遮挡)
68
+ ## 0.1.0-dev.19(审批入口不遮挡)
69
69
 
70
70
  - 触发按钮从右下角浮动改为 `sidebar.footer.action`(设置旁边),不再遮挡任务列表/内容面板;
71
71
  - 审批 inbox 改为点击后居中的模态对话框(带遮罩,Esc/点遮罩关闭);
72
72
  - 轮询在 Client apply 中启动并由 ctx.effect 清理;待审批数量作为按钮徽标;
73
73
  - 已实测:面板点击「允许」后 Host `fleet_approvals` 清空。
74
- ## 0.1.0-dev.18(Phase B:运行时配置 + 配置页)
74
+ ## 0.1.0-dev.19(Phase B:运行时配置 + 配置页)
75
75
 
76
76
  - `RuntimeConfig`:profile patch 为 base,UI 修改写入 `$DSH_HOME/device-fleet/config-overrides.json`,apply 时合并并持久化;
77
77
  - 保存即生效:policy/execution/approvals/deviceName/promptSection/autoApproveAsk 直接更新运行时对象;direct/discovery/relay 通过 `FleetNode.reconfigure()` 原地重启网络监听(不重启插件/DSH);`dataDir` 只读;
78
78
  - Host:`GET /device-fleet/config`、`POST /device-fleet/config`(校验/清洗后应用);
79
79
  - Client:注册 `plugins.row.config`(key `dsh-device-fleet#device-fleet`)与 `plugins.bundle.config`(key `dsh-device-fleet`),配置页含设备/网络、执行上下文、Tool Policy、审批与提示四组表单;
80
80
  - 单测 18/18、网络 9/9。
81
- ## 0.1.0-dev.18(配置页 DSH 化改版)
81
+ ## 0.1.0-dev.19(配置页 DSH 化改版)
82
82
 
83
83
  - Host 新增 `GET /device-fleet/options`:本机地址、可用 preset 列表、shell 工具、subagent providers、工作目录候选;
84
84
  - 配置保存前会 ensure 工作目录存在(Device Fleet 工作区自动创建);
85
85
  - 配置页重做:行式布局(label 左/控件右)、DSH token 配色、分组标题、去掉多余说明文字与 dataDir 展示;
86
86
  - 下拉化:直连地址、局域网发现、Relay 模式、工作目录(工作区/默认/DSH 主目录/自定义)、Agent Preset、Shell、委派 Provider、7 项能力权限、开关项;
87
87
  - 仍保留文本输入:设备名称、端口、超时、根目录/工具列表、自定义工作目录与 Relay 地址。
88
- ## 0.1.0-dev.18(房间详情与配置页修复)
88
+ ## 0.1.0-dev.19(房间详情与配置页修复)
89
89
 
90
90
  - 房间详情接口从 prefix 路由改为精确路由 `GET /device-fleet/room?id=...`,修复控制台一直「加载房间…」;客户端加载失败时显示错误文案;
91
91
  - 配置页宽行改为「标签在上、控件在下」,修复根目录等标签竖排换行;
92
92
  - 保存按钮改为固定品牌蓝底白字,修复按钮看起来空白;
93
93
  - 「允许的原始工具」改为「免审批即用的工具」:从 Host options 拉取本机真实工具清单,以复选框选择(不再手输工具名)。
94
- ## 0.1.0-dev.18(原始工具遵循 DSH 审批)
94
+ ## 0.1.0-dev.19(原始工具遵循 DSH 审批)
95
95
 
96
96
  - 移除「免审批即用的工具」白名单;raw tool 调用不再由插件 allowlist 决定;
97
97
  - `policy.capabilities.tool` 默认 `auto`:完全走 DSH 工具流水线(target Session 的 pre-execute policy + approval seam);`deny` 禁用 raw tools,`ask` 在 DSH 前加一层本机审批;
98
98
  - 新增 `approval/request` 监听:Execution Slot 里 DSH 需要审批的工具调用会转到本设备审批收件箱(面板可处理),不需要审批的工具直接执行;
99
99
  - 旧配置里 `tool: deny` + 空 allowedTools 自动迁移为 `auto`;
100
100
  - 配置页移除工具复选框列表,「原始工具(遵循 DSH 审批)」保留 自动/询问/拒绝 下拉。
101
- ## 0.1.0-dev.18(Phase C:交互动作)
101
+ ## 0.1.0-dev.19(Phase C:交互动作)
102
102
 
103
103
  - Room 用户动作:以用户身份发消息(选择收件人)、看板任务添加/状态更新、关闭房间、移除成员;
104
104
  - 设备动作:生成/复制邀请码、手动地址连接(host+port);
105
105
  - 审批历史:ApprovalInbox 记录最近 50 条已决请求(approved/denied/expired/closed),Console 审批 Tab 展示历史;
106
- - 新增 Host 动作路由:`/room/send`、`/room/task`、`/room/close`、`/room/member/remove`、`/pair/invite`、`/pair/connect`、`/approvals/history`。
106
+ - 新增 Host 动作路由:`/room/send`、`/room/task`、`/room/close`、`/room/member/remove`、`/pair/invite`、`/pair/connect`、`/approvals/history`。
107
+ ## 0.1.0-dev.19(修复控制台空白)
108
+
109
+ - 根因:FleetConsole 的设备/房间交互误用了从未定义的 `ActionButton` 组件(React 渲染抛 ReferenceError,主面板空白)。
110
+ - 修复:统一改用已有的 `smallButton`。
111
+ - 新增 `scripts/client-smoke.mjs`:用最小 Hooks 渲染器 + mock fetch 实际渲染控制台(初始/设备/房间列表/房间详情),防止这类渲染崩溃再次漏过 `node --check`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-device-fleet",
3
- "version": "0.1.0-dev.19",
3
+ "version": "0.1.0-dev.20",
4
4
  "description": "DeepSeek Harness device fleet: enroll devices, direct-call remote tools, shared Rooms with lazy-woken agents, and delegated subagents across devices.",
5
5
  "type": "module",
6
6
  "main": "src/plugin/index.js",
@@ -248,12 +248,17 @@ export class RoomService {
248
248
  if (!(await this.ensureAgent(member))) return false
249
249
  if (typeof member.agent?.followup !== 'function') return false
250
250
  const senderLabel = message.from.kind === 'user' ? 'user' : (message.from.name ?? 'agent')
251
- const text = [
252
- `[Fleet Room ${room.roomId}] ${senderLabel} → you:`,
253
- message.text,
254
- '',
255
- `Reply with room_send (roomId="${room.roomId}", to=["${message.from.memberId ?? 'host'}"]) when you have an answer.`,
256
- ].join('\n')
251
+ // The host is the user's own session: deliver a plain attributed line into
252
+ // the normal Chat stream instead of an agent-to-agent reply instruction.
253
+ const text =
254
+ member.role === 'host'
255
+ ? `[Room] ${senderLabel}: ${message.text}`
256
+ : [
257
+ `[Fleet Room ${room.roomId}] ${senderLabel} → you:`,
258
+ message.text,
259
+ '',
260
+ `Reply with room_send (roomId="${room.roomId}", to=["${message.from.memberId ?? 'host'}"]) when you have an answer.`,
261
+ ].join('\n')
257
262
  const userMessage = this.createUserMessage({ content: [{ type: 'text', text }], source: { kind: 'user' } })
258
263
  try {
259
264
  member.agent.followup(userMessage)
@@ -105,6 +105,12 @@ export function registerUiRoutes({ webServer, inbox, rooms, getOverview, actions
105
105
  return { ok: true, result: await actions.removeMember(body ?? {}) }
106
106
  }),
107
107
  )
108
+ disposers.push(
109
+ actionRoute(webServer, '/device-fleet/room/upgrade', 'POST', async (body) => {
110
+ if (!actions?.upgradeRoom) throw Object.assign(new Error('room actions are unavailable'), { code: 'unsupported' })
111
+ return { ok: true, room: await actions.upgradeRoom(body ?? {}) }
112
+ }),
113
+ )
108
114
  disposers.push(
109
115
  actionRoute(webServer, '/device-fleet/pair/invite', 'POST', async () => {
110
116
  if (!actions?.createInvite) throw Object.assign(new Error('pairing actions are unavailable'), { code: 'unsupported' })
@@ -320,6 +320,13 @@ export function apply(ctx, profileConfig) {
320
320
  },
321
321
  closeRoom: ({ roomId, reason } = {}) => rooms.close({ roomId, reason: reason ?? 'closed by user' }),
322
322
  removeMember: ({ roomId, memberId, reason } = {}) => rooms.removeMember({ roomId, memberId, reason: reason ?? 'removed by user' }),
323
+ async upgradeRoom({ sessionId } = {}) {
324
+ if (typeof sessionId !== 'string' || sessionId === '') throw Object.assign(new Error('sessionId is required'), { code: 'bad-request' })
325
+ if (!sessionController?.resolveAgent) throw Object.assign(new Error('session agent is unavailable'), { code: 'unsupported' })
326
+ const resolved = await sessionController.resolveAgent(sessionId)
327
+ if (!resolved?.agent) throw Object.assign(new Error('session agent is unavailable'), { code: 'unsupported' })
328
+ return rooms.upgradeHost({ agent: resolved.agent })
329
+ },
323
330
  createInvite: async () => {
324
331
  if (!pairingRef?.invite) throw Object.assign(new Error('pairing is unavailable'), { code: 'unsupported' })
325
332
  return pairingRef.invite()
@@ -417,6 +424,37 @@ export function apply(ctx, profileConfig) {
417
424
  return ctx.on('approval/request', handler)
418
425
  })
419
426
 
427
+ // A Room is a normal Session whose user input is also delivered to its
428
+ // participants. Typing in the Host conversation therefore needs no separate
429
+ // Room composer.
430
+ ctx.effect(() =>
431
+ ctx.on?.('session/event', (session, event) => {
432
+ try {
433
+ if (!session?.id || event?.type !== 'user/message') return
434
+ const room = rooms.rooms.get(session.id)
435
+ if (!room) return
436
+ const message = event.data
437
+ if (message?.source?.kind && message.source.kind !== 'user') return
438
+ const text = (Array.isArray(message?.content) ? message.content : [])
439
+ .filter((block) => block?.type === 'text')
440
+ .map((block) => block.text)
441
+ .join('\n')
442
+ .trim()
443
+ if (text === '' || text.startsWith('[Room]') || text.startsWith('[Fleet Room')) return
444
+ const recipients = rooms
445
+ .status(session.id)
446
+ .members.filter((member) => member.role !== 'host')
447
+ .map((member) => member.memberId)
448
+ if (recipients.length === 0) return
449
+ void rooms.send({ roomId: session.id, from: { kind: 'user' }, to: recipients, text }).catch((error) => {
450
+ logger.warn?.(`[device-fleet] cannot broadcast room message: ${String(error?.message ?? error)}`)
451
+ })
452
+ } catch (error) {
453
+ logger.warn?.(`[device-fleet] room broadcast failed: ${String(error?.message ?? error)}`)
454
+ }
455
+ }),
456
+ )
457
+
420
458
  node.onRequest(async (request) => {
421
459
  if (!host) throw Object.assign(new Error('this device cannot serve direct calls (no execution slot)'), { code: 'unsupported' })
422
460
  return host.handleRequest(request)