@echo off
|
setlocal
|
chcp 65001 >nul
|
|
REM MB-X destructive visible reopen helper.
|
REM role: experiment.experimenter
|
REM managed_session_key: project-wuji.laoan
|
REM It terminates only the recorded remote_tui_pid if alive, then resumes the existing thread through app-server.
|
REM It does not delete runtime queues and does not create a new provider session/thread.
|
set "WORKDIR=D:\manage_system\project-wuji"
|
set "MBX_SRC=D:\manage_system\project-mbx-core\src"
|
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 "%WORKDIR%"
|
echo [MB-X] Restoring visible session for experiment.experimenter
|
echo [MB-X][RISK] This may terminate the recorded old remote TUI PID if it is still alive.
|
echo [MB-X][RISK] For management roles, record this as a high-risk management action if used for real validation.
|
set /p MBX_CONFIRM=Type REOPEN to continue:
|
if /I not "%MBX_CONFIRM%"=="REOPEN" (
|
echo [MB-X] Cancelled.
|
exit /b 2
|
)
|
echo [MB-X] Command: python -m mbx.cli session reopen --project project-wuji --role experiment.experimenter --terminate-existing
|
python -m mbx.cli session reopen --project project-wuji --role experiment.experimenter --terminate-existing
|
set "MBX_EXIT=%ERRORLEVEL%"
|
if not "%MBX_EXIT%"=="0" (
|
echo [MB-X][ERROR] session reopen failed with exit code %MBX_EXIT%.
|
pause
|
exit /b %MBX_EXIT%
|
)
|
echo.
|
python -m mbx.cli session status --project project-wuji --role experiment.experimenter
|
echo.
|
echo [MB-X] Verify the visible window shows the old chat history; do not use history/read alone as window proof.
|
pause
|