@gobing-ai/knowledge-kit 0.1.23 → 0.1.24

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.
Files changed (84) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +117 -56
  3. package/package.json +5 -5
  4. package/plugins/generations/content-gen/dist/index.js +9 -9
  5. package/plugins/generations/core-facts-gen/dist/index.js +12 -12
  6. package/plugins/generations/daily-article-gen/dist/index.js +12 -12
  7. package/plugins/generations/dailynews-gen/dist/index.js +11 -11
  8. package/plugins/generations/dailynews-gen/src/script-plan.ts +2 -2
  9. package/plugins/generations/episode-plan-gen/dist/index.js +12 -12
  10. package/plugins/generations/gemini-tts/dist/index.js +9 -9
  11. package/plugins/generations/image-gen/dist/index.js +9 -9
  12. package/plugins/generations/music-gen/dist/index.js +16 -16
  13. package/plugins/generations/news-report-gen/dist/index.js +12 -12
  14. package/plugins/generations/vibe-voice-tts/dist/index.js +9 -9
  15. package/plugins/generations/voice-gen/dist/index.js +9 -9
  16. package/plugins/generations/voxcpm-tts/dist/index.js +9 -9
  17. package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
  18. package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
  19. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  20. package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
  21. package/plugins/ingestions/web-search/dist/index.js +10 -10
  22. package/plugins/kk/plugin.json +1 -1
  23. package/plugins/kk/publish-presets/daily-ai-voice.json +16 -16
  24. package/plugins/kk/scripts/cover-compositor.ts +104 -26
  25. package/plugins/kk/scripts/daily-stages.ts +217 -33
  26. package/plugins/kk/scripts/kk-workflow-stages.ts +144 -6
  27. package/plugins/kk/scripts/series-names.ts +16 -3
  28. package/plugins/kk/skills/news-editorial/SKILL.md +1 -1
  29. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
  30. package/plugins/kk/workflows/kk-news-generate.yaml +3 -0
  31. package/plugins/publishings/bilibili-pub/dist/index.js +22 -22
  32. package/plugins/publishings/bilibili-pub/dist/profile-check.js +22 -22
  33. package/plugins/publishings/cnblogs-pub/dist/index.js +22 -22
  34. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +22 -22
  35. package/plugins/publishings/csdn-pub/dist/index.js +22 -22
  36. package/plugins/publishings/csdn-pub/dist/profile-check.js +22 -22
  37. package/plugins/publishings/emdash-pub/dist/index.js +9 -9
  38. package/plugins/publishings/infoq-pub/dist/index.js +22 -22
  39. package/plugins/publishings/infoq-pub/dist/profile-check.js +22 -22
  40. package/plugins/publishings/jike-pub/dist/index.js +22 -22
  41. package/plugins/publishings/jike-pub/dist/profile-check.js +22 -22
  42. package/plugins/publishings/juejin-pub/dist/index.js +22 -22
  43. package/plugins/publishings/juejin-pub/dist/profile-check.js +22 -22
  44. package/plugins/publishings/linkedin-pub/dist/index.js +82 -24
  45. package/plugins/publishings/linkedin-pub/dist/profile-check.js +22 -22
  46. package/plugins/publishings/linkedin-pub/src/index.ts +93 -6
  47. package/plugins/publishings/medium-pub/dist/index.js +9 -9
  48. package/plugins/publishings/podcast-pub/dist/index.js +240 -37
  49. package/plugins/publishings/podcast-pub/src/index.ts +154 -3
  50. package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
  51. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
  52. package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
  53. package/plugins/publishings/qiita-pub/dist/index.js +9 -9
  54. package/plugins/publishings/shipinhao-pub/dist/index.js +23 -23
  55. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +23 -23
  56. package/plugins/publishings/shipinhao-pub/src/selectors.ts +2 -1
  57. package/plugins/publishings/sspai-pub/dist/index.js +22 -22
  58. package/plugins/publishings/sspai-pub/dist/profile-check.js +22 -22
  59. package/plugins/publishings/substack-pub/dist/index.js +22 -22
  60. package/plugins/publishings/substack-pub/dist/profile-check.js +22 -22
  61. package/plugins/publishings/surfdash-pub/dist/index.js +200 -92
  62. package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
  63. package/plugins/publishings/surfdash-pub/src/index.ts +94 -75
  64. package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
  65. package/plugins/publishings/surfdash-pub/src/patch.ts +28 -23
  66. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
  67. package/plugins/publishings/threads-pub/dist/index.js +36 -22
  68. package/plugins/publishings/threads-pub/dist/profile-check.js +27 -22
  69. package/plugins/publishings/threads-pub/src/post-rail.ts +20 -0
  70. package/plugins/publishings/wechatmp-pub/dist/index.js +180 -64
  71. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
  72. package/plugins/publishings/wechatmp-pub/src/enrich.ts +56 -10
  73. package/plugins/publishings/wechatmp-pub/src/flow.ts +155 -43
  74. package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
  75. package/plugins/publishings/weibo-pub/dist/index.js +22 -22
  76. package/plugins/publishings/weibo-pub/dist/profile-check.js +22 -22
  77. package/plugins/publishings/x-pub/dist/index.js +51 -45
  78. package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
  79. package/plugins/publishings/x-pub/src/post-rail.ts +40 -47
  80. package/plugins/publishings/xhs-pub/dist/index.js +22 -22
  81. package/plugins/publishings/xhs-pub/dist/profile-check.js +22 -22
  82. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +22 -22
  83. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +22 -22
  84. package/plugins/publishings/zenn-pub/dist/index.js +9 -9
@@ -4845,7 +4845,7 @@ var init_zod = __esm(() => {
4845
4845
  init_external();
4846
4846
  });
4847
4847
 
4848
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/errors.js
4848
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
4849
4849
  var ErrorCode;
4850
4850
  var init_errors3 = __esm(() => {
4851
4851
  ErrorCode = {
@@ -4856,7 +4856,7 @@ var init_errors3 = __esm(() => {
4856
4856
  };
4857
4857
  });
4858
4858
 
4859
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4859
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4860
4860
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
4861
4861
  var init_api_response = __esm(() => {
4862
4862
  init_errors3();
@@ -4879,10 +4879,10 @@ var init_api_response = __esm(() => {
4879
4879
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
4880
4880
  });
4881
4881
 
4882
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4882
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4883
4883
  var init_cursor = () => {};
4884
4884
 
4885
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/env.js
4885
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/env.js
4886
4886
  function getEnvVar(name, fallback) {
4887
4887
  const raw = process.env[name];
4888
4888
  return raw === undefined ? fallback : raw;
@@ -4891,10 +4891,10 @@ function getEnvVars() {
4891
4891
  return process.env;
4892
4892
  }
4893
4893
 
4894
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4894
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4895
4895
  var init_event_severity = () => {};
4896
4896
 
4897
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/object.js
4897
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/object.js
4898
4898
  function isPlainObject2(value) {
4899
4899
  return typeof value === "object" && value !== null && !Array.isArray(value);
4900
4900
  }
@@ -4912,7 +4912,7 @@ function deepMerge(target, source) {
4912
4912
  return result;
4913
4913
  }
4914
4914
 
4915
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/output.js
4915
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
4916
4916
  function processStream(name) {
4917
4917
  const proc = globalThis.process;
4918
4918
  const stream = proc?.[name];
@@ -4933,7 +4933,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
4933
4933
  }
4934
4934
  var defaultStdoutTarget, defaultStderrTarget;
4935
4935
 
4936
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/index.js
4936
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
4937
4937
  var init_dist = __esm(() => {
4938
4938
  init_api_response();
4939
4939
  init_cursor();
@@ -11931,7 +11931,7 @@ var init_dist2 = __esm(() => {
11931
11931
  $visitAsync = visit.visitAsync;
11932
11932
  });
11933
11933
 
11934
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/config.js
11934
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
11935
11935
  function getProcessEnv() {
11936
11936
  return getEnvVars();
11937
11937
  }
@@ -12009,7 +12009,7 @@ var init_config = __esm(() => {
12009
12009
  };
12010
12010
  });
12011
12011
 
12012
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
12012
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
12013
12013
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
12014
12014
  import { dirname, resolve as resolvePath } from "path";
12015
12015
  function createNodeFileSystem(root, paths) {
@@ -12096,7 +12096,7 @@ function findProjectRoot(startDir) {
12096
12096
  }
12097
12097
  var init_file_system_node = () => {};
12098
12098
 
12099
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
12099
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
12100
12100
  var DbModuleNotInstalledError;
12101
12101
  var init_db_errors = __esm(() => {
12102
12102
  DbModuleNotInstalledError = class DbModuleNotInstalledError extends Error {
@@ -19307,7 +19307,7 @@ var init_execa = __esm(() => {
19307
19307
  } = getIpcExport());
19308
19308
  });
19309
19309
 
19310
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
19310
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
19311
19311
  function resolveDeadline(optionTimeout, defaultTimeout) {
19312
19312
  if (optionTimeout === null)
19313
19313
  return null;
@@ -19399,7 +19399,7 @@ function ownProcessGroupLifecycle(ownership) {
19399
19399
  }
19400
19400
  var MAX_TIMEOUT_MS = 2147483647, DEFAULT_KILL_GRACE_MS = 5000, GROUP_POLL_INTERVAL_MS = 25, GROUP_KILL_PATIENCE_MS = 2000;
19401
19401
 
19402
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
19402
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
19403
19403
  import { isatty } from "tty";
19404
19404
  function processEventSeverity(reason, exitCode) {
19405
19405
  if (reason === "error")
@@ -19771,7 +19771,7 @@ var init_process_executor = __esm(() => {
19771
19771
  init_config();
19772
19772
  });
19773
19773
 
19774
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
19774
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
19775
19775
  function getNodeFileSystem() {
19776
19776
  if (!_nodeFileSystem)
19777
19777
  _nodeFileSystem = createNodeFileSystem();
@@ -20099,11 +20099,11 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
20099
20099
  });
20100
20100
  }
20101
20101
  });
20102
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
20102
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
20103
20103
  init_file_system_node();
20104
20104
  init_config();
20105
20105
 
20106
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/path.js
20106
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
20107
20107
  function normalizeSeparators(path) {
20108
20108
  return path.replaceAll("\\", "/");
20109
20109
  }
@@ -20161,7 +20161,7 @@ function getProcessCwd() {
20161
20161
  return globalThis.process?.cwd?.() ?? "/";
20162
20162
  }
20163
20163
 
20164
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
20164
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
20165
20165
  init_runtime_node_bun();
20166
20166
 
20167
20167
  // ../../packages/kk-core/src/render-md.ts
@@ -20254,7 +20254,7 @@ async function trySelectors(page, selectors, options = {}) {
20254
20254
  import { join as join5, resolve as resolve5 } from "path";
20255
20255
  import { parseArgs } from "util";
20256
20256
 
20257
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
20257
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
20258
20258
  class BrowserAutomationError extends Error {
20259
20259
  constructor(message, options) {
20260
20260
  super(message, options);
@@ -20303,10 +20303,10 @@ class OperationAbortedError extends BrowserAutomationError {
20303
20303
  this.name = "OperationAbortedError";
20304
20304
  }
20305
20305
  }
20306
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20306
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20307
20307
  import { mkdir } from "fs/promises";
20308
20308
 
20309
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
20309
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
20310
20310
  function resolveProfileDir(profileDir) {
20311
20311
  if (profileDir.trim() === "") {
20312
20312
  throw new InvalidProfileDirError;
@@ -20318,7 +20318,7 @@ function resolveProfileDir(profileDir) {
20318
20318
  return resolved;
20319
20319
  }
20320
20320
 
20321
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20321
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20322
20322
  var PROFILE_DIR_MODE = 448;
20323
20323
  var BUSY_PROFILE_PATTERN = /singleton|already in use|in use by another/i;
20324
20324
  var CHROMIUM_MISSING_PATTERN = /playwright install|executable doesn't exist/i;
@@ -20369,7 +20369,7 @@ function createPersistentLauncher(options = {}) {
20369
20369
  };
20370
20370
  }
20371
20371
 
20372
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20372
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20373
20373
  var DEFAULT_TIMEOUT_MS = 30000;
20374
20374
  var POLL_INTERVAL_MS = 250;
20375
20375
  var defaultLauncher;
@@ -21697,6 +21697,10 @@ async function resolveMediaPath(content, spec) {
21697
21697
  }
21698
21698
  return { path };
21699
21699
  }
21700
+ function isLibraryCover(content) {
21701
+ const wechatmp = content.metadata?.wechatmp;
21702
+ return typeof wechatmp === "object" && wechatmp !== null && !Array.isArray(wechatmp) && wechatmp.coverSource === "library";
21703
+ }
21700
21704
  async function resolveBodyImages(content) {
21701
21705
  const ordered = content.metadata?.images;
21702
21706
  if (ordered !== undefined && !Array.isArray(ordered)) {
@@ -21706,20 +21710,22 @@ async function resolveBodyImages(content) {
21706
21710
  const cover = typeof content.metadata?.wechatmp === "object" && content.metadata.wechatmp !== null ? content.metadata.wechatmp.coverPath : undefined;
21707
21711
  const candidates = [];
21708
21712
  if (typeof cover === "string" && cover.length > 0)
21709
- candidates.push({ path: cover, what: "metadata.wechatmp.coverPath" });
21713
+ candidates.push({ path: cover, what: "metadata.wechatmp.coverPath", coverOnly: true });
21710
21714
  const genericCover = content.metadata?.coverImage;
21711
21715
  const genericCoverPath = typeof genericCover === "string" ? genericCover : typeof genericCover?.path === "string" ? genericCover.path : undefined;
21712
21716
  if (genericCoverPath !== undefined && genericCoverPath.length > 0)
21713
- candidates.push({ path: genericCoverPath, what: "metadata.coverImage" });
21717
+ candidates.push({ path: genericCoverPath, what: "metadata.coverImage", coverOnly: true });
21714
21718
  for (const [index, image] of descriptors.entries()) {
21715
21719
  const path = typeof image === "string" ? image : image?.path;
21716
21720
  if (typeof path !== "string" || path.length === 0) {
21717
21721
  return { error: `images validation: images[${index}] carries no path` };
21718
21722
  }
21719
- candidates.push({ path, what: `metadata.images[${index}]` });
21723
+ candidates.push({ path, what: `metadata.images[${index}]`, coverOnly: false });
21720
21724
  }
21725
+ const skipCoverInBody = isLibraryCover(content);
21721
21726
  const paths = [];
21722
- for (const { path, what } of candidates) {
21727
+ let hasValidatedCover = false;
21728
+ for (const { path, what, coverOnly } of candidates) {
21723
21729
  if (!isAbsolute2(path)) {
21724
21730
  return { error: `images validation: ${what} must be absolute, got '${path}'` };
21725
21731
  }
@@ -21731,9 +21737,12 @@ async function resolveBodyImages(content) {
21731
21737
  if (!await createNodeFileSystem().exists(path)) {
21732
21738
  return { error: `images validation: ${what} does not exist: '${path}'` };
21733
21739
  }
21734
- paths.push(path);
21740
+ if (coverOnly)
21741
+ hasValidatedCover = true;
21742
+ if (!(skipCoverInBody && coverOnly))
21743
+ paths.push(path);
21735
21744
  }
21736
- return { paths };
21745
+ return { paths, hasValidatedCover };
21737
21746
  }
21738
21747
  function deriveDigest(content) {
21739
21748
  const explicit = content.metadata?.digest;
@@ -21811,7 +21820,7 @@ async function validateModeInput(operation, content) {
21811
21820
  const images = await resolveBodyImages(content);
21812
21821
  if (images.error)
21813
21822
  return { error: images.error };
21814
- if ((images.paths ?? []).length === 0) {
21823
+ if ((images.paths ?? []).length === 0 && !(isLibraryCover(content) && images.hasValidatedCover === true)) {
21815
21824
  return {
21816
21825
  error: "cover validation: \u6587\u7AE0 takes its cover from a body image (\u9ED8\u8BA4\u9996\u56FE\u4E3A\u5C01\u9762) but none was supplied \u2014 set metadata.wechatmp.coverPath, metadata.coverImage or metadata.images[]"
21817
21826
  };
@@ -22733,7 +22742,11 @@ var URL_COMMITTED = `(() => {
22733
22742
  return checkbox?.checked === true ? area.querySelector('.article_url_setting')?.textContent ?? null : null;
22734
22743
  })()`;
22735
22744
  var ORIGINAL_DECLARATION = `${DIALOG} label:has(.js_original_type_radio):has-text("\u6587\u5B57\u539F\u521B")`;
22736
- var ORIGINAL_AGREEMENT = `${DIALOG} label.original_agreement:has(input[type="checkbox"]:not(:checked))`;
22745
+ var ORIGINAL_AGREEMENT = [
22746
+ `${DIALOG} label.original_agreement:has(input[type="checkbox"]:not(:checked))`,
22747
+ `${DIALOG} label:has(input[type="checkbox"]:not(:checked)):has-text("\u6211\u5DF2\u9605\u8BFB\u5E76\u540C\u610F") i.weui-desktop-icon-checkbox`,
22748
+ `${DIALOG} label:has(input[type="checkbox"]:not(:checked)):has-text("\u6211\u5DF2\u9605\u8BFB\u5E76\u540C\u610F")`
22749
+ ];
22737
22750
  var COLLECTION_SETTLE_MS = 1200;
22738
22751
  var STEP_RETRY_SETTLE_MS = 1000;
22739
22752
  var SWEEP_SETTLE_MS = 400;
@@ -22745,6 +22758,12 @@ function norm(value) {
22745
22758
  }
22746
22759
  var COMMITTED = {
22747
22760
  original: `(() => {
22761
+ const open = document.querySelector('#js_original_open');
22762
+ if (open) {
22763
+ if (open.getClientRects().length === 0) return false;
22764
+ const sw = open.querySelector('input.weui-desktop-switch__input, input[type="checkbox"]');
22765
+ return sw ? sw.checked === true : true;
22766
+ }
22748
22767
  const el = [...document.querySelectorAll('#js_original input.weui-desktop-switch__input')]
22749
22768
  .find(input => input.parentElement?.getClientRects().length > 0);
22750
22769
  return el ? el.checked === true : null;
@@ -22806,8 +22825,9 @@ async function readChecked(page, expression) {
22806
22825
  return null;
22807
22826
  }
22808
22827
  }
22809
- async function enrichArticle(page, meta) {
22828
+ async function enrichArticleDetailed(page, meta) {
22810
22829
  const warnings = [];
22830
+ const capabilityWarnings = [];
22811
22831
  const str = (key) => typeof meta[key] === "string" ? meta[key] : "";
22812
22832
  const on = (key) => meta[key] === true;
22813
22833
  const sweep = async () => {
@@ -22849,7 +22869,9 @@ async function enrichArticle(page, meta) {
22849
22869
  return "ok";
22850
22870
  } catch (error) {
22851
22871
  if (error instanceof CapabilityError) {
22852
- warnings.push(`${name}: ${error.message}`);
22872
+ const msg = `${name}: ${error.message}`;
22873
+ warnings.push(msg);
22874
+ capabilityWarnings.push(msg);
22853
22875
  return "capability";
22854
22876
  }
22855
22877
  }
@@ -22877,11 +22899,14 @@ async function enrichArticle(page, meta) {
22877
22899
  const outcome = await step(name, async () => {
22878
22900
  await openRow(ROW_ORIGINAL, "\u539F\u521B\u58F0\u660E");
22879
22901
  await clickSelector(page, ORIGINAL_DECLARATION, 5000);
22880
- const agreement = await trySelectors(page, [ORIGINAL_AGREEMENT]);
22881
- if (agreement.found) {
22882
- await clickSelector(page, ORIGINAL_AGREEMENT, 3000);
22902
+ const agreement = await trySelectors(page, ORIGINAL_AGREEMENT);
22903
+ if (agreement.found && agreement.selector != null) {
22904
+ await clickSelector(page, agreement.selector, 3000);
22883
22905
  }
22884
22906
  await clickSelector(page, ORIGINAL_CONFIRM, 8000);
22907
+ await page.locator(DIALOG).first().waitFor?.({ state: "hidden", timeout: 1500 }).catch(() => {
22908
+ return;
22909
+ });
22885
22910
  });
22886
22911
  if (outcome !== "capability" && await readChecked(page, COMMITTED.original) !== true && !await residual(name)) {
22887
22912
  warnings.push(`${name}: \u539F\u521B\u58F0\u660E\u672A\u751F\u6548\uFF0C\u8BF7\u624B\u52A8\u8BBE\u7F6E`);
@@ -22947,7 +22972,9 @@ async function enrichArticle(page, meta) {
22947
22972
  };
22948
22973
  const urlRow = await readUrl() === norm(originalUrl) ? "committed" : await tryFindSelector(page, ROW_URL, 2000);
22949
22974
  if (urlRow === undefined) {
22950
- warnings.push(`${name}: \u884C\u4E0D\u5B58\u5728\uFF08\u5F53\u524D\u516C\u4F17\u53F7\u4E0D\u652F\u6301\uFF09\uFF0C\u8BF7\u624B\u52A8\u5904\u7406\u6216\u79FB\u9664 originalUrl`);
22975
+ const msg = `${name}: \u884C\u4E0D\u5B58\u5728\uFF08\u5F53\u524D\u516C\u4F17\u53F7\u4E0D\u652F\u6301\uFF09\uFF0C\u8BF7\u624B\u52A8\u5904\u7406\u6216\u79FB\u9664 originalUrl`;
22976
+ warnings.push(msg);
22977
+ capabilityWarnings.push(msg);
22951
22978
  } else if (urlRow !== "committed") {
22952
22979
  await step(name, async () => {
22953
22980
  if (await readUrl() === norm(originalUrl))
@@ -22999,7 +23026,14 @@ async function enrichArticle(page, meta) {
22999
23026
  }
23000
23027
  }
23001
23028
  await sweep();
23002
- return warnings;
23029
+ const ranAfterOriginal = on("reward") || collection !== "" || originalUrl !== "" || claimSource !== "";
23030
+ const hadOriginalWarning = warnings.some((w) => w.startsWith("\u539F\u521B\u58F0\u660E:"));
23031
+ if (on("original") && ranAfterOriginal && !hadOriginalWarning) {
23032
+ if (await readChecked(page, COMMITTED.original) === false) {
23033
+ warnings.push("\u539F\u521B\u58F0\u660E: \u540E\u7EED\u8BBE\u7F6E\u540E\u539F\u521B\u58F0\u660E\u88AB\u91CD\u7F6E\uFF0C\u8BF7\u6838\u5BF9");
23034
+ }
23035
+ }
23036
+ return { warnings, capabilityWarnings };
23003
23037
  }
23004
23038
 
23005
23039
  // ../../plugins/publishings/wechatmp-pub/src/flow.ts
@@ -23749,6 +23783,20 @@ async function setCover(page, source, deps, identity) {
23749
23783
  return await warn(`cover: ${error instanceof Error ? error.message : String(error)}`);
23750
23784
  }
23751
23785
  }
23786
+ function genericCoverPathOf(content) {
23787
+ const generic = content.metadata?.coverImage;
23788
+ const genericPath = typeof generic === "string" ? generic : typeof generic?.path === "string" ? generic.path : undefined;
23789
+ return genericPath !== undefined && genericPath.length > 0 ? genericPath : undefined;
23790
+ }
23791
+ function libraryCoverFallback(content) {
23792
+ const meta = content.metadata?.wechatmp;
23793
+ if (meta !== null && typeof meta === "object" && !Array.isArray(meta)) {
23794
+ const coverPath = meta.coverPath;
23795
+ if (typeof coverPath === "string" && coverPath.trim().length > 0)
23796
+ return coverPath.trim();
23797
+ }
23798
+ return genericCoverPathOf(content);
23799
+ }
23752
23800
  function coverSourceOf(content) {
23753
23801
  const meta = content.metadata?.wechatmp;
23754
23802
  if (meta !== null && typeof meta === "object" && !Array.isArray(meta)) {
@@ -23756,9 +23804,7 @@ function coverSourceOf(content) {
23756
23804
  if (declared === "body" || declared === "library")
23757
23805
  return declared;
23758
23806
  }
23759
- const generic = content.metadata?.coverImage;
23760
- const genericPath = typeof generic === "string" ? generic : typeof generic?.path === "string" ? generic.path : undefined;
23761
- return genericPath !== undefined && genericPath.length > 0 ? "body" : "library";
23807
+ return genericCoverPathOf(content) !== undefined ? "body" : "library";
23762
23808
  }
23763
23809
  function audioBlockOf(content) {
23764
23810
  const meta = content.metadata?.wechatmp;
@@ -23776,9 +23822,11 @@ function audioBlockOf(content) {
23776
23822
  async function enrichArticleDraft(page, content, stepTimeoutMs) {
23777
23823
  const enrichMeta = content.metadata?.wechatmp;
23778
23824
  if (enrichMeta === undefined || typeof enrichMeta !== "object" || Array.isArray(enrichMeta))
23779
- return { enrichWarnings: [], coverWarnings: [] };
23825
+ return { enrichWarnings: [], capabilityWarnings: [], coverWarnings: [] };
23780
23826
  const meta = enrichMeta;
23781
- const enrichWarnings = await enrichArticle(page, meta);
23827
+ const detailed = await enrichArticleDetailed(page, meta);
23828
+ const enrichWarnings = [...detailed.warnings];
23829
+ const capabilityWarnings = [...detailed.capabilityWarnings];
23782
23830
  const audio = audioBlockOf(content);
23783
23831
  let audioFailed = false;
23784
23832
  let coverSeeded = false;
@@ -23800,14 +23848,15 @@ async function enrichArticleDraft(page, content, stepTimeoutMs) {
23800
23848
  coverWarnings.push(cover);
23801
23849
  }
23802
23850
  }
23803
- return { enrichWarnings, coverWarnings };
23851
+ return { enrichWarnings, capabilityWarnings, coverWarnings };
23804
23852
  }
23805
23853
  async function composeArticle(input, deps, entry) {
23806
23854
  const page = entry.editor;
23807
23855
  const warnings = [];
23808
23856
  const titlePath = await typeTitle(page, deps);
23809
23857
  await insertBody(page, deps);
23810
- await attachImages(page, input.images, deps);
23858
+ if (input.images.length > 0)
23859
+ await attachImages(page, input.images, deps);
23811
23860
  for (const warning of [
23812
23861
  await fillOptional(page, DIGEST_INPUT, input.digest ?? "", "\u6458\u8981", deps),
23813
23862
  await fillOptional(page, AUTHOR_INPUT, authorOf(deps.content), "\u4F5C\u8005", deps)
@@ -23820,17 +23869,17 @@ async function composeArticle(input, deps, entry) {
23820
23869
  const audioRuns = audioBlockOf(deps.content) !== null;
23821
23870
  if (!(coverSource === "library" && audioRuns)) {
23822
23871
  const cover = await setCover(page, coverSource, deps, {
23823
- requested: input.images[0]
23872
+ requested: input.images[0] ?? libraryCoverFallback(deps.content)
23824
23873
  });
23825
23874
  if (cover !== null)
23826
23875
  warnings.push(cover);
23827
23876
  }
23828
- const { enrichWarnings, coverWarnings } = await enrichArticleDraft(page, deps.content, deps.stepTimeoutMs);
23877
+ const { enrichWarnings, capabilityWarnings, coverWarnings } = await enrichArticleDraft(page, deps.content, deps.stepTimeoutMs);
23829
23878
  warnings.push(...coverWarnings);
23830
23879
  const layout = await applyLayout(page, deps);
23831
23880
  if (layout !== null)
23832
23881
  warnings.push(layout);
23833
- return { warnings, titlePath, enrichWarnings };
23882
+ return { warnings, titlePath, enrichWarnings, capabilityWarnings };
23834
23883
  }
23835
23884
  async function composeSticker(input, deps, entry) {
23836
23885
  const page = entry.editor;
@@ -24615,11 +24664,16 @@ async function runMode(input, deps) {
24615
24664
  if (!result.ok && diagnostics.length > 0) {
24616
24665
  return { ...result, error: `${result.error} \u2014 compose diagnostics: ${diagnostics.join(" | ")}` };
24617
24666
  }
24618
- if (result.ok && composed.enrichWarnings.length > 0 && process.env.WECHATMP_ALLOW_PARTIAL_ENRICH !== "1") {
24667
+ const capabilitySet = new Set(composed.capabilityWarnings ?? []);
24668
+ const blockingEnrichWarnings = composed.enrichWarnings.filter((warning) => !capabilitySet.has(warning));
24669
+ const partialAllowed = process.env.WECHATMP_ALLOW_PARTIAL_ENRICH === "1";
24670
+ const fatalEnrichWarnings = partialAllowed ? blockingEnrichWarnings : composed.enrichWarnings;
24671
+ if (result.ok && fatalEnrichWarnings.length > 0) {
24672
+ const capabilityOnly = blockingEnrichWarnings.length === 0;
24619
24673
  return {
24620
24674
  ...result,
24621
24675
  ok: false,
24622
- error: `draft saved but enrichment did not apply \u2014 ${composed.enrichWarnings.join(" | ")} (set WECHATMP_ALLOW_PARTIAL_ENRICH=1 to accept a partial draft)`
24676
+ error: `draft saved but enrichment did not apply \u2014 ${fatalEnrichWarnings.join(" | ")}${capabilityOnly ? " (set WECHATMP_ALLOW_PARTIAL_ENRICH=1 to accept a partial draft)" : ""}`
24623
24677
  };
24624
24678
  }
24625
24679
  return result;
@@ -24708,7 +24762,18 @@ function markdownToWechatHtml(markdown) {
24708
24762
  function escapeHtml(text) {
24709
24763
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
24710
24764
  }
24711
- async function insertAudioMaterial(page, input) {
24765
+ async function evalOrFallback(page, script, fallback) {
24766
+ try {
24767
+ return String(await page.evaluate(script) ?? fallback);
24768
+ } catch {
24769
+ return fallback;
24770
+ }
24771
+ }
24772
+ async function insertAudioMaterial(page, input, timing = {}) {
24773
+ const uploadWaitMs = timing.uploadWaitMs ?? 120000;
24774
+ const saveCloseWaitMs = timing.saveCloseWaitMs ?? 30000;
24775
+ const saveDispatchWaitMs = timing.saveDispatchWaitMs ?? 1e4;
24776
+ const postUploadRowRetries = timing.rowRetries ?? 15;
24712
24777
  const { title, audioPath, coverPath } = input;
24713
24778
  let libraryHasCover = false;
24714
24779
  const result = (warning) => ({
@@ -24782,16 +24847,35 @@ async function insertAudioMaterial(page, input) {
24782
24847
  return JSON.stringify({ state: 'top', identity });
24783
24848
  })()`;
24784
24849
  const upload = async () => {
24850
+ let sawLiveUpload = false;
24851
+ const failUpload = (warning) => ({ ...result(warning), sawLiveUpload });
24852
+ const uploadDialog = '.weui-desktop-dialog:visible:has(h3.weui-desktop-dialog__title:text-is("\u4E0A\u4F20\u97F3\u9891"))';
24853
+ const isLiveUploadForm = async () => {
24854
+ if (await page.locator(uploadDialog).count() === 0)
24855
+ return false;
24856
+ try {
24857
+ const titleText = await page.locator(`${uploadDialog} h3.weui-desktop-dialog__title`).first().textContent?.() ?? "";
24858
+ return titleText.trim() === "\u4E0A\u4F20\u97F3\u9891";
24859
+ } catch {
24860
+ return false;
24861
+ }
24862
+ };
24785
24863
  const uploadControl = await trySelectors(page, UPLOAD_AUDIO);
24786
24864
  if (!uploadControl.found)
24787
- return result("\u97F3\u9891: \u4E0A\u4F20\u97F3\u9891 control not found in the audio dialog");
24865
+ return failUpload("\u97F3\u9891: \u4E0A\u4F20\u97F3\u9891 control not found in the audio dialog");
24788
24866
  await clickSelector(page, uploadControl.selector ?? UPLOAD_AUDIO[0] ?? "text=\u4E0A\u4F20\u97F3\u9891", 8000);
24789
24867
  const audioInput = await trySelectors(page, AUDIO_UPLOAD_INPUT, { visible: false });
24790
24868
  if (!audioInput.found)
24791
- return result("\u97F3\u9891: no audio file input appeared");
24869
+ return failUpload("\u97F3\u9891: no audio file input appeared");
24792
24870
  await uploadFile(asPlaywrightPage(page), audioInput.selector ?? AUDIO_UPLOAD_INPUT.join(", "), audioPath, {
24793
- timeoutMs: 60000
24871
+ timeoutMs: 120000
24794
24872
  });
24873
+ sawLiveUpload = await isLiveUploadForm();
24874
+ if (sawLiveUpload) {
24875
+ const uploaded = await waitUntil(async () => await page.locator(`${uploadDialog} button:has-text("\u91CD\u65B0\u4E0A\u4F20")`).count() > 0 && /100%/.test(await evalOrFallback(page, `(() => { const d = [...document.querySelectorAll('.weui-desktop-dialog')].find((el) => el.offsetWidth > 0 && el.querySelector('input[name=audio_id]')); return d ? (d.textContent ?? '') : ''; })()`, "")), uploadWaitMs);
24876
+ if (!uploaded)
24877
+ return failUpload("\u97F3\u9891: \u97F3\u9891\u6587\u4EF6\u4E0A\u4F20\u672A\u5B8C\u6210\uFF08\u672A\u8FBE\u5230 100%\uFF09\uFF0C\u672A\u4FDD\u5B58\u97F3\u9891");
24878
+ }
24795
24879
  const coverControl = await trySelectors(page, UPLOAD_COVER);
24796
24880
  if (coverControl.found) {
24797
24881
  await clickSelector(page, coverControl.selector ?? UPLOAD_COVER[0] ?? "text=\u4E0A\u4F20\u5C01\u9762", 8000);
@@ -24804,10 +24888,10 @@ async function insertAudioMaterial(page, input) {
24804
24888
  if (hasChooser) {
24805
24889
  const libraryReady = await waitUntil(async () => Boolean(await page.evaluate(`!document.querySelector('#js_image_dialog_list_wrp .weui-desktop-loading')`)), 5000);
24806
24890
  if (!libraryReady)
24807
- return result("\u97F3\u9891: \u5C01\u9762\u7D20\u6750\u5E93\u52A0\u8F7D\u672A\u5B8C\u6210\uFF0C\u672A\u4E0A\u4F20\u91CD\u590D\u5C01\u9762");
24891
+ return failUpload("\u97F3\u9891: \u5C01\u9762\u7D20\u6750\u5E93\u52A0\u8F7D\u672A\u5B8C\u6210\uFF0C\u672A\u4E0A\u4F20\u91CD\u590D\u5C01\u9762");
24808
24892
  existing = Number(await page.evaluate(`([...document.querySelectorAll('.weui-desktop-img-picker__item')].filter(row => row.offsetWidth > 0 && row.querySelector('.weui-desktop-img-picker__img-title')?.textContent?.trim() === ${JSON.stringify(coverName)})).length`));
24809
24893
  if (existing > 1)
24810
- return result("\u97F3\u9891: \u5185\u5BB9\u7ED1\u5B9A\u5C01\u9762\u5B58\u5728\u591A\u4E2A\u540C\u540D\u7D20\u6750\uFF0C\u672A\u731C\u6D4B\u9009\u62E9");
24894
+ return failUpload("\u97F3\u9891: \u5185\u5BB9\u7ED1\u5B9A\u5C01\u9762\u5B58\u5728\u591A\u4E2A\u540C\u540D\u7D20\u6750\uFF0C\u672A\u731C\u6D4B\u9009\u62E9");
24811
24895
  }
24812
24896
  let uploadPath = coverPath;
24813
24897
  let temporaryDir;
@@ -24836,10 +24920,13 @@ async function insertAudioMaterial(page, input) {
24836
24920
  return row.classList.contains('selected');
24837
24921
  })()`)), 30000);
24838
24922
  if (!selected)
24839
- return result("\u97F3\u9891: \u4E0A\u4F20\u5C01\u9762\u672A\u51FA\u73B0\u552F\u4E00\u5DF2\u9009\u4E2D\u7684\u540C\u540D\u56FE\u7247\uFF0C\u672A\u63D0\u4EA4\u5C01\u9762");
24923
+ return failUpload("\u97F3\u9891: \u4E0A\u4F20\u5C01\u9762\u672A\u51FA\u73B0\u552F\u4E00\u5DF2\u9009\u4E2D\u7684\u540C\u540D\u56FE\u7247\uFF0C\u672A\u63D0\u4EA4\u5C01\u9762");
24840
24924
  libraryHasCover = true;
24841
24925
  const next = await findSelector(page, [`${chooser} button:has-text("\u4E0B\u4E00\u6B65"):not(.weui-desktop-btn_disabled)`], "\u97F3\u9891\u5C01\u9762 \u4E0B\u4E00\u6B65", 30000);
24842
24926
  await clickSelector(page, next, 8000);
24927
+ if (sawLiveUpload && await page.locator(`${chooser} button:has-text("\u4E0A\u4E00\u6B65")`).count() > 0) {
24928
+ await page.waitForTimeout?.(2000);
24929
+ }
24843
24930
  const finish = await findSelector(page, [`${chooser} button:has-text("\u5B8C\u6210"):not(.weui-desktop-btn_disabled)`], "\u97F3\u9891\u5C01\u9762 \u5B8C\u6210", 30000);
24844
24931
  await clickSelector(page, finish, 8000);
24845
24932
  let closed = await waitUntil(async () => !await page.locator(chooser).first().isVisible(), 25000);
@@ -24863,7 +24950,7 @@ async function insertAudioMaterial(page, input) {
24863
24950
  }
24864
24951
  if (!closed) {
24865
24952
  const inventory = await openDialogInventory(page);
24866
- return result(`\u97F3\u9891: \u5C01\u9762\u9009\u62E9\u5668\u5B8C\u6210\u540E\u672A\u5173\u95ED\uFF0C\u672A\u4FDD\u5B58\u97F3\u9891${inventory ? ` (dialogs: ${inventory})` : ""}`);
24953
+ return failUpload(`\u97F3\u9891: \u5C01\u9762\u9009\u62E9\u5668\u5B8C\u6210\u540E\u672A\u5173\u95ED\uFF0C\u672A\u4FDD\u5B58\u97F3\u9891${inventory ? ` (dialogs: ${inventory})` : ""}`);
24867
24954
  }
24868
24955
  }
24869
24956
  } finally {
@@ -24879,10 +24966,29 @@ async function insertAudioMaterial(page, input) {
24879
24966
  await fillSelector(page, titleInput.selector ?? AUDIO_TITLE_INPUT.join(", "), title);
24880
24967
  const agreed = String(await page.evaluate(AGREE));
24881
24968
  if (agreed !== "checked")
24882
- return result(`\u97F3\u9891: \u670D\u52A1\u89C4\u5219\u52FE\u9009\u5931\u8D25 (${agreed})`);
24969
+ return failUpload(`\u97F3\u9891: \u670D\u52A1\u89C4\u5219\u52FE\u9009\u5931\u8D25 (${agreed})`);
24883
24970
  const save = await findSelector(page, UPLOAD_SAVE.map((selector) => `${selector}:not(.weui-desktop-btn_disabled):not([disabled])`), "\u97F3\u9891\u4E0A\u4F20\u5B8C\u6210\u4E14\u5C01\u9762\u5DF2\u63D0\u4EA4\u540E\u7684\u4FDD\u5B58\u6309\u94AE", 90000);
24971
+ if (sawLiveUpload) {
24972
+ await evalOrFallback(page, '(() => { window.__kkToasts = []; new MutationObserver(() => { const t = document.querySelector(".weui-desktop-toast"); if (t && t.textContent) window.__kkToasts.push(t.textContent.trim().slice(0, 200)); }).observe(document.body, { subtree: true, childList: true, characterData: true }); })()', "");
24973
+ }
24884
24974
  await clickSelector(page, save, 8000);
24885
- return result("");
24975
+ if (sawLiveUpload) {
24976
+ let formClosed = await waitUntil(async () => !await isLiveUploadForm(), saveCloseWaitMs);
24977
+ if (!formClosed) {
24978
+ const dispatched = await evalOrFallback(page, '(() => { const form = [...document.querySelectorAll(".weui-desktop-dialog")].find((d) => d.querySelector(".title_form_wrp")); const btn = form && [...form.querySelectorAll("button")].find((b) => (b.textContent ?? "").trim() === "\u4FDD\u5B58"); if (!btn) return "no-btn"; btn.click(); return btn.disabled ? "was-disabled" : "clicked"; })()', "null");
24979
+ formClosed = await waitUntil(async () => !await isLiveUploadForm(), saveDispatchWaitMs);
24980
+ if (!formClosed) {
24981
+ const saveDiagnostics = `(() => {
24982
+ const form = [...document.querySelectorAll(".weui-desktop-dialog")].find((d) => d.querySelector(".title_form_wrp"));
24983
+ const btn = form && [...form.querySelectorAll("button")].find((b) => (b.textContent ?? "").trim() === "\u4FDD\u5B58");
24984
+ return JSON.stringify({ btn: btn ? { disabled: btn.disabled, offW: btn.offsetWidth } : null, toasts: (window.__kkToasts ?? []).slice(-3) });
24985
+ })()`;
24986
+ const diag = (await evalOrFallback(page, saveDiagnostics, "")).slice(0, 400);
24987
+ return failUpload(`\u97F3\u9891: \u4FDD\u5B58\u5931\u8D25\uFF0C\u4E0A\u4F20\u5F39\u7A97\u672A\u5173\u95ED\uFF08dispatch=${dispatched} ${diag}\uFF09`);
24988
+ }
24989
+ }
24990
+ }
24991
+ return failUpload("");
24886
24992
  };
24887
24993
  const matchOnce = async () => {
24888
24994
  try {
@@ -24891,9 +24997,9 @@ async function insertAudioMaterial(page, input) {
24891
24997
  return "error";
24892
24998
  }
24893
24999
  };
24894
- const awaitMatch = async () => {
25000
+ const awaitMatch = async (retries = AUDIO_ROW_RETRIES) => {
24895
25001
  let match = await matchOnce();
24896
- for (let i = 0;match === "missing" && i < AUDIO_ROW_RETRIES; i += 1) {
25002
+ for (let i = 0;match === "missing" && i < retries; i += 1) {
24897
25003
  await page.waitForTimeout?.(AUDIO_ROW_SETTLE_MS);
24898
25004
  match = await matchOnce();
24899
25005
  }
@@ -24907,14 +25013,17 @@ async function insertAudioMaterial(page, input) {
24907
25013
  await page.evaluate(`document.querySelector(${JSON.stringify(AUDIO_MENU)})?.click()`);
24908
25014
  await waitForVisible(page, AUDIO_DIALOG, AUDIO_DIALOG_TIMEOUT_MS);
24909
25015
  let match = await awaitMatch();
25016
+ let postSavePoll = false;
24910
25017
  if (match === "missing") {
24911
25018
  const uploadResult = await upload();
25019
+ postSavePoll = uploadResult.sawLiveUpload;
24912
25020
  if (uploadResult.warning !== "") {
24913
- await page.evaluate(CANCEL);
25021
+ if (!uploadResult.sawLiveUpload)
25022
+ await page.evaluate(CANCEL);
24914
25023
  return result(uploadResult.warning);
24915
25024
  }
24916
25025
  await waitForVisible(page, AUDIO_DIALOG, AUDIO_DIALOG_TIMEOUT_MS);
24917
- match = await awaitMatch();
25026
+ match = await awaitMatch(postSavePoll ? postUploadRowRetries : AUDIO_ROW_RETRIES);
24918
25027
  if (match === "missing") {
24919
25028
  await page.evaluate(CANCEL);
24920
25029
  return result(`\u97F3\u9891: \u4FDD\u5B58\u540E\u7D20\u6750\u5217\u8868\u672A\u51FA\u73B0\u300C${title}\u300D\uFF0C\u672A\u63D2\u5165\u97F3\u9891`);
@@ -24939,7 +25048,14 @@ async function insertAudioMaterial(page, input) {
24939
25048
  await page.evaluate(CANCEL);
24940
25049
  return result("\u97F3\u9891: \u7D20\u6750\u5339\u914D\u63A2\u6D4B\u8FD4\u56DE\u672A\u77E5\u7ED3\u679C\uFF0C\u672A\u63D2\u5165\u97F3\u9891");
24941
25050
  }
24942
- if (await page.evaluate(INSERT) !== true) {
25051
+ let inserted = await page.evaluate(INSERT) === true;
25052
+ if (!inserted && postSavePoll) {
25053
+ for (let i = 0;!inserted && i < 5; i += 1) {
25054
+ await page.waitForTimeout?.(500);
25055
+ inserted = await page.evaluate(INSERT) === true;
25056
+ }
25057
+ }
25058
+ if (!inserted) {
24943
25059
  await page.evaluate(CANCEL);
24944
25060
  return result("\u97F3\u9891: \u63D2\u5165\u6309\u94AE\u672A\u627E\u5230\uFF0C\u8BF7\u624B\u52A8\u63D2\u5165");
24945
25061
  }