dshbase

插件目录 / Knowledge / dsh-tdai-memory

dsh-tdai-memory

已验证 · 实测可装 Scorp1o117

✓ 持续维护 基于 3 个官方 DSH 包

查看 GitHub ↗ ← 返回插件目录

6Stars
0Forks
0未关闭 issue
JavaScript语言
2026-08-16最近推送
跨平台平台

功能简介

腾讯四层记忆(L0-L3:对话层/原子记忆/场景归纳/用户画像)的 DSH 移植,带向量检索。

✅
我们的评价
可用 — 实测通过,早期项目

腾讯四层记忆(L0-L3:对话层/原子记忆/场景归纳/用户画像)的 DSH 移植,带向量检索。 实测能干净安装、正常启动。早期项目,但功能可用。

「已验证」表示我们的自动化 CI 在干净 profile 里实际执行了 dsh plugin add 并启动成功——仅此而已。功能描述与版本兼容性均为作者声明。这不是安全审计,也不代表对第三方代码的背书。

README

dsh-tdai-memory

中文文档

GitHub: Scorp1o117/dsh-tdai-memory · npm: dsh-tdai-memory

Enhancement Suite npm

Part of the DeepSeek Harness Enhancement Suite — Vision · Soul/Persona · Long-term Memory · Plugin Marketplace.

A port of TencentDB Agent Memory (Tencent Cloud's open-source four-layer
memory system, originally an OpenClaw plugin) into DeepSeek Harness.

Features

  • L0 conversation capture: every turn (turn end, request boundary) is
    written to raw conversation storage (JSONL + SQLite + FTS + vectors)
  • L1 structured memory: a background pipeline uses an LLM to extract
    facts / preferences / events (persona / episodic / instruction) from
    conversations, stored in records/ + SQLite + FTS + vectors
  • L2 scenes / L3 persona: scene blocks and user profile generation
    (pipeline-scheduled)
  • Automatic recall injection: on every prompt assembly, relevant memories
    and the user profile are retrieved by the current user message and injected
    as dynamic context (the model "just remembers")
  • Tools: tdai_memory_search (L1 structured search),
    tdai_conversation_search (L0 raw-text search)

The data directory reuses the existing ~/.memory-tencentdb/memory-tdai, so
previously accumulated memories carry over seamlessly.

Architecture (porting approach)

Layer Content
Core The host-neutral core of tdai-memory-openclaw-plugin (src/core, src/utils), tsc-compiled to ESM (dist-dsh/), zero changes
Host adapter StandaloneHostAdapter (official standalone mode, direct OpenAI-compatible calls)
dsh shell index.js: config mapping, session/event + session/flush capture, system-prompt/assemble recall injection on agent.ctx, tool registration, lifecycle
Fallback recall-inject.js: preset-row recall injection (used when mounted inside an agent preset)

Hard-won wiring details:

  • Capture: session/flush listener (await semantics; must complete before
    headless exits); turn/start timestamps as the L0 cursor floor; turn-id dedup
  • Headless one-shot runs: wait for core.handleSessionEnd() inside flush
    (L1 extraction finishes before exit; otherwise the 5s shutdown timeout kills it)
  • Recall injection: must be registered on agent.ctx (assembly runs in
    the agent scope; root listeners never see it); attach one tick after
    session/created by resolving the agent from the agents service

Configuration (profile patch + settings)

Configuration is settings-namespace driven: the profile patch is the base
layer, and the tdai-memory: section of $DSH_HOME/settings.yaml overrides it
(LLM/embedding keys live in settings.yaml). The Web UI Settings → 记忆
section edits every field (v0.2.0, write-only keys); TdaiCore is built at
startup, so changes apply after a restart.

# $DSH_HOME/settings.yaml
tdai-memory:
  llm:
    apiKey: 'sk-...'
  embedding:
    apiKey: 'local-no-key'
# profile patch (base layer)
- id: tdai-memory
  name: 'dsh-tdai-memory'
  config:
    extraction:
      enabled: true
      enableDedup: false      # dedup LLM output parsing is flaky; off by default
    llm:                      # L1/L2/L3 extraction model (OpenAI-compatible)
      baseUrl: 'https://opencode.ai/zen/go/v1'
      model: 'mimo-v2.5'      # deepseek-v4-flash produces invalid extraction JSON
    embedding:                # vectors (OpenAI-compatible /v1/embeddings)
      baseUrl: 'http://127.0.0.1:8088/v1'
      model: 'Qwen3-Embedding-0.6B'
      dimensions: 1024
      sendDimensions: false

Install

dsh plugin --profile web add dsh-tdai-memory

then mount it in $DSH_HOME/profiles/web/cordis.patch.yml:

- insert:
    - id: tdai-memory
      name: 'dsh-tdai-memory'
      config: {}          # keys can live in settings.yaml instead

and restart dsh web. LLM/embedding API keys can be set in the Web UI
settings page (记忆 / Memory) or directly in settings.yaml under
tdai-memory:.

Note for users

  • This plugin is a standard profile bundle (dsh.bundle.patch):
    dsh plugin --profile web add dsh-tdai-memory installs and mounts it in
    one step — no manual cordis.patch.yml edits needed.
  • The settings section needs the dsh-host-apiproxy namespace allowlist;
    the plugin patches it automatically on first start — restart dsh web
    once more
    and the section appears. A dsh update overwrites the patch;
    the next plugin start re-applies it.
  • Settings changes apply after a restart (TdaiCore is built at startup).
  • Tested against DSH 0.1.0-rc.6.

Known trade-offs

  • Extraction model: mimo-v2.5 extracts correctly but takes 20-30s per
    call (background execution, does not block the conversation);
    deepseek-v4-flash is fast but its JSON output is non-compliant (extracts 0)
  • dedup: LLM conflict-detection output parsing is unstable (once caused
    stored=0); off by default; enable only with a more reliable model
  • L1 memory vectors: written with storage (8088 embedding is fast); L0
    vectors run as a background task, drained by destroy() on headless exit
  • Upgrades: after pulling new upstream code, rerun
    npx tsc -p dsh-tsconfig.json in the tdai project dir (output in dist-dsh/)

License

MIT

安装

🧩 让 Agent 自动装(推荐)

装一次目录插件,之后本站所有插件都能让 DeepSeek Harness 自动找、自动装:

dsh plugin add dshbase-catalog

然后对 agent 说「帮我装 dsh-tdai-memory」,它会在目录里找到并自动安装。文档:dshbase-catalog · 已验证场景包。

Web profile:

dsh plugin --profile web add dsh-tdai-memory

Headless(CLI)profile:

dsh plugin --profile headless add dsh-tdai-memory

包信息

npm:dsh-tdai-memory · 版本 0.2.7 · 实测环境 dsh 0.1.0-rc.6

实测报告

端到端验证通过:dsh 0.1.0-rc.6 上 L1 安装 + L2 加载 + L3 运行问答。

使用场景

给 agent 一套记忆、知识库或检索层,让它不再跨会话丢上下文。

适合谁

跑长项目、想让 agent 记住决策、文档和偏好而不用每次重讲的人。

二次开发建议

记忆/检索后端是缝——插新存储、调蒸馏策略,或加引用与审计轨迹。

安全:尚未扫描——我们的每日静态扫描将很快覆盖它。

分享徽章

Knowledge 里更多

浏览全部 7797 个插件 →