feat(bedrock): 新增 Amazon Bedrock 供应商支持(双鉴权路径 + 评审修复)#1374
Open
yourlin wants to merge 1 commit into
Open
Conversation
支持双鉴权路径(Bedrock API Key / AWS Profile SSO),前后端各自实现 生成与识别端并通过 property test 保证契约;同时把评审中提出的 10 项 问题(P0/P1/P2/P3)一并修复。 主要改动: - 生成端:complete_bedrock_bearer_token_config / complete_bedrock_aws_profile_config - 识别端:bedrock_config_from_config_text(Rust/TS 双端保持契约一致) - 前端:BedrockRelayProfileEditor(名称、Provider 标识符、Region、 API Key、IAM 用户名、AWS Profile 等字段),并提供 Long-Term / Short-Term Key 与 AWS SSO 的 CLI 命令示例 - 供应商预设:ProviderPresetSelector 里 Bedrock 入口归入「第三方」 分组、排在 Azure OpenAI 前面;搜索命中 aws / bedrock / amazon 时 也可见 - 常量:BEDROCK_MANTLE_URL_PREFIX / SUFFIX 提取给 Rust/TS 两端参照 - 测试:proptest 覆盖 10 条属性 + regression 覆盖脏字段残留 / 表段感知 / 保留字冲突去重 / 天数校验 评审修复清单: - P0-1 保留字冲突时 inline 与底部错误提示去重 - P0-2 bedrockValidationError 注释与实现对齐 - P1-3 ensure_root_scalars_precede_tables 加入表段感知,忽略注释行 - P1-4 tomlStringAssignment / Bool 对 key 做 escapeRegExp - P2-5 Bearer Token 分支改为整表替换,避免同名旧 provider 表脏字段残留 - P2-6 BEDROCK_MANTLE_URL_PREFIX / SUFFIX 提取常量,Rust/TS 同步 - P3-7 IAM 用户名字段 label 精简,长括号说明改到 field-hint - P3-8 bedrockLongTermApiKeyCommand 拒绝非法天数(fallback 90) - P3-9 require_non_empty label 统一中文("AWS 区域") - UI 补齐:Bedrock 编辑器新增「名称」字段,修复无法改名的问题
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
新增 Amazon Bedrock 供应商,支持 Bedrock API Key (Bearer Token) 与 AWS Profile (SSO) 双鉴权路径。前后端各自实现生成与识别端并通过 property test 保证契约。同时把代码评审中提出的 10 项问题(P0/P1/P2/P3)一并修复。
主要改动
后端(Rust /
codex-plus-core)complete_bedrock_bearer_token_config/complete_bedrock_aws_profile_configbedrock_config_from_config_text(与 TS 端保持契约一致)RelayProfile.bedrock: Option<BedrockConfig>,包含auth_mode/provider_id/region/aws_profile/iam_user_name/iam_key_validity_days六个字段;bedrock: None不序列化(旧 settings.json 落盘格式不变)relay_switch里对 AWS Profile 模式跳过configured检查,避免把合法配置误判为"未检测到完整 custom provider"BEDROCK_MANTLE_URL_PREFIX/BEDROCK_MANTLE_URL_SUFFIX提取到模块顶部,供生成端与识别端共同引用前端(TypeScript / Tauri manager)
BedrockRelayProfileEditor:名称、Provider 标识符、Region、API Key、IAM 用户名、AWS Profile 等字段;提供 Long-Term / Short-Term Key 与 AWS SSO 的 CLI 命令示例ProviderPresetSelector:Bedrock 入口归入「第三方」分组,排在 Azure OpenAI 前面;搜索命中aws/bedrock/amazon时也可见bedrock-config.ts:与 Rust 契约对齐的解析/校验/命令生成纯函数测试
proptest覆盖 10 条属性(Bearer Token / AWS Profile 生成正确性、region 必填、保留字冲突、Base URL 一致性、生成 → 识别往返 等)bedrock-config.test.ts/BedrockRelayProfileEditor.test.ts/ProviderPresetSelector.test.ts用 Node--test+ fast-check 属性测试代码评审修复(P0/P1/P2/P3)
bedrockValidationErrorForBottom)bedrockValidationError注释与实现对齐ensure_root_scalars_precede_tables加入表段感知,忽略注释行;同步 property test 生成器tomlStringAssignment/tomlBoolAssignment对 key 做escapeRegExpenv_key/http_headers等杂字段残留BEDROCK_MANTLE_URL_PREFIX/SUFFIX提取常量,Rust / TS 双端同步field-hintbedrockLongTermApiKeyCommand拒绝非法天数(非正整数、前导零、字母、负号统一 fallback 到90)require_non_empty调用点 label 统一为中文("AWS 区域"),消除"region 不能为空"半中半英验证
cargo test -p codex-plus-core --lib:125/125 通过(含 8 property + 3 新增 regression)cargo test -p codex-plus-core --test relay_switch --test launcher:60/60 通过(含 Bedrock Bearer Token / AWS Profile 两条完整写入路径的集成测试)node --test --experimental-strip-types src/**/*.test.ts:56/56 通过tsc --noEmit:干净npm run build:完整 release 构建通过(Vite +cargo build --release)openai/amazon-bedrock等)只在 Provider ID 下方展示 inline 红字,底部不再重复abc/-5/090均 fallback 到90~/.codex/config.toml生成的[model_providers.*]段落干净、无脏字段残留已知限制 / 备注
tauri.conf.json里bundle.active = false,本 PR 不涉及.app/.dmg打包变化。i18n-en.ts未为本次新增中文串补翻译,沿用项目现状:t()找不到映射时回落到原文。tests/installers.rs有 3 项 bundle 命名相关的失败是仓库既存问题(本 PR 前后一致,与本次改动无关)。BEDROCK_MANTLE_URL_PREFIX/SUFFIX仍需 Rust / TS 两端手动同步;若未来 endpoint 模板改变,两处需同时更新。