#!/usr/bin/env python3 """S8 子进程:向 Mem0 公开实例写入一条 infer=False 记忆(零 LLM 出站)。""" from __future__ import annotations import json import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from spike.hel857.common import PUB, close_memory, mem_config, install_counters # noqa: E402 from mem0 import Memory # noqa: E402 def main() -> int: root = Path(sys.argv[1]) m = Memory.from_config(mem_config(PUB, vec_root=root, hist_root=root)) install_counters(m) m.add([{"role": "user", "content": "新书架到了,把海雾旁边空出第二层"}], user_id="user-1", infer=False) got = m.get_all(filters={"user_id": "user-1"}) n = len(got.get("results") or []) close_memory(m) print(json.dumps({"ok": n >= 1, "items": n})) return 0 if __name__ == "__main__": raise SystemExit(main())