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
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1" />
6
- <title>LuckyTri v1.0.0 · Getting Started</title>
6
+ <title>LuckyTri v1.0.2 · Getting Started</title>
7
7
  <style>
8
8
  * {
9
9
  box-sizing: border-box;
@@ -269,7 +269,7 @@
269
269
  <body>
270
270
  <header>
271
271
  <div>
272
- <b>LuckyTri · Handbook</b><small>TIME · MEMORY · CHOICE / v1.0.0</small>
272
+ <b>LuckyTri · Handbook</b><small>TIME · MEMORY · CHOICE / v1.0.2</small>
273
273
  </div>
274
274
  <nav>
275
275
  <a href="/#setup">Back to the studio</a
@@ -281,7 +281,8 @@
281
281
  <div class="layout">
282
282
  <nav class="toc" aria-label="Guide contents">
283
283
  <p>CONTENTS</p>
284
- <a href="#step-1">1. Start</a><a href="#step-2">2. Local tokens</a
284
+ <a href="#step-1">1. Start</a
285
+ ><a href="#step-2">2. Set your management password</a
285
286
  ><a href="#step-3">3. Try it in simulation mode first</a
286
287
  ><a href="#step-4">4. Connect a model</a
287
288
  ><a href="#step-5">5. Connect QQ</a
@@ -320,17 +321,11 @@ luckytri
320
321
  WebUI. The experimental-SQLite notice does not mean the start failed.
321
322
  </p>
322
323
  <p>
323
- Use <code>luckytri paths</code> to find <code>.env</code>, open it in
324
- a local editor and enter <code>ADMIN_TOKEN</code> in the studio.
325
- <code>luckytri --no-browser</code> launches without opening a browser,
326
- <code>luckytri start</code> runs in the foreground, and
327
- <code>luckytri stop</code> stops the service. Update with
328
- <code>luckytri stop</code>,
329
- <code>npm install -g luckytri@latest</code>, then
330
- <code>luckytri</code>. Your configuration and data stay intact.
331
- Default directories are listed in the
332
- <a href="../../README.en.md#configuration-data-and-privacy">README</a
333
- >.
324
+ Set a password in the studio on your first visit. Use
325
+ <code>luckytri --no-browser</code>, <code>luckytri start</code> and
326
+ <code>luckytri stop</code> for background, foreground and stop. Update
327
+ with stop, <code>npm install -g luckytri@latest</code>, then launch;
328
+ password, configuration and data stay intact.
334
329
  </p>
335
330
  <p>
336
331
  For source development, run <code>npm install</code>,
@@ -451,80 +446,17 @@ luckytri
451
446
  mind. On a phone the navigation sits at the bottom and the other
452
447
  entries are under &quot;More&quot;.
453
448
  </p>
454
- <h2 id="step-2">2. Local tokens</h2>
449
+ <h2 id="step-2">2. Set your management password</h2>
455
450
  <p>
456
- Configuration is created on first launch. You can also initialize in
457
- advance:
451
+ On the first visit, choose and confirm a password of at least 8
452
+ characters. Use it to sign in later; no environment-file token is
453
+ needed. Browser sessions are remembered, and updates or reinstalls
454
+ preserve the password.
458
455
  </p>
459
- <pre><code class="language-powershell">luckytri setup
460
- luckytri paths
461
- </code></pre>
462
- <p>
463
- When there is no <code>.env</code>, setup writes an admin token and an
464
- OneBot connection token. An existing <code>.env</code> is kept as it
465
- is.
466
- </p>
467
- <pre><code class="language-dotenv">HOST=127.0.0.1
468
- PORT=3210
469
- ADMIN_TOKEN=
470
- ONEBOT_TOKEN=
471
- LLM_API_KEY=
472
- </code></pre>
473
- <table>
474
- <thead>
475
- <tr>
476
- <th>Field</th>
477
- <th>Purpose</th>
478
- </tr>
479
- </thead>
480
- <tbody>
481
- <tr>
482
- <td><code>ADMIN_TOKEN</code></td>
483
- <td>
484
- Opens LuckyTri and calls the HTTP API; the stop command uses it
485
- too
486
- </td>
487
- </tr>
488
- <tr>
489
- <td><code>ONEBOT_TOKEN</code></td>
490
- <td>
491
- The OneBot 11 connector uses it for
492
- <code>/onebot/v11/ws</code> (only needed for OneBot)
493
- </td>
494
- </tr>
495
- <tr>
496
- <td><code>LLM_API_KEY</code></td>
497
- <td>
498
- Optional; when set it takes precedence over the model key saved
499
- in LuckyTri
500
- </td>
501
- </tr>
502
- <tr>
503
- <td><code>LUCKYTRI_CHANNEL</code></td>
504
- <td>
505
- Optional; <code>onebot</code> or <code>qqbot</code>. When set,
506
- the connection method cannot be changed in the interface
507
- </td>
508
- </tr>
509
- <tr>
510
- <td><code>QQBOT_APP_ID</code> / <code>QQBOT_APP_SECRET</code></td>
511
- <td>
512
- Optional; credentials of the QQ official bot, they take
513
- precedence over what is saved in the interface
514
- </td>
515
- </tr>
516
- <tr>
517
- <td><code>HOST</code> / <code>PORT</code></td>
518
- <td>Listen address and port; keep the defaults for local use</td>
519
- </tr>
520
- </tbody>
521
- </table>
522
456
  <p>
523
- The first time the page loads data it asks for
524
- <code>ADMIN_TOKEN</code>. The token stays in the current tab only.
525
- Restart after changing <code>.env</code>. Never give
526
- <code>ADMIN_TOKEN</code> to the QQ connector, and do not treat
527
- <code>ONEBOT_TOKEN</code> as the studio password.
457
+ Change the password or sign out under System → Run switches. Only a
458
+ salted verification digest is stored. Existing environment
459
+ configuration and model keys remain intact.
528
460
  </p>
529
461
  <h2 id="step-3">3. Try it in simulation mode first</h2>
530
462
  <p>Simulation mode is on by default, so nothing is sent to QQ.</p>
@@ -632,8 +564,8 @@ LLM_API_KEY=
632
564
  </p>
633
565
  <ol>
634
566
  <li>
635
- Set <code>ONEBOT_TOKEN</code> in the local <code>.env</code> and
636
- restart LuckyTri.
567
+ Local clients need no separate token. Keep an existing client
568
+ address and QQ sign-in.
637
569
  </li>
638
570
  <li>
639
571
  In the connector&#39;s own network settings add an OneBot 11 reverse
@@ -658,7 +590,10 @@ LLM_API_KEY=
658
590
  </tr>
659
591
  <tr>
660
592
  <td>Token</td>
661
- <td><code>ONEBOT_TOKEN</code> from <code>.env</code></td>
593
+ <td>
594
+ Not needed locally; remote clients can use the management
595
+ password or an existing token
596
+ </td>
662
597
  </tr>
663
598
  <tr>
664
599
  <td>Message format</td>
@@ -677,11 +612,9 @@ LLM_API_KEY=
677
612
  </li>
678
613
  </ol>
679
614
  <p>
680
- <code>3210</code> is LuckyTri&#39;s port. When the connector and
681
- LuckyTri are on different machines or in containers,
682
- <code>127.0.0.1</code> points at each own environment: replace it with
683
- LuckyTri&#39;s real address and configure
684
- <code>ADMIN_TOKEN</code> first.
615
+ In a container or another computer, localhost refers to that
616
+ environment. Use the reachable LuckyTri address for remote access, set
617
+ the password locally first, and use HTTPS for remote studio access.
685
618
  </p>
686
619
  <h3>Option two: QQ official bot</h3>
687
620
  <p>
@@ -926,6 +859,46 @@ npm start
926
859
  and restores it into a brand new file; see
927
860
  <code>docs/en/recovery.md</code>.
928
861
  </p>
862
+ <h3>Import and export from the studio</h3>
863
+ <p>
864
+ &quot;System → Data and backups&quot; provides &quot;Export data
865
+ package&quot; and &quot;Choose import file&quot;. A
866
+ <code>.luckytri</code> package contains chats, memories,
867
+ relationships, personal state, diaries, tasks, work versions,
868
+ knowledge text and settings stored in the database, including saved
869
+ credentials. Management passwords and login sessions are not migrated.
870
+ Plugin programs, original knowledge files and the local
871
+ <code>.env</code> are outside the package. Export uses a consistent
872
+ snapshot while the instance continues running and streams large
873
+ downloads.
874
+ </p>
875
+ <p>
876
+ Imports accept <code>.luckytri</code> packages and existing
877
+ <code>.db</code> / SQLite backups. The default upload limit is 10 GiB;
878
+ adjust <code>DATA_TRANSFER_MAX_GB</code> (1–100) in <code>.env</code>.
879
+ Uploads are checked for package SHA-256, database integrity,
880
+ references and supported structures. Older versions are upgraded only
881
+ in staging. The preview shows the name, version and record counts
882
+ before current data changes, so it can be cancelled.
883
+ </p>
884
+ <p>
885
+ Confirming &quot;Import and restart&quot; stops the instance, retains
886
+ a complete <code>luckytri-before-import-*.db</code> snapshot, replaces
887
+ the data and restarts automatically. The local management password,
888
+ current logins, QQ connection settings and backup cleanup rules are
889
+ preserved. Automatic replies are turned off and plugin execution
890
+ grants reset. Review connections, models and tasks before enabling
891
+ replies; reinstall plugins or review their permissions. Import
892
+ replaces the whole database rather than merging records. Pre-import
893
+ snapshots can be managed manually and are excluded from scheduled
894
+ full-backup cleanup.
895
+ </p>
896
+ <p>
897
+ The server removes the export copy after download. Cancelled, expired
898
+ and interrupted staging files are reclaimed; unused previews expire
899
+ after one hour. Failed imports retain or restore the original database
900
+ rather than starting with a partial file.
901
+ </p>
929
902
  <h2 id="step-9">9. Troubleshooting</h2>
930
903
  <table>
931
904
  <thead>
@@ -949,17 +922,17 @@ npm start
949
922
  </td>
950
923
  </tr>
951
924
  <tr>
952
- <td>Wrong token</td>
925
+ <td>Incorrect password</td>
953
926
  <td>
954
- Use <code>ADMIN_TOKEN</code>; restart after editing
955
- <code>.env</code>
927
+ Sign in with your management password; change it under System →
928
+ Run switches
956
929
  </td>
957
930
  </tr>
958
931
  <tr>
959
932
  <td>OneBot not connected</td>
960
933
  <td>
961
- Is the connector logged in; do the URL, port, path and
962
- <code>ONEBOT_TOKEN</code> all match
934
+ Check sign-in, enabled reverse client, address, port and path;
935
+ local clients need no token
963
936
  </td>
964
937
  </tr>
965
938
  <tr>
@@ -1047,7 +1020,7 @@ npm start
1047
1020
  </div>
1048
1021
  <footer>
1049
1022
  LuckyTri · so that experience and choice stay coherent. This guide matches
1050
- the v1.0.0 interface.
1023
+ the v1.0.2 interface.
1051
1024
  </footer>
1052
1025
  </body>
1053
1026
  </html>
package/public/guide.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1" />
6
- <title>LuckyTri v1.0.0 · 使用教程</title>
6
+ <title>LuckyTri v1.0.2 · 使用教程</title>
7
7
  <style>
8
8
  * {
9
9
  box-sizing: border-box;
@@ -269,7 +269,7 @@
269
269
  <body>
270
270
  <header>
271
271
  <div>
272
- <b>LuckyTri · 上手手册</b><small>TIME · MEMORY · CHOICE / v1.0.0</small>
272
+ <b>LuckyTri · 上手手册</b><small>TIME · MEMORY · CHOICE / v1.0.2</small>
273
273
  </div>
274
274
  <nav>
275
275
  <a href="/#setup">返回管理台</a
@@ -283,7 +283,7 @@
283
283
  <div class="layout">
284
284
  <nav class="toc" aria-label="教程目录">
285
285
  <p>CONTENTS</p>
286
- <a href="#step-1">1. 启动</a><a href="#step-2">2. 本机令牌</a
286
+ <a href="#step-1">1. 启动</a><a href="#step-2">2. 设置管理密码</a
287
287
  ><a href="#step-3">3. 先在模拟模式试聊</a
288
288
  ><a href="#step-4">4. 连接模型</a><a href="#step-5">5. 连接 QQ</a
289
289
  ><a href="#step-6">6. 让 TA 参与会话</a
@@ -315,21 +315,13 @@ luckytri
315
315
  实验性提示不表示启动失败,以能否打开 LuckyTri 为准。
316
316
  </p>
317
317
  <p>
318
- 运行 <code>luckytri paths</code> 查看本机
319
- <code>.env</code>,在本机编辑器中取得
320
- <code>ADMIN_TOKEN</code> 并填入管理台。<code
321
- >luckytri --no-browser</code
322
- >
318
+ 首次进入管理台时设置一个密码即可。<code>luckytri --no-browser</code>
323
319
  只后台启动,<code>luckytri start</code> 前台运行,<code
324
320
  >luckytri stop</code
325
321
  >
326
322
  停止服务。更新使用 <code>luckytri stop</code> →
327
323
  <code>npm install -g luckytri@latest</code> →
328
- <code>luckytri</code>,配置与数据会保留;默认目录见
329
- <a
330
- href="../../README.md#%E9%85%8D%E7%BD%AE%E6%95%B0%E6%8D%AE%E4%B8%8E%E9%9A%90%E7%A7%81"
331
- >README</a
332
- >。
324
+ <code>luckytri</code>,密码、配置与数据会保留。
333
325
  </p>
334
326
  <p>
335
327
  从源码开发时,在仓库中执行 <code>npm install</code>、<code
@@ -430,66 +422,16 @@ luckytri
430
422
  戳一下会回应一句,按住是摸摸头,双击或点「聊聊」打开试聊;这些只是界面动画,不会改变
431
423
  TA 的心智。手机上导航在底部,其余入口在「更多」里。
432
424
  </p>
433
- <h2 id="step-2">2. 本机令牌</h2>
434
- <p>首次启动已生成配置;也可以提前初始化:</p>
435
- <pre><code class="language-powershell">luckytri setup
436
- luckytri paths
437
- </code></pre>
425
+ <h2 id="step-2">2. 设置管理密码</h2>
438
426
  <p>
439
- 没有 <code>.env</code> 时,setup 会写入管理令牌和 OneBot
440
- 连接令牌。已有 <code>.env</code> 会原样保留。
427
+ 首次打开管理台时设置一个至少 8
428
+ 个字符的密码,确认后进入。以后用同一个密码登录,不需要打开
429
+ <code>.env</code>
430
+ 查找管理令牌。浏览器登录状态会保留;更新和重装不会重置密码。
441
431
  </p>
442
- <pre><code class="language-dotenv">HOST=127.0.0.1
443
- PORT=3210
444
- ADMIN_TOKEN=
445
- ONEBOT_TOKEN=
446
- LLM_API_KEY=
447
- </code></pre>
448
- <table>
449
- <thead>
450
- <tr>
451
- <th>字段</th>
452
- <th>用途</th>
453
- </tr>
454
- </thead>
455
- <tbody>
456
- <tr>
457
- <td><code>ADMIN_TOKEN</code></td>
458
- <td>打开 LuckyTri 和调用 HTTP API;停止命令也会使用</td>
459
- </tr>
460
- <tr>
461
- <td><code>ONEBOT_TOKEN</code></td>
462
- <td>
463
- OneBot 11 接入端连接 <code>/onebot/v11/ws</code>(只用 OneBot
464
- 方式时需要)
465
- </td>
466
- </tr>
467
- <tr>
468
- <td><code>LLM_API_KEY</code></td>
469
- <td>可选;非空时优先于 LuckyTri 里保存的模型密钥</td>
470
- </tr>
471
- <tr>
472
- <td><code>LUCKYTRI_CHANNEL</code></td>
473
- <td>
474
- 可选;<code>onebot</code> 或
475
- <code>qqbot</code>。设置后在界面里不能更改连接方式
476
- </td>
477
- </tr>
478
- <tr>
479
- <td><code>QQBOT_APP_ID</code> / <code>QQBOT_APP_SECRET</code></td>
480
- <td>可选;QQ 官方机器人的凭据,优先于界面里保存的</td>
481
- </tr>
482
- <tr>
483
- <td><code>HOST</code> / <code>PORT</code></td>
484
- <td>监听地址和端口;本机使用保持默认</td>
485
- </tr>
486
- </tbody>
487
- </table>
488
432
  <p>
489
- 页面第一次取数据时会弹出窗口要求输入
490
- <code>ADMIN_TOKEN</code>。令牌只留在当前标签页。修改
491
- <code>.env</code> 后必须重启。不要把 <code>ADMIN_TOKEN</code> 填给 QQ
492
- 接入端,也不要把 <code>ONEBOT_TOKEN</code> 当成管理台密码。
433
+ 在「系统 →
434
+ 运行开关」可以修改密码或退出登录。密码只以加盐校验摘要保存,现有环境配置和模型密钥保留。
493
435
  </p>
494
436
  <h2 id="step-3">3. 先在模拟模式试聊</h2>
495
437
  <p>默认开启模拟模式,消息不会发到 QQ。</p>
@@ -571,10 +513,7 @@ LLM_API_KEY=
571
513
  接口,接入端需要你自行准备和管理。
572
514
  </p>
573
515
  <ol>
574
- <li>
575
- 在本机 <code>.env</code> 中设置
576
- <code>ONEBOT_TOKEN</code>,修改后重启 LuckyTri。
577
- </li>
516
+ <li>本机连接无需单独令牌,保留已有的接入地址和 QQ 登录。</li>
578
517
  <li>
579
518
  在接入端自己的网络设置里添加 OneBot 11 反向 WebSocket 客户端:
580
519
  </li>
@@ -597,7 +536,7 @@ LLM_API_KEY=
597
536
  </tr>
598
537
  <tr>
599
538
  <td>Token</td>
600
- <td><code>.env</code> 里的 <code>ONEBOT_TOKEN</code></td>
539
+ <td>本机无需填写;远程可使用管理密码,旧远程令牌仍兼容</td>
601
540
  </tr>
602
541
  <tr>
603
542
  <td>消息格式</td>
@@ -616,10 +555,9 @@ LLM_API_KEY=
616
555
  </li>
617
556
  </ol>
618
557
  <p>
619
- 这里的 <code>3210</code> 是 LuckyTri 的端口。接入端和 LuckyTri
620
- 不在同一台机器或放在容器里时,<code>127.0.0.1</code>
621
- 指向各自环境,需要改成 LuckyTri 的实际地址,并先配置
622
- <code>ADMIN_TOKEN</code>。
558
+ 容器或另一台电脑中的 <code>127.0.0.1</code> 指向自身。远程接入使用
559
+ LuckyTri 的可达地址,并先在本机设置管理密码;对外提供管理台时使用
560
+ HTTPS。
623
561
  </p>
624
562
  <h3>方式二:QQ 官方机器人</h3>
625
563
  <p>
@@ -793,6 +731,29 @@ npm start
793
731
  <code>npm run recovery</code> 校验并恢复到一个全新的文件,见
794
732
  <code>docs/zh/recovery.md</code>。
795
733
  </p>
734
+ <h3>从管理台导入与导出</h3>
735
+ <p>
736
+ 「系统 → 数据与备份」提供「导出数据包」和「选择导入文件」。导出的
737
+ <code>.luckytri</code>
738
+ 文件包含数据库内的聊天、记忆、关系、个人状态、日记、待办、作品版本、知识文本和设置,也包含保存在设置中的密钥。管理密码和登录会话不随数据包迁移;插件程序、知识库原始文件及本机
739
+ <code>.env</code>
740
+ 不在其中。导出读取一致快照,实例可以继续运行,大文件通过流式传输下载。
741
+ </p>
742
+ <p>
743
+ 导入支持 <code>.luckytri</code> 数据包及已有 <code>.db</code> / SQLite
744
+ 备份。默认单个文件最多 10 GiB,可用 <code>.env</code> 中的
745
+ <code>DATA_TRANSFER_MAX_GB</code>(1–100)调整。上传后先校验数据包
746
+ SHA-256、数据库完整性、引用和结构,旧版本只在暂存副本上升级,界面会显示姓名、版本和记录数量。此时尚未改变当前数据,可以取消。
747
+ </p>
748
+ <p>
749
+ 确认「导入并重启」后,程序停止实例,保留一份完整的
750
+ <code>luckytri-before-import-*.db</code>
751
+ 快照,再替换数据并自动重启。本机管理密码、当前登录、QQ
752
+ 连接配置和备份整理规则保留。导入后的自动回复关闭,插件执行权限重置;检查连接、模型和待办后可重新开启,插件需重新安装或确认权限。导入是替换整份数据,不与当前记录合并;原有快照可在备份列表手动管理,定时清理完整备份不会删除它。
753
+ </p>
754
+ <p>
755
+ 下载完成后删除服务器导出副本;取消、失效或中断的暂存文件会回收,未使用的预览默认一小时失效。导入失败时保留或恢复原数据,不会把不完整的文件交给实例运行。
756
+ </p>
796
757
  <h2 id="step-9">9. 常见问题</h2>
797
758
  <table>
798
759
  <thead>
@@ -811,16 +772,13 @@ npm start
811
772
  <td>先 <code>npm run stop</code>,不要结束所有 node 进程</td>
812
773
  </tr>
813
774
  <tr>
814
- <td>令牌错误</td>
815
- <td>
816
- 使用 <code>ADMIN_TOKEN</code>;改 <code>.env</code> 后重启
817
- </td>
775
+ <td>密码错误</td>
776
+ <td>使用首次设置的管理密码;可在系统运行开关中修改</td>
818
777
  </tr>
819
778
  <tr>
820
779
  <td>OneBot 未连接</td>
821
780
  <td>
822
- 接入端是否登录,URL、端口、路径和
823
- <code>ONEBOT_TOKEN</code> 是否一致
781
+ 确认接入端已登录、反向客户端启用、地址端口路径一致;本机无需额外令牌
824
782
  </td>
825
783
  </tr>
826
784
  <tr>
@@ -888,6 +846,6 @@ npm start
888
846
  <p>不要把 API 密钥、<code>.env</code> 或私聊原文发到公开位置。</p>
889
847
  </article>
890
848
  </div>
891
- <footer>LuckyTri · 让经历和选择彼此连贯。教程与 v1.0.0 界面同步。</footer>
849
+ <footer>LuckyTri · 让经历和选择彼此连贯。教程与 v1.0.2 界面同步。</footer>
892
850
  </body>
893
851
  </html>
@@ -16,7 +16,7 @@ luckytri
16
16
 
17
17
  LuckyTri starts in the background and opens <http://127.0.0.1:3210>, creating local configuration on the first run. The package includes the built WebUI. The experimental-SQLite notice does not mean the start failed.
18
18
 
19
- Use `luckytri paths` to find `.env`, open it in a local editor and enter `ADMIN_TOKEN` in the studio. `luckytri --no-browser` launches without opening a browser, `luckytri start` runs in the foreground, and `luckytri stop` stops the service. Update with `luckytri stop`, `npm install -g luckytri@latest`, then `luckytri`. Your configuration and data stay intact. Default directories are listed in the [README](../../README.en.md#configuration-data-and-privacy).
19
+ Set a password in the studio on your first visit. Use `luckytri --no-browser`, `luckytri start` and `luckytri stop` for background, foreground and stop. Update with stop, `npm install -g luckytri@latest`, then launch; password, configuration and data stay intact.
20
20
 
21
21
  For source development, run `npm install`, `npm run setup`, `npm run build` and `npm start` in the checkout. Later examples using `npm run setup/stop/backup/recovery/plugin` apply to source checkouts; global users use the corresponding `luckytri setup/stop/backup/recovery/plugin` commands.
22
22
 
@@ -39,35 +39,11 @@ LuckyTri is "TA's little world". The left navigation has three groups and ten en
39
39
 
40
40
  The colors, sky and motion follow TA's mood and rhythm: warm when she is happy, grey-blue when she is low, night once she is asleep. At the bottom left you can pin one theme or turn on "Reduce motion". The small TA at the bottom right answers a poke, a long press is a head-pat, and a double click or "Chat" opens the trial chat. These are interface animations only and never change her mind. On a phone the navigation sits at the bottom and the other entries are under "More".
41
41
 
42
- ## 2. Local tokens
42
+ ## 2. Set your management password
43
43
 
44
- Configuration is created on first launch. You can also initialize in advance:
44
+ On the first visit, choose and confirm a password of at least 8 characters. Use it to sign in later; no environment-file token is needed. Browser sessions are remembered, and updates or reinstalls preserve the password.
45
45
 
46
- ```powershell
47
- luckytri setup
48
- luckytri paths
49
- ```
50
-
51
- When there is no `.env`, setup writes an admin token and an OneBot connection token. An existing `.env` is kept as it is.
52
-
53
- ```dotenv
54
- HOST=127.0.0.1
55
- PORT=3210
56
- ADMIN_TOKEN=
57
- ONEBOT_TOKEN=
58
- LLM_API_KEY=
59
- ```
60
-
61
- | Field | Purpose |
62
- | ----------------------------------- | ------------------------------------------------------------------------------------------------------ |
63
- | `ADMIN_TOKEN` | Opens LuckyTri and calls the HTTP API; the stop command uses it too |
64
- | `ONEBOT_TOKEN` | The OneBot 11 connector uses it for `/onebot/v11/ws` (only needed for OneBot) |
65
- | `LLM_API_KEY` | Optional; when set it takes precedence over the model key saved in LuckyTri |
66
- | `LUCKYTRI_CHANNEL` | Optional; `onebot` or `qqbot`. When set, the connection method cannot be changed in the interface |
67
- | `QQBOT_APP_ID` / `QQBOT_APP_SECRET` | Optional; credentials of the QQ official bot, they take precedence over what is saved in the interface |
68
- | `HOST` / `PORT` | Listen address and port; keep the defaults for local use |
69
-
70
- The first time the page loads data it asks for `ADMIN_TOKEN`. The token stays in the current tab only. Restart after changing `.env`. Never give `ADMIN_TOKEN` to the QQ connector, and do not treat `ONEBOT_TOKEN` as the studio password.
46
+ Change the password or sign out under System → Run switches. Only a salted verification digest is stored. Existing environment configuration and model keys remain intact.
71
47
 
72
48
  ## 3. Try it in simulation mode first
73
49
 
@@ -111,20 +87,20 @@ Open "System → Connect QQ". There are two options at the top: **OneBot 11** an
111
87
 
112
88
  LuckyTri only implements the reverse-WebSocket side of OneBot 11. You prepare and manage the connector yourself.
113
89
 
114
- 1. Set `ONEBOT_TOKEN` in the local `.env` and restart LuckyTri.
90
+ 1. Local clients need no separate token. Keep an existing client address and QQ sign-in.
115
91
  2. In the connector's own network settings add an OneBot 11 reverse WebSocket client:
116
92
 
117
- | Item | Value on this machine |
118
- | -------------- | ----------------------------------- |
119
- | Protocol | OneBot 11 |
120
- | WebSocket URL | `ws://127.0.0.1:3210/onebot/v11/ws` |
121
- | Token | `ONEBOT_TOKEN` from `.env` |
122
- | Message format | array |
123
- | Enabled | on, then save |
93
+ | Item | Value on this machine |
94
+ | -------------- | --------------------------------------------------------------------------------------- |
95
+ | Protocol | OneBot 11 |
96
+ | WebSocket URL | `ws://127.0.0.1:3210/onebot/v11/ws` |
97
+ | Token | Not needed locally; remote clients can use the management password or an existing token |
98
+ | Message format | array |
99
+ | Enabled | on, then save |
124
100
 
125
101
  3. Log in to QQ in the connector. The account must already be in the target group; LuckyTri does not store QQ passwords.
126
102
 
127
- `3210` is LuckyTri's port. When the connector and LuckyTri are on different machines or in containers, `127.0.0.1` points at each own environment: replace it with LuckyTri's real address and configure `ADMIN_TOKEN` first.
103
+ In a container or another computer, localhost refers to that environment. Use the reachable LuckyTri address for remote access, set the password locally first, and use HTTPS for remote studio access.
128
104
 
129
105
  ### Option two: QQ official bot
130
106
 
@@ -192,14 +168,24 @@ Cleanup verifies a retained automatic backup of this instance from the last 72 h
192
168
 
193
169
  To restore, stop the service, move the current `data/friend.db` and its `-wal` and `-shm` files away, then copy the chosen backup to `data/friend.db`. When `DB_PATH` is set, work on that path. Never keep an old WAL file next to a restored database. The safer way is `npm run recovery`, which verifies a backup and restores it into a brand new file; see `docs/en/recovery.md`.
194
170
 
171
+ ### Import and export from the studio
172
+
173
+ "System → Data and backups" provides "Export data package" and "Choose import file". A `.luckytri` package contains chats, memories, relationships, personal state, diaries, tasks, work versions, knowledge text and settings stored in the database, including saved credentials. Management passwords and login sessions are not migrated. Plugin programs, original knowledge files and the local `.env` are outside the package. Export uses a consistent snapshot while the instance continues running and streams large downloads.
174
+
175
+ Imports accept `.luckytri` packages and existing `.db` / SQLite backups. The default upload limit is 10 GiB; adjust `DATA_TRANSFER_MAX_GB` (1–100) in `.env`. Uploads are checked for package SHA-256, database integrity, references and supported structures. Older versions are upgraded only in staging. The preview shows the name, version and record counts before current data changes, so it can be cancelled.
176
+
177
+ Confirming "Import and restart" stops the instance, retains a complete `luckytri-before-import-*.db` snapshot, replaces the data and restarts automatically. The local management password, current logins, QQ connection settings and backup cleanup rules are preserved. Automatic replies are turned off and plugin execution grants reset. Review connections, models and tasks before enabling replies; reinstall plugins or review their permissions. Import replaces the whole database rather than merging records. Pre-import snapshots can be managed manually and are excluded from scheduled full-backup cleanup.
178
+
179
+ The server removes the export copy after download. Cancelled, expired and interrupted staging files are reclaimed; unused previews expire after one hour. Failed imports retain or restore the original database rather than starting with a partial file.
180
+
195
181
  ## 9. Troubleshooting
196
182
 
197
183
  | Symptom | Check first |
198
184
  | --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
199
185
  | The page does not open | Is Node running, and is the address `127.0.0.1:3210` |
200
186
  | Port already in use | Run `npm run stop` first; do not kill every node process |
201
- | Wrong token | Use `ADMIN_TOKEN`; restart after editing `.env` |
202
- | OneBot not connected | Is the connector logged in; do the URL, port, path and `ONEBOT_TOKEN` all match |
187
+ | Incorrect password | Sign in with your management password; change it under System → Run switches |
188
+ | OneBot not connected | Check sign-in, enabled reverse client, address, port and path; local clients need no token |
203
189
  | Official bot not connected | Are the AppID and AppSecret right, are group and one-to-one messages enabled for the bot, can the network reach the QQ Open Platform |
204
190
  | Official bot only gets @ messages | Enable "receive all messages" on the Open Platform; this is a platform permission, not a LuckyTri limit |
205
191
  | Connected but no sessions | Send one more new message in QQ; with OneBot also check the message format is array |