blun-king-cli 9.1.73 → 9.1.75

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
@@ -259910,17 +259910,23 @@ function blunMessageTextChars(message) {
259910
259910
  function blunFastConversationHistory(history) {
259911
259911
  const selected = [];
259912
259912
  let textChars = 0;
259913
+ let expectsAssistant = false;
259913
259914
  for (let index = history.length - 1; index >= 0; index -= 1) {
259914
259915
  const message = history[index];
259915
259916
  if (message === void 0) continue;
259916
259917
  if (message.role === "user" && message.origin?.kind !== "user") continue;
259917
- if (message.role === "assistant" && message.toolCalls.length > 0) continue;
259918
259918
  if (message.role !== "user" && message.role !== "assistant") continue;
259919
+ if (message.role === "user" && selected.length > 0 && expectsAssistant) break;
259920
+ if (message.role === "assistant") {
259921
+ if (!expectsAssistant) continue;
259922
+ if (message.toolCalls.length > 0) break;
259923
+ }
259919
259924
  const messageTextChars = blunMessageTextChars(message);
259920
259925
  if (messageTextChars === 0) continue;
259921
- if (textChars + messageTextChars > 12e3) continue;
259926
+ if (textChars + messageTextChars > 12e3) break;
259922
259927
  selected.push(message);
259923
259928
  textChars += messageTextChars;
259929
+ expectsAssistant = message.role === "user";
259924
259930
  if (selected.length >= 6) break;
259925
259931
  }
259926
259932
  return selected.toReversed();
@@ -502526,7 +502532,7 @@ var EditorKeyboardController = class {
502526
502532
  host.toggleTodoPanelExpansion();
502527
502533
  return;
502528
502534
  }
502529
- if (host.state.appState.streamingPhase === "idle") return;
502535
+ if (!host.streamingUI.hasActiveTurn() && host.state.appState.streamingPhase === "idle") return;
502530
502536
  host.flushQueuedMessages(editor.getText().trim(), editor.inputMode);
502531
502537
  host.updateQueueDisplay();
502532
502538
  host.state.ui.requestRender();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.73",
3
+ "version": "9.1.75",
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",