OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Feature]: Droid (Factory) host adapter for the memory plugin

Open zyaiire opened this issue 3 weeks ago • 1 comments

中文见下

Issue Origin

Observed or reproduced in a real environment

Problem Statement

There is no OpenViking memory integration for local Factory Droid (CLI, interactive and droid exec). Droid has plugins, Claude-Code-style hooks and MCP, and #6880 lists it among the clients that read the Claude Code plugin layout. Three things we measured on Droid CLI 0.232.0 keep claude-code-memory-plugin from covering it as it stands:

  • Transcript format. Droid's Stop stdin does carry transcript_path, but the file (~/.factory/sessions/<cwd>/<id>.jsonl, session_start.version = 2) is not Claude Code's format. Every row is a message record linked by parentId, and hook records, injected context, error notices and Droid's own notices sit in the same stream as the conversation. A fork copies the parent's records into a new file with their original ids.
  • Plugin root in MCP config. Droid substitutes the plugin root into hook commands but not into a native plugin's MCP config: ${DROID_PLUGIN_ROOT} in args reaches the process literally, and ${VAR} in env is read as a credential reference, so the server fails to start when it is unset.
  • Hook stdout. UserPromptSubmit does not fire under droid exec. In interactive mode Droid uses any non-empty stdout of that hook as context, a bare {} included, and keeps only the first hook's context.

The verified extension surface is written up here: https://github.com/zyaiire/openviking-droid-memory/blob/main/DESIGN.md

Proposed Solution

A community plugin is working at https://github.com/zyaiire/openviking-droid-memory:

droid plugin marketplace add https://github.com/zyaiire/openviking-droid-memory
droid plugin install openviking-memory@openviking-droid-memory
  • claude-code-memory-plugin/scripts/shared, servers/mcp-proxy.mjs and the four skills are vendored unmodified at d2ef5dfa (0.7.22), with a hash per file checked in tests.
  • The Droid side is its own hook entries, modeled on upstream's, with client id droid (plugin.droid in ovcli.conf) and OpenViking sessions named dr-<droid session id>.
  • Capture reads only the session file. It follows the main parentId chain, drops the part of a fork that belongs to the parent session, and sends {role, content, turn_id} with the record id as turn_id. Stop commits once pending tokens reach commitTokenThreshold; PreCompact and SessionEnd always commit.
  • Hooks print the context envelope only when they inject, and nothing otherwise.
  • The MCP proxy starts through a short inline launcher that finds the install under ~/.factory/plugins/installed_plugins/.

It was run against Droid 0.232.0 and a live OpenViking server: profile injection, recall, an MCP tool call, capture and commit under droid exec, /compress and /exit. npm test runs 31 tests against transcripts recorded from Droid.

Questions for maintainers

  1. Would you like a Droid host upstream, or should this stay a community plugin? Either way, could droid be added to HARNESS_KEYS so the doctor accepts plugin.droid?
  2. Would a pluggable transcript decoder in claude-code-memory-plugin be welcome? Hosts with Claude-style hooks but their own transcript format could then reuse the capture entries instead of porting them.
  3. Is a host record id (one per message, not one per turn) the intended use of turn_id?

Alternatives Considered

  • Installing the Claude Code plugin on Droid directly (#6880). We did not run this end to end. Its capture parses Claude Code transcript records, and its .mcp.json depends on the plugin root being substituted, which we saw Droid not do for a native plugin.
  • Capturing from Stop stdin: it carries no conversation text.

Feature Area

Other

Use Case

Using Droid alongside other agents on the same machine, all sharing one OpenViking memory: profile at session start, recall on prompt submit, capture of each turn, commit before compaction and at session end, plus the OpenViking MCP tools and skills.

Contribution

  • [x] I am willing to contribute to implementing this feature

Related: #7267 (Devin).


中文

本机 Factory Droid(CLI,交互模式与 droid exec)目前没有 OpenViking 记忆集成。Droid 支持插件、Claude Code 风格的 hook 和 MCP,#6880 也把它列为能读 Claude Code 插件布局的客户端。但我们在 Droid CLI 0.232.0 上实测到三点,使 claude-code-memory-plugin 不能原样覆盖它:

  • 会话文件格式不同。 Droid 的 Stop stdin 带 transcript_path,但文件不是 Claude Code 的格式:每行是用 parentId 串起来的 message 记录,hook 记录、注入的上下文、错误提示和 Droid 自己的提示与对话混在同一个流里;fork 会把父会话的记录连同原 id 复制到新文件。
  • MCP 配置里不替换插件根目录。 hook 命令里会替换,原生插件的 MCP 配置里不会:args 中的 ${DROID_PLUGIN_ROOT} 原样传给进程,env 中的 ${VAR} 被当作凭据引用,未设置时服务启动失败。
  • hook 输出。 droid exec 下不触发 UserPromptSubmit。交互模式下,这个 hook 的任何非空输出(包括 {})都会被当作上下文,而且只取第一个 hook 的上下文。

已验证的扩展面见 https://github.com/zyaiire/openviking-droid-memory/blob/main/DESIGN.md

社区插件已经可用:https://github.com/zyaiire/openviking-droid-memory 。上游的共享运行时、MCP 代理和四个 skill 原样 vendor 并固定在 d2ef5dfa;Droid 专有的 hook 入口、会话解码器和 MCP 启动器自己实现;客户端 id 为 droid,OpenViking 会话名为 dr-<droid 会话 id>。已在 Droid 0.232.0 和真实 OpenViking 服务端上跑通画像注入、召回、MCP 工具调用、捕获与提交、/compress 和 /exit。

想请维护者回答的问题:

  1. 是否欢迎上游收录 Droid 宿主,还是保持社区插件?无论哪种,能否把 droid 加进 HARNESS_KEYS,让 doctor 认识 plugin.droid?
  2. 是否欢迎在 claude-code-memory-plugin 里把 transcript 解码做成可插拔的?这样 hook 是 Claude 风格、但会话格式自成一套的宿主可以直接复用捕获入口,不必移植。
  3. 用宿主的记录 id(每条消息一个,而不是每轮一个)当 turn_id,符合设计意图吗?

zyaiire avatar Nov 10 '26 03:11 zyaiire

感谢反馈,但我们精力有限,只维护主流的框架,其他的可以直接使用 openviking gateway,这个会适配任何的agent框架

qin-ctx avatar Nov 12 '26 13:11 qin-ctx