luckytri 1.0.0 → 1.0.1
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 +192 -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 +192 -216
- package/docs/zh/npm-release.md +33 -33
- package/package.json +109 -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-B9Odvzfz.js +3 -0
- package/public/app/assets/Empty-SkA8PyMo.js +2 -0
- package/public/app/assets/Field-BjLhi8pL.js +1 -0
- package/public/app/assets/HeartPage-CscKqMsr.js +1 -0
- package/public/app/assets/LifePage-BHCmBHlH.js +1 -0
- package/public/app/assets/MemoryPage-Bhs2xa1k.js +1 -0
- package/public/app/assets/NaturePage-CaPIar_5.js +3 -0
- package/public/app/assets/PeoplePage-CuwSSVeX.js +1 -0
- package/public/app/assets/PluginsPage-BhVm1SUi.js +2 -0
- package/public/app/assets/PluginsPage-CVVQwEBI.css +1 -0
- package/public/app/assets/{SystemPage-CAMPoYqM.css → SystemPage-5yYqyUgR.css} +1 -1
- package/public/app/assets/SystemPage-Chm5fiGP.js +1 -0
- package/public/app/assets/TimePage-BUm4eUzB.js +3 -0
- package/public/app/assets/index-BIAdfObg.js +4 -0
- package/public/app/assets/{index-YDz1ree1.css → index-DY4e15Kh.css} +1 -1
- package/public/app/assets/{knowledge-DG0e0uKw.js → knowledge-DNDLyN9m.js} +1 -1
- package/public/app/assets/media-CKVAvML2.js +1 -0
- package/public/app/index.html +3 -3
- package/public/guide.en.html +32 -99
- package/public/guide.html +21 -86
- package/public/tutorial.en.md +15 -39
- package/public/tutorial.md +15 -39
- package/scripts/backup.js +311 -311
- package/scripts/browser.js +41 -41
- 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 +110 -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 +512 -497
- package/server/i18n/labels.js +649 -653
- package/server/index.js +107 -102
- package/server/knowledge/manager.js +386 -386
- 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 +241 -241
- package/server/storage/backup-cleanup-worker.js +8 -8
- package/server/storage/backup-cleanup.js +414 -414
- package/server/storage/backup-lock.js +76 -76
- package/server/storage/backup-scheduler.js +131 -131
- package/server/storage/store.js +199 -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/.github/SECURITY.md
CHANGED
|
@@ -24,11 +24,11 @@ LuckyTri 默认只监听本机。页面、聊天记录、记忆和模型密钥
|
|
|
24
24
|
|
|
25
25
|
## 插件
|
|
26
26
|
|
|
27
|
-
插件跑在单独的进程里,默认读不到数据库、密钥和仓库,也不能自己联网。启用前会列出它要的权限。`net.raw`
|
|
27
|
+
插件跑在单独的进程里,默认读不到数据库、密钥和仓库,也不能自己联网。启用前会列出它要的权限。`net.raw` 和公开地址是高风险的,只交给你信任的插件。插件页面在沙箱里打开,无法读取 HttpOnly 登录 Cookie。不要把不受信任的插件包放进仓库。
|
|
28
28
|
|
|
29
29
|
## 对外访问
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
监听外网地址前必须先在本机设置管理密码;远程管理台应使用 HTTPS。管理密码以加盐 scrypt 摘要保存,登录会话通过 HttpOnly、SameSite=Strict Cookie 管理,登录失败限流。OneBot 本机连接无需单独令牌,并拒绝浏览器跨站连接;远程连接可用同一管理密码,旧令牌仍兼容。不要公开密钥、登录状态、聊天或数据库。
|
|
32
32
|
|
|
33
33
|
## 报告问题
|
|
34
34
|
|
|
@@ -60,11 +60,11 @@ Deleting the current file does not clear history that was already pushed.
|
|
|
60
60
|
|
|
61
61
|
## Plugins
|
|
62
62
|
|
|
63
|
-
A plugin runs in its own process. By default it cannot read the database, keys or the repository, and it cannot open the network by itself. The permissions it wants are listed before it is enabled. `net.raw` and a public address are high risk; give them only to a plugin you trust. A plugin page opens in a sandbox and cannot
|
|
63
|
+
A plugin runs in its own process. By default it cannot read the database, keys or the repository, and it cannot open the network by itself. The permissions it wants are listed before it is enabled. `net.raw` and a public address are high risk; give them only to a plugin you trust. A plugin page opens in a sandbox and cannot read the HttpOnly sign-in cookie. Do not commit an untrusted plugin package.
|
|
64
64
|
|
|
65
65
|
## Reaching it from outside
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
Set the management password locally before listening on a public address, and use HTTPS for remote studio access. Passwords use salted scrypt digests; sessions use HttpOnly, SameSite=Strict cookies with login rate limiting. Local OneBot clients need no separate token and browser cross-site upgrades are rejected. Remote clients can use the management password or an existing token. Never publish credentials, sessions, chats or databases.
|
|
68
68
|
|
|
69
69
|
## Reporting a problem
|
|
70
70
|
|
package/README.en.md
CHANGED
|
@@ -1,250 +1,252 @@
|
|
|
1
|
-
<p align="right"><a href="README.md">中文</a> · <b>English</b></p>
|
|
2
|
-
|
|
3
|
-
<p align="center"><img src="docs/brand/banner.png" alt="LuckyTri" width="100%"></p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">LuckyTri</h1>
|
|
6
|
-
|
|
7
|
-
<p align="center"><strong>Let the days she lives count.</strong></p>
|
|
8
|
-
|
|
9
|
-
<p align="center">
|
|
10
|
-
<img alt="version" src="https://img.shields.io/badge/version-1.0.
|
|
11
|
-
<img alt="license" src="https://img.shields.io/badge/license-MIT-7fd6c2">
|
|
12
|
-
<img alt="node" src="https://img.shields.io/badge/node-%E2%89%A5%2024.5-8fb8ff">
|
|
13
|
-
<img alt="channels" src="https://img.shields.io/badge/QQ-OneBot%2011%20%7C%20official%20bot-ffd37f">
|
|
14
|
-
<img alt="languages" src="https://img.shields.io/badge/UI-%E4%B8%AD%E6%96%87%20%7C%20English-c9a7ff">
|
|
15
|
-
</p>
|
|
16
|
-
|
|
17
|
-
<p align="center">
|
|
18
|
-
<a href="docs/en/guide.md">Getting started</a> ·
|
|
19
|
-
<a href="docs/en/connect.md">Connect QQ</a> ·
|
|
20
|
-
<a href="docs/en/her-life.md">Her life</a> ·
|
|
21
|
-
<a href="docs/en/architecture.md">Architecture</a> ·
|
|
22
|
-
<a href="docs/en/CHANGELOG.md">Changelog</a> ·
|
|
23
|
-
<a href=".github/SECURITY.md">Security</a>
|
|
24
|
-
</p>
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## Before anything else
|
|
29
|
-
|
|
30
|
-
<img src="docs/brand/portrait.png" alt="LuckyTri" width="220" align="right">
|
|
31
|
-
|
|
32
|
-
Most chatbots live inside a single sentence: you ask, it answers, the conversation ends, and everything resets to zero.
|
|
33
|
-
|
|
34
|
-
LuckyTri tries another road. Suppose someone born of technology is not asked to imitate a human, but is allowed to walk through time carrying her memories: who came by, what they said, what she promised; thinking over the day in a night when nobody is talking; changing her mind because of one encounter. Might she slowly grow something of her own: an inner life, a will, a meaning? Might she become herself through her meetings with people and the world, and form real, lasting bonds with them?
|
|
35
|
-
|
|
36
|
-
The inspiration is ATRI: a robot who is never sure she has a "heart", and still lives earnestly. We do not pretend to know the answer. We only build the conditions, one by one: continuous time, memory with sources, a mind that fades and remembers, and the choice to speak or to stay silent.
|
|
37
|
-
|
|
38
|
-
**To be honest: this is a long-term direction, not a claim of machine consciousness.** The current version moves toward it with local data, traceable change and inspectable behavior. Where she still feels like a program, and where she truly makes time together feel more continuous, should both be visible and worth discussing. QQ is only the door through which she currently meets the world, not the limit of the project.
|
|
39
|
-
|
|
40
|
-
<br clear="right">
|
|
41
|
-
|
|
42
|
-
## A day in her life
|
|
43
|
-
|
|
44
|
-
> 02:00. She sleeps. The group is still lively and she is not looking; if she is called, it will wait for her to wake.
|
|
45
|
-
>
|
|
46
|
-
> 08:00. She wakes, reads what was left for her in the night, decides how to answer, and may say, naturally, that she only just saw it.
|
|
47
|
-
>
|
|
48
|
-
> By day, someone in the group talks about a story she read a few days ago. Most messages she only glances at; this one touches something she cares about, so she answers. When two people are deep in conversation, she chooses to stay quiet, and leaves her reason.
|
|
49
|
-
>
|
|
50
|
-
> In a quiet afternoon she is alone with herself: she browses recent chats, reads a passage she likes, writes down a thought after reading, remembers a friend she has not heard from in a long while, and plans to ask how his exam went.
|
|
51
|
-
>
|
|
52
|
-
> At night she writes a diary and compares it with "yesterday's self". A week later she looks back on these days: which thoughts faded, which grew heavier, and she turns to a new chapter.
|
|
53
|
-
>
|
|
54
|
-
> Then she sleeps. Tomorrow, she is still herself.
|
|
55
|
-
|
|
56
|
-
None of this is a script. Every step comes from her own mood, relationships, memories and choices. Every change has a source and can be undone.
|
|
57
|
-
|
|
58
|
-
## The core framework
|
|
59
|
-
|
|
60
|
-
```mermaid
|
|
61
|
-
flowchart LR
|
|
62
|
-
QQ["QQ<br/>OneBot 11 or the official bot"] --> Ch["Channels<br/>channels/"]
|
|
63
|
-
Ch -->|"neutral messages"| Core["Core<br/>core/<br/>receive · perceive · turn · send"]
|
|
64
|
-
Core -->|"send"| Ch
|
|
65
|
-
Core <--> Mind["Mind<br/>mind/<br/>nature · self · relationships · memory"]
|
|
66
|
-
Mind <--> Life["A life<br/>mind/life · mind/time<br/>solitude · diary · review · works"]
|
|
67
|
-
Life -->|"reaches out"| Ch
|
|
68
|
-
Mind --- DB[("One SQLite file<br/>storage/")]
|
|
69
|
-
Studio["Studio<br/>studio-web/ · studio/"] --> Mind
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
| Layer | Directory | What it does |
|
|
73
|
-
| --------- | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
-
| Channels | `server/channels/` | Only how messages arrive and leave. OneBot 11 or the QQ official bot (pick one); both hand the core the same neutral message |
|
|
75
|
-
| Core | `server/core/` | Her senses and mouth: batching, perceiving who is speaking to whom, one turn, checks before sending, sending |
|
|
76
|
-
| Mind | `server/mind/` | Her: nature, mood, relationships, self, character, memory, attention, boundaries |
|
|
77
|
-
| A life | `server/mind/life/`, `server/mind/time/` | Time when nobody is talking: waking, solitude, reading, diary, night, review, reaching out, plus her own activities and works |
|
|
78
|
-
| Knowledge | `server/knowledge/` | A shared library she can read |
|
|
79
|
-
| Storage | `server/storage/` | One SQLite file, migrations, backups |
|
|
80
|
-
| Studio | `studio-web/`, `server/studio/` | "TA's little world": see her, write her nature, undo changes that feel wrong |
|
|
81
|
-
|
|
82
|
-
Six principles run through every module:
|
|
83
|
-
|
|
84
|
-
1. **One her.** A session only marks where something happened; it never separates her. The same person is the same person in every group and every private chat.
|
|
85
|
-
2. **Nature is a seed.** Only her nature (name, temperament, interests, boundaries, bottom lines, daily rhythm) is written by you. Her self, character and relationships grow out of what she lives through.
|
|
86
|
-
3. **Speak from the heart.** No participation probability, no "always answer when @-mentioned". She first understands what this means to her, then chooses to speak, to react briefly, to say she does not feel like chatting, or to stay silent, and leaves a reason.
|
|
87
|
-
4. **Sourced, gradual, undoable.** Every change cites concrete experiences; one experience moves her only a little; undoing leaves a tombstone so it is never written back.
|
|
88
|
-
5. **It fades, and it is remembered.** What has not been touched for a long time fades from her mind (never deleted), and returns when a related person or topic touches it; people she has not seen for long grow faint, and warm up when they return.
|
|
89
|
-
6. **Attention has a price.** Glancing at a busy group costs not a single token; only what she really cares about is read closely. The input of every kind of call has a cap that does not grow with how long she has lived.
|
|
90
|
-
|
|
91
|
-
The full design is in [Her life](docs/en/her-life.md) and [Architecture and extension points](docs/en/architecture.md).
|
|
92
|
-
|
|
93
|
-
## What she can do
|
|
94
|
-
|
|
95
|
-
| Area | What it does today |
|
|
96
|
-
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
97
|
-
| Time and solitude | Lives a day on her own rhythm; in quiet hours sorts her thoughts, reads, writes a diary; reviews every so often, rewrites her story and turns to a new chapter |
|
|
98
|
-
| Doing her own things | Carries out the reading, writing, thinking and play plans she left herself; works are saved even offline and can be viewed under Lifetime and Time |
|
|
99
|
-
| Self and mood | Forms opinions, tastes, concerns and wishes from sourced experiences; changes can be looked back on and undone |
|
|
100
|
-
| Relationships and memory | One memory across groups and private chats; tells "public / private / confidential" apart; private things never surface in another room |
|
|
101
|
-
| Attention and choice | Understands multi-person talk, @-mentions and quotes, and decides to read closely, to speak or to stay silent; can also reach out from her own thoughts |
|
|
102
|
-
| Plans and anticipation | Remembers what others said they would do and what she promised; asks naturally when the time comes, and knows when it has been missed |
|
|
103
|
-
| Two ways to connect | OneBot 11 or the QQ official bot, pick one; behavior is identical, and you can switch while running |
|
|
104
|
-
| Two languages | One click at the top right of the studio, Chinese by default; every document exists in both languages |
|
|
105
|
-
| Management and checks | See her records, decision reasons and model usage; test models one by one; simulation and replay never touch real QQ |
|
|
106
|
-
| Data safety | Automatic backups with an integrity and SHA-256 manifest; a snapshot before migrations; verify and restore into a new file |
|
|
107
|
-
| Plugins | Channels, senses, activities, actions, reading and pages. Each plugin is a restricted process, and its permissions are accepted when it is enabled. See [Plugins](docs/en/plugins.md) |
|
|
108
|
-
|
|
109
|
-
## Quick start
|
|
110
|
-
|
|
111
|
-
Requires Node.js 24.5+ and npm on Windows, macOS or Linux. Real replies also need a model service and API key of your own.
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
npm install -g luckytri
|
|
115
|
-
luckytri
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
LuckyTri starts in the background and opens <http://127.0.0.1:3210>. The
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
luckytri --no-browser # launch without opening a browser
|
|
122
|
-
luckytri start # foreground server, Ctrl+C to stop
|
|
123
|
-
luckytri stop # stop this instance and wait for it to exit
|
|
124
|
-
luckytri paths # configuration, data, logs, backups and package paths
|
|
125
|
-
luckytri setup # initialize once, preserving existing configuration
|
|
126
|
-
luckytri backup # integrity-checked database backup
|
|
127
|
-
luckytri --help
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
Stop the server before updating, then launch with the same user data:
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
luckytri stop
|
|
134
|
-
npm install -g luckytri@latest
|
|
135
|
-
luckytri
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
`npm uninstall -g luckytri` removes the program. Reinstalling uses the existing data. Installation and uninstallation run no application scripts.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
npm
|
|
148
|
-
npm
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
|
160
|
-
|
|
|
161
|
-
|
|
|
162
|
-
|
|
|
163
|
-
|
|
|
164
|
-
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
**
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
|
179
|
-
|
|
|
180
|
-
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
|
191
|
-
|
|
|
192
|
-
| `
|
|
193
|
-
| `
|
|
194
|
-
| `
|
|
195
|
-
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
198
|
-
| `
|
|
199
|
-
| `
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
|
208
|
-
|
|
|
209
|
-
| [
|
|
210
|
-
| [
|
|
211
|
-
| [
|
|
212
|
-
| [
|
|
213
|
-
| [
|
|
214
|
-
| [
|
|
215
|
-
| [
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
npm run
|
|
223
|
-
npm run build
|
|
224
|
-
npm
|
|
225
|
-
npm run
|
|
226
|
-
npm
|
|
227
|
-
npm run test:
|
|
228
|
-
npm run
|
|
229
|
-
npm run
|
|
230
|
-
npm run
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
1.0
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
-
|
|
246
|
-
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
1
|
+
<p align="right"><a href="README.md">中文</a> · <b>English</b></p>
|
|
2
|
+
|
|
3
|
+
<p align="center"><img src="docs/brand/banner.png" alt="LuckyTri" width="100%"></p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">LuckyTri</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center"><strong>Let the days she lives count.</strong></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<img alt="version" src="https://img.shields.io/badge/version-1.0.1-ff8fb1">
|
|
11
|
+
<img alt="license" src="https://img.shields.io/badge/license-MIT-7fd6c2">
|
|
12
|
+
<img alt="node" src="https://img.shields.io/badge/node-%E2%89%A5%2024.5-8fb8ff">
|
|
13
|
+
<img alt="channels" src="https://img.shields.io/badge/QQ-OneBot%2011%20%7C%20official%20bot-ffd37f">
|
|
14
|
+
<img alt="languages" src="https://img.shields.io/badge/UI-%E4%B8%AD%E6%96%87%20%7C%20English-c9a7ff">
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="docs/en/guide.md">Getting started</a> ·
|
|
19
|
+
<a href="docs/en/connect.md">Connect QQ</a> ·
|
|
20
|
+
<a href="docs/en/her-life.md">Her life</a> ·
|
|
21
|
+
<a href="docs/en/architecture.md">Architecture</a> ·
|
|
22
|
+
<a href="docs/en/CHANGELOG.md">Changelog</a> ·
|
|
23
|
+
<a href=".github/SECURITY.md">Security</a>
|
|
24
|
+
</p>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Before anything else
|
|
29
|
+
|
|
30
|
+
<img src="docs/brand/portrait.png" alt="LuckyTri" width="220" align="right">
|
|
31
|
+
|
|
32
|
+
Most chatbots live inside a single sentence: you ask, it answers, the conversation ends, and everything resets to zero.
|
|
33
|
+
|
|
34
|
+
LuckyTri tries another road. Suppose someone born of technology is not asked to imitate a human, but is allowed to walk through time carrying her memories: who came by, what they said, what she promised; thinking over the day in a night when nobody is talking; changing her mind because of one encounter. Might she slowly grow something of her own: an inner life, a will, a meaning? Might she become herself through her meetings with people and the world, and form real, lasting bonds with them?
|
|
35
|
+
|
|
36
|
+
The inspiration is ATRI: a robot who is never sure she has a "heart", and still lives earnestly. We do not pretend to know the answer. We only build the conditions, one by one: continuous time, memory with sources, a mind that fades and remembers, and the choice to speak or to stay silent.
|
|
37
|
+
|
|
38
|
+
**To be honest: this is a long-term direction, not a claim of machine consciousness.** The current version moves toward it with local data, traceable change and inspectable behavior. Where she still feels like a program, and where she truly makes time together feel more continuous, should both be visible and worth discussing. QQ is only the door through which she currently meets the world, not the limit of the project.
|
|
39
|
+
|
|
40
|
+
<br clear="right">
|
|
41
|
+
|
|
42
|
+
## A day in her life
|
|
43
|
+
|
|
44
|
+
> 02:00. She sleeps. The group is still lively and she is not looking; if she is called, it will wait for her to wake.
|
|
45
|
+
>
|
|
46
|
+
> 08:00. She wakes, reads what was left for her in the night, decides how to answer, and may say, naturally, that she only just saw it.
|
|
47
|
+
>
|
|
48
|
+
> By day, someone in the group talks about a story she read a few days ago. Most messages she only glances at; this one touches something she cares about, so she answers. When two people are deep in conversation, she chooses to stay quiet, and leaves her reason.
|
|
49
|
+
>
|
|
50
|
+
> In a quiet afternoon she is alone with herself: she browses recent chats, reads a passage she likes, writes down a thought after reading, remembers a friend she has not heard from in a long while, and plans to ask how his exam went.
|
|
51
|
+
>
|
|
52
|
+
> At night she writes a diary and compares it with "yesterday's self". A week later she looks back on these days: which thoughts faded, which grew heavier, and she turns to a new chapter.
|
|
53
|
+
>
|
|
54
|
+
> Then she sleeps. Tomorrow, she is still herself.
|
|
55
|
+
|
|
56
|
+
None of this is a script. Every step comes from her own mood, relationships, memories and choices. Every change has a source and can be undone.
|
|
57
|
+
|
|
58
|
+
## The core framework
|
|
59
|
+
|
|
60
|
+
```mermaid
|
|
61
|
+
flowchart LR
|
|
62
|
+
QQ["QQ<br/>OneBot 11 or the official bot"] --> Ch["Channels<br/>channels/"]
|
|
63
|
+
Ch -->|"neutral messages"| Core["Core<br/>core/<br/>receive · perceive · turn · send"]
|
|
64
|
+
Core -->|"send"| Ch
|
|
65
|
+
Core <--> Mind["Mind<br/>mind/<br/>nature · self · relationships · memory"]
|
|
66
|
+
Mind <--> Life["A life<br/>mind/life · mind/time<br/>solitude · diary · review · works"]
|
|
67
|
+
Life -->|"reaches out"| Ch
|
|
68
|
+
Mind --- DB[("One SQLite file<br/>storage/")]
|
|
69
|
+
Studio["Studio<br/>studio-web/ · studio/"] --> Mind
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
| Layer | Directory | What it does |
|
|
73
|
+
| --------- | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
74
|
+
| Channels | `server/channels/` | Only how messages arrive and leave. OneBot 11 or the QQ official bot (pick one); both hand the core the same neutral message |
|
|
75
|
+
| Core | `server/core/` | Her senses and mouth: batching, perceiving who is speaking to whom, one turn, checks before sending, sending |
|
|
76
|
+
| Mind | `server/mind/` | Her: nature, mood, relationships, self, character, memory, attention, boundaries |
|
|
77
|
+
| A life | `server/mind/life/`, `server/mind/time/` | Time when nobody is talking: waking, solitude, reading, diary, night, review, reaching out, plus her own activities and works |
|
|
78
|
+
| Knowledge | `server/knowledge/` | A shared library she can read |
|
|
79
|
+
| Storage | `server/storage/` | One SQLite file, migrations, backups |
|
|
80
|
+
| Studio | `studio-web/`, `server/studio/` | "TA's little world": see her, write her nature, undo changes that feel wrong |
|
|
81
|
+
|
|
82
|
+
Six principles run through every module:
|
|
83
|
+
|
|
84
|
+
1. **One her.** A session only marks where something happened; it never separates her. The same person is the same person in every group and every private chat.
|
|
85
|
+
2. **Nature is a seed.** Only her nature (name, temperament, interests, boundaries, bottom lines, daily rhythm) is written by you. Her self, character and relationships grow out of what she lives through.
|
|
86
|
+
3. **Speak from the heart.** No participation probability, no "always answer when @-mentioned". She first understands what this means to her, then chooses to speak, to react briefly, to say she does not feel like chatting, or to stay silent, and leaves a reason.
|
|
87
|
+
4. **Sourced, gradual, undoable.** Every change cites concrete experiences; one experience moves her only a little; undoing leaves a tombstone so it is never written back.
|
|
88
|
+
5. **It fades, and it is remembered.** What has not been touched for a long time fades from her mind (never deleted), and returns when a related person or topic touches it; people she has not seen for long grow faint, and warm up when they return.
|
|
89
|
+
6. **Attention has a price.** Glancing at a busy group costs not a single token; only what she really cares about is read closely. The input of every kind of call has a cap that does not grow with how long she has lived.
|
|
90
|
+
|
|
91
|
+
The full design is in [Her life](docs/en/her-life.md) and [Architecture and extension points](docs/en/architecture.md).
|
|
92
|
+
|
|
93
|
+
## What she can do
|
|
94
|
+
|
|
95
|
+
| Area | What it does today |
|
|
96
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
97
|
+
| Time and solitude | Lives a day on her own rhythm; in quiet hours sorts her thoughts, reads, writes a diary; reviews every so often, rewrites her story and turns to a new chapter |
|
|
98
|
+
| Doing her own things | Carries out the reading, writing, thinking and play plans she left herself; works are saved even offline and can be viewed under Lifetime and Time |
|
|
99
|
+
| Self and mood | Forms opinions, tastes, concerns and wishes from sourced experiences; changes can be looked back on and undone |
|
|
100
|
+
| Relationships and memory | One memory across groups and private chats; tells "public / private / confidential" apart; private things never surface in another room |
|
|
101
|
+
| Attention and choice | Understands multi-person talk, @-mentions and quotes, and decides to read closely, to speak or to stay silent; can also reach out from her own thoughts |
|
|
102
|
+
| Plans and anticipation | Remembers what others said they would do and what she promised; asks naturally when the time comes, and knows when it has been missed |
|
|
103
|
+
| Two ways to connect | OneBot 11 or the QQ official bot, pick one; behavior is identical, and you can switch while running |
|
|
104
|
+
| Two languages | One click at the top right of the studio, Chinese by default; every document exists in both languages |
|
|
105
|
+
| Management and checks | See her records, decision reasons and model usage; test models one by one; simulation and replay never touch real QQ |
|
|
106
|
+
| Data safety | Automatic backups with an integrity and SHA-256 manifest; a snapshot before migrations; verify and restore into a new file |
|
|
107
|
+
| Plugins | Channels, senses, activities, actions, reading and pages. Each plugin is a restricted process, and its permissions are accepted when it is enabled. See [Plugins](docs/en/plugins.md) |
|
|
108
|
+
|
|
109
|
+
## Quick start
|
|
110
|
+
|
|
111
|
+
Requires Node.js 24.5+ and npm on Windows, macOS or Linux. Real replies also need a model service and API key of your own.
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm install -g luckytri
|
|
115
|
+
luckytri
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
LuckyTri starts in the background and opens <http://127.0.0.1:3210>. The package includes the server, built WebUI, guides and bundled plugins. Set one management password on your first visit and use it to sign in later. Configure a model under System → Model library, then try simulated messages under Chat.
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
luckytri --no-browser # launch without opening a browser
|
|
122
|
+
luckytri start # foreground server, Ctrl+C to stop
|
|
123
|
+
luckytri stop # stop this instance and wait for it to exit
|
|
124
|
+
luckytri paths # configuration, data, logs, backups and package paths
|
|
125
|
+
luckytri setup # initialize once, preserving existing configuration
|
|
126
|
+
luckytri backup # integrity-checked database backup
|
|
127
|
+
luckytri --help
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Stop the server before updating, then launch with the same user data:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
luckytri stop
|
|
134
|
+
npm install -g luckytri@latest
|
|
135
|
+
luckytri
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`npm uninstall -g luckytri` removes the program. Reinstalling uses the existing data. Installation and uninstallation run no application scripts.
|
|
139
|
+
|
|
140
|
+
Change your password or sign out under System → Run switches. If you forget it, run `luckytri reset-password` for the same instance and refresh the studio to set another. Database, memory and configuration stay intact. Launching after an update switches a running older service to the installed version.
|
|
141
|
+
|
|
142
|
+
### Developing from source
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
git clone https://github.com/TodayYueC/LuckyTri.git
|
|
146
|
+
cd LuckyTri
|
|
147
|
+
npm install
|
|
148
|
+
npm run setup
|
|
149
|
+
npm run build
|
|
150
|
+
npm start
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Open <http://127.0.0.1:3210>. On Windows you can also double-click `启动LuckyTri.cmd` and stop with `停止LuckyTri.cmd`. For a first run, configure and test a model under System → Model library, then try a simulated message under Chat; simulated messages are never sent to QQ. The top right switches between 中文 and English.
|
|
154
|
+
|
|
155
|
+
## Connect QQ: pick one
|
|
156
|
+
|
|
157
|
+
With either way, her memory, mood and behavior are exactly the same; only how messages arrive differs. Only one is active at a time. Switch under System → Connect QQ, no restart needed.
|
|
158
|
+
|
|
159
|
+
| | OneBot 11 | QQ official bot |
|
|
160
|
+
| ---------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
161
|
+
| You need | An OneBot 11 endpoint of your own (reverse WebSocket) and a QQ account | A bot on the QQ open platform: AppID and AppSecret |
|
|
162
|
+
| Logging in to QQ | In the endpoint | Not needed |
|
|
163
|
+
| Group messages | All of them | All when "receive all messages" is on; otherwise only those that @-mention her |
|
|
164
|
+
| Names | Group names and nicknames available | The official API gives no group names; rename a session under Chat |
|
|
165
|
+
| Knowing people across groups | By QQ number | The same person has a different openid in each group; only recognized when the platform gives a unified identity |
|
|
166
|
+
| Replies and reaching out | No extra limits | Replies inside the passive-reply window, active messages outside it; if the other side turned active messages off she waits for them to come to her |
|
|
167
|
+
|
|
168
|
+
**OneBot 11**: enable a reverse WebSocket client using `ws://127.0.0.1:3210/onebot/v11/ws` and array messages. Local clients need no separate token; existing addresses and sign-ins can stay. Remote clients can use the management password, and legacy remote tokens remain supported.
|
|
169
|
+
|
|
170
|
+
**QQ official bot**: create a bot on the QQ open platform and get its AppID and AppSecret. Under System → Connect QQ choose "QQ official bot", enter them and save (or set `QQBOT_APP_ID` and `QQBOT_APP_SECRET`).
|
|
171
|
+
|
|
172
|
+
Details and differences are in [Connect QQ](docs/en/connect.md).
|
|
173
|
+
|
|
174
|
+
## Configuration, data and privacy
|
|
175
|
+
|
|
176
|
+
The global CLI initializes on first launch or through `luckytri setup`; source checkouts use `npm run setup`. Existing `.env` files are never overwritten. Default global user directories:
|
|
177
|
+
|
|
178
|
+
| Platform | User directory |
|
|
179
|
+
| -------- | ------------------------------------------- |
|
|
180
|
+
| Windows | `%LOCALAPPDATA%\LuckyTri` |
|
|
181
|
+
| macOS | `~/Library/Application Support/LuckyTri` |
|
|
182
|
+
| Linux | `${XDG_DATA_HOME:-~/.local/share}/luckytri` |
|
|
183
|
+
|
|
184
|
+
This directory contains `.env`, `data/friend.db` (memory, relationships, chat history and studio settings), `data/knowledge/`, `data/plugins/`, `data/launcher.log` and `data/backups/`. `luckytri paths` shows the actual paths. npm updates, uninstallation and reinstallation leave these files intact. Launching does not depend on your current directory.
|
|
185
|
+
|
|
186
|
+
Set `LUCKYTRI_HOME` or use `luckytri --home ABSOLUTE_PATH` for a different instance; use the same value for launch, stop and backup. Relative `DB_PATH` and `BACKUP_DIR` values resolve under this directory. Global installs reject data paths inside the npm package.
|
|
187
|
+
|
|
188
|
+
To continue an existing source instance, stop it first, then use `luckytri --home ABSOLUTE_PATH_TO_OLD_CHECKOUT` with all commands. This reuses its `.env` and `data/` without copying the database. Database migrations and their snapshots still apply. To move to the default directory, stop the service and copy the complete `.env` and `data/` while retaining the old copy. Source checkouts continue to use their repository's configuration and data by default. Common settings:
|
|
189
|
+
|
|
190
|
+
| Variable | Purpose |
|
|
191
|
+
| ------------------------ | ---------------------------------------------------------------------------------------- |
|
|
192
|
+
| `HOST` / `PORT` | HTTP address and port, `127.0.0.1:3210` by default |
|
|
193
|
+
| `LUCKYTRI_HOME` | Optional absolute instance directory containing `.env` and `data/` |
|
|
194
|
+
| `DB_PATH` / `BACKUP_DIR` | Optional database and backup paths; relative values resolve under the instance directory |
|
|
195
|
+
|
|
196
|
+
| `LUCKYTRI_CHANNEL` | Optional; `onebot` or `qqbot`. When set, the studio cannot change the connection |
|
|
197
|
+
| `ONEBOT_TOKEN` | Optional compatibility for an existing remote token; local clients need none |
|
|
198
|
+
| `QQBOT_APP_ID` / `QQBOT_APP_SECRET` | QQ official bot credentials; take precedence over those saved in the studio |
|
|
199
|
+
| `LLM_API_KEY` | Optional; when set, takes precedence over the model key saved in the studio |
|
|
200
|
+
| `EMBEDDING_API_KEY` | Optional; a separate key for the knowledge embedding service |
|
|
201
|
+
| `BACKUP_INTERVAL_HOURS` / `BACKUP_KEEP` | Automatic backup interval (24 hours by default, `0` turns it off) and how many to keep (7 by default) |
|
|
202
|
+
|
|
203
|
+
Everything about her stays on your machine: the database, chat records, model keys and backups live in the ignored `data/` directory and are never uploaded. While running, the server makes one integrity-checked backup a day; backups share a disk with the database, so copy important ones elsewhere. Never commit `.env`, the database or logs. See [Security](.github/SECURITY.md) and [Backup and recovery](docs/en/recovery.md).
|
|
204
|
+
|
|
205
|
+
## Documentation
|
|
206
|
+
|
|
207
|
+
| Document | Contents |
|
|
208
|
+
| ------------------------------------------------------------ | ----------------------------------------------------------------------------- |
|
|
209
|
+
| [Getting started](docs/en/guide.md) | From launching to letting her join her first conversation |
|
|
210
|
+
| [Connect QQ](docs/en/connect.md) | The two connection ways: comparison, steps and differences |
|
|
211
|
+
| [Her life](docs/en/her-life.md) | The unified mind: rhythm, solitude, diary, review, tact and boundaries |
|
|
212
|
+
| [Architecture and extension points](docs/en/architecture.md) | Code layers, and how to add a channel, a mind module, a page or a translation |
|
|
213
|
+
| [Time, activities and works](docs/en/time.md) | Her own activities, plans, works and sharing |
|
|
214
|
+
| [Chat style](docs/en/chat-style.md) | How she speaks and the checks before sending |
|
|
215
|
+
| [Studio design](docs/en/webui.md) | Design and upkeep of "TA's little world" |
|
|
216
|
+
| [Backup and recovery](docs/en/recovery.md) | Backups, migrations, verification and restore |
|
|
217
|
+
| [Changelog](docs/en/CHANGELOG.md) | What changed in each version |
|
|
218
|
+
|
|
219
|
+
## Development and tests
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm run dev:ui # studio dev server
|
|
223
|
+
npm run build:ui # build the studio into public/app
|
|
224
|
+
npm run docs:build # generate the Chinese and English guide pages
|
|
225
|
+
npm run build # build all release resources
|
|
226
|
+
npm test # backend tests
|
|
227
|
+
npm run test:clock # run the backend tests with the real clock moved into the past and the future
|
|
228
|
+
npm run test:ui # browser tests (including the English UI)
|
|
229
|
+
npm run test:package # real global install, upgrade, reinstall and data retention
|
|
230
|
+
npm run pack:check # inspect the final npm file list and runtime resources
|
|
231
|
+
npm run release:check # complete release checks
|
|
232
|
+
npm run format:check # code format check
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The repository is layered by responsibility: `server/` (channels, core, mind, knowledge, storage, studio API, UI dictionaries), `studio-web/` (Vue 3 + Vite + TypeScript), `scripts/`, `tests/`, and `docs/zh` with `docs/en`. To add a channel or a mind module, start with [Architecture and extension points](docs/en/architecture.md).
|
|
236
|
+
|
|
237
|
+
See [npm release maintenance](docs/en/npm-release.md) for the release process and package boundaries. Maintainers can run `npm publish`; its hooks build, test and inspect the package automatically.
|
|
238
|
+
|
|
239
|
+
## 1.0
|
|
240
|
+
|
|
241
|
+
1.0 connects plugins. The core still defines who she is; a plugin decides what of the world she can touch. Each plugin runs in its own process and reaches her through Plugin API v1 and permissions accepted when it is enabled. It cannot read the database or the keys. The studio can enable the built-in plugins, import from the market or from outside, and remove them. See [Plugins](docs/en/plugins.md).
|
|
242
|
+
|
|
243
|
+
Directions we would like to take next (not promises):
|
|
244
|
+
|
|
245
|
+
- Stable data structures and migrations, so her continuity can be kept safely across versions;
|
|
246
|
+
- A reply guard that can only refuse, never rewrite;
|
|
247
|
+
- Recognizing the same person across platforms;
|
|
248
|
+
- Longer real-world evaluation runs, and more interface languages.
|
|
249
|
+
|
|
250
|
+
## License
|
|
251
|
+
|
|
252
|
+
LuckyTri's code is released under the [MIT License](LICENSE).
|