1  #!/usr/bin/env python3
   2  import sys
   3  import subprocess
   4  import os
   5  
   6  if len(sys.argv) < 2:
   7      print("Usage:")
   8      print("  remember.py fact <category> <subject> <content>")
   9      print("  remember.py episode <title> <context> <actions> <outcome>")
  10      print("  remember.py skill <name> <trigger> <command> <description>")
  11      sys.exit(1)
  12  
  13  project_dir = os.path.dirname(os.path.abspath(__file__))
  14  conf_file = os.path.join(project_dir, "neuralos.conf")
  15  
  16  dell_ip = "192.168.31.65"
  17  dell_user = "agent"
  18  
  19  if os.path.exists(conf_file):
  20      with open(conf_file) as f:
  21          for line in f:
  22              if line.startswith("DELL_IP="):
  23                  dell_ip = line.split("=")[1].strip().strip('"')
  24              elif line.startswith("DELL_USER="):
  25                  dell_user = line.split("=")[1].strip().strip('"')
  26  
  27  # If running on Dell directly
  28  if os.path.exists("/var/neural_memory/bin/remember.py"):
  29      cmd = ["/var/neural_memory/bin/remember.py"] + sys.argv[1:]
  30      res = subprocess.run(cmd)
  31      sys.exit(res.returncode)
  32  
  33  # If running on Mac, execute on Dell anchor via SSH
  34  args_quoted = " ".join([f"'{a}'" for a in sys.argv[1:]])
  35  ssh_cmd = f"ssh -o BatchMode=yes -o ConnectTimeout=5 {dell_user}@{dell_ip} \"remember {args_quoted}\""
  36  
  37  print(f"[*] Committing memory to Dell anchor ({dell_user}@{dell_ip})...")
  38  res = subprocess.run(ssh_cmd, shell=True)
  39  
  40  if res.returncode == 0:
  41      # Auto sync snapshot back
  42      sync_script = os.path.join(project_dir, "sync_memory.sh")
  43      if os.path.exists(sync_script):
  44          subprocess.run([sync_script], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  45          print("[*] Local memory cache updated.")
  46  else:
  47      print("[!] Failed to commit to Dell anchor. Verify network connection.")
  48  
  49  sys.exit(res.returncode)
  50