mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Implement Amazon Bedrock setup in the app server (#40007)
## What changed - Implement `account/bedrock/discover` to report AWS profiles and available environment credentials. - Implement `account/bedrock/setup` for validated AWS profiles and environment credentials, persisting the selected region and profile in the Bedrock provider configuration. - Resolve Bedrock authentication according to the selected credential source, and clear stale profile configuration when using a Codex-managed Bedrock API key. ## Testing - Cover profile and environment discovery, setup validation and persistence, conflicting credentials, and authentication-source precedence. GitOrigin-RevId: 16d700cb0843df768c2fdb6d0c8d26c3402e93df
This commit is contained in:
1 parent
51d8d12236
commit
e77c2a90af
17 files changed
+951
-90
No files matched your search
@@ -2,7 +2,8 @@ use super::config_processor::map_error as map_config_error;
|
||||
use crate::config_manager::ConfigManager;
|
||||
use crate::error_code::internal_error;
|
||||
use crate::error_code::invalid_request;
|
||||
use codex_app_server_protocol::ConfigValueWriteParams;
|
||||
use codex_app_server_protocol::ConfigBatchWriteParams;
|
||||
use codex_app_server_protocol::ConfigEdit;
|
||||
use codex_app_server_protocol::ConfigWriteErrorCode;
|
||||
use codex_app_server_protocol::JSONRPCErrorError;
|
||||
use codex_app_server_protocol::MergeStrategy;
|
||||
@@ -11,7 +12,40 @@ use codex_config::ConfigLayerSource;
|
||||
use codex_config::format_config_layer_source;
|
||||
use codex_model_provider::AMAZON_BEDROCK_PROVIDER_ID;
|
||||
|
||||
pub(super) async fn set_user_model_provider_to_bedrock(
|
||||
pub(super) async fn configure_bedrock_for_managed_auth(
|
||||
config_manager: &ConfigManager,
|
||||
) -> Result<(), JSONRPCErrorError> {
|
||||
ensure_user_model_provider_can_be_bedrock(config_manager).await?;
|
||||
|
||||
config_manager
|
||||
.batch_write(ConfigBatchWriteParams {
|
||||
edits: [
|
||||
(
|
||||
"model_provider",
|
||||
serde_json::json!(AMAZON_BEDROCK_PROVIDER_ID),
|
||||
),
|
||||
(
|
||||
"model_providers.amazon-bedrock.aws.profile",
|
||||
serde_json::Value::Null,
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.map(|(key_path, value)| ConfigEdit {
|
||||
key_path: key_path.to_string(),
|
||||
value,
|
||||
merge_strategy: MergeStrategy::Replace,
|
||||
})
|
||||
.collect(),
|
||||
file_path: None,
|
||||
expected_version: None,
|
||||
reload_user_config: false,
|
||||
})
|
||||
.await
|
||||
.map(|_| ())
|
||||
.map_err(map_config_error)
|
||||
}
|
||||
|
||||
pub(super) async fn ensure_user_model_provider_can_be_bedrock(
|
||||
config_manager: &ConfigManager,
|
||||
) -> Result<(), JSONRPCErrorError> {
|
||||
let layers = config_manager
|
||||
@@ -45,17 +79,7 @@ pub(super) async fn set_user_model_provider_to_bedrock(
|
||||
)));
|
||||
}
|
||||
|
||||
config_manager
|
||||
.write_value(ConfigValueWriteParams {
|
||||
key_path: "model_provider".to_string(),
|
||||
value: serde_json::json!(AMAZON_BEDROCK_PROVIDER_ID),
|
||||
merge_strategy: MergeStrategy::Replace,
|
||||
file_path: None,
|
||||
expected_version: None,
|
||||
})
|
||||
.await
|
||||
.map(|_| ())
|
||||
.map_err(map_config_error)
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(super) async fn clear_user_model_provider_if_bedrock(
|
||||
|
||||
Reference in new issue
Block a user