From c67dac89d2f7db52bbc199877f78ee8d37f19045 Mon Sep 17 00:00:00 2001 From: xli-oai Date: Thu, 16 Apr 2026 17:08:16 -0700 Subject: [PATCH] Surface unavailable remote plugin details --- .../codex_app_server_protocol.schemas.json | 16 ++ .../codex_app_server_protocol.v2.schemas.json | 16 ++ .../schema/json/v2/PluginReadResponse.json | 16 ++ .../schema/typescript/v2/PluginDetail.ts | 3 +- .../v2/PluginDetailsUnavailableReason.ts | 5 + .../schema/typescript/v2/index.ts | 1 + .../app-server-protocol/src/protocol/v2.rs | 8 + codex-rs/app-server/README.md | 2 +- .../app-server/src/codex_message_processor.rs | 9 + .../app-server/tests/suite/v2/plugin_read.rs | 184 ++++++++++++++++++ 10 files changed, 258 insertions(+), 2 deletions(-) create mode 100644 codex-rs/app-server-protocol/schema/typescript/v2/PluginDetailsUnavailableReason.ts diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json index cb59ac2a8a..edc58ce2a0 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json @@ -10102,6 +10102,16 @@ "null" ] }, + "detailsUnavailableReason": { + "anyOf": [ + { + "$ref": "#/definitions/v2/PluginDetailsUnavailableReason" + }, + { + "type": "null" + } + ] + }, "marketplaceName": { "type": "string" }, @@ -10134,6 +10144,12 @@ ], "type": "object" }, + "PluginDetailsUnavailableReason": { + "enum": [ + "installRequiredForRemoteSource" + ], + "type": "string" + }, "PluginInstallParams": { "$schema": "http://json-schema.org/draft-07/schema#", "properties": { diff --git a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json index 12eb378e90..ef5ccef757 100644 --- a/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json +++ b/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.v2.schemas.json @@ -6874,6 +6874,16 @@ "null" ] }, + "detailsUnavailableReason": { + "anyOf": [ + { + "$ref": "#/definitions/PluginDetailsUnavailableReason" + }, + { + "type": "null" + } + ] + }, "marketplaceName": { "type": "string" }, @@ -6906,6 +6916,12 @@ ], "type": "object" }, + "PluginDetailsUnavailableReason": { + "enum": [ + "installRequiredForRemoteSource" + ], + "type": "string" + }, "PluginInstallParams": { "$schema": "http://json-schema.org/draft-07/schema#", "properties": { diff --git a/codex-rs/app-server-protocol/schema/json/v2/PluginReadResponse.json b/codex-rs/app-server-protocol/schema/json/v2/PluginReadResponse.json index 43628e28f0..a83b3c6102 100644 --- a/codex-rs/app-server-protocol/schema/json/v2/PluginReadResponse.json +++ b/codex-rs/app-server-protocol/schema/json/v2/PluginReadResponse.json @@ -58,6 +58,16 @@ "null" ] }, + "detailsUnavailableReason": { + "anyOf": [ + { + "$ref": "#/definitions/PluginDetailsUnavailableReason" + }, + { + "type": "null" + } + ] + }, "marketplaceName": { "type": "string" }, @@ -90,6 +100,12 @@ ], "type": "object" }, + "PluginDetailsUnavailableReason": { + "enum": [ + "installRequiredForRemoteSource" + ], + "type": "string" + }, "PluginInstallPolicy": { "enum": [ "NOT_AVAILABLE", diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/PluginDetail.ts b/codex-rs/app-server-protocol/schema/typescript/v2/PluginDetail.ts index 4bfd35fe70..2d84651e9b 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/PluginDetail.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/PluginDetail.ts @@ -3,7 +3,8 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { AbsolutePathBuf } from "../AbsolutePathBuf"; import type { AppSummary } from "./AppSummary"; +import type { PluginDetailsUnavailableReason } from "./PluginDetailsUnavailableReason"; import type { PluginSummary } from "./PluginSummary"; import type { SkillSummary } from "./SkillSummary"; -export type PluginDetail = { marketplaceName: string, marketplacePath: AbsolutePathBuf, summary: PluginSummary, description: string | null, skills: Array, apps: Array, mcpServers: Array, }; +export type PluginDetail = { marketplaceName: string, marketplacePath: AbsolutePathBuf, summary: PluginSummary, description: string | null, skills: Array, apps: Array, mcpServers: Array, detailsUnavailableReason: PluginDetailsUnavailableReason | null, }; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/PluginDetailsUnavailableReason.ts b/codex-rs/app-server-protocol/schema/typescript/v2/PluginDetailsUnavailableReason.ts new file mode 100644 index 0000000000..3e819ec6a3 --- /dev/null +++ b/codex-rs/app-server-protocol/schema/typescript/v2/PluginDetailsUnavailableReason.ts @@ -0,0 +1,5 @@ +// GENERATED CODE! DO NOT MODIFY BY HAND! + +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type PluginDetailsUnavailableReason = "installRequiredForRemoteSource"; diff --git a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts index d432530b42..fb88dcecb2 100644 --- a/codex-rs/app-server-protocol/schema/typescript/v2/index.ts +++ b/codex-rs/app-server-protocol/schema/typescript/v2/index.ts @@ -224,6 +224,7 @@ export type { PermissionsRequestApprovalResponse } from "./PermissionsRequestApp export type { PlanDeltaNotification } from "./PlanDeltaNotification"; export type { PluginAuthPolicy } from "./PluginAuthPolicy"; export type { PluginDetail } from "./PluginDetail"; +export type { PluginDetailsUnavailableReason } from "./PluginDetailsUnavailableReason"; export type { PluginInstallParams } from "./PluginInstallParams"; export type { PluginInstallPolicy } from "./PluginInstallPolicy"; export type { PluginInstallResponse } from "./PluginInstallResponse"; diff --git a/codex-rs/app-server-protocol/src/protocol/v2.rs b/codex-rs/app-server-protocol/src/protocol/v2.rs index 35718d614a..afb4be0087 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2.rs @@ -3589,6 +3589,14 @@ pub struct PluginDetail { pub skills: Vec, pub apps: Vec, pub mcp_servers: Vec, + pub details_unavailable_reason: Option, +} + +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)] +#[serde(rename_all = "camelCase")] +#[ts(export_to = "v2/")] +pub enum PluginDetailsUnavailableReason { + InstallRequiredForRemoteSource, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)] diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.md index 5cfe052b50..b5b3240833 100644 --- a/codex-rs/app-server/README.md +++ b/codex-rs/app-server/README.md @@ -185,7 +185,7 @@ Example with notification opt-out: - `skills/list` — list skills for one or more `cwd` values (optional `forceReload`). - `marketplace/add` — add a remote plugin marketplace from an HTTP(S) Git URL, SSH Git URL, or GitHub `owner/repo` shorthand, then persist it into the user marketplace config. Returns the installed root path plus whether the marketplace was already present. - `plugin/list` — list discovered plugin marketplaces and plugin state, including effective marketplace install/auth policy metadata, fail-open `marketplaceLoadErrors` entries for marketplace files that could not be parsed or loaded, and best-effort `featuredPluginIds` for the official curated marketplace. `interface.category` uses the marketplace category when present; otherwise it falls back to the plugin manifest category. Pass `forceRemoteSync: true` to refresh curated plugin state before listing (**under development; do not call from production clients yet**). -- `plugin/read` — read one plugin by `marketplacePath` plus `pluginName`, returning marketplace info, a list-style `summary`, manifest descriptions/interface metadata, and bundled skills/apps/MCP server names. Returned plugin skills include their current `enabled` state after local config filtering. Plugin app summaries also include `needsAuth` when the server can determine connector accessibility (**under development; do not call from production clients yet**). +- `plugin/read` — read one plugin by `marketplacePath` plus `pluginName`, returning marketplace info, a list-style `summary`, manifest descriptions/interface metadata, and bundled skills/apps/MCP server names. For uninstalled remote Git plugin sources, `detailsUnavailableReason` is `installRequiredForRemoteSource` and bundled skills/apps/MCP servers are empty so browsing does not clone remote content. Returned plugin skills include their current `enabled` state after local config filtering. Plugin app summaries also include `needsAuth` when the server can determine connector accessibility (**under development; do not call from production clients yet**). - `skills/changed` — notification emitted when watched local skill files change. - `app/list` — list available apps. - `skills/config/write` — write user-level skill config by name or absolute path. diff --git a/codex-rs/app-server/src/codex_message_processor.rs b/codex-rs/app-server/src/codex_message_processor.rs index 5b39e63a47..82bc492645 100644 --- a/codex-rs/app-server/src/codex_message_processor.rs +++ b/codex-rs/app-server/src/codex_message_processor.rs @@ -98,6 +98,7 @@ use codex_app_server_protocol::MockExperimentalMethodResponse; use codex_app_server_protocol::ModelListParams; use codex_app_server_protocol::ModelListResponse; use codex_app_server_protocol::PluginDetail; +use codex_app_server_protocol::PluginDetailsUnavailableReason; use codex_app_server_protocol::PluginInstallParams; use codex_app_server_protocol::PluginInstallResponse; use codex_app_server_protocol::PluginInterface; @@ -235,6 +236,7 @@ use codex_core::find_thread_path_by_id_str; use codex_core::path_utils; use codex_core::plugins::MarketplaceAddError; use codex_core::plugins::OPENAI_CURATED_MARKETPLACE_NAME; +use codex_core::plugins::PluginDetailsUnavailableReason as CorePluginDetailsUnavailableReason; use codex_core::plugins::PluginInstallError as CorePluginInstallError; use codex_core::plugins::PluginInstallRequest; use codex_core::plugins::PluginReadRequest; @@ -6407,6 +6409,13 @@ impl CodexMessageProcessor { skills: plugin_skills_to_info(&visible_skills, &outcome.plugin.disabled_skill_paths), apps: app_summaries, mcp_servers: outcome.plugin.mcp_server_names, + details_unavailable_reason: outcome.plugin.details_unavailable_reason.map(|reason| { + match reason { + CorePluginDetailsUnavailableReason::InstallRequiredForRemoteSource => { + PluginDetailsUnavailableReason::InstallRequiredForRemoteSource + } + } + }), }; self.outgoing diff --git a/codex-rs/app-server/tests/suite/v2/plugin_read.rs b/codex-rs/app-server/tests/suite/v2/plugin_read.rs index 115a04f0f5..bacbacd1d4 100644 --- a/codex-rs/app-server/tests/suite/v2/plugin_read.rs +++ b/codex-rs/app-server/tests/suite/v2/plugin_read.rs @@ -19,6 +19,8 @@ use axum::routing::get; use codex_app_server_protocol::AppInfo; use codex_app_server_protocol::JSONRPCResponse; use codex_app_server_protocol::PluginAuthPolicy; +use codex_app_server_protocol::PluginDetailsUnavailableReason; +use codex_app_server_protocol::PluginInstallParams; use codex_app_server_protocol::PluginInstallPolicy; use codex_app_server_protocol::PluginReadParams; use codex_app_server_protocol::PluginReadResponse; @@ -262,6 +264,163 @@ enabled = true Ok(()) } +#[tokio::test] +async fn plugin_read_returns_install_required_for_uninstalled_git_source() -> Result<()> { + let codex_home = TempDir::new()?; + write_plugins_enabled_config(&codex_home)?; + let repo_root = TempDir::new()?; + let missing_remote_repo = repo_root.path().join("missing-remote-plugin-repo"); + let missing_remote_repo_url = url::Url::from_directory_path(&missing_remote_repo) + .unwrap() + .to_string(); + std::fs::create_dir_all(repo_root.path().join(".git"))?; + std::fs::create_dir_all(repo_root.path().join(".agents/plugins"))?; + std::fs::write( + repo_root.path().join(".agents/plugins/marketplace.json"), + format!( + r#"{{ + "name": "debug", + "plugins": [ + {{ + "name": "toolkit", + "source": {{ + "source": "git-subdir", + "url": "{missing_remote_repo_url}", + "path": "plugins/toolkit" + }} + }} + ] +}}"# + ), + )?; + + let mut mcp = McpProcess::new(codex_home.path()).await?; + timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??; + + let request_id = mcp + .send_plugin_read_request(PluginReadParams { + marketplace_path: AbsolutePathBuf::try_from( + repo_root.path().join(".agents/plugins/marketplace.json"), + )?, + plugin_name: "toolkit".to_string(), + }) + .await?; + + let response: JSONRPCResponse = timeout( + DEFAULT_TIMEOUT, + mcp.read_stream_until_response_message(RequestId::Integer(request_id)), + ) + .await??; + let response: PluginReadResponse = to_response(response)?; + + assert_eq!( + response.plugin.details_unavailable_reason, + Some(PluginDetailsUnavailableReason::InstallRequiredForRemoteSource) + ); + assert!(!response.plugin.summary.installed); + assert!(response.plugin.skills.is_empty()); + assert!(response.plugin.apps.is_empty()); + assert!(response.plugin.mcp_servers.is_empty()); + assert!( + !codex_home + .path() + .join("plugins/.marketplace-plugin-source-staging") + .exists() + ); + Ok(()) +} + +#[tokio::test] +async fn plugin_read_returns_full_details_after_git_source_install() -> Result<()> { + let codex_home = TempDir::new()?; + write_plugins_enabled_config(&codex_home)?; + let repo_root = TempDir::new()?; + let remote_repo = TempDir::new()?; + let remote_repo_url = url::Url::from_directory_path(remote_repo.path()) + .unwrap() + .to_string(); + let remote_plugin_root = remote_repo.path().join("plugins/toolkit"); + std::fs::create_dir_all(remote_plugin_root.join(".codex-plugin"))?; + std::fs::create_dir_all(remote_plugin_root.join("skills/search"))?; + std::fs::write( + remote_plugin_root.join(".codex-plugin/plugin.json"), + r#"{ + "name": "toolkit", + "description": "Remote toolkit plugin" +}"#, + )?; + std::fs::write( + remote_plugin_root.join("skills/search/SKILL.md"), + "---\nname: search\ndescription: search remote data\n---\n", + )?; + std::fs::write( + remote_plugin_root.join(".mcp.json"), + r#"{"mcpServers":{"toolkit":{"command":"toolkit-mcp"}}}"#, + )?; + init_git_repo(remote_repo.path()); + std::fs::create_dir_all(repo_root.path().join(".git"))?; + std::fs::create_dir_all(repo_root.path().join(".agents/plugins"))?; + std::fs::write( + repo_root.path().join(".agents/plugins/marketplace.json"), + format!( + r#"{{ + "name": "debug", + "plugins": [ + {{ + "name": "toolkit", + "source": {{ + "source": "git-subdir", + "url": "{remote_repo_url}", + "path": "plugins/toolkit" + }} + }} + ] +}}"# + ), + )?; + + let mut mcp = McpProcess::new(codex_home.path()).await?; + timeout(DEFAULT_TIMEOUT, mcp.initialize()).await??; + let marketplace_path = + AbsolutePathBuf::try_from(repo_root.path().join(".agents/plugins/marketplace.json"))?; + let install_request_id = mcp + .send_plugin_install_request(PluginInstallParams { + marketplace_path: marketplace_path.clone(), + plugin_name: "toolkit".to_string(), + force_remote_sync: false, + }) + .await?; + timeout( + DEFAULT_TIMEOUT, + mcp.read_stream_until_response_message(RequestId::Integer(install_request_id)), + ) + .await??; + + let read_request_id = mcp + .send_plugin_read_request(PluginReadParams { + marketplace_path, + plugin_name: "toolkit".to_string(), + }) + .await?; + let response: JSONRPCResponse = timeout( + DEFAULT_TIMEOUT, + mcp.read_stream_until_response_message(RequestId::Integer(read_request_id)), + ) + .await??; + let response: PluginReadResponse = to_response(response)?; + + assert_eq!(response.plugin.details_unavailable_reason, None); + assert!(response.plugin.summary.installed); + assert_eq!( + response.plugin.description.as_deref(), + Some("Remote toolkit plugin") + ); + assert_eq!(response.plugin.skills.len(), 1); + assert_eq!(response.plugin.skills[0].name, "toolkit:search"); + assert_eq!(response.plugin.mcp_servers, vec!["toolkit".to_string()]); + Ok(()) +} + #[tokio::test] async fn plugin_read_returns_app_needs_auth() -> Result<()> { let connectors = vec![ @@ -549,6 +708,31 @@ plugins = true Ok(()) } +fn init_git_repo(repo: &std::path::Path) { + run_git(repo, &["init"]); + run_git(repo, &["config", "user.email", "codex-test@example.com"]); + run_git(repo, &["config", "user.name", "Codex Test"]); + run_git(repo, &["add", "."]); + run_git(repo, &["commit", "-m", "initial"]); +} + +fn run_git(repo: &std::path::Path, args: &[&str]) { + let output = std::process::Command::new("git") + .arg("-C") + .arg(repo) + .args(args) + .output() + .unwrap_or_else(|err| panic!("git should run: {err}")); + assert!( + output.status.success(), + "git -C {} {} failed\nstdout:\n{}\nstderr:\n{}", + repo.display(), + args.join(" "), + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); +} + #[derive(Clone)] struct AppsServerState { response: Arc>,