@gobing-ai/knowledge-kit 0.1.22 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/index.js +282 -147
  3. package/package.json +5 -5
  4. package/plugins/generations/content-gen/dist/index.js +9 -9
  5. package/plugins/generations/core-facts-gen/dist/index.js +12 -12
  6. package/plugins/generations/daily-article-gen/dist/index.js +12 -12
  7. package/plugins/generations/dailynews-gen/dist/index.js +11 -11
  8. package/plugins/generations/dailynews-gen/src/script-plan.ts +2 -2
  9. package/plugins/generations/episode-plan-gen/dist/index.js +12 -12
  10. package/plugins/generations/gemini-tts/dist/index.js +56 -16
  11. package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
  12. package/plugins/generations/image-gen/dist/index.js +9 -9
  13. package/plugins/generations/music-gen/README.md +2 -2
  14. package/plugins/generations/music-gen/dist/index.js +62 -26
  15. package/plugins/generations/music-gen/presets/formats/song.yaml +6 -1
  16. package/plugins/generations/music-gen/presets/themes/synthwave.yaml +6 -1
  17. package/plugins/generations/music-gen/src/adapter/instance.ts +34 -11
  18. package/plugins/generations/music-gen/src/presets.ts +36 -3
  19. package/plugins/generations/news-report-gen/dist/index.js +12 -12
  20. package/plugins/generations/omni-voice-gen/uv.toml +5 -0
  21. package/plugins/generations/vibe-voice-tts/README.md +64 -0
  22. package/plugins/generations/vibe-voice-tts/dist/index.js +14259 -0
  23. package/plugins/generations/vibe-voice-tts/package.json +16 -0
  24. package/plugins/generations/vibe-voice-tts/plugin.json +6 -0
  25. package/plugins/generations/vibe-voice-tts/profiles.json +10 -0
  26. package/plugins/generations/vibe-voice-tts/pyproject.toml +9 -0
  27. package/plugins/generations/vibe-voice-tts/python/worker.py +566 -0
  28. package/plugins/generations/vibe-voice-tts/src/index.ts +88 -0
  29. package/plugins/generations/vibe-voice-tts/src/vibevoice-client.ts +828 -0
  30. package/plugins/generations/vibe-voice-tts/tsconfig.json +8 -0
  31. package/plugins/generations/vibe-voice-tts/uv.lock +1767 -0
  32. package/plugins/generations/vibe-voice-tts/uv.toml +4 -0
  33. package/plugins/generations/voice-gen/dist/index.js +40 -10
  34. package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
  35. package/plugins/generations/voxcpm-tts/dist/index.js +90 -18
  36. package/plugins/generations/voxcpm-tts/python/worker.py +9 -0
  37. package/plugins/generations/voxcpm-tts/src/index.ts +41 -0
  38. package/plugins/generations/voxcpm-tts/src/voxcpm-client.ts +32 -11
  39. package/plugins/generations/voxcpm-tts/uv.toml +5 -0
  40. package/plugins/ingestions/aihot-ingest/dist/index.js +12 -12
  41. package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
  42. package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
  43. package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
  44. package/plugins/ingestions/web-search/dist/index.js +10 -10
  45. package/plugins/kk/README.md +21 -0
  46. package/plugins/kk/decisions/kk-safety.yaml +5 -2
  47. package/plugins/kk/plugin.json +1 -1
  48. package/plugins/kk/publish-presets/daily-ai-voice.json +16 -16
  49. package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +12 -1
  50. package/plugins/kk/scripts/cover-compositor.ts +104 -26
  51. package/plugins/kk/scripts/daily-stages.ts +481 -63
  52. package/plugins/kk/scripts/kk-workflow-stages.ts +218 -17
  53. package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
  54. package/plugins/kk/scripts/series-names.ts +16 -3
  55. package/plugins/kk/skills/news-editorial/SKILL.md +1 -1
  56. package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
  57. package/plugins/kk/workflows/kk-daily-ai-voice.yaml +4 -3
  58. package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -5
  59. package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
  60. package/plugins/kk/workflows/kk-music.yaml +20 -16
  61. package/plugins/kk/workflows/kk-news-generate.yaml +26 -3
  62. package/plugins/kk/workflows/kk-publish.yaml +4 -1
  63. package/plugins/publishings/bilibili-pub/dist/index.js +22 -22
  64. package/plugins/publishings/bilibili-pub/dist/profile-check.js +22 -22
  65. package/plugins/publishings/cnblogs-pub/dist/index.js +22 -22
  66. package/plugins/publishings/cnblogs-pub/dist/profile-check.js +22 -22
  67. package/plugins/publishings/csdn-pub/dist/index.js +22 -22
  68. package/plugins/publishings/csdn-pub/dist/profile-check.js +22 -22
  69. package/plugins/publishings/emdash-pub/dist/index.js +9 -9
  70. package/plugins/publishings/infoq-pub/dist/index.js +22 -22
  71. package/plugins/publishings/infoq-pub/dist/profile-check.js +22 -22
  72. package/plugins/publishings/jike-pub/dist/index.js +22 -22
  73. package/plugins/publishings/jike-pub/dist/profile-check.js +22 -22
  74. package/plugins/publishings/juejin-pub/dist/index.js +22 -22
  75. package/plugins/publishings/juejin-pub/dist/profile-check.js +22 -22
  76. package/plugins/publishings/linkedin-pub/dist/index.js +133 -33
  77. package/plugins/publishings/linkedin-pub/dist/profile-check.js +27 -22
  78. package/plugins/publishings/linkedin-pub/src/index.ts +192 -18
  79. package/plugins/publishings/medium-pub/dist/index.js +9 -9
  80. package/plugins/publishings/podcast-pub/dist/index.js +240 -37
  81. package/plugins/publishings/podcast-pub/src/index.ts +154 -3
  82. package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
  83. package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
  84. package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
  85. package/plugins/publishings/qiita-pub/dist/index.js +9 -9
  86. package/plugins/publishings/shipinhao-pub/dist/index.js +23 -23
  87. package/plugins/publishings/shipinhao-pub/dist/profile-check.js +23 -23
  88. package/plugins/publishings/shipinhao-pub/src/selectors.ts +2 -1
  89. package/plugins/publishings/sspai-pub/dist/index.js +22 -22
  90. package/plugins/publishings/sspai-pub/dist/profile-check.js +22 -22
  91. package/plugins/publishings/substack-pub/dist/index.js +22 -22
  92. package/plugins/publishings/substack-pub/dist/profile-check.js +22 -22
  93. package/plugins/publishings/surfdash-pub/dist/index.js +207 -95
  94. package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
  95. package/plugins/publishings/surfdash-pub/src/index.ts +101 -76
  96. package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
  97. package/plugins/publishings/surfdash-pub/src/patch.ts +49 -26
  98. package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
  99. package/plugins/publishings/threads-pub/dist/index.js +83 -27
  100. package/plugins/publishings/threads-pub/dist/profile-check.js +34 -23
  101. package/plugins/publishings/threads-pub/src/post-rail.ts +121 -4
  102. package/plugins/publishings/wechatmp-pub/dist/index.js +274 -98
  103. package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
  104. package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
  105. package/plugins/publishings/wechatmp-pub/src/enrich.ts +117 -13
  106. package/plugins/publishings/wechatmp-pub/src/flow.ts +183 -43
  107. package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
  108. package/plugins/publishings/weibo-pub/dist/index.js +22 -22
  109. package/plugins/publishings/weibo-pub/dist/profile-check.js +22 -22
  110. package/plugins/publishings/x-pub/dist/index.js +113 -32
  111. package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
  112. package/plugins/publishings/x-pub/src/post-rail.ts +155 -20
  113. package/plugins/publishings/xhs-pub/dist/index.js +22 -22
  114. package/plugins/publishings/xhs-pub/dist/profile-check.js +22 -22
  115. package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +22 -22
  116. package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +22 -22
  117. package/plugins/publishings/zenn-pub/dist/index.js +9 -9
@@ -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();
@@ -20096,11 +20096,11 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
20096
20096
  });
20097
20097
  }
20098
20098
  });
20099
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
20099
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
20100
20100
  init_file_system_node();
20101
20101
  init_config();
20102
20102
 
20103
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/path.js
20103
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/path.js
20104
20104
  function normalizeSeparators(path) {
20105
20105
  return path.replaceAll("\\", "/");
20106
20106
  }
@@ -20158,7 +20158,7 @@ function getProcessCwd() {
20158
20158
  return globalThis.process?.cwd?.() ?? "/";
20159
20159
  }
20160
20160
 
20161
- // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.5.32+180a6e424da77181/node_modules/@gobing-ai/ts-runtime/dist/index.js
20161
+ // ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
20162
20162
  init_runtime_node_bun();
20163
20163
 
20164
20164
  // ../../packages/kk-core/src/render-md.ts
@@ -20256,7 +20256,7 @@ import { extname, isAbsolute as isAbsolute2 } from "path";
20256
20256
  // ../../packages/publish-harness/src/browser.ts
20257
20257
  import { join as join5, resolve as resolve5 } from "path";
20258
20258
 
20259
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
20259
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/errors.js
20260
20260
  class BrowserAutomationError extends Error {
20261
20261
  constructor(message, options) {
20262
20262
  super(message, options);
@@ -20305,10 +20305,10 @@ class OperationAbortedError extends BrowserAutomationError {
20305
20305
  this.name = "OperationAbortedError";
20306
20306
  }
20307
20307
  }
20308
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20308
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20309
20309
  import { mkdir } from "fs/promises";
20310
20310
 
20311
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
20311
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/profile-dir.js
20312
20312
  function resolveProfileDir(profileDir) {
20313
20313
  if (profileDir.trim() === "") {
20314
20314
  throw new InvalidProfileDirError;
@@ -20320,7 +20320,7 @@ function resolveProfileDir(profileDir) {
20320
20320
  return resolved;
20321
20321
  }
20322
20322
 
20323
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20323
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/launcher.js
20324
20324
  var PROFILE_DIR_MODE = 448;
20325
20325
  var BUSY_PROFILE_PATTERN = /singleton|already in use|in use by another/i;
20326
20326
  var CHROMIUM_MISSING_PATTERN = /playwright install|executable doesn't exist/i;
@@ -20371,7 +20371,7 @@ function createPersistentLauncher(options = {}) {
20371
20371
  };
20372
20372
  }
20373
20373
 
20374
- // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.5.32+0f5f0476d0d466a6/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20374
+ // ../../node_modules/.bun/@gobing-ai+ts-browser-automation@0.8.4+7a0bf9ce62a9b753/node_modules/@gobing-ai/ts-browser-automation/dist/operations.js
20375
20375
  var DEFAULT_TIMEOUT_MS = 30000;
20376
20376
  var POLL_INTERVAL_MS = 250;
20377
20377
  var defaultLauncher;
@@ -21004,6 +21004,7 @@ var TARGET = "threads";
21004
21004
  var THREADS_HOME_URL = "https://www.threads.com";
21005
21005
  var THREADS_LOGIN_INSTRUCTION = "bun plugins/publishings/threads-pub/src/profile-check.ts login";
21006
21006
  var STEP_TIMEOUT_MS = 30000;
21007
+ var LINK_PREVIEW_TIMEOUT_MS = 1e4;
21007
21008
  var LOGIN_TIMEOUT_MS = 180000;
21008
21009
  var LOGIN_URL_RE = /(?:^|\.)threads\.(?:net|com)\/(?:login|accounts)|instagram\.com\/accounts\/login/;
21009
21010
  var COVER_EXTS = new Set([".png", ".jpg", ".jpeg", ".webp"]);
@@ -21014,10 +21015,21 @@ var THREADS_POST_SELECTORS = {
21014
21015
  'div[aria-label^="Empty text field"]',
21015
21016
  'div[role="textbox"][contenteditable="true"]'
21016
21017
  ],
21017
- submit: ['div[role="button"]:text-is("Post"):visible', 'button:text-is("Post"):visible'],
21018
+ submit: [
21019
+ 'div[role="button"]:has(> div:text-is("Post")):visible',
21020
+ 'div[role="button"]:has(div:text-is("Post")):visible',
21021
+ 'div[role="button"]:text-is("Post"):visible',
21022
+ 'button:text-is("Post"):visible',
21023
+ 'div[role="button"][aria-label="Post"]:visible'
21024
+ ],
21018
21025
  mediaButton: ['div[role="button"]:text-is("Attach media")', 'div[aria-label*="Attach media" i]'],
21019
21026
  fileInput: ['input[type="file"]'],
21020
21027
  mediaPreview: ['div[role="dialog"] img[src*="cdninstagram"], div[role="dialog"] img[src*="fbcdn"]'],
21028
+ linkPreview: [
21029
+ 'div[role="dialog"] a[role="link"][href*="l.threads.com"]',
21030
+ 'div[role="dialog"] img[src*="fbcdn.net/emg1"]',
21031
+ 'div[role="dialog"] img[src*="external"]'
21032
+ ],
21021
21033
  profileLink: ['a[href^="/@"]'],
21022
21034
  placeholder: 'div[aria-label^="Empty text field"]'
21023
21035
  };
@@ -21152,7 +21164,7 @@ class ThreadsPostBrowserTransport {
21152
21164
  await page.keyboard.type(text, { delay: 12 });
21153
21165
  await evidence(page, "04-typed");
21154
21166
  const readback = await expectOutcome(async () => {
21155
- const value = String(await editor.evaluate(`(() => { const el = arguments[0]; return (el.innerText || el.textContent || el.value || ''); })()`).catch(() => ""));
21167
+ const value = String(await editor.evaluate(`(el) => (el.innerText || el.textContent || el.value || '')`).catch(() => ""));
21156
21168
  return value.trim().length > 0 ? "text retained" : null;
21157
21169
  }, { timeoutMs: this.stepTimeoutMs, label: "threads post readback" });
21158
21170
  if (!readback.ok) {
@@ -21170,14 +21182,58 @@ class ThreadsPostBrowserTransport {
21170
21182
  await uploadFile(page, input, coverPath, { timeoutMs: this.stepTimeoutMs });
21171
21183
  await expectOutcome(async () => await page.locator(THREADS_POST_SELECTORS.mediaPreview[0]).count() > 0 ? "media attached" : null, { timeoutMs: this.stepTimeoutMs, label: "threads post media" });
21172
21184
  }
21185
+ } else if (/https?:\/\/\S+/i.test(text)) {
21186
+ await expectOutcome(async () => {
21187
+ const found = await trySelectors(page, THREADS_POST_SELECTORS.linkPreview);
21188
+ return found.found ? found.selector ?? THREADS_POST_SELECTORS.linkPreview[0] : null;
21189
+ }, {
21190
+ timeoutMs: Math.min(this.stepTimeoutMs, LINK_PREVIEW_TIMEOUT_MS),
21191
+ label: "threads link preview"
21192
+ });
21173
21193
  }
21174
21194
  const submit = await expectOutcome(async () => {
21195
+ const roleEngine = page;
21196
+ const byRole = roleEngine.getByRole?.("button", { name: "Post", exact: true });
21197
+ const roleCount = byRole === undefined ? 0 : await byRole.count().catch(() => 0);
21198
+ if (roleCount > 0)
21199
+ return `role:Post:${roleCount}`;
21175
21200
  const found = await trySelectors(page, THREADS_POST_SELECTORS.submit);
21176
21201
  return found.found ? found.selector ?? THREADS_POST_SELECTORS.submit[0] : null;
21177
21202
  }, { timeoutMs: this.stepTimeoutMs, label: "threads post submit" });
21178
- if (!submit.ok)
21179
- return fail(`threads post control never attached: ${submit.error}`);
21180
- await page.locator(submit.evidence).first().click();
21203
+ if (!submit.ok) {
21204
+ await evidence(page, "06-submit-missing");
21205
+ const observable = page;
21206
+ const inventory = await (observable.evaluate === undefined ? Promise.resolve(null) : observable.evaluate(`(() => {
21207
+ // Search the WHOLE document, not one dialog: the composer may not be the first
21208
+ // [role=dialog] in DOM order (which is why an earlier inventory listed the
21209
+ // composer's chips but not its Post control), and Post may carry no role at all.
21210
+ const hits = [...document.querySelectorAll('*')]
21211
+ .filter((n) => n.children.length === 0 && (n.textContent || '').trim() === 'Post')
21212
+ .map((n) => {
21213
+ const p = n.parentElement;
21214
+ return n.tagName + (n.getAttribute('role') ? '[role=' + n.getAttribute('role') + ']' : '')
21215
+ + (n.getAttribute('aria-label') ? '[aria=' + n.getAttribute('aria-label') + ']' : '')
21216
+ + ' < ' + (p?.tagName ?? '') + (p?.getAttribute('role') ? '[role=' + p.getAttribute('role') + ']' : '')
21217
+ + (p?.className ? '.' + String(p.className).split(/\\s+/).slice(0, 2).join('.') : '');
21218
+ });
21219
+ return hits.slice(0, 4).join(' | ') || 'no element whose text is exactly Post';
21220
+ })()`).catch(() => null));
21221
+ return fail(`threads post control never attached: ${submit.error}${inventory ? ` (dialog buttons: ${String(inventory)})` : ""}`);
21222
+ }
21223
+ const dismiss = await page.locator('div[role="button"]:text-is("Dismiss suggestions"), div[role="button"]:has(> div:text-is("Dismiss suggestions"))').first().click({ timeout: 3000 }).then(() => true).catch(() => false);
21224
+ if (dismiss)
21225
+ await page.waitForTimeout(500);
21226
+ const submitEvidence = String(submit.evidence);
21227
+ if (submitEvidence.startsWith("role:Post:")) {
21228
+ const rolePost = page.getByRole("button", { name: "Post", exact: true });
21229
+ await rolePost.last().click({ timeout: this.stepTimeoutMs });
21230
+ } else {
21231
+ await page.locator(submitEvidence).first().click({ timeout: this.stepTimeoutMs }).catch(async () => {
21232
+ await page.locator(submitEvidence).first().click({ force: true });
21233
+ });
21234
+ }
21235
+ await page.waitForTimeout(2500);
21236
+ await evidence(page, "07-post-clicked");
21181
21237
  const receipt = await expectOutcome(async () => {
21182
21238
  const id = await this.newestPostId(page, handle);
21183
21239
  if (id === null)
@@ -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;
@@ -21123,10 +21123,21 @@ var THREADS_POST_SELECTORS = {
21123
21123
  'div[aria-label^="Empty text field"]',
21124
21124
  'div[role="textbox"][contenteditable="true"]'
21125
21125
  ],
21126
- submit: ['div[role="button"]:text-is("Post"):visible', 'button:text-is("Post"):visible'],
21126
+ submit: [
21127
+ 'div[role="button"]:has(> div:text-is("Post")):visible',
21128
+ 'div[role="button"]:has(div:text-is("Post")):visible',
21129
+ 'div[role="button"]:text-is("Post"):visible',
21130
+ 'button:text-is("Post"):visible',
21131
+ 'div[role="button"][aria-label="Post"]:visible'
21132
+ ],
21127
21133
  mediaButton: ['div[role="button"]:text-is("Attach media")', 'div[aria-label*="Attach media" i]'],
21128
21134
  fileInput: ['input[type="file"]'],
21129
21135
  mediaPreview: ['div[role="dialog"] img[src*="cdninstagram"], div[role="dialog"] img[src*="fbcdn"]'],
21136
+ linkPreview: [
21137
+ 'div[role="dialog"] a[role="link"][href*="l.threads.com"]',
21138
+ 'div[role="dialog"] img[src*="fbcdn.net/emg1"]',
21139
+ 'div[role="dialog"] img[src*="external"]'
21140
+ ],
21130
21141
  profileLink: ['a[href^="/@"]'],
21131
21142
  placeholder: 'div[aria-label^="Empty text field"]'
21132
21143
  };
@@ -35,6 +35,7 @@ export const THREADS_HOME_URL = 'https://www.threads.com';
35
35
  export const THREADS_LOGIN_INSTRUCTION = 'bun plugins/publishings/threads-pub/src/profile-check.ts login';
36
36
 
37
37
  const STEP_TIMEOUT_MS = 30_000;
38
+ const LINK_PREVIEW_TIMEOUT_MS = 10_000;
38
39
  const LOGIN_TIMEOUT_MS = 180_000;
39
40
  const LOGIN_URL_RE = /(?:^|\.)threads\.(?:net|com)\/(?:login|accounts)|instagram\.com\/accounts\/login/;
40
41
  const COVER_EXTS = new Set(['.png', '.jpg', '.jpeg', '.webp']);
@@ -56,10 +57,27 @@ export const THREADS_POST_SELECTORS = {
56
57
  'div[aria-label^="Empty text field"]',
57
58
  'div[role="textbox"][contenteditable="true"]',
58
59
  ],
59
- submit: ['div[role="button"]:text-is("Post"):visible', 'button:text-is("Post"):visible'],
60
+ // Threads renders the label as a CHILD div inside the role=button element, so `text-is` on the
61
+ // button misses whenever the button carries more than the bare label (measured 2026-11-20: the
62
+ // element with text "Post" was `DIV < DIV[role=button]`, and every selector below found nothing).
63
+ // The `:has` shapes match either nesting; the direct forms stay for the plain surface.
64
+ submit: [
65
+ 'div[role="button"]:has(> div:text-is("Post")):visible',
66
+ 'div[role="button"]:has(div:text-is("Post")):visible',
67
+ 'div[role="button"]:text-is("Post"):visible',
68
+ 'button:text-is("Post"):visible',
69
+ 'div[role="button"][aria-label="Post"]:visible',
70
+ ],
60
71
  mediaButton: ['div[role="button"]:text-is("Attach media")', 'div[aria-label*="Attach media" i]'],
61
72
  fileInput: ['input[type="file"]'],
62
73
  mediaPreview: ['div[role="dialog"] img[src*="cdninstagram"], div[role="dialog"] img[src*="fbcdn"]'],
74
+ // Measured 2026-11-21: Threads fetches the URL's OG card asynchronously (~1-2s after typing)
75
+ // inside the composer dialog as an `l.threads.com` link + `fbcdn.net/emg1` image.
76
+ linkPreview: [
77
+ 'div[role="dialog"] a[role="link"][href*="l.threads.com"]',
78
+ 'div[role="dialog"] img[src*="fbcdn.net/emg1"]',
79
+ 'div[role="dialog"] img[src*="external"]',
80
+ ],
63
81
  profileLink: ['a[href^="/@"]'],
64
82
  /** The inline composer's placeholder — the pre-type readiness signal. */
65
83
  placeholder: 'div[aria-label^="Empty text field"]',
@@ -270,7 +288,12 @@ export class ThreadsPostBrowserTransport implements PublishTransport {
270
288
  const value = String(
271
289
  await editor
272
290
  .evaluate(
273
- `(() => { const el = arguments[0]; return (el.innerText || el.textContent || el.value || ''); })()`,
291
+ // Playwright hands the element to this expression as its first
292
+ // parameter. The arrow IIFE that read `arguments[0]` had no `arguments`
293
+ // binding at all, so it threw into the `.catch('')` below and every
294
+ // typed post read as "not retained" (measured 2026-11-20: the composer
295
+ // screenshot showed the full text and Post enabled).
296
+ `(el) => (el.innerText || el.textContent || el.value || '')`,
274
297
  )
275
298
  .catch(() => ''),
276
299
  );
@@ -304,18 +327,112 @@ export class ThreadsPostBrowserTransport implements PublishTransport {
304
327
  { timeoutMs: this.stepTimeoutMs, label: 'threads post media' },
305
328
  );
306
329
  }
330
+ } else if (/https?:\/\/\S+/i.test(text)) {
331
+ // Best-effort wait so Post does not race ahead of Threads' async OG card attachment.
332
+ await expectOutcome(
333
+ async () => {
334
+ const found = await trySelectors(page, THREADS_POST_SELECTORS.linkPreview);
335
+ return found.found ? (found.selector ?? THREADS_POST_SELECTORS.linkPreview[0]) : null;
336
+ },
337
+ {
338
+ timeoutMs: Math.min(this.stepTimeoutMs, LINK_PREVIEW_TIMEOUT_MS),
339
+ label: 'threads link preview',
340
+ },
341
+ );
307
342
  }
308
343
 
309
344
  const submit = await expectOutcome(
310
345
  async () => {
346
+ // Prefer the role engine: Threads puts the label in a CHILD div of a role=button, so a
347
+ // CSS `:text-is` on the parent only matches when the parent holds nothing else, and a
348
+ // selector the harness has to normalize can degrade to a bare `div[role="button"]`
349
+ // whose FIRST match is the composer's Cancel — which is exactly the "Save to drafts?"
350
+ // leave-guard observed on 2026-11-20. `getByRole` derives the accessible name from the
351
+ // child text, so it names the control the user sees.
352
+ const roleEngine = page as unknown as {
353
+ getByRole?: (
354
+ role: string,
355
+ options: { name: string; exact: boolean },
356
+ ) => { count(): Promise<number> };
357
+ };
358
+ const byRole = roleEngine.getByRole?.('button', { name: 'Post', exact: true });
359
+ const roleCount = byRole === undefined ? 0 : await byRole.count().catch(() => 0);
360
+ if (roleCount > 0) return `role:Post:${roleCount}`;
311
361
  const found = await trySelectors(page, THREADS_POST_SELECTORS.submit);
312
362
  return found.found ? (found.selector ?? THREADS_POST_SELECTORS.submit[0]) : null;
313
363
  },
314
364
  { timeoutMs: this.stepTimeoutMs, label: 'threads post submit' },
315
365
  );
316
- if (!submit.ok) return fail(`threads post control never attached: ${submit.error}`);
317
- await page.locator(submit.evidence).first().click();
366
+ if (!submit.ok) {
367
+ // The composer's Post control is a styled div whose text Playwright's `:text-is` must
368
+ // match exactly; a label tweak ("Post" → "Post\u00a0" / an icon-only button) leaves the
369
+ // selector list matching nothing while the button is plainly on screen. Report the
370
+ // dialog's actual clickable inventory instead of the timeout.
371
+ await evidence(page, '06-submit-missing');
372
+ const observable = page as unknown as { evaluate?: (script: string) => Promise<unknown> };
373
+ const inventory = await (observable.evaluate === undefined
374
+ ? Promise.resolve(null)
375
+ : observable
376
+ .evaluate(`(() => {
377
+ // Search the WHOLE document, not one dialog: the composer may not be the first
378
+ // [role=dialog] in DOM order (which is why an earlier inventory listed the
379
+ // composer's chips but not its Post control), and Post may carry no role at all.
380
+ const hits = [...document.querySelectorAll('*')]
381
+ .filter((n) => n.children.length === 0 && (n.textContent || '').trim() === 'Post')
382
+ .map((n) => {
383
+ const p = n.parentElement;
384
+ return n.tagName + (n.getAttribute('role') ? '[role=' + n.getAttribute('role') + ']' : '')
385
+ + (n.getAttribute('aria-label') ? '[aria=' + n.getAttribute('aria-label') + ']' : '')
386
+ + ' < ' + (p?.tagName ?? '') + (p?.getAttribute('role') ? '[role=' + p.getAttribute('role') + ']' : '')
387
+ + (p?.className ? '.' + String(p.className).split(/\\s+/).slice(0, 2).join('.') : '');
388
+ });
389
+ return hits.slice(0, 4).join(' | ') || 'no element whose text is exactly Post';
390
+ })()`)
391
+ .catch(() => null));
392
+ return fail(
393
+ `threads post control never attached: ${submit.error}${inventory ? ` (dialog buttons: ${String(inventory)})` : ''}`,
394
+ );
395
+ }
396
+ // The composer rides under a suggestions layer that intercepts pointer events
397
+ // (`<div class="__fb-light-mode …"> intercepts pointer events`, measured 2026-11-20). A
398
+ // forced click dispatches onto that layer and posts NOTHING — the profile stayed unchanged —
399
+ // so dismiss the layer first and click for real. The force click remains as a fallback for a
400
+ // surface that reports a transient overlay.
401
+ const dismiss = await page
402
+ .locator(
403
+ 'div[role="button"]:text-is("Dismiss suggestions"), div[role="button"]:has(> div:text-is("Dismiss suggestions"))',
404
+ )
405
+ .first()
406
+ .click({ timeout: 3_000 })
407
+ .then(() => true)
408
+ .catch(() => false);
409
+ if (dismiss) await page.waitForTimeout(500);
410
+ const submitEvidence = String(submit.evidence);
411
+ if (submitEvidence.startsWith('role:Post:')) {
412
+ // The composer's Post is the LAST match (the feed's inline composer sits behind it).
413
+ const rolePost = (
414
+ page as unknown as {
415
+ getByRole: (
416
+ role: string,
417
+ options: { name: string; exact: boolean },
418
+ ) => {
419
+ last(): { click(options: { timeout: number }): Promise<unknown> };
420
+ };
421
+ }
422
+ ).getByRole('button', { name: 'Post', exact: true });
423
+ await rolePost.last().click({ timeout: this.stepTimeoutMs });
424
+ } else {
425
+ await page
426
+ .locator(submitEvidence)
427
+ .first()
428
+ .click({ timeout: this.stepTimeoutMs })
429
+ .catch(async () => {
430
+ await page.locator(submitEvidence).first().click({ force: true });
431
+ });
432
+ }
318
433
 
434
+ await page.waitForTimeout(2_500);
435
+ await evidence(page, '07-post-clicked');
319
436
  const receipt = await expectOutcome(
320
437
  async () => {
321
438
  const id = await this.newestPostId(page, handle);