Full sync - all projects, memory, configs
This commit is contained in:
36
extract_assistant_turns_v2.sh
Executable file
36
extract_assistant_turns_v2.sh
Executable file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Extract assistant turns from session file
|
||||
session_file="$1"
|
||||
|
||||
# Create temporary files for user/assistant pairs
|
||||
temp_pairs=$(mktemp)
|
||||
|
||||
# Extract messages with user and assistant roles
|
||||
jq -r 'select(.type=="message") | select(.message.role=="user" or .message.role=="assistant") | [.message.role, (.message.content // [] | map(select(.type=="text") | .text) | join(" "))] | @tsv' "$session_file" > "$temp_pairs"
|
||||
|
||||
# Process pairs and send to auto-memory-hook
|
||||
user_msg=""
|
||||
count=0
|
||||
while IFS=$'\t' read -r role content; do
|
||||
if [ "$role" = "user" ]; then
|
||||
user_msg="$content"
|
||||
elif [ "$role" = "assistant" ] && [ -n "$user_msg" ]; then
|
||||
# Create JSON for auto-memory-hook and send it
|
||||
json_data=$(jq -n --arg user "$user_msg" --arg assistant "$content" \
|
||||
--arg agent_id "case" --arg session "main" \
|
||||
'{user: $user, assistant: $assistant, agent_id: $agent_id, session: $session}')
|
||||
|
||||
echo "$json_data" | python3 /home/wdjones/.openclaw/workspace/tools/auto-memory-hook.py
|
||||
|
||||
((count++))
|
||||
if [ $count -ge 10 ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
user_msg="" # Reset for next pair
|
||||
fi
|
||||
done < "$temp_pairs"
|
||||
|
||||
rm "$temp_pairs"
|
||||
echo "Auto-memory indexing completed - processed $count turns"
|
||||
Reference in New Issue
Block a user