mslxdff 0.1.127 → 0.1.128

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.127",
3
+ "version": "0.1.128",
4
4
  "description": "测试项目,请勿使用。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -117,10 +117,10 @@ export function createClineProvider({
117
117
  return list;
118
118
  }
119
119
 
120
- const { preheat } = (() => {
121
- try { return modelsSvc; } catch { return { preheat: async () => ({ ok: false }) }; }
120
+ const { preheat, checkFreeUpdates } = (() => {
121
+ try { return modelsSvc; } catch { return { preheat: async () => ({ ok: false }), checkFreeUpdates: async () => ({ ok: false }) }; }
122
122
  })();
123
123
 
124
124
  async function close() { if (agent?.close) try { await agent.close(); } catch {} }
125
- return { id, chat, chatWithKeys, listModels, preheat, close, agent, keyRing: ring, baseUrl: resolvedBase, _authPool: authPool };
125
+ return { id, chat, chatWithKeys, listModels, preheat, checkFreeUpdates, close, agent, keyRing: ring, baseUrl: resolvedBase, _authPool: authPool };
126
126
  }
@@ -71,9 +71,9 @@ export function createModelsService({ id, baseUrl, modelsPath, fetchImpl, dispat
71
71
  } catch { return fallbackList(); } finally { clearTimeout(timer); }
72
72
  }
73
73
 
74
- // 每次 daemon 启动(server-lifecycle → dispatcher.preheat)自检 free 列表:
74
+ // 每次 daemon 启动自检 free 列表(server-lifecycle 显式调 checkFreeUpdates,不经 dispatcher.preheat):
75
75
  // 对比快照报增删并留痕(daemon.log),顺带把结果填缓存(省一次 listModels 请求)。
76
- // 快照路径由 index.js 注入 logDir 下文件;未注入时仅跳过自检,不影响预热。
76
+ // 快照路径由 index.js 注入 logDir 下文件;未注入时仅跳过自检,不影响拉取。
77
77
  function readSnapshotFree() {
78
78
  try { const j = JSON.parse(readFileSync(snapshotPath, "utf8")); return Array.isArray(j?.free) ? j.free : null; } catch { return null; }
79
79
  }
@@ -104,7 +104,8 @@ export function createModelsService({ id, baseUrl, modelsPath, fetchImpl, dispat
104
104
  return { added, removed };
105
105
  }
106
106
 
107
- async function preheat() {
107
+ // 启动自检入口:拉 recommended-models → 填缓存 → 对比快照报 free 增删。
108
+ async function checkFreeUpdates() {
108
109
  const url = resolveModelsUrl();
109
110
  const t0 = performance.now();
110
111
  try {
@@ -142,5 +143,10 @@ export function createModelsService({ id, baseUrl, modelsPath, fetchImpl, dispat
142
143
  }
143
144
  }
144
145
 
145
- return { listModels, preheat };
146
+ // preheat 保留为别名:dispatcher 已不再调 clinebot,手动/测试/未来钩子仍可用,行为与自检一致
147
+ async function preheat() {
148
+ return checkFreeUpdates();
149
+ }
150
+
151
+ return { listModels, preheat, checkFreeUpdates };
146
152
  }
@@ -92,17 +92,18 @@ export function createProviderDispatcher(providers = [], opts = {}) {
92
92
  return out;
93
93
  }
94
94
 
95
+ // 只预热默认供应商(opencode):连接池与模型缓存预热是其主链路收益;
96
+ // 其他供应商按需在首次请求时自拉(10min 缓存)。不再逐家预热,避免 daemon 每次启动
97
+ // 对所有上游各发一次 GET;MSLXDFF_PREHEAT=0 的关闭由唯一被调的 opencode preheat 自行尊重。
98
+ // 见 .agents/notes/implemented/simplification/2026-09-16-preheat-opencode-only.md
95
99
  async function preheat() {
96
- const results = [];
97
- for (const p of providers) {
98
- if (typeof p.preheat !== "function") continue;
99
- try {
100
- results.push(await p.preheat());
101
- } catch {
102
- results.push({ ok: false, error: "preheat failed" });
103
- }
100
+ const p = byId.get(DEFAULT_PROVIDER);
101
+ if (!p || typeof p.preheat !== "function") return { ok: false, skipped: true };
102
+ try {
103
+ return await p.preheat();
104
+ } catch {
105
+ return { ok: false, error: "preheat failed" };
104
106
  }
105
- return results.length ? results[0] : { ok: false, skipped: true };
106
107
  }
107
108
 
108
109
  async function close() {
@@ -123,6 +123,12 @@ export async function startServerLifecycle({ VERSION, token, created, upstream,
123
123
  else if (r.ok) console.log(`[preheat] opencode models ok ${r.status} ${r.ms}ms`);
124
124
  else console.log(`[preheat] opencode models failed ${r.error || r.status || ""} ${r.ms || 0}ms`);
125
125
  }).catch(() => {});
126
+ // clinebot free 目录自检(独立于 opencode 连接预热:dispatcher.preheat 只做默认供应商)
127
+ // 见 .agents/notes/implemented/simplification/2026-09-16-preheat-opencode-only.md
128
+ try {
129
+ const cline = upstream?.byId?.get?.("clinebot") ?? upstream?.byId?.get?.("cline");
130
+ if (cline?.checkFreeUpdates) void cline.checkFreeUpdates().catch(() => {});
131
+ } catch {}
126
132
  }, 100).unref?.();
127
133
 
128
134
  // responses 模型判定改元数据驱动(models.dev provider.npm):就绪后注入,每小时重查使新模型自动识别