@cloud411716/fancy-webnovel 4.30.1 → 4.30.3

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.
@@ -36,7 +36,7 @@ https://www.douyin.com/user/MS4wLjABAAAA...
36
36
  LLM 能力自检(图片 / 视频)
37
37
  → 两种能力都没有:退出并通知
38
38
  → 依次扫描账号主页,收集 /note/ 图文、/video/ 视频和 /article/ 文章
39
- → 跳过 douyin_job 表中已导入、已确认无关或已标记失败跳过的作品
39
+ → 跳过 douyin_job 表中已导入、已确认无关或内容级失败的作品;超时/中断的 pending 作品会重试
40
40
  → 文章:提取标题、发布日期、阅读时长和正文
41
41
  → 图文:逐页判断类型
42
42
  → 图片页:下载轮播原图并转成 JPG(避免滚动时截到半张图)
@@ -53,7 +53,7 @@ LLM 能力自检(图片 / 视频)
53
53
  → 继续下一篇
54
54
  ```
55
55
 
56
- 作品级失败(下载、抽帧、文章正文提取失败、LLM 整理失败)会记录为 `failed + skip`,本次跳过且下次不再重试;账号扫描失败不会写入作品记录,下次运行仍会重试。
56
+ 内容级失败(下载、抽帧、文章正文提取失败、LLM 整理失败)会记录为 `failed`,本次跳过且下次不再重试;超时/中断属于可重试失败,会保持 `pending` 并在下次运行继续。子 Agent 超时前已经写出 `materials.jsonl` 的,父进程会先校验导入,能救回多少算多少。账号扫描失败不会写入作品记录,下次运行仍会重试。
57
57
 
58
58
  ## 登录与验证
59
59
 
@@ -132,13 +132,15 @@ cookies 会额外镜像到:
132
132
  <工作区>/.fancy/douyin/jobs/<账号>/<作品ID>/
133
133
  ```
134
134
 
135
- 中途重启 DSH 后,已导入/已跳过的作品直接跳过;已有 `materials.jsonl` 的只重新校验导入;已有采集文件的复用文件,不重新下载。
135
+ 中途重启 DSH 后,已导入/已跳过/内容级失败的作品直接跳过;已有 `materials.jsonl` 的只重新校验导入;已有采集文件的复用文件,不重新下载;超时/中断的 pending 作品继续重试。
136
136
 
137
- 并发数:
137
+ 并发数和超时:
138
138
 
139
139
  ```bash
140
- FANCY_DOUYIN_SUBAGENTS=5 # 默认 5,范围 1–6
141
- FANCY_DOUYIN_SUBAGENTS=0 # 关闭子 Agent,回退单 Agent 串行
140
+ FANCY_DOUYIN_SUBAGENTS=5 # 默认 5,范围 1–6
141
+ FANCY_DOUYIN_SUBAGENTS=0 # 关闭子 Agent,回退单 Agent 串行
142
+ FANCY_DOUYIN_ANALYSIS_TIMEOUT_MS=2400000 # 单个作品分析预算,默认 40 分钟
143
+ FANCY_DOUYIN_NOTE_TIMEOUT_MS=600000 # 图文轮播采集预算,默认 10 分钟
142
144
  ```
143
145
 
144
146
  要求 DSH 挂载了 subagent 服务和 `spawn` provider。没有子 Agent 服务、provider 不存在或并发数为 0 时,会自动回退到原来的单 Agent 流程。
@@ -301,3 +301,10 @@ note 再翻出规则/代价/身份
301
301
  - `styles.js` 增加 `naming_mode` / `generation_chain` / `image_pool` / `hook_rule`,风格块只展开选中风格。
302
302
  - `builtin-styles.js` 已给宿辞、疯狂小鱼、Ael 冷空气、充电进度条补生成链路。
303
303
  - `kindBlock` 按当前 item 注入;能力核心组会展开 6 个部件要求。
304
+
305
+ ## 2026-11-28 · facet 弹框选项说明
306
+
307
+ - 弹框右侧不再重复“选中后必须同时满足”。
308
+ - 新增 `facet-copy.js`:题材按题材簇说明,场景/情绪/情节/身份/关系按选项给具体说明。
309
+ - 例:`霸总` → 现代言情/豪门权势;`影帝` → 娱乐圈顶流/演技派。
310
+ - 题材选项覆盖常见题材与 niche 题材(特摄、ABO、同人、国漫、反乌托邦等)。
package/lib/infra.js CHANGED
@@ -505,7 +505,7 @@ export function spawnScript(cmd, args, { timeout = 30000, cwd, env, onSpawn } =
505
505
  // detached:true —— 子进程成为独立进程组的组长,超时时可整组清理。
506
506
  proc = spawn(cmd, args, { cwd, env, stdio: ['ignore', 'pipe', 'pipe'], detached: true });
507
507
  } catch (spawnErr) {
508
- resolve({ ok: false, output: '', error: spawnErr.message, stderr: '' });
508
+ resolve({ ok: false, output: '', error: spawnErr.message, stderr: '', timedOut: false });
509
509
  return;
510
510
  }
511
511
 
@@ -573,6 +573,7 @@ export function spawnScript(cmd, args, { timeout = 30000, cwd, env, onSpawn } =
573
573
  : undefined),
574
574
  stderr,
575
575
  code,
576
+ timedOut,
576
577
  });
577
578
  return;
578
579
  } catch (_) {
@@ -580,15 +581,18 @@ export function spawnScript(cmd, args, { timeout = 30000, cwd, env, onSpawn } =
580
581
  resolve({
581
582
  ok: false,
582
583
  output: stdout,
583
- error: stderr.trim() || (timedOut ? `timeout after ${timeout}ms` : `exit ${code}`),
584
+ // 非 JSON 输出也必须让超时优先于 stderr。否则脚本被 kill 时,
585
+ // 最后几行普通日志会被当成失败原因,真正的超时反而看不见。
586
+ error: timedOut ? `timeout after ${timeout}ms` : (stderr.trim() || `exit ${code}`),
584
587
  stderr,
585
588
  code,
589
+ timedOut,
586
590
  });
587
591
  }
588
592
  });
589
593
  proc.on('error', (err) => {
590
594
  clearTimeout(timer);
591
- resolve({ ok: false, output: '', error: err.message, stderr: errParts.join(''), code: -1 });
595
+ resolve({ ok: false, output: '', error: err.message, stderr: errParts.join(''), code: -1, timedOut: false });
592
596
  });
593
597
  });
594
598
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "4.30.1",
3
+ "version": "4.30.3",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -47,8 +47,15 @@ import {
47
47
 
48
48
  export const inject = ['commands', 'userQuestions'];
49
49
 
50
+ function envMs(name, fallback) {
51
+ const value = Number(process.env[name]);
52
+ return Number.isFinite(value) && value > 0 ? value : fallback;
53
+ }
54
+
50
55
  const FRAME_SELECTION_VERSION = 4;
51
- const ANALYSIS_TIMEOUT_MS = 20 * 60 * 1000;
56
+ // 图片密集的清单作品会读几十张切图,20 分钟经常在“准备写 JSONL”时被截断。
57
+ // 40 分钟给长尾作品留出余量;仍可通过环境变量按机器速度调整。
58
+ const ANALYSIS_TIMEOUT_MS = envMs('FANCY_DOUYIN_ANALYSIS_TIMEOUT_MS', 40 * 60 * 1000);
52
59
  const ANALYSIS_IDLE_GRACE_MS = 60 * 1000;
53
60
  const CAPABILITY_TIMEOUT_MS = 5 * 60 * 1000;
54
61
  const CAPABILITY_IDLE_GRACE_MS = 30 * 1000;
@@ -56,6 +63,8 @@ const RELEVANCE_TIMEOUT_MS = 5 * 60 * 1000;
56
63
  const RELEVANCE_IDLE_GRACE_MS = 30 * 1000;
57
64
  const SCRIPT_TIMEOUT_MS = 4 * 60 * 1000;
58
65
  const VIDEO_SCRIPT_TIMEOUT_MS = 10 * 60 * 1000;
66
+ // 图文轮播可能包含几十页图片和视频切片,不能按普通图文的 4 分钟算。
67
+ const NOTE_SCRIPT_TIMEOUT_MS = envMs('FANCY_DOUYIN_NOTE_TIMEOUT_MS', 10 * 60 * 1000);
59
68
  const MAX_VIDEO_SECONDS = 60;
60
69
  const LOGIN_RETRIES = 5;
61
70
  const NOTE_DELAY_MIN_MS = 6000;
@@ -74,6 +83,34 @@ function sleep(ms) {
74
83
  return new Promise((resolve) => setTimeout(resolve, ms));
75
84
  }
76
85
 
86
+ /**
87
+ * 把 `timeout after 600000ms` 变成人能直接读的原因。
88
+ * 采集脚本被 kill 时 stderr 往往是一大段进度日志,不能拿它当失败原因。
89
+ */
90
+ export function humanizeTimeoutMessage(text) {
91
+ const raw = String(text || '').trim();
92
+ const match = /timeout after (\d+)ms/i.exec(raw);
93
+ if (!match) return raw || '采集超时';
94
+ const seconds = Math.max(1, Math.round(Number(match[1]) / 1000));
95
+ if (seconds < 60) return `采集超时(超过 ${seconds} 秒未完成)`;
96
+ return `采集超时(超过 ${Math.max(1, Math.round(seconds / 60))} 分钟未完成)`;
97
+ }
98
+
99
+ function conciseError(text, max = 1200) {
100
+ const value = String(text || '').trim();
101
+ if (value.length <= max) return value;
102
+ return value.slice(0, max) + '…(完整日志见同目录 error.log)';
103
+ }
104
+
105
+ function saveErrorLog(outDir, text) {
106
+ const value = String(text || '').trim();
107
+ if (!outDir || !value) return;
108
+ try {
109
+ fs.mkdirSync(outDir, { recursive: true });
110
+ fs.writeFileSync(path.join(outDir, 'error.log'), value + '\n', 'utf8');
111
+ } catch { /* 日志写失败不能反过来中断采集 */ }
112
+ }
113
+
77
114
  function authFailureText(text) {
78
115
  return /登录|验证|login_required/i.test(String(text || ''));
79
116
  }
@@ -157,6 +194,16 @@ async function stopChrome(root, tools, paths) {
157
194
  async function runWithLogin(ctx, invocation, session, root, toolPath, args, outDir, paths, label, nodePath, browser, tools, timeout = SCRIPT_TIMEOUT_MS) {
158
195
  for (let attempt = 1; attempt <= LOGIN_RETRIES; attempt += 1) {
159
196
  const { result, json } = await runTool(toolPath, args, { root, nodePath, timeout });
197
+ // 超时优先于脚本可能已经写出的半截 JSON;否则半截 login_required / ok:true
198
+ // 会把真正的超时带偏。
199
+ if (result.timedOut) {
200
+ saveErrorLog(outDir, result.stderr);
201
+ return {
202
+ ok: false,
203
+ timeout: true,
204
+ error: conciseError(humanizeTimeoutMessage(result.error)),
205
+ };
206
+ }
160
207
  if (json && json.login_required) {
161
208
  if (browser.mode === 'headless') {
162
209
  // Headless cannot show a login UI. Close it, start headed Chrome and
@@ -181,13 +228,26 @@ async function runWithLogin(ctx, invocation, session, root, toolPath, args, outD
181
228
  continue;
182
229
  }
183
230
  if (!json) {
231
+ saveErrorLog(outDir, result.stderr);
232
+ const raw = result.timedOut
233
+ ? humanizeTimeoutMessage(result.error)
234
+ : (result.error || result.stderr || '脚本没有返回 JSON');
184
235
  return {
185
236
  ok: false,
186
- error: (result.stderr || result.error || '脚本没有返回 JSON').trim(),
237
+ timeout: Boolean(result.timedOut),
238
+ error: conciseError(raw),
187
239
  };
188
240
  }
189
241
  if (!result.ok || json.ok !== true) {
190
- return { ok: false, error: json.error || result.error || (label + '失败') };
242
+ saveErrorLog(outDir, result.stderr);
243
+ const raw = result.timedOut
244
+ ? humanizeTimeoutMessage(result.error)
245
+ : (json.error || result.error || (label + '失败'));
246
+ return {
247
+ ok: false,
248
+ timeout: Boolean(result.timedOut),
249
+ error: conciseError(raw),
250
+ };
191
251
  }
192
252
  return { ok: true, json };
193
253
  }
@@ -762,8 +822,17 @@ export function subagentTaskPrompt(job, root, materialTools) {
762
822
  return lines.join('\n');
763
823
  }
764
824
 
765
- async function runSubagentAnalysisJob({
825
+ function fileHasContent(file) {
826
+ try {
827
+ return fs.statSync(file).size > 0;
828
+ } catch {
829
+ return false;
830
+ }
831
+ }
832
+
833
+ export async function runSubagentAnalysisJob({
766
834
  subagents, provider, invocation, job, root, materialTools, signal,
835
+ timeoutMs = ANALYSIS_TIMEOUT_MS,
767
836
  }) {
768
837
  const prompt = subagentTaskPrompt(job, root, materialTools);
769
838
  let activation;
@@ -787,24 +856,40 @@ async function runSubagentAnalysisJob({
787
856
  result = await Promise.race([
788
857
  activation.result,
789
858
  new Promise((_, reject) => {
790
- timer = setTimeout(() => reject(new Error('子 Agent 分析超时')), ANALYSIS_TIMEOUT_MS);
859
+ timer = setTimeout(() => reject(new Error('子 Agent 分析超时')), timeoutMs);
791
860
  if (timer && typeof timer.unref === 'function') timer.unref();
792
861
  }),
793
862
  ]);
794
863
  } catch (err) {
795
864
  const message = err && err.message ? err.message : String(err);
865
+ const timeout = /超时|timeout/i.test(message);
866
+ // 超时前已经写出目标文件时,不要让已完成的素材陪葬。
867
+ // 先交给父进程的串行锁做 validate/import;校验不过再按失败处理。
868
+ if (!(signal && signal.aborted) && fileHasContent(job.target)) {
869
+ return {
870
+ ok: true,
871
+ needsFinalize: true,
872
+ partial: true,
873
+ timeout,
874
+ reason: timeout
875
+ ? '子 Agent 分析超时,已写入目标文件,按已有内容继续校验'
876
+ : '子 Agent 异常结束,已写入目标文件,按已有内容继续校验',
877
+ };
878
+ }
796
879
  return {
797
880
  ok: false,
798
- retryable: Boolean((signal && signal.aborted) || /abort|cancel|interrupt|terminated/i.test(message)),
881
+ retryable: Boolean((signal && signal.aborted) || timeout
882
+ || /abort|cancel|interrupt|terminated/i.test(message)),
883
+ timeout,
799
884
  error: '子 Agent 执行失败:' + message,
800
885
  };
801
886
  } finally {
802
887
  if (timer) clearTimeout(timer);
803
888
  try { await activation.dispose(); } catch { /* best effort */ }
804
889
  }
805
- if (!fs.existsSync(job.target)) {
890
+ if (!fileHasContent(job.target)) {
806
891
  const stop = result && result.stopReason ? String(result.stopReason) : '';
807
- const retryable = /abort|cancel|interrupt|terminated/i.test(stop)
892
+ const retryable = /abort|cancel|interrupt|terminated|timeout|超时/i.test(stop)
808
893
  || Boolean(signal && signal.aborted);
809
894
  return {
810
895
  ok: false,
@@ -1068,9 +1153,28 @@ async function runCrawl(ctx, invocation, session, taskList) {
1068
1153
  () => markJobSkippedLocked(job, reason, options),
1069
1154
  );
1070
1155
 
1156
+ // 超时/中断不是内容级失败:保留 pending,下次运行继续。
1157
+ const markJobRetryableLocked = async (job, reason, { crawl = false } = {}) => {
1158
+ if (!job || !job.id) return;
1159
+ crawled[job.id] = true;
1160
+ if (job.jobKey) {
1161
+ await updateJob(jobStore.db, job.jobKey, {
1162
+ ...(crawl ? { crawl_status: 'pending' } : {}),
1163
+ analysis_status: 'pending',
1164
+ import_status: 'pending',
1165
+ reason,
1166
+ error: '',
1167
+ });
1168
+ }
1169
+ };
1170
+ const markJobRetryable = async (job, reason, options) => withStateLock(
1171
+ () => markJobRetryableLocked(job, reason, options),
1172
+ );
1173
+
1071
1174
  queue = useSubagents ? createJobQueue() : null;
1072
1175
  const queueStats = { queued: 0, finished: 0 };
1073
1176
  const styleAccounts = new Map();
1177
+ const retryableJobs = [];
1074
1178
  let styleResults = [];
1075
1179
  let scannedAccounts = 0;
1076
1180
  let foundNotes = 0;
@@ -1085,6 +1189,7 @@ async function runCrawl(ctx, invocation, session, taskList) {
1085
1189
  let skippedLongVideos = 0;
1086
1190
  let inserted = 0;
1087
1191
  let skippedMaterials = 0;
1192
+ let salvaged = 0;
1088
1193
  let aborted = false;
1089
1194
  let writeActive = false;
1090
1195
 
@@ -1108,27 +1213,43 @@ async function runCrawl(ctx, invocation, session, taskList) {
1108
1213
  writeActive = true;
1109
1214
  taskList.activate(5);
1110
1215
  }
1216
+ const wasPartial = Boolean(analyzed && analyzed.partial);
1111
1217
  if (analyzed && analyzed.needsFinalize) {
1112
1218
  analyzed = await finalizeMaterialFile({
1113
1219
  root,
1114
1220
  target: job.target,
1115
1221
  materialTools,
1116
1222
  });
1223
+ if (wasPartial && analyzed && analyzed.ok) analyzed.partial = true;
1117
1224
  }
1118
1225
  if (analyzed && (analyzed.aborted || analyzed.retryable)) {
1119
1226
  if (job.jobKey) {
1120
1227
  await updateJob(jobStore.db, job.jobKey, {
1121
1228
  analysis_status: 'pending',
1122
1229
  import_status: 'pending',
1123
- reason: '上次分析被中断,等待重试',
1230
+ reason: analyzed.error || '上次分析被中断,等待重试',
1124
1231
  error: '',
1125
1232
  });
1126
1233
  }
1127
- if (jobSignal.aborted) aborted = true;
1234
+ if (jobSignal.aborted) {
1235
+ aborted = true;
1236
+ } else {
1237
+ retryableJobs.push({
1238
+ id: job.id,
1239
+ url: job.url,
1240
+ reason: analyzed.error || analyzed.reason || '等待重试',
1241
+ });
1242
+ crawled[job.id] = true;
1243
+ }
1244
+ queueStats.finished += 1;
1245
+ refreshProgress();
1128
1246
  return;
1129
1247
  }
1130
1248
  if (!analyzed || !analyzed.ok) {
1131
- const reason = (analyzed && (analyzed.error || analyzed.detail)) || '素材没有通过校验';
1249
+ const detail = (analyzed && (analyzed.error || analyzed.detail)) || '素材没有通过校验';
1250
+ const reason = wasPartial
1251
+ ? '子 Agent 分析超时,已有文件未通过校验:' + detail
1252
+ : detail;
1132
1253
  failures.push({ id: job.id, url: job.url, reason });
1133
1254
  await markJobFailedLocked(job, reason);
1134
1255
  queueStats.finished += 1;
@@ -1150,13 +1271,14 @@ async function runCrawl(ctx, invocation, session, taskList) {
1150
1271
  } else {
1151
1272
  inserted += analyzed.inserted || 0;
1152
1273
  skippedMaterials += analyzed.skipped || 0;
1274
+ if (wasPartial) salvaged += 1;
1153
1275
  if (job.accountUrl) styleAccounts.set(job.accountUrl, (styleAccounts.get(job.accountUrl) || 0) + Math.max(1, analyzed.inserted || 0));
1154
1276
  if (job.jobKey) {
1155
1277
  await updateJob(jobStore.db, job.jobKey, {
1156
1278
  analysis_status: 'analyzed',
1157
1279
  import_status: 'imported',
1158
1280
  material_count: analyzed.inserted || 0,
1159
- reason: '',
1281
+ reason: wasPartial ? '超时后按已有素材导入' : '',
1160
1282
  error: '',
1161
1283
  imported_at: new Date(),
1162
1284
  });
@@ -1228,20 +1350,25 @@ async function runCrawl(ctx, invocation, session, taskList) {
1228
1350
  for (const account of accounts) {
1229
1351
  if (abortRequested(invocation)) { aborted = true; break; }
1230
1352
  const accountDir = path.join(runDir, accountSlug(account.url));
1353
+ const jobFor = (id, card, data) => ({
1354
+ id,
1355
+ jobKey: jobKeyFor(account.url, id),
1356
+ accountUrl: account.url,
1357
+ url: data.url || card.href,
1358
+ title: data.title || card.text || '',
1359
+ type: data.type,
1360
+ duration: data.duration,
1361
+ dir: data.dir,
1362
+ card,
1363
+ });
1231
1364
  const markFailed = async (id, card, data, reason) => {
1232
1365
  if (!id) return;
1233
- const job = {
1234
- id,
1235
- jobKey: jobKeyFor(account.url, id),
1236
- accountUrl: account.url,
1237
- url: data.url || card.href,
1238
- title: data.title || card.text || '',
1239
- type: data.type,
1240
- duration: data.duration,
1241
- dir: data.dir,
1242
- card,
1243
- };
1244
- await markJobFailed(job, reason, { crawl: true });
1366
+ await markJobFailed(jobFor(id, card, data), reason, { crawl: true });
1367
+ };
1368
+ const markRetryable = async (id, card, data, reason) => {
1369
+ if (!id) return;
1370
+ retryableJobs.push({ id, url: data.url || card.href, reason });
1371
+ await markJobRetryable(jobFor(id, card, data), reason, { crawl: true });
1245
1372
  };
1246
1373
  const scan = await runWithLogin(
1247
1374
  ctx, invocation, session, root, tools.scripts.scan,
@@ -1383,10 +1510,15 @@ async function runCrawl(ctx, invocation, session, taskList) {
1383
1510
  tools.nodePath,
1384
1511
  browser,
1385
1512
  tools,
1513
+ NOTE_SCRIPT_TIMEOUT_MS,
1386
1514
  );
1387
1515
  if (!noteResult.ok) {
1388
- failures.push({ id: noteId, url: card.href, reason: noteResult.error });
1389
1516
  if (noteResult.cancelled || authFailureText(noteResult.error)) { aborted = true; break outer; }
1517
+ if (noteResult.timeout) {
1518
+ await markRetryable(noteId, card, { type: 'note', dir: noteDir }, noteResult.error);
1519
+ continue;
1520
+ }
1521
+ failures.push({ id: noteId, url: card.href, reason: noteResult.error });
1390
1522
  await markFailed(noteId, card, { type: 'note', dir: noteDir }, noteResult.error);
1391
1523
  continue;
1392
1524
  }
@@ -1500,8 +1632,12 @@ async function runCrawl(ctx, invocation, session, taskList) {
1500
1632
  VIDEO_SCRIPT_TIMEOUT_MS,
1501
1633
  );
1502
1634
  if (!videoResult.ok) {
1503
- failures.push({ id: videoId, url: card.href, reason: videoResult.error });
1504
1635
  if (videoResult.cancelled || authFailureText(videoResult.error)) { aborted = true; break outer; }
1636
+ if (videoResult.timeout) {
1637
+ await markRetryable(videoId, card, { type: 'video', dir: videoDir }, videoResult.error);
1638
+ continue;
1639
+ }
1640
+ failures.push({ id: videoId, url: card.href, reason: videoResult.error });
1505
1641
  await markFailed(videoId, card, { type: 'video', dir: videoDir }, videoResult.error);
1506
1642
  continue;
1507
1643
  }
@@ -1671,8 +1807,12 @@ async function runCrawl(ctx, invocation, session, taskList) {
1671
1807
  tools,
1672
1808
  );
1673
1809
  if (!articleResult.ok) {
1674
- failures.push({ id: articleId, url: card.href, reason: articleResult.error });
1675
1810
  if (articleResult.cancelled || authFailureText(articleResult.error)) { aborted = true; break outer; }
1811
+ if (articleResult.timeout) {
1812
+ await markRetryable(articleId, card, { type: 'article', dir: articleDir }, articleResult.error);
1813
+ continue;
1814
+ }
1815
+ failures.push({ id: articleId, url: card.href, reason: articleResult.error });
1676
1816
  await markFailed(articleId, card, { type: 'article', dir: articleDir }, articleResult.error);
1677
1817
  continue;
1678
1818
  }
@@ -1759,7 +1899,7 @@ async function runCrawl(ctx, invocation, session, taskList) {
1759
1899
  }
1760
1900
 
1761
1901
  taskList.advance(5);
1762
- return notify(session, (aborted || failures.length) ? 'error' : 'success', summaryText({
1902
+ return notify(session, (aborted || failures.length || retryableJobs.length) ? 'error' : 'success', summaryText({
1763
1903
  accounts: accounts.length,
1764
1904
  scannedAccounts,
1765
1905
  foundNotes,
@@ -1774,7 +1914,9 @@ async function runCrawl(ctx, invocation, session, taskList) {
1774
1914
  skippedLongVideos,
1775
1915
  inserted,
1776
1916
  skippedMaterials,
1917
+ salvaged,
1777
1918
  failures,
1919
+ retryableFailures: retryableJobs,
1778
1920
  outputDir: runDir,
1779
1921
  aborted,
1780
1922
  mode: browser.mode,
@@ -179,7 +179,7 @@ export async function recoverInterruptedJobs(db) {
179
179
  let recovered = 0;
180
180
  for (const row of rows) {
181
181
  const text = String(row.error || '') + ' ' + String(row.reason || '');
182
- if (!/abort|cancel|interrupt|terminated|中断|没有写入目标文件/i.test(text)) continue;
182
+ if (!/abort|cancel|interrupt|terminated|timeout|中断|超时|没有写入目标文件/i.test(text)) continue;
183
183
  await updateJob(db, row.job_key, {
184
184
  analysis_status: 'pending',
185
185
  import_status: 'pending',
@@ -39,7 +39,7 @@ export function helpText() {
39
39
  9. 视频作品先判断时长:超过 1 分钟直接跳过;不超过 1 分钟的先看前 5 秒,与网文创作无关就跳过,有关才继续分析关键帧。
40
40
  10. 如果内容与网文创作无关,LLM 会写入 skip 标记,该作品记为已处理并跳过。
41
41
  11. 素材按 material JSONL 格式写入数据库,source 固定为 other,kind 用中文作品主题。
42
- 12. 已成功入库、确认无关或作品级失败的作品记录在素材库 douyin_job 表,后续跳过;账号级失败仍会重试。
42
+ 12. 已成功入库、确认无关或内容级失败的作品记录在素材库 douyin_job 表,后续跳过;超时/中断类待重试项会在下次运行继续;账号级失败仍会重试。
43
43
  13. 登录态保存在 <工作区>/.fancy/douyin/chrome-profile/,并镜像到 login-state.json。
44
44
  14. 首次需要登录时用有头 Chrome;登录态有效后后续运行自动使用无头 Chrome。
45
45
  15. 每次运行结束会自动关闭 Chrome,释放资源。
@@ -250,7 +250,9 @@ export function summaryText({
250
250
  skippedLongVideos = 0,
251
251
  inserted,
252
252
  skippedMaterials,
253
- failures,
253
+ salvaged = 0,
254
+ failures = [],
255
+ retryableFailures = [],
254
256
  outputDir,
255
257
  aborted,
256
258
  mode,
@@ -258,8 +260,11 @@ export function summaryText({
258
260
  subagentWorkers = 0,
259
261
  stylesUpdated = [],
260
262
  }) {
263
+ const hasIssues = failures.length > 0 || retryableFailures.length > 0;
261
264
  const lines = [
262
- aborted ? '⚠️ 抖音采集已中断' : '✅ 抖音采集完成',
265
+ aborted
266
+ ? '⚠️ 抖音采集已中断'
267
+ : (hasIssues ? '⚠️ 抖音采集部分完成' : '✅ 抖音采集完成'),
263
268
  '账号:' + accounts + ' 个(本次扫描 ' + scannedAccounts + ' 个)',
264
269
  '浏览器:' + (mode === 'headless' ? '无头' : '有头'),
265
270
  '分析模式:' + (analysisMode === 'subagent' ? '子 Agent 并行(' + subagentWorkers + ' 个)' : '单 Agent 串行'),
@@ -273,14 +278,23 @@ export function summaryText({
273
278
  '长视频跳过:' + skippedLongVideos + ' 个',
274
279
  '新增素材:' + inserted + ' 条(重复跳过 ' + skippedMaterials + ' 条)',
275
280
  ];
281
+ if (salvaged > 0) lines.push('超时后完成:' + salvaged + ' 篇(按已写入素材导入)');
282
+ if (retryableFailures.length) {
283
+ lines.push('待重试:' + retryableFailures.length + ' 篇');
284
+ for (const item of retryableFailures.slice(0, 10)) {
285
+ lines.push(' - ' + (item.id || item.url || '未知') + ':' + item.reason);
286
+ }
287
+ if (retryableFailures.length > 10) lines.push(' - 其余 ' + (retryableFailures.length - 10) + ' 篇省略');
288
+ lines.push('这些作品是超时或中断,不是内容失败;下次运行会自动重试。');
289
+ }
276
290
  if (failures.length) {
277
291
  lines.push('失败:' + failures.length + ' 篇');
278
292
  for (const item of failures.slice(0, 10)) {
279
293
  lines.push(' - ' + (item.id || item.url || '未知') + ':' + item.reason);
280
294
  }
281
295
  if (failures.length > 10) lines.push(' - 其余 ' + (failures.length - 10) + ' 篇省略');
282
- lines.push('失败项已跳过,不会中断其他作品。');
283
- lines.push('作品级失败已记录为跳过,下次不再重试;账号级失败仍会在下次重试。');
296
+ lines.push('失败项已记录,不会中断其他作品。');
297
+ lines.push('内容级失败后续跳过;超时/中断类待重试项会在下次运行继续。');
284
298
  }
285
299
  if (Array.isArray(stylesUpdated) && stylesUpdated.length) {
286
300
  lines.push('风格更新:' + stylesUpdated.join('、'));
@@ -0,0 +1,200 @@
1
+ /**
2
+ * facet 选项说明。
3
+ *
4
+ * 弹框右侧必须是“这个选项是什么、适合什么”,不能反复写“选中后必须同时满足”。
5
+ */
6
+
7
+ import { selectGenreClusters } from './genre-playbooks.js';
8
+
9
+ const HINTS = {
10
+ settings: {
11
+ 现代: '当代都市/校园/职场背景,适合现实规则与日常异变',
12
+ 当代: '与“现代”接近,强调当下社会与生活细节',
13
+ 古代: '古风/历史/仙侠背景,适合礼法、门派与阶层',
14
+ 远古: '更早的上古/洪荒背景,适合神话与始祖设定',
15
+ 上古: '神话/洪荒前期,适合神兽、遗迹与旧神',
16
+ 民国: '民国/年代背景,适合新旧秩序碰撞',
17
+ 年代: '特定年代生活背景,适合集体记忆与物质匮乏',
18
+ '80年代': '八十年代背景,适合下岗、个体户、旧城生活',
19
+ '90年代': '九十年代背景,适合港风、录像厅、下海潮',
20
+ 架空: '不绑定真实朝代/国家的虚构世界',
21
+ 异世界: '异世界/异大陆,适合完整力量体系',
22
+ 平行世界: '平行现实/同位体,适合身份错位与对照',
23
+ 未来: '未来社会,适合科技、制度与身体改造',
24
+ 星际: '星际文明/舰队/殖民,适合尺度与资源冲突',
25
+ 末世: '灾变后的生存背景,适合秩序崩塌与据点',
26
+ },
27
+ moods: {
28
+ 爽文: '强反馈、快节奏、打脸与兑现密集',
29
+ 甜宠: '低伤害、高糖、关系推进为主',
30
+ 爆笑: '喜剧节奏,靠反差和误会制造笑点',
31
+ 沙雕: '荒诞、无厘头、故意不严肃',
32
+ 轻松: '低压迫、日常感、阅读负担小',
33
+ 治愈: '修复创伤、温暖关系、余味柔和',
34
+ 热血: '高燃目标、正面冲突、行动驱动',
35
+ 励志: '成长与翻身,强调努力和选择',
36
+ 团宠: '被多人偏爱/保护,关系安全感强',
37
+ 打脸: '先抑后扬,靠反转兑现爽感',
38
+ 虐文: '高情感伤害、误会/失去/求不得',
39
+ 虐恋: '感情拉扯为主,甜虐交替',
40
+ 惊悚: '持续不安、未知威胁、生理性紧张',
41
+ 烧脑: '信息差、推理、规则博弈',
42
+ },
43
+ tropes: {
44
+ 系统流: '系统发布任务/奖励,推动升级与选择',
45
+ 无限流: '多副本/多世界循环,规则与生存并重',
46
+ 诸天流: '穿越多个世界/位面,强调世界差异',
47
+ 重生: '带着前世记忆重来,改变命运与选择',
48
+ 穿越: '现代人进入异时空,利用认知差',
49
+ 穿书: '进入书中世界,知道剧情但未必能改',
50
+ 快穿: '快速穿越多个任务世界,单元结构',
51
+ 无敌流: '主角起点极强,冲突转向代价/规则',
52
+ 升级流: '明确成长阶梯,靠升级与资源推进',
53
+ 废柴流: '低起点逆袭,强调反差与打脸',
54
+ 扮猪吃虎: '隐藏实力,先低调后爆发',
55
+ 杀伐果断: '不拖泥带水,决策强硬,代价明确',
56
+ 智商在线: '靠信息、推理和策略解决问题',
57
+ 幕后流: '主角在幕后布局,不正面出手',
58
+ 签到流: '固定地点/时间签到获取资源',
59
+ 模拟流: '先模拟人生/选择,再回到现实',
60
+ },
61
+ roles: {
62
+ 霸总: '现代言情/豪门权势角色,适合控制欲、资源碾压与情感冲突',
63
+ 女总裁: '现代商战/强势决策者,适合权力与亲密关系对撞',
64
+ 影帝: '娱乐圈顶流/演技派,适合人前表演、人后失控',
65
+ 影后: '娱乐圈女性顶流,适合名声、表演与真实自我冲突',
66
+ 神医: '医术金手指/救人打脸,适合医疗现场与身份反差',
67
+ 特种兵: '军事/行动力角色,适合硬碰硬、团队任务与创伤',
68
+ 校花: '校园颜值中心,适合青春、暗恋、群体目光',
69
+ 校草: '校园男性焦点,适合青春、竞争与误会',
70
+ 校霸: '校园冲突源,适合霸凌、反抗与保护关系',
71
+ 学霸: '学业强者,适合智力博弈与反差',
72
+ 学神: '近乎碾压的学业天花板,适合降维打击',
73
+ 首富: '资本顶端,适合豪门、资源与规则博弈',
74
+ 赘婿: '低身份高隐藏,适合扮猪吃虎与婚姻张力',
75
+ 奶爸: '亲子/日常责任,适合温情、反差与生活流',
76
+ 忠犬: '高忠诚、强依恋,适合守护与关系拉扯',
77
+ 反派: '站在主角对立面,适合立场冲突与魅力反派',
78
+ 大佬: '资源/实力高位者,适合压场与权力关系',
79
+ 炮灰: '低存在感/被牺牲者,适合逆袭与命运改写',
80
+ 替身: '被当作他人替代品,适合身份错位与情感伤害',
81
+ 杀手: '高风险执行者,适合冷硬行动与道德困境',
82
+ },
83
+ relations: {
84
+ 白月光: '遥不可及/被神化的旧爱,适合遗憾与替代',
85
+ 朱砂痣: '得不到却刻骨的旧情,适合执念与对照',
86
+ 青梅竹马: '长期共同成长,适合默契、习惯与错过',
87
+ 天降: '突然闯入关系,适合打破旧秩序',
88
+ 姐弟恋: '年龄/成熟度差,适合照顾与平等拉扯',
89
+ 兄妹: '血缘/家庭关系,适合禁忌边界与保护',
90
+ 伪兄妹: '非血缘的兄妹关系,适合暧昧与身份秘密',
91
+ 养兄妹: '共同生活但无血缘,适合家庭与情感边界',
92
+ 师生: '权力/知识差,适合禁忌、引导与反抗',
93
+ 师徒: '传承/责任关系,适合恩义、背叛与成长',
94
+ 同事: '日常协作关系,适合利益与默契并存',
95
+ 上司下属: '权力差关系,适合服从、利用与越界',
96
+ 邻居: '近距离日常关系,适合窥探、照应与边界',
97
+ 同桌: '校园近距离关系,适合青春、竞争与暗恋',
98
+ },
99
+ };
100
+
101
+ const GENRE_HINTS = {
102
+ 仙侠: '东方仙侠/修真,适合宗门、境界、道法与因果',
103
+ 修真: '修仙体系,适合境界、丹药、宗门与资源',
104
+ 玄幻: '东方玄幻/异世,适合力量体系、势力与血脉',
105
+ 奇幻: '广义奇幻,适合魔法、种族与异象',
106
+ 西幻: '西方奇幻,适合契约、教会、骑士与王权',
107
+ 武侠: '江湖/武学,适合门派、侠义与恩怨',
108
+ 江湖: '武侠江湖,适合门派、规矩与底层人',
109
+ 都市: '现代都市,适合日常规则、职场与市井异变',
110
+ 异能: '超能力/异能,适合规则、代价与日常结合',
111
+ 科幻: '科幻/未来,适合技术、制度与物种尺度',
112
+ 赛博朋克: '高科技低生活,适合义体、公司与阶层',
113
+ 蒸汽朋克: '蒸汽工业/复古机械,适合工匠与帝国',
114
+ 末世: '灾变后生存,适合据点、资源与秩序重建',
115
+ 废土: '荒芜废土,适合拾荒、变异与公路',
116
+ 星际: '星际文明,适合舰队、殖民与尺度冲突',
117
+ 历史: '历史/古代,适合制度、阶层与真实质感',
118
+ 古代: '古代背景,适合礼法、家族与权力',
119
+ 现代: '现代背景,适合都市、校园与职场',
120
+ 民国: '民国/年代,适合新旧交替与乱世',
121
+ 架空: '架空世界,适合自洽制度与地理',
122
+ 悬疑: '悬疑/推理,适合信息差、谜题与真相',
123
+ 灵异: '灵异/志怪,适合禁忌、民俗与未知',
124
+ 惊悚: '惊悚/恐怖,适合压迫感与生存威胁',
125
+ 恐怖: '恐怖题材,适合怪物、规则与心理恐惧',
126
+ 志怪: '志怪/异闻,适合传说、精怪与旧事',
127
+ 民俗: '民俗/地方规矩,适合禁忌与仪式',
128
+ 刑侦: '刑侦/探案,适合证据、程序与追凶',
129
+ 推理: '推理/解谜,适合线索、逻辑与反转',
130
+ 探案: '探案/调查,适合单元案件与真相',
131
+ 脑洞: '高概念/脑洞,适合反常识规则与设定',
132
+ 神话: '神话/神祇,适合谱系、神格与传说',
133
+ 洪荒: '洪荒/上古,适合大能、种族与量劫',
134
+ 游戏: '游戏/副本,适合规则、职业与通关',
135
+ 电竞: '电竞/竞技,适合团队、赛训与胜负',
136
+ 娱乐圈: '娱乐圈/行业,适合名声、资源与人设',
137
+ 校园: '校园/青春,适合同学、考试与成长',
138
+ 职场: '职场/公司,适合权力、流程与利益',
139
+ 豪门: '豪门/世家,适合资源、继承与家族斗争',
140
+ 宫斗: '宫廷/后宫,适合位分、规矩与博弈',
141
+ 宅斗: '宅院/家族,适合内宅规矩与嫡庶',
142
+ 种田: '种田/经营,适合生产、资源与日常',
143
+ 言情: '情感关系为主,适合关系张力与选择',
144
+ 古言: '古代言情,适合礼法、家族与情感',
145
+ 现言: '现代言情,适合都市、职场与关系',
146
+ 青春: '青春/成长,适合校园、友情与初恋',
147
+ 甜宠: '甜宠/高糖,适合低伤害关系推进',
148
+ 虐恋: '虐恋/高伤害,适合误会、失去与拉扯',
149
+ 军事: '军事/战争,适合纪律、任务与牺牲',
150
+ 谍战: '谍战/情报,适合身份、试探与背叛',
151
+ 权谋: '权谋/政治,适合阵营、信息与利益',
152
+ 正剧: '正剧/严肃,适合现实逻辑与复杂人性',
153
+ 生存: '生存/极限,适合资源、环境与选择',
154
+ 灾难: '灾难/危机,适合逃逸、秩序与代价',
155
+ 特摄: '特摄/英雄变身,适合巨大威胁、单元怪人与变身代价',
156
+ ABO: 'ABO性别设定,适合信息素、标记与权力关系',
157
+ 同人: '同人/既有角色再创作,适合既定关系与平行演绎',
158
+ 轻小说: '轻小说/二次元叙事,适合轻快单元与角色萌点',
159
+ 二次元: '二次元/动漫风格,适合夸张设定与视觉化',
160
+ 国漫: '国漫/漫画叙事,适合分镜与长线设定',
161
+ 反乌托邦: '反乌托邦/制度压迫,适合规则、监控与反抗',
162
+ 生存: '生存/极限环境,适合资源、环境与选择',
163
+ 灾难: '灾难/危机,适合逃逸、秩序与代价',
164
+ 权谋: '权谋/政治,适合阵营、信息与利益',
165
+ 正剧: '正剧/严肃,适合现实逻辑与复杂人性',
166
+ };
167
+
168
+ function clean(value) {
169
+ return String(value == null ? '' : value).trim();
170
+ }
171
+
172
+ function genreHint(value) {
173
+ const genre = clean(value);
174
+ if (GENRE_HINTS[genre]) return GENRE_HINTS[genre];
175
+ const clusters = selectGenreClusters([genre]);
176
+ if (clusters.length) {
177
+ const formula = clusters[0].formula.split(':')[0];
178
+ return `题材簇:${clusters[0].title};${formula}`;
179
+ }
180
+ return `题材标签:${genre}`;
181
+ }
182
+
183
+ /**
184
+ * 返回一个选项的“说明”,而不是重复的规则提示。
185
+ */
186
+ export function facetOptionDescription(field, value) {
187
+ const key = clean(value);
188
+ if (!key) return '(空选项)';
189
+ if (field === 'genres') return genreHint(key);
190
+ const map = HINTS[field];
191
+ if (map && map[key]) return map[key];
192
+ const fallback = {
193
+ settings: '场景/时代标签:' + key,
194
+ moods: '情绪/调性:' + key,
195
+ tropes: '情节/流派:' + key,
196
+ roles: '身份/职业:' + key,
197
+ relations: '关系张力:' + key,
198
+ };
199
+ return fallback[field] || ('素材条件:' + key);
200
+ }
@@ -22,6 +22,7 @@ import { BUILTIN_GENRES } from '#material-topic';
22
22
  import { MATERIAL_FACET_CANDIDATES } from './facets.js';
23
23
  import { KIND_GROUPS, KIND_LABELS, MATERIAL_KINDS } from './kinds.js';
24
24
  import { normalizeCategories } from './plan.js';
25
+ import { facetOptionDescription } from './facet-copy.js';
25
26
 
26
27
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
27
28
  const WORLD_PROMPT_FILE = path.join(__dirname, 'prompts', 'world-mother.md');
@@ -173,9 +174,8 @@ export function facetQuestion(step, { suggestion = null, selected = [] } = {}) {
173
174
  const isRecommended = recommended.includes(value);
174
175
  options.push({
175
176
  label: value,
176
- description: isRecommended
177
- ? '推荐:来自 _novel_topic_suggestion.json(可改)'
178
- : (step.id === 'genres' ? '题材条件;多选时每一项都要同时满足' : '选中后必须同时满足'),
177
+ description: (isRecommended ? '推荐:来自 _novel_topic_suggestion.json(可改);' : '')
178
+ + facetOptionDescription(step.id, value),
179
179
  });
180
180
  if (Number.isFinite(limit) && options.length >= limit + 1) break;
181
181
  }