@gobing-ai/knowledge-kit 0.1.15 → 0.1.17

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 (116) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +1765 -40
  3. package/package.json +1 -1
  4. package/plugins/generations/content-gen/dist/index.js +58 -52
  5. package/plugins/generations/content-gen/src/storm.ts +94 -61
  6. package/plugins/generations/core-facts-gen/dist/index.js +1 -1
  7. package/plugins/generations/daily-article-gen/dist/index.js +1 -1
  8. package/plugins/generations/dailynews-gen/dist/index.js +1 -1
  9. package/plugins/generations/episode-plan-gen/dist/index.js +1 -1
  10. package/plugins/generations/gemini-tts/dist/index.js +1 -1
  11. package/plugins/generations/image-gen/README.md +31 -10
  12. package/plugins/generations/image-gen/assets/sample/cover__quasi-news-podcast.jpg +0 -0
  13. package/plugins/generations/image-gen/assets/sample/daily-news-cover__quasi-news-podcast.jpg +0 -0
  14. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__clean-webapp-ui.jpg +0 -0
  15. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__cute.jpg +0 -0
  16. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__daily-news.jpg +0 -0
  17. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__editorial.jpg +0 -0
  18. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__fresh.jpg +0 -0
  19. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__minimalist.jpg +0 -0
  20. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__photorealistic.jpg +0 -0
  21. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__quasi-news-podcast.jpg +0 -0
  22. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__sketch.jpg +0 -0
  23. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__technical-diagram.jpg +0 -0
  24. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__vibrant.jpg +0 -0
  25. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__warm.jpg +0 -0
  26. package/plugins/generations/image-gen/assets/sample/daily-news-podcast-cover__xhs-knowledge.jpg +0 -0
  27. package/plugins/generations/image-gen/assets/sample/free__quasi-news-podcast.jpg +0 -0
  28. package/plugins/generations/image-gen/assets/sample/illustration__quasi-news-podcast.jpg +0 -0
  29. package/plugins/generations/image-gen/assets/sample/xhs-card__quasi-news-podcast.jpg +0 -0
  30. package/plugins/generations/image-gen/dist/index.js +1 -1
  31. package/plugins/generations/image-gen/presets/formats/daily-news-podcast-cover.yaml +18 -0
  32. package/plugins/generations/image-gen/presets/styles/quasi-news-podcast.yaml +9 -0
  33. package/plugins/generations/news-report-gen/dist/index.js +1 -1
  34. package/plugins/generations/voice-gen/dist/index.js +1 -1
  35. package/plugins/generations/voxcpm-tts/dist/index.js +1 -1
  36. package/plugins/ingestions/aihot-ingest/dist/index.js +1 -1
  37. package/plugins/ingestions/horizon-ingest/dist/index.js +1 -1
  38. package/plugins/ingestions/last30days-ingest/dist/index.js +1 -1
  39. package/plugins/ingestions/web-search/dist/index.js +1 -1
  40. package/plugins/kk/plugin.json +1 -1
  41. package/plugins/kk/publish-presets/daily-ai-voice-migration.json +12 -3
  42. package/plugins/kk/publish-presets/daily-ai-voice.json +17 -9
  43. package/plugins/kk/publish-presets/itc-main.json +42 -0
  44. package/plugins/kk/scripts/cover-compositor.ts +198 -0
  45. package/plugins/kk/scripts/daily-cover-mock.ts +164 -0
  46. package/plugins/kk/scripts/daily-scheduled-run.ts +188 -3
  47. package/plugins/kk/scripts/daily-stages.ts +134 -26
  48. package/plugins/kk/scripts/daily-triage-core.ts +451 -0
  49. package/plugins/kk/scripts/daily-triage.ts +74 -0
  50. package/plugins/kk/scripts/itc-stages.ts +3 -2
  51. package/plugins/kk/scripts/kk-workflow-stages.ts +31 -2
  52. package/plugins/kk/scripts/voice3-publish-window.ts +5 -1
  53. package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +16 -10
  54. package/plugins/kk/skills/news-editorial/SKILL.md +3 -3
  55. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +2 -1
  56. package/plugins/kk/skills/publish/SKILL.md +1 -1
  57. package/plugins/kk/skills/wiki-authoring/SKILL.md +53 -0
  58. package/plugins/kk/skills/wiki-authoring/references/page-shapes.md +44 -0
  59. package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +3 -3
  60. package/plugins/kk/workflows/kk-daily-publish3.yaml +10 -3
  61. package/plugins/kk/workflows/kk-daily-safety.yaml +32 -7
  62. package/plugins/publishings/bilibili-pub/dist/index.js +90 -17
  63. package/plugins/publishings/bilibili-pub/dist/profile-check.js +90 -16
  64. package/plugins/publishings/cnblogs-pub/dist/index.js +90 -17
  65. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +90 -16
  66. package/plugins/publishings/csdn-pub/dist/index.js +90 -17
  67. package/plugins/publishings/csdn-pub/dist/profile-check.js +91 -17
  68. package/plugins/publishings/emdash-pub/dist/index.js +1 -1
  69. package/plugins/publishings/infoq-pub/dist/index.js +120 -19
  70. package/plugins/publishings/infoq-pub/dist/profile-check.js +95 -18
  71. package/plugins/publishings/infoq-pub/src/index.ts +40 -1
  72. package/plugins/publishings/jike-pub/dist/index.js +90 -17
  73. package/plugins/publishings/jike-pub/dist/profile-check.js +91 -17
  74. package/plugins/publishings/juejin-pub/dist/index.js +117 -20
  75. package/plugins/publishings/juejin-pub/dist/profile-check.js +94 -18
  76. package/plugins/publishings/juejin-pub/src/index.ts +41 -2
  77. package/plugins/publishings/linkedin-pub/dist/index.js +90 -17
  78. package/plugins/publishings/linkedin-pub/dist/profile-check.js +91 -17
  79. package/plugins/publishings/medium-pub/dist/index.js +1 -1
  80. package/plugins/publishings/podcast-pub/dist/index.js +1 -1
  81. package/plugins/publishings/qiita-pub/dist/index.js +1 -1
  82. package/plugins/publishings/shipinhao-pub/dist/index.js +311 -66
  83. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +138 -17
  84. package/plugins/publishings/shipinhao-pub/plugin.json +2 -2
  85. package/plugins/publishings/shipinhao-pub/src/flow.ts +335 -79
  86. package/plugins/publishings/shipinhao-pub/src/index.ts +16 -8
  87. package/plugins/publishings/shipinhao-pub/src/profile-check.ts +1 -1
  88. package/plugins/publishings/shipinhao-pub/src/selectors.ts +103 -5
  89. package/plugins/publishings/sspai-pub/dist/index.js +90 -17
  90. package/plugins/publishings/sspai-pub/dist/profile-check.js +90 -16
  91. package/plugins/publishings/substack-pub/dist/index.js +90 -17
  92. package/plugins/publishings/substack-pub/dist/profile-check.js +91 -17
  93. package/plugins/publishings/surfdash-pub/dist/index.js +244 -13
  94. package/plugins/publishings/surfdash-pub/src/index.ts +144 -8
  95. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +189 -0
  96. package/plugins/publishings/threads-pub/dist/index.js +1 -1
  97. package/plugins/publishings/wechatmp-pub/dist/index.js +186 -39
  98. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +96 -19
  99. package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +14 -2
  100. package/plugins/publishings/wechatmp-pub/src/enrich.ts +10 -3
  101. package/plugins/publishings/wechatmp-pub/src/flow.ts +158 -25
  102. package/plugins/publishings/wechatmp-pub/src/page.ts +14 -0
  103. package/plugins/publishings/wechatmp-pub/src/profile-check.ts +8 -1
  104. package/plugins/publishings/weibo-pub/dist/index.js +90 -17
  105. package/plugins/publishings/weibo-pub/dist/profile-check.js +91 -17
  106. package/plugins/publishings/x-pub/dist/index.js +90 -17
  107. package/plugins/publishings/x-pub/dist/profile-check.js +91 -17
  108. package/plugins/publishings/xhs-pub/dist/index.js +646 -47
  109. package/plugins/publishings/xhs-pub/dist/profile-check.js +109 -17
  110. package/plugins/publishings/xhs-pub/src/errors.ts +45 -0
  111. package/plugins/publishings/xhs-pub/src/flow.ts +773 -45
  112. package/plugins/publishings/xhs-pub/src/page.ts +33 -0
  113. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +90 -17
  114. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +90 -16
  115. package/plugins/publishings/zenn-pub/dist/index.js +94 -2
  116. package/plugins/publishings/zenn-pub/src/index.ts +134 -1
@@ -19905,7 +19905,7 @@ var PLATFORM_CONTENT_LIMITS = Object.freeze({
19905
19905
  shortVideo: Object.freeze({
19906
19906
  douyin: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
19907
19907
  kuaishou: Object.freeze({ max: 1000, unit: "unicode_code_points" }),
19908
- shipinhao: Object.freeze({ max: 1000, unit: "unicode_code_points" })
19908
+ shipinhao: Object.freeze({ max: 100, unit: "unicode_code_points" })
19909
19909
  })
19910
19910
  })
19911
19911
  });
@@ -20446,8 +20446,11 @@ import {
20446
20446
  mkdirSync as mkdirSync2,
20447
20447
  openSync,
20448
20448
  readdirSync as readdirSync2,
20449
+ readlinkSync,
20449
20450
  realpathSync as realpathSync2,
20450
- rmdirSync
20451
+ renameSync as renameSync2,
20452
+ rmdirSync,
20453
+ unlinkSync
20451
20454
  } from "fs";
20452
20455
  function lstat(path) {
20453
20456
  try {
@@ -20482,6 +20485,33 @@ function rmdir(path) {
20482
20485
  throw error;
20483
20486
  }
20484
20487
  }
20488
+ function readlink(path) {
20489
+ try {
20490
+ return readlinkSync(path);
20491
+ } catch {
20492
+ return null;
20493
+ }
20494
+ }
20495
+ function unlink(path) {
20496
+ try {
20497
+ unlinkSync(path);
20498
+ return true;
20499
+ } catch (error) {
20500
+ if (error.code === "ENOENT")
20501
+ return false;
20502
+ throw error;
20503
+ }
20504
+ }
20505
+ function rename(from, to) {
20506
+ try {
20507
+ renameSync2(from, to);
20508
+ return true;
20509
+ } catch (error) {
20510
+ if (error.code === "ENOENT")
20511
+ return false;
20512
+ throw error;
20513
+ }
20514
+ }
20485
20515
  function chmod(path, mode) {
20486
20516
  chmodSync(path, mode);
20487
20517
  }
@@ -20493,14 +20523,14 @@ var DEFAULT_BOT_TRANSACTION_ROOT = join2(homedir2(), ".config", "kk", "browser-t
20493
20523
 
20494
20524
  // ../../packages/publish-harness/src/profile-lease.ts
20495
20525
  import { createHash, randomBytes } from "crypto";
20496
- import { homedir as homedir3 } from "os";
20526
+ import { homedir as homedir3, hostname } from "os";
20497
20527
  import { basename, dirname as dirname3, join as join3, resolve as resolve3 } from "path";
20498
20528
  var DEFAULT_BOT_LEASE_ROOT = join3(homedir3(), ".config", "kk", "browser-leases");
20499
20529
  var KK_BOT_LEASE_PATH = "KK_BOT_LEASE_PATH";
20500
20530
  var KK_BOT_LEASE_TOKEN = "KK_BOT_LEASE_TOKEN";
20501
20531
  var OWNER_FILE = "owner.json";
20502
20532
  var HOLDER_PREFIX = "holder-";
20503
- var NATIVE_LOCK_FILES = ["SingletonLock", "SingletonSocket"];
20533
+ var NATIVE_LOCK_FILES = ["SingletonLock", "SingletonSocket", "SingletonCookie"];
20504
20534
  async function acquireProfileLease(profileDir, options = {}) {
20505
20535
  const fileSystem = options.fileSystem ?? createNodeFileSystem();
20506
20536
  const leaseRoot = options.leaseRoot ?? DEFAULT_BOT_LEASE_ROOT;
@@ -20668,6 +20698,8 @@ function isProcessAlive(pid) {
20668
20698
  }
20669
20699
  }
20670
20700
  function refuseNativeLock(profileDir) {
20701
+ if (reclaimStaleNativeLock(profileDir))
20702
+ return;
20671
20703
  for (const name of NATIVE_LOCK_FILES) {
20672
20704
  const path = join3(profileDir, name);
20673
20705
  if (lstat(path) !== null) {
@@ -20675,6 +20707,24 @@ function refuseNativeLock(profileDir) {
20675
20707
  }
20676
20708
  }
20677
20709
  }
20710
+ function reclaimStaleNativeLock(profileDir) {
20711
+ const lockPath = join3(profileDir, "SingletonLock");
20712
+ const target = readlink(lockPath);
20713
+ if (target === null)
20714
+ return false;
20715
+ const match = /^(.*)-(\d+)$/.exec(target);
20716
+ if (match === null)
20717
+ return false;
20718
+ const [, host, pidText] = match;
20719
+ if (host !== hostname())
20720
+ return false;
20721
+ const pid = Number(pidText);
20722
+ if (!Number.isInteger(pid) || pid <= 0 || isProcessAlive(pid))
20723
+ return false;
20724
+ for (const name of NATIVE_LOCK_FILES)
20725
+ unlink(join3(profileDir, name));
20726
+ return true;
20727
+ }
20678
20728
  function sha256Hex(value) {
20679
20729
  return createHash("sha256").update(value).digest("hex");
20680
20730
  }
@@ -20709,6 +20759,27 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
20709
20759
  // ../../packages/publish-harness/src/browser.ts
20710
20760
  var DEFAULT_CHECK_TIMEOUT_MS = 30000;
20711
20761
  var DEFAULT_POLL_MS = 500;
20762
+ function isInstantBrowserDeath(message) {
20763
+ return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
20764
+ }
20765
+ function classifyLaunchError(error, profileDir, channel) {
20766
+ const message = errorMessage2(error);
20767
+ if (/singleton|already in use|in use by another/i.test(message))
20768
+ return new BrowserProfileBusyError(profileDir, error);
20769
+ if (/playwright install|executable doesn't exist/i.test(message)) {
20770
+ return new PlaywrightUnavailableError(`Browser channel '${channel}' is not installed. Run \`bunx playwright install chromium\` (or install Google Chrome for KK_BROWSER_CHANNEL=chrome).`, { cause: error });
20771
+ }
20772
+ if (isInstantBrowserDeath(message)) {
20773
+ return new PlaywrightUnavailableError(`browser profile ${profileDir} makes Chromium exit during startup (no diagnostic reported). Move it aside (\`mv ${profileDir} ${profileDir}.broken-<date>\`) and log in again; \`storage-state.json\` is the only state worth keeping.`, { cause: error });
20774
+ }
20775
+ return error instanceof Error ? error : new Error(message);
20776
+ }
20777
+ function quarantineProfileSyncData(profileDir) {
20778
+ const syncData = join5(profileDir, "Default", "Sync Data");
20779
+ if (lstat(syncData) === null)
20780
+ return false;
20781
+ return rename(syncData, `${syncData}.broken-${new Date().toISOString().replace(/[:.]/g, "").slice(0, 15)}`);
20782
+ }
20712
20783
  function createKkBrowserLauncher(loadPlaywright = () => import("playwright"), ownership, leaseOptions = {}) {
20713
20784
  return {
20714
20785
  async launch(request) {
@@ -20737,23 +20808,25 @@ async function launchKkContext(loadPlaywright, profileDir, headless) {
20737
20808
  throw new PlaywrightUnavailableError('The "playwright" dependency is not installed. Run `bunx playwright install chromium`.', { cause: error });
20738
20809
  }
20739
20810
  const channel = process.env.KK_BROWSER_CHANNEL?.trim() || "chromium";
20811
+ const launch = () => playwright.chromium.launchPersistentContext(profileDir, {
20812
+ headless,
20813
+ channel,
20814
+ args: ["--disable-blink-features=AutomationControlled"],
20815
+ ignoreDefaultArgs: ["--enable-automation"]
20816
+ });
20740
20817
  let context;
20741
20818
  try {
20742
- context = await playwright.chromium.launchPersistentContext(profileDir, {
20743
- headless,
20744
- channel,
20745
- args: ["--disable-blink-features=AutomationControlled"],
20746
- ignoreDefaultArgs: ["--enable-automation"]
20747
- });
20819
+ context = await launch();
20748
20820
  } catch (error) {
20749
- const message = errorMessage2(error);
20750
- if (/singleton|already in use|in use by another/i.test(message)) {
20751
- throw new BrowserProfileBusyError(profileDir, error);
20752
- }
20753
- if (/playwright install|executable doesn't exist/i.test(message)) {
20754
- throw new PlaywrightUnavailableError(`Browser channel '${channel}' is not installed. Run \`bunx playwright install chromium\` (or install Google Chrome for KK_BROWSER_CHANNEL=chrome).`, { cause: error });
20821
+ if (!isInstantBrowserDeath(errorMessage2(error)))
20822
+ throw classifyLaunchError(error, profileDir, channel);
20823
+ if (!quarantineProfileSyncData(profileDir))
20824
+ throw classifyLaunchError(error, profileDir, channel);
20825
+ try {
20826
+ context = await launch();
20827
+ } catch (retryError) {
20828
+ throw classifyLaunchError(retryError, profileDir, channel);
20755
20829
  }
20756
- throw error;
20757
20830
  }
20758
20831
  try {
20759
20832
  await context.addInitScript(() => {
@@ -20875,7 +20948,21 @@ function errorMessage2(error) {
20875
20948
 
20876
20949
  // ../../plugins/publishings/shipinhao-pub/src/selectors.ts
20877
20950
  var SHP_TARGET = "shipinhao";
20878
- var SHP_HOME_URL = "https://channels.weixin.qq.com/platform/post/video";
20951
+ var SHP_HOME_URL = "https://channels.weixin.qq.com/platform";
20952
+ var SHP_OPERATION_NAMES = ["shortVideo", "audio", "image", "music"];
20953
+ var SHP_CREATE_ENTRY_SELECTORS = ['button:text-is("\u53D1\u8868\u89C6\u9891")'];
20954
+ var SHP_DESCRIPTION_MAX_CHARS = 100;
20955
+ var SHP_DRAFT_CONFIRM_DIALOG_TEXT = "\u4F7F\u7528\u5B9A\u65F6\u53D1\u8868\u5C06\u65E0\u6CD5\u4FDD\u5B58\u8349\u7A3F";
20956
+ var SHP_DRAFT_CONFIRM_PROCEED_LABEL = "\u4FDD\u5B58";
20957
+ var SHP_AUDIO_HOME_URL = SHP_HOME_URL;
20958
+ var SHP_IMAGE_HOME_URL = SHP_HOME_URL;
20959
+ var SHP_MUSIC_HOME_URL = SHP_HOME_URL;
20960
+ var SHP_HOME_URL_BY_OPERATION = {
20961
+ shortVideo: SHP_HOME_URL,
20962
+ audio: SHP_AUDIO_HOME_URL,
20963
+ image: SHP_IMAGE_HOME_URL,
20964
+ music: SHP_MUSIC_HOME_URL
20965
+ };
20879
20966
  var SHP_LOGIN_URL_RE = /(open\.weixin\.qq\.com|channels\.weixin\.qq\.com\/platform\/(login|scan))/;
20880
20967
  var ROOT_SNAPSHOT_SCRIPT = `(() => { // kk-shp-root-snapshot
20881
20968
  const wujieApp = document.querySelector('wujie-app');
@@ -20912,6 +20999,7 @@ async function readRootSnapshot(page) {
20912
20999
  var SHP_ROOT_WAIT_MS = 30000;
20913
21000
  var SHP_COVER_SAVE_WAIT_MS = 60000;
20914
21001
  var SHP_VIDEO_SELECTORS = {
21002
+ createEntry: SHP_CREATE_ENTRY_SELECTORS,
20915
21003
  videoInput: [
20916
21004
  'input[type="file"][accept*="video"]',
20917
21005
  'input[type="file"][accept*=".mp4"]',
@@ -20942,9 +21030,26 @@ var SHP_VIDEO_SELECTORS = {
20942
21030
  saveButton: ['button:text-is("\u4FDD\u5B58\u8349\u7A3F")'],
20943
21031
  publishButton: ['button:text-is("\u53D1\u8868")', '[role="button"]:text-is("\u53D1\u8868")']
20944
21032
  };
21033
+ var SHP_AUDIO_SELECTORS = {
21034
+ ...SHP_VIDEO_SELECTORS,
21035
+ audioInput: ['input[type="file"][accept*="video"]', 'input[type="file"]']
21036
+ };
21037
+ var SHP_MUSIC_SELECTORS = { ...SHP_AUDIO_SELECTORS };
21038
+ var SHP_IMAGE_SELECTORS = {
21039
+ ...SHP_VIDEO_SELECTORS,
21040
+ imagesInput: [
21041
+ 'input[type="file"][multiple]',
21042
+ 'input[type="file"][accept*="image"]',
21043
+ 'section:has(input[type="file"]):has-text("\u4E0A\u4F20\u56FE\u7247") input[type="file"]',
21044
+ 'input[type="file"]'
21045
+ ]
21046
+ };
20945
21047
  var SHP_RECEIPT_URL_RES = [
20946
21048
  /channels\.weixin\.qq\.com\/platform\/record\/detail\/[0-9a-zA-Z_-]+/,
20947
- /channels\.weixin\.qq\.com\/platform\/post\/video\/[0-9a-zA-Z_-]+/
21049
+ /channels\.weixin\.qq\.com\/platform\/post\/video\/[0-9a-zA-Z_-]+/,
21050
+ /channels\.weixin\.qq\.com\/platform\/post\/audio\/[0-9a-zA-Z_-]+/,
21051
+ /channels\.weixin\.qq\.com\/platform\/post\/image\/[0-9a-zA-Z_-]+/,
21052
+ /channels\.weixin\.qq\.com\/platform\/post\/music\/[0-9a-zA-Z_-]+/
20948
21053
  ];
20949
21054
  var SHP_UPLOAD_TIMEOUT_MS = 600000;
20950
21055
  var SHP_LOGIN_TIMEOUT_MS = 180000;
@@ -20998,6 +21103,20 @@ function needsLogin(error) {
20998
21103
  function normalizeText(value) {
20999
21104
  return value.replace(/\s+/g, "");
21000
21105
  }
21106
+ function htmlToPlainText(html) {
21107
+ return html.replace(/<\/(p|h[1-6]|li|blockquote|div)>/gi, `
21108
+ `).replace(/<br\s*\/?>/gi, `
21109
+ `).replace(/<[^>]+>/g, "").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").trim();
21110
+ }
21111
+ function buildShipinhaoDescription(body, tags) {
21112
+ const bodyPlain = htmlToPlainText(sanitizeShipinhaoHtml(markdownToHtml(body)));
21113
+ const topicLine = tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ");
21114
+ const budget = SHP_DESCRIPTION_MAX_CHARS - (tags.length > 0 ? Array.from(topicLine).length + 1 : 0);
21115
+ const clipped = Array.from(bodyPlain).slice(0, Math.max(budget, 0)).join("").trim();
21116
+ const description = tags.length > 0 ? `${clipped}
21117
+ ${topicLine}` : clipped;
21118
+ return { description, html: sanitizeShipinhaoHtml(markdownToHtml(description)) };
21119
+ }
21001
21120
  function sanitizeShipinhaoHtml(html) {
21002
21121
  return html.replace(/<\s*(script|style|iframe|embed|object)\b[\s\S]*?<\s*\/\s*\1\s*>/gi, "").replace(/<\s*(script|style|iframe|embed|object)\b[^>]*>/gi, "").replace(/\son[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, "").replace(/(\s(?:href|src)\s*=\s*)(["'])\s*(?:javascript|data):[^"']*\2/gi, "$1$2$2").replace(/(\s(?:href|src)\s*=\s*)(?:javascript|data):[^\s>]*/gi, '$1""');
21003
21122
  }
@@ -21092,6 +21211,34 @@ function editorTextScript(mode, selector) {
21092
21211
  return el === null ? '' : String(el.innerText ?? el.textContent ?? '');
21093
21212
  })()`;
21094
21213
  }
21214
+ function draftConfirmClickScript(mode) {
21215
+ return `${rootScriptPrefix(mode)} // kk-shp-draft-confirm
21216
+ const mark = ${JSON.stringify(SHP_DRAFT_CONFIRM_DIALOG_TEXT)};
21217
+ const proceed = ${JSON.stringify(SHP_DRAFT_CONFIRM_PROCEED_LABEL)};
21218
+ for (const scope of [document, root]) {
21219
+ if (!scope) continue;
21220
+ // Anchor from the button side: the dialog text repeats across nested toast/dialog spans and
21221
+ // the last text-bearing element is a leaf without buttons (Grounded live probe 2026-11-11).
21222
+ for (const button of scope.querySelectorAll('button')) {
21223
+ if (String(button.textContent || '').trim() !== proceed || button.disabled) continue;
21224
+ // Only click a genuinely rendered dialog button: the vendor ships this dialog as a
21225
+ // permanently hidden 0\xD70 template inside the form (Grounded live probe 2026-11-11) \u2014
21226
+ // clicking the hidden copy is a silent no-op that would otherwise satisfy the rail.
21227
+ const rect = button.getBoundingClientRect();
21228
+ if (!(rect.width > 0 && rect.height > 0)) continue;
21229
+ let ancestor = button;
21230
+ for (let depth = 0; depth < 6 && ancestor; depth++) {
21231
+ if (String(ancestor.textContent || '').includes(mark)) {
21232
+ button.click();
21233
+ return JSON.stringify({ ok: true });
21234
+ }
21235
+ ancestor = ancestor.parentElement;
21236
+ }
21237
+ }
21238
+ }
21239
+ return JSON.stringify({ ok: false, reason: 'absent' });
21240
+ })()`;
21241
+ }
21095
21242
  async function readReceiptUrls(page) {
21096
21243
  const raw = await page.evaluate(`(() => { // kk-shp-receipt-urls
21097
21244
  const patterns = [${SHP_RECEIPT_URL_RES.map((re) => re.toString()).join(", ")}];
@@ -21114,30 +21261,71 @@ async function readReceiptUrls(page) {
21114
21261
  }
21115
21262
  }
21116
21263
  function receiptIdFrom(url) {
21117
- return /\/(?:detail|video)\/([0-9a-zA-Z_-]+)/.exec(url)?.[1];
21264
+ return /\/(?:detail|video|audio|image|music)\/([0-9a-zA-Z_-]+)/.exec(url)?.[1];
21118
21265
  }
21119
- async function resolveVideoPath(raw) {
21266
+ async function resolveMediaPath(raw, spec) {
21120
21267
  if (typeof raw !== "string" || raw.trim().length === 0) {
21121
- return { error: `metadata.videoPath must be a non-empty local video file path, got '${bounded(raw)}'` };
21268
+ return {
21269
+ error: `metadata.${spec.field} must be a non-empty local ${spec.kindLabel} file path, got '${bounded(raw)}'`
21270
+ };
21122
21271
  }
21123
21272
  const path = raw.trim();
21124
- if (!/\.(mp4|mov)$/i.test(path)) {
21273
+ if (!spec.extRe.test(path)) {
21125
21274
  return {
21126
- error: `metadata.videoPath must be a local MP4/MOV file, got unsupported extension in '${bounded(path)}'`
21275
+ error: `metadata.${spec.field} must be a local ${spec.extLabel} file, got unsupported extension in '${bounded(path)}'`
21127
21276
  };
21128
21277
  }
21129
21278
  const file = Bun.file(path);
21130
21279
  const readable = await file.exists().catch(() => false);
21131
21280
  if (!readable || file.size === 0) {
21132
- return { error: "metadata.videoPath does not resolve to a readable nonempty local video file" };
21281
+ return {
21282
+ error: `metadata.${spec.field} does not resolve to a readable nonempty local ${spec.kindLabel} file`
21283
+ };
21133
21284
  }
21134
21285
  if (file.size > MAX_VIDEO_BYTES) {
21135
21286
  return {
21136
- error: `metadata.videoPath exceeds the KK v1 local video cap of 2 GiB (${file.size} bytes; a local product bound, not a platform limit)`
21287
+ error: `metadata.${spec.field} exceeds the KK v1 local ${spec.kindLabel} cap of 2 GiB (${file.size} bytes; a local product bound, not a platform limit)`
21137
21288
  };
21138
21289
  }
21139
21290
  return { path };
21140
21291
  }
21292
+ function resolveVideoPath(raw) {
21293
+ return resolveMediaPath(raw, {
21294
+ field: "videoPath",
21295
+ kindLabel: "video",
21296
+ extLabel: "MP4/MOV",
21297
+ extRe: /\.(mp4|mov)$/i
21298
+ });
21299
+ }
21300
+ function resolveAudioPath(raw) {
21301
+ return resolveMediaPath(raw, {
21302
+ field: "audio (or audioFile)",
21303
+ kindLabel: "audio",
21304
+ extLabel: "MP3/M4A/WAV/AAC/FLAC",
21305
+ extRe: /\.(mp3|m4a|wav|aac|flac)$/i
21306
+ });
21307
+ }
21308
+ async function resolveImagesPath(raw) {
21309
+ if (!Array.isArray(raw) || raw.length === 0) {
21310
+ return {
21311
+ error: `metadata.images must be a non-empty array of local image file paths, got '${bounded(raw)}'`
21312
+ };
21313
+ }
21314
+ const paths = [];
21315
+ for (const entry of raw) {
21316
+ const candidate = typeof entry === "object" && entry !== null && "path" in entry ? entry.path : entry;
21317
+ const one = await resolveMediaPath(candidate, {
21318
+ field: "images[]",
21319
+ kindLabel: "image",
21320
+ extLabel: "PNG/JPEG/WebP",
21321
+ extRe: /\.(png|jpe?g|webp)$/i
21322
+ });
21323
+ if (one.error !== undefined)
21324
+ return { error: one.error };
21325
+ paths.push(one.path);
21326
+ }
21327
+ return { paths };
21328
+ }
21141
21329
  async function resolveCoverPath(raw) {
21142
21330
  if (raw === undefined)
21143
21331
  return {};
@@ -21182,21 +21370,33 @@ function resolveOriginal(raw) {
21182
21370
  }
21183
21371
  return { original: raw };
21184
21372
  }
21185
- function unsupportedFields(payload) {
21373
+ function unsupportedFields(payload, operation) {
21374
+ const perOperation = {
21375
+ shortVideo: ["images", "categories", "publishTime", "scheduling"],
21376
+ audio: ["videoPath", "images", "categories", "publishTime", "scheduling"],
21377
+ music: ["videoPath", "images", "categories", "publishTime", "scheduling"],
21378
+ image: ["videoPath", "coverPath", "categories", "publishTime", "scheduling"]
21379
+ };
21186
21380
  const refused = [];
21187
- for (const [container, keys] of [
21188
- ["options", ["images", "categories", "publishTime", "scheduling"]],
21189
- ["metadata", ["images", "categories", "publishTime", "scheduling"]]
21381
+ for (const [container, source] of [
21382
+ ["options", payload.options],
21383
+ ["metadata", payload.content.metadata]
21190
21384
  ]) {
21191
- const source = container === "options" ? payload.options : payload.content.metadata;
21192
- for (const key of keys) {
21193
- if (source !== undefined && source !== null && typeof source === "object" && key in source) {
21385
+ if (source === undefined || source === null || typeof source !== "object")
21386
+ continue;
21387
+ for (const key of perOperation[operation]) {
21388
+ if (key in source)
21194
21389
  refused.push(`${container}.${key}`);
21195
- }
21196
21390
  }
21197
21391
  }
21198
21392
  return refused;
21199
21393
  }
21394
+ var POST_FLOW_SPECS = {
21395
+ shortVideo: { selectors: SHP_VIDEO_SELECTORS, fileSelectors: SHP_VIDEO_SELECTORS.videoInput, mediaLabel: "video" },
21396
+ audio: { selectors: SHP_AUDIO_SELECTORS, fileSelectors: SHP_AUDIO_SELECTORS.audioInput, mediaLabel: "audio" },
21397
+ music: { selectors: SHP_MUSIC_SELECTORS, fileSelectors: SHP_MUSIC_SELECTORS.audioInput, mediaLabel: "music" },
21398
+ image: { selectors: SHP_IMAGE_SELECTORS, fileSelectors: SHP_IMAGE_SELECTORS.imagesInput, mediaLabel: "image" }
21399
+ };
21200
21400
  function editingFormReadyScript(mode, titleSelector, editorSelector) {
21201
21401
  return `${rootScriptPrefix(mode)}
21202
21402
  const title = root === null ? null : root.querySelector(${JSON.stringify(titleSelector)});
@@ -21357,32 +21557,53 @@ class ShipinhaoBrowserTransport {
21357
21557
  if (requested !== undefined && requested !== "draft" && requested !== "public") {
21358
21558
  return fail(SHP_TARGET, `unknown publishStatus '${bounded(requested)}' for ${SHP_TARGET}: expected 'draft', 'public' or absent (absent defaults to draft)`);
21359
21559
  }
21360
- if (payload.content.format !== "video") {
21560
+ if (this.operation === "shortVideo" && payload.content.format !== "video") {
21361
21561
  return fail(SHP_TARGET, `shipinhao shortVideo requires Content.format 'video', got '${bounded(payload.content.format)}'`);
21362
21562
  }
21363
21563
  const title = payload.content.title?.trim() ?? "";
21364
21564
  if (title.length === 0) {
21365
- return fail(SHP_TARGET, "shipinhao shortVideo requires a non-empty Content.title (the \u77ED\u6807\u9898 input, shipinhao.js:638-654)");
21565
+ return fail(SHP_TARGET, `shipinhao ${this.operation} requires a non-empty Content.title (the \u77ED\u6807\u9898 input, shipinhao.js:638-654)`);
21366
21566
  }
21367
21567
  const body = payload.content.body.trim();
21368
21568
  if (body.length === 0) {
21369
- return fail(SHP_TARGET, "shipinhao shortVideo requires non-empty Content.body Markdown (the \u6DFB\u52A0\u63CF\u8FF0 description is pasted as sanitized text/html, shipinhao.js:669-674)");
21370
- }
21371
- const video = await resolveVideoPath(payload.content.metadata?.videoPath);
21372
- if (video.error !== undefined)
21373
- return fail(SHP_TARGET, video.error);
21374
- const cover = await resolveCoverPath(payload.content.metadata?.coverPath ?? payload.options?.coverPath);
21375
- if (cover.error !== undefined)
21376
- return fail(SHP_TARGET, cover.error);
21569
+ return fail(SHP_TARGET, `shipinhao ${this.operation} requires non-empty Content.body Markdown (the \u6DFB\u52A0\u63CF\u8FF0 description is pasted as sanitized text/html, shipinhao.js:669-674)`);
21570
+ }
21571
+ const metadataRecord = payload.content.metadata ?? {};
21572
+ let media;
21573
+ let coverPath;
21574
+ if (this.operation === "shortVideo") {
21575
+ const video = await resolveVideoPath(metadataRecord.videoPath);
21576
+ if (video.error !== undefined)
21577
+ return fail(SHP_TARGET, video.error);
21578
+ media = [video.path];
21579
+ const cover = await resolveCoverPath(payload.content.metadata?.coverPath ?? payload.options?.coverPath);
21580
+ if (cover.error !== undefined)
21581
+ return fail(SHP_TARGET, cover.error);
21582
+ coverPath = cover.path;
21583
+ } else if (this.operation === "audio" || this.operation === "music") {
21584
+ const audio = await resolveAudioPath(metadataRecord.audio ?? metadataRecord.audioFile);
21585
+ if (audio.error !== undefined)
21586
+ return fail(SHP_TARGET, audio.error);
21587
+ media = [audio.path];
21588
+ const cover = await resolveCoverPath(payload.content.metadata?.coverPath ?? payload.options?.coverPath);
21589
+ if (cover.error !== undefined)
21590
+ return fail(SHP_TARGET, cover.error);
21591
+ coverPath = cover.path;
21592
+ } else {
21593
+ const images = await resolveImagesPath(metadataRecord.images);
21594
+ if (images.error !== undefined)
21595
+ return fail(SHP_TARGET, images.error);
21596
+ media = images.paths;
21597
+ }
21377
21598
  const tags = resolveTags(payload.content.metadata?.tags ?? payload.options?.tags);
21378
21599
  if (tags.error !== undefined)
21379
21600
  return fail(SHP_TARGET, tags.error);
21380
21601
  const original = resolveOriginal(payload.content.metadata?.original);
21381
21602
  if (original.error !== undefined)
21382
21603
  return fail(SHP_TARGET, original.error);
21383
- const unsupported = unsupportedFields(payload);
21604
+ const unsupported = unsupportedFields(payload, this.operation);
21384
21605
  if (unsupported.length > 0) {
21385
- return fail(SHP_TARGET, `unsupported field(s) ${unsupported.join(", ")} for shipinhao: this flow implements title/description/tags/video/cover/original declaration only, and scheduling/publishTime is an unported vendor enhancement (shipinhao.js:7-9)`);
21606
+ return fail(SHP_TARGET, `unsupported field(s) ${unsupported.join(", ")} for shipinhao ${this.operation}: implemented fields are title/description/tags/media/cover/original declaration only, and scheduling/publishTime is an unported vendor enhancement (shipinhao.js:7-9)`);
21386
21607
  }
21387
21608
  const override = typeof payload.options?.profileDir === "string" ? payload.options.profileDir : undefined;
21388
21609
  const profileDir = resolveChannelProfileDir(SHP_TARGET, override);
@@ -21398,18 +21619,18 @@ class ShipinhaoBrowserTransport {
21398
21619
  try {
21399
21620
  return await withProfilePage({
21400
21621
  profileDir,
21401
- url: SHP_HOME_URL,
21622
+ url: SHP_HOME_URL_BY_OPERATION[this.operation],
21402
21623
  isAuthenticated: isShipinhaoAuthenticated,
21403
21624
  headless: payload.options?.headless === true,
21404
21625
  launcher: this.launcher,
21405
21626
  timeoutMs: this.stepTimeoutMs
21406
- }, async ({ page }) => this.runShortVideoFlow(page, title, body, tags.tags, original.original === true, video.path, cover.path, requested === "public", profileDir));
21627
+ }, async ({ page }) => this.runPostFlow(page, POST_FLOW_SPECS[this.operation], title, body, tags.tags, original.original === true, media, coverPath, requested === "public", profileDir));
21407
21628
  } catch (error) {
21408
21629
  const detail = errorMessage3(error);
21409
21630
  return fail(SHP_TARGET, needsLogin(error) ? `${SHP_TARGET} session failed \u2014 run: ${SHP_LOGIN_INSTRUCTION} \u2014 detail: ${detail}` : detail);
21410
21631
  }
21411
21632
  }
21412
- async runShortVideoFlow(page, title, body, tags, declareOriginal, videoPath, coverPath, publishPublic, profileDir) {
21633
+ async runPostFlow(page, spec, title, body, tags, declareOriginal, media, coverPath, publishPublic, profileDir) {
21413
21634
  const publishStatus = publishPublic ? "public" : "draft";
21414
21635
  const metadata = {
21415
21636
  operation: this.operation,
@@ -21418,36 +21639,56 @@ class ShipinhaoBrowserTransport {
21418
21639
  profileDir,
21419
21640
  ...declareOriginal ? { original: true } : {}
21420
21641
  };
21642
+ const entrySnapshot = await readRootSnapshot(page);
21643
+ if (entrySnapshot.shadowFileInputs + entrySnapshot.directFileInputs === 0) {
21644
+ const entryRoot = await resolveCreatorRoot(page);
21645
+ if (entryRoot.error !== undefined)
21646
+ return stageFail(SHP_TARGET, entryRoot.error, "root-resolve", metadata);
21647
+ try {
21648
+ const entry = (await resolveRootLocator(page, entryRoot.mode, spec.selectors.createEntry, "shipinhao create entry", this.stepTimeoutMs)).locator;
21649
+ await entry.click();
21650
+ } catch (error) {
21651
+ return stageFail(SHP_TARGET, `shipinhao create entry click failed \u2014 ${errorMessage3(error)}`, "entry-open", metadata);
21652
+ }
21653
+ const opened = await expectOutcome(async () => {
21654
+ const snapshot = await readRootSnapshot(page);
21655
+ return snapshot.shadowFileInputs + snapshot.directFileInputs > 0 ? "create surface open" : null;
21656
+ }, { timeoutMs: this.stepTimeoutMs, label: "shipinhao create surface" });
21657
+ if (!opened.ok)
21658
+ return stageFail(SHP_TARGET, `shipinhao create surface never opened after the entry click \u2014 no media file input appeared in the active root \u2014 ${opened.error}`, "entry-open", metadata);
21659
+ }
21421
21660
  const root = await resolveCreatorRoot(page);
21422
21661
  if (root.error !== undefined)
21423
21662
  return stageFail(SHP_TARGET, root.error, "root-resolve", metadata);
21424
21663
  const mode = root.mode;
21425
21664
  try {
21426
- const resolved = await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.videoInput, "shipinhao video file input", this.stepTimeoutMs);
21665
+ const resolved = await resolveRootLocator(page, mode, spec.fileSelectors, `shipinhao ${spec.mediaLabel} file input`, this.stepTimeoutMs);
21427
21666
  if (resolved.selector === 'input[type="file"]' && await resolved.locator.count() !== 1) {
21428
- return stageFail(SHP_TARGET, `shipinhao video file input ambiguous: the untyped input[type=file] candidate matched more than one input in the ${mode === "wujie" ? "wujie shadowRoot" : "document"} root \u2014 the vendor resolves a unique untyped input or nothing (shipinhao.js:580-583)`, "root-resolve", metadata);
21667
+ return stageFail(SHP_TARGET, `shipinhao ${spec.mediaLabel} file input ambiguous: the untyped input[type=file] candidate matched more than one input in the ${mode === "wujie" ? "wujie shadowRoot" : "document"} root \u2014 the vendor resolves a unique untyped input or nothing (shipinhao.js:580-583)`, "root-resolve", metadata);
21429
21668
  }
21430
- await resolved.locator.setInputFiles(videoPath, { timeout: this.stepTimeoutMs });
21669
+ await resolved.locator.setInputFiles(media.length === 1 ? media[0] : media, {
21670
+ timeout: this.stepTimeoutMs
21671
+ });
21431
21672
  } catch (error) {
21432
- return stageFail(SHP_TARGET, `shipinhao video file input/attach failed on ${page.url()}: ${errorMessage3(error)}`, "upload-timeout", metadata);
21673
+ return stageFail(SHP_TARGET, `shipinhao ${spec.mediaLabel} file input/attach failed on ${page.url()}: ${errorMessage3(error)}`, "upload-timeout", metadata);
21433
21674
  }
21434
21675
  let titleSelector;
21435
21676
  let editorSelector;
21436
21677
  try {
21437
- titleSelector = (await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.titleInput, "shipinhao title input", this.stepTimeoutMs)).selector;
21438
- editorSelector = (await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.descriptionEditor, "shipinhao description editor", this.stepTimeoutMs)).selector;
21678
+ titleSelector = (await resolveRootLocator(page, mode, spec.selectors.titleInput, "shipinhao title input", this.stepTimeoutMs)).selector;
21679
+ editorSelector = (await resolveRootLocator(page, mode, spec.selectors.descriptionEditor, "shipinhao description editor", this.stepTimeoutMs)).selector;
21439
21680
  } catch (error) {
21440
- return stageFail(SHP_TARGET, `shipinhao media processing not confirmed: the file was assigned but the post-upload editing form never appeared \u2014 ${errorMessage3(error)}; refusing to claim an uploaded video`, "upload-processing", metadata);
21681
+ return stageFail(SHP_TARGET, `shipinhao media processing not confirmed: the file was assigned but the post-upload editing form never appeared \u2014 ${errorMessage3(error)}; refusing to claim an uploaded ${spec.mediaLabel}`, "upload-processing", metadata);
21441
21682
  }
21442
21683
  const formReady = await expectOutcome(async () => {
21443
21684
  const raw = String(await page.evaluate(editingFormReadyScript(mode, titleSelector, editorSelector)));
21444
21685
  return JSON.parse(raw).ready === true ? "editing form observed in the active root" : null;
21445
21686
  }, { timeoutMs: SHP_UPLOAD_TIMEOUT_MS, label: "shipinhao media processing" });
21446
21687
  if (!formReady.ok) {
21447
- return stageFail(SHP_TARGET, `shipinhao media processing not confirmed within the ${SHP_UPLOAD_TIMEOUT_MS}ms ceiling \u2014 the file was assigned but no editing form appeared; refusing to claim an uploaded video`, "upload-processing", metadata);
21688
+ return stageFail(SHP_TARGET, `shipinhao media processing not confirmed within the ${SHP_UPLOAD_TIMEOUT_MS}ms ceiling \u2014 the file was assigned but no editing form appeared; refusing to claim an uploaded ${spec.mediaLabel}`, "upload-processing", metadata);
21448
21689
  }
21449
21690
  try {
21450
- const titleInput = (await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.titleInput, "shipinhao title input", this.stepTimeoutMs)).locator;
21691
+ const titleInput = (await resolveRootLocator(page, mode, spec.selectors.titleInput, "shipinhao title input", this.stepTimeoutMs)).locator;
21451
21692
  await titleInput.fill(title);
21452
21693
  const readback = await expectOutcome(async () => normalizeText(String(await page.evaluate(titleValueScript(mode, titleSelector)))) === normalizeText(title) ? "title read back" : null, { timeoutMs: this.stepTimeoutMs, label: "shipinhao title readback" });
21453
21694
  if (!readback.ok)
@@ -21455,15 +21696,13 @@ class ShipinhaoBrowserTransport {
21455
21696
  } catch (error) {
21456
21697
  return stageFail(SHP_TARGET, `shipinhao title fill failed \u2014 ${errorMessage3(error)}`, "title-readback", metadata);
21457
21698
  }
21458
- const html = sanitizeShipinhaoHtml(markdownToHtml(tags.length === 0 ? body : `${body}
21459
-
21460
- ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21699
+ const { description, html } = buildShipinhaoDescription(body, tags);
21461
21700
  try {
21462
- const editorSelector = (await resolveRootLocator(page, mode, SHP_VIDEO_SELECTORS.descriptionEditor, "shipinhao description editor", this.stepTimeoutMs)).selector;
21701
+ const editorSelector = (await resolveRootLocator(page, mode, spec.selectors.descriptionEditor, "shipinhao description editor", this.stepTimeoutMs)).selector;
21463
21702
  await pasteRichText(page, mode, editorSelector, html);
21464
21703
  const readback = await expectOutcome(async () => {
21465
21704
  const editorText = String(await page.evaluate(editorTextScript(mode, editorSelector)));
21466
- return editorText.length > 0 && normalizeText(editorText).includes(normalizeText(body)) && tags.every((tag) => editorText.includes(`#${tag.replace(/^#/, "")}`)) ? "description and topics read back" : null;
21705
+ return editorText.length > 0 && normalizeText(editorText).includes(normalizeText(description)) && tags.every((tag) => editorText.includes(`#${tag.replace(/^#/, "")}`)) ? "description and topics read back" : null;
21467
21706
  }, { timeoutMs: this.stepTimeoutMs, label: "shipinhao description paste readback" });
21468
21707
  if (!readback.ok)
21469
21708
  return stageFail(SHP_TARGET, `shipinhao description readback failed \u2014 the editor did not retain the pasted description/topics \u2014 ${readback.error}`, "description-paste-readback", metadata);
@@ -21481,7 +21720,7 @@ ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21481
21720
  return coverOutcome;
21482
21721
  }
21483
21722
  const stage = publishPublic ? "publish-click" : "draft-save";
21484
- const submitSelectors = publishPublic ? SHP_VIDEO_SELECTORS.publishButton : SHP_VIDEO_SELECTORS.saveButton;
21723
+ const submitSelectors = publishPublic ? spec.selectors.publishButton : spec.selectors.saveButton;
21485
21724
  let submitLocator;
21486
21725
  try {
21487
21726
  const resolved = await resolveRootLocator(page, mode, submitSelectors, "shipinhao submit control", this.stepTimeoutMs);
@@ -21503,6 +21742,12 @@ ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21503
21742
  const beforeReceipts = new Set(await readReceiptUrls(page));
21504
21743
  await submitLocator.click();
21505
21744
  const confirmed = await expectOutcome(async () => {
21745
+ if (!publishPublic) {
21746
+ const confirmRaw = String(await page.evaluate(draftConfirmClickScript(mode)));
21747
+ const confirm = JSON.parse(confirmRaw);
21748
+ if (confirm.ok)
21749
+ return null;
21750
+ }
21506
21751
  const fresh = (await readReceiptUrls(page)).filter((candidate) => !beforeReceipts.has(candidate));
21507
21752
  if (fresh.length === 0)
21508
21753
  return null;
@@ -21536,7 +21781,7 @@ ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21536
21781
  target: SHP_TARGET,
21537
21782
  id: receiptIdFrom(url),
21538
21783
  url,
21539
- message: `shipinhao shortVideo ${publishStatus} confirmed in profile ${profileDir}`,
21784
+ message: `shipinhao ${this.operation} ${publishStatus} confirmed in profile ${profileDir}`,
21540
21785
  metadata: { ...metadata, confirmedBy: receiptStage }
21541
21786
  });
21542
21787
  }
@@ -21629,7 +21874,7 @@ ${tags.map((tag) => `#${tag.replace(/^#/, "")}`).join(" ")}`));
21629
21874
  }
21630
21875
 
21631
21876
  // ../../plugins/publishings/shipinhao-pub/src/index.ts
21632
- var SHP_OPERATIONS = ["shortVideo"];
21877
+ var SHP_OPERATIONS = SHP_OPERATION_NAMES;
21633
21878
  function resolveOperation(options, content) {
21634
21879
  const raw = options?.operation ?? content?.metadata?.operation ?? "shortVideo";
21635
21880
  if (typeof raw !== "string" || !SHP_OPERATIONS.includes(raw)) {