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,22 +7,65 @@ BUILD_DIR="${PROJECT_DIR}/build"
echo "=== dstalk CI Build ==="
echo "Project: ${PROJECT_DIR}"
# 创建构建目录
# --- Find conan: prefer tools/ local install, fallback to PATH ---
CONAN=""
for candidate in \
"${PROJECT_DIR}/tools/.venv/bin/conan" \
"${PROJECT_DIR}/tools/.venv/Scripts/conan" \
"${PROJECT_DIR}/tools/.venv/Scripts/conan.exe"; do
if [ -x "${candidate}" ]; then
CONAN="${candidate}"
break
fi
done
if [ -z "${CONAN}" ] && command -v conan &>/dev/null; then
CONAN="conan"
fi
if [ -z "${CONAN}" ]; then
echo "ERROR: conan not found in tools/ or PATH" >&2
exit 1
fi
echo "Using conan: ${CONAN}"
# --- Detect conan profile ---
echo "--- Conan Profile Detect ---"
"${CONAN}" profile detect --force
# --- Install dependencies ---
echo "--- Conan Install ---"
mkdir -p "${BUILD_DIR}"
cd "${BUILD_DIR}"
"${CONAN}" install "${PROJECT_DIR}/deps/" --build=missing -s build_type=Release
# CMake 配置
# --- Find conan toolchain ---
TOOLCHAIN=""
for candidate in \
"Release/generators/conan_toolchain.cmake" \
"build/Release/generators/conan_toolchain.cmake"; do
if [ -f "${candidate}" ]; then
TOOLCHAIN="$(pwd)/${candidate}"
break
fi
done
if [ -z "${TOOLCHAIN}" ]; then
echo "ERROR: conan_toolchain.cmake not found" >&2
exit 1
fi
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
# 编译
# --- Build ---
echo "--- Build ---"
cmake --build . --parallel
# 运行测试
# --- Test ---
echo "--- Test ---"
ctest --output-on-failure --parallel 4