@gobing-ai/knowledge-kit 0.1.22 → 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 (117) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +282 -147
  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 +56 -16
  11. package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
  12. package/plugins/generations/image-gen/dist/index.js +9 -9
  13. package/plugins/generations/music-gen/README.md +2 -2
  14. package/plugins/generations/music-gen/dist/index.js +62 -26
  15. package/plugins/generations/music-gen/presets/formats/song.yaml +6 -1
  16. package/plugins/generations/music-gen/presets/themes/synthwave.yaml +6 -1
  17. package/plugins/generations/music-gen/src/adapter/instance.ts +34 -11
  18. package/plugins/generations/music-gen/src/presets.ts +36 -3
  19. package/plugins/generations/news-report-gen/dist/index.js +12 -12
  20. package/plugins/generations/omni-voice-gen/uv.toml +5 -0
  21. package/plugins/generations/vibe-voice-tts/README.md +64 -0
  22. package/plugins/generations/vibe-voice-tts/dist/index.js +14259 -0
  23. package/plugins/generations/vibe-voice-tts/package.json +16 -0
  24. package/plugins/generations/vibe-voice-tts/plugin.json +6 -0
  25. package/plugins/generations/vibe-voice-tts/profiles.json +10 -0
  26. package/plugins/generations/vibe-voice-tts/pyproject.toml +9 -0
  27. package/plugins/generations/vibe-voice-tts/python/worker.py +566 -0
  28. package/plugins/generations/vibe-voice-tts/src/index.ts +88 -0
  29. package/plugins/generations/vibe-voice-tts/src/vibevoice-client.ts +828 -0
  30. package/plugins/generations/vibe-voice-tts/tsconfig.json +8 -0
  31. package/plugins/generations/vibe-voice-tts/uv.lock +1767 -0
  32. package/plugins/generations/vibe-voice-tts/uv.toml +4 -0
  33. package/plugins/generations/voice-gen/dist/index.js +40 -10
  34. package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
  35. package/plugins/generations/voxcpm-tts/dist/index.js +90 -18
  36. package/plugins/generations/voxcpm-tts/python/worker.py +9 -0
  37. package/plugins/generations/voxcpm-tts/src/index.ts +41 -0
  38. package/plugins/generations/voxcpm-tts/src/voxcpm-client.ts +32 -11
  39. package/plugins/generations/voxcpm-tts/uv.toml +5 -0
  40. package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
  41. package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
  42. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  43. package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
  44. package/plugins/ingestions/web-search/dist/index.js +10 -10
  45. package/plugins/kk/README.md +21 -0
  46. package/plugins/kk/decisions/kk-safety.yaml +5 -2
  47. package/plugins/kk/plugin.json +1 -1
  48. package/plugins/kk/publish-presets/daily-ai-voice.json +16 -16
  49. package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +12 -1
  50. package/plugins/kk/scripts/cover-compositor.ts +104 -26
  51. package/plugins/kk/scripts/daily-stages.ts +481 -63
  52. package/plugins/kk/scripts/kk-workflow-stages.ts +218 -17
  53. package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
  54. package/plugins/kk/scripts/series-names.ts +16 -3
  55. package/plugins/kk/skills/news-editorial/SKILL.md +1 -1
  56. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
  57. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +4 -3
  58. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -5
  59. package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
  60. package/plugins/kk/workflows/kk-music.yaml +20 -16
  61. package/plugins/kk/workflows/kk-news-generate.yaml +26 -3
  62. package/plugins/kk/workflows/kk-publish.yaml +4 -1
  63. package/plugins/publishings/bilibili-pub/dist/index.js +22 -22
  64. package/plugins/publishings/bilibili-pub/dist/profile-check.js +22 -22
  65. package/plugins/publishings/cnblogs-pub/dist/index.js +22 -22
  66. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +22 -22
  67. package/plugins/publishings/csdn-pub/dist/index.js +22 -22
  68. package/plugins/publishings/csdn-pub/dist/profile-check.js +22 -22
  69. package/plugins/publishings/emdash-pub/dist/index.js +9 -9
  70. package/plugins/publishings/infoq-pub/dist/index.js +22 -22
  71. package/plugins/publishings/infoq-pub/dist/profile-check.js +22 -22
  72. package/plugins/publishings/jike-pub/dist/index.js +22 -22
  73. package/plugins/publishings/jike-pub/dist/profile-check.js +22 -22
  74. package/plugins/publishings/juejin-pub/dist/index.js +22 -22
  75. package/plugins/publishings/juejin-pub/dist/profile-check.js +22 -22
  76. package/plugins/publishings/linkedin-pub/dist/index.js +133 -33
  77. package/plugins/publishings/linkedin-pub/dist/profile-check.js +27 -22
  78. package/plugins/publishings/linkedin-pub/src/index.ts +192 -18
  79. package/plugins/publishings/medium-pub/dist/index.js +9 -9
  80. package/plugins/publishings/podcast-pub/dist/index.js +240 -37
  81. package/plugins/publishings/podcast-pub/src/index.ts +154 -3
  82. package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
  83. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
  84. package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
  85. package/plugins/publishings/qiita-pub/dist/index.js +9 -9
  86. package/plugins/publishings/shipinhao-pub/dist/index.js +23 -23
  87. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +23 -23
  88. package/plugins/publishings/shipinhao-pub/src/selectors.ts +2 -1
  89. package/plugins/publishings/sspai-pub/dist/index.js +22 -22
  90. package/plugins/publishings/sspai-pub/dist/profile-check.js +22 -22
  91. package/plugins/publishings/substack-pub/dist/index.js +22 -22
  92. package/plugins/publishings/substack-pub/dist/profile-check.js +22 -22
  93. package/plugins/publishings/surfdash-pub/dist/index.js +207 -95
  94. package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
  95. package/plugins/publishings/surfdash-pub/src/index.ts +101 -76
  96. package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
  97. package/plugins/publishings/surfdash-pub/src/patch.ts +49 -26
  98. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
  99. package/plugins/publishings/threads-pub/dist/index.js +83 -27
  100. package/plugins/publishings/threads-pub/dist/profile-check.js +34 -23
  101. package/plugins/publishings/threads-pub/src/post-rail.ts +121 -4
  102. package/plugins/publishings/wechatmp-pub/dist/index.js +274 -98
  103. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
  104. package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
  105. package/plugins/publishings/wechatmp-pub/src/enrich.ts +117 -13
  106. package/plugins/publishings/wechatmp-pub/src/flow.ts +183 -43
  107. package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
  108. package/plugins/publishings/weibo-pub/dist/index.js +22 -22
  109. package/plugins/publishings/weibo-pub/dist/profile-check.js +22 -22
  110. package/plugins/publishings/x-pub/dist/index.js +113 -32
  111. package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
  112. package/plugins/publishings/x-pub/src/post-rail.ts +155 -20
  113. package/plugins/publishings/xhs-pub/dist/index.js +22 -22
  114. package/plugins/publishings/xhs-pub/dist/profile-check.js +22 -22
  115. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +22 -22
  116. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +22 -22
  117. package/plugins/publishings/zenn-pub/dist/index.js +9 -9
@@ -45,7 +45,7 @@ var __esm = (fn, res, err) => () => {
45
45
  };
46
46
  var __require = import.meta.require;
47
47
 
48
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/errors.js
48
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
49
49
  var ErrorCode;
50
50
  var init_errors = __esm(() => {
51
51
  ErrorCode = {
@@ -56,7 +56,7 @@ var init_errors = __esm(() => {
56
56
  };
57
57
  });
58
58
 
59
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/api-response.js
59
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
60
60
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
61
61
  var init_api_response = __esm(() => {
62
62
  init_errors();
@@ -79,10 +79,10 @@ var init_api_response = __esm(() => {
79
79
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
80
80
  });
81
81
 
82
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/cursor.js
82
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
83
83
  var init_cursor = () => {};
84
84
 
85
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/env.js
85
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/env.js
86
86
  function getEnvVar(name, fallback) {
87
87
  const raw = process.env[name];
88
88
  return raw === undefined ? fallback : raw;
@@ -91,10 +91,10 @@ function getEnvVars() {
91
91
  return process.env;
92
92
  }
93
93
 
94
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
94
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
95
95
  var init_event_severity = () => {};
96
96
 
97
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/object.js
97
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/object.js
98
98
  function isPlainObject(value) {
99
99
  return typeof value === "object" && value !== null && !Array.isArray(value);
100
100
  }
@@ -112,7 +112,7 @@ function deepMerge(target, source) {
112
112
  return result;
113
113
  }
114
114
 
115
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/output.js
115
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
116
116
  function processStream(name) {
117
117
  const proc = globalThis.process;
118
118
  const stream = proc?.[name];
@@ -133,7 +133,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
133
133
  }
134
134
  var defaultStdoutTarget, defaultStderrTarget;
135
135
 
136
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/index.js
136
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
137
137
  var init_dist = __esm(() => {
138
138
  init_api_response();
139
139
  init_cursor();
@@ -11931,7 +11931,7 @@ var init_zod = __esm(() => {
11931
11931
  init_external();
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();
@@ -19838,7 +19838,7 @@ import { parseArgs as parseArgs2 } from "util";
19838
19838
  import { join as join5, resolve as resolve5 } from "path";
19839
19839
  import { parseArgs } from "util";
19840
19840
 
19841
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
19841
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
19842
19842
  class BrowserAutomationError extends Error {
19843
19843
  constructor(message, options) {
19844
19844
  super(message, options);
@@ -19887,14 +19887,14 @@ class OperationAbortedError extends BrowserAutomationError {
19887
19887
  this.name = "OperationAbortedError";
19888
19888
  }
19889
19889
  }
19890
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
19890
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
19891
19891
  import { mkdir } from "fs/promises";
19892
19892
 
19893
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
19893
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
19894
19894
  init_file_system_node();
19895
19895
  init_config();
19896
19896
 
19897
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/path.js
19897
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
19898
19898
  function normalizeSeparators(path) {
19899
19899
  return path.replaceAll("\\", "/");
19900
19900
  }
@@ -19952,10 +19952,10 @@ function getProcessCwd() {
19952
19952
  return globalThis.process?.cwd?.() ?? "/";
19953
19953
  }
19954
19954
 
19955
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
19955
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
19956
19956
  init_runtime_node_bun();
19957
19957
 
19958
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
19958
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
19959
19959
  function resolveProfileDir(profileDir) {
19960
19960
  if (profileDir.trim() === "") {
19961
19961
  throw new InvalidProfileDirError;
@@ -19967,7 +19967,7 @@ function resolveProfileDir(profileDir) {
19967
19967
  return resolved;
19968
19968
  }
19969
19969
 
19970
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
19970
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
19971
19971
  var PROFILE_DIR_MODE = 448;
19972
19972
  var BUSY_PROFILE_PATTERN = /singleton|already in use|in use by another/i;
19973
19973
  var CHROMIUM_MISSING_PATTERN = /playwright install|executable doesn't exist/i;
@@ -20018,7 +20018,7 @@ function createPersistentLauncher(options = {}) {
20018
20018
  };
20019
20019
  }
20020
20020
 
20021
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20021
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20022
20022
  var DEFAULT_TIMEOUT_MS = 30000;
20023
20023
  var POLL_INTERVAL_MS = 250;
20024
20024
  var defaultLauncher;
@@ -21174,7 +21174,11 @@ var URL_INPUT = [`${URL_POPOVER} input.js_url[name="source_url"]`];
21174
21174
  var URL_CONFIRM = `${URL_POPOVER} a.jsPopoverBt:text-is("\u786E\u5B9A")`;
21175
21175
  var URL_CANCEL = `${URL_POPOVER} a.jsPopoverBt:text-is("\u53D6\u6D88")`;
21176
21176
  var ORIGINAL_DECLARATION = `${DIALOG} label:has(.js_original_type_radio):has-text("\u6587\u5B57\u539F\u521B")`;
21177
- var ORIGINAL_AGREEMENT = `${DIALOG} label.original_agreement:has(input[type="checkbox"]:not(:checked))`;
21177
+ var ORIGINAL_AGREEMENT = [
21178
+ `${DIALOG} label.original_agreement:has(input[type="checkbox"]:not(:checked))`,
21179
+ `${DIALOG} label:has(input[type="checkbox"]:not(:checked)):has-text("\u6211\u5DF2\u9605\u8BFB\u5E76\u540C\u610F") i.weui-desktop-icon-checkbox`,
21180
+ `${DIALOG} label:has(input[type="checkbox"]:not(:checked)):has-text("\u6211\u5DF2\u9605\u8BFB\u5E76\u540C\u610F")`
21181
+ ];
21178
21182
 
21179
21183
  // ../../plugins/publishings/wechatmp-pub/src/flow.ts
21180
21184
  var PUBLIC_SAVE_REFUSAL_CONTAINERS = [
@@ -35,6 +35,7 @@ export class WechatCgiDraftError extends Error {
35
35
  | 'request-failed'
36
36
  | 'receipt-invalid'
37
37
  | 'readback-failed'
38
+ | 'duplicate-draft'
38
39
  | 'ambiguous-submission',
39
40
  readonly stage: string,
40
41
  message: string,
@@ -421,10 +422,85 @@ function ambiguousSubmission(stage: string, detail: string): WechatCgiDraftError
421
422
  }
422
423
 
423
424
  /**
424
- * The R2 create: eligibility re-asserted at the mutation boundary, ONE same-origin POST, receipt
425
- * gated (HTTP ok, ret absent|0, safe numeric appMsgId), then the id+title readback. Any
426
- * unverifiable create outcome throws ambiguous with metadata.ambiguousSubmission=true; readback
427
- * failures throw readback-failed (the create receipt itself already verified). Never retries.
425
+ * The console's own `list_ex` draft list, read on the authenticated page (task 0406 R4). One reader
426
+ * for both callers — the pre-create duplicate guard and the post-create readback — so the guard can
427
+ * never disagree with the confirmation about what the console holds. `stage` names the caller's
428
+ * step: a read failure is reported where it happened (nothing was created before the create).
429
+ */
430
+ async function readDraftList(
431
+ page: WechatPage,
432
+ session: WechatCgiSession,
433
+ stage: string,
434
+ ): Promise<Record<string, unknown>[]> {
435
+ const listUrl = buildUrl(APPMSG_URL, {
436
+ action: 'list_ex',
437
+ begin: '0',
438
+ count: '5',
439
+ token: session.token,
440
+ lang: 'zh_CN',
441
+ f: 'json',
442
+ });
443
+ let listVerdict: CgiVerdict | undefined;
444
+ try {
445
+ listVerdict = await evaluateCgiVerdict(
446
+ page,
447
+ cgiFetchExpression({
448
+ url: listUrl,
449
+ method: 'GET',
450
+ fields: {},
451
+ maxBytes: MAX_RESPONSE_BYTES,
452
+ timeoutMs: REQUEST_TIMEOUT_MS,
453
+ }),
454
+ );
455
+ } catch (error) {
456
+ throw new WechatCgiDraftError(
457
+ 'readback-failed',
458
+ stage,
459
+ `draft list readback ended before a receipt returned: ${stripQuery(String(error))}`,
460
+ );
461
+ }
462
+ if (listVerdict?.kind !== 'ok') {
463
+ const detail =
464
+ listVerdict?.kind === 'http-status'
465
+ ? `HTTP ${listVerdict.status}`
466
+ : listVerdict?.kind === 'too-large'
467
+ ? `${MAX_RESPONSE_BYTES}-byte bound exceeded`
468
+ : listVerdict?.kind === 'error'
469
+ ? stripQuery(listVerdict.detail)
470
+ : 'page returned no usable verdict';
471
+ throw new WechatCgiDraftError('readback-failed', stage, `draft list readback failed: ${detail}`);
472
+ }
473
+ let list: unknown;
474
+ try {
475
+ list = JSON.parse(listVerdict.text);
476
+ } catch {
477
+ throw new WechatCgiDraftError('readback-failed', stage, 'draft list receipt is not JSON');
478
+ }
479
+ return isRecord(list) && Array.isArray(list.app_msg_list)
480
+ ? list.app_msg_list.filter((item): item is Record<string, unknown> => isRecord(item))
481
+ : [];
482
+ }
483
+
484
+ /**
485
+ * R4: the console already holds a draft with this exact title, so creating would only add a
486
+ * duplicate (3 drafts in one night, 2026-11-19). Refuse with the id that holds it and no side
487
+ * effect — a failed `effect: none` row is retryable once the operator clears the console draft.
488
+ */
489
+ function duplicateDraft(existing: Record<string, unknown>, title: string): WechatCgiDraftError {
490
+ const id = existing.app_id !== undefined ? existing.app_id : existing.appmsgid;
491
+ return new WechatCgiDraftError(
492
+ 'duplicate-draft',
493
+ 'pre-create-lookup',
494
+ `duplicate-draft: appmsgid ${String(id)} already holds "${title}" — delete it or finish it in the console`,
495
+ );
496
+ }
497
+
498
+ /**
499
+ * The R2 create: eligibility re-asserted at the mutation boundary, a duplicate-title lookup
500
+ * (0406 R4) before anything is dispatched, ONE same-origin POST, receipt gated (HTTP ok, ret
501
+ * absent|0, safe numeric appMsgId), then the id+title readback. Any unverifiable create outcome
502
+ * throws ambiguous with metadata.ambiguousSubmission=true; readback failures throw readback-failed
503
+ * (the create receipt itself already verified). Never retries.
428
504
  */
429
505
  export async function createWechatArticleDraft(
430
506
  page: WechatPage,
@@ -432,8 +508,12 @@ export async function createWechatArticleDraft(
432
508
  content: Content,
433
509
  media: WechatArticleMedia,
434
510
  ): Promise<{ appMsgId: string; editPath: string }> {
435
- assertEligibleCgiDraft(content);
511
+ const certified = certifyCgiDraft(content);
436
512
  assertMpOrigin(page);
513
+ const existing = (await readDraftList(page, session, 'pre-create-lookup')).find(
514
+ (item) => item.title === certified.title,
515
+ );
516
+ if (existing !== undefined) throw duplicateDraft(existing, certified.title);
437
517
  const payload = buildCreateArticlePayload(session, content, media);
438
518
  let createVerdict: CgiVerdict | undefined;
439
519
  try {
@@ -487,56 +567,10 @@ export async function createWechatArticleDraft(
487
567
  if (appMsgId === undefined || !/^-?\d{1,12}$/.test(appMsgId)) {
488
568
  throw ambiguousSubmission('create-receipt', 'create receipt did not return a safe numeric appMsgId');
489
569
  }
490
- const listUrl = buildUrl(APPMSG_URL, {
491
- action: 'list_ex',
492
- begin: '0',
493
- count: '5',
494
- token: session.token,
495
- lang: 'zh_CN',
496
- f: 'json',
497
- });
498
- let listVerdict: CgiVerdict | undefined;
499
- try {
500
- listVerdict = await evaluateCgiVerdict(
501
- page,
502
- cgiFetchExpression({
503
- url: listUrl,
504
- method: 'GET',
505
- fields: {},
506
- maxBytes: MAX_RESPONSE_BYTES,
507
- timeoutMs: REQUEST_TIMEOUT_MS,
508
- }),
509
- );
510
- } catch (error) {
511
- throw new WechatCgiDraftError(
512
- 'readback-failed',
513
- 'readback',
514
- `draft list readback ended before a receipt returned: ${stripQuery(String(error))}`,
515
- );
516
- }
517
- if (listVerdict?.kind !== 'ok') {
518
- const detail =
519
- listVerdict?.kind === 'http-status'
520
- ? `HTTP ${listVerdict.status}`
521
- : listVerdict?.kind === 'too-large'
522
- ? `${MAX_RESPONSE_BYTES}-byte bound exceeded`
523
- : listVerdict?.kind === 'error'
524
- ? stripQuery(listVerdict.detail)
525
- : 'page returned no usable verdict';
526
- throw new WechatCgiDraftError('readback-failed', 'readback', `draft list readback failed: ${detail}`);
527
- }
528
- let list: unknown;
529
- try {
530
- list = JSON.parse(listVerdict.text);
531
- } catch {
532
- throw new WechatCgiDraftError('readback-failed', 'readback', 'draft list receipt is not JSON');
533
- }
534
- const items = isRecord(list) && Array.isArray(list.app_msg_list) ? list.app_msg_list : [];
570
+ const items = await readDraftList(page, session, 'readback');
535
571
  const confirmed = items.some(
536
572
  (item) =>
537
- isRecord(item) &&
538
- item.title === content.title &&
539
- (String(item.app_id) === appMsgId || String(item.appmsgid) === appMsgId),
573
+ item.title === content.title && (String(item.app_id) === appMsgId || String(item.appmsgid) === appMsgId),
540
574
  );
541
575
  if (!confirmed) {
542
576
  throw new WechatCgiDraftError(
@@ -72,8 +72,14 @@ const URL_COMMITTED = `(() => {
72
72
  /** The 原创 dialog's declaration radio (measured 2026-10-13): the platform requires an explicit
73
73
  * declaration type + the agreement check before 确定. `无需声明` is the undo choice, never a target. */
74
74
  const ORIGINAL_DECLARATION = `${DIALOG} label:has(.js_original_type_radio):has-text("文字原创")`;
75
- /** Drive the hidden checkbox through its label, preserving a pre-checked agreement (probe 6). */
76
- const ORIGINAL_AGREEMENT = `${DIALOG} label.original_agreement:has(input[type="checkbox"]:not(:checked))`;
75
+ /** Drive the hidden checkbox through its label, preserving a pre-checked agreement (probe 6).
76
+ * Live 2026-11 WeChat v2 replaced `.original_agreement` with `.weui-desktop-form__check-label`, so
77
+ * match the legacy class first and fall back to the checkbox label containing the agreement text. */
78
+ const ORIGINAL_AGREEMENT = [
79
+ `${DIALOG} label.original_agreement:has(input[type="checkbox"]:not(:checked))`,
80
+ `${DIALOG} label:has(input[type="checkbox"]:not(:checked)):has-text("我已阅读并同意") i.weui-desktop-icon-checkbox`,
81
+ `${DIALOG} label:has(input[type="checkbox"]:not(:checked)):has-text("我已阅读并同意")`,
82
+ ] as const;
77
83
  /** The 合集 picker's options load after the dialog opens (the pre-ADR-029 settle, kept). */
78
84
  const COLLECTION_SETTLE_MS = 1_200;
79
85
  /** The settings panel re-renders after a dialog confirm and can briefly detach rows. */
@@ -98,9 +104,18 @@ function norm(value: unknown): string {
98
104
  * Playwright-only syntax (`:visible`, `:has-text`) never enters `querySelector` — it throws there.
99
105
  */
100
106
  const COMMITTED = {
101
- /** Both undeclared and declared templates keep hidden inputs. Read the switch in the visible
102
- * row branch, never the hidden undeclared template or the dialog's matching checkbox. */
107
+ /** Both undeclared and declared templates keep hidden inputs. Live WeChat checks BOTH
108
+ * checkboxes (including the visible `未声明` row) as soon as `#js_original` opens while keeping
109
+ * `#js_original_open` hidden (`rects=0`), so require `#js_original_open` visibility + checked
110
+ * state whenever `#js_original_open` exists in the DOM; fall back to the legacy visible switch
111
+ * when `#js_original_open` is absent. */
103
112
  original: `(() => {
113
+ const open = document.querySelector('#js_original_open');
114
+ if (open) {
115
+ if (open.getClientRects().length === 0) return false;
116
+ const sw = open.querySelector('input.weui-desktop-switch__input, input[type="checkbox"]');
117
+ return sw ? sw.checked === true : true;
118
+ }
104
119
  const el = [...document.querySelectorAll('#js_original input.weui-desktop-switch__input')]
105
120
  .find(input => input.parentElement?.getClientRects().length > 0);
106
121
  return el ? el.checked === true : null;
@@ -124,6 +139,52 @@ const CLAIM_COMMITTED = `(() => {
124
139
  return { enabled, text };
125
140
  })()`;
126
141
 
142
+ /**
143
+ * The 赞赏 row's own state, measured 2026-11-20 on a fresh 文章 draft (account without an authorized
144
+ * 赞赏 account): the row renders `.setting-group__switch.js_reward_allow_click` carrying the text
145
+ * `不开启 … 无法开启赞赏,因为还没有赞赏账户授权给本公众号`, its box is **0×0**, and the click the rail
146
+ * used to attempt therefore burned its full 8 s timeout (`赞赏: click: Timeout 8000ms exceeded`) on
147
+ * an element no operator action in this run could make clickable. One bounded read answers both
148
+ * questions — is the row blocked by text, and is there a box to click at all — before any click.
149
+ * Native CSS only: Playwright's `:visible` throws inside `evaluate` (task 0260 AC4).
150
+ */
151
+ const REWARD_STATE = `(() => {
152
+ const rows = [
153
+ document.querySelector('.js_reward_allow_click'),
154
+ document.querySelector('.js_reward_open'),
155
+ document.querySelector('.setting-group__switch.js_reward_open'),
156
+ ].filter((el) => el !== null);
157
+ if (rows.length === 0) return null;
158
+ const blockedText = /无法开启赞赏|还没有赞赏账户|前往开通|未开通/;
159
+ for (const el of rows) {
160
+ const text = (el.textContent ?? '').replace(/\\s+/g, ' ').trim();
161
+ const box = el.getBoundingClientRect();
162
+ if (blockedText.test(text) || (box.width === 0 && box.height === 0)) {
163
+ return { clickable: false, blocked: true, text: text.slice(0, 200) };
164
+ }
165
+ }
166
+ return { clickable: true, blocked: false, text: '' };
167
+ })()`;
168
+
169
+ /** `{ clickable, blocked, text }` from REWARD_STATE; `null` when the row is absent or unreadable. */
170
+ async function readRewardState(
171
+ page: WechatPage,
172
+ ): Promise<{ clickable: boolean; blocked: boolean; text: string } | null> {
173
+ try {
174
+ const raw: unknown = await page.evaluate(REWARD_STATE);
175
+ if (typeof raw !== 'object' || raw === null) return null;
176
+ const value = raw as { clickable?: unknown; blocked?: unknown; text?: unknown };
177
+ if (typeof value.clickable !== 'boolean' || typeof value.blocked !== 'boolean') return null;
178
+ return {
179
+ clickable: value.clickable,
180
+ blocked: value.blocked,
181
+ text: typeof value.text === 'string' ? value.text : '',
182
+ };
183
+ } catch {
184
+ return null;
185
+ }
186
+ }
187
+
127
188
  /** Read a settings checkbox's committed enabled state; `null` = unobservable (never "satisfied"). */
128
189
  async function readChecked(page: WechatPage, expression: string): Promise<boolean | null> {
129
190
  try {
@@ -134,6 +195,12 @@ async function readChecked(page: WechatPage, expression: string): Promise<boolea
134
195
  }
135
196
  }
136
197
 
198
+ /** Structured enrichment result separating account capability refusals from real setting failures. */
199
+ export interface EnrichOutcome {
200
+ warnings: string[];
201
+ capabilityWarnings: string[];
202
+ }
203
+
137
204
  /**
138
205
  * Set the operator's draft metadata (原创/赞赏/合集/原文链接/创作来源) in the v2 editor.
139
206
  *
@@ -142,7 +209,13 @@ async function readChecked(page: WechatPage, expression: string): Promise<boolea
142
209
  * into warnings and surfaced in the `Result`; the draft still saves.
143
210
  */
144
211
  export async function enrichArticle(page: WechatPage, meta: Record<string, unknown>): Promise<string[]> {
212
+ return (await enrichArticleDetailed(page, meta)).warnings;
213
+ }
214
+
215
+ /** Same behavior as {@link enrichArticle}, also naming capability refusals separately. */
216
+ export async function enrichArticleDetailed(page: WechatPage, meta: Record<string, unknown>): Promise<EnrichOutcome> {
145
217
  const warnings: string[] = [];
218
+ const capabilityWarnings: string[] = [];
146
219
  const str = (key: string) => (typeof meta[key] === 'string' ? (meta[key] as string) : '');
147
220
  const on = (key: string) => meta[key] === true;
148
221
  // Sweep any leaked dialog so the next step (especially 保存为草稿) is never overlay-blocked.
@@ -201,7 +274,9 @@ export async function enrichArticle(page: WechatPage, meta: Record<string, unkno
201
274
  return 'ok';
202
275
  } catch (error) {
203
276
  if (error instanceof CapabilityError) {
204
- warnings.push(`${name}: ${error.message}`);
277
+ const msg = `${name}: ${error.message}`;
278
+ warnings.push(msg);
279
+ capabilityWarnings.push(msg);
205
280
  return 'capability';
206
281
  }
207
282
  // retry once below
@@ -239,11 +314,17 @@ export async function enrichArticle(page: WechatPage, meta: Record<string, unkno
239
314
  // then 确定. The plain-text probe the old rail used could hit the dialog heading.
240
315
  await clickSelector(page, ORIGINAL_DECLARATION, 5_000);
241
316
  // trySelectors absorbs its own probe failures (returns found:false) — no .catch here.
242
- const agreement = await trySelectors(page, [ORIGINAL_AGREEMENT]);
243
- if (agreement.found) {
244
- await clickSelector(page, ORIGINAL_AGREEMENT, 3_000);
317
+ const agreement = await trySelectors(page, ORIGINAL_AGREEMENT);
318
+ if (agreement.found && agreement.selector != null) {
319
+ await clickSelector(page, agreement.selector, 3_000);
245
320
  }
246
321
  await clickSelector(page, ORIGINAL_CONFIRM, 8_000);
322
+ // Allow async confirmation closing without calling page.evaluate (preserves mock FIFO queues).
323
+ await page
324
+ .locator(DIALOG)
325
+ .first()
326
+ .waitFor?.({ state: 'hidden', timeout: 1_500 })
327
+ .catch(() => undefined);
247
328
  });
248
329
  if (
249
330
  outcome !== 'capability' &&
@@ -259,10 +340,22 @@ export async function enrichArticle(page: WechatPage, meta: Record<string, unkno
259
340
  const name = '赞赏';
260
341
  if ((await readChecked(page, COMMITTED.reward)) !== true) {
261
342
  const outcome = await step(name, async () => {
343
+ // Measured 2026-11-20: an account without an authorized 赞赏 account renders the row
344
+ // with the refusal already in it and a 0×0 box, so opening/closing it is impossible and
345
+ // the old path spent its whole 8 s click budget proving that. Read the row first — one
346
+ // bounded evaluation, no click, no dialog wait — and report the capability in one step.
347
+ const state = await readRewardState(page);
348
+ if (state?.blocked === true) {
349
+ throw new CapabilityError(
350
+ `需要赞赏账户(本公众号未被授权,平台原文:${state.text === '' ? '无法开启赞赏' : state.text})— 运营者在平台开通后重跑,本次不请求该字段`,
351
+ );
352
+ }
262
353
  await openRow(ROW_REWARD, '赞赏');
263
- // Measured 2026-10-13: without a 赏账户 the dialog renders the 前往开通 link + a
264
- // 无法开启-style prerequisite line instead of the account field — an operator action
265
- // (开通赞赏), never a selector failure, and no retry of this run can change it.
354
+ // Measured 2026-10-13: on other builds the prerequisite line appears only inside the
355
+ // dialog, so the post-open probe stays for that shape. It stays short on purpose — the
356
+ // row-level read above is what answers the measured 2026-11-20 account, and a longer
357
+ // window here only slows every healthy run (a 4 s probe pushed the enrichment suites
358
+ // past their own step budget).
266
359
  const blocked = await tryFindSelector(
267
360
  page,
268
361
  [`${DIALOG} :has-text("前往开通")`, `${DIALOG} :has-text("无法开启")`],
@@ -331,7 +424,9 @@ export async function enrichArticle(page: WechatPage, meta: Record<string, unkno
331
424
  const urlRow =
332
425
  (await readUrl()) === norm(originalUrl) ? 'committed' : await tryFindSelector(page, ROW_URL, 2_000);
333
426
  if (urlRow === undefined) {
334
- warnings.push(`${name}: 行不存在(当前公众号不支持),请手动处理或移除 originalUrl`);
427
+ const msg = `${name}: 行不存在(当前公众号不支持),请手动处理或移除 originalUrl`;
428
+ warnings.push(msg);
429
+ capabilityWarnings.push(msg);
335
430
  } else if (urlRow !== 'committed') {
336
431
  await step(name, async () => {
337
432
  if ((await readUrl()) === norm(originalUrl)) return;
@@ -386,5 +481,14 @@ export async function enrichArticle(page: WechatPage, meta: Record<string, unkno
386
481
  }
387
482
 
388
483
  await sweep();
389
- return warnings;
484
+ // Recheck 原创声明 when subsequent settings ran: live WeChat can clear 原创 if 创作来源/合集
485
+ // resets editor state. Guarded on subsequent steps so single-setting mock queues do not shift.
486
+ const ranAfterOriginal = on('reward') || collection !== '' || originalUrl !== '' || claimSource !== '';
487
+ const hadOriginalWarning = warnings.some((w) => w.startsWith('原创声明:'));
488
+ if (on('original') && ranAfterOriginal && !hadOriginalWarning) {
489
+ if ((await readChecked(page, COMMITTED.original)) === false) {
490
+ warnings.push('原创声明: 后续设置后原创声明被重置,请核对');
491
+ }
492
+ }
493
+ return { warnings, capabilityWarnings };
390
494
  }