@suifei/dsh-ai-team 0.3.79 → 0.3.81

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.81 - 2026-11-12
4
+
5
+ - **官方资料合规评审复核**:评审代理的 7 medium / 6 low 逐条对照当前源码复核——locale 覆盖、硬编码文案、SSE 清空草稿、模态 Escape/焦点陷阱、toast 字面色、grid 第三列(实为 absolute 浮层)、SSE 诊断、prj_main 兜底**均不成立或已修**(多数为评审后已被后续修复覆盖,二手材料必须核实的实例);唯一可执行项(index.js 未使用常量 PROJECT_ID)已删除。结论归档 docs/15。
6
+
7
+
8
+ ## 0.3.80 - 2026-11-12
9
+
10
+ - **chatGate 自动收敛(UX 一致性修正)**:开关切换不再要求手动「重置会话」——PMO 巡检对**空闲**成员自动重建会话(每轮最多 2 个,约 1 分钟内收敛;忙碌成员等回合结束再应用,绝不打断进行中的工作);boot 时以账本当前值初始化,避免重启即全体重建。命令返回 note 如实说明「自动生效 + 会话记忆会重置」。
11
+ - planChatGateReseats 纯函数(可选重建计划)+ 3 项测试(idle/busy/cold/retired/limit)。
12
+
13
+
3
14
  ## 0.3.79 - 2026-11-12
4
15
 
5
16
  - **Human 直聊门接入项目开关**:成员会话 header 的 parentSession 现在由项目 chatGate 决定——open(默认)不带 parentSession(宿主放行 Human 在 DSH 主界面直接输入);closed 带 parentSession(宿主按 subagent-owned 拒绝)。门只对新建/重建会话生效(header 不可变),切换开关时命令返回明确说明(已有成员需「重置会话」)。2 项映射测试(open/closed 两种 header 断言)。
package/client.js CHANGED
@@ -3019,8 +3019,9 @@ window.__ModuleLoader__.load({
3019
3019
  }
3020
3020
  async function toggleChatGate() {
3021
3021
  try {
3022
- await runCommand('project.chatGate', { gate: chatGateClosed ? 'open' : 'closed' });
3023
- say(chatGateClosed ? t('chatGateOpened') : t('chatGateClosedShort'));
3022
+ const result = await runCommand('project.chatGate', { gate: chatGateClosed ? 'open' : 'closed' });
3023
+ // host 的 note 说明自动收敛语义(空闲成员约 1 分钟内自动重建)。
3024
+ say(result?.note ?? (chatGateClosed ? t('chatGateOpened') : t('chatGateClosedShort')));
3024
3025
  await reloadData();
3025
3026
  } catch (error) {
3026
3027
  sayRight(tf(t, 'sendFailed', { message: error?.message ?? String(error) }));
package/index.js CHANGED
@@ -30,6 +30,7 @@ import { installFaultAdapter } from './lib/host/fault-adapter.js';
30
30
  import { buildModelCatalog } from './lib/host/model-catalog.js';
31
31
  import { createTeamTool } from './lib/host/member-tools.js';
32
32
  import { describeWake, planWakes } from './lib/host/waker.js';
33
+ import { planChatGateReseats } from './lib/host/chat-gate-sync.js';
33
34
  import { aggregatePeople } from './lib/host/people-view.js';
34
35
  import { riskView } from './lib/host/risk-view.js';
35
36
  import { weeklyView } from './lib/host/weekly-view.js';
@@ -41,8 +42,7 @@ export const name = 'ai-team';
41
42
  /** The workbench only makes sense where the Web carrier exists. */
42
43
  export const inject = ['webServer', 'permissionPresets', 'sandboxPolicy'];
43
44
 
44
- const VERSION = '0.3.79';
45
- const PROJECT_ID = 'prj_main';
45
+ const VERSION = '0.3.81';
46
46
  const HUMAN_ID = 'mem_human';
47
47
 
48
48
  const SKILLOPT_BACKENDS = ['mock', 'claude', 'codex', 'copilot', 'cursor', 'pi', 'opencode', 'handoff', 'azure_openai'];
@@ -372,6 +372,9 @@ export function apply(ctx, config = {}) {
372
372
  const pmoLastStall = new Map();
373
373
  const pmoLastHeartbeat = new Map();
374
374
  const pmoLastDispatch = new Map();
375
+ // chatGate 已应用值(内存):boot 时用当前账本值初始化,避免重启即重建
376
+ // 全体会话;此后每轮 tick 收敛到账本值(对空闲成员自动重建会话)。
377
+ const chatGateApplied = new Map();
375
378
  const pmoLastEscalate = new Map();
376
379
  const pmoLastReview = new Map();
377
380
  // Members resumed from cold sessions produce AgentHandles nobody stored;
@@ -508,6 +511,33 @@ export function apply(ctx, config = {}) {
508
511
  // P6 停止门:stopped 项目停止一切派发(补派/心跳/升级/continue 全停),
509
512
  // 正在执行的回合自然完成;唤醒事件 hook 同样检查(见 wakeFromResult)。
510
513
  if (project.runState === 'stopped') return;
514
+ // chatGate 自动收敛:开关变更后成员会话 header 需重建才生效——对
515
+ // **空闲**成员自动 reseat(每轮最多 2 个),忙碌成员等回合结束再应用。
516
+ // 本轮无可重建且无忙碌成员时记为已收敛(停止重复重建)。独立于派发门。
517
+ const gate = project.chatGate === 'closed' ? 'closed' : 'open';
518
+ if (chatGateApplied.get(projectRuntime.id) !== gate) {
519
+ const plan = planChatGateReseats(
520
+ Object.values(state.members ?? {}).filter((member) => member.kind === 'agent'),
521
+ (sessionId) => ctx.get('agents')?.get?.(sessionId)?.status ?? null,
522
+ { limit: 2 },
523
+ );
524
+ for (const memberId of plan.reseat) {
525
+ const member = state.members?.[memberId];
526
+ if (member === undefined) continue;
527
+ diag.append({ ev: 'chatgate.reseat', projectId: projectRuntime.id, memberId, gate, oldSessionId: member.sessionId ?? null });
528
+ const result = await activateMember({
529
+ payload: { memberId, prompt: `会话已重建(Human 对话门:${gate})。先读 tasks/thread 当前状态,继续推进;不要重复已完成的工作。`, force: true },
530
+ }, projectRuntime).catch((error) => ({ error: { message: error?.message ?? String(error) } }));
531
+ if (result?.error !== undefined) {
532
+ diag.append({ ev: 'chatgate.reseat.fail', projectId: projectRuntime.id, memberId, message: result.error.message });
533
+ }
534
+ }
535
+ // 本轮没有可重建对象、也没有忙碌成员 → 全部收敛(cold 成员激活时
536
+ // 自然读取当前门状态)。
537
+ if (plan.reseat.length === 0 && plan.busy.length === 0) {
538
+ chatGateApplied.set(projectRuntime.id, gate);
539
+ }
540
+ }
511
541
  for (const member of Object.values(state.members ?? {})) {
512
542
  if (member.kind === 'agent' && typeof member.sessionId === 'string') {
513
543
  await titleMemberSession(projectRuntime, member);
@@ -0,0 +1,38 @@
1
+ /**
2
+ * chatGate 自动收敛规划(纯函数,便于测试):
3
+ * 项目「Human 对话」开关变更后,成员会话的 header(是否带 parentSession)
4
+ * 在创建时固定,必须重建会话才能让新门状态生效。本函数决定本轮应该重建
5
+ * 哪些成员:
6
+ * - 只挑**空闲**成员(live agent 状态不是 running / 或会话已冷)——绝不打断
7
+ * 进行中的回合;
8
+ * - 每轮最多 `limit` 个,渐进收敛,避免 6 个成员同时激活造成回合风暴;
9
+ * - 忙碌成员不出现在 reseat 列表里,调用方保持「未收敛」状态,下轮再试。
10
+ *
11
+ * @param {Array<{id:string, sessionId:string|null, status?:string}>} members
12
+ * @param {(sessionId:string) => string|null} liveAgentStatus 宿主 agent 状态查询(null=冷会话/已释放)
13
+ * @param {{limit?:number}} [options]
14
+ * @returns {{reseat: Array, busy: Array, cold: Array}}
15
+ */
16
+ export function planChatGateReseats(members, liveAgentStatus, options = {}) {
17
+ const limit = Math.max(1, Number.isSafeInteger(options.limit) ? options.limit : 2);
18
+ const reseat = [];
19
+ const busy = [];
20
+ const cold = [];
21
+ for (const member of members) {
22
+ if (member === null || member === undefined) continue;
23
+ if (member.status === 'retired') continue;
24
+ const sessionId = typeof member.sessionId === 'string' && member.sessionId !== '' ? member.sessionId : null;
25
+ if (sessionId === null) {
26
+ // 从未激活:下次激活自然读当前门状态,无需重建。
27
+ cold.push(member.id);
28
+ continue;
29
+ }
30
+ const live = liveAgentStatus(sessionId);
31
+ if (live === 'running') {
32
+ busy.push(member.id);
33
+ continue;
34
+ }
35
+ reseat.push(member.id);
36
+ }
37
+ return { reseat: reseat.slice(0, limit), busy, cold };
38
+ }
@@ -469,13 +469,13 @@ export class TeamService {
469
469
  if (gate !== 'open' && gate !== 'closed') fail(ERRORS.INVALID_ARGUMENT, 'gate must be open or closed');
470
470
  if (command.actor.kind !== 'human') fail(ERRORS.UNAUTHORIZED, 'only Human may change the chat gate');
471
471
  await this.append(command, 'project/chat-gate', { projectId, gate, reason: payload.reason ?? '' });
472
- // 直聊门只对新建/重建的成员会话生效(session header 不可变):
473
- // 已存在的成员会话需「重置会话」(reseat)后应用新门状态。
472
+ // 直聊门只对新建/重建的成员会话生效(session header 不可变):Host 的
473
+ // PMO 巡检会在成员空闲时自动重建会话(每轮最多 2 个),无需手动操作。
474
474
  return {
475
475
  project: { ...project, chatGate: gate },
476
476
  note: gate === 'closed'
477
- ? '已关闭 Human 直聊:新建会话生效;已有成员会话需重置会话后生效。'
478
- : '已开启 Human 直聊:新建会话生效;已有成员会话需重置会话后生效。',
477
+ ? '已关闭 Human 直聊:成员会话将在空闲时自动重建(每轮 2 个,约 1 分钟内生效;会话记忆会重置)。'
478
+ : '已开启 Human 直聊:成员会话将在空闲时自动重建(每轮 2 个,约 1 分钟内生效;会话记忆会重置)。',
479
479
  };
480
480
  }
481
481
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.3.79",
3
+ "version": "0.3.81",
4
4
  "type": "module",
5
5
  "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
6
  "license": "MIT",