blun-king-cli 9.1.349 → 9.1.351

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 +64 -2
  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
@@ -494027,6 +494030,11 @@ var ToolCallComponent = class ToolCallComponent extends Container {
494027
494030
  this.subToolDeltaRenderTimer = void 0;
494028
494031
  }
494029
494032
  this.pendingSubToolDeltaIds.clear();
494033
+ if (this.subToolLiveOutputRenderTimer !== void 0) {
494034
+ clearTimeout(this.subToolLiveOutputRenderTimer);
494035
+ this.subToolLiveOutputRenderTimer = void 0;
494036
+ }
494037
+ this.pendingSubToolLiveOutputIds.clear();
494030
494038
  if (this.liveOutputRenderTimer !== void 0) {
494031
494039
  clearTimeout(this.liveOutputRenderTimer);
494032
494040
  this.liveOutputRenderTimer = void 0;
@@ -494514,12 +494522,38 @@ var ToolCallComponent = class ToolCallComponent extends Container {
494514
494522
  let output = (activity?.output ?? "") + text;
494515
494523
  if (output.length > MAX_LIVE_OUTPUT_CHARS) output = `${uiText("toolCall.output.truncated")}\n${output.slice(output.length - MAX_LIVE_OUTPUT_CHARS)}`;
494516
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();
494517
494550
  this.rebuildContent();
494518
494551
  this.notifySnapshotChange();
494519
494552
  this.ui?.requestRender();
494520
494553
  }
494521
494554
  finishSubToolCall(result) {
494522
494555
  this.applyPendingSubToolDelta(result.tool_call_id);
494556
+ this.clearPendingSubToolLiveOutput(result.tool_call_id);
494523
494557
  const ongoing = this.ongoingSubCalls.get(result.tool_call_id);
494524
494558
  if (ongoing === void 0) return;
494525
494559
  this.ongoingSubCalls.delete(result.tool_call_id);
@@ -502854,6 +502888,8 @@ var BtwPanelComponent = class {
502854
502888
  maxScrollTop = 0;
502855
502889
  spinnerFrame = 0;
502856
502890
  liveStatusTimer;
502891
+ streamingRenderTimer;
502892
+ lastStreamingFlushAt;
502857
502893
  constructor(options) {
502858
502894
  this.options = options;
502859
502895
  }
@@ -502881,13 +502917,38 @@ var BtwPanelComponent = class {
502881
502917
  const turn = this.currentTurn();
502882
502918
  if (turn === void 0) return;
502883
502919
  turn.answer += delta;
502920
+ this.scheduleStreamingRender();
502884
502921
  }
502885
502922
  appendThinking(delta) {
502886
502923
  const turn = this.currentTurn();
502887
502924
  if (turn === void 0) return;
502888
502925
  turn.thinking += delta;
502926
+ this.scheduleStreamingRender();
502927
+ }
502928
+ scheduleStreamingRender() {
502929
+ if (this.streamingRenderTimer !== void 0) return;
502930
+ const turn = this.currentTurn();
502931
+ const interval = resolveStreamingFlushInterval({
502932
+ assistantChars: turn?.answer.length ?? 0,
502933
+ thinkingChars: turn?.thinking.length ?? 0
502934
+ });
502935
+ const delay = this.lastStreamingFlushAt === void 0 ? 0 : Math.max(0, interval - (Date.now() - this.lastStreamingFlushAt));
502936
+ this.streamingRenderTimer = setTimeout(() => {
502937
+ this.streamingRenderTimer = void 0;
502938
+ this.flushPendingStreamingRender();
502939
+ }, delay);
502940
+ }
502941
+ flushPendingStreamingRender() {
502942
+ this.lastStreamingFlushAt = Date.now();
502943
+ this.options.requestRender();
502944
+ }
502945
+ clearStreamingRenderTimer() {
502946
+ if (this.streamingRenderTimer === void 0) return;
502947
+ clearTimeout(this.streamingRenderTimer);
502948
+ this.streamingRenderTimer = void 0;
502889
502949
  }
502890
502950
  restartCurrentTurn(notice) {
502951
+ this.clearStreamingRenderTimer();
502891
502952
  const turn = this.currentTurn();
502892
502953
  if (turn === void 0 || turn.phase !== "running") return;
502893
502954
  turn.startedAtMs = Date.now();
@@ -502898,6 +502959,7 @@ var BtwPanelComponent = class {
502898
502959
  this.transientNotices.push(notice);
502899
502960
  }
502900
502961
  markDone(resultSummary) {
502962
+ this.clearStreamingRenderTimer();
502901
502963
  const turn = this.currentTurn();
502902
502964
  if (turn === void 0) return;
502903
502965
  if (turn.answer.trim().length === 0 && resultSummary !== void 0) turn.answer = resultSummary;
@@ -502906,6 +502968,7 @@ var BtwPanelComponent = class {
502906
502968
  this.stopLiveStatusTimer();
502907
502969
  }
502908
502970
  markFailed(error) {
502971
+ this.clearStreamingRenderTimer();
502909
502972
  const turn = this.currentTurn();
502910
502973
  if (turn === void 0 || turn.phase !== "running") {
502911
502974
  this.turns.push({
@@ -502927,6 +502990,7 @@ var BtwPanelComponent = class {
502927
502990
  }
502928
502991
  invalidate() {}
502929
502992
  dispose() {
502993
+ this.clearStreamingRenderTimer();
502930
502994
  this.stopLiveStatusTimer();
502931
502995
  }
502932
502996
  render(width) {
@@ -503184,12 +503248,10 @@ var BtwPanelController = class {
503184
503248
  case "assistant.delta":
503185
503249
  this.clearInactivityTimer(this.activeForAgent(event.agentId));
503186
503250
  panel.appendAnswer(event.delta);
503187
- this.host.state.ui.requestRender();
503188
503251
  return true;
503189
503252
  case "thinking.delta":
503190
503253
  panel.appendThinking(event.delta);
503191
503254
  this.armInactivityTimer(this.activeForAgent(event.agentId));
503192
- this.host.state.ui.requestRender();
503193
503255
  return true;
503194
503256
  case "hook.result":
503195
503257
  this.clearInactivityTimer(this.activeForAgent(event.agentId));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.349",
3
+ "version": "9.1.351",
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": {