@gobing-ai/knowledge-kit 0.1.20 → 0.1.23
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/board/collect/index.js +1 -0
- package/dist/board/daily-voice/index.js +1279 -261
- package/dist/board/itc/index.js +1 -0
- package/dist/index.js +13938 -8966
- package/package.json +1 -1
- package/plugins/generations/dailynews-gen/dist/index.js +285 -16
- package/plugins/generations/dailynews-gen/src/editorial-claims.ts +215 -0
- package/plugins/generations/dailynews-gen/src/index.ts +23 -4
- package/plugins/generations/dailynews-gen/src/script-builder.ts +10 -3
- package/plugins/generations/dailynews-gen/src/script-plan.ts +74 -14
- package/plugins/generations/gemini-tts/dist/index.js +47 -7
- package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
- package/plugins/generations/music-gen/README.md +277 -0
- package/plugins/generations/music-gen/dist/index.js +23580 -0
- package/plugins/generations/music-gen/package.json +24 -0
- package/plugins/generations/music-gen/plugin.json +23 -0
- package/plugins/generations/music-gen/presets/SOURCE.md +39 -0
- package/plugins/generations/music-gen/presets/formats/clip.yaml +21 -0
- package/plugins/generations/music-gen/presets/formats/jingle.yaml +22 -0
- package/plugins/generations/music-gen/presets/formats/loop.yaml +21 -0
- package/plugins/generations/music-gen/presets/formats/song.yaml +36 -0
- package/plugins/generations/music-gen/presets/formats/underscore.yaml +22 -0
- package/plugins/generations/music-gen/presets/themes/ambient-tech.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/cinematic.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/lofi.yaml +30 -0
- package/plugins/generations/music-gen/presets/themes/synthwave.yaml +35 -0
- package/plugins/generations/music-gen/scripts/gen-preset-index.ts +181 -0
- package/plugins/generations/music-gen/scripts/resolve-preset.ts +64 -0
- package/plugins/generations/music-gen/src/adapter/index.ts +35 -0
- package/plugins/generations/music-gen/src/adapter/instance.ts +927 -0
- package/plugins/generations/music-gen/src/adapter/offline.ts +124 -0
- package/plugins/generations/music-gen/src/artifact.ts +223 -0
- package/plugins/generations/music-gen/src/audio/checks.ts +618 -0
- package/plugins/generations/music-gen/src/audio/master.ts +267 -0
- package/plugins/generations/music-gen/src/audio/measure.ts +507 -0
- package/plugins/generations/music-gen/src/audio/profile.ts +131 -0
- package/plugins/generations/music-gen/src/audio.ts +122 -0
- package/plugins/generations/music-gen/src/brief.ts +191 -0
- package/plugins/generations/music-gen/src/config.ts +451 -0
- package/plugins/generations/music-gen/src/content.ts +199 -0
- package/plugins/generations/music-gen/src/digest.ts +100 -0
- package/plugins/generations/music-gen/src/index.ts +147 -0
- package/plugins/generations/music-gen/src/job.ts +131 -0
- package/plugins/generations/music-gen/src/plugin.ts +371 -0
- package/plugins/generations/music-gen/src/presets.ts +951 -0
- package/plugins/generations/music-gen/src/render.ts +87 -0
- package/plugins/generations/music-gen/src/request.ts +102 -0
- package/plugins/generations/music-gen/src/spend.ts +495 -0
- package/plugins/generations/music-gen/tsconfig.json +8 -0
- package/plugins/generations/omni-voice-gen/uv.toml +5 -0
- package/plugins/generations/vibe-voice-tts/README.md +64 -0
- package/plugins/generations/vibe-voice-tts/dist/index.js +14259 -0
- package/plugins/generations/vibe-voice-tts/package.json +16 -0
- package/plugins/generations/vibe-voice-tts/plugin.json +6 -0
- package/plugins/generations/vibe-voice-tts/profiles.json +10 -0
- package/plugins/generations/vibe-voice-tts/pyproject.toml +9 -0
- package/plugins/generations/vibe-voice-tts/python/worker.py +566 -0
- package/plugins/generations/vibe-voice-tts/src/index.ts +88 -0
- package/plugins/generations/vibe-voice-tts/src/vibevoice-client.ts +828 -0
- package/plugins/generations/vibe-voice-tts/tsconfig.json +8 -0
- package/plugins/generations/vibe-voice-tts/uv.lock +1767 -0
- package/plugins/generations/vibe-voice-tts/uv.toml +4 -0
- package/plugins/generations/voice-gen/dist/index.js +31 -1
- package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
- package/plugins/generations/voxcpm-tts/dist/index.js +81 -9
- package/plugins/generations/voxcpm-tts/python/worker.py +9 -0
- package/plugins/generations/voxcpm-tts/src/index.ts +41 -0
- package/plugins/generations/voxcpm-tts/src/voxcpm-client.ts +32 -11
- package/plugins/generations/voxcpm-tts/uv.toml +5 -0
- package/plugins/kk/README.md +21 -0
- package/plugins/kk/decisions/kk-safety.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +14 -2
- package/plugins/kk/scripts/cover-compositor.ts +380 -32
- package/plugins/kk/scripts/daily-cover-mock.ts +40 -3
- package/plugins/kk/scripts/daily-stages.ts +933 -60
- package/plugins/kk/scripts/episode-identity.ts +180 -0
- package/plugins/kk/scripts/kk-workflow-stages.ts +111 -12
- package/plugins/kk/scripts/music-stages.ts +624 -0
- package/plugins/kk/scripts/news-editorial-ledger.ts +906 -0
- package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
- package/plugins/kk/scripts/source-citation.ts +187 -0
- package/plugins/kk/scripts/topic-selection-attempts.ts +446 -0
- package/plugins/kk/scripts/topic-selection-calibration.ts +161 -0
- package/plugins/kk/skills/content-judge/SKILL.md +11 -6
- package/plugins/kk/skills/content-judge/references/music-quality-rubric.md +147 -0
- package/plugins/kk/skills/content-judge/references/rubrics.md +15 -0
- package/plugins/kk/skills/content-safety/SKILL.md +12 -0
- package/plugins/kk/skills/music-authoring/SKILL.md +276 -0
- package/plugins/kk/skills/music-authoring/references/judge-input.md +117 -0
- package/plugins/kk/skills/news-editorial/SKILL.md +102 -15
- package/plugins/kk/skills/news-editorial/references/selection.md +4 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +58 -11
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +12 -11
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +13 -12
- package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
- package/plugins/kk/workflows/kk-music.yaml +332 -0
- package/plugins/kk/workflows/kk-news-generate.yaml +81 -6
- package/plugins/kk/workflows/kk-publish.yaml +4 -1
- package/plugins/publishings/bilibili-pub/dist/index.js +11 -1
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/cnblogs-pub/dist/index.js +11 -1
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/csdn-pub/dist/index.js +11 -1
- package/plugins/publishings/csdn-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/infoq-pub/dist/index.js +11 -1
- package/plugins/publishings/infoq-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/jike-pub/dist/index.js +11 -1
- package/plugins/publishings/jike-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/juejin-pub/dist/index.js +11 -1
- package/plugins/publishings/juejin-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/linkedin-pub/dist/index.js +62 -10
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +16 -1
- package/plugins/publishings/linkedin-pub/src/index.ts +99 -12
- package/plugins/publishings/podcast-pub/dist/index.js +586 -20
- package/plugins/publishings/podcast-pub/src/corrections.ts +509 -0
- package/plugins/publishings/podcast-pub/src/index.ts +257 -5
- package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +240 -0
- package/plugins/publishings/podcast-pub/src/show-notes.ts +69 -13
- package/plugins/publishings/shipinhao-pub/dist/index.js +59 -8
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +105 -6
- package/plugins/publishings/sspai-pub/dist/index.js +11 -1
- package/plugins/publishings/sspai-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/substack-pub/dist/index.js +11 -1
- package/plugins/publishings/substack-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/surfdash-pub/dist/index.js +80 -24
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +7 -3
- package/plugins/publishings/surfdash-pub/src/index.ts +107 -18
- package/plugins/publishings/surfdash-pub/src/patch.ts +21 -3
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +3 -1
- package/plugins/publishings/threads-pub/dist/index.js +58 -6
- package/plugins/publishings/threads-pub/dist/profile-check.js +18 -2
- package/plugins/publishings/threads-pub/src/post-rail.ts +101 -4
- package/plugins/publishings/wechatmp-pub/dist/index.js +105 -35
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +61 -3
- package/plugins/publishings/wechatmp-pub/src/flow.ts +28 -0
- package/plugins/publishings/weibo-pub/dist/index.js +11 -1
- package/plugins/publishings/weibo-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/x-pub/dist/index.js +95 -10
- package/plugins/publishings/x-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/x-pub/src/post-rail.ts +154 -12
- package/plugins/publishings/xhs-pub/dist/index.js +11 -1
- package/plugins/publishings/xhs-pub/dist/profile-check.js +11 -1
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +11 -1
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +11 -1
|
@@ -20482,6 +20482,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
|
20482
20482
|
var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
|
|
20483
20483
|
var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
|
|
20484
20484
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20485
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20486
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20487
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20485
20488
|
var DEFAULT_POLL_MS = 500;
|
|
20486
20489
|
function isInstantBrowserDeath(message) {
|
|
20487
20490
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
@@ -20604,14 +20607,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20604
20607
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20605
20608
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20606
20609
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20610
|
+
const deadline = Date.now() + timeoutMs;
|
|
20611
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20612
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20613
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20607
20614
|
for (const headless of passes) {
|
|
20615
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20616
|
+
if (remainingMs < minPassMs)
|
|
20617
|
+
break;
|
|
20608
20618
|
try {
|
|
20609
20619
|
await withProfilePage({
|
|
20610
20620
|
profileDir: opts.profileDir,
|
|
20611
20621
|
headless,
|
|
20612
20622
|
url: config.homeUrl,
|
|
20613
20623
|
isAuthenticated: config.isAuthenticated,
|
|
20614
|
-
timeoutMs,
|
|
20624
|
+
timeoutMs: remainingMs,
|
|
20615
20625
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20616
20626
|
}, async () => true);
|
|
20617
20627
|
return {
|
|
@@ -20776,6 +20776,9 @@ async function ensureProfileDir2(profileDir, headless) {
|
|
|
20776
20776
|
var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
20777
20777
|
// ../../packages/publish-harness/src/browser.ts
|
|
20778
20778
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20779
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20780
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20781
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20779
20782
|
var DEFAULT_STEP_TIMEOUT_MS = 30000;
|
|
20780
20783
|
var DEFAULT_POLL_MS = 500;
|
|
20781
20784
|
var ATTACH_POLL_MS = 100;
|
|
@@ -20900,14 +20903,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20900
20903
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20901
20904
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20902
20905
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20906
|
+
const deadline = Date.now() + timeoutMs;
|
|
20907
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20908
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20909
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20903
20910
|
for (const headless of passes) {
|
|
20911
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20912
|
+
if (remainingMs < minPassMs)
|
|
20913
|
+
break;
|
|
20904
20914
|
try {
|
|
20905
20915
|
await withProfilePage({
|
|
20906
20916
|
profileDir: opts.profileDir,
|
|
20907
20917
|
headless,
|
|
20908
20918
|
url: config.homeUrl,
|
|
20909
20919
|
isAuthenticated: config.isAuthenticated,
|
|
20910
|
-
timeoutMs,
|
|
20920
|
+
timeoutMs: remainingMs,
|
|
20911
20921
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20912
20922
|
}, async () => true);
|
|
20913
20923
|
return {
|
|
@@ -20482,6 +20482,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
|
20482
20482
|
var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
|
|
20483
20483
|
var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
|
|
20484
20484
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20485
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20486
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20487
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20485
20488
|
var DEFAULT_POLL_MS = 500;
|
|
20486
20489
|
function isInstantBrowserDeath(message) {
|
|
20487
20490
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
@@ -20604,14 +20607,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20604
20607
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20605
20608
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20606
20609
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20610
|
+
const deadline = Date.now() + timeoutMs;
|
|
20611
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20612
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20613
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20607
20614
|
for (const headless of passes) {
|
|
20615
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20616
|
+
if (remainingMs < minPassMs)
|
|
20617
|
+
break;
|
|
20608
20618
|
try {
|
|
20609
20619
|
await withProfilePage({
|
|
20610
20620
|
profileDir: opts.profileDir,
|
|
20611
20621
|
headless,
|
|
20612
20622
|
url: config.homeUrl,
|
|
20613
20623
|
isAuthenticated: config.isAuthenticated,
|
|
20614
|
-
timeoutMs,
|
|
20624
|
+
timeoutMs: remainingMs,
|
|
20615
20625
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20616
20626
|
}, async () => true);
|
|
20617
20627
|
return {
|
|
@@ -20776,6 +20776,9 @@ async function ensureProfileDir2(profileDir, headless) {
|
|
|
20776
20776
|
var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
20777
20777
|
// ../../packages/publish-harness/src/browser.ts
|
|
20778
20778
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20779
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20780
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20781
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20779
20782
|
var DEFAULT_STEP_TIMEOUT_MS = 30000;
|
|
20780
20783
|
var DEFAULT_POLL_MS = 500;
|
|
20781
20784
|
var ATTACH_POLL_MS = 100;
|
|
@@ -20900,14 +20903,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20900
20903
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20901
20904
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20902
20905
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20906
|
+
const deadline = Date.now() + timeoutMs;
|
|
20907
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20908
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20909
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20903
20910
|
for (const headless of passes) {
|
|
20911
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20912
|
+
if (remainingMs < minPassMs)
|
|
20913
|
+
break;
|
|
20904
20914
|
try {
|
|
20905
20915
|
await withProfilePage({
|
|
20906
20916
|
profileDir: opts.profileDir,
|
|
20907
20917
|
headless,
|
|
20908
20918
|
url: config.homeUrl,
|
|
20909
20919
|
isAuthenticated: config.isAuthenticated,
|
|
20910
|
-
timeoutMs,
|
|
20920
|
+
timeoutMs: remainingMs,
|
|
20911
20921
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20912
20922
|
}, async () => true);
|
|
20913
20923
|
return {
|
|
@@ -20482,6 +20482,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
|
20482
20482
|
var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
|
|
20483
20483
|
var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
|
|
20484
20484
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20485
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20486
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20487
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20485
20488
|
var DEFAULT_POLL_MS = 500;
|
|
20486
20489
|
function isInstantBrowserDeath(message) {
|
|
20487
20490
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
@@ -20604,14 +20607,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20604
20607
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20605
20608
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20606
20609
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20610
|
+
const deadline = Date.now() + timeoutMs;
|
|
20611
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20612
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20613
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20607
20614
|
for (const headless of passes) {
|
|
20615
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20616
|
+
if (remainingMs < minPassMs)
|
|
20617
|
+
break;
|
|
20608
20618
|
try {
|
|
20609
20619
|
await withProfilePage({
|
|
20610
20620
|
profileDir: opts.profileDir,
|
|
20611
20621
|
headless,
|
|
20612
20622
|
url: config.homeUrl,
|
|
20613
20623
|
isAuthenticated: config.isAuthenticated,
|
|
20614
|
-
timeoutMs,
|
|
20624
|
+
timeoutMs: remainingMs,
|
|
20615
20625
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20616
20626
|
}, async () => true);
|
|
20617
20627
|
return {
|
|
@@ -20776,6 +20776,9 @@ async function ensureProfileDir2(profileDir, headless) {
|
|
|
20776
20776
|
var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
20777
20777
|
// ../../packages/publish-harness/src/browser.ts
|
|
20778
20778
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20779
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20780
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20781
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20779
20782
|
var DEFAULT_STEP_TIMEOUT_MS = 30000;
|
|
20780
20783
|
var DEFAULT_POLL_MS = 500;
|
|
20781
20784
|
var ATTACH_POLL_MS = 100;
|
|
@@ -20900,14 +20903,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20900
20903
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20901
20904
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20902
20905
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20906
|
+
const deadline = Date.now() + timeoutMs;
|
|
20907
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20908
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20909
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20903
20910
|
for (const headless of passes) {
|
|
20911
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20912
|
+
if (remainingMs < minPassMs)
|
|
20913
|
+
break;
|
|
20904
20914
|
try {
|
|
20905
20915
|
await withProfilePage({
|
|
20906
20916
|
profileDir: opts.profileDir,
|
|
20907
20917
|
headless,
|
|
20908
20918
|
url: config.homeUrl,
|
|
20909
20919
|
isAuthenticated: config.isAuthenticated,
|
|
20910
|
-
timeoutMs,
|
|
20920
|
+
timeoutMs: remainingMs,
|
|
20911
20921
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20912
20922
|
}, async () => true);
|
|
20913
20923
|
return {
|
|
@@ -20482,6 +20482,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
|
20482
20482
|
var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
|
|
20483
20483
|
var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
|
|
20484
20484
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20485
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20486
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20487
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20485
20488
|
var DEFAULT_POLL_MS = 500;
|
|
20486
20489
|
function isInstantBrowserDeath(message) {
|
|
20487
20490
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
@@ -20604,14 +20607,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20604
20607
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20605
20608
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20606
20609
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20610
|
+
const deadline = Date.now() + timeoutMs;
|
|
20611
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20612
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20613
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20607
20614
|
for (const headless of passes) {
|
|
20615
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20616
|
+
if (remainingMs < minPassMs)
|
|
20617
|
+
break;
|
|
20608
20618
|
try {
|
|
20609
20619
|
await withProfilePage({
|
|
20610
20620
|
profileDir: opts.profileDir,
|
|
20611
20621
|
headless,
|
|
20612
20622
|
url: config.homeUrl,
|
|
20613
20623
|
isAuthenticated: config.isAuthenticated,
|
|
20614
|
-
timeoutMs,
|
|
20624
|
+
timeoutMs: remainingMs,
|
|
20615
20625
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20616
20626
|
}, async () => true);
|
|
20617
20627
|
return {
|
|
@@ -20776,6 +20776,9 @@ async function ensureProfileDir2(profileDir, headless) {
|
|
|
20776
20776
|
var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
20777
20777
|
// ../../packages/publish-harness/src/browser.ts
|
|
20778
20778
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20779
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20780
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20781
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20779
20782
|
var DEFAULT_STEP_TIMEOUT_MS = 30000;
|
|
20780
20783
|
var DEFAULT_POLL_MS = 500;
|
|
20781
20784
|
var ATTACH_POLL_MS = 100;
|
|
@@ -20900,14 +20903,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20900
20903
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20901
20904
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20902
20905
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20906
|
+
const deadline = Date.now() + timeoutMs;
|
|
20907
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20908
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20909
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20903
20910
|
for (const headless of passes) {
|
|
20911
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20912
|
+
if (remainingMs < minPassMs)
|
|
20913
|
+
break;
|
|
20904
20914
|
try {
|
|
20905
20915
|
await withProfilePage({
|
|
20906
20916
|
profileDir: opts.profileDir,
|
|
20907
20917
|
headless,
|
|
20908
20918
|
url: config.homeUrl,
|
|
20909
20919
|
isAuthenticated: config.isAuthenticated,
|
|
20910
|
-
timeoutMs,
|
|
20920
|
+
timeoutMs: remainingMs,
|
|
20911
20921
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20912
20922
|
}, async () => true);
|
|
20913
20923
|
return {
|
|
@@ -20998,11 +21008,15 @@ var MAX_IMAGES = 1;
|
|
|
20998
21008
|
var IMAGE_EXTS = new Set([".png", ".jpg", ".jpeg", ".webp", ".gif"]);
|
|
20999
21009
|
var LINKEDIN_POST_SELECTORS = {
|
|
21000
21010
|
shareTrigger: [
|
|
21011
|
+
'button:has-text("Start a post")',
|
|
21012
|
+
'div[role="button"]:has-text("Start a post")',
|
|
21001
21013
|
'text="Start a post"',
|
|
21002
21014
|
"button.share-box-feed-entry__trigger",
|
|
21003
21015
|
'button[aria-label*="Start a post" i]'
|
|
21004
21016
|
],
|
|
21005
21017
|
composer: [
|
|
21018
|
+
'div.ProseMirror[contenteditable="true"]',
|
|
21019
|
+
'div[role="textbox"][contenteditable="true"]',
|
|
21006
21020
|
'.tiptap.ProseMirror div[role="textbox"]',
|
|
21007
21021
|
'div[role="textbox"].tiptap',
|
|
21008
21022
|
".tiptap.ProseMirror",
|
|
@@ -21018,6 +21032,7 @@ var LINKEDIN_POST_SELECTORS = {
|
|
|
21018
21032
|
fileInput: ['input[type="file"][accept*="image"]', 'input[type="file"]', '[role="dialog"] input[type="file"]'],
|
|
21019
21033
|
send: [
|
|
21020
21034
|
'button:text-is("Post")',
|
|
21035
|
+
'div[role="button"]:text-is("Post")',
|
|
21021
21036
|
'[role="dialog"] button:text-is("Post")',
|
|
21022
21037
|
'[role="dialog"] button.share-actions__primary-action'
|
|
21023
21038
|
]
|
|
@@ -21196,11 +21211,23 @@ class LinkedinBrowserTransport {
|
|
|
21196
21211
|
let composerSelector;
|
|
21197
21212
|
try {
|
|
21198
21213
|
composerSelector = await resolveSelector(page, LINKEDIN_POST_SELECTORS.composer, {
|
|
21199
|
-
timeoutMs: this.stepTimeoutMs,
|
|
21214
|
+
timeoutMs: Math.min(this.stepTimeoutMs, 15000),
|
|
21200
21215
|
label: "linkedin composer"
|
|
21201
21216
|
});
|
|
21202
21217
|
} catch {
|
|
21203
|
-
|
|
21218
|
+
const retryTrigger = await resolveSelector(page, LINKEDIN_POST_SELECTORS.shareTrigger, {
|
|
21219
|
+
timeoutMs: 1e4,
|
|
21220
|
+
label: "linkedin share box retry"
|
|
21221
|
+
}).catch(() => null);
|
|
21222
|
+
if (retryTrigger !== null)
|
|
21223
|
+
await page.locator(retryTrigger).first().click().catch(() => {});
|
|
21224
|
+
composerSelector = await resolveSelector(page, LINKEDIN_POST_SELECTORS.composer, {
|
|
21225
|
+
timeoutMs: this.stepTimeoutMs,
|
|
21226
|
+
label: "linkedin composer (after retry)"
|
|
21227
|
+
}).catch(() => "");
|
|
21228
|
+
}
|
|
21229
|
+
if (composerSelector === "") {
|
|
21230
|
+
return stageFail(`linkedin composer did not open after the share box, twice (selector drift) \u2014 run: ${LINKEDIN_LOGIN_INSTRUCTION}`, "composer", metadata);
|
|
21204
21231
|
}
|
|
21205
21232
|
const composer = page.locator(composerSelector).first();
|
|
21206
21233
|
if (typeof composer.pressSequentially === "function") {
|
|
@@ -21220,18 +21247,43 @@ class LinkedinBrowserTransport {
|
|
|
21220
21247
|
}
|
|
21221
21248
|
const toastsBefore = new Set(await this.readToasts(page));
|
|
21222
21249
|
const beforeLinks = await this.readPostLinks(page);
|
|
21223
|
-
const
|
|
21250
|
+
const roleEngine = page;
|
|
21251
|
+
const rolePost = roleEngine.getByRole?.("button", { name: "Post", exact: true });
|
|
21252
|
+
const roleCount = rolePost === undefined ? 0 : await rolePost.count().catch(() => 0);
|
|
21253
|
+
const sendSelector = roleCount > 0 ? "role:Post" : await resolveSelector(page, LINKEDIN_POST_SELECTORS.send, {
|
|
21224
21254
|
timeoutMs: this.stepTimeoutMs,
|
|
21225
21255
|
label: "linkedin Post button"
|
|
21256
|
+
}).catch(async (error) => {
|
|
21257
|
+
const state = await page.evaluate(`(() => {
|
|
21258
|
+
const editor = document.querySelector('div.ProseMirror[contenteditable="true"], div[role="textbox"][contenteditable="true"]');
|
|
21259
|
+
const buttons = [...document.querySelectorAll('button, div[role="button"]')]
|
|
21260
|
+
.filter((n) => n.offsetWidth > 0)
|
|
21261
|
+
.map((n) => (n.getAttribute('aria-label') || n.textContent || '').replace(/\\s+/g, ' ').trim())
|
|
21262
|
+
.filter(Boolean).slice(-12);
|
|
21263
|
+
return JSON.stringify({
|
|
21264
|
+
composerOpen: editor !== null,
|
|
21265
|
+
textLen: (editor?.textContent || '').trim().length,
|
|
21266
|
+
buttons,
|
|
21267
|
+
});
|
|
21268
|
+
})()`).catch(() => null);
|
|
21269
|
+
const shot = await page.screenshot({ path: `/tmp/kk-linkedin-send-${Date.now()}.png` }).then((buffer) => typeof buffer === "string" ? buffer : `/tmp/kk-linkedin-send.png`).catch(() => null);
|
|
21270
|
+
await page.screenshot({ path: "/tmp/kk-linkedin-send-latest.png" }).catch(() => null);
|
|
21271
|
+
throw new Error(`${String(error?.message ?? error)}${state ? ` \u2014 composer ${state}` : ""}${shot ? ` \u2014 screenshot /tmp/kk-linkedin-send-latest.png` : ""}`);
|
|
21226
21272
|
});
|
|
21227
|
-
const send = page.locator(sendSelector).first();
|
|
21228
|
-
const enabled = await expectOutcome(async () =>
|
|
21229
|
-
|
|
21230
|
-
|
|
21231
|
-
|
|
21273
|
+
const send = sendSelector === "role:Post" ? null : page.locator(sendSelector).first();
|
|
21274
|
+
const enabled = await expectOutcome(async () => {
|
|
21275
|
+
if (rolePost !== undefined && sendSelector === "role:Post") {
|
|
21276
|
+
return await rolePost.count() > 0 ? "enabled" : null;
|
|
21277
|
+
}
|
|
21278
|
+
return send !== null && await send.isEnabled() ? "enabled" : null;
|
|
21279
|
+
}, { timeoutMs: this.stepTimeoutMs, label: "linkedin Post button enabled" });
|
|
21232
21280
|
if (!enabled.ok)
|
|
21233
21281
|
return stageFail(`linkedin Post button never became clickable \u2014 ${enabled.error}`, "send-enabled", metadata);
|
|
21234
|
-
|
|
21282
|
+
if (rolePost !== undefined && sendSelector === "role:Post") {
|
|
21283
|
+
await rolePost.last().click({ timeout: this.stepTimeoutMs });
|
|
21284
|
+
} else if (send !== null) {
|
|
21285
|
+
await send.click();
|
|
21286
|
+
}
|
|
21235
21287
|
const confirmed = await expectOutcome(() => this.probeConfirmation(page, text, beforeLinks, toastsBefore), {
|
|
21236
21288
|
timeoutMs: this.stepTimeoutMs,
|
|
21237
21289
|
label: "linkedin publish confirmation"
|
|
@@ -20482,6 +20482,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
|
20482
20482
|
var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
|
|
20483
20483
|
var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
|
|
20484
20484
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20485
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20486
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20487
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20485
20488
|
var DEFAULT_POLL_MS = 500;
|
|
20486
20489
|
function isInstantBrowserDeath(message) {
|
|
20487
20490
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
@@ -20604,14 +20607,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20604
20607
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20605
20608
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20606
20609
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20610
|
+
const deadline = Date.now() + timeoutMs;
|
|
20611
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20612
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20613
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20607
20614
|
for (const headless of passes) {
|
|
20615
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20616
|
+
if (remainingMs < minPassMs)
|
|
20617
|
+
break;
|
|
20608
20618
|
try {
|
|
20609
20619
|
await withProfilePage({
|
|
20610
20620
|
profileDir: opts.profileDir,
|
|
20611
20621
|
headless,
|
|
20612
20622
|
url: config.homeUrl,
|
|
20613
20623
|
isAuthenticated: config.isAuthenticated,
|
|
20614
|
-
timeoutMs,
|
|
20624
|
+
timeoutMs: remainingMs,
|
|
20615
20625
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20616
20626
|
}, async () => true);
|
|
20617
20627
|
return {
|
|
@@ -21107,11 +21117,15 @@ var LINKEDIN_LOGIN_URL_RE = /(\/authwall|\/login|\/checkpoint)/;
|
|
|
21107
21117
|
var IMAGE_EXTS = new Set([".png", ".jpg", ".jpeg", ".webp", ".gif"]);
|
|
21108
21118
|
var LINKEDIN_POST_SELECTORS = {
|
|
21109
21119
|
shareTrigger: [
|
|
21120
|
+
'button:has-text("Start a post")',
|
|
21121
|
+
'div[role="button"]:has-text("Start a post")',
|
|
21110
21122
|
'text="Start a post"',
|
|
21111
21123
|
"button.share-box-feed-entry__trigger",
|
|
21112
21124
|
'button[aria-label*="Start a post" i]'
|
|
21113
21125
|
],
|
|
21114
21126
|
composer: [
|
|
21127
|
+
'div.ProseMirror[contenteditable="true"]',
|
|
21128
|
+
'div[role="textbox"][contenteditable="true"]',
|
|
21115
21129
|
'.tiptap.ProseMirror div[role="textbox"]',
|
|
21116
21130
|
'div[role="textbox"].tiptap',
|
|
21117
21131
|
".tiptap.ProseMirror",
|
|
@@ -21127,6 +21141,7 @@ var LINKEDIN_POST_SELECTORS = {
|
|
|
21127
21141
|
fileInput: ['input[type="file"][accept*="image"]', 'input[type="file"]', '[role="dialog"] input[type="file"]'],
|
|
21128
21142
|
send: [
|
|
21129
21143
|
'button:text-is("Post")',
|
|
21144
|
+
'div[role="button"]:text-is("Post")',
|
|
21130
21145
|
'[role="dialog"] button:text-is("Post")',
|
|
21131
21146
|
'[role="dialog"] button.share-actions__primary-action'
|
|
21132
21147
|
]
|
|
@@ -81,11 +81,21 @@ export const LINKEDIN_POST_SELECTORS = {
|
|
|
81
81
|
// share surface is NOT a `[role="dialog"]`, so controls are page-scoped by text, with the old
|
|
82
82
|
// class-based ladder kept as a fallback for accounts still on the previous UI.
|
|
83
83
|
shareTrigger: [
|
|
84
|
+
// Measured 2026-11-20: `text="Start a post"` resolves to the inner text node's element, and
|
|
85
|
+
// clicking THAT does not open the composer (the run then timed out in the composer stage and
|
|
86
|
+
// reported "composer did not open … selector drift"). The has-text forms hit the clickable
|
|
87
|
+
// ancestor; the text form stays last for the previous UI.
|
|
88
|
+
'button:has-text("Start a post")',
|
|
89
|
+
'div[role="button"]:has-text("Start a post")',
|
|
84
90
|
'text="Start a post"',
|
|
85
91
|
'button.share-box-feed-entry__trigger',
|
|
86
92
|
'button[aria-label*="Start a post" i]',
|
|
87
93
|
],
|
|
88
94
|
composer: [
|
|
95
|
+
// Measured 2026-11-20: the editor IS the ProseMirror element (`div[role=textbox]
|
|
96
|
+
// [contenteditable=true].tiptap.ProseMirror`), not a descendant of it.
|
|
97
|
+
'div.ProseMirror[contenteditable="true"]',
|
|
98
|
+
'div[role="textbox"][contenteditable="true"]',
|
|
89
99
|
'.tiptap.ProseMirror div[role="textbox"]',
|
|
90
100
|
'div[role="textbox"].tiptap',
|
|
91
101
|
'.tiptap.ProseMirror',
|
|
@@ -100,7 +110,10 @@ export const LINKEDIN_POST_SELECTORS = {
|
|
|
100
110
|
],
|
|
101
111
|
fileInput: ['input[type="file"][accept*="image"]', 'input[type="file"]', '[role="dialog"] input[type="file"]'],
|
|
102
112
|
send: [
|
|
113
|
+
// Measured 2026-11-20: a plain `<button>` whose text is exactly Post, inside a composer that
|
|
114
|
+
// carries NO dialog role — the dialog-scoped forms below could never match.
|
|
103
115
|
'button:text-is("Post")',
|
|
116
|
+
'div[role="button"]:text-is("Post")',
|
|
104
117
|
'[role="dialog"] button:text-is("Post")',
|
|
105
118
|
'[role="dialog"] button.share-actions__primary-action',
|
|
106
119
|
],
|
|
@@ -397,15 +410,34 @@ export class LinkedinBrowserTransport implements PublishTransport {
|
|
|
397
410
|
await page.locator(triggerSelector).first().click();
|
|
398
411
|
|
|
399
412
|
// Modal editor. A missing editor after the click is the same loud typed refusal family.
|
|
413
|
+
// The share box is a React target that can be clicked before the feed finishes hydrating
|
|
414
|
+
// (measured 2026-11-20: one run opened the composer, the next did not with the same session),
|
|
415
|
+
// so the click is retried once against a freshly resolved trigger before failing.
|
|
400
416
|
let composerSelector: string;
|
|
401
417
|
try {
|
|
402
418
|
composerSelector = await resolveSelector(page, LINKEDIN_POST_SELECTORS.composer, {
|
|
403
|
-
timeoutMs: this.stepTimeoutMs,
|
|
419
|
+
timeoutMs: Math.min(this.stepTimeoutMs, 15_000),
|
|
404
420
|
label: 'linkedin composer',
|
|
405
421
|
});
|
|
406
422
|
} catch {
|
|
423
|
+
const retryTrigger = await resolveSelector(page, LINKEDIN_POST_SELECTORS.shareTrigger, {
|
|
424
|
+
timeoutMs: 10_000,
|
|
425
|
+
label: 'linkedin share box retry',
|
|
426
|
+
}).catch(() => null);
|
|
427
|
+
if (retryTrigger !== null)
|
|
428
|
+
await page
|
|
429
|
+
.locator(retryTrigger)
|
|
430
|
+
.first()
|
|
431
|
+
.click()
|
|
432
|
+
.catch(() => {});
|
|
433
|
+
composerSelector = await resolveSelector(page, LINKEDIN_POST_SELECTORS.composer, {
|
|
434
|
+
timeoutMs: this.stepTimeoutMs,
|
|
435
|
+
label: 'linkedin composer (after retry)',
|
|
436
|
+
}).catch(() => '');
|
|
437
|
+
}
|
|
438
|
+
if (composerSelector === '') {
|
|
407
439
|
return stageFail(
|
|
408
|
-
`linkedin composer did not open after the share box (selector drift) — run: ${LINKEDIN_LOGIN_INSTRUCTION}`,
|
|
440
|
+
`linkedin composer did not open after the share box, twice (selector drift) — run: ${LINKEDIN_LOGIN_INSTRUCTION}`,
|
|
409
441
|
'composer',
|
|
410
442
|
metadata,
|
|
411
443
|
);
|
|
@@ -438,22 +470,77 @@ export class LinkedinBrowserTransport implements PublishTransport {
|
|
|
438
470
|
const beforeLinks = await this.readPostLinks(page);
|
|
439
471
|
|
|
440
472
|
// Send: the Post control inside the share dialog.
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
473
|
+
// Prefer the role engine. The composer's Post is a plain `<button>Post</button>` that is
|
|
474
|
+
// visible and enabled in the captured state (2026-11-20 screenshot) while every CSS form in
|
|
475
|
+
// the list failed to resolve — the same class of miss the threads rail hit with `text-is`
|
|
476
|
+
// against a styled label. `getByRole` names the control as the user sees it; the composer's
|
|
477
|
+
// Post is the LAST match because the feed's own Post entry point sits above it.
|
|
478
|
+
const roleEngine = page as unknown as {
|
|
479
|
+
getByRole?: (
|
|
480
|
+
role: string,
|
|
481
|
+
options: { name: string; exact: boolean },
|
|
482
|
+
) => { count(): Promise<number>; last(): { click(options?: { timeout?: number }): Promise<unknown> } };
|
|
483
|
+
};
|
|
484
|
+
const rolePost = roleEngine.getByRole?.('button', { name: 'Post', exact: true });
|
|
485
|
+
const roleCount = rolePost === undefined ? 0 : await rolePost.count().catch(() => 0);
|
|
486
|
+
const sendSelector =
|
|
487
|
+
roleCount > 0
|
|
488
|
+
? 'role:Post'
|
|
489
|
+
: await resolveSelector(page, LINKEDIN_POST_SELECTORS.send, {
|
|
490
|
+
timeoutMs: this.stepTimeoutMs,
|
|
491
|
+
label: 'linkedin Post button',
|
|
492
|
+
}).catch(async (error: unknown) => {
|
|
493
|
+
// The composer is a plain overlay (no dialog role), so a selector list that matches only
|
|
494
|
+
// inside `[role="dialog"]` reads as "not attached" while Post is plainly on screen. Report
|
|
495
|
+
// what the composer actually holds — and whether it is still open — instead of the list.
|
|
496
|
+
const state = await page
|
|
497
|
+
.evaluate(`(() => {
|
|
498
|
+
const editor = document.querySelector('div.ProseMirror[contenteditable="true"], div[role="textbox"][contenteditable="true"]');
|
|
499
|
+
const buttons = [...document.querySelectorAll('button, div[role="button"]')]
|
|
500
|
+
.filter((n) => n.offsetWidth > 0)
|
|
501
|
+
.map((n) => (n.getAttribute('aria-label') || n.textContent || '').replace(/\\s+/g, ' ').trim())
|
|
502
|
+
.filter(Boolean).slice(-12);
|
|
503
|
+
return JSON.stringify({
|
|
504
|
+
composerOpen: editor !== null,
|
|
505
|
+
textLen: (editor?.textContent || '').trim().length,
|
|
506
|
+
buttons,
|
|
507
|
+
});
|
|
508
|
+
})()`)
|
|
509
|
+
.catch(() => null);
|
|
510
|
+
// A screenshot is the only way to see WHICH overlay is covering Post when the DOM
|
|
511
|
+
// reports the composer open and the typed text present (2026-11-20: media step).
|
|
512
|
+
const shot = await page
|
|
513
|
+
.screenshot({ path: `/tmp/kk-linkedin-send-${Date.now()}.png` })
|
|
514
|
+
.then((buffer: unknown) =>
|
|
515
|
+
typeof buffer === 'string' ? buffer : `/tmp/kk-linkedin-send.png`,
|
|
516
|
+
)
|
|
517
|
+
.catch(() => null);
|
|
518
|
+
await page.screenshot({ path: '/tmp/kk-linkedin-send-latest.png' }).catch(() => null);
|
|
519
|
+
throw new Error(
|
|
520
|
+
`${String((error as Error)?.message ?? error)}${state ? ` — composer ${state}` : ''}${shot ? ` — screenshot /tmp/kk-linkedin-send-latest.png` : ''}`,
|
|
521
|
+
);
|
|
522
|
+
});
|
|
523
|
+
const send = sendSelector === 'role:Post' ? null : page.locator(sendSelector).first();
|
|
524
|
+
const enabled = await expectOutcome(
|
|
525
|
+
async () => {
|
|
526
|
+
if (rolePost !== undefined && sendSelector === 'role:Post') {
|
|
527
|
+
return (await rolePost.count()) > 0 ? 'enabled' : null;
|
|
528
|
+
}
|
|
529
|
+
return send !== null && (await send.isEnabled()) ? 'enabled' : null;
|
|
530
|
+
},
|
|
531
|
+
{ timeoutMs: this.stepTimeoutMs, label: 'linkedin Post button enabled' },
|
|
532
|
+
);
|
|
450
533
|
if (!enabled.ok)
|
|
451
534
|
return stageFail(
|
|
452
535
|
`linkedin Post button never became clickable — ${enabled.error}`,
|
|
453
536
|
'send-enabled',
|
|
454
537
|
metadata,
|
|
455
538
|
);
|
|
456
|
-
|
|
539
|
+
if (rolePost !== undefined && sendSelector === 'role:Post') {
|
|
540
|
+
await rolePost.last().click({ timeout: this.stepTimeoutMs });
|
|
541
|
+
} else if (send !== null) {
|
|
542
|
+
await send.click();
|
|
543
|
+
}
|
|
457
544
|
|
|
458
545
|
// Confirmation: a failure toast fails fast; otherwise the fresh post link is preferred so
|
|
459
546
|
// the Result can carry the created post's url/id, with the fresh success toast as the
|