@icex-labs/openclaw-memory-engine 3.5.2 → 3.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/setup.sh +70 -12
package/package.json
CHANGED
package/setup.sh
CHANGED
|
@@ -7,14 +7,20 @@
|
|
|
7
7
|
|
|
8
8
|
set -euo pipefail
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
NON_INTERACTIVE=false
|
|
11
|
+
WS_ARG=""
|
|
12
|
+
for arg in "$@"; do
|
|
13
|
+
case "$arg" in
|
|
14
|
+
--non-interactive) NON_INTERACTIVE=true ;;
|
|
15
|
+
*) [ -z "$WS_ARG" ] && WS_ARG="$arg" ;;
|
|
16
|
+
esac
|
|
17
|
+
done
|
|
18
|
+
WORKSPACE="${WS_ARG:-${OPENCLAW_WORKSPACE:-$HOME/.openclaw/workspace}}"
|
|
11
19
|
OPENCLAW_DIR="${OPENCLAW_DIR:-$HOME/.openclaw}"
|
|
12
20
|
CONFIG="$OPENCLAW_DIR/openclaw.json"
|
|
13
21
|
MEMORY_DIR="$WORKSPACE/memory"
|
|
14
22
|
AGENTS_MD="$WORKSPACE/AGENTS.md"
|
|
15
23
|
PLUGIN_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
16
|
-
NON_INTERACTIVE=false
|
|
17
|
-
[[ "${2:-}" == "--non-interactive" || "${1:-}" == "--non-interactive" ]] && NON_INTERACTIVE=true
|
|
18
24
|
OS="$(uname -s)"
|
|
19
25
|
|
|
20
26
|
echo "🧠 openclaw-memory-engine setup"
|
|
@@ -321,7 +327,7 @@ else
|
|
|
321
327
|
echo "⚠️ AGENTS.md not found — create it with memory instructions"
|
|
322
328
|
fi
|
|
323
329
|
|
|
324
|
-
# --- 8. Register cron jobs ---
|
|
330
|
+
# --- 8. Register cron jobs (for all agents with workspaces) ---
|
|
325
331
|
if command -v openclaw &>/dev/null; then
|
|
326
332
|
EXISTING_CRONS=$(openclaw cron list --json 2>/dev/null | python3 -c "import sys,json; data=json.load(sys.stdin); print(' '.join(j.get('name','') for j in (data if isinstance(data,list) else data.get('jobs',[]))))" 2>/dev/null || echo "")
|
|
327
333
|
|
|
@@ -339,7 +345,7 @@ except:
|
|
|
339
345
|
" 2>/dev/null || echo "UTC")
|
|
340
346
|
|
|
341
347
|
register_cron() {
|
|
342
|
-
local name="$1" cron="$2"
|
|
348
|
+
local name="$1" cron="$2" agent="$3" msg="$4" desc="$5" timeout="${6:-60000}"
|
|
343
349
|
if echo "$EXISTING_CRONS" | grep -q "$name"; then
|
|
344
350
|
echo "⏭️ Cron '$name' already exists"
|
|
345
351
|
return
|
|
@@ -348,30 +354,82 @@ except:
|
|
|
348
354
|
--name "$name" \
|
|
349
355
|
--cron "$cron" \
|
|
350
356
|
--tz "$TZ_IANA" \
|
|
351
|
-
--agent
|
|
357
|
+
--agent "$agent" \
|
|
352
358
|
--session isolated \
|
|
353
359
|
--model "anthropic/claude-sonnet-4-6" \
|
|
354
360
|
--message "$msg" \
|
|
355
361
|
--description "$desc" \
|
|
356
362
|
--timeout "$timeout" \
|
|
357
|
-
>/dev/null 2>&1 && echo "✅ Cron '$name' registered" || echo "⚠️ Cron '$name' failed (gateway not running?)"
|
|
363
|
+
>/dev/null 2>&1 && echo "✅ Cron '$name' ($agent) registered" || echo "⚠️ Cron '$name' failed (gateway not running?)"
|
|
358
364
|
}
|
|
359
365
|
|
|
360
|
-
|
|
366
|
+
# Discover all agents from openclaw.json
|
|
367
|
+
AGENTS=$(python3 -c "
|
|
368
|
+
import json, os
|
|
369
|
+
try:
|
|
370
|
+
with open(os.path.expanduser('$CONFIG')) as f:
|
|
371
|
+
cfg = json.load(f)
|
|
372
|
+
agents = [a['id'] for a in cfg.get('agents',{}).get('list',[])]
|
|
373
|
+
print(' '.join(agents) if agents else 'main')
|
|
374
|
+
except:
|
|
375
|
+
print('main')
|
|
376
|
+
" 2>/dev/null || echo "main")
|
|
377
|
+
|
|
378
|
+
echo " Agents found: $AGENTS"
|
|
379
|
+
|
|
380
|
+
# Register main agent crons (shared across all agents using default workspace)
|
|
381
|
+
register_cron "memory-reflect-daily" "0 9 * * *" "main" \
|
|
361
382
|
"Run memory_reflect with window_days=7. If you notice patterns, store via archival_insert with tags=['reflection']. Do NOT output to main chat." \
|
|
362
383
|
"Daily reflection: analyze memory patterns"
|
|
363
384
|
|
|
364
|
-
register_cron "memory-consolidate-6h" "0 */6 * * *" \
|
|
385
|
+
register_cron "memory-consolidate-6h" "0 */6 * * *" "main" \
|
|
365
386
|
"Read today's daily log. If it has content not in archival, run memory_consolidate. Then archival_stats. Do NOT output to main chat." \
|
|
366
387
|
"Auto-consolidate daily logs every 6 hours"
|
|
367
388
|
|
|
368
|
-
register_cron "memory-dedup-weekly" "0 4 * * 0" \
|
|
389
|
+
register_cron "memory-dedup-weekly" "0 4 * * 0" "main" \
|
|
369
390
|
"Run archival_deduplicate with apply=true. Then archival_stats. Do NOT output to main chat." \
|
|
370
391
|
"Weekly dedup: clean near-duplicate records"
|
|
371
392
|
|
|
372
|
-
register_cron "memory-dashboard-daily" "30 9 * * *" \
|
|
393
|
+
register_cron "memory-dashboard-daily" "30 9 * * *" "main" \
|
|
373
394
|
"Run memory_dashboard to regenerate the HTML dashboard. Do NOT output to main chat." \
|
|
374
|
-
"Daily dashboard refresh" 30000
|
|
395
|
+
"Daily dashboard refresh for main agent" 30000
|
|
396
|
+
|
|
397
|
+
# Register per-agent crons for agents with separate workspaces
|
|
398
|
+
STAGGER=0
|
|
399
|
+
for agent_id in $AGENTS; do
|
|
400
|
+
# Skip main (already registered above)
|
|
401
|
+
[ "$agent_id" = "main" ] && continue
|
|
402
|
+
|
|
403
|
+
# Check if this agent has its own workspace
|
|
404
|
+
HAS_OWN_WS=$(python3 -c "
|
|
405
|
+
import json, os
|
|
406
|
+
try:
|
|
407
|
+
with open(os.path.expanduser('$CONFIG')) as f:
|
|
408
|
+
cfg = json.load(f)
|
|
409
|
+
default_ws = cfg.get('agents',{}).get('defaults',{}).get('workspace','')
|
|
410
|
+
for a in cfg.get('agents',{}).get('list',[]):
|
|
411
|
+
if a['id'] == '$agent_id' and a.get('workspace','') and a.get('workspace','') != default_ws:
|
|
412
|
+
print('yes')
|
|
413
|
+
break
|
|
414
|
+
else:
|
|
415
|
+
print('no')
|
|
416
|
+
except:
|
|
417
|
+
print('no')
|
|
418
|
+
" 2>/dev/null || echo "no")
|
|
419
|
+
|
|
420
|
+
if [ "$HAS_OWN_WS" = "yes" ]; then
|
|
421
|
+
STAGGER=$((STAGGER + 5))
|
|
422
|
+
register_cron "${agent_id}-memory-dashboard" "$((30 + STAGGER)) 9 * * *" "$agent_id" \
|
|
423
|
+
"Run memory_dashboard to regenerate the HTML dashboard. Do NOT output to main chat." \
|
|
424
|
+
"Daily dashboard refresh for $agent_id agent" 30000
|
|
425
|
+
|
|
426
|
+
register_cron "${agent_id}-memory-consolidate" "30 */6 * * *" "$agent_id" \
|
|
427
|
+
"Read today's daily log. If it has content not in archival, run memory_consolidate. Then archival_stats. Do NOT output to main chat." \
|
|
428
|
+
"Auto-consolidate daily logs for $agent_id" 60000
|
|
429
|
+
|
|
430
|
+
echo " ✅ Per-agent crons registered for: $agent_id"
|
|
431
|
+
fi
|
|
432
|
+
done
|
|
375
433
|
else
|
|
376
434
|
echo "⚠️ openclaw CLI not found — skipping cron registration"
|
|
377
435
|
fi
|