mslxdff 0.1.164 → 0.1.169
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 +1 -1
- package/src/anthropic/translate.js +23 -5
- package/src/anthropic/web-search.js +361 -0
- package/src/api-kind.js +31 -0
- package/src/chat-pipeline/auto-race.js +8 -0
- package/src/chat-pipeline/empty-turn.js +28 -0
- package/src/chat-pipeline/index.js +8 -4
- package/src/chat-pipeline/serial-trial.js +8 -1
- package/src/claude-desktop/apply.js +64 -0
- package/src/claude-desktop/doctor.js +146 -0
- package/src/claude-desktop/slots.js +86 -0
- package/src/cli/commands/claude-desktop.js +264 -0
- package/src/cli/commands/model/list-providers.js +1 -1
- package/src/cli/commands/provider/index.js +7 -0
- package/src/cli/commands/provider/models.js +3 -0
- package/src/cli/commands/provider/raccoon-login.js +131 -0
- package/src/cli/commands/provider/raccoon-quota.js +109 -0
- package/src/cli/commands/sync.js +8 -2
- package/src/cli/format.js +1 -1
- package/src/cli/help.js +2 -0
- package/src/cli/index.js +2 -0
- package/src/cli/provider-row.js +2 -2
- package/src/model-capabilities/parse.js +1 -1
- package/src/model-trace.js +2 -1
- package/src/providers/classify.js +1 -1
- package/src/providers/dispatcher.js +2 -2
- package/src/providers/keyring.js +1 -1
- package/src/providers/model-id.js +10 -0
- package/src/providers/raccoon/account-store.js +216 -0
- package/src/providers/raccoon/auth.js +67 -0
- package/src/providers/raccoon/chat.js +207 -0
- package/src/providers/raccoon/const.js +111 -0
- package/src/providers/raccoon/credits.js +161 -0
- package/src/providers/raccoon/envelope.js +23 -0
- package/src/providers/raccoon/headers.js +45 -0
- package/src/providers/raccoon/index.js +216 -0
- package/src/providers/raccoon/login.js +195 -0
- package/src/providers/raccoon/models.js +160 -0
- package/src/providers/raccoon/qr-codewords.js +115 -0
- package/src/providers/raccoon/qr.js +236 -0
- package/src/providers/raccoon/sse.js +135 -0
- package/src/providers/registry.js +5 -0
- package/src/providers/share-keys.js +1 -1
- package/src/providers/workbuddy/models.js +29 -14
- package/src/providers/workbuddy/payload.js +34 -0
- package/src/routes/chat/exhausted-handler.js +4 -4
- package/src/routes/chat/relay-pipeline.js +6 -7
- package/src/routes/messages-route.js +114 -3
- package/src/runtime/bootstrap.js +5 -0
- package/src/runtime/broadband.js +4 -1
- package/src/runtime/provider-gate.js +3 -1
- package/src/runtime/raccoon-checkin.js +126 -0
- package/src/state/provider-config.js +1 -1
- package/src/sync-claude-desktop.js +234 -0
- package/src/talk-full.js +2 -2
- package/src/talk-log.js +9 -6
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// mslxdff -provider raccoon login — 扫码登录(终端二维码 + 轮询)。
|
|
2
|
+
// 实测该链路匿名可达且**不需要验证码**;成功后落盘 auths/raccoon-<uid>.json(0600)
|
|
3
|
+
// 并把兜底目录只增不减补齐进 allowlist(避免「登录成功却处处 403」)。
|
|
4
|
+
import { normalizeProviderId } from "../../../providers/model-id.js";
|
|
5
|
+
import { compatFetch } from "../../../compat.js";
|
|
6
|
+
import {
|
|
7
|
+
buildQrUrl,
|
|
8
|
+
createQrCode,
|
|
9
|
+
fetchRaccoonUserInfo,
|
|
10
|
+
pollQrLogin,
|
|
11
|
+
} from "../../../providers/raccoon/login.js";
|
|
12
|
+
import { encodeQr, renderTerminal } from "../../../providers/raccoon/qr.js";
|
|
13
|
+
import { ensureRaccoonDeviceId, saveRaccoonAccount } from "../../../providers/raccoon/account-store.js";
|
|
14
|
+
import { seedRaccoonAllowlist } from "../../../providers/raccoon/models.js";
|
|
15
|
+
import { raccoonTokenFingerprint, resolveRaccoonUid } from "../../../providers/raccoon/auth.js";
|
|
16
|
+
import { claimRaccoonLoginReward, raccoonClaimStatus } from "../../../providers/raccoon/credits.js";
|
|
17
|
+
|
|
18
|
+
const LOGIN_SUBS = new Set(["login", "auth", "oauth"]);
|
|
19
|
+
|
|
20
|
+
export async function handleRaccoonLogin(id, sub, rest = [], deps = {}) {
|
|
21
|
+
const pid = normalizeProviderId(id) || String(id || "").toLowerCase();
|
|
22
|
+
if (pid !== "raccoon") return false;
|
|
23
|
+
if (!LOGIN_SUBS.has(sub)) return false;
|
|
24
|
+
|
|
25
|
+
const fetchImpl = deps.fetchImpl || compatFetch;
|
|
26
|
+
const log = deps.log || ((m) => console.log(m));
|
|
27
|
+
const exit = deps.exit || ((code) => process.exit(code));
|
|
28
|
+
|
|
29
|
+
const code = deps.qrCode || createQrCode();
|
|
30
|
+
const url = buildQrUrl(code);
|
|
31
|
+
|
|
32
|
+
log("=".repeat(60));
|
|
33
|
+
log(" Raccoon 登录(商汤小浣熊 · 积分制模型池)");
|
|
34
|
+
log("=".repeat(60));
|
|
35
|
+
log("");
|
|
36
|
+
log(" 1. 用微信「扫一扫」扫描下方二维码,并在微信里点确认(浏览器直接打开会 404)");
|
|
37
|
+
log(" 2. 确认后本机自动继续(CLI 轮询,无需回调)");
|
|
38
|
+
log("");
|
|
39
|
+
|
|
40
|
+
const art = renderTerminal(encodeQr(url));
|
|
41
|
+
if (art) {
|
|
42
|
+
log(art);
|
|
43
|
+
log("");
|
|
44
|
+
}
|
|
45
|
+
log(` 登录链接:${url}`);
|
|
46
|
+
log("");
|
|
47
|
+
log("🔄 等待扫码确认…");
|
|
48
|
+
|
|
49
|
+
let out;
|
|
50
|
+
try {
|
|
51
|
+
out = await pollQrLogin(code, {
|
|
52
|
+
fetchImpl,
|
|
53
|
+
sleepFn: deps.sleepFn,
|
|
54
|
+
intervalMs: deps.intervalMs,
|
|
55
|
+
timeoutMs: deps.timeoutMs,
|
|
56
|
+
onTick: deps.onTick,
|
|
57
|
+
});
|
|
58
|
+
} catch (error) {
|
|
59
|
+
log("");
|
|
60
|
+
log(`❌ 登录失败:${error?.message ?? error}`);
|
|
61
|
+
log(" (可重试:mslxdff -provider raccoon login)");
|
|
62
|
+
exit(1);
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (out.status === "canceled") {
|
|
67
|
+
log("");
|
|
68
|
+
log("❌ 已在手机端取消登录(未写入任何凭据)");
|
|
69
|
+
exit(1);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
if (out.status !== "success") {
|
|
73
|
+
log("");
|
|
74
|
+
log("❌ 登录已超时,请重新运行 login");
|
|
75
|
+
log(" (可重试:mslxdff -provider raccoon login)");
|
|
76
|
+
exit(1);
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const credential = out.credential;
|
|
81
|
+
const info = await fetchRaccoonUserInfo(credential, { fetchImpl });
|
|
82
|
+
const uid = resolveRaccoonUid({
|
|
83
|
+
userId: info.userId,
|
|
84
|
+
officeIdentity: info.officeIdentity || credential.office_identity,
|
|
85
|
+
token: credential.access_token,
|
|
86
|
+
});
|
|
87
|
+
const deviceId = deps.deviceId || ensureRaccoonDeviceId({ uid, dir: deps.dir });
|
|
88
|
+
const save = deps.saveAccount || saveRaccoonAccount;
|
|
89
|
+
const saved = await save({
|
|
90
|
+
uid,
|
|
91
|
+
accessToken: credential.access_token,
|
|
92
|
+
refreshToken: credential.refresh_token || "",
|
|
93
|
+
expiresAt: credential.expires_at || "",
|
|
94
|
+
officeIdentity: info.officeIdentity || credential.office_identity || "",
|
|
95
|
+
deviceId,
|
|
96
|
+
name: info.name || "",
|
|
97
|
+
phone: info.phone || "",
|
|
98
|
+
dir: deps.dir,
|
|
99
|
+
file: deps.file,
|
|
100
|
+
});
|
|
101
|
+
const allow = seedRaccoonAllowlist({ file: deps.file });
|
|
102
|
+
|
|
103
|
+
// 一次性新手礼包只能在这儿领:此刻 access_token 刚签发(寿命约 3 小时),是全程唯一稳的窗口。
|
|
104
|
+
// 刻意不交给 daemon 定时去做 —— 那时 token 多半已过期,要续期就得和网关请求抢同一条一次性 refresh_token。
|
|
105
|
+
let reward;
|
|
106
|
+
if (!deps.skipReward) {
|
|
107
|
+
const claim = deps.claimReward || claimRaccoonLoginReward;
|
|
108
|
+
try {
|
|
109
|
+
reward = await claim({ credential, fetchImpl, env: deps.env });
|
|
110
|
+
} catch (e) {
|
|
111
|
+
reward = { status: "error", msg: String(e?.message || e).slice(0, 120) };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
log("");
|
|
116
|
+
log(`✅ 登录成功!uid=${uid} 昵称=${info.name || "(空)"} token=${raccoonTokenFingerprint(credential.access_token)}…`);
|
|
117
|
+
log(` 凭据: ${saved.file}`);
|
|
118
|
+
if (allow.added.length) log(` allowlist 已补齐 ${allow.added.length} 个模型:${allow.added.join(", ")}`);
|
|
119
|
+
if (reward) {
|
|
120
|
+
const line = {
|
|
121
|
+
claimed: `🎁 已领取登录奖励 +${reward.points} 分(每号仅此一次,账单已确认入账)`,
|
|
122
|
+
already: ` 登录奖励此前已领过 —— 这家每号只有一次,不是每日签到`,
|
|
123
|
+
phantom: ` ⚠ 上游回执「成功」但账单里没有这笔 —— 实为未到账,可稍后用 -provider raccoon checkin 复核`,
|
|
124
|
+
unverified: ` 已提交领取,但账单暂时查不到,稍后用 -provider raccoon quota 核对`,
|
|
125
|
+
error: ` 领取登录奖励失败:${reward.msg || "未知原因"}`,
|
|
126
|
+
}[reward.status || raccoonClaimStatus(reward)];
|
|
127
|
+
if (line) log(line);
|
|
128
|
+
}
|
|
129
|
+
log(" 下一步: mslxdff -provider raccoon quota 查看积分 · mslxdff -provider raccoon models 查看模型(含积分倍率)");
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// mslxdff -provider raccoon quota — 逐号查积分余额(五分项)
|
|
2
|
+
// mslxdff -provider raccoon checkin — 领「桌面端登录奖励」
|
|
3
|
+
// ⚠ 纠偏(2026-10-10 账单实测):这家**没有每日签到**。三种积分来源里只有登录奖励 3000 需要领,
|
|
4
|
+
// 且**每号一次性**;每日 300 与注册礼包 3000 都由服务端自动发(无端点),每日 300 当天 23:59:59 清零。
|
|
5
|
+
// 判据一律走账单:上游对重复领取照样回 code:0,只信回执就会谎报到账。
|
|
6
|
+
import { normalizeProviderId } from "../../../providers/model-id.js";
|
|
7
|
+
import { compatFetch } from "../../../compat.js";
|
|
8
|
+
import { listRaccoonAccountDocs, raccoonCredentialFromDoc } from "../../../providers/raccoon/account-store.js";
|
|
9
|
+
import { claimRaccoonLoginReward, fetchRaccoonBalance, raccoonClaimStatus } from "../../../providers/raccoon/credits.js";
|
|
10
|
+
import { raccoonTokenFingerprint } from "../../../providers/raccoon/auth.js";
|
|
11
|
+
|
|
12
|
+
const SUBS = new Set(["quota", "credits", "balance", "checkin", "signin"]);
|
|
13
|
+
|
|
14
|
+
/** 逐号列出(旧实现只取 docs[0],多号时会漏看余额、漏领一次性礼包)。 */
|
|
15
|
+
function targets(deps) {
|
|
16
|
+
if (deps.credential) return [{ name: "", credential: deps.credential }];
|
|
17
|
+
return listRaccoonAccountDocs(deps.dir ? { dirs: [deps.dir] } : {})
|
|
18
|
+
.filter((d) => d.accessToken)
|
|
19
|
+
.map((d) => ({ name: d.name || "", credential: raccoonCredentialFromDoc(d) }));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const STATUS_LINE = {
|
|
23
|
+
claimed: (r) => `🎁 已领取 +${r.points} 分 —— 账单已确认入账(每号仅此一次)`,
|
|
24
|
+
already: () => `已领过 —— 每号只有一次,没有"明天再来"这回事`,
|
|
25
|
+
phantom: () => `⚠ 上游回执「成功」但账单里查不到这笔 → 判定未到账,别当领过`,
|
|
26
|
+
unverified: () => `已提交,但账单暂时查不到 → 未确认,稍后用 quota 核对`,
|
|
27
|
+
error: (r) => `❌ 领取失败:${r.msg || "未知原因"}`,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// row.account 在构造时已换成 token 指纹(凭据纪律:CLI 只打指纹,绝不打完整 token)
|
|
31
|
+
const label = (row) => `[${row.account}${row.uid ? " · " + row.uid : ""}]`;
|
|
32
|
+
|
|
33
|
+
function expiredHint(error) {
|
|
34
|
+
return error?.authExpired || error?.status === 401 || error?.code === 200001 || error?.code === 200003
|
|
35
|
+
? "登录态已失效(access_token 只有约 3 小时寿命),重新扫码: mslxdff -provider raccoon login"
|
|
36
|
+
: "";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export async function handleRaccoonQuota(id, sub, rest = [], deps = {}) {
|
|
40
|
+
const pid = normalizeProviderId(id) || String(id || "").toLowerCase();
|
|
41
|
+
if (pid !== "raccoon") return false;
|
|
42
|
+
if (!SUBS.has(sub)) return false;
|
|
43
|
+
|
|
44
|
+
const fetchImpl = deps.fetchImpl || compatFetch;
|
|
45
|
+
const log = deps.log || ((m) => console.log(m));
|
|
46
|
+
const exit = deps.exit || ((code) => process.exit(code));
|
|
47
|
+
const json = rest.includes("--json");
|
|
48
|
+
const isCheckin = sub === "checkin" || sub === "signin";
|
|
49
|
+
const list = targets(deps);
|
|
50
|
+
|
|
51
|
+
if (!list.length) {
|
|
52
|
+
if (json) log(JSON.stringify({ error: "not_logged_in", hint: "mslxdff -provider raccoon login" }));
|
|
53
|
+
else {
|
|
54
|
+
log("未登录:还没有可用的 raccoon 账号");
|
|
55
|
+
log(" 先运行: mslxdff -provider raccoon login(登录时会自动领一次性登录奖励)");
|
|
56
|
+
}
|
|
57
|
+
exit(1);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const rows = [];
|
|
62
|
+
for (const t of list) {
|
|
63
|
+
const base = { account: raccoonTokenFingerprint(t.credential.access_token), uid: t.credential.uid, name: t.name };
|
|
64
|
+
try {
|
|
65
|
+
if (isCheckin) {
|
|
66
|
+
const r = await claimRaccoonLoginReward({ credential: t.credential, fetchImpl, env: deps.env });
|
|
67
|
+
const status = raccoonClaimStatus(r);
|
|
68
|
+
rows.push({ ...base, ok: status === "claimed" || status === "already", status, points: r.points });
|
|
69
|
+
} else {
|
|
70
|
+
const b = await fetchRaccoonBalance({ credential: t.credential, fetchImpl, env: deps.env });
|
|
71
|
+
rows.push({ ...base, ok: true, total: b.total, items: b.items });
|
|
72
|
+
}
|
|
73
|
+
} catch (e) {
|
|
74
|
+
rows.push({ ...base, ok: false, status: "error", msg: String(e?.message ?? e).slice(0, 160), relogin: expiredHint(e) });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const failed = rows.filter((r) => !r.ok).length;
|
|
78
|
+
|
|
79
|
+
if (json) {
|
|
80
|
+
log(JSON.stringify({ accounts: rows, ok: rows.length - failed, total: rows.length }));
|
|
81
|
+
exit(failed === rows.length ? 1 : 0);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (isCheckin) {
|
|
86
|
+
log(`raccoon 登录奖励(每号一次性)· 共 ${rows.length} 个号`);
|
|
87
|
+
for (const r of rows) log(` ${label(r)} ${STATUS_LINE[r.status]?.(r) || r.status}`);
|
|
88
|
+
if (rows.some((r) => r.status === "claimed")) log(` 查看余额: mslxdff -provider raccoon quota`);
|
|
89
|
+
exit(failed === rows.length ? 1 : 0);
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
log(`raccoon 积分 · 共 ${rows.length} 个号`);
|
|
94
|
+
for (const r of rows) {
|
|
95
|
+
if (!r.ok) {
|
|
96
|
+
log(` ${label(r)} ❌ ${r.msg}`);
|
|
97
|
+
if (r.relogin) log(` → ${r.relogin}`);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const detail = r.items.length ? r.items.map((i) => `${i.label} ${i.value}`).join(" · ") : "(上游未返回分项明细)";
|
|
101
|
+
log(` ${label(r)} 可用 ${r.total} ${detail}`);
|
|
102
|
+
}
|
|
103
|
+
log("");
|
|
104
|
+
log(" ⚠ 「每日积分」当天 23:59:59 清零,当天不花就作废;奖励/充值积分不过期。上游按倍率自动先扣当日池。");
|
|
105
|
+
log(" ⚠ 倍率 0 的模型不扣积分(`mslxdff -provider raccoon models` 看倍率列),想省积分优先用它们。");
|
|
106
|
+
log(" 登录奖励每号只有一次,登录时已自动领;本命令的 checkin 只是补领兜底。");
|
|
107
|
+
exit(failed === rows.length ? 1 : 0);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
package/src/cli/commands/sync.js
CHANGED
|
@@ -21,10 +21,16 @@ export async function handleSetto(args) {
|
|
|
21
21
|
if (!(args.includes("-setto") || args.includes("--setto"))) return false;
|
|
22
22
|
const idx = args.findIndex((x) => x === "-setto" || x === "--setto");
|
|
23
23
|
const target = args[idx + 1];
|
|
24
|
-
if (!["workbuddy", "opencode", "chatgpt", "codex", "claude"].includes(target)) {
|
|
25
|
-
console.error("usage: mslxdff -setto workbuddy [modelId] | mslxdff -setto opencode [modelId|--all] | mslxdff -setto chatgpt [modelId] | mslxdff -setto claude [modelId] [--behaves-as <id>] (claude: 不带 modelId = 写入 modelPicks 勾选集全集,--all 与之同义)");
|
|
24
|
+
if (!["workbuddy", "opencode", "chatgpt", "codex", "claude", "claude-desktop", "claudedesktop"].includes(target)) {
|
|
25
|
+
console.error("usage: mslxdff -setto workbuddy [modelId] | mslxdff -setto opencode [modelId|--all] | mslxdff -setto chatgpt [modelId] | mslxdff -setto claude [modelId] [--behaves-as <id>] | mslxdff -setto claude-desktop [modelId ...] [--max N] [--no-alias] [--check] [--official] (claude: 不带 modelId = 写入 modelPicks 勾选集全集,--all 与之同义 / claude-desktop: 写 Claude Desktop 3P profile + 角色槽 alias)");
|
|
26
26
|
process.exit(1);
|
|
27
27
|
}
|
|
28
|
+
if (target === "claude-desktop" || target === "claudedesktop") {
|
|
29
|
+
// Claude Desktop on 3P(ADR-0048):写 profile + 角色槽 alias。sync.js 只做转发——
|
|
30
|
+
// 本文件已近 20KB 体积门,实现放 src/cli/commands/claude-desktop.js。
|
|
31
|
+
const { handleClaudeDesktopSetto } = await import("./claude-desktop.js");
|
|
32
|
+
return handleClaudeDesktopSetto(args, idx);
|
|
33
|
+
}
|
|
28
34
|
if (target === "chatgpt" || target === "codex") {
|
|
29
35
|
// Codex/ChatGPT 三端共用 ~/.codex/config.toml:写 model + model_provider + [model_providers.mslxdff]
|
|
30
36
|
const raw = args[idx + 2] && !String(args[idx + 2]).startsWith("-") ? String(args[idx + 2]).trim() : null;
|
package/src/cli/format.js
CHANGED
|
@@ -33,7 +33,7 @@ export function fmtEvent(e) {
|
|
|
33
33
|
const fallbackTag = e.fallback?.fallback ? ` fallback=${e.fallback.requested_model || e.requested}->${e.fallback.actual_model || e.actual}(${e.fallback.reason || e.reason})` : "";
|
|
34
34
|
switch (e?.type) {
|
|
35
35
|
case "request":
|
|
36
|
-
return `${head} request client-> ${m(e.requested || e.model)}${e.auto ? " (auto)" : ""} raw=${m(e.rawModel)} lock=${m(e.lockModel)} hops=${e.hops} from ${e.ip || "?"}${e.stream ? " stream" : ""}${e.prompt ? ` content="${e.prompt}"` : ""} reqId=${e.reqId || ""}`;
|
|
36
|
+
return `${head} request client-> ${m(e.requested || e.model)}${e.auto ? " (auto)" : ""}${e.api ? ` api=${e.api}` : ""} raw=${m(e.rawModel)} lock=${m(e.lockModel)} hops=${e.hops} from ${e.ip || "?"}${e.stream ? " stream" : ""}${e.prompt ? ` content="${e.prompt}"` : ""} reqId=${e.reqId || ""}`;
|
|
37
37
|
case "client-request":
|
|
38
38
|
return `${head} client req 客户端请求 model=${m(e.requested)} raw=${m(e.rawModel)} lock=${m(e.lockModel)} ip=${e.ip || "?"}${e.stream ? " stream" : ""}`;
|
|
39
39
|
case "ordered":
|
package/src/cli/help.js
CHANGED
|
@@ -25,6 +25,8 @@ Usage:
|
|
|
25
25
|
mslxdff -setto workbuddy [modelId] set default model and sync to WorkBuddy models.json (insert or update 127.0.0.1/v1 entry)
|
|
26
26
|
mslxdff -setto chatgpt [modelId] set default model and sync to Codex/ChatGPT ~/.codex/config.toml (model_providers.mslxdff → 127.0.0.1/v1/responses, auth via mslxdff -showtoken)
|
|
27
27
|
mslxdff -setto claude [modelId] [--behaves-as <id>] set default model and sync to Claude Code ~/.claude/settings.json (no modelId = write ALL modelPicks rows, --all is the same thing; env.ANTHROPIC_BASE_URL → 127.0.0.1 without /v1, /v1/messages shell; modelPicker rows carry behavesAs only for ids the client cannot recognize, default claude-sonnet-5; first write backs up settings.pre-mslxdff.json)
|
|
28
|
+
mslxdff -setto claude-desktop [modelId...] [--max N] [--max-effort <lvl>] [--no-alias] [--check] [--official] one-click Claude Desktop on 3P (ADR-0048): writes the app's configLibrary profile (role-slot model ids + labelOverride, baseUrl without /v1, bearer scheme) AND model-aliases.json (role slot → real pool model, hot-reloaded); --official retires only our registration; the app does NOT hot-reload → fully quit and reopen
|
|
29
|
+
mslxdff -claude-desktop [status|slots|check] diagnose Claude Desktop 3P (read-only): managed policy → profile registration → per-slot alias → live /v1/messages probe with reasons and next command
|
|
28
30
|
mslxdff -provider add <id> <baseUrl> <key> [allowedModel...] add a generic OpenAI-compatible provider (myapi/gpt-4, baseUrl https://api.example.com/v1; extra models = allowlist)
|
|
29
31
|
mslxdff -provider add workbuddy https://copilot.tencent.com <key> [allow...] add WorkBuddy专用供应商(workbuddy/hy3 前缀路由,auths 与 keys 一一对应)
|
|
30
32
|
mslxdff -provider <id> [key...|add|remove|list|clear|share|set-url] configure provider API keys/URL (multiple keys = rotating, set-url for generic)
|
package/src/cli/index.js
CHANGED
|
@@ -33,6 +33,8 @@ export async function run(args = process.argv.slice(2)) {
|
|
|
33
33
|
if (await handleModel(args)) return;
|
|
34
34
|
const { handleSetto } = await import("./commands/sync.js");
|
|
35
35
|
if (await handleSetto(args)) return;
|
|
36
|
+
const { handleClaudeDesktop } = await import("./commands/claude-desktop.js");
|
|
37
|
+
if (await handleClaudeDesktop(args)) return;
|
|
36
38
|
const { handleWorkbuddy } = await import("./commands/workbuddy.js");
|
|
37
39
|
if (await handleWorkbuddy(args)) return;
|
|
38
40
|
|
package/src/cli/provider-row.js
CHANGED
|
@@ -40,12 +40,12 @@ export function buildProviderRows({ stateFile, env = process.env } = {}) {
|
|
|
40
40
|
let allowed = [];
|
|
41
41
|
let allowAny = false;
|
|
42
42
|
try { keys = loadProviderKeys(gid, stateFile ? { file: stateFile } : undefined); } catch {}
|
|
43
|
-
try { baseUrl = loadProviderBaseUrl(gid, stateFile ? { file: stateFile } : undefined) || cfg?.baseUrl || (gid === "openrouter" ? "https://openrouter.ai/api/v1" : gid === "workbuddy" ? "https://copilot.tencent.com" : gid === "traework" ? "https://trae-api-cn.mchost.guru" : gid === "qoder" ? "qoder://native" : gid === "qwenwork" ? "qwenwork://native" : gid === "globalqwenwork" ? "globalqwenwork://native" : gid === "zcode" ? "zcode://native" : ""); } catch { baseUrl = cfg?.baseUrl || ""; }
|
|
43
|
+
try { baseUrl = loadProviderBaseUrl(gid, stateFile ? { file: stateFile } : undefined) || cfg?.baseUrl || (gid === "openrouter" ? "https://openrouter.ai/api/v1" : gid === "workbuddy" ? "https://copilot.tencent.com" : gid === "traework" ? "https://trae-api-cn.mchost.guru" : gid === "qoder" ? "qoder://native" : gid === "qwenwork" ? "qwenwork://native" : gid === "globalqwenwork" ? "globalqwenwork://native" : gid === "zcode" ? "zcode://native" : gid === "raccoon" ? "raccoon://native" : ""); } catch { baseUrl = cfg?.baseUrl || ""; }
|
|
44
44
|
try { allowed = loadProviderAllowedModels(gid, stateFile ? { file: stateFile } : undefined); } catch {}
|
|
45
45
|
try { allowAny = loadProviderAllowAnyModels(gid, stateFile ? { file: stateFile } : undefined); } catch {}
|
|
46
46
|
// openrouter 特殊:opencode 例外默认 allowAny true,其余默认 false
|
|
47
47
|
if (gid === "opencode") allowAny = true;
|
|
48
|
-
let enabled = Boolean(baseUrl && keys.length) || (gid === "openrouter" && keys.length > 0) || ((gid === "qoder" || gid === "qwenwork" || gid === "globalqwenwork" || gid === "traework" || gid === "zcode") && keys.length > 0);
|
|
48
|
+
let enabled = Boolean(baseUrl && keys.length) || (gid === "openrouter" && keys.length > 0) || ((gid === "qoder" || gid === "qwenwork" || gid === "globalqwenwork" || gid === "traework" || gid === "zcode" || gid === "raccoon") && keys.length > 0);
|
|
49
49
|
const auths = gid === "workbuddy" ? (() => { try { return loadProviderAuths(gid, stateFile ? { file: stateFile } : undefined) || []; } catch { return []; } })() : [];
|
|
50
50
|
let note = "";
|
|
51
51
|
const isWorkbuddyStub = gid === "workbuddy" && (keys.includes("k-new") || String(baseUrl).includes("127.0.0.1") || (keys.length === 1 && keys[0].length < 20));
|
|
@@ -40,7 +40,7 @@ export function normalizeProviderModels(modelsObj) {
|
|
|
40
40
|
return out;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// workbuddy 上游原生字段(/
|
|
43
|
+
// workbuddy 上游原生字段(/v3/config 产品文档,first-party 最准)→ 统一 caps 形状
|
|
44
44
|
// 实测字段(2026-09-11,29 模型全覆盖):maxInputTokens/maxOutputTokens/supportsImages/
|
|
45
45
|
// supportsReasoning/reasoning{effort,summary}/supportsToolCall/disabledMultimodal/credits/tags/name/vendor
|
|
46
46
|
// reasoning 是"当前档位"非档位列表 → effortType=effort 但 effortValues=null、defaultEffort 记默认档
|
package/src/model-trace.js
CHANGED
|
@@ -110,7 +110,8 @@ export function upstreamEcho(res) {
|
|
|
110
110
|
export function formatModelTrace({ type, reqId, model, data = {}, request = null, totalMs = null } = {}) {
|
|
111
111
|
const base = { time: fmtShanghaiYMDHMS(new Date()), req: reqId || "-", model: model || "-", stage: type || "-" };
|
|
112
112
|
let detail = "";
|
|
113
|
-
|
|
113
|
+
// api= 打在 incoming 行最前:门是排查第一眼要的东西,grep "incoming api=" 直接分得开三门;无值时 kv 自然不落该段(不发散成 api=other)
|
|
114
|
+
if (type === "request") detail = `incoming ${kv({ api: data.api, ...(request || summarizeRequest(data.body)), hops: data.hops, useAuto: data.useAuto })}`;
|
|
114
115
|
else if (type === "ordered") detail = `route order=${(data.order || []).join(" | ")} hops=${data.hops ?? "-"} fallback=${data.canFallback ? 1 : 0}`;
|
|
115
116
|
else if (type === "model-try") detail = `target=${data.model || model || "-"} idx=${data.idx ?? "-"} remaining=${data.remaining ?? "-"}`;
|
|
116
117
|
else if (type === "alias") detail = `rawModel=${data.rawModel || "-"} requested=${data.requested || model || "-"}`;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// latency-compare:key/token 类,direct vs link+remote 比延迟
|
|
5
5
|
export function classifyProvider(id) {
|
|
6
6
|
const s = String(id || "").trim().toLowerCase();
|
|
7
|
-
if (s === "workbuddy" || s === "cline" || s === "codearts" || s === "traework" || s === "qoder" || s === "qwenwork" || s === "globalqwenwork" || s === "zcode") return "local-only";
|
|
7
|
+
if (s === "workbuddy" || s === "cline" || s === "codearts" || s === "traework" || s === "qoder" || s === "qwenwork" || s === "globalqwenwork" || s === "zcode" || s === "raccoon") return "local-only";
|
|
8
8
|
if (s === "opencode") return "quota-pool";
|
|
9
9
|
return "latency-compare";
|
|
10
10
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { appendEvent } from "../logs.js";
|
|
2
2
|
import { splitModelId, DEFAULT_PROVIDER, joinModelId } from "./model-id.js";
|
|
3
3
|
import { isModelAllowed as stateIsAllowed, loadProviderAllowedModels as stateLoadAllowed, loadProviderAllowAnyModels as stateLoadAllowAny } from "../state.js";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// 定制预热名单:registry customProviders 9 家 + 默认 opencode;openrouter/自配 generic 不预热(按需自拉)
|
|
5
|
+
const CUSTOM_PREHEAT_IDS = new Set(["opencode", "workbuddy", "traework", "cline", "codearts", "qoder", "globalqwenwork", "qwenwork", "zcode", "raccoon"]);
|
|
6
6
|
function isPreheatDisabled() {
|
|
7
7
|
const raw = process.env.MSLXDFF_PREHEAT;
|
|
8
8
|
if (raw === undefined || raw === null || raw === "") return false;
|
package/src/providers/keyring.js
CHANGED
|
@@ -57,5 +57,5 @@ export function createKeyRing(keys = [], { cooldownMs = DEFAULT_COOLDOWN_MS, now
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// isCooling 对外暴露:粘号选择器要判断"上次这个号还在冷却吗"(决定是否必须换号)
|
|
60
|
-
return { next, onError, replace, available, isCooling, size
|
|
60
|
+
return { next, onError, replace, available, isCooling, cooldownMs, get size() { return list.length; }, get keys() { return [...list]; } }; // ⚠ size/keys 必须是 getter:replace() 换号后构造期快照会停在已废弃的旧 token
|
|
61
61
|
}
|
|
@@ -52,6 +52,16 @@ export function persistModelAliases(file) {
|
|
|
52
52
|
} catch {}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/** 别名文件路径(单一真相,供只读消费方复用,别再各自拼一遍)。 */
|
|
56
|
+
export function modelAliasFile() {
|
|
57
|
+
return aliasFile();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** 当前已装载的 alias 快照(只读;不触发重读,判"会不会被覆盖"用)。 */
|
|
61
|
+
export function snapshotModelAliases() {
|
|
62
|
+
return Object.fromEntries(_modelAliases);
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
let _aliasLoaded = false;
|
|
56
66
|
export function getModelAlias(id) {
|
|
57
67
|
const key = String(id || "").trim();
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// raccoon 账号落盘单一源:auths/raccoon-<uid>.json(0600 tmp+rename)+ state.json providerConfigs.raccoon.keys 同步。
|
|
2
|
+
// office_identity 与 device_id(per-account 持久 UUID)随账号文档走,**不进 providerConfigs**——
|
|
3
|
+
// 规避 providerConfig 重建路径(allowlist/baseUrl 写回)静默丢字段的既有故障类(与 zcode 同款理由)。
|
|
4
|
+
import { writeFileSync, mkdirSync, existsSync, renameSync, unlinkSync, readdirSync, readFileSync, chmodSync } from "node:fs";
|
|
5
|
+
import { join, dirname } from "node:path";
|
|
6
|
+
import { tmpdir } from "node:os";
|
|
7
|
+
import { uuid } from "../../compat.js";
|
|
8
|
+
import { isTestEnv, defaultStateFile } from "../../state/store.js";
|
|
9
|
+
|
|
10
|
+
export function raccoonAuthDir({ explicit = "", testEnv = false, stateFile } = {}) {
|
|
11
|
+
if (explicit) return explicit;
|
|
12
|
+
if (testEnv) return join(tmpdir(), "mslxdff-test-auths");
|
|
13
|
+
return join(dirname(stateFile), "auths");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function resolveRaccoonAuthDir() {
|
|
17
|
+
return raccoonAuthDir({
|
|
18
|
+
explicit: process.env.MSLXDFF_RACCOON_AUTH_DIR || "",
|
|
19
|
+
testEnv: isTestEnv(),
|
|
20
|
+
stateFile: defaultStateFile(),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** 主目录 + 历史遗留 cwd/auths(只读兜底,防旧副本「复活」)。 */
|
|
25
|
+
export function resolveRaccoonAuthDirs() {
|
|
26
|
+
const primary = resolveRaccoonAuthDir();
|
|
27
|
+
const cwdDir = join(process.cwd(), "auths");
|
|
28
|
+
return primary === cwdDir ? [primary] : [primary, cwdDir];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 列出全部落盘账号(同 uid 主位置优先),跳过无 access_token 的残档。 */
|
|
32
|
+
export function listRaccoonAccountDocs({ dirs } = {}) {
|
|
33
|
+
const out = [];
|
|
34
|
+
const seen = new Set();
|
|
35
|
+
for (const dir of dirs || resolveRaccoonAuthDirs()) {
|
|
36
|
+
let files = [];
|
|
37
|
+
try {
|
|
38
|
+
if (!existsSync(dir)) continue;
|
|
39
|
+
files = readdirSync(dir).filter((f) => f.startsWith("raccoon-") && f.endsWith(".json"));
|
|
40
|
+
} catch {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
for (const f of files) {
|
|
44
|
+
try {
|
|
45
|
+
const doc = JSON.parse(readFileSync(join(dir, f), "utf8"));
|
|
46
|
+
const uid = doc?.account?.uid;
|
|
47
|
+
const token = doc?.auth?.access_token;
|
|
48
|
+
if (!uid || !token) continue;
|
|
49
|
+
if (seen.has(String(uid))) continue;
|
|
50
|
+
seen.add(String(uid));
|
|
51
|
+
out.push({
|
|
52
|
+
uid: String(uid),
|
|
53
|
+
accessToken: String(token),
|
|
54
|
+
refreshToken: String(doc.auth.refresh_token || ""),
|
|
55
|
+
expiresAt: String(doc.auth.expires_at || ""),
|
|
56
|
+
officeIdentity: String(doc.auth.office_identity || ""),
|
|
57
|
+
deviceId: String(doc.auth.device_id || ""),
|
|
58
|
+
name: String(doc.account.name || ""),
|
|
59
|
+
phone: String(doc.account.phone || ""),
|
|
60
|
+
file: join(dir, f),
|
|
61
|
+
dir,
|
|
62
|
+
doc,
|
|
63
|
+
});
|
|
64
|
+
} catch {}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function accountFilePath(uid, dir) {
|
|
71
|
+
return join(dir, `raccoon-${uid}.json`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function writeRaccoonAccountFile(
|
|
75
|
+
{ uid, accessToken, refreshToken = "", expiresAt = "", officeIdentity = "", deviceId = "", name = "", phone = "" },
|
|
76
|
+
{ dir = resolveRaccoonAuthDir() } = {},
|
|
77
|
+
) {
|
|
78
|
+
mkdirSync(dir, { recursive: true });
|
|
79
|
+
const doc = {
|
|
80
|
+
account: { uid, name, phone },
|
|
81
|
+
auth: {
|
|
82
|
+
access_token: accessToken,
|
|
83
|
+
refresh_token: refreshToken,
|
|
84
|
+
expires_at: expiresAt,
|
|
85
|
+
office_identity: officeIdentity,
|
|
86
|
+
device_id: deviceId,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
const fp = accountFilePath(uid, dir);
|
|
90
|
+
const tmp = `${fp}.${process.pid}.${Math.random().toString(36).slice(2, 10)}.tmp`; // 唯一名:防并发写(daemon 续期 vs CLI login)互相踩
|
|
91
|
+
writeFileSync(tmp, JSON.stringify(doc, null, 2), { mode: 0o600 });
|
|
92
|
+
try {
|
|
93
|
+
if (existsSync(fp)) {
|
|
94
|
+
try { chmodSync(fp, 0o600); } catch {}
|
|
95
|
+
unlinkSync(fp);
|
|
96
|
+
}
|
|
97
|
+
renameSync(tmp, fp);
|
|
98
|
+
} catch {
|
|
99
|
+
// 兜底也走「唯一 tmp + rename」,绝不直写正式文件(直写非原子,并发读者会读到半截 JSON → 该号静默消失)
|
|
100
|
+
try { const t2 = `${fp}.${process.pid}.${Math.random().toString(36).slice(2, 10)}.tmp`; writeFileSync(t2, JSON.stringify(doc, null, 2), { mode: 0o600 }); if (existsSync(fp)) unlinkSync(fp); renameSync(t2, fp); } catch {}
|
|
101
|
+
try { unlinkSync(tmp); } catch {}
|
|
102
|
+
}
|
|
103
|
+
try { chmodSync(fp, 0o600); } catch {} // mode 只在新建成时生效,存量必须补 chmod
|
|
104
|
+
return fp;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function readRaccoonAccountDoc(uid, { dir = resolveRaccoonAuthDir() } = {}) {
|
|
108
|
+
try {
|
|
109
|
+
return JSON.parse(readFileSync(accountFilePath(uid, dir), "utf8"));
|
|
110
|
+
} catch {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** 落盘账号文档并同步 state 的 keys;已有 device_id 时复用,不覆盖。 */
|
|
116
|
+
export async function saveRaccoonAccount({
|
|
117
|
+
uid,
|
|
118
|
+
accessToken,
|
|
119
|
+
refreshToken = "",
|
|
120
|
+
expiresAt = "",
|
|
121
|
+
officeIdentity = "",
|
|
122
|
+
deviceId = "",
|
|
123
|
+
name = "",
|
|
124
|
+
phone = "",
|
|
125
|
+
dir,
|
|
126
|
+
file,
|
|
127
|
+
} = {}) {
|
|
128
|
+
if (!uid || !accessToken) throw new Error("saveRaccoonAccount: 缺少 uid/accessToken");
|
|
129
|
+
const targetDir = dir || resolveRaccoonAuthDir();
|
|
130
|
+
const existing = readRaccoonAccountDoc(uid, { dir: targetDir });
|
|
131
|
+
const device = deviceId || existing?.auth?.device_id || uuid();
|
|
132
|
+
const fp = writeRaccoonAccountFile(
|
|
133
|
+
{ uid, accessToken, refreshToken, expiresAt, officeIdentity, deviceId: device, name, phone },
|
|
134
|
+
{ dir: targetDir },
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
// keys 一律以账号文档为准(覆盖式,见 syncRaccoonKeys 的说明)
|
|
138
|
+
const sync = await syncRaccoonKeys({ dirs: [targetDir], ...(file ? { file } : {}) });
|
|
139
|
+
return { file: fp, keys: sync.keys.length, updated: Boolean(existing) };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** device_id:账号文档内持久复用;缺失且已有 token 时生成并写回。 */
|
|
143
|
+
export function ensureRaccoonDeviceId({ uid, dir } = {}) {
|
|
144
|
+
if (!uid) return "";
|
|
145
|
+
const targetDir = dir || resolveRaccoonAuthDir();
|
|
146
|
+
const doc = readRaccoonAccountDoc(uid, { dir: targetDir });
|
|
147
|
+
const cur = String(doc?.auth?.device_id || "").trim();
|
|
148
|
+
if (cur) return cur;
|
|
149
|
+
const device = uuid();
|
|
150
|
+
if (doc?.auth?.access_token) {
|
|
151
|
+
writeRaccoonAccountFile(
|
|
152
|
+
{
|
|
153
|
+
uid,
|
|
154
|
+
accessToken: doc.auth.access_token,
|
|
155
|
+
refreshToken: doc.auth?.refresh_token || "",
|
|
156
|
+
expiresAt: doc.auth?.expires_at || "",
|
|
157
|
+
officeIdentity: doc.auth?.office_identity || "",
|
|
158
|
+
deviceId: device,
|
|
159
|
+
name: doc.account?.name || "",
|
|
160
|
+
phone: doc.account?.phone || "",
|
|
161
|
+
},
|
|
162
|
+
{ dir: targetDir },
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
return device;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** 续期结果回写(refresh 可能不返回新 refresh_token,不能覆盖成空串)。 */
|
|
169
|
+
export function applyRaccoonRefresh(existing, { accessToken, refreshToken, expiresAt }) {
|
|
170
|
+
return {
|
|
171
|
+
...existing,
|
|
172
|
+
access_token: accessToken,
|
|
173
|
+
refresh_token: refreshToken && refreshToken.length > 0 ? refreshToken : existing.refresh_token,
|
|
174
|
+
expires_at: expiresAt || existing.expires_at || "",
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 账号文档 → provider/credits 认的 credential 形状。**单一源**:此前 index.js 的 credentialFor、
|
|
180
|
+
* runtime/raccoon-checkin.js 与 CLI 各自内联一份,漏一个 `expires_at` 就会让过期/临期判定静默失效。
|
|
181
|
+
* 输入是 listRaccoonAccountDocs() 的 camelCase 条目,输出是上游口径的 snake_case credential。
|
|
182
|
+
*/
|
|
183
|
+
export function raccoonCredentialFromDoc(doc) {
|
|
184
|
+
return {
|
|
185
|
+
access_token: doc?.accessToken || "",
|
|
186
|
+
refresh_token: doc?.refreshToken || "",
|
|
187
|
+
expires_at: doc?.expiresAt || "",
|
|
188
|
+
office_identity: doc?.officeIdentity || "",
|
|
189
|
+
device_id: doc?.deviceId || "",
|
|
190
|
+
uid: doc?.uid || "",
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* providerConfigs.raccoon.keys ← auths/ 各号文档里的当前 access_token(**覆盖式**,不是追加)。
|
|
196
|
+
* 为什么必须覆盖(两个都是踩过的坑):
|
|
197
|
+
* 1) access_token 约 3 小时一换,追加会让 keys 越攒越多已作废 token,ring 反复选中它们去撞 401;
|
|
198
|
+
* 2) 续期回写只改账号文档(writeRaccoonAccountFile 从不碰 keys),两者一分叉,daemon 重启后拿到的
|
|
199
|
+
* 就是过期 token —— 症状是「明明登录过、积分还在,却恒 401 / 429 全号冷却」,只能重扫码。
|
|
200
|
+
* 账号文档是身份的唯一可信源(refresh_token / office_identity / device_id 只在文档里),
|
|
201
|
+
* 所以 keys 以它为准;不在任何文档里的 token 一律剔除。
|
|
202
|
+
*/
|
|
203
|
+
export async function syncRaccoonKeys({ dirs, file } = {}) {
|
|
204
|
+
const { loadProviderConfig, saveProviderConfig } = await import("../../state.js");
|
|
205
|
+
const tokens = [...new Set(
|
|
206
|
+
listRaccoonAccountDocs(dirs ? { dirs } : {})
|
|
207
|
+
.map((d) => String(d?.accessToken || "").trim())
|
|
208
|
+
.filter(Boolean),
|
|
209
|
+
)];
|
|
210
|
+
const cfg = loadProviderConfig("raccoon", file ? { file } : {}) || {};
|
|
211
|
+
const prev = Array.isArray(cfg.keys) ? cfg.keys : [];
|
|
212
|
+
const identical = prev.length === tokens.length && prev.every((k) => tokens.includes(k));
|
|
213
|
+
if (identical) return { keys: tokens, changed: false, dropped: 0 };
|
|
214
|
+
saveProviderConfig("raccoon", { ...cfg, keys: tokens }, file ? { file } : {});
|
|
215
|
+
return { keys: tokens, changed: true, dropped: prev.filter((k) => !tokens.includes(k)).length };
|
|
216
|
+
}
|