dsh-planbox-dyb 0.8.4 → 0.8.6
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/README.md +1 -1
- package/client.js +1 -1
- package/index.js +62 -19
- package/market/index.json +66 -0
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ dsh plugin --profile web add dsh-planbox-dyb
|
|
|
23
23
|
## 面板
|
|
24
24
|
|
|
25
25
|
- **手动**:你点「加入计划任务」手动登记的任务。
|
|
26
|
-
- **发现**:模型登记、助手结尾出现「重启」和「需要」(间隔不超过
|
|
26
|
+
- **发现**:模型登记、助手结尾出现「重启」和「需要」(间隔不超过 10 个字符,且间隔词不含「之前/以前/可能/不用/无需」),或从会话消息里扫到的任务。
|
|
27
27
|
- **中断**:上一回合报错或崩溃中断的会话。
|
|
28
28
|
|
|
29
29
|
同一个会话的回合放在一块,手动、发现、中断混排,按由旧到新排列。最近从计划任务点开过的会话排在最前,其余按任务更新时间排序。手动登记同一回合后,该回合的发现或中断记录让位,显示为手动。
|
package/client.js
CHANGED
package/index.js
CHANGED
|
@@ -56,15 +56,15 @@ const SCAN_CONCURRENCY = 6;
|
|
|
56
56
|
const DEFAULT_ABNORMAL_WINDOW_MS = 7 * 24 * 60 * 60 * 1000;
|
|
57
57
|
/** 助手结尾的“需要重启”只自动收最近 24 小时的会话,避免历史会话全部堆进来。 */
|
|
58
58
|
const DEFAULT_RESTART_WINDOW_MS = 24 * 60 * 60 * 1000;
|
|
59
|
-
const DEFAULT_RESTART_GAP =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
];
|
|
59
|
+
const DEFAULT_RESTART_GAP = 10;
|
|
60
|
+
/** 「重启…需要」里不该被当成待续的反向说法。 */
|
|
61
|
+
const RESTART_SKIP_PATTERN = /(?:之前|以前|可能|不用|无需)/;
|
|
62
|
+
const RESTART_HINT_PATTERNS = [/重启/, /需要/];
|
|
64
63
|
const MARKER_PATTERNS = [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
// 重启 / 重启完 / 重启好 / 重启之后 / 重启以后再继续……
|
|
65
|
+
/等?重启(?:完成|完|好)?(?:之后|以后|后|再)?\s*(?:继续|接着)/,
|
|
66
|
+
// 重启 DSH 后继续……
|
|
67
|
+
/重启\s*(?:DSH|dsh)\s*(?:之后|以后|后)\s*(?:再)?\s*(?:继续|接着)/i,
|
|
68
68
|
/resume after (?:a )?restart/i,
|
|
69
69
|
/continue after (?:a )?restart/i,
|
|
70
70
|
];
|
|
@@ -299,10 +299,23 @@ function withTimeout(signal, milliseconds) {
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
function readJson(file, fallback) {
|
|
302
|
+
let raw;
|
|
303
|
+
try {
|
|
304
|
+
raw = fs.readFileSync(file, 'utf8');
|
|
305
|
+
} catch (error) {
|
|
306
|
+
return fallback;
|
|
307
|
+
}
|
|
302
308
|
try {
|
|
303
|
-
const raw = fs.readFileSync(file, 'utf8');
|
|
304
309
|
return JSON.parse(raw);
|
|
305
310
|
} catch (error) {
|
|
311
|
+
// 文件存在但解析失败:备份成 .corrupt-<时间戳> 再按空数据继续,避免被后续写入静默覆盖。
|
|
312
|
+
try {
|
|
313
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
314
|
+
fs.renameSync(file, `${file}.corrupt-${stamp}`);
|
|
315
|
+
console.warn(`[planbox-dyb] ${path.basename(file)} 解析失败,已备份为 .corrupt-* 并按空数据处理`);
|
|
316
|
+
} catch (renameError) {
|
|
317
|
+
/* 备份失败也不阻断 */
|
|
318
|
+
}
|
|
306
319
|
return fallback;
|
|
307
320
|
}
|
|
308
321
|
}
|
|
@@ -565,7 +578,7 @@ function detectCandidate(summary, tail, turn, options) {
|
|
|
565
578
|
// 中断回合之后又出现了用户消息:说明已被自动续跑插件或用户手动继续,
|
|
566
579
|
// 不再作为「异常中断」重复列出。
|
|
567
580
|
const promptedAfter =
|
|
568
|
-
turn.at > 0 && tail.lastUserAt > turn.at;
|
|
581
|
+
!turn.open && turn.at > 0 && tail.lastUserAt > turn.at;
|
|
569
582
|
|
|
570
583
|
if (summary.running !== true && !promptedAfter && withinWindow && isAbnormalTurn(turn)) {
|
|
571
584
|
const detail =
|
|
@@ -599,7 +612,7 @@ function detectCandidate(summary, tail, turn, options) {
|
|
|
599
612
|
kind: 'auto',
|
|
600
613
|
sessionId,
|
|
601
614
|
title: summaryTitle(summary),
|
|
602
|
-
snippet: snippetAround(tail.lastAssistantText,
|
|
615
|
+
snippet: snippetAround(tail.lastAssistantText, RESTART_HINT_PATTERNS),
|
|
603
616
|
prompt: tailOf(tail.lastAssistantText, 240),
|
|
604
617
|
anchor: normalizeAnchor(options.anchor),
|
|
605
618
|
updatedAt: Number(summary.updatedAt ?? options.now),
|
|
@@ -641,10 +654,31 @@ export function restartWindowMs() {
|
|
|
641
654
|
return hours === 0 ? Number.POSITIVE_INFINITY : hours * 60 * 60 * 1000;
|
|
642
655
|
}
|
|
643
656
|
|
|
644
|
-
/**
|
|
645
|
-
export function restartNeededIn(text) {
|
|
646
|
-
const value =
|
|
647
|
-
|
|
657
|
+
/** 助手最后一条消息是否同时提到“重启”和“需要”(间隔内,排除反向说法)。 */
|
|
658
|
+
export function restartNeededIn(text, gap = restartGapChars()) {
|
|
659
|
+
const value = String(text ?? '').replace(/\s+/g, ' ');
|
|
660
|
+
if (value === '') return false;
|
|
661
|
+
let index = value.indexOf('重启');
|
|
662
|
+
while (index >= 0) {
|
|
663
|
+
if (value[index - 1] === '不') {
|
|
664
|
+
index = value.indexOf('重启', index + 2);
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
const after = value.slice(index + 2, index + 2 + gap + 2);
|
|
668
|
+
const needAfter = after.indexOf('需要');
|
|
669
|
+
if (needAfter >= 0 && value[index + 2 + needAfter - 1] !== '不') {
|
|
670
|
+
const between = after.slice(0, needAfter);
|
|
671
|
+
if (!RESTART_SKIP_PATTERN.test(between)) return true;
|
|
672
|
+
}
|
|
673
|
+
const before = value.slice(Math.max(0, index - gap - 2), index);
|
|
674
|
+
const needBefore = before.lastIndexOf('需要');
|
|
675
|
+
if (needBefore >= 0 && before[needBefore - 1] !== '不') {
|
|
676
|
+
const between = before.slice(needBefore + 2);
|
|
677
|
+
if (!RESTART_SKIP_PATTERN.test(between)) return true;
|
|
678
|
+
}
|
|
679
|
+
index = value.indexOf('重启', index + 2);
|
|
680
|
+
}
|
|
681
|
+
return false;
|
|
648
682
|
}
|
|
649
683
|
|
|
650
684
|
/**
|
|
@@ -995,6 +1029,9 @@ const resumingSessions = new Set();
|
|
|
995
1029
|
*/
|
|
996
1030
|
export async function resumeSelected(ctx, store, options = {}) {
|
|
997
1031
|
const ids = Array.isArray(options.ids) && options.ids.length > 0 ? options.ids : null;
|
|
1032
|
+
if (ids === null && options.all !== true) {
|
|
1033
|
+
throw new Error('未指定任务:请先用 planbox_list 取 id,或显式传 all: true 恢复全部任务。');
|
|
1034
|
+
}
|
|
998
1035
|
const selected = ids
|
|
999
1036
|
? await itemsForIds(ctx, store, ids, options)
|
|
1000
1037
|
: (await collectPending(ctx, store, { refresh: true, signal: options.signal })).items;
|
|
@@ -1201,7 +1238,8 @@ export function registerRoutes(ctx, store, connection) {
|
|
|
1201
1238
|
try {
|
|
1202
1239
|
const body = await request.json().catch(() => ({}));
|
|
1203
1240
|
const ids = Array.isArray(body?.ids) ? body.ids.filter((id) => typeof id === 'string') : [];
|
|
1204
|
-
const
|
|
1241
|
+
const all = body?.all === true;
|
|
1242
|
+
const result = await resumeSelected(ctx, store, { ids, all });
|
|
1205
1243
|
return json(200, { ok: true, ...result });
|
|
1206
1244
|
} catch (error) {
|
|
1207
1245
|
return json(500, { ok: false, message: String(error?.message ?? error) });
|
|
@@ -1506,7 +1544,7 @@ export function createToolDefinitions(ctx, store) {
|
|
|
1506
1544
|
const resumeTool = {
|
|
1507
1545
|
name: 'planbox_resume',
|
|
1508
1546
|
description:
|
|
1509
|
-
'
|
|
1547
|
+
'恢复计划任务:向对应会话投递续跑提示,冷会话会被唤醒开始新一轮。传 ids 恢复指定任务;恢复全部必须显式传 all: true。投递成功后对应记录会被删除。',
|
|
1510
1548
|
timeoutMs: 180_000,
|
|
1511
1549
|
parameters: {
|
|
1512
1550
|
type: 'object',
|
|
@@ -1515,7 +1553,11 @@ export function createToolDefinitions(ctx, store) {
|
|
|
1515
1553
|
ids: {
|
|
1516
1554
|
type: 'array',
|
|
1517
1555
|
items: { type: 'string' },
|
|
1518
|
-
description: '要恢复的任务 id
|
|
1556
|
+
description: '要恢复的任务 id;与 all 二选一',
|
|
1557
|
+
},
|
|
1558
|
+
all: {
|
|
1559
|
+
type: 'boolean',
|
|
1560
|
+
description: '显式恢复全部任务;不传 ids 且不传 all=true 时工具会报错,避免误恢复',
|
|
1519
1561
|
},
|
|
1520
1562
|
},
|
|
1521
1563
|
},
|
|
@@ -1554,7 +1596,8 @@ export function createToolDefinitions(ctx, store) {
|
|
|
1554
1596
|
},
|
|
1555
1597
|
async execute(args) {
|
|
1556
1598
|
const ids = Array.isArray(args?.ids) ? args.ids : undefined;
|
|
1557
|
-
const
|
|
1599
|
+
const all = args?.all === true;
|
|
1600
|
+
const result = await resumeSelected(ctx, store, { ids, all });
|
|
1558
1601
|
return { ok: true, ...result };
|
|
1559
1602
|
},
|
|
1560
1603
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": 1,
|
|
3
|
+
"title": {
|
|
4
|
+
"zh": "PlanBox 计划任务",
|
|
5
|
+
"en": "PlanBox"
|
|
6
|
+
},
|
|
7
|
+
"description": {
|
|
8
|
+
"zh": "PlanBox 计划任务收件箱的插件索引,可直接加入 Discover 的索引源。",
|
|
9
|
+
"en": "Plugin index for the PlanBox plan-task inbox; add it as a Discover index source."
|
|
10
|
+
},
|
|
11
|
+
"plugins": [
|
|
12
|
+
{
|
|
13
|
+
"name": "dsh-planbox-dyb",
|
|
14
|
+
"title": {
|
|
15
|
+
"zh": "PlanBox:计划任务收件箱",
|
|
16
|
+
"en": "PlanBox — plan-task inbox"
|
|
17
|
+
},
|
|
18
|
+
"description": {
|
|
19
|
+
"zh": "重启前登记、重启后审核并恢复中断任务:结构化快照、异常中断检测、回合定位与建议填充。",
|
|
20
|
+
"en": "Register work before a DSH restart, then review and restore it after: structured snapshots, interrupted-turn detection, turn anchors and one-click suggestion fill."
|
|
21
|
+
},
|
|
22
|
+
"author": "ZhibinYU",
|
|
23
|
+
"homepage": "https://github.com/LukeYzb/dsh-planbox-dyb",
|
|
24
|
+
"repository": {
|
|
25
|
+
"url": "https://github.com/LukeYzb/dsh-planbox-dyb",
|
|
26
|
+
"directory": "dsh-planbox-dyb"
|
|
27
|
+
},
|
|
28
|
+
"metadata": {
|
|
29
|
+
"category": "workflow",
|
|
30
|
+
"keywords": [
|
|
31
|
+
"dsh",
|
|
32
|
+
"dsh-plugin",
|
|
33
|
+
"plan",
|
|
34
|
+
"resume",
|
|
35
|
+
"inbox"
|
|
36
|
+
],
|
|
37
|
+
"labels": [],
|
|
38
|
+
"sortKeys": {}
|
|
39
|
+
},
|
|
40
|
+
"versions": [
|
|
41
|
+
{
|
|
42
|
+
"version": "0.8.6",
|
|
43
|
+
"publishTimestamp": 1796086252,
|
|
44
|
+
"source": {
|
|
45
|
+
"type": "npm"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"dsh": ">=0.2.2-rc.1 <0.3.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"metadata": {
|
|
55
|
+
"categories": {
|
|
56
|
+
"workflow": {
|
|
57
|
+
"title": {
|
|
58
|
+
"zh": "工作流",
|
|
59
|
+
"en": "Workflow"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"labels": {},
|
|
64
|
+
"sortKeys": {}
|
|
65
|
+
}
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-planbox-dyb",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "PlanBox:DSH 计划任务收件箱——重启前登记、重启后审核并恢复中断任务。宿主 Windows / macOS / Linux,客户端任意现代浏览器(含 iOS / iPadOS Safari)。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ZhibinYU",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+
|
|
9
|
+
"url": "git+https://github.com/LukeYzb/dsh-planbox-dyb.git",
|
|
10
10
|
"directory": "dsh-planbox-dyb"
|
|
11
11
|
},
|
|
12
|
+
"homepage": "https://github.com/LukeYzb/dsh-planbox-dyb#readme",
|
|
12
13
|
"keywords": [
|
|
13
14
|
"dsh",
|
|
14
15
|
"dsh-plugin",
|
|
@@ -20,7 +21,8 @@
|
|
|
20
21
|
"cross-platform"
|
|
21
22
|
],
|
|
22
23
|
"engines": {
|
|
23
|
-
"node": ">=20"
|
|
24
|
+
"node": ">=20",
|
|
25
|
+
"dsh": ">=0.2.2-rc.1 <0.3.0"
|
|
24
26
|
},
|
|
25
27
|
"type": "module",
|
|
26
28
|
"main": "index.js",
|
|
@@ -35,7 +37,8 @@
|
|
|
35
37
|
"client.js",
|
|
36
38
|
"cordis.patch.yml",
|
|
37
39
|
"README.md",
|
|
38
|
-
"LICENSE"
|
|
40
|
+
"LICENSE",
|
|
41
|
+
"market"
|
|
39
42
|
],
|
|
40
43
|
"scripts": {
|
|
41
44
|
"test": "node test/host.test.mjs && node test/client.test.mjs"
|