Download codex-rs/app-server-protocol/src/protocol/v2/apps.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 9.38 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/app-server-protocol/src/protocol/v2/apps.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/app-server-protocol/src/protocol/v2/apps.rs
-
curl -L -o apps.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/app-server-protocol/src/protocol/v2/apps.rs
9.38 kB
| use super::shared::default_enabled; | |
| use crate::JsonSchema; | |
| use crate::TS; | |
| use serde::Deserialize; | |
| use serde::Serialize; | |
| use std::collections::HashMap; | |
| /// EXPERIMENTAL - list available apps/connectors. | |
| pub struct AppsListParams { | |
| /// Opaque pagination cursor returned by a previous call. | |
| pub cursor: Option<String>, | |
| /// Optional page size; defaults to a reasonable server-side value. | |
| pub limit: Option<u32>, | |
| /// Optional thread id used to evaluate app feature gating from that thread's config. | |
| pub thread_id: Option<String>, | |
| /// When true, bypass app caches and fetch the latest data from sources. | |
| pub force_refetch: bool, | |
| } | |
| /// Read the committed installed connector runtime snapshot. | |
| pub struct AppsInstalledParams { | |
| /// Optional loaded thread id used to evaluate effective app configuration. | |
| pub thread_id: Option<String>, | |
| /// When true and Apps are permitted, refresh and publish the hosted connector runtime tool | |
| /// snapshot first. | |
| pub force_refresh: bool, | |
| } | |
| /// 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<String>, | |
| /// 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, | |
| } | |
| /// The installed connectors in one committed runtime snapshot. | |
| pub struct AppsInstalledResponse { | |
| pub apps: Vec<InstalledApp>, | |
| } | |
| /// EXPERIMENTAL - app metadata returned by app-list APIs. | |
| pub struct AppBranding { | |
| pub category: Option<String>, | |
| pub developer: Option<String>, | |
| pub website: Option<String>, | |
| pub privacy_policy: Option<String>, | |
| pub terms_of_service: Option<String>, | |
| pub is_discoverable_app: bool, | |
| } | |
| pub struct AppReview { | |
| pub status: String, | |
| } | |
| pub struct AppScreenshot { | |
| pub url: Option<String>, | |
| pub file_id: Option<String>, | |
| pub user_prompt: String, | |
| } | |
| pub struct AppMetadata { | |
| pub review: Option<AppReview>, | |
| pub categories: Option<Vec<String>>, | |
| pub sub_categories: Option<Vec<String>>, | |
| pub seo_description: Option<String>, | |
| pub screenshots: Option<Vec<AppScreenshot>>, | |
| pub developer: Option<String>, | |
| pub version: Option<String>, | |
| pub version_id: Option<String>, | |
| pub version_notes: Option<String>, | |
| pub first_party_requires_install: Option<bool>, | |
| pub show_in_composer_when_unlinked: Option<bool>, | |
| } | |
| /// EXPERIMENTAL - app metadata returned by app-list APIs. | |
| pub struct AppInfo { | |
| pub id: String, | |
| pub name: String, | |
| pub description: Option<String>, | |
| pub logo_url: Option<String>, | |
| pub logo_url_dark: Option<String>, | |
| pub icon_assets: Option<HashMap<String, String>>, | |
| pub icon_dark_assets: Option<HashMap<String, String>>, | |
| pub distribution_channel: Option<String>, | |
| pub branding: Option<AppBranding>, | |
| pub app_metadata: Option<AppMetadata>, | |
| pub labels: Option<HashMap<String, String>>, | |
| pub install_url: Option<String>, | |
| pub is_accessible: bool, | |
| /// Whether this app is enabled in config.toml. | |
| /// Example: | |
| /// ```toml | |
| /// [apps.bad_app] | |
| /// enabled = false | |
| /// ``` | |
| pub is_enabled: bool, | |
| pub plugin_display_names: Vec<String>, | |
| } | |
| impl AppInfo { | |
| pub fn category(&self) -> Option<String> { | |
| 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<String> { | |
| let category = category?.trim(); | |
| if category.is_empty() { | |
| None | |
| } else { | |
| Some(category.to_string()) | |
| } | |
| } | |
| /// 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<String>, | |
| /// Optional loaded thread id used to evaluate effective app configuration. | |
| pub thread_id: Option<String>, | |
| /// When true, include display-only public tool summaries in the returned metadata. | |
| pub include_tools: bool, | |
| } | |
| /// EXPERIMENTAL - metadata returned by app/read. | |
| pub struct AppToolSummary { | |
| pub name: String, | |
| pub title: Option<String>, | |
| pub description: String, | |
| pub is_enabled: bool, | |
| pub disabled_reason: Option<String>, | |
| pub is_read_only: bool, | |
| } | |
| /// EXPERIMENTAL - metadata returned by app/read. | |
| pub struct ConnectorMetadata { | |
| pub id: String, | |
| pub name: String, | |
| pub description: Option<String>, | |
| pub icon_url: Option<String>, | |
| pub icon_url_dark: Option<String>, | |
| pub distribution_channel: Option<String>, | |
| pub install_url: Option<String>, | |
| pub plugin_display_names: Vec<String>, | |
| pub tool_summaries: Option<Vec<AppToolSummary>>, | |
| } | |
| /// EXPERIMENTAL - app/read response. | |
| pub struct AppsReadResponse { | |
| pub apps: Vec<ConnectorMetadata>, | |
| pub missing_app_ids: Vec<String>, | |
| } | |
| /// EXPERIMENTAL - app metadata summary for plugin responses. | |
| pub struct AppSummary { | |
| pub id: String, | |
| pub name: String, | |
| pub description: Option<String>, | |
| pub install_url: Option<String>, | |
| pub category: Option<String>, | |
| } | |
| impl From<AppInfo> 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, | |
| } | |
| } | |
| } | |
| /// EXPERIMENTAL - app list response. | |
| pub struct AppsListResponse { | |
| pub data: Vec<AppInfo>, | |
| /// 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<String>, | |
| } | |
| /// EXPERIMENTAL - notification emitted when the app list changes. | |
| pub struct AppListUpdatedNotification { | |
| pub data: Vec<AppInfo>, | |
| } | |