aKode fase 2b-2: rimosso login ChatGPT e tutti i sottosistemi solo-ChatGPT
- Login: resta solo chiave API (+ header, Bedrock). Rimossi OAuth/browser, device code, refresh/revoke su auth.openai.com, PAT, agent/workload identity, runtime agent instance, backend-client e openapi-models, workspace routing. - Rimossi: generazione immagini (ext + skill imagegen), history notes, plugin remoti (catalogo, sync, share), cyber access program, daybreak, cloud config e requirements (config_server ora fail-closed), attestation, frozen cloud skills, EMA MCP auth, Codex Apps/connettori, ricerca ospitata, header/zstd/ routing/cookie del backend Codex, fallback OPENAI_API_KEY del realtime. - Messaggi d'errore senza link a chatgpt.com. - Chiavi di config legacy accettate e ignorate; feature rimosse = Stage::Removed. - Test: cancellati solo quelli del codice rimosso; test di sicurezza (sandbox estensioni, permessi, redazione, auth storage, requirements) adattati. Restano solo fallimenti d'ambiente (code-mode-host/V8, ~/.agents). - Istruzioni di sistema invariate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,7 +19,6 @@ use codex_extension_api::ThreadStartInput;
|
||||
use codex_extension_api::ToolContributor;
|
||||
use codex_http_client::HttpClientFactory;
|
||||
use codex_login::AuthManager;
|
||||
use codex_model_provider::WorkspaceRoutingContext;
|
||||
use codex_model_provider_info::ModelProviderInfo;
|
||||
use codex_protocol::config_types::WebSearchContextSize;
|
||||
use codex_protocol::config_types::WebSearchMode;
|
||||
@@ -45,7 +44,6 @@ impl From<&Config> for WebSearchExtensionConfig {
|
||||
fn from(config: &Config) -> Self {
|
||||
Self {
|
||||
provider_supports_search: config.model_provider.is_openai()
|
||||
|| config.model_provider.uses_openai_actor_authorization()
|
||||
|| config.model_provider.supports_standalone_web_search,
|
||||
http_client_factory: config.http_client_factory(),
|
||||
provider: config.model_provider.clone(),
|
||||
@@ -126,9 +124,8 @@ impl ToolContributor for WebSearchExtension {
|
||||
) -> Vec<
|
||||
Arc<dyn for<'call> codex_extension_api::ToolExecutor<codex_extension_api::ToolCall<'call>>>,
|
||||
> {
|
||||
let (Some(config), Some(workspace_routing), Some(mode)) = (
|
||||
let (Some(config), Some(mode)) = (
|
||||
thread_store.get::<WebSearchExtensionConfig>(),
|
||||
thread_store.get::<WorkspaceRoutingContext>(),
|
||||
step_store.get::<WebSearchMode>(),
|
||||
) else {
|
||||
return Vec::new();
|
||||
@@ -141,7 +138,6 @@ impl ToolContributor for WebSearchExtension {
|
||||
.unwrap_or_else(|| {
|
||||
Arc::new(codex_model_provider::ProviderAuthContext {
|
||||
credentials: Arc::clone(&self.auth_manager),
|
||||
runtime_auth: None,
|
||||
})
|
||||
});
|
||||
|
||||
@@ -149,7 +145,6 @@ impl ToolContributor for WebSearchExtension {
|
||||
session_id: session_store.level_id().to_string(),
|
||||
http_client_factory: config.http_client_factory.clone(),
|
||||
provider: auth.model_provider(config.provider.clone()),
|
||||
workspace_routing,
|
||||
settings: SearchSettings {
|
||||
external_web_access: Some(external_web_access_for_mode(*mode)),
|
||||
..config.settings.clone()
|
||||
@@ -174,10 +169,6 @@ pub fn install(registry: &mut ExtensionRegistryBuilder<Config>, auth_manager: Ar
|
||||
registry.tool_contributor(extension);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "routing_tests.rs"]
|
||||
mod routing_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use codex_extension_api::ExtensionData;
|
||||
@@ -186,7 +177,6 @@ mod tests {
|
||||
use codex_http_client::HttpClientFactory;
|
||||
use codex_http_client::OutboundProxyPolicy;
|
||||
use codex_login::CodexAuth;
|
||||
use codex_model_provider::WorkspaceRoutingContext;
|
||||
use codex_model_provider_info::ModelProviderInfo;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -231,9 +221,6 @@ mod tests {
|
||||
let session_store = ExtensionData::new("session");
|
||||
let thread_store = ExtensionData::new("11111111-1111-4111-8111-111111111111");
|
||||
let step_store = ExtensionData::new("step");
|
||||
thread_store.insert(WorkspaceRoutingContext::new(
|
||||
"https://chatgpt.com/backend-api".to_string(),
|
||||
));
|
||||
step_store.insert(WebSearchMode::Cached);
|
||||
thread_store.insert(WebSearchExtensionConfig {
|
||||
provider_supports_search: true,
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
#![cfg(test)]
|
||||
|
||||
//! Search must retain the host's routing context across thread configuration changes.
|
||||
|
||||
use std::io;
|
||||
use std::sync::Arc;
|
||||
|
||||
use codex_core::config::ConfigBuilder;
|
||||
use codex_extension_api::ConfigContributor;
|
||||
use codex_extension_api::ConversationHistory;
|
||||
use codex_extension_api::ExtensionData;
|
||||
use codex_extension_api::FunctionCallError;
|
||||
use codex_extension_api::NoopTurnItemEmitter;
|
||||
use codex_extension_api::ThreadLifecycleContributor;
|
||||
use codex_extension_api::ThreadStartInput;
|
||||
use codex_extension_api::ToolCall;
|
||||
use codex_extension_api::ToolCallSource;
|
||||
use codex_extension_api::ToolContributor;
|
||||
use codex_extension_api::ToolName;
|
||||
use codex_extension_api::ToolPayload;
|
||||
use codex_login::AuthManager;
|
||||
use codex_login::CodexAuth;
|
||||
use codex_login::WorkspaceRouting;
|
||||
use codex_login::WorkspaceRoutingRequest;
|
||||
use codex_login::WorkspaceRoutingResolver;
|
||||
use codex_model_provider::ModelProviderFuture;
|
||||
use codex_model_provider::WorkspaceRoutingContext;
|
||||
use codex_model_provider_info::ModelProviderInfo;
|
||||
use codex_protocol::config_types::WebSearchMode;
|
||||
use codex_protocol::protocol::SessionSource;
|
||||
use codex_protocol::protocol::TruncationPolicy;
|
||||
use serde_json::json;
|
||||
|
||||
use super::WebSearchExtension;
|
||||
|
||||
#[tokio::test]
|
||||
async fn config_changes_preserve_the_threads_established_routing() {
|
||||
struct ReportBootstrap;
|
||||
|
||||
impl WorkspaceRoutingResolver for ReportBootstrap {
|
||||
fn resolve(
|
||||
&self,
|
||||
request: WorkspaceRoutingRequest,
|
||||
) -> ModelProviderFuture<'_, io::Result<Option<WorkspaceRouting>>> {
|
||||
Box::pin(async move { Err(io::Error::other(request.chatgpt_base_url)) })
|
||||
}
|
||||
}
|
||||
|
||||
let home = tempfile::tempdir().unwrap();
|
||||
let mut config = ConfigBuilder::default()
|
||||
.codex_home(home.path().to_path_buf())
|
||||
.fallback_cwd(Some(home.path().to_path_buf()))
|
||||
.build()
|
||||
.await
|
||||
.unwrap();
|
||||
config.web_search_mode.set(WebSearchMode::Cached).unwrap();
|
||||
config.model_provider = ModelProviderInfo::create_openai_provider(Some(
|
||||
"http://127.0.0.1:0/backend-api/codex".into(),
|
||||
));
|
||||
let auth_manager =
|
||||
AuthManager::from_auth_for_testing(CodexAuth::create_dummy_chatgpt_auth_for_testing());
|
||||
let resolver: Arc<dyn WorkspaceRoutingResolver> = Arc::new(ReportBootstrap);
|
||||
auth_manager.set_workspace_routing_resolver(Arc::downgrade(&resolver));
|
||||
let session_store = ExtensionData::new("session");
|
||||
let thread_store = ExtensionData::new("thread");
|
||||
// Use a thread bootstrap distinct from either config so reconstructing it is observable.
|
||||
let thread_bootstrap = "https://thread.example/backend-api";
|
||||
thread_store.insert(WorkspaceRoutingContext::new(thread_bootstrap.into()));
|
||||
let extension = WebSearchExtension { auth_manager };
|
||||
extension
|
||||
.on_thread_start(ThreadStartInput {
|
||||
config: &config,
|
||||
session_source: &SessionSource::Exec,
|
||||
persistent_thread_state_available: false,
|
||||
environments: &[],
|
||||
mcp_resource_client: None,
|
||||
extension_metrics: None,
|
||||
session_store: &session_store,
|
||||
thread_store: &thread_store,
|
||||
})
|
||||
.await;
|
||||
let mut changed = config.clone();
|
||||
changed.chatgpt_base_url = "https://changed.example/backend-api".into();
|
||||
extension.on_config_changed(&session_store, &thread_store, &config, &changed);
|
||||
let step_store = ExtensionData::new("step");
|
||||
step_store.insert(config.web_search_mode.value());
|
||||
let tools = extension.tools_for_step(&session_store, &thread_store, &step_store);
|
||||
let call = ToolCall {
|
||||
turn_id: "turn".into(),
|
||||
call_id: "search".into(),
|
||||
tool_name: ToolName::namespaced("web", "run"),
|
||||
model: "test-model".into(),
|
||||
codex_turn_metadata: None,
|
||||
truncation_policy: TruncationPolicy::Bytes(1024),
|
||||
source: ToolCallSource::Direct,
|
||||
conversation_history: ConversationHistory::default(),
|
||||
turn_item_emitter: Arc::new(NoopTurnItemEmitter),
|
||||
attachment_store: codex_core::passthrough_image_store(),
|
||||
ephemeral: false,
|
||||
environments: Vec::new(),
|
||||
payload: ToolPayload::Function {
|
||||
arguments: json!({"search_query": [{"q": "test"}]}).to_string(),
|
||||
},
|
||||
};
|
||||
assert!(matches!(
|
||||
tools[0].handle(call).await,
|
||||
Err(FunctionCallError::RespondToModel(message)) if message == thread_bootstrap
|
||||
));
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use codex_api::ReqwestTransport;
|
||||
use codex_api::SearchClient;
|
||||
@@ -26,9 +25,7 @@ use codex_login::default_client::ClientRedirectPolicy;
|
||||
use codex_login::default_client::add_originator_header;
|
||||
use codex_login::default_client::create_client_for_route_async;
|
||||
use codex_login::default_client::create_transport_for_routes_async;
|
||||
use codex_model_provider::ACCOUNT_ROUTING_HEADER;
|
||||
use codex_model_provider::SharedModelProvider;
|
||||
use codex_model_provider::WorkspaceRoutingContext;
|
||||
use codex_protocol::models::WebSearchAction as CoreWebSearchAction;
|
||||
use codex_protocol::protocol::EventMsg;
|
||||
use codex_protocol::protocol::WebSearchBeginEvent;
|
||||
@@ -55,7 +52,6 @@ pub(crate) struct WebSearchTool {
|
||||
pub(crate) session_id: String,
|
||||
pub(crate) http_client_factory: HttpClientFactory,
|
||||
pub(crate) provider: SharedModelProvider,
|
||||
pub(crate) workspace_routing: Arc<WorkspaceRoutingContext>,
|
||||
pub(crate) settings: SearchSettings,
|
||||
pub(crate) supports_literature_search: bool,
|
||||
pub(crate) originator: Option<String>,
|
||||
@@ -113,18 +109,11 @@ impl WebSearchTool {
|
||||
let command_action = command_action(&commands);
|
||||
let setup = codex_model_provider::resolve_request(
|
||||
self.provider.as_ref(),
|
||||
/*scope*/ None,
|
||||
Some(&self.workspace_routing),
|
||||
self.http_client_factory.clone(),
|
||||
)
|
||||
.await
|
||||
.map_err(|err| FunctionCallError::RespondToModel(search_error_message(err)))?;
|
||||
let transport = if setup.redirect_policy == ClientRedirectPolicy::Reject
|
||||
|| setup
|
||||
.api_provider
|
||||
.headers
|
||||
.contains_key(ACCOUNT_ROUTING_HEADER)
|
||||
{
|
||||
let transport = if setup.redirect_policy == ClientRedirectPolicy::Reject {
|
||||
create_client_for_route_async(
|
||||
setup.http_client_factory,
|
||||
setup.api_provider.url_for_path("alpha/search"),
|
||||
|
||||
Reference in New Issue
Block a user