mslxdff 0.1.174 → 0.1.176

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.
Files changed (117) hide show
  1. package/bin/mslxdff.js +3 -3
  2. package/package.json +1 -1
  3. package/src/auto.js +254 -254
  4. package/src/bench/cline-bench.js +42 -42
  5. package/src/bench/probe.js +70 -70
  6. package/src/bench/report.js +162 -162
  7. package/src/bench/runner.js +77 -77
  8. package/src/bench/via-probe.js +124 -124
  9. package/src/bench/via-routes.js +87 -87
  10. package/src/bench/workbuddy-bench.js +54 -54
  11. package/src/chat/engine.js +160 -160
  12. package/src/chat/gateway.js +163 -163
  13. package/src/chat/orchestrator.js +234 -234
  14. package/src/chat/prompt.js +70 -70
  15. package/src/chat/repl.js +88 -88
  16. package/src/chat/terminal.js +135 -135
  17. package/src/chat/tools.js +306 -306
  18. package/src/chat-pipeline/auto-race.js +26 -1
  19. package/src/chat-pipeline/index.js +131 -131
  20. package/src/chat-pipeline/policy.js +84 -84
  21. package/src/chat-pipeline/serial-trial.js +35 -8
  22. package/src/chat-pipeline/terminal-verdict.js +109 -0
  23. package/src/cli/commands/group.js +249 -249
  24. package/src/cli/commands/model/picks.js +50 -50
  25. package/src/cli/commands/provider/bench-via.js +247 -247
  26. package/src/cli/commands/provider/bench.js +141 -141
  27. package/src/cli/commands/provider/index.js +136 -133
  28. package/src/cli/commands/provider/keys-guard.js +50 -0
  29. package/src/cli/commands/provider/keys.js +7 -0
  30. package/src/cli/commands/provider/models.js +145 -145
  31. package/src/cli/commands/provider/qwenwork-login.js +119 -119
  32. package/src/cli/commands/provider/traework-checkin.js +144 -0
  33. package/src/cli/commands/provider/traework-login.js +7 -45
  34. package/src/cli/commands/sync.js +310 -310
  35. package/src/cli/help.js +3 -0
  36. package/src/cli/status.js +279 -279
  37. package/src/daemon.js +112 -112
  38. package/src/model-capabilities/enrich.js +86 -86
  39. package/src/model-capabilities/index.js +183 -183
  40. package/src/model-capabilities/parse.js +70 -70
  41. package/src/model-trace.js +2 -0
  42. package/src/models.js +225 -225
  43. package/src/providers/cline/auth.js +228 -228
  44. package/src/providers/cline/chat.js +307 -307
  45. package/src/providers/cline.js +2 -2
  46. package/src/providers/codearts/chat.js +7 -1
  47. package/src/providers/codearts/const.js +6 -1
  48. package/src/providers/codearts/index.js +18 -11
  49. package/src/providers/globalqwenwork/cosy.js +123 -123
  50. package/src/providers/globalqwenwork/crypto.js +218 -218
  51. package/src/providers/globalqwenwork/http.js +20 -20
  52. package/src/providers/globalqwenwork/rsa.js +54 -54
  53. package/src/providers/globalqwenwork/sse.js +268 -268
  54. package/src/providers/globalqwenwork/stream.js +130 -130
  55. package/src/providers/globalqwenwork/upstream.js +122 -122
  56. package/src/providers/keyring.js +60 -60
  57. package/src/providers/qoder/chat.js +203 -203
  58. package/src/providers/qoder/index.js +249 -249
  59. package/src/providers/qoder/sse.js +145 -145
  60. package/src/providers/qwenwork/account-store.js +133 -133
  61. package/src/providers/qwenwork/constants.js +67 -67
  62. package/src/providers/qwenwork/cosy.js +120 -120
  63. package/src/providers/qwenwork/crypto.js +218 -218
  64. package/src/providers/qwenwork/http.js +20 -20
  65. package/src/providers/qwenwork/index.js +327 -327
  66. package/src/providers/qwenwork/payload.js +144 -144
  67. package/src/providers/qwenwork/rsa.js +54 -54
  68. package/src/providers/qwenwork/sse.js +268 -268
  69. package/src/providers/qwenwork/stream.js +130 -130
  70. package/src/providers/qwenwork/upstream.js +120 -120
  71. package/src/providers/qwenwork.js +1 -1
  72. package/src/providers/registry.js +79 -79
  73. package/src/providers/traework/account-store.js +87 -2
  74. package/src/providers/traework/checkin.js +51 -9
  75. package/src/providers/traework/constants.js +20 -0
  76. package/src/providers/traework/headers.js +42 -10
  77. package/src/providers/traework/index.js +14 -4
  78. package/src/providers/traework/market-identity.js +116 -0
  79. package/src/providers/workbuddy/chat.js +248 -248
  80. package/src/providers/workbuddy/reshape.js +152 -152
  81. package/src/providers/workbuddy.js +2 -2
  82. package/src/reasoning.js +32 -32
  83. package/src/routes/chat/gateway.js +46 -46
  84. package/src/routes/chat/relay-pipeline.js +294 -294
  85. package/src/routes/chat/via-route-handler.js +146 -146
  86. package/src/routes/hedge.js +255 -255
  87. package/src/routes/models-route.js +167 -167
  88. package/src/routes/peers.js +273 -273
  89. package/src/routes/stream.js +385 -385
  90. package/src/runtime/bootstrap.js +50 -50
  91. package/src/runtime/provider-gate.js +36 -36
  92. package/src/runtime/providers-setup.js +168 -165
  93. package/src/runtime/traework-checkin.js +26 -11
  94. package/src/server.js +69 -69
  95. package/src/state/schemas/allowlist.js +92 -92
  96. package/src/sync-opencode.js +280 -280
  97. package/src/transport/index.js +244 -244
  98. package/src/transport/pool.js +56 -56
  99. package/src/transport/retry.js +24 -24
  100. package/src/transport/sse.js +93 -93
  101. package/src/upstream-probe/display.js +52 -52
  102. package/src/upstream-probe/probe.js +49 -49
  103. package/src/upstream-probe/rotate.js +110 -110
  104. package/src/upstream-probe/start.js +45 -45
  105. package/src/upstream.js +291 -289
  106. package/src/warp-pool/config.js +71 -0
  107. package/src/warp-pool/health.js +65 -0
  108. package/src/warp-pool/index.js +261 -0
  109. package/src/warp-pool/keys.js +29 -0
  110. package/src/warp-pool/nodes.js +94 -0
  111. package/src/warp-pool/register.js +113 -0
  112. package/src/warp-pool/rotate.js +150 -0
  113. package/src/warp-pool/strategy.js +43 -0
  114. package/src/warp-pool/wireproxy.js +153 -0
  115. package/docs/cli_help_mini.md +0 -143
  116. package/src/providers/AGENTS.md +0 -49
  117. package/src/routes/AGENTS.md +0 -37
@@ -1,144 +1,144 @@
1
- // vendor 自 _shared/body.js(OpenAI body → agent_chat 请求体),逐字搬;去掉 desensitize 分支。
2
- // 实测通过的字段形状(2026-09-29 真号 200):request_id==request_set_id==chat_record_id、
3
- // stream 恒 true、system 抽到顶层且不出现在 messages、parameters.max_tokens 默认 32000。
4
- import { uuid } from "./crypto.js";
5
- import { DEFAULT_MODEL, BUSINESS_PRODUCT, BUSINESS_TYPE, CONTEXT_LENGTH } from "./constants.js";
6
- import { effortFromBody, isReasoningEnabled } from "../../thinking-effort.js";
7
-
8
- export function mapModel(name) {
9
- const m = String(name || "").trim();
10
- switch (m) {
11
- case "":
12
- case "auto":
13
- case "lite":
14
- case "flash":
15
- return "flash";
16
- case "advanced":
17
- case "pro":
18
- return "pro";
19
- case "max":
20
- case "qwen3.8-max":
21
- case "qwen3.8-max-preview":
22
- return "qwen3.8-max-preview";
23
- default:
24
- return m;
25
- }
26
- }
27
-
28
- function contentText(value) {
29
- if (typeof value === "string") return value;
30
- if (Array.isArray(value)) {
31
- let out = "";
32
- for (const part of value) {
33
- if (part && typeof part === "object" && typeof part.text === "string") out += part.text;
34
- }
35
- return out;
36
- }
37
- if (value === null || value === undefined) return "";
38
- return JSON.stringify(value);
39
- }
40
-
41
- function splitMessages(payload) {
42
- const raw = Array.isArray(payload.messages) ? payload.messages : [];
43
- const sysParts = [];
44
- const messages = [];
45
- let lastUser = "";
46
- for (const item of raw) {
47
- if (!item || typeof item !== "object") continue;
48
- if (item.role === "system") {
49
- const text = contentText(item.content);
50
- if (text) sysParts.push(text);
51
- continue;
52
- }
53
- messages.push(item);
54
- }
55
- for (let i = messages.length - 1; i >= 0; i--) {
56
- const m = messages[i];
57
- if (m && m.role === "user") {
58
- lastUser = contentText(m.content);
59
- break;
60
- }
61
- }
62
- return { system: sysParts.join("\n\n"), messages, lastUser };
63
- }
64
-
65
- export function buildBody(payload, modelKey) {
66
- const key = modelKey || DEFAULT_MODEL;
67
- const requestID = uuid();
68
- const { system, messages, lastUser: first } = splitMessages(payload);
69
- let lastUser = first;
70
- if (!lastUser) {
71
- for (const m of messages) {
72
- if (m && m.role === "user") {
73
- lastUser = contentText(m.content);
74
- if (lastUser) break;
75
- }
76
- }
77
- }
78
- if (!lastUser) lastUser = "ping";
79
-
80
- const tokenCap = payload.max_completion_tokens !== undefined ? payload.max_completion_tokens : payload.max_tokens;
81
- const parameters = {};
82
- for (const k of ["temperature", "top_p", "presence_penalty", "frequency_penalty"]) {
83
- if (payload[k] !== undefined && payload[k] !== null) parameters[k] = payload[k];
84
- }
85
- if (tokenCap !== undefined && tokenCap !== null) {
86
- const n = Number(tokenCap);
87
- if (Number.isFinite(n) && n > 0) parameters.max_tokens = Math.floor(n);
88
- }
89
- if (parameters.max_tokens === undefined) parameters.max_tokens = 32000;
90
-
91
- const tools = !(payload.tool_choice === "none") && Array.isArray(payload.tools) ? payload.tools : [];
92
- // 客户端显式档位优先(change fix-thinking-effort-passthrough):关断→false、其余非空→true;无档位→false(旧行为)。
93
- const isReasoning = isReasoningEnabled(effortFromBody(payload), false);
94
-
95
- return JSON.stringify({
96
- request_id: requestID,
97
- request_set_id: requestID,
98
- chat_record_id: requestID,
99
- session_id: uuid(),
100
- stream: true,
101
- chat_task: "FREE_INPUT",
102
- chat_context: {
103
- text: lastUser,
104
- features: [],
105
- extra: {
106
- context: [],
107
- modelConfig: { key, is_reasoning: isReasoning },
108
- originalContent: lastUser,
109
- },
110
- chatPrompt: "",
111
- imageUrls: null,
112
- },
113
- is_reply: true,
114
- is_retry: false,
115
- source: 1,
116
- version: "3",
117
- agent_id: "agent_common",
118
- task_id: "common",
119
- session_type: "qoder_work",
120
- aliyun_user_type: "",
121
- model_config: {
122
- key,
123
- display_name: key,
124
- model: "",
125
- format: "openai",
126
- is_vl: true,
127
- is_reasoning: isReasoning,
128
- api_key: "",
129
- url: "",
130
- source: "system",
131
- max_input_tokens: CONTEXT_LENGTH,
132
- },
133
- system,
134
- messages,
135
- tools,
136
- parameters,
137
- business: {
138
- product: BUSINESS_PRODUCT,
139
- type: BUSINESS_TYPE,
140
- version: "1",
141
- feature_switches: {},
142
- },
143
- });
144
- }
1
+ // vendor 自 _shared/body.js(OpenAI body → agent_chat 请求体),逐字搬;去掉 desensitize 分支。
2
+ // 实测通过的字段形状(2026-09-29 真号 200):request_id==request_set_id==chat_record_id、
3
+ // stream 恒 true、system 抽到顶层且不出现在 messages、parameters.max_tokens 默认 32000。
4
+ import { uuid } from "./crypto.js";
5
+ import { DEFAULT_MODEL, BUSINESS_PRODUCT, BUSINESS_TYPE, CONTEXT_LENGTH } from "./constants.js";
6
+ import { effortFromBody, isReasoningEnabled } from "../../thinking-effort.js";
7
+
8
+ export function mapModel(name) {
9
+ const m = String(name || "").trim();
10
+ switch (m) {
11
+ case "":
12
+ case "auto":
13
+ case "lite":
14
+ case "flash":
15
+ return "flash";
16
+ case "advanced":
17
+ case "pro":
18
+ return "pro";
19
+ case "max":
20
+ case "qwen3.8-max":
21
+ case "qwen3.8-max-preview":
22
+ return "qwen3.8-max-preview";
23
+ default:
24
+ return m;
25
+ }
26
+ }
27
+
28
+ function contentText(value) {
29
+ if (typeof value === "string") return value;
30
+ if (Array.isArray(value)) {
31
+ let out = "";
32
+ for (const part of value) {
33
+ if (part && typeof part === "object" && typeof part.text === "string") out += part.text;
34
+ }
35
+ return out;
36
+ }
37
+ if (value === null || value === undefined) return "";
38
+ return JSON.stringify(value);
39
+ }
40
+
41
+ function splitMessages(payload) {
42
+ const raw = Array.isArray(payload.messages) ? payload.messages : [];
43
+ const sysParts = [];
44
+ const messages = [];
45
+ let lastUser = "";
46
+ for (const item of raw) {
47
+ if (!item || typeof item !== "object") continue;
48
+ if (item.role === "system") {
49
+ const text = contentText(item.content);
50
+ if (text) sysParts.push(text);
51
+ continue;
52
+ }
53
+ messages.push(item);
54
+ }
55
+ for (let i = messages.length - 1; i >= 0; i--) {
56
+ const m = messages[i];
57
+ if (m && m.role === "user") {
58
+ lastUser = contentText(m.content);
59
+ break;
60
+ }
61
+ }
62
+ return { system: sysParts.join("\n\n"), messages, lastUser };
63
+ }
64
+
65
+ export function buildBody(payload, modelKey) {
66
+ const key = modelKey || DEFAULT_MODEL;
67
+ const requestID = uuid();
68
+ const { system, messages, lastUser: first } = splitMessages(payload);
69
+ let lastUser = first;
70
+ if (!lastUser) {
71
+ for (const m of messages) {
72
+ if (m && m.role === "user") {
73
+ lastUser = contentText(m.content);
74
+ if (lastUser) break;
75
+ }
76
+ }
77
+ }
78
+ if (!lastUser) lastUser = "ping";
79
+
80
+ const tokenCap = payload.max_completion_tokens !== undefined ? payload.max_completion_tokens : payload.max_tokens;
81
+ const parameters = {};
82
+ for (const k of ["temperature", "top_p", "presence_penalty", "frequency_penalty"]) {
83
+ if (payload[k] !== undefined && payload[k] !== null) parameters[k] = payload[k];
84
+ }
85
+ if (tokenCap !== undefined && tokenCap !== null) {
86
+ const n = Number(tokenCap);
87
+ if (Number.isFinite(n) && n > 0) parameters.max_tokens = Math.floor(n);
88
+ }
89
+ if (parameters.max_tokens === undefined) parameters.max_tokens = 32000;
90
+
91
+ const tools = !(payload.tool_choice === "none") && Array.isArray(payload.tools) ? payload.tools : [];
92
+ // 客户端显式档位优先(change fix-thinking-effort-passthrough):关断→false、其余非空→true;无档位→false(旧行为)。
93
+ const isReasoning = isReasoningEnabled(effortFromBody(payload), false);
94
+
95
+ return JSON.stringify({
96
+ request_id: requestID,
97
+ request_set_id: requestID,
98
+ chat_record_id: requestID,
99
+ session_id: uuid(),
100
+ stream: true,
101
+ chat_task: "FREE_INPUT",
102
+ chat_context: {
103
+ text: lastUser,
104
+ features: [],
105
+ extra: {
106
+ context: [],
107
+ modelConfig: { key, is_reasoning: isReasoning },
108
+ originalContent: lastUser,
109
+ },
110
+ chatPrompt: "",
111
+ imageUrls: null,
112
+ },
113
+ is_reply: true,
114
+ is_retry: false,
115
+ source: 1,
116
+ version: "3",
117
+ agent_id: "agent_common",
118
+ task_id: "common",
119
+ session_type: "qoder_work",
120
+ aliyun_user_type: "",
121
+ model_config: {
122
+ key,
123
+ display_name: key,
124
+ model: "",
125
+ format: "openai",
126
+ is_vl: true,
127
+ is_reasoning: isReasoning,
128
+ api_key: "",
129
+ url: "",
130
+ source: "system",
131
+ max_input_tokens: CONTEXT_LENGTH,
132
+ },
133
+ system,
134
+ messages,
135
+ tools,
136
+ parameters,
137
+ business: {
138
+ product: BUSINESS_PRODUCT,
139
+ type: BUSINESS_TYPE,
140
+ version: "1",
141
+ feature_switches: {},
142
+ },
143
+ });
144
+ }
@@ -1,54 +1,54 @@
1
- // vendor 自 _shared/crypto.js 的 RSA 段(BigInt modPow + PKCS#1 v1.5 type-2),逐字搬。
2
- // 模数取 constants.js 的 RSA_MODULUS_HEX(与上游一致,勿改)。
3
- import { b64, utf8 } from "./crypto.js";
4
- import { RSA_MODULUS_HEX, RSA_EXPONENT } from "./constants.js";
5
-
6
- export const RSA_N = BigInt("0x" + RSA_MODULUS_HEX);
7
- export const RSA_E = BigInt(RSA_EXPONENT);
8
-
9
- function modPow(base, exp, mod) {
10
- let result = 1n;
11
- let b = base % mod;
12
- let e = exp;
13
- while (e > 0n) {
14
- if (e & 1n) result = (result * b) % mod;
15
- b = (b * b) % mod;
16
- e >>= 1n;
17
- }
18
- return result;
19
- }
20
-
21
- export function rsaPkcs1Encrypt(data, n = RSA_N, e = RSA_E, k = 128) {
22
- const psLen = k - data.length - 3;
23
- if (psLen < 8) throw new Error("rsa: message too long");
24
- const ps = new Uint8Array(psLen);
25
- for (;;) {
26
- crypto.getRandomValues(ps);
27
- let ok = true;
28
- for (let i = 0; i < psLen; i++) {
29
- if (ps[i] === 0) {
30
- ok = false;
31
- break;
32
- }
33
- }
34
- if (ok) break;
35
- }
36
- const em = new Uint8Array(k);
37
- em[0] = 0x00;
38
- em[1] = 0x02;
39
- em.set(ps, 2);
40
- em[2 + psLen] = 0x00;
41
- em.set(data, 3 + psLen);
42
- let m = 0n;
43
- for (let i = 0; i < k; i++) m = (m << 8n) | BigInt(em[i]);
44
- const c = modPow(m, e, n);
45
- const out = new Uint8Array(k);
46
- let v = c;
47
- for (let i = k - 1; i >= 0; i--) {
48
- out[i] = Number(v & 0xffn);
49
- v >>= 8n;
50
- }
51
- return b64(out);
52
- }
53
-
54
- export { b64, utf8 };
1
+ // vendor 自 _shared/crypto.js 的 RSA 段(BigInt modPow + PKCS#1 v1.5 type-2),逐字搬。
2
+ // 模数取 constants.js 的 RSA_MODULUS_HEX(与上游一致,勿改)。
3
+ import { b64, utf8 } from "./crypto.js";
4
+ import { RSA_MODULUS_HEX, RSA_EXPONENT } from "./constants.js";
5
+
6
+ export const RSA_N = BigInt("0x" + RSA_MODULUS_HEX);
7
+ export const RSA_E = BigInt(RSA_EXPONENT);
8
+
9
+ function modPow(base, exp, mod) {
10
+ let result = 1n;
11
+ let b = base % mod;
12
+ let e = exp;
13
+ while (e > 0n) {
14
+ if (e & 1n) result = (result * b) % mod;
15
+ b = (b * b) % mod;
16
+ e >>= 1n;
17
+ }
18
+ return result;
19
+ }
20
+
21
+ export function rsaPkcs1Encrypt(data, n = RSA_N, e = RSA_E, k = 128) {
22
+ const psLen = k - data.length - 3;
23
+ if (psLen < 8) throw new Error("rsa: message too long");
24
+ const ps = new Uint8Array(psLen);
25
+ for (;;) {
26
+ crypto.getRandomValues(ps);
27
+ let ok = true;
28
+ for (let i = 0; i < psLen; i++) {
29
+ if (ps[i] === 0) {
30
+ ok = false;
31
+ break;
32
+ }
33
+ }
34
+ if (ok) break;
35
+ }
36
+ const em = new Uint8Array(k);
37
+ em[0] = 0x00;
38
+ em[1] = 0x02;
39
+ em.set(ps, 2);
40
+ em[2 + psLen] = 0x00;
41
+ em.set(data, 3 + psLen);
42
+ let m = 0n;
43
+ for (let i = 0; i < k; i++) m = (m << 8n) | BigInt(em[i]);
44
+ const c = modPow(m, e, n);
45
+ const out = new Uint8Array(k);
46
+ let v = c;
47
+ for (let i = k - 1; i >= 0; i--) {
48
+ out[i] = Number(v & 0xffn);
49
+ v >>= 8n;
50
+ }
51
+ return b64(out);
52
+ }
53
+
54
+ export { b64, utf8 };