Compare commits

...
1 Commits
Author SHA1 Message Date
Nicolò Boschi 7395d72822 fix: openclaw improve config setup 2026-01-30 17:34:18 +01:00
4 changed files with 71 additions and 7 deletions
@@ -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}"]
+5 -5
View File
@@ -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)"
+2 -2
View File
@@ -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"
@@ -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<void> {
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}`);
}
}