mslxdff 0.1.161 → 0.1.162
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/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 +126 -126
- package/src/chat-pipeline/policy.js +76 -76
- package/src/cli/commands/group.js +249 -249
- 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 +126 -126
- package/src/cli/commands/provider/models.js +142 -142
- package/src/cli/commands/provider/qwenwork-login.js +119 -119
- package/src/cli/commands/sync.js +232 -232
- package/src/cli/format.js +1 -0
- package/src/cli/status.js +279 -279
- package/src/daemon.js +101 -101
- 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 +4 -3
- package/src/models.js +225 -225
- 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/dispatcher.js +26 -14
- package/src/providers/globalqwenwork/cosy.js +123 -123
- package/src/providers/globalqwenwork/crypto.js +218 -218
- package/src/providers/globalqwenwork/http.js +20 -20
- package/src/providers/globalqwenwork/rsa.js +54 -54
- package/src/providers/globalqwenwork/sse.js +268 -268
- package/src/providers/globalqwenwork/stream.js +130 -130
- package/src/providers/globalqwenwork/upstream.js +122 -122
- package/src/providers/keyring.js +60 -60
- package/src/providers/qoder/chat.js +193 -183
- package/src/providers/qoder/index.js +239 -230
- package/src/providers/qoder/sse.js +141 -103
- package/src/providers/qwenwork/account-store.js +133 -133
- package/src/providers/qwenwork/constants.js +67 -67
- package/src/providers/qwenwork/cosy.js +120 -120
- package/src/providers/qwenwork/crypto.js +218 -218
- package/src/providers/qwenwork/http.js +20 -20
- package/src/providers/qwenwork/index.js +327 -327
- package/src/providers/qwenwork/payload.js +142 -142
- package/src/providers/qwenwork/rsa.js +54 -54
- package/src/providers/qwenwork/sse.js +268 -268
- package/src/providers/qwenwork/stream.js +130 -130
- package/src/providers/qwenwork/upstream.js +120 -120
- package/src/providers/qwenwork.js +1 -1
- package/src/providers/registry.js +74 -74
- 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/reasoning.js +32 -32
- package/src/routes/chat/gateway.js +46 -46
- package/src/routes/chat/relay-pipeline.js +276 -276
- package/src/routes/chat/via-route-handler.js +146 -146
- 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 +386 -386
- package/src/runtime/bootstrap.js +45 -45
- package/src/runtime/provider-gate.js +34 -34
- package/src/runtime/providers-setup.js +165 -165
- package/src/runtime/server-lifecycle.js +5 -6
- 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
- package/docs/cli_help_mini.md +0 -135
- package/src/providers/AGENTS.md +0 -46
- package/src/routes/AGENTS.md +0 -37
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
import { appendEvent } from "../logs.js";
|
|
2
|
-
import { splitModelId, DEFAULT_PROVIDER, joinModelId } from "./model-id.js";
|
|
3
|
-
import { isModelAllowed as stateIsAllowed, loadProviderAllowedModels as stateLoadAllowed, loadProviderAllowAnyModels as stateLoadAllowAny } from "../state.js";
|
|
1
|
+
import { appendEvent } from "../logs.js";
|
|
2
|
+
import { splitModelId, DEFAULT_PROVIDER, joinModelId } from "./model-id.js";
|
|
3
|
+
import { isModelAllowed as stateIsAllowed, loadProviderAllowedModels as stateLoadAllowed, loadProviderAllowAnyModels as stateLoadAllowAny } from "../state.js";
|
|
4
|
+
// 定制预热名单:registry customProviders 8 家 + 默认 opencode;openrouter/自配 generic 不预热(按需自拉)
|
|
5
|
+
const CUSTOM_PREHEAT_IDS = new Set(["opencode", "workbuddy", "traework", "cline", "codearts", "qoder", "globalqwenwork", "qwenwork", "zcode"]);
|
|
6
|
+
function isPreheatDisabled() {
|
|
7
|
+
const raw = process.env.MSLXDFF_PREHEAT;
|
|
8
|
+
if (raw === undefined || raw === null || raw === "") return false;
|
|
9
|
+
const s = String(raw).trim().toLowerCase();
|
|
10
|
+
return s === "0" || s === "off" || s === "false" || s === "no" || s === "disable" || s === "disabled";
|
|
11
|
+
}
|
|
4
12
|
|
|
5
13
|
// 多供应商 dispatcher:把多个 Provider 聚合成一个 `upstream` 形状(chat/preheat/close),
|
|
6
14
|
// 按 body.model 的前缀路由到对应供应商,转发上游前剥掉前缀只发原始 id。
|
|
@@ -111,18 +119,22 @@ export function createProviderDispatcher(providers = [], opts = {}) {
|
|
|
111
119
|
return out;
|
|
112
120
|
}
|
|
113
121
|
|
|
114
|
-
//
|
|
115
|
-
//
|
|
116
|
-
// 对所有上游各发一次 GET;MSLXDFF_PREHEAT=0 的关闭由唯一被调的 opencode preheat 自行尊重。
|
|
117
|
-
// 见 .agents/notes/implemented/simplification/2026-09-16-preheat-opencode-only.md
|
|
122
|
+
// 预热定制供应商 + 默认供应商(opencode):registry 名单 8 家 + opencode 共 9 家并发各打一次;
|
|
123
|
+
// openrouter/用户自配 generic 不在此列(按需首次请求自拉)。单家失败静默,不拖累启动。
|
|
118
124
|
async function preheat() {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
if (isPreheatDisabled()) return { ok: true, skipped: true };
|
|
126
|
+
const targets = providers.filter((p) => p && typeof p.preheat === "function" && CUSTOM_PREHEAT_IDS.has(p.id));
|
|
127
|
+
if (!targets.length) return { ok: false, skipped: true };
|
|
128
|
+
const settled = await Promise.all(targets.map(async (p) => {
|
|
129
|
+
try {
|
|
130
|
+
const r = await p.preheat();
|
|
131
|
+
return { id: p.id, ...(r && typeof r === "object" ? r : { ok: false }) };
|
|
132
|
+
} catch {
|
|
133
|
+
return { id: p.id, ok: false, error: "preheat failed" };
|
|
134
|
+
}
|
|
135
|
+
}));
|
|
136
|
+
const okCount = settled.filter((r) => r && r.ok).length;
|
|
137
|
+
return { ok: okCount > 0, results: settled, okCount, total: settled.length };
|
|
126
138
|
}
|
|
127
139
|
|
|
128
140
|
async function close() {
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
// cosy.js(COSY 会话 + 签名头)— vendor 自 src/providers/qwenwork/cosy.js 逐字搬;
|
|
2
|
-
// 本目录 import 全为相对路径,自动绑定本目录 constants/crypto/rsa。线上头 x-qwenwork-* 与 cn 同名,**禁止改名**(实测 .ai 接受)。
|
|
3
|
-
// 关键不变式(改动即 403):
|
|
4
|
-
// · identity/payload 都必须 key 升序紧凑 JSON(sortedCompact)
|
|
5
|
-
// · 签名 = md5(payloadB64 \n cosyKey \n date \n body \n pathSig),pathSig 去 /algo 前缀、不含 query
|
|
6
|
-
// · authorization = `Bearer COSY.${payloadB64}.${sig}`;payloadB64 是**标准 base64(带 padding)**
|
|
7
|
-
// · 同一 requestId 重放会被上游判 `code 103 Duplicate request`
|
|
8
|
-
import { uuid, b64, b64url, utf8, aesCbcEncrypt, md5 } from "./crypto.js";
|
|
9
|
-
import { rsaPkcs1Encrypt } from "./rsa.js";
|
|
10
|
-
import {
|
|
11
|
-
COSY_VERSION, IDE_VERSION, RELEASE_VERSION, BUILD, CLIENT_TYPE,
|
|
12
|
-
BUSINESS_PRODUCT, BUSINESS_TYPE, SCENE, MACHINE_OS, UA,
|
|
13
|
-
} from "./constants.js";
|
|
14
|
-
|
|
15
|
-
const cache = new Map();
|
|
16
|
-
|
|
17
|
-
function sortedCompact(obj) {
|
|
18
|
-
const keys = Object.keys(obj).sort();
|
|
19
|
-
let out = "{";
|
|
20
|
-
for (let i = 0; i < keys.length; i++) {
|
|
21
|
-
if (i > 0) out += ",";
|
|
22
|
-
out += JSON.stringify(keys[i]) + ":" + JSON.stringify(obj[keys[i]]);
|
|
23
|
-
}
|
|
24
|
-
return out + "}";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function newSession(account) {
|
|
28
|
-
const machineID = uuid();
|
|
29
|
-
const seed = (uuid() + uuid()).slice(0, 50);
|
|
30
|
-
const machineToken = b64url(utf8(seed));
|
|
31
|
-
const machineType = uuid().replace(/-/g, "").slice(0, 18);
|
|
32
|
-
const tempKey = uuid().replace(/-/g, "").slice(0, 16);
|
|
33
|
-
|
|
34
|
-
const identity = sortedCompact({
|
|
35
|
-
uid: account.uid || "",
|
|
36
|
-
aid: account.uid || "",
|
|
37
|
-
name: account.nickname || "",
|
|
38
|
-
email: account.email || "",
|
|
39
|
-
security_oauth_token: account.accessToken,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
machineID,
|
|
44
|
-
machineToken,
|
|
45
|
-
machineType,
|
|
46
|
-
tempKey,
|
|
47
|
-
cosyKey: rsaPkcs1Encrypt(utf8(tempKey)),
|
|
48
|
-
info: b64(aesCbcEncrypt(utf8(identity), utf8(tempKey))),
|
|
49
|
-
accessToken: account.accessToken,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function sessionFor(account) {
|
|
54
|
-
if (!account || !account.accessToken) throw new Error("cosy: empty access token");
|
|
55
|
-
const key = account.id || account.uid || account.accessToken.slice(0, 16);
|
|
56
|
-
const hit = cache.get(key);
|
|
57
|
-
if (hit && hit.accessToken === account.accessToken) return hit;
|
|
58
|
-
if (cache.size > 128) cache.clear();
|
|
59
|
-
const sess = newSession(account);
|
|
60
|
-
cache.set(key, sess);
|
|
61
|
-
return sess;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function invalidateSession(account) {
|
|
65
|
-
const key = account && (account.id || account.uid);
|
|
66
|
-
if (key) cache.delete(key);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function pathSig(rawURL) {
|
|
70
|
-
const u = new URL(rawURL);
|
|
71
|
-
let p = u.pathname;
|
|
72
|
-
if (p.startsWith("/algo")) p = p.slice("/algo".length);
|
|
73
|
-
return p;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function signHeaders(account, body, rawURL, modelKey, accept) {
|
|
77
|
-
const sess = sessionFor(account);
|
|
78
|
-
const payload = sortedCompact({
|
|
79
|
-
cosyVersion: COSY_VERSION,
|
|
80
|
-
ideVersion: IDE_VERSION,
|
|
81
|
-
info: sess.info,
|
|
82
|
-
requestId: uuid(),
|
|
83
|
-
version: "v1",
|
|
84
|
-
});
|
|
85
|
-
const payloadB64 = b64(utf8(payload));
|
|
86
|
-
const date = Math.floor(Date.now() / 1000).toString();
|
|
87
|
-
const sig = md5(`${payloadB64}\n${sess.cosyKey}\n${date}\n${body}\n${pathSig(rawURL)}`);
|
|
88
|
-
|
|
89
|
-
const headers = {
|
|
90
|
-
accept: accept || "text/event-stream",
|
|
91
|
-
"content-type": "application/json",
|
|
92
|
-
"user-agent": UA,
|
|
93
|
-
"x-request-id": uuid(),
|
|
94
|
-
"x-qwenwork-version": IDE_VERSION,
|
|
95
|
-
"x-qwenwork-release-version": RELEASE_VERSION,
|
|
96
|
-
"x-qwenwork-build": BUILD,
|
|
97
|
-
"x-qwenwork-platform": "win32",
|
|
98
|
-
"x-qwenwork-arch": "x64",
|
|
99
|
-
"x-qwenwork-channel": "stable",
|
|
100
|
-
"cosy-version": COSY_VERSION,
|
|
101
|
-
"cosy-clienttype": CLIENT_TYPE,
|
|
102
|
-
"cosy-business-product": BUSINESS_PRODUCT,
|
|
103
|
-
"cosy-business-type": BUSINESS_TYPE,
|
|
104
|
-
"cosy-scene": SCENE,
|
|
105
|
-
"cosy-machineos": MACHINE_OS,
|
|
106
|
-
"login-version": "v2",
|
|
107
|
-
authorization: `Bearer COSY.${payloadB64}.${sig}`,
|
|
108
|
-
"cosy-key": sess.cosyKey,
|
|
109
|
-
"cosy-user": account.uid || "",
|
|
110
|
-
"cosy-date": date,
|
|
111
|
-
"cosy-machineid": sess.machineID,
|
|
112
|
-
"accept-encoding": "identity",
|
|
113
|
-
connection: "keep-alive",
|
|
114
|
-
"cache-control": "no-cache",
|
|
115
|
-
};
|
|
116
|
-
if (modelKey) {
|
|
117
|
-
headers["x-model-key"] = modelKey;
|
|
118
|
-
headers["x-model-source"] = "system";
|
|
119
|
-
}
|
|
120
|
-
return headers;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// globalqwenwork 变体(国际站 gateway.qwenwork.ai):协议与 cn 逐字同构,2026-10-01 现网实测签名/请求 200 — 见 docs/adr/0041-globalqwenwork-international-provider.md
|
|
1
|
+
// cosy.js(COSY 会话 + 签名头)— vendor 自 src/providers/qwenwork/cosy.js 逐字搬;
|
|
2
|
+
// 本目录 import 全为相对路径,自动绑定本目录 constants/crypto/rsa。线上头 x-qwenwork-* 与 cn 同名,**禁止改名**(实测 .ai 接受)。
|
|
3
|
+
// 关键不变式(改动即 403):
|
|
4
|
+
// · identity/payload 都必须 key 升序紧凑 JSON(sortedCompact)
|
|
5
|
+
// · 签名 = md5(payloadB64 \n cosyKey \n date \n body \n pathSig),pathSig 去 /algo 前缀、不含 query
|
|
6
|
+
// · authorization = `Bearer COSY.${payloadB64}.${sig}`;payloadB64 是**标准 base64(带 padding)**
|
|
7
|
+
// · 同一 requestId 重放会被上游判 `code 103 Duplicate request`
|
|
8
|
+
import { uuid, b64, b64url, utf8, aesCbcEncrypt, md5 } from "./crypto.js";
|
|
9
|
+
import { rsaPkcs1Encrypt } from "./rsa.js";
|
|
10
|
+
import {
|
|
11
|
+
COSY_VERSION, IDE_VERSION, RELEASE_VERSION, BUILD, CLIENT_TYPE,
|
|
12
|
+
BUSINESS_PRODUCT, BUSINESS_TYPE, SCENE, MACHINE_OS, UA,
|
|
13
|
+
} from "./constants.js";
|
|
14
|
+
|
|
15
|
+
const cache = new Map();
|
|
16
|
+
|
|
17
|
+
function sortedCompact(obj) {
|
|
18
|
+
const keys = Object.keys(obj).sort();
|
|
19
|
+
let out = "{";
|
|
20
|
+
for (let i = 0; i < keys.length; i++) {
|
|
21
|
+
if (i > 0) out += ",";
|
|
22
|
+
out += JSON.stringify(keys[i]) + ":" + JSON.stringify(obj[keys[i]]);
|
|
23
|
+
}
|
|
24
|
+
return out + "}";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function newSession(account) {
|
|
28
|
+
const machineID = uuid();
|
|
29
|
+
const seed = (uuid() + uuid()).slice(0, 50);
|
|
30
|
+
const machineToken = b64url(utf8(seed));
|
|
31
|
+
const machineType = uuid().replace(/-/g, "").slice(0, 18);
|
|
32
|
+
const tempKey = uuid().replace(/-/g, "").slice(0, 16);
|
|
33
|
+
|
|
34
|
+
const identity = sortedCompact({
|
|
35
|
+
uid: account.uid || "",
|
|
36
|
+
aid: account.uid || "",
|
|
37
|
+
name: account.nickname || "",
|
|
38
|
+
email: account.email || "",
|
|
39
|
+
security_oauth_token: account.accessToken,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
machineID,
|
|
44
|
+
machineToken,
|
|
45
|
+
machineType,
|
|
46
|
+
tempKey,
|
|
47
|
+
cosyKey: rsaPkcs1Encrypt(utf8(tempKey)),
|
|
48
|
+
info: b64(aesCbcEncrypt(utf8(identity), utf8(tempKey))),
|
|
49
|
+
accessToken: account.accessToken,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function sessionFor(account) {
|
|
54
|
+
if (!account || !account.accessToken) throw new Error("cosy: empty access token");
|
|
55
|
+
const key = account.id || account.uid || account.accessToken.slice(0, 16);
|
|
56
|
+
const hit = cache.get(key);
|
|
57
|
+
if (hit && hit.accessToken === account.accessToken) return hit;
|
|
58
|
+
if (cache.size > 128) cache.clear();
|
|
59
|
+
const sess = newSession(account);
|
|
60
|
+
cache.set(key, sess);
|
|
61
|
+
return sess;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function invalidateSession(account) {
|
|
65
|
+
const key = account && (account.id || account.uid);
|
|
66
|
+
if (key) cache.delete(key);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function pathSig(rawURL) {
|
|
70
|
+
const u = new URL(rawURL);
|
|
71
|
+
let p = u.pathname;
|
|
72
|
+
if (p.startsWith("/algo")) p = p.slice("/algo".length);
|
|
73
|
+
return p;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function signHeaders(account, body, rawURL, modelKey, accept) {
|
|
77
|
+
const sess = sessionFor(account);
|
|
78
|
+
const payload = sortedCompact({
|
|
79
|
+
cosyVersion: COSY_VERSION,
|
|
80
|
+
ideVersion: IDE_VERSION,
|
|
81
|
+
info: sess.info,
|
|
82
|
+
requestId: uuid(),
|
|
83
|
+
version: "v1",
|
|
84
|
+
});
|
|
85
|
+
const payloadB64 = b64(utf8(payload));
|
|
86
|
+
const date = Math.floor(Date.now() / 1000).toString();
|
|
87
|
+
const sig = md5(`${payloadB64}\n${sess.cosyKey}\n${date}\n${body}\n${pathSig(rawURL)}`);
|
|
88
|
+
|
|
89
|
+
const headers = {
|
|
90
|
+
accept: accept || "text/event-stream",
|
|
91
|
+
"content-type": "application/json",
|
|
92
|
+
"user-agent": UA,
|
|
93
|
+
"x-request-id": uuid(),
|
|
94
|
+
"x-qwenwork-version": IDE_VERSION,
|
|
95
|
+
"x-qwenwork-release-version": RELEASE_VERSION,
|
|
96
|
+
"x-qwenwork-build": BUILD,
|
|
97
|
+
"x-qwenwork-platform": "win32",
|
|
98
|
+
"x-qwenwork-arch": "x64",
|
|
99
|
+
"x-qwenwork-channel": "stable",
|
|
100
|
+
"cosy-version": COSY_VERSION,
|
|
101
|
+
"cosy-clienttype": CLIENT_TYPE,
|
|
102
|
+
"cosy-business-product": BUSINESS_PRODUCT,
|
|
103
|
+
"cosy-business-type": BUSINESS_TYPE,
|
|
104
|
+
"cosy-scene": SCENE,
|
|
105
|
+
"cosy-machineos": MACHINE_OS,
|
|
106
|
+
"login-version": "v2",
|
|
107
|
+
authorization: `Bearer COSY.${payloadB64}.${sig}`,
|
|
108
|
+
"cosy-key": sess.cosyKey,
|
|
109
|
+
"cosy-user": account.uid || "",
|
|
110
|
+
"cosy-date": date,
|
|
111
|
+
"cosy-machineid": sess.machineID,
|
|
112
|
+
"accept-encoding": "identity",
|
|
113
|
+
connection: "keep-alive",
|
|
114
|
+
"cache-control": "no-cache",
|
|
115
|
+
};
|
|
116
|
+
if (modelKey) {
|
|
117
|
+
headers["x-model-key"] = modelKey;
|
|
118
|
+
headers["x-model-source"] = "system";
|
|
119
|
+
}
|
|
120
|
+
return headers;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// globalqwenwork 变体(国际站 gateway.qwenwork.ai):协议与 cn 逐字同构,2026-10-01 现网实测签名/请求 200 — 见 docs/adr/0041-globalqwenwork-international-provider.md
|