blun-king-cli 9.1.382 → 9.1.384

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.
@@ -19,6 +19,10 @@ function shouldOffloadToolResult(textLength) {
19
19
  return Number.isFinite(textLength) && textLength > TOOL_RESULT_MAX_CHARS;
20
20
  }
21
21
 
22
+ function shouldKeepFreshToolResult(toolName) {
23
+ return toolName === 'Read';
24
+ }
25
+
22
26
  function createToolResultPreview(text) {
23
27
  if (text.length <= TOOL_RESULT_PREVIEW_CHARS) return text;
24
28
 
@@ -267,5 +271,6 @@ module.exports = {
267
271
  isPersistedToolResultReference,
268
272
  selectHistoricalToolResultOffloads,
269
273
  selectToolResultBatchOffloads,
274
+ shouldKeepFreshToolResult,
270
275
  shouldOffloadToolResult,
271
276
  };
@@ -63,6 +63,29 @@ function mediaGenerationToolNamesForText(value) {
63
63
  return selected;
64
64
  }
65
65
 
66
+ function mediaToolNamesForTurnText(value) {
67
+ const text = String(value || '');
68
+ const selected = new Set();
69
+ const channelBodies = [...text.matchAll(
70
+ /(?:^|\r?\n)<channel\b[^>]*>\r?\n([\s\S]*?)\r?\n<\/channel>(?=\r?\n|$)/giu,
71
+ )].map((match) => match[1]);
72
+ const intentTexts = channelBodies.length > 0 ? channelBodies : [text];
73
+
74
+ for (const intentText of intentTexts) {
75
+ for (const name of mediaGenerationToolNamesForText(intentText)) selected.add(name);
76
+ }
77
+
78
+ if (/\bimage_path\s*=\s*["'][^"']+["']/iu.test(text)) {
79
+ selected.add('ReadMediaFile');
80
+ selected.add('UnderstandImage');
81
+ }
82
+ if (/\battachment_file_id\s*=\s*["'][^"']+["']/iu.test(text)) {
83
+ selected.add('mcp__plugin-telegram_telegram__download_attachment');
84
+ selected.add('UnderstandImage');
85
+ }
86
+ return selected;
87
+ }
88
+
66
89
  function toolSchemaBudgetTokens(maxContextTokens) {
67
90
  const context = Number(maxContextTokens);
68
91
  if (!Number.isFinite(context) || context <= 0) return TOOL_SCHEMA_MAX_TOKENS;
@@ -326,6 +349,7 @@ module.exports = {
326
349
  deferredToolCatalog,
327
350
  deferredToolNames,
328
351
  mediaGenerationToolNamesForText,
352
+ mediaToolNamesForTurnText,
329
353
  normalizeDeferredToolQuery,
330
354
  rememberDeferredToolAfterNotFound,
331
355
  toolSchemaBudgetTokens,
package/blun.mjs CHANGED
@@ -260587,7 +260587,7 @@ var init_tool_dedup = __esmMin((() => {
260587
260587
  //#region ../../packages/agent-core/src/agent/turn/tool-result-budget.ts
260588
260588
  async function budgetToolResultForModel(options) {
260589
260589
  const text = persistableToolResultText(options.result.output);
260590
- if (text === void 0 || !shouldOffloadToolResult(text.length)) return options.result;
260590
+ if (text === void 0 || shouldKeepFreshToolResult(options.toolName) || !shouldOffloadToolResult(text.length)) return options.result;
260591
260591
  const readSourcePath = reusableReadSourcePath(options);
260592
260592
  if (readSourcePath !== void 0) return referenceReadSourceForModel(options, text, readSourcePath);
260593
260593
  return persistToolResultForModel(options, text);
@@ -260739,7 +260739,7 @@ function renderHistoricalToolResultReference(toolName, toolCallId, text, outputP
260739
260739
  function safeToolResultFileStem(toolName, toolCallId) {
260740
260740
  return `${toolName}-${toolCallId}`.replace(/[^a-zA-Z0-9._-]+/g, "_").replace(/^_+|_+$/g, "").slice(0, 80) || "tool-result";
260741
260741
  }
260742
- var TOOL_RESULT_MAX_CHARS, TOOL_RESULT_PREVIEW_CHARS, TOOL_RESULT_RECOVERY_PAGE_LINES, TOOL_RESULT_OFFLOAD_MARKER, TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES, shouldOffloadToolResult, createToolResultPreview, compactPersistedToolResultReference, compactHistoricalSuccessfulToolResults, dedupeRepeatedSuccessfulToolResults, selectToolResultBatchOffloads, selectHistoricalToolResultOffloads, buildToolResultOffloadTelemetry;
260742
+ var TOOL_RESULT_MAX_CHARS, TOOL_RESULT_PREVIEW_CHARS, TOOL_RESULT_RECOVERY_PAGE_LINES, TOOL_RESULT_OFFLOAD_MARKER, TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES, shouldKeepFreshToolResult, shouldOffloadToolResult, createToolResultPreview, compactPersistedToolResultReference, compactHistoricalSuccessfulToolResults, dedupeRepeatedSuccessfulToolResults, selectToolResultBatchOffloads, selectHistoricalToolResultOffloads, buildToolResultOffloadTelemetry;
260743
260743
  var init_tool_result_budget = __esmMin((() => {
260744
260744
  init_dist$6();
260745
260745
  const toolResultOffloadPolicy = createRequire(import.meta.url)("./bin/tool-result-offload-policy.cjs");
@@ -260749,6 +260749,7 @@ var init_tool_result_budget = __esmMin((() => {
260749
260749
  TOOL_RESULT_RECOVERY_PAGE_LINES = toolResultOffloadPolicy.TOOL_RESULT_RECOVERY_PAGE_LINES;
260750
260750
  TOOL_RESULT_OFFLOAD_MARKER = toolResultOffloadPolicy.TOOL_RESULT_OFFLOAD_MARKER;
260751
260751
  TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES = toolResultOffloadPolicy.TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES;
260752
+ shouldKeepFreshToolResult = toolResultOffloadPolicy.shouldKeepFreshToolResult;
260752
260753
  shouldOffloadToolResult = toolResultOffloadPolicy.shouldOffloadToolResult;
260753
260754
  createToolResultPreview = toolResultOffloadPolicy.createToolResultPreview;
260754
260755
  compactPersistedToolResultReference = toolResultOffloadPolicy.compactPersistedToolResultReference;
@@ -260777,10 +260778,6 @@ var ToolResultBatchOffload = class {
260777
260778
  const recentStart = Math.max(0, history.length - TOOL_RESULT_HISTORICAL_KEEP_RECENT_MESSAGES);
260778
260779
  const historical = history.slice(0, recentStart).filter((message) => message?.role === "tool" && !tailIds.has(message.toolCallId));
260779
260780
  const candidateBatches = [{
260780
- messages: tail,
260781
- historical: false,
260782
- select: selectToolResultBatchOffloads
260783
- }, {
260784
260781
  messages: historical,
260785
260782
  historical: true,
260786
260783
  select: selectHistoricalToolResultOffloads
@@ -261517,7 +261514,7 @@ function toolResultText(result) {
261517
261514
  function abandonedToolResultOutput(ended) {
261518
261515
  return `Tool call did not complete: ${ended.reason === "cancelled" ? "the turn was cancelled" : ended.reason === "failed" ? `the turn failed${ended.error !== void 0 ? ` (${ended.error.message})` : ""}` : "the turn ended"} before its result was recorded. Do not assume the tool completed successfully.`;
261519
261516
  }
261520
- var BLUN_CORE_TOOL_NAMES, BLUN_LEAN_TOOL_NAMES, BLUN_ATTACHMENT_MARKER_RE, BLUN_TELEGRAM_OUTBOUND_TOOL_RE, BLUN_TELEGRAM_CHANNEL_RE, BLUN_TOOL_BUDGET_RATIO, createDeferredToolLoader, mediaGenerationToolNamesForText, rememberDeferredToolAfterNotFound, toolSchemaBudgetTokens, projectRecurringCronHistory, TelegramDeliveryLedger, createRuntimeCognitiveTurnLifecycle, cognitiveFocusScopesForTurn, buildCognitiveWorkFocus, buildAttentionQueueItem, LLM_NOT_SET_MESSAGE, GOAL_CONTINUATION_ORIGIN, GOAL_COMPLETION_REMINDER_NAME, GOAL_BLOCKED_REMINDER_NAME, GOAL_RATE_LIMIT_PAUSE_REASON, GOAL_PROVIDER_CONNECTION_PAUSE_PREFIX, GOAL_PROVIDER_AUTH_PAUSE_PREFIX, GOAL_PROVIDER_API_PAUSE_PREFIX, GOAL_MODEL_CONFIG_PAUSE_PREFIX, GOAL_RUNTIME_PAUSE_PREFIX, GOAL_PROVIDER_FILTERED_PAUSE_REASON, GOAL_CONTINUATION_PROMPT, TurnFlow;
261517
+ var BLUN_CORE_TOOL_NAMES, BLUN_LEAN_TOOL_NAMES, BLUN_ATTACHMENT_MARKER_RE, BLUN_TELEGRAM_OUTBOUND_TOOL_RE, BLUN_TELEGRAM_CHANNEL_RE, BLUN_TOOL_BUDGET_RATIO, createDeferredToolLoader, mediaToolNamesForTurnText, rememberDeferredToolAfterNotFound, toolSchemaBudgetTokens, projectRecurringCronHistory, TelegramDeliveryLedger, createRuntimeCognitiveTurnLifecycle, cognitiveFocusScopesForTurn, buildCognitiveWorkFocus, buildAttentionQueueItem, LLM_NOT_SET_MESSAGE, GOAL_CONTINUATION_ORIGIN, GOAL_COMPLETION_REMINDER_NAME, GOAL_BLOCKED_REMINDER_NAME, GOAL_RATE_LIMIT_PAUSE_REASON, GOAL_PROVIDER_CONNECTION_PAUSE_PREFIX, GOAL_PROVIDER_AUTH_PAUSE_PREFIX, GOAL_PROVIDER_API_PAUSE_PREFIX, GOAL_MODEL_CONFIG_PAUSE_PREFIX, GOAL_RUNTIME_PAUSE_PREFIX, GOAL_PROVIDER_FILTERED_PAUSE_REASON, GOAL_CONTINUATION_PROMPT, TurnFlow;
261521
261518
  var init_turn = __esmMin((() => {
261522
261519
  init_dist$4();
261523
261520
  init_src$4();
@@ -261534,7 +261531,7 @@ var init_turn = __esmMin((() => {
261534
261531
  init_tool_result_budget();
261535
261532
  init_user_message_offload();
261536
261533
  init_assistant_message_offload();
261537
- ({ CORE_TOOL_NAMES: BLUN_CORE_TOOL_NAMES, createDeferredToolLoader, mediaGenerationToolNamesForText, rememberDeferredToolAfterNotFound, toolSchemaBudgetTokens } = createRequire(import.meta.url)("./bin/turn-tool-performance-policy.cjs"));
261534
+ ({ CORE_TOOL_NAMES: BLUN_CORE_TOOL_NAMES, createDeferredToolLoader, mediaToolNamesForTurnText, rememberDeferredToolAfterNotFound, toolSchemaBudgetTokens } = createRequire(import.meta.url)("./bin/turn-tool-performance-policy.cjs"));
261538
261535
  ({ projectRecurringCronHistory } = createRequire(import.meta.url)("./bin/recurring-cron-history-policy.cjs"));
261539
261536
  ({ TelegramDeliveryLedger } = createRequire(import.meta.url)("./bin/repeated-user-message-projection.cjs"));
261540
261537
  ({ createRuntimeCognitiveTurnLifecycle } = createRequire(import.meta.url)("./bin/cognitive-turn-lifecycle.cjs"));
@@ -261542,7 +261539,7 @@ var init_turn = __esmMin((() => {
261542
261539
  ({ buildCognitiveWorkFocus } = createRequire(import.meta.url)("./bin/cognitive-work-focus.cjs"));
261543
261540
  ({ buildAttentionQueueItem } = createRequire(import.meta.url)("./bin/cognitive-attention-delivery.cjs"));
261544
261541
  BLUN_LEAN_TOOL_NAMES = new Set(BLUN_CORE_TOOL_NAMES);
261545
- BLUN_ATTACHMENT_MARKER_RE = /\b(?:attachment_file_id|telegram-anhang|telegram attachment)\b/i;
261542
+ BLUN_ATTACHMENT_MARKER_RE = /\b(?:attachment_file_id|image_path|telegram-anhang|telegram attachment)\b/i;
261546
261543
  BLUN_TELEGRAM_OUTBOUND_TOOL_RE = /^mcp__[^\s]*telegram[^\s]*__(?:reply|react|edit_message)$/i;
261547
261544
  BLUN_TELEGRAM_CHANNEL_RE = /<channel\b[^>]*\bsource=["']telegram["'][^>]*>/i;
261548
261545
  BLUN_TOOL_BUDGET_RATIO = .25;
@@ -262273,8 +262270,7 @@ var init_turn = __esmMin((() => {
262273
262270
  const turnThinkingEffort = turnHasAttachment ? void 0 : selectThinkingEffortForTurn(blunExtractText(blunThinkingIntentInput(input)), origin.kind);
262274
262271
  const fastConversation = turnThinkingEffort === "off" || turnThinkingEffort === "low";
262275
262272
  const pendingMediaJobIds = this.agent.toolServices?.media?.pendingMediaJobIds?.() ?? [];
262276
- const requiredToolNames = mediaGenerationToolNamesForText(blunExtractText(blunThinkingIntentInput(input)));
262277
- if (turnHasAttachment) requiredToolNames.add("mcp__plugin-telegram_telegram__download_attachment");
262273
+ const requiredToolNames = mediaToolNamesForTurnText(blunExtractText(input));
262278
262274
  const turnSystemPrompt = pendingMediaJobIds.length > 0 ? blunPendingMediaSystemPrompt(fastConversation ? this.agent.fastConversationSystemPrompt : this.agent.effectiveSystemPrompt, pendingMediaJobIds) : fastConversation ? this.agent.fastConversationSystemPrompt : void 0;
262279
262275
  const turnLLM = this.agent.llmForTurn(turnThinkingEffort, turnSystemPrompt);
262280
262276
  let previousStepToolOutcome = "initial";
@@ -262360,7 +262356,7 @@ var init_turn = __esmMin((() => {
262360
262356
  const steerThinkingEffort = "low";
262361
262357
  const steerPendingMediaJobIds = this.agent.toolServices?.media?.pendingMediaJobIds?.() ?? [];
262362
262358
  const steerLLM = this.agent.llmForTurn(steerThinkingEffort, blunPendingMediaSystemPrompt(this.agent.fastConversationSystemPrompt, steerPendingMediaJobIds));
262363
- const steerRequiredToolNames = mediaGenerationToolNamesForText(blunExtractText(blunThinkingIntentInput(steerInput)));
262359
+ const steerRequiredToolNames = mediaToolNamesForTurnText(blunExtractText(steerInput));
262364
262360
  const steerTools = [...blunFastConversationTools(eligibleTools, steerInput, steerPendingMediaJobIds, steerRequiredToolNames)];
262365
262361
  const steerHistory = () => blunFastConversationHistory(this.agent.context.history);
262366
262362
  const buildSteerMessages = () => this.agent.context.project(steerHistory(), { dropOrphanResults: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.382",
3
+ "version": "9.1.384",
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": {