@gobing-ai/knowledge-kit 0.1.24 → 0.1.27
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 +416 -79
- package/package.json +1 -1
- package/plugins/generations/episode-plan-gen/dist/index.js +47 -6
- package/plugins/generations/episode-plan-gen/src/index.ts +71 -7
- package/plugins/generations/music-gen/dist/index.js +17 -13
- package/plugins/generations/music-gen/src/audio/measure.ts +25 -20
- package/plugins/kk/decisions/extract/ai-news.yaml +8 -1
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/publish-presets/daily-ai-voice.json +4 -4
- package/plugins/kk/publish-presets/itc-main.json +39 -23
- package/plugins/kk/scripts/cn-lead-gate.ts +494 -0
- package/plugins/kk/scripts/daily-stages.ts +880 -131
- package/plugins/kk/scripts/kk-workflow-stages.ts +58 -3
- package/plugins/kk/skills/content-safety/references/platforms/apple-podcasts.md +12 -5
- package/plugins/kk/skills/content-safety/references/platforms/wechatmp.md +8 -0
- package/plugins/kk/skills/content-safety/references/platforms/xiaoyuzhou.md +5 -0
- package/plugins/kk/skills/daily-news-cover/SKILL.md +96 -0
- package/plugins/kk/skills/daily-news-illustrations/SKILL.md +123 -0
- package/plugins/kk/skills/news-editorial/SKILL.md +25 -6
- package/plugins/kk/skills/news-editorial/references/daily-visual-composition.md +150 -0
- package/plugins/kk/skills/news-editorial/references/selection.md +42 -0
- package/plugins/kk/skills/news-editorial/references/style-contract.zh.md +1 -1
- package/plugins/kk/workflows/kk-article-generate.yaml +13 -1
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +6 -3
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -4
- package/plugins/kk/workflows/kk-news-generate.yaml +71 -1
- package/plugins/publishings/bilibili-pub/dist/index.js +35 -3
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/cnblogs-pub/dist/index.js +35 -3
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/csdn-pub/dist/index.js +35 -3
- package/plugins/publishings/csdn-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/infoq-pub/dist/index.js +35 -3
- package/plugins/publishings/infoq-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/jike-pub/dist/index.js +35 -3
- package/plugins/publishings/jike-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/juejin-pub/dist/index.js +35 -3
- package/plugins/publishings/juejin-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/linkedin-pub/dist/index.js +86 -14
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +52 -6
- package/plugins/publishings/linkedin-pub/src/index.ts +126 -9
- package/plugins/publishings/medium-pub/dist/index.js +9229 -279
- package/plugins/publishings/medium-pub/dist/profile-check.js +21205 -0
- package/plugins/publishings/medium-pub/package.json +3 -1
- package/plugins/publishings/medium-pub/plugin.json +6 -1
- package/plugins/publishings/medium-pub/src/browser-rail.ts +280 -0
- package/plugins/publishings/medium-pub/src/index.ts +17 -1
- package/plugins/publishings/medium-pub/src/profile-check.ts +27 -0
- package/plugins/publishings/shipinhao-pub/dist/index.js +38 -4
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +37 -4
- package/plugins/publishings/shipinhao-pub/src/flow.ts +5 -0
- package/plugins/publishings/shipinhao-pub/src/selectors.ts +11 -4
- package/plugins/publishings/sspai-pub/dist/index.js +35 -3
- package/plugins/publishings/sspai-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/substack-pub/dist/index.js +35 -3
- package/plugins/publishings/substack-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/surfdash-pub/dist/index.js +53 -15
- package/plugins/publishings/surfdash-pub/src/index.ts +31 -4
- package/plugins/publishings/surfdash-pub/src/patch.ts +81 -12
- package/plugins/publishings/threads-pub/dist/index.js +35 -3
- package/plugins/publishings/threads-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/wechatmp-pub/dist/index.js +326 -44
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +69 -4
- package/plugins/publishings/wechatmp-pub/src/flow.ts +447 -53
- package/plugins/publishings/wechatmp-pub/src/index.ts +68 -2
- package/plugins/publishings/wechatmp-pub/src/page.ts +8 -0
- package/plugins/publishings/weibo-pub/dist/index.js +58 -9
- package/plugins/publishings/weibo-pub/dist/profile-check.js +57 -9
- package/plugins/publishings/weibo-pub/plugin.json +1 -1
- package/plugins/publishings/weibo-pub/src/index.ts +76 -8
- package/plugins/publishings/x-pub/dist/index.js +35 -3
- package/plugins/publishings/x-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/xhs-pub/dist/index.js +35 -3
- package/plugins/publishings/xhs-pub/dist/profile-check.js +35 -3
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +35 -3
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +35 -3
|
@@ -19947,7 +19947,12 @@ async function acquireProfileLease(profileDir, options = {}) {
|
|
|
19947
19947
|
const leaseDir = join2(leaseRoot, id);
|
|
19948
19948
|
await fileSystem.ensureDir(leaseRoot);
|
|
19949
19949
|
if (!mkdirExclusive(leaseDir, 448)) {
|
|
19950
|
-
|
|
19950
|
+
if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
|
|
19951
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
19952
|
+
}
|
|
19953
|
+
if (!mkdirExclusive(leaseDir, 448)) {
|
|
19954
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
19955
|
+
}
|
|
19951
19956
|
}
|
|
19952
19957
|
const token = randomBytes(16).toString("hex");
|
|
19953
19958
|
const owner = {
|
|
@@ -20063,7 +20068,34 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
20063
20068
|
}
|
|
20064
20069
|
return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
|
|
20065
20070
|
}
|
|
20066
|
-
|
|
20071
|
+
const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
|
|
20072
|
+
const suffix = live.length > 0 ? `pid ${owner.pid} is gone but child holders ${live.join(", ")} are still running \u2014 stop those processes before retrying` : isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running and the lease could not be reclassified \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
20073
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
20074
|
+
}
|
|
20075
|
+
async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
|
|
20076
|
+
const owner = await readOwner(fileSystem, leaseDir);
|
|
20077
|
+
if (owner === null || isProcessAlive(owner.pid))
|
|
20078
|
+
return false;
|
|
20079
|
+
if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
|
|
20080
|
+
return false;
|
|
20081
|
+
const target = staleLeaseDir(leaseDir);
|
|
20082
|
+
try {
|
|
20083
|
+
rename(leaseDir, target);
|
|
20084
|
+
} catch {
|
|
20085
|
+
return false;
|
|
20086
|
+
}
|
|
20087
|
+
const moved = await readOwner(fileSystem, target);
|
|
20088
|
+
if (moved !== null && moved.token !== owner.token) {
|
|
20089
|
+
try {
|
|
20090
|
+
rename(target, leaseDir);
|
|
20091
|
+
} catch {}
|
|
20092
|
+
return false;
|
|
20093
|
+
}
|
|
20094
|
+
return true;
|
|
20095
|
+
}
|
|
20096
|
+
function staleLeaseDir(leaseDir) {
|
|
20097
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
|
|
20098
|
+
return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
|
|
20067
20099
|
}
|
|
20068
20100
|
async function holderResidue(fileSystem, leaseDir) {
|
|
20069
20101
|
try {
|
|
@@ -20332,7 +20364,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
20332
20364
|
return resolveBrowserProfileDir(channel, chosen);
|
|
20333
20365
|
}
|
|
20334
20366
|
async function checkChannelSession(config, opts) {
|
|
20335
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20367
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20336
20368
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20337
20369
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20338
20370
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -20558,7 +20558,12 @@ async function acquireProfileLease(profileDir, options = {}) {
|
|
|
20558
20558
|
const leaseDir = join3(leaseRoot, id);
|
|
20559
20559
|
await fileSystem.ensureDir(leaseRoot);
|
|
20560
20560
|
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20561
|
-
|
|
20561
|
+
if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
|
|
20562
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20563
|
+
}
|
|
20564
|
+
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20565
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20566
|
+
}
|
|
20562
20567
|
}
|
|
20563
20568
|
const token = randomBytes(16).toString("hex");
|
|
20564
20569
|
const owner = {
|
|
@@ -20674,7 +20679,34 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
20674
20679
|
}
|
|
20675
20680
|
return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
|
|
20676
20681
|
}
|
|
20677
|
-
|
|
20682
|
+
const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
|
|
20683
|
+
const suffix = live.length > 0 ? `pid ${owner.pid} is gone but child holders ${live.join(", ")} are still running \u2014 stop those processes before retrying` : isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running and the lease could not be reclassified \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
20684
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
20685
|
+
}
|
|
20686
|
+
async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
|
|
20687
|
+
const owner = await readOwner(fileSystem, leaseDir);
|
|
20688
|
+
if (owner === null || isProcessAlive(owner.pid))
|
|
20689
|
+
return false;
|
|
20690
|
+
if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
|
|
20691
|
+
return false;
|
|
20692
|
+
const target = staleLeaseDir(leaseDir);
|
|
20693
|
+
try {
|
|
20694
|
+
rename(leaseDir, target);
|
|
20695
|
+
} catch {
|
|
20696
|
+
return false;
|
|
20697
|
+
}
|
|
20698
|
+
const moved = await readOwner(fileSystem, target);
|
|
20699
|
+
if (moved !== null && moved.token !== owner.token) {
|
|
20700
|
+
try {
|
|
20701
|
+
rename(target, leaseDir);
|
|
20702
|
+
} catch {}
|
|
20703
|
+
return false;
|
|
20704
|
+
}
|
|
20705
|
+
return true;
|
|
20706
|
+
}
|
|
20707
|
+
function staleLeaseDir(leaseDir) {
|
|
20708
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
|
|
20709
|
+
return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
|
|
20678
20710
|
}
|
|
20679
20711
|
async function holderResidue(fileSystem, leaseDir) {
|
|
20680
20712
|
try {
|
|
@@ -20900,7 +20932,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
20900
20932
|
return resolveBrowserProfileDir(channel, chosen);
|
|
20901
20933
|
}
|
|
20902
20934
|
async function checkChannelSession(config, opts) {
|
|
20903
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20935
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20904
20936
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20905
20937
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20906
20938
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -20219,7 +20219,12 @@ async function acquireProfileLease(profileDir, options = {}) {
|
|
|
20219
20219
|
const leaseDir = join2(leaseRoot, id);
|
|
20220
20220
|
await fileSystem.ensureDir(leaseRoot);
|
|
20221
20221
|
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20222
|
-
|
|
20222
|
+
if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
|
|
20223
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20224
|
+
}
|
|
20225
|
+
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20226
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20227
|
+
}
|
|
20223
20228
|
}
|
|
20224
20229
|
const token = randomBytes(16).toString("hex");
|
|
20225
20230
|
const owner = {
|
|
@@ -20335,7 +20340,34 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
20335
20340
|
}
|
|
20336
20341
|
return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
|
|
20337
20342
|
}
|
|
20338
|
-
|
|
20343
|
+
const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
|
|
20344
|
+
const suffix = live.length > 0 ? `pid ${owner.pid} is gone but child holders ${live.join(", ")} are still running \u2014 stop those processes before retrying` : isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running and the lease could not be reclassified \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
20345
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
20346
|
+
}
|
|
20347
|
+
async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
|
|
20348
|
+
const owner = await readOwner(fileSystem, leaseDir);
|
|
20349
|
+
if (owner === null || isProcessAlive(owner.pid))
|
|
20350
|
+
return false;
|
|
20351
|
+
if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
|
|
20352
|
+
return false;
|
|
20353
|
+
const target = staleLeaseDir(leaseDir);
|
|
20354
|
+
try {
|
|
20355
|
+
rename(leaseDir, target);
|
|
20356
|
+
} catch {
|
|
20357
|
+
return false;
|
|
20358
|
+
}
|
|
20359
|
+
const moved = await readOwner(fileSystem, target);
|
|
20360
|
+
if (moved !== null && moved.token !== owner.token) {
|
|
20361
|
+
try {
|
|
20362
|
+
rename(target, leaseDir);
|
|
20363
|
+
} catch {}
|
|
20364
|
+
return false;
|
|
20365
|
+
}
|
|
20366
|
+
return true;
|
|
20367
|
+
}
|
|
20368
|
+
function staleLeaseDir(leaseDir) {
|
|
20369
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
|
|
20370
|
+
return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
|
|
20339
20371
|
}
|
|
20340
20372
|
async function holderResidue(fileSystem, leaseDir) {
|
|
20341
20373
|
try {
|
|
@@ -20604,7 +20636,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
20604
20636
|
return resolveBrowserProfileDir(channel, chosen);
|
|
20605
20637
|
}
|
|
20606
20638
|
async function checkChannelSession(config, opts) {
|
|
20607
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20639
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20608
20640
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20609
20641
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20610
20642
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -12400,8 +12400,10 @@ async function patchPostFiles(request) {
|
|
|
12400
12400
|
const written = [];
|
|
12401
12401
|
const absent = [];
|
|
12402
12402
|
const images = {};
|
|
12403
|
+
const coverSkipped = [];
|
|
12403
12404
|
let changed = 0;
|
|
12404
12405
|
let uploadedFallbackCover;
|
|
12406
|
+
let uploadError;
|
|
12405
12407
|
for (const locale of PATCH_LOCALES) {
|
|
12406
12408
|
const indexMd = localeIndexPath(request.postPath, locale);
|
|
12407
12409
|
if (indexMd === undefined || !await fs.exists(indexMd)) {
|
|
@@ -12424,18 +12426,29 @@ async function patchPostFiles(request) {
|
|
|
12424
12426
|
md = upsertFrontmatterKey(md, "og_image", existingImage);
|
|
12425
12427
|
images[locale] = existingImage;
|
|
12426
12428
|
} else if (request.uploadLocalCover !== undefined && request.localCover !== "" && await fs.exists(request.localCover)) {
|
|
12427
|
-
if (uploadedFallbackCover === undefined) {
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12429
|
+
if (uploadedFallbackCover === undefined && uploadError === undefined) {
|
|
12430
|
+
let uploaded;
|
|
12431
|
+
try {
|
|
12432
|
+
uploaded = await request.uploadLocalCover(request.localCover);
|
|
12433
|
+
} catch (error) {
|
|
12434
|
+
uploadError = error instanceof Error ? error.message : String(error);
|
|
12431
12435
|
}
|
|
12432
|
-
|
|
12436
|
+
if (uploaded !== undefined) {
|
|
12437
|
+
if (!/^https:\/\//.test(uploaded)) {
|
|
12438
|
+
throw new Error(`uploaded cover must be an absolute https:// URL, got: ${uploaded}`);
|
|
12439
|
+
}
|
|
12440
|
+
uploadedFallbackCover = uploaded;
|
|
12441
|
+
}
|
|
12442
|
+
}
|
|
12443
|
+
if (uploadedFallbackCover === undefined) {
|
|
12444
|
+
coverSkipped.push(locale);
|
|
12445
|
+
} else {
|
|
12446
|
+
md = upsertFrontmatterKey(md, "image", uploadedFallbackCover);
|
|
12447
|
+
md = upsertFrontmatterKey(md, "og_image", uploadedFallbackCover);
|
|
12448
|
+
images[locale] = uploadedFallbackCover;
|
|
12433
12449
|
}
|
|
12434
|
-
md = upsertFrontmatterKey(md, "image", uploadedFallbackCover);
|
|
12435
|
-
md = upsertFrontmatterKey(md, "og_image", uploadedFallbackCover);
|
|
12436
|
-
images[locale] = uploadedFallbackCover;
|
|
12437
12450
|
} else {
|
|
12438
|
-
|
|
12451
|
+
coverSkipped.push(locale);
|
|
12439
12452
|
}
|
|
12440
12453
|
if (locale === "zh" && (request.episodeTitle ?? "") !== "") {
|
|
12441
12454
|
md = upsertFrontmatterKey(md, "episode_title", request.episodeTitle);
|
|
@@ -12461,7 +12474,22 @@ ${link}
|
|
|
12461
12474
|
changed += 1;
|
|
12462
12475
|
}
|
|
12463
12476
|
}
|
|
12464
|
-
|
|
12477
|
+
const applied = PATCH_LOCALES.filter((locale) => images[locale] !== undefined);
|
|
12478
|
+
return {
|
|
12479
|
+
written,
|
|
12480
|
+
changed,
|
|
12481
|
+
absent,
|
|
12482
|
+
images,
|
|
12483
|
+
slug: basename(dirname2(request.postPath)),
|
|
12484
|
+
coverPatch: {
|
|
12485
|
+
status: coverSkipped.length === 0 ? "applied" : "skipped",
|
|
12486
|
+
applied,
|
|
12487
|
+
skipped: coverSkipped,
|
|
12488
|
+
reason: coverSkipped.length === 0 ? "" : `${coverSkipped.join("/")} post has no remote https:// cover: coverUrl is empty, the frontmatter has no https:// image key and no local cover was uploadable${uploadError === undefined ? "" : ` (local cover upload failed: ${uploadError})`}`,
|
|
12489
|
+
...uploadError === undefined ? {} : { uploadError },
|
|
12490
|
+
pageUrl: request.pageUrl ?? ""
|
|
12491
|
+
}
|
|
12492
|
+
};
|
|
12465
12493
|
}
|
|
12466
12494
|
|
|
12467
12495
|
// ../../plugins/publishings/surfdash-pub/src/digest-check.ts
|
|
@@ -13545,6 +13573,7 @@ async function patchPost(options) {
|
|
|
13545
13573
|
localCover: strOption(options, "localCover"),
|
|
13546
13574
|
dateIso: strOption(options, "dateIso"),
|
|
13547
13575
|
episodeTitle: strOption(options, "episodeTitle"),
|
|
13576
|
+
pageUrl: strOption(options, "pageUrl"),
|
|
13548
13577
|
uploadLocalCover: uploadCoverToMicrofeed
|
|
13549
13578
|
});
|
|
13550
13579
|
} catch (error) {
|
|
@@ -13552,6 +13581,9 @@ async function patchPost(options) {
|
|
|
13552
13581
|
}
|
|
13553
13582
|
if (outcome.changed === 0)
|
|
13554
13583
|
echoError(`patch: no post bytes changed for ${outcome.slug}`);
|
|
13584
|
+
if (outcome.coverPatch.status === "skipped") {
|
|
13585
|
+
echoError(`patch: cover patch skipped for ${outcome.slug} \u2014 ${outcome.coverPatch.reason} (page ${outcome.coverPatch.pageUrl === "" ? "unknown" : outcome.coverPatch.pageUrl})`);
|
|
13586
|
+
}
|
|
13555
13587
|
const synced = await syncPost({ postPath: postPath.postPath });
|
|
13556
13588
|
const commitPaths = new Set(outcome.written.map((path) => relative(surfdashRoot, path)));
|
|
13557
13589
|
if (process.env.SURFDASH_AUTO_PUSH !== "0") {
|
|
@@ -13571,7 +13603,8 @@ async function patchPost(options) {
|
|
|
13571
13603
|
locales: Object.keys(outcome.images),
|
|
13572
13604
|
absentLocales: outcome.absent,
|
|
13573
13605
|
cmsResync: synced.ok ? "ok" : "failed",
|
|
13574
|
-
gitCommit: commit.hash
|
|
13606
|
+
gitCommit: commit.hash,
|
|
13607
|
+
coverPatch: outcome.coverPatch
|
|
13575
13608
|
};
|
|
13576
13609
|
if (!synced.ok) {
|
|
13577
13610
|
return ResultSchema.parse({
|
|
@@ -13584,7 +13617,7 @@ async function patchPost(options) {
|
|
|
13584
13617
|
return ResultSchema.parse({
|
|
13585
13618
|
ok: true,
|
|
13586
13619
|
target: TARGET,
|
|
13587
|
-
message: `patched ${outcome.changed} post(s) for ${outcome.slug}`,
|
|
13620
|
+
message: outcome.coverPatch.status === "skipped" ? `patched ${outcome.changed} post(s) for ${outcome.slug}; cover patch skipped \u2014 ${outcome.coverPatch.reason}` : `patched ${outcome.changed} post(s) for ${outcome.slug}`,
|
|
13588
13621
|
metadata
|
|
13589
13622
|
});
|
|
13590
13623
|
}
|
|
@@ -13858,7 +13891,8 @@ async function preparePost(payload) {
|
|
|
13858
13891
|
filePath,
|
|
13859
13892
|
relPostDir: join("content", "posts", "articles", locale, slug),
|
|
13860
13893
|
relPostDirs: mintedDirs,
|
|
13861
|
-
articleUrl
|
|
13894
|
+
articleUrl,
|
|
13895
|
+
...coverUrl !== undefined ? { coverUrl } : {}
|
|
13862
13896
|
}
|
|
13863
13897
|
};
|
|
13864
13898
|
}
|
|
@@ -13874,13 +13908,15 @@ async function preparePostResult(payload) {
|
|
|
13874
13908
|
postPath: outcome.prepared.filePath,
|
|
13875
13909
|
articleUrl: outcome.prepared.articleUrl,
|
|
13876
13910
|
dateStamp: outcome.prepared.dateStamp,
|
|
13877
|
-
slug: outcome.prepared.slug
|
|
13911
|
+
slug: outcome.prepared.slug,
|
|
13912
|
+
...outcome.prepared.coverUrl !== undefined ? { coverUrl: outcome.prepared.coverUrl } : {}
|
|
13878
13913
|
}
|
|
13879
13914
|
});
|
|
13880
13915
|
}
|
|
13881
13916
|
async function publishPreparedFile(prepared, identity) {
|
|
13882
13917
|
const postsurfingBin = process.env.POSTSURFING_BIN ?? "postsurfing";
|
|
13883
|
-
const { surfdashRoot, locale, dateStamp, filePath, relPostDir, relPostDirs, articleUrl } = prepared;
|
|
13918
|
+
const { surfdashRoot, locale, dateStamp, filePath, relPostDir, relPostDirs, articleUrl, coverUrl } = prepared;
|
|
13919
|
+
const coverMetadata = coverUrl === undefined ? {} : { coverUrl };
|
|
13884
13920
|
const identityMetadata = identity ? {
|
|
13885
13921
|
runDate: identity.runDate,
|
|
13886
13922
|
localeFingerprint: identity.fingerprint,
|
|
@@ -13915,6 +13951,7 @@ async function publishPreparedFile(prepared, identity) {
|
|
|
13915
13951
|
metadata: {
|
|
13916
13952
|
postPath: filePath,
|
|
13917
13953
|
...identityMetadata,
|
|
13954
|
+
...coverMetadata,
|
|
13918
13955
|
refinedTitle: refined?.title,
|
|
13919
13956
|
refinedCanonical: refined?.canonical
|
|
13920
13957
|
}
|
|
@@ -13938,6 +13975,7 @@ async function publishPreparedFile(prepared, identity) {
|
|
|
13938
13975
|
metadata: {
|
|
13939
13976
|
postPath: filePath,
|
|
13940
13977
|
...identityMetadata,
|
|
13978
|
+
...coverMetadata,
|
|
13941
13979
|
gitCommit: pushed.hash,
|
|
13942
13980
|
live,
|
|
13943
13981
|
refinedTitle: refined?.title
|
|
@@ -85,6 +85,8 @@ interface SurfdashPubOptions {
|
|
|
85
85
|
dateIso?: unknown;
|
|
86
86
|
/** `patch`: the episode's frozen identity title (0385 R4); the zh post's `episode_title`. */
|
|
87
87
|
episodeTitle?: unknown;
|
|
88
|
+
/** `patch`: the live page URL, named in the cover-skip warning (0432 R2). */
|
|
89
|
+
pageUrl?: unknown;
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
/**
|
|
@@ -1010,10 +1012,10 @@ async function syncPost(options: SurfdashPubOptions): Promise<Result> {
|
|
|
1010
1012
|
}
|
|
1011
1013
|
}
|
|
1012
1014
|
|
|
1013
|
-
/** `options.<key>` when it is a string, trimmed; else ''. `patch`'s
|
|
1015
|
+
/** `options.<key>` when it is a string, trimmed; else ''. `patch`'s optional fields read this way. */
|
|
1014
1016
|
function strOption(
|
|
1015
1017
|
options: SurfdashPubOptions,
|
|
1016
|
-
key: 'coverUrl' | 'showNotesUrl' | 'localCover' | 'dateIso' | 'episodeTitle',
|
|
1018
|
+
key: 'coverUrl' | 'showNotesUrl' | 'localCover' | 'dateIso' | 'episodeTitle' | 'pageUrl',
|
|
1017
1019
|
): string {
|
|
1018
1020
|
const raw = options[key];
|
|
1019
1021
|
return typeof raw === 'string' ? raw.trim() : '';
|
|
@@ -1050,12 +1052,20 @@ async function patchPost(options: SurfdashPubOptions): Promise<Result> {
|
|
|
1050
1052
|
localCover: strOption(options, 'localCover'),
|
|
1051
1053
|
dateIso: strOption(options, 'dateIso'),
|
|
1052
1054
|
episodeTitle: strOption(options, 'episodeTitle'),
|
|
1055
|
+
pageUrl: strOption(options, 'pageUrl'),
|
|
1053
1056
|
uploadLocalCover: uploadCoverToMicrofeed,
|
|
1054
1057
|
});
|
|
1055
1058
|
} catch (error: unknown) {
|
|
1056
1059
|
return fail(`patch error: ${error instanceof Error ? error.message : String(error)}`);
|
|
1057
1060
|
}
|
|
1058
1061
|
if (outcome.changed === 0) echoError(`patch: no post bytes changed for ${outcome.slug}`);
|
|
1062
|
+
if (outcome.coverPatch.status === 'skipped') {
|
|
1063
|
+
// 0432 R2: a live page whose cover could not be sourced is a warning with its URL, never a
|
|
1064
|
+
// failed target — the CMS row still serves the og:image this patch wanted to write.
|
|
1065
|
+
echoError(
|
|
1066
|
+
`patch: cover patch skipped for ${outcome.slug} — ${outcome.coverPatch.reason} (page ${outcome.coverPatch.pageUrl === '' ? 'unknown' : outcome.coverPatch.pageUrl})`,
|
|
1067
|
+
);
|
|
1068
|
+
}
|
|
1059
1069
|
const synced = await syncPost({ postPath: postPath.postPath });
|
|
1060
1070
|
const commitPaths = new Set(outcome.written.map((path) => relative(surfdashRoot, path)));
|
|
1061
1071
|
if (process.env.SURFDASH_AUTO_PUSH !== '0') {
|
|
@@ -1078,6 +1088,7 @@ async function patchPost(options: SurfdashPubOptions): Promise<Result> {
|
|
|
1078
1088
|
absentLocales: outcome.absent,
|
|
1079
1089
|
cmsResync: synced.ok ? 'ok' : 'failed',
|
|
1080
1090
|
gitCommit: commit.hash,
|
|
1091
|
+
coverPatch: outcome.coverPatch,
|
|
1081
1092
|
};
|
|
1082
1093
|
if (!synced.ok) {
|
|
1083
1094
|
// The posts are patched and committed; only the CMS rows keep the unservable cover. Reported
|
|
@@ -1093,7 +1104,10 @@ async function patchPost(options: SurfdashPubOptions): Promise<Result> {
|
|
|
1093
1104
|
return ResultSchema.parse({
|
|
1094
1105
|
ok: true,
|
|
1095
1106
|
target: TARGET,
|
|
1096
|
-
message:
|
|
1107
|
+
message:
|
|
1108
|
+
outcome.coverPatch.status === 'skipped'
|
|
1109
|
+
? `patched ${outcome.changed} post(s) for ${outcome.slug}; cover patch skipped — ${outcome.coverPatch.reason}`
|
|
1110
|
+
: `patched ${outcome.changed} post(s) for ${outcome.slug}`,
|
|
1097
1111
|
metadata,
|
|
1098
1112
|
});
|
|
1099
1113
|
}
|
|
@@ -1108,6 +1122,12 @@ interface PreparedPost {
|
|
|
1108
1122
|
/** Prepared daily publishes carry all translated sibling directories into the deploy commit. */
|
|
1109
1123
|
relPostDirs?: string[];
|
|
1110
1124
|
articleUrl: string;
|
|
1125
|
+
/**
|
|
1126
|
+
* The `https://` cover this prepare uploaded for the post (0432 R1). Reported in the publish
|
|
1127
|
+
* result so the post-publish patch can heal `image`/`og_image` from the SURFDASH side when the
|
|
1128
|
+
* podcast row never ran — that row used to be the run's only known cover source.
|
|
1129
|
+
*/
|
|
1130
|
+
coverUrl?: string;
|
|
1111
1131
|
}
|
|
1112
1132
|
|
|
1113
1133
|
interface PreparedLocaleIdentity {
|
|
@@ -1484,6 +1504,7 @@ async function preparePost(payload: PublishTransportPayload): Promise<PrepareOut
|
|
|
1484
1504
|
relPostDir: join('content', 'posts', 'articles', locale, slug),
|
|
1485
1505
|
relPostDirs: mintedDirs,
|
|
1486
1506
|
articleUrl,
|
|
1507
|
+
...(coverUrl !== undefined ? { coverUrl } : {}),
|
|
1487
1508
|
},
|
|
1488
1509
|
};
|
|
1489
1510
|
}
|
|
@@ -1501,6 +1522,7 @@ async function preparePostResult(payload: PublishTransportPayload): Promise<Resu
|
|
|
1501
1522
|
articleUrl: outcome.prepared.articleUrl,
|
|
1502
1523
|
dateStamp: outcome.prepared.dateStamp,
|
|
1503
1524
|
slug: outcome.prepared.slug,
|
|
1525
|
+
...(outcome.prepared.coverUrl !== undefined ? { coverUrl: outcome.prepared.coverUrl } : {}),
|
|
1504
1526
|
},
|
|
1505
1527
|
});
|
|
1506
1528
|
}
|
|
@@ -1511,7 +1533,10 @@ async function publishPreparedFile(
|
|
|
1511
1533
|
identity?: Pick<PreparedLocaleIdentity, 'runDate' | 'fingerprint'> & { postSha256?: string },
|
|
1512
1534
|
): Promise<Result> {
|
|
1513
1535
|
const postsurfingBin = process.env.POSTSURFING_BIN ?? 'postsurfing';
|
|
1514
|
-
const { surfdashRoot, locale, dateStamp, filePath, relPostDir, relPostDirs, articleUrl } = prepared;
|
|
1536
|
+
const { surfdashRoot, locale, dateStamp, filePath, relPostDir, relPostDirs, articleUrl, coverUrl } = prepared;
|
|
1537
|
+
// 0432 R1: the cover this publish hosted is what the patch heals from when the podcast row is
|
|
1538
|
+
// held, so it travels with the receipt instead of being re-derived (and lost) downstream.
|
|
1539
|
+
const coverMetadata = coverUrl === undefined ? {} : { coverUrl };
|
|
1515
1540
|
const identityMetadata = identity
|
|
1516
1541
|
? {
|
|
1517
1542
|
runDate: identity.runDate,
|
|
@@ -1571,6 +1596,7 @@ async function publishPreparedFile(
|
|
|
1571
1596
|
metadata: {
|
|
1572
1597
|
postPath: filePath,
|
|
1573
1598
|
...identityMetadata,
|
|
1599
|
+
...coverMetadata,
|
|
1574
1600
|
refinedTitle: refined?.title,
|
|
1575
1601
|
refinedCanonical: refined?.canonical,
|
|
1576
1602
|
},
|
|
@@ -1601,6 +1627,7 @@ async function publishPreparedFile(
|
|
|
1601
1627
|
metadata: {
|
|
1602
1628
|
postPath: filePath,
|
|
1603
1629
|
...identityMetadata,
|
|
1630
|
+
...coverMetadata,
|
|
1604
1631
|
gitCommit: pushed.hash,
|
|
1605
1632
|
live,
|
|
1606
1633
|
refinedTitle: refined?.title,
|
|
@@ -39,6 +39,36 @@ export interface PatchPostRequest {
|
|
|
39
39
|
episodeTitle?: string;
|
|
40
40
|
/** Optional uploader converting a local cover into an `https://` remote URL (e.g. Microfeed R2). */
|
|
41
41
|
uploadLocalCover?: (filePath: string) => Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* The live page these posts serve (0432), named in the cover-skip diagnostic so an operator can
|
|
44
|
+
* check the page instead of hunting the slug. Optional: a caller that does not know it (a
|
|
45
|
+
* fixture, an offline replay) records an empty one rather than inventing a URL.
|
|
46
|
+
*/
|
|
47
|
+
pageUrl?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The remote-cover verdict of one patch pass (0432).
|
|
52
|
+
*
|
|
53
|
+
* A post whose cover cannot be sourced is NOT a failure: the page is already live and its og:image
|
|
54
|
+
* resolves from the CMS row, so the patch only lacks a URL to write into `image`/`og_image`. It
|
|
55
|
+
* records `skipped` with the reason and the page URL instead of throwing — a live, correct page was
|
|
56
|
+
* being reported as a failed target (2026-11-24 dogfood) because the only https cover the run knew
|
|
57
|
+
* about was the one `podcast-pub` hosts, and that row was held by the safety verdict.
|
|
58
|
+
*/
|
|
59
|
+
export interface CoverPatchOutcome {
|
|
60
|
+
/** `applied` when every locale that has a post carries a remote cover; `skipped` otherwise. */
|
|
61
|
+
status: 'applied' | 'skipped';
|
|
62
|
+
/** Locales whose post carries a remote https cover after this pass (written or kept). */
|
|
63
|
+
applied: PatchLocale[];
|
|
64
|
+
/** Locales left on their local/relative image because no https source existed. */
|
|
65
|
+
skipped: PatchLocale[];
|
|
66
|
+
/** Operator-facing reason naming the skipped locales; '' when nothing was skipped. */
|
|
67
|
+
reason: string;
|
|
68
|
+
/** The published page the skip concerns (`request.pageUrl`); '' when the caller supplied none. */
|
|
69
|
+
pageUrl: string;
|
|
70
|
+
/** Why the local-cover upload produced no URL (env/presign/network), absent when it was never tried. */
|
|
71
|
+
uploadError?: string;
|
|
42
72
|
}
|
|
43
73
|
|
|
44
74
|
/** What the file pass changed; the caller commits exactly {@link PatchPostOutcome.written}. */
|
|
@@ -53,6 +83,8 @@ export interface PatchPostOutcome {
|
|
|
53
83
|
images: Record<string, string>;
|
|
54
84
|
/** The primary post's directory name, for the commit message. */
|
|
55
85
|
slug: string;
|
|
86
|
+
/** What happened to the remote cover this pass (0432); never a fatal outcome by itself. */
|
|
87
|
+
coverPatch: CoverPatchOutcome;
|
|
56
88
|
}
|
|
57
89
|
|
|
58
90
|
/**
|
|
@@ -130,8 +162,13 @@ export async function patchPostFiles(request: PatchPostRequest): Promise<PatchPo
|
|
|
130
162
|
const written: string[] = [];
|
|
131
163
|
const absent: PatchLocale[] = [];
|
|
132
164
|
const images: Record<string, string> = {};
|
|
165
|
+
const coverSkipped: PatchLocale[] = [];
|
|
133
166
|
let changed = 0;
|
|
134
167
|
let uploadedFallbackCover: string | undefined;
|
|
168
|
+
// 0432 R2/P3: the local upload is an environment step (base URL, key, presign, network). Its
|
|
169
|
+
// failure leaves no sourceable cover, which is the recorded warning below — never a failed
|
|
170
|
+
// target on a page that is already live.
|
|
171
|
+
let uploadError: string | undefined;
|
|
135
172
|
for (const locale of PATCH_LOCALES) {
|
|
136
173
|
const indexMd = localeIndexPath(request.postPath, locale);
|
|
137
174
|
if (indexMd === undefined || !(await fs.exists(indexMd))) {
|
|
@@ -160,20 +197,34 @@ export async function patchPostFiles(request: PatchPostRequest): Promise<PatchPo
|
|
|
160
197
|
request.localCover !== '' &&
|
|
161
198
|
(await fs.exists(request.localCover))
|
|
162
199
|
) {
|
|
163
|
-
if (uploadedFallbackCover === undefined) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
200
|
+
if (uploadedFallbackCover === undefined && uploadError === undefined) {
|
|
201
|
+
let uploaded: string | undefined;
|
|
202
|
+
try {
|
|
203
|
+
uploaded = await request.uploadLocalCover(request.localCover);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
uploadError = error instanceof Error ? error.message : String(error);
|
|
206
|
+
}
|
|
207
|
+
if (uploaded !== undefined) {
|
|
208
|
+
// A non-https RESULT is an argument defect, not an environment failure: it stays loud.
|
|
209
|
+
if (!/^https:\/\//.test(uploaded)) {
|
|
210
|
+
throw new Error(`uploaded cover must be an absolute https:// URL, got: ${uploaded}`);
|
|
211
|
+
}
|
|
212
|
+
uploadedFallbackCover = uploaded;
|
|
167
213
|
}
|
|
168
|
-
uploadedFallbackCover = uploaded;
|
|
169
214
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
215
|
+
if (uploadedFallbackCover === undefined) {
|
|
216
|
+
coverSkipped.push(locale);
|
|
217
|
+
} else {
|
|
218
|
+
md = upsertFrontmatterKey(md, 'image', uploadedFallbackCover);
|
|
219
|
+
md = upsertFrontmatterKey(md, 'og_image', uploadedFallbackCover);
|
|
220
|
+
images[locale] = uploadedFallbackCover;
|
|
221
|
+
}
|
|
173
222
|
} else {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
223
|
+
// 0432 R2: no https cover anywhere (the podcast row never uploaded one, the frontmatter
|
|
224
|
+
// has none and no local cover is uploadable). The page is live and its og:image resolves,
|
|
225
|
+
// so this is a recorded warning on an otherwise successful patch — never a failed target.
|
|
226
|
+
// The episode identity and the cross-link below are still written.
|
|
227
|
+
coverSkipped.push(locale);
|
|
177
228
|
}
|
|
178
229
|
if (locale === 'zh' && (request.episodeTitle ?? '') !== '') {
|
|
179
230
|
// The article states the episode identity the podcast ships (0385). The site renders it
|
|
@@ -204,5 +255,23 @@ export async function patchPostFiles(request: PatchPostRequest): Promise<PatchPo
|
|
|
204
255
|
changed += 1;
|
|
205
256
|
}
|
|
206
257
|
}
|
|
207
|
-
|
|
258
|
+
const applied = PATCH_LOCALES.filter((locale) => images[locale] !== undefined);
|
|
259
|
+
return {
|
|
260
|
+
written,
|
|
261
|
+
changed,
|
|
262
|
+
absent,
|
|
263
|
+
images,
|
|
264
|
+
slug: basename(dirname(request.postPath)),
|
|
265
|
+
coverPatch: {
|
|
266
|
+
status: coverSkipped.length === 0 ? 'applied' : 'skipped',
|
|
267
|
+
applied,
|
|
268
|
+
skipped: coverSkipped,
|
|
269
|
+
reason:
|
|
270
|
+
coverSkipped.length === 0
|
|
271
|
+
? ''
|
|
272
|
+
: `${coverSkipped.join('/')} post has no remote https:// cover: coverUrl is empty, the frontmatter has no https:// image key and no local cover was uploadable${uploadError === undefined ? '' : ` (local cover upload failed: ${uploadError})`}`,
|
|
273
|
+
...(uploadError === undefined ? {} : { uploadError }),
|
|
274
|
+
pageUrl: request.pageUrl ?? '',
|
|
275
|
+
},
|
|
276
|
+
};
|
|
208
277
|
}
|
|
@@ -20560,7 +20560,12 @@ async function acquireProfileLease(profileDir, options = {}) {
|
|
|
20560
20560
|
const leaseDir = join3(leaseRoot, id);
|
|
20561
20561
|
await fileSystem.ensureDir(leaseRoot);
|
|
20562
20562
|
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20563
|
-
|
|
20563
|
+
if (!await reclaimDeadOwnerLease(fileSystem, leaseDir)) {
|
|
20564
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20565
|
+
}
|
|
20566
|
+
if (!mkdirExclusive(leaseDir, 448)) {
|
|
20567
|
+
throw new BotError("busy", await busyGuidance(fileSystem, leaseDir));
|
|
20568
|
+
}
|
|
20564
20569
|
}
|
|
20565
20570
|
const token = randomBytes(16).toString("hex");
|
|
20566
20571
|
const owner = {
|
|
@@ -20676,7 +20681,34 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
20676
20681
|
}
|
|
20677
20682
|
return `browser lease ${leaseDir} already exists with no owner record \u2014 a previous run may have crashed mid-acquire; confirm no kk browser still uses this profile, then remove ${leaseDir} manually`;
|
|
20678
20683
|
}
|
|
20679
|
-
|
|
20684
|
+
const live = isProcessAlive(owner.pid) ? [] : await liveChildHolders(fileSystem, leaseDir);
|
|
20685
|
+
const suffix = live.length > 0 ? `pid ${owner.pid} is gone but child holders ${live.join(", ")} are still running \u2014 stop those processes before retrying` : isProcessAlive(owner.pid) ? "confirm that process and any browser for this profile have stopped; stale ownership is never auto-removed" : `pid ${owner.pid} is no longer running and the lease could not be reclassified \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
20686
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
20687
|
+
}
|
|
20688
|
+
async function reclaimDeadOwnerLease(fileSystem, leaseDir) {
|
|
20689
|
+
const owner = await readOwner(fileSystem, leaseDir);
|
|
20690
|
+
if (owner === null || isProcessAlive(owner.pid))
|
|
20691
|
+
return false;
|
|
20692
|
+
if ((await liveChildHolders(fileSystem, leaseDir)).length > 0)
|
|
20693
|
+
return false;
|
|
20694
|
+
const target = staleLeaseDir(leaseDir);
|
|
20695
|
+
try {
|
|
20696
|
+
rename(leaseDir, target);
|
|
20697
|
+
} catch {
|
|
20698
|
+
return false;
|
|
20699
|
+
}
|
|
20700
|
+
const moved = await readOwner(fileSystem, target);
|
|
20701
|
+
if (moved !== null && moved.token !== owner.token) {
|
|
20702
|
+
try {
|
|
20703
|
+
rename(target, leaseDir);
|
|
20704
|
+
} catch {}
|
|
20705
|
+
return false;
|
|
20706
|
+
}
|
|
20707
|
+
return true;
|
|
20708
|
+
}
|
|
20709
|
+
function staleLeaseDir(leaseDir) {
|
|
20710
|
+
const stamp = new Date().toISOString().replace(/[:.]/g, "").slice(0, 15);
|
|
20711
|
+
return `${leaseDir}.stale-${stamp}-${process.pid}-${randomBytes(3).toString("hex")}`;
|
|
20680
20712
|
}
|
|
20681
20713
|
async function holderResidue(fileSystem, leaseDir) {
|
|
20682
20714
|
try {
|
|
@@ -20902,7 +20934,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
20902
20934
|
return resolveBrowserProfileDir(channel, chosen);
|
|
20903
20935
|
}
|
|
20904
20936
|
async function checkChannelSession(config, opts) {
|
|
20905
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20937
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
20906
20938
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
20907
20939
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
20908
20940
|
const deadline = Date.now() + timeoutMs;
|