@suifei/dsh-ai-team 0.3.67 → 0.3.69

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.69 — 2026-11-11
4
+
5
+ 用户实证问题批(docs/phase1-2026-11-10/15-问题清单):
6
+
7
+ - **空项目不再被 PMO 自动开工**:`pmo/continue` 加门——从未有过任务的项目等待 Human 首条指令(新装用户配置目录后不再被自动建卡);
8
+ - **批量取消**:「团队动态」分区新增「取消全部待处理(n)」按钮(逐卡 task.cancel + 成功/失败汇总),免去逐卡点开;
9
+ - **会话标题加项目前缀**:`【项目名】成员名(角色)`——多项目同名成员在 DSH 侧栏可区分;
10
+ - **项目归档(软删)**:新命令 `project.archive`(Human-only,账本留痕)+ 项目头「归档项目」按钮:bootstrap 过滤 archived 项目,成员 DSH 会话不受影响;最后一个 active 项目不可归档;
11
+ - 问题清单与 P2(人员池批量模型配置)/P5(direct-subagent 取证)计划见 docs/phase1-2026-11-10/15。
12
+
13
+ ## 0.3.68 — 2026-11-11
14
+
15
+ - **【致命】取消任务对话框卡死修复(用户实证三连)**:①根因是 `WorkbenchDialog` 挂载处**漏传 `onDismiss` prop**——settle/cancel 调用 `onDismiss()` 抛 TypeError,`setDialog(null)` 永不执行,对话框永久驻留无法关闭;②「确定没反应」实为 resolve 已执行(任务在后台真实取消)但关框崩溃吞掉了全部反馈;③「理由可留空」的提示与确定按钮禁用矛盾,且 host 域层 `cancelTask/reopenTask` 的 `requireText(reason)` 也强制必填——三层各自为政。现修复:挂载处显式传 `onDismiss: () => setDialog(null)`;settle 先关框后 resolve(后续异步不再阻断);对话框新增 `optional` 语义(理由类输入允许留空);domain 层 cancel/reopen 理由改 `optionalText`(留空记空串,超长边界保留)。新增 cancel/reason 链路测试 2 项(138 总)。
16
+
3
17
  ## 0.3.67 — 2026-11-11
4
18
 
5
19
  - review 整改:PMO tick 的 prune 数组补入 `pmoLastDispatch`——补派节流时钟的任务条目在离开 active 集后随其余四个时钟一并清理,消除慢性 Map 增长(与 0.3.57 同类问题的复发面闭合)。
package/client.js CHANGED
@@ -222,6 +222,14 @@ window.__ModuleLoader__.load({
222
222
  chatGateOpened: 'Human 对话通道已开启:私信将直达成员下一轮。',
223
223
  chatGateClosedShort: 'Human 对话通道已关闭。',
224
224
  routingHint: '成员的原生会话由团队路由驱动,宿主不接受直接输入;请用下方私信与成员对话(下一轮生效)。',
225
+ cancelAllPending: '取消全部待处理({n})',
226
+ cancelAllHint: '批量取消当前全部待处理任务(逐卡取消并汇总结果)',
227
+ cancelAllDone: '批量取消完成:成功 {done} 个,失败 {failed} 个。',
228
+ working: '处理中…',
229
+ archiveProject: '归档项目',
230
+ archiveHint: '归档当前项目(从工作台移除;账本保留,DSH 会话不受影响)',
231
+ archiveConfirmTitle: '归档项目',
232
+ archiveConfirmBody: '将「{name}」从工作台归档移除?账本保留、成员 DSH 会话不受影响。',
225
233
  pmoEnabled: 'PMO 自动已开启。',
226
234
  pmoDisabled: 'PMO 自动已关闭,决策回到收件箱。',
227
235
  notifyTaskCreated: '新 Task 已创建',
@@ -619,6 +627,14 @@ window.__ModuleLoader__.load({
619
627
  chatGateOpened: 'Human chat channel opened: DMs reach members next round.',
620
628
  chatGateClosedShort: 'Human chat channel closed.',
621
629
  routingHint: 'Member native sessions are driven by team routing; the host rejects direct input. Use the DM below to talk to a member (effective next round).',
630
+ cancelAllPending: 'Cancel all pending ({n})',
631
+ cancelAllHint: 'Batch-cancel every pending task (one by one, with a summary)',
632
+ cancelAllDone: 'Batch cancel done: {done} ok, {failed} failed.',
633
+ working: 'Working…',
634
+ archiveProject: 'Archive project',
635
+ archiveHint: 'Archive this project (removed from the workbench; ledger kept, DSH sessions unaffected)',
636
+ archiveConfirmTitle: 'Archive project',
637
+ archiveConfirmBody: 'Archive "{name}" and remove it from the workbench? The ledger is kept and member DSH sessions are unaffected.',
622
638
  pmoEnabled: 'PMO auto enabled.',
623
639
  pmoDisabled: 'PMO auto disabled; decisions go back to the inbox.',
624
640
  notifyTaskCreated: 'New Task created',
@@ -1613,12 +1629,14 @@ window.__ModuleLoader__.load({
1613
1629
  function WorkbenchDialog({ t, dialog, onDismiss }) {
1614
1630
  const [value, setValue] = React.useState(dialog.value ?? '');
1615
1631
  const settle = (result) => {
1616
- dialog.resolve(result);
1632
+ // 先关框再 resolve:resolve 触发的后续异步命令不应阻断关框。
1617
1633
  onDismiss();
1634
+ dialog.resolve(result);
1618
1635
  };
1619
1636
  const cancel = () => settle(dialog.mode === 'confirm' ? false : null);
1620
1637
  const submit = () => settle(dialog.mode === 'confirm' ? true : value.trim());
1621
- const canSubmit = dialog.mode === 'confirm' || value.trim() !== '';
1638
+ // optional 语义:理由类输入允许留空(placeholder 已声明「可留空」)。
1639
+ const canSubmit = dialog.mode === 'confirm' || dialog.optional === true || value.trim() !== '';
1622
1640
  return h(ModalBack, { onClose: cancel },
1623
1641
  h('div', {
1624
1642
  className: 'at-modal',
@@ -1804,8 +1822,9 @@ window.__ModuleLoader__.load({
1804
1822
  }, '⋯'));
1805
1823
  }
1806
1824
 
1807
- function TeamPulse({ t, agents, tasks, onOpen }) {
1825
+ function TeamPulse({ t, agents, tasks, onOpen, onCancelAllPending, cancelBusy }) {
1808
1826
  const active = tasks.filter((task) => ['pending', 'in_progress', 'pending_acceptance'].includes(task.status)).slice(-5);
1827
+ const pendingTasks = tasks.filter((task) => task.status === 'pending');
1809
1828
  const running = agents.filter((agent) => agent.status === 'running');
1810
1829
  const starting = active.length === 0 && tasks.length === 0 && running.length > 0;
1811
1830
  if (active.length === 0 && !starting) return null;
@@ -1819,7 +1838,11 @@ window.__ModuleLoader__.load({
1819
1838
  return h('section', { className: 'at-teampulse', 'aria-label': t('teamPulseTitle') },
1820
1839
  h('div', { className: 'at-teampulsehead' },
1821
1840
  h('span', { className: 'at-teampulsetitle' }, t('teamPulseTitle')),
1822
- h('span', { className: 'at-teampulsecount' }, summary || t('teamPulseWorking'))),
1841
+ h('span', { className: 'at-teampulsecount' }, summary || t('teamPulseWorking')),
1842
+ // P1b:批量取消——Human 无需逐卡点开(用户实证的取消体验痛点)。
1843
+ pendingTasks.length > 0 && onCancelAllPending
1844
+ ? h('button', { className: 'at-btn at-btn-small', type: 'button', onClick: () => onCancelAllPending(pendingTasks), disabled: cancelBusy === true, title: t('cancelAllHint') }, cancelBusy ? t('working') : tf(t, 'cancelAllPending', { n: pendingTasks.length }))
1845
+ : null),
1823
1846
  active.length
1824
1847
  ? h('div', { className: 'at-teampulselist' }, active.map((task) => h('button', {
1825
1848
  key: task.id,
@@ -2601,7 +2624,7 @@ window.__ModuleLoader__.load({
2601
2624
  dialogSeqRef.current += 1;
2602
2625
  setDialog({ mode: 'confirm', title, body, resolve });
2603
2626
  });
2604
- const askPrompt = (title, { placeholder = '', value = '', options = null } = {}) => new Promise((resolve) => {
2627
+ const askPrompt = (title, { placeholder = '', value = '', options = null, optional = false } = {}) => new Promise((resolve) => {
2605
2628
  dialogSeqRef.current += 1;
2606
2629
  setDialog({
2607
2630
  mode: options === null ? 'prompt' : 'choice',
@@ -2609,6 +2632,7 @@ window.__ModuleLoader__.load({
2609
2632
  placeholder,
2610
2633
  value: value ?? (options && options.length > 0 ? options[0] : ''),
2611
2634
  options,
2635
+ optional,
2612
2636
  resolve,
2613
2637
  });
2614
2638
  });
@@ -2840,6 +2864,37 @@ window.__ModuleLoader__.load({
2840
2864
  const selectedTask = tasks.find((task) => task.id === selected) ?? tasks[0] ?? null;
2841
2865
  const thread = threadFor(data, selectedTask?.id);
2842
2866
  const quadrants = deriveQuadrants(data);
2867
+ // P1b:批量取消全部待处理(逐卡 task.cancel,Human-only;汇总结果)。
2868
+ const [cancelAllBusy, setCancelAllBusy] = React.useState(false);
2869
+ async function cancelAllPending(pendingTasks) {
2870
+ if (!Array.isArray(pendingTasks) || pendingTasks.length === 0) return;
2871
+ setCancelAllBusy(true);
2872
+ let done = 0; let failed = 0;
2873
+ try {
2874
+ for (const task of pendingTasks) {
2875
+ try {
2876
+ await runCommand('task.cancel', { taskId: task.id, expectedRevision: task.revision, reason: t('cancelAllHint') });
2877
+ done += 1;
2878
+ } catch { failed += 1; }
2879
+ }
2880
+ sayRight(tf(t, 'cancelAllDone', { done, failed }));
2881
+ await reloadData();
2882
+ } finally {
2883
+ setCancelAllBusy(false);
2884
+ }
2885
+ }
2886
+ async function archiveCurrentProject() {
2887
+ if (!project) return;
2888
+ const answer = await askConfirm(t('archiveConfirmTitle'), tf(t, 'archiveConfirmBody', { name: project.name }));
2889
+ if (answer !== true) return;
2890
+ try {
2891
+ await runCommand('project.archive', { archived: true });
2892
+ say(t('archiveDone'));
2893
+ await reloadData();
2894
+ } catch (error) {
2895
+ sayRight(tf(t, 'sendFailed', { message: error?.message ?? String(error) }));
2896
+ }
2897
+ }
2843
2898
  const inboxItems = (data.inbox ?? []).filter((item) => !isInformationalInboxItem(item));
2844
2899
  // R-13bis:Human↔成员对话门(项目级开关,账本留痕)。
2845
2900
  const chatGateClosed = (project?.chatGate ?? 'open') === 'closed';
@@ -3641,7 +3696,7 @@ window.__ModuleLoader__.load({
3641
3696
  }
3642
3697
  async function cancelSelected() {
3643
3698
  if (!selectedTask) return;
3644
- const reason = await askPrompt(t('cancelPrompt'));
3699
+ const reason = await askPrompt(t('cancelPrompt'), { optional: true });
3645
3700
  if (reason === null) return;
3646
3701
  try {
3647
3702
  await runCommand('task.cancel', { taskId: selectedTask.id, expectedRevision: selectedTask.revision, reason });
@@ -3653,7 +3708,7 @@ window.__ModuleLoader__.load({
3653
3708
  }
3654
3709
  async function reopenSelected() {
3655
3710
  if (!selectedTask) return;
3656
- const reason = await askPrompt(t('reopenPrompt'));
3711
+ const reason = await askPrompt(t('reopenPrompt'), { optional: true });
3657
3712
  if (reason === null) return;
3658
3713
  try {
3659
3714
  await runCommand('task.reopen', { taskId: selectedTask.id, expectedRevision: selectedTask.revision, reason });
@@ -3860,7 +3915,7 @@ window.__ModuleLoader__.load({
3860
3915
  ? h(Situation, { t, quadrants, tasks, onItem: openQuadrantItem, onViewAll: viewQuadrant })
3861
3916
  : h('div', { className: 'at-stream', role: 'tabpanel', id: 'at-panel-main', 'aria-labelledby': 'at-tab-main' },
3862
3917
  h('div', { className: 'at-streaminner', role: 'log', 'aria-live': 'polite', 'aria-label': t('streamAria') },
3863
- h(TeamPulse, { t, agents: data.agents, tasks, onOpen: openTask }),
3918
+ h(TeamPulse, { t, agents: data.agents, tasks, onOpen: openTask, onCancelAllPending: cancelAllPending, cancelBusy: cancelAllBusy }),
3864
3919
  data.stream.length
3865
3920
  ? data.stream.map((item) => h(StreamMessage, {
3866
3921
  key: item.id,
@@ -3916,7 +3971,13 @@ window.__ModuleLoader__.load({
3916
3971
  title: t('chatGateHint'),
3917
3972
  'aria-pressed': !chatGateClosed,
3918
3973
  onClick: () => { void toggleChatGate(); },
3919
- }, !chatGateClosed ? t('chatGateOn') : t('chatGateOff'))) : null,
3974
+ }, !chatGateClosed ? t('chatGateOn') : t('chatGateOff'),
3975
+ h('button', {
3976
+ className: 'at-workspacebtn',
3977
+ type: 'button',
3978
+ title: t('archiveHint'),
3979
+ onClick: () => { void archiveCurrentProject(); },
3980
+ }, t('archiveProject')))) : null,
3920
3981
  inInbox || inPeople ? null : h('div', { className: 'at-tabs', role: 'tablist', 'aria-label': t('tabsAria'), onKeyDown: tabKeyDown },
3921
3982
  h('button', {
3922
3983
  className: cx('at-tab', tab === 'main' && 'at-on'),
@@ -4171,7 +4232,7 @@ window.__ModuleLoader__.load({
4171
4232
  h('div', { className: 'at-modalactions' },
4172
4233
  h('button', { className: 'at-btn', type: 'button', onClick: () => setNewOpen(false), disabled: nBusy }, t('cancel')),
4173
4234
  h('button', { className: 'at-btn at-btn-primary', type: 'submit', disabled: nBusy || !nName.trim() || !nWorkspace.trim() }, nBusy ? t('saving') : t('projectCreate'))))) : null,
4174
- dialog ? h(WorkbenchDialog, { key: dialogSeqRef.current, t, dialog }) : null,
4235
+ dialog ? h(WorkbenchDialog, { key: dialogSeqRef.current, t, dialog, onDismiss: () => setDialog(null) }) : null,
4175
4236
  shortcutsOpen ? h(ModalBack, { onClose: () => setShortcutsOpen(false) },
4176
4237
  h('div', { className: 'at-modal', role: 'dialog', 'aria-modal': 'true', 'aria-label': t('shortcutTitle') },
4177
4238
  h('h2', { className: 'at-modaltitle' }, t('shortcutTitle')),
package/index.js CHANGED
@@ -41,7 +41,7 @@ export const name = 'ai-team';
41
41
  /** The workbench only makes sense where the Web carrier exists. */
42
42
  export const inject = ['webServer', 'permissionPresets', 'sandboxPolicy'];
43
43
 
44
- const VERSION = '0.3.67';
44
+ const VERSION = '0.3.69';
45
45
  const PROJECT_ID = 'prj_main';
46
46
  const HUMAN_ID = 'mem_human';
47
47
 
@@ -192,14 +192,16 @@ export function apply(ctx, config = {}) {
192
192
  return null;
193
193
  }
194
194
  };
195
- const memberSessionTitle = (member) => `${member?.name ?? 'Agent'}(${member?.role ?? 'Agent'})`.trim().slice(0, 120);
195
+ // 会话标题带项目前缀:多项目同名成员在 DSH 侧栏无法区分(用户实证)。
196
+ const memberSessionTitle = (member, projectName) => `${projectName ? '【' + projectName + '】' : ''}${member?.name ?? 'Agent'}(${member?.role ?? 'Agent'})`.trim().slice(0, 120);
197
+ const projectNameOf = (projectRuntime) => projectRuntime?.service?.state?.projects?.[projectRuntime?.id]?.name ?? '';
196
198
  const titleMemberSession = async (projectRuntime, member) => {
197
199
  if (member === undefined) return;
198
200
  const sessions = ctx.get('sessions');
199
201
  const titleService = ctx.get('sessionTitle');
200
202
  const session = sessions?.get?.(member.sessionId);
201
203
  if (session === undefined || session === null || typeof titleService?.rename !== 'function') return;
202
- const title = memberSessionTitle(member);
204
+ const title = memberSessionTitle(member, projectNameOf(projectRuntime));
203
205
  try {
204
206
  if (typeof titleService.get === 'function' && titleService.get(session)?.title === title) return;
205
207
  titleService.rename(session, title);
@@ -606,6 +608,11 @@ export function apply(ctx, config = {}) {
606
608
  }
607
609
  return;
608
610
  }
611
+ // P1:空项目(从未有过任何任务)不自动开工——新装用户配置完目录后
612
+ // 被 PMO 自动建卡(用户实证:5 张卡违背「等我指令」预期)。等待
613
+ // Human 首条指令(human_message → PMO 建卡链路保持不变)。
614
+ const hasAnyTaskHistory = Object.keys(state.tasks ?? {}).length > 0;
615
+ if (!hasAnyTaskHistory) return;
609
616
  const last = pmoLastKick.get(projectRuntime.id) ?? 0;
610
617
  if (now - last < 10 * 60_000) return;
611
618
  pmoLastKick.set(projectRuntime.id, now);
@@ -40,6 +40,14 @@ const requireText = (value, field, max = 16_384) => {
40
40
  return value.trim();
41
41
  };
42
42
 
43
+ // 理由类可选文本:留空/缺省返回空串(事件里统一为 '',不缺字段)。
44
+ const optionalText = (value, field, max = 16_384) => {
45
+ if (value === undefined || value === null) return '';
46
+ if (typeof value !== 'string') fail(ERRORS.INVALID_ARGUMENT, `${field} must be a string`);
47
+ if (value.length > max) fail(ERRORS.INVALID_ARGUMENT, `${field} is too long (max ${String(max)})`);
48
+ return value.trim();
49
+ };
50
+
43
51
  const next = (task, patch) => ({ ...task, ...patch, revision: task.revision + 1 });
44
52
 
45
53
  /**
@@ -254,7 +262,7 @@ export function cancelTask(task, actor, options = {}) {
254
262
  if (task.status === 'cancelled' || task.tombstone === true) {
255
263
  fail(ERRORS.INVALID_STATE, 'task is already terminal');
256
264
  }
257
- const reason = requireText(options.reason, 'reason', 2_000);
265
+ const reason = optionalText(options.reason, 'reason', 2_000);
258
266
  const updated = next(task, { status: 'cancelled', updatedAt: options.at ?? Date.now() });
259
267
  return {
260
268
  task: updated,
@@ -269,7 +277,7 @@ export function reopenTask(task, actor, options = {}) {
269
277
  if (task.status !== 'done' && task.status !== 'pending_acceptance') {
270
278
  fail(ERRORS.INVALID_STATE, 'only done or pending_acceptance tasks can be reopened');
271
279
  }
272
- const reason = requireText(options.reason, 'reason', 2_000);
280
+ const reason = optionalText(options.reason, 'reason', 2_000);
273
281
  const assignee = task.assigneeId === null ? null : options.members?.[task.assigneeId] ?? null;
274
282
  const assigneeInvalid =
275
283
  assignee !== null && (assignee.status === 'retired' || assignee.status === 'unavailable' || assignee.status === 'failed');
@@ -81,10 +81,12 @@ export class TeamService {
81
81
  /** One page of workbench state; the UI reads this instead of the ledger. */
82
82
  bootstrap(projectId, threadTaskId) {
83
83
  const state = this.state;
84
- const projects = Object.values(state.projects ?? {}).map((p) => ({
85
- id: p.id, name: p.name, goal: p.goal ?? '', owner: p.ownerName ?? p.ownerMemberId ?? p.ownerId, workspacePath: p.workspacePath ?? '', pmoAuto: p.pmoAuto !== false, active: p.status !== 'archived',
86
- chatGate: p.chatGate === 'closed' ? 'closed' : 'open',
87
- }));
84
+ const projects = Object.values(state.projects ?? {})
85
+ .filter((p) => p.status !== 'archived')
86
+ .map((p) => ({
87
+ id: p.id, name: p.name, goal: p.goal ?? '', owner: p.ownerName ?? p.ownerMemberId ?? p.ownerId, workspacePath: p.workspacePath ?? '', pmoAuto: p.pmoAuto !== false, active: p.status !== 'archived',
88
+ chatGate: p.chatGate === 'closed' ? 'closed' : 'open',
89
+ }));
88
90
  const members = Object.values(state.members ?? {}).map((m) => ({
89
91
  id: m.id,
90
92
  name: m.name,
@@ -276,6 +278,7 @@ export class TeamService {
276
278
  case 'project.workspace.update': return await this.changeProjectWorkspace(command, payload);
277
279
  case 'project.pmo.update': return await this.setProjectPmo(command, payload);
278
280
  case 'project.chatGate': return await this.setProjectChatGate(command, payload);
281
+ case 'project.archive': return await this.setProjectArchive(command, payload);
279
282
  case 'stream.post': return await this.postStream(command, payload);
280
283
  case 'member.add': return await this.addMember(command, payload);
281
284
  case 'member.bind': return await this.bindMemberSession(command, payload);
@@ -397,6 +400,23 @@ export class TeamService {
397
400
  return { project: { ...project, chatGate: gate } };
398
401
  }
399
402
 
403
+ // P4:项目归档(软删)——账本 append-only 纪律下不可物理删除;archived
404
+ // 项目从工作台消失(bootstrap 过滤),成员的 DSH 会话不受影响。
405
+ async setProjectArchive(command, payload) {
406
+ const projectId = command.projectId;
407
+ const project = this.state.projects?.[projectId];
408
+ if (project === undefined) fail(ERRORS.NOT_FOUND, `project ${String(projectId)} not found`);
409
+ const archived = payload.archived !== false;
410
+ if (command.actor.kind !== 'human') fail(ERRORS.UNAUTHORIZED, 'only Human may archive a project');
411
+ if (archived === false && project.status === 'archived') fail(ERRORS.INVALID_STATE, 'archived projects cannot be un-archived in this version');
412
+ const active = Object.values(this.state.projects ?? {}).filter((p) => p.status !== 'archived');
413
+ if (archived && active.length <= 1 && active[0]?.id === projectId) {
414
+ fail(ERRORS.INVALID_STATE, 'cannot archive the last active project');
415
+ }
416
+ await this.append(command, 'project/archived', { projectId, archived, reason: payload.reason ?? '' });
417
+ return { project: { ...project, status: archived ? 'archived' : 'active' } };
418
+ }
419
+
400
420
  async setProjectPmo(command, payload) { const projectId = command.projectId;
401
421
  const project = this.state.projects?.[projectId];
402
422
  if (project === undefined) fail(ERRORS.NOT_FOUND, `project ${String(projectId)} not found`);
@@ -686,6 +686,18 @@ export function applyEvent(state, event) {
686
686
  });
687
687
  }
688
688
 
689
+ case 'project/archived': {
690
+ const projectId = textOr(payload.projectId, event.projectId);
691
+ const project = state.projects?.[projectId];
692
+ if (project === undefined || payload.archived !== true) return advance(state, event);
693
+ return advance(state, event, {
694
+ projects: {
695
+ ...state.projects,
696
+ [projectId]: { ...project, status: 'archived', archivedAt: event.at },
697
+ },
698
+ });
699
+ }
700
+
689
701
  case 'project/workspace-changed': {
690
702
  const projectId = textOr(payload.projectId, event.projectId);
691
703
  const workspacePath = textOr(payload.workspacePath, null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.3.67",
3
+ "version": "0.3.69",
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",