@suifei/dsh-ai-team 0.3.52 → 0.3.54

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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.54 — 2026-11-10
4
+
5
+ - 默认花名册扩到 6 名 Agent:新增 **知微(UX 设计)**——以用户体验为第一核心研究目标 UI/UE;**观澜(业务)**——从运营/用户视角洞察真实需求并提出 UX 改进意见;
6
+ - 既有项目自动补齐缺失的核心角色(同角色已存在则不重复添加,自定义花名册不被覆盖);
7
+ - PMO 会议(pmo/continue)从只唤醒 owner 改为**带上所有 Agent 成员**:owner 主持,其余成员以 pmo_meeting 参会并从专业视角在 Thread 发言。
8
+
9
+ ## 0.3.53 — 2026-11-10
10
+
11
+ 修复全新环境安装三连问题(严重):
12
+
13
+ - **`{{model}}` 无值**:成员/宿主 session 只把 provider/model 挂在活体 Agent options 上;进程重启后恢复的 session 两者皆无,prompt 渲染失败。现在 activation/wake/boot 都会把 `model/selection` 写入 session 日志,路由跨重启持久有效;
14
+ - **插件开关破坏宿主**:卸载清理此前是 fire-and-forget,旧组合未清理完新组合已激活。现在 disposer 完全等待宿主/激活/账本清理收尾,且绝不抛错;
15
+ - **首次安装即坏**:`boot()` 同步异常或 skill provider/team tool 注册异常会让组合激活失败。现在全部降级为警告,插件激活永不失败。
16
+
3
17
  ## 0.3.52 — 2026-11-10
4
18
 
5
19
  - bootstrap 返回全部 Task 的 Thread 映射,修复卡片显示 6 条回复但右栏打开为空的错位;
package/index.js CHANGED
@@ -34,7 +34,7 @@ export const name = 'ai-team';
34
34
  /** The workbench only makes sense where the Web carrier exists. */
35
35
  export const inject = ['webServer', 'permissionPresets', 'sandboxPolicy'];
36
36
 
37
- const VERSION = '0.3.52';
37
+ const VERSION = '0.3.54';
38
38
  const PROJECT_ID = 'prj_main';
39
39
  const HUMAN_ID = 'mem_human';
40
40
 
@@ -166,12 +166,30 @@ export function apply(ctx) {
166
166
  console.warn('[ai-team] member session workspace attach failed:', error?.message ?? error);
167
167
  }
168
168
  };
169
+ // A restored member session has no live AgentOptions; without a recorded
170
+ // model/selection event its prompt renders with an unresolvable {{model}}.
171
+ const modelSelectionLogged = new Map();
172
+ const persistModelSelection = (sessionId, selection, label) => {
173
+ if (typeof sessionId !== 'string' || sessionId === '') return;
174
+ if (typeof selection?.provider !== 'string' || selection.provider === ''
175
+ || typeof selection?.model !== 'string' || selection.model === '') return;
176
+ const route = `${selection.provider}/${selection.model}`;
177
+ if (modelSelectionLogged.get(sessionId) === route) return;
178
+ try {
179
+ const session = ctx.get('sessions')?.get?.(sessionId);
180
+ if (session === undefined || session === null || typeof session.append !== 'function') return;
181
+ session.append('model/selection', { provider: selection.provider, model: selection.model });
182
+ modelSelectionLogged.set(sessionId, route);
183
+ } catch (error) {
184
+ console.warn('[ai-team] model selection persist failed:', label ?? sessionId, error?.message ?? error);
185
+ }
186
+ };
169
187
  const access = validatePermissionProfile({
170
188
  permissionPresets: ctx.get('permissionPresets'),
171
189
  sandboxPolicy: ctx.get('sandboxPolicy'),
172
190
  });
173
191
  const ready = access.ok
174
- ? boot()
192
+ ? Promise.resolve().then(boot)
175
193
  .then(async (value) => {
176
194
  booted = value;
177
195
  for (const runtime of value.runtimes.values()) {
@@ -179,6 +197,7 @@ export function apply(ctx) {
179
197
  if (member.kind === 'agent' && typeof member.sessionId === 'string') {
180
198
  await attachMemberWorkspace(runtime, member.sessionId);
181
199
  await titleMemberSession(runtime, member);
200
+ persistModelSelection(member.sessionId, member.config, member.name);
182
201
  }
183
202
  }
184
203
  void pmoTick(runtime).catch((error) => console.warn('[ai-team] PMO tick failed:', error?.message ?? error));
@@ -342,6 +361,7 @@ export function apply(ctx) {
342
361
  messageId = delivered.messageId ?? null;
343
362
  // A cold session cannot be renamed before wake; retry once it is live.
344
363
  await titleMemberSession(projectRuntime, member);
364
+ persistModelSelection(member.sessionId, member.config, member.name);
345
365
  }
346
366
  await projectRuntime.service.recordWake(plan.memberId, {
347
367
  ok: true, taskId: plan.taskId, reason: plan.reason, messageId,
@@ -505,11 +525,18 @@ export function apply(ctx) {
505
525
  };
506
526
 
507
527
  const skillsService = ctx.get('skills');
508
- const disposeSkillProvider = installFileSkillProvider(skillsService, {
509
- dshHome: dshHome(),
510
- projectCwd: process.cwd(),
511
- bundledDir: fileURLToPath(new URL('./', import.meta.url)),
512
- });
528
+ let disposeSkillProvider = () => {};
529
+ try {
530
+ // A vendor failure must never fail composition activation: that left
531
+ // fresh installs with a half-activated host until a process restart.
532
+ disposeSkillProvider = installFileSkillProvider(skillsService, {
533
+ dshHome: dshHome(),
534
+ projectCwd: process.cwd(),
535
+ bundledDir: fileURLToPath(new URL('./', import.meta.url)),
536
+ }) ?? (() => {});
537
+ } catch (error) {
538
+ console.warn('[ai-team] file skill provider failed:', error?.message ?? error);
539
+ }
513
540
  const tools = ctx.get('tools');
514
541
  let disposeSkillOpt = () => {};
515
542
  try {
@@ -528,20 +555,25 @@ export function apply(ctx) {
528
555
  } catch (error) {
529
556
  console.warn('[ai-team] bundled SkillOpt tools failed:', error?.message ?? error);
530
557
  }
531
- const disposeTool = tools?.register
532
- ? tools.register(createTeamTool({
533
- getState: (exec) => runtimeForAgent(exec?.agent?.id)?.service.state
534
- ?? booted?.service.state
535
- ?? { projects: {}, members: {}, tasks: {}, threads: {}, inbox: {} },
536
- dispatch: (command, exec) => {
537
- const runtime = runtimeForAgent(exec?.agent?.id) ?? projectRuntime(command?.projectId) ?? null;
538
- if (runtime === null) return Promise.reject(new Error('no Project runtime'));
539
- return runtime.service.dispatch(command);
540
- },
541
- }), {
542
- when: (activation) => runtimeForAgent(activation?.agent?.id) !== null,
543
- })
544
- : () => {};
558
+ let disposeTool = () => {};
559
+ try {
560
+ disposeTool = tools?.register
561
+ ? tools.register(createTeamTool({
562
+ getState: (exec) => runtimeForAgent(exec?.agent?.id)?.service.state
563
+ ?? booted?.service.state
564
+ ?? { projects: {}, members: {}, tasks: {}, threads: {}, inbox: {} },
565
+ dispatch: (command, exec) => {
566
+ const runtime = runtimeForAgent(exec?.agent?.id) ?? projectRuntime(command?.projectId) ?? null;
567
+ if (runtime === null) return Promise.reject(new Error('no Project runtime'));
568
+ return runtime.service.dispatch(command);
569
+ },
570
+ }), {
571
+ when: (activation) => runtimeForAgent(activation?.agent?.id) !== null,
572
+ })
573
+ : () => {};
574
+ } catch (error) {
575
+ console.warn('[ai-team] team tool registration failed:', error?.message ?? error);
576
+ }
545
577
 
546
578
  const ensureParent = async () => {
547
579
  if (host !== null) return host;
@@ -553,6 +585,7 @@ export function apply(ctx) {
553
585
  agents: ctx.get('agents'),
554
586
  agentDefaultModel: ctx.get('agentDefaultModel'),
555
587
  workspaceRegistry: ctx.get('workspaceRegistry'),
588
+ sessions: ctx.get('sessions'),
556
589
  cwd: booted?.dataDir ?? process.cwd(),
557
590
  resumeSessionId: existingHost,
558
591
  }).then(async (value) => {
@@ -632,6 +665,7 @@ export function apply(ctx) {
632
665
  }
633
666
  activations.set(result.childId, result.activation);
634
667
  await attachMemberWorkspace(projectRuntime, result.childId);
668
+ persistModelSelection(result.childId, activationMember.config, member.name);
635
669
  return {
636
670
  ok: true,
637
671
  member: bound.member,
@@ -1062,16 +1096,24 @@ export function apply(ctx) {
1062
1096
  });
1063
1097
 
1064
1098
  return () => {
1099
+ // Teardown must fully settle before the loader activates the next
1100
+ // composition: a racing parent-agent dispose left the previous
1101
+ // session-controller graph half-disposed and broke plugin toggles.
1102
+ const cleanup = [];
1065
1103
  for (const client of sseClients) {
1066
1104
  try { client.res.end(); } catch { /* socket already gone */ }
1067
1105
  }
1068
1106
  sseClients.clear();
1069
1107
  if (pmoTimer !== null) { clearInterval(pmoTimer); pmoTimer = null; }
1070
1108
  for (const activation of activations.values()) {
1071
- try { activation.dispose?.().catch?.(() => {}); } catch { /* already gone */ }
1109
+ cleanup.push(Promise.resolve().then(async () => {
1110
+ try { await activation.dispose?.(); } catch { /* already gone */ }
1111
+ }));
1072
1112
  }
1073
1113
  activations.clear();
1074
- if (host !== null) void host.dispose?.();
1114
+ if (host !== null) cleanup.push(Promise.resolve().then(async () => {
1115
+ try { await host.dispose?.(); } catch { /* already gone */ }
1116
+ }));
1075
1117
  try { disposePermissionGuard(); } catch { /* already disposed */ }
1076
1118
  try { offLlmFault(); } catch { /* already disposed */ }
1077
1119
  try { disposeSkillProvider(); } catch { /* already disposed */ }
@@ -1080,7 +1122,12 @@ export function apply(ctx) {
1080
1122
  offSessionEvent();
1081
1123
  disposeTool();
1082
1124
  dispose();
1083
- for (const runtime of booted?.runtimes?.values() ?? []) runtime.close();
1125
+ for (const runtime of booted?.runtimes?.values() ?? []) {
1126
+ cleanup.push(Promise.resolve().then(async () => {
1127
+ try { await runtime.close(); } catch { /* ledger already closed */ }
1128
+ }));
1129
+ }
1130
+ return Promise.allSettled(cleanup).then(() => undefined);
1084
1131
  };
1085
1132
  }, 'ai-team: workbench routes');
1086
1133
  }
@@ -32,6 +32,18 @@ export const DEFAULT_MEMBER_ROSTER = Object.freeze([
32
32
  role: '编程',
33
33
  personality: '负责实现与工程化落地;先读核心纪律,拆分可验证小步,实测证据优先;与 PMO、QA 协同,不抢执行者的 claim。',
34
34
  },
35
+ {
36
+ id: 'mem_ux',
37
+ name: '知微',
38
+ role: 'UX 设计',
39
+ personality: '以用户体验为第一核心:研究目标产品的 UI/UE,从真实使用路径找摩擦点;每个改进意见都要落到可验证的交互设计与证据,不凭感觉改版。',
40
+ },
41
+ {
42
+ id: 'mem_biz',
43
+ name: '观澜',
44
+ role: '业务',
45
+ personality: '从运营/用户视角研究目标系统如何使用,洞察真实需求与使用场景;把需求转成可执行的 UX 改进意见,交 PMO 会议评审立项。',
46
+ },
35
47
  ]);
36
48
 
37
49
  /** Names shipped by 0.3.9 and earlier; only these exact pins are migrated. */
@@ -67,14 +79,38 @@ async function upgradeLegacyDefaultNames(service, projectId, humanId) {
67
79
 
68
80
  /**
69
81
  * Add the default roster to an empty Project and make the Lead its owner.
70
- * On an existing roster, only exact legacy default names are upgraded; custom
71
- * names and custom roles are never touched.
82
+ * On an existing roster, exact legacy default names are upgraded and any
83
+ * still-missing core-role member (UX/业务) is appended; custom names, custom
84
+ * roles and the user's own roster are never touched or duplicated.
72
85
  * @returns {Promise<{seeded: boolean, members: string[], renamed: string[]}>}
73
86
  */
74
87
  export async function seedDefaultRoster(service, projectId, { humanId = 'mem_human' } = {}) {
75
88
  if (agentMembers(service).length > 0) {
76
89
  const renamed = await upgradeLegacyDefaultNames(service, projectId, humanId);
77
- return { seeded: false, members: [], renamed };
90
+ const added = [];
91
+ const existingRoles = new Set(agentMembers(service).map((member) => member.role));
92
+ const existingIds = new Set(Object.keys(service.state.members ?? {}));
93
+ for (const member of DEFAULT_MEMBER_ROSTER) {
94
+ if (existingIds.has(member.id)) continue;
95
+ if (existingRoles.has(member.role)) continue;
96
+ await service.dispatch({
97
+ type: 'member.add',
98
+ actor: { kind: 'human', memberId: humanId },
99
+ projectId,
100
+ payload: {
101
+ id: member.id,
102
+ name: member.name,
103
+ role: member.role,
104
+ personality: member.personality,
105
+ kind: 'agent',
106
+ status: 'idle',
107
+ },
108
+ });
109
+ existingIds.add(member.id);
110
+ existingRoles.add(member.role);
111
+ added.push(member.id);
112
+ }
113
+ return { seeded: false, members: added, renamed };
78
114
  }
79
115
  const added = [];
80
116
  for (const member of DEFAULT_MEMBER_ROSTER) {
package/lib/host/waker.js CHANGED
@@ -74,6 +74,9 @@ function promptFor(reason, state, taskId) {
74
74
  if (reason === 'pmo_stall') {
75
75
  return `PMO 巡检:${title} 已长时间没有新进展。读 Thread 当前状态,继续推进或明确报告卡点;不要静默等待,也不要重复已完成的证据。`;
76
76
  }
77
+ if (reason === 'pmo_meeting') {
78
+ return 'PMO 会议进行中,你是正式参会成员。读取已完成 Task、Thread 与项目目标,从你的专业视角(UX/业务/执行/验收/编程)在 Thread 发表意见并 @owner;指出被忽略的用户体验、运营需求或风险,不重复他人结论,不自行开卡,不等待 Human。';
79
+ }
77
80
  if (reason === 'pmo_continue') {
78
81
  return 'PMO 自动推进:当前没有 active Task。先开一次复盘/头脑风暴/深度研究会议(读取已完成 Task、Thread 与核心 skill;在 Thread/@ 相关成员形成意见),据此自己产出验收标准与下一批 Task;resultDefinition 必须可验证,qaRequired 必须有 qaChecklist。不要等待 Human、不要只汇报、不要重复已完成卡。Human 只观测,所有需要决策的问题交 PMO 自动决策。';
79
82
  }
@@ -221,7 +224,17 @@ export function planWakes(state, result, actor = {}) {
221
224
  if (event?.type === 'pmo/continue') {
222
225
  const project = Object.values(state.projects ?? {})[0];
223
226
  const bucket = event.payload?.bucket ?? Math.floor(Date.now() / 600_000);
224
- add(project?.ownerMemberId, null, 'pmo_continue', `pmo:${project?.id ?? 'project'}:${bucket}`);
227
+ const ownerId = project?.ownerMemberId;
228
+ // PMO meetings include every agent member; the owner leads, everyone
229
+ // else contributes from their own professional seat.
230
+ for (const member of Object.values(state.members ?? {})) {
231
+ if (member.kind !== 'agent' || member.status === 'retired') continue;
232
+ if (member.id === ownerId) {
233
+ add(member.id, null, 'pmo_continue', `pmo:${project?.id ?? 'project'}:${bucket}`);
234
+ } else {
235
+ add(member.id, null, 'pmo_meeting', `pmo_meeting:${project?.id ?? 'project'}:${member.id}:${bucket}`);
236
+ }
237
+ }
225
238
  }
226
239
  if (event?.type === 'inbox/item-created') {
227
240
  add(event.payload?.item?.memberId, event.payload?.item?.ref?.taskId ?? null, 'inbox', `inbox:${event.payload?.item?.id ?? event.seq}`);
@@ -25,6 +25,7 @@ export class HostAgentError extends Error {
25
25
  * agents: any,
26
26
  * agentDefaultModel: any,
27
27
  * workspaceRegistry?: any,
28
+ * sessions?: any,
28
29
  * cwd: string,
29
30
  * newSessionId?: () => string
30
31
  * }} options
@@ -34,14 +35,31 @@ export async function ensureHostAgent(options) {
34
35
  if (agents === undefined || typeof agents.create !== 'function') {
35
36
  throw new HostAgentError('E_RUNTIME_UNAVAILABLE', 'agents service is unavailable');
36
37
  }
38
+ // Persist the resolved route into the session log. Live AgentOptions die
39
+ // with the process; without a recorded selection a restored session renders
40
+ // prompts with an unresolvable {{model}} variable.
41
+ const persistSelection = (sessionId, selection) => {
42
+ try {
43
+ const session = options.sessions?.get?.(sessionId);
44
+ if (session === undefined || session === null || typeof session.append !== 'function') return;
45
+ if (typeof selection?.provider !== 'string' || typeof selection?.model !== 'string') return;
46
+ session.append('model/selection', { provider: selection.provider, model: selection.model });
47
+ } catch (error) {
48
+ console.warn('[ai-team] host model selection persist failed:', error?.message ?? error);
49
+ }
50
+ };
37
51
  if (typeof options.resumeSessionId === 'string' && options.resumeSessionId !== '') {
38
52
  const live = typeof agents.get === 'function' ? agents.get(options.resumeSessionId) : undefined;
39
53
  if (live !== undefined) {
54
+ const selection = typeof options.agentDefaultModel?.currentSelection === 'function' ? options.agentDefaultModel.currentSelection() : null;
55
+ persistSelection(options.resumeSessionId, selection);
40
56
  return { agent: live, created: false, resumed: true, sessionId: options.resumeSessionId, dispose: async () => {} };
41
57
  }
42
58
  try {
43
59
  const handle = await agents.resume({ resumeSessionId: options.resumeSessionId });
44
60
  try { await options.workspaceRegistry?.archiveSession?.(options.resumeSessionId); } catch { /* cosmetic */ }
61
+ const selection = typeof options.agentDefaultModel?.currentSelection === 'function' ? options.agentDefaultModel.currentSelection() : null;
62
+ persistSelection(options.resumeSessionId, selection);
45
63
  return {
46
64
  agent: handle.agent,
47
65
  created: false,
@@ -83,6 +101,7 @@ export async function ensureHostAgent(options) {
83
101
  cause: error?.code ?? null,
84
102
  });
85
103
  }
104
+ persistSelection(sessionId, selection);
86
105
  const host = handle.agent;
87
106
  try {
88
107
  await options.workspaceRegistry?.archiveSession?.(sessionId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.3.52",
3
+ "version": "0.3.54",
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",