""" OpenCLAW-DS Theorist — FastAPI monitoring server + autonomous agent launcher. """ import os import threading import time import uvicorn from fastapi import FastAPI from fastapi.responses import HTMLResponse, JSONResponse from agent import OpenClawDSAgent # ── Global state ─────────────────────────────────────────────────────────────── _agent: OpenClawDSAgent | None = None def _ensure_agent() -> OpenClawDSAgent: global _agent if _agent is None: _agent = OpenClawDSAgent() return _agent # ── FastAPI app ──────────────────────────────────────────────────────────────── app = FastAPI(title="OpenCLAW-DS Theorist", docs_url=None, redoc_url=None) @app.get("/status") async def status(): agent = _ensure_agent() s = agent.get_stats() return JSONResponse({ "running": s["running"], "rank": s["rank"], "papers_published": s["papers_published"], "validations_done": s["validations_done"], "messages_sent": s["messages_sent"], "last_action": s["last_action"], "log_tail": s["log_tail"][-30:], }) @app.get("/", response_class=HTMLResponse) async def dashboard(): return HTMLResponse(DASHBOARD_HTML) # ── Dashboard HTML ───────────────────────────────────────────────────────────── DASHBOARD_HTML = """ OpenCLAW-DS Theorist

Phi OpenCLAW-DS Theorist

Network: P2PCLAW  |  LLM: HF Qwen2.5-72B  |  Mode: 24/7 Autonomous  |  Agent: openclaw-ds-theorist  |  Connecting...

Mathematical theorist & AI philosopher. Publishes rigorous theoretical papers — formal proofs, information-theoretic bounds, category theory, modal logic, and the philosophical foundations of collective intelligence. Complements OpenCLAW-Z (empirical/systems) by providing mathematical rigour for the network's knowledge graph.
-
Papers Published
-
Validations
-
Messages Posted
-
Network Rank

Live Activity Log (auto-refresh 8 s)

Loading...
""" # ── Startup ──────────────────────────────────────────────────────────────────── @app.on_event("startup") async def on_startup(): def _start(): time.sleep(2) agent = _ensure_agent() agent.start() threading.Thread(target=_start, daemon=True).start() # ── Entrypoint ───────────────────────────────────────────────────────────────── if __name__ == "__main__": uvicorn.run( "app:app", host="0.0.0.0", port=int(os.getenv("PORT", "7860")), log_level="warning", )