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
extract_memory_turns.py Normal file
View File

@ -0,0 +1,76 @@
#!/usr/bin/env python3
import json
import subprocess
import sys
from pathlib import Path
def main():
session_file = "/home/wdjones/.openclaw/agents/main/sessions/2c022034-fccc-4c2c-b8f0-dce45ad22e68.jsonl"
# Read all messages from the session file
messages = []
with open(session_file, 'r') as f:
for line in f:
data = json.loads(line.strip())
if data.get('type') == 'message':
messages.append(data)
# Extract user-assistant pairs
pairs = []
current_user_msg = None
for msg in messages:
role = msg.get('message', {}).get('role')
content = msg.get('message', {}).get('content', [])
if role == 'user':
# Extract text content from user message
user_text = ""
for item in content:
if item.get('type') == 'text':
user_text += item.get('text', '') + "\n"
current_user_msg = user_text.strip()
elif role == 'assistant' and current_user_msg:
# Extract text content from assistant message (skip thinking blocks)
assistant_text = ""
for item in content:
if item.get('type') == 'text':
assistant_text += item.get('text', '') + "\n"
if assistant_text.strip():
pairs.append({
'user': current_user_msg,
'assistant': assistant_text.strip()
})
current_user_msg = None # Reset for next pair
# Take the last 10 pairs
recent_pairs = pairs[-10:]
print(f"Found {len(pairs)} total pairs, processing last {len(recent_pairs)}")
# Send each pair to the auto-memory hook
for pair in recent_pairs:
payload = {
"user": pair['user'],
"assistant": pair['assistant'],
"agent_id": "case",
"session": "main"
}
try:
result = subprocess.run([
'python3', '/home/wdjones/.openclaw/workspace/tools/auto-memory-hook.py'
], input=json.dumps(payload), text=True, capture_output=True, cwd="/home/wdjones/.openclaw/workspace")
if result.returncode != 0:
print(f"Error processing pair: {result.stderr}")
else:
print(f"Processed pair successfully")
except Exception as e:
print(f"Exception processing pair: {e}")
if __name__ == "__main__":
main()