@gobing-ai/knowledge-kit 0.0.33 → 0.0.35

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 (69) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +25191 -24167
  3. package/package.json +4 -4
  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 +31 -23
  7. package/plugins/generations/daily-article-gen/src/index.ts +39 -14
  8. package/plugins/generations/dailynews-gen/dist/index.js +23 -21
  9. package/plugins/generations/dailynews-gen/src/script-builder.ts +30 -26
  10. package/plugins/generations/episode-plan-gen/dist/index.js +12 -12
  11. package/plugins/generations/gemini-tts/dist/index.js +13 -12
  12. package/plugins/generations/image-gen/dist/index.js +26 -11
  13. package/plugins/generations/image-gen/presets/formats/xhs-card.yaml +16 -14
  14. package/plugins/generations/image-gen/presets/styles/xhs-knowledge.yaml +2 -2
  15. package/plugins/generations/image-gen/src/compose/card.ts +17 -2
  16. package/plugins/generations/news-report-gen/dist/index.js +12 -12
  17. package/plugins/generations/omni-voice-gen/plugin.json +1 -1
  18. package/plugins/generations/voice-gen/dist/index.js +13 -12
  19. package/plugins/generations/voice-gen/src/index.ts +9 -3
  20. package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
  21. package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
  22. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  23. package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
  24. package/plugins/ingestions/web-search/dist/index.js +10 -10
  25. package/plugins/kk/decisions/extract/ai-news.yaml +6 -0
  26. package/plugins/kk/decisions/kk-items.yaml +69 -3
  27. package/plugins/kk/plugin.json +1 -1
  28. package/plugins/kk/scripts/daily-stages.ts +834 -87
  29. package/plugins/kk/scripts/daily-voice-style.zh.md +15 -10
  30. package/plugins/kk/scripts/kk-workflow-stages.ts +46 -3
  31. package/plugins/kk/skills/content-safety/SKILL.md +1 -1
  32. package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +2 -2
  33. package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +2 -2
  34. package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +4 -2
  35. package/plugins/kk/workflows/kk-collect.yaml +7 -9
  36. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +32 -7
  37. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +169 -47
  38. package/plugins/kk/workflows/kk-daily-safety.yaml +9 -12
  39. package/plugins/publishings/emdash-pub/dist/index.js +9 -9
  40. package/plugins/publishings/infoq-pub/dist/index.js +22 -22
  41. package/plugins/publishings/infoq-pub/dist/profile-check.js +30336 -0
  42. package/plugins/publishings/infoq-pub/plugin.json +1 -1
  43. package/plugins/publishings/juejin-pub/dist/index.js +22 -22
  44. package/plugins/publishings/juejin-pub/dist/profile-check.js +30322 -0
  45. package/plugins/publishings/juejin-pub/plugin.json +1 -1
  46. package/plugins/publishings/medium-pub/dist/index.js +9 -9
  47. package/plugins/publishings/podcast-pub/dist/index.js +9 -9
  48. package/plugins/publishings/qiita-pub/dist/index.js +9 -9
  49. package/plugins/publishings/substack-pub/dist/index.js +22 -22
  50. package/plugins/publishings/substack-pub/dist/profile-check.js +30392 -0
  51. package/plugins/publishings/substack-pub/plugin.json +1 -1
  52. package/plugins/publishings/surfdash-pub/dist/index.js +9 -9
  53. package/plugins/publishings/wechatmp-pub/dist/index.js +329 -154
  54. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +30271 -0
  55. package/plugins/publishings/wechatmp-pub/plugin.json +1 -1
  56. package/plugins/publishings/wechatmp-pub/src/enrich.ts +106 -145
  57. package/plugins/publishings/wechatmp-pub/src/flow.ts +283 -42
  58. package/plugins/publishings/wechatmp-pub/src/page.ts +20 -0
  59. package/plugins/publishings/x-pub/dist/index.js +22 -22
  60. package/plugins/publishings/x-pub/dist/profile-check.js +30328 -0
  61. package/plugins/publishings/x-pub/plugin.json +1 -1
  62. package/plugins/publishings/xhs-pub/dist/index.js +76 -27
  63. package/plugins/publishings/xhs-pub/dist/profile-check.js +30538 -0
  64. package/plugins/publishings/xhs-pub/plugin.json +1 -1
  65. package/plugins/publishings/xhs-pub/src/flow.ts +9 -3
  66. package/plugins/publishings/xhs-pub/src/index.ts +111 -5
  67. package/plugins/publishings/zenn-pub/dist/index.js +9 -9
  68. package/plugins/generations/omni-voice-gen/dist/omni-voice-gen-prr8skpb. +0 -2
  69. package/plugins/generations/omni-voice-gen/dist/omni-voice-gen.js +0 -6
@@ -2,7 +2,7 @@
2
2
  "name": "x-pub",
3
3
  "kind": "publish",
4
4
  "entry": "./dist/index.js",
5
- "check": "./src/profile-check.ts",
5
+ "check": "./dist/profile-check.js",
6
6
  "version": "1.0.0",
7
7
  "description": "post via official tweets API; article via script browser transport (ts-browser-automation)"
8
8
  }
@@ -14671,7 +14671,7 @@ var init_zod = __esm(() => {
14671
14671
  init_external();
14672
14672
  });
14673
14673
 
14674
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/errors.js
14674
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.21/node_modules/@gobing-ai/ts-utils/dist/errors.js
14675
14675
  var ErrorCode;
14676
14676
  var init_errors3 = __esm(() => {
14677
14677
  ErrorCode = {
@@ -14682,7 +14682,7 @@ var init_errors3 = __esm(() => {
14682
14682
  };
14683
14683
  });
14684
14684
 
14685
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14685
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.21/node_modules/@gobing-ai/ts-utils/dist/api-response.js
14686
14686
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
14687
14687
  var init_api_response = __esm(() => {
14688
14688
  init_errors3();
@@ -14705,10 +14705,10 @@ var init_api_response = __esm(() => {
14705
14705
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
14706
14706
  });
14707
14707
 
14708
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14708
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.21/node_modules/@gobing-ai/ts-utils/dist/cursor.js
14709
14709
  var init_cursor = () => {};
14710
14710
 
14711
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/env.js
14711
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.21/node_modules/@gobing-ai/ts-utils/dist/env.js
14712
14712
  function getEnvVar(name, fallback) {
14713
14713
  const raw = process.env[name];
14714
14714
  return raw === undefined ? fallback : raw;
@@ -14717,10 +14717,10 @@ function getEnvVars() {
14717
14717
  return process.env;
14718
14718
  }
14719
14719
 
14720
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14720
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.21/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
14721
14721
  var init_event_severity = () => {};
14722
14722
 
14723
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/object.js
14723
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.21/node_modules/@gobing-ai/ts-utils/dist/object.js
14724
14724
  function isPlainObject2(value) {
14725
14725
  return typeof value === "object" && value !== null && !Array.isArray(value);
14726
14726
  }
@@ -14738,7 +14738,7 @@ function deepMerge(target, source) {
14738
14738
  return result;
14739
14739
  }
14740
14740
 
14741
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/output.js
14741
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.21/node_modules/@gobing-ai/ts-utils/dist/output.js
14742
14742
  function processStream(name) {
14743
14743
  const proc = globalThis.process;
14744
14744
  const stream = proc?.[name];
@@ -14756,7 +14756,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
14756
14756
  }
14757
14757
  var defaultStderrTarget;
14758
14758
 
14759
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.18/node_modules/@gobing-ai/ts-utils/dist/index.js
14759
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.21/node_modules/@gobing-ai/ts-utils/dist/index.js
14760
14760
  var init_dist = __esm(() => {
14761
14761
  init_api_response();
14762
14762
  init_cursor();
@@ -21754,7 +21754,7 @@ var init_dist2 = __esm(() => {
21754
21754
  $visitAsync = visit.visitAsync;
21755
21755
  });
21756
21756
 
21757
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/config.js
21757
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.21+44edd5c4d6372504/node_modules/@gobing-ai/ts-runtime/dist/config.js
21758
21758
  function getProcessEnv() {
21759
21759
  return getEnvVars();
21760
21760
  }
@@ -21832,7 +21832,7 @@ var init_config = __esm(() => {
21832
21832
  };
21833
21833
  });
21834
21834
 
21835
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21835
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.21+44edd5c4d6372504/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
21836
21836
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
21837
21837
  import { dirname, resolve as resolvePath } from "path";
21838
21838
  function createNodeFileSystem(root, paths) {
@@ -21919,7 +21919,7 @@ function findProjectRoot(startDir) {
21919
21919
  }
21920
21920
  var init_file_system_node = () => {};
21921
21921
 
21922
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
21922
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.21+44edd5c4d6372504/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
21923
21923
  var DbModuleNotInstalledError;
21924
21924
  var init_db_errors = __esm(() => {
21925
21925
  DbModuleNotInstalledError = class DbModuleNotInstalledError extends Error {
@@ -29130,7 +29130,7 @@ var init_execa = __esm(() => {
29130
29130
  } = getIpcExport());
29131
29131
  });
29132
29132
 
29133
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
29133
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.21+44edd5c4d6372504/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
29134
29134
  function resolveDeadline(optionTimeout, defaultTimeout) {
29135
29135
  if (optionTimeout === null)
29136
29136
  return null;
@@ -29222,7 +29222,7 @@ function ownProcessGroupLifecycle(ownership) {
29222
29222
  }
29223
29223
  var MAX_TIMEOUT_MS = 2147483647, DEFAULT_KILL_GRACE_MS = 5000, GROUP_POLL_INTERVAL_MS = 25, GROUP_KILL_PATIENCE_MS = 2000;
29224
29224
 
29225
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
29225
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.21+44edd5c4d6372504/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
29226
29226
  import { isatty } from "tty";
29227
29227
  function processEventSeverity(reason, exitCode) {
29228
29228
  if (reason === "error")
@@ -29594,7 +29594,7 @@ var init_process_executor = __esm(() => {
29594
29594
  init_config();
29595
29595
  });
29596
29596
 
29597
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
29597
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.21+44edd5c4d6372504/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
29598
29598
  function getNodeFileSystem() {
29599
29599
  if (!_nodeFileSystem)
29600
29600
  _nodeFileSystem = createNodeFileSystem();
@@ -29746,11 +29746,11 @@ var PluginManifestSchema = exports_external.looseObject({
29746
29746
  description: exports_external.string().optional(),
29747
29747
  operations: exports_external.record(exports_external.string(), PluginOperationSchema).optional()
29748
29748
  });
29749
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/index.js
29749
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.21+44edd5c4d6372504/node_modules/@gobing-ai/ts-runtime/dist/index.js
29750
29750
  init_file_system_node();
29751
29751
  init_config();
29752
29752
 
29753
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/path.js
29753
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.21+44edd5c4d6372504/node_modules/@gobing-ai/ts-runtime/dist/path.js
29754
29754
  function normalizeSeparators(path6) {
29755
29755
  return path6.replaceAll("\\", "/");
29756
29756
  }
@@ -29808,7 +29808,7 @@ function getProcessCwd() {
29808
29808
  return globalThis.process?.cwd?.() ?? "/";
29809
29809
  }
29810
29810
 
29811
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.18+ea28d47622d670ff/node_modules/@gobing-ai/ts-runtime/dist/index.js
29811
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.21+44edd5c4d6372504/node_modules/@gobing-ai/ts-runtime/dist/index.js
29812
29812
  init_runtime_node_bun();
29813
29813
 
29814
29814
  // ../../packages/kk-core/src/render-md.ts
@@ -29924,7 +29924,7 @@ async function trySelectors(page, selectors, options = {}) {
29924
29924
  // ../../packages/publish-harness/src/browser.ts
29925
29925
  import { resolve as resolve2 } from "path";
29926
29926
 
29927
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
29927
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.21+b6949ba92ac553f0/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
29928
29928
  class BrowserAutomationError extends Error {
29929
29929
  constructor(message, options) {
29930
29930
  super(message, options);
@@ -29973,10 +29973,10 @@ class OperationAbortedError extends BrowserAutomationError {
29973
29973
  this.name = "OperationAbortedError";
29974
29974
  }
29975
29975
  }
29976
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
29976
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.21+b6949ba92ac553f0/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
29977
29977
  import { mkdir } from "fs/promises";
29978
29978
 
29979
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
29979
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.21+b6949ba92ac553f0/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
29980
29980
  function resolveProfileDir(profileDir) {
29981
29981
  if (profileDir.trim() === "") {
29982
29982
  throw new InvalidProfileDirError;
@@ -29988,7 +29988,7 @@ function resolveProfileDir(profileDir) {
29988
29988
  return resolved;
29989
29989
  }
29990
29990
 
29991
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
29991
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.21+b6949ba92ac553f0/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
29992
29992
  var PROFILE_DIR_MODE = 448;
29993
29993
  var BUSY_PROFILE_PATTERN = /singleton|already in use|in use by another/i;
29994
29994
  var CHROMIUM_MISSING_PATTERN = /playwright install|executable doesn't exist/i;
@@ -30039,7 +30039,7 @@ function createPersistentLauncher(options = {}) {
30039
30039
  };
30040
30040
  }
30041
30041
 
30042
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.18+1f5782d4d327a230/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
30042
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.21+b6949ba92ac553f0/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
30043
30043
  var DEFAULT_TIMEOUT_MS = 30000;
30044
30044
  var POLL_INTERVAL_MS = 250;
30045
30045
  var defaultLauncher;
@@ -30950,7 +30950,7 @@ async function leavePodcastModal(deps) {
30950
30950
  if (await waitUntil(closed, deps.stepTimeoutMs))
30951
30951
  return;
30952
30952
  }
30953
- throw new Error(`podcast modal: the \u53D1\u64AD\u5BA2 modal was still open ${deps.stepTimeoutMs}ms after the audio and cover were attached; the only recorded advance control is '${PODCAST_MODAL_ADVANCE[0]}' and a draft run does not click it (it is publish-adjacent)`);
30953
+ throw new Error(`podcast modal: the \u53D1\u64AD\u5BA2 modal was still open ${deps.stepTimeoutMs}ms after the audio and cover were attached; its post-attach save path has never been measured (task 0236 R3 \u2014 the attended walk is still pending) and the only recorded advance control is '${PODCAST_MODAL_ADVANCE[0]}', which a draft run does not click (it is publish-adjacent)`);
30954
30954
  }
30955
30955
  async function composePodcast(input, deps) {
30956
30956
  await enterMode(deps, input.operation);
@@ -31072,6 +31072,38 @@ var AUTH_GATE = ["div.creator-tab", "text=\u4E0A\u4F20\u56FE\u6587"];
31072
31072
  function fail2(error51) {
31073
31073
  return ResultSchema.parse({ ok: false, target: TARGET, error: error51 });
31074
31074
  }
31075
+ async function planVisit(primary, content) {
31076
+ const raw = content.metadata?.followUps;
31077
+ if (raw === undefined)
31078
+ return { plan: { primary, followUps: [] } };
31079
+ if (!Array.isArray(raw)) {
31080
+ return {
31081
+ error: `followUps validation: Content.metadata.followUps must be an array of Content objects, got ${typeof raw}`
31082
+ };
31083
+ }
31084
+ const followUps = [];
31085
+ for (const [index, entry] of raw.entries()) {
31086
+ const label = `followUps[${index}]`;
31087
+ const parsed = ContentSchema.safeParse(entry);
31088
+ if (!parsed.success) {
31089
+ followUps.push({ operation: label, error: `${label} is not a Content object` });
31090
+ continue;
31091
+ }
31092
+ const operation = typeof parsed.data.metadata?.operation === "string" ? parsed.data.metadata.operation : label;
31093
+ const requested = resolveXhsOperation(undefined, parsed.data);
31094
+ if (requested.error !== undefined) {
31095
+ followUps.push({ operation, error: requested.error });
31096
+ continue;
31097
+ }
31098
+ const validation = await validateModeInput(requested.operation, parsed.data);
31099
+ if (validation.error !== undefined) {
31100
+ followUps.push({ operation, error: validation.error });
31101
+ continue;
31102
+ }
31103
+ followUps.push({ content: parsed.data, operation: requested.operation, input: validation.input });
31104
+ }
31105
+ return { plan: { primary, followUps } };
31106
+ }
31075
31107
  async function createShadowProbe(context2, page) {
31076
31108
  const find = await createShadowFinder(context2, page);
31077
31109
  return find === undefined ? undefined : { findControl: (labels) => find(labels) };
@@ -31145,9 +31177,12 @@ class XhsBrowserTransport {
31145
31177
  if (validation.error !== undefined)
31146
31178
  return fail2(validation.error);
31147
31179
  const input = validation.input;
31180
+ const visited = await planVisit({ content: payload.content, input }, payload.content);
31181
+ if (visited.error !== undefined)
31182
+ return fail2(visited.error);
31183
+ const visit2 = visited.plan;
31148
31184
  const override = typeof payload.options?.profileDir === "string" ? payload.options.profileDir : undefined;
31149
31185
  const profileDir = resolveChannelProfileDir(CHANNEL, override);
31150
- const publishStatus = payload.content.metadata?.publishStatus === "public" ? "public" : "draft";
31151
31186
  const cap = this.automation.allow("publish");
31152
31187
  if (!cap.allowed)
31153
31188
  return fail2(`automation cap: ${cap.reason}`);
@@ -31163,6 +31198,21 @@ class XhsBrowserTransport {
31163
31198
  return fail2(error51 instanceof Error ? error51.message : String(error51));
31164
31199
  }
31165
31200
  const { page, close } = opened;
31201
+ try {
31202
+ const primary = await this.runStep(visit2.primary.input, visit2.primary.content, page, profileDir);
31203
+ if (!primary.ok || visit2.followUps.length === 0)
31204
+ return primary;
31205
+ const followUps = [];
31206
+ for (const followUp of visit2.followUps) {
31207
+ const step = "error" in followUp ? fail2(`follow-up (${followUp.operation}): ${followUp.error}`) : await this.runStep(followUp.input, followUp.content, page, profileDir);
31208
+ followUps.push(ResultSchema.parse({ ...step, metadata: { operation: followUp.operation, ...step.metadata } }));
31209
+ }
31210
+ return ResultSchema.parse({ ...primary, metadata: { ...primary.metadata, followUps } });
31211
+ } finally {
31212
+ await close();
31213
+ }
31214
+ }
31215
+ async runStep(input, content, page, profileDir) {
31166
31216
  const act = async (what, fn) => {
31167
31217
  try {
31168
31218
  return await fn();
@@ -31176,10 +31226,11 @@ class XhsBrowserTransport {
31176
31226
  if (!gated) {
31177
31227
  return fail2(`login timeout after ${this.loginTimeoutMs}ms: no authenticated ${CHANNEL} creator console in ${profileDir}`);
31178
31228
  }
31229
+ const publishStatus = content.metadata?.publishStatus === "public" ? "public" : "draft";
31179
31230
  const draftBaseline = publishStatus === "draft" ? await readDraftBaseline(page) : { count: null, stamps: [] };
31180
31231
  return await runMode(input, {
31181
31232
  page,
31182
- content: payload.content,
31233
+ content,
31183
31234
  publishStatus,
31184
31235
  profileDir,
31185
31236
  driver: this.driver,
@@ -31190,8 +31241,6 @@ class XhsBrowserTransport {
31190
31241
  });
31191
31242
  } catch (error51) {
31192
31243
  return fail2(error51 instanceof Error ? error51.message : String(error51));
31193
- } finally {
31194
- await close();
31195
31244
  }
31196
31245
  }
31197
31246
  }