mslxdff 0.1.80 → 0.1.81
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
|
@@ -174,7 +174,7 @@ async function handleVia({ providerId, opts, fetchImpl, loadConfigs, loadKeys, l
|
|
|
174
174
|
const aIdx = Math.min(kIdx, Math.max(auths.length - 1, 0));
|
|
175
175
|
const key = keys[kIdx] || keys[0] || "";
|
|
176
176
|
const auth = auths[aIdx] || auths[0] || null;
|
|
177
|
-
const cKeys = keys.filter((k) => isRefreshToken(k));
|
|
177
|
+
const cKeys = keys.filter((k) => isRefreshToken(k, p));
|
|
178
178
|
if (cKeys.length) {
|
|
179
179
|
const normBase = String(baseUrl).replace(/\/+$/, "");
|
|
180
180
|
const chatBase = normBase.endsWith("/api/v1") ? normBase.slice(0, -7) : normBase;
|
|
@@ -197,7 +197,7 @@ async function handleVia({ providerId, opts, fetchImpl, loadConfigs, loadKeys, l
|
|
|
197
197
|
const aIdx = Math.min(kIdx, Math.max(auths.length - 1, 0));
|
|
198
198
|
const key = keys[kIdx] || keys[0] || "";
|
|
199
199
|
const auth = auths[aIdx] || auths[0] || null;
|
|
200
|
-
const cKeys = keys.filter((k) => isRefreshToken(k));
|
|
200
|
+
const cKeys = keys.filter((k) => isRefreshToken(k, p));
|
|
201
201
|
if (cKeys.length) {
|
|
202
202
|
// cline refreshToken 需特殊流,暂走旧的 peer chat(peer 需自有 cline 配置)
|
|
203
203
|
return viaProbe({ ...args, token, fetchImpl });
|
|
@@ -280,7 +280,7 @@ export async function handleProviderBench(id, sub, rest, args, deps = {}) {
|
|
|
280
280
|
log(`bench ${providerId}: 共 ${allowed.length} 个已勾选模型,逐个测速(串行,${opts.timeoutMs}ms 超时)...`);
|
|
281
281
|
if (!opts.json) console.log(`prompt="${opts.prompt}" maxTokens=${opts.maxTokens}\n`);
|
|
282
282
|
const chatPath = cfg.chatPath || defaultChatPath(providerId);
|
|
283
|
-
const rtKeys = keys.filter((k) => isRefreshToken(k));
|
|
283
|
+
const rtKeys = keys.filter((k) => isRefreshToken(k, providerId));
|
|
284
284
|
const normBase = String(baseUrl).replace(/\/+$/, "");
|
|
285
285
|
const clineChatBase = normBase.endsWith("/api/v1") ? normBase.slice(0, -7) : normBase;
|
|
286
286
|
const results = [];
|
|
@@ -20,12 +20,18 @@ export function clineHeaders(sessionId, token) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export function isRefreshToken(key) {
|
|
23
|
+
export function isRefreshToken(key, providerId = "") {
|
|
24
24
|
const s = String(key || "").trim();
|
|
25
25
|
if (!s) return false;
|
|
26
|
-
//
|
|
26
|
+
// 仅 cline 系供应商才有 refreshToken 形态(WorkOS 设备授权);其他一律走传统 Key
|
|
27
|
+
const pid = String(providerId || "").toLowerCase();
|
|
28
|
+
const baseHint = pid;
|
|
29
|
+
const isCline = baseHint.includes("cline");
|
|
30
|
+
if (!isCline) {
|
|
31
|
+
// 非 cline 供应商,即使长串也不视为 refreshToken,默认传统 Key(以后 xxx.bot 再扩展此处白名单)
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
27
34
|
if (s.startsWith("sk_") || s.startsWith("sk-")) return false;
|
|
28
|
-
// refreshToken 通常为 JWT 或长随机串,长度 > 20 且含 . 或 -
|
|
29
35
|
if (s.length > 20) return true;
|
|
30
36
|
return false;
|
|
31
37
|
}
|
|
@@ -45,8 +45,8 @@ export function createClineProvider({
|
|
|
45
45
|
if (alt.length) extraKeys = alt;
|
|
46
46
|
} catch {}
|
|
47
47
|
const allKeys = [...new Set([...rawKeys, ...extraKeys].map((k) => String(k).trim()).filter(Boolean))];
|
|
48
|
-
const hasRefresh = allKeys.some((k) => isRefreshToken(k));
|
|
49
|
-
const ring = createKeyRing(allKeys.filter((k) => !isRefreshToken(k)), { cooldownMs });
|
|
48
|
+
const hasRefresh = allKeys.some((k) => isRefreshToken(k, id));
|
|
49
|
+
const ring = createKeyRing(allKeys.filter((k) => !isRefreshToken(k, id)), { cooldownMs });
|
|
50
50
|
|
|
51
51
|
let dispatcher = null; let agent = null;
|
|
52
52
|
const a = createAgent({ keepAliveTimeout: envInt("MSLXDFF_CLINE_KEEPALIVE_TIMEOUT", 30_000), keepAliveMaxTimeout: envInt("MSLXDFF_CLINE_KEEPALIVE_MAX_TIMEOUT", 60_000), connections: envInt("MSLXDFF_CLINE_KEEPALIVE_CONNECTIONS", 20) });
|
|
@@ -62,7 +62,7 @@ export function createClineProvider({
|
|
|
62
62
|
// 新 refreshToken 模式
|
|
63
63
|
let authPool = null; let newChatSvc = null;
|
|
64
64
|
if (hasRefresh) {
|
|
65
|
-
const refreshTokens = allKeys.filter((k) => isRefreshToken(k));
|
|
65
|
+
const refreshTokens = allKeys.filter((k) => isRefreshToken(k, id));
|
|
66
66
|
authPool = createAuthPool({
|
|
67
67
|
id, keys: refreshTokens, fetchImpl, dispatcher, baseUrl: resolvedBase, file,
|
|
68
68
|
saveFn: async ({ oldRefreshToken, newRefreshToken }) => {
|
|
@@ -94,13 +94,13 @@ export function createClineProvider({
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
async function chatWithKeys(body, keys) {
|
|
97
|
-
const refreshSubset = (keys || []).filter((k) => isRefreshToken(k));
|
|
97
|
+
const refreshSubset = (keys || []).filter((k) => isRefreshToken(k, id));
|
|
98
98
|
if (refreshSubset.length && hasRefresh) {
|
|
99
99
|
const tmpPool = createAuthPool({ id, keys: refreshSubset, fetchImpl, dispatcher, baseUrl: resolvedBase, file });
|
|
100
100
|
const tmpSvc = createChatService({ id, baseUrl: resolvedBase, chatPath: resolvedChatPath, fetchImpl, dispatcher, authPool: tmpPool, connectTimeoutMs, retry });
|
|
101
101
|
return tmpSvc.runChat(body, createKeyRing([], { cooldownMs }), "shared");
|
|
102
102
|
}
|
|
103
|
-
const tmpRing = createKeyRing((keys || []).filter((k) => !isRefreshToken(k)), { cooldownMs });
|
|
103
|
+
const tmpRing = createKeyRing((keys || []).filter((k) => !isRefreshToken(k, id)), { cooldownMs });
|
|
104
104
|
return oldRunner.runChat(body, tmpRing, "shared provider keys");
|
|
105
105
|
}
|
|
106
106
|
|