mslxdff 0.1.155 → 0.1.158

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 (151) hide show
  1. package/bin/mslxdff.js +4 -4
  2. package/docs/ARCHITECTURE.md +426 -0
  3. package/docs/FEATURE_TREE.md +164 -0
  4. package/docs/MOBILE.md +82 -0
  5. package/docs/adr/0001-reasoning-content-injection.md +14 -0
  6. package/docs/adr/0002-models-free-filter.md +12 -0
  7. package/docs/adr/0003-zero-state-no-auth.md +10 -0
  8. package/docs/adr/0004-bearer-token.md +18 -0
  9. package/docs/adr/0005-peer-mesh.md +53 -0
  10. package/docs/adr/0006-broadband-member.md +103 -0
  11. package/docs/adr/0007-multi-provider-prefix.md +25 -0
  12. package/docs/adr/0008-share-keys-to-peers.md +52 -0
  13. package/docs/adr/0009-chat-repl.md +37 -0
  14. package/docs/adr/0010-allowlist.md +36 -0
  15. package/docs/adr/0011-broadband-stream.md +30 -0
  16. package/docs/adr/0012-responses-endpoint-codex-sync.md +48 -0
  17. package/docs/adr/0013-node16-compat.md +41 -0
  18. package/docs/adr/0014-deepseek-provider.md +52 -0
  19. package/docs/adr/0015-upstream-probe-routing.md +50 -0
  20. package/docs/adr/0016-model-capabilities.md +27 -0
  21. package/docs/adr/0017-ai-sdk-upstream-engine.md +59 -0
  22. package/docs/adr/0018-zen-client-identity.md +52 -0
  23. package/docs/adr/0019-share-keys-always-lend.md +59 -0
  24. package/docs/adr/0020-zen-free-lane-agent-shape.md +52 -0
  25. package/docs/adr/0021-usage-report-jsonl.md +47 -0
  26. package/docs/adr/0022-models-capability-merge.md +61 -0
  27. package/docs/adr/0023-key-provider-default-direct.md +58 -0
  28. package/docs/adr/0024-node18-baseline.md +63 -0
  29. package/docs/adr/0025-workbuddy-authdir-follows-state.md +71 -0
  30. package/docs/adr/0026-cline-provider-id-unify.md +67 -0
  31. package/docs/adr/0027-codearts-provider.md +48 -0
  32. package/docs/adr/0028-traework-provider.md +34 -0
  33. package/docs/adr/0029-qoder-native-provider.md +60 -0
  34. package/docs/adr/0030-models-list-scoped-by-picks.md +53 -0
  35. package/docs/adr/0031-qoder-true-streaming.md +50 -0
  36. package/docs/adr/0032-generic-responses-channel.md +72 -0
  37. package/docs/adr/0033-cline-allowlist-auto-sync.md +75 -0
  38. package/docs/adr/0034-request-level-human-readable-observability.md +60 -0
  39. package/docs/adr/0035-sdk-channel-headers-timeout.md +49 -0
  40. package/docs/adr/0036-qoder-per-request-sticky-account.md +82 -0
  41. package/docs/adr/0037-qwenwork-independent-provider.md +82 -0
  42. package/docs/adr/0038-zcode-provider.md +140 -0
  43. package/docs/agents/domain.md +51 -0
  44. package/docs/agents/issue-tracker.md +30 -0
  45. package/docs/agents/triage-labels.md +15 -0
  46. package/docs/cli_help.md +1391 -0
  47. package/docs/cli_help_mini.md +133 -0
  48. package/docs/plans/bench-via-latency-2026-09-01.md +215 -0
  49. package/docs/plugins.md +187 -0
  50. package/package.json +1 -1
  51. package/src/auto.js +254 -254
  52. package/src/bench/cline-bench.js +42 -42
  53. package/src/bench/probe.js +70 -70
  54. package/src/bench/report.js +162 -162
  55. package/src/bench/runner.js +77 -77
  56. package/src/bench/via-probe.js +124 -124
  57. package/src/bench/via-routes.js +87 -87
  58. package/src/bench/workbuddy-bench.js +54 -54
  59. package/src/chat/engine.js +160 -160
  60. package/src/chat/gateway.js +163 -163
  61. package/src/chat/orchestrator.js +234 -234
  62. package/src/chat/prompt.js +70 -70
  63. package/src/chat/repl.js +88 -88
  64. package/src/chat/terminal.js +135 -135
  65. package/src/chat/tools.js +306 -306
  66. package/src/chat-pipeline/index.js +123 -123
  67. package/src/chat-pipeline/policy.js +76 -76
  68. package/src/chat-pipeline/serial-trial.js +210 -210
  69. package/src/cli/commands/group.js +249 -249
  70. package/src/cli/commands/model/list-providers.js +4 -3
  71. package/src/cli/commands/model/list-render.js +7 -9
  72. package/src/cli/commands/model/list-sort.js +52 -0
  73. package/src/cli/commands/model/list-tty.js +76 -0
  74. package/src/cli/commands/model/list.js +5 -62
  75. package/src/cli/commands/model/picks.js +50 -50
  76. package/src/cli/commands/provider/bench-via.js +247 -247
  77. package/src/cli/commands/provider/bench.js +141 -141
  78. package/src/cli/commands/provider/index.js +124 -116
  79. package/src/cli/commands/provider/models.js +139 -128
  80. package/src/cli/commands/provider/qwenwork-login.js +119 -0
  81. package/src/cli/commands/provider/zcode-login.js +77 -0
  82. package/src/cli/commands/provider/zcode-quota.js +55 -0
  83. package/src/cli/commands/sync.js +232 -232
  84. package/src/cli/provider-row.js +2 -2
  85. package/src/cli/status.js +279 -279
  86. package/src/daemon.js +96 -96
  87. package/src/model-capabilities/enrich.js +86 -86
  88. package/src/model-capabilities/index.js +183 -183
  89. package/src/model-capabilities/parse.js +70 -70
  90. package/src/model-trace.js +1 -0
  91. package/src/models.js +225 -225
  92. package/src/providers/classify.js +1 -1
  93. package/src/providers/cline/auth.js +228 -228
  94. package/src/providers/cline/chat.js +307 -307
  95. package/src/providers/cline.js +2 -2
  96. package/src/providers/keyring.js +60 -56
  97. package/src/providers/qoder/chat.js +183 -100
  98. package/src/providers/qoder/index.js +230 -184
  99. package/src/providers/qoder/sse.js +103 -46
  100. package/src/providers/qoder/sticky.js +1 -0
  101. package/src/providers/qoder/stream.js +32 -9
  102. package/src/providers/qwenwork/account-store.js +133 -0
  103. package/src/providers/qwenwork/constants.js +67 -0
  104. package/src/providers/qwenwork/cosy.js +120 -0
  105. package/src/providers/qwenwork/crypto.js +218 -0
  106. package/src/providers/qwenwork/http.js +20 -0
  107. package/src/providers/qwenwork/index.js +327 -0
  108. package/src/providers/qwenwork/payload.js +142 -0
  109. package/src/providers/qwenwork/rsa.js +54 -0
  110. package/src/providers/qwenwork/sse.js +268 -0
  111. package/src/providers/qwenwork/stream.js +130 -0
  112. package/src/providers/qwenwork/upstream.js +120 -0
  113. package/src/providers/qwenwork.js +1 -0
  114. package/src/providers/registry.js +66 -56
  115. package/src/providers/share-keys.js +2 -2
  116. package/src/providers/workbuddy/chat.js +248 -248
  117. package/src/providers/workbuddy/reshape.js +152 -152
  118. package/src/providers/workbuddy.js +2 -2
  119. package/src/providers/zcode/account-store.js +129 -0
  120. package/src/providers/zcode/auth.js +28 -0
  121. package/src/providers/zcode/chat.js +171 -0
  122. package/src/providers/zcode/const.js +54 -0
  123. package/src/providers/zcode/headers.js +55 -0
  124. package/src/providers/zcode/index.js +124 -0
  125. package/src/providers/zcode/models.js +65 -0
  126. package/src/providers/zcode/oauth.js +120 -0
  127. package/src/providers/zcode/quota.js +176 -0
  128. package/src/providers/zcode/sse.js +179 -0
  129. package/src/reasoning.js +32 -32
  130. package/src/routes/chat/gateway.js +46 -46
  131. package/src/routes/chat/relay-pipeline.js +250 -246
  132. package/src/routes/chat/via-route-handler.js +144 -144
  133. package/src/routes/hedge.js +255 -255
  134. package/src/routes/models-route.js +167 -167
  135. package/src/routes/peers.js +273 -273
  136. package/src/routes/stream.js +438 -399
  137. package/src/runtime/bootstrap.js +45 -45
  138. package/src/runtime/provider-gate.js +33 -30
  139. package/src/runtime/providers-setup.js +165 -165
  140. package/src/server.js +64 -64
  141. package/src/state/schemas/allowlist.js +92 -92
  142. package/src/sync-opencode.js +280 -280
  143. package/src/transport/index.js +244 -244
  144. package/src/transport/pool.js +56 -56
  145. package/src/transport/retry.js +24 -24
  146. package/src/transport/sse.js +93 -93
  147. package/src/upstream-probe/display.js +52 -52
  148. package/src/upstream-probe/probe.js +49 -49
  149. package/src/upstream-probe/rotate.js +110 -110
  150. package/src/upstream-probe/start.js +45 -45
  151. package/src/upstream.js +289 -289
@@ -1,92 +1,92 @@
1
- import { defaultStateFile, readState, writeStateImmediate } from "../store.js";
2
- import {
3
- normalizeAllowedModel,
4
- normalizeBaseUrl,
5
- normalizeAuths,
6
- normalizeEndpointPath,
7
- loadProviderConfigs,
8
- loadProviderConfig,
9
- loadProviderBaseUrl,
10
- loadProviderKeys,
11
- } from "./provider.js";
12
-
13
- export function loadProviderAllowedModels(id, { file = defaultStateFile() } = {}) {
14
- const cfg = loadProviderConfig(id, { file });
15
- if (cfg && Array.isArray(cfg.allowedModels)) return [...cfg.allowedModels];
16
- const raw = readState(file).providerConfigs?.[id];
17
- if (raw && Array.isArray(raw.allowedModels)) return [...new Set(raw.allowedModels.map((m) => normalizeAllowedModel(m, id)).filter(Boolean))];
18
- return [];
19
- }
20
-
21
- export function saveProviderAllowedModels(id, list, { file = defaultStateFile() } = {}) {
22
- const clean = [...new Set((Array.isArray(list) ? list : []).map((m) => normalizeAllowedModel(m, id)).filter(Boolean))];
23
- const configs = { ...loadProviderConfigs({ file }) };
24
- const cur = configs[id] && typeof configs[id] === "object" ? configs[id] : {};
25
- const baseUrl = normalizeBaseUrl(cur.baseUrl || loadProviderBaseUrl(id, { file }) || "");
26
- const keys = Array.isArray(cur.keys) ? cur.keys : loadProviderKeys(id, { file });
27
- const auths = normalizeAuths(cur.auths);
28
- const modelsPath = typeof cur.modelsPath === "string" ? normalizeEndpointPath(cur.modelsPath) : "";
29
- const chatPath = typeof cur.chatPath === "string" ? normalizeEndpointPath(cur.chatPath) : "";
30
- // allowAnyModels 是独立语义开关:只有它也设过时,即使其余字段全空也不能整键删(否则 clear 会把「允许任意」连带抹掉,供应商从放行降级成全拦 403)
31
- if (!baseUrl && !keys.length && !auths.length && !clean.length && !modelsPath && !chatPath && typeof cur.allowAnyModels !== "boolean") {
32
- delete configs[id];
33
- } else {
34
- configs[id] = { baseUrl, keys };
35
- // 重建 cfg 是 `{ baseUrl, keys }` 起手,不显式带 allowAnyModels 就会静默丢用户的「允许任意」设置
36
- // (实测 2026-09-24:saveProviderAllowedModels 把 allowAnyModels:true 抹成默认 false)。
37
- // cline 白名单 auto-sync 会周期性写这里,丢了就是持续丢,必须保留。
38
- if (typeof cur.allowAnyModels === "boolean") configs[id].allowAnyModels = cur.allowAnyModels;
39
- if (auths.length) configs[id].auths = auths;
40
- if (clean.length) configs[id].allowedModels = clean;
41
- if (modelsPath) configs[id].modelsPath = modelsPath;
42
- if (chatPath) configs[id].chatPath = chatPath;
43
- }
44
- writeStateImmediate(file, { providerConfigs: configs });
45
- return clean;
46
- }
47
-
48
- export function addProviderAllowedModel(id, model, opts = {}) {
49
- const cur = loadProviderAllowedModels(id, opts);
50
- const norm = normalizeAllowedModel(model, id);
51
- if (!norm || cur.includes(norm)) return cur;
52
- return saveProviderAllowedModels(id, [...cur, norm], opts);
53
- }
54
-
55
- export function removeProviderAllowedModel(id, model, opts = {}) {
56
- return removeProviderAllowedModels(id, [model], opts);
57
- }
58
-
59
- export function removeProviderAllowedModels(id, targets = [], opts = {}) {
60
- const set = new Set((Array.isArray(targets) ? targets : [targets]).map((m) => normalizeAllowedModel(m, id)).filter(Boolean));
61
- const cur = loadProviderAllowedModels(id, opts);
62
- const next = cur.filter((m) => !set.has(m));
63
- return saveProviderAllowedModels(id, next, opts);
64
- }
65
-
66
- function normalizeAllowAny(v, id) {
67
- if (typeof v === "boolean") return v;
68
- if (String(id || "").toLowerCase() === "opencode") return true;
69
- return false;
70
- }
71
- export function loadProviderAllowAnyModels(id, { file = defaultStateFile() } = {}) {
72
- const cfg = readState(file).providerConfigs?.[id];
73
- if (cfg && typeof cfg.allowAnyModels === "boolean") return cfg.allowAnyModels;
74
- return normalizeAllowAny(undefined, id);
75
- }
76
- export function saveProviderAllowAnyModels(id, allowAny, { file = defaultStateFile() } = {}) {
77
- const state = readState(file);
78
- const cfgs = { ...(state.providerConfigs || {}) };
79
- const cur = cfgs[id] || {};
80
- cfgs[id] = { ...cur, allowAnyModels: normalizeAllowAny(allowAny, id) };
81
- writeStateImmediate(file, { providerConfigs: cfgs });
82
- return cfgs[id].allowAnyModels;
83
- }
84
- export function isModelAllowed(id, rawModel, { file = defaultStateFile() } = {}) {
85
- const raw = String(rawModel || "").trim();
86
- if (!raw) return true;
87
- const allowed = loadProviderAllowedModels(id, { file });
88
- const allowAny = loadProviderAllowAnyModels(id, { file });
89
- if (!allowed.length) return allowAny;
90
- const norm = normalizeAllowedModel(raw, id);
91
- return allowed.includes(norm);
92
- }
1
+ import { defaultStateFile, readState, writeStateImmediate } from "../store.js";
2
+ import {
3
+ normalizeAllowedModel,
4
+ normalizeBaseUrl,
5
+ normalizeAuths,
6
+ normalizeEndpointPath,
7
+ loadProviderConfigs,
8
+ loadProviderConfig,
9
+ loadProviderBaseUrl,
10
+ loadProviderKeys,
11
+ } from "./provider.js";
12
+
13
+ export function loadProviderAllowedModels(id, { file = defaultStateFile() } = {}) {
14
+ const cfg = loadProviderConfig(id, { file });
15
+ if (cfg && Array.isArray(cfg.allowedModels)) return [...cfg.allowedModels];
16
+ const raw = readState(file).providerConfigs?.[id];
17
+ if (raw && Array.isArray(raw.allowedModels)) return [...new Set(raw.allowedModels.map((m) => normalizeAllowedModel(m, id)).filter(Boolean))];
18
+ return [];
19
+ }
20
+
21
+ export function saveProviderAllowedModels(id, list, { file = defaultStateFile() } = {}) {
22
+ const clean = [...new Set((Array.isArray(list) ? list : []).map((m) => normalizeAllowedModel(m, id)).filter(Boolean))];
23
+ const configs = { ...loadProviderConfigs({ file }) };
24
+ const cur = configs[id] && typeof configs[id] === "object" ? configs[id] : {};
25
+ const baseUrl = normalizeBaseUrl(cur.baseUrl || loadProviderBaseUrl(id, { file }) || "");
26
+ const keys = Array.isArray(cur.keys) ? cur.keys : loadProviderKeys(id, { file });
27
+ const auths = normalizeAuths(cur.auths);
28
+ const modelsPath = typeof cur.modelsPath === "string" ? normalizeEndpointPath(cur.modelsPath) : "";
29
+ const chatPath = typeof cur.chatPath === "string" ? normalizeEndpointPath(cur.chatPath) : "";
30
+ // allowAnyModels 是独立语义开关:只有它也设过时,即使其余字段全空也不能整键删(否则 clear 会把「允许任意」连带抹掉,供应商从放行降级成全拦 403)
31
+ if (!baseUrl && !keys.length && !auths.length && !clean.length && !modelsPath && !chatPath && typeof cur.allowAnyModels !== "boolean") {
32
+ delete configs[id];
33
+ } else {
34
+ configs[id] = { baseUrl, keys };
35
+ // 重建 cfg 是 `{ baseUrl, keys }` 起手,不显式带 allowAnyModels 就会静默丢用户的「允许任意」设置
36
+ // (实测 2026-09-24:saveProviderAllowedModels 把 allowAnyModels:true 抹成默认 false)。
37
+ // cline 白名单 auto-sync 会周期性写这里,丢了就是持续丢,必须保留。
38
+ if (typeof cur.allowAnyModels === "boolean") configs[id].allowAnyModels = cur.allowAnyModels;
39
+ if (auths.length) configs[id].auths = auths;
40
+ if (clean.length) configs[id].allowedModels = clean;
41
+ if (modelsPath) configs[id].modelsPath = modelsPath;
42
+ if (chatPath) configs[id].chatPath = chatPath;
43
+ }
44
+ writeStateImmediate(file, { providerConfigs: configs });
45
+ return clean;
46
+ }
47
+
48
+ export function addProviderAllowedModel(id, model, opts = {}) {
49
+ const cur = loadProviderAllowedModels(id, opts);
50
+ const norm = normalizeAllowedModel(model, id);
51
+ if (!norm || cur.includes(norm)) return cur;
52
+ return saveProviderAllowedModels(id, [...cur, norm], opts);
53
+ }
54
+
55
+ export function removeProviderAllowedModel(id, model, opts = {}) {
56
+ return removeProviderAllowedModels(id, [model], opts);
57
+ }
58
+
59
+ export function removeProviderAllowedModels(id, targets = [], opts = {}) {
60
+ const set = new Set((Array.isArray(targets) ? targets : [targets]).map((m) => normalizeAllowedModel(m, id)).filter(Boolean));
61
+ const cur = loadProviderAllowedModels(id, opts);
62
+ const next = cur.filter((m) => !set.has(m));
63
+ return saveProviderAllowedModels(id, next, opts);
64
+ }
65
+
66
+ function normalizeAllowAny(v, id) {
67
+ if (typeof v === "boolean") return v;
68
+ if (String(id || "").toLowerCase() === "opencode") return true;
69
+ return false;
70
+ }
71
+ export function loadProviderAllowAnyModels(id, { file = defaultStateFile() } = {}) {
72
+ const cfg = readState(file).providerConfigs?.[id];
73
+ if (cfg && typeof cfg.allowAnyModels === "boolean") return cfg.allowAnyModels;
74
+ return normalizeAllowAny(undefined, id);
75
+ }
76
+ export function saveProviderAllowAnyModels(id, allowAny, { file = defaultStateFile() } = {}) {
77
+ const state = readState(file);
78
+ const cfgs = { ...(state.providerConfigs || {}) };
79
+ const cur = cfgs[id] || {};
80
+ cfgs[id] = { ...cur, allowAnyModels: normalizeAllowAny(allowAny, id) };
81
+ writeStateImmediate(file, { providerConfigs: cfgs });
82
+ return cfgs[id].allowAnyModels;
83
+ }
84
+ export function isModelAllowed(id, rawModel, { file = defaultStateFile() } = {}) {
85
+ const raw = String(rawModel || "").trim();
86
+ if (!raw) return true;
87
+ const allowed = loadProviderAllowedModels(id, { file });
88
+ const allowAny = loadProviderAllowAnyModels(id, { file });
89
+ if (!allowed.length) return allowAny;
90
+ const norm = normalizeAllowedModel(raw, id);
91
+ return allowed.includes(norm);
92
+ }