blun-king-cli 9.1.230 → 9.1.232
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/bin/launcher-runtime.js
CHANGED
|
@@ -267,6 +267,33 @@ function resolveHandoffCwd(candidate, fallback) {
|
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
+
function isAutomaticRunningUpdateMode(mode) {
|
|
271
|
+
return mode === RUNNING_UPDATE_MODES.RESUME || mode === RUNNING_UPDATE_MODES.NEW;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
async function prepareAutomaticStartupRuntime(options) {
|
|
275
|
+
if (options.existingRuntime !== undefined) return options.existingRuntime;
|
|
276
|
+
const runningUpdateMode = readRunningUpdateMode(options.profileHome);
|
|
277
|
+
if (!isAutomaticRunningUpdateMode(runningUpdateMode)) return undefined;
|
|
278
|
+
const target = await (options.prepareRunningUpdate || prepareRunningUpdate)({
|
|
279
|
+
currentVersion: options.currentVersion,
|
|
280
|
+
sharedHome: options.sharedHome,
|
|
281
|
+
env: options.env,
|
|
282
|
+
});
|
|
283
|
+
if (target === null) return undefined;
|
|
284
|
+
(options.stageRuntime || stageRuntime)(options.sharedHome, target, {
|
|
285
|
+
mode: runningUpdateMode,
|
|
286
|
+
cwd: options.cwd,
|
|
287
|
+
});
|
|
288
|
+
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(options.sharedHome, {
|
|
289
|
+
event: 'prepared-on-cold-start',
|
|
290
|
+
fromVersion: options.currentVersion,
|
|
291
|
+
toVersion: target.version,
|
|
292
|
+
});
|
|
293
|
+
return (options.readPendingRuntime || readPendingRuntime)(options.sharedHome)
|
|
294
|
+
|| Object.freeze({ ...target, mode: runningUpdateMode, cwd: options.cwd });
|
|
295
|
+
}
|
|
296
|
+
|
|
270
297
|
function shouldRecoverActivatedRuntime(result, recovery, options = {}) {
|
|
271
298
|
if (recovery === undefined || options.runtimeExitIntent === true) return false;
|
|
272
299
|
const signal = result?.signal;
|
|
@@ -697,6 +724,19 @@ async function runLauncher(options = {}) {
|
|
|
697
724
|
const blunDir = profilePaths.home;
|
|
698
725
|
ensurePrivateDirectory(blunDir);
|
|
699
726
|
|
|
727
|
+
const runningUpdateMode = readRunningUpdateMode(profilePaths.home);
|
|
728
|
+
if (deferredPendingRuntime === undefined && isAutomaticRunningUpdateMode(runningUpdateMode)) {
|
|
729
|
+
try {
|
|
730
|
+
deferredPendingRuntime = await prepareAutomaticStartupRuntime({
|
|
731
|
+
currentVersion: readPackageVersion(),
|
|
732
|
+
cwd: callerCwd,
|
|
733
|
+
env: process.env,
|
|
734
|
+
profileHome: profilePaths.home,
|
|
735
|
+
sharedHome: privatePaths.sharedHome,
|
|
736
|
+
});
|
|
737
|
+
} catch {}
|
|
738
|
+
}
|
|
739
|
+
|
|
700
740
|
// --- 1. Oeffentlicher npm-Update-Dialog. -------------------------------
|
|
701
741
|
const updateResult = options.skipUpdateNotice === true
|
|
702
742
|
? { kind: 'continue', reason: 'notice_busy' }
|
|
@@ -710,6 +750,7 @@ async function runLauncher(options = {}) {
|
|
|
710
750
|
blunDir: privatePaths.sharedHome,
|
|
711
751
|
packageRoot: PKG,
|
|
712
752
|
preparedRuntime: deferredPendingRuntime,
|
|
753
|
+
autoInstallPreparedRuntime: isAutomaticRunningUpdateMode(runningUpdateMode),
|
|
713
754
|
noticeLease,
|
|
714
755
|
});
|
|
715
756
|
if (updateResult.kind === 'installed'
|
|
@@ -798,6 +839,7 @@ module.exports = {
|
|
|
798
839
|
RUNNING_UPDATE_RECHECK_MS,
|
|
799
840
|
RUNNING_UPDATE_STABILIZATION_MS,
|
|
800
841
|
createManagedNodeEnvironment,
|
|
842
|
+
prepareAutomaticStartupRuntime,
|
|
801
843
|
resolveLauncherPrivatePaths,
|
|
802
844
|
resolveHandoffCwd,
|
|
803
845
|
runningUpdateRecheckDelay,
|
package/bin/update-notice.js
CHANGED
|
@@ -1400,8 +1400,11 @@ async function runUpdateFlow(options, explicitUpdate) {
|
|
|
1400
1400
|
&& typeof preparedRuntime.packageRoot === 'string'
|
|
1401
1401
|
&& path.isAbsolute(preparedRuntime.packageRoot)
|
|
1402
1402
|
&& verifyInstalledPackageVersion(preparedRuntime.packageRoot, release.version);
|
|
1403
|
+
const automaticPreparedRuntimeReady = options.autoInstallPreparedRuntime === true
|
|
1404
|
+
&& preparedRuntimeReady;
|
|
1403
1405
|
if (!explicitUpdate
|
|
1404
1406
|
&& pendingVersion === undefined
|
|
1407
|
+
&& !automaticPreparedRuntimeReady
|
|
1405
1408
|
&& readSnoozeState(blunDir, release.version, now)) {
|
|
1406
1409
|
return { kind: 'continue', reason: 'snoozed' };
|
|
1407
1410
|
}
|
|
@@ -1417,7 +1420,10 @@ async function runUpdateFlow(options, explicitUpdate) {
|
|
|
1417
1420
|
? explicitFailure(stderr, 'lease_unavailable')
|
|
1418
1421
|
: { kind: 'continue', reason: 'lease_unavailable' };
|
|
1419
1422
|
}
|
|
1420
|
-
if (!explicitUpdate
|
|
1423
|
+
if (!explicitUpdate
|
|
1424
|
+
&& !queuedForRelease
|
|
1425
|
+
&& !automaticPreparedRuntimeReady
|
|
1426
|
+
&& readSkippedVersion(blunDir) === release.version) {
|
|
1421
1427
|
return { kind: 'continue', reason: 'skipped_version' };
|
|
1422
1428
|
}
|
|
1423
1429
|
if (explicitUpdate || queuedForRelease) {
|
|
@@ -1460,7 +1466,7 @@ async function runUpdateFlow(options, explicitUpdate) {
|
|
|
1460
1466
|
}
|
|
1461
1467
|
}
|
|
1462
1468
|
let action;
|
|
1463
|
-
if (explicitUpdate || queuedForRelease) {
|
|
1469
|
+
if (explicitUpdate || queuedForRelease || automaticPreparedRuntimeReady) {
|
|
1464
1470
|
action = 'install';
|
|
1465
1471
|
} else {
|
|
1466
1472
|
try {
|
package/package.json
CHANGED
|
@@ -9814,6 +9814,29 @@ function isRecentDuplicate(chatId, text) {
|
|
|
9814
9814
|
} catch {}
|
|
9815
9815
|
return false;
|
|
9816
9816
|
}
|
|
9817
|
+
function telegramErrorMessage(error) {
|
|
9818
|
+
return error instanceof Error ? error.message : String(error);
|
|
9819
|
+
}
|
|
9820
|
+
function isTelegramEntityParseError(error) {
|
|
9821
|
+
return /bad request: can't parse entities:/iu.test(telegramErrorMessage(error));
|
|
9822
|
+
}
|
|
9823
|
+
async function sendTelegramTextChunk(api, chatId, text, options, parseMode) {
|
|
9824
|
+
try {
|
|
9825
|
+
return {
|
|
9826
|
+
sent: await api.sendMessage(chatId, text, {
|
|
9827
|
+
...options,
|
|
9828
|
+
...parseMode !== void 0 ? { parse_mode: parseMode } : {}
|
|
9829
|
+
}),
|
|
9830
|
+
plainTextFallback: false
|
|
9831
|
+
};
|
|
9832
|
+
} catch (error) {
|
|
9833
|
+
if (parseMode === void 0 || !isTelegramEntityParseError(error)) throw error;
|
|
9834
|
+
return {
|
|
9835
|
+
sent: await api.sendMessage(chatId, text, options),
|
|
9836
|
+
plainTextFallback: true
|
|
9837
|
+
};
|
|
9838
|
+
}
|
|
9839
|
+
}
|
|
9817
9840
|
async function runReply(api, args) {
|
|
9818
9841
|
const chatId = resolveAllowedChatId(args.chat_id);
|
|
9819
9842
|
const text = args.text;
|
|
@@ -9849,13 +9872,15 @@ async function runReply(api, args) {
|
|
|
9849
9872
|
const replyMode = access.replyToMode ?? "first";
|
|
9850
9873
|
const chunks = chunk(text, limit, mode);
|
|
9851
9874
|
const sentIds = [];
|
|
9875
|
+
let plainTextFallbacks = 0;
|
|
9852
9876
|
try {
|
|
9853
9877
|
for (let i = 0; i < chunks.length; i++) {
|
|
9854
9878
|
const shouldReplyTo = replyTo !== void 0 && replyMode !== "off" && (replyMode === "all" || i === 0);
|
|
9855
|
-
const
|
|
9856
|
-
...shouldReplyTo ? { reply_parameters: { message_id: replyTo } } : {}
|
|
9857
|
-
|
|
9858
|
-
|
|
9879
|
+
const result = await sendTelegramTextChunk(api, chatId, chunks[i], {
|
|
9880
|
+
...shouldReplyTo ? { reply_parameters: { message_id: replyTo } } : {}
|
|
9881
|
+
}, parseMode);
|
|
9882
|
+
const sent = result.sent;
|
|
9883
|
+
if (result.plainTextFallback) plainTextFallbacks += 1;
|
|
9859
9884
|
sentIds.push(sent.message_id);
|
|
9860
9885
|
}
|
|
9861
9886
|
} catch (err) {
|
|
@@ -9875,6 +9900,7 @@ async function runReply(api, args) {
|
|
|
9875
9900
|
chat_id: chatId,
|
|
9876
9901
|
message_ids: sentIds,
|
|
9877
9902
|
text,
|
|
9903
|
+
...plainTextFallbacks > 0 ? { plain_text_fallbacks: plainTextFallbacks } : {},
|
|
9878
9904
|
...files.length > 0 ? { files } : {}
|
|
9879
9905
|
});
|
|
9880
9906
|
return sentIds.length === 1 ? `sent (id: ${sentIds[0]})` : `sent ${sentIds.length} parts (ids: ${sentIds.join(", ")})`;
|