feat(provider,adapter): Codex 默认 body_rules 按 provider_type 维度注册,adapter 全链路传递 provider_type

- 新增 register_provider_default_body_rules 注册机制,将 Codex 特有的
  body_rules 从 EndpointDefinition 全局默认移至 codex plugin 按
  (provider_type, endpoint_sig) 维度注册
- handler adapter 的 build_endpoint_url/build_request_body/get_cli_extra_headers
  增加 provider_type 参数,Codex 判断优先使用 provider_type 而非 URL 匹配
- 前端 getDefaultBodyRules API 支持 provider_type 参数,缓存 key 区分不同
  provider 类型;Codex 路径判断同样优先使用 provider_type
- ProviderDetailDrawer 将 mapping-preview 拆为独立加载,不阻塞首屏渲染
- PoolManagement 补全 KeyFormDialog 缺失的 endpoint/available-api-formats props
- 固定类型 Provider 创建时自动填充 provider-scoped 默认 body_rules
This commit is contained in:
fawney19
2026-03-05 19:04:21 +08:00
parent 694167f78f
commit da915208a8
15 changed files with 214 additions and 54 deletions

View File

@@ -176,6 +176,24 @@ def register_all() -> None:
# Behavior
register_behavior_variant("codex", same_format=True, cross_format=True)
# Default Body Rules (Codex-specific, not format-wide)
from src.core.api_format.metadata import register_provider_default_body_rules
_codex_body_rules = (
{"action": "drop", "path": "max_output_tokens"},
{"action": "drop", "path": "temperature"},
{"action": "drop", "path": "top_p"},
{"action": "set", "path": "store", "value": False},
{
"action": "set",
"path": "instructions",
"value": "You are GPT-5.",
"condition": {"path": "instructions", "op": "not_exists"},
},
)
register_provider_default_body_rules("codex", "openai:cli", _codex_body_rules)
register_provider_default_body_rules("codex", "openai:compact", _codex_body_rules)
# Export: Codex uses the default export builder (strip null + temp fields)
# No need to register a custom one — the default in export.py suffices.