Cai
2026-08-14 502d089fe7a6ca943d24110cb3d6252dd41feafe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@echo off
setlocal
chcp 65001 >nul
 
REM MB-X registry-aware Codex app-server start helper.
set "WORKSPACE_ROOT=E:\mb-ms-doc"
set "MBX_SRC=E:\mb-ms-doc\project-mbx-core\src"
set "APP_SERVER_URL=ws://127.0.0.1:4570"
set "PYTHONPATH=%MBX_SRC%;%PYTHONPATH%"
 
echo [MB-X] Preflight: checking python and Codex CLI in this cmd/BAT environment.
echo [MB-X] PATH=%PATH%
where python >nul 2>nul
if errorlevel 1 (
  echo [MB-X][ERROR] python not found in PATH.
  echo [MB-X][NEXT] Add Python to PATH or run this script from a Python-enabled shell.
  pause
  exit /b 1
)
for /f "delims=" %%I in ('where python 2^>nul') do if not defined MBX_PYTHON_EXE set "MBX_PYTHON_EXE=%%I"
echo [MB-X] python=%MBX_PYTHON_EXE%
set "MBX_CODEX_EXE="
for /f "delims=" %%I in ('where codex.cmd 2^>nul') do if not defined MBX_CODEX_EXE set "MBX_CODEX_EXE=%%I"
if not defined MBX_CODEX_EXE for /f "delims=" %%I in ('where codex.exe 2^>nul') do if not defined MBX_CODEX_EXE set "MBX_CODEX_EXE=%%I"
if not defined MBX_CODEX_EXE for /f "delims=" %%I in ('where codex 2^>nul') do if not defined MBX_CODEX_EXE set "MBX_CODEX_EXE=%%I"
if not defined MBX_CODEX_EXE (
  echo [MB-X][ERROR] Codex CLI not found in this cmd/BAT PATH. remote TUI cannot start.
  echo [MB-X][NEXT] Confirm `codex.cmd --version` works in the same shell, add the npm/Codex bin directory to PATH, or update the workspace mbx.yaml provider command to an absolute codex.cmd/codex.exe path.
  echo [MB-X][DIAG] where codex:
  where codex
  echo [MB-X][DIAG] where codex.cmd:
  where codex.cmd
  pause
  exit /b 5
)
echo [MB-X] codex=%MBX_CODEX_EXE%
echo [MB-X] where codex.cmd:
where codex.cmd
echo [MB-X] where codex:
where codex
 
cd /d "%WORKSPACE_ROOT%"
echo [MB-X] Starting or reusing Codex app-server at %APP_SERVER_URL%
python -m mbx.cli codex-server start --listen "%APP_SERVER_URL%"
echo.
echo [MB-X] If you run codex-server restart later, affected role sessions become window_restart_required.
echo [MB-X] After any restart, run each affected open-*.bat or restore-*.bat and verify resume_remote/history before dispatch.
pause