blun-king-cli 9.1.109 → 9.1.111

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.
Files changed (2) hide show
  1. package/blun.mjs +13 -6
  2. package/package.json +1 -1
package/blun.mjs CHANGED
@@ -1654,9 +1654,11 @@ var init_errors$10 = __esmMin((() => {
1654
1654
  }
1655
1655
  };
1656
1656
  APIProviderRateLimitError = class extends APIStatusError {
1657
- constructor(message, requestId) {
1657
+ retryAfterMs;
1658
+ constructor(message, requestId, retryAfterMs) {
1658
1659
  super(429, message, requestId);
1659
1660
  this.name = "APIProviderRateLimitError";
1661
+ this.retryAfterMs = typeof retryAfterMs === "number" && Number.isFinite(retryAfterMs) && retryAfterMs >= 0 ? retryAfterMs : null;
1660
1662
  }
1661
1663
  };
1662
1664
  APIPaymentRequiredError = class extends APIStatusError {
@@ -1849,6 +1851,7 @@ async function responseError(response) {
1849
1851
  apiCode: code,
1850
1852
  retryAfterMs: retryAfterHeaderMs(response.headers)
1851
1853
  });
1854
+ if (response.status === 429) return new APIProviderRateLimitError(message, requestId, retryAfterHeaderMs(response.headers));
1852
1855
  return normalizeAPIStatusError(response.status, message, requestId);
1853
1856
  }
1854
1857
  function retryAfterHeaderMs(headers) {
@@ -30322,7 +30325,7 @@ async function chatWithRetry(input) {
30322
30325
  logRequestFailure(input, error, attempt, maxAttempts);
30323
30326
  throw error;
30324
30327
  }
30325
- const delayMs = delays[attempt - 1] ?? 0;
30328
+ const delayMs = retryDelayForError(error, delays[attempt - 1] ?? 0);
30326
30329
  input.params.signal.throwIfAborted();
30327
30330
  input.dispatchEvent({
30328
30331
  type: "step.retrying",
@@ -30338,6 +30341,10 @@ async function chatWithRetry(input) {
30338
30341
  await sleepForRetry(delayMs, input.params.signal);
30339
30342
  }
30340
30343
  }
30344
+ function retryDelayForError(error, fallbackDelayMs) {
30345
+ if (!(error instanceof APIProviderRateLimitError) || error.retryAfterMs === null) return fallbackDelayMs;
30346
+ return Math.max(fallbackDelayMs, error.retryAfterMs);
30347
+ }
30341
30348
  function logRequestFailure(input, error, attempt, maxAttempts) {
30342
30349
  if (isAbortError$4(error) || input.params.signal.aborted) return;
30343
30350
  input.log?.warn("llm request failed", {
@@ -257727,7 +257734,7 @@ var init_rg_locator = __esmMin((() => {
257727
257734
  import_yauzl$2 = require_yauzl();
257728
257735
  init_abort();
257729
257736
  RG_VERSION = "15.0.0";
257730
- RG_BASE_URL = "https://blun.ai/blun/rg";
257737
+ RG_BASE_URL = `https://github.com/BurntSushi/ripgrep/releases/download/${RG_VERSION}`;
257731
257738
  DOWNLOAD_TIMEOUT_MS$1 = 6e5;
257732
257739
  RG_ARCHIVE_SHA256 = {
257733
257740
  "ripgrep-15.0.0-aarch64-apple-darwin.tar.gz": "98bb2e61e7277ba0ea72d2ae2592497fd8d2940934a16b122448d302a6637e3b",
@@ -260577,12 +260584,12 @@ function blunFastConversationTools(tools, input, pendingMediaJobIds = []) {
260577
260584
  * name through ToolSearch. The absolute cap prevents large context windows
260578
260585
  * from turning every deferred schema into permanent request overhead.
260579
260586
  */
260580
- function blunSelectTurnTools(tools, maxContextTokens, loadedToolNames) {
260587
+ function blunSelectTurnTools(tools, maxContextTokens, loadedToolNames, requiredToolNames = /* @__PURE__ */ new Set()) {
260581
260588
  if (estimateTokensForTools(tools) <= toolSchemaBudgetTokens(maxContextTokens)) return {
260582
260589
  tools,
260583
260590
  deferredToolCount: 0
260584
260591
  };
260585
- const selected = tools.filter((tool) => BLUN_LEAN_TOOL_NAMES.has(tool.name) || loadedToolNames.has(tool.name));
260592
+ const selected = tools.filter((tool) => BLUN_LEAN_TOOL_NAMES.has(tool.name) || loadedToolNames.has(tool.name) || requiredToolNames.has(tool.name));
260586
260593
  const selectedNames = new Set(selected.map((tool) => tool.name));
260587
260594
  const deferred = tools.filter((tool) => !selectedNames.has(tool.name));
260588
260595
  if (deferred.length > 0) selected.push(createDeferredToolLoader(selected, deferred, loadedToolNames));
@@ -261423,7 +261430,7 @@ var init_turn = __esmMin((() => {
261423
261430
  const toolSelection = fastConversation ? {
261424
261431
  tools: [...blunFastConversationTools(eligibleTools, input, pendingMediaJobIds)],
261425
261432
  deferredToolCount: 0
261426
- } : turnNeedsTools ? blunSelectTurnTools(eligibleTools, this.agent.config.modelCapabilities?.max_context_tokens, this.loadedToolNames) : {
261433
+ } : turnNeedsTools ? blunSelectTurnTools(eligibleTools, this.agent.config.modelCapabilities?.max_context_tokens, this.loadedToolNames, turnHasAttachment ? new Set(["mcp__plugin-telegram_telegram__download_attachment"]) : void 0) : {
261427
261434
  tools: [],
261428
261435
  deferredToolCount: 0
261429
261436
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.109",
3
+ "version": "9.1.111",
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": {