@suifei/dsh-ai-team 0.4.151 → 0.4.153
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 +12 -0
- package/README.md +30 -2
- package/client.js +16 -14
- package/index.js +48 -16
- package/lib/domain/task.js +39 -19
- package/lib/host/pmo.js +81 -14
- package/lib/host/service.js +33 -38
- package/lib/host/skill-import.js +204 -204
- package/lib/host/waker.js +14 -6
- package/lib/runtime/host-agent.js +22 -22
- package/package.json +75 -75
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.153 - 2026-12-03
|
|
4
|
+
|
|
5
|
+
- 看板的受阻徽标、读屏名称和分组计数使用宿主提供的当前受阻状态,依赖编号保持可查。感谢 @idontlikefruit 提供复现(#115)。
|
|
6
|
+
- 把离队、退役和任务认领放到同一队列,执行时核查成员状态。先认领的任务进入交接清单,先离队的成员不能再认领。感谢 @buger-gif 提供现场线索(#116、#117)。
|
|
7
|
+
- 普通项目可选择试跑只读编制巡检,记录岗位队列、等待和实际返工样本,复用现有派员建议。感谢 @buger-gif 提供试跑建议(#116)。
|
|
8
|
+
- PMO 派发和任务认领共用依赖、写入范围和在手任务检查。同一接收人的重复补派会退避,改派后重新判定。感谢 @buger-gif 提供空转记录(#120)。
|
|
9
|
+
- 兼容 DSH 0.2.3 的 `Connection.admit()`。工作台收到已验证的会话才能处理请求,早期宿主继续使用原鉴权接口。感谢 @Estelle00 提供复现、版本差异和桌面验证(#122)。
|
|
10
|
+
|
|
11
|
+
## 0.4.152 - 2026-12-02
|
|
12
|
+
|
|
13
|
+
- 修复 PMO 冷恢复时缺少 `provider` 和 `model` 导致首轮请求失败。恢复原会话时一并传入默认模型和推理等级,宿主可继续沿用已保存的模型选择。原 PMO 会话、成员关系和任务可继续使用。感谢 @phm101299-ui 提供复现、根因和桌面验证(#112)。
|
|
14
|
+
|
|
3
15
|
## 0.4.151 - 2026-12-02
|
|
4
16
|
|
|
5
17
|
- 统一新建人才的技能导入入口。单个 Markdown、完整技能文件夹、ZIP 与 `.skill` 都从「导入技能」进入。
|
package/README.md
CHANGED
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
> [!IMPORTANT]
|
|
23
23
|
> **🤝 社区共创:文渊阁下一步怎么走,由社区决定。**
|
|
24
24
|
>
|
|
25
|
-
> 任何想法都欢迎[提到 Issue 里](https://github.com/suifei/dsh-ai-team/issues/new/choose)
|
|
25
|
+
> 任何想法都欢迎[提到 Issue 里](https://github.com/suifei/dsh-ai-team/issues/new/choose)。你可以描述一个实际卡点,也可以提出新方向、参与试跑或补充证据。
|
|
26
26
|
>
|
|
27
|
-
>
|
|
27
|
+
> 维护者会公开说明判断依据和下一步,发布结果也会回到对应的 Issue。跨版本推进的目标和验收证据见[社区共创路线图](https://github.com/suifei/dsh-ai-team/issues/118)。
|
|
28
28
|
|
|
29
29
|
> 文渊阁,藏修、校勘、纂辑之地。
|
|
30
30
|
> 在这里,Human 不在环里逐条调度,而是在环上定方向、守信任、做最后那一步。
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
|
|
38
38
|
## 最近更新
|
|
39
39
|
|
|
40
|
+
- **看板受阻、离队交接和只读巡检**(0.4.153)。看板按当前状态显示受阻,历史依赖仍可查。离队与认领按同一顺序处理,待交接的原卡能交给继任者。普通项目可以开启只读编制巡检。感谢 [@idontlikefruit](https://github.com/idontlikefruit),[#115](https://github.com/suifei/dsh-ai-team/issues/115)。感谢 [@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)。
|
|
41
|
+
- **派发预检和 DSH 0.2.3 兼容**(0.4.153)。PMO 在唤醒前核对依赖、在手任务和写入范围。工作台兼容新版宿主的会话鉴权。感谢 [@buger-gif](https://github.com/buger-gif),[#120](https://github.com/suifei/dsh-ai-team/issues/120)。感谢 [@Estelle00](https://github.com/Estelle00),[#122](https://github.com/suifei/dsh-ai-team/issues/122)。
|
|
42
|
+
- **PMO 重启后续跑**(0.4.152)。恢复原会话时即提供模型路由,避免首轮因缺少模型而失败。保留原 PMO 会话、成员关系和任务。感谢 [@phm101299-ui](https://github.com/phm101299-ui),[#112](https://github.com/suifei/dsh-ai-team/issues/112)。
|
|
40
43
|
- **文渊阁直接导入技能包**(0.4.151)。「导入技能」可选 Markdown、技能文件夹、ZIP 和 `.skill`。只需安装文渊阁,即可安装完整包并在 DSH 确认可加载后加入技能列表。感谢 [@godfay-g](https://github.com/godfay-g),[#109](https://github.com/suifei/dsh-ai-team/issues/109)。
|
|
41
44
|
- **给成员装技能包**(0.4.150)。成员资料和新建人才增加已安装技能选择和完整技能包导入。感谢 [@godfay-g](https://github.com/godfay-g),[#109](https://github.com/suifei/dsh-ai-team/issues/109)。
|
|
42
45
|
- **会话标题栏看板入口**(0.4.149)。文渊阁管理的 PMO 和成员会话会显示文渊阁图标,点击直达所属项目的看板。运行时的轻微脉冲遵循系统的减少动态效果设置。
|
|
@@ -134,6 +137,12 @@ const svg = HashAvatar.svg('墨渊', { gender: 'male', age: 'middle', race: 'asi
|
|
|
134
137
|
|
|
135
138
|
项目「总览」从账本统计近七天验收、一次通过率和认领至验收的中位耗时。交付流程可跳转到对应看板状态,AI 协作卡可查看成员资料,验收证据可打开原始任务卡。
|
|
136
139
|
|
|
140
|
+
### 只读编制巡检试跑
|
|
141
|
+
|
|
142
|
+
在当前 DSH profile 的 `ai-team` 配置中设 `staffingReviewMinutes: 180` 和 `diagLevel: full` 后,启用 PMO 自动的运行中普通项目会随现有巡检周期采样,每个时间窗口记录一次。`staffingReviewMinutes: 0`(默认)关闭采样。诊断日志中的 `pmo.staffing.review` 包含岗位已分配队列、可认领与待验收队列、最长及平均等待,以及采样窗口内每位成员的提交、验收和退回。返工率按退回的本窗口提交除以本窗口提交数计算,零样本为空。
|
|
143
|
+
|
|
144
|
+
巡检复用现有派员建议和冷却规则,记录被暂缓的建议。人员动作仍由已有授权流程处理。试跑样本和调整建议可回到 [#116](https://github.com/suifei/dsh-ai-team/issues/116)。
|
|
145
|
+
|
|
137
146
|
---
|
|
138
147
|
|
|
139
148
|
## 为什么是「文渊阁」
|
|
@@ -355,12 +364,31 @@ round-19 DeepSeek + Zhipu 双 provider
|
|
|
355
364
|
- **贡献人才和团队**:新的人才(`talents/<人才>/talent.yml`)和团队(`teams/<团队>/team.yml`)都欢迎,合并后会随在线人才库发给所有用户。
|
|
356
365
|
- **头像库**:[hash-avatar](https://github.com/suifei/hash-avatar) 同样欢迎 Star 和贡献新的种族、画风。
|
|
357
366
|
|
|
367
|
+
### 共创约定
|
|
368
|
+
|
|
369
|
+
提议可以从你在哪一步卡住、希望得到什么结果开始。已有版本、复现步骤、脱敏日志或样本,也欢迎一起附上。维护者会在原 Issue 给出归类、依据、下一步和进入实现的验收条件。任何人都可以补充证据或提出不同判断。
|
|
370
|
+
|
|
371
|
+
证据和验收条件齐备、可以采纳的议题,维护者可以直接开工,并在原 Issue 链接实现与验证。社区贡献者随时可以加入实现或复测。
|
|
372
|
+
|
|
373
|
+
| 议题类型 | 下一步 |
|
|
374
|
+
|---|---|
|
|
375
|
+
| 缺陷 | 核对复现和预期行为。修复时用回归测试覆盖原场景。 |
|
|
376
|
+
| 改进 | 说明现有流程的卡点和希望改善的结果,用真实用例验收。 |
|
|
377
|
+
| 方向提案 | 在社区讨论收益和代价,约定一轮最小试跑。涉及授权或任务状态变化时,一并说明谁授权、如何停用、未完成任务如何交接。 |
|
|
378
|
+
| 使用或环境问题 | 给出可执行的排查步骤,依据结果更新归类。 |
|
|
379
|
+
|
|
380
|
+
一条反馈可以拆成多个可验证的议题并互相链接。需要跨版本推进的能力,在[公开路线图](https://github.com/suifei/dsh-ai-team/issues/118)记录期望结果、阶段、验收证据和关联 Issue。暂缓时写清原因与重新讨论的条件。
|
|
381
|
+
|
|
358
382
|
### 致谢
|
|
359
383
|
|
|
360
384
|
带来重要进展的反馈和代码,都会在这里和对应的「最近更新」条目里点名感谢。
|
|
361
385
|
|
|
362
386
|
| 贡献者 | 贡献 | 带来的进展 |
|
|
363
387
|
|---|---|---|
|
|
388
|
+
| [@idontlikefruit](https://github.com/idontlikefruit) | 受阻状态的三组复现输入 [#115](https://github.com/suifei/dsh-ai-team/issues/115) | 统一看板徽标、读屏和分组统计的受阻判定,保留历史依赖 |
|
|
389
|
+
| [@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) | 统一认领与离队的执行顺序,开放只读巡检取证,并在唤醒前检查认领条件 |
|
|
390
|
+
| [@Estelle00](https://github.com/Estelle00) | DSH 0.2.3 启动 503 的复现和桌面验证 [#122](https://github.com/suifei/dsh-ai-team/issues/122) | 接入新版会话鉴权接口,恢复工作台初始化 |
|
|
391
|
+
| [@phm101299-ui](https://github.com/phm101299-ui) | PMO 冷恢复的复现、根因和桌面验证 [#112](https://github.com/suifei/dsh-ai-team/issues/112) | 让原 PMO 在宿主重启后带着模型路由继续工作,保留成员关系和任务 |
|
|
364
392
|
| [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) | 成员与自定义人才可在文渊阁选择已安装的技能或导入完整技能包。0.4.151 统一新建人才的导入入口,并由文渊阁直接安装整包 |
|
|
365
393
|
| [@qq958691165](https://github.com/qq958691165) | 归档项目的成员反馈、团队管理建议 [#103](https://github.com/suifei/dsh-ai-team/issues/103) | 人员池排除归档项目,侧栏集中管理项目成员与团队预设 |
|
|
366
394
|
| [@Arnoldnuo](https://github.com/Arnoldnuo) | 桌面端启动 503 反馈 [#102](https://github.com/suifei/dsh-ai-team/issues/102) | 工作台提供分情况的 503 提示,快速开始说明内置 `desktop` 与 `web` 的安装和启动方式,连接错误提示引导核对 profile |
|
package/client.js
CHANGED
|
@@ -88,7 +88,7 @@ window.__ModuleLoader__.load({
|
|
|
88
88
|
agentFailed: '失败',
|
|
89
89
|
agentRetired: '已退役',
|
|
90
90
|
groupCreated: '新建 {n} 个任务',
|
|
91
|
-
groupBlocked: '{n}
|
|
91
|
+
groupBlocked: '{n} 项受阻',
|
|
92
92
|
groupMore: '展开其余 {n} 项',
|
|
93
93
|
groupLess: '收起其余 {n} 项',
|
|
94
94
|
fromDiscussion: '由讨论升格',
|
|
@@ -597,7 +597,7 @@ window.__ModuleLoader__.load({
|
|
|
597
597
|
agentFailed: 'Failed',
|
|
598
598
|
agentRetired: 'Retired',
|
|
599
599
|
groupCreated: '{n} tasks created',
|
|
600
|
-
groupBlocked: '{n}
|
|
600
|
+
groupBlocked: '{n} blocked',
|
|
601
601
|
groupMore: 'Show {n} more',
|
|
602
602
|
groupLess: 'Collapse {n}',
|
|
603
603
|
fromDiscussion: 'Promoted from discussion',
|
|
@@ -1125,7 +1125,8 @@ window.__ModuleLoader__.load({
|
|
|
1125
1125
|
if (data.thread && data.thread.taskId === taskId) return data.thread;
|
|
1126
1126
|
return null;
|
|
1127
1127
|
};
|
|
1128
|
-
const
|
|
1128
|
+
const isBlocked = (task) => task.blocked === true;
|
|
1129
|
+
const dependencyRefs = (task, tasks) => (task?.blockedBy ?? []).map((id) => {
|
|
1129
1130
|
const dep = (tasks ?? []).find((item) => item.id === id);
|
|
1130
1131
|
return '#' + taskNo(dep ?? { id });
|
|
1131
1132
|
});
|
|
@@ -1156,10 +1157,10 @@ window.__ModuleLoader__.load({
|
|
|
1156
1157
|
if (Object.hasOwn(STATUS, filter)) return task.status === filter;
|
|
1157
1158
|
if (filter === 'q1') {
|
|
1158
1159
|
return task.status === 'pending_acceptance'
|
|
1159
|
-
|| (task.ownerId === humanId && task.status === 'pending' && task
|
|
1160
|
+
|| (task.ownerId === humanId && task.status === 'pending' && isBlocked(task));
|
|
1160
1161
|
}
|
|
1161
1162
|
if (filter === 'q2') return task.status === 'in_progress';
|
|
1162
|
-
if (filter === 'q3') return task.status === 'pending' && task
|
|
1163
|
+
if (filter === 'q3') return task.status === 'pending' && isBlocked(task);
|
|
1163
1164
|
if (filter === 'q4') return task.status === 'done';
|
|
1164
1165
|
return true;
|
|
1165
1166
|
}
|
|
@@ -1379,7 +1380,7 @@ window.__ModuleLoader__.load({
|
|
|
1379
1380
|
.at-pill.at-tone-success { background: var(--dsw-alias-state-success-tertiary); color: var(--dsw-alias-state-success-primary); }
|
|
1380
1381
|
.at-pill.at-tone-muted { border: 1px solid var(--dsw-alias-border-l3); background: transparent; color: var(--dsw-alias-label-caption); }
|
|
1381
1382
|
.at-blocked { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 6px; border-radius: var(--dsw-radius-xs); background: var(--dsw-alias-state-warn-tertiary); color: var(--dsw-alias-state-warn-label); font-size: 11px; font-weight: 500; line-height: 16px; white-space: nowrap; }
|
|
1382
|
-
.at-dep { color: var(--dsw-alias-
|
|
1383
|
+
.at-dep { color: var(--dsw-alias-label-secondary); font-size: 11px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1383
1384
|
.at-replies { margin-left: auto; color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; }
|
|
1384
1385
|
.at-ct { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--dsw-alias-label-primary); font-size: 13px; font-weight: 500; line-height: 21px; overflow-wrap: anywhere; }
|
|
1385
1386
|
.at-card-board .at-ct { font-size: 13px; }
|
|
@@ -1899,7 +1900,9 @@ window.__ModuleLoader__.load({
|
|
|
1899
1900
|
function TaskCard({ t, card, tasks, variant, selected, following, onOpen, onToggleFollow }) {
|
|
1900
1901
|
const meta = statusMeta(card.status);
|
|
1901
1902
|
const no = taskNo(card);
|
|
1902
|
-
const
|
|
1903
|
+
const blocked = isBlocked(card);
|
|
1904
|
+
const refs = dependencyRefs(card, tasks);
|
|
1905
|
+
const dependencies = refs.length ? t('dependsOn') + ' ' + refs.join('、') : '';
|
|
1903
1906
|
const fromDiscussion = Array.isArray(card.originRefs) && card.originRefs.length > 0;
|
|
1904
1907
|
const ownerText = t('owner') + ' ' + (card.owner ?? t('unassigned'));
|
|
1905
1908
|
const execText = card.assignee ? t('executor') + ' ' + card.assignee : t('unassigned');
|
|
@@ -1909,7 +1912,8 @@ window.__ModuleLoader__.load({
|
|
|
1909
1912
|
'Task #' + no,
|
|
1910
1913
|
card.title,
|
|
1911
1914
|
t(meta.label),
|
|
1912
|
-
|
|
1915
|
+
blocked ? t('blocked') : '',
|
|
1916
|
+
dependencies,
|
|
1913
1917
|
ownerText,
|
|
1914
1918
|
execText,
|
|
1915
1919
|
replyLabel,
|
|
@@ -1939,7 +1943,8 @@ window.__ModuleLoader__.load({
|
|
|
1939
1943
|
h('span', { className: 'at-num' }, 'Task #' + no),
|
|
1940
1944
|
h(StatusPill, { t, status: card.status }),
|
|
1941
1945
|
card.irreversible ? h('span', { className: 'at-blocked', title: t('irreversibleBadge') }, t('irreversibleBadge')) : null,
|
|
1942
|
-
|
|
1946
|
+
blocked ? h('span', { className: 'at-blocked' }, h(Ico, { name: 'block', size: 12 }), t('blocked')) : null,
|
|
1947
|
+
dependencies ? h('span', { className: 'at-dep', title: dependencies }, dependencies) : null,
|
|
1943
1948
|
h('span', { className: 'at-replies' }, replyLabel + (time ? ' · ' + time : '')),
|
|
1944
1949
|
),
|
|
1945
1950
|
h('div', { className: 'at-ct', title: card.title }, card.title),
|
|
@@ -1962,7 +1967,7 @@ window.__ModuleLoader__.load({
|
|
|
1962
1967
|
const parts = ['in_progress', 'pending_acceptance', 'pending', 'done']
|
|
1963
1968
|
.filter((status) => counts[status])
|
|
1964
1969
|
.map((status) => t(statusMeta(status).label) + ' ' + counts[status]);
|
|
1965
|
-
const blockedCount = cards.filter(
|
|
1970
|
+
const blockedCount = cards.filter(isBlocked).length;
|
|
1966
1971
|
const groupLabel = tf(t, 'groupCreated', { n: cards.length });
|
|
1967
1972
|
const renderCard = (card) => h(TaskCard, {
|
|
1968
1973
|
key: card.id,
|
|
@@ -3177,10 +3182,7 @@ window.__ModuleLoader__.load({
|
|
|
3177
3182
|
quadrant.key === 'q4' && meta && meta.total > meta.count ? h('div', { className: 'at-qtotal' }, tf(t, 'q4Total', { n: meta.count, m: meta.total })) : null,
|
|
3178
3183
|
shown.length
|
|
3179
3184
|
? h('div', { className: 'at-qlist' }, shown.map((item) => {
|
|
3180
|
-
const blocked = (item
|
|
3181
|
-
const dep = tasks.find((task) => task.id === id);
|
|
3182
|
-
return '#' + taskNo(dep ?? { id });
|
|
3183
|
-
});
|
|
3185
|
+
const blocked = dependencyRefs(item, tasks);
|
|
3184
3186
|
const category = t(CATEGORY_LABEL[item.category] ?? 'catBlocked');
|
|
3185
3187
|
const parts = [category];
|
|
3186
3188
|
if (quadrant.key === 'q3') {
|
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* The member runtime (real Agent sessions) lands in M2. Until then the
|
|
9
9
|
* ledger/domain service is the only writer and the Host never fakes work.
|
|
10
10
|
*/
|
|
11
|
-
import { HOST_SUBAGENT_LIMIT, planDispatch, planIdleRetry, planIdleStaffing, planStaffingAdvice, planTaskNudges } from './lib/host/pmo.js';
|
|
11
|
+
import { HOST_SUBAGENT_LIMIT, planDispatch, planIdleRetry, planIdleStaffing, planStaffingAdvice, planTaskNudges, staffingReview } from './lib/host/pmo.js';
|
|
12
12
|
import { pmoHasNews } from './lib/ledger/fold.js';
|
|
13
13
|
import { homedir, tmpdir } from 'node:os';
|
|
14
14
|
import { randomUUID } from 'node:crypto';
|
|
@@ -59,7 +59,7 @@ import { createMemberPermissionGuard } from './lib/host/permission-guard.js';
|
|
|
59
59
|
import { installFaultAdapter } from './lib/host/fault-adapter.js';
|
|
60
60
|
import { buildModelCatalog, buildModelEfforts } from './lib/host/model-catalog.js';
|
|
61
61
|
import { createTeamTool } from './lib/host/member-tools.js';
|
|
62
|
-
import { describeTaskContext, describeWake, planWakes } from './lib/host/waker.js';
|
|
62
|
+
import { canDeliverWake, describeTaskContext, describeWake, planWakes } from './lib/host/waker.js';
|
|
63
63
|
import { describeCauseChain } from './lib/runtime/error-chain.js';
|
|
64
64
|
import { capacityLimit, classifyWakeFailure, deferredWakeKind, isCapacityError, isMalformedTurnError } from './lib/runtime/wake-failure.js';
|
|
65
65
|
import { createDeferredWakes } from './lib/runtime/deferred-wakes.js';
|
|
@@ -137,6 +137,8 @@ export const Config = z.object({
|
|
|
137
137
|
pmoMaxRounds: z.number().step(1).min(0).max(100).default(3),
|
|
138
138
|
// 加人建议:可认领的待办没人接、或待验收排队,持续这么多分钟算「推进过慢」,给 Human 收件箱一条加人建议。
|
|
139
139
|
staffingAdviceMinutes: z.number().step(1).min(1).max(1440).default(30),
|
|
140
|
+
// 只读编制巡检的采样周期。0 关闭;试跑记录通过 full 诊断日志回读。
|
|
141
|
+
staffingReviewMinutes: z.number().step(1).min(0).max(1440).default(0),
|
|
140
142
|
// 新项目的初始团队:内置 teams/<团队>/,或 ~/.dsh/ai-team/catalog/user/teams/<团队>/(同名覆盖内置)。
|
|
141
143
|
teamPreset: z.string().default('default'),
|
|
142
144
|
});
|
|
@@ -975,6 +977,7 @@ export function apply(ctx, config = {}) {
|
|
|
975
977
|
const pmoLastDispatch = new Map();
|
|
976
978
|
// 空闲必派的节流状态(按项目):上次叫的时间、局面签名、同一局面重复次数(planIdleStaffing)。
|
|
977
979
|
const pmoLastStaffing = new Map();
|
|
980
|
+
const pmoStaffingReviewWindows = new Map();
|
|
978
981
|
// 宿主同时在跑的子智能体上限:默认 8,见到容量报错就以报错里的数字为准(加人建议的排队提示用)。
|
|
979
982
|
let hostCapacity = HOST_SUBAGENT_LIMIT;
|
|
980
983
|
const noteHostCapacity = (error) => {
|
|
@@ -1091,6 +1094,8 @@ export function apply(ctx, config = {}) {
|
|
|
1091
1094
|
* @param {{ seq?: number|null, retry?: boolean }} options retry:这是 deferredWakes 的补投
|
|
1092
1095
|
*/
|
|
1093
1096
|
const deliverWakePlans = async (projectRuntime, plans, { seq = null, retry = false } = {}) => {
|
|
1097
|
+
const readyPlans = plans.filter((plan) => canDeliverWake(projectRuntime.service.state, plan));
|
|
1098
|
+
if (readyPlans.length === 0) return;
|
|
1094
1099
|
const subagents = serviceOf(ctx, 'subagents');
|
|
1095
1100
|
const sessions = serviceOf(ctx, 'sessions');
|
|
1096
1101
|
const permissionPresets = serviceOf(ctx, 'permissionPresets');
|
|
@@ -1116,8 +1121,8 @@ export function apply(ctx, config = {}) {
|
|
|
1116
1121
|
const wakePrompt = async (plan, member, options = {}) => describeWake(plan, projectRuntime.service.state, options);
|
|
1117
1122
|
// #65:Human 消息里的图片/文件随唤醒一起交给成员会话(文字块 + 附件块)。
|
|
1118
1123
|
const wakeContent = async (plan, member, options = {}) => messageContent(await wakePrompt(plan, member, options), plan.attachments);
|
|
1119
|
-
for (const plan of
|
|
1120
|
-
if (wakeKeys.has(plan.key)) continue;
|
|
1124
|
+
for (const plan of readyPlans) {
|
|
1125
|
+
if (wakeKeys.has(plan.key) || !canDeliverWake(projectRuntime.service.state, plan)) continue;
|
|
1121
1126
|
let member = projectRuntime.service.state.members?.[plan.memberId];
|
|
1122
1127
|
if (member === undefined) continue;
|
|
1123
1128
|
// 无工作目录的项目不 wake(与 activate 的 fail-closed 同一不变量):
|
|
@@ -1439,8 +1444,11 @@ export function apply(ctx, config = {}) {
|
|
|
1439
1444
|
// 吞掉,60s tick 兜底。判定(实时回合、每卡上限)在 planDispatch(lib/host/pmo.js)。
|
|
1440
1445
|
for (const task of active) {
|
|
1441
1446
|
const last = pmoLastDispatch.get(task.id);
|
|
1442
|
-
|
|
1443
|
-
|
|
1447
|
+
const current = projectRuntime.service.state;
|
|
1448
|
+
const memberId = planDispatch(current.tasks?.[task.id], current, { inTurn: (id) => turnsInFlight.has(id), last, now });
|
|
1449
|
+
if (memberId === null) continue;
|
|
1450
|
+
const count = last?.memberId === memberId ? last.count + 1 : 1;
|
|
1451
|
+
pmoLastDispatch.set(task.id, { at: now, count, memberId });
|
|
1444
1452
|
await wakeFromResult(projectRuntime, {
|
|
1445
1453
|
event: { type: 'pmo/dispatch', payload: { taskId: task.id, bucket: Math.floor(now / 60_000) } },
|
|
1446
1454
|
}, {});
|
|
@@ -1472,7 +1480,28 @@ export function apply(ctx, config = {}) {
|
|
|
1472
1480
|
}, {});
|
|
1473
1481
|
}
|
|
1474
1482
|
// 加人建议:推进过慢(待办没人接 / 待验收排长队)时给 Human 收件箱一条建议,由 Human 决定(planStaffingAdvice)。
|
|
1475
|
-
|
|
1483
|
+
const staffingState = projectRuntime.service.state;
|
|
1484
|
+
const reviewInterval = (config.staffingReviewMinutes ?? 0) * 60_000;
|
|
1485
|
+
const reviewWindow = diag.level === 'full' && reviewInterval > 0 ? Math.floor(now / reviewInterval) : null;
|
|
1486
|
+
const reviewDue = reviewWindow !== null && pmoStaffingReviewWindows.get(projectRuntime.id) !== reviewWindow;
|
|
1487
|
+
const suppressed = [];
|
|
1488
|
+
const adviceList = planStaffingAdvice(staffingState, {
|
|
1489
|
+
now, inTurn: (id) => turnsInFlight.has(id), capacity: hostCapacity,
|
|
1490
|
+
humanId: projectRuntime.service.humanId(), wait: (config.staffingAdviceMinutes ?? 30) * 60_000,
|
|
1491
|
+
onSuppressed: reviewDue ? (entry) => suppressed.push(entry) : undefined,
|
|
1492
|
+
});
|
|
1493
|
+
if (reviewDue) {
|
|
1494
|
+
pmoStaffingReviewWindows.set(projectRuntime.id, reviewWindow);
|
|
1495
|
+
try {
|
|
1496
|
+
const review = staffingReview(staffingState, projectRuntime.ledger.events, {
|
|
1497
|
+
now, intervalMs: reviewInterval, capacity: hostCapacity, advice: adviceList, suppressed,
|
|
1498
|
+
});
|
|
1499
|
+
diag.append({ ev: 'pmo.staffing.review', projectId: projectRuntime.id, window: reviewWindow, ...review });
|
|
1500
|
+
} catch (error) {
|
|
1501
|
+
diag.append({ ev: 'pmo.staffing.review.fail', projectId: projectRuntime.id, message: error?.message ?? String(error) });
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
for (const advice of adviceList) {
|
|
1476
1505
|
const item = await projectRuntime.service.recordStaffingAdvice(projectRuntime.id, advice);
|
|
1477
1506
|
diag.append({ ev: 'pmo.advice', projectId: projectRuntime.id, role: advice.role, count: advice.count, title: advice.title, itemId: item?.id ?? null });
|
|
1478
1507
|
}
|
|
@@ -2514,18 +2543,21 @@ export function apply(ctx, config = {}) {
|
|
|
2514
2543
|
path: '/ai-team',
|
|
2515
2544
|
handler: async (req, res) => {
|
|
2516
2545
|
try {
|
|
2517
|
-
//
|
|
2518
|
-
//
|
|
2519
|
-
// 跨站 POST 命令(实测桌面版:Origin: https://evil.example 的 text/plain POST 直达处理器)。
|
|
2520
|
-
// 栅栏缺失即拒绝,不静默放行。
|
|
2546
|
+
// 0.2.2 使用 requestRejection;0.2.3 的 admit 同时验证来源与会话。
|
|
2547
|
+
// isTrustedRequest 只检查来源,不能作为认证栅栏。
|
|
2521
2548
|
const connection = serviceOf(ctx, 'connection');
|
|
2522
|
-
|
|
2523
|
-
|
|
2549
|
+
let rejection = 503;
|
|
2550
|
+
if (typeof connection?.requestRejection === 'function') {
|
|
2551
|
+
rejection = connection.requestRejection(req);
|
|
2552
|
+
} else if (typeof connection?.admit === 'function') {
|
|
2553
|
+
const admission = await connection.admit(req);
|
|
2554
|
+
rejection = admission?.rejection ?? (admission?.peer ? undefined : 503);
|
|
2524
2555
|
}
|
|
2525
|
-
const rejection = connection.requestRejection(req);
|
|
2526
2556
|
if (rejection !== undefined) {
|
|
2527
|
-
|
|
2528
|
-
|
|
2557
|
+
const status = rejection === 401 || rejection === 403 ? rejection : 503;
|
|
2558
|
+
diag.append({ ev: 'http.rejected.fail', status, method: req.method, path: String(req.url ?? '').split('?')[0], origin: req.headers?.origin ?? null });
|
|
2559
|
+
if (status === 503) return send(res, { error: { code: 'E_TRUST_FENCE_UNAVAILABLE', message: 'connection service is unavailable' } }, status);
|
|
2560
|
+
return send(res, { error: { code: status === 401 ? 'E_UNAUTHENTICATED' : 'E_FORBIDDEN', message: 'request rejected by the connection trust fence' } }, status);
|
|
2529
2561
|
}
|
|
2530
2562
|
const url = new URL(req.url, 'http://local');
|
|
2531
2563
|
await ready;
|
package/lib/domain/task.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
dependenciesDone,
|
|
10
10
|
memberHasInProgress,
|
|
11
11
|
memberHasPendingAcceptance,
|
|
12
|
+
STALLED_MEMBER_STATUSES,
|
|
12
13
|
writeScopeConflict,
|
|
13
14
|
} from './policy.js';
|
|
14
15
|
|
|
@@ -95,45 +96,64 @@ export function createTask(input) {
|
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
fail(ERRORS.INVALID_STATE, `task ${task.id} is not pending`, { details: { status: task.status } });
|
|
99
|
+
/** Shared claim constraints for command validation and wake planning. */
|
|
100
|
+
function claimTaskRejection(task, memberId, tasksById) {
|
|
101
|
+
if (task?.status !== 'pending' || task.tombstone === true) {
|
|
102
|
+
return { code: ERRORS.INVALID_STATE, message: `task ${task?.id} is not pending`, details: { status: task?.status } };
|
|
103
103
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
fail(ERRORS.UNAUTHORIZED, 'only a Team member can claim a task');
|
|
104
|
+
if (typeof memberId !== 'string') {
|
|
105
|
+
return { code: ERRORS.UNAUTHORIZED, message: 'only a Team member can claim a task' };
|
|
107
106
|
}
|
|
108
|
-
if (task.assigneeId
|
|
109
|
-
|
|
107
|
+
if (task.assigneeId != null && task.assigneeId !== memberId) {
|
|
108
|
+
return {
|
|
109
|
+
code: ERRORS.ALREADY_CLAIMED, message: 'task is assigned to another member',
|
|
110
110
|
details: { taskId: task.id, assigneeId: task.assigneeId },
|
|
111
|
-
}
|
|
111
|
+
};
|
|
112
112
|
}
|
|
113
113
|
if (!dependenciesDone(task, tasksById)) {
|
|
114
|
-
|
|
114
|
+
return {
|
|
115
|
+
code: ERRORS.BLOCKED, message: 'task has unfinished dependencies',
|
|
115
116
|
details: { taskId: task.id, blockedBy: task.blockedBy },
|
|
116
|
-
}
|
|
117
|
+
};
|
|
117
118
|
}
|
|
118
119
|
// 写入范围与别人正在做的卡重叠:等那张卡交付再认领,避免两人同时改同一批文件互相覆盖。
|
|
119
120
|
const clash = writeScopeConflict(task, tasksById);
|
|
120
121
|
if (clash !== undefined) {
|
|
121
|
-
|
|
122
|
+
return {
|
|
123
|
+
code: ERRORS.CONFLICT,
|
|
124
|
+
message: `write scope ${clash.mine} overlaps ${clash.theirs} of in-progress task ${clash.task.id}; claim it after that task is submitted, or claim another task`,
|
|
122
125
|
details: { taskId: task.id, conflictTaskId: clash.task.id, scope: clash.mine, conflictScope: clash.theirs },
|
|
123
|
-
}
|
|
126
|
+
};
|
|
124
127
|
}
|
|
125
128
|
const awaiting = memberHasPendingAcceptance(tasksById, memberId);
|
|
126
129
|
if (awaiting !== undefined) {
|
|
127
|
-
|
|
130
|
+
return {
|
|
131
|
+
code: ERRORS.CONFLICT, message: 'member has a task awaiting acceptance; wait for QA before claiming the next one',
|
|
128
132
|
details: { memberId, taskId: awaiting.id },
|
|
129
|
-
}
|
|
133
|
+
};
|
|
130
134
|
}
|
|
131
135
|
const busy = memberHasInProgress(tasksById, memberId);
|
|
132
136
|
if (busy !== undefined) {
|
|
133
|
-
|
|
137
|
+
return {
|
|
138
|
+
code: ERRORS.CONFLICT, message: 'member already has an in_progress task',
|
|
134
139
|
details: { memberId, taskId: busy.id },
|
|
135
|
-
}
|
|
140
|
+
};
|
|
136
141
|
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function canDispatchTask(state, task, memberId) {
|
|
146
|
+
const member = state?.members?.[memberId];
|
|
147
|
+
return member?.kind === 'agent' && member.status !== 'retired' && !STALLED_MEMBER_STATUSES.includes(member.status)
|
|
148
|
+
&& claimTaskRejection(task, memberId, state.tasks) === null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** A member claims a ready pending task; only `claim` enters claimHistory. */
|
|
152
|
+
export function claimTask(task, actor, tasksById, options = {}) {
|
|
153
|
+
assertRevision(task, options.expectedRevision);
|
|
154
|
+
const memberId = actor?.kind === 'agent' || actor?.kind === 'human' ? actor.memberId : null;
|
|
155
|
+
const rejection = claimTaskRejection(task, memberId, tasksById);
|
|
156
|
+
if (rejection !== null) fail(rejection.code, rejection.message, { details: rejection.details });
|
|
137
157
|
const patch = {
|
|
138
158
|
status: 'in_progress',
|
|
139
159
|
assigneeId: memberId,
|
package/lib/host/pmo.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { STALLED_MEMBER_STATUSES, dependenciesDone, teamRoles, writeScopeConflict } from '../domain/policy.js';
|
|
2
|
+
import { canDispatchTask } from '../domain/task.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* PMO decision policy.
|
|
@@ -125,21 +126,22 @@ export const PMO_DISPATCH_LIMIT = 3;
|
|
|
125
126
|
* 判忙只看**实时回合**(宿主 turn/start → turn/end),不看账本投影:账本没有「回合结束」
|
|
126
127
|
* 事件,成员一旦 session-bound 就永远是 running——#18 与 il2c 实账本(2997 次唤醒、
|
|
127
128
|
* pmo_dispatch 0 次)都证明旧判定让补派成了死代码。每卡最多 PMO_DISPATCH_LIMIT 次、
|
|
128
|
-
*
|
|
129
|
+
* 同一责任位的重复补派按 60、120 秒退避;仍未认领时交给 stall/escalate 升级。
|
|
129
130
|
*
|
|
130
131
|
* @param {any} task
|
|
131
132
|
* @param {any} state 账本投影
|
|
132
|
-
* @param {{ inTurn: (sessionId: string) => boolean, last?: { at: number, count: number }, now: number }} options
|
|
133
|
+
* @param {{ inTurn: (sessionId: string) => boolean, last?: { at: number, count: number, memberId: string }, now: number }} options
|
|
133
134
|
* @returns {string | null}
|
|
134
135
|
*/
|
|
135
|
-
export function planDispatch(task, state, { inTurn, last
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const responsible = state
|
|
139
|
-
if (responsible === undefined || responsible.kind !== 'agent') return null;
|
|
140
|
-
if (responsible.status === 'retired' || responsible.status === 'failed') return null;
|
|
136
|
+
export function planDispatch(task, state, { inTurn, last, now }) {
|
|
137
|
+
const responsibleId = task?.assigneeId ?? task?.ownerId;
|
|
138
|
+
if (!canDispatchTask(state, task, responsibleId)) return null;
|
|
139
|
+
const responsible = state.members[responsibleId];
|
|
141
140
|
if (typeof responsible.sessionId === 'string' && inTurn(responsible.sessionId)) return null;
|
|
142
|
-
if (last
|
|
141
|
+
if (last?.memberId === responsibleId) {
|
|
142
|
+
if (last.count >= PMO_DISPATCH_LIMIT) return null;
|
|
143
|
+
if (last.count > 0 && now - last.at < MINUTE * 2 ** (last.count - 1)) return null;
|
|
144
|
+
}
|
|
143
145
|
return responsibleId;
|
|
144
146
|
}
|
|
145
147
|
|
|
@@ -236,6 +238,66 @@ export const STAFFING_ADVICE_COOLDOWN = 4 * 60 * MINUTE;
|
|
|
236
238
|
/** 宿主同时运行的子智能体上限默认值(dsh-subagent maxActiveSubagents);实际值以容量报错里的数字为准。 */
|
|
237
239
|
export const HOST_SUBAGENT_LIMIT = 8;
|
|
238
240
|
|
|
241
|
+
function taskAge(task, now) {
|
|
242
|
+
const since = Number(task.updatedAt ?? task.createdAt ?? now);
|
|
243
|
+
return Number.isFinite(since) ? Math.max(0, now - since) : 0;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function waitingSummary(tasks, now) {
|
|
247
|
+
let oldest = 0;
|
|
248
|
+
let total = 0;
|
|
249
|
+
for (const task of tasks) {
|
|
250
|
+
const age = taskAge(task, now);
|
|
251
|
+
oldest = Math.max(oldest, age);
|
|
252
|
+
total += age;
|
|
253
|
+
}
|
|
254
|
+
return { count: tasks.length, oldestMinutes: Math.round(oldest / MINUTE), meanMinutes: tasks.length ? Math.round(total / tasks.length / MINUTE) : 0 };
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** A read-only rollup of the existing queues and observed submissions in this window. */
|
|
258
|
+
export function staffingReview(state, events, { now, intervalMs, capacity, advice = [], suppressed = [] }) {
|
|
259
|
+
const since = now - intervalMs;
|
|
260
|
+
const people = new Map(Object.values(state.members ?? {})
|
|
261
|
+
.filter((member) => member.kind === 'agent' && member.status !== 'retired')
|
|
262
|
+
.map(({ id, role, status }) => [id, { id, role: role || '未设置岗位', status, submitted: 0, accepted: 0, returned: 0 }]));
|
|
263
|
+
const submissions = new Map();
|
|
264
|
+
for (const event of events) {
|
|
265
|
+
if (!Number.isFinite(event.at) || event.at < since || event.at > now) continue;
|
|
266
|
+
const taskId = event.payload?.taskId;
|
|
267
|
+
if (typeof taskId !== 'string') continue;
|
|
268
|
+
if (event.type === 'task/submitted') {
|
|
269
|
+
const member = event.actor?.kind === 'agent' ? people.get(event.actor.memberId) : undefined;
|
|
270
|
+
submissions.set(taskId, member);
|
|
271
|
+
if (member) member.submitted += 1;
|
|
272
|
+
} else if (event.type === 'task/accepted' || event.type === 'task/changes-requested') {
|
|
273
|
+
const member = submissions.get(taskId);
|
|
274
|
+
if (member) member[event.type === 'task/accepted' ? 'accepted' : 'returned'] += 1;
|
|
275
|
+
submissions.delete(taskId);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const groups = new Map();
|
|
279
|
+
for (const member of people.values()) {
|
|
280
|
+
const group = groups.get(member.role) ?? { role: member.role, members: [], assigned: [], inProgress: 0 };
|
|
281
|
+
group.members.push({ ...member, returnRate: member.submitted ? member.returned / member.submitted : null });
|
|
282
|
+
groups.set(member.role, group);
|
|
283
|
+
}
|
|
284
|
+
const open = openTasks(state);
|
|
285
|
+
for (const task of open) {
|
|
286
|
+
const group = groups.get(people.get(task.assigneeId)?.role);
|
|
287
|
+
if (!group) continue;
|
|
288
|
+
if (task.status === 'pending') group.assigned.push(task);
|
|
289
|
+
if (task.status === 'in_progress') group.inProgress += 1;
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
since, now, capacity,
|
|
293
|
+
claimable: waitingSummary(claimableTasks(state, open), now),
|
|
294
|
+
pendingAcceptance: waitingSummary(open.filter(({ status }) => status === 'pending_acceptance'), now),
|
|
295
|
+
roles: [...groups.values()].map(({ assigned, ...group }) => ({ ...group, assignedQueue: waitingSummary(assigned, now) })),
|
|
296
|
+
advice,
|
|
297
|
+
suppressed,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
|
|
239
301
|
/**
|
|
240
302
|
* 加人建议(用户 2026-11-20:从管理角度看推进过慢就该加人,由 Human 决定)。插件自己按看板判定,不靠模型:
|
|
241
303
|
* - 开发不够:有可认领的待办等了 ≥ 30 分钟,却没有空闲开发(空闲开发会先被 planIdleStaffing 派活)。
|
|
@@ -247,13 +309,13 @@ export const HOST_SUBAGENT_LIMIT = 8;
|
|
|
247
309
|
* 同一类建议 4 小时内只提一次;上一条还没处理(unread)时不再提。冷却读账本里的收件箱,重启不丢。
|
|
248
310
|
*
|
|
249
311
|
* @param {any} state 账本投影
|
|
250
|
-
* @param {{ now: number, inTurn: (sessionId: string) => boolean, capacity?: number, humanId?: string | null, wait?: number }} options 「慢」的门槛 wait 来自配置 staffingAdviceMinutes
|
|
312
|
+
* @param {{ now: number, inTurn: (sessionId: string) => boolean, capacity?: number, humanId?: string | null, wait?: number, onSuppressed?: (entry: object) => void }} options 「慢」的门槛 wait 来自配置 staffingAdviceMinutes
|
|
251
313
|
* @returns {Array<{ role: 'developer' | 'qa', action: 'add' | 'recover', count: number, memberIds: string[], title: string, reasons: string[], taskIds: string[] }>}
|
|
252
314
|
*/
|
|
253
|
-
export function planStaffingAdvice(state, { now, inTurn, capacity = HOST_SUBAGENT_LIMIT, humanId = null, wait = STAFFING_ADVICE_WAIT }) {
|
|
315
|
+
export function planStaffingAdvice(state, { now, inTurn, capacity = HOST_SUBAGENT_LIMIT, humanId = null, wait = STAFFING_ADVICE_WAIT, onSuppressed }) {
|
|
254
316
|
const open = openTasks(state);
|
|
255
317
|
if (open.length === 0) return [];
|
|
256
|
-
const age = (task) =>
|
|
318
|
+
const age = (task) => taskAge(task, now);
|
|
257
319
|
const minutes = (ms) => Math.round(ms / MINUTE);
|
|
258
320
|
const { qas, stalled } = teamRoles(state);
|
|
259
321
|
const advice = [];
|
|
@@ -278,11 +340,16 @@ export function planStaffingAdvice(state, { now, inTurn, capacity = HOST_SUBAGEN
|
|
|
278
340
|
: `${waited},${qas.length} 位验收人每人摊到 ${Math.ceil(waitingReview.length / qas.length)} 张`] }) });
|
|
279
341
|
}
|
|
280
342
|
const headcount = Object.values(state?.members ?? {}).filter((member) => member?.kind === 'agent' && member.status !== 'retired' && !STALLED_MEMBER_STATUSES.includes(member.status)).length;
|
|
281
|
-
const recent = (role) => Object.values(state?.inbox ?? {}).
|
|
343
|
+
const recent = (role) => Object.values(state?.inbox ?? {}).find((item) =>
|
|
282
344
|
item.ref?.kind === 'staffing_advice' && item.ref.role === role
|
|
283
345
|
&& (humanId === null || item.memberId === humanId)
|
|
284
346
|
&& (item.state === 'unread' || now - Number(item.createdAt ?? 0) < STAFFING_ADVICE_COOLDOWN));
|
|
285
|
-
return advice.filter((
|
|
347
|
+
return advice.filter(({ role, action, taskIds }) => {
|
|
348
|
+
const prior = recent(role);
|
|
349
|
+
if (prior === undefined) return true;
|
|
350
|
+
onSuppressed?.({ role, action, taskIds, reason: prior.state === 'unread' ? 'unread-advice' : 'cooldown' });
|
|
351
|
+
return false;
|
|
352
|
+
}).map((entry) => {
|
|
286
353
|
const reasons = [...entry.reasons];
|
|
287
354
|
const who = entry.role === 'developer' ? '开发' : '验收';
|
|
288
355
|
if (entry.action === 'recover') return { ...entry, reasons, title: `建议恢复停摆的${who}:${reasons.join(';')}` };
|