@gobing-ai/knowledge-kit 0.1.23 → 0.1.25

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 (106) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +418 -114
  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 +59 -18
  10. package/plugins/generations/episode-plan-gen/src/index.ts +71 -7
  11. package/plugins/generations/gemini-tts/dist/index.js +9 -9
  12. package/plugins/generations/image-gen/dist/index.js +9 -9
  13. package/plugins/generations/music-gen/dist/index.js +33 -29
  14. package/plugins/generations/music-gen/src/audio/measure.ts +25 -20
  15. package/plugins/generations/news-report-gen/dist/index.js +12 -12
  16. package/plugins/generations/vibe-voice-tts/dist/index.js +9 -9
  17. package/plugins/generations/voice-gen/dist/index.js +9 -9
  18. package/plugins/generations/voxcpm-tts/dist/index.js +9 -9
  19. package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
  20. package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
  21. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  22. package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
  23. package/plugins/ingestions/web-search/dist/index.js +10 -10
  24. package/plugins/kk/decisions/extract/ai-news.yaml +8 -1
  25. package/plugins/kk/plugin.json +1 -1
  26. package/plugins/kk/publish-presets/daily-ai-voice.json +20 -20
  27. package/plugins/kk/publish-presets/itc-main.json +39 -23
  28. package/plugins/kk/scripts/cover-compositor.ts +104 -26
  29. package/plugins/kk/scripts/daily-stages.ts +704 -53
  30. package/plugins/kk/scripts/kk-workflow-stages.ts +149 -6
  31. package/plugins/kk/scripts/series-names.ts +16 -3
  32. package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +12 -5
  33. package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +8 -0
  34. package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +5 -0
  35. package/plugins/kk/skills/daily-news-cover/SKILL.md +96 -0
  36. package/plugins/kk/skills/daily-news-illustrations/SKILL.md +123 -0
  37. package/plugins/kk/skills/news-editorial/SKILL.md +5 -3
  38. package/plugins/kk/skills/news-editorial/references/daily-visual-composition.md +150 -0
  39. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
  40. package/plugins/kk/workflows/kk-article-generate.yaml +13 -1
  41. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +6 -3
  42. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -4
  43. package/plugins/kk/workflows/kk-news-generate.yaml +74 -1
  44. package/plugins/publishings/bilibili-pub/dist/index.js +25 -24
  45. package/plugins/publishings/bilibili-pub/dist/profile-check.js +25 -24
  46. package/plugins/publishings/cnblogs-pub/dist/index.js +25 -24
  47. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +25 -24
  48. package/plugins/publishings/csdn-pub/dist/index.js +25 -24
  49. package/plugins/publishings/csdn-pub/dist/profile-check.js +25 -24
  50. package/plugins/publishings/emdash-pub/dist/index.js +9 -9
  51. package/plugins/publishings/infoq-pub/dist/index.js +25 -24
  52. package/plugins/publishings/infoq-pub/dist/profile-check.js +25 -24
  53. package/plugins/publishings/jike-pub/dist/index.js +25 -24
  54. package/plugins/publishings/jike-pub/dist/profile-check.js +25 -24
  55. package/plugins/publishings/juejin-pub/dist/index.js +25 -24
  56. package/plugins/publishings/juejin-pub/dist/profile-check.js +25 -24
  57. package/plugins/publishings/linkedin-pub/dist/index.js +85 -26
  58. package/plugins/publishings/linkedin-pub/dist/profile-check.js +25 -24
  59. package/plugins/publishings/linkedin-pub/src/index.ts +93 -6
  60. package/plugins/publishings/medium-pub/dist/index.js +9206 -287
  61. package/plugins/publishings/medium-pub/dist/profile-check.js +21174 -0
  62. package/plugins/publishings/medium-pub/package.json +3 -1
  63. package/plugins/publishings/medium-pub/plugin.json +6 -1
  64. package/plugins/publishings/medium-pub/src/browser-rail.ts +280 -0
  65. package/plugins/publishings/medium-pub/src/index.ts +17 -1
  66. package/plugins/publishings/medium-pub/src/profile-check.ts +27 -0
  67. package/plugins/publishings/podcast-pub/dist/index.js +240 -37
  68. package/plugins/publishings/podcast-pub/src/index.ts +154 -3
  69. package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
  70. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
  71. package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
  72. package/plugins/publishings/qiita-pub/dist/index.js +9 -9
  73. package/plugins/publishings/shipinhao-pub/dist/index.js +29 -26
  74. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +28 -26
  75. package/plugins/publishings/shipinhao-pub/src/flow.ts +5 -0
  76. package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -5
  77. package/plugins/publishings/sspai-pub/dist/index.js +25 -24
  78. package/plugins/publishings/sspai-pub/dist/profile-check.js +25 -24
  79. package/plugins/publishings/substack-pub/dist/index.js +25 -24
  80. package/plugins/publishings/substack-pub/dist/profile-check.js +25 -24
  81. package/plugins/publishings/surfdash-pub/dist/index.js +200 -92
  82. package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
  83. package/plugins/publishings/surfdash-pub/src/index.ts +94 -75
  84. package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
  85. package/plugins/publishings/surfdash-pub/src/patch.ts +28 -23
  86. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
  87. package/plugins/publishings/threads-pub/dist/index.js +39 -24
  88. package/plugins/publishings/threads-pub/dist/profile-check.js +30 -24
  89. package/plugins/publishings/threads-pub/src/post-rail.ts +20 -0
  90. package/plugins/publishings/wechatmp-pub/dist/index.js +438 -102
  91. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +30 -25
  92. package/plugins/publishings/wechatmp-pub/src/enrich.ts +56 -10
  93. package/plugins/publishings/wechatmp-pub/src/flow.ts +589 -83
  94. package/plugins/publishings/wechatmp-pub/src/index.ts +4 -1
  95. package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
  96. package/plugins/publishings/wechatmp-pub/src/page.ts +8 -0
  97. package/plugins/publishings/weibo-pub/dist/index.js +25 -24
  98. package/plugins/publishings/weibo-pub/dist/profile-check.js +25 -24
  99. package/plugins/publishings/x-pub/dist/index.js +54 -47
  100. package/plugins/publishings/x-pub/dist/profile-check.js +25 -24
  101. package/plugins/publishings/x-pub/src/post-rail.ts +40 -47
  102. package/plugins/publishings/xhs-pub/dist/index.js +25 -24
  103. package/plugins/publishings/xhs-pub/dist/profile-check.js +25 -24
  104. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +25 -24
  105. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +25 -24
  106. package/plugins/publishings/zenn-pub/dist/index.js +9 -9
@@ -4845,7 +4845,7 @@ var init_zod = __esm(() => {
4845
4845
  init_external();
4846
4846
  });
4847
4847
 
4848
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/errors.js
4848
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
4849
4849
  var ErrorCode;
4850
4850
  var init_errors3 = __esm(() => {
4851
4851
  ErrorCode = {
@@ -4856,7 +4856,7 @@ var init_errors3 = __esm(() => {
4856
4856
  };
4857
4857
  });
4858
4858
 
4859
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4859
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
4860
4860
  var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
4861
4861
  var init_api_response = __esm(() => {
4862
4862
  init_errors3();
@@ -4879,10 +4879,10 @@ var init_api_response = __esm(() => {
4879
4879
  CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
4880
4880
  });
4881
4881
 
4882
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4882
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
4883
4883
  var init_cursor = () => {};
4884
4884
 
4885
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/env.js
4885
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/env.js
4886
4886
  function getEnvVar(name, fallback) {
4887
4887
  const raw = process.env[name];
4888
4888
  return raw === undefined ? fallback : raw;
@@ -4891,10 +4891,10 @@ function getEnvVars() {
4891
4891
  return process.env;
4892
4892
  }
4893
4893
 
4894
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4894
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
4895
4895
  var init_event_severity = () => {};
4896
4896
 
4897
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/object.js
4897
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/object.js
4898
4898
  function isPlainObject2(value) {
4899
4899
  return typeof value === "object" && value !== null && !Array.isArray(value);
4900
4900
  }
@@ -4912,7 +4912,7 @@ function deepMerge(target, source) {
4912
4912
  return result;
4913
4913
  }
4914
4914
 
4915
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/output.js
4915
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
4916
4916
  function processStream(name) {
4917
4917
  const proc = globalThis.process;
4918
4918
  const stream = proc?.[name];
@@ -4930,7 +4930,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
4930
4930
  }
4931
4931
  var defaultStderrTarget;
4932
4932
 
4933
- // ../../node_modules/.bun/@gobing-ai+ts-utils@0.5.32/node_modules/@gobing-ai/ts-utils/dist/index.js
4933
+ // ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
4934
4934
  var init_dist = __esm(() => {
4935
4935
  init_api_response();
4936
4936
  init_cursor();
@@ -11928,7 +11928,7 @@ var init_dist2 = __esm(() => {
11928
11928
  $visitAsync = visit.visitAsync;
11929
11929
  });
11930
11930
 
11931
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/config.js
11931
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
11932
11932
  function getProcessEnv() {
11933
11933
  return getEnvVars();
11934
11934
  }
@@ -12006,7 +12006,7 @@ var init_config = __esm(() => {
12006
12006
  };
12007
12007
  });
12008
12008
 
12009
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
12009
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
12010
12010
  import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
12011
12011
  import { dirname, resolve as resolvePath } from "path";
12012
12012
  function createNodeFileSystem(root, paths) {
@@ -12093,7 +12093,7 @@ function findProjectRoot(startDir) {
12093
12093
  }
12094
12094
  var init_file_system_node = () => {};
12095
12095
 
12096
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
12096
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/db-errors.js
12097
12097
  var DbModuleNotInstalledError;
12098
12098
  var init_db_errors = __esm(() => {
12099
12099
  DbModuleNotInstalledError = class DbModuleNotInstalledError extends Error {
@@ -19304,7 +19304,7 @@ var init_execa = __esm(() => {
19304
19304
  } = getIpcExport());
19305
19305
  });
19306
19306
 
19307
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
19307
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-group.js
19308
19308
  function resolveDeadline(optionTimeout, defaultTimeout) {
19309
19309
  if (optionTimeout === null)
19310
19310
  return null;
@@ -19396,7 +19396,7 @@ function ownProcessGroupLifecycle(ownership) {
19396
19396
  }
19397
19397
  var MAX_TIMEOUT_MS = 2147483647, DEFAULT_KILL_GRACE_MS = 5000, GROUP_POLL_INTERVAL_MS = 25, GROUP_KILL_PATIENCE_MS = 2000;
19398
19398
 
19399
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
19399
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/process-executor.js
19400
19400
  import { isatty } from "tty";
19401
19401
  function processEventSeverity(reason, exitCode) {
19402
19402
  if (reason === "error")
@@ -19768,7 +19768,7 @@ var init_process_executor = __esm(() => {
19768
19768
  init_config();
19769
19769
  });
19770
19770
 
19771
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
19771
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/runtime-node-bun.js
19772
19772
  function getNodeFileSystem() {
19773
19773
  if (!_nodeFileSystem)
19774
19774
  _nodeFileSystem = createNodeFileSystem();
@@ -20097,11 +20097,11 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
20097
20097
  });
20098
20098
  }
20099
20099
  });
20100
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
20100
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
20101
20101
  init_file_system_node();
20102
20102
  init_config();
20103
20103
 
20104
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/path.js
20104
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
20105
20105
  function normalizeSeparators(path) {
20106
20106
  return path.replaceAll("\\", "/");
20107
20107
  }
@@ -20159,7 +20159,7 @@ function getProcessCwd() {
20159
20159
  return globalThis.process?.cwd?.() ?? "/";
20160
20160
  }
20161
20161
 
20162
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
20162
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
20163
20163
  init_runtime_node_bun();
20164
20164
 
20165
20165
  // ../../packages/kk-core/src/render-md.ts
@@ -20279,7 +20279,7 @@ async function trySelectors(page, selectors, options = {}) {
20279
20279
  // ../../packages/publish-harness/src/browser.ts
20280
20280
  import { join as join5, resolve as resolve5 } from "path";
20281
20281
 
20282
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
20282
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
20283
20283
  class BrowserAutomationError extends Error {
20284
20284
  constructor(message, options) {
20285
20285
  super(message, options);
@@ -20328,10 +20328,10 @@ class OperationAbortedError extends BrowserAutomationError {
20328
20328
  this.name = "OperationAbortedError";
20329
20329
  }
20330
20330
  }
20331
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20331
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20332
20332
  import { mkdir } from "fs/promises";
20333
20333
 
20334
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
20334
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
20335
20335
  function resolveProfileDir(profileDir) {
20336
20336
  if (profileDir.trim() === "") {
20337
20337
  throw new InvalidProfileDirError;
@@ -20343,7 +20343,7 @@ function resolveProfileDir(profileDir) {
20343
20343
  return resolved;
20344
20344
  }
20345
20345
 
20346
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20346
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20347
20347
  var PROFILE_DIR_MODE = 448;
20348
20348
  var BUSY_PROFILE_PATTERN = /singleton|already in use|in use by another/i;
20349
20349
  var CHROMIUM_MISSING_PATTERN = /playwright install|executable doesn't exist/i;
@@ -20394,7 +20394,7 @@ function createPersistentLauncher(options = {}) {
20394
20394
  };
20395
20395
  }
20396
20396
 
20397
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20397
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20398
20398
  var DEFAULT_TIMEOUT_MS = 30000;
20399
20399
  var POLL_INTERVAL_MS = 250;
20400
20400
  var defaultLauncher;
@@ -20699,7 +20699,8 @@ async function busyGuidance(fileSystem, leaseDir) {
20699
20699
  }
20700
20700
  return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
20701
20701
  }
20702
- return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed`;
20702
+ const suffix = isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
20703
+ return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
20703
20704
  }
20704
20705
  async function holderResidue(fileSystem, leaseDir) {
20705
20706
  try {
@@ -20925,7 +20926,7 @@ function resolveChannelProfileDir(channel, override) {
20925
20926
  return resolveBrowserProfileDir(channel, chosen);
20926
20927
  }
20927
20928
  async function checkChannelSession(config, opts) {
20928
- const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20929
+ const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20929
20930
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20930
20931
  let lastDetail = `${config.channel} readiness was never probed`;
20931
20932
  const deadline = Date.now() + timeoutMs;
@@ -21202,18 +21203,33 @@ class XPostBrowserTransport {
21202
21203
  await textBox.press("ControlOrMeta+a").catch(() => {});
21203
21204
  await textBox.press("Backspace").catch(() => {});
21204
21205
  await textBox.pressSequentially(text, { delay: 8 });
21205
- const enabled = await expectOutcome(async () => {
21206
- for (const selector of X_POST_SUBMITS) {
21207
- if (await page.locator(selector).first().isEnabled().catch(() => false))
21208
- return "post enabled";
21209
- }
21210
- return null;
21211
- }, { timeoutMs: Math.min(1e4, this.stepTimeoutMs), label: `x post enabled (attempt ${attempt})` });
21206
+ const enabled = await expectOutcome(async () => await this.findEnabledSubmit(page) !== null ? "post enabled" : null, { timeoutMs: Math.min(1e4, this.stepTimeoutMs), label: `x post enabled (attempt ${attempt})` });
21212
21207
  if (enabled.ok)
21213
21208
  return null;
21214
21209
  }
21215
21210
  return "x post submit never enabled \u2014 the editor did not accept the text in three attempts";
21216
21211
  }
21212
+ async findEnabledSubmit(page, opts = {}) {
21213
+ let enabledFallback = null;
21214
+ for (const selector of X_POST_SUBMITS) {
21215
+ const loc = page.locator(selector);
21216
+ const count = await loc.count().catch(() => 0);
21217
+ const limit = Math.max(1, count);
21218
+ for (let index = 0;index < limit; index += 1) {
21219
+ const candidate = index === 0 ? loc.first() : loc.nth(index);
21220
+ const enabled = await candidate.isEnabled({ timeout: 1000 }).catch(() => false);
21221
+ if (!enabled)
21222
+ continue;
21223
+ if (opts.preferVisible !== true)
21224
+ return candidate;
21225
+ const visible = await candidate.isVisible().catch(() => false);
21226
+ if (visible)
21227
+ return candidate;
21228
+ enabledFallback ??= candidate;
21229
+ }
21230
+ }
21231
+ return enabledFallback;
21232
+ }
21217
21233
  async runPostFlow(page, text, coverPath, profileDir) {
21218
21234
  const metadata = { operation: "post", driver: "script", publishStatus: "public", profileDir };
21219
21235
  const handle = await page.locator(POST_SELECTORS.profileLink[0]).first().getAttribute("href").catch(() => null);
@@ -21243,18 +21259,22 @@ class XPostBrowserTransport {
21243
21259
  const attached = await expectOutcome(async () => await page.locator(POST_SELECTORS.mediaPreview[0]).count() > 0 ? "media attached" : null, { timeoutMs: this.stepTimeoutMs, label: "x post media" });
21244
21260
  if (!attached.ok)
21245
21261
  return fail(`x post image was uploaded but never rendered: ${attached.error}`);
21246
- const reEnabled = await expectOutcome(async () => await page.locator(X_POST_SUBMIT).first().isEnabled().catch(() => false) ? "post re-enabled" : null, { timeoutMs: this.stepTimeoutMs * 4, label: "x post submit enabled after media" });
21262
+ const reEnabled = await expectOutcome(async () => await this.findEnabledSubmit(page) !== null ? "post re-enabled" : null, { timeoutMs: this.stepTimeoutMs * 4, label: "x post submit enabled after media" });
21247
21263
  if (!reEnabled.ok) {
21248
21264
  const observable = page;
21249
21265
  const evidence = await (observable.evaluate === undefined ? Promise.resolve(null) : observable.evaluate(`(() => {
21266
+ const readDisabled = (el) => el === null ? 'missing' : (el.getAttribute('aria-disabled') ?? (el.disabled === true ? 'true' : 'false'));
21250
21267
  const editor = document.querySelector('[data-testid="tweetTextarea_0"]');
21251
21268
  const submit = document.querySelector('${X_POST_SUBMIT}');
21269
+ const inlineSubmit = document.querySelector('${X_POST_SUBMIT_INLINE}');
21252
21270
  const alerts = [...document.querySelectorAll('[data-testid="toast"], [role="alert"], [data-testid="error-detail"]')]
21253
21271
  .map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim()).filter(Boolean).slice(0, 3);
21254
21272
  const images = [...document.querySelectorAll('[data-testid="attachments"] img, [data-testid="tweetPhoto"] img')].length;
21255
21273
  return JSON.stringify({
21274
+ url: location.pathname,
21256
21275
  textLen: (editor?.textContent || '').trim().length,
21257
- submitDisabled: submit?.getAttribute('aria-disabled') ?? (submit?.disabled === true ? 'true' : 'false'),
21276
+ submitDisabled: readDisabled(submit),
21277
+ inlineDisabled: readDisabled(inlineSubmit),
21258
21278
  images,
21259
21279
  alerts,
21260
21280
  });
@@ -21262,20 +21282,7 @@ class XPostBrowserTransport {
21262
21282
  return fail(`x post submit stayed disabled after the media: ${reEnabled.error}${evidence ? ` \u2014 composer ${String(evidence)}` : ""}`);
21263
21283
  }
21264
21284
  }
21265
- const submit = await (async () => {
21266
- let enabledFallback = null;
21267
- for (const selector of X_POST_SUBMITS) {
21268
- const candidate = page.locator(selector).first();
21269
- const enabled = await candidate.isEnabled().catch(() => false);
21270
- if (!enabled)
21271
- continue;
21272
- const visible = await candidate.isVisible().catch(() => false);
21273
- if (visible)
21274
- return candidate;
21275
- enabledFallback ??= candidate;
21276
- }
21277
- return enabledFallback;
21278
- })();
21285
+ const submit = await this.findEnabledSubmit(page, { preferVisible: true });
21279
21286
  if (submit === null)
21280
21287
  return fail("x post submit was enabled a moment ago but no clickable control remained");
21281
21288
  await submit.click();
@@ -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();
@@ -19835,7 +19835,7 @@ var init_runtime_node_bun = __esm(() => {
19835
19835
  import { join as join5, resolve as resolve5 } from "path";
19836
19836
  import { parseArgs } from "util";
19837
19837
 
19838
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
19838
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
19839
19839
  class BrowserAutomationError extends Error {
19840
19840
  constructor(message, options) {
19841
19841
  super(message, options);
@@ -19884,14 +19884,14 @@ class OperationAbortedError extends BrowserAutomationError {
19884
19884
  this.name = "OperationAbortedError";
19885
19885
  }
19886
19886
  }
19887
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
19887
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
19888
19888
  import { mkdir } from "fs/promises";
19889
19889
 
19890
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
19890
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
19891
19891
  init_file_system_node();
19892
19892
  init_config();
19893
19893
 
19894
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/path.js
19894
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
19895
19895
  function normalizeSeparators(path) {
19896
19896
  return path.replaceAll("\\", "/");
19897
19897
  }
@@ -19949,10 +19949,10 @@ function getProcessCwd() {
19949
19949
  return globalThis.process?.cwd?.() ?? "/";
19950
19950
  }
19951
19951
 
19952
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
19952
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
19953
19953
  init_runtime_node_bun();
19954
19954
 
19955
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
19955
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
19956
19956
  function resolveProfileDir(profileDir) {
19957
19957
  if (profileDir.trim() === "") {
19958
19958
  throw new InvalidProfileDirError;
@@ -19964,7 +19964,7 @@ function resolveProfileDir(profileDir) {
19964
19964
  return resolved;
19965
19965
  }
19966
19966
 
19967
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
19967
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
19968
19968
  var PROFILE_DIR_MODE = 448;
19969
19969
  var BUSY_PROFILE_PATTERN = /singleton|already in use|in use by another/i;
19970
19970
  var CHROMIUM_MISSING_PATTERN = /playwright install|executable doesn't exist/i;
@@ -20015,7 +20015,7 @@ function createPersistentLauncher(options = {}) {
20015
20015
  };
20016
20016
  }
20017
20017
 
20018
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20018
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20019
20019
  var DEFAULT_TIMEOUT_MS = 30000;
20020
20020
  var POLL_INTERVAL_MS = 250;
20021
20021
  var defaultLauncher;
@@ -20335,7 +20335,8 @@ async function busyGuidance(fileSystem, leaseDir) {
20335
20335
  }
20336
20336
  return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
20337
20337
  }
20338
- return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed`;
20338
+ const suffix = isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
20339
+ return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
20339
20340
  }
20340
20341
  async function holderResidue(fileSystem, leaseDir) {
20341
20342
  try {
@@ -20604,7 +20605,7 @@ function resolveChannelProfileDir(channel, override) {
20604
20605
  return resolveBrowserProfileDir(channel, chosen);
20605
20606
  }
20606
20607
  async function checkChannelSession(config, opts) {
20607
- const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20608
+ const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
20608
20609
  const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
20609
20610
  let lastDetail = `${config.channel} readiness was never probed`;
20610
20611
  const deadline = Date.now() + timeoutMs;
@@ -246,23 +246,7 @@ export class XPostBrowserTransport implements PublishTransport {
246
246
  await textBox.press('Backspace').catch(() => {});
247
247
  await textBox.pressSequentially(text, { delay: 8 });
248
248
  const enabled = await expectOutcome(
249
- async () => {
250
- // Whichever submit control this surface renders: the page composer's
251
- // `tweetButton`, or the inline composer's `tweetButtonInline` on /home. Asked by
252
- // enablement, never by attachment — the page-scoped control is gone the moment the
253
- // surface navigates, and an absent control simply reads disabled.
254
- for (const selector of X_POST_SUBMITS) {
255
- if (
256
- await page
257
- .locator(selector)
258
- .first()
259
- .isEnabled()
260
- .catch(() => false)
261
- )
262
- return 'post enabled';
263
- }
264
- return null;
265
- },
249
+ async () => ((await this.findEnabledSubmit(page)) !== null ? 'post enabled' : null),
266
250
  // One step, capped at 10s: a caller may shrink the step (tests), never stretch it.
267
251
  { timeoutMs: Math.min(10_000, this.stepTimeoutMs), label: `x post enabled (attempt ${attempt})` },
268
252
  );
@@ -271,6 +255,36 @@ export class XPostBrowserTransport implements PublishTransport {
271
255
  return 'x post submit never enabled — the editor did not accept the text in three attempts';
272
256
  }
273
257
 
258
+ /**
259
+ * Locates an enabled submit control across page (`tweetButton`) and inline (`tweetButtonInline`)
260
+ * surfaces without letting `.first()` stall 30s on an absent node or pick a disabled hidden twin.
261
+ */
262
+ private async findEnabledSubmit(
263
+ page: Page,
264
+ opts: { preferVisible?: boolean } = {},
265
+ ): Promise<ReturnType<Page['locator']> | null> {
266
+ let enabledFallback: ReturnType<Page['locator']> | null = null;
267
+ for (const selector of X_POST_SUBMITS) {
268
+ const loc = page.locator(selector);
269
+ const count = await loc.count().catch(() => 0);
270
+ const limit = Math.max(1, count);
271
+ for (let index = 0; index < limit; index += 1) {
272
+ const candidate = index === 0 ? loc.first() : loc.nth(index);
273
+ const enabled = await candidate.isEnabled({ timeout: 1_000 }).catch(() => false);
274
+ if (!enabled) continue;
275
+ if (opts.preferVisible !== true) return candidate;
276
+ // A visible, enabled control is the real one; the composer page also renders a hidden
277
+ // template whose button is enabled-looking but never posts. Preferring visibility and
278
+ // accepting enabled-only when visibility cannot be established keeps a surface whose
279
+ // button reports no layout (and the test double) working.
280
+ const visible = await candidate.isVisible().catch(() => false);
281
+ if (visible) return candidate;
282
+ enabledFallback ??= candidate;
283
+ }
284
+ }
285
+ return enabledFallback;
286
+ }
287
+
274
288
  private async runPostFlow(
275
289
  page: Page,
276
290
  text: string,
@@ -319,14 +333,7 @@ export class XPostBrowserTransport implements PublishTransport {
319
333
  );
320
334
  if (!attached.ok) return fail(`x post image was uploaded but never rendered: ${attached.error}`);
321
335
  const reEnabled = await expectOutcome(
322
- async () =>
323
- (await page
324
- .locator(X_POST_SUBMIT)
325
- .first()
326
- .isEnabled()
327
- .catch(() => false))
328
- ? 'post re-enabled'
329
- : null,
336
+ async () => ((await this.findEnabledSubmit(page)) !== null ? 'post re-enabled' : null),
330
337
  // Four steps: X transcodes the image and only then re-enables Post (30s step → 120s).
331
338
  { timeoutMs: this.stepTimeoutMs * 4, label: 'x post submit enabled after media' },
332
339
  );
@@ -340,14 +347,18 @@ export class XPostBrowserTransport implements PublishTransport {
340
347
  ? Promise.resolve(null)
341
348
  : observable
342
349
  .evaluate(`(() => {
350
+ const readDisabled = (el) => el === null ? 'missing' : (el.getAttribute('aria-disabled') ?? (el.disabled === true ? 'true' : 'false'));
343
351
  const editor = document.querySelector('[data-testid="tweetTextarea_0"]');
344
352
  const submit = document.querySelector('${X_POST_SUBMIT}');
353
+ const inlineSubmit = document.querySelector('${X_POST_SUBMIT_INLINE}');
345
354
  const alerts = [...document.querySelectorAll('[data-testid="toast"], [role="alert"], [data-testid="error-detail"]')]
346
355
  .map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim()).filter(Boolean).slice(0, 3);
347
356
  const images = [...document.querySelectorAll('[data-testid="attachments"] img, [data-testid="tweetPhoto"] img')].length;
348
357
  return JSON.stringify({
358
+ url: location.pathname,
349
359
  textLen: (editor?.textContent || '').trim().length,
350
- submitDisabled: submit?.getAttribute('aria-disabled') ?? (submit?.disabled === true ? 'true' : 'false'),
360
+ submitDisabled: readDisabled(submit),
361
+ inlineDisabled: readDisabled(inlineSubmit),
351
362
  images,
352
363
  alerts,
353
364
  });
@@ -359,27 +370,9 @@ export class XPostBrowserTransport implements PublishTransport {
359
370
  }
360
371
  }
361
372
 
362
- // Click the submit that is actually VISIBLE and ENABLED, across both surfaces. The module
363
- // header already warns that the composer page carries a hidden template whose button never
364
- // enables; `.first()` on `tweetButton` can pick that twin and swallow the click, which reads
365
- // downstream as "Post was clicked but no new status id appeared" (measured 2026-11-20: two
366
- // runs, no status on the profile, no error either).
367
- const submit = await (async () => {
368
- let enabledFallback: ReturnType<typeof page.locator> | null = null;
369
- for (const selector of X_POST_SUBMITS) {
370
- const candidate = page.locator(selector).first();
371
- const enabled = await candidate.isEnabled().catch(() => false);
372
- if (!enabled) continue;
373
- // A visible, enabled control is the real one; the composer page also renders a hidden
374
- // template whose button is enabled-looking but never posts. Preferring visibility and
375
- // accepting enabled-only when visibility cannot be established keeps a surface whose
376
- // button reports no layout (and the test double) working.
377
- const visible = await candidate.isVisible().catch(() => false);
378
- if (visible) return candidate;
379
- enabledFallback ??= candidate;
380
- }
381
- return enabledFallback;
382
- })();
373
+ // Click the submit that is actually VISIBLE and ENABLED, across both surfaces (`tweetButton`
374
+ // / `tweetButtonInline` and non-first visible twins).
375
+ const submit = await this.findEnabledSubmit(page, { preferVisible: true });
383
376
  if (submit === null) return fail('x post submit was enabled a moment ago but no clickable control remained');
384
377
  await submit.click();
385
378
  // Capture the composer's immediate reaction. The receipt step navigates to the profile, so