From 1163b1f6a647870aa8e4f844518942b1010e0517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Fri, 30 Jan 2026 17:23:52 +0100 Subject: [PATCH] fix: openclaw binds embed versioning (#256) * fix: openclaw binds embed versioning * fix: openclaw binds embed versioning --- .../docs/sdks/integrations/openclaw.md | 26 +++++++++---------- hindsight-docs/static/get-cli | 16 +++++++++--- .../version-0.4/sdks/integrations/openclaw.md | 24 ++++++++--------- hindsight-embed/hindsight_embed/cli.py | 3 +++ .../hindsight_embed/daemon_client.py | 18 ++++++++++--- hindsight-integrations/openclaw/README.md | 6 ++--- ...wdbot.plugin.json => openclaw.plugin.json} | 0 hindsight-integrations/openclaw/package.json | 4 +-- .../openclaw/src/embed-manager.ts | 2 +- hindsight-integrations/openclaw/src/index.ts | 11 +++++--- uv.lock | 10 +++---- 11 files changed, 74 insertions(+), 46 deletions(-) rename hindsight-integrations/openclaw/{clawdbot.plugin.json => openclaw.plugin.json} (100%) diff --git a/hindsight-docs/docs/sdks/integrations/openclaw.md b/hindsight-docs/docs/sdks/integrations/openclaw.md index 093de8b8..4dbeb97c 100644 --- a/hindsight-docs/docs/sdks/integrations/openclaw.md +++ b/hindsight-docs/docs/sdks/integrations/openclaw.md @@ -13,13 +13,13 @@ This plugin integrates [hindsight-embed](https://vectorize.io/hindsight/cli), a ```bash # 1. Configure your LLM provider 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 -clawdbot plugins install @vectorize-io/hindsight-openclaw +openclaw plugins install @vectorize-io/hindsight-openclaw # 3. Start OpenClaw -clawdbot gateway +openclaw gateway ``` 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 - **Node.js** 22+ -- **OpenClaw** (Clawdbot) with plugin support +- **OpenClaw** with plugin support - **uv/uvx** for running `hindsight-embed` - **LLM API key** (OpenAI, Anthropic, etc.) @@ -127,13 +127,13 @@ Think of hooks as "forced automation" - they always run. ```bash # 1. Configure your LLM provider 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 -clawdbot plugins install @vectorize-io/hindsight-openclaw +openclaw plugins install @vectorize-io/hindsight-openclaw # 3. Start OpenClaw -clawdbot gateway +openclaw gateway ``` 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 -Optional settings in `~/.clawdbot/clawdbot.json`: +Optional settings in `~/.openclaw/openclaw.json`: ```json { @@ -178,14 +178,14 @@ The plugin auto-detects your configured provider and API key: Configure with: ```bash 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 **Check if plugin is loaded:** ```bash -clawdbot plugins list | grep hindsight +openclaw plugins list | grep hindsight # Should show: ✓ enabled │ Hindsight Memory │ ... ``` @@ -262,10 +262,10 @@ uvx hindsight-embed@latest entity graph openclaw **Plugin not loading?** ```bash # Check plugin installation -clawdbot plugins list | grep -i hindsight +openclaw plugins list | grep -i hindsight # Reinstall if needed -clawdbot plugins install @vectorize-io/hindsight-openclaw +openclaw plugins install @vectorize-io/hindsight-openclaw ``` **Daemon not starting?** @@ -293,7 +293,7 @@ echo $OPENAI_API_KEY **Memories not being stored?** ```bash # Check gateway logs for auto-capture -tail -f /tmp/clawdbot/clawdbot-*.log | grep Hindsight +tail -f /tmp/openclaw/openclaw-*.log | grep Hindsight # Should see: # [Hindsight Hook] agent_end triggered diff --git a/hindsight-docs/static/get-cli b/hindsight-docs/static/get-cli index 477564ad..de7bdd8b 100755 --- a/hindsight-docs/static/get-cli +++ b/hindsight-docs/static/get-cli @@ -3,6 +3,7 @@ set -e # Hindsight CLI installer # 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" INSTALL_DIR="${HINDSIGHT_INSTALL_DIR:-$HOME/.local/bin}" @@ -169,9 +170,18 @@ main() { platform=$(detect_platform) print_info "Detected platform: $platform" - # Get latest version - version=$(get_latest_version) - print_info "Latest version: $version" + # Get version (from env var or latest) + if [[ -n "$HINDSIGHT_CLI_VERSION" ]]; then + 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 tmp_file=$(download_binary "$platform" "$version") diff --git a/hindsight-docs/versioned_docs/version-0.4/sdks/integrations/openclaw.md b/hindsight-docs/versioned_docs/version-0.4/sdks/integrations/openclaw.md index 093de8b8..6f619dfe 100644 --- a/hindsight-docs/versioned_docs/version-0.4/sdks/integrations/openclaw.md +++ b/hindsight-docs/versioned_docs/version-0.4/sdks/integrations/openclaw.md @@ -13,13 +13,13 @@ This plugin integrates [hindsight-embed](https://vectorize.io/hindsight/cli), a ```bash # 1. Configure your LLM provider 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 -clawdbot plugins install @vectorize-io/hindsight-openclaw +openclaw plugins install @vectorize-io/hindsight-openclaw # 3. Start OpenClaw -clawdbot gateway +openclaw gateway ``` 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 # 1. Configure your LLM provider 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 -clawdbot plugins install @vectorize-io/hindsight-openclaw +openclaw plugins install @vectorize-io/hindsight-openclaw # 3. Start OpenClaw -clawdbot gateway +openclaw gateway ``` 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 -Optional settings in `~/.clawdbot/clawdbot.json`: +Optional settings in `~/.openclaw/openclaw.json`: ```json { @@ -178,14 +178,14 @@ The plugin auto-detects your configured provider and API key: Configure with: ```bash 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 **Check if plugin is loaded:** ```bash -clawdbot plugins list | grep hindsight +openclaw plugins list | grep hindsight # Should show: ✓ enabled │ Hindsight Memory │ ... ``` @@ -262,10 +262,10 @@ uvx hindsight-embed@latest entity graph openclaw **Plugin not loading?** ```bash # Check plugin installation -clawdbot plugins list | grep -i hindsight +openclaw plugins list | grep -i hindsight # Reinstall if needed -clawdbot plugins install @vectorize-io/hindsight-openclaw +openclaw plugins install @vectorize-io/hindsight-openclaw ``` **Daemon not starting?** @@ -293,7 +293,7 @@ echo $OPENAI_API_KEY **Memories not being stored?** ```bash # Check gateway logs for auto-capture -tail -f /tmp/clawdbot/clawdbot-*.log | grep Hindsight +tail -f /tmp/openclaw/openclaw-*.log | grep Hindsight # Should see: # [Hindsight Hook] agent_end triggered diff --git a/hindsight-embed/hindsight_embed/cli.py b/hindsight-embed/hindsight_embed/cli.py index 2ebfa628..3325b4a1 100644 --- a/hindsight-embed/hindsight_embed/cli.py +++ b/hindsight-embed/hindsight_embed/cli.py @@ -16,6 +16,9 @@ Environment variables: HINDSIGHT_EMBED_LLM_MODEL: Optional. LLM model (default: "gpt-4o-mini"). 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_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 diff --git a/hindsight-embed/hindsight_embed/daemon_client.py b/hindsight-embed/hindsight_embed/daemon_client.py index 96b06a6e..a12fe8ba 100644 --- a/hindsight-embed/hindsight_embed/daemon_client.py +++ b/hindsight-embed/hindsight_embed/daemon_client.py @@ -39,7 +39,10 @@ def _find_hindsight_api_command() -> list[str]: return ["uv", "run", "--project", str(dev_api_path), "hindsight-api"] # 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: @@ -220,15 +223,24 @@ def install_cli() -> bool: import subprocess 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}") 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( ["bash", "-c", f"curl -fsSL {CLI_INSTALLER_URL} | bash"], capture_output=True, text=True, + env=env, ) if result.returncode != 0: diff --git a/hindsight-integrations/openclaw/README.md b/hindsight-integrations/openclaw/README.md index f038e5fa..581b2f24 100644 --- a/hindsight-integrations/openclaw/README.md +++ b/hindsight-integrations/openclaw/README.md @@ -7,13 +7,13 @@ Biomimetic long-term memory for [OpenClaw](https://openclaw.ai) using [Hindsight ```bash # 1. Configure your LLM provider 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 -clawdbot plugins install @vectorize-io/hindsight-openclaw +openclaw plugins install @vectorize-io/hindsight-openclaw # 3. Start OpenClaw -clawdbot gateway +openclaw gateway ``` That's it! The plugin will automatically start capturing and recalling memories. diff --git a/hindsight-integrations/openclaw/clawdbot.plugin.json b/hindsight-integrations/openclaw/openclaw.plugin.json similarity index 100% rename from hindsight-integrations/openclaw/clawdbot.plugin.json rename to hindsight-integrations/openclaw/openclaw.plugin.json diff --git a/hindsight-integrations/openclaw/package.json b/hindsight-integrations/openclaw/package.json index 67bea2f3..4afdf151 100644 --- a/hindsight-integrations/openclaw/package.json +++ b/hindsight-integrations/openclaw/package.json @@ -5,7 +5,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "type": "module", - "clawdbot": { + "openclaw": { "extensions": [ "./dist/index.js" ] @@ -27,7 +27,7 @@ }, "files": [ "dist", - "clawdbot.plugin.json", + "openclaw.plugin.json", "README.md" ], "scripts": { diff --git a/hindsight-integrations/openclaw/src/embed-manager.ts b/hindsight-integrations/openclaw/src/embed-manager.ts index a49a4a26..4f43b7e6 100644 --- a/hindsight-integrations/openclaw/src/embed-manager.ts +++ b/hindsight-integrations/openclaw/src/embed-manager.ts @@ -25,7 +25,7 @@ export class HindsightEmbedManager { ) { this.port = 8889; // hindsight-embed uses fixed port 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.llmApiKey = llmApiKey; this.llmModel = llmModel; diff --git a/hindsight-integrations/openclaw/src/index.ts b/hindsight-integrations/openclaw/src/index.ts index 9cfa3169..6b344e65 100644 --- a/hindsight-integrations/openclaw/src/index.ts +++ b/hindsight-integrations/openclaw/src/index.ts @@ -107,8 +107,8 @@ function detectLLMConfig(api: MoltbotPluginAPI): { `Please set one of these environment variables:\n${keyInstructions}\n\n` + `You can set them in your shell profile (~/.zshrc or ~/.bashrc):\n` + ` export ANTHROPIC_API_KEY="your-key-here"\n\n` + - `Or run Moltbot with the environment variable:\n` + - ` ANTHROPIC_API_KEY="your-key" clawdbot start\n\n` + + `Or run OpenClaw with the environment variable:\n` + + ` ANTHROPIC_API_KEY="your-key" openclaw gateway\n\n` + `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)); - // Recall relevant memories (up to 1024 tokens) + // Recall relevant memories (up to 512 tokens) const response = await client.recall({ query: prompt, - max_tokens: 1024, + max_tokens: 512, }); 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 contextMessage = ` +Relevant memories from past conversations (score 1=highest, prioritize recent when conflicting): ${memoriesJson} + +User message: ${prompt} `; console.log(`[Hindsight] Auto-recall: Injecting ${response.results.length} memories`); diff --git a/uv.lock b/uv.lock index dac1cdf0..ad677fad 100644 --- a/uv.lock +++ b/uv.lock @@ -1295,7 +1295,7 @@ wheels = [ [[package]] name = "hindsight-all" -version = "0.4.4" +version = "0.4.5" source = { editable = "hindsight" } dependencies = [ { name = "hindsight-api" }, @@ -1319,7 +1319,7 @@ provides-extras = ["test"] [[package]] name = "hindsight-api" -version = "0.4.4" +version = "0.4.5" source = { editable = "hindsight-api" } dependencies = [ { name = "aiohttp" }, @@ -1449,7 +1449,7 @@ dev = [ [[package]] name = "hindsight-client" -version = "0.4.4" +version = "0.4.5" source = { editable = "hindsight-clients/python" } dependencies = [ { name = "aiohttp" }, @@ -1483,7 +1483,7 @@ provides-extras = ["test"] [[package]] name = "hindsight-dev" -version = "0.4.4" +version = "0.4.5" source = { editable = "hindsight-dev" } dependencies = [ { name = "hindsight-api" }, @@ -1529,7 +1529,7 @@ dev = [ [[package]] name = "hindsight-embed" -version = "0.4.4" +version = "0.4.5" source = { editable = "hindsight-embed" } dependencies = [ { name = "httpx" },