@gobing-ai/knowledge-kit 0.1.17 → 0.1.20
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/daily-voice/index.js +40 -7
- package/dist/index.js +8428 -4448
- package/package.json +1 -1
- package/plugins/generations/image-gen/README.md +31 -31
- package/plugins/generations/image-gen/assets/sample/provenance.json +314 -0
- package/plugins/generations/image-gen/config.example.yaml +3 -0
- package/plugins/generations/image-gen/dist/index.js +154 -14
- package/plugins/generations/image-gen/presets/SOURCE.md +65 -0
- package/plugins/generations/image-gen/scripts/eval-style-presets.ts +513 -0
- package/plugins/generations/image-gen/scripts/gen-samples.ts +57 -7
- package/plugins/generations/image-gen/src/presets.ts +6 -5
- package/plugins/generations/image-gen/src/providers/h3-local.ts +196 -0
- package/plugins/generations/image-gen/src/providers/types.ts +11 -1
- package/plugins/kk/config.example.yaml +7 -2
- package/plugins/kk/decisions/extract/ai-news.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/chinese-article.json +8 -2
- package/plugins/kk/publish-presets/daily-ai-voice-migration.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +57 -16
- package/plugins/kk/publish-presets/itc-main.json +36 -9
- package/plugins/kk/publish-presets/technical-article.json +8 -2
- package/plugins/kk/schedules/kk-daily-ai-voice3.cron.tmpl +8 -9
- package/plugins/kk/schedules/kk-daily-publish3-cn-peak.cron.tmpl +13 -19
- package/plugins/kk/schedules/kk-daily-publish3-overseas.cron.tmpl +11 -9
- package/plugins/kk/scripts/daily-stages.ts +238 -14
- package/plugins/kk/scripts/daily-triage-core.ts +43 -25
- package/plugins/kk/scripts/daily-triage.ts +1 -1
- package/plugins/kk/skills/image-authoring/SKILL.md +7 -3
- package/plugins/kk/skills/image-authoring/references/providers.md +27 -0
- package/plugins/kk/skills/image-authoring/references/style-extraction.md +1 -1
- package/plugins/kk/skills/publish/SKILL.md +15 -2
- package/plugins/kk/skills/web-automation/SKILL.md +31 -1
- package/plugins/kk/workflows/kk-article-generate.yaml +485 -0
- package/plugins/kk/workflows/kk-collect.yaml +8 -4
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +2 -1
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +4 -2
- package/plugins/kk/workflows/kk-daily-safety.yaml +5 -7
- package/plugins/kk/workflows/kk-news-generate.yaml +410 -0
- package/plugins/kk/workflows/kk-publish.yaml +236 -0
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +49 -10
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/csdn-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/infoq-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/jike-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/juejin-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/linkedin-pub/dist/index.js +43 -6
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +92 -15
- package/plugins/publishings/linkedin-pub/src/index.ts +52 -6
- package/plugins/publishings/shipinhao-pub/dist/index.js +391 -32
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +52 -11
- package/plugins/publishings/shipinhao-pub/plugin.json +1 -1
- package/plugins/publishings/shipinhao-pub/src/audio-flow.ts +393 -0
- package/plugins/publishings/shipinhao-pub/src/flow.ts +243 -14
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +13 -0
- package/plugins/publishings/sspai-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/substack-pub/dist/profile-check.js +60 -10
- package/plugins/publishings/surfdash-pub/dist/index.js +50 -8
- package/plugins/publishings/surfdash-pub/src/index.ts +59 -8
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +34 -3
- package/plugins/publishings/threads-pub/dist/index.js +9196 -296
- package/plugins/publishings/threads-pub/dist/profile-check.js +21139 -0
- package/plugins/publishings/threads-pub/package.json +3 -1
- package/plugins/publishings/threads-pub/plugin.json +6 -1
- package/plugins/publishings/threads-pub/src/index.ts +8 -1
- package/plugins/publishings/threads-pub/src/post-rail.ts +357 -0
- package/plugins/publishings/threads-pub/src/profile-check.ts +17 -0
- package/plugins/publishings/wechatmp-pub/dist/index.js +454 -81
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +401 -102
- package/plugins/publishings/wechatmp-pub/src/flow.ts +42 -4
- package/plugins/publishings/wechatmp-pub/src/index.ts +142 -102
- package/plugins/publishings/wechatmp-pub/src/profile-check.ts +36 -58
- package/plugins/publishings/weibo-pub/dist/index.js +136 -22
- package/plugins/publishings/weibo-pub/dist/profile-check.js +61 -11
- package/plugins/publishings/weibo-pub/src/index.ts +208 -22
- package/plugins/publishings/x-pub/dist/index.js +263 -43
- package/plugins/publishings/x-pub/dist/profile-check.js +63 -11
- package/plugins/publishings/x-pub/src/index.ts +15 -1
- package/plugins/publishings/x-pub/src/post-rail.ts +334 -0
- package/plugins/publishings/xhs-pub/dist/index.js +193 -201
- package/plugins/publishings/xhs-pub/dist/profile-check.js +380 -85
- package/plugins/publishings/xhs-pub/src/automation-guard.ts +2 -3
- package/plugins/publishings/xhs-pub/src/flow.ts +177 -205
- package/plugins/publishings/xhs-pub/src/index.ts +65 -59
- package/plugins/publishings/xhs-pub/src/modes.ts +1 -1
- package/plugins/publishings/xhs-pub/src/page.ts +2 -2
- package/plugins/publishings/xhs-pub/src/profile-check.ts +86 -150
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +60 -10
- package/plugins/kk/scripts/daily-scheduled-run.ts +0 -581
- package/plugins/kk/scripts/voice3-publish-window.ts +0 -206
- package/plugins/kk/workflows/kk-daily-ai-voice3.yaml +0 -903
- package/plugins/kk/workflows/kk-daily-publish3.yaml +0 -353
- package/plugins/kk/workflows/kk-itc-author.yaml +0 -484
- package/plugins/kk/workflows/kk-itc-publish-tail.yaml +0 -112
- package/plugins/kk/workflows/kk-itc.yaml +0 -291
|
@@ -20997,10 +20997,30 @@ var MAX_TEXT_CHARS = 3000;
|
|
|
20997
20997
|
var MAX_IMAGES = 1;
|
|
20998
20998
|
var IMAGE_EXTS = new Set([".png", ".jpg", ".jpeg", ".webp", ".gif"]);
|
|
20999
20999
|
var LINKEDIN_POST_SELECTORS = {
|
|
21000
|
-
shareTrigger: [
|
|
21001
|
-
|
|
21002
|
-
|
|
21003
|
-
|
|
21000
|
+
shareTrigger: [
|
|
21001
|
+
'text="Start a post"',
|
|
21002
|
+
"button.share-box-feed-entry__trigger",
|
|
21003
|
+
'button[aria-label*="Start a post" i]'
|
|
21004
|
+
],
|
|
21005
|
+
composer: [
|
|
21006
|
+
'.tiptap.ProseMirror div[role="textbox"]',
|
|
21007
|
+
'div[role="textbox"].tiptap',
|
|
21008
|
+
".tiptap.ProseMirror",
|
|
21009
|
+
'[role="dialog"] div[role="textbox"]',
|
|
21010
|
+
'div.editor-content[contenteditable="true"]',
|
|
21011
|
+
'div[role="textbox"][contenteditable="true"]'
|
|
21012
|
+
],
|
|
21013
|
+
mediaButton: [
|
|
21014
|
+
'button[aria-label="Media"]',
|
|
21015
|
+
'button[aria-label*="Media" i]',
|
|
21016
|
+
'[role="dialog"] button[aria-label*="Media" i]'
|
|
21017
|
+
],
|
|
21018
|
+
fileInput: ['input[type="file"][accept*="image"]', 'input[type="file"]', '[role="dialog"] input[type="file"]'],
|
|
21019
|
+
send: [
|
|
21020
|
+
'button:text-is("Post")',
|
|
21021
|
+
'[role="dialog"] button:text-is("Post")',
|
|
21022
|
+
'[role="dialog"] button.share-actions__primary-action'
|
|
21023
|
+
]
|
|
21004
21024
|
};
|
|
21005
21025
|
var FAILURE_TOAST_RE = /post failed|couldn't post|something went wrong/i;
|
|
21006
21026
|
var SUCCESS_TOAST_RE = /post successful/i;
|
|
@@ -21059,7 +21079,14 @@ function resolveDriver(options) {
|
|
|
21059
21079
|
var isLinkedinAuthenticated = async (page) => {
|
|
21060
21080
|
if (LINKEDIN_LOGIN_URL_RE.test(page.url()))
|
|
21061
21081
|
return false;
|
|
21062
|
-
|
|
21082
|
+
if ((await trySelectors(page, LINKEDIN_POST_SELECTORS.shareTrigger.slice(1), { visible: false })).found) {
|
|
21083
|
+
return true;
|
|
21084
|
+
}
|
|
21085
|
+
try {
|
|
21086
|
+
return await page.getByText("Start a post", { exact: true }).count() > 0;
|
|
21087
|
+
} catch {
|
|
21088
|
+
return false;
|
|
21089
|
+
}
|
|
21063
21090
|
};
|
|
21064
21091
|
var LINKEDIN_CONFIG = {
|
|
21065
21092
|
channel: TARGET,
|
|
@@ -21175,7 +21202,13 @@ class LinkedinBrowserTransport {
|
|
|
21175
21202
|
} catch {
|
|
21176
21203
|
return stageFail(`linkedin composer did not open after the share box (selector drift) \u2014 run: ${LINKEDIN_LOGIN_INSTRUCTION}`, "composer", metadata);
|
|
21177
21204
|
}
|
|
21178
|
-
|
|
21205
|
+
const composer = page.locator(composerSelector).first();
|
|
21206
|
+
if (typeof composer.pressSequentially === "function") {
|
|
21207
|
+
await composer.click();
|
|
21208
|
+
await composer.pressSequentially(text, { delay: 3 });
|
|
21209
|
+
} else {
|
|
21210
|
+
await composer.fill(text);
|
|
21211
|
+
}
|
|
21179
21212
|
const readback = await this.requireReadback(page, composerSelector, text);
|
|
21180
21213
|
if (!readback.ok)
|
|
21181
21214
|
return stageFail(readback.error, "text-readback", metadata);
|
|
@@ -21229,6 +21262,10 @@ class LinkedinBrowserTransport {
|
|
|
21229
21262
|
}
|
|
21230
21263
|
async uploadImage(page, image) {
|
|
21231
21264
|
try {
|
|
21265
|
+
const media = await trySelectors(page, LINKEDIN_POST_SELECTORS.mediaButton);
|
|
21266
|
+
if (media.found) {
|
|
21267
|
+
await page.locator(media.selector ?? LINKEDIN_POST_SELECTORS.mediaButton[0]).first().click();
|
|
21268
|
+
}
|
|
21232
21269
|
const inputSelector = await resolveSelector(page, LINKEDIN_POST_SELECTORS.fileInput, {
|
|
21233
21270
|
timeoutMs: this.stepTimeoutMs,
|
|
21234
21271
|
label: "linkedin file input"
|
|
@@ -20482,6 +20482,7 @@ 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 DEFAULT_POLL_MS = 500;
|
|
20485
20486
|
function isInstantBrowserDeath(message) {
|
|
20486
20487
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
20487
20488
|
}
|
|
@@ -20647,6 +20648,16 @@ async function openChannelSession(config, request, deps = {}, stdout = echo) {
|
|
|
20647
20648
|
return 1;
|
|
20648
20649
|
}
|
|
20649
20650
|
const page = context.pages()[0] ?? await context.newPage();
|
|
20651
|
+
const onOpen = config.sessionState?.onOpen;
|
|
20652
|
+
if (onOpen !== undefined) {
|
|
20653
|
+
try {
|
|
20654
|
+
await onOpen({ context, page, profileDir: request.profileDir });
|
|
20655
|
+
} catch (error) {
|
|
20656
|
+
await context.close().catch(() => {});
|
|
20657
|
+
stdout(`${config.channel} profile open failed: ${errorMessage2(error)}`);
|
|
20658
|
+
return 1;
|
|
20659
|
+
}
|
|
20660
|
+
}
|
|
20650
20661
|
try {
|
|
20651
20662
|
await page.goto(request.url, { waitUntil: "commit", timeout: DEFAULT_OPEN_NAV_TIMEOUT_MS });
|
|
20652
20663
|
} catch (error) {
|
|
@@ -20658,6 +20669,36 @@ async function openChannelSession(config, request, deps = {}, stdout = echo) {
|
|
|
20658
20669
|
stdout(`${config.channel} profile open closed: ${request.profileDir}`);
|
|
20659
20670
|
return 0;
|
|
20660
20671
|
}
|
|
20672
|
+
async function loginWithAuthenticatedPage(config, opts) {
|
|
20673
|
+
const context = await opts.launcher.launch({ profileDir: opts.profileDir, headless: false });
|
|
20674
|
+
const sessionCaptured = config.sessionState?.onAuthenticated !== undefined;
|
|
20675
|
+
let captured = false;
|
|
20676
|
+
let facts = {};
|
|
20677
|
+
try {
|
|
20678
|
+
const page = context.pages()[0] ?? await context.newPage();
|
|
20679
|
+
await page.goto(opts.url);
|
|
20680
|
+
if (!await waitUntil(() => Promise.resolve(config.isAuthenticated(page)), opts.timeoutMs)) {
|
|
20681
|
+
throw new Error(`Authentication was not confirmed within ${opts.timeoutMs}ms \u2014 the profile's site session has likely ` + "expired or the sign-in was not completed: run the login command again to sign in again.");
|
|
20682
|
+
}
|
|
20683
|
+
await config.sessionState?.onAuthenticated?.({ context, page, profileDir: opts.profileDir });
|
|
20684
|
+
captured = sessionCaptured;
|
|
20685
|
+
if (opts.captureFacts) {
|
|
20686
|
+
facts = {
|
|
20687
|
+
...await captureSessionFacts(context, config.homeUrl),
|
|
20688
|
+
...config.readIdentity === undefined ? {} : { identity: await readIdentityOrUndefined(config.readIdentity, page) }
|
|
20689
|
+
};
|
|
20690
|
+
}
|
|
20691
|
+
} finally {
|
|
20692
|
+
try {
|
|
20693
|
+
await context.close();
|
|
20694
|
+
} catch {
|
|
20695
|
+
if (captured) {
|
|
20696
|
+
echoError(`${config.channel} browser context close failed after the authenticated session capture; saved state preserved`);
|
|
20697
|
+
}
|
|
20698
|
+
}
|
|
20699
|
+
}
|
|
20700
|
+
return facts;
|
|
20701
|
+
}
|
|
20661
20702
|
async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
20662
20703
|
const stdout = deps.stdout ?? ((line) => {
|
|
20663
20704
|
echo(line);
|
|
@@ -20708,7 +20749,8 @@ async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
|
20708
20749
|
const launcher = deps.launcher ?? kkBrowserLauncher;
|
|
20709
20750
|
stdout(`${config.channel} profile login: a browser window is opening \u2014 sign in there; waiting up to ${Math.round(loginTimeoutMs / 1000)}s for the signed-in state`);
|
|
20710
20751
|
try {
|
|
20711
|
-
|
|
20752
|
+
const captureFacts = url !== undefined;
|
|
20753
|
+
if (!captureFacts && config.sessionState?.onAuthenticated === undefined) {
|
|
20712
20754
|
await loginWithProfile({
|
|
20713
20755
|
profileDir,
|
|
20714
20756
|
url: config.homeUrl,
|
|
@@ -20719,18 +20761,16 @@ async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
|
20719
20761
|
stdout(`${config.channel} profile login verified: ${profileDir}`);
|
|
20720
20762
|
return 0;
|
|
20721
20763
|
}
|
|
20722
|
-
const facts = await
|
|
20764
|
+
const facts = await loginWithAuthenticatedPage(config, {
|
|
20723
20765
|
profileDir,
|
|
20724
|
-
|
|
20725
|
-
url,
|
|
20726
|
-
isAuthenticated: config.isAuthenticated,
|
|
20766
|
+
url: url ?? config.homeUrl,
|
|
20727
20767
|
timeoutMs: loginTimeoutMs,
|
|
20728
|
-
launcher
|
|
20729
|
-
|
|
20730
|
-
|
|
20731
|
-
...config.readIdentity === undefined ? {} : { identity: await readIdentityOrUndefined(config.readIdentity, page) }
|
|
20732
|
-
}));
|
|
20768
|
+
launcher,
|
|
20769
|
+
captureFacts
|
|
20770
|
+
});
|
|
20733
20771
|
stdout(`${config.channel} profile login verified: ${profileDir}`);
|
|
20772
|
+
if (url === undefined)
|
|
20773
|
+
return 0;
|
|
20734
20774
|
stdout(JSON.stringify({
|
|
20735
20775
|
status: "verified",
|
|
20736
20776
|
profileDir,
|
|
@@ -20753,6 +20793,16 @@ async function runProfileCli(config, argv = process.argv.slice(2), deps = {}) {
|
|
|
20753
20793
|
stdout(JSON.stringify(result));
|
|
20754
20794
|
return result.status === "verified" ? 0 : 1;
|
|
20755
20795
|
}
|
|
20796
|
+
async function waitUntil(predicate, timeoutMs, pollMs = DEFAULT_POLL_MS) {
|
|
20797
|
+
const deadline = Date.now() + timeoutMs;
|
|
20798
|
+
while (Date.now() < deadline) {
|
|
20799
|
+
if (await predicate()) {
|
|
20800
|
+
return true;
|
|
20801
|
+
}
|
|
20802
|
+
await new Promise((resolve) => setTimeout(resolve, pollMs));
|
|
20803
|
+
}
|
|
20804
|
+
return predicate();
|
|
20805
|
+
}
|
|
20756
20806
|
async function captureSessionFacts(context, url) {
|
|
20757
20807
|
let cookies;
|
|
20758
20808
|
try {
|
|
@@ -21056,16 +21106,43 @@ var LINKEDIN_HOME_URL = "https://www.linkedin.com/feed/";
|
|
|
21056
21106
|
var LINKEDIN_LOGIN_URL_RE = /(\/authwall|\/login|\/checkpoint)/;
|
|
21057
21107
|
var IMAGE_EXTS = new Set([".png", ".jpg", ".jpeg", ".webp", ".gif"]);
|
|
21058
21108
|
var LINKEDIN_POST_SELECTORS = {
|
|
21059
|
-
shareTrigger: [
|
|
21060
|
-
|
|
21061
|
-
|
|
21062
|
-
|
|
21109
|
+
shareTrigger: [
|
|
21110
|
+
'text="Start a post"',
|
|
21111
|
+
"button.share-box-feed-entry__trigger",
|
|
21112
|
+
'button[aria-label*="Start a post" i]'
|
|
21113
|
+
],
|
|
21114
|
+
composer: [
|
|
21115
|
+
'.tiptap.ProseMirror div[role="textbox"]',
|
|
21116
|
+
'div[role="textbox"].tiptap',
|
|
21117
|
+
".tiptap.ProseMirror",
|
|
21118
|
+
'[role="dialog"] div[role="textbox"]',
|
|
21119
|
+
'div.editor-content[contenteditable="true"]',
|
|
21120
|
+
'div[role="textbox"][contenteditable="true"]'
|
|
21121
|
+
],
|
|
21122
|
+
mediaButton: [
|
|
21123
|
+
'button[aria-label="Media"]',
|
|
21124
|
+
'button[aria-label*="Media" i]',
|
|
21125
|
+
'[role="dialog"] button[aria-label*="Media" i]'
|
|
21126
|
+
],
|
|
21127
|
+
fileInput: ['input[type="file"][accept*="image"]', 'input[type="file"]', '[role="dialog"] input[type="file"]'],
|
|
21128
|
+
send: [
|
|
21129
|
+
'button:text-is("Post")',
|
|
21130
|
+
'[role="dialog"] button:text-is("Post")',
|
|
21131
|
+
'[role="dialog"] button.share-actions__primary-action'
|
|
21132
|
+
]
|
|
21063
21133
|
};
|
|
21064
21134
|
var LOGIN_TIMEOUT_MS = 180000;
|
|
21065
21135
|
var isLinkedinAuthenticated = async (page) => {
|
|
21066
21136
|
if (LINKEDIN_LOGIN_URL_RE.test(page.url()))
|
|
21067
21137
|
return false;
|
|
21068
|
-
|
|
21138
|
+
if ((await trySelectors(page, LINKEDIN_POST_SELECTORS.shareTrigger.slice(1), { visible: false })).found) {
|
|
21139
|
+
return true;
|
|
21140
|
+
}
|
|
21141
|
+
try {
|
|
21142
|
+
return await page.getByText("Start a post", { exact: true }).count() > 0;
|
|
21143
|
+
} catch {
|
|
21144
|
+
return false;
|
|
21145
|
+
}
|
|
21069
21146
|
};
|
|
21070
21147
|
var LINKEDIN_CONFIG = {
|
|
21071
21148
|
channel: TARGET,
|
|
@@ -77,10 +77,33 @@ const IMAGE_EXTS = new Set(['.png', '.jpg', '.jpeg', '.webp', '.gif']);
|
|
|
77
77
|
* A drifted selector is a loud typed refusal at its stage, never a silent skip or a text-only post.
|
|
78
78
|
*/
|
|
79
79
|
export const LINKEDIN_POST_SELECTORS = {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
// 2026-11-16 live measurement of the redesigned feed: the share trigger is a classless div and the
|
|
81
|
+
// share surface is NOT a `[role="dialog"]`, so controls are page-scoped by text, with the old
|
|
82
|
+
// class-based ladder kept as a fallback for accounts still on the previous UI.
|
|
83
|
+
shareTrigger: [
|
|
84
|
+
'text="Start a post"',
|
|
85
|
+
'button.share-box-feed-entry__trigger',
|
|
86
|
+
'button[aria-label*="Start a post" i]',
|
|
87
|
+
],
|
|
88
|
+
composer: [
|
|
89
|
+
'.tiptap.ProseMirror div[role="textbox"]',
|
|
90
|
+
'div[role="textbox"].tiptap',
|
|
91
|
+
'.tiptap.ProseMirror',
|
|
92
|
+
'[role="dialog"] div[role="textbox"]',
|
|
93
|
+
'div.editor-content[contenteditable="true"]',
|
|
94
|
+
'div[role="textbox"][contenteditable="true"]',
|
|
95
|
+
],
|
|
96
|
+
mediaButton: [
|
|
97
|
+
'button[aria-label="Media"]',
|
|
98
|
+
'button[aria-label*="Media" i]',
|
|
99
|
+
'[role="dialog"] button[aria-label*="Media" i]',
|
|
100
|
+
],
|
|
101
|
+
fileInput: ['input[type="file"][accept*="image"]', 'input[type="file"]', '[role="dialog"] input[type="file"]'],
|
|
102
|
+
send: [
|
|
103
|
+
'button:text-is("Post")',
|
|
104
|
+
'[role="dialog"] button:text-is("Post")',
|
|
105
|
+
'[role="dialog"] button.share-actions__primary-action',
|
|
106
|
+
],
|
|
84
107
|
} as const;
|
|
85
108
|
|
|
86
109
|
/** Failure toast words. **Provisional** (LinkedIn's artdeco toast wording). */
|
|
@@ -181,7 +204,14 @@ function resolveDriver(options?: Record<string, unknown>): BrowserDriver | { err
|
|
|
181
204
|
*/
|
|
182
205
|
export const isLinkedinAuthenticated: IsAuthenticatedPredicate = async (page) => {
|
|
183
206
|
if (LINKEDIN_LOGIN_URL_RE.test(page.url())) return false;
|
|
184
|
-
|
|
207
|
+
if ((await trySelectors(page, LINKEDIN_POST_SELECTORS.shareTrigger.slice(1), { visible: false })).found) {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
try {
|
|
211
|
+
return (await page.getByText('Start a post', { exact: true }).count()) > 0;
|
|
212
|
+
} catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
185
215
|
};
|
|
186
216
|
|
|
187
217
|
/**
|
|
@@ -380,7 +410,16 @@ export class LinkedinBrowserTransport implements PublishTransport {
|
|
|
380
410
|
metadata,
|
|
381
411
|
);
|
|
382
412
|
}
|
|
383
|
-
|
|
413
|
+
const composer = page.locator(composerSelector).first();
|
|
414
|
+
if (typeof composer.pressSequentially === 'function') {
|
|
415
|
+
// tiptap/ProseMirror (measured 2026-11-16): `fill()` writes the DOM without the editor's
|
|
416
|
+
// state, so the footer Post control never renders. Type real key events — the same trap
|
|
417
|
+
// as X's Draft.js. A page stub without pressSequentially keeps the fill path.
|
|
418
|
+
await composer.click();
|
|
419
|
+
await composer.pressSequentially(text, { delay: 3 });
|
|
420
|
+
} else {
|
|
421
|
+
await composer.fill(text);
|
|
422
|
+
}
|
|
384
423
|
|
|
385
424
|
// Readback before anything else: a field the editor dropped must never be submitted.
|
|
386
425
|
const readback = await this.requireReadback(page, composerSelector, text);
|
|
@@ -473,6 +512,13 @@ export class LinkedinBrowserTransport implements PublishTransport {
|
|
|
473
512
|
image: string,
|
|
474
513
|
): Promise<{ ok: true; evidence: string } | { ok: false; error: string }> {
|
|
475
514
|
try {
|
|
515
|
+
const media = await trySelectors(page, LINKEDIN_POST_SELECTORS.mediaButton);
|
|
516
|
+
if (media.found) {
|
|
517
|
+
await page
|
|
518
|
+
.locator(media.selector ?? LINKEDIN_POST_SELECTORS.mediaButton[0])
|
|
519
|
+
.first()
|
|
520
|
+
.click();
|
|
521
|
+
}
|
|
476
522
|
const inputSelector = await resolveSelector(page, LINKEDIN_POST_SELECTORS.fileInput, {
|
|
477
523
|
timeoutMs: this.stepTimeoutMs,
|
|
478
524
|
label: 'linkedin file input',
|