mslxdff 0.1.231 → 0.1.233

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 +264 -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/index.js +155 -145
  19. package/src/chat-pipeline/policy.js +84 -84
  20. package/src/cli/commands/group.js +266 -266
  21. package/src/cli/commands/model/picks.js +50 -50
  22. package/src/cli/commands/provider/bench-via.js +247 -247
  23. package/src/cli/commands/provider/bench.js +141 -141
  24. package/src/cli/commands/provider/index.js +139 -139
  25. package/src/cli/commands/provider/models.js +149 -149
  26. package/src/cli/commands/provider/qwenwork-login.js +119 -119
  27. package/src/cli/commands/provider/raccoon-quota.js +156 -156
  28. package/src/cli/commands/sync.js +310 -310
  29. package/src/cli/status.js +279 -279
  30. package/src/daemon.js +246 -246
  31. package/src/model-capabilities/enrich.js +86 -86
  32. package/src/model-capabilities/index.js +183 -183
  33. package/src/model-capabilities/parse.js +70 -70
  34. package/src/model-trace.js +10 -2
  35. package/src/models.js +292 -225
  36. package/src/peers.js +345 -345
  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/account-store.js +18 -0
  53. package/src/providers/qoder/chat.js +292 -203
  54. package/src/providers/qoder/checkin.js +25 -12
  55. package/src/providers/qoder/index.js +311 -249
  56. package/src/providers/qoder/models.js +64 -2
  57. package/src/providers/qoder/oauth.js +42 -1
  58. package/src/providers/qoder/payload.js +116 -80
  59. package/src/providers/qoder/request.js +7 -2
  60. package/src/providers/qoder/session.js +26 -10
  61. package/src/providers/qoder/sse.js +233 -145
  62. package/src/providers/qoder/sticky.js +5 -2
  63. package/src/providers/qoder/wire-messages.js +242 -0
  64. package/src/providers/qwenwork/account-store.js +133 -133
  65. package/src/providers/qwenwork/constants.js +67 -67
  66. package/src/providers/qwenwork/cosy.js +120 -120
  67. package/src/providers/qwenwork/crypto.js +218 -218
  68. package/src/providers/qwenwork/http.js +20 -20
  69. package/src/providers/qwenwork/index.js +337 -337
  70. package/src/providers/qwenwork/payload.js +144 -144
  71. package/src/providers/qwenwork/rsa.js +54 -54
  72. package/src/providers/qwenwork/sse.js +268 -268
  73. package/src/providers/qwenwork/stream.js +130 -130
  74. package/src/providers/qwenwork/upstream.js +120 -120
  75. package/src/providers/qwenwork.js +1 -1
  76. package/src/providers/raccoon/chat.js +1 -1
  77. package/src/providers/raccoon/const.js +219 -202
  78. package/src/providers/raccoon/credits.js +285 -285
  79. package/src/providers/raccoon/index.js +15 -2
  80. package/src/providers/raccoon/models.js +68 -17
  81. package/src/providers/registry.js +89 -89
  82. package/src/providers/workbuddy/auth.js +16 -0
  83. package/src/providers/workbuddy/chat.js +298 -264
  84. package/src/providers/workbuddy/client-headers.js +148 -0
  85. package/src/providers/workbuddy/desktop-info.js +17 -1
  86. package/src/providers/workbuddy/models.js +8 -20
  87. package/src/providers/workbuddy/reshape.js +152 -152
  88. package/src/providers/workbuddy.js +2 -2
  89. package/src/reasoning.js +32 -32
  90. package/src/routes/chat/broadband-handler.js +80 -80
  91. package/src/routes/chat/gateway.js +46 -46
  92. package/src/routes/chat/relay-pipeline.js +282 -282
  93. package/src/routes/chat/via-route-handler.js +156 -156
  94. package/src/routes/hedge.js +260 -260
  95. package/src/routes/models-route.js +167 -167
  96. package/src/routes/peers.js +373 -373
  97. package/src/routes/stream.js +364 -347
  98. package/src/runtime/bootstrap.js +75 -75
  99. package/src/runtime/keep-warm.js +135 -135
  100. package/src/runtime/provider-gate.js +75 -75
  101. package/src/runtime/providers-setup.js +187 -187
  102. package/src/runtime/raccoon-checkin.js +175 -175
  103. package/src/server.js +85 -85
  104. package/src/state/schemas/allowlist.js +92 -92
  105. package/src/sync-opencode.js +280 -280
  106. package/src/transport/index.js +244 -244
  107. package/src/transport/pool.js +56 -56
  108. package/src/transport/retry.js +24 -24
  109. package/src/transport/sse.js +93 -93
  110. package/src/upstream-probe/display.js +52 -52
  111. package/src/upstream-probe/probe.js +49 -49
  112. package/src/upstream-probe/rotate.js +110 -110
  113. package/src/upstream-probe/start.js +45 -45
  114. package/src/upstream.js +355 -355
  115. package/docs/cli_help_mini.md +0 -148
  116. package/src/providers/AGENTS.md +0 -49
  117. package/src/routes/AGENTS.md +0 -37
@@ -1,80 +1,80 @@
1
- import { relay, SLOW_TOTAL_MS, STREAM_TIMEOUT_MS, STALL_TIMEOUT_MS, SCORE_STALL_MS } from "../stream.js";
2
- import { buildFallbackInfo } from "../fallback.js";
3
- import { createRelayPipeline } from "./relay-pipeline.js";
4
- import { tryBroadbandRelay } from "../relay-queue.js";
5
- import { overForwardLimit, contextGuardMessage } from "../../chat-pipeline/context-guard.js";
6
-
7
- /** 薄适配:broadband 两种形态合一经由 pipeline */
8
- export async function handleBroadbandRelay({
9
- model,
10
- body,
11
- hops,
12
- lastErr,
13
- requested,
14
- useAuto,
15
- lockModel,
16
- auto,
17
- groups,
18
- token,
19
- bus,
20
- logs,
21
- handlerCtx,
22
- evt,
23
- mark,
24
- perf0,
25
- attemptStartMs,
26
- stages,
27
- res,
28
- startedAt,
29
- plugins,
30
- deps = {},
31
- }) {
32
- const { createPipeline = createRelayPipeline, tryBroadbandRelay: tryRelay = tryBroadbandRelay } = deps;
33
- // 转发前上下文预检:宽带成员是完全不同的另一台机器,上下文撑爆的代价(白烧它的额度)最实在。
34
- const guard = overForwardLimit(body);
35
- if (guard) {
36
- const msg = contextGuardMessage(guard);
37
- evt("context-guard", { reqId: handlerCtx.reqId, model, via: "broadband", estimated: guard.estimated, limit: guard.limit, over: guard.over });
38
- return { handled: false, lastErr: { model, upstream: null, status: 400, message: msg, contextGuard: true } };
39
- }
40
- const bb = await tryRelay({ groups, token, model, body, hops, bus, logs, reqId: handlerCtx.reqId, evt, res, mark, perf0, stages });
41
- if (!bb) {
42
- evt("relay-miss", { reqId: handlerCtx.reqId, model });
43
- return { handled: false };
44
- }
45
- const pipeline = createPipeline({
46
- relay,
47
- buildFallbackInfo,
48
- auto,
49
- plugins,
50
- evt,
51
- mark,
52
- logCall: () => {},
53
- logError: () => {},
54
- constants: { STREAM_TIMEOUT_MS, SLOW_TOTAL_MS, STALL_TIMEOUT_MS, SCORE_STALL_MS },
55
- startedAt,
56
- stages,
57
- });
58
- const isResponse = bb.result && typeof bb.result.status === "number" && typeof bb.result.headers?.get === "function";
59
- if (isResponse) {
60
- const r = await pipeline.execute({ res, upRes: bb.result, body, requested, actual: model, lastErr, via: "broadband", lockModel, useAuto, handlerCtx, mark, perf0, attemptStartMs, stages, startedAt });
61
- if (!r.handled) return { handled: false, upRes: null, lastErr: r.lastErr };
62
- return { handled: true };
63
- }
64
- if (bb.result && typeof bb.result.status === "number") {
65
- const b = bb.result.body || "";
66
- const str = typeof b === "string" ? b : JSON.stringify(b);
67
- const isSSE = bb.result.headers?.["Content-Type"]?.includes("text/event-stream");
68
- const fakeRes = {
69
- status: bb.result.status,
70
- headers: { get: (k) => bb.result.headers?.[k] || bb.result.headers?.[k.toLowerCase()] || null },
71
- text: async () => str,
72
- body: isSSE ? (async function* () { yield Buffer.from(str); })() : null,
73
- };
74
- const r = await pipeline.execute({ res, upRes: fakeRes, body, requested, actual: model, lastErr, via: "broadband-local", lockModel, useAuto, handlerCtx, mark, perf0, attemptStartMs, stages, startedAt });
75
- if (!r.handled) return { handled: false, upRes: null, lastErr: r.lastErr };
76
- return { handled: true };
77
- }
78
- evt("relay-miss", { reqId: handlerCtx.reqId, model });
79
- return { handled: false };
80
- }
1
+ import { relay, SLOW_TOTAL_MS, STREAM_TIMEOUT_MS, STALL_TIMEOUT_MS, SCORE_STALL_MS } from "../stream.js";
2
+ import { buildFallbackInfo } from "../fallback.js";
3
+ import { createRelayPipeline } from "./relay-pipeline.js";
4
+ import { tryBroadbandRelay } from "../relay-queue.js";
5
+ import { overForwardLimit, contextGuardMessage } from "../../chat-pipeline/context-guard.js";
6
+
7
+ /** 薄适配:broadband 两种形态合一经由 pipeline */
8
+ export async function handleBroadbandRelay({
9
+ model,
10
+ body,
11
+ hops,
12
+ lastErr,
13
+ requested,
14
+ useAuto,
15
+ lockModel,
16
+ auto,
17
+ groups,
18
+ token,
19
+ bus,
20
+ logs,
21
+ handlerCtx,
22
+ evt,
23
+ mark,
24
+ perf0,
25
+ attemptStartMs,
26
+ stages,
27
+ res,
28
+ startedAt,
29
+ plugins,
30
+ deps = {},
31
+ }) {
32
+ const { createPipeline = createRelayPipeline, tryBroadbandRelay: tryRelay = tryBroadbandRelay } = deps;
33
+ // 转发前上下文预检:宽带成员是完全不同的另一台机器,上下文撑爆的代价(白烧它的额度)最实在。
34
+ const guard = overForwardLimit(body);
35
+ if (guard) {
36
+ const msg = contextGuardMessage(guard);
37
+ evt("context-guard", { reqId: handlerCtx.reqId, model, via: "broadband", estimated: guard.estimated, limit: guard.limit, over: guard.over });
38
+ return { handled: false, lastErr: { model, upstream: null, status: 400, message: msg, contextGuard: true } };
39
+ }
40
+ const bb = await tryRelay({ groups, token, model, body, hops, bus, logs, reqId: handlerCtx.reqId, evt, res, mark, perf0, stages });
41
+ if (!bb) {
42
+ evt("relay-miss", { reqId: handlerCtx.reqId, model });
43
+ return { handled: false };
44
+ }
45
+ const pipeline = createPipeline({
46
+ relay,
47
+ buildFallbackInfo,
48
+ auto,
49
+ plugins,
50
+ evt,
51
+ mark,
52
+ logCall: () => {},
53
+ logError: () => {},
54
+ constants: { STREAM_TIMEOUT_MS, SLOW_TOTAL_MS, STALL_TIMEOUT_MS, SCORE_STALL_MS },
55
+ startedAt,
56
+ stages,
57
+ });
58
+ const isResponse = bb.result && typeof bb.result.status === "number" && typeof bb.result.headers?.get === "function";
59
+ if (isResponse) {
60
+ const r = await pipeline.execute({ res, upRes: bb.result, body, requested, actual: model, lastErr, via: "broadband", lockModel, useAuto, handlerCtx, mark, perf0, attemptStartMs, stages, startedAt });
61
+ if (!r.handled) return { handled: false, upRes: null, lastErr: r.lastErr };
62
+ return { handled: true };
63
+ }
64
+ if (bb.result && typeof bb.result.status === "number") {
65
+ const b = bb.result.body || "";
66
+ const str = typeof b === "string" ? b : JSON.stringify(b);
67
+ const isSSE = bb.result.headers?.["Content-Type"]?.includes("text/event-stream");
68
+ const fakeRes = {
69
+ status: bb.result.status,
70
+ headers: { get: (k) => bb.result.headers?.[k] || bb.result.headers?.[k.toLowerCase()] || null },
71
+ text: async () => str,
72
+ body: isSSE ? (async function* () { yield Buffer.from(str); })() : null,
73
+ };
74
+ const r = await pipeline.execute({ res, upRes: fakeRes, body, requested, actual: model, lastErr, via: "broadband-local", lockModel, useAuto, handlerCtx, mark, perf0, attemptStartMs, stages, startedAt });
75
+ if (!r.handled) return { handled: false, upRes: null, lastErr: r.lastErr };
76
+ return { handled: true };
77
+ }
78
+ evt("relay-miss", { reqId: handlerCtx.reqId, model });
79
+ return { handled: false };
80
+ }
@@ -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
  }