aKode: eliminato chatgpt_base_url ormai inutilizzato

- La chiave è ancora accettata nei file di configurazione ma ignorata.
- Schemi JSON e TypeScript dell'app-server rigenerati; i bundle ora si
  chiamano akode_app_server_protocol*.schemas.json, come produce il
  generatore.
- app-server: niente più avviso unused_mut nella build release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
andrea.difonzo
2026-11-11 16:40:27 +01:00
parent f366db7f29
commit 24a3cfe2f4
63 changed files with 129 additions and 501 deletions

View File

@@ -562,9 +562,7 @@ The experimental `account/read.workspaceRouting` response field returns the sele
App-server discovers routing for saved ChatGPT logins at startup and for new logins or workspace switches. After requirements and routing are ready, it sends the existing `account/updated` notification. Newly initialized connections also receive this notification once saved-workspace routing is ready, including when discovery finished before the connection initialized. Clients then reread `configRequirements/read` and `account/read`. Saved ChatGPT credentials without a selected workspace ID retain their account information and return `workspaceRouting: null`; app-server does not guess a workspace from the backend's default account. Discovery failures for a selected workspace, including missing or null fields from older backends, return an `account/read` error. They never produce a successful unrestricted result. A later read retries failed discovery. Logout clears the cached routing, and results from earlier authentication owners are discarded. Token refreshes for the same known user and workspace invalidate cached routing without cancelling discovery or failing sign-in. Configuration is reloaded after discovery; a changed backend, model provider, or required backend rejects the result so the next read discovers against current configuration. Account notifications recheck the auth owner generation after waiting for outbound queue capacity. Superseded sign-in attempts emit a failed `account/login/completed` event instead of silently dropping completion. Notifications remain snapshots: clients reread current account and requirements state rather than treating a queued notification as authorization.
Routing compares origins by scheme, host, and effective port, ignoring API paths. A required
`chatgpt_base_url` must match discovery; if neither provides an origin, `NO_CONSTRAINT` uses the
configured base URL.
Routing compares origins by scheme, host, and effective port, ignoring API paths.
Responses HTTP (including compaction) and WebSockets wait for discovery and preserve API paths.
Guardian v2 classifier HTTP and pooled WebSockets use the same routing.

View File

@@ -36,7 +36,6 @@ async fn embedded_transports_stay_blocked_until_the_same_policy_is_published() -
.loader_overrides(overrides.clone())
.build()
.await?;
config.chatgpt_base_url = server.uri();
let policy = EmbeddedNetworkPolicy::load(&overrides).await;
let application = policy
.bind(config.http_client_factory())

View File

@@ -118,8 +118,6 @@ pub(super) async fn configure(
policy_auth_manager.clone()
};
let config = Arc::make_mut(config);
config.chatgpt_base_url = policy_config.chatgpt_base_url;
config.chatgpt_base_url_is_explicit = policy_config.chatgpt_base_url_is_explicit;
config.enforce_residency = policy_config.enforce_residency;
config.application_network_policy = policy_config.application_network_policy;
config.application_auth_route_config = policy_config.application_auth_route_config;

View File

@@ -22,13 +22,6 @@ async fn startup_reloads_the_callers_selected_project() -> anyhow::Result<()> {
std::fs::create_dir_all(selected.join(".akode"))?;
std::fs::create_dir(selected.join(".git"))?;
set_project_trust_level(&home, &selected, TrustLevel::Trusted)?;
let selected_url = "https://selected.example/backend-api/";
let user_config = home.join("config.toml");
let trust = std::fs::read_to_string(&user_config)?;
std::fs::write(
&user_config,
format!("chatgpt_base_url = '{selected_url}'\n{trust}"),
)?;
let project_config = selected.join(".akode/config.toml");
std::fs::write(&project_config, "model = 'selected-model'")?;
let loader_overrides = LoaderOverrides::without_managed_config_for_tests();
@@ -43,7 +36,6 @@ async fn startup_reloads_the_callers_selected_project() -> anyhow::Result<()> {
.build()
.await?,
);
assert_eq!(config.chatgpt_base_url, selected_url);
assert_eq!(config.model.as_deref(), Some("selected-model"));
let manager = ConfigManager::new(
home,
@@ -63,7 +55,6 @@ async fn startup_reloads_the_callers_selected_project() -> anyhow::Result<()> {
config.cwd.as_path().canonicalize()?,
selected.canonicalize()?
);
assert_eq!(config.chatgpt_base_url, selected_url);
std::fs::write(&project_config, "[malformed")?;
let error = configure(

View File

@@ -838,7 +838,6 @@ pub async fn run_main_with_transport_options(
let (remote_control_accept_handle, remote_control_handle) = start_remote_control(
RemoteControlStartConfig {
remote_control_url: config.chatgpt_base_url.clone(),
installation_id: installation_id.clone(),
policy: remote_control_policy,
},
@@ -1473,9 +1472,11 @@ fn test_user_config_file_from_env() -> Option<std::path::PathBuf> {
}
fn loader_overrides_with_test_user_config_file(
mut loader_overrides: LoaderOverrides,
loader_overrides: LoaderOverrides,
test_user_config_file: Option<std::path::PathBuf>,
) -> IoResult<LoaderOverrides> {
#[cfg(debug_assertions)]
let mut loader_overrides = loader_overrides;
#[cfg(debug_assertions)]
if let Some(path) = test_user_config_file {
let path = AbsolutePathBuf::from_absolute_path(path).map_err(|err| {

View File

@@ -478,7 +478,6 @@ pub(crate) fn map_requirements_to_api(
}
},
),
chatgpt_base_url: requirements.chatgpt_base_url,
additional_developer_instructions: requirements.additional_developer_instructions,
allowed_approval_policies: requirements.allowed_approval_policies.map(|policies| {
policies

View File

@@ -228,16 +228,6 @@ pub fn write_mock_responses_config_toml(
config.write(codex_home)
}
pub fn write_mock_responses_config_toml_with_chatgpt_base_url(
codex_home: &Path,
server_uri: &str,
chatgpt_base_url: &str,
) -> std::io::Result<()> {
MockResponsesConfig::new(server_uri)
.with_root_config(&format!("chatgpt_base_url = \"{chatgpt_base_url}\""))
.write(codex_home)
}
#[cfg(test)]
#[path = "config_tests.rs"]
mod tests;

View File

@@ -13,7 +13,7 @@ fn mock_responses_config_composes_model_provider_features_and_extra_tables() {
.with_sandbox_mode("workspace-write")
.enable_feature(Feature::FastMode)
.disable_feature(Feature::ShellSnapshot)
.with_root_config("chatgpt_base_url = \"http://127.0.0.1:1234\"")
.with_root_config("check_for_update_on_startup = false")
.with_provider_config("requires_openai_auth = true")
.with_extra_config("[extra]\nenabled = true")
.write(home.path())
@@ -25,7 +25,7 @@ fn mock_responses_config_composes_model_provider_features_and_extra_tables() {
"model = \"custom-model\"",
"approval_policy = \"on-request\"",
"sandbox_mode = \"workspace-write\"",
"chatgpt_base_url = \"http://127.0.0.1:1234\"",
"check_for_update_on_startup = false",
"model_provider = \"openai-custom\"",
"shell_snapshot = false",
"fast_mode = true",

View File

@@ -14,7 +14,6 @@ use akode_app_server_protocol::JSONRPCResponse;
pub use config::MockResponsesConfig;
pub use config::bundled_model_catalog_config;
pub use config::write_mock_responses_config_toml;
pub use config::write_mock_responses_config_toml_with_chatgpt_base_url;
pub use core_test_support::PathBufExt;
pub use core_test_support::format_with_current_shell;
pub use core_test_support::format_with_current_shell_display;

View File

@@ -131,11 +131,6 @@ use core_test_support::test_codex::test_env;
use serde::de::DeserializeOwned;
use tempfile::TempDir;
use tokio::process::Command;
use wiremock::Mock;
use wiremock::MockServer;
use wiremock::ResponseTemplate;
use wiremock::matchers::method;
use wiremock::matchers::path;
use crate::json_logging::JsonLogCapture;
use crate::local_websocket_exec_server::LocalWebsocketExecServer;
@@ -156,7 +151,6 @@ pub struct TestAppServer {
// Fields drop in declaration order. Tear down the delayed child before
// removing an owned AKODE_HOME that may still be its cwd on Windows.
_delayed_exec_server: Option<(LocalWebsocketExecServer, WebsocketDelayInterposer)>,
_attribution_settings_server: Option<MockServer>,
_owned_install_dir: Option<TempDir>,
_owned_codex_home: Option<TempDir>,
}
@@ -180,7 +174,6 @@ impl TestAppServer {
env_overrides: Vec::new(),
args: vec![DISABLE_PLUGIN_STARTUP_TASKS_ARG.to_string()],
exec_server_delay: None,
mock_chatgpt_backend: false,
}
}
@@ -344,7 +337,6 @@ impl TestAppServer {
auto_env: None,
json_logs,
_delayed_exec_server: None,
_attribution_settings_server: None,
_owned_install_dir: None,
_owned_codex_home: None,
})
@@ -1804,7 +1796,6 @@ pub struct TestAppServerBuilder {
env_overrides: Vec<(String, Option<String>)>,
args: Vec<String>,
exec_server_delay: Option<Duration>,
mock_chatgpt_backend: bool,
}
enum TestAppServerEnvironment {
@@ -1813,11 +1804,6 @@ enum TestAppServerEnvironment {
}
impl TestAppServerBuilder {
pub fn with_mock_chatgpt_backend(mut self) -> Self {
self.mock_chatgpt_backend = true;
self
}
/// Uses this existing AKODE_HOME instead of a temporary one.
pub fn with_codex_home(mut self, codex_home: &Path) -> Self {
self.codex_home = Some(codex_home.to_path_buf());
@@ -1913,7 +1899,6 @@ impl TestAppServerBuilder {
mut env_overrides,
args,
exec_server_delay,
mock_chatgpt_backend,
} = self;
let (codex_home, owned_codex_home) = match codex_home {
Some(codex_home) => (codex_home, None),
@@ -1925,42 +1910,6 @@ impl TestAppServerBuilder {
)
}
};
let attribution_settings_server = if mock_chatgpt_backend
|| codex_home.join("auth.json").is_file()
{
let config_path = codex_home.join("config.toml");
let config = std::fs::read_to_string(&config_path)?;
if config
.lines()
.any(|line| line.trim_start().starts_with("chatgpt_base_url"))
{
None
} else {
let settings_server = MockServer::start().await;
Mock::given(method("GET"))
.and(path("/backend-api/wham/config/bundle"))
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({})))
.mount(&settings_server)
.await;
Mock::given(method("GET"))
.and(path("/backend-api/wham/settings/user"))
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({
"commit_attribution_enabled": false,
})))
.mount(&settings_server)
.await;
std::fs::write(
&config_path,
format!(
"chatgpt_base_url = \"{}/backend-api\"\n{config}",
settings_server.uri()
),
)?;
Some(settings_server)
}
} else {
None
};
let (auto_env, delayed_exec_server) = match environment {
TestAppServerEnvironment::Auto => {
let environments_toml = codex_home.join("environments.toml");
@@ -2090,7 +2039,6 @@ impl TestAppServerBuilder {
app_server._owned_install_dir = owned_install_dir;
app_server._owned_codex_home = owned_codex_home;
app_server._delayed_exec_server = delayed_exec_server;
app_server._attribution_settings_server = attribution_settings_server;
Ok(app_server)
}
}

View File

@@ -219,7 +219,6 @@ async fn credentials_stay_out_of_persisted_and_feedback_logs() -> Result<()> {
let codex_home = TempDir::new()?;
let server_uri = server.uri();
MockResponsesConfig::new(&server_uri)
.with_root_config(&format!("chatgpt_base_url = \"{server_uri}/backend-api\""))
.with_provider_config("requires_openai_auth = true\nsupports_websockets = false")
.with_extra_config(&format!(
r#"

View File

@@ -38,7 +38,6 @@ struct CreateConfigTomlParams {
forced_workspace_ids: Option<Vec<String>>,
requires_openai_auth: Option<bool>,
base_url: Option<String>,
chatgpt_base_url: Option<String>,
model_provider_id: Option<String>,
extra_provider_config: Option<String>,
}
@@ -70,10 +69,6 @@ fn create_config_toml(codex_home: &Path, params: CreateConfigTomlParams) -> std:
Some(false) => String::new(),
None => String::new(),
};
let chatgpt_base_url_line = params
.chatgpt_base_url
.map(|url| format!("chatgpt_base_url = \"{url}\"\n"))
.unwrap_or_default();
let model_provider_id = params
.model_provider_id
.unwrap_or_else(|| "mock_provider".to_string());
@@ -96,7 +91,6 @@ stream_max_retries = 0
model = "mock-model"
approval_policy = "never"
sandbox_mode = "danger-full-access"
{chatgpt_base_url_line}
{forced_line}
{forced_workspace_line}
@@ -262,13 +256,7 @@ async fn startup_enforces_local_requirements_without_contacting_the_backend(
let codex_home = TempDir::new()?;
let mock_server = MockServer::start().await;
let require_mxc = "[windows]\nrequire_mxc = true\n";
create_config_toml(
codex_home.path(),
CreateConfigTomlParams {
chatgpt_base_url: Some(format!("{}/backend-api", mock_server.uri())),
..Default::default()
},
)?;
create_config_toml(codex_home.path(), CreateConfigTomlParams::default())?;
std::fs::write(
codex_home.path().join("requirements.toml"),
if local_mxc {
@@ -367,7 +355,6 @@ async fn login_account_api_key_rejected_when_forced_chatgpt() -> Result<()> {
)?;
let mut mcp = TestAppServer::builder()
.with_mock_chatgpt_backend()
.with_codex_home(codex_home.path())
.without_auto_env()
.build_initialized_with_timeout(DEFAULT_READ_TIMEOUT)

View File

@@ -6,7 +6,6 @@ use akode_app_server_protocol::TurnStatus;
use anyhow::Result;
use app_test_support::MockResponsesConfig;
use app_test_support::TestAppServer;
use app_test_support::write_api_key_auth;
use app_test_support::write_models_cache;
use core_test_support::streaming_sse::StreamingSseChunk;
use core_test_support::streaming_sse::start_streaming_sse_server;
@@ -14,51 +13,6 @@ use pretty_assertions::assert_eq;
use std::time::Duration;
use tempfile::TempDir;
use tokio::time::timeout;
use wiremock::Mock;
use wiremock::MockServer;
use wiremock::ResponseTemplate;
use wiremock::matchers::method;
use wiremock::matchers::path;
#[tokio::test]
async fn standalone_startup_applies_local_policy_before_fetching_stored_account_requirements()
-> Result<()> {
let backend = MockServer::start().await;
let bundle_path = "/backend-api/wham/config/bundle";
Mock::given(method("GET"))
.and(path(bundle_path))
.respond_with(ResponseTemplate::new(200).set_body_json(serde_json::json!({})))
.expect(0)
.mount(&backend)
.await;
let home = TempDir::new()?;
std::fs::write(
home.path().join("config.toml"),
format!(
"chatgpt_base_url = '{}/backend-api/'\ncli_auth_credentials_store = 'file'\n",
backend.uri()
),
)?;
std::fs::write(
home.path().join("requirements.toml"),
"[application.network]",
)?;
write_api_key_auth(home.path())?;
let _app = TestAppServer::builder()
.with_codex_home(home.path())
.with_env_overrides(&[("OPENAI_API_KEY", None)])
.build_initialized()
.await?;
assert!(
backend
.received_requests()
.await
.unwrap()
.iter()
.all(|request| request.url.path() != bundle_path)
);
Ok(())
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn explicit_reloads_apply_local_edits_and_cancel_active_responses() -> Result<()> {

View File

@@ -334,7 +334,6 @@ async fn turn_start_sends_nested_subagent_lineage_after_cold_thread_resume_v2()
let codex_home = TempDir::new()?;
MockResponsesConfig::new(&server.uri())
.with_root_config(&format!("chatgpt_base_url = \"{}\"", server.uri()))
.with_provider_config("supports_websockets = false")
.write(codex_home.path())?;
@@ -445,7 +444,6 @@ async fn turn_steer_updates_client_metadata_on_follow_up_responses_request_v2(
responses::mount_response_sequence(&server, vec![first_response, second_response]).await;
MockResponsesConfig::new(&server.uri())
.with_root_config(&format!("chatgpt_base_url = \"{}\"", server.uri()))
.with_provider_config("supports_websockets = false")
.write(codex_home.path())?;

View File

@@ -25,7 +25,7 @@ async fn read_requirements(server: &mut TestAppServer) -> Result<Value> {
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn application_network_defaults_and_null_base_url_are_exposed() -> Result<()> {
async fn application_network_defaults_are_exposed() -> Result<()> {
for (contents, application) in [
("", Value::Null),
("[application]", json!({"network": null, "storage": null})),
@@ -48,13 +48,7 @@ async fn application_network_defaults_and_null_base_url_are_exposed() -> Result<
let requirements = wire["requirements"]
.as_object()
.expect("requirements object");
assert_eq!(
(
requirements.get("application"),
requirements.get("chatgptBaseUrl")
),
(Some(&application), Some(&Value::Null)),
);
assert_eq!(requirements.get("application"), Some(&application));
}
let home = TempDir::new()?;
let mut server = start_server(&home).await?;
@@ -77,7 +71,6 @@ async fn application_destinations_stay_separate_from_agent_network() -> Result<(
home.path().join("requirements.toml"),
format!(
r#"
chatgpt_base_url = "https://managed.example.com/backend-api/"
[{table}.domains]
"github.com" = "allow"
[application.network.domains]
@@ -92,12 +85,10 @@ chatgpt_base_url = "https://managed.example.com/backend-api/"
(
&wire["requirements"]["application"],
&wire["requirements"]["network"]["domains"],
&wire["requirements"]["chatgptBaseUrl"]
),
(
&json!({"network": {"enabled": true, "domains": {"gov.example.com": "allow", "github.com": "deny"}}, "storage": null}),
&json!({"github.com": "allow"}),
&json!("https://managed.example.com/backend-api/")
),
"{table}"
);

View File

@@ -157,17 +157,10 @@ review_domains = ["review.example.com"]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn managed_auth_settings_are_exposed_enforced_and_read_only() -> Result<()> {
let codex_home = TempDir::new()?;
write_config(
&codex_home,
r#"cli_auth_credentials_store = "file"
chatgpt_base_url = "https://user.example/backend-api/"
"#,
)?;
write_config(&codex_home, "cli_auth_credentials_store = \"file\"\n")?;
std::fs::write(
codex_home.path().join("requirements.toml"),
r#"cli_auth_credentials_store = "ephemeral"
chatgpt_base_url = "https://managed.example/backend-api/"
"#,
"cli_auth_credentials_store = \"ephemeral\"\n",
)?;
let mut app_server = TestAppServer::builder()
.with_codex_home(codex_home.path())
@@ -183,14 +176,8 @@ chatgpt_base_url = "https://managed.example/backend-api/"
.await??;
let requirements = requirements.requirements.expect("managed requirements");
assert_eq!(
(
requirements.cli_auth_credentials_store,
requirements.chatgpt_base_url.as_deref(),
),
(
Some(CliAuthCredentialsStoreMode::Ephemeral),
Some("https://managed.example/backend-api/"),
),
requirements.cli_auth_credentials_store,
Some(CliAuthCredentialsStoreMode::Ephemeral),
);
let config_id = app_server
@@ -202,23 +189,11 @@ chatgpt_base_url = "https://managed.example/backend-api/"
let config: ConfigReadResponse =
timeout(DEFAULT_READ_TIMEOUT, app_server.read_response(config_id)).await??;
assert_eq!(
(
config.config.additional.get("cli_auth_credentials_store"),
config.config.additional.get("chatgpt_base_url"),
),
(
Some(&json!("ephemeral")),
Some(&json!("https://managed.example/backend-api/")),
),
config.config.additional.get("cli_auth_credentials_store"),
Some(&json!("ephemeral")),
);
for (field, value) in [
("cli_auth_credentials_store", json!("file")),
(
"chatgpt_base_url",
json!("https://user.example/backend-api/"),
),
] {
for (field, value) in [("cli_auth_credentials_store", json!("file"))] {
let write_id = app_server
.send_config_value_write_request(ConfigValueWriteParams {
file_path: None,
@@ -246,7 +221,7 @@ chatgpt_base_url = "https://managed.example/backend-api/"
assert_eq!(
std::fs::read_to_string(codex_home.path().join("config.toml"))?,
"cli_auth_credentials_store = \"file\"\nchatgpt_base_url = \"https://user.example/backend-api/\"\n",
"cli_auth_credentials_store = \"file\"\n",
);
Ok(())

View File

@@ -1473,10 +1473,7 @@ async fn external_agent_config_import_reports_session_config_error_subtype() ->
.with_env_overrides(&[("HOME", Some(home_dir.as_str()))])
.build_initialized_with_timeout(DEFAULT_TIMEOUT)
.await?;
std::fs::write(
codex_home.path().join("config.toml"),
"chatgpt_base_url = [",
)?;
std::fs::write(codex_home.path().join("config.toml"), "model = [")?;
let request_id = mcp
.send_raw_request(

View File

@@ -218,7 +218,6 @@ approvals_reviewer = "auto_review"
sandbox_mode = "read-only"
cli_auth_credentials_store = "file"
model_provider = "openai"
chatgpt_base_url = "{responses_url}/backend-api"
[features]
guardian_approval = true

View File

@@ -801,10 +801,6 @@ exec "{real_git}" "$@"
MockResponsesConfig::new(&server.uri())
.enable_feature(Feature::Plugins)
.enable_feature(Feature::CodexHooks)
.with_root_config(&format!(
"chatgpt_base_url = \"{}/backend-api/\"",
server.uri()
))
.with_extra_config(&format!(
r#"[plugins."demo@test"]
enabled = true

View File

@@ -113,7 +113,6 @@ requires_openai_auth = true
format!("model_provider = 'gateway'\n{providers}"),
)?;
let mut server = TestAppServer::builder()
.with_mock_chatgpt_backend()
.with_codex_home(home.path())
.with_env_overrides(&[("OPENAI_API_KEY", None)])
.build_initialized_with_timeout(Duration::from_secs(/*secs*/ 60))
@@ -297,7 +296,6 @@ async fn model_list_reuses_catalog_until_account_change() -> Result<()> {
);
std::fs::write(home.path().join("config.toml"), toml::to_string(&config)?)?;
let mut server = TestAppServer::builder()
.with_mock_chatgpt_backend()
.with_codex_home(home.path())
.with_env_overrides(&[("OPENAI_API_KEY", None)])
.build_initialized()
@@ -364,7 +362,6 @@ async fn model_list_preserves_invalid_startup_config_fallback() -> Result<()> {
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)])

View File

@@ -78,10 +78,7 @@ async fn entitlement_access_respects_plugin_provenance(case: AccessCall) -> Resu
MockResponsesConfig::new(&server.uri())
.enable_feature(Feature::Plugins)
.disable_feature(Feature::Apps)
.with_root_config(&format!(
"chatgpt_base_url = \"{}\"\ncli_auth_credentials_store = \"file\"",
server.uri()
))
.with_root_config("cli_auth_credentials_store = \"file\"")
.with_extra_config(&extra_config)
.write(home.path())?;
let api_key = matches!(case, AccessCall::ApiKey).then_some("entitlement-test-api-key");

View File

@@ -14,8 +14,8 @@ use akode_protocol::models::ImageDetail;
use akode_protocol::models::ImageReference;
use akode_protocol::models::ResponseItem;
use anyhow::Result;
use app_test_support::MockResponsesConfig;
use app_test_support::TestAppServer;
use app_test_support::write_mock_responses_config_toml_with_chatgpt_base_url;
use pretty_assertions::assert_eq;
use serde_json::json;
use std::time::Duration;
@@ -155,11 +155,7 @@ async fn thread_start_keeps_unknown_field_compatibility_with_named_permissions()
#[tokio::test]
async fn request_handlers_reject_remote_image_urls() -> Result<()> {
let codex_home = TempDir::new()?;
write_mock_responses_config_toml_with_chatgpt_base_url(
codex_home.path(),
"http://localhost/unused",
"http://localhost/unused",
)?;
MockResponsesConfig::new("http://localhost/unused").write(codex_home.path())?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
.build_initialized_with_timeout(DEFAULT_READ_TIMEOUT)

View File

@@ -17,11 +17,11 @@ use akode_utils_absolute_path::AbsolutePathBuf;
use akode_utils_path_uri::PathUri;
use anyhow::Context;
use anyhow::Result;
use app_test_support::MockResponsesConfig;
use app_test_support::TestAppServer;
use app_test_support::create_final_assistant_message_sse_response;
use app_test_support::to_response;
use app_test_support::write_api_key_auth;
use app_test_support::write_mock_responses_config_toml_with_chatgpt_base_url;
use core_test_support::process::wait_for_pid_file;
use core_test_support::responses;
use core_test_support::responses::ResponsesRequest;
@@ -72,7 +72,7 @@ async fn selected_plugin_mcp_startup_respects_explicit_mentions(
) -> Result<()> {
let explicitly_mentioned = !matches!(mention, PluginMention::Unmentioned);
let responses_server = responses::start_mock_server().await;
let fixture = selected_capability_fixture(&responses_server.uri(), &responses_server.uri())?;
let fixture = selected_capability_fixture(&responses_server.uri())?;
write_api_key_auth(fixture.codex_home.path())?;
let config_path = fixture.codex_home.path().join("config.toml");
let config = std::fs::read_to_string(&config_path)?.replace(
@@ -195,16 +195,9 @@ impl SelectedCapabilityFixture {
}
}
fn selected_capability_fixture(
responses_server_uri: &str,
apps_url: &str,
) -> Result<SelectedCapabilityFixture> {
fn selected_capability_fixture(responses_server_uri: &str) -> Result<SelectedCapabilityFixture> {
let codex_home = TempDir::new()?;
write_mock_responses_config_toml_with_chatgpt_base_url(
codex_home.path(),
responses_server_uri,
apps_url,
)?;
MockResponsesConfig::new(responses_server_uri).write(codex_home.path())?;
let config_path = codex_home.path().join("config.toml");
let config = std::fs::read_to_string(&config_path)?.replacen(
"model_provider = \"mock_provider\"",

View File

@@ -988,9 +988,7 @@ async fn skills_changed_notification_is_emitted_after_skill_change() -> Result<(
let server = create_mock_responses_server_repeating_assistant("Done").await;
let codex_home = TempDir::new()?;
MockResponsesConfig::new(&server.uri())
.with_root_config(&format!("chatgpt_base_url = \"{}\"", server.uri()))
.write(codex_home.path())?;
MockResponsesConfig::new(&server.uri()).write(codex_home.path())?;
write_skill(&codex_home, "demo")?;
let mut mcp = TestAppServer::builder()

View File

@@ -280,9 +280,7 @@ async fn thread_archive_shuts_down_resumed_archived_descendant() -> Result<()> {
async fn thread_archive_without_turns(history_mode: ThreadHistoryMode) -> Result<()> {
let server = create_mock_responses_server_repeating_assistant("Done").await;
let codex_home = TempDir::new()?;
MockResponsesConfig::new(&server.uri())
.with_root_config(&format!(r#"chatgpt_base_url = "{}""#, server.uri()))
.write(codex_home.path())?;
MockResponsesConfig::new(&server.uri()).write(codex_home.path())?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
@@ -519,9 +517,7 @@ async fn thread_archive_and_unarchive_spawned_descendants(fail_child_restore: bo
async fn thread_archive_succeeds_when_descendant_archive_fails() -> Result<()> {
let server = create_mock_responses_server_repeating_assistant("Done").await;
let codex_home = TempDir::new()?;
MockResponsesConfig::new(&server.uri())
.with_root_config(&format!(r#"chatgpt_base_url = "{}""#, server.uri()))
.write(codex_home.path())?;
MockResponsesConfig::new(&server.uri()).write(codex_home.path())?;
let parent_id = create_fake_rollout(
codex_home.path(),

View File

@@ -82,7 +82,6 @@ use app_test_support::create_mock_responses_server_sequence;
use app_test_support::create_mock_responses_server_sequence_unchecked;
use app_test_support::format_with_current_shell_display;
use app_test_support::write_api_key_auth;
use app_test_support::write_mock_responses_config_toml_with_chatgpt_base_url;
use app_test_support::write_models_cache;
use app_test_support::write_models_cache_with_models;
use core_test_support::mcp_test_server::CALENDAR_LIST_EVENTS_TOOL_NAME;
@@ -535,9 +534,7 @@ async fn turn_start_with_empty_input_runs_model_request() -> Result<()> {
let server = create_mock_responses_server_sequence_unchecked(responses).await;
let codex_home = TempDir::new()?;
MockResponsesConfig::new(&server.uri())
.with_root_config(&format!("chatgpt_base_url = \"{}\"", server.uri()))
.write(codex_home.path())?;
MockResponsesConfig::new(&server.uri()).write(codex_home.path())?;
let mut mcp = TestAppServer::builder()
.with_codex_home(codex_home.path())
@@ -1473,11 +1470,7 @@ async fn turn_start_forwards_trigger_and_source_after_retry() -> Result<()> {
.await;
let codex_home = TempDir::new()?;
write_mock_responses_config_toml_with_chatgpt_base_url(
codex_home.path(),
&server.uri(),
&server.uri(),
)?;
MockResponsesConfig::new(&server.uri()).write(codex_home.path())?;
let config_path = codex_home.path().join("config.toml");
let config = std::fs::read_to_string(&config_path)?
.replace("stream_max_retries = 0", "stream_max_retries = 1");
@@ -4022,10 +4015,7 @@ async fn turn_start_emits_spawn_agent_item_with_model_metadata_v2() -> Result<()
let codex_home = TempDir::new()?;
MockResponsesConfig::new(&server.uri())
.enable_feature(Feature::Collab)
.with_root_config(&format!(
"chatgpt_base_url = \"{}\"\ntools.update_plan.enabled = true",
server.uri()
))
.with_root_config("tools.update_plan.enabled = true")
.write(codex_home.path())?;
let mut mcp = TestAppServer::builder()
@@ -4245,7 +4235,6 @@ async fn direct_input_to_multi_agent_v2_subagent_is_rejected(
MockResponsesConfig::new(&server.uri())
.enable_feature(Feature::MultiAgentV2)
.enable_feature(Feature::Goals)
.with_root_config(&format!("chatgpt_base_url = \"{}\"", server.uri()))
.write(codex_home.path())?;
write_models_cache(codex_home.path()).await?;

View File

@@ -20,12 +20,12 @@ use akode_app_server_protocol::UserInput as V2UserInput;
use akode_protocol::user_input::MAX_USER_INPUT_TEXT_CHARS;
use anyhow::Context;
use anyhow::Result;
use app_test_support::MockResponsesConfig;
use app_test_support::TestAppServer;
use app_test_support::create_command_execution_sse_response;
use app_test_support::create_mock_responses_server_sequence;
use app_test_support::create_mock_responses_server_sequence_unchecked;
use app_test_support::write_api_key_auth;
use app_test_support::write_mock_responses_config_toml_with_chatgpt_base_url;
use core_test_support::skip_if_remote;
use pretty_assertions::assert_eq;
use serde_json::Value;
@@ -42,11 +42,7 @@ async fn turn_steer_requires_active_turn() -> Result<()> {
std::fs::create_dir(&codex_home)?;
let server = create_mock_responses_server_sequence(vec![]).await;
write_mock_responses_config_toml_with_chatgpt_base_url(
&codex_home,
&server.uri(),
&server.uri(),
)?;
MockResponsesConfig::new(&server.uri()).write(&codex_home)?;
write_api_key_auth(&codex_home)?;
let mut mcp = TestAppServer::builder()
@@ -153,11 +149,7 @@ async fn turn_steer_rejects_oversized_text_input() -> Result<()> {
)?,
])
.await;
write_mock_responses_config_toml_with_chatgpt_base_url(
&codex_home,
&server.uri(),
&server.uri(),
)?;
MockResponsesConfig::new(&server.uri()).write(&codex_home)?;
write_api_key_auth(&codex_home)?;
let mut mcp = TestAppServer::builder()
@@ -270,11 +262,7 @@ async fn turn_steer_returns_active_turn_id(tool_outputs: bool) -> Result<()> {
app_test_support::create_final_assistant_message_sse_response("Done")?,
])
.await;
write_mock_responses_config_toml_with_chatgpt_base_url(
&codex_home,
&server.uri(),
&server.uri(),
)?;
MockResponsesConfig::new(&server.uri()).write(&codex_home)?;
write_api_key_auth(&codex_home)?;
let mut mcp = TestAppServer::builder()
@@ -441,11 +429,7 @@ async fn turn_steer_rejects_context_only_input_without_merging_context() -> Resu
app_test_support::create_final_assistant_message_sse_response("Done")?,
])
.await;
write_mock_responses_config_toml_with_chatgpt_base_url(
&codex_home,
&server.uri(),
&server.uri(),
)?;
MockResponsesConfig::new(&server.uri()).write(&codex_home)?;
write_api_key_auth(&codex_home)?;
let mut mcp = TestAppServer::builder()