luckytri 1.2.0 → 1.2.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 (49) hide show
  1. package/README.en.md +12 -14
  2. package/README.md +1 -3
  3. package/docs/en/CHANGELOG.md +17 -1
  4. package/docs/en/architecture.md +2 -2
  5. package/docs/en/guide.md +2 -0
  6. package/docs/en/npm-release.md +6 -0
  7. package/docs/zh/CHANGELOG.md +17 -1
  8. package/docs/zh/architecture.md +2 -2
  9. package/docs/zh/guide.md +2 -0
  10. package/docs/zh/npm-release.md +8 -0
  11. package/package.json +25 -3
  12. package/public/app/assets/{ChatsPage-eDqFIg97.js → ChatsPage-GGOaUl3H.js} +1 -1
  13. package/public/app/assets/{Empty-CAGOJsfD.js → Empty-BSmsWoGM.js} +1 -1
  14. package/public/app/assets/{Field-CRz-JmN1.js → Field-tUGp0-YL.js} +1 -1
  15. package/public/app/assets/{HeartPage-BGWoeMrC.js → HeartPage-B5_e1hI9.js} +1 -1
  16. package/public/app/assets/{LifePage-iao3o3wt.js → LifePage-D5P5kTzy.js} +1 -1
  17. package/public/app/assets/{MemoryPage-Dwi2yi7E.js → MemoryPage-BrSPiqOS.js} +1 -1
  18. package/public/app/assets/{NaturePage-DniImo9U.js → NaturePage-C0BdvfFu.js} +1 -1
  19. package/public/app/assets/{PeoplePage-D-MC3JEt.js → PeoplePage-DBT70lu7.js} +1 -1
  20. package/public/app/assets/{PluginsPage-D7dJTf96.js → PluginsPage-QBiQg3Jc.js} +1 -1
  21. package/public/app/assets/{SystemPage-C_Y5M7JU.css → SystemPage-Cf8lKh5C.css} +1 -1
  22. package/public/app/assets/{SystemPage-C5CUHjGh.js → SystemPage-EFOEvom-.js} +1 -1
  23. package/public/app/assets/{TimePage-Dwhr3-92.js → TimePage-BuNKjCgN.js} +1 -1
  24. package/public/app/assets/{index-L0bHax8C.js → index-BaXEYeFH.js} +3 -3
  25. package/public/app/assets/{knowledge-BTDNafzl.js → knowledge-COyBves6.js} +1 -1
  26. package/public/app/assets/{media-BBzOAfNG.js → media-8uRD5Ocs.js} +1 -1
  27. package/public/app/assets/{mind-CBTkFje2.js → mind-CQkvddhx.js} +1 -1
  28. package/public/app/index.html +3 -3
  29. package/public/guide.en.html +14 -3
  30. package/public/guide.html +15 -3
  31. package/public/tutorial.en.md +2 -0
  32. package/public/tutorial.md +2 -0
  33. package/scripts/service-supervisor.js +8 -13
  34. package/scripts/start-server.js +8 -1
  35. package/scripts/update-instance.js +93 -27
  36. package/server/core/context-builder.js +4 -1
  37. package/server/core/dialogue-contract.js +1 -1
  38. package/server/core/response-validator.js +18 -2
  39. package/server/core/turn.js +30 -1
  40. package/server/i18n/errors.js +36 -0
  41. package/server/mind/affect.js +4 -2
  42. package/server/mind/view.js +4 -1
  43. package/server/runtime/update-errors.js +73 -0
  44. package/server/runtime/update-execution.js +13 -8
  45. package/server/runtime/update-manager.js +30 -8
  46. package/docs/en/evolution.md +0 -35
  47. package/docs/en/vision.md +0 -50
  48. package/docs/zh/evolution.md +0 -35
  49. package/docs/zh/vision.md +0 -50
package/README.en.md CHANGED
@@ -19,7 +19,6 @@
19
19
  <a href="docs/en/connect.md">Connect QQ</a> ·
20
20
  <a href="docs/en/her-life.md">Her life</a> ·
21
21
  <a href="docs/en/architecture.md">Architecture</a> ·
22
- <a href="docs/en/vision.md">Vision</a> ·
23
22
  <a href="docs/en/CHANGELOG.md">Changelog</a> ·
24
23
  <a href=".github/SECURITY.md">Security</a>
25
24
  </p>
@@ -95,7 +94,7 @@ The full design is in [Her life](docs/en/her-life.md) and [Architecture and exte
95
94
 
96
95
  Recent work focuses on continuity and clearer conversation. Account-based recognition links public encounters across groups and private chats. Relationships, forms of address, her own views and private promises retain their sources and visibility boundaries. An ordinary greeting need not bring back unfinished tasks or demonstrate how much she remembers.
97
96
 
98
- **1.2.0 update:** Instance updates now back up and verify the database before migrating legacy memories and indexes; a failed check restores the previous release and data. See the [changelog](docs/en/CHANGELOG.md).
97
+ **1.2.2 update:** Fix server update supervision through memory migration, replacement handover and stop signals; show the failed stage and actionable cause. Servers using the 1.2.0–1.2.1 foreground supervisor should install this version manually and restart once. See the [changelog](docs/en/CHANGELOG.md) and [server update guidance](docs/en/npm-release.md).
99
98
 
100
99
  | Area | What it does today |
101
100
  | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -211,18 +210,17 @@ The database, chat records, model keys and backups live locally in the ignored `
211
210
 
212
211
  ## Documentation
213
212
 
214
- | Document | Contents |
215
- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
216
- | [Getting started](docs/en/guide.md) | From launching to letting her join her first conversation |
217
- | [Connect QQ](docs/en/connect.md) | The two connection ways: comparison, steps and differences |
218
- | [Her life](docs/en/her-life.md) | The unified mind: rhythm, solitude, diary, review, tact and boundaries |
219
- | [Ultimate vision](docs/en/vision.md) | The highest guiding principle: her judgments come, in the end, from her own experience and choices |
220
- | [Architecture and extension points](docs/en/architecture.md) | Code layers, and how to add a channel, a mind module, a page or a translation |
221
- | [Time, activities and works](docs/en/time.md) | Her own activities, plans, works and sharing |
222
- | [Chat style](docs/en/chat-style.md) | How she speaks and the checks before sending |
223
- | [Studio design](docs/en/webui.md) | Design and upkeep of "TA's little world" |
224
- | [Backup and recovery](docs/en/recovery.md) | Backups, migrations, verification and restore |
225
- | [Changelog](docs/en/CHANGELOG.md) | What changed in each version |
213
+ | Document | Contents |
214
+ | ------------------------------------------------------------ | ----------------------------------------------------------------------------- |
215
+ | [Getting started](docs/en/guide.md) | From launching to letting her join her first conversation |
216
+ | [Connect QQ](docs/en/connect.md) | The two connection ways: comparison, steps and differences |
217
+ | [Her life](docs/en/her-life.md) | The unified mind: rhythm, solitude, diary, review, tact and boundaries |
218
+ | [Architecture and extension points](docs/en/architecture.md) | Code layers, and how to add a channel, a mind module, a page or a translation |
219
+ | [Time, activities and works](docs/en/time.md) | Her own activities, plans, works and sharing |
220
+ | [Chat style](docs/en/chat-style.md) | How she speaks and the checks before sending |
221
+ | [Studio design](docs/en/webui.md) | Design and upkeep of "TA's little world" |
222
+ | [Backup and recovery](docs/en/recovery.md) | Backups, migrations, verification and restore |
223
+ | [Changelog](docs/en/CHANGELOG.md) | What changed in each version |
226
224
 
227
225
  ## Development and tests
228
226
 
package/README.md CHANGED
@@ -19,7 +19,6 @@
19
19
  <a href="docs/zh/connect.md">连接 QQ</a> ·
20
20
  <a href="docs/zh/her-life.md">她的一生</a> ·
21
21
  <a href="docs/zh/architecture.md">架构</a> ·
22
- <a href="docs/zh/vision.md">终极愿景</a> ·
23
22
  <a href="docs/zh/CHANGELOG.md">版本记录</a> ·
24
23
  <a href=".github/SECURITY.md">安全说明</a>
25
24
  </p>
@@ -95,7 +94,7 @@ flowchart LR
95
94
 
96
95
  近期更新集中在让相处更连贯、说话更清楚。她按账号认出同一个人,在不同群与私聊间衔接公开经历;关系、称呼、自己的看法和私人约定分别保留来源与可见范围。普通问候不需要带出旧任务,每次开口也不需要证明自己记住了多少事。
97
96
 
98
- **1.2.0 更新:** 实例更新现在会先备份并校验数据,再迁移旧版记忆和索引;校验不通过会恢复原版本与数据。完整变化见 [版本记录](docs/zh/CHANGELOG.md)。
97
+ **1.2.2 更新:** 修复服务器更新时的记忆迁移等待、进程交接与停止信号,新增失败阶段和具体原因提示。使用 1.2.0–1.2.1 前台守护器的服务器,应手动安装本版并重启一次。完整变化见 [版本记录](docs/zh/CHANGELOG.md),部署方式见 [服务器更新](docs/zh/npm-release.md#服务器更新)。
99
98
 
100
99
  | 方面 | 现在能做什么 |
101
100
  | ------------ | --------------------------------------------------------------------------------------------------------- |
@@ -216,7 +215,6 @@ npm start
216
215
  | [上手教程](docs/zh/guide.md) | 从启动到让她参与第一个会话 |
217
216
  | [连接 QQ](docs/zh/connect.md) | 两种连接方式的对比、步骤与差异 |
218
217
  | [她的一生](docs/zh/her-life.md) | 统一心智的设计:作息、独处、日记、回顾、分寸与底线 |
219
- | [终极愿景](docs/zh/vision.md) | 最高指导原则:她的判断终将来自自己的经历与选择 |
220
218
  | [架构与扩展点](docs/zh/architecture.md) | 代码分层,以及如何新增通道、心智模块、页面与翻译 |
221
219
  | [时间、行动与作品](docs/zh/time.md) | 她自己的活动、待办、作品与分享 |
222
220
  | [聊天口吻](docs/zh/chat-style.md) | 她怎么说话,发出前做哪些检查 |
@@ -2,6 +2,22 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## 1.2.2 — 2026-10-13
6
+
7
+ - Fix the foreground supervisor starting the old server prematurely during memory migration. It now waits until explicit success, failure or worker exit, including stages introduced by future releases.
8
+ - Adopt the replacement PID and forward stop signals correctly. Record rollback PIDs before checking their health so the supervisor can retain control.
9
+ - Preserve the interrupted stage and report recovery requirements. Installation, validation, backup, migration, startup and recovery failures expose actionable causes; raw errors remain in local logs.
10
+ - Check Node.js/npm availability and distinguish network, certificate, permission, disk and timeout failures. Terminate timed-out subprocesses or subprocesses whose log writes fail before recovery proceeds.
11
+ - Add real foreground upgrade and shutdown handover checks, retaining memory, chats, relationships, configuration, knowledge, logs, backups and plugin state. Update both READMEs and server deployment guidance.
12
+
13
+ **Server upgrade note:** Clicking update in 1.2.0–1.2.1 still runs the installed old updater. Affected foreground-managed instances should back up and stop the service, manually run `npm install -g luckytri@1.2.2`, then restart with the same account and instance directory. Use `luckytri start --home /existing-instance` as the managed service entry point. Retain existing data and `runtime/`; see [server update guidance](npm-release.md).
14
+
15
+ ## 1.2.1 — 2026-10-13
16
+
17
+ - Fix message boundaries: a line break starts another message, while a list stays together; lines that continue the same thought are joined, within the turn's message limit.
18
+ - Normalize older sentence-per-line replies in her context and typing-style statistics, so an old layout does not keep teaching her to write that way.
19
+ - Let tired or tense feelings affect her energy more fully; add twelve explicitly synthetic regression scenes for reply shape.
20
+
5
21
  ## 1.2.0 — 2026-10-13
6
22
 
7
23
  - Instance updates now run a versioned memory migration: make and verify a full snapshot, upgrade the database with the candidate release, merge legacy memory records, and rebuild full-text and experience-link indexes. Persistent row counts are checked table by table before switching versions. A failed migration restores the snapshot and restarts the previous release. Chat memories are not sent to a model, and existing vectors are not regenerated.
@@ -23,7 +39,7 @@
23
39
  - Revocations are stamped on her own clock, on the same timeline as the rest of her life.
24
40
  - Each turn records what came to her mind (facts, episodes, self threads, thoughts, promises) in the choice record, kept for good and never sent to the model; turn input stays byte-for-byte the same. The database only gains one column, so older versions still open it.
25
41
  - New `npm run audit:life -- --db <backup>`: a read-only check-up of a backup that reports on the integrity and continuity of her life record. New `npm run evaluate:traits`: trait probes with the scripted model.
26
- - New [Ultimate vision](vision.md) document; the evolution charter sits under it.
42
+ - New Ultimate vision document; the evolution charter sits under it.
27
43
  - Embeddings no longer default to doubao: any OpenAI-compatible `/embeddings` endpoint works with an address, a model name and a key, and Volcengine Ark (including Agent Plan) is one preset. With dimension 0 every model keeps its own length; doubao-embedding-vision stays at 2048 as in 1.1.2, so existing vectors are not rebuilt. In a recall comparison with real vectors 1024 was slightly worse, so it is no longer the default. Vectors returned as base64, the different ways services say a batch is too big, and a 413 without a limit are all handled.
28
44
 
29
45
  ## 1.1.2 — 2026-10-11
@@ -4,7 +4,7 @@
4
4
 
5
5
  This document is for anyone who wants to read, change or extend LuckyTri. It answers three questions: how the code is layered, how a message travels through her life, and where to start when you want to add something.
6
6
 
7
- Every design here serves the [final vision](vision.md#the-final-vision): she is still made of code and models, but her judgments should not have to find their answers only in the original design; they should come more and more from her own experience and choices.
7
+ Every design here serves the final vision: she is still made of code and models, but her judgments should not have to find their answers only in the original design; they should come more and more from her own experience and choices.
8
8
 
9
9
  ## One picture
10
10
 
@@ -155,4 +155,4 @@ Nothing above the core changes. The connection option in settings and the readin
155
155
 
156
156
  ## Cognition and memory
157
157
 
158
- How understanding, recall, episodes, lessons and follow-ups fit together is in [Cognition](cognition.md). The recall index is derived. Episodes and self threads stay append-only. Long-term directions and how changes are evaluated are in the [Ultimate vision](vision.md) and the [Evolution charter](evolution.md) under it.
158
+ How understanding, recall, episodes, lessons and follow-ups fit together is in [Cognition](cognition.md). The recall index is derived. Episodes and self threads stay append-only.
package/docs/en/guide.md CHANGED
@@ -212,3 +212,5 @@ People → Relationships binds a person or another robot by account, with recipr
212
212
  An absent person can still be recalled by name or relationship role. Current facts, actual encounters and her own feelings inform that recognition together. Earlier opinions remain history rather than overriding current facts, and relevant replies are checked before delivery. She still chooses how to interact and address people without reciting management fields.
213
213
 
214
214
  System → Runtime → Version and updates checks npm and links release notes. Update and restart downloads and validates the new program while the instance keeps running, then saves a verified backup and switches. Failed startup attempts recovery of the previous program and data. Managed programs live under the instance's `runtime/releases/`, leaving source and global npm installations untouched; launch commands select the updated program. A manually installed equal or newer source/global package takes precedence. The Nature page uses the server's remaining edit allowance; locally granted extra opportunities are recorded without clearing history.
215
+
216
+ For systemd or PM2 deployments, use `luckytri start --home /existing-instance` as the managed entry point. The 1.2.0–1.2.1 foreground supervisor may start the old server prematurely during memory migration. Back up and stop the managed service, manually install the fixed release with `npm install -g luckytri@1.2.2`, then restart with the same account and instance directory. Retain existing data and `runtime/`; see [server update guidance](npm-release.md).
@@ -6,6 +6,12 @@ The ESM server needs Express, ws and sharp, plus Node.js 24.5 or newer for built
6
6
 
7
7
  `server/paths.js` separates package resources from writable instance data. Global installations use a stable per-user directory; source checkouts retain their existing `.env` and `data/`. Relative database and backup settings resolve under the instance directory. Server and backup workers inherit absolute paths, and service identity uses the instance directory rather than an installation location. The existing SQLite migrations and snapshots remain in use.
8
8
 
9
+ For a server managed by systemd or PM2, use `luckytri start --home /srv/luckytri` with the existing instance directory containing `.env` and `data/`. The foreground supervisor waits through backup, memory migration and startup verification, then adopts the replacement process. Only explicit success or failure ends that wait, so stages introduced by future releases cannot trigger a premature restart. Running `server/index.js` directly bypasses this handover. The background launcher is intended for standalone use. The service account needs Node.js >=24.5, npm, write access to the instance directory and enough room for database snapshots.
10
+
11
+ Updates install and check the candidate separately before stopping the service. A verified backup is retained, migration runs on a database copy, and the replacement must pass a health check. Ordinary failures attempt rollback; an externally terminated worker is reported with its interrupted stage and recovery requirements. The UI distinguishes network, certificate, permission, disk, runtime, migration and startup errors. Raw errors stay in the instance's `data/launcher.log`.
12
+
13
+ The foreground supervisor in 1.2.0–1.2.1 omitted the migration stage and could start the old instance prematurely. Clicking update still runs the already installed updater, so the upgrade to the fixed 1.2.2 release should be performed manually: back up, stop the managed service, run `npm install -g luckytri@1.2.2`, then restart with the same service account and instance directory. Reinstalling 1.2.1 does not fix the defect. Keep the instance and `runtime/` directories, which may contain recovery state and previous programs.
14
+
9
15
  `package.json.files` allows only the CLI, server, runtime scripts, built WebUI, guides, plugin bridge, built-in weather plugin, SDK and public documentation. `.npmignore` adds exclusions. Application install and uninstall hooks are prohibited, so an install never initializes, copies or deletes user data and requires no frontend build tools.
10
16
 
11
17
  `npm run pack:check` inspects npm's actual final file list before reading any contents. Unreviewed paths, credentials, environment configuration, databases, logs, backups, development files and missing resources fail the check. Reviewed source files are scanned for common embedded secret formats. It also verifies the CLI shebang and WebUI asset references.
@@ -2,6 +2,22 @@
2
2
 
3
3
  # 版本记录
4
4
 
5
+ ## 1.2.2 — 2026-10-13
6
+
7
+ - 修复服务器前台守护器漏认记忆迁移阶段而提前启动旧实例的问题。守护器只在更新明确成功、失败或更新进程退出后交接,后续版本新增阶段也会继续等待。
8
+ - 更新后正确接管新版实例的进程与停止信号;恢复旧版时及时记录恢复进程,避免交接丢失。
9
+ - 迁移中断会保留失败阶段并提示检查与恢复;安装、校验、备份、迁移、启动及恢复失败分别显示具体原因,原始报错留在本机日志中。
10
+ - 补充 Node.js/npm 环境检查,以及网络、证书、权限、磁盘和超时错误识别;超时或日志写入失败时先结束子进程,再进入恢复流程。
11
+ - 新增真实前台升级与停止交接测试,核验记忆、聊天、关系、配置、知识、日志、备份和插件数据保留。更新中英文 README 与服务器部署说明。
12
+
13
+ **服务器升级提示:** 1.2.0–1.2.1 点击更新时仍由旧版更新器执行。受影响的前台托管实例应先备份并停止服务,手动执行 `npm install -g luckytri@1.2.2`,再使用同一账号、同一实例目录启动服务。服务管理器的入口使用 `luckytri start --home /原实例目录`,不要删除已有数据或 `runtime/`。详见 [服务器更新](npm-release.md#服务器更新)。
14
+
15
+ ## 1.2.1 — 2026-10-13
16
+
17
+ - 修正消息分段:回复中的换行按另起一条消息处理,列表仍保留在同一条消息里;续写上文的行会并回去,消息数量遵守当前上限。
18
+ - 旧记录中每句话单独换行的回复,在生成上下文和口吻统计里按自然的打字习惯归一,避免她把旧排版继续学成自己的表达。
19
+ - 疲惫或紧绷的感受会更充分地影响精力状态;新增 12 组标明为合成数据的表达形态回归场景。
20
+
5
21
  ## 1.2.0 — 2026-10-13
6
22
 
7
23
  - 实例更新新增版本化记忆迁移:先制作并校验整库快照,再用候选版本升级数据库、合并旧版记忆记录并重建全文与经历关联索引;逐表核对持久记录数量,全部通过后才切换版本。迁移失败会恢复快照并重新启动旧版本。迁移不把聊天记忆发送给模型,也不重新生成已有向量。
@@ -23,7 +39,7 @@
23
39
  - 撤销记录改用她自己的时钟,和她的其他经历在同一条时间线上。
24
40
  - 每一轮记下她当时想起了什么(事实、情景、自我线索、念头、约定),永久保存在选择记录里,不进入提示词,回合输入逐字节不变。数据库只新增一列,旧版本可以照常打开。
25
41
  - 新增 `npm run audit:life -- --db <备份>`:对备份做只读体检,报告她一生记录的完整性和连续性。新增 `npm run evaluate:traits`:脚本模型下的特质探针。
26
- - 文档新增[终极愿景](vision.md),长期演进准则从属于它。
42
+ - 文档新增终极愿景,长期演进准则从属于它。
27
43
  - 向量服务不再默认是豆包:任何 OpenAI 兼容的 `/embeddings` 接口填地址、模型名和密钥即可,火山方舟(含 Agent Plan)是其中一个预设。维度填 0 时所有模型都用自己的长度,`doubao-embedding-vision` 保持 2048,与 1.1.2 相同,已有向量不用重建;真实向量的召回对比里 1024 略差,所以不再默认缩短。服务按 base64 返回向量、各家不同的“批次过大”提示和不带上限的 413 都能处理。
28
44
 
29
45
  ## 1.1.2 — 2026-10-11
@@ -4,7 +4,7 @@
4
4
 
5
5
  这份文档写给想读懂、修改或扩展 LuckyTri 的人。它回答三件事:代码怎样分层、一条消息怎样走完一生、想加东西时从哪里下手。
6
6
 
7
- 所有设计都从属于 [终极愿景](vision.md#最终愿景):她依然由代码和模型构成,但她的判断不应只能从最初的设计里找答案,而要越来越多地来自她自己的经历与选择。
7
+ 所有设计都从属于 终极愿景:她依然由代码和模型构成,但她的判断不应只能从最初的设计里找答案,而要越来越多地来自她自己的经历与选择。
8
8
 
9
9
  ## 一张图
10
10
 
@@ -155,4 +155,4 @@ public/ 构建后的工作室(app/)与教程页
155
155
 
156
156
  ## 认知与记忆
157
157
 
158
- 理解、回忆、情景、教训和主动跟进的数据流写在 [认知](cognition.md)。检索索引是派生数据,情景和自我线索仍然只追加。长期方向与评估原则见 [终极愿景](vision.md) 和从属于它的 [长期演进准则](evolution.md)。
158
+ 理解、回忆、情景、教训和主动跟进的数据流写在 [认知](cognition.md)。检索索引是派生数据,情景和自我线索仍然只追加。
package/docs/zh/guide.md CHANGED
@@ -212,3 +212,5 @@ TA 的一切都存在这一个数据库里,所以服务运行时会自动备
212
212
  对方不在当前会话,也可以因名字或关系称呼被想起。当前关系、实际相处与自己的感受共同参与理解;关系更新前的看法作为历史保留,不再直接代表当前事实。相关回复发送前会再次核对。她仍选择如何相处和称呼,不机械播报关系字段。
213
213
 
214
214
  「系统 → 运行开关 → 版本与更新」可检查 npm 最新版本、查看发布说明,随后点击「更新并重启」。下载检查期间继续运行,切换前保留校验备份,启动失败时尝试恢复原版本和数据。新程序装在实例的 `runtime/releases/`,源码和全局 npm 安装保持原样;启动命令会选择已更新的程序。安装了同版本或更新版本的全局包或源码后,以该安装为准。天性页的剩余修改次数以服务端额度为准;本地维护额外授予的机会有独立记录,不清空原版本。
215
+
216
+ 服务器使用 systemd、PM2 等托管时,启动入口使用 `luckytri start --home /原实例目录`。1.2.0–1.2.1 的前台守护器可能在记忆迁移时提前启动旧实例,升级到修复版 1.2.2 应先备份并停止托管服务,手动执行 `npm install -g luckytri@1.2.2`,再用原账号、原实例目录启动。不要删除数据或 `runtime/`;详细部署与故障说明见 [服务器更新](npm-release.md#服务器更新)。
@@ -10,6 +10,14 @@
10
10
 
11
11
  数据库、心智、聊天、界面配置继续使用原 SQLite 存储与迁移;知识文件、插件安装与插件数据、日志和备份都在实例目录中。启动锁保留到服务退出,阻止重复打开同一实例。Windows、macOS、Linux 分别使用系统浏览器打开方式;无桌面环境可使用 `--no-browser`。
12
12
 
13
+ ## 服务器更新
14
+
15
+ 由 systemd、PM2 等管理进程时,启动命令使用 `luckytri start --home /srv/luckytri`,其中实例目录应指向已有 `.env` 和 `data/` 所在目录。前台守护器会等待下载、备份、记忆迁移与新实例校验结束,并接管更新后的进程;只有任务明确成功或失败才结束等待,后续版本新增阶段也不会提前触发旧实例启动。直接运行 `server/index.js` 会绕过这层交接;后台启动命令适用于独立运行,不能代替服务管理器的前台入口。服务账号需要 Node.js >=24.5、可用的 npm、实例目录写权限和足够的快照空间。
16
+
17
+ 更新先在独立目录安装并校验程序,再停止服务、验证备份,在数据库副本上迁移,最后切换并检查新实例。普通步骤失败时恢复旧版;如果更新进程被外部终止,管理台会标明中断阶段及恢复需求。失败原因分为网络、证书、权限、磁盘、运行环境、迁移与启动等类别,原始错误保留在实例的 `data/launcher.log`。
18
+
19
+ 1.2.0–1.2.1 的前台守护器漏认了记忆迁移阶段,可能在迁移中提前启动旧实例。由于点击更新时运行的是已安装旧版的更新器,升级到修复版 1.2.2 时,应先备份,停止进程管理器中的服务,手动执行 `npm install -g luckytri@1.2.2`,再用相同账号和实例目录启动服务。重新安装 1.2.1 不能修复这一缺陷。不要删除实例目录或 `runtime/` 来尝试修复;其中可能保留更新状态、旧程序及恢复依据。
20
+
13
21
  ## 包内容边界
14
22
 
15
23
  `package.json.files` 白名单只包含 CLI、服务端、运行脚本、构建后的 WebUI、教程、插件桥接资源、内置天气插件、SDK 和公开文档。`.npmignore` 再排除敏感及本地文件。安装和卸载没有应用生命周期脚本,普通用户无需前端构建工具。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "luckytri",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "让由技术诞生的她,在时间、记忆、相遇与选择中逐渐形成自己的方向",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -48,8 +48,30 @@
48
48
  "plugins/weather/luckytri-plugin.json",
49
49
  "plugins/sdk/index.d.ts",
50
50
  "plugins/sdk/testing.js",
51
- "docs/zh/*.md",
52
- "docs/en/*.md",
51
+ "docs/zh/CHANGELOG.md",
52
+ "docs/zh/architecture.md",
53
+ "docs/zh/chat-style.md",
54
+ "docs/zh/cognition.md",
55
+ "docs/zh/connect.md",
56
+ "docs/zh/guide.md",
57
+ "docs/zh/her-life.md",
58
+ "docs/zh/npm-release.md",
59
+ "docs/zh/plugins.md",
60
+ "docs/zh/recovery.md",
61
+ "docs/zh/time.md",
62
+ "docs/zh/webui.md",
63
+ "docs/en/CHANGELOG.md",
64
+ "docs/en/architecture.md",
65
+ "docs/en/chat-style.md",
66
+ "docs/en/cognition.md",
67
+ "docs/en/connect.md",
68
+ "docs/en/guide.md",
69
+ "docs/en/her-life.md",
70
+ "docs/en/npm-release.md",
71
+ "docs/en/plugins.md",
72
+ "docs/en/recovery.md",
73
+ "docs/en/time.md",
74
+ "docs/en/webui.md",
53
75
  "docs/brand/*.png",
54
76
  ".github/SECURITY.md",
55
77
  "README.en.md",
@@ -1,3 +1,3 @@
1
- import{Dt as e,E as t,Et as n,G as r,H as i,I as a,J as o,M as s,P as c,Q as l,St as u,Tt as d,U as f,W as p,X as m,Y as h,Z as g,_t as _,a as v,at as y,bt as b,dt as x,et as S,f as C,ft as w,gt as T,it as E,j as D,lt as O,m as k,n as A,o as j,rt as M,s as N,t as P,tt as F,ut as ee,v as I,wt as L,yt as R,z}from"./Empty-CAGOJsfD.js";import{g as te,y as B}from"./mind-CBTkFje2.js";import{c as V,f as H,h as U,m as W,n as G,o as ne,p as K,u as q,y as re}from"./index-L0bHax8C.js";import{t as ie}from"./media-BBzOAfNG.js";import{t as J}from"./Field-CRz-JmN1.js";async function ae(e,t){let n=new URLSearchParams({session:e});return t!==void 0&&n.set(`after`,String(t)),k(`/core/events?`+n.toString())}async function oe(e,t={}){let n=new URLSearchParams({session:e});return t.limit&&n.set(`limit`,String(t.limit)),t.compact&&n.set(`compact`,`1`),k(`/core/traces?`+n.toString())}async function Y(e){return k(`/core/traces/`+e)}async function se(e){return k(`/simulate`,`POST`,e)}async function ce(e,t){return k(`/decisions/`+e+`/feedback`,`POST`,{tag:t})}async function X(e){return k(`/core/replay`,`POST`,e)}async function le(e){return k(`/core/sessions`,`POST`,e)}async function ue(e,t){return k(`/core/sessions/`+encodeURIComponent(e),`PATCH`,{enabled:t})}async function de(e,t){return k(`/core/sessions/`+encodeURIComponent(e)+`/archive`,`PATCH`,{archived:t})}async function fe(e){return k(`/core/sessions/`+encodeURIComponent(e),`DELETE`,{})}async function pe(e,t){return k(`/core/sessions/`+encodeURIComponent(e),`PUT`,t)}async function me(e){return k(`/core/sessions/`+encodeURIComponent(e)+`/summaries`)}async function he(e){return k(`/core/sessions/`+encodeURIComponent(e)+`/context`,`DELETE`,{})}var ge={class:`session-list`},_e={class:`list-head`},Z=[`placeholder`,`aria-label`],ve={class:`rows scroll-pane`},Q=[`data-pick`,`aria-current`,`onClick`],ye={class:`who`},be=[`aria-label`],xe=[`title`],Se=[`checked`,`aria-label`,`onChange`],Ce={key:0,class:`muted empty-line`},we={key:1,class:`archive-list`},Te={class:`row`},Ee=[`data-restore-session`,`onClick`],De=[`data-delete-session`,`onClick`],Oe=A(M({__name:`SessionList`,props:{sessions:{},selected:{},unread:{}},emits:[`select`,`add`,`toggle`,`restore`,`remove`],setup(t,{emit:s}){let c=t,f=s,p=u(``),m=o(()=>c.sessions.filter(e=>!e.archived&&`${e.name} ${e.id}`.toLowerCase().includes(p.value.toLowerCase()))),_=o(()=>c.sessions.filter(e=>e.archived));return(o,s)=>(x(),l(`div`,ge,[h(`div`,_e,[h(`h2`,null,[S(e(L(a)(`会话`))+` `,1),h(`small`,null,e(m.value.length),1)]),h(`button`,{class:`small primary`,onClick:s[0]||=e=>f(`add`)},e(L(a)(`+ 添加会话`)),1)]),b(h(`input`,{"onUpdate:modelValue":s[1]||=e=>p.value=e,type:`search`,placeholder:L(a)(`搜索名称或号码`),"aria-label":L(a)(`搜索会话`)},null,8,Z),[[i,p.value]]),h(`div`,ve,[(x(!0),l(r,null,w(m.value,r=>(x(),l(`div`,{key:r.id,class:d([`session-row`,{selected:r.id===t.selected,paused:!r.enabled}])},[h(`button`,{class:`row-main`,"data-pick":r.id,"aria-current":r.id===t.selected?`true`:void 0,onClick:e=>f(`select`,r.id)},[h(`span`,{class:`badge`,style:n({"--hue":L(H)(r.id)})},e(r.kind===`private`?L(a)(`私`):L(a)(`群`)),5),h(`span`,ye,[h(`b`,null,e(L(U)(r)),1),h(`small`,null,e(r.enabled?L(a)(`参与中`):L(a)(`已暂停`)),1)]),t.unread[r.id]?(x(),l(`span`,{key:0,class:`unread`,"aria-label":L(a)(`{v} 条没细看`,{v:t.unread[r.id]})},e(t.unread[r.id]),9,be)):g(``,!0)],8,Q),h(`label`,{class:`mini-switch`,title:r.enabled?L(a)(`暂停参与`):L(a)(`开启参与`)},[h(`input`,{type:`checkbox`,checked:r.enabled,"aria-label":L(a)(`参与:{v}`,{v:L(U)(r)}),onChange:e=>f(`toggle`,r)},null,40,Se)],8,xe)],2))),128)),m.value.length?g(``,!0):(x(),l(`p`,Ce,e(L(a)(`暂无匹配的会话。`)),1)),_.value.length?(x(),l(`details`,we,[h(`summary`,null,e(L(a)(`已归档 · {length}`,{length:_.value.length})),1),(x(!0),l(r,null,w(_.value,t=>(x(),l(`article`,{key:t.id},[h(`b`,null,e(L(U)(t)),1),h(`div`,Te,[h(`button`,{class:`small`,"data-restore-session":t.id,onClick:e=>f(`restore`,t.id)},e(L(a)(`恢复`)),9,Ee),h(`button`,{class:`small danger`,"data-delete-session":t.id,onClick:e=>f(`remove`,t.id)},e(L(a)(`永久删除`)),9,De)])]))),128))])):g(``,!0)])]))}}),[[`__scopeId`,`data-v-9b8dcbac`]]),ke={class:`muted`},Ae={key:0,class:`notice`,role:`status`},je=[`pattern`,`inputmode`],Me=[`disabled`],Ne=M({__name:`AddSession`,props:{open:{type:Boolean},channel:{},ready:{type:Boolean}},emits:[`close`,`add`],setup(t,{emit:n}){let r=t,i=u(`group`),s=n,c=o(()=>r.channel===`qqbot`),d=o(()=>c.value?`[0-9A-Za-z_\\-]{8,64}`:`\\d{4,20}`);function f(e){let t=e.target;s(`add`,{...Object.fromEntries(new FormData(t)),channel:r.channel})}return(n,r)=>(x(),m(ne,{open:t.open,title:L(a)(`添加群聊 / 私聊`),eyebrow:L(a)(`NEW PLACE`),width:`440px`,onClose:r[1]||=e=>s(`close`)},{default:R(()=>[h(`form`,{id:`addSession`,class:`stack`,onSubmit:p(f,[`prevent`])},[h(`p`,ke,e(L(a)(`添加之后再决定要不要让 TA 参与;开不开口仍由 TA 自己决定。`)),1),c.value&&!t.ready?(x(),l(`p`,Ae,e(L(a)(`请先在「连接 QQ」里填写机器人的 AppID`)),1)):g(``,!0),F(J,{label:L(a)(`类型`)},{default:R(()=>[F(V,{modelValue:i.value,"onUpdate:modelValue":r[0]||=e=>i.value=e,name:`kind`,"aria-label":L(a)(`类型`),options:[{value:`group`,label:L(a)(`群聊`)},{value:`private`,label:L(a)(`私聊`)}]},null,8,[`modelValue`,`aria-label`,`options`])]),_:1},8,[`label`]),F(J,{label:c.value?L(a)(`群 openid / 用户 openid`):L(a)(`群号 / QQ 号`),hint:c.value?L(a)(`8–64 位字母、数字、下划线或短横线。官方平台的会话通常会在有人 @ 她或私聊她时自动出现,这里只用于提前登记。`):L(a)(`4–20 位数字`)},{default:R(()=>[h(`input`,{name:`id`,required:``,pattern:d.value,inputmode:c.value?`text`:`numeric`,autocomplete:`off`},null,8,je)]),_:1},8,[`label`,`hint`]),F(J,{label:L(a)(`显示名称`)},{default:R(()=>[...r[2]||=[h(`input`,{name:`name`,required:``,maxlength:`100`,autocomplete:`off`},null,-1)]]),_:1},8,[`label`]),h(`button`,{class:`primary`,disabled:c.value&&!t.ready},e(L(a)(`添加会话`)),9,Me)],32)]),_:1},8,[`open`,`title`,`eyebrow`]))}}),Pe={class:`transcript`},Fe={class:`t-head`},Ie=[`aria-label`,`title`],Le={class:`t-title`},Re={id:`liveStatus`,class:`faint`},ze={class:`t-tools`},Be=[`disabled`],Ve={id:`liveMessages`,class:`chat-messages scroll-pane`},He={key:0,class:`day-label`},Ue=[`data-status`],We={key:0},Ge={class:`body`},Ke={class:`message-meta`},qe={key:0,class:`chip`,"data-tone":`warn`},Je={class:`text`},Ye=[`aria-expanded`,`onClick`],Xe={key:0,class:`why`},Ze={key:0,class:`muted`},Qe={key:0},$e={key:1},et={key:2,class:`fb`},tt={class:`composer-note`},nt={class:`chip`,"data-tone":`warn`},rt={class:`faint`},it={class:`composer-row`},at={class:`uid`},ot={class:`sr-only`},st=[`title`],ct=[`placeholder`,`onKeydown`],lt={class:`check mention`},ut=[`disabled`],dt={key:1,class:`composer off`},ft={class:`faint`},pt=A(M({__name:`Transcript`,props:{session:{},sessionId:{},events:{},traces:{},decisions:{},status:{},demo:{type:Boolean},compact:{type:Boolean},sending:{type:Boolean}},emits:[`simulate`,`feedback`,`openList`,`openReplay`],setup(t,{expose:_,emit:v}){let C=t,T=v,E=c({glanced:D(`TA 扫了一眼`),silent:D(`TA 看了,没出声`),deferred:D(`TA 睡着了,醒来再看`)}),O=u(`10001`),k=u(``),A=u(!0),j=u(),M=u({}),ee=()=>B(s(),{month:`long`,day:`numeric`,weekday:`short`}),I=o(()=>{let e=C.events.map(e=>({type:`message`,key:`m`+e.seq,time:e.time,event:e})),t=C.events[0]?.time??2**53-1;for(let n of C.traces)E[n.status]&&n.time>=t&&e.push({type:`divider`,key:`t`+n.id,time:n.time,status:n.status,reasons:[n.reason].filter(Boolean),count:1});e.sort((e,t)=>e.time-t.time);let n=[],r=``;for(let t of e){let e=ee().format(t.time);e!==r&&(r=e,n.push({type:`day`,key:`d`+t.time,time:t.time,label:e}));let i=n[n.length-1];if(t.type===`divider`&&i?.type===`divider`&&i.status===t.status){i.count+=1,t.reasons[0]&&!i.reasons.includes(t.reasons[0])&&i.reasons.push(t.reasons[0]);continue}n.push(t)}return n});function R(e){let t=String(e.payload.text||``);return C.decisions.filter(n=>n.session_id===e.session_id&&n.reply&&n.reply.includes(t)&&Math.abs(n.time-e.time)<6e5).sort((t,n)=>Math.abs(t.time-e.time)-Math.abs(n.time-e.time))[0]}function te(e){return C.traces.filter(t=>t.status===`sent`&&t.time<=e.time+1e3).sort((e,t)=>t.time-e.time)[0]}async function U(e){if(M.value[e.seq]){let{[e.seq]:t,...n}=M.value;M.value=n;return}M.value={...M.value,[e.seq]:{loading:!0,detail:null}};let t=te(e),n=null;try{n=t?await Y(t.id):null}catch{n=null}M.value[e.seq]&&(M.value={...M.value,[e.seq]:{loading:!1,detail:n}})}async function W(){await y(),j.value?.focus()}function G(){k.value.trim()&&!C.sending&&(T(`simulate`,{userId:O.value,text:k.value,mentioned:A.value}),k.value=``)}return _({focusComposer:W}),(o,s)=>(x(),l(`section`,Pe,[h(`header`,Fe,[t.compact?(x(),l(`button`,{key:0,class:`icon-button`,"aria-label":L(a)(`全部会话`),title:L(a)(`全部会话`),onClick:s[0]||=e=>T(`openList`)},` ☰ `,8,Ie)):g(``,!0),t.session?(x(),l(`span`,{key:1,class:`badge`,style:n({"--hue":L(H)(t.session.id)})},e(t.session.kind===`private`?L(a)(`私`):L(a)(`群`)),5)):g(``,!0),h(`div`,Le,[h(`h2`,null,e(t.session?.name||L(a)(`选择一段对话`)),1),h(`span`,Re,e(t.status),1)]),h(`div`,ze,[h(`button`,{class:`small sim-button`,disabled:!t.sessionId,onClick:W},e(L(a)(`模拟消息`)),9,Be),h(`button`,{class:`small`,onClick:s[1]||=e=>T(`openReplay`)},e(L(a)(`回到那一刻`)),1)])]),h(`div`,Ve,[(x(!0),l(r,null,w(I.value,t=>(x(),l(r,{key:t.key},[t.type===`day`?(x(),l(`div`,He,[h(`span`,null,e(t.label),1)])):t.type===`divider`?(x(),l(`div`,{key:1,class:`divider`,"data-status":t.status},[h(`span`,null,e(L(E)[t.status])+e(t.count>1?` × ${t.count}`:``),1),t.reasons.length?(x(),l(`small`,We,e(t.reasons.slice(0,2).join(`;`)),1)):g(``,!0)],8,Ue)):(x(),l(`article`,{key:2,class:d([`message`,{bot:t.event.role===`assistant`,simulated:t.event.payload.simulated}])},[t.event.role===`assistant`?g(``,!0):(x(),l(`span`,{key:0,class:`avatar`,style:n({"--hue":L(H)(String(t.event.payload.userId||t.event.payload.name))}),"aria-hidden":`true`},e(L(K)(t.event.payload.name)),5)),h(`div`,Ge,[h(`div`,Ke,[h(`b`,null,e(t.event.payload.name),1),h(`time`,null,e(L(q)(t.event.time)),1),t.event.payload.simulated?(x(),l(`span`,qe,e(L(a)(`模拟`)),1)):g(``,!0)]),h(`p`,Je,e(t.event.payload.text),1),t.event.role===`assistant`?(x(),l(r,{key:0},[h(`button`,{class:`text-button why-toggle`,"aria-expanded":!!M.value[t.event.seq],onClick:e=>U(t.event)},e(M.value[t.event.seq]?L(a)(`收起`):L(a)(`为什么这么说`)),9,Ye),M.value[t.event.seq]?(x(),l(`div`,Xe,[M.value[t.event.seq].loading?(x(),l(`p`,Ze,e(L(a)(`正在翻当时的记录…`)),1)):(x(),l(r,{key:1},[M.value[t.event.seq].detail?.data?.decision?.appraisal?(x(),l(`p`,Qe,[h(`b`,null,e(L(a)(`TA 当时的理解:`)),1),S(e(M.value[t.event.seq].detail.data.decision.appraisal),1)])):g(``,!0),h(`p`,null,[h(`b`,null,e(L(a)(`理由:`)),1),S(e(M.value[t.event.seq].detail?.data?.reason||M.value[t.event.seq].detail?.data?.decision?.reason||R(t.event)?.reason||L(a)(`没有留下理由。`)),1)]),M.value[t.event.seq].detail?.data?.snapshot?.knowledge?.length?(x(),l(`p`,$e,[h(`b`,null,e(L(a)(`引用的资料:`)),1),S(e(M.value[t.event.seq].detail.data.snapshot.knowledge.map(e=>e.title).join(`、`)),1)])):g(``,!0),R(t.event)?(x(),l(`label`,et,[S(e(L(a)(`这句怎么样?`))+` `,1),F(V,{"model-value":R(t.event).feedback||``,"aria-label":L(a)(`这句怎么样?`),options:[{value:``,label:L(a)(`选择评价`)},...Object.entries(L(N).health.feedbackLabels||{}).map(([e,t])=>({value:e,label:String(t)}))],"onUpdate:modelValue":e=>T(`feedback`,R(t.event).id,e)},null,8,[`model-value`,`aria-label`,`options`,`onUpdate:modelValue`])])):g(``,!0)],64))])):g(``,!0)],64)):g(``,!0)])],2))],64))),128)),t.events.length?g(``,!0):(x(),m(P,{key:0,title:t.sessionId?L(a)(`等待新的消息`):L(a)(`选择一段对话`),text:L(a)(`群聊与私聊消息会在这里实时出现;TA 扫一眼、没出声也会留下一条分隔线。`)},null,8,[`title`,`text`]))]),t.demo?(x(),l(`form`,{key:0,id:`simulate`,class:`composer`,onSubmit:p(G,[`prevent`])},[h(`div`,tt,[h(`span`,nt,e(L(a)(`模拟消息`)),1),h(`span`,rt,e(L(a)(`作为一条模拟消息走完整流程,写进模拟会话;不会发到 QQ,也不进入真实记忆。`)),1)]),h(`div`,it,[h(`label`,at,[h(`span`,ot,e(L(a)(`体验用户 ID`)),1),b(h(`input`,{"onUpdate:modelValue":s[2]||=e=>O.value=e,name:`userId`,pattern:`\\d{4,20}`,required:``,title:L(a)(`体验用户 ID`)},null,8,st),[[i,O.value]])]),b(h(`textarea`,{ref_key:`composer`,ref:j,"onUpdate:modelValue":s[3]||=e=>k.value=e,name:`text`,rows:`1`,placeholder:L(a)(`以这位群友的身份说一句…`),required:``,onKeydown:f(p(G,[`exact`,`prevent`]),[`enter`])},null,40,ct),[[i,k.value]]),h(`label`,lt,[b(h(`input`,{"onUpdate:modelValue":s[4]||=e=>A.value=e,type:`checkbox`},null,512),[[z,A.value]]),S(e(L(a)(`视为 @`)),1)]),h(`button`,{class:`primary`,disabled:t.sending||!t.sessionId},e(t.sending?L(a)(`TA 在想…`):L(a)(`发送模拟消息`)),9,ut)])],32)):(x(),l(`div`,dt,[h(`span`,ft,e(L(a)(`真实模式下不能模拟消息。想看看 TA 会怎么回,可以「和 TA 聊聊」——那是试聊,什么都不写入。`)),1),h(`button`,{class:`small`,onClick:s[5]||=e=>L(N).chatOpen=!0},e(L(a)(`和 TA 聊聊`)),1)]))]))}}),[[`__scopeId`,`data-v-849aeb0f`]]),mt={class:`panel`},ht={key:0,class:`panel-body`},gt={key:1,class:`panel-body scroll-pane`},_t={class:`here`},vt={class:`facts`},yt={class:`eyebrow`},bt={key:1,class:`muted`},xt={key:2,class:`faint`},St={class:`eyebrow`},Ct={class:`faint`},wt={class:`row actions`},Tt=[`data-toggle`],Et=[`data-archive`],Dt=[`open`],Ot=[`data-session`],kt={class:`faint`},At=[`value`],jt={class:`faint`},Mt={class:`check`},Nt={class:`advanced-policy`},Pt={class:`stack tight`},Ft={class:`check`},It={class:`check`},Lt={class:`check`},Rt={class:`save-bar`},zt={class:`primary`,type:`submit`},Bt={class:`faint`},Vt={class:`fold summary-list`},Ht={key:0,class:`muted`},Ut={class:`faint`},Wt={key:0},Gt={key:2,class:`panel-body feedback-pane`},Kt={class:`faint`},qt={id:`feedbackList`,class:`scroll-pane`},Jt={class:`faint`},Yt={class:`reply-excerpt`},Xt={key:0,class:`muted`},Zt={class:`pagination`},Qt=[`disabled`],$t=[`disabled`],$=6,en=A(M({__name:`SessionPanel`,props:E({session:{},group:{},summaries:{},decisions:{}},{settingsOpen:{type:Boolean,default:!1},settingsOpenModifiers:{},tab:{default:`here`},tabModifiers:{}}),emits:E([`toggle`,`archive`,`clear`,`save`,`feedback`],[`update:settingsOpen`,`update:tab`]),setup(t,{emit:n}){let s=t,f=T(t,`settingsOpen`),m=T(t,`tab`),v=n,y=c([D(`近期细摘要`),D(`中期摘要`),D(`较早摘要`),D(`远期摘要`)]),C=u(0),E=o(()=>s.decisions.filter(e=>e.session_id===s.session?.id&&e.reply)),O=o(()=>Math.max(1,Math.ceil(E.value.length/$))),k=u(!1),A=u({});_(()=>s.session?.policy,e=>{A.value={...e||{}}},{immediate:!0,deep:!0}),_(()=>s.session?.id,()=>{C.value=0,k.value=!1});function j(e){let t=e?.face;return t?[t.role,t.tone,t.content].filter(Boolean).join(`
1
+ import{Dt as e,E as t,Et as n,G as r,H as i,I as a,J as o,M as s,P as c,Q as l,St as u,Tt as d,U as f,W as p,X as m,Y as h,Z as g,_t as _,a as v,at as y,bt as b,dt as x,et as S,f as C,ft as w,gt as T,it as E,j as D,lt as O,m as k,n as A,o as j,rt as M,s as N,t as P,tt as F,ut as ee,v as I,wt as L,yt as R,z}from"./Empty-BSmsWoGM.js";import{g as te,y as B}from"./mind-CQkvddhx.js";import{c as V,f as H,h as U,m as W,n as G,o as ne,p as K,u as q,y as re}from"./index-BaXEYeFH.js";import{t as ie}from"./media-8uRD5Ocs.js";import{t as J}from"./Field-tUGp0-YL.js";async function ae(e,t){let n=new URLSearchParams({session:e});return t!==void 0&&n.set(`after`,String(t)),k(`/core/events?`+n.toString())}async function oe(e,t={}){let n=new URLSearchParams({session:e});return t.limit&&n.set(`limit`,String(t.limit)),t.compact&&n.set(`compact`,`1`),k(`/core/traces?`+n.toString())}async function Y(e){return k(`/core/traces/`+e)}async function se(e){return k(`/simulate`,`POST`,e)}async function ce(e,t){return k(`/decisions/`+e+`/feedback`,`POST`,{tag:t})}async function X(e){return k(`/core/replay`,`POST`,e)}async function le(e){return k(`/core/sessions`,`POST`,e)}async function ue(e,t){return k(`/core/sessions/`+encodeURIComponent(e),`PATCH`,{enabled:t})}async function de(e,t){return k(`/core/sessions/`+encodeURIComponent(e)+`/archive`,`PATCH`,{archived:t})}async function fe(e){return k(`/core/sessions/`+encodeURIComponent(e),`DELETE`,{})}async function pe(e,t){return k(`/core/sessions/`+encodeURIComponent(e),`PUT`,t)}async function me(e){return k(`/core/sessions/`+encodeURIComponent(e)+`/summaries`)}async function he(e){return k(`/core/sessions/`+encodeURIComponent(e)+`/context`,`DELETE`,{})}var ge={class:`session-list`},_e={class:`list-head`},Z=[`placeholder`,`aria-label`],ve={class:`rows scroll-pane`},Q=[`data-pick`,`aria-current`,`onClick`],ye={class:`who`},be=[`aria-label`],xe=[`title`],Se=[`checked`,`aria-label`,`onChange`],Ce={key:0,class:`muted empty-line`},we={key:1,class:`archive-list`},Te={class:`row`},Ee=[`data-restore-session`,`onClick`],De=[`data-delete-session`,`onClick`],Oe=A(M({__name:`SessionList`,props:{sessions:{},selected:{},unread:{}},emits:[`select`,`add`,`toggle`,`restore`,`remove`],setup(t,{emit:s}){let c=t,f=s,p=u(``),m=o(()=>c.sessions.filter(e=>!e.archived&&`${e.name} ${e.id}`.toLowerCase().includes(p.value.toLowerCase()))),_=o(()=>c.sessions.filter(e=>e.archived));return(o,s)=>(x(),l(`div`,ge,[h(`div`,_e,[h(`h2`,null,[S(e(L(a)(`会话`))+` `,1),h(`small`,null,e(m.value.length),1)]),h(`button`,{class:`small primary`,onClick:s[0]||=e=>f(`add`)},e(L(a)(`+ 添加会话`)),1)]),b(h(`input`,{"onUpdate:modelValue":s[1]||=e=>p.value=e,type:`search`,placeholder:L(a)(`搜索名称或号码`),"aria-label":L(a)(`搜索会话`)},null,8,Z),[[i,p.value]]),h(`div`,ve,[(x(!0),l(r,null,w(m.value,r=>(x(),l(`div`,{key:r.id,class:d([`session-row`,{selected:r.id===t.selected,paused:!r.enabled}])},[h(`button`,{class:`row-main`,"data-pick":r.id,"aria-current":r.id===t.selected?`true`:void 0,onClick:e=>f(`select`,r.id)},[h(`span`,{class:`badge`,style:n({"--hue":L(H)(r.id)})},e(r.kind===`private`?L(a)(`私`):L(a)(`群`)),5),h(`span`,ye,[h(`b`,null,e(L(U)(r)),1),h(`small`,null,e(r.enabled?L(a)(`参与中`):L(a)(`已暂停`)),1)]),t.unread[r.id]?(x(),l(`span`,{key:0,class:`unread`,"aria-label":L(a)(`{v} 条没细看`,{v:t.unread[r.id]})},e(t.unread[r.id]),9,be)):g(``,!0)],8,Q),h(`label`,{class:`mini-switch`,title:r.enabled?L(a)(`暂停参与`):L(a)(`开启参与`)},[h(`input`,{type:`checkbox`,checked:r.enabled,"aria-label":L(a)(`参与:{v}`,{v:L(U)(r)}),onChange:e=>f(`toggle`,r)},null,40,Se)],8,xe)],2))),128)),m.value.length?g(``,!0):(x(),l(`p`,Ce,e(L(a)(`暂无匹配的会话。`)),1)),_.value.length?(x(),l(`details`,we,[h(`summary`,null,e(L(a)(`已归档 · {length}`,{length:_.value.length})),1),(x(!0),l(r,null,w(_.value,t=>(x(),l(`article`,{key:t.id},[h(`b`,null,e(L(U)(t)),1),h(`div`,Te,[h(`button`,{class:`small`,"data-restore-session":t.id,onClick:e=>f(`restore`,t.id)},e(L(a)(`恢复`)),9,Ee),h(`button`,{class:`small danger`,"data-delete-session":t.id,onClick:e=>f(`remove`,t.id)},e(L(a)(`永久删除`)),9,De)])]))),128))])):g(``,!0)])]))}}),[[`__scopeId`,`data-v-9b8dcbac`]]),ke={class:`muted`},Ae={key:0,class:`notice`,role:`status`},je=[`pattern`,`inputmode`],Me=[`disabled`],Ne=M({__name:`AddSession`,props:{open:{type:Boolean},channel:{},ready:{type:Boolean}},emits:[`close`,`add`],setup(t,{emit:n}){let r=t,i=u(`group`),s=n,c=o(()=>r.channel===`qqbot`),d=o(()=>c.value?`[0-9A-Za-z_\\-]{8,64}`:`\\d{4,20}`);function f(e){let t=e.target;s(`add`,{...Object.fromEntries(new FormData(t)),channel:r.channel})}return(n,r)=>(x(),m(ne,{open:t.open,title:L(a)(`添加群聊 / 私聊`),eyebrow:L(a)(`NEW PLACE`),width:`440px`,onClose:r[1]||=e=>s(`close`)},{default:R(()=>[h(`form`,{id:`addSession`,class:`stack`,onSubmit:p(f,[`prevent`])},[h(`p`,ke,e(L(a)(`添加之后再决定要不要让 TA 参与;开不开口仍由 TA 自己决定。`)),1),c.value&&!t.ready?(x(),l(`p`,Ae,e(L(a)(`请先在「连接 QQ」里填写机器人的 AppID`)),1)):g(``,!0),F(J,{label:L(a)(`类型`)},{default:R(()=>[F(V,{modelValue:i.value,"onUpdate:modelValue":r[0]||=e=>i.value=e,name:`kind`,"aria-label":L(a)(`类型`),options:[{value:`group`,label:L(a)(`群聊`)},{value:`private`,label:L(a)(`私聊`)}]},null,8,[`modelValue`,`aria-label`,`options`])]),_:1},8,[`label`]),F(J,{label:c.value?L(a)(`群 openid / 用户 openid`):L(a)(`群号 / QQ 号`),hint:c.value?L(a)(`8–64 位字母、数字、下划线或短横线。官方平台的会话通常会在有人 @ 她或私聊她时自动出现,这里只用于提前登记。`):L(a)(`4–20 位数字`)},{default:R(()=>[h(`input`,{name:`id`,required:``,pattern:d.value,inputmode:c.value?`text`:`numeric`,autocomplete:`off`},null,8,je)]),_:1},8,[`label`,`hint`]),F(J,{label:L(a)(`显示名称`)},{default:R(()=>[...r[2]||=[h(`input`,{name:`name`,required:``,maxlength:`100`,autocomplete:`off`},null,-1)]]),_:1},8,[`label`]),h(`button`,{class:`primary`,disabled:c.value&&!t.ready},e(L(a)(`添加会话`)),9,Me)],32)]),_:1},8,[`open`,`title`,`eyebrow`]))}}),Pe={class:`transcript`},Fe={class:`t-head`},Ie=[`aria-label`,`title`],Le={class:`t-title`},Re={id:`liveStatus`,class:`faint`},ze={class:`t-tools`},Be=[`disabled`],Ve={id:`liveMessages`,class:`chat-messages scroll-pane`},He={key:0,class:`day-label`},Ue=[`data-status`],We={key:0},Ge={class:`body`},Ke={class:`message-meta`},qe={key:0,class:`chip`,"data-tone":`warn`},Je={class:`text`},Ye=[`aria-expanded`,`onClick`],Xe={key:0,class:`why`},Ze={key:0,class:`muted`},Qe={key:0},$e={key:1},et={key:2,class:`fb`},tt={class:`composer-note`},nt={class:`chip`,"data-tone":`warn`},rt={class:`faint`},it={class:`composer-row`},at={class:`uid`},ot={class:`sr-only`},st=[`title`],ct=[`placeholder`,`onKeydown`],lt={class:`check mention`},ut=[`disabled`],dt={key:1,class:`composer off`},ft={class:`faint`},pt=A(M({__name:`Transcript`,props:{session:{},sessionId:{},events:{},traces:{},decisions:{},status:{},demo:{type:Boolean},compact:{type:Boolean},sending:{type:Boolean}},emits:[`simulate`,`feedback`,`openList`,`openReplay`],setup(t,{expose:_,emit:v}){let C=t,T=v,E=c({glanced:D(`TA 扫了一眼`),silent:D(`TA 看了,没出声`),deferred:D(`TA 睡着了,醒来再看`)}),O=u(`10001`),k=u(``),A=u(!0),j=u(),M=u({}),ee=()=>B(s(),{month:`long`,day:`numeric`,weekday:`short`}),I=o(()=>{let e=C.events.map(e=>({type:`message`,key:`m`+e.seq,time:e.time,event:e})),t=C.events[0]?.time??2**53-1;for(let n of C.traces)E[n.status]&&n.time>=t&&e.push({type:`divider`,key:`t`+n.id,time:n.time,status:n.status,reasons:[n.reason].filter(Boolean),count:1});e.sort((e,t)=>e.time-t.time);let n=[],r=``;for(let t of e){let e=ee().format(t.time);e!==r&&(r=e,n.push({type:`day`,key:`d`+t.time,time:t.time,label:e}));let i=n[n.length-1];if(t.type===`divider`&&i?.type===`divider`&&i.status===t.status){i.count+=1,t.reasons[0]&&!i.reasons.includes(t.reasons[0])&&i.reasons.push(t.reasons[0]);continue}n.push(t)}return n});function R(e){let t=String(e.payload.text||``);return C.decisions.filter(n=>n.session_id===e.session_id&&n.reply&&n.reply.includes(t)&&Math.abs(n.time-e.time)<6e5).sort((t,n)=>Math.abs(t.time-e.time)-Math.abs(n.time-e.time))[0]}function te(e){return C.traces.filter(t=>t.status===`sent`&&t.time<=e.time+1e3).sort((e,t)=>t.time-e.time)[0]}async function U(e){if(M.value[e.seq]){let{[e.seq]:t,...n}=M.value;M.value=n;return}M.value={...M.value,[e.seq]:{loading:!0,detail:null}};let t=te(e),n=null;try{n=t?await Y(t.id):null}catch{n=null}M.value[e.seq]&&(M.value={...M.value,[e.seq]:{loading:!1,detail:n}})}async function W(){await y(),j.value?.focus()}function G(){k.value.trim()&&!C.sending&&(T(`simulate`,{userId:O.value,text:k.value,mentioned:A.value}),k.value=``)}return _({focusComposer:W}),(o,s)=>(x(),l(`section`,Pe,[h(`header`,Fe,[t.compact?(x(),l(`button`,{key:0,class:`icon-button`,"aria-label":L(a)(`全部会话`),title:L(a)(`全部会话`),onClick:s[0]||=e=>T(`openList`)},` ☰ `,8,Ie)):g(``,!0),t.session?(x(),l(`span`,{key:1,class:`badge`,style:n({"--hue":L(H)(t.session.id)})},e(t.session.kind===`private`?L(a)(`私`):L(a)(`群`)),5)):g(``,!0),h(`div`,Le,[h(`h2`,null,e(t.session?.name||L(a)(`选择一段对话`)),1),h(`span`,Re,e(t.status),1)]),h(`div`,ze,[h(`button`,{class:`small sim-button`,disabled:!t.sessionId,onClick:W},e(L(a)(`模拟消息`)),9,Be),h(`button`,{class:`small`,onClick:s[1]||=e=>T(`openReplay`)},e(L(a)(`回到那一刻`)),1)])]),h(`div`,Ve,[(x(!0),l(r,null,w(I.value,t=>(x(),l(r,{key:t.key},[t.type===`day`?(x(),l(`div`,He,[h(`span`,null,e(t.label),1)])):t.type===`divider`?(x(),l(`div`,{key:1,class:`divider`,"data-status":t.status},[h(`span`,null,e(L(E)[t.status])+e(t.count>1?` × ${t.count}`:``),1),t.reasons.length?(x(),l(`small`,We,e(t.reasons.slice(0,2).join(`;`)),1)):g(``,!0)],8,Ue)):(x(),l(`article`,{key:2,class:d([`message`,{bot:t.event.role===`assistant`,simulated:t.event.payload.simulated}])},[t.event.role===`assistant`?g(``,!0):(x(),l(`span`,{key:0,class:`avatar`,style:n({"--hue":L(H)(String(t.event.payload.userId||t.event.payload.name))}),"aria-hidden":`true`},e(L(K)(t.event.payload.name)),5)),h(`div`,Ge,[h(`div`,Ke,[h(`b`,null,e(t.event.payload.name),1),h(`time`,null,e(L(q)(t.event.time)),1),t.event.payload.simulated?(x(),l(`span`,qe,e(L(a)(`模拟`)),1)):g(``,!0)]),h(`p`,Je,e(t.event.payload.text),1),t.event.role===`assistant`?(x(),l(r,{key:0},[h(`button`,{class:`text-button why-toggle`,"aria-expanded":!!M.value[t.event.seq],onClick:e=>U(t.event)},e(M.value[t.event.seq]?L(a)(`收起`):L(a)(`为什么这么说`)),9,Ye),M.value[t.event.seq]?(x(),l(`div`,Xe,[M.value[t.event.seq].loading?(x(),l(`p`,Ze,e(L(a)(`正在翻当时的记录…`)),1)):(x(),l(r,{key:1},[M.value[t.event.seq].detail?.data?.decision?.appraisal?(x(),l(`p`,Qe,[h(`b`,null,e(L(a)(`TA 当时的理解:`)),1),S(e(M.value[t.event.seq].detail.data.decision.appraisal),1)])):g(``,!0),h(`p`,null,[h(`b`,null,e(L(a)(`理由:`)),1),S(e(M.value[t.event.seq].detail?.data?.reason||M.value[t.event.seq].detail?.data?.decision?.reason||R(t.event)?.reason||L(a)(`没有留下理由。`)),1)]),M.value[t.event.seq].detail?.data?.snapshot?.knowledge?.length?(x(),l(`p`,$e,[h(`b`,null,e(L(a)(`引用的资料:`)),1),S(e(M.value[t.event.seq].detail.data.snapshot.knowledge.map(e=>e.title).join(`、`)),1)])):g(``,!0),R(t.event)?(x(),l(`label`,et,[S(e(L(a)(`这句怎么样?`))+` `,1),F(V,{"model-value":R(t.event).feedback||``,"aria-label":L(a)(`这句怎么样?`),options:[{value:``,label:L(a)(`选择评价`)},...Object.entries(L(N).health.feedbackLabels||{}).map(([e,t])=>({value:e,label:String(t)}))],"onUpdate:modelValue":e=>T(`feedback`,R(t.event).id,e)},null,8,[`model-value`,`aria-label`,`options`,`onUpdate:modelValue`])])):g(``,!0)],64))])):g(``,!0)],64)):g(``,!0)])],2))],64))),128)),t.events.length?g(``,!0):(x(),m(P,{key:0,title:t.sessionId?L(a)(`等待新的消息`):L(a)(`选择一段对话`),text:L(a)(`群聊与私聊消息会在这里实时出现;TA 扫一眼、没出声也会留下一条分隔线。`)},null,8,[`title`,`text`]))]),t.demo?(x(),l(`form`,{key:0,id:`simulate`,class:`composer`,onSubmit:p(G,[`prevent`])},[h(`div`,tt,[h(`span`,nt,e(L(a)(`模拟消息`)),1),h(`span`,rt,e(L(a)(`作为一条模拟消息走完整流程,写进模拟会话;不会发到 QQ,也不进入真实记忆。`)),1)]),h(`div`,it,[h(`label`,at,[h(`span`,ot,e(L(a)(`体验用户 ID`)),1),b(h(`input`,{"onUpdate:modelValue":s[2]||=e=>O.value=e,name:`userId`,pattern:`\\d{4,20}`,required:``,title:L(a)(`体验用户 ID`)},null,8,st),[[i,O.value]])]),b(h(`textarea`,{ref_key:`composer`,ref:j,"onUpdate:modelValue":s[3]||=e=>k.value=e,name:`text`,rows:`1`,placeholder:L(a)(`以这位群友的身份说一句…`),required:``,onKeydown:f(p(G,[`exact`,`prevent`]),[`enter`])},null,40,ct),[[i,k.value]]),h(`label`,lt,[b(h(`input`,{"onUpdate:modelValue":s[4]||=e=>A.value=e,type:`checkbox`},null,512),[[z,A.value]]),S(e(L(a)(`视为 @`)),1)]),h(`button`,{class:`primary`,disabled:t.sending||!t.sessionId},e(t.sending?L(a)(`TA 在想…`):L(a)(`发送模拟消息`)),9,ut)])],32)):(x(),l(`div`,dt,[h(`span`,ft,e(L(a)(`真实模式下不能模拟消息。想看看 TA 会怎么回,可以「和 TA 聊聊」——那是试聊,什么都不写入。`)),1),h(`button`,{class:`small`,onClick:s[5]||=e=>L(N).chatOpen=!0},e(L(a)(`和 TA 聊聊`)),1)]))]))}}),[[`__scopeId`,`data-v-849aeb0f`]]),mt={class:`panel`},ht={key:0,class:`panel-body`},gt={key:1,class:`panel-body scroll-pane`},_t={class:`here`},vt={class:`facts`},yt={class:`eyebrow`},bt={key:1,class:`muted`},xt={key:2,class:`faint`},St={class:`eyebrow`},Ct={class:`faint`},wt={class:`row actions`},Tt=[`data-toggle`],Et=[`data-archive`],Dt=[`open`],Ot=[`data-session`],kt={class:`faint`},At=[`value`],jt={class:`faint`},Mt={class:`check`},Nt={class:`advanced-policy`},Pt={class:`stack tight`},Ft={class:`check`},It={class:`check`},Lt={class:`check`},Rt={class:`save-bar`},zt={class:`primary`,type:`submit`},Bt={class:`faint`},Vt={class:`fold summary-list`},Ht={key:0,class:`muted`},Ut={class:`faint`},Wt={key:0},Gt={key:2,class:`panel-body feedback-pane`},Kt={class:`faint`},qt={id:`feedbackList`,class:`scroll-pane`},Jt={class:`faint`},Yt={class:`reply-excerpt`},Xt={key:0,class:`muted`},Zt={class:`pagination`},Qt=[`disabled`],$t=[`disabled`],$=6,en=A(M({__name:`SessionPanel`,props:E({session:{},group:{},summaries:{},decisions:{}},{settingsOpen:{type:Boolean,default:!1},settingsOpenModifiers:{},tab:{default:`here`},tabModifiers:{}}),emits:E([`toggle`,`archive`,`clear`,`save`,`feedback`],[`update:settingsOpen`,`update:tab`]),setup(t,{emit:n}){let s=t,f=T(t,`settingsOpen`),m=T(t,`tab`),v=n,y=c([D(`近期细摘要`),D(`中期摘要`),D(`较早摘要`),D(`远期摘要`)]),C=u(0),E=o(()=>s.decisions.filter(e=>e.session_id===s.session?.id&&e.reply)),O=o(()=>Math.max(1,Math.ceil(E.value.length/$))),k=u(!1),A=u({});_(()=>s.session?.policy,e=>{A.value={...e||{}}},{immediate:!0,deep:!0}),_(()=>s.session?.id,()=>{C.value=0,k.value=!1});function j(e){let t=e?.face;return t?[t.role,t.tone,t.content].filter(Boolean).join(`
2
2
 
3
3
  `):``}function M(e){let t=e.target,n=Object.fromEntries(new FormData(t));for(let e of[`aggregateMs`,`maxWaitMs`,`contextMessages`,`maxReply`])n[e]=Number(n[e]);for(let e of[`memory`,`selectiveVision`,`deepCheck`,`compaction`])n[e]=t.elements.namedItem(e).checked;v(`save`,n)}return(n,o)=>(x(),l(`section`,mt,[F(G,{modelValue:m.value,"onUpdate:modelValue":o[0]||=e=>m.value=e,label:L(a)(`这个会话`),items:[{key:`here`,label:L(a)(`这个会话`)},{key:`feedback`,label:L(a)(`反馈`)}]},null,8,[`modelValue`,`label`,`items`]),t.session?m.value===`here`?(x(),l(`div`,gt,[h(`div`,_t,[h(`div`,vt,[h(`div`,null,[h(`span`,yt,e(L(a)(`TA 在这里的样子`)),1),j(t.group)?(x(),l(r,{key:0},[h(`p`,{class:d([`face-body`,k.value?`open`:`clamp`])},e(j(t.group)),3),j(t.group).length>96?(x(),l(`button`,{key:0,type:`button`,class:`text-button`,onClick:o[1]||=e=>k.value=!k.value},e(k.value?L(a)(`收起`):L(a)(`展开完整内容`)),1)):g(``,!0)],64)):(x(),l(`p`,bt,e(L(a)(`还没有形成在这里的样子。`)),1)),t.group?.face?.aspiration?(x(),l(`small`,xt,e(L(a)(`想成为:{aspiration}`,{aspiration:t.group.face.aspiration})),1)):g(``,!0)]),h(`div`,null,[h(`span`,St,e(t.session.kind===`private`?L(a)(`这段私聊给 TA 的感觉`):L(a)(`这个群给 TA 的感觉`)),1),h(`p`,null,e(t.group?.bond?.feel||L(a)(`刚来这里不久`)),1)])]),h(`p`,Ct,e(L(a)(`在这里开不开口由 TA 自己决定:没有参与概率和冷却。TA 对这里每个人的感觉在「人际」里看。`)),1),h(`div`,wt,[h(`button`,{id:`toggleSession`,"data-toggle":t.session.id,class:d({primary:!t.session.enabled}),onClick:o[2]||=e=>v(`toggle`,t.session)},e(t.session.enabled?L(a)(`暂停参与`):L(a)(`开启参与`)),11,Tt),h(`button`,{"data-archive":t.session.id,onClick:o[3]||=e=>v(`archive`,t.session.id)},e(L(a)(`归档`)),9,Et),h(`button`,{id:`clearLiveContext`,onClick:o[4]||=e=>v(`clear`)},e(L(a)(`清空上下文`)),1)]),h(`details`,{class:`fold session-settings`,open:f.value,onToggle:o[19]||=e=>f.value=e.target.open},[h(`summary`,null,e(L(a)(`会话设置`)),1),(x(),l(`form`,{key:t.session.id,"data-session":t.session.id,class:`stack tight`,onSubmit:p(M,[`prevent`]),onInput:o[17]||=e=>L(N).dirty=!0,onChange:o[18]||=e=>L(N).dirty=!0},[h(`p`,kt,e(L(a)(`所有会话和独处都用模型库里的默认模型;其余已启用的模型按列表顺序做备用。她在这个聊天窗里用什么样子,由她自己从经历里决定。`)),1),h(`label`,null,[S(e(L(a)(`会话名称`))+` `,1),h(`input`,{name:`name`,maxlength:`100`,autocomplete:`off`,value:t.session.name},null,8,At),h(`small`,jt,e(L(a)(`官方机器人平台不提供群名称,可以在这里自己起一个`)),1)]),h(`label`,Mt,[b(h(`input`,{name:`selectiveVision`,type:`checkbox`,"onUpdate:modelValue":o[5]||=e=>A.value.selectiveVision=e,onInput:o[6]||=p(()=>{},[`stop`])},null,544),[[z,A.value.selectiveVision]]),S(e(L(a)(`节能看图:只在被 @ 或明确要求时,看这一条和附近的图`)),1)]),h(`details`,Nt,[h(`summary`,null,e(L(a)(`高级策略`)),1),h(`div`,Pt,[h(`label`,null,[S(e(L(a)(`聚合窗口 ms`)),1),b(h(`input`,{name:`aggregateMs`,type:`number`,"onUpdate:modelValue":o[7]||=e=>A.value.aggregateMs=e},null,512),[[i,A.value.aggregateMs,void 0,{number:!0}]])]),h(`label`,null,[S(e(L(a)(`最长等待 ms`)),1),b(h(`input`,{name:`maxWaitMs`,type:`number`,"onUpdate:modelValue":o[8]||=e=>A.value.maxWaitMs=e},null,512),[[i,A.value.maxWaitMs,void 0,{number:!0}]])]),h(`label`,null,[S(e(L(a)(`近期原文条数(10–500)`)),1),b(h(`input`,{name:`contextMessages`,type:`number`,min:`10`,max:`500`,"onUpdate:modelValue":o[9]||=e=>A.value.contextMessages=e},null,512),[[i,A.value.contextMessages,void 0,{number:!0}]])]),h(`label`,null,[S(e(L(a)(`一轮总字数`)),1),b(h(`input`,{name:`maxReply`,type:`number`,"onUpdate:modelValue":o[10]||=e=>A.value.maxReply=e},null,512),[[i,A.value.maxReply,void 0,{number:!0}]])]),h(`label`,Ft,[b(h(`input`,{name:`compaction`,type:`checkbox`,"onUpdate:modelValue":o[11]||=e=>A.value.compaction=e,onInput:o[12]||=p(()=>{},[`stop`])},null,544),[[z,A.value.compaction]]),S(e(L(a)(`上下文压缩:更早的聊天定期整理成分层摘要,越近越详细`)),1)]),h(`label`,It,[b(h(`input`,{name:`memory`,type:`checkbox`,"onUpdate:modelValue":o[13]||=e=>A.value.memory=e,onInput:o[14]||=p(()=>{},[`stop`])},null,544),[[z,A.value.memory]]),S(e(L(a)(`长期记忆`)),1)]),h(`label`,Lt,[b(h(`input`,{name:`deepCheck`,type:`checkbox`,"onUpdate:modelValue":o[15]||=e=>A.value.deepCheck=e,onInput:o[16]||=p(()=>{},[`stop`])},null,544),[[z,A.value.deepCheck]]),S(e(L(a)(`倾诉、纠正和危机时额外复审一次回复`)),1)])])]),h(`div`,Rt,[h(`button`,zt,e(L(a)(`保存会话设置`)),1),h(`small`,Bt,e(L(N).dirty?L(a)(`有未保存的修改`):L(a)(`保存后下一轮生效`)),1)])],40,Ot))],40,Dt),h(`details`,Vt,[h(`summary`,null,e(L(a)(`语境摘要 · {length} 段`,{length:t.summaries.length})),1),t.summaries.length?g(``,!0):(x(),l(`p`,Ht,e(L(a)(`还没有摘要。聊天超过近期原文条数后,更早的内容会自动整理到这里。`)),1)),(x(!0),l(r,null,w(t.summaries,t=>(x(),l(`article`,{key:t.id,class:`summary`},[h(`header`,null,[h(`b`,null,e(L(y)[t.level]||L(a)(`摘要`)),1),h(`small`,Ut,e(L(a)(`{period} · {messages} 条消息`,{period:t.period,messages:t.messages})),1)]),h(`p`,null,e(t.summary),1),t.keyPoints?.length?(x(),l(`ul`,Wt,[(x(!0),l(r,null,w(t.keyPoints,(t,n)=>(x(),l(`li`,{key:n},e(t.open?L(a)(`未完:`):``)+e(t.text),1))),128))])):g(``,!0)]))),128))])])])):(x(),l(`div`,Gt,[h(`p`,Kt,e(L(a)(`针对具体回复评价口吻;这是 TA 在这个会话里听到的话,不会改写天性。`)),1),h(`div`,qt,[(x(!0),l(r,null,w(E.value.slice(C.value*$,C.value*$+$),t=>(x(),l(`article`,{key:t.id,class:`feedback-item`},[h(`time`,Jt,e(L(q)(t.time)),1),h(`p`,Yt,e(t.reply),1),h(`label`,null,[S(e(L(a)(`这句回复怎么样?`))+` `,1),F(V,{"data-feedback":t.id,"model-value":t.feedback||``,"aria-label":L(a)(`这句回复怎么样?`),options:[{value:``,label:L(a)(`选择评价`)},...Object.entries(L(N).health.feedbackLabels||{}).map(([e,t])=>({value:e,label:String(t)}))],"onUpdate:modelValue":e=>v(`feedback`,t.id,e)},null,8,[`data-feedback`,`model-value`,`aria-label`,`options`,`onUpdate:modelValue`])])]))),128)),E.value.length?g(``,!0):(x(),l(`p`,Xt,e(L(a)(`还没有可以评价的回复。`)),1))]),h(`div`,Zt,[h(`button`,{class:`small`,disabled:C.value===0,onClick:o[20]||=e=>C.value--},`←`,8,Qt),h(`span`,null,e(C.value+1)+` / `+e(O.value),1),h(`button`,{class:`small`,disabled:C.value+1>=O.value,onClick:o[21]||=e=>C.value++},` → `,8,$t)])])):(x(),l(`div`,ht,[F(P,{title:L(a)(`还没有选中会话`),text:L(a)(`从左边选一个群聊或私聊。`)},null,8,[`title`,`text`])]))]))}}),[[`__scopeId`,`data-v-96fbad3d`]]),tn={class:`replay`},nn={class:`col source`},rn={class:`col-head`},an={id:`events`,class:`scroll-pane`},on={key:0},sn={key:1,class:`muted`},cn=[`disabled`],ln={class:`faint`},un={class:`col`},dn={class:`col-head`},fn={id:`traces`,class:`scroll-pane`},pn=[`data-trace`,`onClick`],mn=[`data-tone`],hn={key:0,class:`muted`},gn={class:`col`},_n={class:`col-head`},vn={class:`scroll-pane inspect`},yn={key:0,class:`metrics`},bn={id:`traceTokens`},xn={key:1,class:`notice`},Sn={id:`traceDetail`},Cn=A(M({__name:`ReplaySheet`,props:{open:{type:Boolean},sessionId:{},events:{}},emits:[`close`,`load`],setup(t,{emit:n}){let o=t,s=n,f=c({sent:D(`开口了`),silent:D(`没出声`),glanced:D(`扫了一眼`),deferred:D(`睡着了`),running:D(`处理中`),error:D(`失败`),complete:D(`完成`),stale:D(`旧稿作废`),cancelled:D(`已取消`),interrupted:D(`已中断`)}),v=c({live:D(`真实聊天`),demo:D(`模拟预览`),replay:D(`测试回放`),memory:D(`记忆整理`),summary:D(`语境压缩`)}),y=u([]),C=u(null),T=u(``),E=u(``),O=u(!1),k=u(``);async function A(){o.sessionId&&(y.value=await oe(o.sessionId))}function j(){let e=o.events.map(e=>Number(e.seq));e.length&&(T.value||=String(Math.min(...e)),E.value||=String(Math.max(...e)))}async function M(){if(!O.value){O.value=!0;try{I(a(`回放正在运行`));let e=await X({session:o.sessionId,from:Number(T.value),to:Number(E.value)});k.value=JSON.stringify(e,null,2),I(a(`回放结束`)),await A()}catch(e){I(e.message,!0)}finally{O.value=!1}}}async function N(e){C.value=await Y(e),k.value=JSON.stringify(C.value,null,2)}function P(e){return e?a(`输入 {v}(缓存读 {v2} / 写 {v3})· 输出 {v4}`,{v:W(e.input),v2:W(e.cachedRead),v3:W(e.cacheWrite),v4:W(e.output)}):`—`}return _(()=>[o.open,o.sessionId],()=>{o.open&&(T.value=``,E.value=``,C.value=null,j(),A())},{immediate:!0}),_(()=>o.events.length,j),(n,o)=>(x(),m(ne,{open:t.open,title:L(a)(`回到那一刻`),eyebrow:`REPLAY`,width:`1180px`,onClose:o[3]||=e=>s(`close`)},{default:R(()=>[h(`div`,tn,[h(`section`,nn,[h(`div`,rn,[h(`h3`,null,e(L(a)(`历史消息`)),1),h(`button`,{id:`loadMessages`,class:`small`,onClick:o[0]||=e=>{s(`load`),A()}},e(L(a)(`↻ 加载`)),1)]),h(`div`,an,[t.events.length?(x(),l(`table`,on,[h(`thead`,null,[h(`tr`,null,[h(`th`,null,e(L(a)(`序号`)),1),h(`th`,null,e(L(a)(`发送者`)),1),h(`th`,null,e(L(a)(`消息`)),1)])]),h(`tbody`,null,[(x(!0),l(r,null,w([...t.events].reverse(),t=>(x(),l(`tr`,{key:t.seq},[h(`td`,null,e(t.seq),1),h(`td`,null,e(t.payload.name),1),h(`td`,null,e(t.payload.text),1)]))),128))])])):(x(),l(`p`,sn,e(L(a)(`当前会话暂无历史消息。`)),1))]),h(`form`,{class:`range`,onSubmit:p(M,[`prevent`])},[h(`label`,null,[S(e(L(a)(`起始序号`)),1),b(h(`input`,{"onUpdate:modelValue":o[1]||=e=>T.value=e,name:`from`,type:`number`,required:``},null,512),[[i,T.value]])]),h(`label`,null,[S(e(L(a)(`截止序号`)),1),b(h(`input`,{"onUpdate:modelValue":o[2]||=e=>E.value=e,name:`to`,type:`number`,required:``},null,512),[[i,E.value]])]),h(`button`,{id:`replay`,class:`primary`,disabled:O.value||!t.events.length},e(O.value?L(a)(`正在回放…`):L(a)(`回放这段对话`)),9,cn),h(`p`,ln,e(L(a)(`隔离回放:只测试回复,不发送 QQ,不修改真实记忆和 TA 的心智。`)),1)],32)]),h(`section`,un,[h(`div`,dn,[h(`h3`,null,e(L(a)(`处理记录`)),1)]),h(`div`,fn,[(x(!0),l(r,null,w(y.value,t=>(x(),l(`button`,{key:t.id,"data-trace":t.id,class:d([`trace-row`,{selected:C.value?.id===t.id}]),onClick:e=>N(t.id)},[h(`span`,null,[h(`time`,null,e(L(q)(t.time)),1),h(`small`,{class:`chip`,"data-tone":t.status===`error`?`danger`:`quiet`},e(L(f)[t.status]||t.status),9,mn)]),h(`p`,null,e(t.reason||t.error||L(a)(`查看处理详情`)),1)],10,pn))),128)),y.value.length?g(``,!0):(x(),l(`p`,hn,e(L(a)(`有新的消息处理记录后会显示在这里。`)),1))])]),h(`section`,gn,[h(`div`,_n,[h(`h3`,null,e(L(a)(`运行详情`)),1)]),h(`div`,vn,[C.value?(x(),l(`div`,yn,[h(`span`,null,[S(e(L(a)(`模式`)),1),h(`b`,null,e(L(v)[C.value.mode]||C.value.mode),1)]),h(`span`,null,[S(e(L(a)(`耗时`)),1),h(`b`,null,e(C.value.data?.elapsed??`—`)+` ms`,1)]),h(`span`,null,[S(e(L(a)(`模型调用`)),1),h(`b`,null,e(L(a)(`{v} 次`,{v:C.value.data?.calls?.length??0})),1)]),h(`span`,bn,[o[4]||=S(`Token`,-1),h(`b`,null,e(P(C.value.data?.tokens)),1)])])):g(``,!0),C.value?(x(),l(`p`,xn,e(C.value.reason||C.value.data?.decision?.reason||L(a)(`展开下方查看上下文、模型输入与原始输出。`)),1)):g(``,!0),h(`pre`,Sn,e(k.value||L(a)(`选择一条处理记录,查看最终上下文、Prompt、原始输出、Token 与耗时。`)),1)])])])]),_:1},8,[`open`,`title`]))}}),[[`__scopeId`,`data-v-839b3181`]]),wn={key:0,class:`card col list-col`},Tn={class:`card col talk-col`},En={class:`card col panel-col`},Dn={class:`sheet-list`},On=A(M({__name:`ChatsPage`,setup(e){let n=ie(`(max-width: 1100px)`),r=o(()=>N.core?.sessions||[]),i=o(()=>r.value.filter(e=>!e.archived)),c=sessionStorage.activeSession,f=u(i.value.some(e=>e.id===c)?c:i.value[0]?.id||``),p=o(()=>i.value.find(e=>e.id===f.value)||null),b=u([]),S=u([]),w=u([]),T=u([]),E=u({}),D=u(``),k=u(!1),A=u(!1),M=u(!1),P=u(N.sub===`settings`),z=u(N.sub===`replay`),B=u(`here`),V=o(()=>N.health?.decisions||[]),H=o(()=>T.value.find(e=>e.session===f.value)||null),U=!1,W=!1,G=!1,K=``,q=0,J=null,Y=0;async function X(e=!1){if(!f.value)return;if(U){W=!0,G||=e;return}let t=f.value,n=e||K!==t;U=!0;try{let[e,r]=await Promise.all([ae(t,n?void 0:q),oe(t,{limit:30,compact:!0})]);if(f.value!==t)return;let i=document.getElementById(`liveMessages`),o=K!==t||!i||i.scrollHeight-i.scrollTop-i.clientHeight<80;n?(b.value=e.reverse(),q=0):e.length&&(b.value=[...b.value,...e]);for(let t of e)q=Math.max(q,Number(t.seq)||0);!n&&e.length===100&&(W=!0),S.value=r,K=t,await y();let c=document.getElementById(`liveMessages`);c&&o&&(c.scrollTop=c.scrollHeight),D.value=a(`实时同步 · `)+new Date().toLocaleTimeString(s())}catch(e){D.value=a(`同步失败:`)+e.message}finally{if(U=!1,f.value!==t)W=!1,X();else if(W){let e=G;W=!1,G=!1,X(e)}}}async function ge(){try{let[e,t]=await Promise.all([te.bonds(),te.overview()]);T.value=e.groups,E.value=Object.fromEntries(t.attention.map(e=>[e.session,e.unread]))}catch{}}_(f,e=>{if(J?.abort(),e&&(sessionStorage.activeSession=e),b.value=[],S.value=[],w.value=[],K=``,q=0,W=!1,G=!1,M.value=!1,X(),!e)return;me(e).then(t=>{f.value===e&&(w.value=[...t].reverse())}).catch(()=>{});let t=new AbortController;J=t;let n=``;re(e=>{let t=Number(e?.messages);Number.isSafeInteger(t)&&t<q&&(K=``,q=0,b.value=[]);let r=JSON.stringify(e),i=n!==``&&r!==n;n=r,i&&X()},{session:e,signal:t.signal,reconnectMs:1e3})},{immediate:!0}),_(i,e=>{e.some(e=>e.id===f.value)||(f.value=e[0]?.id||``)}),_(B,async e=>{if(e===`feedback`)try{N.health=await C()}catch{}}),_(z,e=>j(e?`replay`:P.value?`settings`:``)),_(()=>N.sub,e=>{e===`replay`&&(z.value=!0),e===`settings`&&(P.value=!0)}),_(()=>N.pulse,ge),O(()=>{ge(),Y=window.setInterval(()=>X(!0),15e3)}),ee(()=>{clearInterval(Y),J?.abort()});async function _e(e){try{let t=await le(e);await v(),f.value=t?.sessionId||`${e.kind}:${e.id}`,P.value=!0,B.value=`here`,A.value=!1,I(a(`会话已添加`))}catch(e){I(e.message,!0)}}async function Z(e){await ue(e.id,!e.enabled),await v()}async function ve(e){await de(e,!0),await v()}async function Q(e){await de(e,!1),await v()}async function ye(e){await t(a(`永久删除这个会话?它的消息和设置都会消失。`),{title:a(`永久删除`),confirmText:a(`删除`),danger:!0})&&(await fe(e),await v())}async function be(e){if(p.value)try{await pe(p.value.id,{...e,name:String(e.name||``).trim()||p.value.name}),N.dirty=!1,I(a(`会话配置已保存`)),await v()}catch(e){I(e.message,!0)}}async function xe(){f.value&&await t(a(`确定清空这个会话的消息上下文吗?长期记忆不会删除。`),{title:a(`清空上下文`),confirmText:a(`清空`),danger:!0})&&(await he(f.value),b.value=[],S.value=[],K=``,q=0,await X(!0))}async function Se(e){if(!k.value&&f.value){k.value=!0;try{let t=await se({sessionId:f.value,...e});I(t.reason||a(`已发送`)),N.health=await C(),await X()}catch(e){I(e.message,!0)}finally{k.value=!1}}}async function Ce(e,t){try{await ce(e,t),I(a(`反馈已保存`)),N.health=await C()}catch(e){I(e.message,!0)}}return(e,t)=>(x(),l(`div`,{class:d([`page chats`,{compact:L(n)}])},[L(n)?g(``,!0):(x(),l(`aside`,wn,[F(Oe,{sessions:r.value,selected:f.value,unread:E.value,onSelect:t[0]||=e=>f.value=e,onAdd:t[1]||=e=>A.value=!0,onToggle:Z,onRestore:Q,onRemove:ye},null,8,[`sessions`,`selected`,`unread`])])),h(`div`,Tn,[F(pt,{"session-id":f.value,session:p.value,events:b.value,traces:S.value,decisions:V.value,status:D.value||L(a)(`请选择会话`),demo:!!L(N).health.settings.demo,compact:L(n),sending:k.value,onSimulate:Se,onFeedback:Ce,onOpenList:t[2]||=e=>M.value=!0,onOpenReplay:t[3]||=e=>z.value=!0},null,8,[`session-id`,`session`,`events`,`traces`,`decisions`,`status`,`demo`,`compact`,`sending`])]),h(`aside`,En,[F(en,{"settings-open":P.value,"onUpdate:settingsOpen":t[4]||=e=>P.value=e,tab:B.value,"onUpdate:tab":t[5]||=e=>B.value=e,session:p.value,group:H.value,summaries:w.value,decisions:V.value,onToggle:Z,onArchive:ve,onClear:xe,onSave:be,onFeedback:Ce},null,8,[`settings-open`,`tab`,`session`,`group`,`summaries`,`decisions`])]),L(n)?(x(),m(ne,{key:1,open:M.value,title:L(a)(`全部会话`),eyebrow:`CHATS`,width:`400px`,onClose:t[8]||=e=>M.value=!1},{default:R(()=>[h(`div`,Dn,[F(Oe,{sessions:r.value,selected:f.value,unread:E.value,onSelect:t[6]||=e=>f.value=e,onAdd:t[7]||=e=>A.value=!0,onToggle:Z,onRestore:Q,onRemove:ye},null,8,[`sessions`,`selected`,`unread`])])]),_:1},8,[`open`,`title`])):g(``,!0),F(Ne,{open:A.value,channel:L(N).health?.connection?.channel===`qqbot`?`qqbot`:`onebot`,ready:!!L(N).health?.connection?.qqbot?.appId,onClose:t[9]||=e=>A.value=!1,onAdd:_e},null,8,[`open`,`channel`,`ready`]),F(Cn,{open:z.value,"session-id":f.value,events:b.value,onClose:t[10]||=e=>z.value=!1,onLoad:t[11]||=e=>X(!0)},null,8,[`open`,`session-id`,`events`])],2))}}),[[`__scopeId`,`data-v-c328f9fe`]]);export{On as default};