dsh-taskbridge 1.3.1 → 1.4.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 +19 -0
- package/README.md +46 -44
- package/bin/dsh-delegate-codex-agent.js +1 -1
- package/bin/dsh-delegate-mcp.js +4 -0
- package/codex/{dsh-delegate.toml → dsh-taskbridge.toml} +127 -33
- package/docs/INTRODUCTION.md +4 -2
- package/docs/INTRODUCTION.zh.md +7 -3
- package/docs/codex-integration.md +76 -30
- package/docs/conversation-placement.md +11 -0
- 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/runtime-compatibility.md +16 -11
- package/docs/silent-wait.md +73 -10
- package/docs/taskbridge-upgrade.md +6 -6
- package/lib/client.js +155 -53
- package/package.json +143 -137
- package/src/client/api.js +205 -46
- package/src/client/index.jsx +88 -33
- package/src/codex/installer.js +77 -13
- 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 +60 -4
- package/src/http/respond.js +179 -175
- package/src/index.d.ts +102 -2
- 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 +300 -10
- package/src/jobs/history.js +28 -0
- package/src/jobs/title.js +17 -0
- package/src/mcp/server.js +141 -14
- package/src/mcp/wait.js +49 -10
- package/src/runtime/agent-runner.js +2 -0
- package/src/runtime/session-placement.js +20 -2
package/src/client/index.jsx
CHANGED
|
@@ -85,14 +85,17 @@ import {
|
|
|
85
85
|
isCancellable,
|
|
86
86
|
hasLiveTasks,
|
|
87
87
|
formatDuration,
|
|
88
|
+
hostReviewLine,
|
|
88
89
|
isLiveTask,
|
|
89
90
|
minutesToSeconds,
|
|
91
|
+
monitoringDraftOf,
|
|
90
92
|
monitoringOf,
|
|
91
93
|
pendingPermission,
|
|
92
94
|
permissionSummary,
|
|
93
95
|
precheckDraft,
|
|
94
96
|
precheckMonitoring,
|
|
95
97
|
previewEffective,
|
|
98
|
+
repeatFailureLine,
|
|
96
99
|
secondsToMinutes,
|
|
97
100
|
SELF_CHECK_LABELS,
|
|
98
101
|
taskActivity,
|
|
@@ -1454,22 +1457,45 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1454
1457
|
*/
|
|
1455
1458
|
function MonitoringCard({ store, snapshot }) {
|
|
1456
1459
|
const draft = snapshot.draft;
|
|
1457
|
-
|
|
1460
|
+
// The RAW block is what the inputs display and what the save validates. Binding the
|
|
1461
|
+
// inputs to the display-normalized block instead would make a cleared field
|
|
1462
|
+
// immediately re-render as the documented default, hiding the edit.
|
|
1463
|
+
const raw = monitoringDraftOf(draft);
|
|
1458
1464
|
const saved = monitoringOf(snapshot.settings);
|
|
1459
1465
|
const [saving, setSaving] = useState(false);
|
|
1460
|
-
const problems = precheckMonitoring(
|
|
1461
|
-
const dirty =
|
|
1462
|
-
||
|
|
1466
|
+
const problems = precheckMonitoring(raw);
|
|
1467
|
+
const dirty = raw.selfCheckSeconds !== saved.selfCheckSeconds
|
|
1468
|
+
|| raw.attentionSeconds !== saved.attentionSeconds
|
|
1469
|
+
|| raw.repeatFailureThreshold !== saved.repeatFailureThreshold;
|
|
1463
1470
|
|
|
1464
1471
|
/**
|
|
1465
1472
|
* Write one field, converting minutes back to the stored unit.
|
|
1473
|
+
*
|
|
1474
|
+
* The block is spread from the RAW draft, not from `monitoringOf`: normalizing here
|
|
1475
|
+
* would rewrite the operator's other half-typed fields (for example a cleared count)
|
|
1476
|
+
* back to their defaults on every keystroke.
|
|
1466
1477
|
* @param {'selfCheckSeconds' | 'attentionSeconds'} field - target field.
|
|
1467
|
-
* @param {unknown}
|
|
1478
|
+
* @param {unknown} rawMinutes - operator input, in minutes.
|
|
1468
1479
|
* @returns {void}
|
|
1469
1480
|
*/
|
|
1470
|
-
const edit = (field,
|
|
1481
|
+
const edit = (field, rawMinutes) => {
|
|
1471
1482
|
store.editDraft((current) => {
|
|
1472
|
-
current.monitoring = { ...
|
|
1483
|
+
current.monitoring = { ...monitoringDraftOf(current), [field]: minutesToSeconds(rawMinutes) };
|
|
1484
|
+
});
|
|
1485
|
+
};
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* Write the repeated-failure count. A blank field becomes `''`, which the precheck
|
|
1489
|
+
* reports rather than turning into an accidental default.
|
|
1490
|
+
* @param {unknown} value - operator input, a count.
|
|
1491
|
+
* @returns {void}
|
|
1492
|
+
*/
|
|
1493
|
+
const editFailureCount = (value) => {
|
|
1494
|
+
store.editDraft((current) => {
|
|
1495
|
+
current.monitoring = {
|
|
1496
|
+
...monitoringDraftOf(current),
|
|
1497
|
+
repeatFailureThreshold: value === '' ? '' : Number(value),
|
|
1498
|
+
};
|
|
1473
1499
|
});
|
|
1474
1500
|
};
|
|
1475
1501
|
|
|
@@ -1484,7 +1510,7 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1484
1510
|
<Field
|
|
1485
1511
|
label="程序自检间隔(分钟)"
|
|
1486
1512
|
htmlFor="dshdg-monitoring-selfcheck"
|
|
1487
|
-
hint={`${LIMITS.selfCheckSecondsMin / 60}–${LIMITS.selfCheckSecondsMax / 60} 分钟;存成整秒(当前 ${
|
|
1513
|
+
hint={`${LIMITS.selfCheckSecondsMin / 60}–${LIMITS.selfCheckSecondsMax / 60} 分钟;存成整秒(当前 ${raw.selfCheckSeconds === '' ? '未填' : `${raw.selfCheckSeconds} 秒`})`}
|
|
1488
1514
|
>
|
|
1489
1515
|
<input
|
|
1490
1516
|
id="dshdg-monitoring-selfcheck"
|
|
@@ -1493,17 +1519,17 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1493
1519
|
min={LIMITS.selfCheckSecondsMin / 60}
|
|
1494
1520
|
max={LIMITS.selfCheckSecondsMax / 60}
|
|
1495
1521
|
step={0.5}
|
|
1496
|
-
value={String(Number.isFinite(secondsToMinutes(
|
|
1522
|
+
value={String(Number.isFinite(secondsToMinutes(raw.selfCheckSeconds)) ? secondsToMinutes(raw.selfCheckSeconds) : '')}
|
|
1497
1523
|
onChange={(event) => {
|
|
1498
|
-
const
|
|
1499
|
-
edit('selfCheckSeconds',
|
|
1524
|
+
const value = event.target.value;
|
|
1525
|
+
edit('selfCheckSeconds', value === '' ? '' : value);
|
|
1500
1526
|
}}
|
|
1501
1527
|
/>
|
|
1502
1528
|
</Field>
|
|
1503
1529
|
<Field
|
|
1504
1530
|
label="提醒你的间隔(分钟)"
|
|
1505
1531
|
htmlFor="dshdg-monitoring-attention"
|
|
1506
|
-
hint={`${LIMITS.attentionSecondsMin / 60}–${LIMITS.attentionSecondsMax / 60} 分钟,且必须大于自检间隔;存成整秒(当前 ${
|
|
1532
|
+
hint={`${LIMITS.attentionSecondsMin / 60}–${LIMITS.attentionSecondsMax / 60} 分钟,且必须大于自检间隔;存成整秒(当前 ${raw.attentionSeconds === '' ? '未填' : `${raw.attentionSeconds} 秒`})`}
|
|
1507
1533
|
>
|
|
1508
1534
|
<input
|
|
1509
1535
|
id="dshdg-monitoring-attention"
|
|
@@ -1512,18 +1538,35 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1512
1538
|
min={LIMITS.attentionSecondsMin / 60}
|
|
1513
1539
|
max={LIMITS.attentionSecondsMax / 60}
|
|
1514
1540
|
step={0.5}
|
|
1515
|
-
value={String(Number.isFinite(secondsToMinutes(
|
|
1541
|
+
value={String(Number.isFinite(secondsToMinutes(raw.attentionSeconds)) ? secondsToMinutes(raw.attentionSeconds) : '')}
|
|
1516
1542
|
onChange={(event) => {
|
|
1517
|
-
const
|
|
1518
|
-
edit('attentionSeconds',
|
|
1543
|
+
const value = event.target.value;
|
|
1544
|
+
edit('attentionSeconds', value === '' ? '' : value);
|
|
1519
1545
|
}}
|
|
1520
1546
|
/>
|
|
1521
1547
|
</Field>
|
|
1548
|
+
<Field
|
|
1549
|
+
label="重复失败提醒(次)"
|
|
1550
|
+
htmlFor="dshdg-monitoring-repeat"
|
|
1551
|
+
hint={`同一工具、同一操作、同一失败连续这么多次时提醒一次;${LIMITS.repeatFailureThresholdMin} 表示关闭(当前 ${raw.repeatFailureThreshold === '' ? '未填' : `${raw.repeatFailureThreshold} 次`})`}
|
|
1552
|
+
>
|
|
1553
|
+
<input
|
|
1554
|
+
id="dshdg-monitoring-repeat"
|
|
1555
|
+
type="number"
|
|
1556
|
+
inputMode="numeric"
|
|
1557
|
+
min={LIMITS.repeatFailureThresholdMin}
|
|
1558
|
+
max={LIMITS.repeatFailureThresholdMax}
|
|
1559
|
+
step={1}
|
|
1560
|
+
value={String(raw.repeatFailureThreshold)}
|
|
1561
|
+
onChange={(event) => { editFailureCount(event.target.value); }}
|
|
1562
|
+
/>
|
|
1563
|
+
</Field>
|
|
1522
1564
|
</div>
|
|
1523
1565
|
{problems.length === 0 ? null : <p className="dshdg-fail">{problems.join(';')}</p>}
|
|
1524
1566
|
<ul className="dshdg-hint">
|
|
1525
1567
|
<li>「没有新进展」本身不等于失败:插件不会因为安静、也不会因为单个工具跑得久就判定任务失败。</li>
|
|
1526
1568
|
<li>只有确实没有进展、并且超过「提醒你的间隔」之后,才会把这件事报告给派工方。</li>
|
|
1569
|
+
<li>重复失败提醒与上面两个间隔<strong>互相独立</strong>:它数的是同一操作连续失败了几次,而不是安静了多久,所以正在忙碌地反复失败也会被提醒。它只提醒一次,不会自动取消任务、更换模型或改动超时。</li>
|
|
1527
1570
|
<li>修改只影响<strong>之后新提交</strong>的任务;已经运行的任务保留它开始时的那份间隔快照。</li>
|
|
1528
1571
|
<li>程序自检只读取本机已有的事实(任务是否还在、当前阶段、有没有待决定的调用、正在跑哪个工具),不读取代码差异,也不会读取你的文件内容。</li>
|
|
1529
1572
|
</ul>
|
|
@@ -1534,7 +1577,9 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1534
1577
|
onClick={async () => {
|
|
1535
1578
|
setSaving(true);
|
|
1536
1579
|
try {
|
|
1537
|
-
|
|
1580
|
+
// Send exactly what was validated. The button is disabled while
|
|
1581
|
+
// `problems` is non-empty, so this is a well-formed block by construction.
|
|
1582
|
+
await store.saveMonitoring(monitoringDraftOf(draft));
|
|
1538
1583
|
} finally {
|
|
1539
1584
|
setSaving(false);
|
|
1540
1585
|
}
|
|
@@ -1753,15 +1798,15 @@ function TaskDetail({ store, task }) {
|
|
|
1753
1798
|
const permission = permissionSummary(task);
|
|
1754
1799
|
const pending = pendingPermission(task);
|
|
1755
1800
|
const evidence = Array.isArray(task.permission?.evidence) ? task.permission.evidence : [];
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1801
|
+
// The detail header uses the SAME headline as the list, so a task that was reviewed
|
|
1802
|
+
// never still says "等待宿主审查" here while the list says "审查通过".
|
|
1803
|
+
const badgeTone = isAwaitingPermission(task) ? 'warn' : outcome.tone;
|
|
1759
1804
|
return (
|
|
1760
1805
|
<div className="dshdg-item">
|
|
1761
1806
|
<div className="dshdg-item-head">
|
|
1762
|
-
<strong
|
|
1807
|
+
<strong>{task.title || task.taskId}</strong>
|
|
1763
1808
|
<Badge tone={badgeTone}>
|
|
1764
|
-
{
|
|
1809
|
+
{outcome.label}
|
|
1765
1810
|
</Badge>
|
|
1766
1811
|
{isAwaitingPermission(task) ? <Badge tone="warn">{PERMISSION_STATE_LABELS.pending}</Badge> : null}
|
|
1767
1812
|
<span className="dshdg-spacer" />
|
|
@@ -1804,7 +1849,11 @@ function TaskDetail({ store, task }) {
|
|
|
1804
1849
|
: `新开 · 工作区 ${execution.conversation.workspaceId ?? '—'}`)}
|
|
1805
1850
|
</dd>
|
|
1806
1851
|
<dt>阶段</dt>
|
|
1807
|
-
<dd>
|
|
1852
|
+
<dd>
|
|
1853
|
+
{/* A finished/reviewed run never says "waiting for host review" here: that is the
|
|
1854
|
+
headline's job. What remains true is that the execution is over. */}
|
|
1855
|
+
{outcome.decided || task.state === 'awaiting-host-review' ? '执行已结束' : taskPhaseLabel(task.phase)}
|
|
1856
|
+
</dd>
|
|
1808
1857
|
<dt>最近进展</dt>
|
|
1809
1858
|
<dd>
|
|
1810
1859
|
{activity === null || activity.lastActivityAt === null
|
|
@@ -1830,6 +1879,8 @@ function TaskDetail({ store, task }) {
|
|
|
1830
1879
|
? '未采集到'
|
|
1831
1880
|
: `自检 ${formatDuration(activity.selfCheckSeconds * 1000)} · 提醒 ${formatDuration((activity.attentionSeconds ?? 0) * 1000)}`}
|
|
1832
1881
|
</dd>
|
|
1882
|
+
<dt>重复失败提醒</dt>
|
|
1883
|
+
<dd>{repeatFailureLine(activity)}</dd>
|
|
1833
1884
|
<dt>创建</dt>
|
|
1834
1885
|
<dd>{formatTime(task.createdAt)}</dd>
|
|
1835
1886
|
<dt>结束</dt>
|
|
@@ -1844,7 +1895,7 @@ function TaskDetail({ store, task }) {
|
|
|
1844
1895
|
: ` · ${REVIEW_VERDICT_LABELS[review.verdict] ?? review.verdict}`}
|
|
1845
1896
|
</dd>
|
|
1846
1897
|
<dt>宿主验收</dt>
|
|
1847
|
-
<dd>{task
|
|
1898
|
+
<dd>{hostReviewLine(task, formatTime)}</dd>
|
|
1848
1899
|
</dl>
|
|
1849
1900
|
|
|
1850
1901
|
<h4>改动文件</h4>
|
|
@@ -2019,16 +2070,20 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2019
2070
|
<div className="dshdg-list">
|
|
2020
2071
|
{tasks.map((task) => {
|
|
2021
2072
|
const progress = taskProgress(task);
|
|
2073
|
+
// The ONE headline for this task: it already reflects a recorded review, so
|
|
2074
|
+
// the raw state label can never sit next to a "审查通过" badge contradicting it.
|
|
2075
|
+
const outcome = taskOutcome(task);
|
|
2076
|
+
// Only a phase that says something DIFFERENT is shown (a live run); a finished
|
|
2077
|
+
// or reviewed task would otherwise repeat its own headline.
|
|
2078
|
+
const phase = outcome.phaseLabel;
|
|
2022
2079
|
return (
|
|
2023
2080
|
<div className="dshdg-item" key={task.taskId}>
|
|
2024
2081
|
<div className="dshdg-item-head">
|
|
2025
|
-
<span
|
|
2026
|
-
<Badge tone={isAwaitingPermission(task)
|
|
2027
|
-
|
|
2028
|
-
: (task.state === 'awaiting-host-review' ? 'warn' : (task.state === 'failed' ? 'warn' : 'off'))}>
|
|
2029
|
-
{taskStateLabel(task.state)}
|
|
2082
|
+
<span>{task.title || task.taskId}</span>
|
|
2083
|
+
<Badge tone={isAwaitingPermission(task) ? 'warn' : outcome.tone}>
|
|
2084
|
+
{outcome.label}
|
|
2030
2085
|
</Badge>
|
|
2031
|
-
<Badge tone={progress.tone}>{
|
|
2086
|
+
{phase === null ? null : <Badge tone={progress.tone}>{phase}</Badge>}
|
|
2032
2087
|
{isAwaitingPermission(task) ? <Badge tone="warn">{PERMISSION_STATE_LABELS.pending}</Badge> : null}
|
|
2033
2088
|
<span className="dshdg-mono dshdg-faint">
|
|
2034
2089
|
{task.config?.worker?.model ?? task.effective?.worker?.model ?? '—'}
|
|
@@ -2131,7 +2186,7 @@ function CodexPanel({ store, snapshot }) {
|
|
|
2131
2186
|
</div>
|
|
2132
2187
|
<p className="dshdg-muted">
|
|
2133
2188
|
{'点下面的按钮,把 '}
|
|
2134
|
-
<span className="dshdg-mono">agents/dsh-
|
|
2189
|
+
<span className="dshdg-mono">agents/dsh-taskbridge.toml</span>
|
|
2135
2190
|
{' 装进 Codex 目录,并在 Codex 的 '}
|
|
2136
2191
|
<span className="dshdg-mono">config.toml</span>
|
|
2137
2192
|
{' 里登记本插件的 stdio MCP 服务(delegate_status / delegate_submit / delegate_result / delegate_wait / delegate_cancel)。'
|
|
@@ -2158,7 +2213,7 @@ function CodexPanel({ store, snapshot }) {
|
|
|
2158
2213
|
<p className="dshdg-hint" data-dshdg-codex-drift="">
|
|
2159
2214
|
{'这个托管 MCP 条目已经过期:'}
|
|
2160
2215
|
{codexMcpDriftText(codex.mcp)}
|
|
2161
|
-
{'。插件下次启动会自动在原地更新;也可以点上面的「安装 / 更新
|
|
2216
|
+
{'。插件下次启动会自动在原地更新;也可以点上面的「安装 / 更新 TaskBridge 智能体」。'}
|
|
2162
2217
|
</p>
|
|
2163
2218
|
) : null}
|
|
2164
2219
|
{notes.length === 0 ? null : (
|
|
@@ -2171,7 +2226,7 @@ function CodexPanel({ store, snapshot }) {
|
|
|
2171
2226
|
{refreshing ? '读取中…' : '刷新状态'}
|
|
2172
2227
|
</button>
|
|
2173
2228
|
<button type="button" className="dshdg-primary" disabled={disabled} onClick={() => { void store.runCodexAction('install'); }}>
|
|
2174
|
-
{busy ? '处理中…' : '安装 / 更新
|
|
2229
|
+
{busy ? '处理中…' : '安装 / 更新 TaskBridge 智能体'}
|
|
2175
2230
|
</button>
|
|
2176
2231
|
<button type="button" disabled={disabled} onClick={() => { void store.runCodexAction('repair'); }}>
|
|
2177
2232
|
仅修复 MCP 配置
|
|
@@ -2187,7 +2242,7 @@ function CodexPanel({ store, snapshot }) {
|
|
|
2187
2242
|
)}
|
|
2188
2243
|
<p className="dshdg-hint">
|
|
2189
2244
|
{'安装后需要让 Codex 重新载入:新开会话或重启 Codex,才会读到新的子智能体和 MCP 条目。'
|
|
2190
|
-
+ '本插件不宣称当前 Codex 桌面版/CLI 能在输入框用 @dsh-
|
|
2245
|
+
+ '本插件不宣称当前 Codex 桌面版/CLI 能在输入框用 @dsh-taskbridge 直接选中该子智能体——这取决于 Codex 版本自身是否提供提及选择;'
|
|
2191
2246
|
+ '这里只保证子智能体文件与 MCP 工具存在,并由你在 Codex 提供的选择方式中指派它。'
|
|
2192
2247
|
+ '子智能体只在明确指派时派发任务,并在提交前先检查上面的本机调用开关;本页不会替你打开该开关。'
|
|
2193
2248
|
+ '同名的自定义 agent 会被保留并报告为冲突;没有本插件托管标记注释的同名 MCP 条目也视为你自己写的,不会被覆盖或删除。'}
|
package/src/codex/installer.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// -------------------------------------
|
|
6
6
|
// This module owns exactly two things in a Codex home:
|
|
7
7
|
//
|
|
8
|
-
// 1. `$CODEX_HOME/agents/dsh-
|
|
9
|
-
// template `codex/dsh-
|
|
8
|
+
// 1. `$CODEX_HOME/agents/dsh-taskbridge.toml` — a *managed copy* of the shipped
|
|
9
|
+
// template `codex/dsh-taskbridge.toml`. Ownership is proved by content, never by
|
|
10
10
|
// the file name or a version line alone:
|
|
11
11
|
// * a file that is byte-identical to the template this build would write is
|
|
12
12
|
// `installed` (and removable);
|
|
@@ -94,7 +94,8 @@ import {
|
|
|
94
94
|
} from './toml.js';
|
|
95
95
|
|
|
96
96
|
/** Agent file name inside `$CODEX_HOME/agents`. */
|
|
97
|
-
export const AGENT_FILENAME = 'dsh-
|
|
97
|
+
export const AGENT_FILENAME = 'dsh-taskbridge.toml';
|
|
98
|
+
export const LEGACY_AGENT_FILENAME = 'dsh-delegate.toml';
|
|
98
99
|
|
|
99
100
|
/** MCP server entry name inside Codex's `mcp_servers` table. */
|
|
100
101
|
export const MCP_SERVER_NAME = 'dsh-delegate';
|
|
@@ -127,6 +128,8 @@ export const CODEX_ACTIONS = Object.freeze(['status', 'install', 'repair', 'remo
|
|
|
127
128
|
* @type {Array<{ version: string, sha256: string }>}
|
|
128
129
|
*/
|
|
129
130
|
export const KNOWN_AGENT_TEMPLATES = [
|
|
131
|
+
{ version: '1.3.1', sha256: '2793b656be4a1906e16edfdd0103540bfad05681a413c166b578b02333ea2618' },
|
|
132
|
+
{ version: '1.3.1', sha256: 'b48558d6d6acca58b94a01029d6c884c4789488c7926cdaca40cb6cd15eea2ae' },
|
|
130
133
|
{
|
|
131
134
|
version: '0.1.6',
|
|
132
135
|
sha256: '6a9d0da5b32d62a2a1f61d1fba37d54789cde0774afb3abccb5dc12b400c82be',
|
|
@@ -305,9 +308,34 @@ export const KNOWN_AGENT_TEMPLATES = [
|
|
|
305
308
|
version: '1.1.0',
|
|
306
309
|
sha256: '93d580bd849bb6d2c30c2db6286695ef3e0356896a88e552abae5f03eafc7601',
|
|
307
310
|
},
|
|
308
|
-
// Exact published 1.3.0 bytes (archive fixture, LF and CRLF forms).
|
|
309
|
-
{ version: '1.3.0', sha256: '63695008f53aa2c19a0df9e2cb37285f631b775cb98f26c1d280cfbc54a0d9e8' },
|
|
310
|
-
{ 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' },
|
|
311
339
|
// Exact published 1.2.0 bytes (archive fixture, LF and CRLF forms).
|
|
312
340
|
{ version: '1.2.0', sha256: '8479c8ab418d71b15fb30880aa5149fb1070d194e8444a110a2a614cebf4eaf4' },
|
|
313
341
|
{ version: '1.2.0', sha256: '947f3fb8a8e9ae5cc6fb3c9d379c69b595af4c46f89ac77f69aa1edf696a8f8e' },
|
|
@@ -1448,6 +1476,19 @@ export async function isOwnedEntryScript(candidate, installed, options = {}) {
|
|
|
1448
1476
|
return await isOtherInstallationOfThisPackage(recorded, options.rootPackageName ?? PACKAGE_NAME);
|
|
1449
1477
|
}
|
|
1450
1478
|
|
|
1479
|
+
/** Explicit repair also accepts an uninstalled legacy sibling in the same node_modules. */
|
|
1480
|
+
export async function isExplicitlyMigratableScript(candidate, installed) {
|
|
1481
|
+
if (await isOwnedEntryScript(candidate, installed)) return true;
|
|
1482
|
+
const oldRoot = packageEntryRoot(candidate);
|
|
1483
|
+
const newRoot = packageEntryRoot(installed);
|
|
1484
|
+
if (oldRoot === null || newRoot === null) return false;
|
|
1485
|
+
if (!['dsh-delegate', 'dsh-taskdispatch'].includes(basename(oldRoot))) return false;
|
|
1486
|
+
if (basename(newRoot) !== 'dsh-taskbridge' || basename(dirname(newRoot)) !== 'node_modules') return false;
|
|
1487
|
+
if (!samePlatformPath(dirname(oldRoot), dirname(newRoot))) return false;
|
|
1488
|
+
try { await lstat(oldRoot); return false; }
|
|
1489
|
+
catch (error) { return error?.code === 'ENOENT'; }
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1451
1492
|
/**
|
|
1452
1493
|
* The SYNCHRONOUS proof the classifier may use: the recorded script is this
|
|
1453
1494
|
* installation's own file.
|
|
@@ -2233,7 +2274,7 @@ function buildNotes({ agent, mcp, script, configError, nodeError = null }) {
|
|
|
2233
2274
|
if (agent.state === AGENT_STATES.modified) {
|
|
2234
2275
|
notes.push({
|
|
2235
2276
|
code: 'AGENT_USER_MODIFIED',
|
|
2236
|
-
text:
|
|
2277
|
+
text: `已存在内容不同的 agents/${AGENT_FILENAME},本插件不会覆盖或删除它;如需插件版本请先自行移动该文件。`,
|
|
2237
2278
|
});
|
|
2238
2279
|
}
|
|
2239
2280
|
if (agent.state === AGENT_STATES.conflict) {
|
|
@@ -2241,12 +2282,12 @@ function buildNotes({ agent, mcp, script, configError, nodeError = null }) {
|
|
|
2241
2282
|
// operator needs to know which one: a link on the way to the file (home or
|
|
2242
2283
|
// `agents/`), or a final path that is not a regular file (a link, a directory).
|
|
2243
2284
|
const text = agent.reason === 'codex-home-is-link'
|
|
2244
|
-
?
|
|
2285
|
+
? `Codex home 本身是链接(符号链接或 Windows reparse point/junction),本插件不会穿过它写入或删除 agents/${AGENT_FILENAME}。`
|
|
2245
2286
|
: agent.reason === 'agents-dir-is-link'
|
|
2246
|
-
?
|
|
2287
|
+
? `agents 目录是链接(符号链接或 Windows reparse point/junction),本插件不会穿过它写入或删除 ${AGENT_FILENAME}。`
|
|
2247
2288
|
: agent.reason === 'boundary-unverified'
|
|
2248
2289
|
? 'Codex home 或 agents 目录无法确认是真实目录(可能缺少 Windows PowerShell),本插件不会写入或删除任何文件。'
|
|
2249
|
-
:
|
|
2290
|
+
: `agents/${AGENT_FILENAME} 不是普通文件(可能是链接或目录),本插件不会改动它。`;
|
|
2250
2291
|
notes.push({ code: 'AGENT_PATH_CONFLICT', text });
|
|
2251
2292
|
}
|
|
2252
2293
|
if (agent.state === AGENT_STATES.outdated) {
|
|
@@ -2362,6 +2403,7 @@ export async function runCodexAction(action, {
|
|
|
2362
2403
|
|
|
2363
2404
|
if (action === 'remove') {
|
|
2364
2405
|
await removeManaged(before, { changed, refused });
|
|
2406
|
+
await migrateLegacyAgent(before, { changed, refused }, { removeOnly: true });
|
|
2365
2407
|
} else if (action === 'repair') {
|
|
2366
2408
|
// MCP only: the agent file is not touched at all — not created, not refreshed,
|
|
2367
2409
|
// not deleted. The returned status still reports its real (possibly `not-installed`
|
|
@@ -2386,9 +2428,30 @@ export async function runCodexAction(action, {
|
|
|
2386
2428
|
*/
|
|
2387
2429
|
async function installManaged(before, outcome) {
|
|
2388
2430
|
await installManagedAgent(before, outcome);
|
|
2431
|
+
await migrateLegacyAgent(before, outcome);
|
|
2389
2432
|
await installMcpEntry(before, outcome);
|
|
2390
2433
|
}
|
|
2391
2434
|
|
|
2435
|
+
/** Move a previously installed, unchanged companion to the public TaskBridge name. */
|
|
2436
|
+
async function migrateLegacyAgent(before, outcome, { removeOnly = false } = {}) {
|
|
2437
|
+
const legacyPath = join(before.codexHome, 'agents', LEGACY_AGENT_FILENAME);
|
|
2438
|
+
const legacy = await inspectFile(legacyPath);
|
|
2439
|
+
if (legacy.kind !== 'file' || !isKnownPriorTemplate(legacy.contents)) return;
|
|
2440
|
+
if (!removeOnly) {
|
|
2441
|
+
if (before.agent.state === AGENT_STATES.missing) {
|
|
2442
|
+
const current = await inspectFile(before.agent.path);
|
|
2443
|
+
if (current.kind === 'missing') await installManagedAgent(before, outcome);
|
|
2444
|
+
}
|
|
2445
|
+
const template = renderAgentFile(await readAgentTemplate(), before.packageVersion);
|
|
2446
|
+
const current = await inspectFile(before.agent.path);
|
|
2447
|
+
if (current.kind !== 'file' || current.contents !== template) return;
|
|
2448
|
+
}
|
|
2449
|
+
const currentLegacy = await inspectFile(legacyPath);
|
|
2450
|
+
if (currentLegacy.kind !== 'file' || currentLegacy.contents !== legacy.contents) return;
|
|
2451
|
+
await unlink(legacyPath);
|
|
2452
|
+
if (!outcome.changed.includes('agent')) outcome.changed.push('agent');
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2392
2455
|
/**
|
|
2393
2456
|
* Refresh only an agent file whose complete bytes match a known shipped template.
|
|
2394
2457
|
*
|
|
@@ -2428,6 +2491,7 @@ export async function refreshKnownAgentTemplate(options = {}) {
|
|
|
2428
2491
|
if (before.agent.state === AGENT_STATES.outdated) {
|
|
2429
2492
|
await installManagedAgent(before, { changed, refused });
|
|
2430
2493
|
}
|
|
2494
|
+
await migrateLegacyAgent(before, { changed, refused });
|
|
2431
2495
|
if (refreshMcp === true) {
|
|
2432
2496
|
// The automatic MCP half: only a provably-owned, merely-stale definition is
|
|
2433
2497
|
// rewritten, and only after the boundary and the config digest are re-proved. It
|
|
@@ -3128,7 +3192,7 @@ export async function adoptProvedMovedInstall(before) {
|
|
|
3128
3192
|
const args = Array.isArray(mcp.previous.args) ? mcp.previous.args : [];
|
|
3129
3193
|
if (args.length !== 1) return null;
|
|
3130
3194
|
if (mcp.previous.command !== mcp.desired.command && !isLegacyDesktopCommand(mcp.previous.command)) return null;
|
|
3131
|
-
if ((await
|
|
3195
|
+
if ((await isExplicitlyMigratableScript(args[0], mcp.desired.args[0])) !== true) return null;
|
|
3132
3196
|
let loaded;
|
|
3133
3197
|
try {
|
|
3134
3198
|
loaded = await loadConfig(mcp.path);
|
|
@@ -3145,7 +3209,7 @@ export async function adoptProvedMovedInstall(before) {
|
|
|
3145
3209
|
if (classification.marked !== true || classification.reason !== 'args-shape-not-ours') return null;
|
|
3146
3210
|
const currentArgs = Array.isArray(classification.previous?.args) ? classification.previous.args : [];
|
|
3147
3211
|
if (currentArgs.length !== 1) return null;
|
|
3148
|
-
if ((await
|
|
3212
|
+
if ((await isExplicitlyMigratableScript(currentArgs[0], mcp.desired.args[0])) !== true) return null;
|
|
3149
3213
|
return { document: loaded.document, classification, desired: mcp.desired };
|
|
3150
3214
|
}
|
|
3151
3215
|
|
|
@@ -3236,7 +3300,7 @@ export async function adoptMovedInstall(adopted, outcome, before) {
|
|
|
3236
3300
|
return;
|
|
3237
3301
|
}
|
|
3238
3302
|
const currentArgs = Array.isArray(classification.previous?.args) ? classification.previous.args : [];
|
|
3239
|
-
if (currentArgs.length !== 1 || (await
|
|
3303
|
+
if (currentArgs.length !== 1 || (await isExplicitlyMigratableScript(currentArgs[0], mcp.desired.args[0])) !== true) {
|
|
3240
3304
|
refuse('MCP_ENTRY_CONFLICT',
|
|
3241
3305
|
'the recorded entry script is no longer provably an installation of this package, so nothing was written',
|
|
3242
3306
|
'script-not-provably-ours');
|
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) {
|
package/src/config/validate.js
CHANGED
|
@@ -423,7 +423,7 @@ export function validateReviewSettings(value, providers) {
|
|
|
423
423
|
/**
|
|
424
424
|
* Validate the activity-monitoring block.
|
|
425
425
|
*
|
|
426
|
-
* Two silence thresholds
|
|
426
|
+
* Two silence thresholds and one failure-count threshold:
|
|
427
427
|
*
|
|
428
428
|
* * `selfCheckSeconds` is when the engine performs ONE read-only local
|
|
429
429
|
* inspection of the executor it already holds (alive, phase, pending request,
|
|
@@ -431,33 +431,39 @@ export function validateReviewSettings(value, providers) {
|
|
|
431
431
|
* call and never touches the task's state, budget or deadline.
|
|
432
432
|
* * `attentionSeconds` is when a wait stops keeping quiet and reports
|
|
433
433
|
* `attention` to the commander instead of `heartbeat`.
|
|
434
|
+
* * `repeatFailureThreshold` is how many CONSECUTIVE identical tool failures are
|
|
435
|
+
* reported once, or `0` to switch that reminder off. It is a count, so it is
|
|
436
|
+
* independent of the two silence thresholds: a busy run that keeps failing the
|
|
437
|
+
* same way never reaches either of them.
|
|
434
438
|
*
|
|
435
439
|
* A missing block is the documented default (backwards compatible: documents
|
|
436
|
-
* written before this field existed keep loading
|
|
437
|
-
*
|
|
438
|
-
*
|
|
440
|
+
* written before this field existed keep loading, and a document that has the other
|
|
441
|
+
* two but not this one gets the default rather than an error). Everything else is
|
|
442
|
+
* refused rather than repaired — an unknown key (a typo such as `atentionSeconds`
|
|
443
|
+
* would otherwise silently keep the default), a wrong type, a non-integer, an
|
|
439
444
|
* out-of-range value, and any pair where the attention threshold is not strictly
|
|
440
|
-
* greater than the self-check one. A repaired value would make the
|
|
441
|
-
*
|
|
442
|
-
*
|
|
445
|
+
* greater than the self-check one. A repaired value would make the timers disagree
|
|
446
|
+
* with what the operator stored, which is exactly the class of silent mismatch this
|
|
447
|
+
* plugin refuses everywhere else.
|
|
443
448
|
* @param {unknown} value - candidate monitoring block.
|
|
444
|
-
* @returns {{ selfCheckSeconds: number, attentionSeconds: number }} normalized block.
|
|
449
|
+
* @returns {{ selfCheckSeconds: number, attentionSeconds: number, repeatFailureThreshold: number }} normalized block.
|
|
445
450
|
*/
|
|
446
451
|
export function validateMonitoringSettings(value) {
|
|
447
452
|
if (value === undefined || value === null) {
|
|
448
453
|
return {
|
|
449
454
|
selfCheckSeconds: MONITORING_DEFAULTS.selfCheckSeconds,
|
|
450
455
|
attentionSeconds: MONITORING_DEFAULTS.attentionSeconds,
|
|
456
|
+
repeatFailureThreshold: MONITORING_DEFAULTS.repeatFailureThreshold,
|
|
451
457
|
};
|
|
452
458
|
}
|
|
453
459
|
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
454
460
|
throw new ConfigError('MONITORING_INVALID', 'monitoring settings must be an object', { field: 'monitoring' });
|
|
455
461
|
}
|
|
456
462
|
for (const key of Object.keys(value)) {
|
|
457
|
-
if (key !== 'selfCheckSeconds' && key !== 'attentionSeconds') {
|
|
463
|
+
if (key !== 'selfCheckSeconds' && key !== 'attentionSeconds' && key !== 'repeatFailureThreshold') {
|
|
458
464
|
throw new ConfigError('MONITORING_INVALID', `monitoring setting ${key} is not supported`, {
|
|
459
465
|
field: `monitoring.${key}`,
|
|
460
|
-
supported: ['selfCheckSeconds', 'attentionSeconds'],
|
|
466
|
+
supported: ['selfCheckSeconds', 'attentionSeconds', 'repeatFailureThreshold'],
|
|
461
467
|
});
|
|
462
468
|
}
|
|
463
469
|
}
|
|
@@ -482,7 +488,16 @@ export function validateMonitoringSettings(value) {
|
|
|
482
488
|
{ field: 'monitoring.attentionSeconds', selfCheckSeconds, attentionSeconds },
|
|
483
489
|
);
|
|
484
490
|
}
|
|
485
|
-
|
|
491
|
+
const repeatFailureThreshold = requireInt(
|
|
492
|
+
value.repeatFailureThreshold === undefined
|
|
493
|
+
? MONITORING_DEFAULTS.repeatFailureThreshold
|
|
494
|
+
: value.repeatFailureThreshold,
|
|
495
|
+
'MONITORING_INVALID',
|
|
496
|
+
'monitoring.repeatFailureThreshold',
|
|
497
|
+
LIMITS.repeatFailureThresholdMin,
|
|
498
|
+
LIMITS.repeatFailureThresholdMax,
|
|
499
|
+
);
|
|
500
|
+
return { selfCheckSeconds, attentionSeconds, repeatFailureThreshold };
|
|
486
501
|
}
|
|
487
502
|
|
|
488
503
|
/** Validate legacy grant TTLs kept for backwards-compatible imports. */
|