blun-king-cli 9.1.184 → 9.1.185
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 +53 -37
- package/blun.mjs +9 -3
- package/package.json +1 -1
package/bin/launcher-runtime.js
CHANGED
|
@@ -34,6 +34,7 @@ const {
|
|
|
34
34
|
RUNNING_UPDATE_MODE_MESSAGE,
|
|
35
35
|
RUNNING_UPDATE_PREPARED_MESSAGE,
|
|
36
36
|
activateRuntime,
|
|
37
|
+
handoffArgsForMode,
|
|
37
38
|
handoffRuntime,
|
|
38
39
|
prepareRunningUpdate,
|
|
39
40
|
readActiveRuntime,
|
|
@@ -156,14 +157,18 @@ function resolveLauncherPrivatePaths(options = {}) {
|
|
|
156
157
|
};
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
function
|
|
160
|
-
const { version } = JSON.parse(fs.readFileSync(path.join(
|
|
160
|
+
function readPackageVersionAt(packageRoot = PKG) {
|
|
161
|
+
const { version } = JSON.parse(fs.readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
|
|
161
162
|
if (typeof version !== 'string' || version.length === 0) {
|
|
162
163
|
throw new Error('Ungueltige Paketversion in package.json');
|
|
163
164
|
}
|
|
164
165
|
return version;
|
|
165
166
|
}
|
|
166
167
|
|
|
168
|
+
function readPackageVersion() {
|
|
169
|
+
return readPackageVersionAt(PKG);
|
|
170
|
+
}
|
|
171
|
+
|
|
167
172
|
function shouldDetachProtectedCore(options = {}) {
|
|
168
173
|
const platform = options.platform || process.platform;
|
|
169
174
|
const stdinIsTTY = Object.hasOwn(options, 'stdinIsTTY')
|
|
@@ -321,38 +326,45 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
321
326
|
scheduleNextPreparation(child);
|
|
322
327
|
});
|
|
323
328
|
};
|
|
324
|
-
const
|
|
329
|
+
const handleCoreMessage = (message, child) => {
|
|
330
|
+
if (message?.type === RUNTIME_READY_MESSAGE) {
|
|
331
|
+
runtimeReady = true;
|
|
332
|
+
refreshRunningUpdateMode();
|
|
333
|
+
if (automaticMode()) startPreparation(child);
|
|
334
|
+
else scheduleNextPreparation(child);
|
|
335
|
+
}
|
|
336
|
+
if (message?.type === RUNNING_UPDATE_MODE_MESSAGE && typeof message.mode === 'string') {
|
|
337
|
+
runningUpdateMode = normalizeRunningUpdateMode(message.mode);
|
|
338
|
+
handoffSessionId = undefined;
|
|
339
|
+
handoffMode = undefined;
|
|
340
|
+
clearRunningUpdatePoll();
|
|
341
|
+
if (automaticMode()) {
|
|
342
|
+
if (preparedTarget !== undefined) announcePrepared(child);
|
|
343
|
+
else if (runtimeReady) {
|
|
344
|
+
updateStarted = false;
|
|
345
|
+
startPreparation(child);
|
|
346
|
+
}
|
|
347
|
+
} else if (runtimeReady) scheduleNextPreparation(child);
|
|
348
|
+
}
|
|
349
|
+
if (message?.type === RUNNING_UPDATE_HANDOFF_MESSAGE
|
|
350
|
+
&& typeof message.sessionId === 'string'
|
|
351
|
+
&& message.sessionId.length > 0
|
|
352
|
+
&& message.mode === runningUpdateMode
|
|
353
|
+
&& automaticMode()) {
|
|
354
|
+
handoffSessionId = message.sessionId;
|
|
355
|
+
handoffMode = runningUpdateMode;
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const spawnCore = options.spawnProtectedCore || spawnProtectedCore;
|
|
359
|
+
const core = options.existingCore || spawnCore(args, env, cwd, {
|
|
325
360
|
packageRoot,
|
|
326
|
-
onMessage
|
|
327
|
-
if (message?.type === RUNTIME_READY_MESSAGE) {
|
|
328
|
-
runtimeReady = true;
|
|
329
|
-
refreshRunningUpdateMode();
|
|
330
|
-
if (automaticMode()) startPreparation(child);
|
|
331
|
-
else scheduleNextPreparation(child);
|
|
332
|
-
}
|
|
333
|
-
if (message?.type === RUNNING_UPDATE_MODE_MESSAGE && typeof message.mode === 'string') {
|
|
334
|
-
runningUpdateMode = normalizeRunningUpdateMode(message.mode);
|
|
335
|
-
handoffSessionId = undefined;
|
|
336
|
-
handoffMode = undefined;
|
|
337
|
-
clearRunningUpdatePoll();
|
|
338
|
-
if (automaticMode()) {
|
|
339
|
-
if (preparedTarget !== undefined) announcePrepared(child);
|
|
340
|
-
else if (runtimeReady) {
|
|
341
|
-
updateStarted = false;
|
|
342
|
-
startPreparation(child);
|
|
343
|
-
}
|
|
344
|
-
} else if (runtimeReady) scheduleNextPreparation(child);
|
|
345
|
-
}
|
|
346
|
-
if (message?.type === RUNNING_UPDATE_HANDOFF_MESSAGE
|
|
347
|
-
&& typeof message.sessionId === 'string'
|
|
348
|
-
&& message.sessionId.length > 0
|
|
349
|
-
&& message.mode === runningUpdateMode
|
|
350
|
-
&& automaticMode()) {
|
|
351
|
-
handoffSessionId = message.sessionId;
|
|
352
|
-
handoffMode = runningUpdateMode;
|
|
353
|
-
}
|
|
354
|
-
},
|
|
361
|
+
onMessage: handleCoreMessage,
|
|
355
362
|
});
|
|
363
|
+
let existingMessageHandler;
|
|
364
|
+
if (options.existingCore) {
|
|
365
|
+
existingMessageHandler = (message) => handleCoreMessage(message, core.child);
|
|
366
|
+
core.child.on('message', existingMessageHandler);
|
|
367
|
+
}
|
|
356
368
|
const loaded = await core.loaded;
|
|
357
369
|
if (loaded && !runtimeReady) {
|
|
358
370
|
// Core load is an independent readiness signal. Start the download even
|
|
@@ -366,6 +378,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
366
378
|
await releaseNotice();
|
|
367
379
|
const result = await core.completed;
|
|
368
380
|
clearRunningUpdatePoll();
|
|
381
|
+
if (existingMessageHandler) core.child.off('message', existingMessageHandler);
|
|
369
382
|
if (result.error) throw result.error;
|
|
370
383
|
if (result.code === RUNNING_UPDATE_HANDOFF_EXIT_CODE
|
|
371
384
|
&& preparedTarget !== undefined
|
|
@@ -374,14 +387,14 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
374
387
|
writeRunningUpdateHandoffNotice(options.runningUpdateNoticeOutput || process.stdout);
|
|
375
388
|
const handoff = await handoffRuntime({
|
|
376
389
|
target: preparedTarget,
|
|
377
|
-
previous: { packageRoot, version:
|
|
390
|
+
previous: { packageRoot, version: readPackageVersionAt(packageRoot) },
|
|
378
391
|
sessionId: handoffSessionId,
|
|
379
392
|
mode: handoffMode,
|
|
380
393
|
args,
|
|
381
394
|
probeTarget: options.probeRunningUpdate || (() => true),
|
|
382
395
|
stopOld: async () => {},
|
|
383
396
|
startCore: async ({ packageRoot: nextRoot, args: nextArgs }) => {
|
|
384
|
-
const nextCore =
|
|
397
|
+
const nextCore = spawnCore(nextArgs, env, cwd, { packageRoot: nextRoot });
|
|
385
398
|
const nextLoaded = await nextCore.loaded;
|
|
386
399
|
const ready = nextLoaded && await waitForRuntimeReady(nextCore, options.readyTimeoutMs);
|
|
387
400
|
if (!ready) {
|
|
@@ -394,9 +407,12 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
394
407
|
});
|
|
395
408
|
const resumed = handoff.core;
|
|
396
409
|
if (resumed === undefined || resumed.ready !== true) return 1;
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
410
|
+
const resumedArgs = handoffArgsForMode(args, handoffMode, handoffSessionId);
|
|
411
|
+
return superviseProtectedCore(resumedArgs, env, cwd, async () => {}, {
|
|
412
|
+
...options,
|
|
413
|
+
existingCore: resumed,
|
|
414
|
+
packageRoot: handoff.runtime.packageRoot,
|
|
415
|
+
});
|
|
400
416
|
}
|
|
401
417
|
return exitCodeForChild(result, loaded);
|
|
402
418
|
}
|
package/blun.mjs
CHANGED
|
@@ -514886,7 +514886,7 @@ function notifyRunningRuntimeReady(tui) {
|
|
|
514886
514886
|
}
|
|
514887
514887
|
function requestRunningUpdateAtSafeBoundary(tui) {
|
|
514888
514888
|
if (tui.runningUpdatePreparedVersion === void 0 || tui.runningUpdatePreparedMode === void 0 || tui.runningUpdateHandoffStarted || !process.connected) return false;
|
|
514889
|
-
|
|
514889
|
+
const boundaryState = () => ({
|
|
514890
514890
|
isShuttingDown: tui.isShuttingDown,
|
|
514891
514891
|
streamingPhase: tui.state.appState.streamingPhase,
|
|
514892
514892
|
isCompacting: tui.state.appState.isCompacting,
|
|
@@ -514894,7 +514894,8 @@ function requestRunningUpdateAtSafeBoundary(tui) {
|
|
|
514894
514894
|
activeToolCalls: tui.streamingUI.hasActiveToolCalls() ? 1 : 0,
|
|
514895
514895
|
shellCommands: tui.shellOutputStreams.size,
|
|
514896
514896
|
queueCommandRunning: tui.queueCommandRunning
|
|
514897
|
-
})
|
|
514897
|
+
});
|
|
514898
|
+
if (!isSafeRuntimeBoundary(boundaryState())) return false;
|
|
514898
514899
|
const sessionId = tui.getCurrentSessionId();
|
|
514899
514900
|
if (sessionId.length === 0) return false;
|
|
514900
514901
|
tui.runningUpdateHandoffStarted = true;
|
|
@@ -514904,12 +514905,17 @@ function requestRunningUpdateAtSafeBoundary(tui) {
|
|
|
514904
514905
|
sessionId,
|
|
514905
514906
|
version: tui.runningUpdatePreparedVersion,
|
|
514906
514907
|
mode: tui.runningUpdatePreparedMode
|
|
514908
|
+
}, (error) => {
|
|
514909
|
+
if (error || !isSafeRuntimeBoundary(boundaryState())) {
|
|
514910
|
+
tui.runningUpdateHandoffStarted = false;
|
|
514911
|
+
return;
|
|
514912
|
+
}
|
|
514913
|
+
void tui.stop(RUNNING_UPDATE_HANDOFF_EXIT_CODE);
|
|
514907
514914
|
});
|
|
514908
514915
|
} catch {
|
|
514909
514916
|
tui.runningUpdateHandoffStarted = false;
|
|
514910
514917
|
return false;
|
|
514911
514918
|
}
|
|
514912
|
-
void tui.stop(RUNNING_UPDATE_HANDOFF_EXIT_CODE);
|
|
514913
514919
|
return true;
|
|
514914
514920
|
}
|
|
514915
514921
|
function installRunningUpdateListener(tui) {
|