blun-king-cli 9.1.183 → 9.1.184
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/turn-tool-performance-policy.cjs +29 -2
- package/blun.mjs +10 -7
- package/package.json +1 -1
|
@@ -29,11 +29,37 @@ const CORE_TOOL_NAMES = Object.freeze([
|
|
|
29
29
|
'Grep',
|
|
30
30
|
'Write',
|
|
31
31
|
'Glob',
|
|
32
|
-
'GenerateImage',
|
|
33
|
-
'GenerateVideo',
|
|
34
32
|
'mcp__plugin-telegram_telegram__reply',
|
|
35
33
|
]);
|
|
36
34
|
|
|
35
|
+
const IMAGE_MEDIA_TERM_RE = /(?:^|[^\p{L}])(?:bild(?:er)?|foto(?:s)?|grafik(?:en)?|illustration(?:en)?|logo(?:s)?|image|images|photo|photos|picture|pictures|illustration|illustrations|visual|visuals)(?=$|[^\p{L}])/u;
|
|
36
|
+
const VIDEO_MEDIA_TERM_RE = /(?:^|[^\p{L}])(?:video(?:s)?|clip(?:s)?|film(?:e)?|animation(?:en)?|movie|movies)(?=$|[^\p{L}])/u;
|
|
37
|
+
const ANIMATE_ACTION_RE = /(?:^|[^\p{L}])(?:animier(?:e|en|t)?|animate|animated|animating)(?=$|[^\p{L}])/u;
|
|
38
|
+
const CREATE_ACTION_RE = /(?:^|[^\p{L}])(?:erstell(?:e|en|t)?|generier(?:e|en|t)?|erzeug(?:e|en|t)?|produzier(?:e|en|t)?|zeichn(?:e|en|et)?|mal(?:e|en|t)?|render(?:e|n|t)?|mach(?:e|en|t)?|create|creates|creating|generate|generates|generating|make|makes|making|draw|draws|drawing|paint|paints|painting|render|renders|rendering|produce|produces|producing)(?=$|[^\p{L}])/u;
|
|
39
|
+
const REQUEST_PREFIX_RE = /^(?:bitte\s+|please\s+)?(?:erstell|generier|erzeug|produzier|zeichn|mal|render|mach|animier|create|generate|make|draw|paint|render|produce|animate)/u;
|
|
40
|
+
const REQUEST_PHRASE_RE = /(?:^|[^\p{L}])(?:bitte|kannst du|könntest du|ich möchte|ich will|ich brauche|please|can you|could you|i want|i need)(?=$|[^\p{L}])/u;
|
|
41
|
+
|
|
42
|
+
function mediaGenerationToolNamesForText(value) {
|
|
43
|
+
const text = String(value || '').normalize('NFKC').trim().toLowerCase();
|
|
44
|
+
const selected = new Set();
|
|
45
|
+
if (!text) return selected;
|
|
46
|
+
if (/(?:^|[^a-z])generateimage(?=$|[^a-z])/u.test(text)) selected.add('GenerateImage');
|
|
47
|
+
if (/(?:^|[^a-z])generatevideo(?=$|[^a-z])/u.test(text)) selected.add('GenerateVideo');
|
|
48
|
+
if (selected.size > 0) return selected;
|
|
49
|
+
|
|
50
|
+
const animate = ANIMATE_ACTION_RE.test(text);
|
|
51
|
+
const create = CREATE_ACTION_RE.test(text);
|
|
52
|
+
const explicitRequest = REQUEST_PREFIX_RE.test(text) || REQUEST_PHRASE_RE.test(text);
|
|
53
|
+
if (!explicitRequest || (!create && !animate)) return selected;
|
|
54
|
+
if (animate && (IMAGE_MEDIA_TERM_RE.test(text) || VIDEO_MEDIA_TERM_RE.test(text))) {
|
|
55
|
+
selected.add('GenerateVideo');
|
|
56
|
+
return selected;
|
|
57
|
+
}
|
|
58
|
+
if (IMAGE_MEDIA_TERM_RE.test(text)) selected.add('GenerateImage');
|
|
59
|
+
if (VIDEO_MEDIA_TERM_RE.test(text)) selected.add('GenerateVideo');
|
|
60
|
+
return selected;
|
|
61
|
+
}
|
|
62
|
+
|
|
37
63
|
function toolSchemaBudgetTokens(maxContextTokens) {
|
|
38
64
|
const context = Number(maxContextTokens);
|
|
39
65
|
if (!Number.isFinite(context) || context <= 0) return TOOL_SCHEMA_MAX_TOKENS;
|
|
@@ -247,5 +273,6 @@ module.exports = {
|
|
|
247
273
|
createDeferredToolLoader,
|
|
248
274
|
deferredToolCatalog,
|
|
249
275
|
deferredToolNames,
|
|
276
|
+
mediaGenerationToolNamesForText,
|
|
250
277
|
toolSchemaBudgetTokens,
|
|
251
278
|
};
|
package/blun.mjs
CHANGED
|
@@ -260959,10 +260959,10 @@ function blunPendingMediaSystemPrompt(systemPrompt, pendingMediaJobIds) {
|
|
|
260959
260959
|
if (pendingMediaJobIds.length === 0) return systemPrompt;
|
|
260960
260960
|
return `${systemPrompt}\n\n## Pending BLUN media\n\nThe following media jobs were already accepted and are still pending: ${pendingMediaJobIds.join(", ")}. Call GetMedia exactly once for each listed id before replying. If a job is still processing, report that status truthfully and wait for a later turn; do not claim that media tools are unavailable.`;
|
|
260961
260961
|
}
|
|
260962
|
-
function blunFastConversationTools(tools, input, pendingMediaJobIds = []) {
|
|
260962
|
+
function blunFastConversationTools(tools, input, pendingMediaJobIds = [], requiredToolNames = /* @__PURE__ */ new Set()) {
|
|
260963
260963
|
const telegramTurn = BLUN_TELEGRAM_CHANNEL_RE.test(blunExtractText(input));
|
|
260964
260964
|
const mediaPending = pendingMediaJobIds.length > 0;
|
|
260965
|
-
return tools.filter((tool) => telegramTurn && BLUN_TELEGRAM_OUTBOUND_TOOL_RE.test(tool.name) || mediaPending && tool.name === "GetMedia");
|
|
260965
|
+
return tools.filter((tool) => telegramTurn && BLUN_TELEGRAM_OUTBOUND_TOOL_RE.test(tool.name) || mediaPending && tool.name === "GetMedia" || requiredToolNames.has(tool.name));
|
|
260966
260966
|
}
|
|
260967
260967
|
/**
|
|
260968
260968
|
* Keep frequently used native tools resident and expose every other tool by
|
|
@@ -261208,7 +261208,7 @@ function toolResultText(result) {
|
|
|
261208
261208
|
function abandonedToolResultOutput(ended) {
|
|
261209
261209
|
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.`;
|
|
261210
261210
|
}
|
|
261211
|
-
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, toolSchemaBudgetTokens, projectRecurringCronHistory, 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;
|
|
261211
|
+
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, toolSchemaBudgetTokens, projectRecurringCronHistory, 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;
|
|
261212
261212
|
var init_turn = __esmMin((() => {
|
|
261213
261213
|
init_dist$4();
|
|
261214
261214
|
init_src$4();
|
|
@@ -261225,7 +261225,7 @@ var init_turn = __esmMin((() => {
|
|
|
261225
261225
|
init_tool_result_budget();
|
|
261226
261226
|
init_user_message_offload();
|
|
261227
261227
|
init_assistant_message_offload();
|
|
261228
|
-
({ CORE_TOOL_NAMES: BLUN_CORE_TOOL_NAMES, createDeferredToolLoader, toolSchemaBudgetTokens } = createRequire(import.meta.url)("./bin/turn-tool-performance-policy.cjs"));
|
|
261228
|
+
({ CORE_TOOL_NAMES: BLUN_CORE_TOOL_NAMES, createDeferredToolLoader, mediaGenerationToolNamesForText, toolSchemaBudgetTokens } = createRequire(import.meta.url)("./bin/turn-tool-performance-policy.cjs"));
|
|
261229
261229
|
({ projectRecurringCronHistory } = createRequire(import.meta.url)("./bin/recurring-cron-history-policy.cjs"));
|
|
261230
261230
|
BLUN_LEAN_TOOL_NAMES = new Set(BLUN_CORE_TOOL_NAMES);
|
|
261231
261231
|
BLUN_ATTACHMENT_MARKER_RE = /\b(?:attachment_file_id|telegram-anhang|telegram attachment)\b/i;
|
|
@@ -261800,6 +261800,8 @@ var init_turn = __esmMin((() => {
|
|
|
261800
261800
|
const turnThinkingEffort = turnHasAttachment ? void 0 : selectThinkingEffortForTurn(blunExtractText(blunThinkingIntentInput(input)), origin.kind);
|
|
261801
261801
|
const fastConversation = turnThinkingEffort === "off" || turnThinkingEffort === "low";
|
|
261802
261802
|
const pendingMediaJobIds = this.agent.toolServices?.media?.pendingMediaJobIds?.() ?? [];
|
|
261803
|
+
const requiredToolNames = mediaGenerationToolNamesForText(blunExtractText(blunThinkingIntentInput(input)));
|
|
261804
|
+
if (turnHasAttachment) requiredToolNames.add("mcp__plugin-telegram_telegram__download_attachment");
|
|
261803
261805
|
const turnSystemPrompt = pendingMediaJobIds.length > 0 ? blunPendingMediaSystemPrompt(fastConversation ? this.agent.fastConversationSystemPrompt : this.agent.effectiveSystemPrompt, pendingMediaJobIds) : fastConversation ? this.agent.fastConversationSystemPrompt : void 0;
|
|
261804
261806
|
const turnLLM = this.agent.llmForTurn(turnThinkingEffort, turnSystemPrompt);
|
|
261805
261807
|
let previousStepToolOutcome = "initial";
|
|
@@ -261815,9 +261817,9 @@ var init_turn = __esmMin((() => {
|
|
|
261815
261817
|
const compactConversationTool = originTools.find((tool) => tool.name === "CompactConversation");
|
|
261816
261818
|
const eligibleTools = originTools.filter((tool) => tool.name !== "CompactConversation" || this.agent.fullCompaction.isProactiveCompactionEligible());
|
|
261817
261819
|
const toolSelection = fastConversation ? {
|
|
261818
|
-
tools: [...blunFastConversationTools(eligibleTools, input, pendingMediaJobIds)],
|
|
261820
|
+
tools: [...blunFastConversationTools(eligibleTools, input, pendingMediaJobIds, requiredToolNames)],
|
|
261819
261821
|
deferredToolCount: 0
|
|
261820
|
-
} : turnNeedsTools ? blunSelectTurnTools(eligibleTools, this.agent.config.modelCapabilities?.max_context_tokens, this.loadedToolNames,
|
|
261822
|
+
} : turnNeedsTools ? blunSelectTurnTools(eligibleTools, this.agent.config.modelCapabilities?.max_context_tokens, this.loadedToolNames, requiredToolNames) : {
|
|
261821
261823
|
tools: [],
|
|
261822
261824
|
deferredToolCount: 0
|
|
261823
261825
|
};
|
|
@@ -261884,7 +261886,8 @@ var init_turn = __esmMin((() => {
|
|
|
261884
261886
|
const steerThinkingEffort = "low";
|
|
261885
261887
|
const steerPendingMediaJobIds = this.agent.toolServices?.media?.pendingMediaJobIds?.() ?? [];
|
|
261886
261888
|
const steerLLM = this.agent.llmForTurn(steerThinkingEffort, blunPendingMediaSystemPrompt(this.agent.fastConversationSystemPrompt, steerPendingMediaJobIds));
|
|
261887
|
-
const
|
|
261889
|
+
const steerRequiredToolNames = mediaGenerationToolNamesForText(blunExtractText(blunThinkingIntentInput(steerInput)));
|
|
261890
|
+
const steerTools = [...blunFastConversationTools(eligibleTools, steerInput, steerPendingMediaJobIds, steerRequiredToolNames)];
|
|
261888
261891
|
const steerHistory = () => blunFastConversationHistory(this.agent.context.history);
|
|
261889
261892
|
const buildSteerMessages = () => this.agent.context.project(steerHistory(), { dropOrphanResults: true });
|
|
261890
261893
|
const buildSteerMessagesStrict = () => this.agent.context.project(steerHistory(), {
|