mslxdff 0.1.90 → 0.1.91

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mslxdff",
3
- "version": "0.1.90",
3
+ "version": "0.1.91",
4
4
  "description": "测试项目,请勿使用。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,6 +4,16 @@ import { createTransport } from "../../transport/index.js";
4
4
 
5
5
  function genSessionId() { return `sess_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`; }
6
6
 
7
+ // stripProviderPrefix 去掉本地供应商前缀,发上游用裸模型 id。
8
+ // 上游(对标 cline2api-workers MODELS)只认裸 id:"deepseek/deepseek-v4-flash"、
9
+ // "poolside/laguna-s-2.1:free";本地 "clinebot/deepseek/..." 需取后两段。
10
+ // 两段及以内视为已是裸 id,原样透传。
11
+ function stripProviderPrefix(id) {
12
+ const parts = String(id || "").split("/").filter(Boolean);
13
+ if (parts.length > 2) return parts.slice(1).join("/");
14
+ return String(id || "");
15
+ }
16
+
7
17
  function unwrapData(obj) {
8
18
  if (obj && obj.data && typeof obj.data === "object") {
9
19
  const d = obj.data;
@@ -144,7 +154,7 @@ export function createChatService({
144
154
  const model = body?.model || "deepseek/deepseek-v4-flash";
145
155
  const sessionId = genSessionId();
146
156
  const isStream = body?.stream === true;
147
- const upstreamModel = String(model).split("/").pop().includes(":") ? model : model;
157
+ const upstreamModel = stripProviderPrefix(model);
148
158
  const upstreamBody = {
149
159
  model: upstreamModel,
150
160
  max_tokens: body?.max_tokens || body?.max_completion_tokens || 4096,
@@ -171,7 +181,10 @@ export function createChatService({
171
181
  return new Response(JSON.stringify(ret.data), { status: 200, headers: hdrs });
172
182
  }
173
183
  const raw = await resp.json().catch(() => null);
174
- if (!raw) return resp;
184
+ if (!raw || typeof raw !== "object") {
185
+ if (!raw) return resp;
186
+ return new Response(JSON.stringify({ error: { message: "upstream returned non-JSON body", type: "api_error" } }), { status: 502, headers: { "Content-Type": "application/json" } });
187
+ }
175
188
  const normalized = unwrapData(raw);
176
189
  normalized.model = model;
177
190
  return new Response(JSON.stringify(normalized), { status: 200, headers: { "Content-Type": "application/json" } });