dsh-workplan 1.9.1 → 1.11.0
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 +317 -0
- package/README.en.md +8 -3
- package/README.md +9 -4
- package/client.js +195 -8
- package/docs/collaboration.md +16 -5
- package/docs/departments.md +2 -2
- package/docs/release-record-1.10.6-20261101.md +78 -0
- package/lib/auto-resume.js +175 -0
- package/lib/client.js +2742 -0
- package/lib/host.js +451 -4
- package/lib/plan.js +1011 -46
- package/lib/replan.js +602 -0
- package/lib/runtime.js +1826 -61
- package/package.json +2 -2
- package/src/auto-resume.ts +246 -0
- package/src/client.ts +212 -7
- package/src/host.ts +492 -3
- package/src/plan.ts +967 -41
- package/src/replan.ts +642 -0
- package/src/runtime.ts +1819 -57
package/client.js
CHANGED
|
@@ -84,6 +84,13 @@ window.__ModuleLoader__.load({
|
|
|
84
84
|
"done": "做好了",
|
|
85
85
|
"blocked": "卡住了"
|
|
86
86
|
},
|
|
87
|
+
"handoff": {
|
|
88
|
+
"open": "待处置",
|
|
89
|
+
"routed": "已指派",
|
|
90
|
+
"answered": "已答复",
|
|
91
|
+
"closed": "无需动作"
|
|
92
|
+
},
|
|
93
|
+
"handoffs": "跨部门需求",
|
|
87
94
|
"dept": {
|
|
88
95
|
"engineering": "工程研发",
|
|
89
96
|
"research": "研究分析",
|
|
@@ -117,7 +124,23 @@ window.__ModuleLoader__.load({
|
|
|
117
124
|
"willDeliver": "做完交付",
|
|
118
125
|
"waitFor": "要等",
|
|
119
126
|
"blockedReason": "卡住原因",
|
|
127
|
+
"pendingReason": "还没做完的原因",
|
|
128
|
+
"lastErrorNote": "上一轮的失败记录(已完成,仅留档)",
|
|
129
|
+
"notDeliverable": "还不能交付",
|
|
130
|
+
"notDeliverableHint": "「全部做完」不等于「可以交付」:交付还需要每一行都有可核对的证据。下面是没有通过的部分。",
|
|
120
131
|
"progressLabel": "进度",
|
|
132
|
+
"closureReported": "已回报",
|
|
133
|
+
"closureDone": "完成 · 待回报",
|
|
134
|
+
"closureAssigned": "已下发 · 待回应",
|
|
135
|
+
"closureAcknowledged": "已回应 · 执行中",
|
|
136
|
+
"closureInstructed": "已给指示 · 待执行",
|
|
137
|
+
"closureEscalated": "待你决定",
|
|
138
|
+
"closureRunning": "执行中",
|
|
139
|
+
"closureNoAck": "指示还没被执行",
|
|
140
|
+
"changePending": "需求变更待落实",
|
|
141
|
+
"changePendingHint": "你在执行中提出的变更已记录,本轮不会中途改写正在跑的任务;本轮结束后会按新需求重规划,已发出的变更不会丢失。",
|
|
142
|
+
"closureReplanned": "已重规划",
|
|
143
|
+
"closureReplannedTo": "已重规划 → 修订 {ids}",
|
|
121
144
|
"more": "更多细节(不看也不影响理解)",
|
|
122
145
|
"why": "为什么这样安排",
|
|
123
146
|
"whyHint": "先找出最关键的问题,再按顺序解决;每一步做完先检查,再决定下一步。",
|
|
@@ -256,6 +279,13 @@ window.__ModuleLoader__.load({
|
|
|
256
279
|
"done": "Done",
|
|
257
280
|
"blocked": "Stuck"
|
|
258
281
|
},
|
|
282
|
+
"handoff": {
|
|
283
|
+
"open": "Open",
|
|
284
|
+
"routed": "Assigned",
|
|
285
|
+
"answered": "Answered",
|
|
286
|
+
"closed": "No action"
|
|
287
|
+
},
|
|
288
|
+
"handoffs": "Cross-team needs",
|
|
259
289
|
"dept": {
|
|
260
290
|
"engineering": "Engineering",
|
|
261
291
|
"research": "Research",
|
|
@@ -289,7 +319,23 @@ window.__ModuleLoader__.load({
|
|
|
289
319
|
"willDeliver": "What it delivers",
|
|
290
320
|
"waitFor": "Waits for",
|
|
291
321
|
"blockedReason": "Why it is stuck",
|
|
322
|
+
"pendingReason": "Why it is not finished yet",
|
|
323
|
+
"lastErrorNote": "Previous attempt's failure (done, kept for the record)",
|
|
324
|
+
"notDeliverable": "Not deliverable yet",
|
|
325
|
+
"notDeliverableHint": "All rows done does not mean deliverable: every row needs checkable evidence. The gaps are listed below.",
|
|
292
326
|
"progressLabel": "Progress",
|
|
327
|
+
"closureReported": "Reported back",
|
|
328
|
+
"closureDone": "Done · not reported",
|
|
329
|
+
"closureAssigned": "Sent · no reply yet",
|
|
330
|
+
"closureAcknowledged": "Acknowledged",
|
|
331
|
+
"closureInstructed": "Instruction sent",
|
|
332
|
+
"closureEscalated": "Needs your call",
|
|
333
|
+
"closureRunning": "Running",
|
|
334
|
+
"closureNoAck": "Instruction not started yet",
|
|
335
|
+
"changePending": "Change request pending",
|
|
336
|
+
"changePendingHint": "Your mid-run change is recorded. This round will not rewrite running work; the plan is replanned from your new requirements as soon as this round ends, so nothing is lost.",
|
|
337
|
+
"closureReplanned": "Replanned",
|
|
338
|
+
"closureReplannedTo": "Replanned → revised {ids}",
|
|
293
339
|
"more": "More detail (optional)",
|
|
294
340
|
"why": "Why it is arranged this way",
|
|
295
341
|
"whyHint": "Find the most important problem first, solve in order, and check after each step before deciding the next one.",
|
|
@@ -1080,6 +1126,18 @@ window.__ModuleLoader__.load({
|
|
|
1080
1126
|
const value = t(key);
|
|
1081
1127
|
return value === key ? String(id || '') : value;
|
|
1082
1128
|
}
|
|
1129
|
+
/*
|
|
1130
|
+
* [1.11.0] 跨部门需求的四档文案(用户 m00687)。
|
|
1131
|
+
*
|
|
1132
|
+
* 客户端只做「状态值 → 文案」映射,不推导状态:服务端写 open/routed/
|
|
1133
|
+
* answered/closed,这里原样显示。未知值退回原文,避免把新状态误写成
|
|
1134
|
+
* “已答复”。
|
|
1135
|
+
*/
|
|
1136
|
+
function handoffStatusText(t, status) {
|
|
1137
|
+
const key = `handoff.${String(status ?? '')}`;
|
|
1138
|
+
const value = t(key);
|
|
1139
|
+
return value === key ? String(status || '') : value;
|
|
1140
|
+
}
|
|
1083
1141
|
function levelText(t, value) {
|
|
1084
1142
|
const key = `level.${value}`;
|
|
1085
1143
|
const text = t(key);
|
|
@@ -1370,13 +1428,89 @@ window.__ModuleLoader__.load({
|
|
|
1370
1428
|
}
|
|
1371
1429
|
function SubtaskRow({ item, subtask, index, t }) {
|
|
1372
1430
|
const status = item?.status ?? 'pending';
|
|
1373
|
-
|
|
1431
|
+
/*
|
|
1432
|
+
* [1.11.0] 闭环徽标:完成 ≠ 已回报;被重规划的行灰化并指向后继。
|
|
1433
|
+
*
|
|
1434
|
+
* 这里只渲染 `serialisePlan` 下发的 `closure/replacedBy`,不在客户端
|
|
1435
|
+
* 推导任何状态(契约 §8.3:客户端不得维护本地状态机)。计划定义里的
|
|
1436
|
+
* `supersededAt` 是同一事实的镜像,只用于「状态行缺失」的历史载荷。
|
|
1437
|
+
*/
|
|
1438
|
+
const closure = item?.closure ?? (subtask?.supersededAt ? 'replanned' : null);
|
|
1439
|
+
const replacedBy = Array.isArray(item?.replacedBy)
|
|
1440
|
+
? item.replacedBy
|
|
1441
|
+
: (Array.isArray(subtask?.replacedBy) ? subtask.replacedBy : []);
|
|
1442
|
+
/*
|
|
1443
|
+
* [1.11.0] M9:闭环每一档都要在左侧栏可见。
|
|
1444
|
+
*
|
|
1445
|
+
* 只显示「已回报/已重规划」时,一条正在等主 Agent 决定的请示看起来就是
|
|
1446
|
+
* 普通「受阻」,主 Agent 与用户都无法从进度栏看出「它在等你拍板」。
|
|
1447
|
+
* 文案由服务端下发的 `closure` 决定,客户端不推导状态。
|
|
1448
|
+
*/
|
|
1449
|
+
const closureText = closure === 'replanned'
|
|
1450
|
+
? (replacedBy.length > 0 ? fill(t('closureReplannedTo'), { ids: replacedBy.join('、') }) : t('closureReplanned'))
|
|
1451
|
+
: closure === 'reported' ? t('closureReported')
|
|
1452
|
+
: closure === 'done' ? t('closureDone')
|
|
1453
|
+
: closure === 'assigned' ? t('closureAssigned')
|
|
1454
|
+
: closure === 'acknowledged' ? t('closureAcknowledged')
|
|
1455
|
+
: closure === 'instructed' ? t('closureInstructed')
|
|
1456
|
+
: closure === 'escalated' ? t('closureEscalated')
|
|
1457
|
+
/*
|
|
1458
|
+
* [1.11.0] 瞬态兜底(T10 N7):状态行已经 in_progress,
|
|
1459
|
+
* 但闭环字段还是 pending(旧载荷 / 重建中的一行)。没有
|
|
1460
|
+
* 徽标会让这一行看起来「没有闭环含义」,补一个只描述
|
|
1461
|
+
* 事实的「执行中」,不推断它是否已回报。
|
|
1462
|
+
*/
|
|
1463
|
+
: status === 'in_progress' ? t('closureRunning')
|
|
1464
|
+
: '';
|
|
1465
|
+
const closureLabel = closureText;
|
|
1466
|
+
const closureTone = closure === 'reported' ? 'done'
|
|
1467
|
+
: closure === 'escalated' ? 'blocked'
|
|
1468
|
+
: closure === 'replanned' ? 'idle'
|
|
1469
|
+
: 'idle';
|
|
1470
|
+
/*
|
|
1471
|
+
* [1.11.0] 「指示已发出、子会话还没动」(T10 N4)。
|
|
1472
|
+
*
|
|
1473
|
+
* `instructionOverdue` 由 60s 定时器写、由子会话首次进展清除;它描述的
|
|
1474
|
+
* 是等待事实,不是失败,所以用 blocked 色提醒但不改 status。
|
|
1475
|
+
*/
|
|
1476
|
+
const instructionOverdue = item?.instructionOverdue === true;
|
|
1477
|
+
const tone = closure === 'replanned' ? 'idle' : toneOfStatus(status);
|
|
1374
1478
|
const pct = clampPct(item?.progress ?? 0);
|
|
1375
|
-
return h('div', { className: `dsh-wp-subtask dsh-wp-tone-${tone}` }, h('div', { className: 'dsh-wp-subtask-head' }, h('div', { className: 'dsh-wp-subtask-title' }, `${workLabel(t, index)}:${subtask.title}`), h(Pill, { tone }, progressText(item, t))), h('div', { className: 'dsh-wp-subtask-meta' }, h('span', null, `${t('who')}:${deptName(t, subtask.department)} · ${subtask.role}`)), h('div', { className: 'dsh-wp-subtask-body' }, h('p', null, h('strong', null, `${t('what')}:`), subtask.objective), h('div', null, h('strong', null, `${t('how')}:`), h(Bullets, { items: subtask.method })), h('div', null, h('strong', null, `${t('doneWhen')}:`), h(Bullets, { items: subtask.acceptance })), subtask.outputs?.length ? h('div', null, h('strong', null, `${t('willDeliver')}:`), h(Bullets, { items: subtask.outputs })) : null, subtask.dependsOn?.length ? h('p', { className: 'dsh-wp-muted' }, `${t('waitFor')}:先等前面的工作做完,才能开始这一步。`) : null), status === 'in_progress' ? h(Progress, { value: pct, tone }) : null, status === 'in_progress' ? h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${t('progressLabel')} ${pct}%`)) : null,
|
|
1479
|
+
return h('div', { className: `dsh-wp-subtask dsh-wp-tone-${tone}` }, h('div', { className: 'dsh-wp-subtask-head' }, h('div', { className: 'dsh-wp-subtask-title' }, `${workLabel(t, index)}:${subtask.title}`), closureLabel ? h(Pill, { tone: closureTone }, closureLabel) : null, instructionOverdue ? h(Pill, { tone: 'blocked' }, t('closureNoAck')) : null, h(Pill, { tone }, progressText(item, t))), h('div', { className: 'dsh-wp-subtask-meta' }, h('span', null, `${t('who')}:${deptName(t, subtask.department)} · ${subtask.role}`)), h('div', { className: 'dsh-wp-subtask-body' }, h('p', null, h('strong', null, `${t('what')}:`), subtask.objective), h('div', null, h('strong', null, `${t('how')}:`), h(Bullets, { items: subtask.method })), h('div', null, h('strong', null, `${t('doneWhen')}:`), h(Bullets, { items: subtask.acceptance })), subtask.outputs?.length ? h('div', null, h('strong', null, `${t('willDeliver')}:`), h(Bullets, { items: subtask.outputs })) : null, subtask.dependsOn?.length ? h('p', { className: 'dsh-wp-muted' }, `${t('waitFor')}:先等前面的工作做完,才能开始这一步。`) : null), status === 'in_progress' ? h(Progress, { value: pct, tone }) : null, status === 'in_progress' ? h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${t('progressLabel')} ${pct}%`)) : null,
|
|
1480
|
+
/*
|
|
1481
|
+
* [1.11.0] 跨部门需求(用户 m00687):提出方、指派对象、答复都必须在
|
|
1482
|
+
* 进度栏可见。否则用户只能从结果消息的一段文字里猜「这条需求谁在办、
|
|
1483
|
+
* 办没办」,而交付门禁却已经因为它把整份计划拦住了。
|
|
1484
|
+
*/
|
|
1485
|
+
Array.isArray(item?.handoffs) && item.handoffs.length
|
|
1486
|
+
? h('div', { className: 'dsh-wp-subtask-body' }, h('div', null, h('strong', null, `${t('handoffs')}:`)), h('ul', { className: 'dsh-wp-muted' }, item.handoffs.map((handoff) => h('li', { key: String(handoff?.id ?? '') }, `${String(handoff?.id ?? 'H?')} ${String(handoff?.request ?? '')}`
|
|
1487
|
+
+ `${handoff?.department ? ` → ${deptName(t, handoff.department)}` : ''}`
|
|
1488
|
+
+ `|${handoffStatusText(t, handoff?.status)}`
|
|
1489
|
+
+ `${handoff?.response ? `:${String(handoff.response)}` : ''}`))))
|
|
1490
|
+
: null, status !== 'blocked' && item?.summary ? h('p', { className: 'dsh-wp-muted' }, `${t('summary')}:${plainError(item.summary)}`) : null,
|
|
1491
|
+
/*
|
|
1492
|
+
* [1.10.0] R-02:「卡住原因」只属于没做完的行。
|
|
1493
|
+
*
|
|
1494
|
+
* 1.9.1 无条件渲染 `item.error`,只要历史记录里残留一句失败文本,就会在
|
|
1495
|
+
* 一行 status=done 的卡片下面写「卡住原因:本轮预算用尽…」——「已完成」
|
|
1496
|
+
* 与「卡住了」同屏,正是用户截图里的矛盾。数据层已经保证 done 行没有
|
|
1497
|
+
* error(I12),这里再做一次呈现守卫:任何历史载荷、旧缓存都不会重现。
|
|
1498
|
+
*/
|
|
1499
|
+
item?.error && status !== 'done'
|
|
1500
|
+
? h('p', { className: 'dsh-wp-error-text' }, `${t(status === 'blocked' ? 'blockedReason' : 'pendingReason')}:${plainError(item.error)}`)
|
|
1501
|
+
: null, status === 'done' && item?.lastError
|
|
1502
|
+
? h('p', { className: 'dsh-wp-muted' }, `${t('lastErrorNote')}:${plainError(item.lastError)}`)
|
|
1503
|
+
: null, h('details', { className: 'dsh-wp-details' }, h('summary', null, t('more')), h('div', { className: 'dsh-wp-grid', style: { marginTop: '8px' } }, h(Field, { label: t('person') }, subtask.role || '—'), h(Field, { label: t('inputs') }, h(Bullets, { items: subtask.inputs })), h(Field, { label: t('risk') }, subtask.risk || '—'), h(Field, { label: t('planId') }, subtask.id || '—'))));
|
|
1376
1504
|
}
|
|
1377
1505
|
function StageCard({ stage, statuses, index, t }) {
|
|
1378
1506
|
const byId = useMemo(() => new Map((statuses || []).map((item) => [item.subtaskId, item])), [statuses]);
|
|
1379
|
-
const
|
|
1507
|
+
const allItems = (stage.subtasks || []).map((subtask) => ({ subtask, item: byId.get(subtask.id) }));
|
|
1508
|
+
/*
|
|
1509
|
+
* [1.11.0] 被重规划替换/撤销的行仍然渲染(可追溯),但不进入阶段分母:
|
|
1510
|
+
* 否则「替换一项」会让阶段永远停在 4/5,用户看到的进度与总数互相矛盾。
|
|
1511
|
+
* 同一个 `supersededAt` 也决定了 `definedSubtaskCount` 的分母。
|
|
1512
|
+
*/
|
|
1513
|
+
const items = allItems.filter(({ subtask }) => !subtask.supersededAt);
|
|
1380
1514
|
const done = items.filter(({ item }) => item?.status === 'done').length;
|
|
1381
1515
|
const blocked = items.filter(({ item }) => item?.status === 'blocked').length;
|
|
1382
1516
|
const inProgress = items.some(({ item }) => item?.status === 'in_progress');
|
|
@@ -1399,7 +1533,7 @@ window.__ModuleLoader__.load({
|
|
|
1399
1533
|
title: `${stageLabel(t, index)}:${stage.name}`,
|
|
1400
1534
|
meta: `${done}/${items.length} ${t('stats.done')}`,
|
|
1401
1535
|
badge: h(Pill, { tone }, stateText),
|
|
1402
|
-
}, h('div', { className: 'dsh-wp-stage-goal' }, `${t('what')}:${stage.goal}`), h('div', { className: 'dsh-wp-checkpoint' }, `${t('checkpoint')}:${stage.checkpoint}`),
|
|
1536
|
+
}, h('div', { className: 'dsh-wp-stage-goal' }, `${t('what')}:${stage.goal}`), h('div', { className: 'dsh-wp-checkpoint' }, `${t('checkpoint')}:${stage.checkpoint}`), allItems.map(({ subtask, item }, subIndex) => h(SubtaskRow, { key: subtask.id, subtask, item, index: subIndex, t }))));
|
|
1403
1537
|
}
|
|
1404
1538
|
function Analysis({ session, t }) {
|
|
1405
1539
|
const task = session.taskUnderstanding || {};
|
|
@@ -1431,6 +1565,24 @@ window.__ModuleLoader__.load({
|
|
|
1431
1565
|
function planPercent(done, total) {
|
|
1432
1566
|
return total > 0 ? Math.round((done / total) * 100) : null;
|
|
1433
1567
|
}
|
|
1568
|
+
/*
|
|
1569
|
+
* [1.10.0] C-11:100% 只有一个来源。
|
|
1570
|
+
*
|
|
1571
|
+
* `done/total` 是「行数」,服务端的 `stats.progress` 是「加权完成度」,
|
|
1572
|
+
* 二者在 12 done + 1 blocked@95 时分别是 92 与 95(T3 实测)。界面只展示
|
|
1573
|
+
* 一个数:行数百分比;但只要加权口径还差一点(或全部行 done 却不可交付),
|
|
1574
|
+
* 就不允许显示成 100——"100%" 在这一页上必须同时意味着「每行都做完」。
|
|
1575
|
+
*/
|
|
1576
|
+
function cappedPercent(raw, stats) {
|
|
1577
|
+
if (raw === null)
|
|
1578
|
+
return null;
|
|
1579
|
+
const weighted = Number(stats?.progress);
|
|
1580
|
+
if (raw >= 100 && Number.isFinite(weighted) && weighted < 100)
|
|
1581
|
+
return 99;
|
|
1582
|
+
if (raw > 100)
|
|
1583
|
+
return 100;
|
|
1584
|
+
return raw;
|
|
1585
|
+
}
|
|
1434
1586
|
// 与 groupTotals 同一套口径:先夹到 [0,total],再让「正在做/还没开始」
|
|
1435
1587
|
// 吃掉剩余量,四段之和恒等于总数(构成条不会溢出或出现负宽度)。
|
|
1436
1588
|
function planCounts(stats) {
|
|
@@ -1440,7 +1592,7 @@ window.__ModuleLoader__.load({
|
|
|
1440
1592
|
const blocked = Math.min(planCount(source.blocked), total - done);
|
|
1441
1593
|
const active = Math.min(planCount(source.inProgress), total - done - blocked);
|
|
1442
1594
|
const pending = Math.max(0, total - done - blocked - active);
|
|
1443
|
-
return { total, done, active, blocked, pending, percent: planPercent(done, total) };
|
|
1595
|
+
return { total, done, active, blocked, pending, percent: cappedPercent(planPercent(done, total), source) };
|
|
1444
1596
|
}
|
|
1445
1597
|
/*
|
|
1446
1598
|
* [1.5.2] 完成语义的第二道保险:状态文案必须服从计数事实。
|
|
@@ -1522,7 +1674,19 @@ window.__ModuleLoader__.load({
|
|
|
1522
1674
|
const rows = [];
|
|
1523
1675
|
const list = Array.isArray(stages) ? stages : [];
|
|
1524
1676
|
list.forEach((stage, index) => {
|
|
1525
|
-
|
|
1677
|
+
/*
|
|
1678
|
+
* [1.11.0] 被重规划替换的旧行不参与阶段步进条(T10 N1)。
|
|
1679
|
+
*
|
|
1680
|
+
* 卡片头部按 `definedSubtaskCount` 已排除 `supersededAt`,这里却把
|
|
1681
|
+
* 计划定义里的全部行都算进分母,于是重规划后出现「头部 100%,
|
|
1682
|
+
* 阶段条 1/2 做好了」的双口径。旧行仍是审计记录(下面按状态行渲染、
|
|
1683
|
+
* 灰化),但不再是「还要做的工作」,所以不进入 total/done/active/
|
|
1684
|
+
* blocked 四个计数;一个阶段若只剩旧行,整段也不再显示。
|
|
1685
|
+
*/
|
|
1686
|
+
const allSubtasks = Array.isArray(stage?.subtasks) ? stage.subtasks : [];
|
|
1687
|
+
const subtasks = allSubtasks.filter((subtask) => !subtask?.supersededAt);
|
|
1688
|
+
if (allSubtasks.length > 0 && subtasks.length === 0)
|
|
1689
|
+
return;
|
|
1526
1690
|
let done = 0;
|
|
1527
1691
|
let active = 0;
|
|
1528
1692
|
let blocked = 0;
|
|
@@ -1755,7 +1919,30 @@ window.__ModuleLoader__.load({
|
|
|
1755
1919
|
badge: h(Pill, { tone }, phaseLabel(phase, session, t)),
|
|
1756
1920
|
}, session.updatedAt
|
|
1757
1921
|
? h('div', { className: 'dsh-wp-meta dsh-wp-session-updated' }, `${t('updatedAt')} ${formatTime(session.updatedAt)}`)
|
|
1758
|
-
: null, open === true ? h(PlanOverview, { t, stats, counts, rows: stageRows }) : null, session.degraded ? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('degraded')), h('div', null, plainError(session.error || '')), h('div', { className: 'dsh-wp-muted' }, t('degradedHint'))) : null,
|
|
1922
|
+
: null, open === true ? h(PlanOverview, { t, stats, counts, rows: stageRows }) : null, session.degraded ? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('degraded')), h('div', null, plainError(session.error || '')), h('div', { className: 'dsh-wp-muted' }, t('degradedHint'))) : null,
|
|
1923
|
+
/*
|
|
1924
|
+
* [1.11.0] 执行中收到的需求变更(T10 N5)。
|
|
1925
|
+
*
|
|
1926
|
+
* 服务端从 1.11.0 起把 `changeRequest` 放进每份载荷,但卡片原先
|
|
1927
|
+
* 一字不显示:用户提了变更、工具也回了「已记录」,进度栏却看不出
|
|
1928
|
+
* 来,只能等主 Agent 自己再解释一遍。这里只显示「已记录 + 原文 +
|
|
1929
|
+
* 何时生效」,不显示任何未落地的承诺。
|
|
1930
|
+
*/
|
|
1931
|
+
session.changeRequest?.status === 'pending'
|
|
1932
|
+
? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('changePending')), h('div', { className: 'dsh-wp-muted' }, t('changePendingHint')), typeof session.changeRequest.text === 'string' && session.changeRequest.text
|
|
1933
|
+
? h('div', { className: 'dsh-wp-error-text' }, plainError(session.changeRequest.text))
|
|
1934
|
+
: null) : null,
|
|
1935
|
+
/*
|
|
1936
|
+
* [1.10.0] C-09:把服务端已经下发、却从来没人读的交付门禁搬上界面。
|
|
1937
|
+
*
|
|
1938
|
+
* 1.9.1 的载荷里一直带着 `deliveryReady / deliveryBlockers`(present 用的
|
|
1939
|
+
* 就是同一份判定),但 `client.ts` 一处都没消费。于是「13/13、100%、绿」,
|
|
1940
|
+
* 而 present 被拒——「进度 100% ≠ 可交付」这条事实在界面上完全不可见。
|
|
1941
|
+
*/
|
|
1942
|
+
session.deliveryReady === false
|
|
1943
|
+
? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('notDeliverable')), h('div', { className: 'dsh-wp-muted' }, t('notDeliverableHint')), Array.isArray(session.deliveryBlockers) && session.deliveryBlockers.length
|
|
1944
|
+
? h('ul', { className: 'dsh-wp-muted' }, session.deliveryBlockers.slice(0, 6).map((blocker, index) => h('li', { key: index }, plainError(String(blocker)))))
|
|
1945
|
+
: null) : null, h(Guide, { session, t }), departments.length ? h('div', { className: 'dsh-wp-section' }, h('div', { className: 'dsh-wp-section-title' }, t('who')), h('div', { className: 'dsh-wp-departments' }, departments.map((dept) => h(Pill, { key: dept.id, tone: dept.blocked > 0 ? 'blocked' : dept.done === dept.total ? 'done' : 'active' }, `${deptName(t, dept.id)} ${dept.done}/${dept.total} ${t('stats.done')}`)))) : null, h('div', { className: 'dsh-wp-section' }, h('div', { className: 'dsh-wp-section-title' }, t('steps')), (session.stages || []).map((stage, index) => h(StageCard, {
|
|
1759
1946
|
key: stage.id,
|
|
1760
1947
|
stage,
|
|
1761
1948
|
statuses: session.statuses || [],
|
|
@@ -2302,7 +2489,7 @@ window.__ModuleLoader__.load({
|
|
|
2302
2489
|
return {
|
|
2303
2490
|
label: raw.length > 14 ? `${raw.slice(0, 14)}…` : raw,
|
|
2304
2491
|
// [1.5.2] 与卡片/组头同一个百分比函数,杜绝第二套口径。
|
|
2305
|
-
value: planPercent(planCount(session.stats?.done), planCount(session.stats?.total)) ?? 0,
|
|
2492
|
+
value: cappedPercent(planPercent(planCount(session.stats?.done), planCount(session.stats?.total)), session.stats) ?? 0,
|
|
2306
2493
|
};
|
|
2307
2494
|
}), [groups, t]);
|
|
2308
2495
|
/*
|
package/docs/collaboration.md
CHANGED
|
@@ -251,21 +251,32 @@ pending ──dispatch──▶ executing ──全部 done──▶ done
|
|
|
251
251
|
子 Agent 必须用**自由文本**汇报,并满足:
|
|
252
252
|
|
|
253
253
|
- 优先在输出末尾追加结构化证据块(`<!-- WORKPLAN_EVIDENCE:START -->` … JSON … `<!-- WORKPLAN_EVIDENCE:END -->`),含 `status` / `blockedReason` / `acceptance[]` / `artifacts[]` / `needs[]`。这是 1.7.0 的主信号:`partial`、任一验收 `fail`、坏块都判受阻,只有全 `pass` 直接采信。
|
|
254
|
-
- 没有证据块时,失败仍可**第一行**写 `BLOCKED: 原因`(大小写不敏感,中英文冒号都认,行首允许空白)——按 `legacy`
|
|
254
|
+
- 没有证据块时,失败仍可**第一行**写 `BLOCKED: 原因`(大小写不敏感,中英文冒号都认,行首允许空白)——按 `legacy` 判受阻。
|
|
255
|
+
- **1.11.0 起,没有证据块、也没有 `BLOCKED` 的「纯散文」不再算完成**:默认(`strictCompletion`,可用 `DSH_WORKPLAN_STRICT_COMPLETION=0` 关闭)判 `blocked` + `unverified`,错误信息写明「结果块缺失,无法确认验收项是否真的通过」。历史回放仍按 `legacy` 读取,避免旧计划整体失效。
|
|
256
|
+
- 验收条目自称 `pass` 但 `evidence` 为空时,1.11.0 降级为 `unverified`,且 `deliveryReadiness` 增加「验收自称通过但没有证据」阻塞项。
|
|
255
257
|
- 正文写清:做了什么、证据/文件路径、验收结果、遗留问题;
|
|
256
258
|
- 不编造命令输出、文件或证据;无法确认就写「未验证」;
|
|
257
259
|
- 需要别人配合时,写「需要主 Agent 执行/确认什么」,**不要等待或空转**。
|
|
258
260
|
|
|
259
261
|
`summary` 会被截断到 3000 字,因此**关键结论和绝对路径要放在最前面**。
|
|
260
262
|
|
|
263
|
+
### 5.2.1 验收覆盖与上游门槛(1.11.0)
|
|
264
|
+
|
|
265
|
+
- **验收不可自证**:裁决与交付门共用 `acceptanceCoverage`。计划写了 N 条验收,证据块必须逐条回应;允许措辞差异(规范化后包含关系),短文本(<6 字)只接受等值。少一条即 `blocked/unverified`,交付阻塞写明「验收项未被逐条回应(N/M)」。
|
|
266
|
+
- **未验收上游不得解锁下游**:调度门 `dependencyOk` 对上游 `verification` 为 `unverified` / `failed` 时返回 false;`structured` 与 `legacy`(旧日志)仍放行。下游因此停在 pending,并由 `describePendingCause` 说明原因。
|
|
267
|
+
- **cancel 的悬挂下游**:`replan cancel` 不重写下游依赖;派发与交付判定前由 `blockCancelledDependents` 把这类下游标成 `blocked` 并写明处理方式,不再永久 pending。
|
|
268
|
+
- **子会话不得直接交付**:`present` 守卫对非根会话返回 `NOT_ROOT`;产物写工作区,由主 Agent 统一核对后交付。
|
|
269
|
+
|
|
261
270
|
### 5.3 跨部门转达
|
|
262
271
|
|
|
263
|
-
1.
|
|
272
|
+
1.11.0 **仍没有**子 Agent 直连、共享黑板或会签——这是刻意的权限边界,不是遗漏。跨部门只有三条路:
|
|
264
273
|
|
|
265
|
-
1.
|
|
266
|
-
|
|
274
|
+
1. **带编号的 hand-off(1.11.0 新增,唯一处置入口)**:子 Agent 每条 `needs` 由 `applyStatus` 自动登记为 `{id: H1, request, department, status}`;主 Agent 用 `dsh_workplan_handoff` 处置:`list` / `assign`(登记责任部门)/ `resolve`(写入答复或产物引用)/ `close`(确认无需动作)。四态为 `open → routed → answered / closed`。**未处置的 hand-off 会进 `deliveryReadiness`,直接拦住交付**;对正处于「待指示」的行执行 `resolve`,会复用 `instructSubtask` 把答复直接投递给该子会话。
|
|
275
|
+
- `assign` 只登记责任,**不会自动产生工作**(插件没有常驻部门代理);需要产出时用 `dsh_workplan_replan(action=add)` 建该部门的子任务,或由主 Agent 自己完成,再 `resolve`。
|
|
276
|
+
2. **经主 Agent 对话**:`dsh_workplan_instruct` 回答请示、`dsh_workplan_replan` 就地修订计划;
|
|
277
|
+
3. **经工作区文件**:上游把接口/产物落到双方都能读到的路径,并在摘要里写绝对路径;`dependsOn` 上游的 `artifacts[].ref`(`exists:true`)会作为「可消费产物」注入下游提示词。
|
|
267
278
|
|
|
268
|
-
「兄弟任务只读一览」与 `needs`
|
|
279
|
+
「兄弟任务只读一览」与 `needs` 清单自 1.7.0 起存在(`buildTeamBrief`、`buildResultMessage`);子 Agent 直连仍然不开放。
|
|
269
280
|
|
|
270
281
|
---
|
|
271
282
|
|
package/docs/departments.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- **是职责标签。** `src/plan.ts#DEPARTMENTS` 里的 12 个 key 决定子任务的提示词、面板分组与统计口径。
|
|
8
8
|
- **不是组织架构。** 1.7.0 仍没有部门负责人、部门队列、部门内串行、部门预算;同一部门的两个子任务也可以并行。
|
|
9
|
-
- **不是通信通道。** 部门之间不能直接对话;跨部门信息经主 Agent 转达、落到工作区文件,或写进子 Agent 回传的 `needs
|
|
9
|
+
- **不是通信通道。** 部门之间不能直接对话;跨部门信息经主 Agent 转达、落到工作区文件,或写进子 Agent 回传的 `needs`(1.11.0 起自动登记为带编号、可处置、会拦住交付的 hand-off,见协作契约 §5.3)。
|
|
10
10
|
- **不代表权限。** 任何部门都不能派发、改判、取消计划;这些只有主 Agent 能做。
|
|
11
11
|
|
|
12
12
|
选部门的唯一标准:**这件工作主要由谁的专业判断负责,就选谁。** 拿不准时按「产物归谁验收」选,而不是按「谁顺手动一下」选。
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
|---|---|---|---|
|
|
61
61
|
| 串联 | 下游依赖上游结论/产物 | 计划里写 `dependsOn: ["T1"]` | 只有上游 `done` 下游才开跑;下游只看到上游摘要,**务必把路径写进摘要** |
|
|
62
62
|
| 并行对齐 | 两件事可同时做,但接口要对齐 | 同一阶段、无依赖 | 彼此看不到对方;接口必须由计划或主 Agent 事先写死 |
|
|
63
|
-
| 升级转达 | 需要另一个部门补信息/做决定 |
|
|
63
|
+
| 升级转达 | 需要另一个部门补信息/做决定 | 子 Agent 写 `needs` 或调用 `dsh_workplan_escalate`;主 Agent 用 `dsh_workplan_handoff` 处置(`assign`/`resolve`/`close`),用 `dsh_workplan_instruct` 下达指示 | 1.11.0 起 `needs` 自动登记为带编号的 hand-off,未处置拦住交付;`assign` 只登记责任,需要产出时用 `dsh_workplan_replan(action=add)` 建子任务 |
|
|
64
64
|
|
|
65
65
|
### 2.4 交接自检清单(交接前逐条过)
|
|
66
66
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Release record — v1.10.6(2026-11-01)
|
|
2
|
+
|
|
3
|
+
本文件按 `RELEASING.md` 第 6 节生成:只记录可复核的证据,不写形容词。
|
|
4
|
+
|
|
5
|
+
## 1. 源码与版本
|
|
6
|
+
|
|
7
|
+
| 项目 | 值 |
|
|
8
|
+
|---|---|
|
|
9
|
+
| commit | `5cecb83b4e3c9b42107b2055f2b0825b4c2fb40a` |
|
|
10
|
+
| tag | `v1.10.6`(annotated,tag object `1414bb26975e6a5ac97265703488a25d607595c5`) |
|
|
11
|
+
| package.json version | `1.10.6` |
|
|
12
|
+
| package-lock.json version | `1.10.6`(root + `packages[""]`) |
|
|
13
|
+
| src/host.ts `meta.version` | `1.10.6` |
|
|
14
|
+
| CHANGELOG | `## 1.10.6 — 2026-11-01` |
|
|
15
|
+
|
|
16
|
+
## 2. 发布前检查
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
npm run check → 通过(tsc --noEmit,无输出)
|
|
20
|
+
npm test → tests 332 / pass 332 / fail 0(duration 4.37s)
|
|
21
|
+
构建可复现(build 后 git diff lib client.js)→ 无差异
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
A/B 跨版本探针(R-W5-01):本次改动集中在重试链路与 auto-resume 开关,未触及
|
|
25
|
+
superseded/cancelled 信封与 present 判定,探针结论沿用 v1.9.1 记录的 PASS;未重跑,
|
|
26
|
+
此处如实标注为"未在 1.10.6 树重跑"。
|
|
27
|
+
|
|
28
|
+
## 3. GitHub Release
|
|
29
|
+
|
|
30
|
+
| 项目 | 值 |
|
|
31
|
+
|---|---|
|
|
32
|
+
| Release | https://github.com/abbaababa/dsh-workplan/releases/tag/v1.10.6 |
|
|
33
|
+
| 资产 | `dsh-workplan-1.10.6.tgz` |
|
|
34
|
+
| 大小 | 805,574 bytes(API 回报 `state: uploaded`,大小一致) |
|
|
35
|
+
| sha256 | `0f11fc01c98fc1ba7079b6b2eb87c69c495f79e118dfc01e50141891d7cc2718` |
|
|
36
|
+
| 构建方式 | 从 tag 干净克隆 → `npm ci` → `npm run build` → `npm pack` |
|
|
37
|
+
|
|
38
|
+
## 4. npm
|
|
39
|
+
|
|
40
|
+
| 项目 | 值 |
|
|
41
|
+
|---|---|
|
|
42
|
+
| 版本 | `dsh-workplan@1.10.6`,`dist-tags.latest = 1.10.6` |
|
|
43
|
+
| tarball | https://registry.npmjs.org/dsh-workplan/-/dsh-workplan-1.10.6.tgz |
|
|
44
|
+
| shasum | `7ba4fdf8c5c69c507b581a2beb511accd1e19826` |
|
|
45
|
+
| integrity | `sha512-O98ViT+dm/fO4dMQgZ0TTmIRFn11Mee3aOzS6AXkVMXnxYcU8pCrk0MiCGBaZ2XB7y60PhOiec6hcCI44eMx6A==` |
|
|
46
|
+
| 发布账号 | `open-dsh` |
|
|
47
|
+
| 端到端安装验证 | 空目录 `npm i dsh-workplan@1.10.6` → `added 1 package in 844ms`,`node_modules/dsh-workplan` 版本 1.10.6,`lib/` 存在 |
|
|
48
|
+
|
|
49
|
+
## 5. 索引源(dsh-plugin-catalog)
|
|
50
|
+
|
|
51
|
+
| 项目 | 值 |
|
|
52
|
+
|---|---|
|
|
53
|
+
| 上游条目 | `data/plugins/abbaababa__dsh-workplan.yml` |
|
|
54
|
+
| PR | https://github.com/awesome-dsh-plugin/awesome-dsh-plugin/pull/11154 |
|
|
55
|
+
| 变更 | `tarball:` 由 v1.8.3 指向 v1.10.6(只改这一行) |
|
|
56
|
+
| 合并前 catalog 状态 | jsDelivr `index.json` 中该条目 `versions` 仍为 `1.8.4`(catalog 由上游 CI 依 npm 重建,本仓库无法直接触发) |
|
|
57
|
+
| 合并后复验命令 | `npm view dsh-plugin-catalog@latest version`;`curl -s https://cdn.jsdelivr.net/npm/dsh-plugin-catalog/index.json \| grep -o '"name":"dsh-workplan"'` |
|
|
58
|
+
|
|
59
|
+
## 6. 已知限制
|
|
60
|
+
|
|
61
|
+
- 本机对 `github.com` 直连(curl)不可达(返回 000),因此 Release 资产的 HTTP 200
|
|
62
|
+
复验未能用 curl 完成;改用 GitHub API 校验资产存在、`state: uploaded` 且大小与本地
|
|
63
|
+
制品一致(805,574 bytes)。资产字节的 sha256 已在打包时记录。
|
|
64
|
+
- catalog 收录依赖上游 CI,PR 合并后需要等待一轮构建,本记录不预先声称已收录。
|
|
65
|
+
|
|
66
|
+
## 7. 回滚
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# npm(24 小时内)
|
|
70
|
+
npm unpublish dsh-workplan@1.10.6
|
|
71
|
+
# 或发布 1.10.7 补丁,不覆盖 1.10.6
|
|
72
|
+
|
|
73
|
+
# GitHub
|
|
74
|
+
gh release delete v1.10.6 --repo abbaababa/dsh-workplan --yes # tag 保留可追溯
|
|
75
|
+
|
|
76
|
+
# 索引源
|
|
77
|
+
把 PR 中的 tarball 改回 v1.8.3(或合并后反向 PR),并重跑 `npm view dsh-plugin-catalog@latest version` 确认
|
|
78
|
+
```
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [1.10.4][auto-resume] Automatic continuation of a plan whose round budget ran out.
|
|
3
|
+
*
|
|
4
|
+
* Why this module exists
|
|
5
|
+
* ----------------------
|
|
6
|
+
* The 2026-11-01 incident: subtask T12 was killed by the whole-round budget
|
|
7
|
+
* (`TOTAL_TIMEOUT`, 20 min) at 15:31:26, reset to `pending`, and then **never
|
|
8
|
+
* ran again** — the plan stayed `paused` until a human dispatched it 24 minutes
|
|
9
|
+
* later. `shouldRetryAttempt()` is right to refuse `ABORTED`/`TOTAL_TIMEOUT`
|
|
10
|
+
* *inside* a round: that round has no budget left, so a retry would be cut by
|
|
11
|
+
* the same blade. The missing layer is not "retry the child"; it is
|
|
12
|
+
* "start the next round" — a new deadline, the same plan, and `done` work
|
|
13
|
+
* never re-run.
|
|
14
|
+
*
|
|
15
|
+
* This module owns only the decision table (`should we continue?`). It is a
|
|
16
|
+
* pure function with no timer, no I/O and no record mutation, so every branch
|
|
17
|
+
* can be pinned by a unit test without mounting the host. The runtime supplies
|
|
18
|
+
* the bookkeeping; `src/runtime.ts` owns the timer.
|
|
19
|
+
*
|
|
20
|
+
* Safety stance (the reason it is more than a loop)
|
|
21
|
+
* -------------------------------------------------
|
|
22
|
+
* Automatic recovery must never manufacture a green result. Therefore:
|
|
23
|
+
* - it only ever continues a `paused` plan; `blocked` means a real failure and
|
|
24
|
+
* is repaired by a human adjudication or the resume budget, never silently;
|
|
25
|
+
* - `done` rows are never re-run (the resumer calls `resetBlockedStatuses`,
|
|
26
|
+
* which only clears blocked/in_progress, and a paused round leaves them
|
|
27
|
+
* `pending`);
|
|
28
|
+
* - it never adjudicates evidence: every continuation goes through the normal
|
|
29
|
+
* child path (`settleFromOutput` → `deliveryReadiness`), so "all done" is
|
|
30
|
+
* still decided by structured evidence;
|
|
31
|
+
* - "all done but evidence gaps" stops here on purpose (`NOTHING_PENDING`):
|
|
32
|
+
* re-running a done subtask cannot fix a missing acceptance item, it only
|
|
33
|
+
* produces duplicate work and a chance to overwrite the evidence.
|
|
34
|
+
*
|
|
35
|
+
* Default: **off**. See `AUTO_RESUME_DEFAULTS.enabled`.
|
|
36
|
+
*/
|
|
37
|
+
/** Tunables that are policy, not deployment config. */
|
|
38
|
+
export const AUTO_RESUME_DEFAULTS = Object.freeze({
|
|
39
|
+
/**
|
|
40
|
+
* [1.10.6] On by default.
|
|
41
|
+
*
|
|
42
|
+
* The 2026-11-01 user verdict on the previous "off by default" stance was
|
|
43
|
+
* unambiguous: a subtask killed by the round budget sat untouched for 1h57m
|
|
44
|
+
* and the only reason was a flag nobody had been told to flip. A recovery
|
|
45
|
+
* feature that ships silent is indistinguishable from a missing one.
|
|
46
|
+
*
|
|
47
|
+
* Every safety branch below still applies when this is on (cancel, plan mode,
|
|
48
|
+
* blocked rows, no-progress, attempt cap), and `autoResume: false` in the
|
|
49
|
+
* profile or `DSH_WORKPLAN_AUTO_RESUME=0` turns it off for one deployment.
|
|
50
|
+
*/
|
|
51
|
+
enabled: true,
|
|
52
|
+
/** How many continuation rounds one plan may start without a human. */
|
|
53
|
+
maxAttempts: 2,
|
|
54
|
+
/** Delay before the first continuation round. */
|
|
55
|
+
baseDelayMs: 30_000,
|
|
56
|
+
/** Upper bound of the exponential backoff. */
|
|
57
|
+
maxDelayMs: 300_000,
|
|
58
|
+
/** Consecutive continuation rounds that completed no new subtask before stopping. */
|
|
59
|
+
stallLimit: 1,
|
|
60
|
+
});
|
|
61
|
+
/** Hard cap for a configured attempt budget (0 disables the chain). */
|
|
62
|
+
export const AUTO_RESUME_MAX_ATTEMPTS_CAP = 4;
|
|
63
|
+
/**
|
|
64
|
+
* Clamp a configured attempt budget.
|
|
65
|
+
*
|
|
66
|
+
* Non-numeric input falls back to the default instead of disabling the feature
|
|
67
|
+
* silently; only an explicit in-range number is honoured.
|
|
68
|
+
*
|
|
69
|
+
* @param value - configured value, if any.
|
|
70
|
+
* @returns an integer within `[0, AUTO_RESUME_MAX_ATTEMPTS_CAP]`.
|
|
71
|
+
*/
|
|
72
|
+
export function autoResumeAttemptCap(value) {
|
|
73
|
+
const numeric = Number(value);
|
|
74
|
+
if (!Number.isFinite(numeric))
|
|
75
|
+
return AUTO_RESUME_DEFAULTS.maxAttempts;
|
|
76
|
+
return Math.min(AUTO_RESUME_MAX_ATTEMPTS_CAP, Math.max(0, Math.floor(numeric)));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* [1.10.6] Resolve the feature flag from profile config + environment.
|
|
80
|
+
*
|
|
81
|
+
* Explicit config wins; an explicit environment value wins over the default;
|
|
82
|
+
* anything unset falls back to `AUTO_RESUME_DEFAULTS.enabled` (now true).
|
|
83
|
+
* Values are read the same way for both sources so `0/false/no/off` turn it off
|
|
84
|
+
* instead of being treated as "present, therefore on".
|
|
85
|
+
*
|
|
86
|
+
* @param configValue - `autoResume` from the profile config, if any.
|
|
87
|
+
* @param envValue - `DSH_WORKPLAN_AUTO_RESUME`, if set.
|
|
88
|
+
* @returns whether automatic continuation rounds are allowed.
|
|
89
|
+
*/
|
|
90
|
+
export function autoResumeEnabledFrom(configValue, envValue) {
|
|
91
|
+
if (typeof configValue === 'boolean')
|
|
92
|
+
return configValue;
|
|
93
|
+
const raw = envValue === undefined || envValue === null ? '' : String(envValue).trim();
|
|
94
|
+
if (raw !== '') {
|
|
95
|
+
if (/^(1|true|yes|on)$/i.test(raw))
|
|
96
|
+
return true;
|
|
97
|
+
if (/^(0|false|no|off)$/i.test(raw))
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return AUTO_RESUME_DEFAULTS.enabled === true;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Decide whether one more round may start, and when.
|
|
104
|
+
*
|
|
105
|
+
* Branch order is the contract (first match wins):
|
|
106
|
+
* 1. feature flag / no plan
|
|
107
|
+
* 2. user stop (`cancelled`, `superseded`) — never resurrect a decision
|
|
108
|
+
* 3. already running / plan mode
|
|
109
|
+
* 4. only a `paused` phase is auto-continuable
|
|
110
|
+
* 5. nothing pending (includes "all done, evidence gap" — human work)
|
|
111
|
+
* 6. any `blocked` row — a real failure, not a budget artifact
|
|
112
|
+
* 7. attempt / progress budgets
|
|
113
|
+
*
|
|
114
|
+
* @param input - the frozen facts of the round that just ended.
|
|
115
|
+
* @returns the decision plus a model-readable reason.
|
|
116
|
+
*/
|
|
117
|
+
export function decideAutoResume(input) {
|
|
118
|
+
const attempt = Math.max(0, Math.floor(Number(input.attempt) || 0));
|
|
119
|
+
const maxAttempts = Math.max(0, Math.floor(Number(input.maxAttempts) || 0));
|
|
120
|
+
const stop = (code, reason) => ({
|
|
121
|
+
action: 'stop',
|
|
122
|
+
code,
|
|
123
|
+
reason,
|
|
124
|
+
attempt,
|
|
125
|
+
delayMs: 0,
|
|
126
|
+
});
|
|
127
|
+
if (input.enabled !== true) {
|
|
128
|
+
return stop('AUTO_RESUME_DISABLED', '自动续跑开关未开启(默认关闭)');
|
|
129
|
+
}
|
|
130
|
+
if (input.degraded === true || Number(input.total) <= 0) {
|
|
131
|
+
return stop('NO_PLAN', '没有可续跑的计划(自动分解降级或子任务数为 0)');
|
|
132
|
+
}
|
|
133
|
+
if (input.cancelled === true || input.phase === 'cancelled') {
|
|
134
|
+
return stop('CANCELLED', '用户已取消:自动重来等于违背停下的决定');
|
|
135
|
+
}
|
|
136
|
+
if (input.phase === 'superseded') {
|
|
137
|
+
return stop('SUPERSEDED', '责任已转移到承接计划,本计划不得自动续跑');
|
|
138
|
+
}
|
|
139
|
+
if (input.running === true) {
|
|
140
|
+
return stop('ALREADY_RUNNING', '已有一轮在跑,不能并发再开一轮');
|
|
141
|
+
}
|
|
142
|
+
if (input.planMode === true) {
|
|
143
|
+
return stop('PLAN_MODE', 'plan 模式下计划只供审阅,不自动执行');
|
|
144
|
+
}
|
|
145
|
+
if (input.phase !== 'paused') {
|
|
146
|
+
return stop('PHASE_NOT_PAUSED', `计划阶段是 ${String(input.phase ?? 'unknown')},只有 paused(预算到点)才自动续跑`);
|
|
147
|
+
}
|
|
148
|
+
if (Number(input.pending) <= 0) {
|
|
149
|
+
/*
|
|
150
|
+
* Also the evidence-gap case: all rows done but deliveryReady=false.
|
|
151
|
+
* Re-running done work is forbidden by the delivery contract; the gap can
|
|
152
|
+
* only be closed by a human re-adjudication, so stop and say so.
|
|
153
|
+
*/
|
|
154
|
+
return stop('NOTHING_PENDING', '没有 pending 项:若仍未就绪,那是证据缺口,需主 Agent 复核,不能靠重跑 done 项解决');
|
|
155
|
+
}
|
|
156
|
+
if (Number(input.blocked) > 0) {
|
|
157
|
+
return stop('HAS_BLOCKED', `存在 ${input.blocked} 个 blocked 子任务:那是真实失败,需人工改判或显式续跑,不自动修复`);
|
|
158
|
+
}
|
|
159
|
+
if (attempt >= maxAttempts) {
|
|
160
|
+
return stop('BUDGET_EXHAUSTED', `自动续跑已用满 ${maxAttempts} 轮,交给主 Agent 决定`);
|
|
161
|
+
}
|
|
162
|
+
if (Number(input.noProgressRounds) >= Math.max(1, Number(input.stallLimit) || 1)) {
|
|
163
|
+
return stop('NO_PROGRESS', `连续 ${input.noProgressRounds} 轮没有新增完成项,停止空转`);
|
|
164
|
+
}
|
|
165
|
+
const base = Math.max(0, Number(input.baseDelayMs) || 0);
|
|
166
|
+
const cap = Math.max(base, Number(input.maxDelayMs) || base);
|
|
167
|
+
const delayMs = Math.min(cap, base * Math.pow(2, attempt));
|
|
168
|
+
return {
|
|
169
|
+
action: 'schedule',
|
|
170
|
+
code: 'SCHEDULED',
|
|
171
|
+
reason: `第 ${attempt + 1}/${maxAttempts} 轮自动续跑将在 ${Math.round(delayMs / 1000)}s 后开始`,
|
|
172
|
+
attempt: attempt + 1,
|
|
173
|
+
delayMs,
|
|
174
|
+
};
|
|
175
|
+
}
|