blun-king-cli 9.1.72 → 9.1.74

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 CHANGED
@@ -502426,7 +502426,7 @@ var EditorKeyboardController = class {
502426
502426
  this.clearPendingExit();
502427
502427
  return;
502428
502428
  }
502429
- if (host.state.appState.streamingPhase !== "idle") {
502429
+ if (host.streamingUI.hasActiveTurn() || host.state.appState.streamingPhase !== "idle") {
502430
502430
  this.clearPendingExit();
502431
502431
  this.cancelCurrentStream();
502432
502432
  return;
@@ -502475,7 +502475,7 @@ var EditorKeyboardController = class {
502475
502475
  this.clearPendingUndoEsc();
502476
502476
  return;
502477
502477
  }
502478
- if (host.state.appState.streamingPhase !== "idle") {
502478
+ if (host.streamingUI.hasActiveTurn() || host.state.appState.streamingPhase !== "idle") {
502479
502479
  this.cancelCurrentStream();
502480
502480
  this.clearPendingUndoEsc();
502481
502481
  return;
@@ -502526,7 +502526,7 @@ var EditorKeyboardController = class {
502526
502526
  host.toggleTodoPanelExpansion();
502527
502527
  return;
502528
502528
  }
502529
- if (host.state.appState.streamingPhase === "idle") return;
502529
+ if (!host.streamingUI.hasActiveTurn() && host.state.appState.streamingPhase === "idle") return;
502530
502530
  host.flushQueuedMessages(editor.getText().trim(), editor.inputMode);
502531
502531
  host.updateQueueDisplay();
502532
502532
  host.state.ui.requestRender();
@@ -514511,7 +514511,7 @@ var BlunTUI = class {
514511
514511
  this.channelQueueDeadline.requestDeliveryAtSafePoint();
514512
514512
  }
514513
514513
  canDrainQueue() {
514514
- return !this.isShuttingDown && !this.queueCommandRunning && this.queueSteerInFlight === void 0 && !this.editorReplacementActive && !this.deferUserMessages && this.state.appState.streamingPhase === "idle" && !this.state.appState.isCompacting;
514514
+ return !this.isShuttingDown && !this.queueCommandRunning && this.queueSteerInFlight === void 0 && !this.editorReplacementActive && !this.deferUserMessages && !this.streamingUI.hasActiveTurn() && this.state.appState.streamingPhase === "idle" && !this.state.appState.isCompacting;
514515
514515
  }
514516
514516
  scheduleQueueDrain() {
514517
514517
  if (this.queueDrainTimer !== void 0 || !this.canDrainQueue()) return;
@@ -514640,7 +514640,7 @@ var BlunTUI = class {
514640
514640
  }
514641
514641
  injectChannelEnvelope({
514642
514642
  canDeliver: () => this.session !== void 0 && this.state.appState.model.trim().length > 0,
514643
- isBusy: () => this.state.queuedMessages.length > 0 || this.queueSteerInFlight !== void 0 || this.deferUserMessages || this.state.appState.streamingPhase !== "idle" || this.state.appState.isCompacting,
514643
+ isBusy: () => this.state.queuedMessages.length > 0 || this.queueSteerInFlight !== void 0 || this.deferUserMessages || this.streamingUI.hasActiveTurn() || this.state.appState.streamingPhase !== "idle" || this.state.appState.isCompacting,
514644
514644
  deliverNow: (modelInput, displayText, origin, contextOnly) => {
514645
514645
  this.sendChannelMessageInternal(this.requireSession(), modelInput, displayText, origin, envelope.meta.chat_id, envelope.meta["image_path"], contextOnly, false, acknowledge);
514646
514646
  },
@@ -514694,7 +514694,7 @@ var BlunTUI = class {
514694
514694
  channelAcknowledge: acknowledge,
514695
514695
  telegramCommandName: command.name
514696
514696
  };
514697
- const busy = this.state.queuedMessages.length > 0 || this.queueSteerInFlight !== void 0 || this.pendingChannelReplyGuard !== void 0 || this.deferUserMessages || this.state.appState.streamingPhase !== "idle" || this.state.appState.isCompacting;
514697
+ const busy = this.state.queuedMessages.length > 0 || this.queueSteerInFlight !== void 0 || this.pendingChannelReplyGuard !== void 0 || this.deferUserMessages || this.streamingUI.hasActiveTurn() || this.state.appState.streamingPhase !== "idle" || this.state.appState.isCompacting;
514698
514698
  if (busy) {
514699
514699
  this.state.queuedMessages.push(item);
514700
514700
  this.track("input_queue", { kind: "channel-command" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.72",
3
+ "version": "9.1.74",
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": {
@@ -9744,26 +9744,38 @@ const TOOL_DEFINITIONS = [
9744
9744
  }
9745
9745
  }
9746
9746
  ];
9747
+ function resolveAllowedChatId(chatId) {
9748
+ const access = readAccess();
9749
+ const requested = String(chatId).trim();
9750
+ const isAllowed = (candidate) => access.allowFrom.includes(candidate) || Object.hasOwn(access.groups, candidate);
9751
+ if (isAllowed(requested)) return requested;
9752
+ if (/^100\d+$/.test(requested)) {
9753
+ const supergroupId = `-${requested}`;
9754
+ if (isAllowed(supergroupId)) return supergroupId;
9755
+ }
9756
+ throw new Error(`chat ${requested} is not allowlisted — add via /telegram:access`);
9757
+ }
9747
9758
  async function runTool(api, token, name, args) {
9748
9759
  switch (name) {
9749
9760
  case "reply": return runReply(api, args);
9750
- case "react":
9751
- assertAllowedChat(args.chat_id);
9752
- await api.setMessageReaction(args.chat_id, Number(args.message_id), [{
9761
+ case "react": {
9762
+ const chatId = resolveAllowedChatId(args.chat_id);
9763
+ await api.setMessageReaction(chatId, Number(args.message_id), [{
9753
9764
  type: "emoji",
9754
9765
  emoji: args.emoji
9755
9766
  }]);
9756
9767
  return "reacted";
9768
+ }
9757
9769
  case "download_attachment": return runDownload(api, token, args.file_id);
9758
9770
  case "edit_message": {
9759
- assertAllowedChat(args.chat_id);
9771
+ const chatId = resolveAllowedChatId(args.chat_id);
9760
9772
  const parseMode = args.format === "markdownv2" ? "MarkdownV2" : void 0;
9761
- const edited = await api.editMessageText(args.chat_id, Number(args.message_id), args.text, parseMode !== void 0 ? { parse_mode: parseMode } : void 0);
9773
+ const edited = await api.editMessageText(chatId, Number(args.message_id), args.text, parseMode !== void 0 ? { parse_mode: parseMode } : void 0);
9762
9774
  const id = typeof edited === "object" ? edited.message_id : args.message_id;
9763
9775
  appendJsonl(outboxLog(), {
9764
9776
  direction: "out",
9765
9777
  kind: "edit",
9766
- chat_id: args.chat_id,
9778
+ chat_id: chatId,
9767
9779
  message_id: id,
9768
9780
  text: args.text
9769
9781
  });
@@ -9803,12 +9815,11 @@ function isRecentDuplicate(chatId, text) {
9803
9815
  return false;
9804
9816
  }
9805
9817
  async function runReply(api, args) {
9806
- const chatId = args.chat_id;
9818
+ const chatId = resolveAllowedChatId(args.chat_id);
9807
9819
  const text = args.text;
9808
9820
  const replyTo = args.reply_to != null ? Number(args.reply_to) : void 0;
9809
9821
  const files = args.files ?? [];
9810
9822
  const parseMode = args.format === "markdownv2" ? "MarkdownV2" : void 0;
9811
- assertAllowedChat(chatId);
9812
9823
  if (files.length === 0 && isGroupChat(chatId) && isGroupNoiseReply(text)) {
9813
9824
  appendJsonl(outboxLog(), {
9814
9825
  direction: "out",