@echo off
|
setlocal
|
chcp 65001 >nul
|
|
REM MB-X non-destructive managed open helper.
|
REM role: project.admin
|
REM managed_session_key: project-info.infoadmin
|
REM Use this first when the recorded PID is stale/missing or when you only want safe open/reuse.
|
REM It resumes the existing provider_session_id/thread_id and never terminates an alive remote TUI.
|
REM If a PID is alive but the visible window is missing, use restore-*.bat instead.
|
set "WORKDIR=E:\mb-ms-doc\project-info"
|
set "MBX_SRC=E:\mb-ms-doc\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] Target status before open for project.admin
|
python -m mbx.cli session status --project project-info --role project.admin
|
echo.
|
echo [MB-X] Read-only terminal crash diagnostics before open:
|
python -m mbx.cli session terminal-diagnose --project project-info --role project.admin
|
echo.
|
echo [MB-X] Opening/reusing visible session for project.admin
|
echo [MB-X] Use this script for stale/missing PID. Use restore-*.bat only when an alive recorded PID has no visible window.
|
echo [MB-X] Command: python -m mbx.cli session open --project project-info --role project.admin
|
python -m mbx.cli session open --project project-info --role project.admin
|
set "MBX_EXIT=%ERRORLEVEL%"
|
if not "%MBX_EXIT%"=="0" (
|
echo [MB-X][ERROR] session open failed with exit code %MBX_EXIT%.
|
echo [MB-X][NEXT] Read the error details above. If app-server is alive but remote_tui_start_failed reports missing executable, fix Codex CLI PATH/codex.cmd first. If a PID is alive but no window is visible, use restore-*.bat only with recorded approval.
|
pause
|
exit /b %MBX_EXIT%
|
)
|
echo.
|
echo [MB-X] Target status after open for project.admin
|
python -m mbx.cli session status --project project-info --role project.admin
|
echo.
|
echo [MB-X] Verify the visible Codex window shows old chat history. If it disappears after Enter, run the terminal-diagnose command above and consider terminal-rendering apply only with recorded approval.
|
pause
|