deskpaw-memory/README.md
2026-09-22 23:33:47 +08:00

55 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# deskpaw-memory
DeskPaw 的本地记忆与上下文整理模块。它作为 `deskpaw-agent` 的平级服务运行,通过本地 socket 提供:
- 任务卡和执行结果的持久化;
- 新旧任务关联度提示;
- 日程附属资料夹;
- 每轮执行前的有限上下文包;
- 主动整理记录与可观测事件。
模块不保存隐藏思考,不接管日程执行,不直接操作电脑或发送消息。Agent 不依赖本服务才能运行;服务离线时自动降级。
`deploy/deskpaw-memory.service` 是当前 KickPi 部署模板。`bin/run-memory` 会读取设备配置中的 `DESKPAW_NODE_BIN`,避免 systemd 找不到 NVM 安装的 Node。服务应先于 Agent 启动;它故障重启时不会要求 Agent 一起重启。
## 启动
Linux 默认 socket 为 `~/.deskpaw/runtime/memory.sock`:
```bash
npm start
```
正式状态统一保存在 `~/.deskpaw/memory/`:SQLite 数据库位于
`data/memory.sqlite3`,日程和项目资料位于 `bundles/`。旧版 Python
记忆服务的数据应迁到 `~/.deskpaw/memory-legacy/`,不要与本模块共用数据库。
可配置:
```text
DESKPAW_STATE_DIR=/path/to/state
DESKPAW_MEMORY_SOCKET=/path/to/memory.sock
DESKPAW_MEMORY_DB=/path/to/memory.sqlite
DESKPAW_MEMORY_BUNDLES=/path/to/bundles
```
协议为单请求连接的 JSON Lines。请求包含 `id、method、params`,响应包含 `id、ok、result/error`。
首版接口:`health`、`transition.assess`、`context.prepare`、`task.complete`、`task.list`、`consolidation.record`、`bundle.get`、`bundle.list`、`bundle.document.put`。修改资料使用 `expected_revision`,防止猫窝和桌喵同时编辑时旧内容覆盖新内容。
## 资料夹
日程第一次运行时会按稳定 `schedule_id` 建立:
```text
bundles/schedule/<schedule_id>/
INDEX.md
requirements.md
preferences.md
lessons.md
state.json
runs/<run_id>/summary.md
```
数据库保存权威状态,以上文件用于猫窝展示和按需阅读。