@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
|
@@ -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 {
|
|
@@ -20801,6 +20801,9 @@ async function ensureProfileDir2(profileDir, headless) {
|
|
|
20801
20801
|
var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
20802
20802
|
// ../../packages/publish-harness/src/browser.ts
|
|
20803
20803
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20804
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20805
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20806
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20804
20807
|
var DEFAULT_STEP_TIMEOUT_MS = 30000;
|
|
20805
20808
|
var DEFAULT_POLL_MS = 500;
|
|
20806
20809
|
var ATTACH_POLL_MS = 100;
|
|
@@ -20925,14 +20928,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20925
20928
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20926
20929
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20927
20930
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20931
|
+
const deadline = Date.now() + timeoutMs;
|
|
20932
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20933
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20934
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20928
20935
|
for (const headless of passes) {
|
|
20936
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20937
|
+
if (remainingMs < minPassMs)
|
|
20938
|
+
break;
|
|
20929
20939
|
try {
|
|
20930
20940
|
await withProfilePage({
|
|
20931
20941
|
profileDir: opts.profileDir,
|
|
20932
20942
|
headless,
|
|
20933
20943
|
url: config.homeUrl,
|
|
20934
20944
|
isAuthenticated: config.isAuthenticated,
|
|
20935
|
-
timeoutMs,
|
|
20945
|
+
timeoutMs: remainingMs,
|
|
20936
20946
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20937
20947
|
}, async () => true);
|
|
20938
20948
|
return {
|
|
@@ -21045,7 +21055,8 @@ function editorTextScript(selector) {
|
|
|
21045
21055
|
init_dist();
|
|
21046
21056
|
|
|
21047
21057
|
// ../../plugins/publishings/x-pub/src/post-rail.ts
|
|
21048
|
-
import {
|
|
21058
|
+
import { tmpdir } from "os";
|
|
21059
|
+
import { extname, isAbsolute as isAbsolute2, join as join6 } from "path";
|
|
21049
21060
|
var TARGET = "x";
|
|
21050
21061
|
var LOGIN_INSTRUCTION = "bun plugins/publishings/x-pub/src/profile-check.ts login";
|
|
21051
21062
|
var STEP_TIMEOUT_MS = 30000;
|
|
@@ -21056,6 +21067,8 @@ var X_POST_URL = "https://x.com/home";
|
|
|
21056
21067
|
var X_NEW_POST_BUTTON = '[data-testid="SideNav_NewTweet_Button"]';
|
|
21057
21068
|
var X_COMPOSE_PATH = "/compose/post";
|
|
21058
21069
|
var X_POST_SUBMIT = '[data-testid="tweetButton"]';
|
|
21070
|
+
var X_POST_SUBMIT_INLINE = '[data-testid="tweetButtonInline"]';
|
|
21071
|
+
var X_POST_SUBMITS = [X_POST_SUBMIT, X_POST_SUBMIT_INLINE];
|
|
21059
21072
|
var POST_SELECTORS = {
|
|
21060
21073
|
text: ['[data-testid="tweetTextarea_0"]'],
|
|
21061
21074
|
mediaButton: ['button[aria-label="Add photos or video"]', '[aria-label*="Add photos" i]'],
|
|
@@ -21180,9 +21193,7 @@ class XPostBrowserTransport {
|
|
|
21180
21193
|
}
|
|
21181
21194
|
async typeAndEnable(page, text) {
|
|
21182
21195
|
const textBox = page.locator(POST_SELECTORS.text[0]).first();
|
|
21183
|
-
const submit = page.locator(X_POST_SUBMIT).first();
|
|
21184
21196
|
for (let attempt = 1;attempt <= 3; attempt++) {
|
|
21185
|
-
await page.keyboard.press("Escape").catch(() => {});
|
|
21186
21197
|
await page.waitForTimeout(250);
|
|
21187
21198
|
const focused = await textBox.click({ force: true }).then(() => true, () => textBox.focus().then(() => true).catch(() => false));
|
|
21188
21199
|
if (!focused)
|
|
@@ -21191,7 +21202,13 @@ class XPostBrowserTransport {
|
|
|
21191
21202
|
await textBox.press("ControlOrMeta+a").catch(() => {});
|
|
21192
21203
|
await textBox.press("Backspace").catch(() => {});
|
|
21193
21204
|
await textBox.pressSequentially(text, { delay: 8 });
|
|
21194
|
-
const enabled = await expectOutcome(async () =>
|
|
21205
|
+
const enabled = await expectOutcome(async () => {
|
|
21206
|
+
for (const selector of X_POST_SUBMITS) {
|
|
21207
|
+
if (await page.locator(selector).first().isEnabled().catch(() => false))
|
|
21208
|
+
return "post enabled";
|
|
21209
|
+
}
|
|
21210
|
+
return null;
|
|
21211
|
+
}, { timeoutMs: Math.min(1e4, this.stepTimeoutMs), label: `x post enabled (attempt ${attempt})` });
|
|
21195
21212
|
if (enabled.ok)
|
|
21196
21213
|
return null;
|
|
21197
21214
|
}
|
|
@@ -21227,10 +21244,58 @@ class XPostBrowserTransport {
|
|
|
21227
21244
|
if (!attached.ok)
|
|
21228
21245
|
return fail(`x post image was uploaded but never rendered: ${attached.error}`);
|
|
21229
21246
|
const reEnabled = await expectOutcome(async () => await page.locator(X_POST_SUBMIT).first().isEnabled().catch(() => false) ? "post re-enabled" : null, { timeoutMs: this.stepTimeoutMs * 4, label: "x post submit enabled after media" });
|
|
21230
|
-
if (!reEnabled.ok)
|
|
21231
|
-
|
|
21232
|
-
|
|
21233
|
-
|
|
21247
|
+
if (!reEnabled.ok) {
|
|
21248
|
+
const observable = page;
|
|
21249
|
+
const evidence = await (observable.evaluate === undefined ? Promise.resolve(null) : observable.evaluate(`(() => {
|
|
21250
|
+
const editor = document.querySelector('[data-testid="tweetTextarea_0"]');
|
|
21251
|
+
const submit = document.querySelector('${X_POST_SUBMIT}');
|
|
21252
|
+
const alerts = [...document.querySelectorAll('[data-testid="toast"], [role="alert"], [data-testid="error-detail"]')]
|
|
21253
|
+
.map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim()).filter(Boolean).slice(0, 3);
|
|
21254
|
+
const images = [...document.querySelectorAll('[data-testid="attachments"] img, [data-testid="tweetPhoto"] img')].length;
|
|
21255
|
+
return JSON.stringify({
|
|
21256
|
+
textLen: (editor?.textContent || '').trim().length,
|
|
21257
|
+
submitDisabled: submit?.getAttribute('aria-disabled') ?? (submit?.disabled === true ? 'true' : 'false'),
|
|
21258
|
+
images,
|
|
21259
|
+
alerts,
|
|
21260
|
+
});
|
|
21261
|
+
})()`).catch(() => null));
|
|
21262
|
+
return fail(`x post submit stayed disabled after the media: ${reEnabled.error}${evidence ? ` \u2014 composer ${String(evidence)}` : ""}`);
|
|
21263
|
+
}
|
|
21264
|
+
}
|
|
21265
|
+
const submit = await (async () => {
|
|
21266
|
+
let enabledFallback = null;
|
|
21267
|
+
for (const selector of X_POST_SUBMITS) {
|
|
21268
|
+
const candidate = page.locator(selector).first();
|
|
21269
|
+
const enabled = await candidate.isEnabled().catch(() => false);
|
|
21270
|
+
if (!enabled)
|
|
21271
|
+
continue;
|
|
21272
|
+
const visible = await candidate.isVisible().catch(() => false);
|
|
21273
|
+
if (visible)
|
|
21274
|
+
return candidate;
|
|
21275
|
+
enabledFallback ??= candidate;
|
|
21276
|
+
}
|
|
21277
|
+
return enabledFallback;
|
|
21278
|
+
})();
|
|
21279
|
+
if (submit === null)
|
|
21280
|
+
return fail("x post submit was enabled a moment ago but no clickable control remained");
|
|
21281
|
+
await submit.click();
|
|
21282
|
+
await page.waitForTimeout(2500);
|
|
21283
|
+
const observable = page;
|
|
21284
|
+
const afterClick = await (observable.evaluate === undefined ? Promise.resolve(null) : observable.evaluate(`(() => {
|
|
21285
|
+
const alerts = [...document.querySelectorAll('[data-testid="toast"], [role="alert"], [data-testid="error-detail"]')]
|
|
21286
|
+
.map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim()).filter(Boolean).slice(0, 3);
|
|
21287
|
+
const dialogs = [...document.querySelectorAll('[role="dialog"]')]
|
|
21288
|
+
.map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim().slice(0, 120)).filter(Boolean).slice(0, 2);
|
|
21289
|
+
const editor = document.querySelector('[data-testid="tweetTextarea_0"]');
|
|
21290
|
+
return JSON.stringify({
|
|
21291
|
+
path: location.pathname,
|
|
21292
|
+
textLen: (editor?.textContent || '').trim().length,
|
|
21293
|
+
alerts,
|
|
21294
|
+
dialogs,
|
|
21295
|
+
});
|
|
21296
|
+
})()`).catch(() => null));
|
|
21297
|
+
const shot = join6(tmpdir(), `kk-x-post-${Date.now()}.png`);
|
|
21298
|
+
const shotOk = await (observable.screenshot === undefined ? Promise.resolve(false) : observable.screenshot({ path: shot }).then(() => true).catch(() => false));
|
|
21234
21299
|
const receipt = await expectOutcome(async () => {
|
|
21235
21300
|
const id = await this.newestStatusId(page, handle);
|
|
21236
21301
|
if (id === null)
|
|
@@ -21239,8 +21304,28 @@ class XPostBrowserTransport {
|
|
|
21239
21304
|
return null;
|
|
21240
21305
|
return `https://x.com${handle}/status/${id}`;
|
|
21241
21306
|
}, { timeoutMs: this.stepTimeoutMs, label: "x status receipt" });
|
|
21307
|
+
const sentToast = /post was sent|\u5DF2\u53D1\u5E03|\u53D1\u9001\u6210\u529F|\u5DF2\u53D1\u9001/i.test(String(afterClick ?? ""));
|
|
21308
|
+
if (!receipt.ok && sentToast) {
|
|
21309
|
+
return ResultSchema.parse({
|
|
21310
|
+
ok: true,
|
|
21311
|
+
target: TARGET,
|
|
21312
|
+
url: `https://x.com${handle}`,
|
|
21313
|
+
message: `x post sent \u2014 X confirmed it in the composer toast; the profile timeline had not rendered it yet, so no status id was recorded`,
|
|
21314
|
+
metadata: { ...metadata, confirmedBy: "post-sent-toast" }
|
|
21315
|
+
});
|
|
21316
|
+
}
|
|
21242
21317
|
if (!receipt.ok) {
|
|
21243
|
-
|
|
21318
|
+
const evidence = await (observable.evaluate === undefined ? Promise.resolve(null) : observable.evaluate(`(() => {
|
|
21319
|
+
const alerts = [...document.querySelectorAll('[data-testid="toast"], [role="alert"], [data-testid="error-detail"]')]
|
|
21320
|
+
.map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim()).filter(Boolean).slice(0, 3);
|
|
21321
|
+
const editor = document.querySelector('[data-testid="tweetTextarea_0"]');
|
|
21322
|
+
return JSON.stringify({
|
|
21323
|
+
url: location.pathname,
|
|
21324
|
+
textLen: (editor?.textContent || '').trim().length,
|
|
21325
|
+
alerts,
|
|
21326
|
+
});
|
|
21327
|
+
})()`).catch(() => null));
|
|
21328
|
+
return fail(`x post receipt not confirmed \u2014 Post was clicked but no new status id appeared on the profile (${receipt.error}); an unobserved submit is never reported as published${afterClick ? ` \u2014 after click ${afterClick}` : ""}${shotOk ? ` \u2014 screenshot ${shot}` : ""}${evidence ? ` \u2014 console ${evidence}` : ""}`);
|
|
21244
21329
|
}
|
|
21245
21330
|
const id = /\/status\/(\d+)/.exec(receipt.evidence)?.[1];
|
|
21246
21331
|
return ResultSchema.parse({
|
|
@@ -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 {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* `fill()` leaves Post disabled), media `button[aria-label="Add photos or video"]` then
|
|
17
17
|
* `input[data-testid="fileInput"]`, submit `[data-testid="tweetButton"]`.
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
19
|
+
import { tmpdir } from 'node:os';
|
|
20
|
+
import { extname, isAbsolute, join } from 'node:path';
|
|
20
21
|
import type { Result } from '@gobing-ai/kk-core';
|
|
21
22
|
import { ResultSchema } from '@gobing-ai/kk-core';
|
|
22
23
|
import { type PublishTransport, type PublishTransportPayload, trySelectors } from '@gobing-ai/publish-harness';
|
|
@@ -47,8 +48,15 @@ export const X_POST_URL = 'https://x.com/home';
|
|
|
47
48
|
export const X_NEW_POST_BUTTON = '[data-testid="SideNav_NewTweet_Button"]';
|
|
48
49
|
/** Composer page the nav button lands on. */
|
|
49
50
|
export const X_COMPOSE_PATH = '/compose/post';
|
|
50
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Submit controls, measured 2026-11-20 on `/compose/post`: the **page** composer carries
|
|
53
|
+
* `[data-testid="tweetButton"]`, and the inline composer on `/home` carries
|
|
54
|
+
* `[data-testid="tweetButtonInline"]`. Both start `disabled`/`aria-disabled="true"` and enable as soon
|
|
55
|
+
* as the editor holds text, so the rail must accept either rather than assume the page one survives.
|
|
56
|
+
*/
|
|
51
57
|
export const X_POST_SUBMIT = '[data-testid="tweetButton"]';
|
|
58
|
+
export const X_POST_SUBMIT_INLINE = '[data-testid="tweetButtonInline"]';
|
|
59
|
+
export const X_POST_SUBMITS: readonly string[] = [X_POST_SUBMIT, X_POST_SUBMIT_INLINE];
|
|
52
60
|
|
|
53
61
|
/** Composer controls, all page-scoped (measured 2026-11-16). */
|
|
54
62
|
export const POST_SELECTORS = {
|
|
@@ -211,15 +219,18 @@ export class XPostBrowserTransport implements PublishTransport {
|
|
|
211
219
|
return composer.ok ? null : `x composer never opened at ${X_COMPOSE_PATH}: ${composer.error}`;
|
|
212
220
|
}
|
|
213
221
|
|
|
214
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Types the text and requires the Post control to enable (bounded three attempts).
|
|
224
|
+
*
|
|
225
|
+
* Measured 2026-11-20: **Escape on `/compose/post` navigates to `/home`** — the compose surface is a
|
|
226
|
+
* page there, not an overlay — so the old "press Escape to clear the mask" first move threw the
|
|
227
|
+
* run off the page whose submit it then waited on (`[data-testid="tweetButton"]` is page-scoped and
|
|
228
|
+
* disappears), and every attempt ended as "post submit never enabled". A mask, when it exists, is
|
|
229
|
+
* cleared by the forced editor click below, which never navigates.
|
|
230
|
+
*/
|
|
215
231
|
private async typeAndEnable(page: Page, text: string): Promise<string | null> {
|
|
216
232
|
const textBox = page.locator(POST_SELECTORS.text[0]).first();
|
|
217
|
-
const submit = page.locator(X_POST_SUBMIT).first();
|
|
218
233
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
219
|
-
// X can leave a `[data-testid="mask"]` layer over the composer (it opens the compose
|
|
220
|
-
// surface as an overlay after an in-app navigation), which swallows pointer events. A
|
|
221
|
-
// forced click, and focus as the fallback, reach the editor without dismissing it.
|
|
222
|
-
await page.keyboard.press('Escape').catch(() => {});
|
|
223
234
|
await page.waitForTimeout(250);
|
|
224
235
|
const focused = await textBox.click({ force: true }).then(
|
|
225
236
|
() => true,
|
|
@@ -235,7 +246,23 @@ export class XPostBrowserTransport implements PublishTransport {
|
|
|
235
246
|
await textBox.press('Backspace').catch(() => {});
|
|
236
247
|
await textBox.pressSequentially(text, { delay: 8 });
|
|
237
248
|
const enabled = await expectOutcome(
|
|
238
|
-
async () =>
|
|
249
|
+
async () => {
|
|
250
|
+
// Whichever submit control this surface renders: the page composer's
|
|
251
|
+
// `tweetButton`, or the inline composer's `tweetButtonInline` on /home. Asked by
|
|
252
|
+
// enablement, never by attachment — the page-scoped control is gone the moment the
|
|
253
|
+
// surface navigates, and an absent control simply reads disabled.
|
|
254
|
+
for (const selector of X_POST_SUBMITS) {
|
|
255
|
+
if (
|
|
256
|
+
await page
|
|
257
|
+
.locator(selector)
|
|
258
|
+
.first()
|
|
259
|
+
.isEnabled()
|
|
260
|
+
.catch(() => false)
|
|
261
|
+
)
|
|
262
|
+
return 'post enabled';
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
},
|
|
239
266
|
// One step, capped at 10s: a caller may shrink the step (tests), never stretch it.
|
|
240
267
|
{ timeoutMs: Math.min(10_000, this.stepTimeoutMs), label: `x post enabled (attempt ${attempt})` },
|
|
241
268
|
);
|
|
@@ -303,10 +330,93 @@ export class XPostBrowserTransport implements PublishTransport {
|
|
|
303
330
|
// Four steps: X transcodes the image and only then re-enables Post (30s step → 120s).
|
|
304
331
|
{ timeoutMs: this.stepTimeoutMs * 4, label: 'x post submit enabled after media' },
|
|
305
332
|
);
|
|
306
|
-
if (!reEnabled.ok)
|
|
333
|
+
if (!reEnabled.ok) {
|
|
334
|
+
// The submit state is a projection of what X thinks the composer holds: an empty
|
|
335
|
+
// editor (a re-mount dropped the typed text), a rejected upload, or an account
|
|
336
|
+
// banner all look identical as "disabled". Report the evidence instead of the
|
|
337
|
+
// symptom — the first live failure (2026-11-20) named only the timeout.
|
|
338
|
+
const observable = page as unknown as { evaluate?: (script: string) => Promise<unknown> };
|
|
339
|
+
const evidence = await (observable.evaluate === undefined
|
|
340
|
+
? Promise.resolve(null)
|
|
341
|
+
: observable
|
|
342
|
+
.evaluate(`(() => {
|
|
343
|
+
const editor = document.querySelector('[data-testid="tweetTextarea_0"]');
|
|
344
|
+
const submit = document.querySelector('${X_POST_SUBMIT}');
|
|
345
|
+
const alerts = [...document.querySelectorAll('[data-testid="toast"], [role="alert"], [data-testid="error-detail"]')]
|
|
346
|
+
.map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim()).filter(Boolean).slice(0, 3);
|
|
347
|
+
const images = [...document.querySelectorAll('[data-testid="attachments"] img, [data-testid="tweetPhoto"] img')].length;
|
|
348
|
+
return JSON.stringify({
|
|
349
|
+
textLen: (editor?.textContent || '').trim().length,
|
|
350
|
+
submitDisabled: submit?.getAttribute('aria-disabled') ?? (submit?.disabled === true ? 'true' : 'false'),
|
|
351
|
+
images,
|
|
352
|
+
alerts,
|
|
353
|
+
});
|
|
354
|
+
})()`)
|
|
355
|
+
.catch(() => null));
|
|
356
|
+
return fail(
|
|
357
|
+
`x post submit stayed disabled after the media: ${reEnabled.error}${evidence ? ` — composer ${String(evidence)}` : ''}`,
|
|
358
|
+
);
|
|
359
|
+
}
|
|
307
360
|
}
|
|
308
361
|
|
|
309
|
-
|
|
362
|
+
// Click the submit that is actually VISIBLE and ENABLED, across both surfaces. The module
|
|
363
|
+
// header already warns that the composer page carries a hidden template whose button never
|
|
364
|
+
// enables; `.first()` on `tweetButton` can pick that twin and swallow the click, which reads
|
|
365
|
+
// downstream as "Post was clicked but no new status id appeared" (measured 2026-11-20: two
|
|
366
|
+
// runs, no status on the profile, no error either).
|
|
367
|
+
const submit = await (async () => {
|
|
368
|
+
let enabledFallback: ReturnType<typeof page.locator> | null = null;
|
|
369
|
+
for (const selector of X_POST_SUBMITS) {
|
|
370
|
+
const candidate = page.locator(selector).first();
|
|
371
|
+
const enabled = await candidate.isEnabled().catch(() => false);
|
|
372
|
+
if (!enabled) continue;
|
|
373
|
+
// A visible, enabled control is the real one; the composer page also renders a hidden
|
|
374
|
+
// template whose button is enabled-looking but never posts. Preferring visibility and
|
|
375
|
+
// accepting enabled-only when visibility cannot be established keeps a surface whose
|
|
376
|
+
// button reports no layout (and the test double) working.
|
|
377
|
+
const visible = await candidate.isVisible().catch(() => false);
|
|
378
|
+
if (visible) return candidate;
|
|
379
|
+
enabledFallback ??= candidate;
|
|
380
|
+
}
|
|
381
|
+
return enabledFallback;
|
|
382
|
+
})();
|
|
383
|
+
if (submit === null) return fail('x post submit was enabled a moment ago but no clickable control remained');
|
|
384
|
+
await submit.click();
|
|
385
|
+
// Capture the composer's immediate reaction. The receipt step navigates to the profile, so
|
|
386
|
+
// any validation toast, "Posting…" state or blocking modal is gone by the time it reports —
|
|
387
|
+
// which is exactly how two silent failures happened on 2026-11-20. A screenshot is the
|
|
388
|
+
// cheapest decisive evidence: X says WHY it refused, in the UI, once.
|
|
389
|
+
await page.waitForTimeout(2_500);
|
|
390
|
+
// The double in `tests/post-rail.test.ts` models only the surface the rail clicks and reads;
|
|
391
|
+
// evaluate/screenshot are evidence-only, so a page without them must still publish.
|
|
392
|
+
const observable = page as unknown as {
|
|
393
|
+
evaluate?: (script: string) => Promise<unknown>;
|
|
394
|
+
screenshot?: (options: { path: string }) => Promise<unknown>;
|
|
395
|
+
};
|
|
396
|
+
const afterClick = await (observable.evaluate === undefined
|
|
397
|
+
? Promise.resolve(null)
|
|
398
|
+
: observable
|
|
399
|
+
.evaluate(`(() => {
|
|
400
|
+
const alerts = [...document.querySelectorAll('[data-testid="toast"], [role="alert"], [data-testid="error-detail"]')]
|
|
401
|
+
.map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim()).filter(Boolean).slice(0, 3);
|
|
402
|
+
const dialogs = [...document.querySelectorAll('[role="dialog"]')]
|
|
403
|
+
.map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim().slice(0, 120)).filter(Boolean).slice(0, 2);
|
|
404
|
+
const editor = document.querySelector('[data-testid="tweetTextarea_0"]');
|
|
405
|
+
return JSON.stringify({
|
|
406
|
+
path: location.pathname,
|
|
407
|
+
textLen: (editor?.textContent || '').trim().length,
|
|
408
|
+
alerts,
|
|
409
|
+
dialogs,
|
|
410
|
+
});
|
|
411
|
+
})()`)
|
|
412
|
+
.catch(() => null));
|
|
413
|
+
const shot = join(tmpdir(), `kk-x-post-${Date.now()}.png`);
|
|
414
|
+
const shotOk = await (observable.screenshot === undefined
|
|
415
|
+
? Promise.resolve(false)
|
|
416
|
+
: observable
|
|
417
|
+
.screenshot({ path: shot })
|
|
418
|
+
.then(() => true)
|
|
419
|
+
.catch(() => false));
|
|
310
420
|
const receipt = await expectOutcome(
|
|
311
421
|
async () => {
|
|
312
422
|
const id = await this.newestStatusId(page, handle);
|
|
@@ -316,9 +426,41 @@ export class XPostBrowserTransport implements PublishTransport {
|
|
|
316
426
|
},
|
|
317
427
|
{ timeoutMs: this.stepTimeoutMs, label: 'x status receipt' },
|
|
318
428
|
);
|
|
429
|
+
// X's own confirmation toast is a receipt in its own right. The profile-timeline poll above
|
|
430
|
+
// is the *preferred* evidence because it yields the status id, but the timeline can lag or
|
|
431
|
+
// refuse to render for a session that still posts fine (measured 2026-11-20: the toast read
|
|
432
|
+
// "Your post was sent. You have 1 hour to make any edits.", the profile showed nothing within
|
|
433
|
+
// 30 s, and the row failed — so a retry posted the same text AGAIN). Confirming on the toast
|
|
434
|
+
// turns a duplicate-generating "failure" into an honest success with no status id.
|
|
435
|
+
const sentToast = /post was sent|已发布|发送成功|已发送/i.test(String(afterClick ?? ''));
|
|
436
|
+
if (!receipt.ok && sentToast) {
|
|
437
|
+
return ResultSchema.parse({
|
|
438
|
+
ok: true,
|
|
439
|
+
target: TARGET,
|
|
440
|
+
url: `https://x.com${handle}`,
|
|
441
|
+
message: `x post sent — X confirmed it in the composer toast; the profile timeline had not rendered it yet, so no status id was recorded`,
|
|
442
|
+
metadata: { ...metadata, confirmedBy: 'post-sent-toast' },
|
|
443
|
+
});
|
|
444
|
+
}
|
|
319
445
|
if (!receipt.ok) {
|
|
446
|
+
// Name what the console said, not just that nothing appeared: a validation toast, a
|
|
447
|
+
// duplicate guard, an alt-text prompt and a swallowed click all look identical here.
|
|
448
|
+
const evidence = await (observable.evaluate === undefined
|
|
449
|
+
? Promise.resolve(null)
|
|
450
|
+
: observable
|
|
451
|
+
.evaluate(`(() => {
|
|
452
|
+
const alerts = [...document.querySelectorAll('[data-testid="toast"], [role="alert"], [data-testid="error-detail"]')]
|
|
453
|
+
.map((n) => (n.textContent || '').replace(/\\s+/g, ' ').trim()).filter(Boolean).slice(0, 3);
|
|
454
|
+
const editor = document.querySelector('[data-testid="tweetTextarea_0"]');
|
|
455
|
+
return JSON.stringify({
|
|
456
|
+
url: location.pathname,
|
|
457
|
+
textLen: (editor?.textContent || '').trim().length,
|
|
458
|
+
alerts,
|
|
459
|
+
});
|
|
460
|
+
})()`)
|
|
461
|
+
.catch(() => null));
|
|
320
462
|
return fail(
|
|
321
|
-
`x post receipt not confirmed — Post was clicked but no new status id appeared on the profile (${receipt.error}); an unobserved submit is never reported as published`,
|
|
463
|
+
`x post receipt not confirmed — Post was clicked but no new status id appeared on the profile (${receipt.error}); an unobserved submit is never reported as published${afterClick ? ` — after click ${afterClick}` : ''}${shotOk ? ` — screenshot ${shot}` : ''}${evidence ? ` — console ${evidence}` : ''}`,
|
|
322
464
|
);
|
|
323
465
|
}
|
|
324
466
|
const id = /\/status\/(\d+)/.exec(receipt.evidence)?.[1];
|
|
@@ -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 {
|
|
@@ -20583,6 +20583,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
|
20583
20583
|
var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
|
|
20584
20584
|
var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
|
|
20585
20585
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20586
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20587
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20588
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20586
20589
|
var DEFAULT_POLL_MS = 500;
|
|
20587
20590
|
function isInstantBrowserDeath(message) {
|
|
20588
20591
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
@@ -20705,14 +20708,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20705
20708
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20706
20709
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20707
20710
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20711
|
+
const deadline = Date.now() + timeoutMs;
|
|
20712
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20713
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20714
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20708
20715
|
for (const headless of passes) {
|
|
20716
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20717
|
+
if (remainingMs < minPassMs)
|
|
20718
|
+
break;
|
|
20709
20719
|
try {
|
|
20710
20720
|
await withProfilePage({
|
|
20711
20721
|
profileDir: opts.profileDir,
|
|
20712
20722
|
headless,
|
|
20713
20723
|
url: config.homeUrl,
|
|
20714
20724
|
isAuthenticated: config.isAuthenticated,
|
|
20715
|
-
timeoutMs,
|
|
20725
|
+
timeoutMs: remainingMs,
|
|
20716
20726
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20717
20727
|
}, async () => true);
|
|
20718
20728
|
return {
|
|
@@ -20782,6 +20782,9 @@ async function ensureProfileDir2(profileDir, headless) {
|
|
|
20782
20782
|
var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
20783
20783
|
// ../../packages/publish-harness/src/browser.ts
|
|
20784
20784
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20785
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20786
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20787
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20785
20788
|
var DEFAULT_STEP_TIMEOUT_MS = 30000;
|
|
20786
20789
|
var DEFAULT_POLL_MS = 500;
|
|
20787
20790
|
var ATTACH_POLL_MS = 100;
|
|
@@ -20906,14 +20909,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20906
20909
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20907
20910
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20908
20911
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20912
|
+
const deadline = Date.now() + timeoutMs;
|
|
20913
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20914
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20915
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20909
20916
|
for (const headless of passes) {
|
|
20917
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20918
|
+
if (remainingMs < minPassMs)
|
|
20919
|
+
break;
|
|
20910
20920
|
try {
|
|
20911
20921
|
await withProfilePage({
|
|
20912
20922
|
profileDir: opts.profileDir,
|
|
20913
20923
|
headless,
|
|
20914
20924
|
url: config.homeUrl,
|
|
20915
20925
|
isAuthenticated: config.isAuthenticated,
|
|
20916
|
-
timeoutMs,
|
|
20926
|
+
timeoutMs: remainingMs,
|
|
20917
20927
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20918
20928
|
}, async () => true);
|
|
20919
20929
|
return {
|
|
@@ -20210,6 +20210,9 @@ var MAX_QUEUED_BYTES = 8 * 1024 * 1024;
|
|
|
20210
20210
|
var DEFAULT_LOGIN_TIMEOUT_MS = 180000;
|
|
20211
20211
|
var DEFAULT_OPEN_NAV_TIMEOUT_MS = 30000;
|
|
20212
20212
|
var DEFAULT_CHECK_TIMEOUT_MS = 30000;
|
|
20213
|
+
var VERDICT_PRINT_MARGIN_MS = 2000;
|
|
20214
|
+
var MIN_PASS_BUDGET_MS = 5000;
|
|
20215
|
+
var PASS_LAUNCH_RESERVE_MS = 20000;
|
|
20213
20216
|
var DEFAULT_POLL_MS = 500;
|
|
20214
20217
|
function isInstantBrowserDeath(message) {
|
|
20215
20218
|
return /target page, context or browser has been closed|browser has been closed|target closed/i.test(message);
|
|
@@ -20332,14 +20335,21 @@ async function checkChannelSession(config, opts) {
|
|
|
20332
20335
|
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20333
20336
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20334
20337
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20338
|
+
const deadline = Date.now() + timeoutMs;
|
|
20339
|
+
const printMarginMs = Math.min(VERDICT_PRINT_MARGIN_MS, Math.floor(timeoutMs / 4));
|
|
20340
|
+
const minPassMs = Math.min(MIN_PASS_BUDGET_MS, Math.floor(timeoutMs / 3));
|
|
20341
|
+
const launchReserveMs = Math.min(PASS_LAUNCH_RESERVE_MS, Math.floor(timeoutMs / 3));
|
|
20335
20342
|
for (const headless of passes) {
|
|
20343
|
+
const remainingMs = deadline - Date.now() - printMarginMs - launchReserveMs;
|
|
20344
|
+
if (remainingMs < minPassMs)
|
|
20345
|
+
break;
|
|
20336
20346
|
try {
|
|
20337
20347
|
await withProfilePage({
|
|
20338
20348
|
profileDir: opts.profileDir,
|
|
20339
20349
|
headless,
|
|
20340
20350
|
url: config.homeUrl,
|
|
20341
20351
|
isAuthenticated: config.isAuthenticated,
|
|
20342
|
-
timeoutMs,
|
|
20352
|
+
timeoutMs: remainingMs,
|
|
20343
20353
|
launcher: opts.launcher ?? kkBrowserLauncher
|
|
20344
20354
|
}, async () => true);
|
|
20345
20355
|
return {
|