mslxdff 0.1.187 → 0.1.188
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.
- package/bin/mslxdff.js +3 -3
- package/docs/cli_help_mini.md +145 -0
- package/package.json +1 -1
- package/src/auto.js +254 -254
- package/src/autostart.js +5 -2
- package/src/bench/cline-bench.js +42 -42
- package/src/bench/probe.js +70 -70
- package/src/bench/report.js +162 -162
- package/src/bench/runner.js +77 -77
- package/src/bench/via-probe.js +124 -124
- package/src/bench/via-routes.js +87 -87
- package/src/bench/workbuddy-bench.js +54 -54
- package/src/chat/engine.js +160 -160
- package/src/chat/gateway.js +163 -163
- package/src/chat/orchestrator.js +234 -234
- package/src/chat/prompt.js +70 -70
- package/src/chat/repl.js +88 -88
- package/src/chat/terminal.js +135 -135
- package/src/chat/tools.js +306 -306
- package/src/chat-pipeline/index.js +173 -131
- package/src/chat-pipeline/policy.js +84 -84
- package/src/chat-pipeline/serial-trial.js +6 -3
- package/src/chat-pipeline/terminal-verdict.js +29 -0
- package/src/cli/commands/daemon.js +55 -18
- package/src/cli/commands/group.js +249 -249
- package/src/cli/commands/model/picks.js +50 -50
- package/src/cli/commands/provider/bench-via.js +247 -247
- package/src/cli/commands/provider/bench.js +141 -141
- package/src/cli/commands/provider/index.js +136 -136
- package/src/cli/commands/provider/models.js +145 -145
- package/src/cli/commands/provider/qwenwork-login.js +119 -119
- package/src/cli/commands/sync.js +310 -310
- package/src/cli/commands/system.js +23 -7
- package/src/cli/join-wizard.js +8 -4
- package/src/cli/policy.js +14 -2
- package/src/cli/status.js +279 -279
- package/src/daemon.js +232 -195
- package/src/logs.js +27 -11
- package/src/model-capabilities/enrich.js +86 -86
- package/src/model-capabilities/index.js +183 -183
- package/src/model-capabilities/parse.js +70 -70
- package/src/model-trace.js +35 -4
- package/src/models.js +225 -225
- package/src/peers.js +20 -1
- package/src/providers/AGENTS.md +49 -0
- package/src/providers/cline/auth.js +228 -228
- package/src/providers/cline/chat.js +307 -307
- package/src/providers/cline.js +2 -2
- package/src/providers/codearts/chat.js +182 -182
- package/src/providers/globalqwenwork/cosy.js +123 -123
- package/src/providers/globalqwenwork/crypto.js +218 -218
- package/src/providers/globalqwenwork/http.js +20 -20
- package/src/providers/globalqwenwork/rsa.js +54 -54
- package/src/providers/globalqwenwork/sse.js +268 -268
- package/src/providers/globalqwenwork/stream.js +130 -130
- package/src/providers/globalqwenwork/upstream.js +122 -122
- package/src/providers/keyring.js +60 -60
- package/src/providers/qoder/chat.js +203 -203
- package/src/providers/qoder/index.js +249 -249
- package/src/providers/qoder/sse.js +145 -145
- package/src/providers/qwenwork/account-store.js +133 -133
- package/src/providers/qwenwork/constants.js +67 -67
- package/src/providers/qwenwork/cosy.js +120 -120
- package/src/providers/qwenwork/crypto.js +218 -218
- package/src/providers/qwenwork/http.js +20 -20
- package/src/providers/qwenwork/index.js +337 -327
- package/src/providers/qwenwork/payload.js +144 -144
- package/src/providers/qwenwork/rsa.js +54 -54
- package/src/providers/qwenwork/sse.js +268 -268
- package/src/providers/qwenwork/stream.js +130 -130
- package/src/providers/qwenwork/upstream.js +120 -120
- package/src/providers/qwenwork.js +1 -1
- package/src/providers/registry.js +79 -79
- package/src/providers/traework/chat.js +7 -1
- package/src/providers/workbuddy/chat.js +248 -248
- package/src/providers/workbuddy/reshape.js +152 -152
- package/src/providers/workbuddy.js +2 -2
- package/src/reasoning.js +32 -32
- package/src/routes/AGENTS.md +37 -0
- package/src/routes/chat/empty-turn-report.js +31 -0
- package/src/routes/chat/gateway.js +46 -46
- package/src/routes/chat/peer-handler.js +3 -2
- package/src/routes/chat/relay-pipeline.js +282 -294
- package/src/routes/chat/via-route-handler.js +146 -146
- package/src/routes/hedge.js +253 -255
- package/src/routes/index.js +14 -6
- package/src/routes/models-route.js +167 -167
- package/src/routes/peers.js +335 -273
- package/src/routes/responses-route.js +44 -2
- package/src/routes/stream-body.js +84 -0
- package/src/routes/stream-hold.js +152 -4
- package/src/routes/stream-scan.js +27 -2
- package/src/routes/stream.js +343 -385
- package/src/runtime/bootstrap.js +67 -67
- package/src/runtime/group-sync.js +70 -17
- package/src/runtime/provider-gate.js +36 -36
- package/src/runtime/providers-setup.js +168 -168
- package/src/runtime/server-lifecycle.js +1 -1
- package/src/server.js +78 -78
- package/src/state/schemas/allowlist.js +92 -92
- package/src/sync-opencode.js +280 -280
- package/src/transport/index.js +244 -244
- package/src/transport/pool.js +56 -56
- package/src/transport/retry.js +24 -24
- package/src/transport/sse.js +93 -93
- package/src/upstream-engine/sdk/attempt.js +9 -1
- package/src/upstream-probe/display.js +52 -52
- package/src/upstream-probe/probe.js +49 -49
- package/src/upstream-probe/rotate.js +110 -110
- package/src/upstream-probe/start.js +45 -45
- package/src/upstream.js +293 -293
|
@@ -3,7 +3,7 @@ import { join, dirname } from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { defaultStateFile } from "../../state.js";
|
|
5
5
|
import { loadToken, refreshToken } from "../../state.js";
|
|
6
|
-
import { stopDaemon, pidFile, logFile } from "../../daemon.js";
|
|
6
|
+
import { stopDaemon, pidFile, logFile, isPidAlive } from "../../daemon.js";
|
|
7
7
|
import { logDir, eventsFile, callsFile, errorsFile, recentEvents, timelineFile, recentTimeline } from "../../logs.js";
|
|
8
8
|
import { fmtEvent } from "../format.js";
|
|
9
9
|
import { fmtShanghaiYMDHMS, fmtShanghaiHMS } from "../../time.js";
|
|
@@ -58,10 +58,21 @@ export async function handleUpdate(args, VERSION) {
|
|
|
58
58
|
const daemon = readPid();
|
|
59
59
|
if (daemon) {
|
|
60
60
|
console.log("restarting daemon on the new version…");
|
|
61
|
-
stopDaemon({ reason: "restart" });
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
const r = stopDaemon({ reason: "restart" });
|
|
62
|
+
// 同 BUG-29:停不掉就绝不能报 restarted —— 旧版还占着端口,新进程 EADDRINUSE 秒退,
|
|
63
|
+
// 而 waitForHealth 打的是旧 daemon 的 /health,照样 200,读 pid 读到的也是旧值。
|
|
64
|
+
if (!r.stopped && r.pid) {
|
|
65
|
+
console.error(`⚠ 旧 daemon (pid ${r.pid}) 没能停掉:${r.reason}`);
|
|
66
|
+
console.error(` 新版本已装好,但旧版仍在运行(未生效)。请用管理员终端停掉它后重新 -restart。`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
69
|
+
const spawned = startDaemon([]);
|
|
70
|
+
const health = await waitForHealth(resolvePort(), 4000, { expectPid: spawned });
|
|
71
|
+
if (!isPidAlive(spawned)) {
|
|
72
|
+
console.error(`⚠ 新 daemon (pid ${spawned}) 启动后立即退出 —— 端口大概仍被旧进程占着(EADDRINUSE)。旧版仍在运行,升级未生效。`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
console.log(`restarted (pid ${spawned})${health.ok ? "" : " — health check pending"}`);
|
|
65
76
|
}
|
|
66
77
|
process.exit(0);
|
|
67
78
|
}
|
|
@@ -82,9 +93,14 @@ export async function handleShowToken(args) {
|
|
|
82
93
|
|
|
83
94
|
export async function handleUninstall(args) {
|
|
84
95
|
if (!(args.includes("-uninstall") || args.includes("--uninstall"))) return false;
|
|
85
|
-
const { stopped, pid } = stopDaemon({ reason: "uninstall" });
|
|
96
|
+
const { stopped, pid, reason } = stopDaemon({ reason: "uninstall" });
|
|
86
97
|
if (stopped) console.log(`mslxdff daemon stopped (pid ${pid})`);
|
|
87
|
-
else
|
|
98
|
+
else if (pid) {
|
|
99
|
+
// 杀被拒 ≠ 没在跑:它还活着并持有 state/logs,继续删文件会让在跑的 daemon 半瘫(写不进也不重来)。
|
|
100
|
+
console.error(`mslxdff daemon still running (pid ${pid}) — uninstall aborted: ${reason}`);
|
|
101
|
+
console.error("先停掉它(管理员终端执行 mslxdff -stop,或 taskkill /PID " + pid + " /F),再重新 -uninstall");
|
|
102
|
+
process.exit(1);
|
|
103
|
+
} else console.log("mslxdff daemon not running");
|
|
88
104
|
const stateFile = defaultStateFile();
|
|
89
105
|
const dir = dirname(stateFile);
|
|
90
106
|
const removed = [];
|
package/src/cli/join-wizard.js
CHANGED
|
@@ -52,8 +52,11 @@ export async function ensureServiceRunning() {
|
|
|
52
52
|
const pid = readPid();
|
|
53
53
|
if (pid && isPidAlive(pid)) return { pid, started: false };
|
|
54
54
|
const newPid = startDaemon([]);
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
// 只认刚起的 pid:旧 daemon 若仍占端口,它的 /health 照样 200(同 BUG-29/30)。
|
|
56
|
+
const health = await waitForHealth(effectivePort([]), SERVICE_HEALTH_TIMEOUT_MS, { expectPid: newPid });
|
|
57
|
+
// 起完立即退出 = 端口被占(EADDRINUSE)。向导不能报「服务已启动」,那会把后续入组失败归错因。
|
|
58
|
+
if (!isPidAlive(newPid)) return { pid: null, started: false, failed: true, reason: "daemon exited right after start (port in use?)" };
|
|
59
|
+
return { pid: newPid, started: true, healthy: health.ok };
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
/**
|
|
@@ -148,8 +151,9 @@ export async function runJoinWizard(opts = {}) {
|
|
|
148
151
|
|
|
149
152
|
out("→ 正在启动后台服务 ...");
|
|
150
153
|
const service = await ensureService().catch((err) => ({ error: errMsg(err) }));
|
|
151
|
-
if (service?.error) {
|
|
152
|
-
|
|
154
|
+
if (service?.error || service?.failed) {
|
|
155
|
+
// failed 是「进程起来又立刻死了」(端口被占用):不能落到下面「已在运行(pid null)」分支谎报成功。
|
|
156
|
+
out(`✗ 后台服务启动失败:${service.error || service.reason}`);
|
|
153
157
|
out(" 手动启动:mslxdff -d 查看日志:mslxdff -log 50");
|
|
154
158
|
} else if (service?.started) {
|
|
155
159
|
out(`✓ 后台服务已启动(pid ${service.pid})`);
|
package/src/cli/policy.js
CHANGED
|
@@ -36,17 +36,29 @@ export function effectiveHost() {
|
|
|
36
36
|
return "0.0.0.0";
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* 等 /health 可用。给了 expectPid 就**只认那个 pid**:旧 daemon 仍占着端口时它也会回 200,
|
|
41
|
+
* 不校验身份的话「新进程 EADDRINUSE 秒退、旧版还在服务」会被当成启动成功(BUG-29)。
|
|
42
|
+
* 返回 { ok, pid, version }:ok=true 表示确认到位(无 expectPid 时即 res.ok)。
|
|
43
|
+
*/
|
|
44
|
+
export async function waitForHealth(port, timeoutMs, { expectPid = null } = {}) {
|
|
40
45
|
const start = Date.now();
|
|
41
46
|
while (Date.now() - start < timeoutMs) {
|
|
42
47
|
try {
|
|
43
48
|
const res = await compatFetch(`http://127.0.0.1:${port}/health`);
|
|
44
|
-
if (res.ok)
|
|
49
|
+
if (res.ok) {
|
|
50
|
+
if (expectPid == null) return { ok: true, pid: null, version: null };
|
|
51
|
+
let body = null;
|
|
52
|
+
try { body = await res.json(); } catch { /* 老版本 daemon 不认 JSON 之外的东西 */ }
|
|
53
|
+
// 老版本 /health 只回 {status:"ok"},没有 pid ⇒ 无法证明是新进程,继续等(旧版本来就该被换掉)
|
|
54
|
+
if (body && Number(body.pid) === Number(expectPid)) return { ok: true, pid: body.pid, version: body.version ?? null };
|
|
55
|
+
}
|
|
45
56
|
} catch {
|
|
46
57
|
// not up yet
|
|
47
58
|
}
|
|
48
59
|
await new Promise((r) => setTimeout(r, 100));
|
|
49
60
|
}
|
|
61
|
+
return { ok: false, pid: null, version: null };
|
|
50
62
|
}
|
|
51
63
|
|
|
52
64
|
// Only upgrade, never downgrade. Keeps a newer daemon running.
|