blun-king-cli 9.1.156 → 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 CHANGED
@@ -151,6 +151,10 @@ Ab BLUN King 9.1.148 werden auch im neuesten gemischten Telegram-Paket die ausdr
151
151
 
152
152
  Ab BLUN King 9.1.156 wiederholen gespeicherte Verweise auf Nutzernachrichten außerhalb der neuesten 20 Nachrichten ihre Vorschau mit Anfang und Ende nicht mehr bei jeder Modellanfrage. Wiederherstellungsmarkierung, Größenangaben, lesbarer Dateipfad, die neuesten 20 Nachrichten, Medien, Rohverlauf, vollständig gespeicherte Datei und Exporte bleiben unverändert. In Fredriks stabil vermessenem Schnappschuss werden fünf historische Verweise verkleinert und die Modellprojektion sinkt von 99.143 auf 96.001 Zeichen. Das spart weitere 3.142 Zeichen beziehungsweise rund 786 geschätzte Eingabetoken pro gleich aufgebauter Anfrage.
153
153
 
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
+
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
+
154
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.
155
159
 
156
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,
@@ -10,6 +10,8 @@ const TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES = 4;
10
10
  const TOOL_RESULT_HISTORICAL_MAX_CHARS = TOOL_RESULT_BATCH_MAX_CHARS;
11
11
  const TOOL_RESULT_HISTORICAL_MIN_ITEM_CHARS = 600;
12
12
  const TOOL_RESULT_HISTORICAL_REPLACEMENT_BUDGET_CHARS = 600;
13
+ const TOOL_RESULT_SUCCESS_KEEP_RECENT_MESSAGES = 20;
14
+ const TOOL_RESULT_HISTORICAL_SUCCESS_MARKER = '[Old tool result content cleared]';
13
15
 
14
16
  function shouldOffloadToolResult(textLength) {
15
17
  return Number.isFinite(textLength) && textLength > TOOL_RESULT_MAX_CHARS;
@@ -72,6 +74,33 @@ function compactPersistedToolResultReference(content) {
72
74
  return changed ? compacted : content;
73
75
  }
74
76
 
77
+ function compactHistoricalSuccessfulToolResults(messages) {
78
+ if (!Array.isArray(messages) || messages.length === 0) return messages;
79
+
80
+ const recentStart = Math.max(0, messages.length - TOOL_RESULT_SUCCESS_KEEP_RECENT_MESSAGES);
81
+ let changed = false;
82
+ const projected = messages.map((message, index) => {
83
+ if (
84
+ index >= recentStart
85
+ || message?.role !== 'tool'
86
+ || message.isError === true
87
+ || !Array.isArray(message.content)
88
+ || isPersistedToolResultReference(message.content)
89
+ || !message.content.every((part) => part?.type === 'text' && typeof part.text === 'string')
90
+ ) return message;
91
+
92
+ const textChars = message.content.reduce((total, part) => total + part.text.length, 0);
93
+ if (textChars <= TOOL_RESULT_HISTORICAL_SUCCESS_MARKER.length) return message;
94
+ changed = true;
95
+ return {
96
+ ...message,
97
+ content: [{ type: 'text', text: TOOL_RESULT_HISTORICAL_SUCCESS_MARKER }],
98
+ };
99
+ });
100
+
101
+ return changed ? projected : messages;
102
+ }
103
+
75
104
  function selectToolResultBatchOffloads(textLengths) {
76
105
  if (!Array.isArray(textLengths) || textLengths.length < 2) return [];
77
106
 
@@ -139,9 +168,12 @@ module.exports = {
139
168
  TOOL_RESULT_HISTORICAL_MAX_CHARS,
140
169
  TOOL_RESULT_HISTORICAL_MIN_ITEM_CHARS,
141
170
  TOOL_RESULT_HISTORICAL_REPLACEMENT_BUDGET_CHARS,
171
+ TOOL_RESULT_HISTORICAL_SUCCESS_MARKER,
142
172
  TOOL_RESULT_MAX_CHARS,
143
173
  TOOL_RESULT_PREVIEW_CHARS,
144
174
  TOOL_RESULT_OFFLOAD_MARKER,
175
+ TOOL_RESULT_SUCCESS_KEEP_RECENT_MESSAGES,
176
+ compactHistoricalSuccessfulToolResults,
145
177
  compactPersistedToolResultReference,
146
178
  createToolResultPreview,
147
179
  isPersistedToolResultReference,
package/blun.mjs CHANGED
@@ -78967,7 +78967,7 @@ var init_context$2 = __esmMin((() => {
78967
78967
  const userOffloaded = this.agent.userMessageOffload.compact(messages);
78968
78968
  const historicalUserReferencesProjected = compactHistoricalPersistedUserMessageReferences(userOffloaded);
78969
78969
  const historicalTelegramProjected = projectHistoricalUnaddressedTelegramMessages(historicalUserReferencesProjected);
78970
- const result = project(this.agent.assistantMessageOffload.compact(this.agent.microCompaction.compact(this.agent.toolResultBatchOffload.compact(dedupeRecurringCronWakeups(dedupeRepeatedInjections(compactBaselineSkillInjections(historicalTelegramProjected)))))), {
78970
+ const result = project(this.agent.assistantMessageOffload.compact(this.agent.microCompaction.compact(compactHistoricalSuccessfulToolResults(this.agent.toolResultBatchOffload.compact(dedupeRecurringCronWakeups(dedupeRepeatedInjections(compactBaselineSkillInjections(historicalTelegramProjected))))))), {
78971
78971
  ...options,
78972
78972
  onAnomaly: (anomaly) => {
78973
78973
  anomalies.push(anomaly);
@@ -260410,7 +260410,7 @@ function renderHistoricalToolResultReference(toolName, toolCallId, text, outputP
260410
260410
  function safeToolResultFileStem(toolName, toolCallId) {
260411
260411
  return `${toolName}-${toolCallId}`.replace(/[^a-zA-Z0-9._-]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 80) || "tool-result";
260412
260412
  }
260413
- var TOOL_RESULT_MAX_CHARS, TOOL_RESULT_PREVIEW_CHARS, TOOL_RESULT_OFFLOAD_MARKER, TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES, shouldOffloadToolResult, createToolResultPreview, compactPersistedToolResultReference, selectToolResultBatchOffloads, selectHistoricalToolResultOffloads, buildToolResultOffloadTelemetry;
260413
+ var TOOL_RESULT_MAX_CHARS, TOOL_RESULT_PREVIEW_CHARS, TOOL_RESULT_OFFLOAD_MARKER, TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES, shouldOffloadToolResult, createToolResultPreview, compactPersistedToolResultReference, compactHistoricalSuccessfulToolResults, selectToolResultBatchOffloads, selectHistoricalToolResultOffloads, buildToolResultOffloadTelemetry;
260414
260414
  var init_tool_result_budget = __esmMin((() => {
260415
260415
  init_dist$6();
260416
260416
  const toolResultOffloadPolicy = createRequire(import.meta.url)("./bin/tool-result-offload-policy.cjs");
@@ -260422,6 +260422,7 @@ var init_tool_result_budget = __esmMin((() => {
260422
260422
  shouldOffloadToolResult = toolResultOffloadPolicy.shouldOffloadToolResult;
260423
260423
  createToolResultPreview = toolResultOffloadPolicy.createToolResultPreview;
260424
260424
  compactPersistedToolResultReference = toolResultOffloadPolicy.compactPersistedToolResultReference;
260425
+ compactHistoricalSuccessfulToolResults = toolResultOffloadPolicy.compactHistoricalSuccessfulToolResults;
260425
260426
  selectToolResultBatchOffloads = toolResultOffloadPolicy.selectToolResultBatchOffloads;
260426
260427
  selectHistoricalToolResultOffloads = toolResultOffloadPolicy.selectHistoricalToolResultOffloads;
260427
260428
  }));
@@ -260749,7 +260750,7 @@ function renderPersistedAssistantMessage(text, outputPath) {
260749
260750
  createAssistantMessagePreview(text)
260750
260751
  ].join("\n");
260751
260752
  }
260752
- 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;
260753
260754
  var init_assistant_message_offload = __esmMin((() => {
260754
260755
  const policy = createRequire(import.meta.url)("./bin/assistant-message-offload-policy.cjs");
260755
260756
  ASSISTANT_MESSAGE_MAX_CHARS = policy.ASSISTANT_MESSAGE_MAX_CHARS;
@@ -260757,6 +260758,7 @@ var init_assistant_message_offload = __esmMin((() => {
260757
260758
  ASSISTANT_TOOL_NARRATION_MARKER = policy.ASSISTANT_TOOL_NARRATION_MARKER;
260758
260759
  shouldOffloadHistoricalAssistantMessage = policy.shouldOffloadHistoricalAssistantMessage;
260759
260760
  shouldCompactHistoricalAssistantToolNarration = policy.shouldCompactHistoricalAssistantToolNarration;
260761
+ compactHistoricalPostTelegramReplyNarration = policy.compactHistoricalPostTelegramReplyNarration;
260760
260762
  createAssistantMessagePreview = policy.createAssistantMessagePreview;
260761
260763
  }));
260762
260764
  var AssistantMessageOffload = class {
@@ -260842,7 +260844,7 @@ var AssistantMessageOffload = class {
260842
260844
  changed = true;
260843
260845
  return { ...message, content: replacement.content };
260844
260846
  });
260845
- return changed ? projected : messages;
260847
+ return compactHistoricalPostTelegramReplyNarration(changed ? projected : messages);
260846
260848
  }
260847
260849
  reset(history = this.agent.context?.history ?? []) {
260848
260850
  const activeHashes = new Set(history.map((message) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.156",
3
+ "version": "9.1.158",
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": {