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.
Files changed (139) hide show
  1. package/.github/SECURITY.md +4 -4
  2. package/README.en.md +252 -250
  3. package/README.md +252 -250
  4. package/bin/luckytri.js +5 -1
  5. package/docs/en/CHANGELOG.md +8 -0
  6. package/docs/en/connect.md +18 -18
  7. package/docs/en/guide.md +202 -216
  8. package/docs/en/npm-release.md +25 -25
  9. package/docs/zh/CHANGELOG.md +8 -0
  10. package/docs/zh/connect.md +17 -17
  11. package/docs/zh/guide.md +202 -216
  12. package/docs/zh/npm-release.md +33 -33
  13. package/package.json +110 -108
  14. package/plugins/sdk/index.d.ts +155 -155
  15. package/plugins/sdk/testing.js +58 -58
  16. package/plugins/weather/index.js +82 -82
  17. package/plugins/weather/luckytri-plugin.json +29 -29
  18. package/public/app/assets/ChatsPage-BhlJHseG.js +3 -0
  19. package/public/app/assets/Empty-DP6WMGHi.js +2 -0
  20. package/public/app/assets/Field-CtbdqaiB.js +1 -0
  21. package/public/app/assets/HeartPage-32BeTPn2.js +1 -0
  22. package/public/app/assets/LifePage-CxSm0XKI.js +1 -0
  23. package/public/app/assets/MemoryPage-BeKBcPCY.js +1 -0
  24. package/public/app/assets/NaturePage-NEPYl2HS.js +3 -0
  25. package/public/app/assets/PeoplePage-DxtpekwM.js +1 -0
  26. package/public/app/assets/PluginsPage-CVVQwEBI.css +1 -0
  27. package/public/app/assets/PluginsPage-DksEZbUU.js +2 -0
  28. package/public/app/assets/{SystemPage-CAMPoYqM.css → SystemPage-BkRu0Rvx.css} +1 -1
  29. package/public/app/assets/SystemPage-BvzJlHuY.js +1 -0
  30. package/public/app/assets/TimePage-7-awH5XL.js +3 -0
  31. package/public/app/assets/index-4rItIkD-.js +4 -0
  32. package/public/app/assets/{index-YDz1ree1.css → index-DY4e15Kh.css} +1 -1
  33. package/public/app/assets/{knowledge-DG0e0uKw.js → knowledge-C6_HvoyB.js} +1 -1
  34. package/public/app/assets/media-SMfTT-yc.js +1 -0
  35. package/public/app/index.html +3 -3
  36. package/public/guide.en.html +72 -99
  37. package/public/guide.html +44 -86
  38. package/public/tutorial.en.md +25 -39
  39. package/public/tutorial.md +25 -39
  40. package/scripts/backup.js +311 -311
  41. package/scripts/browser.js +41 -41
  42. package/scripts/import-data.js +128 -0
  43. package/scripts/launch.js +101 -94
  44. package/scripts/plugin.js +150 -150
  45. package/scripts/reset-password.js +22 -0
  46. package/scripts/runtime.js +25 -25
  47. package/scripts/service.js +56 -47
  48. package/scripts/setup.js +50 -50
  49. package/scripts/start-server.js +41 -41
  50. package/scripts/stop.js +36 -36
  51. package/server/app.js +112 -96
  52. package/server/auth.js +217 -0
  53. package/server/channels/contract.js +57 -57
  54. package/server/channels/hub.js +165 -165
  55. package/server/channels/index.js +28 -25
  56. package/server/channels/onebot/index.js +335 -336
  57. package/server/channels/onebot/token.js +22 -3
  58. package/server/core/capabilities.js +208 -208
  59. package/server/core/events.js +64 -60
  60. package/server/core/image-preprocessor.js +208 -208
  61. package/server/core/model-manager.js +1213 -1213
  62. package/server/core/net-guard.js +49 -49
  63. package/server/core/orchestrator.js +569 -569
  64. package/server/core/perceivers.js +91 -91
  65. package/server/core/persona-manager.js +243 -243
  66. package/server/core/repository.js +293 -293
  67. package/server/core/response-validator.js +508 -508
  68. package/server/core/turn-processor.js +630 -630
  69. package/server/core/turn.js +236 -236
  70. package/server/core/vision-manager.js +633 -633
  71. package/server/i18n/errors.js +548 -497
  72. package/server/i18n/labels.js +649 -653
  73. package/server/index.js +151 -102
  74. package/server/knowledge/manager.js +386 -386
  75. package/server/knowledge/schema.js +12 -8
  76. package/server/local-access.js +32 -0
  77. package/server/mind/anticipations.js +507 -507
  78. package/server/mind/api.js +703 -703
  79. package/server/mind/budget.js +152 -152
  80. package/server/mind/context-selection.js +61 -61
  81. package/server/mind/day-planner.js +324 -324
  82. package/server/mind/evidence.js +148 -148
  83. package/server/mind/index.js +445 -445
  84. package/server/mind/life/diary.js +786 -786
  85. package/server/mind/life/index.js +1049 -1049
  86. package/server/mind/observations.js +84 -84
  87. package/server/mind/own-day.js +324 -324
  88. package/server/mind/own-voice.js +318 -318
  89. package/server/mind/senses.js +53 -53
  90. package/server/mind/time/activity-clock.js +196 -196
  91. package/server/mind/time/availability.js +69 -69
  92. package/server/mind/time/commitment-review.js +198 -198
  93. package/server/mind/time/executor.js +512 -512
  94. package/server/mind/time/experiences.js +128 -128
  95. package/server/mind/time/games.js +562 -562
  96. package/server/mind/time/index.js +739 -739
  97. package/server/mind/time/intent.js +166 -166
  98. package/server/mind/time/kinds.js +171 -171
  99. package/server/mind/time/plugin-activity.js +207 -207
  100. package/server/mind/time/tasks.js +587 -587
  101. package/server/mind/util.js +110 -110
  102. package/server/mind/view.js +273 -273
  103. package/server/paths.js +102 -102
  104. package/server/plugins/api.js +204 -204
  105. package/server/plugins/host.js +967 -967
  106. package/server/plugins/install.js +295 -295
  107. package/server/plugins/manifest.js +201 -201
  108. package/server/plugins/permissions.js +42 -42
  109. package/server/plugins/runner/guard.mjs +36 -36
  110. package/server/plugins/runner/worker.mjs +250 -250
  111. package/server/plugins/schema.js +91 -91
  112. package/server/plugins/zip.js +112 -112
  113. package/server/startup-lock.js +118 -118
  114. package/server/storage/archive.js +242 -241
  115. package/server/storage/backup-cleanup-worker.js +8 -8
  116. package/server/storage/backup-cleanup.js +415 -414
  117. package/server/storage/backup-lock.js +76 -76
  118. package/server/storage/backup-scheduler.js +131 -131
  119. package/server/storage/data-package.js +298 -0
  120. package/server/storage/data-transfer-api.js +50 -0
  121. package/server/storage/data-transfer-worker.js +18 -0
  122. package/server/storage/data-transfer.js +415 -0
  123. package/server/storage/store.js +202 -199
  124. package/server/studio/readiness.js +181 -190
  125. package/server/studio/settings.js +236 -236
  126. package/public/app/assets/ChatsPage-C-FcRapR.js +0 -3
  127. package/public/app/assets/Empty-CpP5kQHH.js +0 -2
  128. package/public/app/assets/Field-D4gY-INU.js +0 -1
  129. package/public/app/assets/HeartPage-CPy_thQd.js +0 -1
  130. package/public/app/assets/LifePage-CxWvwmSf.js +0 -1
  131. package/public/app/assets/MemoryPage-DC4rhQ68.js +0 -1
  132. package/public/app/assets/NaturePage-IvYw04Zq.js +0 -3
  133. package/public/app/assets/PeoplePage-Cqefm9-q.js +0 -1
  134. package/public/app/assets/PluginsPage-DKSaKvXb.js +0 -2
  135. package/public/app/assets/PluginsPage-HyBe5D8w.css +0 -1
  136. package/public/app/assets/SystemPage-CJmtJkrK.js +0 -1
  137. package/public/app/assets/TimePage-Cw44inM4.js +0 -3
  138. package/public/app/assets/index-BheRW-1t.js +0 -4
  139. package/public/app/assets/media-BzPDBm7e.js +0 -1
@@ -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
- 监听 `127.0.0.1`、`localhost` 或 `::1` 以外的地址时,必须设置 `ADMIN_TOKEN`,否则进程拒绝启动。OneBot WebSocket 使用单独的 `ONEBOT_TOKEN`;QQ 官方机器人的 AppSecret 只会被保存,不会再回显给页面。不要在公开 Issue 里粘贴密钥、令牌、聊天记录或数据库文件。
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 see the admin token. Do not commit an untrusted plugin package.
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
- When listening on anything other than `127.0.0.1`, `localhost` or `::1`, `ADMIN_TOKEN` must be set, or the process refuses to start. The OneBot WebSocket uses its own `ONEBOT_TOKEN`; the QQ official bot's AppSecret is only stored and never shown back to the page. Do not paste keys, tokens, chat records or database files into public issues.
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.0-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 npm package includes the server, built WebUI, guides and bundled plugins. The first run creates a local `.env`. Use `luckytri paths` to find it, open it in a local editor, and enter `ADMIN_TOKEN` in the studio's token dialog. Then configure a model under System → Model library and 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
- ### Developing from source
141
-
142
- ```bash
143
- git clone https://github.com/TodayYueC/LuckyTri.git
144
- cd LuckyTri
145
- npm install
146
- npm run setup
147
- npm run build
148
- npm start
149
- ```
150
-
151
- 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.
152
-
153
- ## Connect QQ: pick one
154
-
155
- 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.
156
-
157
- | | OneBot 11 | QQ official bot |
158
- | ---------------------------- | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
159
- | 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 |
160
- | Logging in to QQ | In the endpoint | Not needed |
161
- | Group messages | All of them | All when "receive all messages" is on; otherwise only those that @-mention her |
162
- | Names | Group names and nicknames available | The official API gives no group names; rename a session under Chat |
163
- | 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 |
164
- | 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 |
165
-
166
- **OneBot 11**: set `ONEBOT_TOKEN` in `.env` (`npm run setup` generates one) and add a reverse WebSocket client in your endpoint: address `ws://127.0.0.1:3210/onebot/v11/ws`, the same token, message format "array".
167
-
168
- **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`).
169
-
170
- Details and differences are in [Connect QQ](docs/en/connect.md).
171
-
172
- ## Configuration, data and privacy
173
-
174
- 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:
175
-
176
- | Platform | User directory |
177
- | -------- | ------------------------------------------- |
178
- | Windows | `%LOCALAPPDATA%\LuckyTri` |
179
- | macOS | `~/Library/Application Support/LuckyTri` |
180
- | Linux | `${XDG_DATA_HOME:-~/.local/share}/luckytri` |
181
-
182
- 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.
183
-
184
- 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.
185
-
186
- 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:
187
-
188
- | Variable | Purpose |
189
- | --------------------------------------- | ----------------------------------------------------------------------------------------------------- |
190
- | `HOST` / `PORT` | HTTP address and port, `127.0.0.1:3210` by default |
191
- | `LUCKYTRI_HOME` | Optional absolute instance directory containing `.env` and `data/` |
192
- | `DB_PATH` / `BACKUP_DIR` | Optional database and backup paths; relative values resolve under the instance directory |
193
- | `ADMIN_TOKEN` | Access token for the studio and the HTTP API; required when listening on a non-local address |
194
- | `LUCKYTRI_CHANNEL` | Optional; `onebot` or `qqbot`. When set, the studio cannot change the connection |
195
- | `ONEBOT_TOKEN` | Connection token for the OneBot reverse WebSocket |
196
- | `QQBOT_APP_ID` / `QQBOT_APP_SECRET` | QQ official bot credentials; take precedence over those saved in the studio |
197
- | `LLM_API_KEY` | Optional; when set, takes precedence over the model key saved in the studio |
198
- | `EMBEDDING_API_KEY` | Optional; a separate key for the knowledge embedding service |
199
- | `BACKUP_INTERVAL_HOURS` / `BACKUP_KEEP` | Automatic backup interval (24 hours by default, `0` turns it off) and how many to keep (7 by default) |
200
-
201
- 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).
202
-
203
- ## Documentation
204
-
205
- | Document | Contents |
206
- | ------------------------------------------------------------ | ----------------------------------------------------------------------------- |
207
- | [Getting started](docs/en/guide.md) | From launching to letting her join her first conversation |
208
- | [Connect QQ](docs/en/connect.md) | The two connection ways: comparison, steps and differences |
209
- | [Her life](docs/en/her-life.md) | The unified mind: rhythm, solitude, diary, review, tact and boundaries |
210
- | [Architecture and extension points](docs/en/architecture.md) | Code layers, and how to add a channel, a mind module, a page or a translation |
211
- | [Time, activities and works](docs/en/time.md) | Her own activities, plans, works and sharing |
212
- | [Chat style](docs/en/chat-style.md) | How she speaks and the checks before sending |
213
- | [Studio design](docs/en/webui.md) | Design and upkeep of "TA's little world" |
214
- | [Backup and recovery](docs/en/recovery.md) | Backups, migrations, verification and restore |
215
- | [Changelog](docs/en/CHANGELOG.md) | What changed in each version |
216
-
217
- ## Development and tests
218
-
219
- ```bash
220
- npm run dev:ui # studio dev server
221
- npm run build:ui # build the studio into public/app
222
- npm run docs:build # generate the Chinese and English guide pages
223
- npm run build # build all release resources
224
- npm test # backend tests
225
- npm run test:clock # run the backend tests with the real clock moved into the past and the future
226
- npm run test:ui # browser tests (including the English UI)
227
- npm run test:package # real global install, upgrade, reinstall and data retention
228
- npm run pack:check # inspect the final npm file list and runtime resources
229
- npm run release:check # complete release checks
230
- npm run format:check # code format check
231
- ```
232
-
233
- 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).
234
-
235
- 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.
236
-
237
- ## 1.0
238
-
239
- 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).
240
-
241
- Directions we would like to take next (not promises):
242
-
243
- - Stable data structures and migrations, so her continuity can be kept safely across versions;
244
- - A reply guard that can only refuse, never rewrite;
245
- - Recognizing the same person across platforms;
246
- - Longer real-world evaluation runs, and more interface languages.
247
-
248
- ## License
249
-
250
- LuckyTri's code is released under the [MIT License](LICENSE).
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).