mslxdff 0.1.155 → 0.1.158
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/bin/mslxdff.js +4 -4
- package/docs/ARCHITECTURE.md +426 -0
- package/docs/FEATURE_TREE.md +164 -0
- package/docs/MOBILE.md +82 -0
- package/docs/adr/0001-reasoning-content-injection.md +14 -0
- package/docs/adr/0002-models-free-filter.md +12 -0
- package/docs/adr/0003-zero-state-no-auth.md +10 -0
- package/docs/adr/0004-bearer-token.md +18 -0
- package/docs/adr/0005-peer-mesh.md +53 -0
- package/docs/adr/0006-broadband-member.md +103 -0
- package/docs/adr/0007-multi-provider-prefix.md +25 -0
- package/docs/adr/0008-share-keys-to-peers.md +52 -0
- package/docs/adr/0009-chat-repl.md +37 -0
- package/docs/adr/0010-allowlist.md +36 -0
- package/docs/adr/0011-broadband-stream.md +30 -0
- package/docs/adr/0012-responses-endpoint-codex-sync.md +48 -0
- package/docs/adr/0013-node16-compat.md +41 -0
- package/docs/adr/0014-deepseek-provider.md +52 -0
- package/docs/adr/0015-upstream-probe-routing.md +50 -0
- package/docs/adr/0016-model-capabilities.md +27 -0
- package/docs/adr/0017-ai-sdk-upstream-engine.md +59 -0
- package/docs/adr/0018-zen-client-identity.md +52 -0
- package/docs/adr/0019-share-keys-always-lend.md +59 -0
- package/docs/adr/0020-zen-free-lane-agent-shape.md +52 -0
- package/docs/adr/0021-usage-report-jsonl.md +47 -0
- package/docs/adr/0022-models-capability-merge.md +61 -0
- package/docs/adr/0023-key-provider-default-direct.md +58 -0
- package/docs/adr/0024-node18-baseline.md +63 -0
- package/docs/adr/0025-workbuddy-authdir-follows-state.md +71 -0
- package/docs/adr/0026-cline-provider-id-unify.md +67 -0
- package/docs/adr/0027-codearts-provider.md +48 -0
- package/docs/adr/0028-traework-provider.md +34 -0
- package/docs/adr/0029-qoder-native-provider.md +60 -0
- package/docs/adr/0030-models-list-scoped-by-picks.md +53 -0
- package/docs/adr/0031-qoder-true-streaming.md +50 -0
- package/docs/adr/0032-generic-responses-channel.md +72 -0
- package/docs/adr/0033-cline-allowlist-auto-sync.md +75 -0
- package/docs/adr/0034-request-level-human-readable-observability.md +60 -0
- package/docs/adr/0035-sdk-channel-headers-timeout.md +49 -0
- package/docs/adr/0036-qoder-per-request-sticky-account.md +82 -0
- package/docs/adr/0037-qwenwork-independent-provider.md +82 -0
- package/docs/adr/0038-zcode-provider.md +140 -0
- package/docs/agents/domain.md +51 -0
- package/docs/agents/issue-tracker.md +30 -0
- package/docs/agents/triage-labels.md +15 -0
- package/docs/cli_help.md +1391 -0
- package/docs/cli_help_mini.md +133 -0
- package/docs/plans/bench-via-latency-2026-09-01.md +215 -0
- package/docs/plugins.md +187 -0
- package/package.json +1 -1
- package/src/auto.js +254 -254
- package/src/bench/cline-bench.js +42 -42
- package/src/bench/probe.js +70 -70
- package/src/bench/report.js +162 -162
- package/src/bench/runner.js +77 -77
- package/src/bench/via-probe.js +124 -124
- package/src/bench/via-routes.js +87 -87
- package/src/bench/workbuddy-bench.js +54 -54
- package/src/chat/engine.js +160 -160
- package/src/chat/gateway.js +163 -163
- package/src/chat/orchestrator.js +234 -234
- package/src/chat/prompt.js +70 -70
- package/src/chat/repl.js +88 -88
- package/src/chat/terminal.js +135 -135
- package/src/chat/tools.js +306 -306
- package/src/chat-pipeline/index.js +123 -123
- package/src/chat-pipeline/policy.js +76 -76
- package/src/chat-pipeline/serial-trial.js +210 -210
- package/src/cli/commands/group.js +249 -249
- package/src/cli/commands/model/list-providers.js +4 -3
- package/src/cli/commands/model/list-render.js +7 -9
- package/src/cli/commands/model/list-sort.js +52 -0
- package/src/cli/commands/model/list-tty.js +76 -0
- package/src/cli/commands/model/list.js +5 -62
- package/src/cli/commands/model/picks.js +50 -50
- package/src/cli/commands/provider/bench-via.js +247 -247
- package/src/cli/commands/provider/bench.js +141 -141
- package/src/cli/commands/provider/index.js +124 -116
- package/src/cli/commands/provider/models.js +139 -128
- package/src/cli/commands/provider/qwenwork-login.js +119 -0
- package/src/cli/commands/provider/zcode-login.js +77 -0
- package/src/cli/commands/provider/zcode-quota.js +55 -0
- package/src/cli/commands/sync.js +232 -232
- package/src/cli/provider-row.js +2 -2
- package/src/cli/status.js +279 -279
- package/src/daemon.js +96 -96
- package/src/model-capabilities/enrich.js +86 -86
- package/src/model-capabilities/index.js +183 -183
- package/src/model-capabilities/parse.js +70 -70
- package/src/model-trace.js +1 -0
- package/src/models.js +225 -225
- package/src/providers/classify.js +1 -1
- package/src/providers/cline/auth.js +228 -228
- package/src/providers/cline/chat.js +307 -307
- package/src/providers/cline.js +2 -2
- package/src/providers/keyring.js +60 -56
- package/src/providers/qoder/chat.js +183 -100
- package/src/providers/qoder/index.js +230 -184
- package/src/providers/qoder/sse.js +103 -46
- package/src/providers/qoder/sticky.js +1 -0
- package/src/providers/qoder/stream.js +32 -9
- package/src/providers/qwenwork/account-store.js +133 -0
- package/src/providers/qwenwork/constants.js +67 -0
- package/src/providers/qwenwork/cosy.js +120 -0
- package/src/providers/qwenwork/crypto.js +218 -0
- package/src/providers/qwenwork/http.js +20 -0
- package/src/providers/qwenwork/index.js +327 -0
- package/src/providers/qwenwork/payload.js +142 -0
- package/src/providers/qwenwork/rsa.js +54 -0
- package/src/providers/qwenwork/sse.js +268 -0
- package/src/providers/qwenwork/stream.js +130 -0
- package/src/providers/qwenwork/upstream.js +120 -0
- package/src/providers/qwenwork.js +1 -0
- package/src/providers/registry.js +66 -56
- package/src/providers/share-keys.js +2 -2
- package/src/providers/workbuddy/chat.js +248 -248
- package/src/providers/workbuddy/reshape.js +152 -152
- package/src/providers/workbuddy.js +2 -2
- package/src/providers/zcode/account-store.js +129 -0
- package/src/providers/zcode/auth.js +28 -0
- package/src/providers/zcode/chat.js +171 -0
- package/src/providers/zcode/const.js +54 -0
- package/src/providers/zcode/headers.js +55 -0
- package/src/providers/zcode/index.js +124 -0
- package/src/providers/zcode/models.js +65 -0
- package/src/providers/zcode/oauth.js +120 -0
- package/src/providers/zcode/quota.js +176 -0
- package/src/providers/zcode/sse.js +179 -0
- package/src/reasoning.js +32 -32
- package/src/routes/chat/gateway.js +46 -46
- package/src/routes/chat/relay-pipeline.js +250 -246
- package/src/routes/chat/via-route-handler.js +144 -144
- package/src/routes/hedge.js +255 -255
- package/src/routes/models-route.js +167 -167
- package/src/routes/peers.js +273 -273
- package/src/routes/stream.js +438 -399
- package/src/runtime/bootstrap.js +45 -45
- package/src/runtime/provider-gate.js +33 -30
- package/src/runtime/providers-setup.js +165 -165
- package/src/server.js +64 -64
- package/src/state/schemas/allowlist.js +92 -92
- package/src/sync-opencode.js +280 -280
- package/src/transport/index.js +244 -244
- package/src/transport/pool.js +56 -56
- package/src/transport/retry.js +24 -24
- package/src/transport/sse.js +93 -93
- package/src/upstream-probe/display.js +52 -52
- package/src/upstream-probe/probe.js +49 -49
- package/src/upstream-probe/rotate.js +110 -110
- package/src/upstream-probe/start.js +45 -45
- package/src/upstream.js +289 -289
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// zcode 供应商常量单一源:网关地址、客户端版本、业务码表、Start/Coding Plan 模型目录。
|
|
2
|
+
// 端点契约调研自 zai-org/ZCode 源码(official-coding-plan-gateway.ts / zcodeEndpoint.ts)与 zcode-switch 实测。
|
|
3
|
+
export const ZCODE_ORIGIN = "https://zcode.z.ai";
|
|
4
|
+
export const ZCODE_CLI_INIT_URL = `${ZCODE_ORIGIN}/api/v1/oauth/cli/init`;
|
|
5
|
+
export const zcodeCliPollUrl = (flowId) =>
|
|
6
|
+
`${ZCODE_ORIGIN}/api/v1/oauth/cli/poll/${encodeURIComponent(String(flowId || ""))}`;
|
|
7
|
+
export const ZCODE_MESSAGES_URL = `${ZCODE_ORIGIN}/api/v1/zcode-plan/anthropic/v1/messages`;
|
|
8
|
+
export const zcodeBalanceUrl = (appVersion) =>
|
|
9
|
+
`${ZCODE_ORIGIN}/api/v1/zcode-plan/billing/balance?app_version=${encodeURIComponent(String(appVersion || ""))}`;
|
|
10
|
+
|
|
11
|
+
export const ZCODE_DEFAULT_APP_VERSION = "3.11.2";
|
|
12
|
+
export const ZCODE_RELEASE_CHANNEL = "stable";
|
|
13
|
+
|
|
14
|
+
export function zcodeAppVersion(env = process.env) {
|
|
15
|
+
const v = typeof env?.MSLXDFF_ZCODE_APP_VERSION === "string" ? env.MSLXDFF_ZCODE_APP_VERSION.trim() : "";
|
|
16
|
+
return v || ZCODE_DEFAULT_APP_VERSION;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 业务码表(zcode-switch quota.rs classify + ZCode 客户端 model-execution.ts 实测):
|
|
20
|
+
// 401/1006 鉴权失效,1005 额度耗尽(data/plan/ends_at 为下次时间),限流组,3007 安全校验拒绝。
|
|
21
|
+
export const ZCODE_ERROR_KINDS = {
|
|
22
|
+
401: "auth",
|
|
23
|
+
1006: "auth",
|
|
24
|
+
1005: "quota",
|
|
25
|
+
3002: "rate_limit",
|
|
26
|
+
3008: "rate_limit",
|
|
27
|
+
3009: "rate_limit",
|
|
28
|
+
3010: "rate_limit",
|
|
29
|
+
3007: "security",
|
|
30
|
+
2007: "server",
|
|
31
|
+
3001: "param",
|
|
32
|
+
3006: "param",
|
|
33
|
+
3102: "param",
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function zcodeErrorKind(code) {
|
|
37
|
+
const n = Number(code);
|
|
38
|
+
return ZCODE_ERROR_KINDS[n] || "unknown";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 官方 canonical id(quota.rs BUILTIN_*_MODELS);入站大小写不敏感,出站规范化为该表内的写法。
|
|
42
|
+
export const ZCODE_CODING_PLAN_MODELS = ["GLM-5.3", "GLM-5.3-Flash"];
|
|
43
|
+
export const ZCODE_START_PLAN_MODELS = ["GLM-5.3-Flash", "GLM-5.2", "GLM-5-Turbo"];
|
|
44
|
+
export const ZCODE_MODEL_CATALOG = [...new Set([...ZCODE_CODING_PLAN_MODELS, ...ZCODE_START_PLAN_MODELS])];
|
|
45
|
+
|
|
46
|
+
export function canonicalZcodeModel(id) {
|
|
47
|
+
let raw = String(id || "").trim();
|
|
48
|
+
if (raw.startsWith("zcode/")) raw = raw.slice(6);
|
|
49
|
+
const low = raw.toLowerCase();
|
|
50
|
+
for (const m of ZCODE_MODEL_CATALOG) {
|
|
51
|
+
if (m.toLowerCase() === low) return m;
|
|
52
|
+
}
|
|
53
|
+
return raw;
|
|
54
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// zcode source headers 构造:与官方客户端同形的 12 项(zcode-source-headers.ts / quota.rs 双源核对)。
|
|
2
|
+
// 官方要求 header value 必须是可见 ASCII,非法值一律剔除(缺失优于脏值)。
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import { uuid } from "../../compat.js";
|
|
5
|
+
import { ZCODE_ORIGIN, ZCODE_RELEASE_CHANNEL, zcodeAppVersion } from "./const.js";
|
|
6
|
+
|
|
7
|
+
const ASCII = /^[\x20-\x7e]+$/;
|
|
8
|
+
|
|
9
|
+
export function normalizeHeaderValue(v) {
|
|
10
|
+
const t = typeof v === "string" ? v.trim() : "";
|
|
11
|
+
return t && ASCII.test(t) ? t : undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function osCategory(platform) {
|
|
15
|
+
switch (platform) {
|
|
16
|
+
case "win32":
|
|
17
|
+
return "windows";
|
|
18
|
+
case "darwin":
|
|
19
|
+
return "macos";
|
|
20
|
+
default:
|
|
21
|
+
return "linux";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function buildZcodeHeaders(opts = {}) {
|
|
26
|
+
const ver = normalizeHeaderValue(opts.version) ?? zcodeAppVersion();
|
|
27
|
+
const platform = normalizeHeaderValue(opts.platform) ?? process.platform;
|
|
28
|
+
const arch = normalizeHeaderValue(opts.arch) ?? process.arch;
|
|
29
|
+
const intl = (() => { try { return Intl.DateTimeFormat().resolvedOptions() || {}; } catch { return {}; } })();
|
|
30
|
+
const language = normalizeHeaderValue(opts.lang) ?? normalizeHeaderValue(intl.locale) ?? "unknown";
|
|
31
|
+
const timeZone = normalizeHeaderValue(opts.tz) ?? normalizeHeaderValue(intl.timeZone) ?? "unknown";
|
|
32
|
+
// osVersion 显式传空 = 未知(省略该头);未传则取系统 release。
|
|
33
|
+
const osVersion = "osVersion" in opts ? normalizeHeaderValue(opts.osVersion) : normalizeHeaderValue(os.release());
|
|
34
|
+
const deviceMid = normalizeHeaderValue(opts.deviceMid);
|
|
35
|
+
const requestId = normalizeHeaderValue(opts.requestId) ?? uuid();
|
|
36
|
+
|
|
37
|
+
const headers = {
|
|
38
|
+
"User-Agent": `ZCode/${ver}`,
|
|
39
|
+
"HTTP-Referer": ZCODE_ORIGIN,
|
|
40
|
+
"X-Title": "Z Code@electron",
|
|
41
|
+
"X-ZCode-App-Version": ver,
|
|
42
|
+
"X-Platform": `${platform}-${arch}`,
|
|
43
|
+
"X-Release-Channel": ZCODE_RELEASE_CHANNEL,
|
|
44
|
+
"X-Client-Language": language,
|
|
45
|
+
"X-Client-Timezone": timeZone,
|
|
46
|
+
"X-Os-Category": osCategory(platform),
|
|
47
|
+
};
|
|
48
|
+
if (osVersion) headers["X-Os-Version"] = osVersion;
|
|
49
|
+
if (deviceMid) headers["X-Device-Mid"] = deviceMid;
|
|
50
|
+
headers["x-request-id"] = requestId;
|
|
51
|
+
|
|
52
|
+
const token = normalizeHeaderValue(opts.token);
|
|
53
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
54
|
+
return headers;
|
|
55
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// zcode 供应商工厂:keyring 多号轮换 + 差异化冷却(auth/限流/服务端=短冷却、1005=长冷却、3007/参数=不冷却)。
|
|
2
|
+
import { compatFetch } from "../../compat.js";
|
|
3
|
+
import { envInt } from "../base.js";
|
|
4
|
+
import { createKeyRing } from "../keyring.js";
|
|
5
|
+
import { loadProviderKeys } from "../../state.js";
|
|
6
|
+
import { createModelsService } from "./models.js";
|
|
7
|
+
import { forwardZcodeChat } from "./chat.js";
|
|
8
|
+
import { fetchZcodeBalance } from "./quota.js";
|
|
9
|
+
import { listZcodeAccountDocs } from "./account-store.js";
|
|
10
|
+
|
|
11
|
+
// 冷却策略:auth/限流/服务端/网络=短冷却;quota=长冷却(按日重置);security/param/unknown=不冷却(换号无意义)
|
|
12
|
+
const COOLDOWN_BY_KIND = { auth: "short", rate_limit: "short", server: "short", network: "short", quota: "long" };
|
|
13
|
+
|
|
14
|
+
function notLoggedInResponse() {
|
|
15
|
+
return new Response(
|
|
16
|
+
JSON.stringify({ error: { message: "zcode: 无可用账号 —— 先运行 mslxdff -provider zcode login", type: "auth_error" } }),
|
|
17
|
+
{ status: 401, headers: { "Content-Type": "application/json" } },
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function allCoolingResponse() {
|
|
22
|
+
return new Response(
|
|
23
|
+
JSON.stringify({ error: { message: "zcode: 账号暂不可用(冷却中,可能额度用尽或限流),请稍后重试", type: "all_cooling" } }),
|
|
24
|
+
{ status: 429, headers: { "Content-Type": "application/json", "x-mslxdff-zcode-all-cooling": "1" } },
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function createZcodeProvider({
|
|
29
|
+
id = "zcode",
|
|
30
|
+
apiKeys,
|
|
31
|
+
file,
|
|
32
|
+
fetchImpl,
|
|
33
|
+
cooldownMs = envInt("MSLXDFF_ZCODE_COOLDOWN_MS", 30_000),
|
|
34
|
+
quotaCooldownMs = envInt("MSLXDFF_ZCODE_QUOTA_COOLDOWN_MS", 3_600_000),
|
|
35
|
+
timeoutMs = Number(process.env.MSLXDFF_ZCODE_TIMEOUT_MS) || 120_000,
|
|
36
|
+
} = {}) {
|
|
37
|
+
if (!fetchImpl) fetchImpl = compatFetch;
|
|
38
|
+
const keys = (() => {
|
|
39
|
+
if (Array.isArray(apiKeys) && apiKeys.length) return [...new Set(apiKeys.map((k) => String(k).trim()).filter(Boolean))];
|
|
40
|
+
try {
|
|
41
|
+
return loadProviderKeys(id, file ? { file } : {});
|
|
42
|
+
} catch {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
})();
|
|
46
|
+
const ring = createKeyRing(keys, { cooldownMs });
|
|
47
|
+
|
|
48
|
+
// JWT → deviceMid 映射(设备身份跟账号走,取自 auths/zcode-<uid>.json)
|
|
49
|
+
let midCache = null;
|
|
50
|
+
function deviceMidFor(key) {
|
|
51
|
+
if (midCache === null) {
|
|
52
|
+
try {
|
|
53
|
+
midCache = new Map(listZcodeAccountDocs().map((d) => [d.jwt, d.deviceMid]));
|
|
54
|
+
} catch {
|
|
55
|
+
midCache = new Map();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return midCache.get(key) || "";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const modelsSvc = createModelsService({
|
|
62
|
+
id,
|
|
63
|
+
hasAccount: () => ring.keys.length > 0,
|
|
64
|
+
// balance capabilities 探测:entitlement 名 → canonical 目录交集(失败/空 → 服务回退全量目录)
|
|
65
|
+
probe: async () => {
|
|
66
|
+
const token = ring.keys[0];
|
|
67
|
+
if (!token) return [];
|
|
68
|
+
const r = await fetchZcodeBalance({ token, deviceMid: deviceMidFor(token), fetchImpl });
|
|
69
|
+
return r.ok ? r.modelIds : [];
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
async function chat(body, opts = {}) {
|
|
74
|
+
const total = ring.keys.length;
|
|
75
|
+
if (!total) return notLoggedInResponse();
|
|
76
|
+
let lastRes = null;
|
|
77
|
+
for (let hop = 0; hop <= total; hop++) {
|
|
78
|
+
const key = ring.next();
|
|
79
|
+
if (!key) break;
|
|
80
|
+
const res = await forwardZcodeChat({ body, token: key, deviceMid: deviceMidFor(key), fetchImpl, timeoutMs });
|
|
81
|
+
const kind = res.headers.get("x-mslxdff-zcode-kind");
|
|
82
|
+
if (!kind) return res;
|
|
83
|
+
const mode = COOLDOWN_BY_KIND[kind] || "none";
|
|
84
|
+
if (mode === "long") ring.onError(key, quotaCooldownMs);
|
|
85
|
+
else if (mode === "short") ring.onError(key, cooldownMs);
|
|
86
|
+
lastRes = res;
|
|
87
|
+
if (mode === "none") break; // security/param/unknown:换号无意义,如实透出
|
|
88
|
+
if (ring.available() === 0) break; // 没有别的可用号
|
|
89
|
+
}
|
|
90
|
+
if (lastRes) return lastRes;
|
|
91
|
+
return allCoolingResponse();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function listModels() {
|
|
95
|
+
return modelsSvc.listModels();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function preheat() {
|
|
99
|
+
try {
|
|
100
|
+
const list = await modelsSvc.listModels();
|
|
101
|
+
return list.length ? { ok: true } : { ok: false, error: "no catalog" };
|
|
102
|
+
} catch (e) {
|
|
103
|
+
return { ok: false, error: String(e?.message || e).slice(0, 120) };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function close() {}
|
|
108
|
+
|
|
109
|
+
async function chatWithKeys(body, keysOverride, opts) {
|
|
110
|
+
const tmp = createZcodeProvider({ id, apiKeys: keysOverride, file, fetchImpl, cooldownMs, quotaCooldownMs, timeoutMs });
|
|
111
|
+
return tmp.chat(body, opts);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
id,
|
|
116
|
+
chat,
|
|
117
|
+
chatWithKeys,
|
|
118
|
+
listModels,
|
|
119
|
+
preheat,
|
|
120
|
+
close,
|
|
121
|
+
keyRing: ring,
|
|
122
|
+
baseUrl: "zcode://native",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// zcode 模型目录:内置 Start/Coding Plan 目录 + allowlist 只增不减补齐 + 目录服务(可选按额度 capabilities 过滤)。
|
|
2
|
+
import { joinModelId } from "../model-id.js";
|
|
3
|
+
import { loadProviderAllowedModels, saveProviderAllowedModels } from "../../state.js";
|
|
4
|
+
import { ZCODE_MODEL_CATALOG } from "./const.js";
|
|
5
|
+
|
|
6
|
+
const CREATED = 1753600000;
|
|
7
|
+
const CACHE_TTL_MS = 10 * 60 * 1000;
|
|
8
|
+
|
|
9
|
+
// 登录后开箱可用:内置目录只增不减并入 allowlist(对齐 cline allowlist-sync 先例,避免显式请求 403)。
|
|
10
|
+
export function seedZcodeAllowlist({ ids = ZCODE_MODEL_CATALOG, file } = {}) {
|
|
11
|
+
const opts = file ? { file } : {};
|
|
12
|
+
const cur = loadProviderAllowedModels("zcode", opts);
|
|
13
|
+
const added = ids.filter((m) => !cur.includes(m));
|
|
14
|
+
if (added.length) saveProviderAllowedModels("zcode", [...cur, ...added], opts);
|
|
15
|
+
return { allowed: [...cur, ...added], added };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 对外目录条目(免费池:价格 0.00;id 带 provider 前缀,对齐 joinModelId 契约)。
|
|
19
|
+
export function buildZcodeModelList({ id = "zcode", ids = ZCODE_MODEL_CATALOG } = {}) {
|
|
20
|
+
return ids.map((raw) => ({
|
|
21
|
+
id: joinModelId(id, raw),
|
|
22
|
+
object: "model",
|
|
23
|
+
created: CREATED,
|
|
24
|
+
owned_by: "zcode",
|
|
25
|
+
name: raw,
|
|
26
|
+
price: "0.00",
|
|
27
|
+
enable: true,
|
|
28
|
+
free: true,
|
|
29
|
+
mark: "*", // 可用标注:免费额度内,登录后可直接调用
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 目录服务:静态目录 + 可选 probe()(额度 capabilities 的 live id 列表)过滤;10 分钟缓存。
|
|
34
|
+
// probe 缺失/失败/为空 → 返回全量目录(宁可多列不可误删)。
|
|
35
|
+
export function createModelsService({ id = "zcode", probe, hasAccount = () => true, clock = Date.now } = {}) {
|
|
36
|
+
let cache = null;
|
|
37
|
+
let fetchedAt = 0;
|
|
38
|
+
|
|
39
|
+
async function listModels() {
|
|
40
|
+
if (!hasAccount()) return []; // 未登录:空目录(不假装有额度)
|
|
41
|
+
const now = clock();
|
|
42
|
+
if (cache && now - fetchedAt < CACHE_TTL_MS) return cache;
|
|
43
|
+
let ids = ZCODE_MODEL_CATALOG;
|
|
44
|
+
if (typeof probe === "function") {
|
|
45
|
+
try {
|
|
46
|
+
const live = await probe();
|
|
47
|
+
if (Array.isArray(live) && live.length) {
|
|
48
|
+
const low = new Set(live.map((m) => String(m).toLowerCase()));
|
|
49
|
+
const filtered = ZCODE_MODEL_CATALOG.filter((m) => low.has(m.toLowerCase()));
|
|
50
|
+
ids = filtered.length ? filtered : ZCODE_MODEL_CATALOG;
|
|
51
|
+
}
|
|
52
|
+
} catch {}
|
|
53
|
+
}
|
|
54
|
+
cache = buildZcodeModelList({ id, ids });
|
|
55
|
+
fetchedAt = now;
|
|
56
|
+
return cache;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function clearCache() {
|
|
60
|
+
cache = null;
|
|
61
|
+
fetchedAt = 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { listModels, clearCache, _cache: () => cache };
|
|
65
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// zcode CLI 轮询 OAuth:POST cli/init → 浏览器授权 → GET cli/poll/{flow_id} 拿 zcode JWT。
|
|
2
|
+
// 契约对齐 zcode-switch oauth.rs(init 自带 poll_token 鉴权;服务端返回的 poll_token 优先;3004=流程过期)。
|
|
3
|
+
import { randomBytes } from "node:crypto";
|
|
4
|
+
import { timeoutSignal } from "../../compat.js";
|
|
5
|
+
import { sleep } from "../base.js";
|
|
6
|
+
import { ZCODE_CLI_INIT_URL, zcodeCliPollUrl, zcodeAppVersion } from "./const.js";
|
|
7
|
+
import { buildZcodeHeaders } from "./headers.js";
|
|
8
|
+
|
|
9
|
+
const INIT_TIMEOUT_MS = 20_000;
|
|
10
|
+
const POLL_TIMEOUT_MS = 15_000;
|
|
11
|
+
const DEFAULT_FLOW_TTL_MS = 300_000;
|
|
12
|
+
|
|
13
|
+
export class ZcodeOAuthError extends Error {
|
|
14
|
+
constructor(message, code = 0) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "ZcodeOAuthError";
|
|
17
|
+
this.code = code;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function parseExpiresAtMs(v) {
|
|
22
|
+
const n = Number(v);
|
|
23
|
+
return Number.isFinite(n) && n > 0 ? n * 1000 : 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export async function initZcodeFlow({ provider = "zai", fetchImpl, deviceMid, version } = {}) {
|
|
27
|
+
const pollToken = randomBytes(32).toString("hex");
|
|
28
|
+
const headers = {
|
|
29
|
+
...buildZcodeHeaders({ token: pollToken, deviceMid, version: version || zcodeAppVersion() }),
|
|
30
|
+
"Content-Type": "application/json",
|
|
31
|
+
};
|
|
32
|
+
const res = await fetchImpl(ZCODE_CLI_INIT_URL, {
|
|
33
|
+
method: "POST",
|
|
34
|
+
headers,
|
|
35
|
+
body: JSON.stringify({ provider }),
|
|
36
|
+
signal: timeoutSignal(INIT_TIMEOUT_MS),
|
|
37
|
+
});
|
|
38
|
+
const payload = await res.json().catch(() => null);
|
|
39
|
+
if (!res.ok || payload?.code !== 0) {
|
|
40
|
+
const msg = String(payload?.msg || "").trim();
|
|
41
|
+
throw new ZcodeOAuthError(`zcode 登录初始化失败:HTTP ${res.status}${msg ? ` ${msg}` : ""}`, Number(payload?.code) || 0);
|
|
42
|
+
}
|
|
43
|
+
const data = payload?.data || {};
|
|
44
|
+
const flowId = String(data.flow_id || "").trim();
|
|
45
|
+
const authorizeUrl = String(data.authorize_url || "").trim();
|
|
46
|
+
if (!flowId || !authorizeUrl) throw new ZcodeOAuthError("zcode 登录初始化响应缺少 flow_id/authorize_url");
|
|
47
|
+
let parsed;
|
|
48
|
+
try { parsed = new URL(authorizeUrl); } catch { throw new ZcodeOAuthError("zcode authorize_url 非法"); }
|
|
49
|
+
if (parsed.protocol !== "https:") throw new ZcodeOAuthError("zcode authorize_url 必须 https");
|
|
50
|
+
const state = parsed.searchParams.get("state") || "";
|
|
51
|
+
if (!state) throw new ZcodeOAuthError("zcode authorize_url 缺少 state");
|
|
52
|
+
return {
|
|
53
|
+
provider,
|
|
54
|
+
flowId,
|
|
55
|
+
authorizeUrl,
|
|
56
|
+
state,
|
|
57
|
+
deviceMid: String(deviceMid || ""),
|
|
58
|
+
pollUrl: zcodeCliPollUrl(flowId),
|
|
59
|
+
pollToken: String(data.poll_token || "").trim() || pollToken,
|
|
60
|
+
expiresAtMs: parseExpiresAtMs(data.expires_at) || Date.now() + DEFAULT_FLOW_TTL_MS,
|
|
61
|
+
pollIntervalMs: Math.max(1000, Number(data.poll_interval_sec) * 1000 || 3000),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 单次轮询:pending 继续、ready 返回凭据;3004/failed 抛终态;网络抖动按 pending(不判死)。
|
|
66
|
+
export async function pollZcodeFlowOnce({ pollUrl, pollToken, deviceMid, version, fetchImpl } = {}) {
|
|
67
|
+
let res;
|
|
68
|
+
try {
|
|
69
|
+
res = await fetchImpl(pollUrl, {
|
|
70
|
+
headers: buildZcodeHeaders({ token: pollToken, deviceMid, version: version || zcodeAppVersion() }),
|
|
71
|
+
signal: timeoutSignal(POLL_TIMEOUT_MS),
|
|
72
|
+
});
|
|
73
|
+
} catch {
|
|
74
|
+
return { status: "pending" };
|
|
75
|
+
}
|
|
76
|
+
if (res.status >= 400) {
|
|
77
|
+
if (res.status === 408 || res.status === 429) return { status: "pending" };
|
|
78
|
+
const body = await res.json().catch(() => null);
|
|
79
|
+
const code = Number(body?.code) || 0;
|
|
80
|
+
if (code === 3004) throw new ZcodeOAuthError("授权已过期,请重新运行 login", 3004);
|
|
81
|
+
const msg = String(body?.msg || "").trim();
|
|
82
|
+
throw new ZcodeOAuthError(`zcode 登录轮询失败:HTTP ${res.status}${msg ? ` ${msg}` : ""}`, code);
|
|
83
|
+
}
|
|
84
|
+
const payload = await res.json().catch(() => null);
|
|
85
|
+
if (!payload || payload.code !== 0) {
|
|
86
|
+
const msg = String(payload?.msg || "响应异常").trim();
|
|
87
|
+
throw new ZcodeOAuthError(`zcode 登录轮询失败:${msg}`, Number(payload?.code) || 0);
|
|
88
|
+
}
|
|
89
|
+
const data = payload?.data || {};
|
|
90
|
+
const status = String(data.status || "").trim();
|
|
91
|
+
if (status === "pending") return { status: "pending" };
|
|
92
|
+
if (status === "failed") throw new ZcodeOAuthError("授权失败(服务端标记 failed),请重试", 0);
|
|
93
|
+
if (status === "ready") {
|
|
94
|
+
const jwt = String(data.token || "").trim();
|
|
95
|
+
const accessToken = String(data?.zai?.access_token || data?.bigmodel?.access_token || "").trim();
|
|
96
|
+
const user = {
|
|
97
|
+
userId: String(data?.user?.user_id || "").trim(),
|
|
98
|
+
name: String(data?.user?.name || "").trim(),
|
|
99
|
+
email: String(data?.user?.email || "").trim(),
|
|
100
|
+
};
|
|
101
|
+
if (!jwt || !user.userId) throw new ZcodeOAuthError("zcode 登录响应缺少 token/user_id");
|
|
102
|
+
return { status: "ready", jwt, accessToken, user };
|
|
103
|
+
}
|
|
104
|
+
throw new ZcodeOAuthError(`zcode 登录轮询未知状态:${status || "(空)"}`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function waitForZcodeLogin({ flow, fetchImpl, log = () => {}, sleepFn = sleep, now = Date.now } = {}) {
|
|
108
|
+
if (!flow?.pollUrl) throw new ZcodeOAuthError("缺少轮询信息");
|
|
109
|
+
while (now() < (flow.expiresAtMs || 0)) {
|
|
110
|
+
const out = await pollZcodeFlowOnce({
|
|
111
|
+
pollUrl: flow.pollUrl,
|
|
112
|
+
pollToken: flow.pollToken,
|
|
113
|
+
deviceMid: flow.deviceMid,
|
|
114
|
+
fetchImpl,
|
|
115
|
+
});
|
|
116
|
+
if (out.status === "ready") return { ...out, provider: flow.provider || "zai" };
|
|
117
|
+
await sleepFn(flow.pollIntervalMs || 3000);
|
|
118
|
+
}
|
|
119
|
+
throw new ZcodeOAuthError("授权已过期,请重新运行 login", 3004);
|
|
120
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
// zcode 额度:GET /api/v1/zcode-plan/billing/balance?app_version= 解析(plans/balances 分组)+ CLI 渲染。
|
|
2
|
+
// 契约来自 zcode-switch quota.rs(unwrap data/result → plans[].plan_id/name/status/expire、balances[].*_units)。
|
|
3
|
+
import { timeoutSignal } from "../../compat.js";
|
|
4
|
+
import { ZCODE_MODEL_CATALOG, zcodeAppVersion, zcodeBalanceUrl, zcodeErrorKind } from "./const.js";
|
|
5
|
+
import { buildZcodeHeaders } from "./headers.js";
|
|
6
|
+
|
|
7
|
+
const num = (v) => {
|
|
8
|
+
if (typeof v === "number" && Number.isFinite(v)) return v;
|
|
9
|
+
if (typeof v === "string" && v.trim()) {
|
|
10
|
+
const n = Number(v.replace(/,/g, "").trim());
|
|
11
|
+
return Number.isFinite(n) ? n : null;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
const firstStr = (obj, keys) => {
|
|
16
|
+
for (const k of keys) {
|
|
17
|
+
const v = obj?.[k];
|
|
18
|
+
if (typeof v === "string" && v.trim()) return v.trim();
|
|
19
|
+
}
|
|
20
|
+
return "";
|
|
21
|
+
};
|
|
22
|
+
const firstNum = (obj, keys) => {
|
|
23
|
+
for (const k of keys) {
|
|
24
|
+
const n = num(obj?.[k]);
|
|
25
|
+
if (n != null) return n;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
const fmtNum = (n) => {
|
|
30
|
+
if (n == null) return "—";
|
|
31
|
+
return String(Math.round(Number(n))).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// 上游可能把业务体包在 data/result 里(最多下钻 4 层,与 zcode-switch unwrap 同语义)
|
|
35
|
+
export function unwrapZcodeData(payload) {
|
|
36
|
+
let cur = payload;
|
|
37
|
+
for (let i = 0; i < 4; i++) {
|
|
38
|
+
if (!cur || typeof cur !== "object" || Array.isArray(cur)) break;
|
|
39
|
+
if (cur.data && typeof cur.data === "object" && !Array.isArray(cur.data)) { cur = cur.data; continue; }
|
|
40
|
+
if (cur.result && typeof cur.result === "object" && !Array.isArray(cur.result)) { cur = cur.result; continue; }
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return cur || {};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function parseZcodeBalance(payload) {
|
|
47
|
+
const data = unwrapZcodeData(payload);
|
|
48
|
+
const rawPlans = Array.isArray(data.plans) ? data.plans : [];
|
|
49
|
+
const rawBalances = Array.isArray(data.balances) ? data.balances : [];
|
|
50
|
+
|
|
51
|
+
const plans = rawPlans.map((p) => ({
|
|
52
|
+
id: firstStr(p, ["plan_id", "planId", "id"]),
|
|
53
|
+
name: firstStr(p, ["name", "show_name", "plan_name"]) || firstStr(p, ["plan_id", "planId"]) || "套餐",
|
|
54
|
+
status: firstStr(p, ["status"]) || "UNKNOWN",
|
|
55
|
+
expire: firstStr(p, ["ends_at", "end_at", "expires_at", "expire", "period_end"]),
|
|
56
|
+
items: [],
|
|
57
|
+
}));
|
|
58
|
+
const loose = [];
|
|
59
|
+
|
|
60
|
+
for (const b of rawBalances) {
|
|
61
|
+
const item = {
|
|
62
|
+
name: firstStr(b, ["show_name", "name", "entitlement_id", "plan_id"]) || "Unknown",
|
|
63
|
+
total: firstNum(b, ["total_units", "total"]),
|
|
64
|
+
used: firstNum(b, ["used_units", "used"]),
|
|
65
|
+
remaining: firstNum(b, ["remaining_units", "available_units", "remaining"]),
|
|
66
|
+
unit: firstStr(b, ["unit_type", "meter", "unit"]) || "quota",
|
|
67
|
+
periodEnd: firstStr(b, ["period_end", "expires_at", "end_at"]),
|
|
68
|
+
planId: firstStr(b, ["plan_id", "planId", "entitlement_id"]),
|
|
69
|
+
};
|
|
70
|
+
item.percentUsed = item.total > 0 && item.used != null ? Math.min(100, Math.round((item.used / item.total) * 1000) / 10) : null;
|
|
71
|
+
const slot = item.planId ? plans.find((s) => s.id === item.planId) : plans.length === 1 ? plans[0] : null;
|
|
72
|
+
if (slot) slot.items.push(item);
|
|
73
|
+
else loose.push(item);
|
|
74
|
+
}
|
|
75
|
+
for (const s of plans) if (!s.expire) s.expire = s.items.map((i) => i.periodEnd).find(Boolean) || "";
|
|
76
|
+
|
|
77
|
+
const all = [...plans.flatMap((s) => s.items), ...loose];
|
|
78
|
+
const sum = (k) => (all.some((i) => i[k] != null) ? all.reduce((a, i) => a + (i[k] || 0), 0) : null);
|
|
79
|
+
return {
|
|
80
|
+
isEmpty: plans.length === 0 && loose.length === 0,
|
|
81
|
+
plans,
|
|
82
|
+
loose,
|
|
83
|
+
totals: { total: sum("total"), used: sum("used"), remaining: sum("remaining") },
|
|
84
|
+
itemCount: all.length,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// entitlement 名 → 内置目录里的 canonical id(同名词取最长命中的目录项,避免 GLM-5.3-Flash 误配 GLM-5.3)
|
|
89
|
+
export function balanceModelIds(parsed) {
|
|
90
|
+
const names = [
|
|
91
|
+
...(parsed?.plans || []).flatMap((s) => s.items.map((i) => i.name)),
|
|
92
|
+
...(parsed?.loose || []).map((i) => i.name),
|
|
93
|
+
]
|
|
94
|
+
.filter(Boolean)
|
|
95
|
+
.map((n) => String(n).toLowerCase().replace(/\s+/g, "-"));
|
|
96
|
+
const out = [];
|
|
97
|
+
for (const n of names) {
|
|
98
|
+
const hit = ZCODE_MODEL_CATALOG.filter((m) => n.includes(m.toLowerCase())).sort((a, b) => b.length - a.length)[0];
|
|
99
|
+
if (hit && !out.includes(hit)) out.push(hit);
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export async function fetchZcodeBalance({ token, deviceMid = "", fetchImpl, version = zcodeAppVersion(), timeoutMs = 15_000 } = {}) {
|
|
105
|
+
const url = zcodeBalanceUrl(version);
|
|
106
|
+
const headers = { ...buildZcodeHeaders({ token, deviceMid, version }), Accept: "application/json" };
|
|
107
|
+
let res;
|
|
108
|
+
try {
|
|
109
|
+
res = await fetchImpl(url, { method: "GET", headers, signal: timeoutSignal(timeoutMs) });
|
|
110
|
+
} catch (e) {
|
|
111
|
+
return { ok: false, kind: "network", status: 0, code: 0, message: String(e?.message || e).slice(0, 160), modelIds: [] };
|
|
112
|
+
}
|
|
113
|
+
const payload = await res.json().catch(() => null);
|
|
114
|
+
const code = Number(payload?.code) || 0;
|
|
115
|
+
const bizOk = Boolean(payload) && payload.success !== false && (!code || code === 200);
|
|
116
|
+
if (!res.ok || !bizOk) {
|
|
117
|
+
let kind = zcodeErrorKind(code);
|
|
118
|
+
if (kind === "unknown") {
|
|
119
|
+
if (res.status === 401) kind = "auth";
|
|
120
|
+
else if (res.status === 429) kind = "rate_limit";
|
|
121
|
+
else if (res.status >= 500) kind = "server";
|
|
122
|
+
else if (!bizOk) kind = "server";
|
|
123
|
+
}
|
|
124
|
+
const message = String(payload?.msg || payload?.message || `HTTP ${res.status}`).trim();
|
|
125
|
+
return { ok: false, kind, status: res.status, code, message, modelIds: [] };
|
|
126
|
+
}
|
|
127
|
+
const parsed = parseZcodeBalance(payload);
|
|
128
|
+
return { ok: true, status: res.status, code, parsed, modelIds: balanceModelIds(parsed) };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function formatZcodeQuota(result = {}, { account = "" } = {}) {
|
|
132
|
+
const head = `zcode quota${account ? ` · ${account}` : ""}`;
|
|
133
|
+
if (!result.ok) {
|
|
134
|
+
const kind = result.kind || "unknown";
|
|
135
|
+
if (kind === "auth") {
|
|
136
|
+
return [head, `登录已失效(code ${result.code || 1006})。请重新登录:`, " mslxdff -provider zcode login"].join("\n");
|
|
137
|
+
}
|
|
138
|
+
const detail = `${kind}${result.code ? ` code ${result.code}` : ""}${result.status ? ` HTTP ${result.status}` : ""}`;
|
|
139
|
+
return [
|
|
140
|
+
head,
|
|
141
|
+
`查询失败(${detail})${result.message ? `:${result.message}` : ""}`,
|
|
142
|
+
"稍后重试;若反复失败:mslxdff -provider zcode login 重新登录",
|
|
143
|
+
].join("\n");
|
|
144
|
+
}
|
|
145
|
+
const parsed = result.parsed || {};
|
|
146
|
+
if (parsed.isEmpty) {
|
|
147
|
+
return [
|
|
148
|
+
head,
|
|
149
|
+
"当前账号无套餐(未领取体验额度)。",
|
|
150
|
+
"可在官方 ZCode 客户端 / zcode-switch 领取 Start Plan 体验额度后重试:",
|
|
151
|
+
" mslxdff -provider zcode quota",
|
|
152
|
+
].join("\n");
|
|
153
|
+
}
|
|
154
|
+
const lines = [head];
|
|
155
|
+
if (parsed.totals?.remaining != null) {
|
|
156
|
+
lines.push(`总余量 ${fmtNum(parsed.totals.remaining)}(已用 ${fmtNum(parsed.totals.used ?? 0)} / 总 ${fmtNum(parsed.totals.total ?? 0)})`);
|
|
157
|
+
}
|
|
158
|
+
for (const p of parsed.plans || []) {
|
|
159
|
+
lines.push("");
|
|
160
|
+
lines.push(`[${p.name || p.id || "套餐"}] ${p.status}${p.expire ? ` 有效期至 ${p.expire}` : ""}`);
|
|
161
|
+
const w = Math.max(6, ...p.items.map((i) => String(i.name).length));
|
|
162
|
+
for (const i of p.items) {
|
|
163
|
+
const used = i.percentUsed != null ? ` 已用 ${i.percentUsed}%` : "";
|
|
164
|
+
lines.push(` * ${String(i.name).padEnd(w)} 余 ${fmtNum(i.remaining ?? 0)} ${i.unit} / 总 ${fmtNum(i.total ?? 0)}${used}`);
|
|
165
|
+
}
|
|
166
|
+
if (!p.items.length) lines.push(" (该套餐无 entitlement 明细)");
|
|
167
|
+
}
|
|
168
|
+
if ((parsed.loose || []).length) {
|
|
169
|
+
lines.push("");
|
|
170
|
+
lines.push("[未归属套餐的额度]");
|
|
171
|
+
for (const i of parsed.loose) lines.push(` * ${i.name} 余 ${fmtNum(i.remaining ?? 0)} ${i.unit} / 总 ${fmtNum(i.total ?? 0)}`);
|
|
172
|
+
}
|
|
173
|
+
lines.push("");
|
|
174
|
+
lines.push("提示: mslxdff -provider zcode models 查看可用模型 · 额度按官方计费周期重置");
|
|
175
|
+
return lines.join("\n");
|
|
176
|
+
}
|