@zhongqian97-code/ecode 0.3.7 → 0.3.8

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/dist/index.js +30 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -38,7 +38,11 @@ var MODEL_CONTEXT_LIMITS = {
38
38
  "claude-haiku-4-5-20251001": 2e5,
39
39
  // DeepSeek 系列(上下文较小,截断策略需更激进)
40
40
  "deepseek-chat": 65536,
41
- "deepseek-reasoner": 65536
41
+ "deepseek-reasoner": 65536,
42
+ // MiniMax 系列(baseUrl: https://api.minimax.chat/v1)
43
+ "MiniMax-M2.5": 1e6,
44
+ "MiniMax-M2.5-highspeed": 192e3,
45
+ "MiniMax-Text-01": 1e6
42
46
  };
43
47
  var DEFAULT_CONTEXT_LIMIT = 128e3;
44
48
  function getContextLimit(model, override) {
@@ -159,6 +163,7 @@ function createOpenAIProvider(profile) {
159
163
  );
160
164
  const tcAccumulator = /* @__PURE__ */ new Map();
161
165
  let reasoningAccumulator = "";
166
+ const reasoningDetailsAcc = /* @__PURE__ */ new Map();
162
167
  for await (const chunk of response) {
163
168
  const choice = chunk.choices[0];
164
169
  if (!choice) continue;
@@ -166,6 +171,26 @@ function createOpenAIProvider(profile) {
166
171
  if (delta.reasoning_content) {
167
172
  reasoningAccumulator += delta.reasoning_content;
168
173
  }
174
+ if (delta.reasoning_details && delta.reasoning_details.length > 0) {
175
+ for (const rd of delta.reasoning_details) {
176
+ const id = rd.id ?? "";
177
+ const text = rd.text ?? "";
178
+ if (!reasoningDetailsAcc.has(id)) {
179
+ reasoningDetailsAcc.set(id, {
180
+ type: rd.type ?? "reasoning.text",
181
+ id,
182
+ format: rd.format ?? "",
183
+ index: rd.index ?? 0,
184
+ text: ""
185
+ });
186
+ }
187
+ const existing = reasoningDetailsAcc.get(id);
188
+ existing.text += text;
189
+ if (!delta.reasoning_content && text) {
190
+ reasoningAccumulator += text;
191
+ }
192
+ }
193
+ }
169
194
  if (delta.tool_calls) {
170
195
  for (const tc of delta.tool_calls) {
171
196
  if (!tcAccumulator.has(tc.index)) {
@@ -192,6 +217,8 @@ function createOpenAIProvider(profile) {
192
217
  // 让调用方用 if (chunk.toolCalls) 做简洁判断
193
218
  toolCalls: tcAccumulator.size > 0 ? Array.from(tcAccumulator.values()) : void 0,
194
219
  reasoning: reasoningAccumulator || void 0,
220
+ // reasoningDetails 仅在流中出现过结构化推理时返回(MiniMax 兼容)
221
+ reasoningDetails: reasoningDetailsAcc.size > 0 ? Array.from(reasoningDetailsAcc.values()) : void 0,
195
222
  // 将 snake_case 的原始字段映射为 camelCase,对外接口保持一致
196
223
  usage: rawUsage ? {
197
224
  promptTokens: rawUsage.prompt_tokens,
@@ -200,9 +227,10 @@ function createOpenAIProvider(profile) {
200
227
  } : void 0
201
228
  };
202
229
  } else {
230
+ const incrementalReasoning = delta.reasoning_content ?? (delta.reasoning_details && delta.reasoning_details.length > 0 ? delta.reasoning_details.map((rd) => rd.text ?? "").join("") : void 0);
203
231
  yield {
204
232
  text: delta.content ?? "",
205
- reasoning: delta.reasoning_content,
233
+ reasoning: incrementalReasoning,
206
234
  done: false
207
235
  };
208
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhongqian97-code/ecode",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "A minimal Claude Code clone with REPL interface and bash tool calling",
5
5
  "type": "module",
6
6
  "author": "zhongqian97-code",