reasonix 0.5.21 → 0.5.23

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/dist/cli/index.js CHANGED
@@ -196,7 +196,7 @@ var DeepSeekClient = class {
196
196
  }
197
197
  this.apiKey = apiKey;
198
198
  this.baseUrl = (opts.baseUrl ?? process.env.DEEPSEEK_BASE_URL ?? "https://api.deepseek.com").replace(/\/+$/, "");
199
- this.timeoutMs = opts.timeoutMs ?? 12e4;
199
+ this.timeoutMs = opts.timeoutMs ?? 66e4;
200
200
  this._fetch = opts.fetch ?? globalThis.fetch.bind(globalThis);
201
201
  this.retry = opts.retry ?? {};
202
202
  }
@@ -2645,10 +2645,41 @@ function formatLoopError(err) {
2645
2645
  if (msg.includes("maximum context length")) {
2646
2646
  const reqMatch = msg.match(/requested\s+(\d+)\s+tokens/);
2647
2647
  const requested = reqMatch ? `${Number(reqMatch[1]).toLocaleString()} tokens` : "too many tokens";
2648
- return `Context overflow (DeepSeek 400): session history is ${requested}, past the 131,072-token limit. Usually this means a single tool call returned a huge payload. v0.3.0-alpha.6+ caps new tool results at 32k chars, AND auto-heals oversized history on session load \u2014 restart Reasonix and this session should come back trimmed. If it still overflows, run /forget (delete the session) or /clear (drop the displayed history) to start fresh.`;
2648
+ return `Context overflow (DeepSeek 400): session history is ${requested}, past the model's prompt limit (V4: 1M tokens; legacy chat/reasoner: 131k). Usually a single tool result grew too big. Reasonix caps new tool results at 8k tokens and auto-heals oversized history on session load \u2014 a restart often clears it. If it still overflows, run /forget (delete the session) or /clear (drop the displayed history) to start fresh.`;
2649
+ }
2650
+ const m = /^DeepSeek (\d{3}):\s*([\s\S]*)$/.exec(msg);
2651
+ if (!m) return msg;
2652
+ const status = m[1] ?? "";
2653
+ const body = m[2] ?? "";
2654
+ const inner = extractDeepSeekErrorMessage(body);
2655
+ if (status === "401") {
2656
+ return `Authentication failed (DeepSeek 401): ${inner}. Your API key is rejected. Fix with \`reasonix setup\` or \`export DEEPSEEK_API_KEY=sk-...\`. Get one at https://platform.deepseek.com/api_keys.`;
2657
+ }
2658
+ if (status === "402") {
2659
+ return `Out of balance (DeepSeek 402): ${inner}. Top up at https://platform.deepseek.com/top_up \u2014 the panel header shows your balance once it's non-zero.`;
2660
+ }
2661
+ if (status === "422") {
2662
+ return `Invalid parameter (DeepSeek 422): ${inner}`;
2663
+ }
2664
+ if (status === "400") {
2665
+ return `Bad request (DeepSeek 400): ${inner}`;
2649
2666
  }
2650
2667
  return msg;
2651
2668
  }
2669
+ function extractDeepSeekErrorMessage(body) {
2670
+ const trimmed = body.trim();
2671
+ if (!trimmed) return "(no message)";
2672
+ try {
2673
+ const parsed = JSON.parse(trimmed);
2674
+ if (parsed && typeof parsed === "object") {
2675
+ const obj = parsed;
2676
+ if (obj.error && typeof obj.error.message === "string") return obj.error.message;
2677
+ if (typeof obj.message === "string") return obj.message;
2678
+ }
2679
+ } catch {
2680
+ }
2681
+ return trimmed;
2682
+ }
2652
2683
 
2653
2684
  // src/at-mentions.ts
2654
2685
  import { existsSync as existsSync4, readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as statSync2 } from "fs";