blun-king-cli 9.1.633 → 9.1.635
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/blun.mjs +37 -17
- package/package.json +1 -1
package/blun.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// BLUN_BUILD_INPUT_SHA256:
|
|
2
|
+
// BLUN_BUILD_INPUT_SHA256:efe2db101f5ddf60971c8504d9cd59f86444a9b24bae53a5d1e1032307d4171a
|
|
3
3
|
/*! wasm-webp 0.1.0
|
|
4
4
|
MIT License
|
|
5
5
|
|
|
@@ -513542,6 +513542,7 @@ var init_compaction = __esmMin((() => {
|
|
|
513542
513542
|
}
|
|
513543
513543
|
if (this.failed) return `${currentTheme.fg("error", STATUS_BULLET)}${currentTheme.boldFg("error", this.failureTitle ?? uiText("compaction.failed"))}${currentTheme.fg("textDim", ` · ${this.failureDetail ?? uiText("compaction.failureDetail")}`)}`;
|
|
513544
513544
|
if (this.canceled) return `${currentTheme.fg("warning", STATUS_BULLET)}${currentTheme.boldFg("warning", uiText("compaction.canceled"))}`;
|
|
513545
|
+
if (process.env["BLUN_REDUCED_MOTION"] === "1" || process.env["BLUN_REDUCED_MOTION"] === "true") return `${currentTheme.fg("primary", STATUS_BULLET)}${currentTheme.boldFg("primary", uiText("compaction.running"))}${currentTheme.fg("textDim", ` · ${uiText("compaction.cancelHint")}`)}`;
|
|
513545
513546
|
const elapsedMs = Math.max(0, Date.now() - this.attemptStartedAtMs);
|
|
513546
513547
|
const percent = this.estimatedProgressPercent ?? estimateCompactionPercent(elapsedMs, this.estimatedInputTokens);
|
|
513547
513548
|
const filled = Math.round(percent / 100 * BAR_WIDTH);
|
|
@@ -513559,6 +513560,7 @@ var init_compaction = __esmMin((() => {
|
|
|
513559
513560
|
return `${currentTheme.fg("primary", bar)} ${currentTheme.boldFg("primary", runningText)}${this.windowUsagePercent === void 0 ? currentTheme.fg("textDim", ` ~${String(percent)} %`) : ""}${currentTheme.fg("textDim", ` · ${String(this.elapsedSeconds())}s`)}${this.attempt > 1 ? currentTheme.fg("textDim", uiText("compaction.attempt", { attempt: this.attempt })) : ""}${currentTheme.fg("textDim", ` · ${uiText("compaction.cancelHint")}`)}${this.instruction ? currentTheme.fg("textDim", ` · ${this.instruction}`) : ""}${this.tip ? currentTheme.fg("textDim", ` · ${this.tip}`) : ""}`;
|
|
513560
513561
|
}
|
|
513561
513562
|
startTicking() {
|
|
513563
|
+
if (process.env["BLUN_REDUCED_MOTION"] === "1" || process.env["BLUN_REDUCED_MOTION"] === "true") return;
|
|
513562
513564
|
this.timer = setInterval(() => {
|
|
513563
513565
|
this.statusText.setText(this.buildStatusLine());
|
|
513564
513566
|
this.ui?.requestRender();
|
|
@@ -515932,7 +515934,11 @@ var init_strip_control_tokens = __esmMin((() => {
|
|
|
515932
515934
|
/** Remove model-only envelopes before assistant text reaches a transcript renderer. */
|
|
515933
515935
|
function sanitizeAssistantDisplayText(text, options = {}) {
|
|
515934
515936
|
const transient = options.transient === true;
|
|
515935
|
-
|
|
515937
|
+
const displayText = stripIncompleteInternalSuffix(stripControlTokens(stripDsmlBlocks(stripSystemReminderBlocks(stripEchoedRuntimeInstructions(text), transient))), transient);
|
|
515938
|
+
const sentinel = "[[BLUN_TELEGRAM_SILENT]]";
|
|
515939
|
+
const candidate = displayText.trim();
|
|
515940
|
+
if (candidate === sentinel || transient && candidate.length > 0 && sentinel.startsWith(candidate)) return "";
|
|
515941
|
+
return displayText;
|
|
515936
515942
|
}
|
|
515937
515943
|
function stripEchoedRuntimeInstructions(text) {
|
|
515938
515944
|
let cursor = 0;
|
|
@@ -533513,9 +533519,12 @@ var init_message_replay_copy = __esmMin((() => {
|
|
|
533513
533519
|
}));
|
|
533514
533520
|
function appStateFromResumeAgent(agent) {
|
|
533515
533521
|
const maxContextTokens = agent.context.effectiveMaxContextTokens ?? agent.config.modelCapabilities?.max_context_tokens ?? 0;
|
|
533516
|
-
const
|
|
533522
|
+
const projectedTokens = agent.context.projectedTokenCount;
|
|
533523
|
+
const contextMetricsKnown = projectedTokens !== void 0 && Number.isFinite(projectedTokens) && projectedTokens >= 0;
|
|
533524
|
+
const contextTokens = contextMetricsKnown ? projectedTokens : 0;
|
|
533517
533525
|
const contextUsage = maxContextTokens > 0 ? contextTokens / maxContextTokens : 0;
|
|
533518
533526
|
return {
|
|
533527
|
+
contextMetricsKnown,
|
|
533519
533528
|
model: agent.config.modelAlias ?? agent.config.provider?.model ?? "",
|
|
533520
533529
|
contextTokens,
|
|
533521
533530
|
maxContextTokens,
|
|
@@ -535778,7 +535787,10 @@ var init_session_event_handler = __esmMin((() => {
|
|
|
535778
535787
|
const shouldRenderSwarmEnded = event.swarmMode === false && this.host.state.appState.swarmMode && this.host.state.appState.swarmModeEntry === "task";
|
|
535779
535788
|
const patch = {};
|
|
535780
535789
|
if (event.contextUsage !== void 0) patch.contextUsage = event.contextUsage;
|
|
535781
|
-
if (event.contextTokens !== void 0
|
|
535790
|
+
if (event.contextTokens !== void 0 && Number.isFinite(event.contextTokens) && event.contextTokens >= 0) {
|
|
535791
|
+
patch.contextTokens = event.contextTokens;
|
|
535792
|
+
patch.contextMetricsKnown = true;
|
|
535793
|
+
}
|
|
535782
535794
|
if (event.maxContextTokens !== void 0) patch.maxContextTokens = event.maxContextTokens;
|
|
535783
535795
|
patch.compactionBudgetTokens = event.compactionBudgetTokens ?? 0;
|
|
535784
535796
|
if (event.planMode !== void 0) patch.planMode = event.planMode;
|
|
@@ -536190,9 +536202,18 @@ var init_session_event_handler = __esmMin((() => {
|
|
|
536190
536202
|
this.host.streamingUI.beginCompaction(event.instruction);
|
|
536191
536203
|
}
|
|
536192
536204
|
handleCompactionEnd(event) {
|
|
536205
|
+
if (!this.host.state.appState.isCompacting) return;
|
|
536193
536206
|
this.pendingCompactionRetry = void 0;
|
|
536194
536207
|
this.hideCompactionRetry();
|
|
536195
|
-
|
|
536208
|
+
const tokens = event.projectedContextTokens;
|
|
536209
|
+
if (tokens !== void 0 && Number.isFinite(tokens) && tokens >= 0) {
|
|
536210
|
+
const maxTokens = this.host.state.appState.maxContextTokens;
|
|
536211
|
+
this.host.setAppState({
|
|
536212
|
+
contextTokens: tokens,
|
|
536213
|
+
contextUsage: Number.isFinite(maxTokens) && maxTokens > 0 ? Math.min(1, tokens / maxTokens) : void 0,
|
|
536214
|
+
contextMetricsKnown: true
|
|
536215
|
+
});
|
|
536216
|
+
} else this.host.setAppState({ contextMetricsKnown: false });
|
|
536196
536217
|
this.host.streamingUI.endCompaction(event.result.tokensBefore, event.result.tokensAfter, event.stageCount);
|
|
536197
536218
|
this.lastCompactionInstruction = void 0;
|
|
536198
536219
|
this.finishCompaction();
|
|
@@ -537162,7 +537183,8 @@ function clockHhmm(now) {
|
|
|
537162
537183
|
return `${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}`;
|
|
537163
537184
|
}
|
|
537164
537185
|
function formatContextStatus(usage, tokens, maxTokens, colors, width, now = /* @__PURE__ */ new Date()) {
|
|
537165
|
-
|
|
537186
|
+
if (tokens === void 0 || !Number.isFinite(tokens)) return truncateToWidth(`${uiText("footer.context")} ${uiText("context.unavailable")}`, Math.max(0, width), "…");
|
|
537187
|
+
const ratio = safeUsage(usage ?? 0);
|
|
537166
537188
|
const pct = `${(ratio * 100).toFixed(0)}%`;
|
|
537167
537189
|
const bar = `${renderContextBar(ratio, colors)} `;
|
|
537168
537190
|
const clock = chalk.hex(colors.textDim)(` · ${clockHhmm(now)}`);
|
|
@@ -537187,15 +537209,13 @@ function formatContextStatus(usage, tokens, maxTokens, colors, width, now = /* @
|
|
|
537187
537209
|
for (const variant of variants) if (visibleWidth(variant) <= available) return variant;
|
|
537188
537210
|
return truncateToWidth(current, available, "…");
|
|
537189
537211
|
}
|
|
537190
|
-
|
|
537191
|
-
const filled = Math.max(1, Math.ceil(CONTEXT_BAR_WIDTH * (1 - percent / 100)));
|
|
537192
|
-
const bar = chalk.hex(colors.success ?? colors.primary)("█".repeat(filled) + "░".repeat(CONTEXT_BAR_WIDTH - filled));
|
|
537193
|
-
const variants = [`${bar}${chalk.hex(colors.textDim)(` · ${clockHhmm(now)}`)}`, bar];
|
|
537194
|
-
const available = Math.max(0, width);
|
|
537195
|
-
for (const variant of variants) if (visibleWidth(variant) <= available) return variant;
|
|
537196
|
-
return truncateToWidth(bar, available, "");
|
|
537197
|
-
}
|
|
537212
|
+
|
|
537198
537213
|
function contextMetrics(state) {
|
|
537214
|
+
if (state.contextMetricsKnown === false) return {
|
|
537215
|
+
tokens: void 0,
|
|
537216
|
+
maxTokens: state.maxContextTokens,
|
|
537217
|
+
usage: void 0
|
|
537218
|
+
};
|
|
537199
537219
|
const tokens = Number.isFinite(state.contextTokens) ? Math.max(0, state.contextTokens) : 0;
|
|
537200
537220
|
const responderAlias = state.activeResponderModel ?? state.model;
|
|
537201
537221
|
const responder = state.availableModels[responderAlias];
|
|
@@ -537512,7 +537532,7 @@ var init_footer = __esmMin((() => {
|
|
|
537512
537532
|
const estimate = this.compactionProgress?.estimatedProgressPercent ?? estimateCompactionPercent(Math.max(0, Date.now() - this.compactionAttemptStartedAtMs), this.compactionEstimatedInputTokens);
|
|
537513
537533
|
if (Number.isFinite(estimate)) this.compactionPercent = Math.max(this.compactionPercent, Math.min(97, estimate));
|
|
537514
537534
|
}
|
|
537515
|
-
const contextText =
|
|
537535
|
+
const contextText = formatContextStatus(context.usage, context.tokens, context.maxTokens, colors, width);
|
|
537516
537536
|
const right = this.transientHint && this.compactionAttemptStartedAtMs === null ? chalk.hex(colors.warning).bold(this.transientHint) : chalk.hex(colors.text)(contextText);
|
|
537517
537537
|
const rightWidth = visibleWidth(right);
|
|
537518
537538
|
let line1;
|
|
@@ -538469,10 +538489,10 @@ var init_streaming_ui = __esmMin((() => {
|
|
|
538469
538489
|
const { state } = this.host;
|
|
538470
538490
|
this._cancelledCompactionBlock = void 0;
|
|
538471
538491
|
if (this._activeCompactionBlock !== void 0) {
|
|
538472
|
-
this._activeCompactionBlock.
|
|
538492
|
+
this._activeCompactionBlock.markCanceled();
|
|
538473
538493
|
this._activeCompactionBlock = void 0;
|
|
538474
538494
|
}
|
|
538475
|
-
const block = new CompactionComponent(state.ui, instruction, currentWorkingTip()?.text
|
|
538495
|
+
const block = new CompactionComponent(state.ui, instruction, currentWorkingTip()?.text);
|
|
538476
538496
|
this._activeCompactionBlock = block;
|
|
538477
538497
|
state.transcriptContainer.addChild(block);
|
|
538478
538498
|
state.ui.requestRender();
|