blun-king-cli 9.1.347 → 9.1.349
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 +67 -3
- package/package.json +1 -1
package/blun.mjs
CHANGED
|
@@ -493830,6 +493830,9 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
493830
493830
|
finishedSubCalls = [];
|
|
493831
493831
|
subToolActivities = /* @__PURE__ */ new Map();
|
|
493832
493832
|
subToolOrderSeq = 0;
|
|
493833
|
+
pendingSubToolDeltaIds = /* @__PURE__ */ new Set();
|
|
493834
|
+
subToolDeltaRenderTimer;
|
|
493835
|
+
lastSubToolDeltaFlushAt;
|
|
493833
493836
|
hiddenSubCallCount = 0;
|
|
493834
493837
|
/**
|
|
493835
493838
|
* Recent normal-output lines from the child agent. Historical replay can also
|
|
@@ -493837,6 +493840,8 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
493837
493840
|
*/
|
|
493838
493841
|
subagentText = "";
|
|
493839
493842
|
subagentThinkingText = "";
|
|
493843
|
+
subagentTextRenderTimer;
|
|
493844
|
+
lastSubagentTextFlushAt;
|
|
493840
493845
|
/** Tracks whether the child agent's latest streamed delta was text or thinking,
|
|
493841
493846
|
* so the active window can follow whichever is currently live. */
|
|
493842
493847
|
lastSubagentStreamKind = "text";
|
|
@@ -494016,6 +494021,12 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
494016
494021
|
this.stopStreamingProgressTimer();
|
|
494017
494022
|
this.stopSubagentElapsedTimer();
|
|
494018
494023
|
this.stopDetachHintTimer();
|
|
494024
|
+
this.clearSubagentTextFlushTimer();
|
|
494025
|
+
if (this.subToolDeltaRenderTimer !== void 0) {
|
|
494026
|
+
clearTimeout(this.subToolDeltaRenderTimer);
|
|
494027
|
+
this.subToolDeltaRenderTimer = void 0;
|
|
494028
|
+
}
|
|
494029
|
+
this.pendingSubToolDeltaIds.clear();
|
|
494019
494030
|
if (this.liveOutputRenderTimer !== void 0) {
|
|
494020
494031
|
clearTimeout(this.liveOutputRenderTimer);
|
|
494021
494032
|
this.liveOutputRenderTimer = void 0;
|
|
@@ -494288,6 +494299,7 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
494288
494299
|
* token usage plus the result summary for the header chip and tail summary.
|
|
494289
494300
|
*/
|
|
494290
494301
|
onSubagentCompleted(payload) {
|
|
494302
|
+
this.clearSubagentTextFlushTimer();
|
|
494291
494303
|
this.subagentPhase = "done";
|
|
494292
494304
|
this.subagentEndedAtMs ??= Date.now();
|
|
494293
494305
|
if (payload.contextTokens !== void 0 && payload.contextTokens > 0) this.subagentContextTokens = payload.contextTokens;
|
|
@@ -494311,6 +494323,7 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
494311
494323
|
}
|
|
494312
494324
|
/** Handles SDK `subagent.failed`. */
|
|
494313
494325
|
onSubagentFailed(payload) {
|
|
494326
|
+
this.clearSubagentTextFlushTimer();
|
|
494314
494327
|
this.subagentPhase = "failed";
|
|
494315
494328
|
this.subagentEndedAtMs ??= Date.now();
|
|
494316
494329
|
this.subagentError = payload.error;
|
|
@@ -494406,11 +494419,32 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
494406
494419
|
if (kind === "thinking") this.subagentThinkingText += text;
|
|
494407
494420
|
else this.subagentText += text;
|
|
494408
494421
|
if (this.subagentPhase === void 0 || this.subagentPhase === "queued" || this.subagentPhase === "spawning") this.subagentPhase = "running";
|
|
494422
|
+
this.scheduleSubagentTextFlush();
|
|
494423
|
+
}
|
|
494424
|
+
scheduleSubagentTextFlush() {
|
|
494425
|
+
if (this.subagentTextRenderTimer !== void 0) return;
|
|
494426
|
+
const interval = resolveStreamingFlushInterval({
|
|
494427
|
+
assistantChars: this.subagentText.length,
|
|
494428
|
+
thinkingChars: this.subagentThinkingText.length
|
|
494429
|
+
});
|
|
494430
|
+
const delay = this.lastSubagentTextFlushAt === void 0 ? 0 : Math.max(0, interval - (Date.now() - this.lastSubagentTextFlushAt));
|
|
494431
|
+
this.subagentTextRenderTimer = setTimeout(() => {
|
|
494432
|
+
this.subagentTextRenderTimer = void 0;
|
|
494433
|
+
this.flushPendingSubagentText();
|
|
494434
|
+
}, delay);
|
|
494435
|
+
}
|
|
494436
|
+
flushPendingSubagentText() {
|
|
494437
|
+
this.lastSubagentTextFlushAt = Date.now();
|
|
494409
494438
|
this.headerText.setText(this.buildHeader());
|
|
494410
494439
|
this.rebuildContent();
|
|
494411
494440
|
this.notifySnapshotChange();
|
|
494412
494441
|
this.ui?.requestRender();
|
|
494413
494442
|
}
|
|
494443
|
+
clearSubagentTextFlushTimer() {
|
|
494444
|
+
if (this.subagentTextRenderTimer === void 0) return;
|
|
494445
|
+
clearTimeout(this.subagentTextRenderTimer);
|
|
494446
|
+
this.subagentTextRenderTimer = void 0;
|
|
494447
|
+
}
|
|
494414
494448
|
appendSubToolCall(call) {
|
|
494415
494449
|
const existing = this.ongoingSubCalls.get(call.id);
|
|
494416
494450
|
this.ongoingSubCalls.set(call.id, {
|
|
@@ -494428,14 +494462,43 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
494428
494462
|
appendSubToolCallDelta(delta) {
|
|
494429
494463
|
const existing = this.ongoingSubCalls.get(delta.id);
|
|
494430
494464
|
const nextArgsText = appendStreamingArgsPreview(existing?.streamingArguments, delta.argumentsPart);
|
|
494431
|
-
const parsed = parseArgsPreview(nextArgsText);
|
|
494432
494465
|
this.ongoingSubCalls.set(delta.id, {
|
|
494433
494466
|
name: delta.name ?? existing?.name ?? "Tool",
|
|
494434
|
-
args:
|
|
494467
|
+
args: existing?.args ?? {},
|
|
494435
494468
|
streamingArguments: nextArgsText
|
|
494436
494469
|
});
|
|
494437
|
-
this.upsertSubToolActivity(delta.id, delta.name ?? existing?.name ?? "Tool", parsed, "ongoing");
|
|
494438
494470
|
if (this.subagentPhase === void 0 || this.subagentPhase === "queued" || this.subagentPhase === "spawning") this.subagentPhase = "running";
|
|
494471
|
+
this.pendingSubToolDeltaIds.add(delta.id);
|
|
494472
|
+
this.scheduleSubToolDeltaFlush();
|
|
494473
|
+
}
|
|
494474
|
+
scheduleSubToolDeltaFlush() {
|
|
494475
|
+
if (this.subToolDeltaRenderTimer !== void 0) return;
|
|
494476
|
+
let chars = 0;
|
|
494477
|
+
for (const id of this.pendingSubToolDeltaIds) chars += this.ongoingSubCalls.get(id)?.streamingArguments?.length ?? 0;
|
|
494478
|
+
const interval = resolveStreamingFlushInterval({ toolCallChars: chars });
|
|
494479
|
+
const delay = this.lastSubToolDeltaFlushAt === void 0 ? 0 : Math.max(0, interval - (Date.now() - this.lastSubToolDeltaFlushAt));
|
|
494480
|
+
this.subToolDeltaRenderTimer = setTimeout(() => {
|
|
494481
|
+
this.subToolDeltaRenderTimer = void 0;
|
|
494482
|
+
this.flushPendingSubToolDeltas();
|
|
494483
|
+
}, delay);
|
|
494484
|
+
}
|
|
494485
|
+
applyPendingSubToolDelta(id) {
|
|
494486
|
+
if (!this.pendingSubToolDeltaIds.delete(id)) return;
|
|
494487
|
+
const ongoing = this.ongoingSubCalls.get(id);
|
|
494488
|
+
if (ongoing === void 0 || ongoing.streamingArguments === void 0) return;
|
|
494489
|
+
const parsed = parseArgsPreview(ongoing.streamingArguments);
|
|
494490
|
+
ongoing.args = parsed;
|
|
494491
|
+
this.upsertSubToolActivity(id, ongoing.name, parsed, "ongoing");
|
|
494492
|
+
if (this.pendingSubToolDeltaIds.size === 0 && this.subToolDeltaRenderTimer !== void 0) {
|
|
494493
|
+
clearTimeout(this.subToolDeltaRenderTimer);
|
|
494494
|
+
this.subToolDeltaRenderTimer = void 0;
|
|
494495
|
+
}
|
|
494496
|
+
}
|
|
494497
|
+
flushPendingSubToolDeltas() {
|
|
494498
|
+
if (this.pendingSubToolDeltaIds.size === 0) return;
|
|
494499
|
+
const pending = [...this.pendingSubToolDeltaIds];
|
|
494500
|
+
this.lastSubToolDeltaFlushAt = Date.now();
|
|
494501
|
+
for (const id of pending) this.applyPendingSubToolDelta(id);
|
|
494439
494502
|
this.headerText.setText(this.buildHeader());
|
|
494440
494503
|
this.rebuildContent();
|
|
494441
494504
|
this.notifySnapshotChange();
|
|
@@ -494456,6 +494519,7 @@ var ToolCallComponent = class ToolCallComponent extends Container {
|
|
|
494456
494519
|
this.ui?.requestRender();
|
|
494457
494520
|
}
|
|
494458
494521
|
finishSubToolCall(result) {
|
|
494522
|
+
this.applyPendingSubToolDelta(result.tool_call_id);
|
|
494459
494523
|
const ongoing = this.ongoingSubCalls.get(result.tool_call_id);
|
|
494460
494524
|
if (ongoing === void 0) return;
|
|
494461
494525
|
this.ongoingSubCalls.delete(result.tool_call_id);
|