fix: openclaw binds embed versioning (#256)

* fix: openclaw binds embed versioning

* fix: openclaw binds embed versioning
This commit is contained in:
Nicolò Boschi 2026-01-30 17:23:52 +01:00 committed by GitHub
parent fe88bdf704
commit 1163b1f6a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 74 additions and 46 deletions

View file

@ -13,13 +13,13 @@ This plugin integrates [hindsight-embed](https://vectorize.io/hindsight/cli), a
```bash ```bash
# 1. Configure your LLM provider # 1. Configure your LLM provider
export OPENAI_API_KEY="sk-your-key" export OPENAI_API_KEY="sk-your-key"
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}' openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
# 2. Install and enable the plugin # 2. Install and enable the plugin
clawdbot plugins install @vectorize-io/hindsight-openclaw openclaw plugins install @vectorize-io/hindsight-openclaw
# 3. Start OpenClaw # 3. Start OpenClaw
clawdbot gateway openclaw gateway
``` ```
That's it! The plugin will automatically start capturing and recalling memories. 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.
### Prerequisites ### Prerequisites
- **Node.js** 22+ - **Node.js** 22+
- **OpenClaw** (Clawdbot) with plugin support - **OpenClaw** with plugin support
- **uv/uvx** for running `hindsight-embed` - **uv/uvx** for running `hindsight-embed`
- **LLM API key** (OpenAI, Anthropic, etc.) - **LLM API key** (OpenAI, Anthropic, etc.)
@ -127,13 +127,13 @@ Think of hooks as "forced automation" - they always run.
```bash ```bash
# 1. Configure your LLM provider # 1. Configure your LLM provider
export OPENAI_API_KEY="sk-your-key" export OPENAI_API_KEY="sk-your-key"
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}' openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
# 2. Install and enable the plugin # 2. Install and enable the plugin
clawdbot plugins install @vectorize-io/hindsight-openclaw openclaw plugins install @vectorize-io/hindsight-openclaw
# 3. Start OpenClaw # 3. Start OpenClaw
clawdbot gateway openclaw gateway
``` ```
On first start, `uvx` will automatically download `hindsight-embed` (no manual installation needed). On first start, `uvx` will automatically download `hindsight-embed` (no manual installation needed).
@ -141,7 +141,7 @@ On first start, `uvx` will automatically download `hindsight-embed` (no manual i
## Configuration ## Configuration
Optional settings in `~/.clawdbot/clawdbot.json`: Optional settings in `~/.openclaw/openclaw.json`:
```json ```json
{ {
@ -178,14 +178,14 @@ The plugin auto-detects your configured provider and API key:
Configure with: Configure with:
```bash ```bash
export OPENAI_API_KEY="sk-your-key" export OPENAI_API_KEY="sk-your-key"
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}' openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
``` ```
## Verification ## Verification
**Check if plugin is loaded:** **Check if plugin is loaded:**
```bash ```bash
clawdbot plugins list | grep hindsight openclaw plugins list | grep hindsight
# Should show: ✓ enabled │ Hindsight Memory │ ... # Should show: ✓ enabled │ Hindsight Memory │ ...
``` ```
@ -262,10 +262,10 @@ uvx hindsight-embed@latest entity graph openclaw
**Plugin not loading?** **Plugin not loading?**
```bash ```bash
# Check plugin installation # Check plugin installation
clawdbot plugins list | grep -i hindsight openclaw plugins list | grep -i hindsight
# Reinstall if needed # Reinstall if needed
clawdbot plugins install @vectorize-io/hindsight-openclaw openclaw plugins install @vectorize-io/hindsight-openclaw
``` ```
**Daemon not starting?** **Daemon not starting?**
@ -293,7 +293,7 @@ echo $OPENAI_API_KEY
**Memories not being stored?** **Memories not being stored?**
```bash ```bash
# Check gateway logs for auto-capture # Check gateway logs for auto-capture
tail -f /tmp/clawdbot/clawdbot-*.log | grep Hindsight tail -f /tmp/openclaw/openclaw-*.log | grep Hindsight
# Should see: # Should see:
# [Hindsight Hook] agent_end triggered # [Hindsight Hook] agent_end triggered

View file

@ -3,6 +3,7 @@ set -e
# Hindsight CLI installer # Hindsight CLI installer
# Usage: curl -fsSL https://hindsight.vectorize.io/get-cli | bash # Usage: curl -fsSL https://hindsight.vectorize.io/get-cli | bash
# Or with specific version: HINDSIGHT_CLI_VERSION=0.4.3 curl -fsSL https://hindsight.vectorize.io/get-cli | bash
REPO_URL="https://github.com/vectorize-io/hindsight" REPO_URL="https://github.com/vectorize-io/hindsight"
INSTALL_DIR="${HINDSIGHT_INSTALL_DIR:-$HOME/.local/bin}" INSTALL_DIR="${HINDSIGHT_INSTALL_DIR:-$HOME/.local/bin}"
@ -169,9 +170,18 @@ main() {
platform=$(detect_platform) platform=$(detect_platform)
print_info "Detected platform: $platform" print_info "Detected platform: $platform"
# Get latest version # Get version (from env var or latest)
version=$(get_latest_version) if [[ -n "$HINDSIGHT_CLI_VERSION" ]]; then
print_info "Latest version: $version" version="$HINDSIGHT_CLI_VERSION"
# Add 'v' prefix if not present (GitHub releases use v-prefix)
if [[ ! "$version" =~ ^v ]]; then
version="v${version}"
fi
print_info "Using specified version: $version"
else
version=$(get_latest_version)
print_info "Latest version: $version"
fi
# Download binary # Download binary
tmp_file=$(download_binary "$platform" "$version") tmp_file=$(download_binary "$platform" "$version")

View file

@ -13,13 +13,13 @@ This plugin integrates [hindsight-embed](https://vectorize.io/hindsight/cli), a
```bash ```bash
# 1. Configure your LLM provider # 1. Configure your LLM provider
export OPENAI_API_KEY="sk-your-key" export OPENAI_API_KEY="sk-your-key"
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}' openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
# 2. Install and enable the plugin # 2. Install and enable the plugin
clawdbot plugins install @vectorize-io/hindsight-openclaw openclaw plugins install @vectorize-io/hindsight-openclaw
# 3. Start OpenClaw # 3. Start OpenClaw
clawdbot gateway openclaw gateway
``` ```
That's it! The plugin will automatically start capturing and recalling memories. That's it! The plugin will automatically start capturing and recalling memories.
@ -127,13 +127,13 @@ Think of hooks as "forced automation" - they always run.
```bash ```bash
# 1. Configure your LLM provider # 1. Configure your LLM provider
export OPENAI_API_KEY="sk-your-key" export OPENAI_API_KEY="sk-your-key"
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}' openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
# 2. Install and enable the plugin # 2. Install and enable the plugin
clawdbot plugins install @vectorize-io/hindsight-openclaw openclaw plugins install @vectorize-io/hindsight-openclaw
# 3. Start OpenClaw # 3. Start OpenClaw
clawdbot gateway openclaw gateway
``` ```
On first start, `uvx` will automatically download `hindsight-embed` (no manual installation needed). On first start, `uvx` will automatically download `hindsight-embed` (no manual installation needed).
@ -141,7 +141,7 @@ On first start, `uvx` will automatically download `hindsight-embed` (no manual i
## Configuration ## Configuration
Optional settings in `~/.clawdbot/clawdbot.json`: Optional settings in `~/.openclaw/openclaw.json`:
```json ```json
{ {
@ -178,14 +178,14 @@ The plugin auto-detects your configured provider and API key:
Configure with: Configure with:
```bash ```bash
export OPENAI_API_KEY="sk-your-key" export OPENAI_API_KEY="sk-your-key"
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}' openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
``` ```
## Verification ## Verification
**Check if plugin is loaded:** **Check if plugin is loaded:**
```bash ```bash
clawdbot plugins list | grep hindsight openclaw plugins list | grep hindsight
# Should show: ✓ enabled │ Hindsight Memory │ ... # Should show: ✓ enabled │ Hindsight Memory │ ...
``` ```
@ -262,10 +262,10 @@ uvx hindsight-embed@latest entity graph openclaw
**Plugin not loading?** **Plugin not loading?**
```bash ```bash
# Check plugin installation # Check plugin installation
clawdbot plugins list | grep -i hindsight openclaw plugins list | grep -i hindsight
# Reinstall if needed # Reinstall if needed
clawdbot plugins install @vectorize-io/hindsight-openclaw openclaw plugins install @vectorize-io/hindsight-openclaw
``` ```
**Daemon not starting?** **Daemon not starting?**
@ -293,7 +293,7 @@ echo $OPENAI_API_KEY
**Memories not being stored?** **Memories not being stored?**
```bash ```bash
# Check gateway logs for auto-capture # Check gateway logs for auto-capture
tail -f /tmp/clawdbot/clawdbot-*.log | grep Hindsight tail -f /tmp/openclaw/openclaw-*.log | grep Hindsight
# Should see: # Should see:
# [Hindsight Hook] agent_end triggered # [Hindsight Hook] agent_end triggered

View file

@ -16,6 +16,9 @@ Environment variables:
HINDSIGHT_EMBED_LLM_MODEL: Optional. LLM model (default: "gpt-4o-mini"). HINDSIGHT_EMBED_LLM_MODEL: Optional. LLM model (default: "gpt-4o-mini").
HINDSIGHT_EMBED_BANK_ID: Optional. Memory bank ID (default: "default"). HINDSIGHT_EMBED_BANK_ID: Optional. Memory bank ID (default: "default").
HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT: Optional. Seconds before daemon auto-exits when idle (default: 300). HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT: Optional. Seconds before daemon auto-exits when idle (default: 300).
HINDSIGHT_EMBED_API_VERSION: Optional. hindsight-api version to use (default: matches embed version).
Note: Only applies when starting daemon. To change version, stop daemon first.
HINDSIGHT_EMBED_CLI_VERSION: Optional. hindsight CLI version to install (default: {embed_version}).
""" """
import argparse import argparse

View file

@ -39,7 +39,10 @@ def _find_hindsight_api_command() -> list[str]:
return ["uv", "run", "--project", str(dev_api_path), "hindsight-api"] return ["uv", "run", "--project", str(dev_api_path), "hindsight-api"]
# Fall back to uvx for installed version # Fall back to uvx for installed version
return ["uvx", "hindsight-api"] # Allow version override via environment variable (defaults to matching embed version)
from . import __version__
api_version = os.getenv("HINDSIGHT_EMBED_API_VERSION", __version__)
return ["uvx", f"hindsight-api@{api_version}"]
def _is_daemon_running() -> bool: def _is_daemon_running() -> bool:
@ -220,15 +223,24 @@ def install_cli() -> bool:
import subprocess import subprocess
import sys import sys
print("Installing hindsight CLI...") from . import __version__
# Determine CLI version (use env var or match embed version)
cli_version = os.getenv("HINDSIGHT_EMBED_CLI_VERSION", __version__)
print(f"Installing hindsight CLI (version {cli_version})...")
print(f" Installer URL: {CLI_INSTALLER_URL}") print(f" Installer URL: {CLI_INSTALLER_URL}")
try: try:
# Download and run installer # Download and run installer with version env var
env = os.environ.copy()
env["HINDSIGHT_CLI_VERSION"] = cli_version
result = subprocess.run( result = subprocess.run(
["bash", "-c", f"curl -fsSL {CLI_INSTALLER_URL} | bash"], ["bash", "-c", f"curl -fsSL {CLI_INSTALLER_URL} | bash"],
capture_output=True, capture_output=True,
text=True, text=True,
env=env,
) )
if result.returncode != 0: if result.returncode != 0:

View file

@ -7,13 +7,13 @@ Biomimetic long-term memory for [OpenClaw](https://openclaw.ai) using [Hindsight
```bash ```bash
# 1. Configure your LLM provider # 1. Configure your LLM provider
export OPENAI_API_KEY="sk-your-key" export OPENAI_API_KEY="sk-your-key"
clawdbot config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}' openclaw config set 'agents.defaults.models."openai/gpt-4o-mini"' '{}'
# 2. Install and enable the plugin # 2. Install and enable the plugin
clawdbot plugins install @vectorize-io/hindsight-openclaw openclaw plugins install @vectorize-io/hindsight-openclaw
# 3. Start OpenClaw # 3. Start OpenClaw
clawdbot gateway openclaw gateway
``` ```
That's it! The plugin will automatically start capturing and recalling memories. That's it! The plugin will automatically start capturing and recalling memories.

View file

@ -5,7 +5,7 @@
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"type": "module", "type": "module",
"clawdbot": { "openclaw": {
"extensions": [ "extensions": [
"./dist/index.js" "./dist/index.js"
] ]
@ -27,7 +27,7 @@
}, },
"files": [ "files": [
"dist", "dist",
"clawdbot.plugin.json", "openclaw.plugin.json",
"README.md" "README.md"
], ],
"scripts": { "scripts": {

View file

@ -25,7 +25,7 @@ export class HindsightEmbedManager {
) { ) {
this.port = 8889; // hindsight-embed uses fixed port 8889 this.port = 8889; // hindsight-embed uses fixed port 8889
this.baseUrl = `http://127.0.0.1:8889`; this.baseUrl = `http://127.0.0.1:8889`;
this.embedDir = join(homedir(), '.clawdbot', 'hindsight-embed'); this.embedDir = join(homedir(), '.openclaw', 'hindsight-embed');
this.llmProvider = llmProvider; this.llmProvider = llmProvider;
this.llmApiKey = llmApiKey; this.llmApiKey = llmApiKey;
this.llmModel = llmModel; this.llmModel = llmModel;

View file

@ -107,8 +107,8 @@ function detectLLMConfig(api: MoltbotPluginAPI): {
`Please set one of these environment variables:\n${keyInstructions}\n\n` + `Please set one of these environment variables:\n${keyInstructions}\n\n` +
`You can set them in your shell profile (~/.zshrc or ~/.bashrc):\n` + `You can set them in your shell profile (~/.zshrc or ~/.bashrc):\n` +
` export ANTHROPIC_API_KEY="your-key-here"\n\n` + ` export ANTHROPIC_API_KEY="your-key-here"\n\n` +
`Or run Moltbot with the environment variable:\n` + `Or run OpenClaw with the environment variable:\n` +
` ANTHROPIC_API_KEY="your-key" clawdbot start\n\n` + ` ANTHROPIC_API_KEY="your-key" openclaw gateway\n\n` +
`Alternatively, configure ollama provider which doesn't require an API key.` `Alternatively, configure ollama provider which doesn't require an API key.`
); );
} }
@ -272,10 +272,10 @@ export default function (api: MoltbotPluginAPI) {
console.log('[Hindsight] Auto-recall for prompt:', prompt.substring(0, 50)); console.log('[Hindsight] Auto-recall for prompt:', prompt.substring(0, 50));
// Recall relevant memories (up to 1024 tokens) // Recall relevant memories (up to 512 tokens)
const response = await client.recall({ const response = await client.recall({
query: prompt, query: prompt,
max_tokens: 1024, max_tokens: 512,
}); });
if (!response.results || response.results.length === 0) { if (!response.results || response.results.length === 0) {
@ -287,7 +287,10 @@ export default function (api: MoltbotPluginAPI) {
const memoriesJson = JSON.stringify(response.results, null, 2); const memoriesJson = JSON.stringify(response.results, null, 2);
const contextMessage = `<hindsight_memories> const contextMessage = `<hindsight_memories>
Relevant memories from past conversations (score 1=highest, prioritize recent when conflicting):
${memoriesJson} ${memoriesJson}
User message: ${prompt}
</hindsight_memories>`; </hindsight_memories>`;
console.log(`[Hindsight] Auto-recall: Injecting ${response.results.length} memories`); console.log(`[Hindsight] Auto-recall: Injecting ${response.results.length} memories`);

10
uv.lock
View file

@ -1295,7 +1295,7 @@ wheels = [
[[package]] [[package]]
name = "hindsight-all" name = "hindsight-all"
version = "0.4.4" version = "0.4.5"
source = { editable = "hindsight" } source = { editable = "hindsight" }
dependencies = [ dependencies = [
{ name = "hindsight-api" }, { name = "hindsight-api" },
@ -1319,7 +1319,7 @@ provides-extras = ["test"]
[[package]] [[package]]
name = "hindsight-api" name = "hindsight-api"
version = "0.4.4" version = "0.4.5"
source = { editable = "hindsight-api" } source = { editable = "hindsight-api" }
dependencies = [ dependencies = [
{ name = "aiohttp" }, { name = "aiohttp" },
@ -1449,7 +1449,7 @@ dev = [
[[package]] [[package]]
name = "hindsight-client" name = "hindsight-client"
version = "0.4.4" version = "0.4.5"
source = { editable = "hindsight-clients/python" } source = { editable = "hindsight-clients/python" }
dependencies = [ dependencies = [
{ name = "aiohttp" }, { name = "aiohttp" },
@ -1483,7 +1483,7 @@ provides-extras = ["test"]
[[package]] [[package]]
name = "hindsight-dev" name = "hindsight-dev"
version = "0.4.4" version = "0.4.5"
source = { editable = "hindsight-dev" } source = { editable = "hindsight-dev" }
dependencies = [ dependencies = [
{ name = "hindsight-api" }, { name = "hindsight-api" },
@ -1529,7 +1529,7 @@ dev = [
[[package]] [[package]]
name = "hindsight-embed" name = "hindsight-embed"
version = "0.4.4" version = "0.4.5"
source = { editable = "hindsight-embed" } source = { editable = "hindsight-embed" }
dependencies = [ dependencies = [
{ name = "httpx" }, { name = "httpx" },