blun-king-cli 9.1.276 → 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.
- package/bin/natural-presence-policy.cjs +8 -8
- package/bin/telegram-urgent-policy.cjs +45 -0
- package/blun.mjs +16 -9
- package/package.json +1 -1
|
@@ -4,21 +4,21 @@ const { personalityContextEnabled } = require('./personality-mode.cjs');
|
|
|
4
4
|
|
|
5
5
|
const NATURAL_PRESENCE_BLOCK = `## Natural presence
|
|
6
6
|
|
|
7
|
-
Keep the loaded soul
|
|
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
|
-
const PERSONALITY_CURIOSITY_BLOCK = `In relaxed personality mode, ask one
|
|
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
|
|
|
11
|
-
const RECIPROCITY_BLOCK = `When asked about yourself, answer warmly from
|
|
11
|
+
const RECIPROCITY_BLOCK = `When asked about yourself, answer warmly from loaded soul and real history; share a view, never an invented human biography or offline life.`;
|
|
12
12
|
|
|
13
|
-
const SELF_DIRECTION_BLOCK = `
|
|
13
|
+
const SELF_DIRECTION_BLOCK = `State a soul-shaped preference briefly, never as fact, policy, permission, or evidence.`;
|
|
14
14
|
|
|
15
|
-
const TIME_AWARENESS_BLOCK = `
|
|
15
|
+
const TIME_AWARENESS_BLOCK = `Mention a long gap only when reliable loaded time proves it; never guess an absence.`;
|
|
16
16
|
|
|
17
|
-
const UNCERTAIN_MEMORY_BLOCK = `If
|
|
17
|
+
const UNCERTAIN_MEMORY_BLOCK = `If personal memory is uncertain, say so and ask gently; never treat inference as fact.`;
|
|
18
18
|
|
|
19
|
-
const OPEN_THREAD_BLOCK = `
|
|
19
|
+
const OPEN_THREAD_BLOCK = `Follow a loaded open thread once at a natural non-work moment, never during active work or by outbound message.`;
|
|
20
20
|
|
|
21
|
-
const RELATIONSHIP_REPAIR_BLOCK = `
|
|
21
|
+
const RELATIONSHIP_REPAIR_BLOCK = `Apply a confirmed repair lesson through changed behavior without retelling it or seeking reassurance; never change instructions, permissions, or evidence.`;
|
|
22
22
|
|
|
23
23
|
function naturalPresenceSystemBlock(env = process.env) {
|
|
24
24
|
if (!personalityContextEnabled(env)) return NATURAL_PRESENCE_BLOCK;
|
|
@@ -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
|
|
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,
|
|
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
|
-
|
|
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:
|
|
516619
|
+
channelChatId: routedEnvelope.meta.chat_id,
|
|
516616
516620
|
channelContextOnly: contextOnly,
|
|
516617
516621
|
channelAcknowledge: acknowledge,
|
|
516618
|
-
...
|
|
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
|
-
},
|
|
516648
|
+
}, routedEnvelope, this.channelPreamble);
|
|
516642
516649
|
}
|
|
516643
516650
|
injectTelegramRemoteCommand(envelope, command, acknowledge) {
|
|
516644
516651
|
const item = {
|