luckytri 1.0.0 → 1.0.2
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/.github/SECURITY.md +4 -4
- package/README.en.md +252 -250
- package/README.md +252 -250
- package/bin/luckytri.js +5 -1
- package/docs/en/CHANGELOG.md +8 -0
- package/docs/en/connect.md +18 -18
- package/docs/en/guide.md +202 -216
- package/docs/en/npm-release.md +25 -25
- package/docs/zh/CHANGELOG.md +8 -0
- package/docs/zh/connect.md +17 -17
- package/docs/zh/guide.md +202 -216
- package/docs/zh/npm-release.md +33 -33
- package/package.json +110 -108
- package/plugins/sdk/index.d.ts +155 -155
- package/plugins/sdk/testing.js +58 -58
- package/plugins/weather/index.js +82 -82
- package/plugins/weather/luckytri-plugin.json +29 -29
- package/public/app/assets/ChatsPage-BhlJHseG.js +3 -0
- package/public/app/assets/Empty-DP6WMGHi.js +2 -0
- package/public/app/assets/Field-CtbdqaiB.js +1 -0
- package/public/app/assets/HeartPage-32BeTPn2.js +1 -0
- package/public/app/assets/LifePage-CxSm0XKI.js +1 -0
- package/public/app/assets/MemoryPage-BeKBcPCY.js +1 -0
- package/public/app/assets/NaturePage-NEPYl2HS.js +3 -0
- package/public/app/assets/PeoplePage-DxtpekwM.js +1 -0
- package/public/app/assets/PluginsPage-CVVQwEBI.css +1 -0
- package/public/app/assets/PluginsPage-DksEZbUU.js +2 -0
- package/public/app/assets/{SystemPage-CAMPoYqM.css → SystemPage-BkRu0Rvx.css} +1 -1
- package/public/app/assets/SystemPage-BvzJlHuY.js +1 -0
- package/public/app/assets/TimePage-7-awH5XL.js +3 -0
- package/public/app/assets/index-4rItIkD-.js +4 -0
- package/public/app/assets/{index-YDz1ree1.css → index-DY4e15Kh.css} +1 -1
- package/public/app/assets/{knowledge-DG0e0uKw.js → knowledge-C6_HvoyB.js} +1 -1
- package/public/app/assets/media-SMfTT-yc.js +1 -0
- package/public/app/index.html +3 -3
- package/public/guide.en.html +72 -99
- package/public/guide.html +44 -86
- package/public/tutorial.en.md +25 -39
- package/public/tutorial.md +25 -39
- package/scripts/backup.js +311 -311
- package/scripts/browser.js +41 -41
- package/scripts/import-data.js +128 -0
- package/scripts/launch.js +101 -94
- package/scripts/plugin.js +150 -150
- package/scripts/reset-password.js +22 -0
- package/scripts/runtime.js +25 -25
- package/scripts/service.js +56 -47
- package/scripts/setup.js +50 -50
- package/scripts/start-server.js +41 -41
- package/scripts/stop.js +36 -36
- package/server/app.js +112 -96
- package/server/auth.js +217 -0
- package/server/channels/contract.js +57 -57
- package/server/channels/hub.js +165 -165
- package/server/channels/index.js +28 -25
- package/server/channels/onebot/index.js +335 -336
- package/server/channels/onebot/token.js +22 -3
- package/server/core/capabilities.js +208 -208
- package/server/core/events.js +64 -60
- package/server/core/image-preprocessor.js +208 -208
- package/server/core/model-manager.js +1213 -1213
- package/server/core/net-guard.js +49 -49
- package/server/core/orchestrator.js +569 -569
- package/server/core/perceivers.js +91 -91
- package/server/core/persona-manager.js +243 -243
- package/server/core/repository.js +293 -293
- package/server/core/response-validator.js +508 -508
- package/server/core/turn-processor.js +630 -630
- package/server/core/turn.js +236 -236
- package/server/core/vision-manager.js +633 -633
- package/server/i18n/errors.js +548 -497
- package/server/i18n/labels.js +649 -653
- package/server/index.js +151 -102
- package/server/knowledge/manager.js +386 -386
- package/server/knowledge/schema.js +12 -8
- package/server/local-access.js +32 -0
- package/server/mind/anticipations.js +507 -507
- package/server/mind/api.js +703 -703
- package/server/mind/budget.js +152 -152
- package/server/mind/context-selection.js +61 -61
- package/server/mind/day-planner.js +324 -324
- package/server/mind/evidence.js +148 -148
- package/server/mind/index.js +445 -445
- package/server/mind/life/diary.js +786 -786
- package/server/mind/life/index.js +1049 -1049
- package/server/mind/observations.js +84 -84
- package/server/mind/own-day.js +324 -324
- package/server/mind/own-voice.js +318 -318
- package/server/mind/senses.js +53 -53
- package/server/mind/time/activity-clock.js +196 -196
- package/server/mind/time/availability.js +69 -69
- package/server/mind/time/commitment-review.js +198 -198
- package/server/mind/time/executor.js +512 -512
- package/server/mind/time/experiences.js +128 -128
- package/server/mind/time/games.js +562 -562
- package/server/mind/time/index.js +739 -739
- package/server/mind/time/intent.js +166 -166
- package/server/mind/time/kinds.js +171 -171
- package/server/mind/time/plugin-activity.js +207 -207
- package/server/mind/time/tasks.js +587 -587
- package/server/mind/util.js +110 -110
- package/server/mind/view.js +273 -273
- package/server/paths.js +102 -102
- package/server/plugins/api.js +204 -204
- package/server/plugins/host.js +967 -967
- package/server/plugins/install.js +295 -295
- package/server/plugins/manifest.js +201 -201
- package/server/plugins/permissions.js +42 -42
- package/server/plugins/runner/guard.mjs +36 -36
- package/server/plugins/runner/worker.mjs +250 -250
- package/server/plugins/schema.js +91 -91
- package/server/plugins/zip.js +112 -112
- package/server/startup-lock.js +118 -118
- package/server/storage/archive.js +242 -241
- package/server/storage/backup-cleanup-worker.js +8 -8
- package/server/storage/backup-cleanup.js +415 -414
- package/server/storage/backup-lock.js +76 -76
- package/server/storage/backup-scheduler.js +131 -131
- package/server/storage/data-package.js +298 -0
- package/server/storage/data-transfer-api.js +50 -0
- package/server/storage/data-transfer-worker.js +18 -0
- package/server/storage/data-transfer.js +415 -0
- package/server/storage/store.js +202 -199
- package/server/studio/readiness.js +181 -190
- package/server/studio/settings.js +236 -236
- package/public/app/assets/ChatsPage-C-FcRapR.js +0 -3
- package/public/app/assets/Empty-CpP5kQHH.js +0 -2
- package/public/app/assets/Field-D4gY-INU.js +0 -1
- package/public/app/assets/HeartPage-CPy_thQd.js +0 -1
- package/public/app/assets/LifePage-CxWvwmSf.js +0 -1
- package/public/app/assets/MemoryPage-DC4rhQ68.js +0 -1
- package/public/app/assets/NaturePage-IvYw04Zq.js +0 -3
- package/public/app/assets/PeoplePage-Cqefm9-q.js +0 -1
- package/public/app/assets/PluginsPage-DKSaKvXb.js +0 -2
- package/public/app/assets/PluginsPage-HyBe5D8w.css +0 -1
- package/public/app/assets/SystemPage-CJmtJkrK.js +0 -1
- package/public/app/assets/TimePage-Cw44inM4.js +0 -3
- package/public/app/assets/index-BheRW-1t.js +0 -4
- package/public/app/assets/media-BzPDBm7e.js +0 -1
package/scripts/browser.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
export function browserCommand(url, platform = process.platform) {
|
|
4
|
-
if (platform === "win32")
|
|
5
|
-
return {
|
|
6
|
-
command: "powershell.exe",
|
|
7
|
-
args: [
|
|
8
|
-
"-NoProfile",
|
|
9
|
-
"-NonInteractive",
|
|
10
|
-
"-Command",
|
|
11
|
-
"Start-Process $env:LUCKY_LAUNCH_URL",
|
|
12
|
-
],
|
|
13
|
-
env: { ...process.env, LUCKY_LAUNCH_URL: url },
|
|
14
|
-
};
|
|
15
|
-
return { command: platform === "darwin" ? "open" : "xdg-open", args: [url] };
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export async function openBrowser(url) {
|
|
19
|
-
const { command, args, env } = browserCommand(url);
|
|
20
|
-
const child = spawn(command, args, {
|
|
21
|
-
windowsHide: true,
|
|
22
|
-
stdio: "ignore",
|
|
23
|
-
env,
|
|
24
|
-
});
|
|
25
|
-
await new Promise((resolve, reject) => {
|
|
26
|
-
const timeout = setTimeout(() => {
|
|
27
|
-
child.kill();
|
|
28
|
-
reject(Error("浏览器未打开,请手动打开上方地址。"));
|
|
29
|
-
}, 10000);
|
|
30
|
-
const finish = (error) => {
|
|
31
|
-
clearTimeout(timeout);
|
|
32
|
-
error ? reject(error) : resolve();
|
|
33
|
-
};
|
|
34
|
-
child.once("error", () =>
|
|
35
|
-
finish(Error("浏览器未打开,请手动打开上方地址。")),
|
|
36
|
-
);
|
|
37
|
-
child.once("exit", (code) =>
|
|
38
|
-
finish(code === 0 ? null : Error("浏览器未打开,请手动打开上方地址。")),
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
export function browserCommand(url, platform = process.platform) {
|
|
4
|
+
if (platform === "win32")
|
|
5
|
+
return {
|
|
6
|
+
command: "powershell.exe",
|
|
7
|
+
args: [
|
|
8
|
+
"-NoProfile",
|
|
9
|
+
"-NonInteractive",
|
|
10
|
+
"-Command",
|
|
11
|
+
"Start-Process $env:LUCKY_LAUNCH_URL",
|
|
12
|
+
],
|
|
13
|
+
env: { ...process.env, LUCKY_LAUNCH_URL: url },
|
|
14
|
+
};
|
|
15
|
+
return { command: platform === "darwin" ? "open" : "xdg-open", args: [url] };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function openBrowser(url) {
|
|
19
|
+
const { command, args, env } = browserCommand(url);
|
|
20
|
+
const child = spawn(command, args, {
|
|
21
|
+
windowsHide: true,
|
|
22
|
+
stdio: "ignore",
|
|
23
|
+
env,
|
|
24
|
+
});
|
|
25
|
+
await new Promise((resolve, reject) => {
|
|
26
|
+
const timeout = setTimeout(() => {
|
|
27
|
+
child.kill();
|
|
28
|
+
reject(Error("浏览器未打开,请手动打开上方地址。"));
|
|
29
|
+
}, 10000);
|
|
30
|
+
const finish = (error) => {
|
|
31
|
+
clearTimeout(timeout);
|
|
32
|
+
error ? reject(error) : resolve();
|
|
33
|
+
};
|
|
34
|
+
child.once("error", () =>
|
|
35
|
+
finish(Error("浏览器未打开,请手动打开上方地址。")),
|
|
36
|
+
);
|
|
37
|
+
child.once("exit", (code) =>
|
|
38
|
+
finish(code === 0 ? null : Error("浏览器未打开,请手动打开上方地址。")),
|
|
39
|
+
);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { openSync, closeSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { prepareRuntime } from "./runtime.js";
|
|
5
|
+
import { claimLaunch, clearStarting } from "../server/startup-lock.js";
|
|
6
|
+
import { applyDataImport } from "../server/storage/data-package.js";
|
|
7
|
+
import {
|
|
8
|
+
transferRoot,
|
|
9
|
+
readTransferJob,
|
|
10
|
+
writeTransferJob,
|
|
11
|
+
IMPORT_FAILURE,
|
|
12
|
+
IMPORT_START_FAILURE,
|
|
13
|
+
IMPORT_RESTART_FAILURE,
|
|
14
|
+
} from "../server/storage/data-transfer.js";
|
|
15
|
+
|
|
16
|
+
const id = process.argv[2];
|
|
17
|
+
const parent = Number(process.argv[3]);
|
|
18
|
+
let job,
|
|
19
|
+
paths,
|
|
20
|
+
claimed = false;
|
|
21
|
+
const alive = (pid) => {
|
|
22
|
+
try {
|
|
23
|
+
process.kill(pid, 0);
|
|
24
|
+
return true;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
return error.code !== "ESRCH";
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
try {
|
|
30
|
+
paths = prepareRuntime({ initialize: false });
|
|
31
|
+
if (!Number.isInteger(parent) || parent <= 0) throw Error("导入启动信息无效");
|
|
32
|
+
job = readTransferJob(transferRoot(), id);
|
|
33
|
+
if (job.kind !== "import" || job.status !== "queued")
|
|
34
|
+
throw Error("导入任务已经处理或不可用");
|
|
35
|
+
for (let attempt = 0; attempt < 160 && alive(parent); attempt++)
|
|
36
|
+
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
37
|
+
if (alive(parent)) throw Error("旧实例仍在运行,未替换数据");
|
|
38
|
+
if (!claimLaunch()) throw Error("另一次启动正在进行,未替换数据");
|
|
39
|
+
claimed = true;
|
|
40
|
+
try {
|
|
41
|
+
const result = applyDataImport(
|
|
42
|
+
join(transferRoot(), id, "data.db"),
|
|
43
|
+
paths.database,
|
|
44
|
+
paths.backups,
|
|
45
|
+
{
|
|
46
|
+
id,
|
|
47
|
+
beforeSwap(backup) {
|
|
48
|
+
job = { ...job, backup };
|
|
49
|
+
writeTransferJob(transferRoot(), job);
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
);
|
|
53
|
+
job = {
|
|
54
|
+
...job,
|
|
55
|
+
status: "done",
|
|
56
|
+
applied: Date.now(),
|
|
57
|
+
...result,
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
writeTransferJob(transferRoot(), job);
|
|
61
|
+
} catch {
|
|
62
|
+
console.error("导入结果记录未写入,重启后会核对已提交的数据。");
|
|
63
|
+
}
|
|
64
|
+
console.log("数据导入完成,当前数据快照已保留。");
|
|
65
|
+
} catch (error) {
|
|
66
|
+
writeTransferJob(transferRoot(), {
|
|
67
|
+
...job,
|
|
68
|
+
status: "error",
|
|
69
|
+
error: IMPORT_FAILURE,
|
|
70
|
+
});
|
|
71
|
+
console.error("数据导入未完成:", error.code || "校验或替换失败");
|
|
72
|
+
}
|
|
73
|
+
// Hand the launch claim directly to the new server so no other launch can
|
|
74
|
+
// open the database halfway through the swap.
|
|
75
|
+
const log = openSync(paths.log, "a", 0o600);
|
|
76
|
+
const child = spawn(
|
|
77
|
+
process.execPath,
|
|
78
|
+
[
|
|
79
|
+
...(process.execArgv.includes("--use-env-proxy")
|
|
80
|
+
? ["--use-env-proxy"]
|
|
81
|
+
: []),
|
|
82
|
+
join(paths.package, "server", "index.js"),
|
|
83
|
+
],
|
|
84
|
+
{
|
|
85
|
+
cwd: paths.home,
|
|
86
|
+
env: { ...process.env, LUCKYTRI_LAUNCH_PID: String(process.pid) },
|
|
87
|
+
detached: true,
|
|
88
|
+
windowsHide: true,
|
|
89
|
+
stdio: ["ignore", log, log],
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
closeSync(log);
|
|
93
|
+
await new Promise((resolve, reject) => {
|
|
94
|
+
child.once("spawn", resolve);
|
|
95
|
+
child.once("error", reject);
|
|
96
|
+
});
|
|
97
|
+
child.unref();
|
|
98
|
+
for (let attempt = 0; attempt < 120; attempt++) {
|
|
99
|
+
try {
|
|
100
|
+
const info = JSON.parse(
|
|
101
|
+
(await import("node:fs")).readFileSync(
|
|
102
|
+
join(paths.data, "startup.json"),
|
|
103
|
+
"utf8",
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
if (info.pid === child.pid && info.role === "server") {
|
|
107
|
+
claimed = false;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
} catch {}
|
|
111
|
+
await new Promise((resolve) => setTimeout(resolve, 250));
|
|
112
|
+
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (job) {
|
|
115
|
+
try {
|
|
116
|
+
writeTransferJob(transferRoot(), {
|
|
117
|
+
...job,
|
|
118
|
+
status: "error",
|
|
119
|
+
error:
|
|
120
|
+
job.status === "done" ? IMPORT_RESTART_FAILURE : IMPORT_START_FAILURE,
|
|
121
|
+
});
|
|
122
|
+
} catch {}
|
|
123
|
+
}
|
|
124
|
+
console.error("导入启动失败:", error.code || "请查看数据任务状态");
|
|
125
|
+
process.exitCode = 1;
|
|
126
|
+
} finally {
|
|
127
|
+
if (claimed) clearStarting();
|
|
128
|
+
}
|
package/scripts/launch.js
CHANGED
|
@@ -1,94 +1,101 @@
|
|
|
1
|
-
import { openSync, closeSync, mkdirSync } from "node:fs";
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { prepareRuntime } from "./runtime.js";
|
|
5
|
-
import { running, serviceUrl } from "./service.js";
|
|
6
|
-
import { openBrowser } from "./browser.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
env:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
child.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
import { openSync, closeSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { prepareRuntime } from "./runtime.js";
|
|
5
|
+
import { running, serviceUrl } from "./service.js";
|
|
6
|
+
import { openBrowser } from "./browser.js";
|
|
7
|
+
import { VERSION } from "../server/version.js";
|
|
8
|
+
import {
|
|
9
|
+
claimLaunch,
|
|
10
|
+
clearStarting,
|
|
11
|
+
starting,
|
|
12
|
+
} from "../server/startup-lock.js";
|
|
13
|
+
import {
|
|
14
|
+
resolveProxyEnvironment,
|
|
15
|
+
supportsNodeEnvironmentProxy,
|
|
16
|
+
} from "./proxy-config.js";
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const paths = prepareRuntime();
|
|
20
|
+
const proxy = await resolveProxyEnvironment(process.env);
|
|
21
|
+
const base = serviceUrl();
|
|
22
|
+
const existing = await running({ base });
|
|
23
|
+
if (existing && existing.version && existing.version !== VERSION) {
|
|
24
|
+
console.log(`正在将运行中的 LuckyTri 更新到 ${VERSION}…`);
|
|
25
|
+
await import("./stop.js");
|
|
26
|
+
if (process.exitCode) throw Error("旧服务未停止,请稍后重试");
|
|
27
|
+
}
|
|
28
|
+
if (proxy.enabled && !supportsNodeEnvironmentProxy())
|
|
29
|
+
throw new Error(
|
|
30
|
+
"系统代理转发需要 Node.js 24.5 或更高版本。请升级 Node.js 后重试。",
|
|
31
|
+
);
|
|
32
|
+
if (!(await running({ base }))) {
|
|
33
|
+
let childExited = false;
|
|
34
|
+
const fresh = claimLaunch();
|
|
35
|
+
if (!fresh) console.log("上一次启动还在进行,正在等它就绪,不会再开一份。");
|
|
36
|
+
else {
|
|
37
|
+
console.log("正在启动 LuckyTri…");
|
|
38
|
+
console.log("窗口会停在这里直到服务就绪,请不要关闭。");
|
|
39
|
+
try {
|
|
40
|
+
await import("express").catch(() => {
|
|
41
|
+
throw new Error("缺少依赖,请先在项目目录执行 npm install。");
|
|
42
|
+
});
|
|
43
|
+
mkdirSync(paths.data, { recursive: true, mode: 0o700 });
|
|
44
|
+
const log = openSync(paths.log, "a", 0o600);
|
|
45
|
+
const args = [
|
|
46
|
+
...(proxy.enabled ? ["--use-env-proxy"] : []),
|
|
47
|
+
join(paths.package, "server", "index.js"),
|
|
48
|
+
];
|
|
49
|
+
const child = spawn(process.execPath, args, {
|
|
50
|
+
cwd: paths.home,
|
|
51
|
+
detached: true,
|
|
52
|
+
windowsHide: true,
|
|
53
|
+
env: {
|
|
54
|
+
...process.env,
|
|
55
|
+
...proxy.env,
|
|
56
|
+
LUCKYTRI_LAUNCH_PID: String(process.pid),
|
|
57
|
+
},
|
|
58
|
+
stdio: ["ignore", log, log],
|
|
59
|
+
});
|
|
60
|
+
closeSync(log);
|
|
61
|
+
child.once("exit", () => {
|
|
62
|
+
childExited = true;
|
|
63
|
+
});
|
|
64
|
+
await new Promise((resolve, reject) => {
|
|
65
|
+
child.once("spawn", resolve);
|
|
66
|
+
child.once("error", reject);
|
|
67
|
+
});
|
|
68
|
+
child.unref();
|
|
69
|
+
} catch (error) {
|
|
70
|
+
clearStarting();
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
let ready = false;
|
|
75
|
+
for (let attempt = 0; attempt < 2000; attempt++) {
|
|
76
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
77
|
+
if (attempt > 0 && attempt % 16 === 0) console.log("仍在启动…");
|
|
78
|
+
if (await running({ base, lenient: true })) {
|
|
79
|
+
ready = true;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (fresh && childExited)
|
|
83
|
+
throw new Error(`启动进程已退出,请查看 ${paths.log}`);
|
|
84
|
+
if (!fresh && !starting())
|
|
85
|
+
throw new Error("上一次启动已中断,请再试一次。");
|
|
86
|
+
}
|
|
87
|
+
if (!ready) throw new Error(`启动未完成,请查看 ${paths.log}`);
|
|
88
|
+
console.log(
|
|
89
|
+
proxy.enabled
|
|
90
|
+
? "LuckyTri 已在后台启动,外部 API 走系统代理。"
|
|
91
|
+
: "LuckyTri 已在后台启动。",
|
|
92
|
+
);
|
|
93
|
+
} else console.log("LuckyTri 已经运行,直接打开管理台。");
|
|
94
|
+
console.log(base);
|
|
95
|
+
if (!process.argv.includes("--no-browser")) {
|
|
96
|
+
await openBrowser(base).catch((error) => console.warn(error.message));
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error(error.message);
|
|
100
|
+
process.exitCode = 1;
|
|
101
|
+
}
|