blun-king-cli 9.1.317 → 9.1.318
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 +12 -108
- package/blun.mjs +8 -52
- package/package.json +1 -1
package/bin/launcher-runtime.js
CHANGED
|
@@ -30,20 +30,16 @@ const { startMnemoConnectHeartbeat } = require('./mnemo-connect-heartbeat.cjs');
|
|
|
30
30
|
const { acquireSharedRuntimeLease, tryAcquireUpdateLease } = require('./update-lease');
|
|
31
31
|
const { compareSemver, runExplicitUpdate, runUpdateNotice } = require('./update-notice');
|
|
32
32
|
const {
|
|
33
|
-
RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
|
|
34
|
-
RUNNING_UPDATE_HANDOFF_EXIT_CODE,
|
|
35
|
-
RUNNING_UPDATE_HANDOFF_MESSAGE,
|
|
36
33
|
RUNNING_UPDATE_MODE_MESSAGE,
|
|
34
|
+
RUNNING_UPDATE_PREPARED_MESSAGE,
|
|
37
35
|
RUNTIME_EXIT_INTENT_MESSAGE,
|
|
38
36
|
activateRuntime,
|
|
39
37
|
clearActiveRuntime,
|
|
40
|
-
handoffArgsForMode,
|
|
41
38
|
prepareRunningUpdate,
|
|
42
39
|
pruneRunningUpdateReleases,
|
|
43
40
|
recordRunningUpdateEvent,
|
|
44
41
|
readActiveRuntime,
|
|
45
42
|
readPendingRuntime,
|
|
46
|
-
restoreActiveRuntime,
|
|
47
43
|
clearPendingRuntime,
|
|
48
44
|
stageRuntime,
|
|
49
45
|
} = require('./running-update.cjs');
|
|
@@ -310,7 +306,6 @@ function shouldRecoverActivatedRuntime(result, recovery, options = {}) {
|
|
|
310
306
|
async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {}) {
|
|
311
307
|
const packageRoot = path.resolve(options.packageRoot || PKG);
|
|
312
308
|
let preparedTarget;
|
|
313
|
-
let pendingHandoff;
|
|
314
309
|
let updateStarted = false;
|
|
315
310
|
let runtimeReady = false;
|
|
316
311
|
let activeSession;
|
|
@@ -350,7 +345,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
350
345
|
};
|
|
351
346
|
const scheduleNextPreparation = (child) => {
|
|
352
347
|
clearRunningUpdatePoll();
|
|
353
|
-
if (supervisionCompleted ||
|
|
348
|
+
if (supervisionCompleted || updateStarted) return;
|
|
354
349
|
runningUpdatePollTimer = (options.scheduleRunningUpdateRecheck || scheduleRunningUpdateRecheck)(() => {
|
|
355
350
|
runningUpdatePollTimer = undefined;
|
|
356
351
|
refreshRunningUpdateMode();
|
|
@@ -359,7 +354,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
359
354
|
});
|
|
360
355
|
};
|
|
361
356
|
const startPreparation = (child) => {
|
|
362
|
-
if (supervisionCompleted ||
|
|
357
|
+
if (supervisionCompleted || updateStarted
|
|
363
358
|
|| options.runningUpdate === false || !automaticMode()) return;
|
|
364
359
|
updateStarted = true;
|
|
365
360
|
const sharedHome = env.BLUN_SHARED_HOME;
|
|
@@ -387,6 +382,15 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
387
382
|
}
|
|
388
383
|
preparedTarget = target;
|
|
389
384
|
persistPreparedRuntime();
|
|
385
|
+
if (child?.connected === true) {
|
|
386
|
+
try {
|
|
387
|
+
child.send({
|
|
388
|
+
type: RUNNING_UPDATE_PREPARED_MESSAGE,
|
|
389
|
+
version: target.version,
|
|
390
|
+
mode: runningUpdateMode,
|
|
391
|
+
});
|
|
392
|
+
} catch {}
|
|
393
|
+
}
|
|
390
394
|
const runningVersion = readPackageVersionAt(packageRoot);
|
|
391
395
|
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, previousTarget === undefined ? {
|
|
392
396
|
event: 'prepared-for-next-start',
|
|
@@ -411,43 +415,6 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
411
415
|
};
|
|
412
416
|
const handleCoreMessage = (message, child) => {
|
|
413
417
|
if (message?.type === RUNTIME_EXIT_INTENT_MESSAGE) runtimeExitIntent = true;
|
|
414
|
-
if (message?.type === RUNNING_UPDATE_HANDOFF_MESSAGE
|
|
415
|
-
&& preparedTarget !== undefined
|
|
416
|
-
&& message.version === preparedTarget.version
|
|
417
|
-
&& message.mode === runningUpdateMode
|
|
418
|
-
&& validSessionMessage(message)) {
|
|
419
|
-
activeSession = Object.freeze({
|
|
420
|
-
cwd: resolveHandoffCwd(message.cwd, cwd),
|
|
421
|
-
sessionId: message.sessionId,
|
|
422
|
-
});
|
|
423
|
-
try {
|
|
424
|
-
persistPreparedRuntime();
|
|
425
|
-
} catch (error) {
|
|
426
|
-
options.onRunningUpdateError?.(error);
|
|
427
|
-
scheduleNextPreparation(child);
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
pendingHandoff = Object.freeze({
|
|
431
|
-
cwd: activeSession.cwd,
|
|
432
|
-
mode: message.mode,
|
|
433
|
-
sessionId: message.sessionId,
|
|
434
|
-
target: preparedTarget,
|
|
435
|
-
});
|
|
436
|
-
clearRunningUpdatePoll();
|
|
437
|
-
if (child?.connected === true) {
|
|
438
|
-
try {
|
|
439
|
-
child.send({
|
|
440
|
-
type: RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
|
|
441
|
-
version: preparedTarget.version,
|
|
442
|
-
mode: message.mode,
|
|
443
|
-
sessionId: message.sessionId,
|
|
444
|
-
});
|
|
445
|
-
} catch {
|
|
446
|
-
pendingHandoff = undefined;
|
|
447
|
-
scheduleNextPreparation(child);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
418
|
if (message?.type === RUNTIME_READY_MESSAGE) {
|
|
452
419
|
if (validSessionMessage(message)) {
|
|
453
420
|
activeSession = Object.freeze({
|
|
@@ -513,69 +480,6 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
513
480
|
supervisionCompleted = true;
|
|
514
481
|
clearRunningUpdatePoll();
|
|
515
482
|
if (existingMessageHandler) core.child.off('message', existingMessageHandler);
|
|
516
|
-
if (result.code === RUNNING_UPDATE_HANDOFF_EXIT_CODE && pendingHandoff !== undefined) {
|
|
517
|
-
const sharedHome = env.BLUN_SHARED_HOME;
|
|
518
|
-
const target = pendingHandoff.target;
|
|
519
|
-
const handoffArgs = handoffArgsForMode(args, pendingHandoff.mode, pendingHandoff.sessionId);
|
|
520
|
-
const handoffCwd = pendingHandoff.cwd;
|
|
521
|
-
const previousActive = (options.readActiveRuntime || readActiveRuntime)(sharedHome);
|
|
522
|
-
const resumeEnv = {
|
|
523
|
-
...env,
|
|
524
|
-
[RUNNING_UPDATE_RESUME_SESSION_ENV]: pendingHandoff.sessionId,
|
|
525
|
-
};
|
|
526
|
-
const nextCore = spawnCore(handoffArgs, resumeEnv, handoffCwd, { packageRoot: target.packageRoot });
|
|
527
|
-
const nextLoaded = await nextCore.loaded;
|
|
528
|
-
const nextReady = nextLoaded && await (options.waitForRuntimeReady || waitForRuntimeReady)(
|
|
529
|
-
nextCore,
|
|
530
|
-
options.readyTimeoutMs,
|
|
531
|
-
);
|
|
532
|
-
if (nextReady) {
|
|
533
|
-
await (options.activateRuntime || activateRuntime)(sharedHome, target);
|
|
534
|
-
(options.clearPendingRuntime || clearPendingRuntime)(sharedHome, target);
|
|
535
|
-
const activatedAt = (options.nowImpl || Date.now)();
|
|
536
|
-
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
|
|
537
|
-
event: 'activated-at-safe-boundary',
|
|
538
|
-
fromVersion: readPackageVersionAt(packageRoot),
|
|
539
|
-
toVersion: target.version,
|
|
540
|
-
mode: pendingHandoff.mode,
|
|
541
|
-
}, { now: options.nowImpl });
|
|
542
|
-
return superviseProtectedCore(handoffArgs, resumeEnv, handoffCwd, async () => {}, {
|
|
543
|
-
...options,
|
|
544
|
-
existingCore: nextCore,
|
|
545
|
-
packageRoot: target.packageRoot,
|
|
546
|
-
recoveryRuntime: {
|
|
547
|
-
activeRuntime: previousActive,
|
|
548
|
-
activatedAt,
|
|
549
|
-
packageRoot,
|
|
550
|
-
version: readPackageVersionAt(packageRoot),
|
|
551
|
-
},
|
|
552
|
-
staleActiveRuntime: undefined,
|
|
553
|
-
startupPendingRuntime: undefined,
|
|
554
|
-
});
|
|
555
|
-
}
|
|
556
|
-
try { nextCore.child.kill(); } catch {}
|
|
557
|
-
(options.clearPendingRuntime || clearPendingRuntime)(sharedHome, target);
|
|
558
|
-
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
|
|
559
|
-
event: 'safe-boundary-start-failed',
|
|
560
|
-
fromVersion: readPackageVersionAt(packageRoot),
|
|
561
|
-
toVersion: target.version,
|
|
562
|
-
}, { now: options.nowImpl });
|
|
563
|
-
const fallback = spawnCore(handoffArgs, resumeEnv, handoffCwd, { packageRoot });
|
|
564
|
-
const fallbackLoaded = await fallback.loaded;
|
|
565
|
-
const fallbackReady = fallbackLoaded && await (options.waitForRuntimeReady || waitForRuntimeReady)(
|
|
566
|
-
fallback,
|
|
567
|
-
options.readyTimeoutMs,
|
|
568
|
-
);
|
|
569
|
-
if (!fallbackReady) return 1;
|
|
570
|
-
return superviseProtectedCore(handoffArgs, resumeEnv, handoffCwd, async () => {}, {
|
|
571
|
-
...options,
|
|
572
|
-
existingCore: fallback,
|
|
573
|
-
packageRoot,
|
|
574
|
-
recoveryRuntime: undefined,
|
|
575
|
-
staleActiveRuntime: undefined,
|
|
576
|
-
startupPendingRuntime: undefined,
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
483
|
const recovery = options.recoveryRuntime;
|
|
580
484
|
if (shouldRecoverActivatedRuntime(result, recovery, {
|
|
581
485
|
now: (options.nowImpl || Date.now)(),
|
package/blun.mjs
CHANGED
|
@@ -495659,7 +495659,7 @@ async function handleUpdateCommand(host) {
|
|
|
495659
495659
|
}
|
|
495660
495660
|
host.runningUpdatePreparedVersion = void 0;
|
|
495661
495661
|
host.runningUpdatePreparedMode = void 0;
|
|
495662
|
-
host.
|
|
495662
|
+
host.runningUpdatePreparedNoticeVersion = void 0;
|
|
495663
495663
|
if (process.connected) try {
|
|
495664
495664
|
process.send({ type: RUNNING_UPDATE_MODE_MESSAGE, mode: selectedMode });
|
|
495665
495665
|
} catch {}
|
|
@@ -515761,7 +515761,6 @@ const {
|
|
|
515761
515761
|
RUNNING_UPDATE_PREPARED_MESSAGE,
|
|
515762
515762
|
RUNTIME_EXIT_INTENT_MESSAGE,
|
|
515763
515763
|
RUNTIME_READY_MESSAGE,
|
|
515764
|
-
isSafeRuntimeBoundary,
|
|
515765
515764
|
pruneRunningUpdateReleases
|
|
515766
515765
|
} = __require("./bin/running-update.cjs");
|
|
515767
515766
|
const {
|
|
@@ -515792,64 +515791,21 @@ function notifyRunningRuntimeReady(tui) {
|
|
|
515792
515791
|
sendRunningRuntimeSession(tui);
|
|
515793
515792
|
}
|
|
515794
515793
|
function requestRunningUpdateAtSafeBoundary(tui) {
|
|
515795
|
-
if (tui.runningUpdateHandoffStarted || tui.isShuttingDown || !process.connected) return false;
|
|
515796
515794
|
const version = tui.runningUpdatePreparedVersion;
|
|
515797
515795
|
const mode = tui.runningUpdatePreparedMode;
|
|
515798
|
-
|
|
515799
|
-
|
|
515800
|
-
|
|
515801
|
-
|
|
515802
|
-
|
|
515803
|
-
streamingPhase: tui.state.appState.streamingPhase,
|
|
515804
|
-
isCompacting: tui.state.appState.isCompacting,
|
|
515805
|
-
queuedMessages: tui.state.queuedMessages.length,
|
|
515806
|
-
activeToolCalls: tui.streamingUI.hasActiveToolCalls() ? 1 : 0,
|
|
515807
|
-
shellCommands: tui.shellOutputStreams.size,
|
|
515808
|
-
queueCommandRunning: tui.queueCommandRunning
|
|
515809
|
-
})) return false;
|
|
515810
|
-
tui.runningUpdateHandoffStarted = true;
|
|
515811
|
-
tui.showStatus(`Update ${version} ist bereit. Die sichere Update-Pause beginnt jetzt.`, "success");
|
|
515812
|
-
try {
|
|
515813
|
-
process.send({
|
|
515814
|
-
type: RUNNING_UPDATE_HANDOFF_MESSAGE,
|
|
515815
|
-
version,
|
|
515816
|
-
mode,
|
|
515817
|
-
sessionId,
|
|
515818
|
-
cwd
|
|
515819
|
-
}, (error) => {
|
|
515820
|
-
if (!error) return;
|
|
515821
|
-
tui.runningUpdateHandoffStarted = false;
|
|
515822
|
-
tui.showStatus("Das Update bleibt bereit und wird an der naechsten sicheren Grenze erneut versucht.", "warning");
|
|
515823
|
-
});
|
|
515824
|
-
return true;
|
|
515825
|
-
} catch {
|
|
515826
|
-
tui.runningUpdateHandoffStarted = false;
|
|
515827
|
-
return false;
|
|
515828
|
-
}
|
|
515796
|
+
if (typeof version !== "string" || mode !== RUNNING_UPDATE_MODES.RESUME && mode !== RUNNING_UPDATE_MODES.NEW) return false;
|
|
515797
|
+
if (tui.runningUpdatePreparedNoticeVersion === version) return false;
|
|
515798
|
+
tui.runningUpdatePreparedNoticeVersion = version;
|
|
515799
|
+
tui.showStatus(`Update ${version} ist sicher geladen. Die laufende Sitzung bleibt aktiv; beim naechsten natuerlichen Start wird sie automatisch fortgesetzt.`, "success");
|
|
515800
|
+
return false;
|
|
515829
515801
|
}
|
|
515830
515802
|
function installRunningUpdateListener(tui) {
|
|
515831
515803
|
const handler = (message) => {
|
|
515832
515804
|
if (message?.type === RUNNING_UPDATE_PREPARED_MESSAGE && typeof message.version === "string" && (message.mode === RUNNING_UPDATE_MODES.RESUME || message.mode === RUNNING_UPDATE_MODES.NEW)) {
|
|
515833
515805
|
tui.runningUpdatePreparedVersion = message.version;
|
|
515834
515806
|
tui.runningUpdatePreparedMode = message.mode;
|
|
515835
|
-
|
|
515836
|
-
return;
|
|
515837
|
-
}
|
|
515838
|
-
if (message?.type !== RUNNING_UPDATE_HANDOFF_ACK_MESSAGE || tui.runningUpdateHandoffStarted !== true || message.version !== tui.runningUpdatePreparedVersion || message.mode !== tui.runningUpdatePreparedMode || message.sessionId !== tui.getCurrentSessionId()) return;
|
|
515839
|
-
if (!isSafeRuntimeBoundary({
|
|
515840
|
-
isShuttingDown: tui.isShuttingDown,
|
|
515841
|
-
streamingPhase: tui.state.appState.streamingPhase,
|
|
515842
|
-
isCompacting: tui.state.appState.isCompacting,
|
|
515843
|
-
queuedMessages: tui.state.queuedMessages.length,
|
|
515844
|
-
activeToolCalls: tui.streamingUI.hasActiveToolCalls() ? 1 : 0,
|
|
515845
|
-
shellCommands: tui.shellOutputStreams.size,
|
|
515846
|
-
queueCommandRunning: tui.queueCommandRunning
|
|
515847
|
-
})) {
|
|
515848
|
-
tui.runningUpdateHandoffStarted = false;
|
|
515849
|
-
return;
|
|
515807
|
+
requestRunningUpdateAtSafeBoundary(tui);
|
|
515850
515808
|
}
|
|
515851
|
-
tui.showStatus(`Update ${message.version} wird aktiviert. Die Sitzung wird automatisch fortgesetzt.`, "success");
|
|
515852
|
-
void tui.stop(RUNNING_UPDATE_HANDOFF_EXIT_CODE);
|
|
515853
515809
|
};
|
|
515854
515810
|
process.on("message", handler);
|
|
515855
515811
|
return () => process.off("message", handler);
|
|
@@ -515941,7 +515897,7 @@ var BlunTUI = class {
|
|
|
515941
515897
|
startupGoalPromptedSessionId;
|
|
515942
515898
|
runningUpdatePreparedVersion;
|
|
515943
515899
|
runningUpdatePreparedMode;
|
|
515944
|
-
|
|
515900
|
+
runningUpdatePreparedNoticeVersion;
|
|
515945
515901
|
runningUpdateMessageDispose;
|
|
515946
515902
|
startupPhaseMs = {};
|
|
515947
515903
|
lastActivityMode;
|