blun-king-cli 9.1.209 → 9.1.211
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 +69 -12
- package/bin/running-update.cjs +77 -7
- package/blun.mjs +14 -28
- package/package.json +1 -1
package/bin/launcher-runtime.js
CHANGED
|
@@ -35,13 +35,17 @@ const {
|
|
|
35
35
|
RUNNING_UPDATE_PREPARED_MESSAGE,
|
|
36
36
|
RUNTIME_EXIT_INTENT_MESSAGE,
|
|
37
37
|
activateRuntime,
|
|
38
|
+
clearActiveRuntime,
|
|
38
39
|
handoffArgsForMode,
|
|
39
40
|
handoffRuntime,
|
|
40
41
|
prepareRunningUpdate,
|
|
41
42
|
pruneRunningUpdateReleases,
|
|
42
43
|
recordRunningUpdateEvent,
|
|
43
44
|
readActiveRuntime,
|
|
45
|
+
readPendingRuntime,
|
|
44
46
|
restoreActiveRuntime,
|
|
47
|
+
clearPendingRuntime,
|
|
48
|
+
stageRuntime,
|
|
45
49
|
} = require('./running-update.cjs');
|
|
46
50
|
const {
|
|
47
51
|
RUNNING_UPDATE_MODES,
|
|
@@ -65,9 +69,8 @@ const PROFILE = parseProfileLaunchArgs(RAW_ARGS, launcherModeFromArgv(process.ar
|
|
|
65
69
|
const ARGS = PROFILE.args;
|
|
66
70
|
const CORE_LOAD_TIMEOUT_MS = 30_000;
|
|
67
71
|
const RUNTIME_READY_TIMEOUT_MS = 60_000;
|
|
68
|
-
const RUNNING_UPDATE_RECHECK_MS = 60_000;
|
|
69
|
-
const RUNNING_UPDATE_RECHECK_JITTER_MS =
|
|
70
|
-
const RUNNING_UPDATE_HANDOFF_NOTICE = 'Ein Update wird geladen. Die TUI wird anschließend neu gestartet.';
|
|
72
|
+
const RUNNING_UPDATE_RECHECK_MS = 5 * 60_000;
|
|
73
|
+
const RUNNING_UPDATE_RECHECK_JITTER_MS = 2 * 60_000;
|
|
71
74
|
const RUNNING_UPDATE_STABILIZATION_MS = 2 * 60 * 1000;
|
|
72
75
|
|
|
73
76
|
function runningUpdateRecheckDelay(randomValue = Math.random()) {
|
|
@@ -87,10 +90,6 @@ function scheduleRunningUpdateRecheck(callback, options = {}) {
|
|
|
87
90
|
return timer;
|
|
88
91
|
}
|
|
89
92
|
|
|
90
|
-
function writeRunningUpdateHandoffNotice(output = process.stdout) {
|
|
91
|
-
output.write(`\n${RUNNING_UPDATE_HANDOFF_NOTICE}\n`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
93
|
function normalizeWindowsPath(value) {
|
|
95
94
|
return path.win32.normalize(value).replace(/\\+$/u, '').toLowerCase();
|
|
96
95
|
}
|
|
@@ -351,6 +350,15 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
351
350
|
return;
|
|
352
351
|
}
|
|
353
352
|
preparedTarget = target;
|
|
353
|
+
(options.stageRuntime || stageRuntime)(sharedHome, target, { mode: runningUpdateMode });
|
|
354
|
+
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
|
|
355
|
+
event: 'prepared-for-next-start',
|
|
356
|
+
fromVersion: readPackageVersionAt(packageRoot),
|
|
357
|
+
toVersion: target.version,
|
|
358
|
+
}, { now: options.nowImpl });
|
|
359
|
+
Promise.resolve((options.pruneRunningUpdateReleases || pruneRunningUpdateReleases)(sharedHome, {
|
|
360
|
+
activePackageRoot: packageRoot,
|
|
361
|
+
})).catch((error) => options.onRunningUpdateError?.(error));
|
|
354
362
|
clearRunningUpdatePoll();
|
|
355
363
|
announcePrepared(child);
|
|
356
364
|
}).catch((error) => {
|
|
@@ -389,6 +397,13 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
389
397
|
handoffSessionId = message.sessionId;
|
|
390
398
|
handoffMode = runningUpdateMode;
|
|
391
399
|
handoffCwd = resolveHandoffCwd(message.cwd, cwd);
|
|
400
|
+
if (preparedTarget !== undefined) {
|
|
401
|
+
(options.stageRuntime || stageRuntime)(env.BLUN_SHARED_HOME, preparedTarget, {
|
|
402
|
+
mode: handoffMode,
|
|
403
|
+
sessionId: handoffSessionId,
|
|
404
|
+
cwd: handoffCwd,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
392
407
|
}
|
|
393
408
|
};
|
|
394
409
|
const spawnCore = options.spawnProtectedCore || spawnProtectedCore;
|
|
@@ -402,6 +417,21 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
402
417
|
core.child.on('message', existingMessageHandler);
|
|
403
418
|
}
|
|
404
419
|
const loaded = await core.loaded;
|
|
420
|
+
if (loaded && options.startupPendingRuntime !== undefined) {
|
|
421
|
+
await (options.activateRuntime || activateRuntime)(env.BLUN_SHARED_HOME, options.startupPendingRuntime);
|
|
422
|
+
(options.clearPendingRuntime || clearPendingRuntime)(env.BLUN_SHARED_HOME, options.startupPendingRuntime);
|
|
423
|
+
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(env.BLUN_SHARED_HOME, {
|
|
424
|
+
event: 'activated-on-start',
|
|
425
|
+
version: options.startupPendingRuntime.version,
|
|
426
|
+
}, { now: options.nowImpl });
|
|
427
|
+
} else if (loaded && options.staleActiveRuntime !== undefined) {
|
|
428
|
+
(options.clearActiveRuntime || clearActiveRuntime)(env.BLUN_SHARED_HOME, options.staleActiveRuntime);
|
|
429
|
+
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(env.BLUN_SHARED_HOME, {
|
|
430
|
+
event: 'stale-active-cleared',
|
|
431
|
+
staleVersion: options.staleActiveRuntime.version,
|
|
432
|
+
runningVersion: readPackageVersionAt(packageRoot),
|
|
433
|
+
}, { now: options.nowImpl });
|
|
434
|
+
}
|
|
405
435
|
if (loaded && !runtimeReady) {
|
|
406
436
|
// Core load is an independent readiness signal. Start the download even
|
|
407
437
|
// when the later TUI-ready IPC message is lost; handoff still waits for
|
|
@@ -419,7 +449,6 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
419
449
|
&& preparedTarget !== undefined
|
|
420
450
|
&& handoffSessionId !== undefined
|
|
421
451
|
&& handoffMode !== undefined) {
|
|
422
|
-
writeRunningUpdateHandoffNotice(options.runningUpdateNoticeOutput || process.stdout);
|
|
423
452
|
const previousActiveRuntime = (options.readActiveRuntime || readActiveRuntime)(env.BLUN_SHARED_HOME);
|
|
424
453
|
const activatedAt = (options.nowImpl || Date.now)();
|
|
425
454
|
const handoff = await handoffRuntime({
|
|
@@ -463,6 +492,8 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
463
492
|
...options,
|
|
464
493
|
existingCore: resumed,
|
|
465
494
|
packageRoot: handoff.runtime.packageRoot,
|
|
495
|
+
startupPendingRuntime: undefined,
|
|
496
|
+
staleActiveRuntime: undefined,
|
|
466
497
|
recoveryRuntime: handoff.kind === 'activated' ? {
|
|
467
498
|
activatedAt,
|
|
468
499
|
activeRuntime: previousActiveRuntime,
|
|
@@ -497,6 +528,8 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
497
528
|
...options,
|
|
498
529
|
existingCore: fallback,
|
|
499
530
|
packageRoot: recovery.packageRoot,
|
|
531
|
+
startupPendingRuntime: undefined,
|
|
532
|
+
staleActiveRuntime: undefined,
|
|
500
533
|
recoveryRuntime: undefined,
|
|
501
534
|
});
|
|
502
535
|
}
|
|
@@ -575,12 +608,12 @@ function spawnManagedLauncher(binary, cwd) {
|
|
|
575
608
|
});
|
|
576
609
|
}
|
|
577
610
|
|
|
578
|
-
function spawnActiveLauncher(packageRoot, cwd) {
|
|
611
|
+
function spawnActiveLauncher(packageRoot, cwd, args = RAW_ARGS) {
|
|
579
612
|
const entryName = path.basename(process.argv[1] || 'king.js').toLowerCase() === 'blun.js'
|
|
580
613
|
? 'blun.js'
|
|
581
614
|
: 'king.js';
|
|
582
615
|
return new Promise((resolve, reject) => {
|
|
583
|
-
const child = spawn(process.execPath, [path.join(packageRoot, 'bin', entryName), ...
|
|
616
|
+
const child = spawn(process.execPath, [path.join(packageRoot, 'bin', entryName), ...args], {
|
|
584
617
|
cwd,
|
|
585
618
|
env: { ...process.env, BLUN_ACTIVE_RUNTIME_ROOT: packageRoot },
|
|
586
619
|
stdio: 'inherit',
|
|
@@ -598,16 +631,40 @@ function spawnActiveLauncher(packageRoot, cwd) {
|
|
|
598
631
|
|
|
599
632
|
async function runLauncher(options = {}) {
|
|
600
633
|
const callerCwd = process.cwd();
|
|
634
|
+
let startupPendingRuntime;
|
|
635
|
+
let staleActiveRuntime;
|
|
601
636
|
if (options.skipActiveRuntime !== true) {
|
|
602
637
|
const activeHome = resolveLauncherPrivatePaths().sharedHome;
|
|
638
|
+
const pendingRuntime = readPendingRuntime(activeHome);
|
|
603
639
|
const activeRuntime = readActiveRuntime(activeHome);
|
|
604
640
|
const currentVersion = readPackageVersion();
|
|
605
|
-
if (
|
|
641
|
+
if (pendingRuntime !== null
|
|
642
|
+
&& path.resolve(pendingRuntime.packageRoot) !== PKG
|
|
643
|
+
&& compareSemver(currentVersion, pendingRuntime.version) === -1) {
|
|
644
|
+
const pendingArgs = pendingRuntime.mode !== undefined && pendingRuntime.sessionId !== undefined
|
|
645
|
+
? handoffArgsForMode(RAW_ARGS, pendingRuntime.mode, pendingRuntime.sessionId)
|
|
646
|
+
: RAW_ARGS;
|
|
647
|
+
process.exitCode = await spawnActiveLauncher(
|
|
648
|
+
pendingRuntime.packageRoot,
|
|
649
|
+
pendingRuntime.cwd || callerCwd,
|
|
650
|
+
pendingArgs,
|
|
651
|
+
);
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
if (pendingRuntime !== null && path.resolve(pendingRuntime.packageRoot) === PKG) {
|
|
655
|
+
startupPendingRuntime = pendingRuntime;
|
|
656
|
+
}
|
|
657
|
+
if (startupPendingRuntime === undefined && activeRuntime !== null
|
|
606
658
|
&& path.resolve(activeRuntime.packageRoot) !== PKG
|
|
607
659
|
&& compareSemver(currentVersion, activeRuntime.version) === -1) {
|
|
608
660
|
process.exitCode = await spawnActiveLauncher(activeRuntime.packageRoot, callerCwd);
|
|
609
661
|
return;
|
|
610
662
|
}
|
|
663
|
+
if (activeRuntime !== null
|
|
664
|
+
&& path.resolve(activeRuntime.packageRoot) !== PKG
|
|
665
|
+
&& compareSemver(currentVersion, activeRuntime.version) >= 0) {
|
|
666
|
+
staleActiveRuntime = activeRuntime;
|
|
667
|
+
}
|
|
611
668
|
}
|
|
612
669
|
const mode = options.mode || launcherModeFromArgv(process.argv);
|
|
613
670
|
const explicitUpdateRequest = isNpmPackageUpdateRequest(ARGS);
|
|
@@ -822,6 +879,7 @@ async function runLauncher(options = {}) {
|
|
|
822
879
|
env,
|
|
823
880
|
callerCwd,
|
|
824
881
|
releaseNotice,
|
|
882
|
+
{ startupPendingRuntime, staleActiveRuntime },
|
|
825
883
|
);
|
|
826
884
|
} finally {
|
|
827
885
|
await releaseNotice();
|
|
@@ -842,5 +900,4 @@ module.exports = {
|
|
|
842
900
|
shouldDetachProtectedCore,
|
|
843
901
|
spawnManagedLauncher,
|
|
844
902
|
superviseProtectedCore,
|
|
845
|
-
writeRunningUpdateHandoffNotice,
|
|
846
903
|
};
|
package/bin/running-update.cjs
CHANGED
|
@@ -14,6 +14,7 @@ const PACKAGE_NAME = 'blun-king-cli';
|
|
|
14
14
|
const MANIFEST_URL = 'https://chat.blun.ai/blun-code-version.json';
|
|
15
15
|
const REGISTRY_URL = 'https://registry.npmjs.org/blun-king-cli';
|
|
16
16
|
const ACTIVE_RUNTIME_FILE = 'active-runtime.json';
|
|
17
|
+
const PENDING_RUNTIME_FILE = 'pending-runtime.json';
|
|
17
18
|
const RUNNING_UPDATE_HANDOFF_EXIT_CODE = 76;
|
|
18
19
|
const RUNNING_UPDATE_PREPARED_MESSAGE = 'blun-running-update-prepared';
|
|
19
20
|
const RUNNING_UPDATE_HANDOFF_MESSAGE = 'blun-running-update-handoff';
|
|
@@ -204,6 +205,10 @@ function activeRuntimePath(sharedHome) {
|
|
|
204
205
|
return path.join(path.resolve(sharedHome), 'updates', ACTIVE_RUNTIME_FILE);
|
|
205
206
|
}
|
|
206
207
|
|
|
208
|
+
function pendingRuntimePath(sharedHome) {
|
|
209
|
+
return path.join(path.resolve(sharedHome), 'updates', PENDING_RUNTIME_FILE);
|
|
210
|
+
}
|
|
211
|
+
|
|
207
212
|
function pathWithin(root, candidate) {
|
|
208
213
|
const relative = path.relative(root, candidate);
|
|
209
214
|
return relative === '' || (relative !== '..'
|
|
@@ -230,9 +235,8 @@ function verifyRuntimePackage(packageRoot, version, options = {}) {
|
|
|
230
235
|
}
|
|
231
236
|
}
|
|
232
237
|
|
|
233
|
-
function
|
|
238
|
+
function readRuntimeRecord(sharedHome, filePath) {
|
|
234
239
|
try {
|
|
235
|
-
const filePath = activeRuntimePath(sharedHome);
|
|
236
240
|
const stat = fs.lstatSync(filePath);
|
|
237
241
|
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 16 * 1024) return null;
|
|
238
242
|
const record = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
@@ -246,13 +250,31 @@ function readActiveRuntime(sharedHome) {
|
|
|
246
250
|
|| !verifyRuntimePackage(packageRoot, version, { sharedHome })) {
|
|
247
251
|
return null;
|
|
248
252
|
}
|
|
249
|
-
|
|
253
|
+
const mode = ownData(record, 'mode');
|
|
254
|
+
const sessionId = ownData(record, 'sessionId');
|
|
255
|
+
const cwd = ownData(record, 'cwd');
|
|
256
|
+
return Object.freeze({
|
|
257
|
+
version,
|
|
258
|
+
packageRoot: path.resolve(packageRoot),
|
|
259
|
+
integrity,
|
|
260
|
+
...(mode === 'resume' || mode === 'new' ? { mode } : {}),
|
|
261
|
+
...(typeof sessionId === 'string' && sessionId.length > 0 ? { sessionId } : {}),
|
|
262
|
+
...(typeof cwd === 'string' && path.isAbsolute(cwd) ? { cwd: path.resolve(cwd) } : {}),
|
|
263
|
+
});
|
|
250
264
|
} catch {
|
|
251
265
|
return null;
|
|
252
266
|
}
|
|
253
267
|
}
|
|
254
268
|
|
|
255
|
-
function
|
|
269
|
+
function readActiveRuntime(sharedHome) {
|
|
270
|
+
return readRuntimeRecord(sharedHome, activeRuntimePath(sharedHome));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function readPendingRuntime(sharedHome) {
|
|
274
|
+
return readRuntimeRecord(sharedHome, pendingRuntimePath(sharedHome));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function writeRuntimeRecord(sharedHome, fileName, target, extra = {}) {
|
|
256
278
|
if (!verifyRuntimePackage(target.packageRoot, target.version, { sharedHome })
|
|
257
279
|
|| !validIntegrity(target.integrity)) {
|
|
258
280
|
throw new Error('RUNNING_UPDATE_TARGET_INVALID');
|
|
@@ -260,14 +282,14 @@ function activateRuntime(sharedHome, target) {
|
|
|
260
282
|
const updateRoot = path.join(path.resolve(sharedHome), 'updates');
|
|
261
283
|
ensurePrivateDirectory(path.resolve(sharedHome));
|
|
262
284
|
ensurePrivateDirectory(updateRoot);
|
|
263
|
-
const filePath =
|
|
264
|
-
const temporaryPath = path.join(updateRoot, `.${
|
|
285
|
+
const filePath = path.join(updateRoot, fileName);
|
|
286
|
+
const temporaryPath = path.join(updateRoot, `.${fileName}.${process.pid}.${randomUUID()}.tmp`);
|
|
265
287
|
try {
|
|
266
288
|
writePrivateFile(temporaryPath, `${JSON.stringify({
|
|
267
289
|
version: target.version,
|
|
268
290
|
packageRoot: path.resolve(target.packageRoot),
|
|
269
291
|
integrity: target.integrity,
|
|
270
|
-
|
|
292
|
+
...extra,
|
|
271
293
|
})}\n`);
|
|
272
294
|
fs.renameSync(temporaryPath, filePath);
|
|
273
295
|
securePrivateFile(filePath);
|
|
@@ -277,6 +299,48 @@ function activateRuntime(sharedHome, target) {
|
|
|
277
299
|
}
|
|
278
300
|
}
|
|
279
301
|
|
|
302
|
+
function activateRuntime(sharedHome, target) {
|
|
303
|
+
writeRuntimeRecord(sharedHome, ACTIVE_RUNTIME_FILE, target, {
|
|
304
|
+
activatedAt: new Date().toISOString(),
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function stageRuntime(sharedHome, target, options = {}) {
|
|
309
|
+
const mode = options.mode === 'resume' || options.mode === 'new' ? options.mode : undefined;
|
|
310
|
+
const sessionId = typeof options.sessionId === 'string' && options.sessionId.length > 0
|
|
311
|
+
? options.sessionId
|
|
312
|
+
: undefined;
|
|
313
|
+
const cwd = typeof options.cwd === 'string' && path.isAbsolute(options.cwd)
|
|
314
|
+
? path.resolve(options.cwd)
|
|
315
|
+
: undefined;
|
|
316
|
+
writeRuntimeRecord(sharedHome, PENDING_RUNTIME_FILE, target, {
|
|
317
|
+
preparedAt: new Date((options.now || Date.now)()).toISOString(),
|
|
318
|
+
...(mode === undefined ? {} : { mode }),
|
|
319
|
+
...(sessionId === undefined ? {} : { sessionId }),
|
|
320
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function clearRuntimeRecord(sharedHome, expected, readRecord, filePath) {
|
|
325
|
+
const runtime = readRecord(sharedHome);
|
|
326
|
+
if (runtime === null) return false;
|
|
327
|
+
if (expected !== undefined
|
|
328
|
+
&& (runtime.version !== expected.version
|
|
329
|
+
|| runtime.packageRoot !== path.resolve(expected.packageRoot))) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
fs.rmSync(filePath(sharedHome), { force: true });
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function clearActiveRuntime(sharedHome, expected) {
|
|
337
|
+
return clearRuntimeRecord(sharedHome, expected, readActiveRuntime, activeRuntimePath);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function clearPendingRuntime(sharedHome, expected) {
|
|
341
|
+
return clearRuntimeRecord(sharedHome, expected, readPendingRuntime, pendingRuntimePath);
|
|
342
|
+
}
|
|
343
|
+
|
|
280
344
|
function restoreActiveRuntime(sharedHome, runtime) {
|
|
281
345
|
if (runtime === null || runtime === undefined) {
|
|
282
346
|
fs.rmSync(activeRuntimePath(sharedHome), { force: true });
|
|
@@ -492,6 +556,7 @@ async function prepareRunningUpdate(options) {
|
|
|
492
556
|
|
|
493
557
|
module.exports = {
|
|
494
558
|
ACTIVE_RUNTIME_FILE,
|
|
559
|
+
PENDING_RUNTIME_FILE,
|
|
495
560
|
AUTO_UPDATE_SETTLE_MS,
|
|
496
561
|
RUNNING_UPDATE_HANDOFF_EXIT_CODE,
|
|
497
562
|
RUNNING_UPDATE_HANDOFF_MESSAGE,
|
|
@@ -501,6 +566,8 @@ module.exports = {
|
|
|
501
566
|
RUNTIME_READY_MESSAGE,
|
|
502
567
|
activateRuntime,
|
|
503
568
|
activeRuntimePath,
|
|
569
|
+
clearActiveRuntime,
|
|
570
|
+
clearPendingRuntime,
|
|
504
571
|
defaultProbeRuntime,
|
|
505
572
|
handoffArgsForMode,
|
|
506
573
|
handoffRuntime,
|
|
@@ -509,8 +576,11 @@ module.exports = {
|
|
|
509
576
|
pruneRunningUpdateReleases,
|
|
510
577
|
recordRunningUpdateEvent,
|
|
511
578
|
readActiveRuntime,
|
|
579
|
+
readPendingRuntime,
|
|
512
580
|
restoreActiveRuntime,
|
|
513
581
|
resumeArgsForHandoff,
|
|
514
582
|
selectRunningUpdateTarget,
|
|
583
|
+
stageRuntime,
|
|
584
|
+
pendingRuntimePath,
|
|
515
585
|
verifyRuntimePackage,
|
|
516
586
|
};
|
package/blun.mjs
CHANGED
|
@@ -78012,7 +78012,10 @@ function parseLoopInterval(rawInterval) {
|
|
|
78012
78012
|
cron: hours === 1 ? "0 * * * *" : `0 */${String(hours)} * * *`
|
|
78013
78013
|
};
|
|
78014
78014
|
}
|
|
78015
|
-
|
|
78015
|
+
return {
|
|
78016
|
+
interval: `${String(amount)}${unit}`,
|
|
78017
|
+
cron: "* * * * *"
|
|
78018
|
+
};
|
|
78016
78019
|
}
|
|
78017
78020
|
function invalidLoopInterval(rawInterval) {
|
|
78018
78021
|
return new BlunError(ErrorCodes.LOOP_INTERVAL_INVALID, `Invalid loop interval ${JSON.stringify(rawInterval)}`);
|
|
@@ -418410,17 +418413,13 @@ function injectChannelEnvelope(host, envelope, preamble) {
|
|
|
418410
418413
|
host.displayContext?.(envelope.text, origin);
|
|
418411
418414
|
return "buffered";
|
|
418412
418415
|
}
|
|
418413
|
-
if (!host.canDeliver()) {
|
|
418414
|
-
host.reportUndeliverable(uiText("channelInjection.noActiveSession"));
|
|
418415
|
-
return "dropped";
|
|
418416
|
-
}
|
|
418417
418416
|
const modelParts = [...preamble.bufferedByChat?.get(envelope.meta.chat_id) ?? [], envelope.tag];
|
|
418418
418417
|
if (!preamble.sent && envelope.preamble !== void 0 && envelope.preamble.length > 0) {
|
|
418419
418418
|
modelParts.unshift(envelope.preamble);
|
|
418420
418419
|
preamble.sent = true;
|
|
418421
418420
|
}
|
|
418422
418421
|
const modelInput = modelParts.join("\n\n");
|
|
418423
|
-
if (host.isBusy()) {
|
|
418422
|
+
if (!host.canDeliver() || host.isBusy()) {
|
|
418424
418423
|
host.enqueue(modelInput, envelope.text, origin, contextOnly);
|
|
418425
418424
|
preamble.bufferedByChat?.delete(envelope.meta.chat_id);
|
|
418426
418425
|
return "queued";
|
|
@@ -422400,9 +422399,14 @@ function parseLoopCommand(rawArgs) {
|
|
|
422400
422399
|
}
|
|
422401
422400
|
if (LOOP_CREATE_FILLERS.has(tokens[startIndex]?.toLowerCase() ?? "")) startIndex += 1;
|
|
422402
422401
|
const intervalToken = tokens[startIndex];
|
|
422403
|
-
|
|
422402
|
+
let interval = intervalToken === void 0 ? null : normalizeLoopIntervalToken(intervalToken);
|
|
422403
|
+
let intervalTokenCount = 1;
|
|
422404
|
+
if (interval === null && /^\d+$/u.test(intervalToken ?? "") && tokens[startIndex + 1] !== void 0) {
|
|
422405
|
+
interval = normalizeLoopIntervalToken(`${intervalToken}${tokens[startIndex + 1]}`);
|
|
422406
|
+
if (interval !== null) intervalTokenCount = 2;
|
|
422407
|
+
}
|
|
422404
422408
|
if (interval !== null) {
|
|
422405
|
-
const prompt = tokens.slice(startIndex +
|
|
422409
|
+
const prompt = tokens.slice(startIndex + intervalTokenCount).join(" ").trim();
|
|
422406
422410
|
if (prompt.length === 0) return { kind: "error" };
|
|
422407
422411
|
return {
|
|
422408
422412
|
kind: "create",
|
|
@@ -515067,17 +515071,6 @@ function notifyRunningRuntimeReady(tui) {
|
|
|
515067
515071
|
}
|
|
515068
515072
|
function requestRunningUpdateAtSafeBoundary(tui) {
|
|
515069
515073
|
if (tui.runningUpdatePreparedVersion === void 0 || tui.runningUpdatePreparedMode === void 0 || tui.runningUpdateHandoffStarted || !process.connected) return false;
|
|
515070
|
-
const waitMs = tui.runningUpdateNotBeforeMs - Date.now();
|
|
515071
|
-
if (Number.isFinite(waitMs) && waitMs > 0) {
|
|
515072
|
-
if (tui.runningUpdateDelayTimer === void 0) {
|
|
515073
|
-
tui.runningUpdateDelayTimer = setTimeout(() => {
|
|
515074
|
-
tui.runningUpdateDelayTimer = void 0;
|
|
515075
|
-
requestRunningUpdateAtSafeBoundary(tui);
|
|
515076
|
-
}, waitMs);
|
|
515077
|
-
tui.runningUpdateDelayTimer.unref?.();
|
|
515078
|
-
}
|
|
515079
|
-
return false;
|
|
515080
|
-
}
|
|
515081
515074
|
const boundaryState = () => ({
|
|
515082
515075
|
isShuttingDown: tui.isShuttingDown,
|
|
515083
515076
|
streamingPhase: tui.state.appState.streamingPhase,
|
|
@@ -515101,9 +515094,7 @@ function requestRunningUpdateAtSafeBoundary(tui) {
|
|
|
515101
515094
|
}, (error) => {
|
|
515102
515095
|
if (error || !isSafeRuntimeBoundary(boundaryState())) {
|
|
515103
515096
|
tui.runningUpdateHandoffStarted = false;
|
|
515104
|
-
return;
|
|
515105
515097
|
}
|
|
515106
|
-
void tui.stop(RUNNING_UPDATE_HANDOFF_EXIT_CODE);
|
|
515107
515098
|
});
|
|
515108
515099
|
} catch {
|
|
515109
515100
|
tui.runningUpdateHandoffStarted = false;
|
|
@@ -515116,6 +515107,7 @@ function installRunningUpdateListener(tui) {
|
|
|
515116
515107
|
if (message?.type !== RUNNING_UPDATE_PREPARED_MESSAGE || typeof message.version !== "string" || message.mode !== RUNNING_UPDATE_MODES.RESUME && message.mode !== RUNNING_UPDATE_MODES.NEW) return;
|
|
515117
515108
|
tui.runningUpdatePreparedVersion = message.version;
|
|
515118
515109
|
tui.runningUpdatePreparedMode = message.mode;
|
|
515110
|
+
tui.showStatus(`Update ${message.version} ist bereit und wird beim nächsten Start aktiviert.`, "success");
|
|
515119
515111
|
requestRunningUpdateAtSafeBoundary(tui);
|
|
515120
515112
|
};
|
|
515121
515113
|
process.on("message", handler);
|
|
@@ -515208,8 +515200,6 @@ var BlunTUI = class {
|
|
|
515208
515200
|
runningUpdatePreparedVersion;
|
|
515209
515201
|
runningUpdatePreparedMode;
|
|
515210
515202
|
runningUpdateHandoffStarted = false;
|
|
515211
|
-
runningUpdateNotBeforeMs = Date.now() + AUTO_UPDATE_SETTLE_MS;
|
|
515212
|
-
runningUpdateDelayTimer;
|
|
515213
515203
|
runningUpdateMessageDispose;
|
|
515214
515204
|
startupPhaseMs = {};
|
|
515215
515205
|
lastActivityMode;
|
|
@@ -516327,10 +516317,6 @@ var BlunTUI = class {
|
|
|
516327
516317
|
}, envelope, this.channelPreamble);
|
|
516328
516318
|
}
|
|
516329
516319
|
injectTelegramRemoteCommand(envelope, command, acknowledge) {
|
|
516330
|
-
if (this.session === void 0 || this.state.appState.model.trim().length === 0) {
|
|
516331
|
-
this.showStatus(uiText("channelInjection.noActiveSession"), "warning");
|
|
516332
|
-
return;
|
|
516333
|
-
}
|
|
516334
516320
|
const item = {
|
|
516335
516321
|
text: command.input,
|
|
516336
516322
|
displayText: command.displayText,
|
|
@@ -516341,7 +516327,7 @@ var BlunTUI = class {
|
|
|
516341
516327
|
channelAcknowledge: acknowledge,
|
|
516342
516328
|
telegramCommandName: command.name
|
|
516343
516329
|
};
|
|
516344
|
-
const busy = this.state.queuedMessages.length > 0 || this.queueSteerInFlight !== void 0 || this.pendingChannelReplyGuard !== void 0 || this.deferUserMessages || this.streamingUI.hasActiveTurn() || this.state.appState.streamingPhase !== "idle" || this.state.appState.isCompacting;
|
|
516330
|
+
const busy = this.session === void 0 || this.state.appState.model.trim().length === 0 || this.state.queuedMessages.length > 0 || this.queueSteerInFlight !== void 0 || this.pendingChannelReplyGuard !== void 0 || this.deferUserMessages || this.streamingUI.hasActiveTurn() || this.state.appState.streamingPhase !== "idle" || this.state.appState.isCompacting;
|
|
516345
516331
|
if (busy) {
|
|
516346
516332
|
this.state.queuedMessages.push(item);
|
|
516347
516333
|
this.track("input_queue", { kind: "channel-command" });
|