@suifei/dsh-ai-team 0.4.157 → 0.4.159
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 +9 -0
- package/README.md +9 -4
- package/index.js +16 -14
- package/lib/host/pmo.js +9 -5
- package/lib/host/session-team-command.js +32 -5
- package/lib/runtime/wake-failure.js +19 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.159 - 2026-12-04
|
|
4
|
+
|
|
5
|
+
- 在 DSH 会话建队目标末尾可用「配 6 个人」指定人数。草稿显示目标人数、预设人数和岗位,人数不一致时先提示调整预设。感谢 @buger-gif 的会话组队与指定人数反馈(#121)。
|
|
6
|
+
|
|
7
|
+
## 0.4.158 - 2026-12-04
|
|
8
|
+
|
|
9
|
+
- 编制巡检从支持 `capacityOf` 的 DSH 读取当前代理树的已占用与剩余槽位,加人建议会标明采样时的并发余量。旧宿主沿用容量回执或默认估计。感谢 @buger-gif 提供编制巡检和并发边界的案例(#116)。
|
|
10
|
+
- 工作台使用 DSH 0.2.3 Alpha 的 Web 路由会话认证,修复已登录时仍无法打开看板。感谢 @Estelle00 提供新版宿主的启动场景(#122)。
|
|
11
|
+
|
|
3
12
|
## 0.4.157 - 2026-12-03
|
|
4
13
|
|
|
5
14
|
- DSH 会话可根据目标建议团队,显示匹配的交付物。有多个候选时请用户选择。`/ai-team 调整` 可用一句话准备增员、改岗位或离队交接草稿,沿用会话确认和原卡交接。感谢 @buger-gif 的会话建队与编制反馈(#121)。
|
package/README.md
CHANGED
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
|
|
38
38
|
## 最近更新
|
|
39
39
|
|
|
40
|
+
- **会话建队人数核对**(0.4.159)。目标可用「配 6 个人」指定人数,草稿列出目标人数和预设编制,人数不一致时先提示调整预设。感谢 [@buger-gif](https://github.com/buger-gif),[#121](https://github.com/suifei/dsh-ai-team/issues/121)。
|
|
41
|
+
- **实时代理树槽位**(0.4.158)。支持 `capacityOf` 的宿主会在编制巡检中报告已占用和剩余槽位,建议新增成员时可看出同时启动是否需要排队。感谢 [@buger-gif](https://github.com/buger-gif),[#116](https://github.com/suifei/dsh-ai-team/issues/116)。
|
|
42
|
+
- **DSH 0.2.3 Alpha 看板兼容**(0.4.158)。工作台沿用宿主 Web 路由的会话认证,修复已登录时看板仍加载失败的问题。感谢 [@Estelle00](https://github.com/Estelle00),[#122](https://github.com/suifei/dsh-ai-team/issues/122)。
|
|
40
43
|
- **会话建队建议与一句话调整编制**(0.4.157)。根据目标匹配团队预设并显示依据。可用一句话准备增员、改岗位或离队交接的草稿。感谢 [@buger-gif](https://github.com/buger-gif),[#121](https://github.com/suifei/dsh-ai-team/issues/121)。
|
|
41
44
|
- **从会话调整编制**(0.4.156)。可查看同一工作区的团队,从人才库增员、修改岗位或把原任务交给接手人后离队。变更经草稿确认。感谢 [@buger-gif](https://github.com/buger-gif),[#121](https://github.com/suifei/dsh-ai-team/issues/121)、[#116](https://github.com/suifei/dsh-ai-team/issues/116)。
|
|
42
45
|
- **从会话建队与分树容量**(0.4.155)。在 DSH 会话输入目标即可预览目录和岗位,确认后由现有流程创建项目。编制巡检和排队补投按项目代理树处理并发。感谢 [@buger-gif](https://github.com/buger-gif),[#121](https://github.com/suifei/dsh-ai-team/issues/121)、[#116](https://github.com/suifei/dsh-ai-team/issues/116)。
|
|
@@ -141,7 +144,9 @@ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asi
|
|
|
141
144
|
|
|
142
145
|
可用 `/ai-team 建队 --recommend 整理接口文档` 根据目标匹配文档、内容、教育、视频或游戏预设。唯一候选会随匹配依据进入草稿。有多个候选或线索不足时,用 `--team` 指定预设。省略这两个选项时使用设置中的团队。
|
|
143
146
|
|
|
144
|
-
|
|
147
|
+
若有明确人数,可用 `/ai-team 建队 --recommend 编写培训教材,配 6 个人`。预设需要达到目标人数才能生成草稿。人数不一致时,可以用 `--team` 选择其他预设或在文渊阁调整预设。
|
|
148
|
+
|
|
149
|
+
会话会显示工作目录、目标、团队预设、人数与岗位。输入草稿末尾的 `/ai-team 确认 草稿ID` 创建项目,或用对应的取消命令丢弃草稿。草稿跟随当前会话,宿主重启后可以重新生成。
|
|
145
150
|
|
|
146
151
|
新项目会出现在文渊阁,PMO 自动初始关闭。团队准备好后,可以在项目页开启 PMO 自动。
|
|
147
152
|
|
|
@@ -179,7 +184,7 @@ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asi
|
|
|
179
184
|
|
|
180
185
|
在当前 DSH profile 的 `ai-team` 配置中设 `staffingReviewMinutes: 180` 和 `diagLevel: full` 后,启用 PMO 自动的运行中普通项目会随现有巡检周期采样,每个时间窗口记录一次。`staffingReviewMinutes: 0`(默认)关闭采样。诊断日志中的 `pmo.staffing.review` 包含岗位已分配队列、可认领与待验收队列、最长及平均等待,以及采样窗口内每位成员的提交、验收和退回。返工率按退回的本窗口提交除以本窗口提交数计算,零样本为空。
|
|
181
186
|
|
|
182
|
-
巡检还会记录没有合格验收人的任务 ID
|
|
187
|
+
巡检还会记录没有合格验收人的任务 ID 和在队成员运行回合数。宿主提供 `capacityOf` 时,`host-live` 表示当前代理树的实时槽位快照,`occupiedSlots` 和 `remainingSlots` 分别记录占用和余量。`host` 表示这棵树的容量回执,`default` 表示默认估计。这两种来源的占用和余量字段为空。宿主释放槽位后,插件优先补投本树排队最久的成员。加人建议会提示采样时的槽位不足,长期无人可验收的任务也会进入现有补位建议。
|
|
183
188
|
|
|
184
189
|
巡检复用现有派员建议和冷却规则,记录被暂缓的建议。人员动作仍由已有授权流程处理。试跑样本和调整建议可回到 [#116](https://github.com/suifei/dsh-ai-team/issues/116)。
|
|
185
190
|
|
|
@@ -428,8 +433,8 @@ round-19 DeepSeek + Zhipu 双 provider
|
|
|
428
433
|
| 贡献者 | 贡献 | 带来的进展 |
|
|
429
434
|
|---|---|---|
|
|
430
435
|
| [@idontlikefruit](https://github.com/idontlikefruit) | 受阻状态的三组复现输入 [#115](https://github.com/suifei/dsh-ai-team/issues/115) | 统一看板徽标、读屏和分组统计的受阻判定,保留历史依赖 |
|
|
431
|
-
| [@buger-gif](https://github.com/buger-gif) | 编制巡检、离队交接案例 [#116](https://github.com/suifei/dsh-ai-team/issues/116)、[#117](https://github.com/suifei/dsh-ai-team/issues/117),派发空转记录 [#120](https://github.com/suifei/dsh-ai-team/issues/120)
|
|
432
|
-
| [@Estelle00](https://github.com/Estelle00) | DSH 0.2.3 启动 503 的复现和桌面验证 [#122](https://github.com/suifei/dsh-ai-team/issues/122) |
|
|
436
|
+
| [@buger-gif](https://github.com/buger-gif) | 编制巡检、离队交接案例 [#116](https://github.com/suifei/dsh-ai-team/issues/116)、[#117](https://github.com/suifei/dsh-ai-team/issues/117),派发空转记录 [#120](https://github.com/suifei/dsh-ai-team/issues/120),会话建队、指定人数与调整编制场景 [#121](https://github.com/suifei/dsh-ai-team/issues/121) | 统一认领与离队顺序,减少派发空转,记录验收缺口与代理树的实时槽位。在 DSH 会话按目标建议预设并核对人数,确认一句话编制草稿及原任务交接 |
|
|
437
|
+
| [@Estelle00](https://github.com/Estelle00) | DSH 0.2.3 启动 503 的复现和桌面验证 [#122](https://github.com/suifei/dsh-ai-team/issues/122) | 接入新版会话鉴权接口,恢复工作台初始化,并在 Alpha 宿主验证看板登录 |
|
|
433
438
|
| [@phm101299-ui](https://github.com/phm101299-ui) | PMO 冷恢复的复现、根因和桌面验证 [#112](https://github.com/suifei/dsh-ai-team/issues/112) | 让原 PMO 在宿主重启后带着模型路由继续工作,保留成员关系和任务 |
|
|
434
439
|
| [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) | 成员与自定义人才可在文渊阁选择已安装的技能或导入完整技能包。0.4.151 统一新建人才的导入入口,并由文渊阁直接安装整包 |
|
|
435
440
|
| [@qq958691165](https://github.com/qq958691165) | 归档项目的成员反馈、团队管理建议 [#103](https://github.com/suifei/dsh-ai-team/issues/103) | 人员池排除归档项目,侧栏集中管理项目成员与团队预设 |
|
package/index.js
CHANGED
|
@@ -1007,7 +1007,7 @@ export function apply(ctx, config = {}) {
|
|
|
1007
1007
|
const pmoLastStaffing = new Map();
|
|
1008
1008
|
const pmoStaffingReviewWindows = new Map();
|
|
1009
1009
|
// DSH 的 ActivationPool 按根 Agent 分配,已观察的上限随当前项目树而变。
|
|
1010
|
-
const treeCapacity = observeTreeCapacity();
|
|
1010
|
+
const treeCapacity = observeTreeCapacity({ diag });
|
|
1011
1011
|
const pmoLastEscalate = new Map();
|
|
1012
1012
|
const pmoLastReview = new Map();
|
|
1013
1013
|
let pmoTimer = null;
|
|
@@ -1510,10 +1510,10 @@ export function apply(ctx, config = {}) {
|
|
|
1510
1510
|
const reviewDue = reviewWindow !== null && pmoStaffingReviewWindows.get(projectRuntime.id) !== reviewWindow;
|
|
1511
1511
|
const suppressed = [];
|
|
1512
1512
|
const inTurn = (id) => turnsInFlight.has(id);
|
|
1513
|
-
const
|
|
1514
|
-
const capacity =
|
|
1513
|
+
const hostCapacity = treeCapacity.read(hosts.get(projectRuntime.id)?.agent, serviceOf(ctx, 'subagents'));
|
|
1514
|
+
const capacity = hostCapacity.capacity ?? HOST_SUBAGENT_LIMIT;
|
|
1515
1515
|
const adviceList = planStaffingAdvice(staffingState, {
|
|
1516
|
-
now, inTurn, capacity,
|
|
1516
|
+
now, inTurn, capacity, remainingSlots: hostCapacity.remainingSlots,
|
|
1517
1517
|
humanId: projectRuntime.service.humanId(), wait: (config.staffingAdviceMinutes ?? 30) * 60_000,
|
|
1518
1518
|
onSuppressed: reviewDue ? (entry) => suppressed.push(entry) : undefined,
|
|
1519
1519
|
});
|
|
@@ -1521,7 +1521,7 @@ export function apply(ctx, config = {}) {
|
|
|
1521
1521
|
pmoStaffingReviewWindows.set(projectRuntime.id, reviewWindow);
|
|
1522
1522
|
try {
|
|
1523
1523
|
const review = staffingReview(staffingState, projectRuntime.ledger.events, {
|
|
1524
|
-
now, intervalMs: reviewInterval, capacity,
|
|
1524
|
+
...hostCapacity, now, intervalMs: reviewInterval, capacity,
|
|
1525
1525
|
inTurn, advice: adviceList, suppressed,
|
|
1526
1526
|
});
|
|
1527
1527
|
diag.append({ ev: 'pmo.staffing.review', projectId: projectRuntime.id, window: reviewWindow, ...review });
|
|
@@ -2636,17 +2636,19 @@ export function apply(ctx, config = {}) {
|
|
|
2636
2636
|
const dispose = webServer.register({
|
|
2637
2637
|
kind: 'prefix',
|
|
2638
2638
|
path: '/ai-team',
|
|
2639
|
-
|
|
2639
|
+
auth: 'required',
|
|
2640
|
+
handler: async (req, res, peer) => {
|
|
2640
2641
|
try {
|
|
2641
|
-
// 0.2.
|
|
2642
|
-
// isTrustedRequest 只检查来源,不能作为认证栅栏。
|
|
2643
|
-
const connection = serviceOf(ctx, 'connection');
|
|
2642
|
+
// 0.2.3 的 WebServer 从宿主认证作用域传入 Peer;0.2.2 由 Connection 检查。
|
|
2644
2643
|
let rejection = 503;
|
|
2645
|
-
if (
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2644
|
+
if (peer) {
|
|
2645
|
+
const aborted = peer.signal?.aborted;
|
|
2646
|
+
if (typeof aborted === 'boolean') rejection = aborted ? 401 : undefined;
|
|
2647
|
+
} else {
|
|
2648
|
+
const connection = serviceOf(ctx, 'connection');
|
|
2649
|
+
if (typeof connection?.requestRejection === 'function') {
|
|
2650
|
+
rejection = connection.requestRejection(req);
|
|
2651
|
+
}
|
|
2650
2652
|
}
|
|
2651
2653
|
if (rejection !== undefined) {
|
|
2652
2654
|
const status = rejection === 401 || rejection === 403 ? rejection : 503;
|
package/lib/host/pmo.js
CHANGED
|
@@ -260,7 +260,7 @@ function tasksWithoutReviewer(state, tasks) {
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
/** A read-only rollup of the existing queues and observed submissions in this window. */
|
|
263
|
-
export function staffingReview(state, events, { now, intervalMs, capacity, capacitySource = null, inTurn, advice = [], suppressed = [] }) {
|
|
263
|
+
export function staffingReview(state, events, { now, intervalMs, capacity, capacitySource = null, occupiedSlots = null, remainingSlots = null, inTurn, advice = [], suppressed = [] }) {
|
|
264
264
|
const since = now - intervalMs;
|
|
265
265
|
const people = new Map(Object.values(state.members ?? {})
|
|
266
266
|
.filter((member) => member.kind === 'agent' && member.status !== 'retired')
|
|
@@ -299,7 +299,7 @@ export function staffingReview(state, events, { now, intervalMs, capacity, capac
|
|
|
299
299
|
if (task.status === 'in_progress') group.inProgress += 1;
|
|
300
300
|
}
|
|
301
301
|
return {
|
|
302
|
-
since, now, capacity, capacitySource, capacityScope: 'agent-tree', activeMemberTurns,
|
|
302
|
+
since, now, capacity, capacitySource, capacityScope: 'agent-tree', occupiedSlots, remainingSlots, activeMemberTurns,
|
|
303
303
|
claimable: waitingSummary(claimableTasks(state, open), now),
|
|
304
304
|
pendingAcceptance: waitingSummary(waitingReview, now),
|
|
305
305
|
pendingAcceptanceWithoutReviewer: { ...waitingSummary(missingReviewers, now), taskIds: missingReviewers.map(({ id }) => id) },
|
|
@@ -320,10 +320,10 @@ export function staffingReview(state, events, { now, intervalMs, capacity, capac
|
|
|
320
320
|
* 同一类建议 4 小时内只提一次;上一条还没处理(unread)时不再提。冷却读账本里的收件箱,重启不丢。
|
|
321
321
|
*
|
|
322
322
|
* @param {any} state 账本投影
|
|
323
|
-
* @param {{ now: number, inTurn: (sessionId: string) => boolean, capacity?: number, humanId?: string | null, wait?: number, onSuppressed?: (entry: object) => void }} options 「慢」的门槛 wait 来自配置 staffingAdviceMinutes
|
|
323
|
+
* @param {{ now: number, inTurn: (sessionId: string) => boolean, capacity?: number, remainingSlots?: number | null, humanId?: string | null, wait?: number, onSuppressed?: (entry: object) => void }} options 「慢」的门槛 wait 来自配置 staffingAdviceMinutes
|
|
324
324
|
* @returns {Array<{ role: 'developer' | 'qa', action: 'add' | 'recover', count: number, memberIds: string[], title: string, reasons: string[], taskIds: string[] }>}
|
|
325
325
|
*/
|
|
326
|
-
export function planStaffingAdvice(state, { now, inTurn, capacity = HOST_SUBAGENT_LIMIT, humanId = null, wait = STAFFING_ADVICE_WAIT, onSuppressed }) {
|
|
326
|
+
export function planStaffingAdvice(state, { now, inTurn, capacity = HOST_SUBAGENT_LIMIT, remainingSlots = null, humanId = null, wait = STAFFING_ADVICE_WAIT, onSuppressed }) {
|
|
327
327
|
const open = openTasks(state);
|
|
328
328
|
if (open.length === 0) return [];
|
|
329
329
|
const age = (task) => taskAge(task, now);
|
|
@@ -369,7 +369,11 @@ export function planStaffingAdvice(state, { now, inTurn, capacity = HOST_SUBAGEN
|
|
|
369
369
|
const reasons = [...entry.reasons];
|
|
370
370
|
const who = entry.role === 'developer' ? '开发' : '验收';
|
|
371
371
|
if (entry.action === 'recover') return { ...entry, reasons, title: `建议恢复停摆的${who}:${reasons.join(';')}` };
|
|
372
|
-
if (
|
|
372
|
+
if (remainingSlots !== null && remainingSlots < entry.count) {
|
|
373
|
+
reasons.push(`采样时这棵代理树剩余 ${remainingSlots} 个并发位,新增成员同时启动会排队`);
|
|
374
|
+
} else if (headcount + entry.count > capacity) {
|
|
375
|
+
reasons.push(`团队现有 ${headcount} 名 AI 成员,按这棵代理树的 ${capacity} 个并发位估算,同时跑满时会排队`);
|
|
376
|
+
}
|
|
373
377
|
return { ...entry, reasons, title: `建议加 ${entry.count} 名${who}:${reasons.join(';')}` };
|
|
374
378
|
});
|
|
375
379
|
}
|
|
@@ -5,7 +5,7 @@ import { ids, newId } from '../domain/ids.js';
|
|
|
5
5
|
import { isRosterAction, rosterHelp } from './session-roster.js';
|
|
6
6
|
import { requireWorkspaceDirectory } from './workspace-path.js';
|
|
7
7
|
|
|
8
|
-
const HELP = `用 /ai-team 建队 目标 生成草稿。可在目标前加 --team 预设ID 或 --recommend
|
|
8
|
+
const HELP = `用 /ai-team 建队 目标 生成草稿。可在目标前加 --team 预设ID 或 --recommend,或在目标末尾加「,配 6 个人」核对编制。按草稿中的命令确认或取消。\n${rosterHelp}`;
|
|
9
9
|
|
|
10
10
|
function sessionWorkspace(session) {
|
|
11
11
|
const path = session?.header?.cwd;
|
|
@@ -17,6 +17,21 @@ function sessionWorkspace(session) {
|
|
|
17
17
|
|
|
18
18
|
const presetSignature = (preset) => JSON.stringify([preset.id, preset.source, preset.dir, preset.team]);
|
|
19
19
|
|
|
20
|
+
function requestedRosterSize(goal) {
|
|
21
|
+
const count = /(?:^|[,;。\r\n])\s*配\s*([+-]?\d+(?:\.\d+)?|[零〇一二两三四五六七八九十]+)\s*(?:[个名位]\s*)?(?:人|成员)\s*[。.!]?$/u.exec(goal.normalize('NFKC'))?.[1];
|
|
22
|
+
if (count === undefined) return null;
|
|
23
|
+
const digits = '零一二三四五六七八九';
|
|
24
|
+
const chinese = /^(?:([一二三四五六七八九]?)十)?([零一二三四五六七八九]?)$/u.exec(count.replaceAll('两', '二').replaceAll('〇', '零'));
|
|
25
|
+
let size = Number(count);
|
|
26
|
+
if (chinese) {
|
|
27
|
+
const [, tens, ones] = chinese;
|
|
28
|
+
const tensDigit = tens === '' ? 1 : digits.indexOf(tens ?? '零');
|
|
29
|
+
size = 10 * tensDigit + digits.indexOf(ones || '零');
|
|
30
|
+
}
|
|
31
|
+
if (!Number.isSafeInteger(size) || size < 1) fail(ERRORS.INVALID_ARGUMENT, '请填写正整数人数,例如「,配 6 个人」。');
|
|
32
|
+
return size;
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
/** 只有当前用户会话能确认它的草稿。建队和编制共用同一确认流程。 */
|
|
21
36
|
export function sessionTeamCommand({ prepare, create, prepareRoster, diag }) {
|
|
22
37
|
const drafts = new WeakMap();
|
|
@@ -52,25 +67,37 @@ export function sessionTeamCommand({ prepare, create, prepareRoster, diag }) {
|
|
|
52
67
|
const goal = (recommend ? argument.slice('--recommend'.length) : selected?.[2] ?? argument).trim();
|
|
53
68
|
if (goal === '' || (!selected && argument.startsWith('--team'))) return { kind: 'error', text: HELP };
|
|
54
69
|
const input = { name: goal.split(/\r?\n/, 1)[0], goal, workspacePath, team: selected?.[1] ?? '', recommend };
|
|
55
|
-
const
|
|
70
|
+
const requestedMembers = requestedRosterSize(goal);
|
|
71
|
+
const prepareDraft = () => {
|
|
72
|
+
const project = prepare(input);
|
|
73
|
+
const count = project.teamPreset.team.members.length;
|
|
74
|
+
if (requestedMembers !== null && count !== requestedMembers) {
|
|
75
|
+
const { id, team } = project.teamPreset;
|
|
76
|
+
fail(ERRORS.INVALID_ARGUMENT, `目标要求 ${requestedMembers} 人,${team.name}(${id})有 ${count} 人。请用 --team 选择匹配人数的预设,或在文渊阁调整预设后重新建队。`);
|
|
77
|
+
}
|
|
78
|
+
return project;
|
|
79
|
+
};
|
|
80
|
+
const proposed = prepareDraft();
|
|
81
|
+
const members = proposed.teamPreset.team.members;
|
|
56
82
|
const id = ids.project();
|
|
57
83
|
const signature = presetSignature(proposed.teamPreset);
|
|
58
84
|
return preview(session, workspacePath, {
|
|
59
85
|
id, action,
|
|
60
|
-
details: { preset: proposed.teamPreset.id, members:
|
|
86
|
+
details: { preset: proposed.teamPreset.id, members: members.length, requestedMembers },
|
|
61
87
|
lines: [
|
|
62
88
|
`建队草稿 ${input.name}`,
|
|
63
89
|
`目标 ${goal}`,
|
|
64
90
|
`工作目录 ${workspacePath}`,
|
|
65
91
|
`预设 ${proposed.teamPreset.team.name}(${proposed.teamPreset.id})`,
|
|
66
92
|
...(proposed.matchedTerms ? [`匹配依据 ${proposed.matchedTerms.join('、')}`] : []),
|
|
67
|
-
|
|
93
|
+
`编制 ${members.length} 人${requestedMembers !== null ? `(目标 ${requestedMembers} 人)` : ''}`,
|
|
94
|
+
...members.map((member) => `- ${member.name} · ${member.role}`),
|
|
68
95
|
'确认后创建项目,PMO 自动为关闭状态。',
|
|
69
96
|
],
|
|
70
97
|
async apply() {
|
|
71
98
|
let approved;
|
|
72
99
|
try {
|
|
73
|
-
approved =
|
|
100
|
+
approved = prepareDraft();
|
|
74
101
|
} catch (error) {
|
|
75
102
|
if (error instanceof DomainError) fail(ERRORS.REVISION, '团队预设已更新,请重新生成草稿后再确认。');
|
|
76
103
|
throw error;
|
|
@@ -45,14 +45,29 @@ export function isCapacityError(error) {
|
|
|
45
45
|
export function capacityLimit(error) {
|
|
46
46
|
if (!isCapacityError(error)) return null;
|
|
47
47
|
const match = /active child limit:\s*(\d+)/i.exec(String(error?.message ?? ''));
|
|
48
|
-
|
|
48
|
+
const limit = match === null ? null : Number(match[1]);
|
|
49
|
+
return Number.isSafeInteger(limit) && limit > 0 ? limit : null;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
/**
|
|
52
|
-
export function observeTreeCapacity() {
|
|
52
|
+
/** Sample the exact live Agent tree. Older hosts only reveal a limit in their capacity errors. */
|
|
53
|
+
export function observeTreeCapacity({ diag } = {}) {
|
|
53
54
|
const limits = new WeakMap();
|
|
54
55
|
return {
|
|
55
|
-
|
|
56
|
+
read(root, subagents) {
|
|
57
|
+
if (root != null && typeof subagents?.capacityOf === 'function') {
|
|
58
|
+
try {
|
|
59
|
+
const { running, limit } = subagents.capacityOf(root) ?? {};
|
|
60
|
+
if (!Number.isSafeInteger(running) || running < 0 || !Number.isSafeInteger(limit) || limit < 1) {
|
|
61
|
+
throw new Error('capacityOf returned invalid slot counts');
|
|
62
|
+
}
|
|
63
|
+
return { capacity: limit, capacitySource: 'host-live', occupiedSlots: running, remainingSlots: Math.max(0, limit - running) };
|
|
64
|
+
} catch (error) {
|
|
65
|
+
diag?.append({ ev: 'pmo.staffing.capacity.fail', rootId: root.id ?? null, code: error?.code ?? null, message: error?.message ?? String(error) });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const capacity = limits.get(root) ?? null;
|
|
69
|
+
return { capacity, capacitySource: capacity === null ? 'default' : 'host', occupiedSlots: null, remainingSlots: null };
|
|
70
|
+
},
|
|
56
71
|
record(root, error) {
|
|
57
72
|
if (root == null || typeof root !== 'object') return;
|
|
58
73
|
const limit = capacityLimit(error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suifei/dsh-ai-team",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.159",
|
|
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",
|