activeloopai / activeloopai/hivemind

OpenClaw: bring to summary-lifecycle parity with the other five agents

Đang mở
#85 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
1.6k
Fork
107
Merge trung bình
17 giờ 30 phút
Pull request đã merge (30 ngày)
6

Mô tả

## Background

After the work on branch `embedding_generation`, five of the six supported agents are at full summary-lifecycle parity:

- **Capture**: every user prompt + tool call lands in the `sessions` table with a 768-dim `message_embedding` and `agent=""`.
- **Periodic summary**: a wiki-worker spawns when the per-session summary-state sidecar trips one of three triggers (first-chat at ≥10 msgs, every-N-messages, every-N-hours).
- **Final summary**: a wiki-worker spawns on `session_end` / `Stop` / equivalent.
- **Lock coordination**: a per-session `~/.claude/hooks/summary-state/.lock` (shared across all agents — UUID session ids prevent collision) prevents periodic + final from racing.
- **summary_embedding**: every memory row gets a 768-dim summary vector via the canonical embed-daemon at `~/.hivemind/embed-deps/embed-daemon.js`.

Agents at parity:

- ✅ Claude Code (canonical)
- ✅ Codex
- ✅ Cursor (`cursor-agent --print --model X --force`)
- ✅ Hermes (`hermes -z --provider X -m Y --yolo`)
- ✅ Pi (`pi --print --provider X --model Y`)

## What's missing

**OpenClaw is the only agent not yet at parity.** It was deferred during the multi-agent rollout because its plugin lives in-process (extension-style, similar to Pi but with different lifecycle hooks) rather than as external subprocess hooks. None of the new pieces have been wired into it:

- No periodic-summary trigger logic in the OpenClaw extension.
- No `spawn-wiki-worker` for OpenClaw, no `wiki-worker.js` bundle entry, no install step that drops it into the OpenClaw plugins dir.
- No agent-tagged capture (capture currently doesn't set `agent=\"openclaw\"`).
- No source-level lock-in tests like \`hermes-wiki-worker-source.test.ts\` / \`cursor-wiki-worker-source.test.ts\`.
- No README env-var documentation (\`HIVEMIND_OPENCLAW_PROVIDER\` / \`HIVEMIND_OPENCLAW_MODEL\`) — the knobs don't exist yet.

## Suggested approach

Mirror the Pi rollout, since both agents are in-process extensions:

1. Fork \`src/hooks/codex/wiki-worker.ts\` → \`src/hooks/openclaw/wiki-worker.ts\`. Shell out to the OpenClaw equivalent of \`pi --print\` (whatever the OpenClaw oneshot CLI is — needs a quick check of the OpenClaw README).
2. Fork \`src/hooks/codex/spawn-wiki-worker.ts\` → \`src/hooks/openclaw/spawn-wiki-worker.ts\` with \`findOpenclawBin\`, hooks dir at \`~/.openclaw/hooks\`, env vars \`HIVEMIND_OPENCLAW_PROVIDER\` / \`HIVEMIND_OPENCLAW_MODEL\`.
3. Add the in-process triggers to \`openclaw/extension-source/hivemind.ts\` (or wherever the OpenClaw extension lives) — mirror the Pi pattern: \`bumpTotalCount\` / \`shouldTriggerNow\` / \`tryAcquireLock\` / spawn detached wiki-worker; final summary on \`session_shutdown\`.
4. Tag capture rows \`agent=\"openclaw\"\`.
5. Add a bundle entry in \`esbuild.config.mjs\` for \`openclaw/bundle/wiki-worker.js\`; update the install step to deposit it.
6. Add a source-level lock-in test (\`claude-code/tests/openclaw-wiki-worker-source.test.ts\`) following the same shape as the hermes/cursor ones.
7. README config table: add the two new env-var rows.
8. E2E: tmux-driven session, force \`HIVEMIND_SUMMARY_EVERY_N_MSGS=2\`, verify a memory row + sessions rows with 768-dim embeddings and \`agent=\"openclaw\"\`.

## Acceptance criteria

- A \`hivemind install\` (or \`hivemind openclaw install\`) on a machine with OpenClaw deposits \`wiki-worker.js\` and wires the extension exactly like Pi.
- An OpenClaw session with \`HIVEMIND_SUMMARY_EVERY_N_MSGS=2\` and \`HIVEMIND_DEBUG=1\` produces:
- N+ rows in sessions with \`agent=\"openclaw\"\` and \`message_embedding\` length 768
- ≥1 row in memory with \`agent=\"openclaw\"\` and \`summary_embedding\` length 768 after either the periodic threshold trips or the final session ends
- Source-level test passing: locks the spawn shape, agent label, env-var defaults, hooks dir, and the \`spawnOpenclawWikiWorker\` export.

## Out of scope

- Switching OpenClaw from extension-style to external subprocess hooks. Keep the in-process model — Pi proved this works fine.

## Context links

- \`claude-code/tests/cursor-wiki-worker-source.test.ts\` and \`claude-code/tests/hermes-wiki-worker-source.test.ts\` — source-level test pattern to mirror.
- \`src/hooks/pi/wiki-worker.ts\` and \`pi/extension-source/hivemind.ts\` — closest architectural reference (in-process extension).
- Branch where the other five agents reached parity: \`embedding_generation\`.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.