Skip to content

Commit 1163b1f

Browse files
authored
fix: openclaw binds embed versioning (#256)
* fix: openclaw binds embed versioning * fix: openclaw binds embed versioning
1 parent fe88bdf commit 1163b1f

File tree

11 files changed

+74
-46
lines changed

11 files changed

+74
-46
lines changed

hindsight-docs/docs/sdks/integrations/openclaw.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ This plugin integrates [hindsight-embed](https://vectorize.io/hindsight/cli), a
1313
```bash
1414
# 1. Configure your LLM provider
1515
export OPENAI_API_KEY="sk-your-key"
16-
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
16+
openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
1717

1818
# 2. Install and enable the plugin
19-
clawdbot plugins install @vectorize-io/hindsight-openclaw
19+
openclaw plugins install @vectorize-io/hindsight-openclaw
2020

2121
# 3. Start OpenClaw
22-
clawdbot gateway
22+
openclaw gateway
2323
```
2424

2525
That's it! The plugin will automatically start capturing and recalling memories.
@@ -118,7 +118,7 @@ Think of hooks as "forced automation" - they always run.
118118
### Prerequisites
119119

120120
- **Node.js** 22+
121-
- **OpenClaw** (Clawdbot) with plugin support
121+
- **OpenClaw** with plugin support
122122
- **uv/uvx** for running `hindsight-embed`
123123
- **LLM API key** (OpenAI, Anthropic, etc.)
124124

@@ -127,21 +127,21 @@ Think of hooks as "forced automation" - they always run.
127127
```bash
128128
# 1. Configure your LLM provider
129129
export OPENAI_API_KEY="sk-your-key"
130-
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
130+
openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
131131

132132
# 2. Install and enable the plugin
133-
clawdbot plugins install @vectorize-io/hindsight-openclaw
133+
openclaw plugins install @vectorize-io/hindsight-openclaw
134134

135135
# 3. Start OpenClaw
136-
clawdbot gateway
136+
openclaw gateway
137137
```
138138

139139
On first start, `uvx` will automatically download `hindsight-embed` (no manual installation needed).
140140

141141

142142
## Configuration
143143

144-
Optional settings in `~/.clawdbot/clawdbot.json`:
144+
Optional settings in `~/.openclaw/openclaw.json`:
145145

146146
```json
147147
{
@@ -178,14 +178,14 @@ The plugin auto-detects your configured provider and API key:
178178
Configure with:
179179
```bash
180180
export OPENAI_API_KEY="sk-your-key"
181-
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
181+
openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
182182
```
183183

184184
## Verification
185185

186186
**Check if plugin is loaded:**
187187
```bash
188-
clawdbot plugins list | grep hindsight
188+
openclaw plugins list | grep hindsight
189189
# Should show: ✓ enabled │ Hindsight Memory │ ...
190190
```
191191

@@ -262,10 +262,10 @@ uvx hindsight-embed@latest entity graph openclaw
262262
**Plugin not loading?**
263263
```bash
264264
# Check plugin installation
265-
clawdbot plugins list | grep -i hindsight
265+
openclaw plugins list | grep -i hindsight
266266

267267
# Reinstall if needed
268-
clawdbot plugins install @vectorize-io/hindsight-openclaw
268+
openclaw plugins install @vectorize-io/hindsight-openclaw
269269
```
270270

271271
**Daemon not starting?**
@@ -293,7 +293,7 @@ echo $OPENAI_API_KEY
293293
**Memories not being stored?**
294294
```bash
295295
# Check gateway logs for auto-capture
296-
tail -f /tmp/clawdbot/clawdbot-*.log | grep Hindsight
296+
tail -f /tmp/openclaw/openclaw-*.log | grep Hindsight
297297

298298
# Should see:
299299
# [Hindsight Hook] agent_end triggered

hindsight-docs/static/get-cli

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set -e
33

44
# Hindsight CLI installer
55
# Usage: curl -fsSL https://hindsight.vectorize.io/get-cli | bash
6+
# Or with specific version: HINDSIGHT_CLI_VERSION=0.4.3 curl -fsSL https://hindsight.vectorize.io/get-cli | bash
67

78
REPO_URL="https://github.com/vectorize-io/hindsight"
89
INSTALL_DIR="${HINDSIGHT_INSTALL_DIR:-$HOME/.local/bin}"
@@ -169,9 +170,18 @@ main() {
169170
platform=$(detect_platform)
170171
print_info "Detected platform: $platform"
171172

172-
# Get latest version
173-
version=$(get_latest_version)
174-
print_info "Latest version: $version"
173+
# Get version (from env var or latest)
174+
if [[ -n "$HINDSIGHT_CLI_VERSION" ]]; then
175+
version="$HINDSIGHT_CLI_VERSION"
176+
# Add 'v' prefix if not present (GitHub releases use v-prefix)
177+
if [[ ! "$version" =~ ^v ]]; then
178+
version="v${version}"
179+
fi
180+
print_info "Using specified version: $version"
181+
else
182+
version=$(get_latest_version)
183+
print_info "Latest version: $version"
184+
fi
175185

176186
# Download binary
177187
tmp_file=$(download_binary "$platform" "$version")

hindsight-docs/versioned_docs/version-0.4/sdks/integrations/openclaw.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ This plugin integrates [hindsight-embed](https://vectorize.io/hindsight/cli), a
1313
```bash
1414
# 1. Configure your LLM provider
1515
export OPENAI_API_KEY="sk-your-key"
16-
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
16+
openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
1717

1818
# 2. Install and enable the plugin
19-
clawdbot plugins install @vectorize-io/hindsight-openclaw
19+
openclaw plugins install @vectorize-io/hindsight-openclaw
2020

2121
# 3. Start OpenClaw
22-
clawdbot gateway
22+
openclaw gateway
2323
```
2424

2525
That's it! The plugin will automatically start capturing and recalling memories.
@@ -127,21 +127,21 @@ Think of hooks as "forced automation" - they always run.
127127
```bash
128128
# 1. Configure your LLM provider
129129
export OPENAI_API_KEY="sk-your-key"
130-
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
130+
openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
131131

132132
# 2. Install and enable the plugin
133-
clawdbot plugins install @vectorize-io/hindsight-openclaw
133+
openclaw plugins install @vectorize-io/hindsight-openclaw
134134

135135
# 3. Start OpenClaw
136-
clawdbot gateway
136+
openclaw gateway
137137
```
138138

139139
On first start, `uvx` will automatically download `hindsight-embed` (no manual installation needed).
140140

141141

142142
## Configuration
143143

144-
Optional settings in `~/.clawdbot/clawdbot.json`:
144+
Optional settings in `~/.openclaw/openclaw.json`:
145145

146146
```json
147147
{
@@ -178,14 +178,14 @@ The plugin auto-detects your configured provider and API key:
178178
Configure with:
179179
```bash
180180
export OPENAI_API_KEY="sk-your-key"
181-
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
181+
openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
182182
```
183183

184184
## Verification
185185

186186
**Check if plugin is loaded:**
187187
```bash
188-
clawdbot plugins list | grep hindsight
188+
openclaw plugins list | grep hindsight
189189
# Should show: ✓ enabled │ Hindsight Memory │ ...
190190
```
191191

@@ -262,10 +262,10 @@ uvx hindsight-embed@latest entity graph openclaw
262262
**Plugin not loading?**
263263
```bash
264264
# Check plugin installation
265-
clawdbot plugins list | grep -i hindsight
265+
openclaw plugins list | grep -i hindsight
266266

267267
# Reinstall if needed
268-
clawdbot plugins install @vectorize-io/hindsight-openclaw
268+
openclaw plugins install @vectorize-io/hindsight-openclaw
269269
```
270270

271271
**Daemon not starting?**
@@ -293,7 +293,7 @@ echo $OPENAI_API_KEY
293293
**Memories not being stored?**
294294
```bash
295295
# Check gateway logs for auto-capture
296-
tail -f /tmp/clawdbot/clawdbot-*.log | grep Hindsight
296+
tail -f /tmp/openclaw/openclaw-*.log | grep Hindsight
297297

298298
# Should see:
299299
# [Hindsight Hook] agent_end triggered

hindsight-embed/hindsight_embed/cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
HINDSIGHT_EMBED_LLM_MODEL: Optional. LLM model (default: "gpt-4o-mini").
1717
HINDSIGHT_EMBED_BANK_ID: Optional. Memory bank ID (default: "default").
1818
HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT: Optional. Seconds before daemon auto-exits when idle (default: 300).
19+
HINDSIGHT_EMBED_API_VERSION: Optional. hindsight-api version to use (default: matches embed version).
20+
Note: Only applies when starting daemon. To change version, stop daemon first.
21+
HINDSIGHT_EMBED_CLI_VERSION: Optional. hindsight CLI version to install (default: {embed_version}).
1922
"""
2023

2124
import argparse

hindsight-embed/hindsight_embed/daemon_client.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ def _find_hindsight_api_command() -> list[str]:
3939
return ["uv", "run", "--project", str(dev_api_path), "hindsight-api"]
4040

4141
# Fall back to uvx for installed version
42-
return ["uvx", "hindsight-api"]
42+
# Allow version override via environment variable (defaults to matching embed version)
43+
from . import __version__
44+
api_version = os.getenv("HINDSIGHT_EMBED_API_VERSION", __version__)
45+
return ["uvx", f"hindsight-api@{api_version}"]
4346

4447

4548
def _is_daemon_running() -> bool:
@@ -220,15 +223,24 @@ def install_cli() -> bool:
220223
import subprocess
221224
import sys
222225

223-
print("Installing hindsight CLI...")
226+
from . import __version__
227+
228+
# Determine CLI version (use env var or match embed version)
229+
cli_version = os.getenv("HINDSIGHT_EMBED_CLI_VERSION", __version__)
230+
231+
print(f"Installing hindsight CLI (version {cli_version})...")
224232
print(f" Installer URL: {CLI_INSTALLER_URL}")
225233

226234
try:
227-
# Download and run installer
235+
# Download and run installer with version env var
236+
env = os.environ.copy()
237+
env["HINDSIGHT_CLI_VERSION"] = cli_version
238+
228239
result = subprocess.run(
229240
["bash", "-c", f"curl -fsSL {CLI_INSTALLER_URL} | bash"],
230241
capture_output=True,
231242
text=True,
243+
env=env,
232244
)
233245

234246
if result.returncode != 0:

hindsight-integrations/openclaw/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ Biomimetic long-term memory for [OpenClaw](https://openclaw.ai) using [Hindsight
77
```bash
88
# 1. Configure your LLM provider
99
export OPENAI_API_KEY="sk-your-key"
10-
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
10+
openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
1111

1212
# 2. Install and enable the plugin
13-
clawdbot plugins install @vectorize-io/hindsight-openclaw
13+
openclaw plugins install @vectorize-io/hindsight-openclaw
1414

1515
# 3. Start OpenClaw
16-
clawdbot gateway
16+
openclaw gateway
1717
```
1818

1919
That's it! The plugin will automatically start capturing and recalling memories.
File renamed without changes.

hindsight-integrations/openclaw/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"type": "module",
8-
"clawdbot": {
8+
"openclaw": {
99
"extensions": [
1010
"./dist/index.js"
1111
]
@@ -27,7 +27,7 @@
2727
},
2828
"files": [
2929
"dist",
30-
"clawdbot.plugin.json",
30+
"openclaw.plugin.json",
3131
"README.md"
3232
],
3333
"scripts": {

hindsight-integrations/openclaw/src/embed-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class HindsightEmbedManager {
2525
) {
2626
this.port = 8889; // hindsight-embed uses fixed port 8889
2727
this.baseUrl = `http://127.0.0.1:8889`;
28-
this.embedDir = join(homedir(), '.clawdbot', 'hindsight-embed');
28+
this.embedDir = join(homedir(), '.openclaw', 'hindsight-embed');
2929
this.llmProvider = llmProvider;
3030
this.llmApiKey = llmApiKey;
3131
this.llmModel = llmModel;

hindsight-integrations/openclaw/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ function detectLLMConfig(api: MoltbotPluginAPI): {
107107
`Please set one of these environment variables:\n${keyInstructions}\n\n` +
108108
`You can set them in your shell profile (~/.zshrc or ~/.bashrc):\n` +
109109
` export ANTHROPIC_API_KEY="your-key-here"\n\n` +
110-
`Or run Moltbot with the environment variable:\n` +
111-
` ANTHROPIC_API_KEY="your-key" clawdbot start\n\n` +
110+
`Or run OpenClaw with the environment variable:\n` +
111+
` ANTHROPIC_API_KEY="your-key" openclaw gateway\n\n` +
112112
`Alternatively, configure ollama provider which doesn't require an API key.`
113113
);
114114
}
@@ -272,10 +272,10 @@ export default function (api: MoltbotPluginAPI) {
272272

273273
console.log('[Hindsight] Auto-recall for prompt:', prompt.substring(0, 50));
274274

275-
// Recall relevant memories (up to 1024 tokens)
275+
// Recall relevant memories (up to 512 tokens)
276276
const response = await client.recall({
277277
query: prompt,
278-
max_tokens: 1024,
278+
max_tokens: 512,
279279
});
280280

281281
if (!response.results || response.results.length === 0) {
@@ -287,7 +287,10 @@ export default function (api: MoltbotPluginAPI) {
287287
const memoriesJson = JSON.stringify(response.results, null, 2);
288288

289289
const contextMessage = `<hindsight_memories>
290+
Relevant memories from past conversations (score 1=highest, prioritize recent when conflicting):
290291
${memoriesJson}
292+
293+
User message: ${prompt}
291294
</hindsight_memories>`;
292295

293296
console.log(`[Hindsight] Auto-recall: Injecting ${response.results.length} memories`);

0 commit comments

Comments
 (0)