dsh-tdai-memory 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +56 -0
- package/README.md +38 -163
- package/README.zh.md +3 -122
- package/package.json +12 -6
package/README.en.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# DSH TDAI Memory
|
|
2
|
+
|
|
3
|
+
[简体中文](README.md) | English
|
|
4
|
+
|
|
5
|
+
Bring TencentDB Agent Memory's layered memory system to [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness): capture conversations, extract structured memories and retrieve relevant context in later conversations. This project adapts the original OpenClaw plugin's core to DSH.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
| Layer | Purpose |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| L0 | Capture raw conversations for later search |
|
|
12
|
+
| L1 | Use an extraction model to organize facts, preferences and events |
|
|
13
|
+
| L2 / L3 | Produce scene information and a user profile |
|
|
14
|
+
| Recall and search | Retrieve relevant memory for the current message; expose `tdai_memory_search` and `tdai_conversation_search` |
|
|
15
|
+
|
|
16
|
+
Data defaults to `~/.memory-tencentdb/memory-tdai`, allowing existing data in that directory to be reused. Capture, extraction and recall depend on enabled settings, model connections and retrieval results; saving or recalling every detail is not guaranteed.
|
|
17
|
+
|
|
18
|
+
## Compatibility and installation
|
|
19
|
+
|
|
20
|
+
Supports DSH Web / Desktop. The repository declares compatibility with `0.2.0-rc.2`, `0.2.1-rc.1` / `rc.2` / `rc.3` / `rc.4` / `rc.5` and versions matching `>=0.2.0-rc.2 <0.3.0`; see [package.json](package.json) for the complete prerelease range. Node.js `>=22.18` is required.
|
|
21
|
+
|
|
22
|
+
For Desktop, install its `dsh` command through **Application → Manage dsh Command** first:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
dsh plugin --profile desktop add dsh-tdai-memory
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Replace `desktop` with `web` for Web. Restart DSH and open **Plugins → Installed → dsh-tdai-memory**. You can also install it through the [Enhancement Suite](https://github.com/Scorp1o117/dsh-enhancement-suite).
|
|
29
|
+
|
|
30
|
+
## Quick setup
|
|
31
|
+
|
|
32
|
+
1. Configure an **OpenAI-compatible LLM address, model and key** for memory extraction.
|
|
33
|
+
2. Configure an **OpenAI-compatible embedding address, model and dimensions**. The default `http://127.0.0.1:8088/v1` is a configuration value, not an included service; provide a working embedding service yourself.
|
|
34
|
+
3. Select **Automatic memory**, save and restart DSH to apply pipeline changes.
|
|
35
|
+
4. After a conversation, ask the Agent to search memory or check the plugin logs for extraction and tool registration.
|
|
36
|
+
|
|
37
|
+
| Mode | Capture | Extraction | Automatic recall | Search tools |
|
|
38
|
+
| --- | --- | --- | --- | --- |
|
|
39
|
+
| Automatic memory | On | On | On | On |
|
|
40
|
+
| Search existing memory only | Off | Off | Off | On |
|
|
41
|
+
| Pause memory features | Off | Off | Off | Off |
|
|
42
|
+
|
|
43
|
+
Advanced settings expose individual switches, storage location and tuning. Existing mixed settings appear as a custom combination and are not overwritten automatically. The search-tool switch applies immediately; restart as prompted for other pipeline changes. The form writes edited fields only and retains unchanged keys.
|
|
44
|
+
|
|
45
|
+
## Usage notes
|
|
46
|
+
|
|
47
|
+
- The extraction model needs to produce reliable structured output. Extraction runs in the background; latency and quality depend on the model and service.
|
|
48
|
+
- LLM deduplication is off by default. The default embedding configuration points to a local OpenAI-compatible endpoint; remote compatible endpoints do not require `node-llama-cpp`. For the fully local embedding backend, install and approve the optional `node-llama-cpp` build in the target profile separately.
|
|
49
|
+
- If search tools are missing, check that they are enabled and look for `[tdai-memory] tools registered` in the logs. The interface follows the DSH language setting.
|
|
50
|
+
- Captured conversations and memories are stored locally; extraction and embedding requests go to your configured services. Choose appropriate endpoints and back up your data.
|
|
51
|
+
|
|
52
|
+
## Development, attribution and feedback
|
|
53
|
+
|
|
54
|
+
- The [historical detailed documentation](https://github.com/Scorp1o117/dsh-tdai-memory/blob/7e1dd9c9b1214f5fc531f560296e492af204c4e1/README.md) preserves architecture, configuration examples and older notes; its install commands and compatibility information may be outdated.
|
|
55
|
+
- This project ports TencentDB Agent Memory. See the corresponding directories for third-party code and license notices included with the repository.
|
|
56
|
+
- [npm](https://www.npmjs.com/package/dsh-tdai-memory) · [Issues](https://github.com/Scorp1o117/dsh-tdai-memory/issues) · [MIT License](LICENSE)
|
package/README.md
CHANGED
|
@@ -1,181 +1,56 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DSH TDAI Memory
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
简体中文 | [English](README.en.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
将 TencentDB Agent Memory 的分层记忆系统接入 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness):捕获对话、提取结构化记忆,并在后续对话中检索相关内容。项目基于原 OpenClaw 插件的核心进行 DSH 适配。
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## 功能
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
| 层级 | 用途 |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| L0 | 捕获原始对话,供后续检索 |
|
|
12
|
+
| L1 | 使用提取模型整理事实、偏好和事件等结构化记忆 |
|
|
13
|
+
| L2 / L3 | 生成场景信息与用户画像 |
|
|
14
|
+
| 召回与搜索 | 按当前消息召回相关记忆;提供 `tdai_memory_search` 和 `tdai_conversation_search` 工具 |
|
|
10
15
|
|
|
11
|
-
|
|
16
|
+
数据默认保存在 `~/.memory-tencentdb/memory-tdai`,可复用已有同目录记忆。记忆写入、提取和召回依赖启用状态、模型连接及检索结果,不保证每条信息都会被保存或召回。
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
## 兼容性与安装
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
支持 DSH Web / Desktop;仓库声明兼容 `0.2.0-rc.2`、`0.2.1-rc.1` / `rc.2` / `rc.3` / `rc.4` / `rc.5` 和符合 `>=0.2.0-rc.2 <0.3.0` 的版本,预发布版本范围见 [package.json](package.json)。要求 Node.js `>=22.18`。
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
Desktop 先在 **应用 → 管理 dsh 命令** 安装桌面版 `dsh`:
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
[](README.zh.md)
|
|
24
|
-
|
|
25
|
-
**GitHub**: [Scorp1o117/dsh-tdai-memory](https://github.com/Scorp1o117/dsh-tdai-memory) · **npm**: [dsh-tdai-memory](https://www.npmjs.com/package/dsh-tdai-memory)
|
|
26
|
-
|
|
27
|
-
[](https://github.com/Scorp1o117/dsh-enhancement-suite) [](https://www.npmjs.com/package/dsh-enhancement-suite)
|
|
28
|
-
|
|
29
|
-
Part of the [DeepSeek Harness Enhancement Suite](https://github.com/Scorp1o117/dsh-enhancement-suite) — Vision · Soul/Persona · Long-term Memory · Plugin Marketplace.
|
|
30
|
-
|
|
31
|
-
A port of **TencentDB Agent Memory** (Tencent Cloud's open-source four-layer
|
|
32
|
-
memory system, originally an OpenClaw plugin) into DeepSeek Harness.
|
|
33
|
-
|
|
34
|
-
## Compatibility (v0.4.1)
|
|
35
|
-
|
|
36
|
-
Verified with DSH `0.1.7-rc.2` (Web) and `0.2.0-rc.2` (Desktop runtime) in isolated profiles. The Desktop app uses its own `desktop` profile. Other DSH prereleases remain unverified.
|
|
24
|
+
```sh
|
|
25
|
+
dsh plugin --profile desktop add dsh-tdai-memory
|
|
26
|
+
```
|
|
37
27
|
|
|
38
|
-
|
|
28
|
+
Web 将 `desktop` 改为 `web`。安装后重启 DSH,打开 **插件 → 已安装 → dsh-tdai-memory**。也可通过 [Enhancement Suite](https://github.com/Scorp1o117/dsh-enhancement-suite) 安装。
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
## 快速配置
|
|
41
31
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
1. 配置用于记忆提取的 **OpenAI 兼容 LLM 地址、模型和密钥**。
|
|
33
|
+
2. 配置 **OpenAI 兼容 Embedding 地址、模型和维度**。默认地址 `http://127.0.0.1:8088/v1` 只是配置值,你需要自行提供可用的 Embedding 服务。
|
|
34
|
+
3. 选择**自动记忆**并保存,重启 DSH 使记忆管线配置生效。
|
|
35
|
+
4. 对话后可让 Agent 搜索记忆,或检查插件日志确认提取和工具注册情况。
|
|
45
36
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
- **L0 conversation capture**: every turn (turn end, request boundary) is
|
|
52
|
-
written to raw conversation storage (JSONL + SQLite + FTS + vectors)
|
|
53
|
-
- **L1 structured memory**: a background pipeline uses an LLM to extract
|
|
54
|
-
facts / preferences / events (persona / episodic / instruction) from
|
|
55
|
-
conversations, stored in `records/` + SQLite + FTS + vectors
|
|
56
|
-
- **L2 scenes / L3 persona**: scene blocks and user profile generation
|
|
57
|
-
(pipeline-scheduled)
|
|
58
|
-
- **Automatic recall injection**: on every prompt assembly, relevant memories
|
|
59
|
-
and the user profile are retrieved by the current user message and injected
|
|
60
|
-
as dynamic context (the model "just remembers")
|
|
61
|
-
- **Tools**: `tdai_memory_search` (L1 structured search),
|
|
62
|
-
`tdai_conversation_search` (L0 raw-text search)
|
|
63
|
-
|
|
64
|
-
The data directory reuses the existing `~/.memory-tencentdb/memory-tdai`, so
|
|
65
|
-
**previously accumulated memories carry over seamlessly**.
|
|
66
|
-
|
|
67
|
-
## Architecture (porting approach)
|
|
68
|
-
|
|
69
|
-
| Layer | Content |
|
|
70
|
-
|---|---|
|
|
71
|
-
| Core | The host-neutral core of `tdai-memory-openclaw-plugin` (`src/core`, `src/utils`), tsc-compiled to ESM (`dist-dsh/`), zero changes |
|
|
72
|
-
| Host adapter | `StandaloneHostAdapter` (official standalone mode, direct OpenAI-compatible calls) |
|
|
73
|
-
| dsh shell | `index.js`: config mapping, `session/event` + `session/flush` capture, `system-prompt/assemble` recall injection on `agent.ctx`, tool registration, lifecycle |
|
|
74
|
-
| Fallback | `recall-inject.js`: preset-row recall injection (used when mounted inside an agent preset) |
|
|
75
|
-
|
|
76
|
-
Recall caches expire after 30 seconds and retain at most 128 sessions per
|
|
77
|
-
injection instance. Failed or timed-out recalls are retried on the next assembly.
|
|
78
|
-
The preset row also accepts `timeoutMs` (default 4000); reaching this deadline
|
|
79
|
-
continues prompt assembly without memory context. Deadline timers are cleared
|
|
80
|
-
when recall settles early. Underlying recall work may continue after the deadline.
|
|
81
|
-
|
|
82
|
-
Hard-won wiring details:
|
|
83
|
-
|
|
84
|
-
- **Capture**: `session/flush` listener (await semantics; must complete before
|
|
85
|
-
headless exits); `turn/start` timestamps as the L0 cursor floor; turn-id dedup
|
|
86
|
-
- **Headless one-shot runs**: wait for `core.handleSessionEnd()` inside flush
|
|
87
|
-
(L1 extraction finishes before exit; otherwise the 5s shutdown timeout kills it)
|
|
88
|
-
- **Recall injection**: must be registered on **`agent.ctx`** (assembly runs in
|
|
89
|
-
the agent scope; root listeners never see it); attach one tick after
|
|
90
|
-
`session/created` by resolving the agent from the `agents` service
|
|
91
|
-
|
|
92
|
-
## Configuration (profile patch + settings)
|
|
93
|
-
|
|
94
|
-
Configuration is stored in the `tdai-memory` entry of the active Profile patch.
|
|
95
|
-
On first launch, DSH imports the old `$DSH_HOME/settings.yaml` values into that
|
|
96
|
-
entry. The **Web UI Settings → 记忆**
|
|
97
|
-
section edits every field (v0.2.0, write-only keys); TdaiCore is built at
|
|
98
|
-
startup, so changes apply **after a restart**.
|
|
99
|
-
|
|
100
|
-
```yaml
|
|
101
|
-
# $DSH_HOME/profiles/web/cordis.patch.yml
|
|
102
|
-
- id: tdai-memory
|
|
103
|
-
name: 'dsh-tdai-memory'
|
|
104
|
-
config:
|
|
105
|
-
extraction:
|
|
106
|
-
enabled: true
|
|
107
|
-
enableDedup: false # dedup LLM output parsing is flaky; off by default
|
|
108
|
-
llm: # L1/L2/L3 extraction model (OpenAI-compatible)
|
|
109
|
-
baseUrl: 'https://opencode.ai/zen/go/v1'
|
|
110
|
-
model: 'mimo-v2.5' # deepseek-v4-flash produces invalid extraction JSON
|
|
111
|
-
sendSessionHeader: true # send x-opencode-session on LLM requests (required by OpenCode Go & similar gateways)
|
|
112
|
-
sessionId: '' # fixed session id; empty = persistent auto id under the data dir
|
|
113
|
-
embedding: # vectors (OpenAI-compatible /v1/embeddings)
|
|
114
|
-
baseUrl: 'http://127.0.0.1:8088/v1'
|
|
115
|
-
model: 'Qwen3-Embedding-0.6B'
|
|
116
|
-
dimensions: 1024
|
|
117
|
-
sendDimensions: false
|
|
118
|
-
```
|
|
37
|
+
| 模式 | 捕获 | 提取 | 自动召回 | 搜索工具 |
|
|
38
|
+
| --- | --- | --- | --- | --- |
|
|
39
|
+
| 自动记忆 | 开 | 开 | 开 | 开 |
|
|
40
|
+
| 仅搜索已有记忆 | 关 | 关 | 关 | 开 |
|
|
41
|
+
| 暂停记忆功能 | 关 | 关 | 关 | 关 |
|
|
119
42
|
|
|
120
|
-
|
|
43
|
+
高级设置可单独调整开关、存储位置和调优参数;已有混合配置显示为自定义组合,不会自动覆盖。搜索工具开关可即时生效,其他管线配置按提示重启。表单只写入编辑过的字段,未修改的密钥保留。
|
|
121
44
|
|
|
122
|
-
|
|
123
|
-
dsh plugin --profile web add dsh-tdai-memory
|
|
124
|
-
```
|
|
45
|
+
## 使用说明
|
|
125
46
|
|
|
126
|
-
|
|
47
|
+
- 提取模型需要稳定输出结构化结果;提取在后台进行,耗时和质量取决于模型与服务。
|
|
48
|
+
- 默认关闭 LLM 去重。默认 Embedding 使用本地 OpenAI 兼容端点;远程兼容端点不需要 `node-llama-cpp`。若选择完全本地的 Embedding 后端,需要在目标 Profile 另行安装并批准可选的 `node-llama-cpp` 构建。
|
|
49
|
+
- 搜索工具缺失时,确认工具开关已开启,并检查 `[tdai-memory] tools registered` 日志。语言跟随 DSH。
|
|
50
|
+
- 捕获的对话和记忆会保存在本机;提取与 Embedding 请求会发送到你配置的服务,请自行选择合适的端点并备份数据。
|
|
127
51
|
|
|
128
|
-
|
|
129
|
-
- insert:
|
|
130
|
-
- id: tdai-memory
|
|
131
|
-
name: 'dsh-tdai-memory'
|
|
132
|
-
config: {} # fill through Settings → 记忆
|
|
133
|
-
```
|
|
52
|
+
## 开发、来源与反馈
|
|
134
53
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
> **Note for users**
|
|
139
|
-
> - This plugin is a standard **profile bundle** (`dsh.bundle.patch`):
|
|
140
|
-
> `dsh plugin --profile web add dsh-tdai-memory` installs and mounts it in
|
|
141
|
-
> one step — no manual `cordis.patch.yml` edits needed.
|
|
142
|
-
> - DSH exposes the registered `tdai-memory` settings namespace directly; the
|
|
143
|
-
> plugin does not modify files in the host installation.
|
|
144
|
-
> - Settings changes apply **after a restart** (TdaiCore is built at startup).
|
|
145
|
-
> - Version 0.2.13 and newer require DSH `0.1.0-rc.7` or newer and are tested
|
|
146
|
-
> against `0.1.0-rc.7`, `0.1.0-rc.8`, and `0.1.1-rc.1`.
|
|
147
|
-
> - DSH `0.1.0-rc.6` users must pin `dsh-tdai-memory@0.2.11`, the last release
|
|
148
|
-
> carrying the legacy settings-allowlist compatibility patch.
|
|
149
|
-
|
|
150
|
-
`node-llama-cpp` is an optional peer used only by the fully local embedding
|
|
151
|
-
backend. It is intentionally not installed by default because its native build
|
|
152
|
-
requires explicit pnpm build approval. Remote OpenAI-compatible embeddings do
|
|
153
|
-
not need it. Users who select the local backend should install and approve
|
|
154
|
-
`node-llama-cpp` in the target DSH profile separately.
|
|
155
|
-
|
|
156
|
-
## Known trade-offs
|
|
157
|
-
|
|
158
|
-
- **Extraction model**: `mimo-v2.5` extracts correctly but takes 20-30s per
|
|
159
|
-
call (background execution, does not block the conversation);
|
|
160
|
-
`deepseek-v4-flash` is fast but its JSON output is non-compliant (extracts 0)
|
|
161
|
-
- **dedup**: LLM conflict-detection output parsing is unstable (once caused
|
|
162
|
-
stored=0); off by default; enable only with a more reliable model
|
|
163
|
-
- **L1 memory vectors**: written with storage (8088 embedding is fast); L0
|
|
164
|
-
vectors run as a background task, drained by `destroy()` on headless exit
|
|
165
|
-
- **Search tools** (`toolsEnabled`, on by default): the switch lives in the
|
|
166
|
-
Plugins page and applies in place — the row config is `volatile`, so the
|
|
167
|
-
plugin re-syncs its registration without a restart. If both tools are
|
|
168
|
-
missing, look for the plugin's
|
|
169
|
-
`[tdai-memory] tools registered: tdai_memory_search, tdai_conversation_search`
|
|
170
|
-
log line (v0.4.1+). Before v0.4.1 it read `config.toolsEnabled` off the
|
|
171
|
-
Volatile wrapper cordis hands to `apply` — a property that never exists — so
|
|
172
|
-
the failure was completely silent (issue #3)
|
|
173
|
-
- **Upgrades**: after pulling new upstream code, rerun
|
|
174
|
-
`npx tsc -p dsh-tsconfig.json` in the tdai project dir (output in `dist-dsh/`)
|
|
175
|
-
|
|
176
|
-
## License
|
|
177
|
-
|
|
178
|
-
MIT
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Saves use the configuration form API. Rejected writes retain the draft and show an error. Changing a model preserves credentials, and disabling a default-on option explicitly stores `false`.
|
|
54
|
+
- [历史详细文档](https://github.com/Scorp1o117/dsh-tdai-memory/blob/7e1dd9c9b1214f5fc531f560296e492af204c4e1/README.zh.md)保留架构、配置示例和旧版说明,其中安装命令与兼容性信息可能已过时。
|
|
55
|
+
- 本项目移植 TencentDB Agent Memory;随仓库分发的第三方代码和许可证请参见对应目录。
|
|
56
|
+
- [npm](https://www.npmjs.com/package/dsh-tdai-memory) · [问题反馈](https://github.com/Scorp1o117/dsh-tdai-memory/issues) · [MIT License](LICENSE)
|
package/README.zh.md
CHANGED
|
@@ -1,124 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DSH TDAI Memory(简体中文)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
中文文档已迁移至仓库首页:[阅读中文版](README.md)。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## DSH 0.2.1-rc.2
|
|
8
|
-
|
|
9
|
-
适配 DSH 0.2.1-rc.2,明确声明该预发布版本的 engines.dsh 与 peer 范围。宿主新增 DeepSeek V4.1 Flash 1017 及 Search/Fetch API,本插件使用的接口保持不变。保留已有推理配置及自动补齐显式开启策略。
|
|
10
|
-
|
|
11
|
-
## DSH 0.2.1-rc.1
|
|
12
|
-
|
|
13
|
-
支持 DSH 0.2.1-rc.1,通过 `engines.dsh` 和一致的 peer 范围声明兼容,明确包含该预发布版本,并保留已有 0.2.0-rc.2 支持。
|
|
14
|
-
|
|
15
|
-
插件跟随 DSH 的语言设置(DSH 0.2.0-rc.2 内置中文和 English),配置页面、状态提示和插件列表名称/简介同步切换。扩展语言使用宿主的回退链。切换语言保留未保存的设置,无需单独选择插件语言。
|
|
16
|
-
|
|
17
|
-
## 配置入口(DSH 0.2.0-rc.2 起)
|
|
18
|
-
|
|
19
|
-
在首页侧边栏打开 **插件 → 已安装 → dsh-tdai-memory**,直接在插件详情页配置并保存。配置页注册到官方的 `plugins.bundle.config` 接口;全局设置页不再重复显示配置入口。Web 与桌面版使用相同界面,本版要求 DSH 0.2.0-rc.2 或更新的 0.2.x 版本。现有配置无需迁移。
|
|
20
|
-
|
|
21
|
-
选择 **自动记忆**,一次开启捕获、提取、召回和搜索;**仅搜索已有记忆** 关闭捕获、提取和自动召回,保留搜索工具;**暂停记忆功能** 关闭全部四项。主页面只展示两个模型的连接信息,独立开关、存储路径和调优参数保留在 **高级设置** 中。已有开关组合显示为 **自定义组合**,不会自动覆盖。选择模式后保存,并重启 DSH 使记忆流水线设置生效(搜索工具开关即时生效)。只写入编辑过的字段,密钥留空及未编辑的高级设置保持原值。
|
|
22
|
-
|
|
23
|
-
**GitHub**: [Scorp1o117/dsh-tdai-memory](https://github.com/Scorp1o117/dsh-tdai-memory) · **npm**: [dsh-tdai-memory](https://www.npmjs.com/package/dsh-tdai-memory) · [English](README.md)
|
|
24
|
-
|
|
25
|
-
[](https://github.com/Scorp1o117/dsh-enhancement-suite) [](https://www.npmjs.com/package/dsh-enhancement-suite)
|
|
26
|
-
|
|
27
|
-
属于 [DeepSeek Harness Enhancement Suite](https://github.com/Scorp1o117/dsh-enhancement-suite) —— Vision · Soul/Persona · 长期记忆 · 插件市场。
|
|
28
|
-
|
|
29
|
-
把 **TencentDB Agent Memory**(腾讯云开源的四层记忆系统,原为 OpenClaw 插件)移植进 DeepSeek Harness。
|
|
30
|
-
|
|
31
|
-
## 兼容性(v0.4.1)
|
|
32
|
-
|
|
33
|
-
已在 DSH `0.1.7-rc.2`(Web)与 `0.2.0-rc.2`(桌面端运行时)的一次性 Profile 验证。桌面端使用独立的 `desktop` Profile;其他预发布版本暂未验证。
|
|
34
|
-
|
|
35
|
-
## 桌面端安装
|
|
36
|
-
|
|
37
|
-
在桌面端的“插件”页面安装,或使用桌面端“应用 → 管理 dsh 命令”注册的命令:
|
|
38
|
-
|
|
39
|
-
```powershell
|
|
40
|
-
dsh plugin --profile desktop add dsh-tdai-memory@0.3.6
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
重启桌面端以加载客户端插件。配置位于 `$DSH_HOME/profiles/desktop`。
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## 能力
|
|
47
|
-
|
|
48
|
-
- **L0 对话捕获**:每轮对话(turn 结束、请求边界)自动写入原始对话(JSONL + SQLite + FTS + 向量)
|
|
49
|
-
- **L1 结构化记忆**:后台管线用 LLM 从对话中提取事实/偏好/事件(persona / episodic / instruction),写入 `records/` + SQLite + FTS + 向量
|
|
50
|
-
- **L2 场景 / L3 画像**:场景块与用户画像生成(管线自动调度)
|
|
51
|
-
- **自动召回注入**:每次组装提示词时,按当前用户消息检索相关记忆 + 画像,作为动态上下文注入(模型"凭空想起")
|
|
52
|
-
- **工具**:`tdai_memory_search`(L1 结构化检索)、`tdai_conversation_search`(L0 原文检索)
|
|
53
|
-
|
|
54
|
-
数据目录复用现有 `~/.memory-tencentdb/memory-tdai`,**旧记忆无缝继承**。
|
|
55
|
-
|
|
56
|
-
`node-llama-cpp` 仅供完全本地的 embedding 后端使用,现在声明为可选 peer,默认安装不会再触发原生构建脚本。使用 OpenAI 兼容远程 embedding 时不需要它;选择本地后端的用户需在目标 DSH profile 中单独安装并批准 `node-llama-cpp` 的构建。
|
|
57
|
-
|
|
58
|
-
从 `0.2.13` 起最低支持 DSH `0.1.0-rc.7`,已针对 `0.1.0-rc.7`、
|
|
59
|
-
`0.1.0-rc.8` 和 `0.1.1-rc.1` 测试。仍使用 DSH `0.1.0-rc.6` 的用户请锁定
|
|
60
|
-
`dsh-tdai-memory@0.2.11`;这是最后一个包含旧 settings 白名单兼容补丁的版本。
|
|
61
|
-
|
|
62
|
-
## 架构(移植方式)
|
|
63
|
-
|
|
64
|
-
| 层 | 内容 |
|
|
65
|
-
|---|---|
|
|
66
|
-
| 核心 | `tdai-memory-openclaw-plugin` 的 host-neutral 核心(`src/core`、`src/utils`),tsc 编译为 ESM(`dist-dsh/`),零改动 |
|
|
67
|
-
| 宿主适配 | `StandaloneHostAdapter`(官方 standalone 模式,OpenAI 兼容直调) |
|
|
68
|
-
| dsh 壳 | `index.js`:配置映射、`session/event`+`session/flush` 捕获、`agent.ctx` 上的 `system-prompt/assemble` waterfall 召回注入、工具注册、生命周期 |
|
|
69
|
-
| 备用 | `recall-inject.js`:preset 行形态的召回注入(挂在 agent preset 内时用) |
|
|
70
|
-
|
|
71
|
-
召回缓存默认 30 秒过期,每个注入实例最多保留 128 个会话。失败或超时的召回
|
|
72
|
-
会在下次组装时重试。preset 行还支持 `timeoutMs`(默认 4000),到达期限后
|
|
73
|
-
不注入记忆并继续组装提示词;提前完成时会清除超时定时器。期限到达后,底层
|
|
74
|
-
召回任务可能仍会继续运行。
|
|
75
|
-
|
|
76
|
-
关键接线(都是踩坑换来的):
|
|
77
|
-
|
|
78
|
-
- **捕获**:`session/flush` 监听器(await 语义,headless 退出前必完成);`turn/start` 时间戳做 L0 cursor 下限;turn id 去重
|
|
79
|
-
- **headless 一次性任务**:flush 内再等 `core.handleSessionEnd()`(L1 提取跑完才退出;否则 5s 关闭超时会杀掉提取)
|
|
80
|
-
- **召回注入**:必须注册在 **`agent.ctx`** 上(组装在 agent 作用域进行,root 监听器收不到);`session/created` 后延迟一 tick 从 `agents` 服务拿 agent
|
|
81
|
-
|
|
82
|
-
## 配置(profile patch + settings)
|
|
83
|
-
|
|
84
|
-
配置以 **settings 命名空间**驱动:profile patch 作为 base 层,`$DSH_HOME/settings.yaml` 的 `tdai-memory:` 节覆盖(LLM/embedding 密钥已迁到 settings.yaml)。首页侧边栏插件 → dsh-tdai-memory 可编辑全部字段(v0.2.0,含写-only 密钥);TdaiCore 启动时构建,改动**重启后生效**。
|
|
85
|
-
|
|
86
|
-
```yaml
|
|
87
|
-
# $DSH_HOME/settings.yaml
|
|
88
|
-
tdai-memory:
|
|
89
|
-
llm:
|
|
90
|
-
apiKey: 'sk-...'
|
|
91
|
-
embedding:
|
|
92
|
-
apiKey: 'local-no-key'
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
```yaml
|
|
96
|
-
# profile patch(base 层)
|
|
97
|
-
- id: tdai-memory
|
|
98
|
-
name: 'dsh-tdai-memory'
|
|
99
|
-
config:
|
|
100
|
-
extraction:
|
|
101
|
-
enabled: true
|
|
102
|
-
enableDedup: false # dedup 的 LLM 输出解析不稳,先关
|
|
103
|
-
llm: # L1/L2/L3 提取模型(OpenAI 兼容)
|
|
104
|
-
baseUrl: 'https://opencode.ai/zen/go/v1'
|
|
105
|
-
model: 'mimo-v2.5' # deepseek-v4-flash 对提取 JSON 输出不合格
|
|
106
|
-
sendSessionHeader: true # 给 LLM 请求带 x-opencode-session(OpenCode Go 等网关要求)
|
|
107
|
-
sessionId: '' # 固定会话 ID;留空 = 数据目录下自动持久化 ID(重启不变)
|
|
108
|
-
embedding: # 向量(OpenAI 兼容 /v1/embeddings)
|
|
109
|
-
baseUrl: 'http://127.0.0.1:8088/v1'
|
|
110
|
-
model: 'Qwen3-Embedding-0.6B'
|
|
111
|
-
dimensions: 1024
|
|
112
|
-
sendDimensions: false
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## 已知取舍
|
|
116
|
-
|
|
117
|
-
- **提取模型**:`mimo-v2.5` 提取正确但单次 20-30s(后台执行,不阻塞对话);`deepseek-v4-flash` 快但 JSON 输出不合规(提取 0 条)
|
|
118
|
-
- **dedup**:LLM 冲突检测输出解析不稳(曾导致 stored=0),默认关闭;开启需换更稳的模型
|
|
119
|
-
- **L1 记忆向量**:随存储写入(8088 embedding 快);L0 向量走后台任务,headless 退出时由 `destroy()` drain
|
|
120
|
-
- **搜索工具**(`toolsEnabled`,默认开启):开关在插件页,切换后**原地生效**(行配置是 `volatile`,无需重启即重新注册)。若两个工具完全缺失,可查插件日志 `[tdai-memory] tools registered: …`(v0.4.1 起);v0.4.1 之前它读的是 cordis 交给 `apply` 的 Volatile 包装对象上的 `config.toolsEnabled` —— 那个属性永远不存在,因此整个失败过程完全静默(issue #3)
|
|
121
|
-
- **升级**:上游拉新代码后,在 tdai 项目目录重跑 `npx tsc -p dsh-tsconfig.json`(产物在 `dist-dsh/`)
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
保存使用配置表单 API;宿主拒绝写入时保留草稿并提示错误。只修改模型不会覆盖密钥,关闭默认开启的选项会显式保存 `false`。
|
|
5
|
+
[English](README.en.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-tdai-memory",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "DeepSeek Harness 的 TencentDB Agent Memory 移植:L0 对话捕获 → L1 结构化记忆提取 → L2 场景/L3 画像,自动召回注入 + 记忆/对话搜索工具;复用现有 ~/.memory-tencentdb/memory-tdai 数据;附 Web UI 设置栏。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"platform": "web"
|
|
19
19
|
},
|
|
20
20
|
"compatibility": {
|
|
21
|
-
"dsh": ">=0.2.0-rc.2 <0.3.0 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3",
|
|
21
|
+
"dsh": ">=0.2.0-rc.2 <0.3.0 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
|
|
22
22
|
"dshReleases": {
|
|
23
23
|
"0.1.5-rc.2": "incompatible",
|
|
24
24
|
"0.1.5-rc.3": "incompatible",
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"0.2.0-rc.2": "compatible",
|
|
32
32
|
"0.2.1-rc.1": "compatible",
|
|
33
33
|
"0.2.1-rc.2": "compatible",
|
|
34
|
-
"0.2.1-rc.3": "compatible"
|
|
34
|
+
"0.2.1-rc.3": "compatible",
|
|
35
|
+
"0.2.1-rc.4": "compatible",
|
|
36
|
+
"0.2.1-rc.5": "compatible"
|
|
35
37
|
},
|
|
36
38
|
"node": ">=22.18",
|
|
37
39
|
"profiles": [
|
|
@@ -68,7 +70,7 @@
|
|
|
68
70
|
"license": "MIT",
|
|
69
71
|
"engines": {
|
|
70
72
|
"node": ">=22.18",
|
|
71
|
-
"dsh": ">=0.2.0-rc.2 <0.3.0 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3"
|
|
73
|
+
"dsh": ">=0.2.0-rc.2 <0.3.0 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5"
|
|
72
74
|
},
|
|
73
75
|
"repository": {
|
|
74
76
|
"type": "git",
|
|
@@ -87,10 +89,14 @@
|
|
|
87
89
|
"sqlite-vec": "0.1.7-alpha.2",
|
|
88
90
|
"undici": "^8.1.0"
|
|
89
91
|
},
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"@deepseek-ai/dsh-settings": "0.2.1-rc.5",
|
|
94
|
+
"@deepseek-ai/dsh-tools": "0.2.1-rc.5"
|
|
95
|
+
},
|
|
90
96
|
"peerDependencies": {
|
|
91
97
|
"react": "^18.2.0",
|
|
92
|
-
"@deepseek-ai/dsh-tools": ">=0.2.0-rc.2 <0.3.0 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3",
|
|
93
|
-
"@deepseek-ai/dsh-settings": ">=0.2.0-rc.2 <0.3.0 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3",
|
|
98
|
+
"@deepseek-ai/dsh-tools": ">=0.2.0-rc.2 <0.3.0 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
|
|
99
|
+
"@deepseek-ai/dsh-settings": ">=0.2.0-rc.2 <0.3.0 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
|
|
94
100
|
"node-llama-cpp": "^3.19.1"
|
|
95
101
|
},
|
|
96
102
|
"peerDependenciesMeta": {
|