Add automatic dialog sync to memory files

This commit is contained in:
OpenClaw Assistant
2026-02-21 14:21:43 +00:00
parent b55cfb7b45
commit dc61a0bd84
3 changed files with 4452 additions and 0 deletions

4
MEMORY.md Normal file
View File

@@ -0,0 +1,4 @@
# MEMORY.md
Долгосрочная память ЕВА.

4414
memory/dialogs/2026-02-21.md Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail
SESS_DIR="$HOME/.openclaw/agents/main/sessions"
OUT_DIR="/home/openclaw/.openclaw/workspace/memory/dialogs"
OUT_FILE="$OUT_DIR/$(date +%F).md"
mkdir -p "$OUT_DIR"
LATEST_JSONL=$(ls -1t "$SESS_DIR"/*.jsonl 2>/dev/null | head -n1 || true)
if [[ -z "${LATEST_JSONL:-}" ]]; then
exit 0
fi
TMP=$(mktemp)
{
echo "# Диалоги за $(date +%F)"
echo
echo "Источник: $LATEST_JSONL"
echo
jq -r '
select(.type=="message")
| .timestamp as $ts
| .message.role as $role
| (.message.content // [])[]?
| select(.type=="text")
| "## [\($ts)] \($role)\n\(.text)\n"
' "$LATEST_JSONL"
} > "$TMP"
if [[ ! -f "$OUT_FILE" ]] || ! cmp -s "$TMP" "$OUT_FILE"; then
mv "$TMP" "$OUT_FILE"
else
rm -f "$TMP"
fi