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/package.json
CHANGED
|
@@ -1,137 +1,143 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-taskbridge",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "让 Claude Code 或 Codex 指挥 DSH 完成任务;在 DSH 插件中配置 API、执行模型、思考强度、权限审批与集中审查。",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/ranranyya/dsh-taskbridge.git"
|
|
9
|
-
},
|
|
10
|
-
"homepage": "https://github.com/ranranyya/dsh-taskbridge#readme",
|
|
11
|
-
"bugs": {
|
|
12
|
-
"url": "https://github.com/ranranyya/dsh-taskbridge/issues"
|
|
13
|
-
},
|
|
14
|
-
"type": "module",
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=24",
|
|
17
|
-
"dsh": "0.2.0-rc.2 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.2-rc.1"
|
|
18
|
-
},
|
|
19
|
-
"main": "src/index.js",
|
|
20
|
-
"types": "src/index.d.ts",
|
|
21
|
-
"exports": {
|
|
22
|
-
".": {
|
|
23
|
-
"types": "./src/index.d.ts",
|
|
24
|
-
"default": "./src/index.js"
|
|
25
|
-
},
|
|
26
|
-
"./client": {
|
|
27
|
-
"types": "./lib/client.d.ts",
|
|
28
|
-
"default": "./lib/client.js"
|
|
29
|
-
},
|
|
30
|
-
"./mcp": {
|
|
31
|
-
"types": "./bin/dsh-delegate-mcp.d.ts",
|
|
32
|
-
"default": "./bin/dsh-delegate-mcp.js"
|
|
33
|
-
},
|
|
34
|
-
"./package.json": "./package.json"
|
|
35
|
-
},
|
|
36
|
-
"bin": {
|
|
37
|
-
"dsh-delegate-mcp": "bin/dsh-delegate-mcp.js",
|
|
38
|
-
"dsh-delegate-codex-agent": "bin/dsh-delegate-codex-agent.js",
|
|
39
|
-
"dsh-delegate-control": "bin/dsh-delegate-control.js"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"bin/dsh-delegate-
|
|
51
|
-
"bin/dsh-delegate-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"docs/
|
|
61
|
-
"docs/
|
|
62
|
-
"docs/
|
|
63
|
-
"docs/
|
|
64
|
-
"docs/
|
|
65
|
-
"docs/
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"docs/
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"docs/
|
|
72
|
-
"docs/
|
|
73
|
-
"docs/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"@
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"@deepseek-ai/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"@deepseek-ai/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"@deepseek-ai/
|
|
106
|
-
"@deepseek-ai/dsh-
|
|
107
|
-
"@deepseek-ai/dsh-
|
|
108
|
-
"@deepseek-ai/dsh-
|
|
109
|
-
"@deepseek-ai/dsh-
|
|
110
|
-
"@deepseek-ai/
|
|
111
|
-
"@
|
|
112
|
-
"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
"dsh",
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-taskbridge",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "让 Claude Code 或 Codex 指挥 DSH 完成任务;在 DSH 插件中配置 API、执行模型、思考强度、权限审批与集中审查。",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/ranranyya/dsh-taskbridge.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/ranranyya/dsh-taskbridge#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/ranranyya/dsh-taskbridge/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=24",
|
|
17
|
+
"dsh": "0.2.0-rc.2 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.2-rc.1"
|
|
18
|
+
},
|
|
19
|
+
"main": "src/index.js",
|
|
20
|
+
"types": "src/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./src/index.d.ts",
|
|
24
|
+
"default": "./src/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./client": {
|
|
27
|
+
"types": "./lib/client.d.ts",
|
|
28
|
+
"default": "./lib/client.js"
|
|
29
|
+
},
|
|
30
|
+
"./mcp": {
|
|
31
|
+
"types": "./bin/dsh-delegate-mcp.d.ts",
|
|
32
|
+
"default": "./bin/dsh-delegate-mcp.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"bin": {
|
|
37
|
+
"dsh-delegate-mcp": "bin/dsh-delegate-mcp.js",
|
|
38
|
+
"dsh-delegate-codex-agent": "bin/dsh-delegate-codex-agent.js",
|
|
39
|
+
"dsh-delegate-control": "bin/dsh-delegate-control.js",
|
|
40
|
+
"dsh-taskbridge-mcp": "bin/dsh-delegate-mcp.js",
|
|
41
|
+
"dsh-taskbridge-codex-agent": "bin/dsh-delegate-codex-agent.js",
|
|
42
|
+
"dsh-taskbridge-control": "bin/dsh-delegate-control.js"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"src/**/*.js",
|
|
46
|
+
"src/**/*.jsx",
|
|
47
|
+
"src/**/*.d.ts",
|
|
48
|
+
"lib/client.js",
|
|
49
|
+
"lib/client.d.ts",
|
|
50
|
+
"bin/dsh-delegate-mcp.js",
|
|
51
|
+
"bin/dsh-delegate-mcp.d.ts",
|
|
52
|
+
"bin/dsh-delegate-codex-agent.js",
|
|
53
|
+
"bin/dsh-delegate-control.js",
|
|
54
|
+
"bin/dsh-delegate-control.d.ts",
|
|
55
|
+
"codex/dsh-taskbridge.toml",
|
|
56
|
+
"cordis.patch.yml",
|
|
57
|
+
"README.md",
|
|
58
|
+
"LICENSE",
|
|
59
|
+
"CHANGELOG.md",
|
|
60
|
+
"docs/auth-contract.md",
|
|
61
|
+
"docs/codex-integration.md",
|
|
62
|
+
"docs/conversation-placement.md",
|
|
63
|
+
"docs/contracts-stage-b.md",
|
|
64
|
+
"docs/redaction-contract.md",
|
|
65
|
+
"docs/runtime-compatibility.md",
|
|
66
|
+
"docs/silent-wait.md",
|
|
67
|
+
"docs/worker-permissions.md",
|
|
68
|
+
"docs/workspace-contract.md",
|
|
69
|
+
"icon.svg",
|
|
70
|
+
"locale/*.json",
|
|
71
|
+
"docs/INTRODUCTION.zh.md",
|
|
72
|
+
"docs/INTRODUCTION.md",
|
|
73
|
+
"docs/taskdispatch-upgrade.md",
|
|
74
|
+
"docs/claude-code.md",
|
|
75
|
+
"docs/plugin-market.md",
|
|
76
|
+
"docs/taskbridge-upgrade.md",
|
|
77
|
+
"docs/releases/1.4.0.zh.md",
|
|
78
|
+
"docs/releases/1.4.0-token-benchmark.zh.md"
|
|
79
|
+
],
|
|
80
|
+
"dsh": {
|
|
81
|
+
"manifestVersion": 1,
|
|
82
|
+
"bundle": {
|
|
83
|
+
"patch": "./cordis.patch.yml"
|
|
84
|
+
},
|
|
85
|
+
"client": {
|
|
86
|
+
"inject": [
|
|
87
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
88
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager"
|
|
89
|
+
],
|
|
90
|
+
"platform": "web"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.2 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.2-rc.1",
|
|
95
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.2 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.2-rc.1",
|
|
96
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.2-rc.1",
|
|
97
|
+
"@deepseek-ai/dsh-tool-fs": "0.2.0-rc.2 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.2-rc.1",
|
|
98
|
+
"@deepseek-ai/dsh-tool-fs-search": "0.2.0-rc.2 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.2-rc.1",
|
|
99
|
+
"@earendil-works/pi-ai": "^0.87.1 || ^1.1.0"
|
|
100
|
+
},
|
|
101
|
+
"dependencies": {
|
|
102
|
+
"@deepseek-ai/schemastery": "~3.18.4"
|
|
103
|
+
},
|
|
104
|
+
"devDependencies": {
|
|
105
|
+
"@deepseek-ai/cordis": "4.0.5",
|
|
106
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
107
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
108
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
|
|
109
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.2.0-rc.2",
|
|
110
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
111
|
+
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
|
|
112
|
+
"@deepseek-ai/dsh-tool-fs": "0.2.0-rc.2",
|
|
113
|
+
"@deepseek-ai/dsh-tool-fs-search": "0.2.0-rc.2",
|
|
114
|
+
"@deepseek-ai/dsh-user-approval": "0.2.0-rc.2",
|
|
115
|
+
"@deepseek-ai/schemastery": "~3.18.4",
|
|
116
|
+
"@earendil-works/pi-ai": "^0.87.1",
|
|
117
|
+
"esbuild": "0.25.11"
|
|
118
|
+
},
|
|
119
|
+
"scripts": {
|
|
120
|
+
"test": "node --test --test-concurrency=1 tests/*.test.js",
|
|
121
|
+
"test:isolated": "node --test tests/*.test.js",
|
|
122
|
+
"build:client": "node scripts/build-client.mjs",
|
|
123
|
+
"check:client": "node scripts/build-client.mjs --check",
|
|
124
|
+
"mcp": "node bin/dsh-delegate-mcp.js",
|
|
125
|
+
"codex-agent": "node bin/dsh-delegate-codex-agent.js",
|
|
126
|
+
"control": "node bin/dsh-delegate-control.js",
|
|
127
|
+
"pack:dry": "npm pack --dry-run",
|
|
128
|
+
"build:market": "node scripts/build-plugin-market.mjs",
|
|
129
|
+
"verify:silent-wait": "node scripts/verify-silent-wait.mjs --duration-seconds 1200"
|
|
130
|
+
},
|
|
131
|
+
"keywords": [
|
|
132
|
+
"dsh",
|
|
133
|
+
"dsh-plugin",
|
|
134
|
+
"deepseek-harness",
|
|
135
|
+
"taskbridge",
|
|
136
|
+
"codex",
|
|
137
|
+
"claude-code",
|
|
138
|
+
"mcp",
|
|
139
|
+
"delegation"
|
|
140
|
+
],
|
|
141
|
+
"author": "ranranyya",
|
|
142
|
+
"icon": "./icon.svg"
|
|
143
|
+
}
|
package/src/client/api.js
CHANGED
|
@@ -426,9 +426,10 @@ export function conversationModeLabel(mode) {
|
|
|
426
426
|
* inconsistent pair is passed through so the operator sees what they typed and the
|
|
427
427
|
* precheck can explain it. Only a missing block, a non-object, or a non-finite value
|
|
428
428
|
* falls back to the documented default — an older stored document (no `monitoring`
|
|
429
|
-
* key) therefore opens at 300/600 s, i.e. 5/10 minutes
|
|
429
|
+
* key) therefore opens at 300/600 s, i.e. 5/10 minutes, with the repeated-failure
|
|
430
|
+
* reminder at its default of 3.
|
|
430
431
|
* @param {object | null} source - served document, draft, or raw block.
|
|
431
|
-
* @returns {{ selfCheckSeconds: number, attentionSeconds: number }} normalized block.
|
|
432
|
+
* @returns {{ selfCheckSeconds: number, attentionSeconds: number, repeatFailureThreshold: number }} normalized block.
|
|
432
433
|
*/
|
|
433
434
|
export function monitoringOf(source) {
|
|
434
435
|
const block = source?.monitoring;
|
|
@@ -437,6 +438,36 @@ export function monitoringOf(source) {
|
|
|
437
438
|
return {
|
|
438
439
|
selfCheckSeconds: whole(block.selfCheckSeconds, MONITORING_DEFAULTS.selfCheckSeconds),
|
|
439
440
|
attentionSeconds: whole(block.attentionSeconds, MONITORING_DEFAULTS.attentionSeconds),
|
|
441
|
+
repeatFailureThreshold: whole(block.repeatFailureThreshold, MONITORING_DEFAULTS.repeatFailureThreshold),
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* The RAW monitoring block of a draft, for validation only.
|
|
447
|
+
*
|
|
448
|
+
* `monitoringOf` is a display normalizer: it turns a blank or non-finite field into the
|
|
449
|
+
* documented default so the inputs still render. That is exactly wrong for validating
|
|
450
|
+
* an edit — a cleared field would silently look like the default and the save button
|
|
451
|
+
* would stay enabled. This keeps whatever the operator actually typed (including `''`),
|
|
452
|
+
* so the shared precheck can refuse it. Only a missing block falls back to the defaults.
|
|
453
|
+
*
|
|
454
|
+
* One narrow exception: a block that predates the repeated-failure count has no such key
|
|
455
|
+
* at all, and an absent key is not an operator error — it is the documented default. So
|
|
456
|
+
* `undefined` becomes the default value (making the field editable for an older document),
|
|
457
|
+
* while an explicit `''`, `null`, fractional or out-of-range value is preserved exactly so
|
|
458
|
+
* the precheck still refuses it.
|
|
459
|
+
* @param {object | null} source - draft or served document.
|
|
460
|
+
* @returns {object} the block as stored, or the defaults when there is none.
|
|
461
|
+
*/
|
|
462
|
+
export function monitoringDraftOf(source) {
|
|
463
|
+
const block = source?.monitoring;
|
|
464
|
+
if (block === null || typeof block !== 'object' || Array.isArray(block)) return { ...MONITORING_DEFAULTS };
|
|
465
|
+
return {
|
|
466
|
+
selfCheckSeconds: block.selfCheckSeconds,
|
|
467
|
+
attentionSeconds: block.attentionSeconds,
|
|
468
|
+
repeatFailureThreshold: block.repeatFailureThreshold === undefined
|
|
469
|
+
? MONITORING_DEFAULTS.repeatFailureThreshold
|
|
470
|
+
: block.repeatFailureThreshold,
|
|
440
471
|
};
|
|
441
472
|
}
|
|
442
473
|
|
|
@@ -590,10 +621,13 @@ export const LIMITS = Object.freeze({
|
|
|
590
621
|
selfCheckSecondsMax: 3600,
|
|
591
622
|
attentionSecondsMin: 31,
|
|
592
623
|
attentionSecondsMax: 7200,
|
|
624
|
+
// Repeated-failure reminder: a COUNT of consecutive identical failures, 0 = off.
|
|
625
|
+
repeatFailureThresholdMin: 0,
|
|
626
|
+
repeatFailureThresholdMax: 20,
|
|
593
627
|
});
|
|
594
628
|
|
|
595
629
|
/**
|
|
596
|
-
* Default silence thresholds, mirroring `MONITORING_DEFAULTS`.
|
|
630
|
+
* Default silence thresholds and failure count, mirroring `MONITORING_DEFAULTS`.
|
|
597
631
|
*
|
|
598
632
|
* Stored as whole SECONDS (300 / 600). The panel presents them as minutes because
|
|
599
633
|
* that is how an operator thinks about them; a value that is not a whole number of
|
|
@@ -602,6 +636,7 @@ export const LIMITS = Object.freeze({
|
|
|
602
636
|
export const MONITORING_DEFAULTS = Object.freeze({
|
|
603
637
|
selfCheckSeconds: 300,
|
|
604
638
|
attentionSeconds: 600,
|
|
639
|
+
repeatFailureThreshold: 3,
|
|
605
640
|
});
|
|
606
641
|
|
|
607
642
|
/** Chinese labels for the self-check verdicts the host publishes. */
|
|
@@ -614,6 +649,30 @@ export const SELF_CHECK_LABELS = Object.freeze({
|
|
|
614
649
|
settled: '任务已经结束',
|
|
615
650
|
});
|
|
616
651
|
|
|
652
|
+
/** Chinese label for the repeated-failure reminder kind. */
|
|
653
|
+
export const REPEATED_FAILURE_LABEL = '同一操作连续失败';
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* One line describing the repeated-failure reminder on a task page.
|
|
657
|
+
*
|
|
658
|
+
* The engine already reduced this to a tool name, a failure code and counts, so this
|
|
659
|
+
* is a formatter and nothing else: no arguments, output or error prose is available
|
|
660
|
+
* here even if a stored record somehow carried it.
|
|
661
|
+
* @param {object | null} activity - the task's activity block.
|
|
662
|
+
* @returns {string} display text.
|
|
663
|
+
*/
|
|
664
|
+
export function repeatFailureLine(activity) {
|
|
665
|
+
const block = activity?.repeatFailure;
|
|
666
|
+
if (block === null || block === undefined) return '未采集到';
|
|
667
|
+
const reported = Array.isArray(block.reported) ? block.reported : [];
|
|
668
|
+
if (reported.length === 0) {
|
|
669
|
+
return block.threshold === 0 ? '已关闭' : `尚未触发(连续 ${block.threshold} 次才提醒)`;
|
|
670
|
+
}
|
|
671
|
+
return reported
|
|
672
|
+
.map((entry) => `${entry.toolName ?? '工具'} · ${entry.failureCode ?? 'error'} 连续 ${entry.consecutive} 次`)
|
|
673
|
+
.join(';');
|
|
674
|
+
}
|
|
675
|
+
|
|
617
676
|
/** Chinese labels for the reasons a wait returns. */
|
|
618
677
|
export const WAIT_REASON_LABELS = Object.freeze({
|
|
619
678
|
heartbeat: '没有需要处理的事(内部心跳)',
|
|
@@ -1006,25 +1065,12 @@ export function precheckDraft(draft) {
|
|
|
1006
1065
|
if (!Number.isInteger(parallelism) || parallelism < LIMITS.maxParallelismMin || parallelism > LIMITS.maxParallelismMax) {
|
|
1007
1066
|
problems.push(`最大并发需为 ${LIMITS.maxParallelismMin}–${LIMITS.maxParallelismMax} 之间的整数`);
|
|
1008
1067
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
const min = field === 'selfCheckSeconds' ? LIMITS.selfCheckSecondsMin : LIMITS.attentionSecondsMin;
|
|
1016
|
-
const max = field === 'selfCheckSeconds' ? LIMITS.selfCheckSecondsMax : LIMITS.attentionSecondsMax;
|
|
1017
|
-
if (!Number.isInteger(value) || value < min || value > max) {
|
|
1018
|
-
problems.push(`${label}需为 ${min}–${max} 秒之间的整数`);
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
// The ordering rule mirrors `validateMonitoringSettings`: an attention threshold at
|
|
1022
|
-
// or below the self-check one would alert about something the self-check has not
|
|
1023
|
-
// even examined yet.
|
|
1024
|
-
if (Number.isInteger(monitoring.selfCheckSeconds) && Number.isInteger(monitoring.attentionSeconds)
|
|
1025
|
-
&& monitoring.attentionSeconds <= monitoring.selfCheckSeconds) {
|
|
1026
|
-
problems.push('提醒你的间隔必须大于程序自检间隔');
|
|
1027
|
-
}
|
|
1068
|
+
// The RAW block, not the display-normalized one: a cleared field must be refused
|
|
1069
|
+
// here instead of silently becoming the documented default on save. The rules
|
|
1070
|
+
// themselves live in exactly one place — `precheckMonitoring` — so a field can never
|
|
1071
|
+
// be validated by the narrow monitoring button and forgotten by this whole-draft check
|
|
1072
|
+
// (which is what happened to the repeated-failure count).
|
|
1073
|
+
problems.push(...precheckMonitoring(monitoringDraftOf(draft)));
|
|
1028
1074
|
return problems;
|
|
1029
1075
|
}
|
|
1030
1076
|
|
|
@@ -1209,7 +1255,11 @@ export function taskActivity(task) {
|
|
|
1209
1255
|
*/
|
|
1210
1256
|
export function taskProgress(task) {
|
|
1211
1257
|
const activity = taskActivity(task);
|
|
1212
|
-
|
|
1258
|
+
// The headline must not contradict the task's own status badge. `taskOutcome` owns the
|
|
1259
|
+
// headline wording, so a recorded review (or a finished run) says THAT here instead of
|
|
1260
|
+
// repeating the raw phase label a second time.
|
|
1261
|
+
const outcome = taskOutcome(task);
|
|
1262
|
+
const phase = outcome.label;
|
|
1213
1263
|
if (activity === null) {
|
|
1214
1264
|
return {
|
|
1215
1265
|
available: false,
|
|
@@ -1297,18 +1347,36 @@ export function hasLiveTasks(tasks) {
|
|
|
1297
1347
|
}
|
|
1298
1348
|
|
|
1299
1349
|
/**
|
|
1300
|
-
* Pre-flight checks for the
|
|
1350
|
+
* Pre-flight checks for the silence thresholds AND the repeated-failure count.
|
|
1301
1351
|
*
|
|
1302
1352
|
* Mirrors `validateMonitoringSettings`. Kept separate because the monitoring save has
|
|
1303
1353
|
* its own narrow button: a bad timer must not block saving the rest of the settings,
|
|
1304
1354
|
* and a bad provider block must not block saving a timer.
|
|
1305
|
-
*
|
|
1355
|
+
*
|
|
1356
|
+
* The block passed in must be the RAW one (`monitoringDraftOf`), not the display-normalized
|
|
1357
|
+
* `monitoringOf`: the latter replaces a cleared field with the documented default, which
|
|
1358
|
+
* would make an empty input look valid. This is the single validation path — `precheckDraft`
|
|
1359
|
+
* and the monitoring card both delegate here, so the count cannot be checked in one place
|
|
1360
|
+
* and forgotten in another.
|
|
1361
|
+
*
|
|
1362
|
+
* Backwards compatible with an older document or an older host that has no
|
|
1363
|
+
* `repeatFailureThreshold` at all: an ABSENT value takes the documented default, exactly as
|
|
1364
|
+
* the host validator does. A value that is present but wrong is still refused.
|
|
1365
|
+
* @param {{ selfCheckSeconds: number, attentionSeconds: number, repeatFailureThreshold?: number }} monitoring - raw block.
|
|
1306
1366
|
* @returns {string[]} Chinese problem descriptions; empty when plausible.
|
|
1307
1367
|
*/
|
|
1308
1368
|
export function precheckMonitoring(monitoring) {
|
|
1309
1369
|
const problems = [];
|
|
1310
1370
|
const self = monitoring?.selfCheckSeconds;
|
|
1311
1371
|
const attention = monitoring?.attentionSeconds;
|
|
1372
|
+
// An ABSENT count is not an operator error: a document written before this setting
|
|
1373
|
+
// existed has no such key, and the host fills in the documented default. Anything the
|
|
1374
|
+
// operator actually supplied — `''`, `null`, a fraction, an out-of-range number — is
|
|
1375
|
+
// validated exactly as given. There is deliberately no `Number()` coercion and no
|
|
1376
|
+
// rounding, so nothing is "repaired" into a value nobody chose.
|
|
1377
|
+
const repeat = monitoring?.repeatFailureThreshold === undefined
|
|
1378
|
+
? MONITORING_DEFAULTS.repeatFailureThreshold
|
|
1379
|
+
: monitoring.repeatFailureThreshold;
|
|
1312
1380
|
if (!Number.isInteger(self) || self < LIMITS.selfCheckSecondsMin || self > LIMITS.selfCheckSecondsMax) {
|
|
1313
1381
|
problems.push(`程序自检间隔需为 ${LIMITS.selfCheckSecondsMin}–${LIMITS.selfCheckSecondsMax} 秒之间的整数`);
|
|
1314
1382
|
}
|
|
@@ -1318,34 +1386,121 @@ export function precheckMonitoring(monitoring) {
|
|
|
1318
1386
|
if (Number.isInteger(self) && Number.isInteger(attention) && attention <= self) {
|
|
1319
1387
|
problems.push('提醒你的间隔必须大于程序自检间隔');
|
|
1320
1388
|
}
|
|
1389
|
+
// The repeated-failure reminder is a COUNT of consecutive identical failures; `0` is a
|
|
1390
|
+
// legal "off" value, so the range starts at zero rather than at one.
|
|
1391
|
+
if (!Number.isInteger(repeat)
|
|
1392
|
+
|| repeat < LIMITS.repeatFailureThresholdMin
|
|
1393
|
+
|| repeat > LIMITS.repeatFailureThresholdMax) {
|
|
1394
|
+
problems.push(`重复失败提醒次数需为 ${LIMITS.repeatFailureThresholdMin}–${LIMITS.repeatFailureThresholdMax} 之间的整数(0 表示关闭)`);
|
|
1395
|
+
}
|
|
1321
1396
|
return problems;
|
|
1322
1397
|
}
|
|
1323
1398
|
|
|
1324
1399
|
/**
|
|
1325
|
-
* Honest execution/acceptance summary for one task.
|
|
1400
|
+
* Honest execution/acceptance summary for one task — the ONE source of a task's headline.
|
|
1326
1401
|
*
|
|
1327
|
-
* The engine reports `awaiting-host-review` after successful execution. That is
|
|
1328
|
-
*
|
|
1329
|
-
*
|
|
1402
|
+
* The engine reports `awaiting-host-review` after successful execution. That is NOT
|
|
1403
|
+
* acceptance: `selfApproved` is always false, and only a recorded host decision with
|
|
1404
|
+
* `accepted === true` counts. A recorded `changes-requested` is a real conclusion too —
|
|
1405
|
+
* "reviewed and needs correction" — and must never read as accepted.
|
|
1406
|
+
*
|
|
1407
|
+
* `label` is what a list or a detail header shows INSTEAD of the raw state, so a task with
|
|
1408
|
+
* a recorded conclusion never keeps reading "等待宿主审查". The underlying `state` is
|
|
1409
|
+
* untouched (older clients and `continueFromTaskId` depend on it); this is presentation
|
|
1410
|
+
* only.
|
|
1330
1411
|
* @param {object} task - task view.
|
|
1331
|
-
* @returns {{ label: string, executed: boolean, accepted: boolean,
|
|
1412
|
+
* @returns {{ label: string, tone: string, executed: boolean, accepted: boolean, decided: boolean,
|
|
1413
|
+
* phaseLabel: string | null, note: string }} summary. `phaseLabel` is `null` when the
|
|
1414
|
+
* phase would repeat the label.
|
|
1332
1415
|
*/
|
|
1333
1416
|
export function taskOutcome(task) {
|
|
1334
1417
|
const state = String(task?.state ?? '');
|
|
1335
|
-
const
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1418
|
+
const acceptance = task?.hostAcceptance;
|
|
1419
|
+
// Only an explicit `accepted === true` is acceptance. The presence of an object is NOT
|
|
1420
|
+
// enough: a `changes-requested` record is also an object.
|
|
1421
|
+
const accepted = acceptance !== null && acceptance !== undefined && acceptance.accepted === true;
|
|
1422
|
+
const decided = acceptance !== null && acceptance !== undefined;
|
|
1423
|
+
const executed = state === 'awaiting-host-review' || decided;
|
|
1424
|
+
let label;
|
|
1425
|
+
let tone;
|
|
1426
|
+
let note;
|
|
1427
|
+
let phaseLabel;
|
|
1428
|
+
if (accepted) {
|
|
1429
|
+
label = '审查通过';
|
|
1430
|
+
tone = 'on';
|
|
1431
|
+
note = '宿主已记录验收结论:审查通过。';
|
|
1432
|
+
// The run is over AND reviewed, so the phase would only repeat itself.
|
|
1433
|
+
phaseLabel = null;
|
|
1434
|
+
} else if (decided) {
|
|
1435
|
+
label = '需要修正';
|
|
1436
|
+
tone = 'warn';
|
|
1437
|
+
note = '宿主已记录验收结论:需要修正(本任务的执行结果未被接受)。';
|
|
1438
|
+
phaseLabel = null;
|
|
1439
|
+
} else if (state === 'awaiting-host-review') {
|
|
1440
|
+
label = '等待宿主审查';
|
|
1441
|
+
tone = 'warn';
|
|
1442
|
+
note = '执行已完成,等待宿主(Codex)审查;插件不会自行验收。';
|
|
1443
|
+
// Stated once, as the headline above; a second identical phase badge is noise.
|
|
1444
|
+
phaseLabel = null;
|
|
1445
|
+
} else if (state === 'failed') {
|
|
1446
|
+
label = taskStateLabel(state);
|
|
1447
|
+
tone = 'warn';
|
|
1448
|
+
note = '执行失败;错误详情见下方证据。';
|
|
1449
|
+
phaseLabel = null;
|
|
1450
|
+
} else if (state === 'cancelled') {
|
|
1451
|
+
label = taskStateLabel(state);
|
|
1452
|
+
tone = 'off';
|
|
1453
|
+
note = '任务已取消,未产生验收结论。';
|
|
1454
|
+
phaseLabel = null;
|
|
1455
|
+
} else {
|
|
1456
|
+
label = taskStateLabel(state);
|
|
1457
|
+
tone = state === 'running' ? 'on' : 'off';
|
|
1458
|
+
note = '任务尚未产生结果。';
|
|
1459
|
+
// A live run DOES keep a distinct phase badge: it says what is happening right now,
|
|
1460
|
+
// which the state label does not. That is information, not a contradiction.
|
|
1461
|
+
phaseLabel = taskPhaseLabel(task?.phase);
|
|
1462
|
+
}
|
|
1463
|
+
return { label, tone, executed, accepted, decided, phaseLabel, note };
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* The host-review badge for one task, or `null` when the headline already says it.
|
|
1468
|
+
*
|
|
1469
|
+
* `taskOutcome(...).label` is the primary status; this exists so a caller that wants a
|
|
1470
|
+
* SEPARATE review badge gets exactly the same wording and tone rather than a second,
|
|
1471
|
+
* possibly contradictory, string. It returns `null` whenever the headline already carries
|
|
1472
|
+
* the review state, which is what keeps "等待审查" from appearing twice — or alongside
|
|
1473
|
+
* "审查通过".
|
|
1474
|
+
* @param {object} task - task view.
|
|
1475
|
+
* @returns {{ label: string, tone: string } | null} badge, or null to show nothing.
|
|
1476
|
+
*/
|
|
1477
|
+
export function hostReviewBadge(task) {
|
|
1478
|
+
const acceptance = task?.hostAcceptance;
|
|
1479
|
+
if (acceptance === null || acceptance === undefined) return null;
|
|
1480
|
+
// Derive from the same helper, so the two can never disagree.
|
|
1481
|
+
const { label, tone } = taskOutcome(task);
|
|
1482
|
+
return { label, tone };
|
|
1347
1483
|
}
|
|
1348
1484
|
|
|
1485
|
+
/**
|
|
1486
|
+
* A task's recorded review conclusion as one bounded display line.
|
|
1487
|
+
*
|
|
1488
|
+
* Only a short note and the time are shown: the stored note is already redacted, and
|
|
1489
|
+
* nothing else about the review exists.
|
|
1490
|
+
* @param {object} task - task view.
|
|
1491
|
+
* @param {(at: number) => string} formatTime - time formatter from the page.
|
|
1492
|
+
* @returns {string} display text.
|
|
1493
|
+
*/
|
|
1494
|
+
export function hostReviewLine(task, formatTime) {
|
|
1495
|
+
const acceptance = task?.hostAcceptance;
|
|
1496
|
+
if (acceptance === null || acceptance === undefined) return '未记录(插件不会自行验收)';
|
|
1497
|
+
const label = acceptance.accepted === true ? '审查通过' : '需要修正';
|
|
1498
|
+
const at = typeof acceptance.acceptedAt === 'number' ? `(${formatTime(acceptance.acceptedAt)})` : '';
|
|
1499
|
+
const note = typeof acceptance.note === 'string' && acceptance.note !== ''
|
|
1500
|
+
? `:${boundedText(acceptance.note, 200)}`
|
|
1501
|
+
: '';
|
|
1502
|
+
return `${label}${at}${note}`;
|
|
1503
|
+
}
|
|
1349
1504
|
/**
|
|
1350
1505
|
* Discoverable changed-file list in a task's diff payload.
|
|
1351
1506
|
*
|
|
@@ -2183,22 +2338,26 @@ export function createStore(options = {}) {
|
|
|
2183
2338
|
},
|
|
2184
2339
|
|
|
2185
2340
|
/**
|
|
2186
|
-
* Replace
|
|
2341
|
+
* Replace the silence thresholds and the repeated-failure count.
|
|
2187
2342
|
*
|
|
2188
2343
|
* The narrow route exists so an operator adjusting a timer cannot rewrite a
|
|
2189
2344
|
* provider list. On success the committed document is adopted for `settings` and
|
|
2190
2345
|
* the draft's monitoring block, and OTHER unsaved draft edits are left alone —
|
|
2191
2346
|
* a timer save must never discard a half-finished provider edit.
|
|
2192
|
-
*
|
|
2347
|
+
*
|
|
2348
|
+
* Order matters: the RAW block is validated first and only then normalized for the
|
|
2349
|
+
* wire. Validating the normalized block would accept a cleared field, because
|
|
2350
|
+
* `monitoringOf` replaces it with the documented default.
|
|
2351
|
+
* @param {{ selfCheckSeconds: number, attentionSeconds: number, repeatFailureThreshold: number }} monitoring - the block as the operator typed it.
|
|
2193
2352
|
* @returns {Promise<{ ok: boolean, error?: unknown }>} outcome.
|
|
2194
2353
|
*/
|
|
2195
2354
|
async saveMonitoring(monitoring) {
|
|
2196
|
-
const
|
|
2197
|
-
const problems = precheckMonitoring(normalized);
|
|
2355
|
+
const problems = precheckMonitoring(monitoring);
|
|
2198
2356
|
if (problems.length > 0) {
|
|
2199
2357
|
notify('error', `未保存:${problems.join(';')}`);
|
|
2200
2358
|
return { ok: false, problems };
|
|
2201
2359
|
}
|
|
2360
|
+
const normalized = monitoringOf({ monitoring });
|
|
2202
2361
|
return await track('monitoring', async () => {
|
|
2203
2362
|
try {
|
|
2204
2363
|
const body = await api.putMonitoring(normalized);
|