mslxdff 0.1.144 → 0.1.145

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.144",
3
+ "version": "0.1.145",
4
4
  "description": "测试项目,请勿使用。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -51,10 +51,19 @@ export function createModelsService({ id, baseUrl, modelsPath, fetchImpl, dispat
51
51
  const res = await fetchImpl(url, opts);
52
52
  if (!res.ok) return fallbackList();
53
53
  const json = await res.json().catch(() => ({}));
54
- if (isClineBotHost(resolvedBase) && Array.isArray(json.free)) {
55
- const out = json.free.filter((m) => m && typeof m.id === "string").map((m) => ({ ...m, id: joinModelId(id, m.id) }));
56
- if (!out.length) return fallbackList();
57
- cache = out; fetchedAt = now; return out;
54
+ if (isClineBotHost(resolvedBase) && json && typeof json === "object") {
55
+ const all = [];
56
+ for (const k of ["free", "clinePass"]) {
57
+ const arr = Array.isArray(json[k]) ? json[k] : null;
58
+ if (!arr || !arr.length) continue;
59
+ for (const m of arr) {
60
+ if (!m || typeof m.id !== "string") continue;
61
+ const mid = joinModelId(id, m.id);
62
+ if (!all.some((x) => x.id === mid)) all.push({ ...m, id: mid });
63
+ }
64
+ }
65
+ if (!all.length) return fallbackList();
66
+ cache = all; fetchedAt = now; return all;
58
67
  }
59
68
  const raw = Array.isArray(json.data) ? json.data : Array.isArray(json.models) ? json.models : Array.isArray(json) ? json : [];
60
69
  const out = raw.filter((m) => m && typeof m.id === "string").map((m) => ({ ...m, id: joinModelId(id, m.id) }));
@@ -108,8 +117,8 @@ export function createModelsService({ id, baseUrl, modelsPath, fetchImpl, dispat
108
117
  return { ok: httpOk, status: cat.status, ...(httpOk ? {} : { error: cat.error }), ms: ms() };
109
118
  }
110
119
  const valid = cat.models;
111
- cache = valid.map((m) => ({ ...m, id: joinModelId(id, m.id) }));
112
- fetchedAt = Date.now();
120
+ // 注意:只做快照 diff,不碰 listModels 的合并缓存——缓存里是 free+clinePass 全量,
121
+ // 这里 cat.models 只有 free,写进去会把 pass 挤掉 10 分钟(daemon 启动后 /v1/models 就缺 pass)。
113
122
  let change = null;
114
123
  if (snapshotPath) { try { change = detectFreeChanges(valid.map((m) => m.id)); } catch {} }
115
124
  return {