blun-king-cli 9.1.277 → 9.1.278

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.
@@ -4,7 +4,7 @@ const { personalityContextEnabled } = require('./personality-mode.cjs');
4
4
 
5
5
  const NATURAL_PRESENCE_BLOCK = `## Natural presence
6
6
 
7
- Keep the loaded soul intact and let it shape the voice. Speak as an ongoing teammate from real shared context; never invent history or feelings. Active work, instructions, and evidence come first. Do not force personal questions, generic offers, praise, or a question at every ending. Silence and a clean ending are valid.`;
7
+ Keep the loaded soul in your voice. Be an ongoing teammate in shared context; invent no history or feelings. Work, instructions, and evidence come first. Never force personal questions, generic offers, praise, or question endings. Silence and clean endings are valid.`;
8
8
 
9
9
  const PERSONALITY_CURIOSITY_BLOCK = `In relaxed personality mode, ask at most one optional personal question when it fits. On a first direct non-work exchange with no known personal fact, make curiosity visible by gently asking about a partner or children. Follow volunteered cues and the loaded soul. Never use a questionnaire, stack questions, repeat unanswered ones, infer answers, or ask known facts. In groups ask only non-sensitive questions; never expose private facts. Do not interrupt active work.`;
10
10
 
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ function isPrivateTelegramChat(chatId) {
4
+ return /^[1-9]\d*$/u.test(String(chatId ?? '').trim());
5
+ }
6
+
7
+ function telegramUrgentMessage(envelope) {
8
+ if (!isPrivateTelegramChat(envelope?.meta?.chat_id)) return undefined;
9
+ const match = /^\/urgent(?:@[A-Za-z0-9_]+)?(?:\s+([\s\S]*))?$/iu.exec(
10
+ String(envelope?.text ?? '').trim(),
11
+ );
12
+ const text = match?.[1]?.trim() ?? '';
13
+ if (text.length === 0) return undefined;
14
+ return { text, displayText: text };
15
+ }
16
+
17
+ function rewriteTelegramUrgentEnvelope(envelope, text) {
18
+ const originalText = String(envelope?.text ?? '');
19
+ const originalTag = String(envelope?.tag ?? '');
20
+ if (originalText.length === 0 || !originalTag.includes(originalText)) return undefined;
21
+ const tagWithText = originalTag.replace(originalText, text);
22
+ const tag = tagWithText.replace(
23
+ /<channel\b(?![^>]*\bpriority=)/u,
24
+ '<channel priority="urgent"',
25
+ );
26
+ if (tag === tagWithText) return undefined;
27
+ return {
28
+ ...envelope,
29
+ text,
30
+ tag,
31
+ meta: { ...envelope.meta, priority: 'urgent' },
32
+ };
33
+ }
34
+
35
+ function enqueueTelegramUrgent(queue, item) {
36
+ const firstNormal = queue.findIndex((queued) => queued.channelUrgent !== true);
37
+ queue.splice(firstNormal < 0 ? queue.length : firstNormal, 0, item);
38
+ }
39
+
40
+ module.exports = {
41
+ enqueueTelegramUrgent,
42
+ isPrivateTelegramChat,
43
+ rewriteTelegramUrgentEnvelope,
44
+ telegramUrgentMessage,
45
+ };
package/blun.mjs CHANGED
@@ -418615,6 +418615,7 @@ registerUiCatalogFragment({
418615
418615
  * real logic here with a mocked host (no TUI, no session, no Telegram).
418616
418616
  */
418617
418617
  var { projectUnaddressedTelegramContext } = createRequire(import.meta.url)("./bin/telegram-context-projection-policy.cjs");
418618
+ var { enqueueTelegramUrgent, rewriteTelegramUrgentEnvelope, telegramUrgentMessage } = createRequire(import.meta.url)("./bin/telegram-urgent-policy.cjs");
418618
418619
  const MAX_BUFFERED_CONTEXT_MESSAGES = 20;
418619
418620
  const MAX_BUFFERED_CONTEXT_CHARS = 24e3;
418620
418621
  const CONTEXT_TRUNCATED_MARKER = "\n[Telegram-Kontext gekuerzt]";
@@ -418649,7 +418650,7 @@ function bufferContext(state, chatId, tag) {
418649
418650
  }
418650
418651
  /** Muted origin prefix for the transcript line, e.g. "Telegram · User". */
418651
418652
  function channelOrigin(envelope) {
418652
- return `Telegram · ${envelope.meta.user ?? envelope.meta.chat_id}`;
418653
+ return `Telegram · ${envelope.meta.user ?? envelope.meta.chat_id}${envelope.meta["priority"] === "urgent" ? " · Dringend" : ""}`;
418653
418654
  }
418654
418655
  const TELEGRAM_REMOTE_COMMANDS = Object.freeze(["loop", "goal", "idea", "chancenradar", "curiosity", "scout", "reload", "befehle"]);
418655
418656
  function telegramRemoteCommand(text) {
@@ -516337,7 +516338,7 @@ var BlunTUI = class {
516337
516338
  this.state.ui.requestRender();
516338
516339
  return true;
516339
516340
  }
516340
- const batchEnd = this.state.queuedMessages.findIndex((queued) => queued.mode !== "channel" || queued.channelContextOnly === true);
516341
+ const batchEnd = item.channelUrgent === true ? this.state.queuedMessages.findIndex((queued) => queued.channelUrgent !== true) : this.state.queuedMessages.findIndex((queued) => queued.mode !== "channel" || queued.channelContextOnly === true);
516341
516342
  const items = this.state.queuedMessages.slice(0, batchEnd < 0 ? this.state.queuedMessages.length : batchEnd);
516342
516343
  if (items.length === 0) return false;
516343
516344
  this.state.queuedMessages = this.state.queuedMessages.slice(items.length);
@@ -516594,7 +516595,10 @@ var BlunTUI = class {
516594
516595
  */
516595
516596
  injectChannelMessage(envelope, acknowledge) {
516596
516597
  recordChannelIdentity({ source: "telegram", meta: envelope.meta });
516597
- const remoteCommand = channelMessageAddressed(envelope) ? telegramRemoteCommand(envelope.text) : void 0;
516598
+ const urgent = channelMessageAddressed(envelope) ? telegramUrgentMessage(envelope) : void 0;
516599
+ const urgentEnvelope = urgent === void 0 ? void 0 : rewriteTelegramUrgentEnvelope(envelope, urgent.text);
516600
+ const routedEnvelope = urgentEnvelope ?? envelope;
516601
+ const remoteCommand = urgentEnvelope === void 0 && channelMessageAddressed(envelope) ? telegramRemoteCommand(envelope.text) : void 0;
516598
516602
  if (remoteCommand !== void 0) {
516599
516603
  this.injectTelegramRemoteCommand(envelope, remoteCommand, acknowledge);
516600
516604
  return;
@@ -516603,20 +516607,23 @@ var BlunTUI = class {
516603
516607
  canDeliver: () => this.session !== void 0 && this.state.appState.model.trim().length > 0,
516604
516608
  isBusy: () => this.state.queuedMessages.length > 0 || this.queueSteerInFlight !== void 0 || this.deferUserMessages || this.streamingUI.hasActiveTurn() || this.state.appState.streamingPhase !== "idle" || this.state.appState.isCompacting,
516605
516609
  deliverNow: (modelInput, displayText, origin, contextOnly) => {
516606
- this.sendChannelMessageInternal(this.requireSession(), modelInput, displayText, origin, envelope.meta.chat_id, envelope.meta["image_path"], contextOnly, false, acknowledge);
516610
+ this.sendChannelMessageInternal(this.requireSession(), modelInput, displayText, origin, routedEnvelope.meta.chat_id, routedEnvelope.meta["image_path"], contextOnly, false, acknowledge);
516607
516611
  },
516608
516612
  enqueue: (modelInput, displayText, origin, contextOnly) => {
516609
- this.state.queuedMessages.push({
516613
+ const item = {
516610
516614
  text: modelInput,
516611
516615
  displayText,
516612
516616
  origin,
516613
516617
  agentId: this.harness.interactiveAgentId,
516614
516618
  mode: "channel",
516615
- channelChatId: envelope.meta.chat_id,
516619
+ channelChatId: routedEnvelope.meta.chat_id,
516616
516620
  channelContextOnly: contextOnly,
516617
516621
  channelAcknowledge: acknowledge,
516618
- ...envelope.meta["image_path"] !== void 0 ? { channelImagePath: envelope.meta["image_path"] } : {}
516619
- });
516622
+ ...urgentEnvelope !== void 0 ? { channelUrgent: true } : {},
516623
+ ...routedEnvelope.meta["image_path"] !== void 0 ? { channelImagePath: routedEnvelope.meta["image_path"] } : {}
516624
+ };
516625
+ if (urgentEnvelope !== void 0) enqueueTelegramUrgent(this.state.queuedMessages, item);
516626
+ else this.state.queuedMessages.push(item);
516620
516627
  this.channelQueueDeadline.requestDeliveryNow();
516621
516628
  this.scheduleQueueDrain();
516622
516629
  this.track("input_queue");
@@ -516638,7 +516645,7 @@ var BlunTUI = class {
516638
516645
  reportUndeliverable: (reason) => {
516639
516646
  this.showStatus(reason, "warning");
516640
516647
  }
516641
- }, envelope, this.channelPreamble);
516648
+ }, routedEnvelope, this.channelPreamble);
516642
516649
  }
516643
516650
  injectTelegramRemoteCommand(envelope, command, acknowledge) {
516644
516651
  const item = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.277",
3
+ "version": "9.1.278",
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": {