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

@@ -101,8 +101,8 @@ int ConfigStore::load_file(const char* path)
|------|------|------|
| 插件目录 | 功能名,小写 + 下划线 | `plugins_upper/openai/``plugins_base/file_io/` |
| 插件源文件 | `<功能名>_plugin.cpp` | `openai_plugin.cpp``session_plugin.cpp` |
| CMake 目标 | `plugin-<功能名>` | `plugin-openai``plugin-network` |
| 服务注册名 | 小写 + 点号分级 | `"ai.openai"``"http"``"session"` |
| CMake 目标 | `plugin_<功能名>` | `plugin_openai``plugin_network` |
| 服务注册名 | 小写 + 下划线 | `"ai_openai"``"http"``"session"` |
| 插件入口函数 | 固定为 `dstalk_plugin_init` | — |
### 3.5 禁止项