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

@@ -45,8 +45,8 @@
| 目录 | 服务名 | 功能说明 | 依赖 |
|------|--------|---------|------|
| `plugins_upper/context/` | `"context"` | Token 计数UTF-8 字节估算)、上下文窗口裁剪 | `session` |
| `plugins_upper/openai/` | `"ai.openai"` | OpenAI 兼容格式 AI 接入chat/stream/tools、SSE 解析) | `http``config` |
| `plugins_upper/anthropic/` | `"ai.anthropic"` | Anthropic Claude Messages API 接入chat/stream、SSE 解析) | `http``config` |
| `plugins_upper/openai/` | `"ai_openai"` | OpenAI 兼容格式 AI 接入chat/stream/tools、SSE 解析) | `http``config` |
| `plugins_upper/anthropic/` | `"ai_anthropic"` | Anthropic Claude Messages API 接入chat/stream、SSE 解析) | `http``config` |
### 3.4 规划中的插件(尚未实现)