@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.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/index.js +282 -147
- package/package.json +5 -5
- package/plugins/generations/content-gen/dist/index.js +9 -9
- package/plugins/generations/core-facts-gen/dist/index.js +12 -12
- package/plugins/generations/daily-article-gen/dist/index.js +12 -12
- package/plugins/generations/dailynews-gen/dist/index.js +11 -11
- package/plugins/generations/dailynews-gen/src/script-plan.ts +2 -2
- package/plugins/generations/episode-plan-gen/dist/index.js +12 -12
- package/plugins/generations/gemini-tts/dist/index.js +56 -16
- package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
- package/plugins/generations/image-gen/dist/index.js +9 -9
- package/plugins/generations/music-gen/README.md +2 -2
- package/plugins/generations/music-gen/dist/index.js +62 -26
- package/plugins/generations/music-gen/presets/formats/song.yaml +6 -1
- package/plugins/generations/music-gen/presets/themes/synthwave.yaml +6 -1
- package/plugins/generations/music-gen/src/adapter/instance.ts +34 -11
- package/plugins/generations/music-gen/src/presets.ts +36 -3
- package/plugins/generations/news-report-gen/dist/index.js +12 -12
- 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 +40 -10
- package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
- package/plugins/generations/voxcpm-tts/dist/index.js +90 -18
- 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/ingestions/aihot-ingest/dist/index.js +12 -12
- package/plugins/ingestions/horizon-ingest/dist/index.js +12 -12
- package/plugins/ingestions/karakeep-local/dist/index.js +13 -13
- package/plugins/ingestions/last30days-ingest/dist/index.js +12 -12
- package/plugins/ingestions/web-search/dist/index.js +10 -10
- 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/publish-presets/daily-ai-voice.json +16 -16
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +12 -1
- package/plugins/kk/scripts/cover-compositor.ts +104 -26
- package/plugins/kk/scripts/daily-stages.ts +481 -63
- package/plugins/kk/scripts/kk-workflow-stages.ts +218 -17
- package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
- package/plugins/kk/scripts/series-names.ts +16 -3
- package/plugins/kk/skills/news-editorial/SKILL.md +1 -1
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +3 -3
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +4 -3
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -5
- package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
- package/plugins/kk/workflows/kk-music.yaml +20 -16
- package/plugins/kk/workflows/kk-news-generate.yaml +26 -3
- package/plugins/kk/workflows/kk-publish.yaml +4 -1
- package/plugins/publishings/bilibili-pub/dist/index.js +22 -22
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/cnblogs-pub/dist/index.js +22 -22
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/csdn-pub/dist/index.js +22 -22
- package/plugins/publishings/csdn-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/emdash-pub/dist/index.js +9 -9
- package/plugins/publishings/infoq-pub/dist/index.js +22 -22
- package/plugins/publishings/infoq-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/jike-pub/dist/index.js +22 -22
- package/plugins/publishings/jike-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/juejin-pub/dist/index.js +22 -22
- package/plugins/publishings/juejin-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/linkedin-pub/dist/index.js +133 -33
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +27 -22
- package/plugins/publishings/linkedin-pub/src/index.ts +192 -18
- package/plugins/publishings/medium-pub/dist/index.js +9 -9
- package/plugins/publishings/podcast-pub/dist/index.js +240 -37
- package/plugins/publishings/podcast-pub/src/index.ts +154 -3
- package/plugins/publishings/podcast-pub/src/seo.ts +25 -8
- package/plugins/publishings/podcast-pub/src/show-notes-brief.ts +93 -23
- package/plugins/publishings/podcast-pub/src/show-notes.ts +26 -6
- package/plugins/publishings/qiita-pub/dist/index.js +9 -9
- package/plugins/publishings/shipinhao-pub/dist/index.js +23 -23
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +23 -23
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +2 -1
- package/plugins/publishings/sspai-pub/dist/index.js +22 -22
- package/plugins/publishings/sspai-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/substack-pub/dist/index.js +22 -22
- package/plugins/publishings/substack-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/surfdash-pub/dist/index.js +207 -95
- package/plugins/publishings/surfdash-pub/src/digest-check.ts +30 -1
- package/plugins/publishings/surfdash-pub/src/index.ts +101 -76
- package/plugins/publishings/surfdash-pub/src/media-upload.ts +83 -0
- package/plugins/publishings/surfdash-pub/src/patch.ts +49 -26
- package/plugins/publishings/surfdash-pub/src/topic-claims.ts +12 -4
- package/plugins/publishings/threads-pub/dist/index.js +83 -27
- package/plugins/publishings/threads-pub/dist/profile-check.js +34 -23
- package/plugins/publishings/threads-pub/src/post-rail.ts +121 -4
- package/plugins/publishings/wechatmp-pub/dist/index.js +274 -98
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +27 -23
- package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +117 -13
- package/plugins/publishings/wechatmp-pub/src/flow.ts +183 -43
- package/plugins/publishings/wechatmp-pub/src/modes.ts +30 -12
- package/plugins/publishings/weibo-pub/dist/index.js +22 -22
- package/plugins/publishings/weibo-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/x-pub/dist/index.js +113 -32
- package/plugins/publishings/x-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/x-pub/src/post-rail.ts +155 -20
- package/plugins/publishings/xhs-pub/dist/index.js +22 -22
- package/plugins/publishings/xhs-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +22 -22
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +22 -22
- package/plugins/publishings/zenn-pub/dist/index.js +9 -9
|
@@ -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
|
],
|
|
@@ -117,6 +130,8 @@ const POST_LINK_SELECTOR = 'a[href*="/feed/update/"], a[href*="/posts/"]';
|
|
|
117
130
|
/** Image upload preview wait: source-pinned 5s @ 250ms like the jike peer, not the step timeout. */
|
|
118
131
|
const PREVIEW_TIMEOUT_MS = 5_000;
|
|
119
132
|
const PREVIEW_POLL_MS = 250;
|
|
133
|
+
/** Best-effort async OG link-preview unfurl wait (measured 2026-11-21: ~1s live). */
|
|
134
|
+
const LINK_PREVIEW_TIMEOUT_MS = 10_000;
|
|
120
135
|
|
|
121
136
|
const STEP_TIMEOUT_MS = 30_000;
|
|
122
137
|
const LOGIN_TIMEOUT_MS = 180_000;
|
|
@@ -227,15 +242,21 @@ export const LINKEDIN_CONFIG: ChannelBrowserConfig = {
|
|
|
227
242
|
};
|
|
228
243
|
|
|
229
244
|
/**
|
|
230
|
-
* Resolves the optional single image (`options.images ?? metadata.images`)
|
|
231
|
-
* a payload of at most one existing local image file, so a bad path is a fast
|
|
232
|
-
* (0328 R1 "text plus one image").
|
|
245
|
+
* Resolves the optional single image (`options.images ?? metadata.images ?? metadata.coverImage`)
|
|
246
|
+
* without uploading: a payload of at most one existing local image file, so a bad path is a fast
|
|
247
|
+
* pre-browser refusal (0328 R1 "text plus one image").
|
|
233
248
|
*/
|
|
234
249
|
async function resolveImages(
|
|
235
250
|
options?: Record<string, unknown>,
|
|
236
251
|
content?: Content,
|
|
237
252
|
): Promise<{ paths: string[] } | { error: string }> {
|
|
238
|
-
const
|
|
253
|
+
const rawImages = options?.images ?? content?.metadata?.images;
|
|
254
|
+
const raw =
|
|
255
|
+
rawImages !== undefined
|
|
256
|
+
? rawImages
|
|
257
|
+
: content?.metadata?.coverImage !== undefined
|
|
258
|
+
? [content.metadata.coverImage]
|
|
259
|
+
: undefined;
|
|
239
260
|
if (raw === undefined) return { paths: [] };
|
|
240
261
|
if (!Array.isArray(raw)) {
|
|
241
262
|
return { error: `metadata.images must be an array of local image paths, got '${bounded(raw)}'` };
|
|
@@ -397,15 +418,34 @@ export class LinkedinBrowserTransport implements PublishTransport {
|
|
|
397
418
|
await page.locator(triggerSelector).first().click();
|
|
398
419
|
|
|
399
420
|
// Modal editor. A missing editor after the click is the same loud typed refusal family.
|
|
421
|
+
// The share box is a React target that can be clicked before the feed finishes hydrating
|
|
422
|
+
// (measured 2026-11-20: one run opened the composer, the next did not with the same session),
|
|
423
|
+
// so the click is retried once against a freshly resolved trigger before failing.
|
|
400
424
|
let composerSelector: string;
|
|
401
425
|
try {
|
|
402
426
|
composerSelector = await resolveSelector(page, LINKEDIN_POST_SELECTORS.composer, {
|
|
403
|
-
timeoutMs: this.stepTimeoutMs,
|
|
427
|
+
timeoutMs: Math.min(this.stepTimeoutMs, 15_000),
|
|
404
428
|
label: 'linkedin composer',
|
|
405
429
|
});
|
|
406
430
|
} catch {
|
|
431
|
+
const retryTrigger = await resolveSelector(page, LINKEDIN_POST_SELECTORS.shareTrigger, {
|
|
432
|
+
timeoutMs: 10_000,
|
|
433
|
+
label: 'linkedin share box retry',
|
|
434
|
+
}).catch(() => null);
|
|
435
|
+
if (retryTrigger !== null)
|
|
436
|
+
await page
|
|
437
|
+
.locator(retryTrigger)
|
|
438
|
+
.first()
|
|
439
|
+
.click()
|
|
440
|
+
.catch(() => {});
|
|
441
|
+
composerSelector = await resolveSelector(page, LINKEDIN_POST_SELECTORS.composer, {
|
|
442
|
+
timeoutMs: this.stepTimeoutMs,
|
|
443
|
+
label: 'linkedin composer (after retry)',
|
|
444
|
+
}).catch(() => '');
|
|
445
|
+
}
|
|
446
|
+
if (composerSelector === '') {
|
|
407
447
|
return stageFail(
|
|
408
|
-
`linkedin composer did not open after the share box (selector drift) — run: ${LINKEDIN_LOGIN_INSTRUCTION}`,
|
|
448
|
+
`linkedin composer did not open after the share box, twice (selector drift) — run: ${LINKEDIN_LOGIN_INSTRUCTION}`,
|
|
409
449
|
'composer',
|
|
410
450
|
metadata,
|
|
411
451
|
);
|
|
@@ -426,11 +466,14 @@ export class LinkedinBrowserTransport implements PublishTransport {
|
|
|
426
466
|
if (!readback.ok) return stageFail(readback.error, 'text-readback', metadata);
|
|
427
467
|
|
|
428
468
|
// Image upload: confirmed landed; an unconfirmed upload refuses before submit — never a
|
|
429
|
-
// silent text-only post while an image was requested.
|
|
469
|
+
// silent text-only post while an image was requested. When posting a URL with no image,
|
|
470
|
+
// wait briefly (best-effort) for LinkedIn to finish attaching the async OG link-preview card.
|
|
430
471
|
const [image] = images;
|
|
431
472
|
if (image !== undefined) {
|
|
432
473
|
const uploaded = await this.uploadImage(page, image);
|
|
433
474
|
if (!uploaded.ok) return stageFail(uploaded.error, 'image-upload', metadata);
|
|
475
|
+
} else {
|
|
476
|
+
await this.waitForLinkPreview(page, composerSelector, text);
|
|
434
477
|
}
|
|
435
478
|
|
|
436
479
|
// Baselines before submit: only fresh toast and fresh post-link signals can confirm.
|
|
@@ -438,22 +481,77 @@ export class LinkedinBrowserTransport implements PublishTransport {
|
|
|
438
481
|
const beforeLinks = await this.readPostLinks(page);
|
|
439
482
|
|
|
440
483
|
// Send: the Post control inside the share dialog.
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
484
|
+
// Prefer the role engine. The composer's Post is a plain `<button>Post</button>` that is
|
|
485
|
+
// visible and enabled in the captured state (2026-11-20 screenshot) while every CSS form in
|
|
486
|
+
// the list failed to resolve — the same class of miss the threads rail hit with `text-is`
|
|
487
|
+
// against a styled label. `getByRole` names the control as the user sees it; the composer's
|
|
488
|
+
// Post is the LAST match because the feed's own Post entry point sits above it.
|
|
489
|
+
const roleEngine = page as unknown as {
|
|
490
|
+
getByRole?: (
|
|
491
|
+
role: string,
|
|
492
|
+
options: { name: string; exact: boolean },
|
|
493
|
+
) => { count(): Promise<number>; last(): { click(options?: { timeout?: number }): Promise<unknown> } };
|
|
494
|
+
};
|
|
495
|
+
const rolePost = roleEngine.getByRole?.('button', { name: 'Post', exact: true });
|
|
496
|
+
const roleCount = rolePost === undefined ? 0 : await rolePost.count().catch(() => 0);
|
|
497
|
+
const sendSelector =
|
|
498
|
+
roleCount > 0
|
|
499
|
+
? 'role:Post'
|
|
500
|
+
: await resolveSelector(page, LINKEDIN_POST_SELECTORS.send, {
|
|
501
|
+
timeoutMs: this.stepTimeoutMs,
|
|
502
|
+
label: 'linkedin Post button',
|
|
503
|
+
}).catch(async (error: unknown) => {
|
|
504
|
+
// The composer is a plain overlay (no dialog role), so a selector list that matches only
|
|
505
|
+
// inside `[role="dialog"]` reads as "not attached" while Post is plainly on screen. Report
|
|
506
|
+
// what the composer actually holds — and whether it is still open — instead of the list.
|
|
507
|
+
const state = await page
|
|
508
|
+
.evaluate(`(() => {
|
|
509
|
+
const editor = document.querySelector('div.ProseMirror[contenteditable="true"], div[role="textbox"][contenteditable="true"]');
|
|
510
|
+
const buttons = [...document.querySelectorAll('button, div[role="button"]')]
|
|
511
|
+
.filter((n) => n.offsetWidth > 0)
|
|
512
|
+
.map((n) => (n.getAttribute('aria-label') || n.textContent || '').replace(/\\s+/g, ' ').trim())
|
|
513
|
+
.filter(Boolean).slice(-12);
|
|
514
|
+
return JSON.stringify({
|
|
515
|
+
composerOpen: editor !== null,
|
|
516
|
+
textLen: (editor?.textContent || '').trim().length,
|
|
517
|
+
buttons,
|
|
518
|
+
});
|
|
519
|
+
})()`)
|
|
520
|
+
.catch(() => null);
|
|
521
|
+
// A screenshot is the only way to see WHICH overlay is covering Post when the DOM
|
|
522
|
+
// reports the composer open and the typed text present (2026-11-20: media step).
|
|
523
|
+
const shot = await page
|
|
524
|
+
.screenshot({ path: `/tmp/kk-linkedin-send-${Date.now()}.png` })
|
|
525
|
+
.then((buffer: unknown) =>
|
|
526
|
+
typeof buffer === 'string' ? buffer : `/tmp/kk-linkedin-send.png`,
|
|
527
|
+
)
|
|
528
|
+
.catch(() => null);
|
|
529
|
+
await page.screenshot({ path: '/tmp/kk-linkedin-send-latest.png' }).catch(() => null);
|
|
530
|
+
throw new Error(
|
|
531
|
+
`${String((error as Error)?.message ?? error)}${state ? ` — composer ${state}` : ''}${shot ? ` — screenshot /tmp/kk-linkedin-send-latest.png` : ''}`,
|
|
532
|
+
);
|
|
533
|
+
});
|
|
534
|
+
const send = sendSelector === 'role:Post' ? null : page.locator(sendSelector).first();
|
|
535
|
+
const enabled = await expectOutcome(
|
|
536
|
+
async () => {
|
|
537
|
+
if (rolePost !== undefined && sendSelector === 'role:Post') {
|
|
538
|
+
return (await rolePost.count()) > 0 ? 'enabled' : null;
|
|
539
|
+
}
|
|
540
|
+
return send !== null && (await send.isEnabled()) ? 'enabled' : null;
|
|
541
|
+
},
|
|
542
|
+
{ timeoutMs: this.stepTimeoutMs, label: 'linkedin Post button enabled' },
|
|
543
|
+
);
|
|
450
544
|
if (!enabled.ok)
|
|
451
545
|
return stageFail(
|
|
452
546
|
`linkedin Post button never became clickable — ${enabled.error}`,
|
|
453
547
|
'send-enabled',
|
|
454
548
|
metadata,
|
|
455
549
|
);
|
|
456
|
-
|
|
550
|
+
if (rolePost !== undefined && sendSelector === 'role:Post') {
|
|
551
|
+
await rolePost.last().click({ timeout: this.stepTimeoutMs });
|
|
552
|
+
} else if (send !== null) {
|
|
553
|
+
await send.click();
|
|
554
|
+
}
|
|
457
555
|
|
|
458
556
|
// Confirmation: a failure toast fails fast; otherwise the fresh post link is preferred so
|
|
459
557
|
// the Result can carry the created post's url/id, with the fresh success toast as the
|
|
@@ -538,12 +636,49 @@ export class LinkedinBrowserTransport implements PublishTransport {
|
|
|
538
636
|
error: `linkedin composer preview never reached ${before + 1} media nodes (baseline ${before}) for the uploaded image`,
|
|
539
637
|
};
|
|
540
638
|
}
|
|
639
|
+
const mediaNext = (
|
|
640
|
+
page as unknown as {
|
|
641
|
+
getByRole?: (
|
|
642
|
+
role: 'button',
|
|
643
|
+
opts: { name: RegExp },
|
|
644
|
+
) => {
|
|
645
|
+
count(): Promise<number>;
|
|
646
|
+
first(): { click(opts?: { timeout?: number }): Promise<unknown> };
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
).getByRole?.('button', { name: /^(?:Next|Done)$/i });
|
|
650
|
+
if (mediaNext !== undefined && (await mediaNext.count()) > 0) {
|
|
651
|
+
await mediaNext.first().click({ timeout: this.stepTimeoutMs });
|
|
652
|
+
await expectOutcome(async () => ((await mediaNext.count()) === 0 ? 'media editor closed' : null), {
|
|
653
|
+
timeoutMs: Math.min(this.stepTimeoutMs, 10_000),
|
|
654
|
+
label: 'linkedin media editor close',
|
|
655
|
+
});
|
|
656
|
+
}
|
|
541
657
|
return { ok: true, evidence: confirmed.evidence };
|
|
542
658
|
} catch (error) {
|
|
543
659
|
return { ok: false, error: `linkedin image upload failed — ${errorMessage(error)}` };
|
|
544
660
|
}
|
|
545
661
|
}
|
|
546
662
|
|
|
663
|
+
/** Best-effort wait for LinkedIn's async OG card fetch when posting a URL without an image. */
|
|
664
|
+
private async waitForLinkPreview(page: Page, composerSelector: string, text: string): Promise<void> {
|
|
665
|
+
const host = extractUrlHost(text);
|
|
666
|
+
if (host === null) return;
|
|
667
|
+
await expectOutcome(
|
|
668
|
+
async () => {
|
|
669
|
+
const hit = String(
|
|
670
|
+
await page.evaluate(linkPreviewScript(composerSelector, host)).catch(() => ''),
|
|
671
|
+
).trim();
|
|
672
|
+
return hit.length > 0 ? 'link preview attached' : null;
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
timeoutMs: Math.min(this.stepTimeoutMs, LINK_PREVIEW_TIMEOUT_MS),
|
|
676
|
+
pollMs: PREVIEW_POLL_MS,
|
|
677
|
+
label: 'linkedin link preview',
|
|
678
|
+
},
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
|
|
547
682
|
/** Visible toast texts (provisional containers), used as the pre-send baseline. */
|
|
548
683
|
private async readToasts(page: Page): Promise<readonly string[]> {
|
|
549
684
|
return parseStringArray(await page.evaluate(toastTextsScript()));
|
|
@@ -612,11 +747,50 @@ function editorTextScript(selector: string): string {
|
|
|
612
747
|
*/
|
|
613
748
|
function mediaEvidenceScript(): string {
|
|
614
749
|
return `(() => { // kk-linkedin-media-evidence
|
|
615
|
-
const
|
|
750
|
+
const dialogs = [...document.querySelectorAll('[role="dialog"]')].filter((n) => n.offsetWidth > 0);
|
|
751
|
+
const scope = dialogs.length > 0 ? dialogs[dialogs.length - 1] : document;
|
|
616
752
|
return scope.querySelectorAll('img[src], video[src], video source[src], [style*="background-image"]').length;
|
|
617
753
|
})()`;
|
|
618
754
|
}
|
|
619
755
|
|
|
756
|
+
/** Extracts a lowercase hostname from the first HTTP(S) URL in post text, if parseable. */
|
|
757
|
+
function extractUrlHost(text: string): string | null {
|
|
758
|
+
const match = /https?:\/\/[^\s)>"'<>]+/i.exec(text);
|
|
759
|
+
if (!match) return null;
|
|
760
|
+
const cleaned = match[0].replace(/[.,;:!?。,;!?]+$/, '');
|
|
761
|
+
try {
|
|
762
|
+
return new URL(cleaned).hostname.toLowerCase();
|
|
763
|
+
} catch {
|
|
764
|
+
return null;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Detects an asynchronously attached OG preview card inside the share composer without matching
|
|
770
|
+
* text inside the editor itself (`img[src*="articleshare"]` or a leaf node displaying the URL host).
|
|
771
|
+
*/
|
|
772
|
+
function linkPreviewScript(composerSelector: string, host: string): string {
|
|
773
|
+
return `(() => { // kk-linkedin-link-preview
|
|
774
|
+
const editor = document.querySelector(${JSON.stringify(composerSelector)});
|
|
775
|
+
if (!editor) return '';
|
|
776
|
+
let scope = editor.parentElement;
|
|
777
|
+
while (scope && scope.parentElement && scope !== document.body) {
|
|
778
|
+
if ([...scope.querySelectorAll('button')].some((b) => (b.textContent || '').trim() === 'Post')) break;
|
|
779
|
+
scope = scope.parentElement;
|
|
780
|
+
}
|
|
781
|
+
scope = scope || editor.closest('[role="dialog"]') || document.body;
|
|
782
|
+
if (scope.querySelector('img[src*="articleshare"]')) return '1';
|
|
783
|
+
const hostLower = ${JSON.stringify(host)};
|
|
784
|
+
for (const node of scope.querySelectorAll('*')) {
|
|
785
|
+
if (editor.contains(node) || node.contains(editor)) continue;
|
|
786
|
+
if (node.children.length === 0 && (node.textContent || '').toLowerCase().includes(hostLower)) {
|
|
787
|
+
return '1';
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return '';
|
|
791
|
+
})()`;
|
|
792
|
+
}
|
|
793
|
+
|
|
620
794
|
/** Visible toast texts, used as the pre-send baseline and as the fresh-signal read (provisional). */
|
|
621
795
|
function toastTextsScript(): string {
|
|
622
796
|
return `(() => { // kk-linkedin-toasts
|
|
@@ -4813,7 +4813,7 @@ var init_zod = __esm(() => {
|
|
|
4813
4813
|
init_external();
|
|
4814
4814
|
});
|
|
4815
4815
|
|
|
4816
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4816
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/errors.js
|
|
4817
4817
|
var ErrorCode;
|
|
4818
4818
|
var init_errors3 = __esm(() => {
|
|
4819
4819
|
ErrorCode = {
|
|
@@ -4824,7 +4824,7 @@ var init_errors3 = __esm(() => {
|
|
|
4824
4824
|
};
|
|
4825
4825
|
});
|
|
4826
4826
|
|
|
4827
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4827
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/api-response.js
|
|
4828
4828
|
var API_ERROR_CODES, ERROR_CODE_TO_HTTP, CLIENT_SAFE_CODES;
|
|
4829
4829
|
var init_api_response = __esm(() => {
|
|
4830
4830
|
init_errors3();
|
|
@@ -4847,13 +4847,13 @@ var init_api_response = __esm(() => {
|
|
|
4847
4847
|
CLIENT_SAFE_CODES = new Set([ErrorCode.NotFound, ErrorCode.Validation, ErrorCode.Conflict]);
|
|
4848
4848
|
});
|
|
4849
4849
|
|
|
4850
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4850
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/cursor.js
|
|
4851
4851
|
var init_cursor = () => {};
|
|
4852
4852
|
|
|
4853
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4853
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/event-severity.js
|
|
4854
4854
|
var init_event_severity = () => {};
|
|
4855
4855
|
|
|
4856
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4856
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/output.js
|
|
4857
4857
|
function processStream(name) {
|
|
4858
4858
|
const proc = globalThis.process;
|
|
4859
4859
|
const stream = proc?.[name];
|
|
@@ -4871,7 +4871,7 @@ function echoError(message, target = defaultStderrTarget ?? processStream("stder
|
|
|
4871
4871
|
}
|
|
4872
4872
|
var defaultStderrTarget;
|
|
4873
4873
|
|
|
4874
|
-
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.
|
|
4874
|
+
// ../../node_modules/.bun/@gobing-ai+ts-utils@0.8.4/node_modules/@gobing-ai/ts-utils/dist/index.js
|
|
4875
4875
|
var init_dist = __esm(() => {
|
|
4876
4876
|
init_api_response();
|
|
4877
4877
|
init_cursor();
|
|
@@ -11869,7 +11869,7 @@ var init_dist2 = __esm(() => {
|
|
|
11869
11869
|
$visitAsync = visit.visitAsync;
|
|
11870
11870
|
});
|
|
11871
11871
|
|
|
11872
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11872
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/config.js
|
|
11873
11873
|
var configSchema;
|
|
11874
11874
|
var init_config = __esm(() => {
|
|
11875
11875
|
init_dist2();
|
|
@@ -11893,7 +11893,7 @@ var init_config = __esm(() => {
|
|
|
11893
11893
|
});
|
|
11894
11894
|
});
|
|
11895
11895
|
|
|
11896
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
11896
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/file-system-node.js
|
|
11897
11897
|
import { appendFileSync, cpSync, createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
|
|
11898
11898
|
import { dirname, resolve as resolvePath } from "path";
|
|
11899
11899
|
function createNodeFileSystem(root, paths) {
|
|
@@ -12248,7 +12248,7 @@ var PluginManifestSchema = PluginManifestSchemaBase.superRefine((manifest, ctx)
|
|
|
12248
12248
|
});
|
|
12249
12249
|
}
|
|
12250
12250
|
});
|
|
12251
|
-
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.
|
|
12251
|
+
// ../../node_modules/.bun/@gobing-ai+ts-runtime@0.8.4+b85a65bb895e3074/node_modules/@gobing-ai/ts-runtime/dist/index.js
|
|
12252
12252
|
init_file_system_node();
|
|
12253
12253
|
init_config();
|
|
12254
12254
|
|