@suifei/dsh-ai-team 0.4.121 → 0.4.123

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,28 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.123 - 2026-11-17
4
+
5
+ **被 @ 的成员可以在主对话直接回一条**
6
+
7
+ - il2c 11-17 21:44 实机:Human 在「文渊阁·PMO」里「@tony老师 hi」,tony 老师被直接叫醒、也看到了图,
8
+ 可唤醒提示让他「用 team action=say 在主对话回复」,而 `say` 只许负责人用,被 `E_UNAUTHORIZED` 拒,只能请墨渊代发;
9
+ - 规则改为:Human 每 @ 一次,被 @ 的成员可在主对话回一条(`unansweredMention`),回完发言权收回;
10
+ 其余时候仍只有负责人在主对话说话;team 工具说明与点名唤醒提示同步改写;
11
+ - 测试:`test/pmo-voice.test.js` 补一例(回一次、再说被拒、未点名不给、下次点名再给、负责人照常);
12
+ 实机 E2E(rc.1 / rc.3):宿主会话 @青岚 → 青岚在主对话回「到」,无拒绝记录。
13
+
14
+ ## 0.4.122 - 2026-11-17
15
+
16
+ **DSH 标准会话里的 @ 也能点名成员**
17
+
18
+ - il2c 11-17 20:53 实机:在「【il2c】文渊阁·PMO」里用 DSH 输入框 @ 了 tony 老师,DSH 插入的是会话链接
19
+ `@[tony老师](dsh-session:…)`,0.4.121 只认「@名字」,账本没有 mentions,tony 老师没被直接叫醒(靠墨渊建卡转达);
20
+ 主对话里还露出一长串链接编码;
21
+ - `findMentions` 也认 DSH 会话链接:先按链接里的会话 id 对上成员,对不上再按链接里的名字;与普通 @ 混用按出现顺序;
22
+ - 主对话里把这种链接显示成「@名字」(`plainMentionLinks`);
23
+ - 测试:`test/rich-message.test.js` 用实机原文补两例;实机 E2E(rc.1 / rc.3):宿主会话发 `@[青岚](dsh-session:<青岚会话>)` →
24
+ 主对话显示「@青岚 …」、mentions 记下青岚、负责人与青岚各被唤醒一次。
25
+
3
26
  ## 0.4.121 - 2026-11-17
4
27
 
5
28
  **主对话支持图片、文件与 @成员;文渊阁对话框与 DSH 标准会话同一套**(#65)
@@ -27,6 +50,8 @@
27
50
  沿用角色、人格、运行配方、模型与推理档位、输出上限与技能;笔记、会话与任务不带(`copyMemberDraft`);
28
51
  - 测试:`test/client-composer-copy.test.js`(长高与封顶、拖动下限、复制草稿与命名、界面接线)。
29
52
 
53
+ ## 0.4.119 - 2026-11-17
54
+
30
55
  **在「文渊阁·PMO」会话里说话等于在文渊阁主对话里说话;宿主模型不再自己跑**
31
56
 
32
57
  - il2c 11-17 16:33:Human 在桌面版的「【il2c】文渊阁·PMO」会话里发「继续」。插件只认文渊阁主对话,账本没有 Human 消息,
@@ -65,17 +65,45 @@ export function findMentions(body, members) {
65
65
  if (typeof body !== 'string' || !body.includes('@')) return [];
66
66
  const roster = (Array.isArray(members) ? members : Object.values(members ?? {}))
67
67
  .filter((member) => member?.kind === 'agent' && member.status !== 'retired' && typeof member.name === 'string' && member.name.trim() !== '')
68
- .map((member) => ({ id: member.id, name: member.name.trim() }))
68
+ .map((member) => ({ id: member.id, name: member.name.trim(), sessionId: member.sessionId ?? null }))
69
69
  .sort((a, b) => b.name.length - a.name.length);
70
- const ids = [];
70
+ const hits = [];
71
+ // DSH 标准会话输入框的 @ 插入的是会话链接 `@[名字](dsh-session:<base64url 的 JSON 会话 id>)`
72
+ // (il2c 11-17 20:53 实机:「@[tony老师](dsh-session:…)」没叫醒 tony 老师)。先按会话 id 对上成员,对不上再按名字。
73
+ for (const match of body.matchAll(DSH_SESSION_MENTION)) {
74
+ const sessionId = decodeSessionRef(match[2]);
75
+ const byName = roster.find((member) => member.name === match[1].trim());
76
+ const bySession = sessionId === null ? undefined : roster.find((member) => member.sessionId === sessionId);
77
+ const hit = bySession ?? byName;
78
+ if (hit !== undefined) hits.push([match.index, hit.id]);
79
+ }
71
80
  for (let at = body.indexOf('@'); at !== -1; at = body.indexOf('@', at + 1)) {
72
81
  const rest = body.slice(at + 1);
73
82
  const hit = roster.find((member) => rest.startsWith(member.name));
74
- if (hit !== undefined && !ids.includes(hit.id)) ids.push(hit.id);
83
+ if (hit !== undefined) hits.push([at, hit.id]);
75
84
  }
85
+ const ids = [];
86
+ for (const [, id] of hits.sort((a, b) => a[0] - b[0])) if (!ids.includes(id)) ids.push(id);
76
87
  return ids;
77
88
  }
78
89
 
90
+ const DSH_SESSION_MENTION = /@\[([^\]\n]{1,64})\]\(dsh-session:([A-Za-z0-9_-]{4,400})\)/g;
91
+
92
+ /** `dsh-session:` 后面的引用 = base64url 编码的 JSON 字符串(会话 id);解不开返回 null。 */
93
+ function decodeSessionRef(ref) {
94
+ try {
95
+ const value = JSON.parse(Buffer.from(ref, 'base64url').toString('utf8'));
96
+ return typeof value === 'string' && value !== '' ? value : null;
97
+ } catch {
98
+ return null;
99
+ }
100
+ }
101
+
102
+ /** 主对话里把 DSH 会话链接显示成「@名字」(链接只对 DSH 自己的界面有意义,在文渊阁里是一串乱码)。 */
103
+ export function plainMentionLinks(body) {
104
+ return typeof body === 'string' ? body.replace(DSH_SESSION_MENTION, (_, name) => '@' + name.trim()) : body;
105
+ }
106
+
79
107
  /** 附件的一行文字说明(主对话摘要、提示词里给模型看清有几张图几个文件)。 */
80
108
  export function describeAttachments(attachments) {
81
109
  const list = Array.isArray(attachments) ? attachments : [];
@@ -92,3 +120,17 @@ export function messageContent(text, attachments) {
92
120
  const list = normalizeAttachments(attachments);
93
121
  return list.length === 0 ? text : [{ type: 'text', text }, ...list];
94
122
  }
123
+ /**
124
+ * Human 在主对话 @ 了这个成员、而成员还没在主对话回过话时,返回那条点名消息;否则 null。
125
+ * 主对话平时只有负责人发言;被点名的成员可以直接回这一次(il2c 11-17 21:44:tony 老师被 @ 后 say 被拒,只能请墨渊代发)。
126
+ * 每次点名只换一次发言:成员在点名之后发过一条,这次点名就算答过了。
127
+ */
128
+ export function unansweredMention(stream, memberId, projectId) {
129
+ const entries = (Array.isArray(stream) ? stream : []).filter((entry) => projectId === undefined || projectId === null || entry.projectId === undefined || entry.projectId === projectId);
130
+ let mention = null;
131
+ for (const entry of entries) {
132
+ if (entry.kind === 'human_message' && Array.isArray(entry.mentions) && entry.mentions.includes(memberId)) mention = entry;
133
+ else if (mention !== null && entry.authorId === memberId && entry.seq > mention.seq) mention = null;
134
+ }
135
+ return mention;
136
+ }
@@ -9,6 +9,7 @@
9
9
  */
10
10
  import { taskCard } from './views.js';
11
11
  import { isQaMember } from '../domain/member-profile.js';
12
+ import { unansweredMention } from '../domain/rich-message.js';
12
13
 
13
14
  const ACTIONS = ['tasks', 'members', 'inbox', 'recall', 'create', 'askHuman', 'member', 'evolve', 'distill', 'note', 'skill', 'claim', 'submit', 'thread', 'reply', 'accept', 'requestChanges', 'say'];
14
15
 
@@ -56,7 +57,7 @@ function rosterText(state) {
56
57
  export function createTeamTool(options) {
57
58
  return {
58
59
  name: 'team',
59
- description: 'Read and act on the AI Team board. The Project owner (the PMO) is the only member who speaks to Human in the Main stream, with action=say (optionally listing taskIds); everyone else talks in Task Threads. The Project owner can create tasks with action=create and must set resultDefinition and ownerId. Use members for the exact roster id/name/role; use tasks for ids/revisions. When Human must decide something, call askHuman with every question and options—do not bury questions in a report. Use recall to search your notes/skills and your past Tasks/Threads. Claim before working; read a Thread before replying; submit evidence before acceptance.',
60
+ description: 'Read and act on the AI Team board. The Project owner (the PMO) speaks to Human in the Main stream with action=say (optionally listing taskIds); a member whom Human @-mentioned there may answer that mention once with action=say; everyone else talks in Task Threads. The Project owner can create tasks with action=create and must set resultDefinition and ownerId. Use members for the exact roster id/name/role; use tasks for ids/revisions. When Human must decide something, call askHuman with every question and options—do not bury questions in a report. Use recall to search your notes/skills and your past Tasks/Threads. Claim before working; read a Thread before replying; submit evidence before acceptance.',
60
61
  parameters: {
61
62
  type: 'object',
62
63
  properties: {
@@ -314,7 +315,9 @@ export function createTeamTool(options) {
314
315
  if (args.action === 'say') {
315
316
  // 核心模型:只有项目 PMO 面向 Human 说话(主对话);成员在各自 Task Thread 里协作。
316
317
  const ownerId = state.projects?.[pid]?.ownerMemberId ?? state.projects?.[pid]?.ownerId;
317
- if (ownerId !== member.id) return failure({ code: 'E_UNAUTHORIZED', message: 'only the Project owner (PMO) speaks in the Main stream; use reply in the Task Thread instead' });
318
+ // #65:Human @ 了谁,谁就能在主对话直接回这一次点名(回完即收回);其余时候只有负责人说话。
319
+ const mentioned = ownerId === member.id ? null : unansweredMention(state.stream, member.id, pid);
320
+ if (ownerId !== member.id && mentioned === null) return failure({ code: 'E_UNAUTHORIZED', message: 'only the Project owner (PMO) speaks in the Main stream, or a member answering the Human message that @-mentioned it; use reply in the Task Thread instead' });
318
321
  if (typeof args.body !== 'string' || args.body.trim() === '') return failure({ code: 'E_INVALID_ARGUMENT', message: 'body is required' });
319
322
  const taskIds = Array.isArray(args.taskIds) ? args.taskIds.filter((id) => typeof id === 'string' && id !== '') : [];
320
323
  const result = await command('stream.post', { body: args.body, taskIds });
@@ -26,7 +26,7 @@ import { MEMBER_STATUS, isBoardIdle } from '../ledger/fold.js';
26
26
 
27
27
  const MEMBER_STATUS_VALUES = new Set(Object.values(MEMBER_STATUS));
28
28
  import { checkPersonality, isQaMember, unfinishedTasksFor } from '../domain/member-profile.js';
29
- import { describeAttachments, findMentions, normalizeAttachments } from '../domain/rich-message.js';
29
+ import { describeAttachments, findMentions, normalizeAttachments, plainMentionLinks } from '../domain/rich-message.js';
30
30
 
31
31
  function mentionsHuman(body) {
32
32
  return typeof body === 'string'
@@ -678,7 +678,8 @@ export class TeamService {
678
678
  const attachments = normalizeAttachments(payload.attachments);
679
679
  const typed = typeof payload.body === 'string' ? payload.body.trim() : '';
680
680
  if (typed === '' && attachments.length === 0) fail(ERRORS.INVALID_ARGUMENT, 'stream message body is required');
681
- const body = typed === '' ? describeAttachments(attachments) : typed;
681
+ // DSH 标准会话的 @ 是会话链接:@ 先按原文识别(链接里带会话 id),主对话里显示成「@名字」。
682
+ const body = typed === '' ? describeAttachments(attachments) : plainMentionLinks(typed);
682
683
  const author = this.state.members?.[command.actor.memberId];
683
684
  if (author === undefined) fail(ERRORS.UNAUTHORIZED, 'actor must be a Team member');
684
685
  // seq 由账本事件定(fold 用 event.seq;payload 里的幻影计数会被忽略,
@@ -690,7 +691,7 @@ export class TeamService {
690
691
  ? [...new Set(payload.taskIds.filter((id) => typeof id === 'string' && Object.hasOwn(this.state.tasks ?? {}, id)))]
691
692
  : [];
692
693
  // @成员只对 Human 的话生效(负责人照常收到,被点名者另行唤醒,见 waker)。
693
- const mentions = command.actor.kind === 'human' ? findMentions(body, this.state.members) : [];
694
+ const mentions = command.actor.kind === 'human' ? findMentions(typed, this.state.members) : [];
694
695
  const entry = {
695
696
  kind: command.actor.kind === 'human' ? 'human_message' : 'milestone',
696
697
  authorId: author.id,
package/lib/host/waker.js CHANGED
@@ -269,7 +269,7 @@ export function planWakes(state, result, actor = {}, options = {}) {
269
269
  null,
270
270
  'human_mention',
271
271
  `human_mention:${event.seq ?? event.payload?.seq}`,
272
- `Human 在主对话点名你:“${body.slice(0, 2000)}”。${attachmentNote}项目负责人(${ownerName})也收到了这句话并统筹安排。先读 tasks 与主对话,再从你的岗位回应:要说明的用 team action=say 在主对话回复 Human;需要建卡、改派的交给负责人,不要自己另开一摊。`,
272
+ `Human 在主对话点名你:“${body.slice(0, 2000)}”。${attachmentNote}项目负责人(${ownerName})也收到了这句话并统筹安排。先读 tasks 与主对话,再从你的岗位回应:用 team action=say 在主对话直接回复 Human(这次点名你可以回一条,回完发言权收回,想清楚再写全);需要建卡、改派的交给负责人,不要自己另开一摊。`,
273
273
  );
274
274
  }
275
275
  for (const plan of targets.values()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.121",
3
+ "version": "0.4.123",
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",