Dmitry Beresnev commited on
Commit Β·
bbb7286
1
Parent(s): 15c8440
add nemoclaw from nvidia
Browse files29 unmodified lines30313233343556 unmodified lines92939495969721 unmodified lines11912012112212312482 unmodified lines207208209210211212231 unmodified lines444445446447448449360 unmodified lines81081181281381481581681781881982082116 unmodified lines8388398408418428437 unmodified lines851852853854855856157 unmodified lines101410151016101710181019126 unmodified lines11461147114811491150115136 unmodified lines11881189119011911192119329 unmodified linesPICOCLAW_CONFIG_PATH = Path(os.getenv("PICOCLAW_CONFIG_PATH", "picoclaw.json"))ZEROCLAW_CONFIG_PATH = Path(os.getenv("ZEROCLAW_CONFIG_PATH", "zeroclaw.json"))NULLCLAW_CONFIG_PATH = Path(os.getenv("NULLCLAW_CONFIG_PATH", "nullclaw.json"))ENV_EXAMPLE_PATH = Path("config/openclaw.env.example")LOG_MAX_LINES = 300OPENCLAW_STANDARD_UI_URL = os.getenv(56 unmodified linesNULLCLAW_PROXY_LOCAL_URL = os.getenv("NULLCLAW_PROXY_LOCAL_URL", f"http://127.0.0.1:7860{NULLCLAW_BASE_PATH}/")IRONCLAW_LOG_PATH = Path(os.getenv("IRONCLAW_LOG_PATH", "/tmp/ironclaw.log"))IRONCLAW_ERR_LOG_PATH = Path(os.getenv("IRONCLAW_ERR_LOG_PATH", "/tmp/ironclaw.err.log"))IRONCLAW_ENABLED = os.getenv("IRONCLAW_ENABLED", "1") == "1"21 unmodified linesst.session_state.setdefault("picoclaw_config_text", load_picoclaw_config_text())st.session_state.setdefault("zeroclaw_config_text", load_zeroclaw_config_text())st.session_state.setdefault("nullclaw_config_text", load_nullclaw_config_text())st.session_state.setdefault("auto_started", False)st.session_state.setdefault("auto_start_attempted", False)st.session_state.setdefault("backtest_result", None)82 unmodified linesreturn {}def gateway_process() -> subprocess.Popen | None:proc = st.session_state.get("gateway_process")if proc is None:231 unmodified linesreturn sock.connect_ex(("127.0.0.1", NULLCLAW_PORT)) == 0def supervisorctl(action: str, program: str) -> tuple[bool, str]:cmd = shutil.which("supervisorctl")if not cmd:360 unmodified linespicoclaw_up = is_picoclaw_port_open() if PICOCLAW_ENABLED else Falsezeroclaw_up = is_zeroclaw_port_open() if ZEROCLAW_ENABLED else Falsenullclaw_up = is_nullclaw_port_open() if NULLCLAW_ENABLED else Falsest.write(f"OpenClaw: {'π’ Running' if openclaw_up else 'π΄ Down'} (port {OPENCLAW_PORT})")st.write(f"NanoClaw: {'π’ Running' if nanoclaw_up else 'π΄ Down'} (port {NANOCLAW_PORT})")st.write(f"NanoBot: {'π’ Running' if nanobot_up else 'π΄ Down'} (port {NANOBOT_PORT})")st.write(f"PicoClaw: {'π’ Running' if picoclaw_up else 'π΄ Down'} (port {PICOCLAW_PORT})")st.write(f"ZeroClaw: {'π’ Running' if zeroclaw_up else 'π΄ Down'} (port {ZEROCLAW_PORT})")st.write(f"NullClaw: {'π’ Running' if nullclaw_up else 'π΄ Down'} (port {NULLCLAW_PORT})")st.write(f"IronClaw: {'π’ Enabled' if IRONCLAW_ENABLED else 'π΄ Disabled'} (no gateway port)")with svc_col_2:16 unmodified linesif st.button("Restart NullClaw", use_container_width=True):ok, msg = supervisorctl("restart", "nullclaw")(st.success if ok else st.error)(msg)if st.button("Restart IronClaw", use_container_width=True):ok, msg = supervisorctl("restart", "ironclaw")(st.success if ok else st.error)(msg)7 unmodified linesst.info("ZeroClaw is disabled. Set `ZEROCLAW_ENABLED=1` to start it.")if not NULLCLAW_ENABLED:st.info("NullClaw is disabled. Set `NULLCLAW_ENABLED=1` to start it.")if not IRONCLAW_ENABLED:st.info("IronClaw is disabled. Set `IRONCLAW_ENABLED=1` to start it.")157 unmodified lineselse:st.caption("Disabled")st.markdown("**IronClaw**")st.caption("No gateway port detected. Run `ironclaw` CLI after onboarding.")126 unmodified linesexcept json.JSONDecodeError as exc:st.error(f"Invalid JSON: {exc}")st.divider()test_col, logs_col = st.columns([2, 3])36 unmodified linestail_text_file(NULLCLAW_ERR_LOG_PATH),"=== nullclaw.log ===",tail_text_file(NULLCLAW_LOG_PATH),"=== ironclaw.err.log ===",tail_text_file(IRONCLAW_ERR_LOG_PATH),"=== ironclaw.log ===",29 unmodified lines3031323334353656 unmodified lines9394959697989910010110210310410510621 unmodified lines12812913013113213313482 unmodified lines217218219220221222223224225226227228229230231232233234235231 unmodified lines467468469470471472473474475476477478360 unmodified lines83984084184284384484584684784884985085185216 unmodified lines8698708718728738748758768777 unmodified lines885886887888889890891892157 unmodified lines10501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072126 unmodified lines119912001201120212031204120512061207120812091210121112121213121412151216121712181219122036 unmodified lines125712581259126012611262126312641265126629 unmodified linesPICOCLAW_CONFIG_PATH = Path(os.getenv("PICOCLAW_CONFIG_PATH", "picoclaw.json"))ZEROCLAW_CONFIG_PATH = Path(os.getenv("ZEROCLAW_CONFIG_PATH", "zeroclaw.json"))NULLCLAW_CONFIG_PATH = Path(os.getenv("NULLCLAW_CONFIG_PATH", "nullclaw.json"))NEMOCLAW_CONFIG_PATH = Path(os.getenv("NEMOCLAW_CONFIG_PATH", "nemoclaw.json"))ENV_EXAMPLE_PATH = Path("config/openclaw.env.example")LOG_MAX_LINES = 300OPENCLAW_STANDARD_UI_URL = os.getenv(56 unmodified linesNULLCLAW_PROXY_LOCAL_URL = os.getenv("NULLCLAW_PROXY_LOCAL_URL", f"http://127.0.0.1:7860{NULLCLAW_BASE_PATH}/")NEMOCLAW_LOG_PATH = Path(os.getenv("NEMOCLAW_LOG_PATH", "/tmp/nemoclaw.log"))NEMOCLAW_ERR_LOG_PATH = Path(os.getenv("NEMOCLAW_ERR_LOG_PATH", "/tmp/nemoclaw.err.log"))NEMOCLAW_PORT = int(os.getenv("NEMOCLAW_PORT", "18793"))NEMOCLAW_BASE_PATH = os.getenv("NEMOCLAW_BASE_PATH", "/nemoclaw")NEMOCLAW_ENABLED = os.getenv("NEMOCLAW_ENABLED", "1") == "1"NEMOCLAW_PROXY_LOCAL_URL = os.getenv("NEMOCLAW_PROXY_LOCAL_URL", f"http://127.0.0.1:7860{NEMOCLAW_BASE_PATH}/")IRONCLAW_LOG_PATH = Path(os.getenv("IRONCLAW_LOG_PATH", "/tmp/ironclaw.log"))IRONCLAW_ERR_LOG_PATH = Path(os.getenv("IRONCLAW_ERR_LOG_PATH", "/tmp/ironclaw.err.log"))IRONCLAW_ENABLED = os.getenv("IRONCLAW_ENABLED", "1") == "1"21 unmodified linesst.session_state.setdefault("picoclaw_config_text", load_picoclaw_config_text())st.session_state.setdefault("zeroclaw_config_text", load_zeroclaw_config_text())st.session_state.setdefault("nullclaw_config_text", load_nullclaw_config_text())st.session_state.setdefault("nemoclaw_config_text", load_nemoclaw_config_text())st.session_state.setdefault("auto_started", False)st.session_state.setdefault("auto_start_attempted", False)st.session_state.setdefault("backtest_result", None)82 unmodified linesreturn {}def load_nemoclaw_config_text() -> str:if NEMOCLAW_CONFIG_PATH.exists():return NEMOCLAW_CONFIG_PATH.read_text(encoding="utf-8")return "{}"def load_nemoclaw_config_json() -> dict:try:return json.loads(load_nemoclaw_config_text())except json.JSONDecodeError:return {}def gateway_process() -> subprocess.Popen | None:proc = st.session_state.get("gateway_process")if proc is None:231 unmodified linesreturn sock.connect_ex(("127.0.0.1", NULLCLAW_PORT)) == 0def is_nemoclaw_port_open(timeout: float = 0.5) -> bool:with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:sock.settimeout(timeout)return sock.connect_ex(("127.0.0.1", NEMOCLAW_PORT)) == 0def supervisorctl(action: str, program: str) -> tuple[bool, str]:cmd = shutil.which("supervisorctl")if not cmd:360 unmodified linespicoclaw_up = is_picoclaw_port_open() if PICOCLAW_ENABLED else Falsezeroclaw_up = is_zeroclaw_port_open() if ZEROCLAW_ENABLED else Falsenullclaw_up = is_nullclaw_port_open() if NULLCLAW_ENABLED else Falsenemoclaw_up = is_nemoclaw_port_open() if NEMOCLAW_ENABLED else Falsest.write(f"OpenClaw: {'π’ Running' if openclaw_up else 'π΄ Down'} (port {OPENCLAW_PORT})")st.write(f"NanoClaw: {'π’ Running' if nanoclaw_up else 'π΄ Down'} (port {NANOCLAW_PORT})")st.write(f"NanoBot: {'π’ Running' if nanobot_up else 'π΄ Down'} (port {NANOBOT_PORT})")st.write(f"PicoClaw: {'π’ Running' if picoclaw_up else 'π΄ Down'} (port {PICOCLAW_PORT})")st.write(f"ZeroClaw: {'π’ Running' if zeroclaw_up else 'π΄ Down'} (port {ZEROCLAW_PORT})")st.write(f"NullClaw: {'π’ Running' if nullclaw_up else 'π΄ Down'} (port {NULLCLAW_PORT})")st.write(f"NemoClaw: {'π’ Running' if nemoclaw_up else 'π΄ Down'} (port {NEMOCLAW_PORT})")st.write(f"IronClaw: {'π’ Enabled' if IRONCLAW_ENABLED else 'π΄ Disabled'} (no gateway port)")with svc_col_2:16 unmodified linesif st.button("Restart NullClaw", use_container_width=True):ok, msg = supervisorctl("restart", "nullclaw")(st.success if ok else st.error)(msg)if st.button("Restart NemoClaw", use_container_width=True):ok, msg = supervisorctl("restart", "nemoclaw")(st.success if ok else st.error)(msg)if st.button("Restart IronClaw", use_container_width=True):ok, msg = supervisorctl("restart", "ironclaw")(st.success if ok else st.error)(msg)7 unmodified linesst.info("ZeroClaw is disabled. Set `ZEROCLAW_ENABLED=1` to start it.")if not NULLCLAW_ENABLED:st.info("NullClaw is disabled. Set `NULLCLAW_ENABLED=1` to start it.")if not NEMOCLAW_ENABLED:st.info("NemoClaw is disabled. Set `NEMOCLAW_ENABLED=1` to start it.")if not IRONCLAW_ENABLED:st.info("IronClaw is disabled. Set `IRONCLAW_ENABLED=1` to start it.")157 unmodified lineselse:st.caption("Disabled")st.markdown("**NemoClaw**")nemoclaw_ok = Falseif NEMOCLAW_ENABLED:try:nemoclaw_resp = requests.get(NEMOCLAW_PROXY_LOCAL_URL, timeout=2, allow_redirects=True)nemoclaw_ok = nemoclaw_resp.status_code < 500except Exception:nemoclaw_ok = Falseif NEMOCLAW_ENABLED:st.markdown(f'<a href="{NEMOCLAW_PROXY_LOCAL_URL}" target="_blank" rel="noopener noreferrer">Open NemoClaw</a>',unsafe_allow_html=True,)st.caption(f"Proxy: {NEMOCLAW_PROXY_LOCAL_URL} ({'ok' if nemoclaw_ok else 'down'})")else:st.caption("Disabled")st.markdown("**IronClaw**")st.caption("No gateway port detected. Run `ironclaw` CLI after onboarding.")126 unmodified linesexcept json.JSONDecodeError as exc:st.error(f"Invalid JSON: {exc}")nemoclaw_text = st.text_area("nemoclaw.json",value=st.session_state.get("nemoclaw_config_text", load_nemoclaw_config_text()),height=220,)st.session_state["nemoclaw_config_text"] = nemoclaw_textif st.button("Save NemoClaw Config", use_container_width=True):try:parsed = json.loads(nemoclaw_text)NEMOCLAW_CONFIG_PATH.write_text(json.dumps(parsed, indent=2) + "\n", encoding="utf-8")st.success(f"Saved {NEMOCLAW_CONFIG_PATH}.")except json.JSONDecodeError as exc:st.error(f"Invalid JSON: {exc}")st.divider()test_col, logs_col = st.columns([2, 3])36 unmodified linestail_text_file(NULLCLAW_ERR_LOG_PATH),"=== nullclaw.log ===",tail_text_file(NULLCLAW_LOG_PATH),"=== nemoclaw.err.log ===",tail_text_file(NEMOCLAW_ERR_LOG_PATH),"=== nemoclaw.log ===",tail_text_file(NEMOCLAW_LOG_PATH),"=== ironclaw.err.log ===",tail_text_file(IRONCLAW_ERR_LOG_PATH),"=== ironclaw.log ===",
app.py+73