dsh-taskbridge 1.3.2 → 1.4.1
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 +23 -2
- package/README.md +19 -13
- package/bin/dsh-delegate-mcp.js +4 -0
- package/codex/dsh-taskbridge.toml +129 -24
- package/docs/INTRODUCTION.md +19 -15
- package/docs/INTRODUCTION.zh.md +38 -34
- package/docs/codex-integration.md +63 -20
- package/docs/plugin-market.md +1 -1
- package/docs/releases/1.4.0-token-benchmark.zh.md +40 -0
- package/docs/releases/1.4.0.zh.md +54 -0
- package/docs/releases/1.4.1.zh.md +59 -0
- package/docs/runtime-compatibility.md +17 -9
- package/docs/silent-wait.md +87 -10
- package/docs/taskbridge-upgrade.md +1 -1
- package/lib/client.js +305 -65
- package/package.json +7 -3
- package/src/client/api.js +326 -46
- package/src/client/index.jsx +226 -52
- package/src/codex/installer.js +39 -6
- package/src/config/defaults.js +12 -0
- package/src/config/settings.js +12 -10
- package/src/config/validate.js +26 -11
- package/src/http/execution-plane.js +179 -9
- package/src/http/respond.js +179 -175
- package/src/http/user-plane.js +5 -4
- package/src/index.d.ts +157 -3
- package/src/index.js +1 -1
- package/src/jobs/activity.js +1369 -1008
- package/src/jobs/diagnostics.js +15 -0
- package/src/jobs/engine.js +1029 -12
- package/src/jobs/history.js +152 -6
- package/src/jobs/review-note.js +63 -0
- package/src/mcp/server.js +345 -21
- package/src/mcp/wait.js +67 -10
package/src/client/index.jsx
CHANGED
|
@@ -85,14 +85,22 @@ import {
|
|
|
85
85
|
isCancellable,
|
|
86
86
|
hasLiveTasks,
|
|
87
87
|
formatDuration,
|
|
88
|
+
hostReviewLine,
|
|
89
|
+
RECORD_REFRESH_INTERVAL_MS,
|
|
90
|
+
REVIEW_NOTE_PREVIEW_CHARS,
|
|
91
|
+
recordRefreshPlan,
|
|
92
|
+
reviewNotePreview,
|
|
93
|
+
hasChangingRecords,
|
|
88
94
|
isLiveTask,
|
|
89
95
|
minutesToSeconds,
|
|
96
|
+
monitoringDraftOf,
|
|
90
97
|
monitoringOf,
|
|
91
98
|
pendingPermission,
|
|
92
99
|
permissionSummary,
|
|
93
100
|
precheckDraft,
|
|
94
101
|
precheckMonitoring,
|
|
95
102
|
previewEffective,
|
|
103
|
+
repeatFailureLine,
|
|
96
104
|
secondsToMinutes,
|
|
97
105
|
SELF_CHECK_LABELS,
|
|
98
106
|
taskActivity,
|
|
@@ -1454,22 +1462,45 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1454
1462
|
*/
|
|
1455
1463
|
function MonitoringCard({ store, snapshot }) {
|
|
1456
1464
|
const draft = snapshot.draft;
|
|
1457
|
-
|
|
1465
|
+
// The RAW block is what the inputs display and what the save validates. Binding the
|
|
1466
|
+
// inputs to the display-normalized block instead would make a cleared field
|
|
1467
|
+
// immediately re-render as the documented default, hiding the edit.
|
|
1468
|
+
const raw = monitoringDraftOf(draft);
|
|
1458
1469
|
const saved = monitoringOf(snapshot.settings);
|
|
1459
1470
|
const [saving, setSaving] = useState(false);
|
|
1460
|
-
const problems = precheckMonitoring(
|
|
1461
|
-
const dirty =
|
|
1462
|
-
||
|
|
1471
|
+
const problems = precheckMonitoring(raw);
|
|
1472
|
+
const dirty = raw.selfCheckSeconds !== saved.selfCheckSeconds
|
|
1473
|
+
|| raw.attentionSeconds !== saved.attentionSeconds
|
|
1474
|
+
|| raw.repeatFailureThreshold !== saved.repeatFailureThreshold;
|
|
1463
1475
|
|
|
1464
1476
|
/**
|
|
1465
1477
|
* Write one field, converting minutes back to the stored unit.
|
|
1478
|
+
*
|
|
1479
|
+
* The block is spread from the RAW draft, not from `monitoringOf`: normalizing here
|
|
1480
|
+
* would rewrite the operator's other half-typed fields (for example a cleared count)
|
|
1481
|
+
* back to their defaults on every keystroke.
|
|
1466
1482
|
* @param {'selfCheckSeconds' | 'attentionSeconds'} field - target field.
|
|
1467
|
-
* @param {unknown}
|
|
1483
|
+
* @param {unknown} rawMinutes - operator input, in minutes.
|
|
1468
1484
|
* @returns {void}
|
|
1469
1485
|
*/
|
|
1470
|
-
const edit = (field,
|
|
1486
|
+
const edit = (field, rawMinutes) => {
|
|
1471
1487
|
store.editDraft((current) => {
|
|
1472
|
-
current.monitoring = { ...
|
|
1488
|
+
current.monitoring = { ...monitoringDraftOf(current), [field]: minutesToSeconds(rawMinutes) };
|
|
1489
|
+
});
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* Write the repeated-failure count. A blank field becomes `''`, which the precheck
|
|
1494
|
+
* reports rather than turning into an accidental default.
|
|
1495
|
+
* @param {unknown} value - operator input, a count.
|
|
1496
|
+
* @returns {void}
|
|
1497
|
+
*/
|
|
1498
|
+
const editFailureCount = (value) => {
|
|
1499
|
+
store.editDraft((current) => {
|
|
1500
|
+
current.monitoring = {
|
|
1501
|
+
...monitoringDraftOf(current),
|
|
1502
|
+
repeatFailureThreshold: value === '' ? '' : Number(value),
|
|
1503
|
+
};
|
|
1473
1504
|
});
|
|
1474
1505
|
};
|
|
1475
1506
|
|
|
@@ -1484,7 +1515,7 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1484
1515
|
<Field
|
|
1485
1516
|
label="程序自检间隔(分钟)"
|
|
1486
1517
|
htmlFor="dshdg-monitoring-selfcheck"
|
|
1487
|
-
hint={`${LIMITS.selfCheckSecondsMin / 60}–${LIMITS.selfCheckSecondsMax / 60} 分钟;存成整秒(当前 ${
|
|
1518
|
+
hint={`${LIMITS.selfCheckSecondsMin / 60}–${LIMITS.selfCheckSecondsMax / 60} 分钟;存成整秒(当前 ${raw.selfCheckSeconds === '' ? '未填' : `${raw.selfCheckSeconds} 秒`})`}
|
|
1488
1519
|
>
|
|
1489
1520
|
<input
|
|
1490
1521
|
id="dshdg-monitoring-selfcheck"
|
|
@@ -1493,17 +1524,17 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1493
1524
|
min={LIMITS.selfCheckSecondsMin / 60}
|
|
1494
1525
|
max={LIMITS.selfCheckSecondsMax / 60}
|
|
1495
1526
|
step={0.5}
|
|
1496
|
-
value={String(Number.isFinite(secondsToMinutes(
|
|
1527
|
+
value={String(Number.isFinite(secondsToMinutes(raw.selfCheckSeconds)) ? secondsToMinutes(raw.selfCheckSeconds) : '')}
|
|
1497
1528
|
onChange={(event) => {
|
|
1498
|
-
const
|
|
1499
|
-
edit('selfCheckSeconds',
|
|
1529
|
+
const value = event.target.value;
|
|
1530
|
+
edit('selfCheckSeconds', value === '' ? '' : value);
|
|
1500
1531
|
}}
|
|
1501
1532
|
/>
|
|
1502
1533
|
</Field>
|
|
1503
1534
|
<Field
|
|
1504
1535
|
label="提醒你的间隔(分钟)"
|
|
1505
1536
|
htmlFor="dshdg-monitoring-attention"
|
|
1506
|
-
hint={`${LIMITS.attentionSecondsMin / 60}–${LIMITS.attentionSecondsMax / 60} 分钟,且必须大于自检间隔;存成整秒(当前 ${
|
|
1537
|
+
hint={`${LIMITS.attentionSecondsMin / 60}–${LIMITS.attentionSecondsMax / 60} 分钟,且必须大于自检间隔;存成整秒(当前 ${raw.attentionSeconds === '' ? '未填' : `${raw.attentionSeconds} 秒`})`}
|
|
1507
1538
|
>
|
|
1508
1539
|
<input
|
|
1509
1540
|
id="dshdg-monitoring-attention"
|
|
@@ -1512,18 +1543,35 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1512
1543
|
min={LIMITS.attentionSecondsMin / 60}
|
|
1513
1544
|
max={LIMITS.attentionSecondsMax / 60}
|
|
1514
1545
|
step={0.5}
|
|
1515
|
-
value={String(Number.isFinite(secondsToMinutes(
|
|
1546
|
+
value={String(Number.isFinite(secondsToMinutes(raw.attentionSeconds)) ? secondsToMinutes(raw.attentionSeconds) : '')}
|
|
1516
1547
|
onChange={(event) => {
|
|
1517
|
-
const
|
|
1518
|
-
edit('attentionSeconds',
|
|
1548
|
+
const value = event.target.value;
|
|
1549
|
+
edit('attentionSeconds', value === '' ? '' : value);
|
|
1519
1550
|
}}
|
|
1520
1551
|
/>
|
|
1521
1552
|
</Field>
|
|
1553
|
+
<Field
|
|
1554
|
+
label="重复失败提醒(次)"
|
|
1555
|
+
htmlFor="dshdg-monitoring-repeat"
|
|
1556
|
+
hint={`同一工具、同一操作、同一失败连续这么多次时提醒一次;${LIMITS.repeatFailureThresholdMin} 表示关闭(当前 ${raw.repeatFailureThreshold === '' ? '未填' : `${raw.repeatFailureThreshold} 次`})`}
|
|
1557
|
+
>
|
|
1558
|
+
<input
|
|
1559
|
+
id="dshdg-monitoring-repeat"
|
|
1560
|
+
type="number"
|
|
1561
|
+
inputMode="numeric"
|
|
1562
|
+
min={LIMITS.repeatFailureThresholdMin}
|
|
1563
|
+
max={LIMITS.repeatFailureThresholdMax}
|
|
1564
|
+
step={1}
|
|
1565
|
+
value={String(raw.repeatFailureThreshold)}
|
|
1566
|
+
onChange={(event) => { editFailureCount(event.target.value); }}
|
|
1567
|
+
/>
|
|
1568
|
+
</Field>
|
|
1522
1569
|
</div>
|
|
1523
1570
|
{problems.length === 0 ? null : <p className="dshdg-fail">{problems.join(';')}</p>}
|
|
1524
1571
|
<ul className="dshdg-hint">
|
|
1525
1572
|
<li>「没有新进展」本身不等于失败:插件不会因为安静、也不会因为单个工具跑得久就判定任务失败。</li>
|
|
1526
1573
|
<li>只有确实没有进展、并且超过「提醒你的间隔」之后,才会把这件事报告给派工方。</li>
|
|
1574
|
+
<li>重复失败提醒与上面两个间隔<strong>互相独立</strong>:它数的是同一操作连续失败了几次,而不是安静了多久,所以正在忙碌地反复失败也会被提醒。它只提醒一次,不会自动取消任务、更换模型或改动超时。</li>
|
|
1527
1575
|
<li>修改只影响<strong>之后新提交</strong>的任务;已经运行的任务保留它开始时的那份间隔快照。</li>
|
|
1528
1576
|
<li>程序自检只读取本机已有的事实(任务是否还在、当前阶段、有没有待决定的调用、正在跑哪个工具),不读取代码差异,也不会读取你的文件内容。</li>
|
|
1529
1577
|
</ul>
|
|
@@ -1534,7 +1582,9 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1534
1582
|
onClick={async () => {
|
|
1535
1583
|
setSaving(true);
|
|
1536
1584
|
try {
|
|
1537
|
-
|
|
1585
|
+
// Send exactly what was validated. The button is disabled while
|
|
1586
|
+
// `problems` is non-empty, so this is a well-formed block by construction.
|
|
1587
|
+
await store.saveMonitoring(monitoringDraftOf(draft));
|
|
1538
1588
|
} finally {
|
|
1539
1589
|
setSaving(false);
|
|
1540
1590
|
}
|
|
@@ -1729,6 +1779,53 @@ function ReviewPanel({ store, snapshot }) {
|
|
|
1729
1779
|
// Task records
|
|
1730
1780
|
// ---------------------------------------------------------------------------
|
|
1731
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* The full recorded review note of one task, expandable and copyable.
|
|
1784
|
+
*
|
|
1785
|
+
* The note itself is never shortened — the list shows a preview, this shows the whole text —
|
|
1786
|
+
* and a copy that fails says so instead of pretending the clipboard holds it.
|
|
1787
|
+
* @param {object} props - `task`.
|
|
1788
|
+
* @returns {object} the detail control.
|
|
1789
|
+
*/
|
|
1790
|
+
function ReviewNoteDetail({ task }) {
|
|
1791
|
+
const [open, setOpen] = useState(false);
|
|
1792
|
+
const [copyState, setCopyState] = useState(null);
|
|
1793
|
+
const preview = reviewNotePreview(task);
|
|
1794
|
+
if (preview === null) return '未记录(插件不会自行验收)';
|
|
1795
|
+
if (preview.omitted === true) {
|
|
1796
|
+
return `审查意见已保存(${preview.chars} 字符),当前读取结果省略正文;可在结果详情中按需读取全文。`;
|
|
1797
|
+
}
|
|
1798
|
+
if (preview.chars === 0) return '(无审查意见正文)';
|
|
1799
|
+
const full = typeof task?.hostAcceptance?.note === 'string' ? task.hostAcceptance.note : '';
|
|
1800
|
+
const copy = () => {
|
|
1801
|
+
const clipboard = globalThis.navigator?.clipboard;
|
|
1802
|
+
if (typeof clipboard?.writeText !== 'function') {
|
|
1803
|
+
setCopyState('复制失败:浏览器不支持写入剪贴板,请手动选择文本。');
|
|
1804
|
+
return;
|
|
1805
|
+
}
|
|
1806
|
+
void Promise.resolve().then(() => clipboard.writeText(full)).then(
|
|
1807
|
+
() => { setCopyState('已复制完整审查意见'); },
|
|
1808
|
+
() => { setCopyState('复制失败:浏览器未允许写入剪贴板,请手动选择文本。'); },
|
|
1809
|
+
);
|
|
1810
|
+
};
|
|
1811
|
+
return (
|
|
1812
|
+
<div className="dshdg-note">
|
|
1813
|
+
<div className="dshdg-row">
|
|
1814
|
+
<span className="dshdg-hint">{preview.chars} 字符</span>
|
|
1815
|
+
<span className="dshdg-spacer" />
|
|
1816
|
+
{preview.chars > REVIEW_NOTE_PREVIEW_CHARS ? (
|
|
1817
|
+
<button type="button" onClick={() => setOpen(!open)}>{open ? '收起' : '展开全文'}</button>
|
|
1818
|
+
) : null}
|
|
1819
|
+
<button type="button" onClick={copy}>复制全文</button>
|
|
1820
|
+
</div>
|
|
1821
|
+
{copyState === null ? null : <p className="dshdg-hint">{copyState}</p>}
|
|
1822
|
+
{open || preview.chars <= REVIEW_NOTE_PREVIEW_CHARS
|
|
1823
|
+
? <pre className="dshdg-mono dshdg-note-full">{full}</pre>
|
|
1824
|
+
: <pre className="dshdg-mono dshdg-note-preview">{`${preview.text}…`}</pre>}
|
|
1825
|
+
</div>
|
|
1826
|
+
);
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1732
1829
|
/**
|
|
1733
1830
|
* One task's details: effective config, diff, evidence, usage, review outcome.
|
|
1734
1831
|
* @param {object} props - `store`, `task`.
|
|
@@ -1753,15 +1850,15 @@ function TaskDetail({ store, task }) {
|
|
|
1753
1850
|
const permission = permissionSummary(task);
|
|
1754
1851
|
const pending = pendingPermission(task);
|
|
1755
1852
|
const evidence = Array.isArray(task.permission?.evidence) ? task.permission.evidence : [];
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1853
|
+
// The detail header uses the SAME headline as the list, so a task that was reviewed
|
|
1854
|
+
// never still says "等待宿主审查" here while the list says "审查通过".
|
|
1855
|
+
const badgeTone = isAwaitingPermission(task) ? 'warn' : outcome.tone;
|
|
1759
1856
|
return (
|
|
1760
1857
|
<div className="dshdg-item">
|
|
1761
1858
|
<div className="dshdg-item-head">
|
|
1762
1859
|
<strong>{task.title || task.taskId}</strong>
|
|
1763
1860
|
<Badge tone={badgeTone}>
|
|
1764
|
-
{
|
|
1861
|
+
{outcome.label}
|
|
1765
1862
|
</Badge>
|
|
1766
1863
|
{isAwaitingPermission(task) ? <Badge tone="warn">{PERMISSION_STATE_LABELS.pending}</Badge> : null}
|
|
1767
1864
|
<span className="dshdg-spacer" />
|
|
@@ -1804,7 +1901,11 @@ function TaskDetail({ store, task }) {
|
|
|
1804
1901
|
: `新开 · 工作区 ${execution.conversation.workspaceId ?? '—'}`)}
|
|
1805
1902
|
</dd>
|
|
1806
1903
|
<dt>阶段</dt>
|
|
1807
|
-
<dd>
|
|
1904
|
+
<dd>
|
|
1905
|
+
{/* A finished/reviewed run never says "waiting for host review" here: that is the
|
|
1906
|
+
headline's job. What remains true is that the execution is over. */}
|
|
1907
|
+
{outcome.decided || task.state === 'awaiting-host-review' ? '执行已结束' : taskPhaseLabel(task.phase)}
|
|
1908
|
+
</dd>
|
|
1808
1909
|
<dt>最近进展</dt>
|
|
1809
1910
|
<dd>
|
|
1810
1911
|
{activity === null || activity.lastActivityAt === null
|
|
@@ -1830,6 +1931,8 @@ function TaskDetail({ store, task }) {
|
|
|
1830
1931
|
? '未采集到'
|
|
1831
1932
|
: `自检 ${formatDuration(activity.selfCheckSeconds * 1000)} · 提醒 ${formatDuration((activity.attentionSeconds ?? 0) * 1000)}`}
|
|
1832
1933
|
</dd>
|
|
1934
|
+
<dt>重复失败提醒</dt>
|
|
1935
|
+
<dd>{repeatFailureLine(activity)}</dd>
|
|
1833
1936
|
<dt>创建</dt>
|
|
1834
1937
|
<dd>{formatTime(task.createdAt)}</dd>
|
|
1835
1938
|
<dt>结束</dt>
|
|
@@ -1844,7 +1947,9 @@ function TaskDetail({ store, task }) {
|
|
|
1844
1947
|
: ` · ${REVIEW_VERDICT_LABELS[review.verdict] ?? review.verdict}`}
|
|
1845
1948
|
</dd>
|
|
1846
1949
|
<dt>宿主验收</dt>
|
|
1847
|
-
<dd>{task
|
|
1950
|
+
<dd>{hostReviewLine(task, formatTime)}</dd>
|
|
1951
|
+
<dt>完整审查意见</dt>
|
|
1952
|
+
<dd><ReviewNoteDetail key={task.taskId} task={task} /></dd>
|
|
1848
1953
|
</dl>
|
|
1849
1954
|
|
|
1850
1955
|
<h4>改动文件</h4>
|
|
@@ -1931,33 +2036,43 @@ function TaskDetail({ store, task }) {
|
|
|
1931
2036
|
*
|
|
1932
2037
|
* * it runs ONLY while the tasks tab is mounted (the effect lives in `TasksPanel`),
|
|
1933
2038
|
* so switching tabs or unmounting clears the timer;
|
|
1934
|
-
* * it runs
|
|
1935
|
-
* or a
|
|
1936
|
-
*
|
|
1937
|
-
*
|
|
1938
|
-
*
|
|
1939
|
-
* * it
|
|
1940
|
-
*
|
|
2039
|
+
* * it runs while any RECORD may still change — a running task, a task awaiting host
|
|
2040
|
+
* review, or a review that is still being written — not only while something is
|
|
2041
|
+
* executing. A finished run's conclusion is written by the commander, and a page that
|
|
2042
|
+
* stopped polling when execution ended would never show it;
|
|
2043
|
+
* * it stops once every visible record is settled (the conclusion is durable);
|
|
2044
|
+
* * it skips a hidden document and registers a `visibilitychange` listener so returning
|
|
2045
|
+
* to the tab reads immediately instead of waiting out the interval;
|
|
2046
|
+
* * it never overlaps: a refresh in flight suppresses the next tick;
|
|
1941
2047
|
* * it is a pure read of the task list — no model call, no task action, no settings
|
|
1942
|
-
* write — so it cannot disturb an unsaved draft or the selected task
|
|
1943
|
-
*
|
|
1944
|
-
* The interval is deliberately much slower than the host's 5 s suggestion is worth
|
|
1945
|
-
* fighting over: 5 s of list reads costs nothing and keeps the page truthful.
|
|
2048
|
+
* write — so it cannot disturb an unsaved draft or the selected task;
|
|
2049
|
+
* * a failed refresh keeps the records already shown and states the failure.
|
|
1946
2050
|
* @param {object} props - `store`, `snapshot`, `intervalMs`.
|
|
1947
2051
|
* @returns {object | null} nothing (side effects only).
|
|
1948
2052
|
*/
|
|
1949
|
-
function useTaskAutoRefresh({ store, snapshot, intervalMs =
|
|
1950
|
-
const
|
|
2053
|
+
function useTaskAutoRefresh({ store, snapshot, intervalMs = RECORD_REFRESH_INTERVAL_MS }) {
|
|
2054
|
+
const plan = recordRefreshPlan({
|
|
2055
|
+
tasks: snapshot.tasks,
|
|
2056
|
+
selectedTask: snapshot.taskDetail,
|
|
2057
|
+
visible: globalThis.document?.hidden !== true,
|
|
2058
|
+
loading: snapshot.loading?.tasks === true,
|
|
2059
|
+
});
|
|
2060
|
+
const changing = hasChangingRecords([
|
|
2061
|
+
...(Array.isArray(snapshot.tasks) ? snapshot.tasks : []),
|
|
2062
|
+
...(snapshot.taskDetail === null || snapshot.taskDetail === undefined ? [] : [snapshot.taskDetail]),
|
|
2063
|
+
]);
|
|
1951
2064
|
// Read through a ref so the effect does not restart on every store revision: a
|
|
1952
2065
|
// restarted effect would reset the timer constantly and effectively poll far
|
|
1953
2066
|
// faster than the interval.
|
|
1954
|
-
const
|
|
1955
|
-
|
|
2067
|
+
const changingRef = useRef(changing);
|
|
2068
|
+
changingRef.current = changing;
|
|
2069
|
+
const [refreshError, setRefreshError] = useState(null);
|
|
1956
2070
|
|
|
1957
2071
|
useEffect(() => {
|
|
1958
|
-
if (!
|
|
2072
|
+
if (!changing) return undefined;
|
|
1959
2073
|
let timer = null;
|
|
1960
2074
|
let disposed = false;
|
|
2075
|
+
let inFlight = false;
|
|
1961
2076
|
|
|
1962
2077
|
const schedule = () => {
|
|
1963
2078
|
if (disposed) return;
|
|
@@ -1966,22 +2081,38 @@ function useTaskAutoRefresh({ store, snapshot, intervalMs = 5000 }) {
|
|
|
1966
2081
|
timer.unref?.();
|
|
1967
2082
|
};
|
|
1968
2083
|
|
|
2084
|
+
const read = () => {
|
|
2085
|
+
if (inFlight) return;
|
|
2086
|
+
inFlight = true;
|
|
2087
|
+
setRefreshError(null);
|
|
2088
|
+
void store.refreshTasks('auto').then((result) => {
|
|
2089
|
+
// A failed read keeps the records already shown (the store does not clear them) and
|
|
2090
|
+
// is stated as a refresh problem — never as a lost task or a failed execution.
|
|
2091
|
+
if (result?.ok === false) setRefreshError(describeError(result.error));
|
|
2092
|
+
}).finally(() => {
|
|
2093
|
+
inFlight = false;
|
|
2094
|
+
schedule();
|
|
2095
|
+
});
|
|
2096
|
+
};
|
|
2097
|
+
|
|
1969
2098
|
const tick = () => {
|
|
1970
2099
|
timer = null;
|
|
1971
2100
|
if (disposed) return;
|
|
1972
2101
|
// A hidden tab is not watching anything: skip the read entirely, and let the
|
|
1973
2102
|
// visibility listener below schedule the next one when it comes back.
|
|
1974
2103
|
if (globalThis.document?.hidden === true) return;
|
|
1975
|
-
if (!
|
|
1976
|
-
|
|
2104
|
+
if (!changingRef.current) return;
|
|
2105
|
+
read();
|
|
1977
2106
|
};
|
|
1978
2107
|
|
|
1979
2108
|
const onVisibility = () => {
|
|
1980
2109
|
if (globalThis.document?.hidden === true) return;
|
|
1981
|
-
if (!
|
|
2110
|
+
if (!changingRef.current) return;
|
|
1982
2111
|
if (timer !== null) clearTimeout(timer);
|
|
1983
2112
|
timer = null;
|
|
1984
|
-
|
|
2113
|
+
// Coming back to the page reads once IMMEDIATELY: the operator must not wait out
|
|
2114
|
+
// an interval to see what changed while the tab was hidden.
|
|
2115
|
+
read();
|
|
1985
2116
|
};
|
|
1986
2117
|
|
|
1987
2118
|
schedule();
|
|
@@ -1993,42 +2124,84 @@ function useTaskAutoRefresh({ store, snapshot, intervalMs = 5000 }) {
|
|
|
1993
2124
|
timer = null;
|
|
1994
2125
|
doc?.removeEventListener?.('visibilitychange', onVisibility);
|
|
1995
2126
|
};
|
|
1996
|
-
}, [store,
|
|
2127
|
+
}, [store, changing, intervalMs]);
|
|
2128
|
+
return { ...plan, refreshError };
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/**
|
|
2132
|
+
* The review-note preview of one task row: at most 200 code points, plus a clear way to
|
|
2133
|
+
* read the whole note. The preview is a display cut; the saved body is untouched.
|
|
2134
|
+
* @param {object} props - `task`, `onOpen`.
|
|
2135
|
+
* @returns {object | null} the preview line, or null when there is no conclusion.
|
|
2136
|
+
*/
|
|
2137
|
+
function TaskListNote({ task, onOpen }) {
|
|
2138
|
+
const preview = reviewNotePreview(task);
|
|
2139
|
+
if (preview === null) return null;
|
|
2140
|
+
if (preview.omitted === true) {
|
|
2141
|
+
return (
|
|
2142
|
+
<p className="dshdg-hint">
|
|
2143
|
+
{`审查意见已保存(${preview.chars} 字符),此处省略正文。`}
|
|
2144
|
+
<button type="button" className="dshdg-link" onClick={onOpen}>查看完整审查意见</button>
|
|
2145
|
+
</p>
|
|
2146
|
+
);
|
|
2147
|
+
}
|
|
2148
|
+
if (preview.chars === 0) return null;
|
|
2149
|
+
return (
|
|
2150
|
+
<p className="dshdg-hint dshdg-note-preview">
|
|
2151
|
+
{`审查意见:${preview.text}${preview.truncated ? '…' : ''}(${preview.chars} 字符)`}
|
|
2152
|
+
{preview.truncated
|
|
2153
|
+
? <button type="button" className="dshdg-link" onClick={onOpen}>查看完整审查意见</button>
|
|
2154
|
+
: null}
|
|
2155
|
+
</p>
|
|
2156
|
+
);
|
|
1997
2157
|
}
|
|
1998
2158
|
|
|
1999
2159
|
function TasksPanel({ store, snapshot }) {
|
|
2000
2160
|
const tasks = snapshot.tasks ?? [];
|
|
2001
2161
|
const detail = snapshot.taskDetail;
|
|
2002
|
-
useTaskAutoRefresh({ store, snapshot });
|
|
2162
|
+
const plan = useTaskAutoRefresh({ store, snapshot });
|
|
2003
2163
|
const liveCount = tasks.filter(isLiveTask).length;
|
|
2164
|
+
const changing = hasChangingRecords([
|
|
2165
|
+
...tasks,
|
|
2166
|
+
...(detail === null || detail === undefined ? [] : [detail]),
|
|
2167
|
+
]);
|
|
2004
2168
|
return (
|
|
2005
2169
|
<div className="dshdg-panel">
|
|
2006
2170
|
<div className="dshdg-row">
|
|
2007
2171
|
<p className="dshdg-muted">这里只记录执行事实。执行完成不等于被接受:“等待宿主审查”要由宿主(例如 Codex)单独给出结论。</p>
|
|
2008
2172
|
<span className="dshdg-spacer" />
|
|
2009
2173
|
<span className="dshdg-hint">
|
|
2010
|
-
{
|
|
2011
|
-
? '
|
|
2012
|
-
: `有 ${liveCount}
|
|
2174
|
+
{changing !== true
|
|
2175
|
+
? '当前没有会变化的记录,不会自动刷新。'
|
|
2176
|
+
: `${liveCount > 0 ? `有 ${liveCount} 个进行中的任务;` : ''}有记录可能变化(待审或结论保存中),页面可见时每 5 秒只读刷新一次(不调用模型)。`}
|
|
2013
2177
|
</span>
|
|
2014
2178
|
<button type="button" disabled={snapshot.loading?.tasks === true} onClick={() => { void store.refreshTasks('manual'); }}>
|
|
2015
2179
|
{snapshot.loading?.tasks === true ? '读取中…' : '刷新'}
|
|
2016
2180
|
</button>
|
|
2017
2181
|
</div>
|
|
2182
|
+
{plan.refreshError !== null && plan.refreshError !== undefined ? (
|
|
2183
|
+
<p className="dshdg-warn">
|
|
2184
|
+
自动刷新失败({String(plan.refreshError)}),下面仍是上次读取的内容;可点“刷新”重试。
|
|
2185
|
+
</p>
|
|
2186
|
+
) : null}
|
|
2018
2187
|
{tasks.length === 0 ? <p className="dshdg-faint">还没有任务记录。</p> : (
|
|
2019
2188
|
<div className="dshdg-list">
|
|
2020
2189
|
{tasks.map((task) => {
|
|
2021
2190
|
const progress = taskProgress(task);
|
|
2191
|
+
// The ONE headline for this task: it already reflects a recorded review, so
|
|
2192
|
+
// the raw state label can never sit next to a "审查通过" badge contradicting it.
|
|
2193
|
+
const outcome = taskOutcome(task);
|
|
2194
|
+
// Only a phase that says something DIFFERENT is shown (a live run); a finished
|
|
2195
|
+
// or reviewed task would otherwise repeat its own headline.
|
|
2196
|
+
const phase = outcome.phaseLabel;
|
|
2022
2197
|
return (
|
|
2023
2198
|
<div className="dshdg-item" key={task.taskId}>
|
|
2024
2199
|
<div className="dshdg-item-head">
|
|
2025
2200
|
<span>{task.title || task.taskId}</span>
|
|
2026
|
-
<Badge tone={isAwaitingPermission(task)
|
|
2027
|
-
|
|
2028
|
-
: (task.state === 'awaiting-host-review' ? 'warn' : (task.state === 'failed' ? 'warn' : 'off'))}>
|
|
2029
|
-
{taskStateLabel(task.state)}
|
|
2201
|
+
<Badge tone={isAwaitingPermission(task) ? 'warn' : outcome.tone}>
|
|
2202
|
+
{outcome.label}
|
|
2030
2203
|
</Badge>
|
|
2031
|
-
<Badge tone={progress.tone}>{
|
|
2204
|
+
{phase === null ? null : <Badge tone={progress.tone}>{phase}</Badge>}
|
|
2032
2205
|
{isAwaitingPermission(task) ? <Badge tone="warn">{PERMISSION_STATE_LABELS.pending}</Badge> : null}
|
|
2033
2206
|
<span className="dshdg-mono dshdg-faint">
|
|
2034
2207
|
{task.config?.worker?.model ?? task.effective?.worker?.model ?? '—'}
|
|
@@ -2054,6 +2227,7 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2054
2227
|
</button>
|
|
2055
2228
|
</div>
|
|
2056
2229
|
<p className="dshdg-hint">{progress.headline}</p>
|
|
2230
|
+
<TaskListNote task={task} onOpen={() => { void store.openTask(task.taskId); }} />
|
|
2057
2231
|
{isAwaitingPermission(task)
|
|
2058
2232
|
? <p className="dshdg-hint">{permissionSummary(task).note}</p>
|
|
2059
2233
|
: null}
|
package/src/codex/installer.js
CHANGED
|
@@ -94,7 +94,7 @@ import {
|
|
|
94
94
|
} from './toml.js';
|
|
95
95
|
|
|
96
96
|
/** Agent file name inside `$CODEX_HOME/agents`. */
|
|
97
|
-
export const AGENT_FILENAME = 'dsh-taskbridge.toml';
|
|
97
|
+
export const AGENT_FILENAME = 'dsh-taskbridge.toml';
|
|
98
98
|
export const LEGACY_AGENT_FILENAME = 'dsh-delegate.toml';
|
|
99
99
|
|
|
100
100
|
/** MCP server entry name inside Codex's `mcp_servers` table. */
|
|
@@ -127,8 +127,8 @@ export const CODEX_ACTIONS = Object.freeze(['status', 'install', 'repair', 'remo
|
|
|
127
127
|
* historical release in the product data.
|
|
128
128
|
* @type {Array<{ version: string, sha256: string }>}
|
|
129
129
|
*/
|
|
130
|
-
export const KNOWN_AGENT_TEMPLATES = [
|
|
131
|
-
{ version: '1.3.1', sha256: '2793b656be4a1906e16edfdd0103540bfad05681a413c166b578b02333ea2618' },
|
|
130
|
+
export const KNOWN_AGENT_TEMPLATES = [
|
|
131
|
+
{ version: '1.3.1', sha256: '2793b656be4a1906e16edfdd0103540bfad05681a413c166b578b02333ea2618' },
|
|
132
132
|
{ version: '1.3.1', sha256: 'b48558d6d6acca58b94a01029d6c884c4789488c7926cdaca40cb6cd15eea2ae' },
|
|
133
133
|
{
|
|
134
134
|
version: '0.1.6',
|
|
@@ -308,12 +308,45 @@ export const KNOWN_AGENT_TEMPLATES = [
|
|
|
308
308
|
version: '1.1.0',
|
|
309
309
|
sha256: '93d580bd849bb6d2c30c2db6286695ef3e0356896a88e552abae5f03eafc7601',
|
|
310
310
|
},
|
|
311
|
-
// Exact published 1.3.0 bytes (archive fixture, LF and CRLF forms).
|
|
312
|
-
{ version: '1.3.0', sha256: '63695008f53aa2c19a0df9e2cb37285f631b775cb98f26c1d280cfbc54a0d9e8' },
|
|
313
|
-
{ version: '1.3.0', sha256: '31b0ba3149032058fe31e1e884e5c24a9a3d6459b7dd35df6420c7f3756d6257' },
|
|
311
|
+
// Exact published 1.3.0 bytes (archive fixture, LF and CRLF forms).
|
|
312
|
+
{ version: '1.3.0', sha256: '63695008f53aa2c19a0df9e2cb37285f631b775cb98f26c1d280cfbc54a0d9e8' },
|
|
313
|
+
{ version: '1.3.0', sha256: '31b0ba3149032058fe31e1e884e5c24a9a3d6459b7dd35df6420c7f3756d6257' },
|
|
314
|
+
// The published 1.3.2 companion — the file an existing 1.3.2 installation holds.
|
|
315
|
+
// The instruction body changed again in this release, so it is a DISTINCT published
|
|
316
|
+
// build: without these identities every existing 1.3.2 install would be reported
|
|
317
|
+
// `modified` ("somebody else's file") and never refreshed by startup or by install.
|
|
318
|
+
//
|
|
319
|
+
// Three exact byte identities, because three byte forms really exist on disk:
|
|
320
|
+
//
|
|
321
|
+
// * `46b5b98a…` — the PUBLISHED file itself, preserved byte for byte as
|
|
322
|
+
// `tests/fixtures/codex-agent-1.3.2.toml` (18380 bytes). It is a MIXED form, not a
|
|
323
|
+
// uniform one: most lines end CRLF but some end with a bare LF, so hashing it as
|
|
324
|
+
// "the CRLF form" would be wrong. This is what the release shipped, so it is the
|
|
325
|
+
// identity a real installation has.
|
|
326
|
+
// * `da14ba05…` — the same text with every `\r\n` turned into `\n`: the LF form a
|
|
327
|
+
// POSIX checkout writes (18135 bytes).
|
|
328
|
+
// * `055079c5…` — that LF text with every `\n` turned into `\r\n`: the fully uniform
|
|
329
|
+
// CRLF form an editor or a Windows checkout can produce (18382 bytes). It is a
|
|
330
|
+
// genuinely different file from the published bytes above, which is why it needs its
|
|
331
|
+
// own entry.
|
|
332
|
+
//
|
|
333
|
+
// Each is an exact content identity, never a normalized comparison: normalizing would
|
|
334
|
+
// also make an operator-edited file hash to a known value, which is the defect these
|
|
335
|
+
// digests exist to prevent.
|
|
336
|
+
{ version: '1.3.2', sha256: '46b5b98a3489b59a9e7e437a100fea6072db6a34c1220496530efdf812117c17' },
|
|
337
|
+
{ version: '1.3.2', sha256: 'da14ba0511ca25d9118670ccb2c39c104d7952d110b104c9b157376b330dccfc' },
|
|
338
|
+
{ version: '1.3.2', sha256: '055079c5daf6ba44639bfaa1851c9d56b0b06e45b2f22331326117a64f350e6b' },
|
|
314
339
|
// Exact published 1.2.0 bytes (archive fixture, LF and CRLF forms).
|
|
315
340
|
{ version: '1.2.0', sha256: '8479c8ab418d71b15fb30880aa5149fb1070d194e8444a110a2a614cebf4eaf4' },
|
|
316
341
|
{ version: '1.2.0', sha256: '947f3fb8a8e9ae5cc6fb3c9d379c69b595af4c46f89ac77f69aa1edf696a8f8e' },
|
|
342
|
+
// Exact 1.4.0 bytes, taken from that release's own `codex/dsh-taskbridge.toml`
|
|
343
|
+
// (`tests/fixtures/agent-1.4.0.toml`, written by 1.4.0 and stamped by ITS renderer), in
|
|
344
|
+
// the LF form it was published in and the CRLF form a Windows install rewrites it to.
|
|
345
|
+
// These are the digests of the OLD file, never derived from the new template: that is what
|
|
346
|
+
// lets an untouched 1.4.0 install be recognised and refreshed, while any operator edit
|
|
347
|
+
// still hashes to something unknown and is left alone.
|
|
348
|
+
{ version: '1.4.0', sha256: '2b2f6c35ffc9e99d98f38d00e07fef11de8bf96a9dd446e80889fcf92ba45cd8' },
|
|
349
|
+
{ version: '1.4.0', sha256: 'cfb21bc510b47be27c5e64bce86c48cbc9a49055777cd265e118ed942a94d9a5' },
|
|
317
350
|
];
|
|
318
351
|
|
|
319
352
|
/** The `version = "…"` line of an agent file, at column 0. */
|
package/src/config/defaults.js
CHANGED
|
@@ -79,6 +79,11 @@ export const LIMITS = Object.freeze({
|
|
|
79
79
|
selfCheckSecondsMax: 60 * 60,
|
|
80
80
|
attentionSecondsMin: 31,
|
|
81
81
|
attentionSecondsMax: 2 * 60 * 60,
|
|
82
|
+
// Repeated-failure reminder. `0` disables it, so the minimum is a switch rather
|
|
83
|
+
// than an error; the ceiling keeps a silly value from being indistinguishable from
|
|
84
|
+
// "off" in practice. This is a COUNT, not a duration.
|
|
85
|
+
repeatFailureThresholdMin: 0,
|
|
86
|
+
repeatFailureThresholdMax: 20,
|
|
82
87
|
promptChars: 200_000,
|
|
83
88
|
reviewPromptChars: 400_000,
|
|
84
89
|
});
|
|
@@ -95,6 +100,13 @@ export const MONITORING_DEFAULTS = Object.freeze({
|
|
|
95
100
|
selfCheckSeconds: 300,
|
|
96
101
|
/** Idle span after which the wait reports `attention` instead of `heartbeat`. */
|
|
97
102
|
attentionSeconds: 600,
|
|
103
|
+
/**
|
|
104
|
+
* How many CONSECUTIVE identical tool failures are reported once, or `0` to disable.
|
|
105
|
+
*
|
|
106
|
+
* Independent of the two silence thresholds: a run can be busy and still be failing
|
|
107
|
+
* the same way, which is the case this exists for.
|
|
108
|
+
*/
|
|
109
|
+
repeatFailureThreshold: 3,
|
|
98
110
|
});
|
|
99
111
|
|
|
100
112
|
/**
|
package/src/config/settings.js
CHANGED
|
@@ -166,15 +166,16 @@ export function resolveEffectiveConfig(settings, { projectPath = null, overrides
|
|
|
166
166
|
// snapshot therefore carries the rule rather than a stored mode, so a task
|
|
167
167
|
// record states what the plugin will do instead of echoing a retired setting.
|
|
168
168
|
conversation: { policy: CONVERSATION_POLICY },
|
|
169
|
-
// The silence thresholds this task runs under,
|
|
170
|
-
// global-only (no project or per-job layer): an
|
|
171
|
-
// a per-job override would let one submission ask
|
|
172
|
-
// clock than the alert thresholds the operator
|
|
173
|
-
// is what makes an edit during a live run apply to
|
|
174
|
-
// silently retiming one already in flight.
|
|
169
|
+
// The silence thresholds and the repeated-failure count this task runs under,
|
|
170
|
+
// FROZEN at admission. They are global-only (no project or per-job layer): an
|
|
171
|
+
// operator edits them rarely, and a per-job override would let one submission ask
|
|
172
|
+
// to be watched on a different clock than the alert thresholds the operator
|
|
173
|
+
// actually set. Freezing them here is what makes an edit during a live run apply to
|
|
174
|
+
// the NEXT task instead of silently retiming one already in flight.
|
|
175
175
|
monitoring: {
|
|
176
176
|
selfCheckSeconds: settings.monitoring.selfCheckSeconds,
|
|
177
177
|
attentionSeconds: settings.monitoring.attentionSeconds,
|
|
178
|
+
repeatFailureThreshold: settings.monitoring.repeatFailureThreshold,
|
|
178
179
|
},
|
|
179
180
|
provenance: {
|
|
180
181
|
// Canonical, not the caller's spelling: a recorded snapshot must compare
|
|
@@ -532,14 +533,15 @@ export class SettingsService {
|
|
|
532
533
|
* Replace the activity-monitoring block.
|
|
533
534
|
*
|
|
534
535
|
* This is the mutator a later authenticated UI endpoint calls; it is the only
|
|
535
|
-
* write path for these
|
|
536
|
-
*
|
|
537
|
-
*
|
|
536
|
+
* write path for these thresholds and for the repeated-failure count, so the
|
|
537
|
+
* bounds and the ordering rule live in exactly one place
|
|
538
|
+
* ({@link validateMonitoringSettings}) and no caller can persist a block the
|
|
539
|
+
* monitor would refuse to run.
|
|
538
540
|
*
|
|
539
541
|
* The write goes through the same serialized queue as every other settings
|
|
540
542
|
* mutation, so it cannot lose a concurrent edit and a fresh task admitted after
|
|
541
543
|
* it freezes the new values. A task already running keeps the snapshot it froze.
|
|
542
|
-
* @param {unknown} candidate - `{ selfCheckSeconds, attentionSeconds }`.
|
|
544
|
+
* @param {unknown} candidate - `{ selfCheckSeconds, attentionSeconds, repeatFailureThreshold }`.
|
|
543
545
|
* @returns {Promise<object>} committed settings.
|
|
544
546
|
*/
|
|
545
547
|
async setMonitoring(candidate) {
|