@suifei/dsh-ai-team 0.3.51 → 0.3.53

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,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.53 — 2026-11-10
4
+
5
+ 修复全新环境安装三连问题(严重):
6
+
7
+ - **`{{model}}` 无值**:成员/宿主 session 只把 provider/model 挂在活体 Agent options 上;进程重启后恢复的 session 两者皆无,prompt 渲染失败。现在 activation/wake/boot 都会把 `model/selection` 写入 session 日志,路由跨重启持久有效;
8
+ - **插件开关破坏宿主**:卸载清理此前是 fire-and-forget,旧组合未清理完新组合已激活。现在 disposer 完全等待宿主/激活/账本清理收尾,且绝不抛错;
9
+ - **首次安装即坏**:`boot()` 同步异常或 skill provider/team tool 注册异常会让组合激活失败。现在全部降级为警告,插件激活永不失败。
10
+
11
+ ## 0.3.52 — 2026-11-10
12
+
13
+ - bootstrap 返回全部 Task 的 Thread 映射,修复卡片显示 6 条回复但右栏打开为空的错位;
14
+ - 右栏标题改为「任务记录」,新增可展开的任务详情(结果定义、QA 进度、更新时间);
15
+ - 右栏「Agent 会话」直接打开该 Agent 的 DSH session,完整上下文不再在插件里重复;
16
+ - 左栏返回标签由「对话」改为「项目总览」,避免与任务 Thread 混淆。
17
+
3
18
  ## 0.3.51 — 2026-11-10
4
19
 
5
20
  - 唤醒后再同步一次 session 标题:cold session 在唤醒前无法 rename,唤醒变 live 后补同步;
package/client.js CHANGED
@@ -24,7 +24,7 @@ window.__ModuleLoader__.load({
24
24
 
25
25
  const zh = {
26
26
  panel: '文渊阁',
27
- back: '对话',
27
+ back: '项目总览',
28
28
  inbox: '收件箱',
29
29
  board: '任务看板',
30
30
  projects: '项目',
@@ -45,9 +45,13 @@ window.__ModuleLoader__.load({
45
45
  send: '发送',
46
46
  createTask: '创建 Task',
47
47
  enterHint: 'Ctrl/⌘ + Enter 发送',
48
- thread: '讨论',
49
- closeThread: '关闭讨论',
50
- threadChat: '对话',
48
+ thread: '任务记录',
49
+ closeThread: '关闭任务记录',
50
+ threadChat: 'Agent 会话',
51
+ taskDetail: '任务详情',
52
+ resultDefinition: '结果定义',
53
+ qaProgress: 'QA {done}/{total}',
54
+ updated: '更新',
51
55
  follow: '关注',
52
56
  unfollow: '取消关注',
53
57
  convert: '转为 Task',
@@ -130,7 +134,7 @@ window.__ModuleLoader__.load({
130
134
  expandDone: '展开全部',
131
135
  collapseDone: '收起',
132
136
  threadEmptyTitle: '还没有消息',
133
- threadEmptyBody: '先写下完成判据,再开始执行。',
137
+ threadEmptyBody: '还没有任务记录;可在下方回复,或打开 Agent 会话查看完整上下文。',
134
138
  acceptance: '验收',
135
139
  candidate: '候选验收',
136
140
  acceptEligible: '你从未认领过该任务,且不是执行者,所以可以由你验收。',
@@ -360,7 +364,7 @@ window.__ModuleLoader__.load({
360
364
  };
361
365
  const en = {
362
366
  panel: 'Wenyuan Pavilion',
363
- back: 'Chat',
367
+ back: 'Overview',
364
368
  inbox: 'Inbox',
365
369
  board: 'All tasks',
366
370
  projects: 'Projects',
@@ -381,9 +385,13 @@ window.__ModuleLoader__.load({
381
385
  send: 'Send',
382
386
  createTask: 'Create task',
383
387
  enterHint: 'Ctrl/⌘ + Enter to send',
384
- thread: 'Discussion',
385
- closeThread: 'Close discussion',
386
- threadChat: 'Chat',
388
+ thread: 'Task record',
389
+ closeThread: 'Close task record',
390
+ threadChat: 'Agent session',
391
+ taskDetail: 'Task details',
392
+ resultDefinition: 'Definition of done',
393
+ qaProgress: 'QA {done}/{total}',
394
+ updated: 'Updated',
387
395
  follow: 'Follow',
388
396
  unfollow: 'Unfollow',
389
397
  convert: 'Turn into task',
@@ -466,7 +474,7 @@ window.__ModuleLoader__.load({
466
474
  expandDone: 'Show all',
467
475
  collapseDone: 'Collapse',
468
476
  threadEmptyTitle: 'No messages yet',
469
- threadEmptyBody: 'Write the definition of done before starting.',
477
+ threadEmptyBody: 'No task record yet. Reply below, or open the Agent session for full context.',
470
478
  acceptance: 'Acceptance',
471
479
  candidate: 'Candidate',
472
480
  acceptEligible: 'You never claimed this task and are not its executor, so acceptance is yours.',
@@ -1252,6 +1260,9 @@ window.__ModuleLoader__.load({
1252
1260
  .at-iconbtn { width: 28px; padding: 0; }
1253
1261
  .at-rnote { flex: 0 0 auto; display: flex; align-items: flex-start; gap: 8px; margin: 8px 10px 0; padding: 6px 8px; border-left: 2px solid var(--dsw-alias-state-business-primary); border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-secondary); font-size: 11px; line-height: 16px; }
1254
1262
  .at-rbody { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 14px 12px; scrollbar-width: thin; scrollbar-color: var(--dsw-alias-scrollbar-bg-l1) transparent; }
1263
+ .at-taskdetail { margin: 10px 0 4px; border: 1px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-sm); background: var(--dsw-alias-bg-layer-2); }
1264
+ .at-taskdetailsum { padding: 8px 10px; cursor: pointer; color: var(--dsw-alias-label-secondary); font-size: 12px; font-weight: 500; line-height: 18px; }
1265
+ .at-taskdetailbody { display: flex; flex-direction: column; gap: 6px; padding: 0 10px 10px; }
1255
1266
  .at-tmsgs { display: flex; flex-direction: column; }
1256
1267
  .at-tmsg { padding: 10px 0; border-bottom: 1px solid var(--dsw-alias-border-l1); }
1257
1268
  .at-tmsg:last-child { border-bottom: 0; }
@@ -1972,6 +1983,23 @@ window.__ModuleLoader__.load({
1972
1983
  task.submission?.summary ? h('p', { className: 'at-donetext' }, task.submission.summary) : null);
1973
1984
  }
1974
1985
 
1986
+ function TaskDetail({ t, task }) {
1987
+ const qa = Array.isArray(task.qaChecklist) ? task.qaChecklist : [];
1988
+ const passed = Array.isArray(task.qaChecks) ? task.qaChecks.filter((item) => item.passed === true).length : 0;
1989
+ return h('details', { className: 'at-taskdetail', open: task.status !== 'done' },
1990
+ h('summary', { className: 'at-taskdetailsum' }, t('taskDetail')),
1991
+ h('div', { className: 'at-taskdetailbody' },
1992
+ h('div', { className: 'at-kv' },
1993
+ h('span', { className: 'at-kvlabel' }, t('resultDefinition')),
1994
+ h('div', { className: 'at-kvbody' }, task.resultDefinition || t('noSummary'))),
1995
+ qa.length > 0 ? h('div', { className: 'at-kv' },
1996
+ h('span', { className: 'at-kvlabel' }, t('qaChecklist')),
1997
+ h('div', { className: 'at-kvbody' }, tf(t, 'qaProgress', { done: passed, total: qa.length }) + ' · ' + qa.join(' / '))) : null,
1998
+ h('div', { className: 'at-kv' },
1999
+ h('span', { className: 'at-kvlabel' }, t('updated')),
2000
+ h('div', { className: 'at-kvbody' }, task.updatedAt ? fmtDateTime(task.updatedAt) : '—'))));
2001
+ }
2002
+
1975
2003
  function ThreadPanel({ t, task, thread, project, following, onToggleFollow, onClose, onChat, converting, convert, reply, onReplyChange, onReplySend, replyBase, onContinue, onContext, note, onDismissNote, acceptChecked, onAcceptChecked, qaChecks, onQaCheck, onAccept, onChanges, actions, panelRef, replyRef }) {
1976
2004
  const headSeq = thread?.headSeq ?? thread?.entries?.length ?? 0;
1977
2005
  const stale = replyBase !== null && replyBase !== undefined && headSeq > replyBase;
@@ -1992,7 +2020,7 @@ window.__ModuleLoader__.load({
1992
2020
  ? h(ConvertForm, { t, project, task, thread, title: convert.title, dod: convert.dod, onTitle: convert.onTitle, onDod: convert.onDod, onCancel: convert.onCancel, onSubmit: convert.onSubmit })
1993
2021
  : h('div', { className: 'at-rbody' },
1994
2022
  stale ? h(ConflictBanner, { t, thread, baseSeq: replyBase, headSeq, onContinue, onContext }) : null,
1995
- task.status === 'done' ? h(DoneSummary, { t, task }) : null,
2023
+ task.status === 'done' ? h(DoneSummary, { t, task }) : h(TaskDetail, { t, task }),
1996
2024
  entries.length
1997
2025
  ? h('div', { className: 'at-tmsgs' }, entries.map((message, index) => h('div', { key: message.seq ?? index, className: 'at-tmsg' },
1998
2026
  h('div', { className: 'at-tmh' },
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.51';
37
+ const VERSION = '0.3.53';
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
  }
@@ -126,6 +126,10 @@ export class TeamService {
126
126
  const stream = project === undefined ? [] : (state.stream ?? []).filter((entry) => entry.projectId === project.id);
127
127
  const selected = threadTaskId ?? tasks.find((task) => task.status === 'in_progress')?.id ?? tasks[0]?.id;
128
128
  const thread = selected === undefined ? null : (state.threads?.[selected] ?? { taskId: selected, headSeq: 0, entries: [] });
129
+ const threads = Object.fromEntries(tasks.map((task) => [
130
+ task.id,
131
+ state.threads?.[task.id] ?? { taskId: task.id, headSeq: 0, entries: [] },
132
+ ]));
129
133
  const inbox = Object.values(state.inbox ?? {}).filter((item) =>
130
134
  (item.memberId === state.humanMemberId || item.memberId === 'h1')
131
135
  && !isInformationalThreadMention(item));
@@ -137,6 +141,7 @@ export class TeamService {
137
141
  tasks,
138
142
  stream,
139
143
  thread,
144
+ threads,
140
145
  inbox,
141
146
  board: project === undefined ? null : this.board(project.id),
142
147
  quadrants: project === undefined ? null : this.quadrants(project.id),
@@ -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.51",
3
+ "version": "0.3.53",
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",