//! Connector-domain app metadata used by directory discovery, caching, and tool selection. //! //! The Serde implementations decode connector-directory response metadata and persist normalized //! app information in the connector-directory disk cache. They do not define the app-server wire //! format; `codex-app-server-protocol` owns separate API types for that boundary. use serde::Deserialize; use serde::Serialize; use std::collections::HashMap; /// Branding supplied by the connector directory for an app. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[serde(rename_all = "camelCase")] pub struct AppBranding { pub category: Option, pub developer: Option, pub website: Option, pub privacy_policy: Option, pub terms_of_service: Option, pub is_discoverable_app: bool, } /// Review state supplied by the connector directory for an app. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[serde(rename_all = "camelCase")] pub struct AppReview { pub status: String, } /// Screenshot metadata supplied by the connector directory for an app. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[serde(rename_all = "camelCase")] pub struct AppScreenshot { pub url: Option, #[serde(alias = "file_id")] pub file_id: Option, #[serde(alias = "user_prompt")] pub user_prompt: String, } /// Extended metadata supplied by the connector directory for an app. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[serde(rename_all = "camelCase")] pub struct AppMetadata { pub review: Option, pub categories: Option>, pub sub_categories: Option>, pub seo_description: Option, pub screenshots: Option>, pub developer: Option, pub version: Option, pub version_id: Option, pub version_notes: Option, pub first_party_requires_install: Option, pub show_in_composer_when_unlinked: Option, } /// Connector metadata used by connector discovery, caching, and tool selection. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] #[serde(rename_all = "camelCase")] pub struct AppInfo { pub id: String, pub name: String, pub description: Option, pub logo_url: Option, pub logo_url_dark: Option, pub icon_assets: Option>, pub icon_dark_assets: Option>, pub distribution_channel: Option, pub branding: Option, pub app_metadata: Option, pub labels: Option>, pub install_url: Option, #[serde(default)] pub is_accessible: bool, #[serde(default = "default_enabled")] pub is_enabled: bool, #[serde(default)] pub plugin_display_names: Vec, } impl AppInfo { pub fn category(&self) -> Option { self.branding .as_ref() .and_then(|branding| non_empty_category(branding.category.as_deref())) .or_else(|| { self.app_metadata .as_ref() .and_then(|metadata| metadata.categories.as_ref()) .and_then(|categories| { categories .iter() .find_map(|category| non_empty_category(Some(category.as_str()))) }) }) } } const fn default_enabled() -> bool { true } fn non_empty_category(category: Option<&str>) -> Option { let category = category?.trim(); if category.is_empty() { None } else { Some(category.to_string()) } }