mslxdff 0.1.222 → 0.1.223
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
|
@@ -10,7 +10,7 @@ export async function renderOtherProviders({ pickedIds, ids, fullAliases }) {
|
|
|
10
10
|
try { _la2(); } catch {}
|
|
11
11
|
const configs = loadProviderConfigs();
|
|
12
12
|
const otherIds = Object.keys(configs).filter((k) => String(k).toLowerCase() !== "opencode");
|
|
13
|
-
const order2 = ["workbuddy", "cline", "openrouter", "bai", "qoder", "qwenwork", "globalqwenwork", "traework", "zcode", "raccoon", "codearts"];
|
|
13
|
+
const order2 = ["workbuddy", "cline", "openrouter", "bai", "qoder", "qwenwork", "globalqwenwork", "traework", "zcode", "raccoon", "codearts", "railway"];
|
|
14
14
|
otherIds.sort((a, b) => {
|
|
15
15
|
const ia = order2.indexOf(a), ib = order2.indexOf(b);
|
|
16
16
|
if (ia !== -1 || ib !== -1) {
|
|
@@ -31,10 +31,25 @@ export async function renderOtherProviders({ pickedIds, ids, fullAliases }) {
|
|
|
31
31
|
? (allowed.length ? `allowlist ${allowed.length} (allowAny ON)` : `allowAny ON (allowlist 空=放行全部)`)
|
|
32
32
|
: (allowed.length ? `allowlist ${allowed.length} (allowAny OFF)` : `allowlist 空 + allowAny OFF = 阻塞`);
|
|
33
33
|
console.log(`\n ── ${pid} (${header})${baseUrl ? ` baseUrl=${baseUrl}` : ""} ──`);
|
|
34
|
+
// allowAny ON 且没设 allowlist = 该供应商全部模型放行。此时**把 live 列表展开**:
|
|
35
|
+
// 只打「未设 allowlist」两行会让用户以为这家没有模型(2026-10-20 railway 就是这么"消失"的)。
|
|
36
|
+
const live = (ids || []).filter((id) => String(id).startsWith(`${pid}/`));
|
|
34
37
|
if (!allowed.length) {
|
|
35
38
|
if (allowAny) {
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
if (live.length) {
|
|
40
|
+
for (const canonical of live.sort(compareModelIds)) {
|
|
41
|
+
let alias = null;
|
|
42
|
+
try { alias = _gaf(canonical); } catch {}
|
|
43
|
+
if (!alias && String(canonical).includes("/")) alias = String(canonical).replace(/\//g, "-");
|
|
44
|
+
const aliasStr = alias && alias !== canonical ? ` (别名: ${alias})` : "";
|
|
45
|
+
const pickedMark = pickedIds.includes(canonical) || pickedIds.includes(alias || "") ? "*" : " ";
|
|
46
|
+
console.log(` ${pickedMark} ${canonical}${aliasStr}`);
|
|
47
|
+
}
|
|
48
|
+
console.log(` 管理: mslxdff -provider ${pid} allowlist [list|add|remove|clear] | allowAny on|off`);
|
|
49
|
+
} else {
|
|
50
|
+
console.log(` (未设 allowlist,全部模型放行) 查看 live 列表: mslxdff -provider ${pid} models`);
|
|
51
|
+
console.log(` 限制可用模型: mslxdff -provider ${pid} allowlist set <model1> <model2>`);
|
|
52
|
+
}
|
|
38
53
|
} else {
|
|
39
54
|
console.log(` 阻塞中:无可用模型 — 设白名单: mslxdff -provider ${pid} allowlist set <model1> <model2>`);
|
|
40
55
|
console.log(` 或放行全部: mslxdff -provider ${pid} allowAny on`);
|
|
@@ -30,7 +30,31 @@ export async function handleModelList(args, idx, sub) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
const cacheFile = join(logDir(), "models.json");
|
|
33
|
+
// 模型来源:优先问**本机网关**(daemon 的多供应商聚合,含 railway/codearts/workbuddy 等),
|
|
34
|
+
// 拉不到才退回「直连 opencode 单家」——后者只有一个供应商,会让所有定制供应商的模型消失
|
|
35
|
+
// (2026-10-20 实测:-models 看不到 railway 正是这个原因)。
|
|
36
|
+
async function tryGatewayModels() {
|
|
37
|
+
try {
|
|
38
|
+
const port = process.env.PORT || process.env.MSLXDFF_PORT || 8989;
|
|
39
|
+
const { loadToken } = await import("../../../state.js");
|
|
40
|
+
const { token } = await loadToken();
|
|
41
|
+
if (!token) return null;
|
|
42
|
+
const res = await fetch(`http://127.0.0.1:${port}/v1/models?all=1`, {
|
|
43
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
44
|
+
signal: AbortSignal.timeout(6000),
|
|
45
|
+
});
|
|
46
|
+
if (!res.ok) return null;
|
|
47
|
+
const j = await res.json();
|
|
48
|
+
return Array.isArray(j?.data) && j.data.length ? j : null;
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
33
53
|
async function tryRefreshModels() {
|
|
54
|
+
// ① 网关聚合(最全,含所有已装配供应商)
|
|
55
|
+
const viaGateway = await tryGatewayModels();
|
|
56
|
+
if (viaGateway) return viaGateway;
|
|
57
|
+
// ② 回退:直连 opencode(daemon 没起/无 token 时的单家兜底)
|
|
34
58
|
try {
|
|
35
59
|
const models = createModelsService({
|
|
36
60
|
baseUrl: process.env.UPSTREAM_BASE_URL || "https://opencode.ai",
|