Restore CLI originator for tui app server

This commit is contained in:
Eric Traut
2026-03-19 10:55:59 -06:00
parent 412b86ec9b
commit 043cd18a29
4 changed files with 11 additions and 100 deletions

View File

@@ -3,8 +3,6 @@ use codex_app_server_protocol::AppInfo;
use serde::Deserialize;
use serde::Serialize;
const TUI_APP_SERVER_CLIENT_NAME: &str = "codex-tui";
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub(crate) enum DiscoverableToolType {
@@ -94,16 +92,9 @@ impl From<DiscoverablePluginInfo> for DiscoverableTool {
pub(crate) fn filter_tool_suggest_discoverable_tools_for_client(
discoverable_tools: Vec<DiscoverableTool>,
app_server_client_name: Option<&str>,
_app_server_client_name: Option<&str>,
) -> Vec<DiscoverableTool> {
if app_server_client_name != Some(TUI_APP_SERVER_CLIENT_NAME) {
return discoverable_tools;
}
discoverable_tools
.into_iter()
.filter(|tool| !matches!(tool, DiscoverableTool::Plugin(_)))
.collect()
}
#[derive(Clone, Debug, PartialEq, Eq)]

View File

@@ -102,14 +102,6 @@ impl ToolHandler for ToolSuggestHandler {
"tool suggestions currently support only action_type=\"install\"".to_string(),
));
}
if args.tool_type == DiscoverableToolType::Plugin
&& turn.app_server_client_name.as_deref() == Some("codex-tui")
{
return Err(FunctionCallError::RespondToModel(
"plugin tool suggestions are not available in codex-tui yet".to_string(),
));
}
let auth = session.services.auth_manager.auth().await;
let manager = session.services.mcp_connection_manager.read().await;
let mcp_tools = manager.list_all_tools().await;

View File

@@ -159,54 +159,6 @@ fn build_tool_suggestion_meta_uses_expected_shape() {
);
}
#[test]
fn filter_tool_suggest_discoverable_tools_for_codex_tui_omits_plugins() {
let discoverable_tools = vec![
DiscoverableTool::Connector(Box::new(AppInfo {
id: "connector_google_calendar".to_string(),
name: "Google Calendar".to_string(),
description: Some("Plan events and schedules.".to_string()),
logo_url: None,
logo_url_dark: None,
distribution_channel: None,
branding: None,
app_metadata: None,
labels: None,
install_url: Some("https://example.test/google-calendar".to_string()),
is_accessible: false,
is_enabled: true,
plugin_display_names: Vec::new(),
})),
DiscoverableTool::Plugin(Box::new(DiscoverablePluginInfo {
id: "slack@openai-curated".to_string(),
name: "Slack".to_string(),
description: Some("Search Slack messages".to_string()),
has_skills: true,
mcp_server_names: vec!["slack".to_string()],
app_connector_ids: vec!["connector_slack".to_string()],
})),
];
assert_eq!(
filter_tool_suggest_discoverable_tools_for_client(discoverable_tools, Some("codex-tui"),),
vec![DiscoverableTool::Connector(Box::new(AppInfo {
id: "connector_google_calendar".to_string(),
name: "Google Calendar".to_string(),
description: Some("Plan events and schedules.".to_string()),
logo_url: None,
logo_url_dark: None,
distribution_channel: None,
branding: None,
app_metadata: None,
labels: None,
install_url: Some("https://example.test/google-calendar".to_string()),
is_accessible: false,
is_enabled: true,
plugin_display_names: Vec::new(),
}))]
);
}
#[test]
fn verified_connector_suggestion_completed_requires_accessible_connector() {
let accessible_connectors = vec![AppInfo {

View File

@@ -338,21 +338,17 @@ pub fn normalize_remote_addr(addr: &str) -> color_eyre::Result<String> {
}
async fn connect_remote_app_server(websocket_url: String) -> color_eyre::Result<AppServerClient> {
let app_server = RemoteAppServerClient::connect(remote_app_server_connect_args(websocket_url))
.await
.wrap_err("failed to connect to remote app server")?;
Ok(AppServerClient::Remote(app_server))
}
fn remote_app_server_connect_args(websocket_url: String) -> RemoteAppServerConnectArgs {
RemoteAppServerConnectArgs {
let app_server = RemoteAppServerClient::connect(RemoteAppServerConnectArgs {
websocket_url,
client_name: DEFAULT_ORIGINATOR.to_string(),
client_version: env!("CARGO_PKG_VERSION").to_string(),
experimental_api: true,
opt_out_notification_methods: Vec::new(),
channel_capacity: DEFAULT_IN_PROCESS_CHANNEL_CAPACITY,
}
})
.await
.wrap_err("failed to connect to remote app server")?;
Ok(AppServerClient::Remote(app_server))
}
async fn start_app_server(
@@ -428,30 +424,7 @@ where
range: None,
})
.collect();
let client = start_client(in_process_client_start_args(
arg0_paths,
config,
cli_kv_overrides,
loader_overrides,
cloud_requirements,
feedback,
config_warnings,
))
.await
.wrap_err("failed to start embedded app server")?;
Ok(client)
}
fn in_process_client_start_args(
arg0_paths: Arg0DispatchPaths,
config: Config,
cli_kv_overrides: Vec<(String, toml::Value)>,
loader_overrides: LoaderOverrides,
cloud_requirements: CloudRequirementsLoader,
feedback: codex_feedback::CodexFeedback,
config_warnings: Vec<ConfigWarningNotification>,
) -> InProcessClientStartArgs {
InProcessClientStartArgs {
let client = start_client(InProcessClientStartArgs {
arg0_paths,
config: Arc::new(config),
cli_overrides: cli_kv_overrides,
@@ -466,7 +439,10 @@ fn in_process_client_start_args(
experimental_api: true,
opt_out_notification_methods: Vec::new(),
channel_capacity: DEFAULT_IN_PROCESS_CHANNEL_CAPACITY,
}
})
.await
.wrap_err("failed to start embedded app server")?;
Ok(client)
}
async fn shutdown_app_server_if_present(app_server: Option<AppServerSession>) {