blun-king-cli 9.1.286 → 9.1.287

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.
@@ -4,6 +4,7 @@ const TOOL_SCHEMA_BUDGET_RATIO = 0.25;
4
4
  const TOOL_SCHEMA_MAX_TOKENS = 32_000;
5
5
  const DEFERRED_TOOL_LOADER_NAME = 'ToolSearch';
6
6
  const MAX_PERSISTENT_DEFERRED_TOOLS = 4;
7
+ const MAX_TOOL_SEARCH_QUERY_CHARS = 1_000;
7
8
  const TOOL_SEARCH_INTENT_WORDS = new Set([
8
9
  'find', 'fetch', 'get', 'holen', 'list', 'read', 'search', 'show', 'anzeigen', 'lesen', 'suchen',
9
10
  ]);
@@ -83,8 +84,18 @@ function deferredToolCatalog(tools) {
83
84
  .sort((left, right) => left.localeCompare(right));
84
85
  }
85
86
 
87
+ function normalizeDeferredToolQuery(value) {
88
+ const query = String(value ?? '').trim();
89
+ if (query.length <= MAX_TOOL_SEARCH_QUERY_CHARS) return query;
90
+ const bounded = query.slice(0, MAX_TOOL_SEARCH_QUERY_CHARS);
91
+ const wordBoundary = bounded.lastIndexOf(' ');
92
+ return (wordBoundary >= MAX_TOOL_SEARCH_QUERY_CHARS * 0.8
93
+ ? bounded.slice(0, wordBoundary)
94
+ : bounded).trimEnd();
95
+ }
96
+
86
97
  function searchDeferredTools(tools, query) {
87
- const normalized = String(query || '').trim().toLowerCase();
98
+ const normalized = normalizeDeferredToolQuery(query).toLowerCase();
88
99
  if (!normalized) return [];
89
100
  if (normalized.startsWith('select:')) {
90
101
  const selector = normalized.slice('select:'.length).trim();
@@ -132,7 +143,7 @@ function relatedSearchTerms(token) {
132
143
  }
133
144
 
134
145
  function searchRelatedDeferredTools(tools, query, options = {}) {
135
- const normalized = String(query || '').trim().toLowerCase();
146
+ const normalized = normalizeDeferredToolQuery(query).toLowerCase();
136
147
  if (!normalized || normalized.startsWith('select:')) return [];
137
148
  const tokens = normalized.split(/\s+/).filter(Boolean);
138
149
  const requestedNameTokens = tokens
@@ -230,6 +241,7 @@ function createDeferredToolLoader(selectedTools, deferredTools, loadedToolNames
230
241
  properties: {
231
242
  query: {
232
243
  type: 'string',
244
+ maxLength: MAX_TOOL_SEARCH_QUERY_CHARS,
233
245
  description: 'Exact selection or keyword query, for example select:download_attachment or +slack send.',
234
246
  },
235
247
  },
@@ -237,7 +249,7 @@ function createDeferredToolLoader(selectedTools, deferredTools, loadedToolNames
237
249
  additionalProperties: false,
238
250
  },
239
251
  resolveExecution(args) {
240
- const query = String(args?.query || '').trim();
252
+ const query = normalizeDeferredToolQuery(args?.query);
241
253
  return {
242
254
  description: query ? `Searching tool schemas for ${query}` : 'Searching tool schemas',
243
255
  approvalRule: DEFERRED_TOOL_LOADER_NAME,
@@ -302,12 +314,14 @@ module.exports = {
302
314
  CORE_TOOL_NAMES,
303
315
  DEFERRED_TOOL_LOADER_NAME,
304
316
  MAX_PERSISTENT_DEFERRED_TOOLS,
317
+ MAX_TOOL_SEARCH_QUERY_CHARS,
305
318
  TOOL_SCHEMA_BUDGET_RATIO,
306
319
  TOOL_SCHEMA_MAX_TOKENS,
307
320
  createDeferredToolLoader,
308
321
  deferredToolCatalog,
309
322
  deferredToolNames,
310
323
  mediaGenerationToolNamesForText,
324
+ normalizeDeferredToolQuery,
311
325
  rememberDeferredToolAfterNotFound,
312
326
  toolSchemaBudgetTokens,
313
327
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.286",
3
+ "version": "9.1.287",
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": {