Full sync - all projects, memory, configs

This commit is contained in:
2026-03-21 20:27:59 -05:00
parent 2447677d4a
commit b33de10902
395 changed files with 1635300 additions and 459211 deletions

76
run_memory_indexer.py Normal file
View File

@ -0,0 +1,76 @@
#!/usr/bin/env python3
import json
import subprocess
import sys
import os
def run_memory_hook(user_msg, assistant_msg, agent_id="case", session="main"):
"""Run the auto-memory-hook.py script with command-line arguments."""
cmd = [
"python3",
"/home/wdjones/.openclaw/workspace/tools/auto-memory-hook.py",
"--user", user_msg,
"--assistant", assistant_msg,
"--agent-id", agent_id,
"--session", session
]
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
if result.returncode != 0:
print(f"Error running auto-memory-hook: {result.stderr}", file=sys.stderr)
return result.returncode == 0
except subprocess.TimeoutExpired:
print("auto-memory-hook timed out", file=sys.stderr)
return False
except Exception as e:
print(f"Exception running auto-memory-hook: {e}", file=sys.stderr)
return False
def main():
# Get conversations from the extraction script
extract_script = "/home/wdjones/.openclaw/workspace/extract_assistant_turns.py"
try:
result = subprocess.run(["python3", extract_script], capture_output=True, text=True)
if result.returncode != 0:
print(f"Error running extraction script: {result.stderr}", file=sys.stderr)
return
# Parse each line as JSON
lines = result.stdout.strip().split('\n')
conversations = []
for line in lines:
if line.strip():
try:
conv = json.loads(line)
conversations.append(conv)
except json.JSONDecodeError as e:
print(f"Error parsing JSON: {e}", file=sys.stderr)
continue
print(f"Processing {len(conversations)} conversations...", file=sys.stderr)
# Process each conversation
success_count = 0
for i, conv in enumerate(conversations):
user_msg = conv.get('user', '')
assistant_msg = conv.get('assistant', '')
agent_id = conv.get('agent_id', 'case')
session = conv.get('session', 'main')
if user_msg and assistant_msg:
if run_memory_hook(user_msg, assistant_msg, agent_id, session):
success_count += 1
print(f"Processed conversation {i+1}/{len(conversations)}", file=sys.stderr)
else:
print(f"Failed to process conversation {i+1}/{len(conversations)}", file=sys.stderr)
print(f"Successfully processed {success_count}/{len(conversations)} conversations", file=sys.stderr)
except Exception as e:
print(f"Error in main: {e}", file=sys.stderr)
if __name__ == "__main__":
main()