diff --git a/hindsight-embed/hindsight_embed/daemon_client.py b/hindsight-embed/hindsight_embed/daemon_client.py index a12fe8ba..85e16a5d 100644 --- a/hindsight-embed/hindsight_embed/daemon_client.py +++ b/hindsight-embed/hindsight_embed/daemon_client.py @@ -41,6 +41,7 @@ def _find_hindsight_api_command() -> list[str]: # Fall back to uvx for installed version # 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}"] diff --git a/hindsight-integrations/openclaw/install.sh b/hindsight-integrations/openclaw/install.sh index 6ec9143c..baba2dbc 100755 --- a/hindsight-integrations/openclaw/install.sh +++ b/hindsight-integrations/openclaw/install.sh @@ -1,11 +1,11 @@ #!/bin/bash set -e -echo "🚀 Installing Hindsight Memory Plugin for Moltbot..." +echo "🚀 Installing Hindsight Memory Plugin for OpenClaw..." # Get the directory where this script is located SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -INSTALL_DIR="$HOME/.clawdbot/extensions/hindsight-openclaw" +INSTALL_DIR="$HOME/.openclaw/extensions/hindsight-openclaw" # Check Node version if ! command -v node &> /dev/null; then @@ -25,7 +25,7 @@ rm -rf "$INSTALL_DIR" mkdir -p "$INSTALL_DIR" # Copy files -cp -r dist package.json clawdbot.plugin.json README.md "$INSTALL_DIR/" +cp -r dist package.json openclaw.plugin.json README.md "$INSTALL_DIR/" # Install dependencies in deployed location echo "📥 Installing dependencies..." @@ -41,9 +41,9 @@ echo "1. Make sure you have an OpenAI API key set:" echo " export OPENAI_API_KEY=\"sk-your-key-here\"" echo "" echo "2. Enable the plugin:" -echo " clawdbot plugins enable hindsight-openclaw" +echo " openclaw plugins enable hindsight-openclaw" echo "" echo "3. Start OpenClaw:" -echo " clawdbot start" +echo " openclaw gateway" echo "" echo "On first start, uvx will automatically download hindsight-embed (no manual install needed)" diff --git a/hindsight-integrations/openclaw/package-lock.json b/hindsight-integrations/openclaw/package-lock.json index 1f66d3c7..a05d853d 100644 --- a/hindsight-integrations/openclaw/package-lock.json +++ b/hindsight-integrations/openclaw/package-lock.json @@ -1,12 +1,12 @@ { "name": "@vectorize-io/hindsight-openclaw", - "version": "0.4.3", + "version": "0.4.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@vectorize-io/hindsight-openclaw", - "version": "0.4.3", + "version": "0.4.5", "license": "MIT", "dependencies": { "node-fetch": "^3.3.2" diff --git a/hindsight-integrations/openclaw/src/embed-manager.ts b/hindsight-integrations/openclaw/src/embed-manager.ts index 4f43b7e6..31fc7c47 100644 --- a/hindsight-integrations/openclaw/src/embed-manager.ts +++ b/hindsight-integrations/openclaw/src/embed-manager.ts @@ -48,6 +48,9 @@ export class HindsightEmbedManager { env['HINDSIGHT_EMBED_LLM_MODEL'] = this.llmModel; } + // Write env vars to ~/.hindsight/config.env for daemon persistence + await this.writeConfigEnv(env); + // Start hindsight-embed daemon (it manages itself) const embedPackage = this.embedVersion ? `hindsight-embed@${this.embedVersion}` : 'hindsight-embed@latest'; const startDaemon = spawn( @@ -145,4 +148,64 @@ export class HindsightEmbedManager { isRunning(): boolean { return this.process !== null; } + + private async writeConfigEnv(env: NodeJS.ProcessEnv): Promise { + const hindsightDir = join(homedir(), '.hindsight'); + const embedConfigPath = join(hindsightDir, 'embed'); + + // Ensure directory exists + await fs.mkdir(hindsightDir, { recursive: true }); + + // Read existing config to preserve extra settings + let existingContent = ''; + let extraSettings: string[] = []; + try { + existingContent = await fs.readFile(embedConfigPath, 'utf-8'); + // Extract non-LLM settings (like FORCE_CPU flags) + const lines = existingContent.split('\n'); + for (const line of lines) { + const trimmed = line.trim(); + if (trimmed && !trimmed.startsWith('#') && + !trimmed.startsWith('HINDSIGHT_EMBED_LLM_') && + !trimmed.startsWith('HINDSIGHT_EMBED_BANK_ID') && + !trimmed.startsWith('HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT')) { + extraSettings.push(line); + } + } + } catch { + // File doesn't exist yet, that's fine + } + + // Build config file with header + const configLines: string[] = [ + '# Hindsight Embed Configuration', + '# Generated by OpenClaw Hindsight plugin', + '', + ]; + + // Add LLM config + if (env.HINDSIGHT_EMBED_LLM_PROVIDER) { + configLines.push(`HINDSIGHT_EMBED_LLM_PROVIDER=${env.HINDSIGHT_EMBED_LLM_PROVIDER}`); + } + if (env.HINDSIGHT_EMBED_LLM_MODEL) { + configLines.push(`HINDSIGHT_EMBED_LLM_MODEL=${env.HINDSIGHT_EMBED_LLM_MODEL}`); + } + if (env.HINDSIGHT_EMBED_LLM_API_KEY) { + configLines.push(`HINDSIGHT_EMBED_LLM_API_KEY=${env.HINDSIGHT_EMBED_LLM_API_KEY}`); + } + if (env.HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT) { + configLines.push(`HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT=${env.HINDSIGHT_EMBED_DAEMON_IDLE_TIMEOUT}`); + } + + // Add extra settings if they exist + if (extraSettings.length > 0) { + configLines.push(''); + configLines.push('# Additional settings'); + configLines.push(...extraSettings); + } + + // Write to file + await fs.writeFile(embedConfigPath, configLines.join('\n') + '\n', 'utf-8'); + console.log(`[Hindsight] Wrote config to ${embedConfigPath}`); + } }