This commit is contained in:
Owen Lin
2026-05-19 12:49:53 -07:00
parent 94a78f45ec
commit 8eadd5249d
26 changed files with 248 additions and 451 deletions
+28 -57
View File
@@ -233,14 +233,14 @@ impl ConnectionSessionState {
self.initialized
.get()
.and_then(|session| session.originator.app_server_client())
.map(|client| client.name())
.map(codex_login::default_client::AppServerClient::name)
}
pub(crate) fn client_version(&self) -> Option<&str> {
self.initialized
.get()
.and_then(|session| session.originator.app_server_client())
.map(|client| client.version())
.map(codex_login::default_client::AppServerClient::version)
}
pub(crate) fn originator(&self) -> Option<Originator> {
@@ -810,7 +810,12 @@ impl MessageProcessor {
);
let serialization_scope = codex_request.serialization_scope();
let originator = session.originator();
let Some(originator) = session.originator() else {
return Err(crate::error_code::internal_error(
"initialized session is missing originator",
));
};
let request_context = request_context.with_originator(originator);
let error_request_id = connection_request_id.clone();
let rpc_gate = Arc::clone(&session.rpc_gate);
let processor = Arc::clone(self);
@@ -824,7 +829,6 @@ impl MessageProcessor {
connection_request_id,
codex_request,
request_context,
originator,
)
.await;
if let Err(error) = result {
@@ -852,16 +856,12 @@ impl MessageProcessor {
connection_request_id: ConnectionRequestId,
codex_request: ClientRequest,
request_context: RequestContext,
originator: Option<Originator>,
) -> Result<(), JSONRPCErrorError> {
let connection_id = connection_request_id.connection_id;
let request_id = ConnectionRequestId {
connection_id,
request_id: codex_request.id().clone(),
};
let app_server_client = originator.as_ref().and_then(Originator::app_server_client);
let app_server_client_name = app_server_client.map(|client| client.name().to_string());
let client_version = app_server_client.map(|client| client.version().to_string());
let result: Result<Option<ClientResponsePayload>, JSONRPCErrorError> = match codex_request {
ClientRequest::Initialize { .. } => {
@@ -884,7 +884,7 @@ impl MessageProcessor {
.map(|response| Some(response.into())),
ClientRequest::ExternalAgentConfigImport { params, .. } => self
.external_agent_config_processor
.import(request_id.clone(), params)
.import(request_id.clone(), params, &request_context)
.await
.map(|()| None),
ClientRequest::ConfigValueWrite { params, .. } => {
@@ -895,11 +895,7 @@ impl MessageProcessor {
}
ClientRequest::ExperimentalFeatureEnablementSet { params, .. } => {
self.config_processor
.experimental_feature_enablement_set(
request_id.clone(),
params,
originator.as_ref(),
)
.experimental_feature_enablement_set(&request_context, params)
.await
}
ClientRequest::RemoteControlEnable { .. } => self
@@ -974,14 +970,7 @@ impl MessageProcessor {
.map(|response| Some(response.into())),
ClientRequest::ThreadStart { params, .. } => {
self.thread_processor
.thread_start(
request_id.clone(),
params,
app_server_client_name.clone(),
client_version.clone(),
originator.clone(),
request_context,
)
.thread_start(request_id.clone(), params, request_context)
.await
}
ClientRequest::ThreadUnsubscribe { params, .. } => {
@@ -991,24 +980,12 @@ impl MessageProcessor {
}
ClientRequest::ThreadResume { params, .. } => {
self.thread_processor
.thread_resume(
request_id.clone(),
params,
app_server_client_name.clone(),
client_version.clone(),
originator.clone(),
)
.thread_resume(request_id.clone(), params, &request_context)
.await
}
ClientRequest::ThreadFork { params, .. } => {
self.thread_processor
.thread_fork(
request_id.clone(),
params,
app_server_client_name.clone(),
client_version.clone(),
originator.clone(),
)
.thread_fork(request_id.clone(), params, &request_context)
.await
}
ClientRequest::ThreadArchive { params, .. } => {
@@ -1116,52 +1093,52 @@ impl MessageProcessor {
}
ClientRequest::PluginList { params, .. } => {
self.plugin_processor
.plugin_list(params, originator.as_ref())
.plugin_list(params, &request_context)
.await
}
ClientRequest::PluginInstalled { params, .. } => {
self.plugin_processor
.plugin_installed(params, originator.as_ref())
.plugin_installed(params, &request_context)
.await
}
ClientRequest::PluginRead { params, .. } => {
self.plugin_processor
.plugin_read(params, originator.as_ref())
.plugin_read(params, &request_context)
.await
}
ClientRequest::PluginSkillRead { params, .. } => {
self.plugin_processor
.plugin_skill_read(params, originator.as_ref())
.plugin_skill_read(params, &request_context)
.await
}
ClientRequest::PluginShareSave { params, .. } => {
self.plugin_processor
.plugin_share_save(params, originator.as_ref())
.plugin_share_save(params, &request_context)
.await
}
ClientRequest::PluginShareUpdateTargets { params, .. } => {
self.plugin_processor
.plugin_share_update_targets(params, originator.as_ref())
.plugin_share_update_targets(params, &request_context)
.await
}
ClientRequest::PluginShareList { params, .. } => {
self.plugin_processor
.plugin_share_list(params, originator.as_ref())
.plugin_share_list(params, &request_context)
.await
}
ClientRequest::PluginShareCheckout { params, .. } => {
self.plugin_processor
.plugin_share_checkout(params, originator.as_ref())
.plugin_share_checkout(params, &request_context)
.await
}
ClientRequest::PluginShareDelete { params, .. } => {
self.plugin_processor
.plugin_share_delete(params, originator.as_ref())
.plugin_share_delete(params, &request_context)
.await
}
ClientRequest::AppsList { params, .. } => {
self.apps_processor
.apps_list(&request_id, params, originator.as_ref())
.apps_list(&request_context, params)
.await
}
ClientRequest::SkillsConfigWrite { params, .. } => {
@@ -1169,17 +1146,17 @@ impl MessageProcessor {
}
ClientRequest::PluginInstall { params, .. } => {
self.plugin_processor
.plugin_install(params, originator.as_ref())
.plugin_install(params, &request_context)
.await
}
ClientRequest::PluginUninstall { params, .. } => {
self.plugin_processor
.plugin_uninstall(params, originator.as_ref())
.plugin_uninstall(params, &request_context)
.await
}
ClientRequest::ModelList { params, .. } => {
self.catalog_processor
.model_list(params, originator.clone())
.model_list(params, &request_context)
.await
}
ClientRequest::ExperimentalFeatureList { params, .. } => {
@@ -1197,13 +1174,7 @@ impl MessageProcessor {
}
ClientRequest::TurnStart { params, .. } => {
self.turn_processor
.turn_start(
request_id.clone(),
params,
app_server_client_name.clone(),
client_version.clone(),
originator.clone(),
)
.turn_start(request_id.clone(), params, &request_context)
.await
}
ClientRequest::ThreadInjectItems { params, .. } => {
@@ -1242,7 +1213,7 @@ impl MessageProcessor {
}
ClientRequest::ReviewStart { params, .. } => {
self.turn_processor
.review_start(&request_id, params, originator.clone())
.review_start(&request_id, params, &request_context)
.await
}
ClientRequest::McpServerOauthLogin { params, .. } => {
@@ -14,6 +14,7 @@ use codex_app_server_protocol::ServerNotification;
use codex_app_server_protocol::ServerRequest;
use codex_app_server_protocol::ServerRequestPayload;
use codex_app_server_protocol::ServerResponse;
use codex_login::default_client::Originator;
use codex_otel::span_w3c_trace_context;
use codex_protocol::ThreadId;
use codex_protocol::protocol::W3cTraceContext;
@@ -52,6 +53,7 @@ pub(crate) struct RequestContext {
request_id: ConnectionRequestId,
span: Span,
parent_trace: Option<W3cTraceContext>,
originator: Originator,
}
impl RequestContext {
@@ -64,9 +66,23 @@ impl RequestContext {
request_id,
span,
parent_trace,
originator: Originator::process_default(),
}
}
pub(crate) fn with_originator(mut self, originator: Originator) -> Self {
self.originator = originator;
self
}
pub(crate) fn request_id(&self) -> &ConnectionRequestId {
&self.request_id
}
pub(crate) fn originator(&self) -> &Originator {
&self.originator
}
pub(crate) fn request_trace(&self) -> Option<W3cTraceContext> {
span_w3c_trace_context(&self.span).or_else(|| self.parent_trace.clone())
}
@@ -331,6 +331,7 @@ use codex_login::ServerOptions as LoginServerOptions;
use codex_login::ShutdownHandle;
use codex_login::auth::login_with_chatgpt_auth_tokens;
use codex_login::complete_device_code_login;
use codex_login::default_client::AppServerClient;
use codex_login::default_client::Originator;
use codex_login::login_with_api_key;
use codex_login::request_device_code;
@@ -28,20 +28,18 @@ impl AppsRequestProcessor {
pub(crate) async fn apps_list(
&self,
request_id: &ConnectionRequestId,
request_context: &RequestContext,
params: AppsListParams,
originator: Option<&Originator>,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.apps_list_inner(request_id, params, originator)
self.apps_list_inner(request_context, params)
.await
.map(|response| response.map(Into::into))
}
async fn apps_list_inner(
&self,
request_id: &ConnectionRequestId,
request_context: &RequestContext,
params: AppsListParams,
originator: Option<&Originator>,
) -> Result<Option<AppsListResponse>, JSONRPCErrorError> {
let thread = if let Some(thread_id) = params.thread_id.as_deref() {
let (_, loaded_thread) = self.load_thread(thread_id).await?;
@@ -82,12 +80,10 @@ impl AppsRequestProcessor {
}));
}
let request = request_id.clone();
let request = request_context.request_id().clone();
let outgoing = Arc::clone(&self.outgoing);
let environment_manager = self.thread_manager.environment_manager();
let originator = originator
.cloned()
.unwrap_or_else(Originator::process_default);
let originator = request_context.originator().clone();
tokio::spawn(async move {
Self::apps_list_task(
outgoing,
@@ -140,11 +140,15 @@ impl CatalogRequestProcessor {
pub(crate) async fn model_list(
&self,
params: ModelListParams,
originator: Option<Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
Self::list_models(self.thread_manager.clone(), params, originator)
.await
.map(|response| Some(response.into()))
Self::list_models(
self.thread_manager.clone(),
params,
Some(request_context.originator().clone()),
)
.await
.map(|response| Some(response.into()))
}
pub(crate) async fn experimental_feature_list(
@@ -4,8 +4,8 @@ use crate::config_manager::ConfigManager;
use crate::config_manager_service::ConfigManagerError;
use crate::error_code::internal_error;
use crate::error_code::invalid_request;
use crate::outgoing_message::ConnectionRequestId;
use crate::outgoing_message::OutgoingMessageSender;
use crate::outgoing_message::RequestContext;
use codex_analytics::AnalyticsEventsClient;
use codex_app_server_protocol::AppListUpdatedNotification;
use codex_app_server_protocol::ClientResponsePayload;
@@ -146,20 +146,17 @@ impl ConfigRequestProcessor {
pub(crate) async fn experimental_feature_enablement_set(
&self,
request_id: ConnectionRequestId,
request_context: &RequestContext,
params: ExperimentalFeatureEnablementSetParams,
originator: Option<&Originator>,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
let originator = originator
.cloned()
.unwrap_or_else(Originator::process_default);
let originator = request_context.originator().clone();
let should_refresh_apps_list = params.enablement.get("apps").copied() == Some(true);
let response = self
.handle_config_mutation_result(self.set_experimental_feature_enablement(params).await)
.await?;
self.outgoing
.send_response_as(
request_id,
request_context.request_id().clone(),
ClientResponsePayload::ExperimentalFeatureEnablementSet(response),
)
.await;
@@ -11,6 +11,7 @@ use crate::error_code::internal_error;
use crate::error_code::invalid_params;
use crate::outgoing_message::ConnectionRequestId;
use crate::outgoing_message::OutgoingMessageSender;
use crate::outgoing_message::RequestContext;
use codex_app_server_protocol::CommandMigration;
use codex_app_server_protocol::ExternalAgentConfigDetectParams;
use codex_app_server_protocol::ExternalAgentConfigDetectResponse;
@@ -34,6 +35,7 @@ use codex_external_agent_sessions::ImportedExternalAgentSession;
use codex_external_agent_sessions::PendingSessionImport;
use codex_external_agent_sessions::prepare_validated_session_imports;
use codex_external_agent_sessions::record_imported_session;
use codex_login::default_client::Originator;
use codex_protocol::ThreadId;
use codex_protocol::protocol::InitialHistory;
use codex_thread_store::ThreadMetadataPatch;
@@ -174,6 +176,7 @@ impl ExternalAgentConfigRequestProcessor {
&self,
request_id: ConnectionRequestId,
params: ExternalAgentConfigImportParams,
request_context: &RequestContext,
) -> Result<(), JSONRPCErrorError> {
let needs_runtime_refresh = migration_items_need_runtime_refresh(&params.migration_items);
let has_migration_items = !params.migration_items.is_empty();
@@ -212,6 +215,7 @@ impl ExternalAgentConfigRequestProcessor {
let plugin_processor = self.clone();
let outgoing = Arc::clone(&self.outgoing);
let thread_manager = Arc::clone(&self.thread_manager);
let originator = request_context.originator().clone();
tokio::spawn(async move {
let session_imports = async move {
if !pending_session_imports.is_empty() {
@@ -223,7 +227,10 @@ impl ExternalAgentConfigRequestProcessor {
.prepare_validated_session_imports(pending_session_imports);
for pending_session_import in pending_session_imports {
match session_processor
.import_external_agent_session(pending_session_import.session)
.import_external_agent_session(
pending_session_import.session,
originator.clone(),
)
.await
{
Ok(imported_thread_id) => {
@@ -277,6 +284,7 @@ impl ExternalAgentConfigRequestProcessor {
async fn import_external_agent_session(
&self,
session: ImportedExternalAgentSession,
originator: Originator,
) -> Result<ThreadId, JSONRPCErrorError> {
let ImportedExternalAgentSession {
cwd,
@@ -313,9 +321,7 @@ impl ExternalAgentConfigRequestProcessor {
metrics_service_name: None,
parent_trace: None,
environments,
app_server_client_name: None,
app_server_client_version: None,
originator: None,
originator,
})
.await
.map_err(|err| internal_error(format!("failed to import session: {err}")))?;
@@ -13,7 +13,6 @@ use codex_mcp::McpOAuthLoginSupport;
use codex_mcp::oauth_login_support;
use codex_mcp::should_retry_without_scopes;
use codex_rmcp_client::perform_oauth_login_silent;
use std::borrow::Cow;
#[derive(Clone)]
pub(crate) struct PluginRequestProcessor {
@@ -51,13 +50,6 @@ fn plugin_skills_to_info(
.collect()
}
fn originator_or_process(originator: Option<&Originator>) -> Cow<'_, Originator> {
match originator {
Some(originator) => Cow::Borrowed(originator),
None => Cow::Owned(Originator::process_default()),
}
}
fn local_plugin_interface_to_info(interface: PluginManifestInterface) -> PluginInterface {
PluginInterface {
display_name: interface.display_name,
@@ -304,9 +296,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_list(
&self,
params: PluginListParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_list_response(params, originator)
self.plugin_list_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -314,9 +306,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_installed(
&self,
params: PluginInstalledParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_installed_response(params, originator)
self.plugin_installed_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -324,9 +316,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_read(
&self,
params: PluginReadParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_read_response(params, originator)
self.plugin_read_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -334,9 +326,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_skill_read(
&self,
params: PluginSkillReadParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_skill_read_response(params, originator)
self.plugin_skill_read_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -344,9 +336,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_share_save(
&self,
params: PluginShareSaveParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_share_save_response(params, originator)
self.plugin_share_save_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -354,9 +346,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_share_update_targets(
&self,
params: PluginShareUpdateTargetsParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_share_update_targets_response(params, originator)
self.plugin_share_update_targets_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -364,9 +356,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_share_list(
&self,
params: PluginShareListParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_share_list_response(params, originator)
self.plugin_share_list_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -374,9 +366,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_share_checkout(
&self,
params: PluginShareCheckoutParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_share_checkout_response(params, originator)
self.plugin_share_checkout_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -384,9 +376,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_share_delete(
&self,
params: PluginShareDeleteParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_share_delete_response(params, originator)
self.plugin_share_delete_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -394,9 +386,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_install(
&self,
params: PluginInstallParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_install_response(params, originator)
self.plugin_install_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -404,9 +396,9 @@ impl PluginRequestProcessor {
pub(crate) async fn plugin_uninstall(
&self,
params: PluginUninstallParams,
originator: Option<&Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.plugin_uninstall_response(params, originator)
self.plugin_uninstall_response(params, request_context.originator())
.await
.map(|response| Some(response.into()))
}
@@ -483,7 +475,7 @@ impl PluginRequestProcessor {
async fn plugin_list_response(
&self,
params: PluginListParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginListResponse, JSONRPCErrorError> {
let plugins_manager = self.thread_manager.plugins_manager();
let PluginListParams {
@@ -597,14 +589,13 @@ impl PluginRequestProcessor {
remote_sources.push(RemoteMarketplaceSource::SharedWithMe);
}
if !remote_sources.is_empty() {
let originator = originator_or_process(originator);
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
match codex_core_plugins::remote::fetch_remote_marketplaces(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
&remote_sources,
)
.await
@@ -683,7 +674,7 @@ impl PluginRequestProcessor {
async fn plugin_installed_response(
&self,
params: PluginInstalledParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginInstalledResponse, JSONRPCErrorError> {
let plugins_manager = self.thread_manager.plugins_manager();
let PluginInstalledParams {
@@ -834,19 +825,18 @@ impl PluginRequestProcessor {
plugins_input: &codex_core_plugins::PluginsConfigInput,
visible_scopes: &[RemotePluginScope],
auth: Option<&CodexAuth>,
originator: Option<&Originator>,
originator: &Originator,
) -> Vec<PluginMarketplaceEntry> {
let remote_marketplaces = if let Some(remote_marketplaces) =
plugins_manager.build_remote_installed_plugin_marketplaces_from_cache(visible_scopes)
{
Ok(remote_marketplaces)
} else {
let originator = originator_or_process(originator);
plugins_manager
.build_and_cache_remote_installed_plugin_marketplaces(
plugins_input,
auth,
originator.as_ref(),
originator,
visible_scopes,
Some(self.effective_plugins_changed_callback()),
)
@@ -875,7 +865,7 @@ impl PluginRequestProcessor {
async fn plugin_read_response(
&self,
params: PluginReadParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginReadResponse, JSONRPCErrorError> {
let plugins_manager = self.thread_manager.plugins_manager();
let PluginReadParams {
@@ -921,11 +911,10 @@ impl PluginRequestProcessor {
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let request_originator = originator_or_process(originator);
match codex_core_plugins::remote::fetch_remote_plugin_share_context(
&remote_plugin_service_config,
auth.as_ref(),
request_originator.as_ref(),
originator,
&context.remote_plugin_id,
)
.await
@@ -1031,11 +1020,10 @@ impl PluginRequestProcessor {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
validate_remote_plugin_id(&plugin_name)?;
let request_originator = originator_or_process(originator);
let remote_detail = codex_core_plugins::remote::fetch_remote_plugin_detail(
&remote_plugin_service_config,
auth.as_ref(),
request_originator.as_ref(),
originator,
&remote_marketplace_name,
&plugin_name,
)
@@ -1054,7 +1042,7 @@ impl PluginRequestProcessor {
&config,
&plugin_apps,
&environment_manager,
Some(request_originator.as_ref()),
originator,
)
.await;
remote_plugin_detail_to_info(remote_detail, app_summaries)
@@ -1067,7 +1055,7 @@ impl PluginRequestProcessor {
async fn plugin_skill_read_response(
&self,
params: PluginSkillReadParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginSkillReadResponse, JSONRPCErrorError> {
let PluginSkillReadParams {
remote_marketplace_name,
@@ -1092,11 +1080,10 @@ impl PluginRequestProcessor {
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let originator = originator_or_process(originator);
let remote_skill_detail = codex_core_plugins::remote::fetch_remote_plugin_skill_detail(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
&remote_marketplace_name,
&remote_plugin_id,
&skill_name,
@@ -1114,7 +1101,7 @@ impl PluginRequestProcessor {
async fn plugin_share_save_response(
&self,
params: PluginShareSaveParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginShareSaveResponse, JSONRPCErrorError> {
let (config, auth) = self.load_plugin_share_config_and_auth().await?;
if !config.features.enabled(Feature::PluginSharing) {
@@ -1148,7 +1135,6 @@ impl PluginRequestProcessor {
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let originator = originator_or_process(originator);
let access_policy = codex_core_plugins::remote::RemotePluginShareAccessPolicy {
discoverability: discoverability.map(remote_plugin_share_discoverability),
share_targets: share_targets.map(remote_plugin_share_targets),
@@ -1156,7 +1142,7 @@ impl PluginRequestProcessor {
let result = codex_core_plugins::remote::save_remote_plugin_share(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
config.codex_home.as_path(),
&plugin_path,
remote_plugin_id.as_deref(),
@@ -1175,7 +1161,7 @@ impl PluginRequestProcessor {
async fn plugin_share_update_targets_response(
&self,
params: PluginShareUpdateTargetsParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginShareUpdateTargetsResponse, JSONRPCErrorError> {
let (config, auth) = self.load_plugin_share_config_and_auth().await?;
if !config.features.enabled(Feature::PluginSharing) {
@@ -1194,11 +1180,10 @@ impl PluginRequestProcessor {
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let originator = originator_or_process(originator);
let result = codex_core_plugins::remote::update_remote_plugin_share_targets(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
&remote_plugin_id,
remote_plugin_share_targets(share_targets),
remote_plugin_share_update_discoverability(discoverability),
@@ -1221,17 +1206,16 @@ impl PluginRequestProcessor {
async fn plugin_share_list_response(
&self,
_params: PluginShareListParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginShareListResponse, JSONRPCErrorError> {
let (config, auth) = self.load_plugin_share_config_and_auth().await?;
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let originator = originator_or_process(originator);
let data = codex_core_plugins::remote::list_remote_plugin_shares(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
config.codex_home.as_path(),
)
.await
@@ -1255,7 +1239,7 @@ impl PluginRequestProcessor {
async fn plugin_share_checkout_response(
&self,
params: PluginShareCheckoutParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginShareCheckoutResponse, JSONRPCErrorError> {
let (config, auth) = self.load_plugin_share_config_and_auth().await?;
if !config.features.enabled(Feature::PluginSharing) {
@@ -1269,11 +1253,10 @@ impl PluginRequestProcessor {
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let originator = originator_or_process(originator);
let result = codex_core_plugins::remote::checkout_remote_plugin_share(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
config.codex_home.as_path(),
&remote_plugin_id,
)
@@ -1294,7 +1277,7 @@ impl PluginRequestProcessor {
async fn plugin_share_delete_response(
&self,
params: PluginShareDeleteParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginShareDeleteResponse, JSONRPCErrorError> {
let (config, auth) = self.load_plugin_share_config_and_auth().await?;
let PluginShareDeleteParams { remote_plugin_id } = params;
@@ -1305,11 +1288,10 @@ impl PluginRequestProcessor {
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let originator = originator_or_process(originator);
codex_core_plugins::remote::delete_remote_plugin_share(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
config.codex_home.as_path(),
&remote_plugin_id,
)
@@ -1333,7 +1315,7 @@ impl PluginRequestProcessor {
async fn plugin_install_response(
&self,
params: PluginInstallParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginInstallResponse, JSONRPCErrorError> {
let PluginInstallParams {
marketplace_path,
@@ -1420,7 +1402,7 @@ impl PluginRequestProcessor {
&self,
remote_marketplace_name: String,
remote_plugin_id: String,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginInstallResponse, JSONRPCErrorError> {
let config = self.load_latest_config(/*fallback_cwd*/ None).await?;
if !config.features.enabled(Feature::Plugins) {
@@ -1434,12 +1416,11 @@ impl PluginRequestProcessor {
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let originator = originator_or_process(originator);
let remote_detail =
codex_core_plugins::remote::fetch_remote_plugin_detail_with_download_urls(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
&remote_marketplace_name,
&remote_plugin_id,
)
@@ -1491,7 +1472,7 @@ impl PluginRequestProcessor {
codex_core_plugins::remote::install_remote_plugin(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
&actual_remote_marketplace_name,
&remote_plugin_id,
)
@@ -1525,7 +1506,7 @@ impl PluginRequestProcessor {
auth.as_ref().is_some_and(CodexAuth::is_chatgpt_auth),
&result.plugin_id.as_key(),
&plugin_apps,
Some(originator.as_ref()),
originator,
)
.await;
@@ -1541,20 +1522,17 @@ impl PluginRequestProcessor {
is_chatgpt_auth: bool,
plugin_id: &str,
plugin_apps: &[codex_plugin::AppConnectorId],
originator: Option<&Originator>,
originator: &Originator,
) -> Vec<AppSummary> {
if plugin_apps.is_empty() || !config.features.apps_enabled_for_auth(is_chatgpt_auth) {
return Vec::new();
}
let environment_manager = self.thread_manager.environment_manager();
let originator = originator_or_process(originator);
let originator_value = originator.value().to_string();
let (all_connectors_result, accessible_connectors_result) = tokio::join!(
connectors::list_all_connectors_with_options_and_originator(
config,
/*force_refetch*/ true,
originator.as_ref(),
config, /*force_refetch*/ true, originator,
),
connectors::list_accessible_connectors_from_mcp_tools_with_environment_manager(
config,
@@ -1571,7 +1549,7 @@ impl PluginRequestProcessor {
plugin = plugin_id,
"failed to load app metadata after plugin install: {err:#}"
);
connectors::list_cached_all_connectors_with_originator(config, originator.as_ref())
connectors::list_cached_all_connectors_with_originator(config, originator)
.await
.unwrap_or_default()
}
@@ -1698,7 +1676,7 @@ impl PluginRequestProcessor {
async fn plugin_uninstall_response(
&self,
params: PluginUninstallParams,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginUninstallResponse, JSONRPCErrorError> {
let PluginUninstallParams { plugin_id } = params;
if codex_plugin::PluginId::parse(&plugin_id).is_err()
@@ -1792,7 +1770,7 @@ impl PluginRequestProcessor {
async fn remote_plugin_uninstall_response(
&self,
plugin_id: String,
originator: Option<&Originator>,
originator: &Originator,
) -> Result<PluginUninstallResponse, JSONRPCErrorError> {
let config = self.load_latest_config(/*fallback_cwd*/ None).await?;
if !config.features.enabled(Feature::Plugins) {
@@ -1804,11 +1782,10 @@ impl PluginRequestProcessor {
let remote_plugin_service_config = RemotePluginServiceConfig {
chatgpt_base_url: config.chatgpt_base_url.clone(),
};
let originator = originator_or_process(originator);
let uninstall_result = codex_core_plugins::remote::uninstall_remote_plugin(
&remote_plugin_service_config,
auth.as_ref(),
originator.as_ref(),
originator,
config.codex_home.to_path_buf(),
&plugin_id,
)
@@ -1840,25 +1817,22 @@ async fn load_plugin_app_summaries(
config: &Config,
plugin_apps: &[codex_plugin::AppConnectorId],
environment_manager: &EnvironmentManager,
originator: Option<&Originator>,
originator: &Originator,
) -> Vec<AppSummary> {
if plugin_apps.is_empty() {
return Vec::new();
}
let originator = originator_or_process(originator);
let originator_value = originator.value().to_string();
let connectors = match connectors::list_all_connectors_with_options_and_originator(
config,
/*force_refetch*/ false,
originator.as_ref(),
config, /*force_refetch*/ false, originator,
)
.await
{
Ok(connectors) => connectors,
Err(err) => {
warn!("failed to load app metadata for plugin/read: {err:#}");
connectors::list_cached_all_connectors_with_originator(config, originator.as_ref())
connectors::list_cached_all_connectors_with_originator(config, originator)
.await
.unwrap_or_default()
}
@@ -382,21 +382,11 @@ impl ThreadRequestProcessor {
&self,
request_id: ConnectionRequestId,
params: ThreadStartParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
request_context: RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.thread_start_inner(
request_id,
params,
app_server_client_name,
app_server_client_version,
originator,
request_context,
)
.await
.map(|()| None)
self.thread_start_inner(request_id, params, request_context)
.await
.map(|()| None)
}
pub(crate) async fn thread_unsubscribe(
@@ -413,38 +403,22 @@ impl ThreadRequestProcessor {
&self,
request_id: ConnectionRequestId,
params: ThreadResumeParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.thread_resume_inner(
request_id,
params,
app_server_client_name,
app_server_client_version,
originator,
)
.await
.map(|()| None)
self.thread_resume_inner(request_id, params, request_context.originator().clone())
.await
.map(|()| None)
}
pub(crate) async fn thread_fork(
&self,
request_id: ConnectionRequestId,
params: ThreadForkParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.thread_fork_inner(
request_id,
params,
app_server_client_name,
app_server_client_version,
originator,
)
.await
.map(|()| None)
self.thread_fork_inner(request_id, params, request_context.originator().clone())
.await
.map(|()| None)
}
pub(crate) async fn thread_archive(
@@ -695,21 +669,15 @@ impl ThreadRequestProcessor {
async fn set_app_server_client_info(
thread: &CodexThread,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> Result<(), JSONRPCErrorError> {
let app_server_client = originator.app_server_client();
let mcp_elicitations_auto_deny = xcode_26_4_mcp_elicitations_auto_deny(
app_server_client_name.as_deref(),
app_server_client_version.as_deref(),
app_server_client.map(AppServerClient::name),
app_server_client.map(AppServerClient::version),
);
thread
.set_app_server_client_info(
app_server_client_name,
app_server_client_version,
originator,
mcp_elicitations_auto_deny,
)
.set_app_server_client_info(originator, mcp_elicitations_auto_deny)
.await
.map_err(|err| internal_error(format!("failed to set app server client info: {err}")))
}
@@ -822,9 +790,6 @@ impl ThreadRequestProcessor {
&self,
request_id: ConnectionRequestId,
params: ThreadStartParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
request_context: RequestContext,
) -> Result<(), JSONRPCErrorError> {
let ThreadStartParams {
@@ -888,6 +853,7 @@ impl ThreadRequestProcessor {
skills_watcher: Arc::clone(&self.skills_watcher),
};
let request_trace = request_context.request_trace();
let originator = request_context.originator().clone();
let config_manager = self.config_manager.clone();
let outgoing = Arc::clone(&listener_task_context.outgoing);
let error_request_id = request_id.clone();
@@ -896,8 +862,6 @@ impl ThreadRequestProcessor {
listener_task_context,
config_manager,
request_id,
app_server_client_name,
app_server_client_version,
originator,
config,
typesafe_overrides,
@@ -981,9 +945,7 @@ impl ThreadRequestProcessor {
listener_task_context: ListenerTaskContext,
config_manager: ConfigManager,
request_id: ConnectionRequestId,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
config_overrides: Option<HashMap<String, serde_json::Value>>,
typesafe_overrides: ConfigOverrides,
dynamic_tools: Option<Vec<ApiDynamicToolSpec>>,
@@ -1112,8 +1074,6 @@ impl ThreadRequestProcessor {
metrics_service_name: service_name,
parent_trace: request_trace,
environments,
app_server_client_name: app_server_client_name.clone(),
app_server_client_version: app_server_client_version.clone(),
originator: originator.clone(),
})
.instrument(tracing::info_span!(
@@ -1134,13 +1094,7 @@ impl ThreadRequestProcessor {
Some("ready"),
);
Self::set_app_server_client_info(
thread.as_ref(),
app_server_client_name,
app_server_client_version,
originator,
)
.await?;
Self::set_app_server_client_info(thread.as_ref(), originator).await?;
let config_snapshot = thread
.config_snapshot()
@@ -2319,9 +2273,7 @@ impl ThreadRequestProcessor {
&self,
request_id: ConnectionRequestId,
params: ThreadResumeParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> Result<(), JSONRPCErrorError> {
if let Ok(thread_id) = ThreadId::from_string(&params.thread_id)
&& self
@@ -2354,6 +2306,9 @@ impl ThreadRequestProcessor {
self.send_persist_extended_history_deprecation_notice(request_id.connection_id)
.await;
}
let app_server_client_name = originator
.app_server_client()
.map(|client| client.name().to_string());
let redact_resume_payloads =
should_redact_thread_resume_payloads(app_server_client_name.as_deref());
@@ -2365,13 +2320,7 @@ impl ThreadRequestProcessor {
}
};
match self
.resume_running_thread(
&request_id,
&params,
app_server_client_name.clone(),
app_server_client_version.clone(),
originator.clone(),
)
.resume_running_thread(&request_id, &params, originator.clone())
.await
{
Ok(true) => return Ok(()),
@@ -2467,8 +2416,6 @@ impl ThreadRequestProcessor {
self.auth_manager.clone(),
/*persist_extended_history*/ false,
self.request_trace_context(&request_id).await,
app_server_client_name.clone(),
app_server_client_version.clone(),
originator.clone(),
)
.await
@@ -2479,13 +2426,8 @@ impl ThreadRequestProcessor {
session_configured,
..
}) => {
if let Err(err) = Self::set_app_server_client_info(
codex_thread.as_ref(),
app_server_client_name,
app_server_client_version,
originator,
)
.await
if let Err(err) =
Self::set_app_server_client_info(codex_thread.as_ref(), originator).await
{
self.outgoing.send_error(request_id, err).await;
return Ok(());
@@ -2634,9 +2576,7 @@ impl ThreadRequestProcessor {
&self,
request_id: &ConnectionRequestId,
params: &ThreadResumeParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> Result<bool, JSONRPCErrorError> {
let running_thread = if params.history.is_some() {
if let Ok(existing_thread_id) = ThreadId::from_string(&params.thread_id)
@@ -2698,6 +2638,9 @@ impl ThreadRequestProcessor {
};
if let Some((existing_thread_id, existing_thread, source_thread)) = running_thread {
let app_server_client_name = originator
.app_server_client()
.map(|client| client.name().to_string());
let redact_resume_payloads =
should_redact_thread_resume_payloads(app_server_client_name.as_deref());
let history_items = source_thread
@@ -2720,13 +2663,7 @@ impl ThreadRequestProcessor {
thread_state.clone(),
)
.await?;
Self::set_app_server_client_info(
existing_thread.as_ref(),
app_server_client_name,
app_server_client_version,
originator,
)
.await?;
Self::set_app_server_client_info(existing_thread.as_ref(), originator).await?;
let config_snapshot = existing_thread.config_snapshot().await;
let mismatch_details = collect_resume_override_mismatches(params, &config_snapshot);
@@ -3024,9 +2961,7 @@ impl ThreadRequestProcessor {
&self,
request_id: ConnectionRequestId,
params: ThreadForkParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> Result<(), JSONRPCErrorError> {
let ThreadForkParams {
thread_id,
@@ -3139,8 +3074,6 @@ impl ThreadRequestProcessor {
thread_source.map(Into::into),
/*persist_extended_history*/ false,
self.request_trace_context(&request_id).await,
app_server_client_name.clone(),
app_server_client_version.clone(),
originator.clone(),
)
.await
@@ -3152,13 +3085,7 @@ impl ThreadRequestProcessor {
err => internal_error(format!("error forking thread: {err}")),
})?;
Self::set_app_server_client_info(
forked_thread.as_ref(),
app_server_client_name,
app_server_client_version,
originator,
)
.await?;
Self::set_app_server_client_info(forked_thread.as_ref(), originator).await?;
// Auto-attach a conversation listener when forking a thread.
log_listener_attach_result(
@@ -66,19 +66,11 @@ impl TurnRequestProcessor {
&self,
request_id: ConnectionRequestId,
params: TurnStartParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
self.turn_start_inner(
request_id,
params,
app_server_client_name,
app_server_client_version,
originator,
)
.await
.map(|response| Some(response.into()))
self.turn_start_inner(request_id, params, request_context.originator().clone())
.await
.map(|response| Some(response.into()))
}
pub(crate) async fn thread_inject_items(
@@ -165,8 +157,9 @@ impl TurnRequestProcessor {
&self,
request_id: &ConnectionRequestId,
params: ReviewStartParams,
originator: Option<Originator>,
request_context: &RequestContext,
) -> Result<Option<ClientResponsePayload>, JSONRPCErrorError> {
let originator = request_context.originator().clone();
self.review_start_inner(request_id, params, originator)
.await
.map(|()| None)
@@ -333,9 +326,7 @@ impl TurnRequestProcessor {
&self,
request_id: ConnectionRequestId,
params: TurnStartParams,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> Result<TurnStartResponse, JSONRPCErrorError> {
if let Err(error) = Self::validate_v2_input_limit(&params.input) {
self.track_error_response(
@@ -351,16 +342,11 @@ impl TurnRequestProcessor {
.inspect_err(|error| {
self.track_error_response(&request_id, error, /*error_type*/ None);
})?;
Self::set_app_server_client_info(
thread.as_ref(),
app_server_client_name,
app_server_client_version,
originator,
)
.await
.inspect_err(|error| {
self.track_error_response(&request_id, error, /*error_type*/ None);
})?;
Self::set_app_server_client_info(thread.as_ref(), originator)
.await
.inspect_err(|error| {
self.track_error_response(&request_id, error, /*error_type*/ None);
})?;
let collaboration_mode = params
.collaboration_mode
@@ -600,21 +586,15 @@ impl TurnRequestProcessor {
async fn set_app_server_client_info(
thread: &CodexThread,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> Result<(), JSONRPCErrorError> {
let app_server_client = originator.app_server_client();
let mcp_elicitations_auto_deny = xcode_26_4_mcp_elicitations_auto_deny(
app_server_client_name.as_deref(),
app_server_client_version.as_deref(),
app_server_client.map(AppServerClient::name),
app_server_client.map(AppServerClient::version),
);
thread
.set_app_server_client_info(
app_server_client_name,
app_server_client_version,
originator,
mcp_elicitations_auto_deny,
)
.set_app_server_client_info(originator, mcp_elicitations_auto_deny)
.await
.map_err(|err| internal_error(format!("failed to set app server client info: {err}")))
}
@@ -929,7 +909,7 @@ impl TurnRequestProcessor {
parent_thread: Arc<CodexThread>,
review_request: ReviewRequest,
display_text: &str,
originator: Option<Originator>,
originator: Originator,
) -> std::result::Result<(), JSONRPCErrorError> {
parent_thread.ensure_rollout_materialized().await;
parent_thread.flush_rollout().await.map_err(|err| {
@@ -968,8 +948,6 @@ impl TurnRequestProcessor {
/*thread_source*/ None,
/*persist_extended_history*/ false,
self.request_trace_context(request_id).await,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
originator,
)
.await
@@ -1042,7 +1020,7 @@ impl TurnRequestProcessor {
&self,
request_id: &ConnectionRequestId,
params: ReviewStartParams,
originator: Option<Originator>,
originator: Originator,
) -> Result<(), JSONRPCErrorError> {
let ReviewStartParams {
thread_id,
+2 -1
View File
@@ -13,6 +13,7 @@ use crate::thread_manager::ResumeThreadWithHistoryOptions;
use crate::thread_manager::ThreadManagerState;
use crate::thread_rollout_truncation::truncate_rollout_to_last_n_fork_turns;
use codex_features::Feature;
use codex_login::default_client::Originator;
use codex_protocol::AgentPath;
use codex_protocol::SessionId;
use codex_protocol::ThreadId;
@@ -303,7 +304,7 @@ impl AgentControl {
crate::session::session::AppServerClientMetadata {
client_name: None,
client_version: None,
originator: None,
originator: Originator::process_default(),
}
}
};
+1 -4
View File
@@ -75,7 +75,6 @@ pub(crate) async fn run_codex_thread_interactive(
let (tx_sub, rx_sub) = async_channel::bounded(SUBMISSION_CHANNEL_CAPACITY);
let (tx_ops, rx_ops) = async_channel::bounded(SUBMISSION_CHANNEL_CAPACITY);
let client_metadata = parent_session.app_server_client_metadata().await;
let originator = client_metadata.originator.clone();
let CodexSpawnOk { codex, .. } = Box::pin(Codex::spawn(CodexSpawnArgs {
config,
installation_id: parent_session.installation_id.clone(),
@@ -93,9 +92,7 @@ pub(crate) async fn run_codex_thread_interactive(
dynamic_tools: Vec::new(),
persist_extended_history: false,
metrics_service_name: None,
app_server_client_name: client_metadata.client_name.clone(),
app_server_client_version: client_metadata.client_version.clone(),
originator,
originator: client_metadata.originator.clone(),
inherited_shell_snapshot: None,
user_shell_override: None,
inherited_exec_policy: Some(Arc::clone(&parent_session.services.exec_policy)),
+3 -9
View File
@@ -6,6 +6,7 @@ use crate::session::Codex;
use crate::session::SessionSettingsUpdate;
use crate::session::SteerInputError;
use codex_features::Feature;
use codex_login::default_client::Originator;
use codex_otel::SessionTelemetry;
use codex_protocol::config_types::ApprovalsReviewer;
use codex_protocol::config_types::CollaborationMode;
@@ -246,18 +247,11 @@ impl CodexThread {
pub async fn set_app_server_client_info(
&self,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<codex_login::default_client::Originator>,
originator: Originator,
mcp_elicitations_auto_deny: bool,
) -> ConstraintResult<()> {
self.codex
.set_app_server_client_info(
app_server_client_name,
app_server_client_version,
originator,
mcp_elicitations_auto_deny,
)
.set_app_server_client_info(originator, mcp_elicitations_auto_deny)
.await
}
+20 -14
View File
@@ -404,9 +404,7 @@ pub(crate) struct CodexSpawnArgs {
pub(crate) dynamic_tools: Vec<DynamicToolSpec>,
pub(crate) persist_extended_history: bool,
pub(crate) metrics_service_name: Option<String>,
pub(crate) app_server_client_name: Option<String>,
pub(crate) app_server_client_version: Option<String>,
pub(crate) originator: Option<Originator>,
pub(crate) originator: Originator,
pub(crate) inherited_shell_snapshot: Option<Arc<ShellSnapshot>>,
pub(crate) inherited_exec_policy: Option<Arc<ExecPolicyManager>>,
/// Parent rollout trace used only to derive fresh spawned child traces.
@@ -471,8 +469,6 @@ impl Codex {
dynamic_tools,
persist_extended_history,
metrics_service_name,
app_server_client_name,
app_server_client_version,
originator,
inherited_shell_snapshot,
user_shell_override,
@@ -542,7 +538,7 @@ impl Codex {
)
{
let _ = models_manager
.list_models(refresh_strategy, originator.clone())
.list_models(refresh_strategy, Some(originator.clone()))
.await;
}
let model = models_manager
@@ -615,6 +611,10 @@ impl Codex {
account_plan_type,
config.features.enabled(Feature::FastMode),
);
let app_server_client = originator.app_server_client();
let app_server_client_name = app_server_client.map(|client| client.name().to_string());
let app_server_client_version =
app_server_client.map(|client| client.version().to_string());
let session_configuration = SessionConfiguration {
provider: config.model_provider.clone(),
collaboration_mode,
@@ -638,7 +638,7 @@ impl Codex {
metrics_service_name,
app_server_client_name,
app_server_client_version,
app_server_originator: originator,
app_server_originator: Some(originator),
session_source,
thread_source,
dynamic_tools,
@@ -775,16 +775,18 @@ impl Codex {
pub(crate) async fn set_app_server_client_info(
&self,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
mcp_elicitations_auto_deny: bool,
) -> ConstraintResult<()> {
let app_server_client = originator.app_server_client();
let app_server_client_name = app_server_client.map(|client| client.name().to_string());
let app_server_client_version =
app_server_client.map(|client| client.version().to_string());
self.session
.update_settings(SessionSettingsUpdate {
app_server_client_name: app_server_client_name.clone(),
app_server_client_version: app_server_client_version.clone(),
app_server_originator: originator.clone(),
app_server_client_name,
app_server_client_version,
app_server_originator: Some(originator),
..Default::default()
})
.await?;
@@ -896,7 +898,11 @@ impl Session {
.session_configuration
.app_server_client_version
.clone(),
originator: state.session_configuration.app_server_originator.clone(),
originator: state
.session_configuration
.app_server_originator
.clone()
.unwrap_or_else(Originator::process_default),
}
}
+1 -1
View File
@@ -410,7 +410,7 @@ pub(crate) struct SessionSettingsUpdate {
pub(crate) struct AppServerClientMetadata {
pub(crate) client_name: Option<String>,
pub(crate) client_version: Option<String>,
pub(crate) originator: Option<Originator>,
pub(crate) originator: Originator,
}
impl Session {
@@ -18,6 +18,7 @@ use codex_execpolicy::Decision;
use codex_execpolicy::Evaluation;
use codex_execpolicy::RuleMatch;
use codex_features::Feature;
use codex_login::default_client::Originator;
use codex_model_provider::create_model_provider;
use codex_protocol::config_types::ApprovalsReviewer;
use codex_protocol::models::AdditionalPermissionProfile as PermissionProfile;
@@ -697,9 +698,7 @@ async fn guardian_subagent_does_not_inherit_parent_exec_policy_rules() {
dynamic_tools: Vec::new(),
persist_extended_history: false,
metrics_service_name: None,
app_server_client_name: None,
app_server_client_version: None,
originator: None,
originator: Originator::process_default(),
inherited_shell_snapshot: None,
inherited_exec_policy: Some(Arc::new(parent_exec_policy)),
parent_rollout_thread_trace: codex_rollout_trace::ThreadTraceContext::disabled(),
+14 -54
View File
@@ -183,9 +183,7 @@ pub struct StartThreadOptions {
pub metrics_service_name: Option<String>,
pub parent_trace: Option<W3cTraceContext>,
pub environments: Vec<TurnEnvironmentSelection>,
pub app_server_client_name: Option<String>,
pub app_server_client_version: Option<String>,
pub originator: Option<Originator>,
pub originator: Originator,
}
pub(crate) struct ResumeThreadWithHistoryOptions {
@@ -582,9 +580,7 @@ impl ThreadManager {
metrics_service_name: None,
parent_trace: None,
environments,
app_server_client_name: None,
app_server_client_version: None,
originator: None,
originator: Originator::process_default(),
}))
.await
}
@@ -614,8 +610,6 @@ impl ThreadManager {
options.parent_trace,
options.environments,
/*user_shell_override*/ None,
options.app_server_client_name,
options.app_server_client_version,
options.originator,
))
.await
@@ -665,9 +659,7 @@ impl ThreadManager {
auth_manager,
/*persist_extended_history*/ false,
parent_trace,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
))
.await
}
@@ -679,9 +671,7 @@ impl ThreadManager {
auth_manager: Arc<AuthManager>,
persist_extended_history: bool,
parent_trace: Option<W3cTraceContext>,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> CodexResult<NewThread> {
let environments = default_thread_environment_selections(
self.state.environment_manager.as_ref(),
@@ -700,8 +690,6 @@ impl ThreadManager {
parent_trace,
environments,
/*user_shell_override*/ None,
app_server_client_name,
app_server_client_version,
originator,
))
.await
@@ -728,9 +716,7 @@ impl ThreadManager {
/*parent_trace*/ None,
environments,
/*user_shell_override*/ Some(user_shell_override),
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
))
.await
}
@@ -760,9 +746,7 @@ impl ThreadManager {
/*parent_trace*/ None,
environments,
/*user_shell_override*/ Some(user_shell_override),
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
))
.await
}
@@ -850,9 +834,7 @@ impl ThreadManager {
thread_source,
persist_extended_history,
parent_trace,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
}
@@ -884,9 +866,7 @@ impl ThreadManager {
thread_source: Option<ThreadSource>,
persist_extended_history: bool,
parent_trace: Option<W3cTraceContext>,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> CodexResult<NewThread>
where
S: Into<ForkSnapshot>,
@@ -898,8 +878,6 @@ impl ThreadManager {
thread_source,
persist_extended_history,
parent_trace,
app_server_client_name,
app_server_client_version,
originator,
)
.await
@@ -913,9 +891,7 @@ impl ThreadManager {
thread_source: Option<ThreadSource>,
persist_extended_history: bool,
parent_trace: Option<W3cTraceContext>,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> CodexResult<NewThread> {
let interrupted_marker = InterruptedTurnHistoryMarker::from_config(&config);
let history = fork_history_from_snapshot(snapshot, history, interrupted_marker);
@@ -935,8 +911,6 @@ impl ThreadManager {
parent_trace,
environments,
/*user_shell_override*/ None,
app_server_client_name,
app_server_client_version,
originator,
))
.await
@@ -1084,9 +1058,7 @@ impl ThreadManagerState {
/*parent_trace*/ None,
environments,
/*user_shell_override*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
))
.await
}
@@ -1121,9 +1093,7 @@ impl ThreadManagerState {
/*parent_trace*/ None,
environments,
/*user_shell_override*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
))
.await
}
@@ -1159,9 +1129,7 @@ impl ThreadManagerState {
/*parent_trace*/ None,
environments,
/*user_shell_override*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
))
.await
}
@@ -1181,9 +1149,7 @@ impl ThreadManagerState {
parent_trace: Option<W3cTraceContext>,
environments: Vec<TurnEnvironmentSelection>,
user_shell_override: Option<crate::shell::Shell>,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> CodexResult<NewThread> {
Box::pin(self.spawn_thread_with_source(
config,
@@ -1200,8 +1166,6 @@ impl ThreadManagerState {
parent_trace,
environments,
user_shell_override,
app_server_client_name,
app_server_client_version,
originator,
))
.await
@@ -1224,9 +1188,7 @@ impl ThreadManagerState {
parent_trace: Option<W3cTraceContext>,
environments: Vec<TurnEnvironmentSelection>,
user_shell_override: Option<crate::shell::Shell>,
app_server_client_name: Option<String>,
app_server_client_version: Option<String>,
originator: Option<Originator>,
originator: Originator,
) -> CodexResult<NewThread> {
let is_resumed_thread = matches!(&initial_history, InitialHistory::Resumed(_));
if let InitialHistory::Resumed(resumed) = &initial_history {
@@ -1275,8 +1237,6 @@ impl ThreadManagerState {
dynamic_tools,
persist_extended_history,
metrics_service_name,
app_server_client_name,
app_server_client_version,
originator,
inherited_shell_snapshot,
inherited_exec_policy,
+9 -27
View File
@@ -334,9 +334,7 @@ async fn start_thread_rejects_explicit_local_environment_when_default_provider_i
environment_id: "local".to_string(),
cwd: config.cwd.clone(),
}],
app_server_client_name: None,
app_server_client_version: None,
originator: None,
originator: Originator::process_default(),
})
.await;
let err = match result {
@@ -468,9 +466,7 @@ async fn start_thread_keeps_internal_threads_hidden_from_normal_lookups() {
metrics_service_name: None,
parent_trace: None,
environments: Vec::new(),
app_server_client_name: None,
app_server_client_version: None,
originator: None,
originator: Originator::process_default(),
})
.await
.expect("internal thread should start");
@@ -527,9 +523,7 @@ async fn resume_and_fork_do_not_restore_thread_environments_from_rollout() {
metrics_service_name: None,
parent_trace: None,
environments: environments.clone(),
app_server_client_name: None,
app_server_client_version: None,
originator: None,
originator: Originator::process_default(),
})
.await
.expect("start source thread");
@@ -802,9 +796,7 @@ async fn resume_stopped_thread_from_rollout_preserves_thread_source() {
metrics_service_name: None,
parent_trace: None,
environments: Vec::new(),
app_server_client_name: None,
app_server_client_version: None,
originator: None,
originator: Originator::process_default(),
})
.await
.expect("start source thread");
@@ -910,9 +902,7 @@ async fn rollout_path_resume_and_fork_read_history_through_thread_store() {
auth_manager.clone(),
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("seed rollout path in store");
@@ -1220,9 +1210,7 @@ async fn interrupted_fork_snapshot_does_not_synthesize_turn_id_for_legacy_histor
auth_manager,
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("create source thread from completed history");
@@ -1337,9 +1325,7 @@ async fn interrupted_fork_snapshot_preserves_explicit_turn_id() {
auth_manager,
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("create source thread from explicit partial history");
@@ -1431,9 +1417,7 @@ async fn interrupted_fork_snapshot_uses_persisted_mid_turn_history_without_live_
auth_manager,
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("create source thread from partial history");
@@ -1574,9 +1558,7 @@ async fn resumed_thread_keeps_paused_goal_paused() -> anyhow::Result<()> {
auth_manager.clone(),
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("create source thread");
@@ -19,6 +19,7 @@ use codex_extension_api::empty_extension_registry;
use codex_features::Feature;
use codex_login::AuthManager;
use codex_login::CodexAuth;
use codex_login::default_client::Originator;
use codex_model_provider::create_model_provider;
use codex_model_provider_info::built_in_model_providers;
use codex_protocol::AgentPath;
@@ -2583,9 +2584,7 @@ async fn resume_agent_restores_closed_agent_and_accepts_send_input() {
AuthManager::from_auth_for_testing(CodexAuth::from_api_key("dummy")),
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("start thread");
+2 -3
View File
@@ -1,6 +1,7 @@
use codex_core::ForkSnapshot;
use codex_core::NewThread;
use codex_core::parse_turn_item;
use codex_login::default_client::Originator;
use codex_protocol::items::TurnItem;
use codex_protocol::protocol::EventMsg;
use codex_protocol::protocol::InitialHistory;
@@ -204,9 +205,7 @@ async fn fork_thread_from_history_does_not_require_source_rollout_path() {
/*thread_source*/ None,
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("fork from stored history");
@@ -5,6 +5,7 @@ use codex_config::config_toml::RealtimeWsVersion;
use codex_core::test_support::auth_manager_from_auth;
use codex_login::CodexAuth;
use codex_login::OPENAI_API_KEY_ENV_VAR;
use codex_login::default_client::Originator;
use codex_protocol::ThreadId;
use codex_protocol::models::ContentItem;
use codex_protocol::models::ResponseItem;
@@ -1890,9 +1891,7 @@ async fn conversation_startup_context_current_thread_selects_many_turns_by_budge
auth_manager_from_auth(CodexAuth::from_api_key("dummy")),
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await?;
let codex = resumed_thread.thread;
+2 -3
View File
@@ -2,6 +2,7 @@
use codex_core::NewThread;
use codex_login::CodexAuth;
use codex_login::default_client::Originator;
use codex_protocol::ThreadId;
use codex_protocol::config_types::ModeKind;
use codex_protocol::config_types::ReasoningSummary;
@@ -106,9 +107,7 @@ async fn emits_warning_when_resumed_model_differs() {
auth_manager,
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("resume conversation");
@@ -4,6 +4,7 @@ use codex_config::CONFIG_TOML_FILE;
use codex_core::NewThread;
use codex_features::Feature;
use codex_login::CodexAuth;
use codex_login::default_client::Originator;
use codex_protocol::protocol::EventMsg;
use codex_protocol::protocol::InitialHistory;
use codex_protocol::protocol::WarningEvent;
@@ -48,9 +49,7 @@ async fn emits_warning_when_unstable_features_enabled_via_config() {
auth_manager,
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("spawn conversation");
@@ -98,9 +97,7 @@ async fn suppresses_warning_when_configured() {
auth_manager,
/*persist_extended_history*/ false,
/*parent_trace*/ None,
/*app_server_client_name*/ None,
/*app_server_client_version*/ None,
/*originator*/ None,
Originator::process_default(),
)
.await
.expect("spawn conversation");
+2 -3
View File
@@ -31,7 +31,7 @@ async fn send_codex_exec_originator() -> anyhow::Result<()> {
}
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn supports_originator_override() -> anyhow::Result<()> {
async fn app_server_client_info_ignores_originator_override() -> anyhow::Result<()> {
let test = test_codex_exec();
let server = responses::start_mock_server().await;
@@ -40,8 +40,7 @@ async fn supports_originator_override() -> anyhow::Result<()> {
responses::ev_assistant_message("response_1", "Hello, world!"),
responses::ev_completed("response_1"),
]);
responses::mount_sse_once_match(&server, header("Originator", "codex_exec_override"), body)
.await;
responses::mount_sse_once_match(&server, header("Originator", "codex_exec"), body).await;
test.cmd_with_server(&server)
.env("CODEX_INTERNAL_ORIGINATOR_OVERRIDE", "codex_exec_override")
+1 -3
View File
@@ -254,9 +254,7 @@ impl MemoryStartupContext {
metrics_service_name: None,
parent_trace: None,
environments,
app_server_client_name: None,
app_server_client_version: None,
originator: Some(self.originator.clone()),
originator: self.originator.clone(),
})
.await?;
+1 -3
View File
@@ -145,9 +145,7 @@ async fn run_main(arg0_paths: Arg0DispatchPaths) -> anyhow::Result<()> {
metrics_service_name: None,
parent_trace: None,
environments,
app_server_client_name: None,
app_server_client_version: None,
originator: Some(originator),
originator,
})
.await
.context("start Codex thread")?;