@suifei/dsh-ai-team 0.4.18 → 0.4.21

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/index.js CHANGED
@@ -52,7 +52,7 @@ export const name = 'ai-team';
52
52
  // 实际使用的服务(含可选服务:缺失时 serviceOf 回退 ctx.get 并返回 undefined)。
53
53
  export const inject = ['webServer', 'permissionPresets', 'sandboxPolicy', 'tools', 'shell', 'agents', 'subagents', 'sessions'];
54
54
 
55
- const VERSION = '0.4.18';
55
+ const VERSION = '0.4.21';
56
56
  const HUMAN_ID = 'mem_human';
57
57
 
58
58
  const SKILLOPT_BACKENDS = ['mock', 'claude', 'codex', 'copilot', 'cursor', 'pi', 'opencode', 'handoff', 'azure_openai'];
@@ -381,6 +381,27 @@ export function apply(ctx, config = {}) {
381
381
  return { kind: 'retry' };
382
382
  })
383
383
  : () => {};
384
+ // 诊断:记录每个新建 agent(含成员)可见的工具名与 preset,
385
+ // 用于判定「成员是否能调用插件注册的 team 工具」(SDK:工具默认继承,
386
+ // 仅 ctx.tools.restrict() 会移除)。
387
+ const offAgentCreated = typeof ctx.on === 'function'
388
+ ? ctx.on('agent/created', (agent) => {
389
+ try {
390
+ const names = (agent?.ctx?.tools?.definitions?.() ?? []).map((definition) => definition.name);
391
+ diag.append({
392
+ ev: 'agent.created.probe.fail',
393
+ agentId: agent?.id ?? null,
394
+ parentId: agent?.meta?.parentSession ?? null,
395
+ toolCount: names.length,
396
+ hasTeam: names.includes('team'),
397
+ preset: agent?.meta?.agentPreset ?? agent?.meta?.preset ?? null,
398
+ names: names.slice(0, 40),
399
+ });
400
+ } catch (error) {
401
+ diag.append({ ev: 'agent.created.probe.fail', error: error?.message ?? String(error) });
402
+ }
403
+ })
404
+ : () => {};
384
405
  const offSessionEvent = typeof ctx.on === 'function'
385
406
  ? ctx.on('session/event', async (session, event) => {
386
407
  if (booted === null || event?.type !== 'turn/end') return;
@@ -1859,6 +1880,8 @@ export function apply(ctx, config = {}) {
1859
1880
  : '会话已重建(成员恢复)。先读 tasks/thread 当前状态,继续推进;不要重复已完成的工作。',
1860
1881
  },
1861
1882
  }, runtime);
1883
+ // reseat 后旧会话不再使用:清掉选择日志缓存,避免随重建累积(泄漏)。
1884
+ if (before !== null) modelSelectionLogged.delete(before);
1862
1885
  results.push({
1863
1886
  memberId,
1864
1887
  ok: activated.error === undefined,
@@ -1944,6 +1967,7 @@ export function apply(ctx, config = {}) {
1944
1967
  try { disposeSkillOpt(); } catch { /* already disposed */ }
1945
1968
  offRequestError();
1946
1969
  offSessionEvent();
1970
+ offAgentCreated();
1947
1971
  disposeTool();
1948
1972
  dispose();
1949
1973
  for (const runtime of booted?.runtimes?.values() ?? []) {
@@ -52,7 +52,7 @@ export async function startReview({ service, projectRuntime, job, actor, votes }
52
52
  const orders = [];
53
53
  for (let index = 0; index < count; index++) {
54
54
  const order = Math.random() < 0.5 ? 'ab' : 'ba';
55
- const body = buildReviewRequest({ before: job.before, after: job.candidate, order, jobId: job.id });
55
+ const body = buildReviewRequest({ before: job.before, after: job.candidate, order, jobId: job.id, taskId: reviewTaskId, baseSeq: 0 });
56
56
  await service.dispatch({
57
57
  type: 'member.message',
58
58
  payload: { memberId: reviewer.id, body },
@@ -13,10 +13,12 @@ export const REVIEWER_ROLE = '评审';
13
13
  export const REVIEWER_NAME = '评审官';
14
14
 
15
15
  /** 评审 prompt(盲评两版,输出一行 JSON)。 */
16
- export function buildReviewRequest({ before, after, order, jobId }) {
16
+ export function buildReviewRequest({ before, after, order, jobId, taskId, baseSeq = 0 }) {
17
17
  const aIsAfter = order === 'ba';
18
18
  const versionA = aIsAfter ? after : before;
19
19
  const versionB = aIsAfter ? before : after;
20
+ const card = typeof taskId === 'string' && taskId !== '' ? taskId : '<taskId>';
21
+ const verdict = '{"better":"A","margin":"clear","reason":"一句话理由"}';
20
22
  return [
21
23
  `【技能盲评 ${jobId}】你是独立评审。只做比较,不要修改任何文件。`,
22
24
  '',
@@ -30,9 +32,13 @@ export function buildReviewRequest({ before, after, order, jobId }) {
30
32
  '## 版本 B',
31
33
  versionB,
32
34
  '',
33
- '用 team 工具把结果作为一条 thread 回复发到本评审卡:',
34
- '{"better":"A"|"B"|"tie","margin":"clear"|"slight","reason":"一句话理由"}',
35
- '只发这一行 JSON,不要其它内容。',
35
+ '## 如何提交结论(必须用 team 工具,两步)',
36
+ '1) 读取评审卡当前 headSeq:调用 team 工具',
37
+ ` {"action":"thread","taskId":"${card}"}`,
38
+ '2) 用拿到的 headSeq 回帖(body 里只放一行 JSON):',
39
+ ` {"action":"reply","taskId":"${card}","baseSeq":${baseSeq},"body":"${verdict.replace(/"/g, '\\"')}"}`,
40
+ `注意:action 必须是 "reply"(不是 thread.post),参数名是 taskId / baseSeq / body;初始 baseSeq 通常为 ${baseSeq},若第 1 步返回的 headSeq 不同,用返回的 headSeq。`,
41
+ '除这次 team 回帖外不要做其它动作。',
36
42
  ].join('\n');
37
43
  }
38
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.18",
3
+ "version": "0.4.21",
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",