@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;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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;
|