blun-king-cli 9.1.157 → 9.1.158
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/LIESMICH.txt +2 -0
- package/bin/assistant-message-offload-policy.cjs +40 -0
- package/blun.mjs +3 -2
- package/package.json +1 -1
package/LIESMICH.txt
CHANGED
|
@@ -153,6 +153,8 @@ Ab BLUN King 9.1.156 wiederholen gespeicherte Verweise auf Nutzernachrichten au
|
|
|
153
153
|
|
|
154
154
|
Ab BLUN King 9.1.157 werden geeignete erfolgreiche, rein textbasierte Werkzeugausgaben außerhalb der neuesten 20 Nachrichten in der Modellprojektion durch einen kurzen Abschlussvermerk ersetzt. Fehlerausgaben, Medien, ausgelagerte Dateiverweise, die neuesten 20 Nachrichten, Rohverlauf und Exporte bleiben unverändert. In Fredriks stabil vermessenem Sitzungsschnappschuss werden 43 alte Ergebnisse verkleinert. Das spart 9.680 Zeichen beziehungsweise rund 2.420 geschätzte Eingabetoken pro gleich aufgebauter Anfrage.
|
|
155
155
|
|
|
156
|
+
Ab BLUN King 9.1.158 werden reine Statusnachrichten, die unmittelbar auf eine abgeschlossene Telegram-Antwort folgen, außerhalb der neuesten 20 Nachrichten in der Modellprojektion durch einen kurzen Vermerk ersetzt. Der versendete Antwortaufruf und sein Ergebnis, aktuelle Nachrichten, Zusammenfassungen nach anderen Werkzeugen, gemischte Inhalte, Rohverlauf und Exporte bleiben unverändert. In Fredriks stabil vermessenem Sitzungsschnappschuss werden sechs historische Statusnachrichten um 1.837 Zeichen verkleinert. Das spart rund 460 geschätzte Eingabetoken pro gleich aufgebauter Anfrage.
|
|
157
|
+
|
|
156
158
|
Ab BLUN King 9.1.155 werden gespeicherte Verweise auf Nutzernachrichten wiederhergestellt, bevor Textprojektionen den Hash der ursprünglichen Nachricht verändern können. Bestehende Auslagerungen bleiben dadurch wirksam, statt unbemerkt auf die projizierte vollständige Nachricht zurückzufallen. Rohverlauf, wiederlesbare Dateiverweise, die neuesten 20 Nachrichten, Medien und Exporte bleiben unverändert. In Fredriks stabil vermessenem Schnappschuss sinkt die Modellprojektion von 105.810 auf 99.143 Zeichen. Das spart weitere 6.667 Zeichen beziehungsweise rund 1.667 geschätzte Eingabetoken pro gleich aufgebauter Anfrage.
|
|
157
159
|
|
|
158
160
|
Ab BLUN King 9.1.154 werden adressierte Telegram-Kanalabschnitte außerhalb der neuesten 20 Nachrichten auf eine 500 statt 1.000 Zeichen lange Vorschau mit Anfang und Ende begrenzt. Vollständige Kanalmetadaten, Anfang und Ende des Nachrichteninhalts, die neuesten 20 Nachrichten, Anhänge, Rohverlauf und Exporte bleiben unverändert. In Fredriks stabil vermessenem Schnappschuss werden sieben zusätzliche historische adressierte Abschnitte verkleinert. Das spart 3.500 Zeichen beziehungsweise rund 875 geschätzte Token pro wiederholter Anfrage.
|
|
@@ -7,6 +7,8 @@ const ASSISTANT_MESSAGE_PREVIEW_LINE_CHARS = 1_000;
|
|
|
7
7
|
const ASSISTANT_MESSAGE_OFFLOAD_MARKER = '[Assistant message offloaded]';
|
|
8
8
|
const ASSISTANT_TOOL_NARRATION_MIN_CHARS = 120;
|
|
9
9
|
const ASSISTANT_TOOL_NARRATION_MARKER = '[Earlier completed tool-step narration compacted]';
|
|
10
|
+
const ASSISTANT_POST_TELEGRAM_REPLY_MARKER = '[Earlier post-reply status compacted]';
|
|
11
|
+
const TELEGRAM_REPLY_TOOL_RE = /^mcp__[^\s]*telegram[^\s]*__reply$/iu;
|
|
10
12
|
|
|
11
13
|
function shouldOffloadHistoricalAssistantMessage(options = {}) {
|
|
12
14
|
const historyIndex = Number(options.historyIndex);
|
|
@@ -65,6 +67,42 @@ function shouldCompactHistoricalAssistantToolNarration(options = {}) {
|
|
|
65
67
|
&& completedToolCallCount === toolCallCount;
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
function compactHistoricalPostTelegramReplyNarration(messages) {
|
|
71
|
+
if (!Array.isArray(messages) || messages.length === 0) return messages;
|
|
72
|
+
|
|
73
|
+
const toolNameByCallId = new Map(messages.flatMap((message) => (
|
|
74
|
+
message?.role === 'assistant' && Array.isArray(message.toolCalls)
|
|
75
|
+
? message.toolCalls.map((call) => [call?.id, call?.name])
|
|
76
|
+
: []
|
|
77
|
+
)).filter(([id, name]) => typeof id === 'string' && typeof name === 'string'));
|
|
78
|
+
const recentStart = Math.max(0, messages.length - ASSISTANT_MESSAGE_KEEP_RECENT_MESSAGES);
|
|
79
|
+
let changed = false;
|
|
80
|
+
const projected = messages.map((message, historyIndex) => {
|
|
81
|
+
if (
|
|
82
|
+
historyIndex >= recentStart
|
|
83
|
+
|| message?.role !== 'assistant'
|
|
84
|
+
|| (message.toolCalls?.length ?? 0) !== 0
|
|
85
|
+
|| !Array.isArray(message.content)
|
|
86
|
+
|| !message.content.every((part) => part?.type === 'text' && typeof part.text === 'string')
|
|
87
|
+
) return message;
|
|
88
|
+
|
|
89
|
+
const previous = messages[historyIndex - 1];
|
|
90
|
+
const toolName = previous?.role === 'tool'
|
|
91
|
+
? toolNameByCallId.get(previous.toolCallId)
|
|
92
|
+
: undefined;
|
|
93
|
+
if (!TELEGRAM_REPLY_TOOL_RE.test(toolName ?? '')) return message;
|
|
94
|
+
const textChars = message.content.reduce((sum, part) => sum + part.text.length, 0);
|
|
95
|
+
if (textChars <= ASSISTANT_POST_TELEGRAM_REPLY_MARKER.length) return message;
|
|
96
|
+
changed = true;
|
|
97
|
+
return {
|
|
98
|
+
...message,
|
|
99
|
+
content: [{ type: 'text', text: ASSISTANT_POST_TELEGRAM_REPLY_MARKER }],
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return changed ? projected : messages;
|
|
104
|
+
}
|
|
105
|
+
|
|
68
106
|
module.exports = {
|
|
69
107
|
ASSISTANT_MESSAGE_KEEP_RECENT_MESSAGES,
|
|
70
108
|
ASSISTANT_MESSAGE_MAX_CHARS,
|
|
@@ -73,6 +111,8 @@ module.exports = {
|
|
|
73
111
|
ASSISTANT_MESSAGE_PREVIEW_LINE_CHARS,
|
|
74
112
|
ASSISTANT_TOOL_NARRATION_MARKER,
|
|
75
113
|
ASSISTANT_TOOL_NARRATION_MIN_CHARS,
|
|
114
|
+
ASSISTANT_POST_TELEGRAM_REPLY_MARKER,
|
|
115
|
+
compactHistoricalPostTelegramReplyNarration,
|
|
76
116
|
createAssistantMessagePreview,
|
|
77
117
|
shouldCompactHistoricalAssistantToolNarration,
|
|
78
118
|
shouldOffloadHistoricalAssistantMessage,
|
package/blun.mjs
CHANGED
|
@@ -260750,7 +260750,7 @@ function renderPersistedAssistantMessage(text, outputPath) {
|
|
|
260750
260750
|
createAssistantMessagePreview(text)
|
|
260751
260751
|
].join("\n");
|
|
260752
260752
|
}
|
|
260753
|
-
var ASSISTANT_MESSAGE_MAX_CHARS, ASSISTANT_MESSAGE_OFFLOAD_MARKER, ASSISTANT_TOOL_NARRATION_MARKER, shouldOffloadHistoricalAssistantMessage, shouldCompactHistoricalAssistantToolNarration, createAssistantMessagePreview;
|
|
260753
|
+
var ASSISTANT_MESSAGE_MAX_CHARS, ASSISTANT_MESSAGE_OFFLOAD_MARKER, ASSISTANT_TOOL_NARRATION_MARKER, shouldOffloadHistoricalAssistantMessage, shouldCompactHistoricalAssistantToolNarration, compactHistoricalPostTelegramReplyNarration, createAssistantMessagePreview;
|
|
260754
260754
|
var init_assistant_message_offload = __esmMin((() => {
|
|
260755
260755
|
const policy = createRequire(import.meta.url)("./bin/assistant-message-offload-policy.cjs");
|
|
260756
260756
|
ASSISTANT_MESSAGE_MAX_CHARS = policy.ASSISTANT_MESSAGE_MAX_CHARS;
|
|
@@ -260758,6 +260758,7 @@ var init_assistant_message_offload = __esmMin((() => {
|
|
|
260758
260758
|
ASSISTANT_TOOL_NARRATION_MARKER = policy.ASSISTANT_TOOL_NARRATION_MARKER;
|
|
260759
260759
|
shouldOffloadHistoricalAssistantMessage = policy.shouldOffloadHistoricalAssistantMessage;
|
|
260760
260760
|
shouldCompactHistoricalAssistantToolNarration = policy.shouldCompactHistoricalAssistantToolNarration;
|
|
260761
|
+
compactHistoricalPostTelegramReplyNarration = policy.compactHistoricalPostTelegramReplyNarration;
|
|
260761
260762
|
createAssistantMessagePreview = policy.createAssistantMessagePreview;
|
|
260762
260763
|
}));
|
|
260763
260764
|
var AssistantMessageOffload = class {
|
|
@@ -260843,7 +260844,7 @@ var AssistantMessageOffload = class {
|
|
|
260843
260844
|
changed = true;
|
|
260844
260845
|
return { ...message, content: replacement.content };
|
|
260845
260846
|
});
|
|
260846
|
-
return changed ? projected : messages;
|
|
260847
|
+
return compactHistoricalPostTelegramReplyNarration(changed ? projected : messages);
|
|
260847
260848
|
}
|
|
260848
260849
|
reset(history = this.agent.context?.history ?? []) {
|
|
260849
260850
|
const activeHashes = new Set(history.map((message) => {
|