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/server/index.js
CHANGED
|
@@ -1,102 +1,151 @@
|
|
|
1
|
-
import { claimServer, clearStarting } from "./startup-lock.js";
|
|
2
|
-
import { createStore } from "./storage/store.js";
|
|
3
|
-
import { ChatSystem } from "./core/orchestrator.js";
|
|
4
|
-
import { Life } from "./mind/life/index.js";
|
|
5
|
-
import { createApp } from "./app.js";
|
|
6
|
-
import { createChannelHub, createChannels } from "./channels/index.js";
|
|
7
|
-
import { createBackupScheduler } from "./storage/backup-scheduler.js";
|
|
8
|
-
import { createBackupCleanup } from "./storage/backup-cleanup.js";
|
|
9
|
-
import { PluginHost } from "./plugins/host.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
process.
|
|
102
|
-
|
|
1
|
+
import { claimServer, clearStarting } from "./startup-lock.js";
|
|
2
|
+
import { createStore } from "./storage/store.js";
|
|
3
|
+
import { ChatSystem } from "./core/orchestrator.js";
|
|
4
|
+
import { Life } from "./mind/life/index.js";
|
|
5
|
+
import { createApp } from "./app.js";
|
|
6
|
+
import { createChannelHub, createChannels } from "./channels/index.js";
|
|
7
|
+
import { createBackupScheduler } from "./storage/backup-scheduler.js";
|
|
8
|
+
import { createBackupCleanup } from "./storage/backup-cleanup.js";
|
|
9
|
+
import { PluginHost } from "./plugins/host.js";
|
|
10
|
+
import { createManagementAuth } from "./auth.js";
|
|
11
|
+
import { createDataTransfer } from "./storage/data-transfer.js";
|
|
12
|
+
import { runtimePaths } from "./paths.js";
|
|
13
|
+
import { spawn } from "node:child_process";
|
|
14
|
+
import { openSync, closeSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
|
|
17
|
+
claimServer();
|
|
18
|
+
process.on("exit", clearStarting);
|
|
19
|
+
const store = createStore();
|
|
20
|
+
const auth = createManagementAuth(store);
|
|
21
|
+
// One channel at a time connects her to QQ; the rest of the system only ever
|
|
22
|
+
// talks to the hub.
|
|
23
|
+
const channel = createChannelHub(
|
|
24
|
+
store,
|
|
25
|
+
createChannels(store, {
|
|
26
|
+
onebot: { verifyPassword: auth.verifyConnectionPassword },
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
29
|
+
const chatSystem = new ChatSystem(store, channel.send, {
|
|
30
|
+
fetchQuoted: (message) => channel.fetchQuoted(message),
|
|
31
|
+
fetchImage: (file, sessionId) => channel.fetchImage(file, sessionId),
|
|
32
|
+
});
|
|
33
|
+
const life = new Life(chatSystem, {
|
|
34
|
+
online: () => channel.online(),
|
|
35
|
+
canReach: (session) => channel.canReach(session),
|
|
36
|
+
});
|
|
37
|
+
life.start();
|
|
38
|
+
const plugins = new PluginHost({ store, chat: chatSystem, channel, life });
|
|
39
|
+
chatSystem.mind.embody(() => plugins.aware());
|
|
40
|
+
plugins
|
|
41
|
+
.start()
|
|
42
|
+
.catch((error) => console.error(`插件没有启动:${error.message}`));
|
|
43
|
+
const backups = createBackupScheduler();
|
|
44
|
+
const cleanup = createBackupCleanup({ store, backup: backups });
|
|
45
|
+
const transfer = createDataTransfer({
|
|
46
|
+
backup: backups,
|
|
47
|
+
cleanup,
|
|
48
|
+
async onApply(id) {
|
|
49
|
+
const paths = runtimePaths();
|
|
50
|
+
const log = openSync(paths.log, "a", 0o600);
|
|
51
|
+
try {
|
|
52
|
+
const child = spawn(
|
|
53
|
+
process.execPath,
|
|
54
|
+
[
|
|
55
|
+
...(process.execArgv.includes("--use-env-proxy")
|
|
56
|
+
? ["--use-env-proxy"]
|
|
57
|
+
: []),
|
|
58
|
+
join(paths.package, "scripts", "import-data.js"),
|
|
59
|
+
id,
|
|
60
|
+
String(process.pid),
|
|
61
|
+
],
|
|
62
|
+
{
|
|
63
|
+
cwd: paths.home,
|
|
64
|
+
detached: true,
|
|
65
|
+
windowsHide: true,
|
|
66
|
+
env: process.env,
|
|
67
|
+
stdio: ["ignore", log, log],
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
child.unref();
|
|
71
|
+
await new Promise((resolve, reject) => {
|
|
72
|
+
child.once("spawn", resolve);
|
|
73
|
+
child.once("error", reject);
|
|
74
|
+
});
|
|
75
|
+
setTimeout(shutdown, 300);
|
|
76
|
+
return child.pid;
|
|
77
|
+
} finally {
|
|
78
|
+
closeSync(log);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
const host = process.env.HOST || "127.0.0.1";
|
|
83
|
+
if (!["127.0.0.1", "localhost", "::1"].includes(host) && !auth.configured())
|
|
84
|
+
throw new Error("绑定外网地址前请先在本机设置管理密码");
|
|
85
|
+
|
|
86
|
+
let stopping = false;
|
|
87
|
+
function shutdown() {
|
|
88
|
+
if (stopping) return;
|
|
89
|
+
stopping = true;
|
|
90
|
+
backups.stop();
|
|
91
|
+
plugins.close();
|
|
92
|
+
life.close();
|
|
93
|
+
chatSystem.close();
|
|
94
|
+
channel.close();
|
|
95
|
+
store.revision++;
|
|
96
|
+
clearInterval(maintenance);
|
|
97
|
+
const finish = () => {
|
|
98
|
+
try {
|
|
99
|
+
store.db.close();
|
|
100
|
+
} finally {
|
|
101
|
+
process.exit(0);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
server.close(finish);
|
|
105
|
+
setTimeout(finish, 3000).unref();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const app = createApp({
|
|
109
|
+
auth,
|
|
110
|
+
store,
|
|
111
|
+
chatSystem,
|
|
112
|
+
life,
|
|
113
|
+
plugins,
|
|
114
|
+
runtime: {
|
|
115
|
+
connection: () => channel.status(),
|
|
116
|
+
syncChannel: () => channel.sync(),
|
|
117
|
+
backup: () => backups.status(),
|
|
118
|
+
cleanup,
|
|
119
|
+
transfer,
|
|
120
|
+
shutdown,
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
const server = app.listen(Number(process.env.PORT || 3210), host, () => {
|
|
124
|
+
console.log(`LuckyTri 管理台 http://${host}:${process.env.PORT || 3210}`);
|
|
125
|
+
});
|
|
126
|
+
channel.attach(server, chatSystem);
|
|
127
|
+
function runMaintenance() {
|
|
128
|
+
store.maintenance();
|
|
129
|
+
try {
|
|
130
|
+
chatSystem.maintain();
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.error(`后台维护失败:${error.message}`);
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
if (!cleanup.running && !transfer.busy) backups.tick();
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error(`自动备份调度失败:${error.message}`);
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
if (!transfer.busy) cleanup.tick();
|
|
141
|
+
transfer.info();
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error(`定时备份整理调度失败:${error.message}`);
|
|
144
|
+
}
|
|
145
|
+
channel.refreshDirectory().catch(() => {});
|
|
146
|
+
}
|
|
147
|
+
runMaintenance();
|
|
148
|
+
const maintenance = setInterval(runMaintenance, 60000);
|
|
149
|
+
maintenance.unref();
|
|
150
|
+
process.on("SIGTERM", shutdown);
|
|
151
|
+
process.on("SIGINT", shutdown);
|