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

@@ -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()