@suifei/dsh-ai-team 0.3.79 → 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 +6 -0
- package/client.js +3 -2
- package/index.js +32 -1
- package/lib/host/chat-gate-sync.js +38 -0
- package/lib/host/service.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 0.3.79 - 2026-11-12
|
|
4
10
|
|
|
5
11
|
- **Human 直聊门接入项目开关**:成员会话 header 的 parentSession 现在由项目 chatGate 决定——open(默认)不带 parentSession(宿主放行 Human 在 DSH 主界面直接输入);closed 带 parentSession(宿主按 subagent-owned 拒绝)。门只对新建/重建会话生效(header 不可变),切换开关时命令返回明确说明(已有成员需「重置会话」)。2 项映射测试(open/closed 两种 header 断言)。
|
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;
|
|
@@ -508,6 +512,33 @@ export function apply(ctx, config = {}) {
|
|
|
508
512
|
// P6 停止门:stopped 项目停止一切派发(补派/心跳/升级/continue 全停),
|
|
509
513
|
// 正在执行的回合自然完成;唤醒事件 hook 同样检查(见 wakeFromResult)。
|
|
510
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
|
+
}
|
|
511
542
|
for (const member of Object.values(state.members ?? {})) {
|
|
512
543
|
if (member.kind === 'agent' && typeof member.sessionId === 'string') {
|
|
513
544
|
await titleMemberSession(projectRuntime, member);
|
|
@@ -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,13 +469,13 @@ 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
|
-
// 直聊门只对新建/重建的成员会话生效(session header 不可变):
|
|
473
|
-
//
|
|
472
|
+
// 直聊门只对新建/重建的成员会话生效(session header 不可变):Host 的
|
|
473
|
+
// PMO 巡检会在成员空闲时自动重建会话(每轮最多 2 个),无需手动操作。
|
|
474
474
|
return {
|
|
475
475
|
project: { ...project, chatGate: gate },
|
|
476
476
|
note: gate === 'closed'
|
|
477
|
-
? '已关闭 Human
|
|
478
|
-
: '已开启 Human
|
|
477
|
+
? '已关闭 Human 直聊:成员会话将在空闲时自动重建(每轮 2 个,约 1 分钟内生效;会话记忆会重置)。'
|
|
478
|
+
: '已开启 Human 直聊:成员会话将在空闲时自动重建(每轮 2 个,约 1 分钟内生效;会话记忆会重置)。',
|
|
479
479
|
};
|
|
480
480
|
}
|
|
481
481
|
|
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",
|