Rimossi i provider integrati OpenAI, Bedrock e GCP e ogni fallback a OpenAI (B)
Parte "sicurezza" della fase 3 di aKode (e39aae00), senza le funzioni di imeAI:
- via i provider integrati openai, amazon-bedrock, amazon-bedrock-runtime e gcp
(crate model-provider: moduli amazon_bedrock, gcp, chatgpt_base_url; login Bedrock;
onboarding Bedrock/GCP; richieste app-server di setup cloud);
- nessun URL predefinito verso api.openai.com / chatgpt.com: un provider senza
base_url non viene mai contattato; senza model_provider configurato exec e TUI
mostrano come scriverne uno in config.toml (NO_MODEL_PROVIDER_CONFIGURED_ERROR);
- via la skill openai-docs, la sample skill-installer (scaricava da github.com/openai/skills),
request_plugin_install, AppsInstructions, URL predefiniti di realtime e updater;
- test di sicurezza adattati (provider "mock" al posto di quello integrato), non cancellati.
Restano fuori da questo commit (categoria F/D/E, non portate): chiave per provider nel
portachiavi, modelli da /models, unione dei messaggi di sistema, crate web-tools e
SearXNG, header @@ in apply_patch, modello ausiliario, tool function per apply_patch.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,88 +0,0 @@
|
||||
//! GCP account reporting follows the selected provider without resolving its credentials.
|
||||
|
||||
use anyhow::Result;
|
||||
use app_test_support::TestAppServer;
|
||||
use app_test_support::write_api_key_auth;
|
||||
use codex_app_server_protocol::GetAccountParams;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use tempfile::TempDir;
|
||||
use test_case::test_case;
|
||||
use tokio::time::timeout;
|
||||
|
||||
const READ_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(/*secs*/ 30);
|
||||
|
||||
#[test_case(""; "application_default_credentials")]
|
||||
#[test_case(
|
||||
r#"
|
||||
[model_providers.gcp]
|
||||
base_url = "https://vertex.example.com/v1"
|
||||
[model_providers.gcp.auth]
|
||||
command = "codex-test-gcp-command-that-does-not-exist"
|
||||
"#;
|
||||
"external_command_and_endpoint"
|
||||
)]
|
||||
#[tokio::test]
|
||||
async fn gcp_account_is_reported_without_resolving_credentials(overrides: &str) -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
format!("model_provider = \"gcp\"\n{overrides}"),
|
||||
)?;
|
||||
let mut app_server = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.with_env_overrides(&[("OPENAI_API_KEY", None)])
|
||||
.build_initialized()
|
||||
.await?;
|
||||
|
||||
let request_id = app_server
|
||||
.send_get_account_request(GetAccountParams {})
|
||||
.await?;
|
||||
let received: Value = timeout(READ_TIMEOUT, app_server.read_response(request_id)).await??;
|
||||
assert_eq!(
|
||||
received,
|
||||
json!({"account": {"type": "gcp"}, "requiresOpenaiAuth": false})
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn gcp_account_tracks_provider_changes_with_saved_api_key() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let config_path = codex_home.path().join("config.toml");
|
||||
std::fs::write(&config_path, "model_provider = \"gcp\"\n")?;
|
||||
write_api_key_auth(codex_home.path())?;
|
||||
let mut app_server = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.with_env_overrides(&[("OPENAI_API_KEY", None)])
|
||||
.build_initialized()
|
||||
.await?;
|
||||
|
||||
for (provider, expected) in [
|
||||
(
|
||||
"gcp",
|
||||
json!({"account": {"type": "gcp"}, "requiresOpenaiAuth": false}),
|
||||
),
|
||||
(
|
||||
"amazon-bedrock",
|
||||
json!({"account": {"type": "amazonBedrock", "usesCodexManagedCredentials": false}, "requiresOpenaiAuth": false}),
|
||||
),
|
||||
(
|
||||
"openai",
|
||||
json!({"account": {"type": "apiKey"}, "requiresOpenaiAuth": true}),
|
||||
),
|
||||
(
|
||||
"gcp",
|
||||
json!({"account": {"type": "gcp"}, "requiresOpenaiAuth": false}),
|
||||
),
|
||||
] {
|
||||
std::fs::write(&config_path, format!("model_provider = \"{provider}\"\n"))?;
|
||||
let request_id = app_server
|
||||
.send_get_account_request(GetAccountParams {})
|
||||
.await?;
|
||||
let received: Value = timeout(READ_TIMEOUT, app_server.read_response(request_id)).await??;
|
||||
assert_eq!(received, expected);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -27,6 +27,11 @@ async fn builder_interposes_fixed_delay_for_auto_env() -> Result<()> {
|
||||
skip_if_remote!(Ok(()), "the fixed-delay fixture is local-only");
|
||||
|
||||
let codex_home = TempDir::new()?;
|
||||
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
app_test_support::bundled_model_catalog_config(codex_home.path())?,
|
||||
)?;
|
||||
let requested_delay = Duration::from_secs(1);
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
|
||||
@@ -1,223 +0,0 @@
|
||||
//! GovCloud checks use current login state and refresh managed requirements without a restart.
|
||||
|
||||
use anyhow::Result;
|
||||
use app_test_support::TestAppServer;
|
||||
use codex_app_server_protocol::BedrockCheckGovCloudRequirementsParams;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::LoginAccountParams;
|
||||
use codex_app_server_protocol::LoginAccountResponse;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_config::types::AuthCredentialsStoreMode;
|
||||
use codex_login::AuthKeyringBackendKind;
|
||||
use codex_login::login_with_bedrock_api_key;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use tempfile::TempDir;
|
||||
use test_case::test_case;
|
||||
|
||||
const BASELINE: &str = r#"
|
||||
allowed_login_methods = ["api"]
|
||||
[application.network]
|
||||
enabled = true
|
||||
[application.network.domains]
|
||||
"bedrock-mantle.us-gov-west-1.api.aws" = "allow"
|
||||
"#;
|
||||
|
||||
async fn check(server: &mut TestAppServer) -> Result<Value> {
|
||||
server
|
||||
.request(
|
||||
|request_id| ClientRequest::BedrockCheckGovCloudRequirements {
|
||||
request_id,
|
||||
params: BedrockCheckGovCloudRequirementsParams {},
|
||||
},
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn checks_current_provider_after_login_without_restart() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(home.path().join("config.toml"), "")?;
|
||||
login_with_bedrock_api_key(
|
||||
home.path(),
|
||||
"test-key",
|
||||
"us-gov-west-1",
|
||||
AuthCredentialsStoreMode::File,
|
||||
AuthKeyringBackendKind::default(),
|
||||
)?;
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
assert_eq!(
|
||||
check(&mut server).await?,
|
||||
json!({"isGovCloud": false, "shouldWarn": false})
|
||||
);
|
||||
// GovCloud onboarding is enabled separately. Select the provider using the
|
||||
// existing login so stale startup configuration produces a different result.
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
"model_provider = 'amazon-bedrock'\n",
|
||||
)?;
|
||||
assert_eq!(
|
||||
check(&mut server).await?,
|
||||
json!({"isGovCloud": true, "shouldWarn": true})
|
||||
);
|
||||
let _: LoginAccountResponse = server
|
||||
.request(|request_id| ClientRequest::LoginAccount {
|
||||
request_id,
|
||||
params: LoginAccountParams::AmazonBedrock {
|
||||
api_key: "test-key".to_string(),
|
||||
region: "us-west-2".to_string(),
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(
|
||||
check(&mut server).await?,
|
||||
json!({"isGovCloud": false, "shouldWarn": false})
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case("amazon-bedrock", "", "bedrock-mantle.us-gov-west-1.api.aws"; "mantle")]
|
||||
#[test_case("amazon-bedrock-runtime", "", "bedrock-runtime.us-gov-west-1.amazonaws.com"; "runtime")]
|
||||
#[test_case("amazon-bedrock", "[model_providers.amazon-bedrock]\nbase_url = 'https://bedrock.example.com/openai/v1'", "bedrock.example.com"; "custom_endpoint")]
|
||||
#[tokio::test]
|
||||
async fn checks_required_policy_fields_and_endpoint(
|
||||
provider: &str,
|
||||
provider_config: &str,
|
||||
domain: &str,
|
||||
) -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!("model_provider = '{provider}'\n{provider_config}\n"),
|
||||
)?;
|
||||
login_with_bedrock_api_key(
|
||||
home.path(),
|
||||
"test-key",
|
||||
"us-gov-west-1",
|
||||
AuthCredentialsStoreMode::File,
|
||||
AuthKeyringBackendKind::default(),
|
||||
)?;
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
let baseline = BASELINE.replace("bedrock-mantle.us-gov-west-1.api.aws", domain);
|
||||
for (requirements, should_warn) in [
|
||||
(
|
||||
baseline.replace("[\"api\"]", "[\"api\", \"chatgpt\"]"),
|
||||
true,
|
||||
),
|
||||
(baseline.replace("enabled = true", "enabled = false"), true),
|
||||
(baseline.replace("\"allow\"", "\"deny\""), true),
|
||||
(baseline, false),
|
||||
] {
|
||||
std::fs::write(home.path().join("requirements.toml"), &requirements)?;
|
||||
assert_eq!(
|
||||
check(&mut server).await?,
|
||||
json!({"isGovCloud": true, "shouldWarn": should_warn}),
|
||||
"{requirements}"
|
||||
);
|
||||
}
|
||||
std::fs::write(home.path().join("requirements.toml"), "[invalid toml")?;
|
||||
let request_id = server
|
||||
.send_request("account/bedrock/checkGovCloudRequirements", Some(json!({})))
|
||||
.await?;
|
||||
let error = tokio::time::timeout(
|
||||
std::time::Duration::from_secs(/*secs*/ 10),
|
||||
server.read_stream_until_error_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
assert_eq!((error.error.code, error.error.data), (-32603, None));
|
||||
assert!(
|
||||
error
|
||||
.error
|
||||
.message
|
||||
.starts_with("failed to load configuration:")
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn check_preserves_current_login_when_saved_credentials_are_unreadable() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
"model_provider = 'amazon-bedrock'\ncli_auth_credentials_store = 'file'\n",
|
||||
)?;
|
||||
login_with_bedrock_api_key(
|
||||
home.path(),
|
||||
"test-key",
|
||||
"us-gov-west-1",
|
||||
AuthCredentialsStoreMode::File,
|
||||
AuthKeyringBackendKind::default(),
|
||||
)?;
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
|
||||
// The advisory must keep using the running session's credentials even when
|
||||
// its persistent credential store becomes unreadable.
|
||||
std::fs::write(home.path().join("auth.json"), "invalid json")?;
|
||||
assert_eq!(
|
||||
check(&mut server).await?,
|
||||
json!({"isGovCloud": true, "shouldWarn": true})
|
||||
);
|
||||
std::fs::write(home.path().join("requirements.toml"), BASELINE)?;
|
||||
assert_eq!(
|
||||
check(&mut server).await?,
|
||||
json!({"isGovCloud": true, "shouldWarn": false})
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case("bedrock-mantle.us-gov-west-1.api.aws", "us-west-2", true; "mantle_url_overrides_commercial_region")]
|
||||
#[test_case("bedrock-runtime.us-gov-east-1.amazonaws.com", "us-west-2", true; "runtime_url_overrides_commercial_region")]
|
||||
#[test_case("bedrock-runtime-fips.us-gov-west-1.amazonaws.com", "us-west-2", true; "fips_url_overrides_commercial_region")]
|
||||
#[test_case("bedrock-mantle.us-west-2.api.aws", "us-gov-west-1", false; "commercial_url_overrides_govcloud_region")]
|
||||
#[test_case("bedrock-mantle.us-gov-west-1.api.aws.example.com", "us-west-2", false; "lookalike_proxy_uses_region")]
|
||||
#[tokio::test]
|
||||
async fn official_endpoint_takes_precedence_over_auth_region(
|
||||
domain: &str,
|
||||
auth_region: &str,
|
||||
is_gov_cloud: bool,
|
||||
) -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!(
|
||||
"model_provider = 'amazon-bedrock'\n\
|
||||
[model_providers.amazon-bedrock]\n\
|
||||
base_url = 'https://{domain}/openai/v1'\n"
|
||||
),
|
||||
)?;
|
||||
login_with_bedrock_api_key(
|
||||
home.path(),
|
||||
"test-key",
|
||||
auth_region,
|
||||
AuthCredentialsStoreMode::File,
|
||||
AuthKeyringBackendKind::default(),
|
||||
)?;
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
assert_eq!(
|
||||
check(&mut server).await?,
|
||||
json!({"isGovCloud": is_gov_cloud, "shouldWarn": is_gov_cloud})
|
||||
);
|
||||
std::fs::write(
|
||||
home.path().join("requirements.toml"),
|
||||
BASELINE.replace("bedrock-mantle.us-gov-west-1.api.aws", domain),
|
||||
)?;
|
||||
assert_eq!(
|
||||
check(&mut server).await?,
|
||||
json!({"isGovCloud": is_gov_cloud, "shouldWarn": false})
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
//! Verifies Bedrock service-tier discovery through the public model/list API.
|
||||
|
||||
use app_test_support::TestAppServer;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::ModelListParams;
|
||||
use codex_app_server_protocol::ModelListResponse;
|
||||
use codex_app_server_protocol::ModelServiceTier;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tempfile::TempDir;
|
||||
|
||||
#[test_case::test_case("amazon-bedrock", vec!["openai.gpt-6.1-sol", "openai.gpt-6-astra"]; "mantle")]
|
||||
#[test_case::test_case("amazon-bedrock-runtime", vec!["global.openai.gpt-6.1-sol", "global.openai.gpt-6-astra", "us.openai.gpt-6.1-sol", "us.openai.gpt-6-astra"]; "runtime")]
|
||||
#[tokio::test]
|
||||
async fn bedrock_model_list_advertises_ultrafast_without_changing_default(
|
||||
provider_id: &str,
|
||||
expected_models: Vec<&str>,
|
||||
) -> anyhow::Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!(
|
||||
r#"model_provider = "{provider_id}"
|
||||
[model_providers.{provider_id}.aws]
|
||||
region = "us-west-2"
|
||||
"#
|
||||
),
|
||||
)?;
|
||||
let mut app_server = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
let response: ModelListResponse = app_server
|
||||
.request(|request_id| ClientRequest::ModelList {
|
||||
request_id,
|
||||
params: ModelListParams {
|
||||
cursor: None,
|
||||
limit: Some(100),
|
||||
include_hidden: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
|
||||
assert_eq!(
|
||||
response
|
||||
.data
|
||||
.iter()
|
||||
.filter(|model| !model.service_tiers.is_empty())
|
||||
.map(|model| (
|
||||
model.model.as_str(),
|
||||
model.service_tiers.clone(),
|
||||
model.default_service_tier.clone()
|
||||
))
|
||||
.collect::<Vec<_>>(),
|
||||
expected_models
|
||||
.into_iter()
|
||||
.map(|model| (
|
||||
model,
|
||||
vec![ModelServiceTier {
|
||||
id: "ultrafast".to_string(),
|
||||
name: "Ultrafast".to_string(),
|
||||
description: "The fastest available responses for latency-sensitive work."
|
||||
.to_string(),
|
||||
}],
|
||||
None
|
||||
))
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case::test_case("amazon-bedrock", "openai.gpt-6-astra"; "mantle")]
|
||||
#[test_case::test_case("amazon-bedrock-runtime", "global.openai.gpt-6-astra"; "runtime")]
|
||||
#[tokio::test]
|
||||
async fn bedrock_model_list_preserves_custom_service_tiers(
|
||||
provider_id: &str,
|
||||
model_id: &str,
|
||||
) -> anyhow::Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
let mut model = codex_models_manager::bundled_models_response()?
|
||||
.models
|
||||
.into_iter()
|
||||
.find(|model| model.slug == "gpt-6-astra")
|
||||
.expect("bundled Astra model");
|
||||
model.slug = model_id.to_string();
|
||||
model.additional_speed_tiers = vec!["fast".to_string()];
|
||||
model.service_tiers = vec![codex_protocol::openai_models::ModelServiceTier {
|
||||
id: "ultrafast".to_string(),
|
||||
name: "Express".to_string(),
|
||||
description: "My custom Bedrock tier.".to_string(),
|
||||
}];
|
||||
model.default_service_tier = Some("ultrafast".to_string());
|
||||
let catalog_path = home.path().join("models.json");
|
||||
std::fs::write(
|
||||
&catalog_path,
|
||||
serde_json::to_vec(&codex_protocol::openai_models::ModelsResponse {
|
||||
models: vec![model],
|
||||
})?,
|
||||
)?;
|
||||
let catalog_path = serde_json::to_string(&catalog_path)?;
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!(
|
||||
r#"model_provider = "{provider_id}"
|
||||
model_catalog_json = {catalog_path}
|
||||
[model_providers.{provider_id}.aws]
|
||||
region = "us-west-2"
|
||||
"#
|
||||
),
|
||||
)?;
|
||||
let mut app_server = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
let response: ModelListResponse = app_server
|
||||
.request(|request_id| ClientRequest::ModelList {
|
||||
request_id,
|
||||
params: ModelListParams {
|
||||
cursor: None,
|
||||
limit: Some(100),
|
||||
include_hidden: Some(true),
|
||||
..Default::default()
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
|
||||
assert_eq!(
|
||||
response
|
||||
.data
|
||||
.into_iter()
|
||||
.map(|model| (
|
||||
model.model,
|
||||
model.additional_speed_tiers,
|
||||
model.service_tiers,
|
||||
model.default_service_tier,
|
||||
))
|
||||
.collect::<Vec<_>>(),
|
||||
vec![(
|
||||
model_id.to_string(),
|
||||
vec!["fast".to_string()],
|
||||
vec![ModelServiceTier {
|
||||
id: "ultrafast".to_string(),
|
||||
name: "Express".to_string(),
|
||||
description: "My custom Bedrock tier.".to_string(),
|
||||
}],
|
||||
Some("ultrafast".to_string()),
|
||||
)]
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,412 +0,0 @@
|
||||
use anyhow::Result;
|
||||
use app_test_support::TestAppServer;
|
||||
use codex_app_server_protocol::BedrockDiscoverParams;
|
||||
use codex_app_server_protocol::BedrockDiscoverResponse;
|
||||
use codex_app_server_protocol::BedrockSetupParams;
|
||||
use codex_app_server_protocol::BedrockSetupResponse;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::ModelListParams;
|
||||
use codex_app_server_protocol::ModelListResponse;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_app_server_protocol::ThreadStartParams;
|
||||
use codex_config::types::AuthCredentialsStoreMode;
|
||||
use codex_login::AuthKeyringBackendKind;
|
||||
use codex_login::login_with_bedrock_api_key;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::json;
|
||||
use std::path::Path;
|
||||
use std::time::Duration;
|
||||
use tempfile::TempDir;
|
||||
use tokio::time::timeout;
|
||||
|
||||
const READ_TIMEOUT: Duration = Duration::from_secs(/*secs*/ 60);
|
||||
|
||||
async fn bedrock_app_server(
|
||||
codex_home: &Path,
|
||||
environment: &[(&str, Option<&str>)],
|
||||
) -> Result<TestAppServer> {
|
||||
let aws_config = codex_home.join("aws-config");
|
||||
let aws_credentials = codex_home.join("aws-credentials");
|
||||
std::fs::write(&aws_config, "[profile engineering]\nregion = us-west-2\n")?;
|
||||
std::fs::write(
|
||||
&aws_credentials,
|
||||
"[engineering]\naws_access_key_id = engineering-id\naws_secret_access_key = engineering-secret\n\
|
||||
[finance]\naws_access_key_id = finance-id\naws_secret_access_key = finance-secret\n",
|
||||
)?;
|
||||
let aws_config_path = aws_config.to_string_lossy();
|
||||
let aws_credentials_path = aws_credentials.to_string_lossy();
|
||||
TestAppServer::builder()
|
||||
.with_codex_home(codex_home)
|
||||
.with_env_overrides(&[
|
||||
("AWS_CONFIG_FILE", Some(aws_config_path.as_ref())),
|
||||
(
|
||||
"AWS_SHARED_CREDENTIALS_FILE",
|
||||
Some(aws_credentials_path.as_ref()),
|
||||
),
|
||||
("AWS_PROFILE", None),
|
||||
("AWS_ACCESS_KEY_ID", None),
|
||||
("AWS_SECRET_ACCESS_KEY", None),
|
||||
("AWS_SESSION_TOKEN", None),
|
||||
("AWS_BEARER_TOKEN_BEDROCK", None),
|
||||
("AWS_REGION", None),
|
||||
("AWS_DEFAULT_REGION", None),
|
||||
("AWS_EC2_METADATA_DISABLED", Some("true")),
|
||||
])
|
||||
.with_env_overrides(environment)
|
||||
.build_initialized_with_timeout(READ_TIMEOUT)
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn discover_bedrock_profiles_and_environment_credentials() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let mut app_server = bedrock_app_server(
|
||||
codex_home.path(),
|
||||
&[
|
||||
("AWS_PROFILE", Some("engineering")),
|
||||
("AWS_ACCESS_KEY_ID", Some("environment-id")),
|
||||
("AWS_SECRET_ACCESS_KEY", Some("environment-secret")),
|
||||
("AWS_SESSION_TOKEN", Some("environment-token")),
|
||||
("AWS_BEARER_TOKEN_BEDROCK", Some("environment-bedrock-key")),
|
||||
("AWS_DEFAULT_REGION", Some("us-west-2")),
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
|
||||
let response: BedrockDiscoverResponse = app_server
|
||||
.request(|request_id| ClientRequest::BedrockDiscover {
|
||||
request_id,
|
||||
params: BedrockDiscoverParams {},
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(
|
||||
serde_json::to_value(response)?,
|
||||
json!({
|
||||
"profiles": [
|
||||
{"name": "engineering", "region": "us-west-2"},
|
||||
{"name": "finance", "region": null}
|
||||
],
|
||||
"environmentCredentials": [
|
||||
{"type": "accessKeys", "region": null},
|
||||
{"type": "bedrockApiKey", "region": null}
|
||||
]
|
||||
})
|
||||
);
|
||||
|
||||
let response: BedrockSetupResponse = app_server
|
||||
.request(|request_id| ClientRequest::BedrockSetup {
|
||||
request_id,
|
||||
params: BedrockSetupParams::Environment {
|
||||
region: " us-east-2 ".to_string(),
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(response, BedrockSetupResponse {});
|
||||
|
||||
let config: toml::Value = toml::from_str(&std::fs::read_to_string(
|
||||
codex_home.path().join("config.toml"),
|
||||
)?)?;
|
||||
assert_eq!(
|
||||
config,
|
||||
toml::toml! {
|
||||
model_provider = "amazon-bedrock"
|
||||
[model_providers.amazon-bedrock.aws]
|
||||
region = "us-east-2"
|
||||
}
|
||||
.into()
|
||||
);
|
||||
assert!(!codex_home.path().join(".env").exists());
|
||||
|
||||
// The same server must route both the picker and the first thread to Bedrock.
|
||||
let models: ModelListResponse = app_server
|
||||
.request(|request_id| ClientRequest::ModelList {
|
||||
request_id,
|
||||
params: ModelListParams::default(),
|
||||
})
|
||||
.await?;
|
||||
let default_model = models.data.iter().find(|model| model.is_default).unwrap();
|
||||
assert!(default_model.model.starts_with("openai."));
|
||||
let thread = app_server
|
||||
.start_thread(ThreadStartParams::default())
|
||||
.await?;
|
||||
assert_eq!(thread.model_provider, "amazon-bedrock");
|
||||
assert_eq!(thread.model, default_model.model);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn setup_bedrock_profile_and_environment() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let config_path = codex_home.path().join("config.toml");
|
||||
let dotenv_path = codex_home.path().join(".env");
|
||||
let existing_config = "[model_providers.amazon-bedrock]\nhttp_headers = { X-Existing = \"preserved\" }\n\
|
||||
[model_providers.amazon-bedrock.aws]\nprofile = \"old\"\nregion = \"us-east-1\"\n\
|
||||
auth_refresh = { command = \"aws\", args = [\"login\"] }\n";
|
||||
std::fs::write(&config_path, existing_config)?;
|
||||
let existing_dotenv = "# existing configuration\nUNRELATED=value\nAWS_ACCESS_KEY_ID=old-id\n\
|
||||
export AWS_SECRET_ACCESS_KEY=old-secret\nAWS_SESSION_TOKEN=stale-token\n";
|
||||
std::fs::write(&dotenv_path, existing_dotenv)?;
|
||||
let mut app_server = bedrock_app_server(
|
||||
codex_home.path(),
|
||||
&[
|
||||
("AWS_ACCESS_KEY_ID", Some("environment-id")),
|
||||
("AWS_SECRET_ACCESS_KEY", Some("environment-secret")),
|
||||
("AWS_DEFAULT_REGION", Some("us-east-1")),
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
|
||||
let response: BedrockSetupResponse = app_server
|
||||
.request(|request_id| ClientRequest::BedrockSetup {
|
||||
request_id,
|
||||
params: BedrockSetupParams::Profile {
|
||||
profile: " engineering ".to_string(),
|
||||
region: " us-west-2 ".to_string(),
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(response, BedrockSetupResponse {});
|
||||
let config: toml::Value = toml::from_str(&std::fs::read_to_string(&config_path)?)?;
|
||||
assert_eq!(
|
||||
serde_json::to_value(&config["model_providers"]["amazon-bedrock"]["aws"])?,
|
||||
json!({
|
||||
"profile": "engineering",
|
||||
"region": "us-west-2",
|
||||
"auth_refresh": {"command": "aws", "args": ["login"]}
|
||||
})
|
||||
);
|
||||
assert_eq!(std::fs::read_to_string(&dotenv_path)?, existing_dotenv);
|
||||
|
||||
std::fs::write(&config_path, existing_config)?;
|
||||
let response: BedrockSetupResponse = app_server
|
||||
.request(|request_id| ClientRequest::BedrockSetup {
|
||||
request_id,
|
||||
params: BedrockSetupParams::Environment {
|
||||
region: "us-east-1".to_string(),
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(response, BedrockSetupResponse {});
|
||||
assert_eq!(std::fs::read_to_string(&dotenv_path)?, existing_dotenv);
|
||||
let config: toml::Value = toml::from_str(&std::fs::read_to_string(&config_path)?)?;
|
||||
assert_eq!(
|
||||
serde_json::to_value(&config["model_providers"]["amazon-bedrock"]["aws"])?,
|
||||
json!({
|
||||
"region": "us-east-1",
|
||||
"auth_refresh": {"command": "aws", "args": ["login"]}
|
||||
})
|
||||
);
|
||||
|
||||
let config: toml::Value = toml::from_str(&std::fs::read_to_string(&config_path)?)?;
|
||||
assert_eq!(
|
||||
config,
|
||||
toml::toml! {
|
||||
model_provider = "amazon-bedrock"
|
||||
|
||||
[model_providers.amazon-bedrock]
|
||||
http_headers = { X-Existing = "preserved" }
|
||||
|
||||
[model_providers.amazon-bedrock.aws]
|
||||
region = "us-east-1"
|
||||
auth_refresh = { command = "aws", args = ["login"] }
|
||||
}
|
||||
.into()
|
||||
);
|
||||
|
||||
let managed_home = TempDir::new()?;
|
||||
let managed_config_path = managed_home.path().join("config.toml");
|
||||
std::fs::write(&managed_config_path, "model_provider = 'openai'")?;
|
||||
std::fs::write(
|
||||
managed_home.path().join("requirements.toml"),
|
||||
"model_provider = 'amazon-bedrock'",
|
||||
)?;
|
||||
login_with_bedrock_api_key(
|
||||
managed_home.path(),
|
||||
"managed-bedrock-api-key",
|
||||
"us-east-1",
|
||||
AuthCredentialsStoreMode::File,
|
||||
AuthKeyringBackendKind::default(),
|
||||
)?;
|
||||
let auth_path = managed_home.path().join("auth.json");
|
||||
let expected_auth = std::fs::read_to_string(&auth_path)?;
|
||||
let mut app_server = bedrock_app_server(
|
||||
managed_home.path(),
|
||||
&[(
|
||||
"AWS_BEARER_TOKEN_BEDROCK",
|
||||
Some("environment-bedrock-api-key"),
|
||||
)],
|
||||
)
|
||||
.await?;
|
||||
let mut expected_config: toml::Value =
|
||||
toml::from_str(&std::fs::read_to_string(&managed_config_path)?)?;
|
||||
expected_config
|
||||
.as_table_mut()
|
||||
.expect("config should be a table")
|
||||
.extend(toml::toml! {
|
||||
[model_providers.amazon-bedrock.aws]
|
||||
profile = "engineering"
|
||||
region = "us-west-2"
|
||||
});
|
||||
let response: BedrockSetupResponse = app_server
|
||||
.request(|request_id| ClientRequest::BedrockSetup {
|
||||
request_id,
|
||||
params: BedrockSetupParams::Profile {
|
||||
profile: "engineering".to_string(),
|
||||
region: "us-west-2".to_string(),
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(response, BedrockSetupResponse {});
|
||||
assert_eq!(
|
||||
toml::from_str::<toml::Value>(&std::fs::read_to_string(&managed_config_path)?)?,
|
||||
expected_config
|
||||
);
|
||||
|
||||
let request_id = app_server
|
||||
.send_raw_request(
|
||||
"account/bedrock/setup",
|
||||
Some(json!({"type": "environment", "region": "us-east-1"})),
|
||||
)
|
||||
.await?;
|
||||
let error = timeout(
|
||||
READ_TIMEOUT,
|
||||
app_server.read_stream_until_error_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
assert_eq!(
|
||||
error.error.message,
|
||||
"Codex-managed Bedrock credentials are already configured and take priority over AWS environment credentials. Run `codex logout` and try again."
|
||||
);
|
||||
assert_eq!(std::fs::read_to_string(&auth_path)?, expected_auth);
|
||||
assert_eq!(
|
||||
toml::from_str::<toml::Value>(&std::fs::read_to_string(&managed_config_path)?)?,
|
||||
expected_config
|
||||
);
|
||||
assert!(!managed_home.path().join(".env").exists());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn setup_bedrock_rejects_invalid_or_conflicting_credentials() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let mut app_server = bedrock_app_server(codex_home.path(), &[]).await?;
|
||||
|
||||
for (params, expected_error) in [
|
||||
(
|
||||
json!({"type": "profile", "profile": "engineering", "region": "us-west-1"}),
|
||||
"Amazon Bedrock does not support region `us-west-1`",
|
||||
),
|
||||
(
|
||||
json!({"type": "profile", "profile": " ", "region": "us-west-2"}),
|
||||
"AWS profile name must not be empty.",
|
||||
),
|
||||
(
|
||||
json!({"type": "profile", "profile": "missing", "region": "us-west-2"}),
|
||||
"failed to load credentials for AWS profile `missing`:",
|
||||
),
|
||||
(
|
||||
json!({"type": "environment", "region": "us-west-2"}),
|
||||
"No AWS credentials found. Please Configure AWS credentials or complete AWS sign-in, then try again.",
|
||||
),
|
||||
] {
|
||||
let request_id = app_server
|
||||
.send_raw_request("account/bedrock/setup", Some(params))
|
||||
.await?;
|
||||
let error = timeout(
|
||||
READ_TIMEOUT,
|
||||
app_server.read_stream_until_error_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
assert!(
|
||||
error.error.message.contains(expected_error),
|
||||
"expected {expected_error:?}, got {:?}",
|
||||
error.error.message
|
||||
);
|
||||
}
|
||||
assert!(!codex_home.path().join(".env").exists());
|
||||
assert!(!codex_home.path().join("config.toml").exists());
|
||||
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
"forced_login_method = \"chatgpt\"\n",
|
||||
)?;
|
||||
let mut app_server = bedrock_app_server(home.path(), &[]).await?;
|
||||
let request_id = app_server
|
||||
.send_raw_request("account/bedrock/discover", Some(json!({})))
|
||||
.await?;
|
||||
let error = timeout(
|
||||
READ_TIMEOUT,
|
||||
app_server.read_stream_until_error_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
assert_eq!(
|
||||
error.error.message,
|
||||
"Amazon Bedrock login is disabled by the configured login policy."
|
||||
);
|
||||
assert!(!home.path().join(".env").exists());
|
||||
|
||||
for source_file in ["selected.config.toml", "config.toml", "managed_config.toml"] {
|
||||
let layered_home = TempDir::new()?;
|
||||
let layered_home_path =
|
||||
AbsolutePathBuf::from_absolute_path(layered_home.path().canonicalize()?)?
|
||||
.into_path_buf();
|
||||
let config_path = layered_home_path.join("config.toml");
|
||||
let source_path = layered_home_path.join(source_file);
|
||||
let active_path = layered_home_path.join("selected.config.toml");
|
||||
let exporter_config = "[model_providers.amazon-bedrock.aws.credential_export]\n\
|
||||
command = \"secret-command\"\nargs = [\"secret-argument\"]\n";
|
||||
std::fs::write(&config_path, "")?;
|
||||
std::fs::write(&active_path, "")?;
|
||||
std::fs::write(&source_path, exporter_config)?;
|
||||
let active_config_path = active_path.to_string_lossy();
|
||||
let mut app_server = bedrock_app_server(
|
||||
&layered_home_path,
|
||||
&[(
|
||||
"CODEX_APP_SERVER_TEST_USER_CONFIG_FILE",
|
||||
Some(active_config_path.as_ref()),
|
||||
)],
|
||||
)
|
||||
.await?;
|
||||
let expected_config = std::fs::read_to_string(&config_path)?;
|
||||
let expected_active = std::fs::read_to_string(&active_path)?;
|
||||
let expected_error = "Amazon Bedrock is configured to use `aws.credential_export`. Please clear this setting to use another sign-in method.";
|
||||
|
||||
for (method, params) in [
|
||||
(
|
||||
"account/bedrock/setup",
|
||||
json!({"type": "profile", "profile": "engineering", "region": "us-west-2"}),
|
||||
),
|
||||
(
|
||||
"account/bedrock/setup",
|
||||
json!({"type": "environment", "region": "us-west-2"}),
|
||||
),
|
||||
(
|
||||
"account/login/start",
|
||||
json!({"type": "amazonBedrock", "apiKey": "new-key", "region": "us-west-2"}),
|
||||
),
|
||||
(
|
||||
"account/login/start",
|
||||
json!({"type": "amazonBedrockAccessKeys", "accessKeyId": "new-id", "secretAccessKey": "new-secret", "region": "us-west-2"}),
|
||||
),
|
||||
] {
|
||||
let request_id = app_server.send_raw_request(method, Some(params)).await?;
|
||||
let error = timeout(
|
||||
READ_TIMEOUT,
|
||||
app_server.read_stream_until_error_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
assert_eq!(error.error.message, expected_error);
|
||||
}
|
||||
assert_eq!(std::fs::read_to_string(&config_path)?, expected_config);
|
||||
assert_eq!(std::fs::read_to_string(&source_path)?, exporter_config);
|
||||
assert_eq!(std::fs::read_to_string(&active_path)?, expected_active);
|
||||
assert!(!layered_home.path().join("auth.json").exists());
|
||||
assert!(!layered_home.path().join(".env").exists());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -306,9 +306,14 @@ async fn auto_compaction_emits_started_and_completed_items(route: CompactionRout
|
||||
let codex_home = TempDir::new()?;
|
||||
let mut config = compaction_config(&server.uri(), /*auto_compact_limit*/ 200_000);
|
||||
if let CompactionRoute::Remote = route {
|
||||
// aKode: remote compaction is an explicit provider capability, not implied by
|
||||
// the provider name "OpenAI".
|
||||
config = config
|
||||
.with_provider_name("OpenAI")
|
||||
.with_provider_config("requires_openai_auth = true");
|
||||
.with_provider_config("requires_openai_auth = true")
|
||||
.with_provider_config(
|
||||
"capabilities = { hosted_web_search = true, remote_compaction = \"v2\" }",
|
||||
);
|
||||
write_api_key_auth(codex_home.path())?;
|
||||
}
|
||||
config.write(codex_home.path())?;
|
||||
|
||||
@@ -29,9 +29,11 @@ base_url = "https://gateway.example.test/v1"
|
||||
requires_openai_auth = true
|
||||
"#;
|
||||
std::fs::write(home.path().join("requirements.toml"), requirements)?;
|
||||
// aKode: an explicit catalog keeps thread/start offline (no default bundled catalog).
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
r#"
|
||||
format!(
|
||||
r#"{}
|
||||
model_provider = "openai"
|
||||
[model_providers.gateway]
|
||||
name = "Local override"
|
||||
@@ -40,6 +42,8 @@ env_key = "LOCAL_KEY"
|
||||
[model_providers.gateway.http_headers]
|
||||
X-Local = "no"
|
||||
"#,
|
||||
app_test_support::bundled_model_catalog_config(home.path())?
|
||||
),
|
||||
)?;
|
||||
let expected: ConfigToml = toml::from_str(requirements)?;
|
||||
let expected_providers = json!(expected.model_providers);
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
use anyhow::Result;
|
||||
use app_test_support::TestAppServer;
|
||||
use codex_app_server_protocol::Account;
|
||||
use codex_app_server_protocol::GetAccountParams;
|
||||
use codex_app_server_protocol::GetAccountResponse;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_protocol::config_types::ForcedLoginMethod;
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -14,7 +11,6 @@ use std::time::Duration;
|
||||
use tempfile::TempDir;
|
||||
use test_case::test_case;
|
||||
use tokio::time::timeout;
|
||||
use wiremock::MockServer;
|
||||
|
||||
const READ_TIMEOUT: Duration = Duration::from_secs(/*secs*/ 60);
|
||||
|
||||
@@ -116,48 +112,3 @@ async fn config_requirements_read_rejects_invalid_login_method() -> Result<()> {
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn config_requirements_read_preserves_api_only_bedrock_without_chatgpt_requests() -> Result<()>
|
||||
{
|
||||
let backend = MockServer::start().await;
|
||||
let (_home, mut server) = start_server(
|
||||
&format!(
|
||||
r#"
|
||||
forced_login_method = "api"
|
||||
chatgpt_base_url = "{}/backend-api"
|
||||
model_provider = "amazon-bedrock"
|
||||
[model_providers.amazon-bedrock]
|
||||
base_url = "https://bedrock.example.com/v1"
|
||||
[model_providers.amazon-bedrock.auth]
|
||||
command = "print-token"
|
||||
"#,
|
||||
backend.uri()
|
||||
),
|
||||
/*requirements*/ None,
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(
|
||||
read_requirements(&mut server).await?["requirements"]["allowedLoginMethods"],
|
||||
json!(["api"])
|
||||
);
|
||||
let id = server.send_get_account_request(GetAccountParams {}).await?;
|
||||
let account: GetAccountResponse = timeout(READ_TIMEOUT, server.read_response(id)).await??;
|
||||
assert_eq!(
|
||||
account,
|
||||
GetAccountResponse {
|
||||
account: Some(Account::AmazonBedrock {
|
||||
uses_codex_managed_credentials: false
|
||||
}),
|
||||
requires_openai_auth: false,
|
||||
}
|
||||
);
|
||||
assert!(
|
||||
backend
|
||||
.received_requests()
|
||||
.await
|
||||
.expect("recorded requests")
|
||||
.is_empty()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -74,9 +74,13 @@ async fn selected_environment_emits_connection_lifecycle_notifications() -> Resu
|
||||
let exec_server_url = format!("ws://{}", listener.local_addr()?);
|
||||
|
||||
let codex_home = TempDir::new()?;
|
||||
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
"[features]\ndeferred_executor = true\n",
|
||||
format!(
|
||||
"{}[features]\ndeferred_executor = true\n",
|
||||
app_test_support::bundled_model_catalog_config(codex_home.path())?
|
||||
),
|
||||
)?;
|
||||
let mut app_server = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
|
||||
@@ -118,7 +118,7 @@ model = "mock-model"
|
||||
approval_policy = "{approval_policy}"
|
||||
{sandbox_config}
|
||||
model_provider = "mock_provider"
|
||||
|
||||
{catalog}
|
||||
[skills]
|
||||
include_instructions = true
|
||||
|
||||
@@ -128,10 +128,13 @@ base_url = "{}/v1"
|
||||
wire_api = "responses"
|
||||
request_max_retries = 0
|
||||
stream_max_retries = 0
|
||||
merge_system_messages = false
|
||||
{permission_profile}
|
||||
{requested_permission_feature}
|
||||
"#,
|
||||
server.uri()
|
||||
server.uri(),
|
||||
// aKode: explicit catalog (no bundled default) and upstream message layout.
|
||||
catalog = app_test_support::bundled_model_catalog_config(codex_home.path())?
|
||||
),
|
||||
)?;
|
||||
let local_skill_dir = codex_home.path().join("skills/local-deploy");
|
||||
|
||||
@@ -155,6 +155,9 @@ async fn experimental_feature_list_resolves_thread_project_config() -> Result<()
|
||||
.write(codex_home.path())?;
|
||||
#[cfg(unix)]
|
||||
let config_toml = std::fs::read(codex_home.path().join("config.toml"))?;
|
||||
// aKode: config.toml references the harness's explicit model catalog file.
|
||||
#[cfg(unix)]
|
||||
let model_catalog = std::fs::read(codex_home.path().join("test-models.json"))?;
|
||||
let project_config_dir = workspace.path().join(".codex");
|
||||
std::fs::create_dir_all(&project_config_dir)?;
|
||||
std::fs::write(
|
||||
@@ -182,6 +185,7 @@ memories = true
|
||||
std::fs::rename(codex_home.path(), &deleted_launch_dir)?;
|
||||
std::fs::create_dir(codex_home.path())?;
|
||||
std::fs::write(codex_home.path().join("config.toml"), config_toml)?;
|
||||
std::fs::write(codex_home.path().join("test-models.json"), model_catalog)?;
|
||||
std::fs::create_dir(&launch_project_config_dir)?;
|
||||
std::fs::copy(
|
||||
project_config_dir.join("config.toml"),
|
||||
|
||||
@@ -55,6 +55,12 @@ struct ImportFixture {
|
||||
impl ImportFixture {
|
||||
async fn new() -> Result<Self> {
|
||||
let codex_home = TempDir::new()?;
|
||||
// aKode: there is no bundled catalog, so threads need an explicit one. No provider is
|
||||
// configured on purpose: imported sessions must stay appendable without one.
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
app_test_support::bundled_model_catalog_config(codex_home.path())?,
|
||||
)?;
|
||||
let project_root = codex_home.path().join("repo");
|
||||
std::fs::create_dir_all(&project_root)?;
|
||||
let session_path = codex_home
|
||||
|
||||
@@ -209,10 +209,15 @@ async fn model_list_leaves_oauth_gateway_after_account_change() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(home.path().join("config.toml"), gateway_config(&oauth))?;
|
||||
let mut server = gateway_server(home.path()).await?;
|
||||
std::fs::write(home.path().join("config.toml"), "")?;
|
||||
// aKode: there is no built-in `openai` provider or bundled catalog; route to a plain
|
||||
// provider with an explicit catalog instead.
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
app_test_support::bundled_model_catalog_config(home.path())?,
|
||||
)?;
|
||||
std::fs::write(
|
||||
home.path().join("requirements.toml"),
|
||||
"model_provider = 'openai'",
|
||||
"model_provider = 'plain'\n[model_providers.plain]\nname = 'Plain'\nbase_url = 'http://127.0.0.1:9/v1'\n",
|
||||
)?;
|
||||
let id = server
|
||||
.send_login_account_api_key_request("sk-catalog-test")
|
||||
@@ -629,9 +634,15 @@ async fn initialization_selects_legacy_or_explicit_gateway_login() -> Result<()>
|
||||
// Force automatic authorization to fail before launching a real browser.
|
||||
let callback = std::net::TcpListener::bind("127.0.0.1:0")?;
|
||||
let port = callback.local_addr()?.port();
|
||||
// aKode: an explicit catalog keeps the gateway's `/models` listing (and the OAuth
|
||||
// mock) out of thread startup; there is no bundled default catalog anymore.
|
||||
let catalog = app_test_support::bundled_model_catalog_config(home.path())?;
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!("{}\nredirect_port = {port}\n", gateway_config(&oauth)),
|
||||
format!(
|
||||
"{catalog}{}\nredirect_port = {port}\n",
|
||||
gateway_config(&oauth)
|
||||
),
|
||||
)?;
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
@@ -653,8 +664,11 @@ async fn initialization_selects_legacy_or_explicit_gateway_login() -> Result<()>
|
||||
.await?;
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!("{}\nredirect_port = {port}\n", gateway_config(&oauth))
|
||||
.replace("app-server-explicit-test", "gateway-after-initialize"),
|
||||
format!(
|
||||
"{catalog}{}\nredirect_port = {port}\n",
|
||||
gateway_config(&oauth)
|
||||
)
|
||||
.replace("app-server-explicit-test", "gateway-after-initialize"),
|
||||
)?;
|
||||
let thread = server
|
||||
.send_thread_start_request_with_auto_env(ThreadStartParams::default())
|
||||
@@ -692,15 +706,18 @@ async fn initialization_selects_legacy_or_explicit_gateway_login() -> Result<()>
|
||||
async fn selected_gateway_read_notifies_matching_providers() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
let oauth = MockServer::start().await;
|
||||
let config = gateway_config(&oauth).replace(
|
||||
"model_provider = \"gateway\"",
|
||||
"model_provider = \"openai\"",
|
||||
);
|
||||
// aKode: the non-gateway default is a plain custom provider (no built-in `openai`)
|
||||
// with an explicit catalog.
|
||||
let config = gateway_config(&oauth)
|
||||
.replace("model_provider = \"gateway\"", "model_provider = \"plain\"");
|
||||
let alias = config[config.find("[model_providers.gateway]").unwrap()..]
|
||||
.replace("model_providers.gateway", "model_providers.alias");
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!("{config}\n{alias}"),
|
||||
format!(
|
||||
"{}{config}\n{alias}\n[model_providers.plain]\nname = \"Plain\"\nbase_url = \"http://127.0.0.1:9/v1\"\n",
|
||||
app_test_support::bundled_model_catalog_config(home.path())?
|
||||
),
|
||||
)?;
|
||||
let mut server = gateway_server(home.path()).await?;
|
||||
assert!(!read_gateway(&mut server).await?.required);
|
||||
|
||||
@@ -1,357 +0,0 @@
|
||||
//! GCP setup validates before saving and shares provider configuration with subsequent requests.
|
||||
|
||||
use anyhow::Context;
|
||||
use anyhow::Result;
|
||||
use app_test_support::TestAppServer;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::GcpSetupParams;
|
||||
use codex_app_server_protocol::GcpSetupResponse;
|
||||
use codex_app_server_protocol::JSONRPCErrorError;
|
||||
use codex_app_server_protocol::ModelListParams;
|
||||
use codex_app_server_protocol::ModelListResponse;
|
||||
use codex_app_server_protocol::RequestId;
|
||||
use codex_app_server_protocol::ThreadStartParams;
|
||||
use codex_protocol::openai_models::ModelVisibility;
|
||||
use pretty_assertions::assert_eq;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
use tempfile::TempDir;
|
||||
use tokio::time::timeout;
|
||||
|
||||
const CLEARED_AUTH_ENV: &[(&str, Option<&str>)] = &[
|
||||
("OPENAI_API_KEY", None),
|
||||
("CODEX_API_KEY", None),
|
||||
("OPENAI_FEDERATION_RULE_ID", None),
|
||||
("OPENAI_IDENTITY_TOKEN_FILE", None),
|
||||
("OPENAI_WORKLOAD_IDENTITY_CONTEXT", None),
|
||||
];
|
||||
|
||||
const READ_TIMEOUT: Duration = Duration::from_secs(/*secs*/ 60);
|
||||
|
||||
fn write_fake_gcloud(home: &Path) -> Result<PathBuf> {
|
||||
#[cfg(unix)]
|
||||
let script = home.join("gcloud");
|
||||
#[cfg(unix)]
|
||||
codex_utils_cargo_bin::write_executable(
|
||||
&script,
|
||||
r#"#!/bin/sh
|
||||
if [ -f fail ]; then exit 1; fi
|
||||
printf '%s\n' "$GOOGLE_APPLICATION_CREDENTIALS" >> credential-log
|
||||
printf '%s\n' setup-token
|
||||
"#,
|
||||
)?;
|
||||
#[cfg(windows)]
|
||||
let script = home.join("gcloud.cmd");
|
||||
#[cfg(windows)]
|
||||
std::fs::write(
|
||||
&script,
|
||||
"@echo off\r\nif exist fail exit /b 1\r\nsetlocal EnableDelayedExpansion\r\necho(!GOOGLE_APPLICATION_CREDENTIALS!>>credential-log\r\nendlocal\r\necho setup-token\r\n",
|
||||
)?;
|
||||
Ok(script)
|
||||
}
|
||||
|
||||
async fn gcp_app_server(
|
||||
home: &Path,
|
||||
env_overrides: &[(&str, Option<&str>)],
|
||||
) -> Result<TestAppServer> {
|
||||
let existing_path = std::env::var_os("PATH").unwrap_or_default();
|
||||
let child_path = std::env::join_paths(
|
||||
std::iter::once(home.to_path_buf()).chain(std::env::split_paths(&existing_path)),
|
||||
)?;
|
||||
TestAppServer::builder()
|
||||
.with_codex_home(home)
|
||||
.with_env_overrides(&[
|
||||
(
|
||||
"PATH",
|
||||
Some(child_path.to_str().context("child PATH must be UTF-8")?),
|
||||
),
|
||||
("GOOGLE_APPLICATION_CREDENTIALS", None),
|
||||
("GOOGLE_CLOUD_PROJECT", Some("ambient-project")),
|
||||
("GOOGLE_CLOUD_LOCATION", Some("ambient-location")),
|
||||
])
|
||||
.with_env_overrides(CLEARED_AUTH_ENV)
|
||||
.with_env_overrides(env_overrides)
|
||||
.build_initialized_with_timeout(READ_TIMEOUT)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn setup_error(app_server: &mut TestAppServer, params: Value) -> Result<JSONRPCErrorError> {
|
||||
let id = app_server
|
||||
.send_raw_request("account/gcp/setup", Some(params))
|
||||
.await?;
|
||||
let error = timeout(
|
||||
READ_TIMEOUT,
|
||||
app_server.read_stream_until_error_message(RequestId::Integer(id)),
|
||||
)
|
||||
.await??;
|
||||
assert_eq!(error.error.code, -32600);
|
||||
Ok(error.error)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn setup_gcp_saves_overrides_restores_adc_and_refreshes_catalog() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
let home = home.path();
|
||||
write_fake_gcloud(home)?;
|
||||
let mut catalog = codex_models_manager::bundled_models_response()?;
|
||||
catalog.models.retain(|model| model.slug == "gpt-6.1-sol");
|
||||
let model = catalog
|
||||
.models
|
||||
.first_mut()
|
||||
.context("bundled catalog must include a supported Vertex model")?;
|
||||
model.visibility = ModelVisibility::List;
|
||||
model.supported_in_api = true;
|
||||
let mut unsupported_model = model.clone();
|
||||
unsupported_model.slug = "test-non-vertex-model".to_string();
|
||||
// Make the startup catalog's default distinguishable from the GCP default.
|
||||
unsupported_model.priority = model.priority - 1;
|
||||
catalog.models.push(unsupported_model);
|
||||
let catalog_path = home.join("models.json");
|
||||
std::fs::write(&catalog_path, serde_json::to_vec(&catalog)?)?;
|
||||
let config_path = home.join("config.toml");
|
||||
let mut expected_config = json!({
|
||||
"model_catalog_json": catalog_path,
|
||||
"model_providers": {"gcp": {"http_headers": {"X-Existing": "preserved"}}}
|
||||
});
|
||||
std::fs::write(&config_path, toml::to_string(&expected_config)?)?;
|
||||
let selected = home.join("selected.json");
|
||||
let ambient = home.join("ambient.json");
|
||||
for file in [&selected, &ambient] {
|
||||
std::fs::write(file, r#"{"type":"external_account"}"#)?;
|
||||
}
|
||||
let mut app_server = gcp_app_server(
|
||||
home,
|
||||
&[(
|
||||
"GOOGLE_APPLICATION_CREDENTIALS",
|
||||
Some(ambient.to_str().context("non-UTF-8 ADC path")?),
|
||||
)],
|
||||
)
|
||||
.await?;
|
||||
let before: ModelListResponse = app_server
|
||||
.request(|request_id| ClientRequest::ModelList {
|
||||
request_id,
|
||||
params: ModelListParams::default(),
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(before.data.len(), 2);
|
||||
|
||||
let _: GcpSetupResponse = app_server
|
||||
.request(|request_id| ClientRequest::GcpSetup {
|
||||
request_id,
|
||||
params: GcpSetupParams {
|
||||
project_id: " selected-project ".to_string(),
|
||||
location: Some(" us-central1 ".to_string()),
|
||||
credential_file: Some(selected.to_string_lossy().into_owned()),
|
||||
},
|
||||
})
|
||||
.await?;
|
||||
expected_config["model_provider"] = json!("gcp");
|
||||
expected_config["model_providers"]["gcp"]["project_id"] = json!("selected-project");
|
||||
expected_config["model_providers"]["gcp"]["location"] = json!("us-central1");
|
||||
expected_config["model_providers"]["gcp"]["credential_file"] = json!(selected);
|
||||
assert_eq!(
|
||||
toml::from_str::<Value>(&std::fs::read_to_string(&config_path)?)?,
|
||||
expected_config
|
||||
);
|
||||
|
||||
let after: ModelListResponse = app_server
|
||||
.request(|request_id| ClientRequest::ModelList {
|
||||
request_id,
|
||||
params: ModelListParams::default(),
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(after.data.len(), 1);
|
||||
assert_eq!(after.data[0].model, "gpt-6.1-sol");
|
||||
|
||||
// A managed GCP selection takes precedence without replacing the user's preference.
|
||||
expected_config["model_provider"] = json!("openai");
|
||||
std::fs::write(&config_path, toml::to_string(&expected_config)?)?;
|
||||
std::fs::write(home.join("requirements.toml"), "model_provider = 'gcp'")?;
|
||||
let request_id = app_server
|
||||
.send_raw_request(
|
||||
"account/gcp/setup",
|
||||
Some(json!({"projectId": "other-project"})),
|
||||
)
|
||||
.await?;
|
||||
let _: GcpSetupResponse = app_server.read_response(request_id).await?;
|
||||
expected_config["model_providers"]["gcp"]["project_id"] = json!("other-project");
|
||||
expected_config["model_providers"]["gcp"]["location"] = json!("global");
|
||||
expected_config["model_providers"]["gcp"]
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("credential_file");
|
||||
assert_eq!(
|
||||
toml::from_str::<Value>(&std::fs::read_to_string(&config_path)?)?,
|
||||
expected_config
|
||||
);
|
||||
assert_eq!(
|
||||
std::fs::read_to_string(home.join("credential-log"))?
|
||||
.lines()
|
||||
.map(Path::new)
|
||||
.collect::<Vec<_>>(),
|
||||
[selected.as_path(), ambient.as_path()]
|
||||
);
|
||||
let thread = app_server
|
||||
.start_thread(ThreadStartParams::default())
|
||||
.await?;
|
||||
assert_eq!(thread.model, after.data[0].model);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn setup_gcp_rejects_invalid_inputs_and_credentials_before_saving() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
let home = home.path();
|
||||
let config_path = home.join("config.toml");
|
||||
std::fs::write(&config_path, "")?;
|
||||
let invalid = home.join("invalid.json");
|
||||
std::fs::write(&invalid, r#"["authorized_user"]"#)?;
|
||||
let mut server = gcp_app_server(
|
||||
home,
|
||||
&[("PATH", Some(home.to_str().context("non-UTF-8 PATH")?))],
|
||||
)
|
||||
.await?;
|
||||
let params = json!({"projectId": "project"});
|
||||
for (request, reason) in [
|
||||
(json!({"projectId": " "}), None),
|
||||
(params.clone(), Some("gcloudNotInstalled")),
|
||||
(
|
||||
json!({"projectId": "project", "credentialFile": invalid}),
|
||||
Some("credentialFileInvalid"),
|
||||
),
|
||||
] {
|
||||
let error = setup_error(&mut server, request).await?;
|
||||
assert_eq!(error.data, reason.map(|reason| json!({ "reason": reason })));
|
||||
}
|
||||
|
||||
write_fake_gcloud(home)?;
|
||||
std::fs::write(home.join("fail"), "")?;
|
||||
let error = setup_error(&mut server, params).await?;
|
||||
assert_eq!(error.data, Some(json!({"reason": "authCommandFailed"})));
|
||||
assert_eq!(std::fs::read_to_string(config_path)?, "");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn setup_gcp_validates_the_auth_override_relative_to_the_startup_directory() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
let startup = TempDir::new()?;
|
||||
let script = write_fake_gcloud(home.path())?;
|
||||
let auth = toml::Value::try_from(json!({"command": script, "cwd": "."}))?;
|
||||
let config_path = home.path().join("config.toml");
|
||||
std::fs::write(&config_path, "")?;
|
||||
// The same command succeeds in CODEX_HOME but fails in the catalog's startup context.
|
||||
std::fs::write(startup.path().join("fail"), "")?;
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_codex_home(startup.path())
|
||||
.with_env_overrides(CLEARED_AUTH_ENV)
|
||||
.with_env_overrides(&[(
|
||||
"CODEX_HOME",
|
||||
Some(home.path().to_str().context("non-UTF-8 CODEX_HOME")?),
|
||||
)])
|
||||
.with_args(&["-c", &format!("model_providers.gcp.auth={auth}")])
|
||||
.build_initialized_with_timeout(READ_TIMEOUT)
|
||||
.await?;
|
||||
|
||||
let error = setup_error(&mut server, json!({"projectId": "project"})).await?;
|
||||
assert_eq!(error.data, Some(json!({"reason": "authCommandFailed"})));
|
||||
assert_eq!(std::fs::read_to_string(config_path)?, "");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn setup_gcp_rejects_policy_and_endpoint_conflicts_before_saving() -> Result<()> {
|
||||
for (file, policy, expected_message) in [
|
||||
(
|
||||
"managed_config.toml",
|
||||
"forced_login_method = 'chatgpt'",
|
||||
"Google Cloud setup is disabled by the configured login policy.",
|
||||
),
|
||||
(
|
||||
"managed_config.toml",
|
||||
"[model_providers.gcp]\nproject_id = 'managed-project'",
|
||||
"Cannot configure `model_providers.gcp.project_id`: Overridden by legacy managed_config.toml",
|
||||
),
|
||||
(
|
||||
"managed_config.toml",
|
||||
"[model_providers.gcp]\nbase_url = 'https://vertex.example.com/v1'",
|
||||
"Google Cloud has a custom `base_url`",
|
||||
),
|
||||
(
|
||||
"requirements.toml",
|
||||
"model_provider = 'openai'",
|
||||
"requirements set `model_provider` to `openai`",
|
||||
),
|
||||
(
|
||||
"requirements.toml",
|
||||
"[application.network.domains]\n'oauth2.googleapis.com' = 'allow'",
|
||||
"disabled by application network restrictions",
|
||||
),
|
||||
] {
|
||||
let home = TempDir::new()?;
|
||||
let home = home.path();
|
||||
write_fake_gcloud(home)?;
|
||||
std::fs::write(home.join(file), policy)?;
|
||||
let config_path = home.join("config.toml");
|
||||
std::fs::write(&config_path, "")?;
|
||||
let mut app_server = gcp_app_server(home, &[]).await?;
|
||||
let error = setup_error(
|
||||
&mut app_server,
|
||||
json!({"projectId": "project", "credentialFile": home.join("missing.json")}),
|
||||
)
|
||||
.await?;
|
||||
assert!(
|
||||
error.message.contains(expected_message),
|
||||
"expected {expected_message:?}, got {:?}",
|
||||
error.message
|
||||
);
|
||||
assert_eq!(std::fs::read_to_string(config_path)?, "");
|
||||
assert!(!home.join("credential-log").exists());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[tokio::test]
|
||||
async fn setup_gcp_stops_the_credential_command_when_network_permission_is_revoked() -> Result<()> {
|
||||
use core_test_support::process::wait_for_pid_file;
|
||||
use core_test_support::process::wait_for_process_exit;
|
||||
|
||||
let home = TempDir::new()?;
|
||||
let config_path = home.path().join("config.toml");
|
||||
let initial_config = r#"
|
||||
[model_providers.gcp.auth]
|
||||
command = "sh"
|
||||
args = ["-c", "echo $$ > refresh.pid; exec sleep 120"]
|
||||
timeout_ms = 120000
|
||||
"#;
|
||||
std::fs::write(&config_path, initial_config)?;
|
||||
let mut app_server = gcp_app_server(home.path(), &[]).await?;
|
||||
let request_id = app_server
|
||||
.send_raw_request("account/gcp/setup", Some(json!({"projectId": "project"})))
|
||||
.await?;
|
||||
let pid = wait_for_pid_file(&home.path().join("refresh.pid")).await?;
|
||||
|
||||
std::fs::write(
|
||||
home.path().join("requirements.toml"),
|
||||
"[application.network]",
|
||||
)?;
|
||||
app_server
|
||||
.send_raw_request("config/read", Some(json!({})))
|
||||
.await?;
|
||||
let error = timeout(
|
||||
READ_TIMEOUT,
|
||||
app_server.read_stream_until_error_message(RequestId::Integer(request_id)),
|
||||
)
|
||||
.await??;
|
||||
assert_eq!(
|
||||
error.error.message,
|
||||
"application network permission was revoked"
|
||||
);
|
||||
wait_for_process_exit(&pid).await?;
|
||||
assert_eq!(std::fs::read_to_string(config_path)?, initial_config);
|
||||
Ok(())
|
||||
}
|
||||
@@ -260,9 +260,12 @@ async fn managed_reviewer_refreshes_global_instructions_before_reuse() -> Result
|
||||
.iter()
|
||||
.find(|replayed| replayed["content"] == item["content"])
|
||||
.expect("previous Guardian reply is replayed");
|
||||
// aKode: internal metadata passthrough is stripped from model requests unless
|
||||
// the provider holds the runtime-only `include_internal_metadata` grant.
|
||||
assert!(item["internal_chat_message_metadata_passthrough"].is_object());
|
||||
assert_eq!(
|
||||
replayed["internal_chat_message_metadata_passthrough"],
|
||||
item["internal_chat_message_metadata_passthrough"],
|
||||
replayed.get("internal_chat_message_metadata_passthrough"),
|
||||
None
|
||||
);
|
||||
}
|
||||
// Private reviewer events arrive on the parent's subscription with the
|
||||
|
||||
@@ -217,7 +217,7 @@ approval_policy = "on-request"
|
||||
approvals_reviewer = "auto_review"
|
||||
sandbox_mode = "read-only"
|
||||
cli_auth_credentials_store = "file"
|
||||
openai_base_url = "{responses_url}/backend-api/codex"
|
||||
model_provider = "openai"
|
||||
chatgpt_base_url = "{responses_url}/backend-api"
|
||||
|
||||
[features]
|
||||
@@ -233,6 +233,17 @@ enabled = true
|
||||
|
||||
[features.guardianv2.review_scope]
|
||||
computer_use_only = false
|
||||
|
||||
# aKode: `openai_base_url` no longer configures a built-in provider; declare the
|
||||
# equivalent of the removed built-in `openai` provider explicitly.
|
||||
[model_providers.openai]
|
||||
name = "OpenAI"
|
||||
base_url = "{responses_url}/backend-api/codex"
|
||||
wire_api = "responses"
|
||||
requires_openai_auth = true
|
||||
supports_websockets = true
|
||||
merge_system_messages = false
|
||||
capabilities = {{ hosted_web_search = true, remote_compaction = "v2" }}
|
||||
"#
|
||||
),
|
||||
)?;
|
||||
|
||||
@@ -105,15 +105,19 @@ fn write_plugin_hook_config(codex_home: &std::path::Path, hooks_json: &str) -> R
|
||||
r#"{"name":"demo"}"#,
|
||||
)?;
|
||||
std::fs::write(plugin_root.join("hooks/hooks.json"), hooks_json)?;
|
||||
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
|
||||
std::fs::write(
|
||||
codex_home.join("config.toml"),
|
||||
r#"[features]
|
||||
format!(
|
||||
r#"{}[features]
|
||||
plugins = true
|
||||
hooks = true
|
||||
|
||||
[plugins."demo@test"]
|
||||
enabled = true
|
||||
"#,
|
||||
app_test_support::bundled_model_catalog_config(codex_home)?
|
||||
),
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ model = "mock-model"
|
||||
approval_policy = "never"
|
||||
sandbox_mode = "read-only"
|
||||
model_provider = "mock_provider"
|
||||
|
||||
{catalog}
|
||||
[skills]
|
||||
include_instructions = true
|
||||
|
||||
@@ -75,8 +75,11 @@ base_url = "{}/v1"
|
||||
wire_api = "responses"
|
||||
request_max_retries = 0
|
||||
stream_max_retries = 0
|
||||
merge_system_messages = false
|
||||
"#,
|
||||
server.uri()
|
||||
server.uri(),
|
||||
// aKode: explicit catalog (no bundled default) and upstream message layout.
|
||||
catalog = app_test_support::bundled_model_catalog_config(codex_home.path())?
|
||||
),
|
||||
)?;
|
||||
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
mod account;
|
||||
|
||||
mod account_gcp;
|
||||
mod agent_message_board;
|
||||
mod application_network;
|
||||
#[path = "attached_thread_tests.rs"]
|
||||
mod attached_thread;
|
||||
mod auto_env;
|
||||
#[path = "bedrock_gov_cloud_tests.rs"]
|
||||
mod bedrock_gov_cloud;
|
||||
#[path = "bedrock_service_tier_tests.rs"]
|
||||
mod bedrock_service_tier;
|
||||
mod bedrock_setup;
|
||||
mod client_metadata;
|
||||
mod code_mode_host;
|
||||
mod collaboration_mode_list;
|
||||
@@ -58,8 +52,6 @@ mod feedback;
|
||||
mod fs;
|
||||
#[path = "gateway_oauth_tests.rs"]
|
||||
mod gateway_oauth;
|
||||
#[path = "gcp_setup_tests.rs"]
|
||||
mod gcp_setup;
|
||||
mod guardian_v2;
|
||||
mod hooks_list;
|
||||
mod host_skills;
|
||||
|
||||
@@ -3,7 +3,6 @@ use std::time::Duration;
|
||||
use anyhow::Error;
|
||||
use anyhow::Result;
|
||||
use app_test_support::TestAppServer;
|
||||
use app_test_support::write_models_cache;
|
||||
use codex_app_server_protocol::ClientRequest;
|
||||
use codex_app_server_protocol::ExperimentalFeatureEnablementSetParams;
|
||||
use codex_app_server_protocol::ExperimentalFeatureEnablementSetResponse;
|
||||
@@ -165,7 +164,9 @@ requires_openai_auth = true
|
||||
// prevents bundled models from being advertised for this provider.
|
||||
&[]
|
||||
} else {
|
||||
&bundled
|
||||
// aKode: without `model_catalog_url` the provider's OpenAI-format `GET /models`
|
||||
// listing is the source (no bundled catalog); this codex-format body lists nothing.
|
||||
&[]
|
||||
};
|
||||
assert_eq!(
|
||||
response,
|
||||
@@ -174,8 +175,20 @@ requires_openai_auth = true
|
||||
next_cursor: None,
|
||||
}
|
||||
);
|
||||
let _ = bundled;
|
||||
if !catalog_opt_in {
|
||||
// aKode: providers without a catalog URL list their models from `GET /models`.
|
||||
assert!(
|
||||
server
|
||||
.received_requests()
|
||||
.await
|
||||
.expect("request recording is enabled")
|
||||
.iter()
|
||||
.any(|request| request.url.path() == "/v1/models")
|
||||
);
|
||||
}
|
||||
// Only startup opt-outs prevent fetches before the app sends its enablement.
|
||||
if user_enablement == Some(false) || !catalog_opt_in {
|
||||
if user_enablement == Some(false) {
|
||||
assert!(
|
||||
server
|
||||
.received_requests()
|
||||
@@ -235,6 +248,15 @@ fn model_from_preset(preset: &ModelPreset) -> Model {
|
||||
}
|
||||
}
|
||||
|
||||
/// aKode: providers without `model_catalog_url` no longer fall back to the bundled
|
||||
/// catalog (or read `models_cache.json`), so the listing tests configure it explicitly.
|
||||
fn write_bundled_model_catalog_config(codex_home: &std::path::Path) -> std::io::Result<()> {
|
||||
std::fs::write(
|
||||
codex_home.join("config.toml"),
|
||||
app_test_support::bundled_model_catalog_config(codex_home)?,
|
||||
)
|
||||
}
|
||||
|
||||
fn expected_visible_models() -> Vec<Model> {
|
||||
// Filter by supported_in_api to support testing with both ChatGPT and non-ChatGPT auth modes.
|
||||
let mut presets = ModelPreset::filter_by_auth(
|
||||
@@ -255,7 +277,7 @@ fn expected_visible_models() -> Vec<Model> {
|
||||
#[tokio::test]
|
||||
async fn list_models_returns_all_models_with_large_limit() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
write_models_cache(codex_home.path()).await?;
|
||||
write_bundled_model_catalog_config(codex_home.path())?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.without_auto_env()
|
||||
@@ -286,7 +308,7 @@ async fn list_models_returns_all_models_with_large_limit() -> Result<()> {
|
||||
#[tokio::test]
|
||||
async fn list_models_includes_hidden_models() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
write_models_cache(codex_home.path()).await?;
|
||||
write_bundled_model_catalog_config(codex_home.path())?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.without_auto_env()
|
||||
@@ -471,7 +493,7 @@ model_catalog_url = "{server_uri}/v1/models"
|
||||
#[tokio::test]
|
||||
async fn list_models_pagination_works() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
write_models_cache(codex_home.path()).await?;
|
||||
write_bundled_model_catalog_config(codex_home.path())?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.without_auto_env()
|
||||
@@ -518,7 +540,7 @@ async fn list_models_pagination_works() -> Result<()> {
|
||||
#[tokio::test]
|
||||
async fn list_models_rejects_invalid_cursor() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
write_models_cache(codex_home.path()).await?;
|
||||
write_bundled_model_catalog_config(codex_home.path())?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.without_auto_env()
|
||||
|
||||
@@ -51,32 +51,6 @@ async fn list_models(server: &mut TestAppServer) -> Result<ModelListResponse> {
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn model_list_accepts_unchanged_gcp_requirements() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(home.path().join("config.toml"), "")?;
|
||||
std::fs::write(
|
||||
home.path().join("requirements.toml"),
|
||||
r#"
|
||||
model_provider = "gcp"
|
||||
[model_providers.gcp]
|
||||
project_id = "managed-project"
|
||||
location = "us-central1"
|
||||
"#,
|
||||
)?;
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_mock_chatgpt_backend()
|
||||
.with_codex_home(home.path())
|
||||
.with_env_overrides(&[("OPENAI_API_KEY", None)])
|
||||
.build_initialized()
|
||||
.await?;
|
||||
|
||||
let initial = list_models(&mut server).await?;
|
||||
assert!(!initial.data.is_empty());
|
||||
assert_eq!(list_models(&mut server).await?, initial);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn sign_in(server: &mut TestAppServer) -> Result<()> {
|
||||
let id = server
|
||||
.send_login_account_api_key_request("sk-catalog-test")
|
||||
@@ -378,8 +352,20 @@ async fn model_list_reuses_catalog_until_account_change() -> Result<()> {
|
||||
async fn model_list_preserves_invalid_startup_config_fallback() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(home.path().join("config.toml"), "model = [")?;
|
||||
// aKode: there is no bundled default catalog; supply one through a CLI override,
|
||||
// which the invalid-config fallback still honors.
|
||||
let catalog_path = home.path().join("bundled-models.json");
|
||||
std::fs::write(
|
||||
&catalog_path,
|
||||
include_str!("../../../../models-manager/models.json"),
|
||||
)?;
|
||||
let catalog_override = format!(
|
||||
"model_catalog_json={}",
|
||||
serde_json::to_string(&catalog_path.display().to_string())?
|
||||
);
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_mock_chatgpt_backend()
|
||||
.with_args(&["-c", &catalog_override])
|
||||
.with_codex_home(home.path())
|
||||
.with_env_overrides(&[("OPENAI_API_KEY", None)])
|
||||
.build_initialized_with_timeout(Duration::from_secs(/*secs*/ 60))
|
||||
|
||||
@@ -25,19 +25,26 @@ async fn read_default_provider_capabilities() -> Result<()> {
|
||||
let received: ModelProviderCapabilitiesReadResponse =
|
||||
timeout(DEFAULT_TIMEOUT, mcp.read_response(request_id)).await??;
|
||||
|
||||
let expected = ModelProviderCapabilitiesReadResponse {
|
||||
web_search: true,
|
||||
};
|
||||
// aKode: hosted web search is provider-opt-in, and there is no default provider.
|
||||
let expected = ModelProviderCapabilitiesReadResponse { web_search: false };
|
||||
assert_eq!(received, expected);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn read_amazon_bedrock_provider_capabilities() -> Result<()> {
|
||||
async fn read_opted_in_provider_capabilities() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
r#"model_provider = "amazon-bedrock"
|
||||
r#"model_provider = "mock"
|
||||
|
||||
[model_providers.mock]
|
||||
name = "mock"
|
||||
base_url = "http://127.0.0.1:0/v1"
|
||||
wire_api = "responses"
|
||||
|
||||
[model_providers.mock.capabilities]
|
||||
hosted_web_search = true
|
||||
"#,
|
||||
)?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
@@ -52,37 +59,9 @@ async fn read_amazon_bedrock_provider_capabilities() -> Result<()> {
|
||||
let received: ModelProviderCapabilitiesReadResponse =
|
||||
timeout(DEFAULT_TIMEOUT, mcp.read_response(request_id)).await??;
|
||||
|
||||
let expected = ModelProviderCapabilitiesReadResponse {
|
||||
web_search: true,
|
||||
};
|
||||
assert_eq!(received, expected);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn read_amazon_bedrock_runtime_provider_capabilities() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
r#"model_provider = "amazon-bedrock-runtime"
|
||||
"#,
|
||||
)?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.build_initialized_with_timeout(DEFAULT_TIMEOUT)
|
||||
.await?;
|
||||
|
||||
let request_id = mcp
|
||||
.send_model_provider_capabilities_read_request(ModelProviderCapabilitiesReadParams {})
|
||||
.await?;
|
||||
let received: ModelProviderCapabilitiesReadResponse =
|
||||
timeout(DEFAULT_TIMEOUT, mcp.read_response(request_id)).await??;
|
||||
|
||||
assert_eq!(
|
||||
received,
|
||||
ModelProviderCapabilitiesReadResponse {
|
||||
web_search: false,
|
||||
}
|
||||
ModelProviderCapabilitiesReadResponse { web_search: true }
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -93,7 +93,8 @@ async fn create_and_patch_gateway_providers_without_changing_the_default() -> Re
|
||||
.find(|p| p["id"] == "team-gateway"),
|
||||
Some(&expected)
|
||||
);
|
||||
assert_eq!(after["defaultProviderId"], "openai");
|
||||
// aKode: there is no default (`openai`) provider when none is configured.
|
||||
assert_eq!(after["defaultProviderId"], "");
|
||||
let persisted: Value = toml::from_str(&before)?;
|
||||
assert_eq!(
|
||||
persisted["model_providers"]["team-gateway"],
|
||||
@@ -145,11 +146,8 @@ async fn custom_provider_edits_preserve_other_fields_and_respect_policy() -> Res
|
||||
json!({"name": "Changed"}),
|
||||
"configLayerReadonly",
|
||||
),
|
||||
(
|
||||
"openai",
|
||||
json!({"name": "Changed"}),
|
||||
"configValidationError",
|
||||
),
|
||||
// aKode: `openai` is no longer a built-in provider, so it is an unknown id here.
|
||||
("openai", json!({"name": "Changed"}), "configPathNotFound"),
|
||||
("external", json!({"envKey": null}), "configValidationError"),
|
||||
(
|
||||
"basic",
|
||||
@@ -163,7 +161,6 @@ async fn custom_provider_edits_preserve_other_fields_and_respect_policy() -> Res
|
||||
"configValidationError",
|
||||
),
|
||||
("ollama", json!({}), "configValidationError"),
|
||||
("gcp", json!({}), "configValidationError"),
|
||||
] {
|
||||
patch["type"] = json!("customGateway");
|
||||
patch["providerId"] = json!(id);
|
||||
@@ -191,177 +188,3 @@ async fn custom_provider_edits_preserve_other_fields_and_respect_policy() -> Res
|
||||
assert_eq!(persisted, expected);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn custom_provider_writes_reject_builtin_auth_names_and_preserve_existing_ids() -> Result<()>
|
||||
{
|
||||
let home = TempDir::new()?;
|
||||
let config_path = home.path().join("config.toml");
|
||||
let ids = [r"team\gpu", "corp.gateway", r#"team"gpu"#];
|
||||
let mut providers = json!({});
|
||||
for id in ids {
|
||||
providers[id] = json!({"name":"Amazon Bedrock", "base_url":"https://old.example.test"});
|
||||
}
|
||||
std::fs::write(
|
||||
&config_path,
|
||||
toml::to_string(&json!({"model_providers":providers}))?,
|
||||
)?;
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.with_env_overrides(CLEARED_AUTH_ENV)
|
||||
.build_initialized()
|
||||
.await?;
|
||||
|
||||
let new_url = "https://new.example.test";
|
||||
for (provider_id, mut settings) in [
|
||||
(None, json!({"name": "OpenAI", "baseUrl": new_url})),
|
||||
(
|
||||
None,
|
||||
json!({"name": " Amazon Bedrock ", "baseUrl": new_url}),
|
||||
),
|
||||
(Some(ids[0]), json!({"name": "Amazon Bedrock Runtime"})),
|
||||
(Some(ids[0]), json!({"name": "Google Cloud Vertex AI"})),
|
||||
(Some(ids[0]), json!({"baseUrl": new_url})),
|
||||
(Some(ids[0]), json!({"name":"Renamed", "envKey":null})),
|
||||
] {
|
||||
settings["type"] = json!("customGateway");
|
||||
settings["providerId"] = json!(provider_id);
|
||||
let request = server
|
||||
.send_request(
|
||||
"modelProvider/config/write",
|
||||
Some(json!({"settings":settings})),
|
||||
)
|
||||
.await?;
|
||||
let error = server
|
||||
.read_stream_until_error_message(RequestId::Integer(request))
|
||||
.await?;
|
||||
assert_eq!(
|
||||
error.error.data,
|
||||
Some(json!({"config_write_error_code":"configValidationError"}))
|
||||
);
|
||||
}
|
||||
|
||||
for id in ids {
|
||||
let request = server
|
||||
.send_request(
|
||||
"modelProvider/config/write",
|
||||
Some(json!({"settings":{"type":"customGateway","providerId":id,"name":"Amazon Bedrock Mantle","baseUrl":new_url}})),
|
||||
)
|
||||
.await?;
|
||||
let saved: Value = server.read_response(request).await?;
|
||||
assert_eq!(saved["provider"]["id"], id);
|
||||
providers[id] = json!({"name": "Amazon Bedrock Mantle", "base_url": new_url});
|
||||
}
|
||||
let saved: Value = toml::from_str(&std::fs::read_to_string(config_path)?)?;
|
||||
assert_eq!(saved["model_providers"], providers);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn builtin_provider_patches_preserve_auth_and_do_not_select_or_authenticate() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
let config_path = home.path().join("config.toml");
|
||||
std::fs::write(
|
||||
home.path().join("requirements.toml"),
|
||||
"model_provider = 'openai'\n",
|
||||
)?;
|
||||
let mut server = TestAppServer::builder()
|
||||
.with_codex_home(home.path())
|
||||
.with_env_overrides(CLEARED_AUTH_ENV)
|
||||
.build_initialized()
|
||||
.await?;
|
||||
let credential_file = home.path().join("missing-credentials.json");
|
||||
for mut settings in [
|
||||
json!({"type":"bedrock", "providerId":"amazon-bedrock", "profile":"work", "region":"us-east-1"}),
|
||||
json!({"type":"bedrock", "providerId":"amazon-bedrock-runtime", "profile":null, "region":"us-west-2"}),
|
||||
json!({"type":"gcp", "providerId":"gcp", "projectId":"test-project", "location":"global", "credentialFile":credential_file}),
|
||||
] {
|
||||
let params = serde_json::from_value(json!({"settings":settings}))?;
|
||||
let saved: Value = server
|
||||
.request(|request_id| ClientRequest::ModelProviderConfigWrite { request_id, params })
|
||||
.await?;
|
||||
let id = settings
|
||||
.as_object_mut()
|
||||
.unwrap()
|
||||
.remove("providerId")
|
||||
.unwrap();
|
||||
assert_eq!(saved["provider"]["id"], id);
|
||||
assert_eq!(saved["provider"]["settings"], settings);
|
||||
}
|
||||
let refresh = json!({"command":"aws", "args":["sso", "login"]});
|
||||
let export = json!({"command":"unused-credential-command", "args":["test-only"]});
|
||||
let mut configured: Value = toml::from_str(&std::fs::read_to_string(&config_path)?)?;
|
||||
configured["model_providers"]["amazon-bedrock"]["aws"]["auth_refresh"] = refresh.clone();
|
||||
configured["model_providers"]["amazon-bedrock-runtime"]["aws"]["credential_export"] =
|
||||
export.clone();
|
||||
std::fs::write(&config_path, toml::to_string(&configured)?)?;
|
||||
for settings in [
|
||||
json!({"type":"bedrock", "providerId":"amazon-bedrock", "region":null}),
|
||||
json!({"type":"bedrock", "providerId":"amazon-bedrock-runtime", "region":"eu-west-1"}),
|
||||
json!({"type":"gcp", "providerId":"gcp", "location":"us-central1", "credentialFile":null}),
|
||||
json!({"type":"gcp", "providerId":"gcp"}),
|
||||
] {
|
||||
let params = serde_json::from_value(json!({"settings":settings}))?;
|
||||
let saved: Value = server
|
||||
.request(|request_id| ClientRequest::ModelProviderConfigWrite { request_id, params })
|
||||
.await?;
|
||||
assert_eq!(saved["provider"]["id"], settings["providerId"]);
|
||||
}
|
||||
let list: Value = server
|
||||
.request(|request_id| ClientRequest::ModelProviderList {
|
||||
request_id,
|
||||
params: Default::default(),
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(list["defaultProviderId"], "openai");
|
||||
assert_eq!(list["canChangeDefault"], false);
|
||||
let before_rejections = std::fs::read_to_string(&config_path)?;
|
||||
let actual: Value = toml::from_str(&before_rejections)?;
|
||||
assert_eq!(
|
||||
actual,
|
||||
json!({"model_providers": {
|
||||
"amazon-bedrock": {"aws":{"profile":"work", "auth_refresh":refresh}},
|
||||
"amazon-bedrock-runtime": {"aws":{"region":"eu-west-1", "credential_export":export}},
|
||||
"gcp":{"project_id":"test-project", "location":"us-central1"}
|
||||
}})
|
||||
);
|
||||
for settings in [
|
||||
json!({"type":"bedrock", "providerId":"amazon-bedrock-runtime", "profile":"conflicts-with-command", "region":"must-not-save"}),
|
||||
json!({"type":"gcp", "providerId":"gcp", "credentialFile":"relative/path", "location":"must-not-save"}),
|
||||
] {
|
||||
let write = server
|
||||
.send_request(
|
||||
"modelProvider/config/write",
|
||||
Some(json!({"settings":settings})),
|
||||
)
|
||||
.await?;
|
||||
let error = server
|
||||
.read_stream_until_error_message(RequestId::Integer(write))
|
||||
.await?;
|
||||
assert_eq!(
|
||||
error.error.data,
|
||||
Some(json!({"config_write_error_code":"configValidationError"}))
|
||||
);
|
||||
assert_eq!(std::fs::read_to_string(&config_path)?, before_rejections);
|
||||
}
|
||||
for settings in [
|
||||
json!({"type":"bedrock", "providerId":"gcp", "region":"must-not-save"}),
|
||||
json!({"type":"gcp", "providerId":"amazon-bedrock", "location":"must-not-save"}),
|
||||
json!({"type":"bedrock", "providerId":"amazon-bedrock", "envKey":"UNSUPPORTED"}),
|
||||
json!({"type":"gcp", "providerId":"gcp", "profile":"wrong-provider-field"}),
|
||||
json!({"type":"gcp", "location":"missing-id"}),
|
||||
] {
|
||||
let write = server
|
||||
.send_request(
|
||||
"modelProvider/config/write",
|
||||
Some(json!({"settings":settings})),
|
||||
)
|
||||
.await?;
|
||||
let error = server
|
||||
.read_stream_until_error_message(RequestId::Integer(write))
|
||||
.await?;
|
||||
assert_eq!(error.error.code, -32600);
|
||||
}
|
||||
assert_eq!(std::fs::read_to_string(&config_path)?, before_rejections);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -17,20 +17,12 @@ const CLEARED_AUTH_ENV: &[(&str, Option<&str>)] = &[
|
||||
];
|
||||
|
||||
#[tokio::test]
|
||||
async fn list_without_provider_definitions_only_returns_openai() -> Result<()> {
|
||||
for (config, default_id, base_url) in [
|
||||
("", "openai", None),
|
||||
("model_provider = 'ollama'", "ollama", None),
|
||||
(
|
||||
"openai_base_url = 'https://proxy.example.test/v1'",
|
||||
"openai",
|
||||
Some("https://proxy.example.test/v1"),
|
||||
),
|
||||
(
|
||||
"openai_base_url = 'https://proxy.example.test/v1?token=test-only'",
|
||||
"openai",
|
||||
None,
|
||||
),
|
||||
async fn list_without_provider_definitions_is_empty_and_has_no_openai_default() -> Result<()> {
|
||||
// aKode has no built-in OpenAI provider; `openai_base_url` no longer creates one.
|
||||
for (config, default_id) in [
|
||||
("", ""),
|
||||
("model_provider = 'ollama'", "ollama"),
|
||||
("openai_base_url = 'https://proxy.example.test/v1'", ""),
|
||||
] {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(home.path().join("config.toml"), config)?;
|
||||
@@ -46,8 +38,7 @@ async fn list_without_provider_definitions_only_returns_openai() -> Result<()> {
|
||||
assert_eq!(
|
||||
list,
|
||||
json!({
|
||||
"data": [{"id":"openai", "name":"OpenAI", "canEdit":false,
|
||||
"baseUrl":base_url, "settings":{"type":"openai"}}],
|
||||
"data": [],
|
||||
"defaultProviderId":default_id, "canChangeDefault":true,
|
||||
})
|
||||
);
|
||||
@@ -56,19 +47,15 @@ async fn list_without_provider_definitions_only_returns_openai() -> Result<()> {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn list_builtin_and_custom_providers_with_editable_settings() -> Result<()> {
|
||||
async fn list_custom_providers_with_editable_settings() -> Result<()> {
|
||||
let home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
r#"
|
||||
[model_providers.amazon-bedrock]
|
||||
base_url = "https://bedrock.example.test/v1"
|
||||
[model_providers.amazon-bedrock.aws]
|
||||
profile = "work"
|
||||
region = "us-east-1"
|
||||
[model_providers.amazon-bedrock-runtime.aws]
|
||||
region = "us-east-1"
|
||||
[model_providers.gcp]
|
||||
[model_providers.local]
|
||||
name = "Local server"
|
||||
base_url = "http://192.0.2.10:8080/v1"
|
||||
api_key = "keyring"
|
||||
[model_providers.basic]
|
||||
name = "Basic auth gateway"
|
||||
base_url = "https://user:password@basic.example.test/v1"
|
||||
@@ -110,14 +97,6 @@ base_url = "https://managed.example.test"
|
||||
json!({
|
||||
"defaultProviderId":"corp.gateway", "canChangeDefault":false,
|
||||
"data": [
|
||||
{
|
||||
"id":"amazon-bedrock", "name":"Amazon Bedrock Mantle", "canEdit":true,
|
||||
"baseUrl":"https://bedrock.example.test/v1", "settings":{"type":"bedrock", "profile":"work", "region":"us-east-1"},
|
||||
},
|
||||
{
|
||||
"id":"amazon-bedrock-runtime", "name":"Amazon Bedrock Runtime", "canEdit":true,
|
||||
"baseUrl":null, "settings":{"type":"bedrock", "profile":null, "region":"us-east-1"},
|
||||
},
|
||||
{
|
||||
"id":"basic", "name":"Basic auth gateway", "canEdit":true, "baseUrl":null,
|
||||
"settings":{"type":"customGateway", "auth":{"mode":"externallyConfigured", "envKey":null}},
|
||||
@@ -131,12 +110,8 @@ base_url = "https://managed.example.test"
|
||||
"baseUrl":null, "settings":{"type":"customGateway", "auth":{"mode":"externallyConfigured", "envKey":"EXTERNAL_KEY"}},
|
||||
},
|
||||
{
|
||||
"id":"gcp", "name":"Google Cloud Vertex AI", "canEdit":true,
|
||||
"baseUrl":null, "settings":{"type":"gcp", "projectId":null, "location":null, "credentialFile":null},
|
||||
},
|
||||
{
|
||||
"id":"openai", "name":"OpenAI", "canEdit":false,
|
||||
"baseUrl":null, "settings":{"type":"openai"},
|
||||
"id":"local", "name":"Local server", "canEdit":true,
|
||||
"baseUrl":"http://192.0.2.10:8080/v1", "settings":{"type":"customGateway", "auth":{"mode":"externallyConfigured", "envKey":null}},
|
||||
},
|
||||
{
|
||||
"id":"query", "name":"Query gateway", "canEdit":true,
|
||||
|
||||
@@ -1593,60 +1593,6 @@ async fn plugin_list_includes_api_curated_marketplace_for_api_auth() -> Result<(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn plugin_list_includes_api_curated_marketplace_for_bedrock_without_codex_auth() -> Result<()>
|
||||
{
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
r#"model_provider = "amazon-bedrock"
|
||||
|
||||
[model_providers.amazon-bedrock.aws]
|
||||
region = "us-east-2"
|
||||
profile = "default"
|
||||
|
||||
[features]
|
||||
plugins = true
|
||||
"#,
|
||||
)?;
|
||||
write_openai_curated_marketplace(codex_home.path(), &["chatgpt-plugin"])?;
|
||||
write_openai_api_curated_marketplace(codex_home.path(), &["api-plugin"])?;
|
||||
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.build_initialized_with_timeout(DEFAULT_TIMEOUT)
|
||||
.await?;
|
||||
|
||||
let request_id = mcp
|
||||
.send_plugin_list_request(PluginListParams {
|
||||
cwds: None,
|
||||
force_refetch: false,
|
||||
})
|
||||
.await?;
|
||||
let response: PluginListResponse =
|
||||
timeout(DEFAULT_TIMEOUT, mcp.read_response(request_id)).await??;
|
||||
|
||||
assert!(!codex_home.path().join("auth.json").exists());
|
||||
let api_curated_marketplace = response
|
||||
.marketplaces
|
||||
.iter()
|
||||
.find(|marketplace| marketplace.name == "openai-api-curated")
|
||||
.expect("expected API curated marketplace");
|
||||
assert_eq!(api_curated_marketplace.plugins.len(), 1);
|
||||
assert_eq!(
|
||||
api_curated_marketplace.plugins[0].id,
|
||||
"api-plugin@openai-api-curated"
|
||||
);
|
||||
assert!(
|
||||
response
|
||||
.marketplaces
|
||||
.iter()
|
||||
.all(|marketplace| marketplace.name != "openai-curated")
|
||||
);
|
||||
assert!(response.marketplace_load_errors.is_empty());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(false; "no project override")]
|
||||
#[test_case(true; "project enables local plugins only")]
|
||||
#[tokio::test]
|
||||
@@ -1776,19 +1722,6 @@ fn write_installed_plugin_with_version(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_openai_curated_marketplace(
|
||||
codex_home: &std::path::Path,
|
||||
plugin_names: &[&str],
|
||||
) -> std::io::Result<()> {
|
||||
write_curated_marketplace(
|
||||
codex_home,
|
||||
"marketplace.json",
|
||||
"openai-curated",
|
||||
/*display_name*/ None,
|
||||
plugin_names,
|
||||
)
|
||||
}
|
||||
|
||||
fn write_openai_api_curated_marketplace(
|
||||
codex_home: &std::path::Path,
|
||||
plugin_names: &[&str],
|
||||
|
||||
@@ -982,7 +982,11 @@ async fn projects_validate_filters_cursors_and_sqlite_less_assignment() -> Resul
|
||||
let store_id = Uuid::now_v7();
|
||||
std::fs::write(
|
||||
unsupported_projects_home.path().join("config.toml"),
|
||||
format!("experimental_thread_store = {{ type = \"in_memory\", id = \"{store_id}\" }}"),
|
||||
// aKode: this overwrites the mock config; keep an explicit catalog (no default one).
|
||||
format!(
|
||||
"{}experimental_thread_store = {{ type = \"in_memory\", id = \"{store_id}\" }}",
|
||||
app_test_support::bundled_model_catalog_config(unsupported_projects_home.path())?
|
||||
),
|
||||
)?;
|
||||
let mut unsupported_projects = TestAppServer::builder()
|
||||
.with_codex_home(unsupported_projects_home.path())
|
||||
|
||||
@@ -786,6 +786,8 @@ fn assert_no_local_persistence_artifacts(codex_home: &Path) -> Result<()> {
|
||||
#[cfg(windows)]
|
||||
entries.remove(".sandbox");
|
||||
entries.remove("shell_snapshots");
|
||||
// aKode: the explicit model catalog the test harness writes is configuration input.
|
||||
entries.remove("test-models.json");
|
||||
assert_eq!(
|
||||
entries,
|
||||
BTreeSet::from([
|
||||
|
||||
@@ -116,6 +116,11 @@ async fn legacy_permission_profile_requests_fail_closed() -> Result<()> {
|
||||
#[tokio::test]
|
||||
async fn thread_start_keeps_unknown_field_compatibility_with_named_permissions() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
app_test_support::bundled_model_catalog_config(codex_home.path())?,
|
||||
)?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.build_initialized_with_timeout(DEFAULT_READ_TIMEOUT)
|
||||
|
||||
@@ -17,7 +17,7 @@ Settings:
|
||||
stream: true
|
||||
tool_choice: "auto"
|
||||
-- request 1 (turn) --
|
||||
00:additional_tools/developer (3; hash=bf13940dee826ebd):
|
||||
00:additional_tools/developer (2; hash=439dcadc72baaea1):
|
||||
- namespace/functions; hash=028af59ad835936d
|
||||
- function/exec_command
|
||||
- function/write_stdin
|
||||
@@ -34,8 +34,6 @@ Settings:
|
||||
- function/send_input
|
||||
- function/spawn_agent
|
||||
- function/wait_agent
|
||||
- namespace/web: Tools in the web namespace.; hash=0037b1ed8d50fab5
|
||||
- function/run
|
||||
01:message/developer:
|
||||
Retain these base instructions.
|
||||
02:message/developer[4]:
|
||||
@@ -47,9 +45,8 @@ Settings:
|
||||
- `r0` = `<SKILLS_ROOT>`
|
||||
- `r1` = `<SKILLS_ROOT>/.system`
|
||||
### Available skills
|
||||
- openai-docs: API first-timers, Codex/Work Q&A. If the user already has an OpenAI API integration, skip...upplied text or data. (file: r1/openai-docs/SKILL.md) [hash=8ba7f79795ddc1cb]
|
||||
- skill-creator: Create or update a Codex skill with appropriately scoped instructions and any needed supporting resources. (file: r1/skill-creator/SKILL.md)
|
||||
- skill-installer: Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo pat...g private repos). (file: r1/skill-installer/SKILL.md) [hash=80e87da510d34d88]
|
||||
- skill-installer: Install aKode skills into $CODEX_HOME/skills from the default skills repository (the ...g private repos). (file: r1/skill-installer/SKILL.md) [hash=50f61366dff05eec]
|
||||
- app-store-screenshots: App Store and Google Play screenshot creation with exact platform specs. Covers...ore listing (file: r0/app-store-screenshots/SKILL.md) [hash=3f178aa58b5c4f8e]
|
||||
- assistant-ui: Overview and router for assistant-ui, the React library for building AI chat interfaces ...d by those siblings. (file: r0/assistant-ui/SKILL.md) [hash=61291772e6f2139c]
|
||||
- find-skills: Helps users discover and install agent skills when they ask questions like "how do I do X...an installable skill. (file: r0/find-skills/SKILL.md) [hash=48b9e99d9200af8d]
|
||||
@@ -82,7 +79,7 @@ Settings:
|
||||
## Window 2 (after request 2: input repeated)
|
||||
Settings: same as window 1
|
||||
-- request 3 (turn) --
|
||||
00:additional_tools/developer (3; hash=bf13940dee826ebd):
|
||||
00:additional_tools/developer (2; hash=439dcadc72baaea1):
|
||||
- namespace/functions; hash=028af59ad835936d
|
||||
- function/exec_command
|
||||
- function/write_stdin
|
||||
@@ -99,8 +96,6 @@ Settings: same as window 1
|
||||
- function/send_input
|
||||
- function/spawn_agent
|
||||
- function/wait_agent
|
||||
- namespace/web: Tools in the web namespace.; hash=0037b1ed8d50fab5
|
||||
- function/run
|
||||
01:message/developer:
|
||||
Retain these base instructions.
|
||||
02:message/developer[4]:
|
||||
@@ -112,9 +107,8 @@ Settings: same as window 1
|
||||
- `r0` = `<SKILLS_ROOT>`
|
||||
- `r1` = `<SKILLS_ROOT>/.system`
|
||||
### Available skills
|
||||
- openai-docs: API first-timers, Codex/Work Q&A. If the user already has an OpenAI API integration, skip...upplied text or data. (file: r1/openai-docs/SKILL.md) [hash=8ba7f79795ddc1cb]
|
||||
- skill-creator: Create or update a Codex skill with appropriately scoped instructions and any needed supporting resources. (file: r1/skill-creator/SKILL.md)
|
||||
- skill-installer: Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo pat...g private repos). (file: r1/skill-installer/SKILL.md) [hash=80e87da510d34d88]
|
||||
- skill-installer: Install aKode skills into $CODEX_HOME/skills from the default skills repository (the ...g private repos). (file: r1/skill-installer/SKILL.md) [hash=50f61366dff05eec]
|
||||
- app-store-screenshots: App Store and Google Play screenshot creation with exact platform specs. Covers...ore listing (file: r0/app-store-screenshots/SKILL.md) [hash=3f178aa58b5c4f8e]
|
||||
- assistant-ui: Overview and router for assistant-ui, the React library for building AI chat interfaces ...d by those siblings. (file: r0/assistant-ui/SKILL.md) [hash=61291772e6f2139c]
|
||||
- find-skills: Helps users discover and install agent skills when they ask questions like "how do I do X...an installable skill. (file: r0/find-skills/SKILL.md) [hash=48b9e99d9200af8d]
|
||||
@@ -146,7 +140,7 @@ Settings: same as window 1
|
||||
## Window 3 (after request 3: input repeated)
|
||||
Settings: same as window 1
|
||||
-- request 4 (turn) --
|
||||
00:additional_tools/developer (3; hash=bf13940dee826ebd):
|
||||
00:additional_tools/developer (2; hash=439dcadc72baaea1):
|
||||
- namespace/functions; hash=028af59ad835936d
|
||||
- function/exec_command
|
||||
- function/write_stdin
|
||||
@@ -163,8 +157,6 @@ Settings: same as window 1
|
||||
- function/send_input
|
||||
- function/spawn_agent
|
||||
- function/wait_agent
|
||||
- namespace/web: Tools in the web namespace.; hash=0037b1ed8d50fab5
|
||||
- function/run
|
||||
01:message/developer:
|
||||
Retain these base instructions.
|
||||
02:message/developer[4]:
|
||||
@@ -176,9 +168,8 @@ Settings: same as window 1
|
||||
- `r0` = `<SKILLS_ROOT>`
|
||||
- `r1` = `<SKILLS_ROOT>/.system`
|
||||
### Available skills
|
||||
- openai-docs: API first-timers, Codex/Work Q&A. If the user already has an OpenAI API integration, skip...upplied text or data. (file: r1/openai-docs/SKILL.md) [hash=8ba7f79795ddc1cb]
|
||||
- skill-creator: Create or update a Codex skill with appropriately scoped instructions and any needed supporting resources. (file: r1/skill-creator/SKILL.md)
|
||||
- skill-installer: Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo pat...g private repos). (file: r1/skill-installer/SKILL.md) [hash=80e87da510d34d88]
|
||||
- skill-installer: Install aKode skills into $CODEX_HOME/skills from the default skills repository (the ...g private repos). (file: r1/skill-installer/SKILL.md) [hash=50f61366dff05eec]
|
||||
- app-store-screenshots: App Store and Google Play screenshot creation with exact platform specs. Covers...ore listing (file: r0/app-store-screenshots/SKILL.md) [hash=3f178aa58b5c4f8e]
|
||||
- assistant-ui: Overview and router for assistant-ui, the React library for building AI chat interfaces ...d by those siblings. (file: r0/assistant-ui/SKILL.md) [hash=61291772e6f2139c]
|
||||
- find-skills: Helps users discover and install agent skills when they ask questions like "how do I do X...an installable skill. (file: r0/find-skills/SKILL.md) [hash=48b9e99d9200af8d]
|
||||
|
||||
@@ -16,12 +16,12 @@ use tokio::time::timeout;
|
||||
async fn startup_reports_shared_and_fallback_recovery() -> Result<()> {
|
||||
for log_dir_is_configured in [false, true] {
|
||||
let home = TempDir::new()?;
|
||||
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
|
||||
let mut config = app_test_support::bundled_model_catalog_config(home.path())?;
|
||||
if log_dir_is_configured {
|
||||
std::fs::write(
|
||||
home.path().join("config.toml"),
|
||||
format!("log_dir = {:?}\n", home.path().join("log")),
|
||||
)?;
|
||||
config.push_str(&format!("log_dir = {:?}\n", home.path().join("log")));
|
||||
}
|
||||
std::fs::write(home.path().join("config.toml"), config)?;
|
||||
let sqlite = core_test_support::load_default_config_for_test(&home)
|
||||
.await
|
||||
.sqlite;
|
||||
|
||||
@@ -298,6 +298,11 @@ fn create_delete_test_rollout(codex_home: &Path, minute: u8, preview: &str) -> R
|
||||
#[tokio::test]
|
||||
async fn thread_delete_handles_live_threads_before_rollout_exists() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
app_test_support::bundled_model_catalog_config(codex_home.path())?,
|
||||
)?;
|
||||
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
|
||||
@@ -1013,7 +1013,8 @@ async fn sample_rejects_invalid_sources_and_prompts() -> Result<()> {
|
||||
}
|
||||
|
||||
#[test_case(false; "unsupported model")]
|
||||
#[test_case(true; "unsupported provider")]
|
||||
// aKode: the "unsupported provider" case was removed with the name-based `is_openai()`
|
||||
// gate on reasoning-effort updates; provider names no longer matter.
|
||||
#[tokio::test]
|
||||
async fn unsupported_effort_updates_keep_inherited_effort(
|
||||
unsupported_provider: bool,
|
||||
|
||||
@@ -79,34 +79,14 @@ async fn start_thread_with_model(
|
||||
.await
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_provider_model_fallback_applies_to_configured_model() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
r#"model_provider = "amazon-bedrock"
|
||||
model = "gpt-5.4-mini"
|
||||
"#,
|
||||
)?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
|
||||
let response = mcp
|
||||
.start_thread(ThreadStartParams {
|
||||
allow_provider_model_fallback: true,
|
||||
..Default::default()
|
||||
})
|
||||
.await?;
|
||||
|
||||
assert_eq!(response.model, "openai.gpt-6.1-sol");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_warns_for_exec_policy_parse_failure_after_initialize() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
app_test_support::bundled_model_catalog_config(codex_home.path())?,
|
||||
)?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.build_initialized()
|
||||
@@ -175,6 +155,11 @@ async fn thread_start_warns_for_exec_policy_parse_failure_after_initialize() ->
|
||||
#[tokio::test]
|
||||
async fn thread_start_does_not_repeat_initialize_exec_policy_warning() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
// aKode: no default provider or bundled catalog; threads need an explicit catalog.
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
app_test_support::bundled_model_catalog_config(codex_home.path())?,
|
||||
)?;
|
||||
let rules_dir = codex_home.path().join("rules");
|
||||
std::fs::create_dir_all(&rules_dir)?;
|
||||
std::fs::write(rules_dir.join("broken.rules"), "prefix_rule(")?;
|
||||
@@ -210,103 +195,6 @@ async fn thread_start_does_not_repeat_initialize_exec_policy_warning() -> Result
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_provider_model_fallback_uses_bedrock_static_catalog() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
r#"model_provider = "amazon-bedrock"
|
||||
"#,
|
||||
)?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
|
||||
let unsupported_with_fallback = start_thread_with_model(
|
||||
&mut mcp,
|
||||
"gpt-5.4-mini",
|
||||
/*allow_provider_model_fallback*/ true,
|
||||
)
|
||||
.await?;
|
||||
for model in [
|
||||
"openai.gpt-6.1-sol",
|
||||
"openai.gpt-6.1-terra",
|
||||
"openai.gpt-6-sol",
|
||||
"openai.gpt-6-luna",
|
||||
"openai.gpt-5.6-sol",
|
||||
] {
|
||||
let response =
|
||||
start_thread_with_model(&mut mcp, model, /*allow_provider_model_fallback*/ true)
|
||||
.await?;
|
||||
assert_eq!(response.model, model);
|
||||
}
|
||||
let supported_with_fallback = start_thread_with_model(
|
||||
&mut mcp,
|
||||
"openai.gpt-5.5",
|
||||
/*allow_provider_model_fallback*/ true,
|
||||
)
|
||||
.await?;
|
||||
let unsupported_without_fallback = start_thread_with_model(
|
||||
&mut mcp,
|
||||
"gpt-5.4-mini",
|
||||
/*allow_provider_model_fallback*/ false,
|
||||
)
|
||||
.await?;
|
||||
|
||||
assert_eq!(
|
||||
vec![
|
||||
unsupported_with_fallback.model,
|
||||
supported_with_fallback.model,
|
||||
unsupported_without_fallback.model,
|
||||
],
|
||||
vec!["openai.gpt-6.1-sol", "openai.gpt-5.5", "gpt-5.4-mini"]
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_bedrock_runtime_prefers_global_cross_region_models() -> Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
r#"model_provider = "amazon-bedrock-runtime"
|
||||
"#,
|
||||
)?;
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(codex_home.path())
|
||||
.build_initialized()
|
||||
.await?;
|
||||
|
||||
for model in [
|
||||
"global.openai.gpt-6.1-sol",
|
||||
"us.openai.gpt-6.1-sol",
|
||||
"global.openai.gpt-6.1-terra",
|
||||
"us.openai.gpt-6.1-terra",
|
||||
"global.openai.gpt-6-sol",
|
||||
"us.openai.gpt-6-sol",
|
||||
"global.openai.gpt-6-luna",
|
||||
"us.openai.gpt-6-luna",
|
||||
"global.openai.gpt-5.6-sol",
|
||||
"us.openai.gpt-5.6-sol",
|
||||
] {
|
||||
let response =
|
||||
start_thread_with_model(&mut mcp, model, /*allow_provider_model_fallback*/ true)
|
||||
.await?;
|
||||
assert_eq!(response.model, model);
|
||||
}
|
||||
|
||||
let response = start_thread_with_model(
|
||||
&mut mcp,
|
||||
"openai.gpt-5.6-sol",
|
||||
/*allow_provider_model_fallback*/ true,
|
||||
)
|
||||
.await?;
|
||||
assert_eq!(response.model, "global.openai.gpt-6.1-sol");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn thread_start_provider_model_fallback_ignores_dynamic_catalog() -> Result<()> {
|
||||
let server = create_mock_responses_server_repeating_assistant("Done").await;
|
||||
|
||||
@@ -473,13 +473,11 @@ async fn tool_call_metadata_stays_out_of_raw_response_item_notifications() -> Re
|
||||
.find(|item| item["type"] == "function_call_output" && item["call_id"] == "mcp-call")
|
||||
.context("follow-up tool output")?;
|
||||
assert!(serde_json::to_string(&output["output"])?.contains("Calendar result"));
|
||||
// aKode: internal metadata passthrough is stripped from model requests unless the
|
||||
// provider holds the runtime-only `include_internal_metadata` grant.
|
||||
assert_eq!(
|
||||
output["internal_chat_message_metadata_passthrough"]["executed_tool_calls"],
|
||||
json!([{"name": DIRECT_CALENDAR_LIST_EVENTS_TOOL, "arguments": arguments}]),
|
||||
);
|
||||
assert_eq!(
|
||||
output["internal_chat_message_metadata_passthrough"]["tool_calls_complete"],
|
||||
true,
|
||||
output.get("internal_chat_message_metadata_passthrough"),
|
||||
None
|
||||
);
|
||||
|
||||
let raw_output = &raw_params["item"];
|
||||
@@ -488,10 +486,10 @@ async fn tool_call_metadata_stays_out_of_raw_response_item_notifications() -> Re
|
||||
let public_metadata = raw_output["internal_chat_message_metadata_passthrough"]
|
||||
.as_object()
|
||||
.context("public passthrough metadata")?;
|
||||
assert_eq!(
|
||||
public_metadata.get("turn_id").context("public turn id")?,
|
||||
&output["internal_chat_message_metadata_passthrough"]["turn_id"],
|
||||
);
|
||||
let public_turn_id = public_metadata
|
||||
.get("turn_id")
|
||||
.context("public turn id")?
|
||||
.clone();
|
||||
for field in ["executed_tool_calls", "tool_calls_complete", "cell_id"] {
|
||||
assert!(
|
||||
public_metadata.get(field).is_none(),
|
||||
@@ -514,6 +512,14 @@ async fn tool_call_metadata_stays_out_of_raw_response_item_notifications() -> Re
|
||||
.find(|item| item["type"] == "function_call_output" && item["call_id"] == "mcp-call")
|
||||
.context("persisted MCP output")?;
|
||||
assert_eq!(captured["output"], raw_output["output"]);
|
||||
assert_eq!(
|
||||
captured["internal_chat_message_metadata_passthrough"]["turn_id"],
|
||||
public_turn_id
|
||||
);
|
||||
assert_eq!(
|
||||
captured["internal_chat_message_metadata_passthrough"]["executed_tool_calls"][0]["name"],
|
||||
json!(DIRECT_CALENDAR_LIST_EVENTS_TOOL),
|
||||
);
|
||||
// Raw MCP result metadata is never recorded, not even in the local rollout.
|
||||
assert_eq!(
|
||||
captured["internal_chat_message_metadata_passthrough"]["executed_tool_calls"][0]
|
||||
@@ -644,7 +650,10 @@ async fn turn_start_steers_active_turn_and_returns_active_turn_id() -> Result<()
|
||||
std::fs::write(
|
||||
codex_home.path().join("config.toml"),
|
||||
format!(
|
||||
"model = \"gpt-5.5\"\napproval_policy = \"never\"\nopenai_base_url = \"{}/v1\"\ncli_auth_credentials_store = \"file\"\n[features]\nenable_request_compression = false\n",
|
||||
// aKode: `openai_base_url` no longer configures a built-in provider; declare an
|
||||
// equivalent `openai` provider explicitly, with an explicit model catalog.
|
||||
"{}model = \"gpt-5.5\"\napproval_policy = \"never\"\nmodel_provider = \"openai\"\ncli_auth_credentials_store = \"file\"\n[features]\nenable_request_compression = false\n[model_providers.openai]\nname = \"OpenAI\"\nbase_url = \"{}/v1\"\nwire_api = \"responses\"\nrequires_openai_auth = true\nsupports_websockets = false\nmerge_system_messages = false\n",
|
||||
app_test_support::bundled_model_catalog_config(codex_home.path())?,
|
||||
server.uri()
|
||||
),
|
||||
)?;
|
||||
@@ -1085,7 +1094,12 @@ async fn turn_start_emits_thread_scoped_warning_notification_for_trimmed_skills(
|
||||
.expect("model slug should be present")
|
||||
.to_string();
|
||||
entry["context_window"] = serde_json::Value::from(100);
|
||||
std::fs::write(&cache_path, serde_json::to_string_pretty(&cache)?)?;
|
||||
// aKode: cached models are served through the explicit test catalog.
|
||||
write_models_cache_with_models(
|
||||
codex_home.path(),
|
||||
serde_json::from_value(cache["models"].clone())?,
|
||||
)
|
||||
.await?;
|
||||
let config_path = codex_home.path().join("config.toml");
|
||||
let config = std::fs::read_to_string(&config_path)?;
|
||||
std::fs::write(
|
||||
@@ -1125,9 +1139,10 @@ async fn turn_start_emits_thread_scoped_warning_notification_for_trimmed_skills(
|
||||
let warning: WarningNotification =
|
||||
timeout(DEFAULT_READ_TIMEOUT, mcp.read_notification("warning")).await??;
|
||||
assert_eq!(warning.thread_id.as_deref(), Some(thread.id.as_str()));
|
||||
// aKode: the bundled `openai-docs` system skill was removed, so one fewer skill is trimmed.
|
||||
assert_eq!(
|
||||
warning.message,
|
||||
"Exceeded skills context budget. All skill descriptions were removed and 5 additional skills were not included in the model-visible skills list."
|
||||
"Exceeded skills context budget. All skill descriptions were removed and 4 additional skills were not included in the model-visible skills list."
|
||||
);
|
||||
|
||||
timeout(
|
||||
@@ -3270,13 +3285,14 @@ model = "mock-model"
|
||||
approval_policy = "never"
|
||||
default_permissions = "dev"
|
||||
model_provider = "mock_provider"
|
||||
|
||||
{catalog}
|
||||
[model_providers.mock_provider]
|
||||
name = "Mock provider for test"
|
||||
base_url = "{server_uri}/v1"
|
||||
wire_api = "responses"
|
||||
request_max_retries = 0
|
||||
stream_max_retries = 0
|
||||
merge_system_messages = false
|
||||
|
||||
# This test only exercises writable workspace roots; the Windows restricted-token
|
||||
# sandbox cannot enforce a filesystem policy without root read access.
|
||||
@@ -3285,7 +3301,9 @@ stream_max_retries = 0
|
||||
|
||||
[permissions.dev.filesystem.":workspace_roots"]
|
||||
"." = "write"
|
||||
"#
|
||||
"#,
|
||||
// aKode: explicit catalog (no bundled default) and upstream message layout.
|
||||
catalog = app_test_support::bundled_model_catalog_config(&codex_home)?
|
||||
),
|
||||
)?;
|
||||
|
||||
@@ -3868,7 +3886,12 @@ async fn turn_start_streams_apply_patch_change_updates_v2() -> Result<()> {
|
||||
model["slug"] = serde_json::Value::from("mock-model");
|
||||
model["display_name"] = serde_json::Value::from("mock-model");
|
||||
model["apply_patch_tool_type"] = serde_json::Value::from("freeform");
|
||||
std::fs::write(&cache_path, serde_json::to_string_pretty(&cache)?)?;
|
||||
// aKode: cached models are served through the explicit test catalog.
|
||||
write_models_cache_with_models(
|
||||
&codex_home,
|
||||
serde_json::from_value(cache["models"].clone())?,
|
||||
)
|
||||
.await?;
|
||||
|
||||
let mut mcp = TestAppServer::builder()
|
||||
.with_codex_home(&codex_home)
|
||||
|
||||
@@ -300,7 +300,9 @@ async fn assert_standalone_web_search_round_trips_output(
|
||||
.with_model_provider("openai-custom")
|
||||
.with_provider_name("OpenAI")
|
||||
.with_provider_base_url(&format!("{}/api/codex", server.uri()))
|
||||
.with_provider_config("requires_openai_auth = true"),
|
||||
.with_provider_config("requires_openai_auth = true")
|
||||
// aKode: standalone search is provider opt-in; the name "OpenAI" no longer implies it.
|
||||
.with_provider_config("supports_standalone_web_search = true"),
|
||||
WebSearchProvider::CustomResponses => config
|
||||
.with_model_provider("custom-responses")
|
||||
.with_provider_name("Custom Responses")
|
||||
|
||||
Reference in New Issue
Block a user