@suifei/dsh-ai-team 0.3.78 → 0.3.80
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 +11 -0
- package/client.js +3 -2
- package/index.js +34 -1
- package/lib/host/chat-gate-sync.js +38 -0
- package/lib/host/service.js +8 -1
- package/lib/runtime/member-runtime.js +10 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.80 - 2026-11-12
|
|
4
|
+
|
|
5
|
+
- **chatGate 自动收敛(UX 一致性修正)**:开关切换不再要求手动「重置会话」——PMO 巡检对**空闲**成员自动重建会话(每轮最多 2 个,约 1 分钟内收敛;忙碌成员等回合结束再应用,绝不打断进行中的工作);boot 时以账本当前值初始化,避免重启即全体重建。命令返回 note 如实说明「自动生效 + 会话记忆会重置」。
|
|
6
|
+
- planChatGateReseats 纯函数(可选重建计划)+ 3 项测试(idle/busy/cold/retired/limit)。
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## 0.3.79 - 2026-11-12
|
|
10
|
+
|
|
11
|
+
- **Human 直聊门接入项目开关**:成员会话 header 的 parentSession 现在由项目 chatGate 决定——open(默认)不带 parentSession(宿主放行 Human 在 DSH 主界面直接输入);closed 带 parentSession(宿主按 subagent-owned 拒绝)。门只对新建/重建会话生效(header 不可变),切换开关时命令返回明确说明(已有成员需「重置会话」)。2 项映射测试(open/closed 两种 header 断言)。
|
|
12
|
+
|
|
13
|
+
|
|
3
14
|
## 0.3.78 - 2026-11-12
|
|
4
15
|
|
|
5
16
|
- **【关键】成员会话对 Human 只读的根因修复**:宿主 hasApiSessionSubagentOwner 除 origin=subagent 外,对「header 带 parentSession 且 parent 拥有该 agent」的会话同样判定为 subagent-owned 并拒绝 Human 输入。插件 direct 模式创建成员会话时恰好设置了 meta.parentSession,导致所有成员会话被拒。现移除该 header 字段(驱动改用 agents.resume 的 parentAgent,不依赖 header)——新激活/重置后的成员会话可在 DSH 主界面直接输入。
|
package/client.js
CHANGED
|
@@ -3019,8 +3019,9 @@ window.__ModuleLoader__.load({
|
|
|
3019
3019
|
}
|
|
3020
3020
|
async function toggleChatGate() {
|
|
3021
3021
|
try {
|
|
3022
|
-
await runCommand('project.chatGate', { gate: chatGateClosed ? 'open' : 'closed' });
|
|
3023
|
-
|
|
3022
|
+
const result = await runCommand('project.chatGate', { gate: chatGateClosed ? 'open' : 'closed' });
|
|
3023
|
+
// host 的 note 说明自动收敛语义(空闲成员约 1 分钟内自动重建)。
|
|
3024
|
+
say(result?.note ?? (chatGateClosed ? t('chatGateOpened') : t('chatGateClosedShort')));
|
|
3024
3025
|
await reloadData();
|
|
3025
3026
|
} catch (error) {
|
|
3026
3027
|
sayRight(tf(t, 'sendFailed', { message: error?.message ?? String(error) }));
|
package/index.js
CHANGED
|
@@ -30,6 +30,7 @@ import { installFaultAdapter } from './lib/host/fault-adapter.js';
|
|
|
30
30
|
import { buildModelCatalog } from './lib/host/model-catalog.js';
|
|
31
31
|
import { createTeamTool } from './lib/host/member-tools.js';
|
|
32
32
|
import { describeWake, planWakes } from './lib/host/waker.js';
|
|
33
|
+
import { planChatGateReseats } from './lib/host/chat-gate-sync.js';
|
|
33
34
|
import { aggregatePeople } from './lib/host/people-view.js';
|
|
34
35
|
import { riskView } from './lib/host/risk-view.js';
|
|
35
36
|
import { weeklyView } from './lib/host/weekly-view.js';
|
|
@@ -41,7 +42,7 @@ export const name = 'ai-team';
|
|
|
41
42
|
/** The workbench only makes sense where the Web carrier exists. */
|
|
42
43
|
export const inject = ['webServer', 'permissionPresets', 'sandboxPolicy'];
|
|
43
44
|
|
|
44
|
-
const VERSION = '0.3.
|
|
45
|
+
const VERSION = '0.3.80';
|
|
45
46
|
const PROJECT_ID = 'prj_main';
|
|
46
47
|
const HUMAN_ID = 'mem_human';
|
|
47
48
|
|
|
@@ -372,6 +373,9 @@ export function apply(ctx, config = {}) {
|
|
|
372
373
|
const pmoLastStall = new Map();
|
|
373
374
|
const pmoLastHeartbeat = new Map();
|
|
374
375
|
const pmoLastDispatch = new Map();
|
|
376
|
+
// chatGate 已应用值(内存):boot 时用当前账本值初始化,避免重启即重建
|
|
377
|
+
// 全体会话;此后每轮 tick 收敛到账本值(对空闲成员自动重建会话)。
|
|
378
|
+
const chatGateApplied = new Map();
|
|
375
379
|
const pmoLastEscalate = new Map();
|
|
376
380
|
const pmoLastReview = new Map();
|
|
377
381
|
// Members resumed from cold sessions produce AgentHandles nobody stored;
|
|
@@ -455,6 +459,7 @@ export function apply(ctx, config = {}) {
|
|
|
455
459
|
agents: ctx.get('agents'),
|
|
456
460
|
agentPresets: ctx.get('agentPresets'),
|
|
457
461
|
direct: true,
|
|
462
|
+
allowHumanWrite: projectRuntime.service.state.projects?.[projectRuntime.id]?.chatGate !== 'closed',
|
|
458
463
|
parent: parentInfo.agent,
|
|
459
464
|
provider: providers[0],
|
|
460
465
|
preset: 'standard',
|
|
@@ -507,6 +512,33 @@ export function apply(ctx, config = {}) {
|
|
|
507
512
|
// P6 停止门:stopped 项目停止一切派发(补派/心跳/升级/continue 全停),
|
|
508
513
|
// 正在执行的回合自然完成;唤醒事件 hook 同样检查(见 wakeFromResult)。
|
|
509
514
|
if (project.runState === 'stopped') return;
|
|
515
|
+
// chatGate 自动收敛:开关变更后成员会话 header 需重建才生效——对
|
|
516
|
+
// **空闲**成员自动 reseat(每轮最多 2 个),忙碌成员等回合结束再应用。
|
|
517
|
+
// 本轮无可重建且无忙碌成员时记为已收敛(停止重复重建)。独立于派发门。
|
|
518
|
+
const gate = project.chatGate === 'closed' ? 'closed' : 'open';
|
|
519
|
+
if (chatGateApplied.get(projectRuntime.id) !== gate) {
|
|
520
|
+
const plan = planChatGateReseats(
|
|
521
|
+
Object.values(state.members ?? {}).filter((member) => member.kind === 'agent'),
|
|
522
|
+
(sessionId) => ctx.get('agents')?.get?.(sessionId)?.status ?? null,
|
|
523
|
+
{ limit: 2 },
|
|
524
|
+
);
|
|
525
|
+
for (const memberId of plan.reseat) {
|
|
526
|
+
const member = state.members?.[memberId];
|
|
527
|
+
if (member === undefined) continue;
|
|
528
|
+
diag.append({ ev: 'chatgate.reseat', projectId: projectRuntime.id, memberId, gate, oldSessionId: member.sessionId ?? null });
|
|
529
|
+
const result = await activateMember({
|
|
530
|
+
payload: { memberId, prompt: `会话已重建(Human 对话门:${gate})。先读 tasks/thread 当前状态,继续推进;不要重复已完成的工作。`, force: true },
|
|
531
|
+
}, projectRuntime).catch((error) => ({ error: { message: error?.message ?? String(error) } }));
|
|
532
|
+
if (result?.error !== undefined) {
|
|
533
|
+
diag.append({ ev: 'chatgate.reseat.fail', projectId: projectRuntime.id, memberId, message: result.error.message });
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
// 本轮没有可重建对象、也没有忙碌成员 → 全部收敛(cold 成员激活时
|
|
537
|
+
// 自然读取当前门状态)。
|
|
538
|
+
if (plan.reseat.length === 0 && plan.busy.length === 0) {
|
|
539
|
+
chatGateApplied.set(projectRuntime.id, gate);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
510
542
|
for (const member of Object.values(state.members ?? {})) {
|
|
511
543
|
if (member.kind === 'agent' && typeof member.sessionId === 'string') {
|
|
512
544
|
await titleMemberSession(projectRuntime, member);
|
|
@@ -859,6 +891,7 @@ export function apply(ctx, config = {}) {
|
|
|
859
891
|
agents: ctx.get('agents'),
|
|
860
892
|
agentPresets: ctx.get('agentPresets'),
|
|
861
893
|
direct: true,
|
|
894
|
+
allowHumanWrite: projectRuntime.service.state.projects?.[projectRuntime.id]?.chatGate !== 'closed',
|
|
862
895
|
parent: parentInfo.agent,
|
|
863
896
|
provider: providers[0],
|
|
864
897
|
preset: 'standard',
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* chatGate 自动收敛规划(纯函数,便于测试):
|
|
3
|
+
* 项目「Human 对话」开关变更后,成员会话的 header(是否带 parentSession)
|
|
4
|
+
* 在创建时固定,必须重建会话才能让新门状态生效。本函数决定本轮应该重建
|
|
5
|
+
* 哪些成员:
|
|
6
|
+
* - 只挑**空闲**成员(live agent 状态不是 running / 或会话已冷)——绝不打断
|
|
7
|
+
* 进行中的回合;
|
|
8
|
+
* - 每轮最多 `limit` 个,渐进收敛,避免 6 个成员同时激活造成回合风暴;
|
|
9
|
+
* - 忙碌成员不出现在 reseat 列表里,调用方保持「未收敛」状态,下轮再试。
|
|
10
|
+
*
|
|
11
|
+
* @param {Array<{id:string, sessionId:string|null, status?:string}>} members
|
|
12
|
+
* @param {(sessionId:string) => string|null} liveAgentStatus 宿主 agent 状态查询(null=冷会话/已释放)
|
|
13
|
+
* @param {{limit?:number}} [options]
|
|
14
|
+
* @returns {{reseat: Array, busy: Array, cold: Array}}
|
|
15
|
+
*/
|
|
16
|
+
export function planChatGateReseats(members, liveAgentStatus, options = {}) {
|
|
17
|
+
const limit = Math.max(1, Number.isSafeInteger(options.limit) ? options.limit : 2);
|
|
18
|
+
const reseat = [];
|
|
19
|
+
const busy = [];
|
|
20
|
+
const cold = [];
|
|
21
|
+
for (const member of members) {
|
|
22
|
+
if (member === null || member === undefined) continue;
|
|
23
|
+
if (member.status === 'retired') continue;
|
|
24
|
+
const sessionId = typeof member.sessionId === 'string' && member.sessionId !== '' ? member.sessionId : null;
|
|
25
|
+
if (sessionId === null) {
|
|
26
|
+
// 从未激活:下次激活自然读当前门状态,无需重建。
|
|
27
|
+
cold.push(member.id);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const live = liveAgentStatus(sessionId);
|
|
31
|
+
if (live === 'running') {
|
|
32
|
+
busy.push(member.id);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
reseat.push(member.id);
|
|
36
|
+
}
|
|
37
|
+
return { reseat: reseat.slice(0, limit), busy, cold };
|
|
38
|
+
}
|
package/lib/host/service.js
CHANGED
|
@@ -469,7 +469,14 @@ export class TeamService {
|
|
|
469
469
|
if (gate !== 'open' && gate !== 'closed') fail(ERRORS.INVALID_ARGUMENT, 'gate must be open or closed');
|
|
470
470
|
if (command.actor.kind !== 'human') fail(ERRORS.UNAUTHORIZED, 'only Human may change the chat gate');
|
|
471
471
|
await this.append(command, 'project/chat-gate', { projectId, gate, reason: payload.reason ?? '' });
|
|
472
|
-
|
|
472
|
+
// 直聊门只对新建/重建的成员会话生效(session header 不可变):Host 的
|
|
473
|
+
// PMO 巡检会在成员空闲时自动重建会话(每轮最多 2 个),无需手动操作。
|
|
474
|
+
return {
|
|
475
|
+
project: { ...project, chatGate: gate },
|
|
476
|
+
note: gate === 'closed'
|
|
477
|
+
? '已关闭 Human 直聊:成员会话将在空闲时自动重建(每轮 2 个,约 1 分钟内生效;会话记忆会重置)。'
|
|
478
|
+
: '已开启 Human 直聊:成员会话将在空闲时自动重建(每轮 2 个,约 1 分钟内生效;会话记忆会重置)。',
|
|
479
|
+
};
|
|
473
480
|
}
|
|
474
481
|
|
|
475
482
|
// P4:项目归档(软删)——账本 append-only 纪律下不可物理删除;archived
|
|
@@ -98,6 +98,11 @@ export class MemberRuntime {
|
|
|
98
98
|
this.preset = options.preset ?? null;
|
|
99
99
|
this.agentPresets = options.agentPresets ?? null;
|
|
100
100
|
this.direct = options.direct === true;
|
|
101
|
+
// chatGate 门:Human 对话开启时成员会话不带 parentSession(宿主放行
|
|
102
|
+
// Human 直聊);关闭时带 parentSession(宿主 hasApiSessionSubagentOwner
|
|
103
|
+
// 判定 subagent-owned → 拒绝 Human 输入)。仅对**新建**会话生效,
|
|
104
|
+
// 已存在会话的 header 不可变,需重置会话(reseat)后应用新门状态。
|
|
105
|
+
this.allowHumanWrite = options.allowHumanWrite === true;
|
|
101
106
|
// Cold resumes produce AgentHandles the caller does not store; the owner
|
|
102
107
|
// tracks them here so teardown can dispose every member activation.
|
|
103
108
|
this.trackHandle = typeof options.trackHandle === 'function' ? options.trackHandle : null;
|
|
@@ -184,11 +189,11 @@ export class MemberRuntime {
|
|
|
184
189
|
parentAgent: this.parent,
|
|
185
190
|
meta: {
|
|
186
191
|
cwd: member.workspace ?? this.cwd,
|
|
187
|
-
//
|
|
188
|
-
//
|
|
189
|
-
// subagent-owned
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
+
// Human 对话门:open 时不带 parentSession(宿主放行 Human 直聊);
|
|
193
|
+
// closed 时带 parentSession(hasApiSessionSubagentOwner 判定
|
|
194
|
+
// subagent-owned → Human 输入被 session/agent-busy 拒绝)。
|
|
195
|
+
// 驱动仍靠 agents.resume(parentAgent),不依赖该 header。
|
|
196
|
+
...(this.allowHumanWrite ? {} : { parentSession: this.parent.id }),
|
|
192
197
|
delegationDepth: 1,
|
|
193
198
|
...(preset ? { agentPreset: preset } : {}),
|
|
194
199
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suifei/dsh-ai-team",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.80",
|
|
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",
|