@suifei/dsh-ai-team 0.4.157 → 0.4.158

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,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.158 - 2026-12-04
4
+
5
+ - 编制巡检从支持 `capacityOf` 的 DSH 读取当前代理树的已占用与剩余槽位,加人建议会标明采样时的并发余量。旧宿主沿用容量回执或默认估计。感谢 @buger-gif 提供编制巡检和并发边界的案例(#116)。
6
+ - 工作台使用 DSH 0.2.3 Alpha 的 Web 路由会话认证,修复已登录时仍无法打开看板。感谢 @Estelle00 提供新版宿主的启动场景(#122)。
7
+
3
8
  ## 0.4.157 - 2026-12-03
4
9
 
5
10
  - DSH 会话可根据目标建议团队,显示匹配的交付物。有多个候选时请用户选择。`/ai-team 调整` 可用一句话准备增员、改岗位或离队交接草稿,沿用会话确认和原卡交接。感谢 @buger-gif 的会话建队与编制反馈(#121)。
package/README.md CHANGED
@@ -37,6 +37,8 @@
37
37
 
38
38
  ## 最近更新
39
39
 
40
+ - **实时代理树槽位**(0.4.158)。支持 `capacityOf` 的宿主会在编制巡检中报告已占用和剩余槽位,建议新增成员时可看出同时启动是否需要排队。感谢 [@buger-gif](https://github.com/buger-gif),[#116](https://github.com/suifei/dsh-ai-team/issues/116)。
41
+ - **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
42
  - **会话建队建议与一句话调整编制**(0.4.157)。根据目标匹配团队预设并显示依据。可用一句话准备增员、改岗位或离队交接的草稿。感谢 [@buger-gif](https://github.com/buger-gif),[#121](https://github.com/suifei/dsh-ai-team/issues/121)。
41
43
  - **从会话调整编制**(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
44
  - **从会话建队与分树容量**(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)。
@@ -179,7 +181,7 @@ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asi
179
181
 
180
182
  在当前 DSH profile 的 `ai-team` 配置中设 `staffingReviewMinutes: 180` 和 `diagLevel: full` 后,启用 PMO 自动的运行中普通项目会随现有巡检周期采样,每个时间窗口记录一次。`staffingReviewMinutes: 0`(默认)关闭采样。诊断日志中的 `pmo.staffing.review` 包含岗位已分配队列、可认领与待验收队列、最长及平均等待,以及采样窗口内每位成员的提交、验收和退回。返工率按退回的本窗口提交除以本窗口提交数计算,零样本为空。
181
183
 
182
- 巡检还会记录没有合格验收人的任务 ID、插件观察到的在队成员运行回合数和容量来源。并发上限按当前项目的根代理树记录,来源为 `default` 时使用默认估计,为 `host` 时来自这棵树的宿主容量回执。宿主释放槽位后,插件优先补投本树排队最久的成员。PMO 会把长期无人可验收的任务带进现有补位建议。
184
+ 巡检还会记录没有合格验收人的任务 ID 和在队成员运行回合数。宿主提供 `capacityOf` 时,`host-live` 表示当前代理树的实时槽位快照,`occupiedSlots` 和 `remainingSlots` 分别记录占用和余量。`host` 表示这棵树的容量回执,`default` 表示默认估计。这两种来源的占用和余量字段为空。宿主释放槽位后,插件优先补投本树排队最久的成员。加人建议会提示采样时的槽位不足,长期无人可验收的任务也会进入现有补位建议。
183
185
 
184
186
  巡检复用现有派员建议和冷却规则,记录被暂缓的建议。人员动作仍由已有授权流程处理。试跑样本和调整建议可回到 [#116](https://github.com/suifei/dsh-ai-team/issues/116)。
185
187
 
@@ -428,8 +430,8 @@ round-19 DeepSeek + Zhipu 双 provider
428
430
  | 贡献者 | 贡献 | 带来的进展 |
429
431
  |---|---|---|
430
432
  | [@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),会话建队与调整编制场景 [#121](https://github.com/suifei/dsh-ai-team/issues/121) | 统一认领与离队顺序,减少派发空转,记录验收缺口与代理树容量。在 DSH 会话按目标建议预设,并确认一句话编制草稿及原任务交接 |
432
- | [@Estelle00](https://github.com/Estelle00) | DSH 0.2.3 启动 503 的复现和桌面验证 [#122](https://github.com/suifei/dsh-ai-team/issues/122) | 接入新版会话鉴权接口,恢复工作台初始化 |
433
+ | [@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 会话按目标建议预设,并确认一句话编制草稿及原任务交接 |
434
+ | [@Estelle00](https://github.com/Estelle00) | DSH 0.2.3 启动 503 的复现和桌面验证 [#122](https://github.com/suifei/dsh-ai-team/issues/122) | 接入新版会话鉴权接口,恢复工作台初始化,并在 Alpha 宿主验证看板登录 |
433
435
  | [@phm101299-ui](https://github.com/phm101299-ui) | PMO 冷恢复的复现、根因和桌面验证 [#112](https://github.com/suifei/dsh-ai-team/issues/112) | 让原 PMO 在宿主重启后带着模型路由继续工作,保留成员关系和任务 |
434
436
  | [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) | 成员与自定义人才可在文渊阁选择已安装的技能或导入完整技能包。0.4.151 统一新建人才的导入入口,并由文渊阁直接安装整包 |
435
437
  | [@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 observedHostCapacity = treeCapacity.get(hosts.get(projectRuntime.id)?.agent);
1514
- const capacity = observedHostCapacity ?? HOST_SUBAGENT_LIMIT;
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, capacitySource: observedHostCapacity === null ? 'default' : 'host',
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
- handler: async (req, res) => {
2639
+ auth: 'required',
2640
+ handler: async (req, res, peer) => {
2640
2641
  try {
2641
- // 0.2.2 使用 requestRejection;0.2.3 的 admit 同时验证来源与会话。
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 (typeof connection?.requestRejection === 'function') {
2646
- rejection = connection.requestRejection(req);
2647
- } else if (typeof connection?.admit === 'function') {
2648
- const admission = await connection.admit(req);
2649
- rejection = admission?.rejection ?? (admission?.peer ? undefined : 503);
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 (headcount + entry.count > capacity) reasons.push(`团队现有 ${headcount} 名 AI 成员,按这棵代理树的 ${capacity} 个并发位估算,同时跑满时会排队`);
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
  }
@@ -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
- return match === null ? null : Number(match[1]);
48
+ const limit = match === null ? null : Number(match[1]);
49
+ return Number.isSafeInteger(limit) && limit > 0 ? limit : null;
49
50
  }
50
51
 
51
- /** DSH reserves activation slots per root Agent. A replacement root starts with no observed limit. */
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
- get: (root) => limits.get(root) ?? null,
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.157",
3
+ "version": "0.4.158",
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",