mslxdff 0.1.236 → 0.1.237

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 (102) hide show
  1. package/bin/mslxdff.js +3 -3
  2. package/package.json +1 -1
  3. package/src/auto.js +264 -264
  4. package/src/autostart.js +62 -15
  5. package/src/bench/cline-bench.js +42 -42
  6. package/src/bench/probe.js +70 -70
  7. package/src/bench/report.js +162 -162
  8. package/src/bench/runner.js +77 -77
  9. package/src/bench/via-probe.js +124 -124
  10. package/src/bench/via-routes.js +87 -87
  11. package/src/bench/workbuddy-bench.js +54 -54
  12. package/src/chat/engine.js +160 -160
  13. package/src/chat/gateway.js +163 -163
  14. package/src/chat/orchestrator.js +234 -234
  15. package/src/chat/prompt.js +70 -70
  16. package/src/chat/repl.js +88 -88
  17. package/src/chat/terminal.js +135 -135
  18. package/src/chat/tools.js +306 -306
  19. package/src/chat-pipeline/index.js +155 -155
  20. package/src/chat-pipeline/policy.js +84 -84
  21. package/src/cli/commands/group.js +266 -266
  22. package/src/cli/commands/model/picks.js +50 -50
  23. package/src/cli/commands/provider/bench-via.js +247 -247
  24. package/src/cli/commands/provider/bench.js +141 -141
  25. package/src/cli/commands/provider/index.js +139 -139
  26. package/src/cli/commands/provider/models.js +149 -149
  27. package/src/cli/commands/provider/qwenwork-login.js +119 -119
  28. package/src/cli/commands/provider/raccoon-quota.js +156 -156
  29. package/src/cli/commands/sync.js +310 -310
  30. package/src/cli/status.js +282 -282
  31. package/src/daemon.js +246 -246
  32. package/src/model-capabilities/enrich.js +86 -86
  33. package/src/model-capabilities/index.js +183 -183
  34. package/src/model-capabilities/parse.js +70 -70
  35. package/src/models.js +293 -293
  36. package/src/peers.js +389 -389
  37. package/src/providers/agentrouter.js +238 -238
  38. package/src/providers/base.js +164 -164
  39. package/src/providers/cline/auth.js +228 -228
  40. package/src/providers/cline/chat.js +307 -307
  41. package/src/providers/cline.js +2 -2
  42. package/src/providers/codearts/chat.js +207 -207
  43. package/src/providers/dispatcher.js +147 -147
  44. package/src/providers/globalqwenwork/cosy.js +123 -123
  45. package/src/providers/globalqwenwork/crypto.js +218 -218
  46. package/src/providers/globalqwenwork/http.js +20 -20
  47. package/src/providers/globalqwenwork/rsa.js +54 -54
  48. package/src/providers/globalqwenwork/sse.js +268 -268
  49. package/src/providers/globalqwenwork/stream.js +130 -130
  50. package/src/providers/globalqwenwork/upstream.js +122 -122
  51. package/src/providers/keyring.js +60 -60
  52. package/src/providers/qoder/chat.js +292 -292
  53. package/src/providers/qoder/index.js +311 -311
  54. package/src/providers/qoder/sse.js +233 -233
  55. package/src/providers/qwenwork/account-store.js +133 -133
  56. package/src/providers/qwenwork/constants.js +67 -67
  57. package/src/providers/qwenwork/cosy.js +120 -120
  58. package/src/providers/qwenwork/crypto.js +218 -218
  59. package/src/providers/qwenwork/http.js +20 -20
  60. package/src/providers/qwenwork/index.js +337 -337
  61. package/src/providers/qwenwork/payload.js +144 -144
  62. package/src/providers/qwenwork/rsa.js +54 -54
  63. package/src/providers/qwenwork/sse.js +268 -268
  64. package/src/providers/qwenwork/stream.js +130 -130
  65. package/src/providers/qwenwork/upstream.js +120 -120
  66. package/src/providers/qwenwork.js +1 -1
  67. package/src/providers/raccoon/const.js +219 -219
  68. package/src/providers/raccoon/credits.js +285 -285
  69. package/src/providers/registry.js +89 -89
  70. package/src/providers/workbuddy/chat.js +298 -298
  71. package/src/providers/workbuddy/reshape.js +152 -152
  72. package/src/providers/workbuddy.js +2 -2
  73. package/src/reasoning.js +32 -32
  74. package/src/routes/chat/broadband-handler.js +80 -80
  75. package/src/routes/chat/gateway.js +46 -46
  76. package/src/routes/chat/relay-pipeline.js +282 -282
  77. package/src/routes/chat/via-route-handler.js +158 -158
  78. package/src/routes/hedge.js +260 -260
  79. package/src/routes/models-route.js +167 -167
  80. package/src/routes/peers.js +373 -373
  81. package/src/routes/stream.js +364 -364
  82. package/src/runtime/bootstrap.js +75 -75
  83. package/src/runtime/keep-warm.js +135 -135
  84. package/src/runtime/provider-gate.js +75 -75
  85. package/src/runtime/providers-setup.js +187 -187
  86. package/src/runtime/raccoon-checkin.js +175 -175
  87. package/src/runtime/server-lifecycle.js +34 -10
  88. package/src/server.js +85 -85
  89. package/src/state/schemas/allowlist.js +92 -92
  90. package/src/sync-opencode.js +280 -280
  91. package/src/transport/index.js +244 -244
  92. package/src/transport/pool.js +56 -56
  93. package/src/transport/retry.js +24 -24
  94. package/src/transport/sse.js +93 -93
  95. package/src/upstream-probe/display.js +52 -52
  96. package/src/upstream-probe/probe.js +49 -49
  97. package/src/upstream-probe/rotate.js +110 -110
  98. package/src/upstream-probe/start.js +45 -45
  99. package/src/upstream.js +355 -355
  100. package/docs/cli_help_mini.md +0 -149
  101. package/src/providers/AGENTS.md +0 -49
  102. 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 };