@gobing-ai/knowledge-kit 0.1.10 → 0.1.11

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 (46) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +128 -25
  3. package/package.json +1 -1
  4. package/plugins/kk/plugin.json +1 -1
  5. package/plugins/kk/scripts/daily-scheduled-run.ts +298 -0
  6. package/plugins/kk/scripts/daily-stages.ts +1057 -108
  7. package/plugins/kk/scripts/kk-workflow-stages.ts +76 -10
  8. package/plugins/kk/scripts/safety-artifact-check.ts +235 -0
  9. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +168 -121
  10. package/plugins/kk/workflows/kk-daily-safety.yaml +129 -50
  11. package/plugins/publishings/bilibili-pub/dist/index.js +2 -1
  12. package/plugins/publishings/bilibili-pub/dist/profile-check.js +2 -1
  13. package/plugins/publishings/cnblogs-pub/dist/index.js +2 -1
  14. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +2 -1
  15. package/plugins/publishings/csdn-pub/dist/index.js +2 -1
  16. package/plugins/publishings/csdn-pub/dist/profile-check.js +2 -1
  17. package/plugins/publishings/infoq-pub/dist/index.js +2 -1
  18. package/plugins/publishings/infoq-pub/dist/profile-check.js +2 -1
  19. package/plugins/publishings/jike-pub/dist/index.js +2 -1
  20. package/plugins/publishings/jike-pub/dist/profile-check.js +2 -1
  21. package/plugins/publishings/juejin-pub/dist/index.js +2 -1
  22. package/plugins/publishings/juejin-pub/dist/profile-check.js +2 -1
  23. package/plugins/publishings/podcast-pub/dist/index.js +46 -8
  24. package/plugins/publishings/podcast-pub/src/index.ts +62 -5
  25. package/plugins/publishings/shipinhao-pub/dist/index.js +2 -1
  26. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +2 -1
  27. package/plugins/publishings/sspai-pub/dist/index.js +2 -1
  28. package/plugins/publishings/sspai-pub/dist/profile-check.js +2 -1
  29. package/plugins/publishings/substack-pub/dist/index.js +2 -1
  30. package/plugins/publishings/substack-pub/dist/profile-check.js +2 -1
  31. package/plugins/publishings/surfdash-pub/dist/index.js +460 -52
  32. package/plugins/publishings/surfdash-pub/src/digest-check.ts +85 -19
  33. package/plugins/publishings/surfdash-pub/src/index.ts +589 -64
  34. package/plugins/publishings/wechatmp-pub/dist/index.js +933 -98
  35. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +60 -3
  36. package/plugins/publishings/wechatmp-pub/src/flow.ts +1125 -85
  37. package/plugins/publishings/wechatmp-pub/src/index.ts +112 -30
  38. package/plugins/publishings/wechatmp-pub/src/page.ts +105 -0
  39. package/plugins/publishings/weibo-pub/dist/index.js +2 -1
  40. package/plugins/publishings/weibo-pub/dist/profile-check.js +2 -1
  41. package/plugins/publishings/x-pub/dist/index.js +2 -1
  42. package/plugins/publishings/x-pub/dist/profile-check.js +2 -1
  43. package/plugins/publishings/xhs-pub/dist/index.js +2 -1
  44. package/plugins/publishings/xhs-pub/dist/profile-check.js +2 -1
  45. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +2 -1
  46. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +2 -1
@@ -20026,9 +20026,11 @@ import { isAbsolute, join as join3, relative, resolve as resolve3, sep } from "p
20026
20026
  // ../../packages/publish-harness/src/bot-fs.ts
20027
20027
  import {
20028
20028
  chmodSync,
20029
+ closeSync,
20029
20030
  copyFileSync,
20030
20031
  lstatSync,
20031
20032
  mkdirSync as mkdirSync2,
20033
+ openSync,
20032
20034
  readdirSync as readdirSync2,
20033
20035
  realpathSync as realpathSync2,
20034
20036
  rmdirSync
@@ -20069,6 +20071,9 @@ function rmdir(path) {
20069
20071
  function chmod(path, mode) {
20070
20072
  chmodSync(path, mode);
20071
20073
  }
20074
+ function createExclusiveFile(path) {
20075
+ closeSync(openSync(path, "wx", 384));
20076
+ }
20072
20077
 
20073
20078
  // ../../packages/publish-harness/src/bot-transaction.ts
20074
20079
  import { homedir } from "os";
@@ -20273,7 +20278,6 @@ class BotError extends Error {
20273
20278
  this.code = code;
20274
20279
  }
20275
20280
  }
20276
-
20277
20281
  // ../../packages/publish-harness/src/index.ts
20278
20282
  import { homedir as homedir4 } from "os";
20279
20283
  import { join as join4, resolve as resolve4 } from "path";
@@ -20409,6 +20413,12 @@ async function waitUntil(predicate, timeoutMs, pollMs = DEFAULT_POLL_MS) {
20409
20413
  }
20410
20414
  return predicate();
20411
20415
  }
20416
+ var DEFAULT_SIGNAL_CONTAINERS = [
20417
+ '[class*="toast" i]',
20418
+ '[class*="notification" i]',
20419
+ '[role="alert"]',
20420
+ '[class*="message" i]'
20421
+ ];
20412
20422
  function errorMessage2(error) {
20413
20423
  return error instanceof Error ? error.message : String(error);
20414
20424
  }
@@ -20416,6 +20426,9 @@ function errorMessage2(error) {
20416
20426
  // ../../plugins/publishings/wechatmp-pub/src/profile-check.ts
20417
20427
  init_dist();
20418
20428
 
20429
+ // ../../plugins/publishings/wechatmp-pub/src/index.ts
20430
+ import { randomUUID } from "crypto";
20431
+
20419
20432
  // ../../packages/kk-core/src/content-limits.ts
20420
20433
  var PLATFORM_CONTENT_LIMITS = Object.freeze({
20421
20434
  schemaVersion: 5,
@@ -20686,6 +20699,9 @@ if (false) {}
20686
20699
  var CJK_TERMINATORS = new Set(["\u3002", "\uFF01", "\uFF1F"]);
20687
20700
  var LATIN_TERMINATORS = new Set([".", "!", "?"]);
20688
20701
  var ATTACHED_CLOSERS = new Set(["\u201D", "\u2019", "\u300D", "\u300F", "\uFF09", ")", '"', "'"]);
20702
+ // ../../plugins/publishings/wechatmp-pub/src/index.ts
20703
+ init_dist();
20704
+
20689
20705
  // ../../plugins/publishings/wechatmp-pub/src/cgi.ts
20690
20706
  var MP_ORIGIN = "https://mp.weixin.qq.com";
20691
20707
  var FILETRANSFER_URL = `${MP_ORIGIN}/cgi-bin/filetransfer`;
@@ -20747,6 +20763,13 @@ var URL_CANCEL = `${URL_POPOVER} a.jsPopoverBt:text-is("\u53D6\u6D88")`;
20747
20763
  var ORIGINAL_DECLARATION = `${DIALOG} label:has(.js_original_type_radio):has-text("\u6587\u5B57\u539F\u521B")`;
20748
20764
  var ORIGINAL_AGREEMENT = `${DIALOG} label.original_agreement:has(input[type="checkbox"]:not(:checked))`;
20749
20765
 
20766
+ // ../../plugins/publishings/wechatmp-pub/src/flow.ts
20767
+ var PUBLIC_SAVE_REFUSAL_CONTAINERS = [
20768
+ ...DEFAULT_SIGNAL_CONTAINERS,
20769
+ "div.version_fail_dialog:visible",
20770
+ "div.weui-desktop-dialog:visible"
20771
+ ];
20772
+
20750
20773
  // ../../plugins/publishings/wechatmp-pub/src/index.ts
20751
20774
  var CHANNEL = TARGET;
20752
20775
  var CONSOLE_READY_TIMEOUT_MS = 30000;
@@ -20756,6 +20779,25 @@ function isConsoleReady(page) {
20756
20779
  function storageStatePath(profileDir) {
20757
20780
  return `${profileDir}/storage-state.json`;
20758
20781
  }
20782
+ async function persistWechatSessionState(context, profileDir) {
20783
+ const target = storageStatePath(profileDir);
20784
+ const temporary = `${target}.${process.pid}.${randomUUID()}.tmp`;
20785
+ const fs = createNodeFileSystem();
20786
+ let reserved = false;
20787
+ try {
20788
+ createExclusiveFile(temporary);
20789
+ reserved = true;
20790
+ await context.storageState({ path: temporary });
20791
+ chmod(temporary, 384);
20792
+ await fs.rename(temporary, target);
20793
+ } finally {
20794
+ if (reserved) {
20795
+ await Promise.resolve().then(() => fs.deleteFile(temporary)).catch(() => {
20796
+ return;
20797
+ });
20798
+ }
20799
+ }
20800
+ }
20759
20801
  async function checkWechatSession(profileDir, opts = {}) {
20760
20802
  const { page, context } = await openWithState(profileDir, opts.headless ?? true);
20761
20803
  try {
@@ -20778,6 +20820,8 @@ async function openWechatLogin(opts) {
20778
20820
  headless: false,
20779
20821
  launcher: kkBrowserLauncher
20780
20822
  });
20823
+ let failed = false;
20824
+ let failure;
20781
20825
  try {
20782
20826
  const page = context.pages()[0] ?? await context.newPage();
20783
20827
  await page.goto(CONSOLE_URL);
@@ -20785,10 +20829,23 @@ async function openWechatLogin(opts) {
20785
20829
  if (!ready)
20786
20830
  throw new Error(`QR scan not completed within ${timeoutMs / 1000}s`);
20787
20831
  await page.waitForTimeout(1e4);
20788
- await context.storageState({ path: storageStatePath(opts.profileDir) });
20789
- } finally {
20832
+ try {
20833
+ await persistWechatSessionState(context, opts.profileDir);
20834
+ } catch {
20835
+ throw new Error("wechatmp authenticated session snapshot failed");
20836
+ }
20837
+ } catch (error) {
20838
+ failed = true;
20839
+ failure = error;
20840
+ }
20841
+ try {
20790
20842
  await context.close();
20843
+ } catch {
20844
+ if (!failed)
20845
+ echoError("wechatmp browser context close failed after authenticated session snapshot; saved state preserved");
20791
20846
  }
20847
+ if (failed)
20848
+ throw failure;
20792
20849
  }
20793
20850
  async function openWechatSession(profileDir, opts = {}) {
20794
20851
  const { context } = await openWithState(profileDir, opts.headless ?? false, opts.url ?? CONSOLE_URL);