W17: extract ai_common shared module + fix anthropic data race + brace bugs

- New plugins_upper/ai_common/ static library: shared PluginConfig, ToolCallAccum,
  StreamContext, secure_zero, extract_host_port, serialize_tool_calls, free_chat_result
- Refactored openai/anthropic plugins to use dstalk_ai:: namespace from ai_common
- Fixed anthropic g_config raw pointer → std::atomic (data race)
- Added SSE parse error counter with threshold abort (kMaxSseParseErrors=5)
- Fixed missing closing brace in both plugins' error-body catch block
- Updated test targets: ai_common include path + link, using namespace dstalk_ai
- plugin_loader_test: added stub_unreg + service_registry.cpp for unregister_service
- Includes pre-existing uncommitted changes from prior waves

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 16:58:25 +08:00
parent ba7382db2a
commit 8faa02c3d5
49 changed files with 1062 additions and 413 deletions

View File

@@ -7,17 +7,80 @@ set BUILD_DIR=%PROJECT_DIR%\build
echo === dstalk CI Build ===
echo Project: %PROJECT_DIR%
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
cd /d "%BUILD_DIR%"
echo --- CMake Configure ---
cmake "%PROJECT_DIR%" -G Ninja -DCMAKE_BUILD_TYPE=Release -DDSTALK_BUILD_TESTS=ON -DDSTALK_BUILD_GUI=OFF
:: --- Find vcvarsall.bat for MSVC environment ---
set VCVARSALL=
for %%d in (
"C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
"C:\Program Files\Microsoft Visual Studio\2022\Professional"
"C:\Program Files\Microsoft Visual Studio\2022\Community"
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise"
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional"
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community"
) do (
if exist "%%~d\VC\Auxiliary\Build\vcvarsall.bat" (
set "VCVARSALL=%%~d\VC\Auxiliary\Build\vcvarsall.bat"
goto :found_vcvars
)
)
:found_vcvars
if "%VCVARSALL%"=="" (
echo ERROR: vcvarsall.bat not found - install Visual Studio or set VCVARSALL
exit /b 1
)
echo Using vcvarsall: %VCVARSALL%
call "%VCVARSALL%" x64
if errorlevel 1 exit /b 1
:: --- Find conan: prefer tools\ local install, fallback to PATH ---
set CONAN=
if exist "%PROJECT_DIR%\tools\.venv\Scripts\conan.exe" (
set "CONAN=%PROJECT_DIR%\tools\.venv\Scripts\conan.exe"
) else (
where conan >nul 2>&1
if not errorlevel 1 set "CONAN=conan"
)
if "%CONAN%"=="" (
echo ERROR: conan not found in tools\ or PATH
exit /b 1
)
echo Using conan: %CONAN%
:: --- Detect conan profile ---
echo --- Conan Profile Detect ---
"%CONAN%" profile detect --force
if errorlevel 1 exit /b 1
:: --- Install dependencies ---
echo --- Conan Install ---
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
cd /d "%BUILD_DIR%"
"%CONAN%" install "%PROJECT_DIR%\deps\" --build=missing -s build_type=Release
if errorlevel 1 exit /b 1
:: --- Find conan toolchain ---
set TOOLCHAIN=
if exist "%BUILD_DIR%\build\Release\generators\conan_toolchain.cmake" (
set "TOOLCHAIN=%BUILD_DIR%\build\Release\generators\conan_toolchain.cmake"
) else if exist "%BUILD_DIR%\Release\generators\conan_toolchain.cmake" (
set "TOOLCHAIN=%BUILD_DIR%\Release\generators\conan_toolchain.cmake"
)
if "%TOOLCHAIN%"=="" (
echo ERROR: conan_toolchain.cmake not found
exit /b 1
)
echo Toolchain: %TOOLCHAIN%
:: --- CMake configure ---
echo --- CMake Configure ---
cmake "%PROJECT_DIR%" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="%TOOLCHAIN%" -DDSTALK_BUILD_TESTS=ON -DDSTALK_BUILD_GUI=OFF
if errorlevel 1 exit /b 1
:: --- Build ---
echo --- Build ---
cmake --build . --parallel
if errorlevel 1 exit /b 1
:: --- Test ---
echo --- Test ---
ctest --output-on-failure --parallel 4
if errorlevel 1 exit /b 1