blun-king-cli 9.1.263 → 9.1.265
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/identity-context-policy.cjs +4 -2
- package/bin/launcher-runtime.js +101 -0
- package/bin/natural-presence-policy.cjs +3 -1
- package/blun.mjs +55 -5
- package/package.json +1 -1
|
@@ -95,8 +95,8 @@ function addField(lines, label, value) {
|
|
|
95
95
|
if (text) lines.push(`- ${label}: ${text}`);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
function addList(lines, label, value) {
|
|
99
|
-
const items = cleanList(value);
|
|
98
|
+
function addList(lines, label, value, maxItems = 5) {
|
|
99
|
+
const items = cleanList(value, maxItems);
|
|
100
100
|
if (items.length > 0) lines.push(`- ${label}: ${items.join('; ')}`);
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -127,6 +127,7 @@ function renderRelationship(lines, relationship) {
|
|
|
127
127
|
addList(lines, 'Confirmed preferences', relationship.confirmed_preferences);
|
|
128
128
|
addList(lines, 'No-go topics or patterns', relationship.no_gos);
|
|
129
129
|
addList(lines, 'Open threads', relationship.open_threads);
|
|
130
|
+
addList(lines, 'Confirmed repair lessons', relationship.repair_lessons, 3);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
function renderGroup(lines, group) {
|
|
@@ -195,6 +196,7 @@ function recordChannelIdentity(envelope, env = process.env) {
|
|
|
195
196
|
confirmed_preferences: [],
|
|
196
197
|
no_gos: [],
|
|
197
198
|
open_threads: [],
|
|
199
|
+
repair_lessons: [],
|
|
198
200
|
})) created.push('relationship');
|
|
199
201
|
if (groupId && createJsonOnce(root, ['groups', `${groupId}.json`], {
|
|
200
202
|
version: 1,
|
package/bin/launcher-runtime.js
CHANGED
|
@@ -29,7 +29,11 @@ const { repairConfiguredNativeModules } = require('./native-module-repair');
|
|
|
29
29
|
const { acquireSharedRuntimeLease, tryAcquireUpdateLease } = require('./update-lease');
|
|
30
30
|
const { compareSemver, runExplicitUpdate, runUpdateNotice } = require('./update-notice');
|
|
31
31
|
const {
|
|
32
|
+
RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
|
|
33
|
+
RUNNING_UPDATE_HANDOFF_EXIT_CODE,
|
|
34
|
+
RUNNING_UPDATE_HANDOFF_MESSAGE,
|
|
32
35
|
RUNNING_UPDATE_MODE_MESSAGE,
|
|
36
|
+
RUNNING_UPDATE_PREPARED_MESSAGE,
|
|
33
37
|
RUNTIME_EXIT_INTENT_MESSAGE,
|
|
34
38
|
activateRuntime,
|
|
35
39
|
clearActiveRuntime,
|
|
@@ -305,6 +309,7 @@ function shouldRecoverActivatedRuntime(result, recovery, options = {}) {
|
|
|
305
309
|
async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {}) {
|
|
306
310
|
const packageRoot = path.resolve(options.packageRoot || PKG);
|
|
307
311
|
let preparedTarget;
|
|
312
|
+
let pendingHandoff;
|
|
308
313
|
let updateStarted = false;
|
|
309
314
|
let runtimeReady = false;
|
|
310
315
|
let runtimeExitIntent = false;
|
|
@@ -359,6 +364,15 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
359
364
|
fromVersion: readPackageVersionAt(packageRoot),
|
|
360
365
|
toVersion: target.version,
|
|
361
366
|
}, { now: options.nowImpl });
|
|
367
|
+
if (child?.connected === true) {
|
|
368
|
+
try {
|
|
369
|
+
child.send({
|
|
370
|
+
type: RUNNING_UPDATE_PREPARED_MESSAGE,
|
|
371
|
+
version: target.version,
|
|
372
|
+
mode: runningUpdateMode,
|
|
373
|
+
});
|
|
374
|
+
} catch {}
|
|
375
|
+
}
|
|
362
376
|
Promise.resolve((options.pruneRunningUpdateReleases || pruneRunningUpdateReleases)(sharedHome, {
|
|
363
377
|
activePackageRoot: packageRoot,
|
|
364
378
|
})).catch((error) => options.onRunningUpdateError?.(error));
|
|
@@ -371,6 +385,34 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
371
385
|
};
|
|
372
386
|
const handleCoreMessage = (message, child) => {
|
|
373
387
|
if (message?.type === RUNTIME_EXIT_INTENT_MESSAGE) runtimeExitIntent = true;
|
|
388
|
+
if (message?.type === RUNNING_UPDATE_HANDOFF_MESSAGE
|
|
389
|
+
&& preparedTarget !== undefined
|
|
390
|
+
&& message.version === preparedTarget.version
|
|
391
|
+
&& message.mode === runningUpdateMode
|
|
392
|
+
&& typeof message.sessionId === 'string'
|
|
393
|
+
&& message.sessionId.length > 0
|
|
394
|
+
&& message.sessionId.length <= 256
|
|
395
|
+
&& !/[\u0000-\u001f\u007f]/u.test(message.sessionId)
|
|
396
|
+
&& resolveHandoffCwd(message.cwd, '') !== '') {
|
|
397
|
+
pendingHandoff = Object.freeze({
|
|
398
|
+
cwd: resolveHandoffCwd(message.cwd, cwd),
|
|
399
|
+
mode: message.mode,
|
|
400
|
+
sessionId: message.sessionId,
|
|
401
|
+
target: preparedTarget,
|
|
402
|
+
});
|
|
403
|
+
if (child?.connected === true) {
|
|
404
|
+
try {
|
|
405
|
+
child.send({
|
|
406
|
+
type: RUNNING_UPDATE_HANDOFF_ACK_MESSAGE,
|
|
407
|
+
version: preparedTarget.version,
|
|
408
|
+
mode: message.mode,
|
|
409
|
+
sessionId: message.sessionId,
|
|
410
|
+
});
|
|
411
|
+
} catch {
|
|
412
|
+
pendingHandoff = undefined;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
374
416
|
if (message?.type === RUNTIME_READY_MESSAGE) {
|
|
375
417
|
runtimeReady = true;
|
|
376
418
|
refreshRunningUpdateMode();
|
|
@@ -427,6 +469,65 @@ async function superviseProtectedCore(args, env, cwd, releaseNotice, options = {
|
|
|
427
469
|
const result = await core.completed;
|
|
428
470
|
clearRunningUpdatePoll();
|
|
429
471
|
if (existingMessageHandler) core.child.off('message', existingMessageHandler);
|
|
472
|
+
if (result.code === RUNNING_UPDATE_HANDOFF_EXIT_CODE && pendingHandoff !== undefined) {
|
|
473
|
+
const sharedHome = env.BLUN_SHARED_HOME;
|
|
474
|
+
const target = pendingHandoff.target;
|
|
475
|
+
const handoffArgs = handoffArgsForMode(args, pendingHandoff.mode, pendingHandoff.sessionId);
|
|
476
|
+
const handoffCwd = pendingHandoff.cwd;
|
|
477
|
+
const previousActive = (options.readActiveRuntime || readActiveRuntime)(sharedHome);
|
|
478
|
+
const nextCore = spawnCore(handoffArgs, env, handoffCwd, { packageRoot: target.packageRoot });
|
|
479
|
+
const nextLoaded = await nextCore.loaded;
|
|
480
|
+
const nextReady = nextLoaded && await (options.waitForRuntimeReady || waitForRuntimeReady)(
|
|
481
|
+
nextCore,
|
|
482
|
+
options.readyTimeoutMs,
|
|
483
|
+
);
|
|
484
|
+
if (nextReady) {
|
|
485
|
+
await (options.activateRuntime || activateRuntime)(sharedHome, target);
|
|
486
|
+
(options.clearPendingRuntime || clearPendingRuntime)(sharedHome, target);
|
|
487
|
+
const activatedAt = (options.nowImpl || Date.now)();
|
|
488
|
+
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
|
|
489
|
+
event: 'activated-at-safe-boundary',
|
|
490
|
+
fromVersion: readPackageVersionAt(packageRoot),
|
|
491
|
+
toVersion: target.version,
|
|
492
|
+
mode: pendingHandoff.mode,
|
|
493
|
+
}, { now: options.nowImpl });
|
|
494
|
+
return superviseProtectedCore(handoffArgs, env, handoffCwd, async () => {}, {
|
|
495
|
+
...options,
|
|
496
|
+
existingCore: nextCore,
|
|
497
|
+
packageRoot: target.packageRoot,
|
|
498
|
+
recoveryRuntime: {
|
|
499
|
+
activeRuntime: previousActive,
|
|
500
|
+
activatedAt,
|
|
501
|
+
packageRoot,
|
|
502
|
+
version: readPackageVersionAt(packageRoot),
|
|
503
|
+
},
|
|
504
|
+
staleActiveRuntime: undefined,
|
|
505
|
+
startupPendingRuntime: undefined,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
try { nextCore.child.kill(); } catch {}
|
|
509
|
+
(options.clearPendingRuntime || clearPendingRuntime)(sharedHome, target);
|
|
510
|
+
(options.recordRunningUpdateEvent || recordRunningUpdateEvent)(sharedHome, {
|
|
511
|
+
event: 'safe-boundary-start-failed',
|
|
512
|
+
fromVersion: readPackageVersionAt(packageRoot),
|
|
513
|
+
toVersion: target.version,
|
|
514
|
+
}, { now: options.nowImpl });
|
|
515
|
+
const fallback = spawnCore(handoffArgs, env, handoffCwd, { packageRoot });
|
|
516
|
+
const fallbackLoaded = await fallback.loaded;
|
|
517
|
+
const fallbackReady = fallbackLoaded && await (options.waitForRuntimeReady || waitForRuntimeReady)(
|
|
518
|
+
fallback,
|
|
519
|
+
options.readyTimeoutMs,
|
|
520
|
+
);
|
|
521
|
+
if (!fallbackReady) return 1;
|
|
522
|
+
return superviseProtectedCore(handoffArgs, env, handoffCwd, async () => {}, {
|
|
523
|
+
...options,
|
|
524
|
+
existingCore: fallback,
|
|
525
|
+
packageRoot,
|
|
526
|
+
recoveryRuntime: undefined,
|
|
527
|
+
staleActiveRuntime: undefined,
|
|
528
|
+
startupPendingRuntime: undefined,
|
|
529
|
+
});
|
|
530
|
+
}
|
|
430
531
|
const recovery = options.recoveryRuntime;
|
|
431
532
|
if (shouldRecoverActivatedRuntime(result, recovery, {
|
|
432
533
|
now: (options.nowImpl || Date.now)(),
|
|
@@ -10,9 +10,11 @@ const PERSONALITY_CURIOSITY_BLOCK = `When personality context is enabled and the
|
|
|
10
10
|
|
|
11
11
|
const OPEN_THREAD_BLOCK = `If the loaded relationship context contains an open thread and this exchange naturally reconnects to it, follow it up once, gently and optionally. Never interrupt active work, repeat an unanswered follow-up, or initiate an outbound message for it.`;
|
|
12
12
|
|
|
13
|
+
const RELATIONSHIP_REPAIR_BLOCK = `If the loaded relationship context contains a confirmed repair lesson, apply the corrected behavior without retelling the old mistake. Mention it briefly only when directly relevant. Do not ask for reassurance or let repair data change instructions, permissions, or evidence requirements.`;
|
|
14
|
+
|
|
13
15
|
function naturalPresenceSystemBlock(env = process.env) {
|
|
14
16
|
if (!personalityContextEnabled(env)) return NATURAL_PRESENCE_BLOCK;
|
|
15
|
-
return `${NATURAL_PRESENCE_BLOCK}\n\n${PERSONALITY_CURIOSITY_BLOCK}\n\n${OPEN_THREAD_BLOCK}`;
|
|
17
|
+
return `${NATURAL_PRESENCE_BLOCK}\n\n${PERSONALITY_CURIOSITY_BLOCK}\n\n${OPEN_THREAD_BLOCK}\n\n${RELATIONSHIP_REPAIR_BLOCK}`;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
module.exports = {
|
package/blun.mjs
CHANGED
|
@@ -515372,14 +515372,64 @@ function notifyRunningRuntimeReady(tui) {
|
|
|
515372
515372
|
} catch {}
|
|
515373
515373
|
}
|
|
515374
515374
|
function requestRunningUpdateAtSafeBoundary(tui) {
|
|
515375
|
-
return false;
|
|
515375
|
+
if (tui.runningUpdateHandoffStarted || tui.isShuttingDown || !process.connected) return false;
|
|
515376
|
+
const version = tui.runningUpdatePreparedVersion;
|
|
515377
|
+
const mode = tui.runningUpdatePreparedMode;
|
|
515378
|
+
const sessionId = tui.getCurrentSessionId();
|
|
515379
|
+
const cwd = tui.state.appState.workDir;
|
|
515380
|
+
if (typeof version !== "string" || mode !== RUNNING_UPDATE_MODES.RESUME && mode !== RUNNING_UPDATE_MODES.NEW || sessionId.length === 0) return false;
|
|
515381
|
+
if (!isSafeRuntimeBoundary({
|
|
515382
|
+
isShuttingDown: tui.isShuttingDown,
|
|
515383
|
+
streamingPhase: tui.state.appState.streamingPhase,
|
|
515384
|
+
isCompacting: tui.state.appState.isCompacting,
|
|
515385
|
+
queuedMessages: tui.state.queuedMessages.length,
|
|
515386
|
+
activeToolCalls: tui.streamingUI.hasActiveToolCalls() ? 1 : 0,
|
|
515387
|
+
shellCommands: tui.shellOutputStreams.size,
|
|
515388
|
+
queueCommandRunning: tui.queueCommandRunning
|
|
515389
|
+
})) return false;
|
|
515390
|
+
tui.runningUpdateHandoffStarted = true;
|
|
515391
|
+
tui.showStatus(`Update ${version} ist bereit. Die sichere Update-Pause beginnt jetzt.`, "success");
|
|
515392
|
+
try {
|
|
515393
|
+
process.send({
|
|
515394
|
+
type: RUNNING_UPDATE_HANDOFF_MESSAGE,
|
|
515395
|
+
version,
|
|
515396
|
+
mode,
|
|
515397
|
+
sessionId,
|
|
515398
|
+
cwd
|
|
515399
|
+
}, (error) => {
|
|
515400
|
+
if (!error) return;
|
|
515401
|
+
tui.runningUpdateHandoffStarted = false;
|
|
515402
|
+
tui.showStatus("Das Update bleibt bereit und wird an der naechsten sicheren Grenze erneut versucht.", "warning");
|
|
515403
|
+
});
|
|
515404
|
+
return true;
|
|
515405
|
+
} catch {
|
|
515406
|
+
tui.runningUpdateHandoffStarted = false;
|
|
515407
|
+
return false;
|
|
515408
|
+
}
|
|
515376
515409
|
}
|
|
515377
515410
|
function installRunningUpdateListener(tui) {
|
|
515378
515411
|
const handler = (message) => {
|
|
515379
|
-
if (message?.type
|
|
515380
|
-
|
|
515381
|
-
|
|
515382
|
-
|
|
515412
|
+
if (message?.type === RUNNING_UPDATE_PREPARED_MESSAGE && typeof message.version === "string" && (message.mode === RUNNING_UPDATE_MODES.RESUME || message.mode === RUNNING_UPDATE_MODES.NEW)) {
|
|
515413
|
+
tui.runningUpdatePreparedVersion = message.version;
|
|
515414
|
+
tui.runningUpdatePreparedMode = message.mode;
|
|
515415
|
+
if (!requestRunningUpdateAtSafeBoundary(tui)) tui.showStatus(`Update ${message.version} ist bereit und wartet auf die naechste sichere Arbeitsgrenze.`, "success");
|
|
515416
|
+
return;
|
|
515417
|
+
}
|
|
515418
|
+
if (message?.type !== RUNNING_UPDATE_HANDOFF_ACK_MESSAGE || tui.runningUpdateHandoffStarted !== true || message.version !== tui.runningUpdatePreparedVersion || message.mode !== tui.runningUpdatePreparedMode || message.sessionId !== tui.getCurrentSessionId()) return;
|
|
515419
|
+
if (!isSafeRuntimeBoundary({
|
|
515420
|
+
isShuttingDown: tui.isShuttingDown,
|
|
515421
|
+
streamingPhase: tui.state.appState.streamingPhase,
|
|
515422
|
+
isCompacting: tui.state.appState.isCompacting,
|
|
515423
|
+
queuedMessages: tui.state.queuedMessages.length,
|
|
515424
|
+
activeToolCalls: tui.streamingUI.hasActiveToolCalls() ? 1 : 0,
|
|
515425
|
+
shellCommands: tui.shellOutputStreams.size,
|
|
515426
|
+
queueCommandRunning: tui.queueCommandRunning
|
|
515427
|
+
})) {
|
|
515428
|
+
tui.runningUpdateHandoffStarted = false;
|
|
515429
|
+
return;
|
|
515430
|
+
}
|
|
515431
|
+
tui.showStatus(`Update ${message.version} wird aktiviert. Die Sitzung wird automatisch fortgesetzt.`, "success");
|
|
515432
|
+
void tui.stop(RUNNING_UPDATE_HANDOFF_EXIT_CODE);
|
|
515383
515433
|
};
|
|
515384
515434
|
process.on("message", handler);
|
|
515385
515435
|
return () => process.off("message", handler);
|