blun-king-cli 9.1.348 → 9.1.350

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.
Files changed (2) hide show
  1. package/blun.mjs +60 -0
  2. package/package.json +1 -1
package/blun.mjs CHANGED
@@ -493833,6 +493833,9 @@ var ToolCallComponent = class ToolCallComponent extends Container {
493833
493833
  pendingSubToolDeltaIds = /* @__PURE__ */ new Set();
493834
493834
  subToolDeltaRenderTimer;
493835
493835
  lastSubToolDeltaFlushAt;
493836
+ pendingSubToolLiveOutputIds = /* @__PURE__ */ new Set();
493837
+ subToolLiveOutputRenderTimer;
493838
+ lastSubToolLiveOutputFlushAt;
493836
493839
  hiddenSubCallCount = 0;
493837
493840
  /**
493838
493841
  * Recent normal-output lines from the child agent. Historical replay can also
@@ -493840,6 +493843,8 @@ var ToolCallComponent = class ToolCallComponent extends Container {
493840
493843
  */
493841
493844
  subagentText = "";
493842
493845
  subagentThinkingText = "";
493846
+ subagentTextRenderTimer;
493847
+ lastSubagentTextFlushAt;
493843
493848
  /** Tracks whether the child agent's latest streamed delta was text or thinking,
493844
493849
  * so the active window can follow whichever is currently live. */
493845
493850
  lastSubagentStreamKind = "text";
@@ -494019,11 +494024,17 @@ var ToolCallComponent = class ToolCallComponent extends Container {
494019
494024
  this.stopStreamingProgressTimer();
494020
494025
  this.stopSubagentElapsedTimer();
494021
494026
  this.stopDetachHintTimer();
494027
+ this.clearSubagentTextFlushTimer();
494022
494028
  if (this.subToolDeltaRenderTimer !== void 0) {
494023
494029
  clearTimeout(this.subToolDeltaRenderTimer);
494024
494030
  this.subToolDeltaRenderTimer = void 0;
494025
494031
  }
494026
494032
  this.pendingSubToolDeltaIds.clear();
494033
+ if (this.subToolLiveOutputRenderTimer !== void 0) {
494034
+ clearTimeout(this.subToolLiveOutputRenderTimer);
494035
+ this.subToolLiveOutputRenderTimer = void 0;
494036
+ }
494037
+ this.pendingSubToolLiveOutputIds.clear();
494027
494038
  if (this.liveOutputRenderTimer !== void 0) {
494028
494039
  clearTimeout(this.liveOutputRenderTimer);
494029
494040
  this.liveOutputRenderTimer = void 0;
@@ -494296,6 +494307,7 @@ var ToolCallComponent = class ToolCallComponent extends Container {
494296
494307
  * token usage plus the result summary for the header chip and tail summary.
494297
494308
  */
494298
494309
  onSubagentCompleted(payload) {
494310
+ this.clearSubagentTextFlushTimer();
494299
494311
  this.subagentPhase = "done";
494300
494312
  this.subagentEndedAtMs ??= Date.now();
494301
494313
  if (payload.contextTokens !== void 0 && payload.contextTokens > 0) this.subagentContextTokens = payload.contextTokens;
@@ -494319,6 +494331,7 @@ var ToolCallComponent = class ToolCallComponent extends Container {
494319
494331
  }
494320
494332
  /** Handles SDK `subagent.failed`. */
494321
494333
  onSubagentFailed(payload) {
494334
+ this.clearSubagentTextFlushTimer();
494322
494335
  this.subagentPhase = "failed";
494323
494336
  this.subagentEndedAtMs ??= Date.now();
494324
494337
  this.subagentError = payload.error;
@@ -494414,11 +494427,32 @@ var ToolCallComponent = class ToolCallComponent extends Container {
494414
494427
  if (kind === "thinking") this.subagentThinkingText += text;
494415
494428
  else this.subagentText += text;
494416
494429
  if (this.subagentPhase === void 0 || this.subagentPhase === "queued" || this.subagentPhase === "spawning") this.subagentPhase = "running";
494430
+ this.scheduleSubagentTextFlush();
494431
+ }
494432
+ scheduleSubagentTextFlush() {
494433
+ if (this.subagentTextRenderTimer !== void 0) return;
494434
+ const interval = resolveStreamingFlushInterval({
494435
+ assistantChars: this.subagentText.length,
494436
+ thinkingChars: this.subagentThinkingText.length
494437
+ });
494438
+ const delay = this.lastSubagentTextFlushAt === void 0 ? 0 : Math.max(0, interval - (Date.now() - this.lastSubagentTextFlushAt));
494439
+ this.subagentTextRenderTimer = setTimeout(() => {
494440
+ this.subagentTextRenderTimer = void 0;
494441
+ this.flushPendingSubagentText();
494442
+ }, delay);
494443
+ }
494444
+ flushPendingSubagentText() {
494445
+ this.lastSubagentTextFlushAt = Date.now();
494417
494446
  this.headerText.setText(this.buildHeader());
494418
494447
  this.rebuildContent();
494419
494448
  this.notifySnapshotChange();
494420
494449
  this.ui?.requestRender();
494421
494450
  }
494451
+ clearSubagentTextFlushTimer() {
494452
+ if (this.subagentTextRenderTimer === void 0) return;
494453
+ clearTimeout(this.subagentTextRenderTimer);
494454
+ this.subagentTextRenderTimer = void 0;
494455
+ }
494422
494456
  appendSubToolCall(call) {
494423
494457
  const existing = this.ongoingSubCalls.get(call.id);
494424
494458
  this.ongoingSubCalls.set(call.id, {
@@ -494488,12 +494522,38 @@ var ToolCallComponent = class ToolCallComponent extends Container {
494488
494522
  let output = (activity?.output ?? "") + text;
494489
494523
  if (output.length > MAX_LIVE_OUTPUT_CHARS) output = `${uiText("toolCall.output.truncated")}\n${output.slice(output.length - MAX_LIVE_OUTPUT_CHARS)}`;
494490
494524
  this.upsertSubToolActivity(id, name, args, activity?.phase ?? "ongoing", output);
494525
+ this.pendingSubToolLiveOutputIds.add(id);
494526
+ this.scheduleSubToolLiveOutputFlush();
494527
+ }
494528
+ scheduleSubToolLiveOutputFlush() {
494529
+ if (this.subToolLiveOutputRenderTimer !== void 0) return;
494530
+ let chars = 0;
494531
+ for (const id of this.pendingSubToolLiveOutputIds) chars += this.subToolActivities.get(id)?.output?.length ?? 0;
494532
+ const interval = resolveStreamingFlushInterval({ toolCallChars: chars });
494533
+ const delay = this.lastSubToolLiveOutputFlushAt === void 0 ? 0 : Math.max(0, interval - (Date.now() - this.lastSubToolLiveOutputFlushAt));
494534
+ this.subToolLiveOutputRenderTimer = setTimeout(() => {
494535
+ this.subToolLiveOutputRenderTimer = void 0;
494536
+ this.flushPendingSubToolLiveOutputs();
494537
+ }, delay);
494538
+ }
494539
+ clearPendingSubToolLiveOutput(id) {
494540
+ if (!this.pendingSubToolLiveOutputIds.delete(id)) return;
494541
+ if (this.pendingSubToolLiveOutputIds.size === 0 && this.subToolLiveOutputRenderTimer !== void 0) {
494542
+ clearTimeout(this.subToolLiveOutputRenderTimer);
494543
+ this.subToolLiveOutputRenderTimer = void 0;
494544
+ }
494545
+ }
494546
+ flushPendingSubToolLiveOutputs() {
494547
+ if (this.pendingSubToolLiveOutputIds.size === 0) return;
494548
+ this.pendingSubToolLiveOutputIds.clear();
494549
+ this.lastSubToolLiveOutputFlushAt = Date.now();
494491
494550
  this.rebuildContent();
494492
494551
  this.notifySnapshotChange();
494493
494552
  this.ui?.requestRender();
494494
494553
  }
494495
494554
  finishSubToolCall(result) {
494496
494555
  this.applyPendingSubToolDelta(result.tool_call_id);
494556
+ this.clearPendingSubToolLiveOutput(result.tool_call_id);
494497
494557
  const ongoing = this.ongoingSubCalls.get(result.tool_call_id);
494498
494558
  if (ongoing === void 0) return;
494499
494559
  this.ongoingSubCalls.delete(result.tool_call_id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.348",
3
+ "version": "9.1.350",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {