Download codex-rs/app-server-protocol/src/protocol/v2/plugin.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 35.5 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/app-server-protocol/src/protocol/v2/plugin.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/app-server-protocol/src/protocol/v2/plugin.rs
-
curl -L -o plugin.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/app-server-protocol/src/protocol/v2/plugin.rs
35.5 kB
| use super::AppSummary; | |
| use super::HookEventName; | |
| use super::HookSource; | |
| use super::HookTrustStatus; | |
| use crate::JsonSchema; | |
| use crate::TS; | |
| use codex_protocol::protocol::SkillDependencies as CoreSkillDependencies; | |
| use codex_protocol::protocol::SkillInterface as CoreSkillInterface; | |
| use codex_protocol::protocol::SkillMetadata as CoreSkillMetadata; | |
| use codex_protocol::protocol::SkillScope as CoreSkillScope; | |
| use codex_protocol::protocol::SkillToolDependency as CoreSkillToolDependency; | |
| use codex_utils_absolute_path::AbsolutePathBuf; | |
| use serde::Deserialize; | |
| use serde::Serialize; | |
| use std::path::PathBuf; | |
| pub struct SkillsListParams { | |
| /// When empty, defaults to the current session working directory. | |
| pub cwds: Vec<PathBuf>, | |
| /// When true, bypass the skills cache and re-scan skills from disk. | |
| pub force_reload: bool, | |
| } | |
| pub struct SkillsListResponse { | |
| pub data: Vec<SkillsListEntry>, | |
| } | |
| pub struct SkillsExtraRootsSetParams { | |
| pub extra_roots: Vec<AbsolutePathBuf>, | |
| } | |
| pub struct SkillsExtraRootsSetResponse {} | |
| pub struct HooksListParams { | |
| /// When empty, defaults to the current session working directory. | |
| pub cwds: Vec<PathBuf>, | |
| } | |
| pub struct HooksListResponse { | |
| pub data: Vec<HooksListEntry>, | |
| } | |
| pub struct MarketplaceAddParams { | |
| pub source: String, | |
| pub ref_name: Option<String>, | |
| pub sparse_paths: Option<Vec<String>>, | |
| } | |
| pub struct MarketplaceAddResponse { | |
| pub marketplace_name: String, | |
| pub installed_root: AbsolutePathBuf, | |
| pub already_added: bool, | |
| } | |
| pub struct MarketplaceRemoveParams { | |
| pub marketplace_name: String, | |
| } | |
| pub struct MarketplaceRemoveResponse { | |
| pub marketplace_name: String, | |
| pub installed_root: Option<AbsolutePathBuf>, | |
| } | |
| pub struct MarketplaceUpgradeParams { | |
| pub marketplace_name: Option<String>, | |
| } | |
| pub struct MarketplaceUpgradeResponse { | |
| pub selected_marketplaces: Vec<String>, | |
| pub upgraded_roots: Vec<AbsolutePathBuf>, | |
| pub errors: Vec<MarketplaceUpgradeErrorInfo>, | |
| } | |
| pub struct MarketplaceUpgradeErrorInfo { | |
| pub marketplace_name: String, | |
| pub message: String, | |
| } | |
| pub struct PluginListParams { | |
| /// Optional working directories used to discover repo marketplaces. When omitted, | |
| /// only home-scoped marketplaces and the official curated marketplace are considered. | |
| pub cwds: Option<Vec<AbsolutePathBuf>>, | |
| /// Optional marketplace kind filter. When omitted, only local marketplaces are queried, plus | |
| /// the default remote catalog when enabled by feature flag. | |
| pub marketplace_kinds: Option<Vec<PluginListMarketplaceKind>>, | |
| /// Whether the client requests a fresh remote plugin catalog fetch. | |
| pub force_refetch: bool, | |
| } | |
| pub struct PluginInstalledParams { | |
| /// Optional working directories used to discover repo marketplaces. | |
| pub cwds: Option<Vec<AbsolutePathBuf>>, | |
| /// Additional uninstalled plugin names that should be returned when present locally. | |
| /// This is used by mention surfaces that intentionally expose install entrypoints. | |
| pub install_suggestion_plugin_names: Option<Vec<String>>, | |
| } | |
| pub enum PluginListMarketplaceKind { | |
| Local, | |
| Vertical, | |
| WorkspaceDirectory, | |
| SharedWithMe, | |
| CreatedByMeRemote, | |
| } | |
| pub struct PluginListResponse { | |
| pub marketplaces: Vec<PluginMarketplaceEntry>, | |
| pub marketplace_load_errors: Vec<MarketplaceLoadErrorInfo>, | |
| pub featured_plugin_ids: Vec<String>, | |
| } | |
| pub struct PluginInstalledResponse { | |
| pub marketplaces: Vec<PluginMarketplaceEntry>, | |
| pub marketplace_load_errors: Vec<MarketplaceLoadErrorInfo>, | |
| } | |
| pub struct PluginReconcileParams { | |
| /// Optional client-provided reason recorded with the reconciliation attempt. | |
| pub reason: Option<String>, | |
| } | |
| /// Bundle and installed-state changes observed by this pass, not a runtime-readiness | |
| /// acknowledgement or a cumulative diff since the client's last request. Other metadata-only | |
| /// changes are not listed. | |
| pub struct PluginReconcileResponse { | |
| /// Plugins affected by bundle changes, enablement changes, or removals. | |
| /// Installed-state changes compare against the previous cached snapshot, including | |
| /// cached reinstalls. Removal hints survive cache cleanup failures; unchanged plugins are omitted. | |
| pub changed_plugins: Vec<PluginReconcileChangedPlugin>, | |
| /// Backend remote plugin IDs whose bundle or identity update failed. | |
| pub failed_remote_plugin_ids: Vec<String>, | |
| /// Subset of failures for which the requested bundle could not be materialized. | |
| /// A previously cached version may still be available. | |
| pub failed_materialization_remote_plugin_ids: Vec<String>, | |
| } | |
| /// Runtime categories affected by this change, not just capabilities currently present. | |
| /// Flags describe declarations before runtime policy filtering. Updates OR the old and new | |
| /// bundle flags; enablement changes and cached reinstalls use the cached bundle; removals retain | |
| /// the old bundle's flags. | |
| pub struct PluginReconcileChangedPlugin { | |
| /// Local plugin ID (`name@marketplace`), matching `PluginSummary.id`. | |
| pub id: String, | |
| pub has_mcps: bool, | |
| pub has_apps: bool, | |
| pub has_hooks: bool, | |
| /// Whether either bundle declares skill roots; not a validated inventory of enabled skills. | |
| pub has_skills: bool, | |
| } | |
| pub struct MarketplaceLoadErrorInfo { | |
| pub marketplace_path: AbsolutePathBuf, | |
| pub message: String, | |
| } | |
| pub struct PluginReadParams { | |
| pub marketplace_path: Option<AbsolutePathBuf>, | |
| pub remote_marketplace_name: Option<String>, | |
| pub plugin_name: String, | |
| } | |
| pub struct PluginReadResponse { | |
| pub plugin: PluginDetail, | |
| } | |
| pub struct PluginSkillReadParams { | |
| pub remote_marketplace_name: String, | |
| pub remote_plugin_id: String, | |
| pub skill_name: String, | |
| } | |
| pub struct PluginSkillReadResponse { | |
| pub contents: Option<String>, | |
| } | |
| pub struct PluginShareSaveParams { | |
| pub plugin_path: AbsolutePathBuf, | |
| pub remote_plugin_id: Option<String>, | |
| pub discoverability: Option<PluginShareDiscoverability>, | |
| pub share_targets: Option<Vec<PluginShareTarget>>, | |
| } | |
| pub struct PluginShareSaveResponse { | |
| pub remote_plugin_id: String, | |
| pub share_url: String, | |
| pub can_publish_to_workspace: Option<bool>, | |
| } | |
| pub struct PluginShareUpdateTargetsParams { | |
| pub remote_plugin_id: String, | |
| pub discoverability: PluginShareUpdateDiscoverability, | |
| pub share_targets: Vec<PluginShareTarget>, | |
| } | |
| pub struct PluginShareUpdateTargetsResponse { | |
| pub principals: Vec<PluginSharePrincipal>, | |
| pub discoverability: PluginShareDiscoverability, | |
| } | |
| pub struct PluginShareListParams {} | |
| pub struct PluginShareListResponse { | |
| pub data: Vec<PluginShareListItem>, | |
| } | |
| pub struct PluginShareCheckoutParams { | |
| pub remote_plugin_id: String, | |
| } | |
| pub struct PluginShareCheckoutResponse { | |
| pub remote_plugin_id: String, | |
| pub plugin_id: String, | |
| pub plugin_name: String, | |
| pub plugin_path: AbsolutePathBuf, | |
| pub marketplace_name: String, | |
| pub marketplace_path: AbsolutePathBuf, | |
| pub remote_version: Option<String>, | |
| } | |
| pub struct PluginShareDeleteParams { | |
| pub remote_plugin_id: String, | |
| } | |
| pub struct PluginShareDeleteResponse {} | |
| pub struct PluginShareListItem { | |
| pub plugin: PluginSummary, | |
| pub local_plugin_path: Option<AbsolutePathBuf>, | |
| } | |
| pub enum PluginShareDiscoverability { | |
| Listed, | |
| Unlisted, | |
| Private, | |
| } | |
| pub enum PluginShareUpdateDiscoverability { | |
| Unlisted, | |
| Private, | |
| Listed, | |
| } | |
| pub enum PluginSharePrincipalType { | |
| User, | |
| Group, | |
| Workspace, | |
| } | |
| pub struct PluginShareTarget { | |
| pub principal_type: PluginSharePrincipalType, | |
| pub principal_id: String, | |
| pub role: PluginShareTargetRole, | |
| } | |
| pub struct PluginSharePrincipal { | |
| pub principal_type: PluginSharePrincipalType, | |
| pub principal_id: String, | |
| pub role: PluginSharePrincipalRole, | |
| pub name: String, | |
| } | |
| pub enum PluginShareTargetRole { | |
| Reader, | |
| Editor, | |
| } | |
| pub enum PluginSharePrincipalRole { | |
| Reader, | |
| Editor, | |
| Owner, | |
| } | |
| pub enum SkillScope { | |
| User, | |
| Repo, | |
| System, | |
| Admin, | |
| } | |
| pub struct SkillMetadata { | |
| pub name: String, | |
| pub description: String, | |
| /// Legacy short_description from SKILL.md. Prefer SKILL.json interface.short_description. | |
| pub short_description: Option<String>, | |
| pub interface: Option<SkillInterface>, | |
| pub dependencies: Option<SkillDependencies>, | |
| pub path: AbsolutePathBuf, | |
| pub scope: SkillScope, | |
| pub enabled: bool, | |
| /// Owning plugin ID, matching `PluginSummary.id`, when known. | |
| pub plugin_id: Option<String>, | |
| } | |
| pub struct SkillInterface { | |
| pub display_name: Option<String>, | |
| pub short_description: Option<String>, | |
| pub icon_small: Option<AbsolutePathBuf>, | |
| pub icon_large: Option<AbsolutePathBuf>, | |
| /// Remote small icon URL from the plugin catalog. | |
| pub icon_small_url: Option<String>, | |
| /// Remote large icon URL from the plugin catalog. | |
| pub icon_large_url: Option<String>, | |
| pub brand_color: Option<String>, | |
| pub default_prompt: Option<String>, | |
| } | |
| pub struct SkillDependencies { | |
| pub tools: Vec<SkillToolDependency>, | |
| } | |
| pub struct SkillToolDependency { | |
| pub r#type: String, | |
| pub value: String, | |
| pub description: Option<String>, | |
| pub transport: Option<String>, | |
| pub command: Option<String>, | |
| pub url: Option<String>, | |
| } | |
| pub struct SkillErrorInfo { | |
| pub path: PathBuf, | |
| pub message: String, | |
| } | |
| pub struct SkillsListEntry { | |
| pub cwd: PathBuf, | |
| pub skills: Vec<SkillMetadata>, | |
| pub errors: Vec<SkillErrorInfo>, | |
| } | |
| pub struct HooksListEntry { | |
| pub cwd: PathBuf, | |
| pub hooks: Vec<HookMetadata>, | |
| pub warnings: Vec<String>, | |
| pub errors: Vec<HookErrorInfo>, | |
| } | |
| pub enum HookHandlerMetadata { | |
| Command { | |
| command: String, | |
| r#async: bool, | |
| }, | |
| McpTool { | |
| server: String, | |
| tool: String, | |
| }, | |
| Prompt {}, | |
| Agent {}, | |
| } | |
| pub struct HookMetadata { | |
| pub key: String, | |
| pub event_name: HookEventName, | |
| pub handler: HookHandlerMetadata, | |
| pub matcher: Option<String>, | |
| pub timeout_sec: u64, | |
| pub status_message: Option<String>, | |
| /// Configured `additionalContext` spill threshold. | |
| /// `null` uses 2,500 tokens; `0` disables spilling. | |
| pub additional_context_limit: Option<usize>, | |
| pub source_path: AbsolutePathBuf, | |
| pub source: HookSource, | |
| pub plugin_id: Option<String>, | |
| pub display_order: i64, | |
| pub enabled: bool, | |
| pub is_managed: bool, | |
| pub current_hash: String, | |
| pub trust_status: HookTrustStatus, | |
| } | |
| pub struct HookErrorInfo { | |
| pub path: PathBuf, | |
| pub message: String, | |
| } | |
| pub struct PluginMarketplaceEntry { | |
| pub name: String, | |
| /// Local marketplace file path when the marketplace is backed by a local file. | |
| /// Remote-only catalog marketplaces do not have a local path. | |
| pub path: Option<AbsolutePathBuf>, | |
| pub interface: Option<MarketplaceInterface>, | |
| pub plugins: Vec<PluginSummary>, | |
| } | |
| pub struct MarketplaceInterface { | |
| pub display_name: Option<String>, | |
| } | |
| pub enum PluginInstallPolicy { | |
| NotAvailable, | |
| Available, | |
| InstalledByDefault, | |
| } | |
| pub enum PluginInstallPolicySource { | |
| WorkspaceSetting, | |
| ImplicitCanonicalApp, | |
| } | |
| pub enum PluginAuthPolicy { | |
| OnInstall, | |
| OnUse, | |
| } | |
| pub enum PluginAvailability { | |
| /// Plugin-service currently sends `"ENABLED"` for available remote plugins. | |
| /// Codex app-server exposes `"AVAILABLE"` in its API; the alias keeps | |
| /// decoding compatible with that upstream response. | |
| Available, | |
| DisabledByAdmin, | |
| } | |
| pub enum PluginDisabledReason { | |
| DisabledByAdmin, | |
| PlanNotEligible, | |
| RequiredAppUnavailable, | |
| Unknown, | |
| } | |
| pub struct PluginSummary { | |
| pub id: String, | |
| /// Backend remote plugin identifier when available. | |
| pub remote_plugin_id: Option<String>, | |
| /// Version advertised by the remote marketplace backend when available. | |
| pub version: Option<String>, | |
| /// Version of the locally materialized plugin package when available. | |
| pub local_version: Option<String>, | |
| pub name: String, | |
| /// Remote sharing context associated with this plugin when available. | |
| pub share_context: Option<PluginShareContext>, | |
| pub source: PluginSource, | |
| pub installed: bool, | |
| /// Unix timestamp in seconds when the remote plugin was installed, when available. | |
| pub installed_at: Option<i64>, | |
| pub enabled: bool, | |
| pub install_policy: PluginInstallPolicy, | |
| pub install_policy_source: Option<PluginInstallPolicySource>, | |
| pub must_show_installation_interstitial: Option<bool>, | |
| pub auth_policy: PluginAuthPolicy, | |
| /// Availability state for installing and using the plugin. | |
| pub availability: PluginAvailability, | |
| /// Why the remote plugin is unavailable, when provided by plugin-service. | |
| pub disabled_reason: Option<PluginDisabledReason>, | |
| /// Raw plugin-service plan identifiers eligible to install the plugin. | |
| pub eligible_plan_types: Option<Vec<String>>, | |
| pub interface: Option<PluginInterface>, | |
| pub keywords: Vec<String>, | |
| } | |
| pub struct PluginShareContext { | |
| pub remote_plugin_id: String, | |
| /// Version of the remote shared plugin release when available. | |
| pub remote_version: Option<String>, | |
| pub discoverability: Option<PluginShareDiscoverability>, | |
| pub share_url: Option<String>, | |
| pub creator_account_user_id: Option<String>, | |
| pub creator_name: Option<String>, | |
| pub share_principals: Option<Vec<PluginSharePrincipal>>, | |
| pub can_publish_to_workspace: Option<bool>, | |
| } | |
| pub struct PluginDetail { | |
| pub marketplace_name: String, | |
| pub marketplace_path: Option<AbsolutePathBuf>, | |
| pub summary: PluginSummary, | |
| pub share_url: Option<String>, | |
| pub description: Option<String>, | |
| pub skills: Vec<SkillSummary>, | |
| pub hooks: Vec<PluginHookSummary>, | |
| pub apps: Vec<AppSummary>, | |
| pub app_templates: Vec<AppTemplateSummary>, | |
| pub mcp_servers: Vec<String>, | |
| pub scheduled_tasks: Option<Vec<ScheduledTaskSummary>>, | |
| } | |
| pub struct ScheduledTaskSummary { | |
| pub key: String, | |
| pub name: String, | |
| pub prompt: String, | |
| pub schedule: ScheduledTaskSchedule, | |
| } | |
| pub enum ScheduledTaskSchedule { | |
| Hourly { | |
| interval_hours: u32, | |
| days: Option<Vec<ScheduledTaskWeekday>>, | |
| }, | |
| Daily { time: String }, | |
| Weekdays { time: String }, | |
| Weekly { | |
| days: Vec<ScheduledTaskWeekday>, | |
| time: String, | |
| }, | |
| } | |
| pub enum ScheduledTaskWeekday { | |
| Mo, | |
| Tu, | |
| We, | |
| Th, | |
| Fr, | |
| Sa, | |
| Su, | |
| } | |
| pub enum AppTemplateUnavailableReason { | |
| NotConfiguredForWorkspace, | |
| NoActiveWorkspace, | |
| } | |
| pub struct AppTemplateSummary { | |
| pub template_id: String, | |
| pub name: String, | |
| pub description: Option<String>, | |
| pub category: Option<String>, | |
| pub canonical_connector_id: Option<String>, | |
| pub logo_url: Option<String>, | |
| pub logo_url_dark: Option<String>, | |
| pub materialized_app_ids: Vec<String>, | |
| pub reason: Option<AppTemplateUnavailableReason>, | |
| } | |
| pub struct PluginHookSummary { | |
| pub key: String, | |
| pub event_name: HookEventName, | |
| } | |
| pub struct SkillSummary { | |
| pub name: String, | |
| pub description: String, | |
| pub short_description: Option<String>, | |
| pub interface: Option<SkillInterface>, | |
| pub path: Option<AbsolutePathBuf>, | |
| pub enabled: bool, | |
| } | |
| pub struct PluginInterface { | |
| pub display_name: Option<String>, | |
| pub short_description: Option<String>, | |
| pub long_description: Option<String>, | |
| pub developer_name: Option<String>, | |
| pub category: Option<String>, | |
| pub capabilities: Vec<String>, | |
| pub website_url: Option<String>, | |
| pub privacy_policy_url: Option<String>, | |
| pub terms_of_service_url: Option<String>, | |
| /// Starter prompts for the plugin. Capped at 3 entries with a maximum of | |
| /// 128 characters per entry. | |
| pub default_prompt: Option<Vec<String>>, | |
| pub brand_color: Option<String>, | |
| /// Local composer icon path, resolved from the installed plugin package. | |
| pub composer_icon: Option<AbsolutePathBuf>, | |
| /// Remote composer icon URL from the plugin catalog. | |
| pub composer_icon_url: Option<String>, | |
| /// Local logo path, resolved from the installed plugin package. | |
| pub logo: Option<AbsolutePathBuf>, | |
| /// Local dark-mode logo path, resolved from the installed plugin package. | |
| pub logo_dark: Option<AbsolutePathBuf>, | |
| /// Remote logo URL from the plugin catalog. | |
| pub logo_url: Option<String>, | |
| /// Remote dark-mode logo URL from the plugin catalog. | |
| pub logo_url_dark: Option<String>, | |
| /// Local screenshot paths, resolved from the installed plugin package. | |
| pub screenshots: Vec<AbsolutePathBuf>, | |
| /// Remote screenshot URLs from the plugin catalog. | |
| pub screenshot_urls: Vec<String>, | |
| } | |
| pub enum PluginSource { | |
| Local { path: AbsolutePathBuf }, | |
| Git { | |
| url: String, | |
| path: Option<String>, | |
| ref_name: Option<String>, | |
| sha: Option<String>, | |
| }, | |
| Npm { | |
| package: String, | |
| /// Optional npm version or version range. | |
| version: Option<String>, | |
| /// Optional HTTPS registry URL. Authentication stays in the user's npm config. | |
| registry: Option<String>, | |
| }, | |
| /// The plugin is available in the remote catalog. Download metadata is | |
| /// kept server-side and is not exposed through the app-server API. | |
| Remote, | |
| } | |
| pub struct SkillsConfigWriteParams { | |
| /// Path-based selector. | |
| pub path: Option<AbsolutePathBuf>, | |
| /// Name-based selector. | |
| pub name: Option<String>, | |
| pub enabled: bool, | |
| } | |
| pub struct SkillsConfigWriteResponse { | |
| pub effective_enabled: bool, | |
| } | |
| pub struct PluginInstallParams { | |
| pub marketplace_path: Option<AbsolutePathBuf>, | |
| pub remote_marketplace_name: Option<String>, | |
| /// Client-generated identifier used to correlate one installation attempt. | |
| pub install_attempt_id: Option<String>, | |
| pub plugin_name: String, | |
| } | |
| pub struct PluginInstallResponse { | |
| pub auth_policy: PluginAuthPolicy, | |
| pub apps_needing_auth: Vec<AppSummary>, | |
| } | |
| pub struct PluginUninstallParams { | |
| pub plugin_id: String, | |
| } | |
| pub struct PluginUninstallResponse {} | |
| impl From<CoreSkillMetadata> for SkillMetadata { | |
| fn from(value: CoreSkillMetadata) -> Self { | |
| Self { | |
| name: value.name, | |
| description: value.description, | |
| short_description: value.short_description, | |
| interface: value.interface.map(SkillInterface::from), | |
| dependencies: value.dependencies.map(SkillDependencies::from), | |
| path: value.path, | |
| scope: value.scope.into(), | |
| enabled: true, | |
| plugin_id: None, | |
| } | |
| } | |
| } | |
| impl From<CoreSkillInterface> for SkillInterface { | |
| fn from(value: CoreSkillInterface) -> Self { | |
| Self { | |
| display_name: value.display_name, | |
| short_description: value.short_description, | |
| brand_color: value.brand_color, | |
| default_prompt: value.default_prompt, | |
| icon_small: value.icon_small, | |
| icon_large: value.icon_large, | |
| icon_small_url: None, | |
| icon_large_url: None, | |
| } | |
| } | |
| } | |
| impl From<CoreSkillDependencies> for SkillDependencies { | |
| fn from(value: CoreSkillDependencies) -> Self { | |
| Self { | |
| tools: value | |
| .tools | |
| .into_iter() | |
| .map(SkillToolDependency::from) | |
| .collect(), | |
| } | |
| } | |
| } | |
| impl From<CoreSkillToolDependency> for SkillToolDependency { | |
| fn from(value: CoreSkillToolDependency) -> Self { | |
| Self { | |
| r#type: value.r#type, | |
| value: value.value, | |
| description: value.description, | |
| transport: value.transport, | |
| command: value.command, | |
| url: value.url, | |
| } | |
| } | |
| } | |
| impl From<CoreSkillScope> for SkillScope { | |
| fn from(value: CoreSkillScope) -> Self { | |
| match value { | |
| CoreSkillScope::User => Self::User, | |
| CoreSkillScope::Repo => Self::Repo, | |
| CoreSkillScope::System => Self::System, | |
| CoreSkillScope::Admin => Self::Admin, | |
| } | |
| } | |
| } | |
| /// Notification emitted when watched local skill files change. | |
| /// | |
| /// Treat this as an invalidation signal and re-run `skills/list` with the | |
| /// client's current parameters when refreshed skill metadata is needed. | |
| pub struct SkillsChangedNotification {} | |