mslxdff 0.1.233 → 0.1.235

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 (106) hide show
  1. package/bin/mslxdff.js +3 -3
  2. package/docs/cli_help_mini.md +149 -0
  3. package/package.json +1 -1
  4. package/src/auto.js +264 -264
  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/chat-pipeline/serial-trial.js +16 -3
  22. package/src/chat-pipeline/upstream-5xx-retry.js +72 -0
  23. package/src/cli/commands/group.js +266 -266
  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 +139 -139
  28. package/src/cli/commands/provider/models.js +149 -149
  29. package/src/cli/commands/provider/qwenwork-login.js +119 -119
  30. package/src/cli/commands/provider/raccoon-quota.js +156 -156
  31. package/src/cli/commands/sync.js +310 -310
  32. package/src/cli/status.js +279 -279
  33. package/src/daemon.js +246 -246
  34. package/src/model-capabilities/enrich.js +86 -86
  35. package/src/model-capabilities/index.js +183 -183
  36. package/src/model-capabilities/parse.js +70 -70
  37. package/src/models.js +293 -293
  38. package/src/peers.js +345 -345
  39. package/src/providers/AGENTS.md +49 -0
  40. package/src/providers/agentrouter.js +238 -238
  41. package/src/providers/base.js +164 -164
  42. package/src/providers/cline/auth.js +228 -228
  43. package/src/providers/cline/chat.js +307 -307
  44. package/src/providers/cline.js +2 -2
  45. package/src/providers/codearts/chat.js +207 -207
  46. package/src/providers/dispatcher.js +147 -147
  47. package/src/providers/globalqwenwork/cosy.js +123 -123
  48. package/src/providers/globalqwenwork/crypto.js +218 -218
  49. package/src/providers/globalqwenwork/http.js +20 -20
  50. package/src/providers/globalqwenwork/rsa.js +54 -54
  51. package/src/providers/globalqwenwork/sse.js +268 -268
  52. package/src/providers/globalqwenwork/stream.js +130 -130
  53. package/src/providers/globalqwenwork/upstream.js +122 -122
  54. package/src/providers/keyring.js +60 -60
  55. package/src/providers/qoder/chat.js +292 -292
  56. package/src/providers/qoder/index.js +311 -311
  57. package/src/providers/qoder/sse.js +233 -233
  58. package/src/providers/qwenwork/account-store.js +133 -133
  59. package/src/providers/qwenwork/constants.js +67 -67
  60. package/src/providers/qwenwork/cosy.js +120 -120
  61. package/src/providers/qwenwork/crypto.js +218 -218
  62. package/src/providers/qwenwork/http.js +20 -20
  63. package/src/providers/qwenwork/index.js +337 -337
  64. package/src/providers/qwenwork/payload.js +144 -144
  65. package/src/providers/qwenwork/rsa.js +54 -54
  66. package/src/providers/qwenwork/sse.js +268 -268
  67. package/src/providers/qwenwork/stream.js +130 -130
  68. package/src/providers/qwenwork/upstream.js +120 -120
  69. package/src/providers/qwenwork.js +1 -1
  70. package/src/providers/raccoon/const.js +219 -219
  71. package/src/providers/raccoon/credits.js +285 -285
  72. package/src/providers/raccoon/index.js +36 -4
  73. package/src/providers/raccoon/sticky.js +46 -0
  74. package/src/providers/registry.js +89 -89
  75. package/src/providers/workbuddy/chat.js +298 -298
  76. package/src/providers/workbuddy/reshape.js +152 -152
  77. package/src/providers/workbuddy.js +2 -2
  78. package/src/reasoning.js +32 -32
  79. package/src/routes/AGENTS.md +37 -0
  80. package/src/routes/chat/broadband-handler.js +80 -80
  81. package/src/routes/chat/gateway.js +46 -46
  82. package/src/routes/chat/peer-handler.js +14 -4
  83. package/src/routes/chat/relay-pipeline.js +282 -282
  84. package/src/routes/chat/via-route-handler.js +156 -156
  85. package/src/routes/hedge.js +260 -260
  86. package/src/routes/models-route.js +167 -167
  87. package/src/routes/peer-serial.js +5 -2
  88. package/src/routes/peers.js +373 -373
  89. package/src/routes/stream.js +364 -364
  90. package/src/runtime/bootstrap.js +75 -75
  91. package/src/runtime/keep-warm.js +135 -135
  92. package/src/runtime/provider-gate.js +75 -75
  93. package/src/runtime/providers-setup.js +187 -187
  94. package/src/runtime/raccoon-checkin.js +175 -175
  95. package/src/server.js +85 -85
  96. package/src/state/schemas/allowlist.js +92 -92
  97. package/src/sync-opencode.js +280 -280
  98. package/src/transport/index.js +244 -244
  99. package/src/transport/pool.js +56 -56
  100. package/src/transport/retry.js +24 -24
  101. package/src/transport/sse.js +93 -93
  102. package/src/upstream-probe/display.js +52 -52
  103. package/src/upstream-probe/probe.js +49 -49
  104. package/src/upstream-probe/rotate.js +110 -110
  105. package/src/upstream-probe/start.js +45 -45
  106. package/src/upstream.js +355 -355
@@ -1,47 +1,47 @@
1
- import { clientIp, json, readBody, parseHops } from "../helpers.js";
2
- import { runHook } from "../../plugins.js";
3
- import { createChatPipeline } from "../../chat-pipeline/index.js";
4
-
5
- /**
6
- * ChatGateway 薄适配层:仅负责 HTTP I/O(readBody + request:received hook)→ 委托 ChatPipeline.execute
7
- * Policy/Order/AutoRace/hedge/peer/broadband 全部在 chat-pipeline 深模块内。
8
- */
9
- export function createChatGateway(deps = {}) {
10
- const pipeline = createChatPipeline(deps);
11
-
12
- async function handle({ req, res }) {
13
- let body;
14
- try {
15
- body = await readBody(req);
16
- } catch {
17
- return json(res, 400, { error: "Invalid JSON body" });
18
- }
19
- if (deps.plugins?.length) {
20
- const rc = await runHook(deps.plugins, "request:received", {
21
- ip: clientIp(req),
22
- hops: parseHops(req.headers["x-mslxdff-hops"]),
23
- headers: { "content-type": req.headers["content-type"] },
24
- body,
25
- });
26
- for (const e of rc.errors) deps.logs?.appendEvent?.({ ts: Date.now(), type: "plugin-hook-error", hook: "request:received", plugin: e.plugin, error: e.error });
27
- const respond = rc.value?.respond;
28
- if (respond && typeof respond === "object") return json(res, respond.status || 200, respond.body ?? {});
29
- }
30
- req.body = body;
31
- try {
32
- await pipeline.execute({ req, res });
33
- } catch (err) {
34
- const msg = err?.message || String(err);
35
- if (!res.headersSent) return json(res, 502, { error: msg });
36
- try { res.end(); } catch {}
37
- }
38
- }
39
-
40
- return { handle };
41
- }
42
-
43
- // 薄适配:保持原 chatHandler 签名兼容
44
- export async function chatHandler(ctx) {
45
- const gw = createChatGateway(ctx);
46
- return gw.handle(ctx);
1
+ import { clientIp, json, readBody, parseHops } from "../helpers.js";
2
+ import { runHook } from "../../plugins.js";
3
+ import { createChatPipeline } from "../../chat-pipeline/index.js";
4
+
5
+ /**
6
+ * ChatGateway 薄适配层:仅负责 HTTP I/O(readBody + request:received hook)→ 委托 ChatPipeline.execute
7
+ * Policy/Order/AutoRace/hedge/peer/broadband 全部在 chat-pipeline 深模块内。
8
+ */
9
+ export function createChatGateway(deps = {}) {
10
+ const pipeline = createChatPipeline(deps);
11
+
12
+ async function handle({ req, res }) {
13
+ let body;
14
+ try {
15
+ body = await readBody(req);
16
+ } catch {
17
+ return json(res, 400, { error: "Invalid JSON body" });
18
+ }
19
+ if (deps.plugins?.length) {
20
+ const rc = await runHook(deps.plugins, "request:received", {
21
+ ip: clientIp(req),
22
+ hops: parseHops(req.headers["x-mslxdff-hops"]),
23
+ headers: { "content-type": req.headers["content-type"] },
24
+ body,
25
+ });
26
+ for (const e of rc.errors) deps.logs?.appendEvent?.({ ts: Date.now(), type: "plugin-hook-error", hook: "request:received", plugin: e.plugin, error: e.error });
27
+ const respond = rc.value?.respond;
28
+ if (respond && typeof respond === "object") return json(res, respond.status || 200, respond.body ?? {});
29
+ }
30
+ req.body = body;
31
+ try {
32
+ await pipeline.execute({ req, res });
33
+ } catch (err) {
34
+ const msg = err?.message || String(err);
35
+ if (!res.headersSent) return json(res, 502, { error: msg });
36
+ try { res.end(); } catch {}
37
+ }
38
+ }
39
+
40
+ return { handle };
41
+ }
42
+
43
+ // 薄适配:保持原 chatHandler 签名兼容
44
+ export async function chatHandler(ctx) {
45
+ const gw = createChatGateway(ctx);
46
+ return gw.handle(ctx);
47
47
  }
@@ -30,10 +30,20 @@ export async function handlePeerRelay({
30
30
  const peerErrors = [];
31
31
  // 三批共享同一 peer 阶段总预算(同 hedge:旧行为是每批各吃满一次等头超时,串行叠加到 90s+)
32
32
  const pctx = peerStageCtx({ ...handlerCtx, peerErrors });
33
- const win =
34
- (await race(peers.ordered(), pctx)) ||
35
- (await race(peers.orderedByLastError(), pctx)) ||
36
- (await race(peers.coolingByLastError(), pctx));
33
+ // singlePeer:指定模型 5xx 重试耗尽后只换 1 个节点,该节点仍失败就交回上层收场。
34
+ // 选人仍按「组长第一 → 延迟升序」,只是取链头一个;三批候选不叠加,也不进 IPv6 阶段。
35
+ const singlePeer = handlerCtx?.singlePeer === true;
36
+ let win = null;
37
+ if (singlePeer) {
38
+ pctx.peerMaxPeers = 1;
39
+ const pick = peers.ordered()[0] || peers.orderedByLastError?.()?.[0] || peers.coolingByLastError?.()?.[0] || null;
40
+ win = pick ? await race([pick], pctx) : null;
41
+ } else {
42
+ win =
43
+ (await race(peers.ordered(), pctx)) ||
44
+ (await race(peers.orderedByLastError(), pctx)) ||
45
+ (await race(peers.coolingByLastError(), pctx));
46
+ }
37
47
  if (!win) {
38
48
  evt("peer-race-lose", { reqId: handlerCtx.reqId, model });
39
49
  // 组员全失败:把每个组员的真实返回汇总给调用者(否则只剩一个无信息的 429/502)