use super::shared::default_enabled; use crate::JsonSchema; use crate::TS; use serde::Deserialize; use serde::Serialize; use std::collections::HashMap; #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - list available apps/connectors. pub struct AppsListParams { /// Opaque pagination cursor returned by a previous call. #[ts(optional = nullable)] pub cursor: Option, /// Optional page size; defaults to a reasonable server-side value. #[ts(optional = nullable)] pub limit: Option, /// Optional thread id used to evaluate app feature gating from that thread's config. #[ts(optional = nullable)] pub thread_id: Option, /// When true, bypass app caches and fetch the latest data from sources. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub force_refetch: bool, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// Read the committed installed connector runtime snapshot. pub struct AppsInstalledParams { /// Optional loaded thread id used to evaluate effective app configuration. #[ts(optional = nullable)] pub thread_id: Option, /// When true and Apps are permitted, refresh and publish the hosted connector runtime tool /// snapshot first. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub force_refresh: bool, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// Installed connector runtime state. pub struct InstalledApp { pub id: String, /// Best-effort name carried by the runtime tool catalog. Canonical app metadata remains owned /// by `app/read`. pub runtime_name: Option, /// Effective enabled state after applying global, workspace, local, and managed configuration /// at read time. pub enabled: bool, /// Whether the connector is enabled and has a non-synthetic, model-visible tool allowed by /// effective MCP and app/tool policy in the committed runtime snapshot. pub callable: bool, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// The installed connectors in one committed runtime snapshot. pub struct AppsInstalledResponse { pub apps: Vec, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - app metadata returned by app-list APIs. 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, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct AppReview { pub status: String, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct AppScreenshot { pub url: Option, #[serde(alias = "file_id")] pub file_id: Option, #[serde(alias = "user_prompt")] pub user_prompt: String, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] 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, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - app metadata returned by app-list APIs. 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, /// Whether this app is enabled in config.toml. /// Example: /// ```toml /// [apps.bad_app] /// enabled = false /// ``` #[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()))) }) }) } } fn non_empty_category(category: Option<&str>) -> Option { let category = category?.trim(); if category.is_empty() { None } else { Some(category.to_string()) } } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - read metadata for specific apps/connectors. pub struct AppsReadParams { /// App ids to read. The server accepts at most 100 ids and deduplicates repeated ids while /// preserving their first-request order. pub app_ids: Vec, /// Optional loaded thread id used to evaluate effective app configuration. #[ts(optional = nullable)] pub thread_id: Option, /// When true, include display-only public tool summaries in the returned metadata. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub include_tools: bool, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - metadata returned by app/read. pub struct AppToolSummary { pub name: String, pub title: Option, pub description: String, #[serde(default = "default_enabled")] pub is_enabled: bool, pub disabled_reason: Option, #[serde(default)] pub is_read_only: bool, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - metadata returned by app/read. pub struct ConnectorMetadata { pub id: String, pub name: String, pub description: Option, pub icon_url: Option, pub icon_url_dark: Option, pub distribution_channel: Option, pub install_url: Option, #[serde(default)] pub plugin_display_names: Vec, pub tool_summaries: Option>, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - app/read response. pub struct AppsReadResponse { pub apps: Vec, pub missing_app_ids: Vec, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - app metadata summary for plugin responses. pub struct AppSummary { pub id: String, pub name: String, pub description: Option, pub install_url: Option, pub category: Option, } impl From for AppSummary { fn from(value: AppInfo) -> Self { let category = value.category(); Self { id: value.id, name: value.name, description: value.description, install_url: value.install_url, category, } } } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - app list response. pub struct AppsListResponse { pub data: Vec, /// Opaque cursor to pass to the next call to continue after the last item. /// If None, there are no more items to return. pub next_cursor: Option, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] /// EXPERIMENTAL - notification emitted when the app list changes. pub struct AppListUpdatedNotification { pub data: Vec, }