blun-king-cli 9.1.170 → 9.1.172
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
|
@@ -58,6 +58,25 @@ const PROFILE = parseProfileLaunchArgs(RAW_ARGS, launcherModeFromArgv(process.ar
|
|
|
58
58
|
const ARGS = PROFILE.args;
|
|
59
59
|
const CORE_LOAD_TIMEOUT_MS = 30_000;
|
|
60
60
|
const RUNTIME_READY_TIMEOUT_MS = 60_000;
|
|
61
|
+
const RUNNING_UPDATE_RECHECK_MS = 60_000;
|
|
62
|
+
const RUNNING_UPDATE_RECHECK_JITTER_MS = 30_000;
|
|
63
|
+
|
|
64
|
+
function runningUpdateRecheckDelay(randomValue = Math.random()) {
|
|
65
|
+
const normalized = Number.isFinite(randomValue)
|
|
66
|
+
? Math.min(Math.max(randomValue, 0), 0.999999999)
|
|
67
|
+
: 0;
|
|
68
|
+
return RUNNING_UPDATE_RECHECK_MS
|
|
69
|
+
+ Math.floor(normalized * RUNNING_UPDATE_RECHECK_JITTER_MS);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function scheduleRunningUpdateRecheck(callback, options = {}) {
|
|
73
|
+
const timer = (options.setTimeoutImpl || setTimeout)(
|
|
74
|
+
callback,
|
|
75
|
+
options.delayMs ?? runningUpdateRecheckDelay((options.randomImpl || Math.random)()),
|
|
76
|
+
);
|
|
77
|
+
timer.unref?.();
|
|
78
|
+
return timer;
|
|
79
|
+
}
|
|
61
80
|
|
|
62
81
|
function normalizeWindowsPath(value) {
|
|
63
82
|
return path.win32.normalize(value).replace(/\\+$/u, '').toLowerCase();
|
|
@@ -232,9 +251,23 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
232
251
|
let handoffMode;
|
|
233
252
|
let updateStarted = false;
|
|
234
253
|
let runtimeReady = false;
|
|
254
|
+
let runningUpdatePollTimer;
|
|
235
255
|
let runningUpdateMode = readRunningUpdateMode(env.BLUN_HOME);
|
|
236
256
|
const automaticMode = () => runningUpdateMode === RUNNING_UPDATE_MODES.RESUME
|
|
237
257
|
|| runningUpdateMode === RUNNING_UPDATE_MODES.NEW;
|
|
258
|
+
const clearRunningUpdatePoll = () => {
|
|
259
|
+
if (runningUpdatePollTimer === undefined) return;
|
|
260
|
+
(options.clearTimeoutImpl || clearTimeout)(runningUpdatePollTimer);
|
|
261
|
+
runningUpdatePollTimer = undefined;
|
|
262
|
+
};
|
|
263
|
+
const scheduleNextPreparation = (child) => {
|
|
264
|
+
clearRunningUpdatePoll();
|
|
265
|
+
if (preparedTarget !== undefined || updateStarted || !automaticMode()) return;
|
|
266
|
+
runningUpdatePollTimer = (options.scheduleRunningUpdateRecheck || scheduleRunningUpdateRecheck)(() => {
|
|
267
|
+
runningUpdatePollTimer = undefined;
|
|
268
|
+
startPreparation(child);
|
|
269
|
+
});
|
|
270
|
+
};
|
|
238
271
|
const announcePrepared = (child) => {
|
|
239
272
|
if (preparedTarget === undefined || !automaticMode() || child.connected !== true) return;
|
|
240
273
|
child.send({
|
|
@@ -249,6 +282,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
249
282
|
const sharedHome = env.BLUN_SHARED_HOME;
|
|
250
283
|
if (typeof sharedHome !== 'string' || sharedHome.length === 0) {
|
|
251
284
|
updateStarted = false;
|
|
285
|
+
scheduleNextPreparation(child);
|
|
252
286
|
return;
|
|
253
287
|
}
|
|
254
288
|
Promise.resolve((options.prepareRunningUpdate || prepareRunningUpdate)({
|
|
@@ -258,16 +292,19 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
258
292
|
})).then((target) => {
|
|
259
293
|
if (target === null) {
|
|
260
294
|
updateStarted = false;
|
|
295
|
+
scheduleNextPreparation(child);
|
|
261
296
|
return;
|
|
262
297
|
}
|
|
263
298
|
preparedTarget = target;
|
|
299
|
+
clearRunningUpdatePoll();
|
|
264
300
|
announcePrepared(child);
|
|
265
301
|
}).catch((error) => {
|
|
266
302
|
updateStarted = false;
|
|
267
303
|
options.onRunningUpdateError?.(error);
|
|
304
|
+
scheduleNextPreparation(child);
|
|
268
305
|
});
|
|
269
306
|
};
|
|
270
|
-
const core = spawnProtectedCore(args, env, cwd, {
|
|
307
|
+
const core = (options.spawnProtectedCore || spawnProtectedCore)(args, env, cwd, {
|
|
271
308
|
packageRoot,
|
|
272
309
|
onMessage(message, child) {
|
|
273
310
|
if (message?.type === RUNTIME_READY_MESSAGE) {
|
|
@@ -278,6 +315,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
278
315
|
runningUpdateMode = normalizeRunningUpdateMode(message.mode);
|
|
279
316
|
handoffSessionId = undefined;
|
|
280
317
|
handoffMode = undefined;
|
|
318
|
+
clearRunningUpdatePoll();
|
|
281
319
|
if (automaticMode()) {
|
|
282
320
|
if (preparedTarget !== undefined) announcePrepared(child);
|
|
283
321
|
else if (runtimeReady) {
|
|
@@ -299,6 +337,7 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
299
337
|
const loaded = await core.loaded;
|
|
300
338
|
await releaseNotice();
|
|
301
339
|
const result = await core.completed;
|
|
340
|
+
clearRunningUpdatePoll();
|
|
302
341
|
if (result.error) throw result.error;
|
|
303
342
|
if (result.code === RUNNING_UPDATE_HANDOFF_EXIT_CODE
|
|
304
343
|
&& preparedTarget !== undefined
|
|
@@ -656,9 +695,14 @@ async function runLauncher(options = {}) {
|
|
|
656
695
|
}
|
|
657
696
|
|
|
658
697
|
module.exports = {
|
|
698
|
+
RUNNING_UPDATE_RECHECK_JITTER_MS,
|
|
699
|
+
RUNNING_UPDATE_RECHECK_MS,
|
|
659
700
|
createManagedNodeEnvironment,
|
|
660
701
|
resolveLauncherPrivatePaths,
|
|
702
|
+
runningUpdateRecheckDelay,
|
|
661
703
|
runLauncher,
|
|
704
|
+
scheduleRunningUpdateRecheck,
|
|
662
705
|
shouldDetachProtectedCore,
|
|
663
706
|
spawnManagedLauncher,
|
|
707
|
+
superviseProtectedCore,
|
|
664
708
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const TOOL_SCHEMA_BUDGET_RATIO = 0.25;
|
|
4
4
|
const TOOL_SCHEMA_MAX_TOKENS = 32_000;
|
|
5
5
|
const DEFERRED_TOOL_LOADER_NAME = 'ToolSearch';
|
|
6
|
-
const MAX_PERSISTENT_DEFERRED_TOOLS =
|
|
6
|
+
const MAX_PERSISTENT_DEFERRED_TOOLS = 4;
|
|
7
7
|
const TOOL_SEARCH_INTENT_WORDS = new Set([
|
|
8
8
|
'find', 'fetch', 'get', 'holen', 'list', 'read', 'search', 'show', 'anzeigen', 'lesen', 'suchen',
|
|
9
9
|
]);
|