@cloud411716/fancy-webnovel 4.27.1 → 4.27.2

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/lib/task-list.js CHANGED
@@ -23,6 +23,8 @@
23
23
  * 不手动清空 —— 用户还能看到刚才做了哪些事,下一次对话开始时
24
24
  * DSH 自己会清掉。失败时已完成步骤保持 completed,当前及后续
25
25
  * 保持 pending,不谎报完成。
26
+ * 4. **长时间本地任务**:agent 一直 idle 时每 60 秒补写一次列表,
27
+ * 避免 UI 把长时间没有更新的任务栏收起。
26
28
  */
27
29
 
28
30
  import { installCommandRecovery, registerManagedCommand } from './command-recovery.js';
@@ -227,7 +229,7 @@ class TaskListController {
227
229
  * 写回命令自己的版本。
228
230
  *
229
231
  * @param {object} invocation DSH command invocation
230
- * @param {{onTurnEnd?: Function, stopAfterFirstEnd?: boolean}} [opts]
232
+ * @param {{onTurnEnd?: Function, stopAfterFirstEnd?: boolean, keepAliveMs?: number}} [opts]
231
233
  */
232
234
  watchTurns(invocation, opts = {}) {
233
235
  const agent = invocation && invocation.agent;
@@ -235,14 +237,21 @@ class TaskListController {
235
237
  const onTurnEnd = typeof opts.onTurnEnd === 'function' ? opts.onTurnEnd : null;
236
238
  const stopAfterFirstEnd = opts.stopAfterFirstEnd === true;
237
239
  const timeoutMs = Number(opts.timeoutMs) > 0 ? Number(opts.timeoutMs) : 0;
240
+ // 长时间本地采集时 agent 一直是 idle,DSH 的 UI 可能把任务栏收起。
241
+ // 每 60 秒补写一次(只在 idle 时),让任务栏在整段采集中保持可见。
242
+ const keepAliveMs = Number(opts.keepAliveMs) > 0 ? Number(opts.keepAliveMs) : 60 * 1000;
238
243
  const startedAt = Date.now();
244
+ let lastWriteAt = Date.now();
239
245
 
240
246
  this._stopWatcher();
241
247
  let running = agent.status === 'running';
242
248
  this._watchState = { running };
243
249
  // 启动时如果已经在 running,说明 turn/start 已经发生过,
244
250
  // 当前列表可能刚被清空;先补写一次。
245
- if (running) this._write();
251
+ if (running) {
252
+ this._write();
253
+ lastWriteAt = Date.now();
254
+ }
246
255
 
247
256
  this._watcher = setInterval(() => {
248
257
  if (this.closed) {
@@ -260,9 +269,11 @@ class TaskListController {
260
269
  if (current && !running) {
261
270
  // turn/start:DSH 已把列表投影清空,立刻写回
262
271
  this._write();
272
+ lastWriteAt = Date.now();
263
273
  } else if (!current && running) {
264
274
  // turn/end:写回命令自己的列表,再执行调用方的收尾回调
265
275
  this._write();
276
+ lastWriteAt = Date.now();
266
277
  if (onTurnEnd) {
267
278
  try { onTurnEnd(this); } catch (e) {
268
279
  console.error('[task-list] onTurnEnd 失败:' + (e && e.message ? e.message : String(e)));
@@ -273,6 +284,13 @@ class TaskListController {
273
284
  return;
274
285
  }
275
286
  }
287
+ // 长时间没有 turn(本地 OCR/采集)时也要定期刷新,否则 UI 可能
288
+ // 把任务栏当作过期内容隐藏。只在 idle 时写,running 期间不抢
289
+ // 模型自己的 todo。
290
+ if (!current && keepAliveMs > 0 && Date.now() - lastWriteAt >= keepAliveMs) {
291
+ this._write();
292
+ lastWriteAt = Date.now();
293
+ }
276
294
  running = current;
277
295
  }, WATCH_INTERVAL_MS);
278
296
  if (this._watcher && typeof this._watcher.unref === 'function') this._watcher.unref();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "4.27.1",
3
+ "version": "4.27.2",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -207,10 +207,6 @@ function buildBooksSelfCheckPrompt({ request, resultPath, platform, rank }) {
207
207
  '',
208
208
  '## 第二步:读取截图',
209
209
  '',
210
- `平台:${platform}`,
211
- `榜单:${rank}`,
212
- `页面地址:${request.url || ''}`,
213
- '',
214
210
  '请用 read 工具读取以下截图(绝对路径):',
215
211
  '',
216
212
  ...screenshots.map((file, index) => `${index + 1}. \`${file}\``),
@@ -236,6 +232,8 @@ function buildBooksSelfCheckPrompt({ request, resultPath, platform, rank }) {
236
232
  }, null, 2),
237
233
  '```',
238
234
  '',
235
+ '上面只是格式示例,实际值必须按截图如实抄录。',
236
+ '',
239
237
  '抄录规则:',
240
238
  '- 按截图中显示的中文原文抄录,不要翻译、改写、概括或补全。',
241
239
  '- 看不清的字段填空字符串 `""`,不要猜。',