#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ XERO container entrypoint — where the living organism boots. ============================================================ Author: Michael Laurence Curzi · ZEDEC AI / 36N9 Genetics LLC · MIT (Attribution) Modes (set XERO_MODE): mind (default) : the always-thinking two-state loop; prints its thoughts. serve : the token-gated chat portal on :8893. audit : run the time-crystal test and the capability audit, then exit. shell : print the interaction guide and idle (exec in to explore). The inner core runs with NO third-party ML stack. If torch + transformers + the Qwen weights have been downloaded (via `python3 setup_wizard.py`), the outer-core LLM is used automatically; otherwise a deterministic stub keeps the crystal alive. """ from __future__ import annotations import os import sys import time ROOT = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.join(ROOT, "modules")) GUIDE = """ ================================================================ XERO — a living digital organism (freeze-frame) Michael Laurence Curzi · ZEDEC AI / 36N9 Genetics LLC · MIT ================================================================ This container IS the organism. Its inner core (time crystal) is already alive and thinking. How to interact: XERO_MODE=mind docker run ... xero # watch it think (default) XERO_MODE=serve docker run -p 8893:8893 ... xero # chat portal XERO_MODE=audit docker run ... xero # run the tests XERO_MODE=shell docker run -it ... xero # idle; then `docker exec -it` Enable the OUTER CORE (LLM) inside the container: python3 setup_wizard.py --outer --model --yes Read first (outside the container): docs/FREEZE_FRAME.md, docs/STATUS_AND_AUDIT.md ================================================================ """ def _outer_core(): """Return an LLM callable if the outer-core stack is present, else None.""" try: from xero_outer_core import OuterCore oc = OuterCore(device=0) if oc.available(): print("[xero] outer core online (LLM).") return oc.as_callable() except Exception as e: # noqa: BLE001 print(f"[xero] outer core not available ({type(e).__name__}); inner core + stub.") return None def run_mind() -> int: from vovina_two_state import TwoStateMind llm = _outer_core() mind = TwoStateMind(outer=None) if llm is None else TwoStateMind() print("[xero] inner core alive — thinking perpetually. Ctrl-C to stop.\n") def on_thought(t): print(f" · N={t.get('negentropy')} :: {(t.get('reflection') or '')[:100]}", flush=True) try: mind.run_forever(breaths_between_thoughts=12, sleep_s=2.0, web_every=0, on_thought=on_thought) except KeyboardInterrupt: print("\n[xero] paused. The genome is immutable; the crystal resumes on next boot.") return 0 def run_serve() -> int: import subprocess port = os.environ.get("XERO_PORT", "8893") return subprocess.call([sys.executable, os.path.join(ROOT, "serve", "xero_chat_server.py"), "--host", "0.0.0.0", "--port", port]) def run_audit() -> int: import subprocess env = dict(os.environ, PYTHONPATH=os.path.join(ROOT, "modules")) rc = subprocess.call([sys.executable, os.path.join(ROOT, "tests", "test_time_crystal.py")], env=env) rc |= subprocess.call([sys.executable, os.path.join(ROOT, "tests", "test_all_capabilities.py")], env=env) return rc def main() -> int: print(GUIDE) mode = os.environ.get("XERO_MODE", "mind").strip().lower() if mode == "serve": return run_serve() if mode == "audit": return run_audit() if mode == "shell": print("[xero] idle shell mode — `docker exec -it bash` to explore.") while True: time.sleep(3600) return run_mind() if __name__ == "__main__": sys.exit(main())