mirror of
https://github.com/openai/codex.git
synced 2026-11-06 00:30:29 +00:00
Add executor-owned plugin resolution (#27692)
## Why
CCA can select a capability root that lives in an executor environment,
but
Codex only had a host-filesystem plugin loader. Before selected executor
plugins can contribute MCP servers, we need a small package boundary
that can
answer:
> Does this selected root contain a plugin, and if so, what does its
manifest
> declare?
The answer must come from the selected environment's filesystem. A
failed
executor lookup must never fall back to the orchestrator filesystem.
## What this changes
This PR introduces:
```rust
PluginProvider::resolve(root)
-> Result<Option<ResolvedPlugin>, Error>
```
`ExecutorPluginProvider` resolves one `SelectedCapabilityRoot` through
its
exact `environment_id`. It checks the recognized manifest locations,
reads the
manifest through that environment's `ExecutorFileSystem`, and returns an
inert
`ResolvedPlugin` containing:
- the opaque selected-root ID;
- the environment-bound plugin root;
- the authority-bound manifest resource;
- parsed metadata and authority-bound component locators.
Descriptor construction rejects manifest or component paths outside the
selected package root, so consumers cannot accidentally lose the package
boundary when they receive a resolved plugin.
If the root has no plugin manifest, resolution returns `None`, allowing
the
caller to treat it as a standalone capability such as a skill.
```text
selected root: repo -> env-1:/workspace/repo
|
| env-1 filesystem only
v
.codex-plugin/plugin.json
|
v
ResolvedPlugin { authority, root, manifest }
```
The existing host loader and the new executor provider now share the
same
manifest parser. Existing `codex-core-plugins::manifest` type paths
remain
available through re-exports, so host behavior and callers are
unchanged.
## Scope
This is intentionally a non-user-visible package-resolution PR. It does
not:
- parse or register plugin MCP server configurations;
- activate skills, connectors, hooks, or MCP servers;
- change app-server wiring;
- introduce host fallback, caching, or lifecycle behavior.
#27670 has merged, and this PR is now based directly on `main`. Together
with
the resolved MCP catalog from #27634, it establishes the inputs needed
for the
executor stdio MCP vertical without changing the existing MCP runtime.
## Follow-up
The next PR will consume `ResolvedPlugin`, read its declared/default MCP
config
through the same executor filesystem, bind supported stdio servers to
that
environment, and feed those registrations into the resolved MCP catalog.
An
app-server E2E will prove that selecting an executor plugin exposes and
invokes
its tool on the owning executor.
Resume/fork semantics, dynamic environment replacement, and non-stdio
placement remain separate lifecycle decisions.
## Validation
- `just fmt`
- `cargo check --tests -p codex-plugin -p codex-core-plugins`
- `just bazel-lock-check`
- `git diff --check`
Test targets were compiled but not executed locally; CI will run the
test and
Clippy suites.
This commit is contained in:
13 files changed
+1177
-172
No files matched your search
@@ -0,0 +1,157 @@
|
||||
use codex_config::HooksFile;
|
||||
|
||||
/// Parsed plugin metadata parameterized by its resource locator representation.
|
||||
///
|
||||
/// Host loading uses absolute paths, while resolved packages replace them with
|
||||
/// authority-bound locators before exposing the manifest to consumers.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct PluginManifest<Resource> {
|
||||
pub name: String,
|
||||
pub version: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub keywords: Vec<String>,
|
||||
pub paths: PluginManifestPaths<Resource>,
|
||||
pub interface: Option<PluginManifestInterface<Resource>>,
|
||||
}
|
||||
|
||||
/// Component resources declared by a plugin manifest.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct PluginManifestPaths<Resource> {
|
||||
pub skills: Option<Resource>,
|
||||
pub mcp_servers: Option<Resource>,
|
||||
pub apps: Option<Resource>,
|
||||
pub hooks: Option<PluginManifestHooks<Resource>>,
|
||||
}
|
||||
|
||||
/// Hook declarations embedded in or referenced by a plugin manifest.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum PluginManifestHooks<Resource> {
|
||||
Paths(Vec<Resource>),
|
||||
Inline(Vec<HooksFile>),
|
||||
}
|
||||
|
||||
/// Optional model- and UI-facing plugin metadata.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct PluginManifestInterface<Resource> {
|
||||
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>,
|
||||
pub default_prompt: Option<Vec<String>>,
|
||||
pub brand_color: Option<String>,
|
||||
pub composer_icon: Option<Resource>,
|
||||
pub logo: Option<Resource>,
|
||||
pub screenshots: Vec<Resource>,
|
||||
}
|
||||
|
||||
impl<Resource> Default for PluginManifestInterface<Resource> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
display_name: None,
|
||||
short_description: None,
|
||||
long_description: None,
|
||||
developer_name: None,
|
||||
category: None,
|
||||
capabilities: Vec::new(),
|
||||
website_url: None,
|
||||
privacy_policy_url: None,
|
||||
terms_of_service_url: None,
|
||||
default_prompt: None,
|
||||
brand_color: None,
|
||||
composer_icon: None,
|
||||
logo: None,
|
||||
screenshots: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Resource> PluginManifest<Resource> {
|
||||
pub(crate) fn try_map_resources<Mapped, Error>(
|
||||
self,
|
||||
mut map: impl FnMut(Resource) -> Result<Mapped, Error>,
|
||||
) -> Result<PluginManifest<Mapped>, Error> {
|
||||
let PluginManifest {
|
||||
name,
|
||||
version,
|
||||
description,
|
||||
keywords,
|
||||
paths,
|
||||
interface,
|
||||
} = self;
|
||||
let PluginManifestPaths {
|
||||
skills,
|
||||
mcp_servers,
|
||||
apps,
|
||||
hooks,
|
||||
} = paths;
|
||||
let hooks = match hooks {
|
||||
Some(PluginManifestHooks::Paths(paths)) => Some(PluginManifestHooks::Paths(
|
||||
paths
|
||||
.into_iter()
|
||||
.map(&mut map)
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
)),
|
||||
Some(PluginManifestHooks::Inline(hooks)) => Some(PluginManifestHooks::Inline(hooks)),
|
||||
None => None,
|
||||
};
|
||||
let interface = match interface {
|
||||
Some(interface) => {
|
||||
let PluginManifestInterface {
|
||||
display_name,
|
||||
short_description,
|
||||
long_description,
|
||||
developer_name,
|
||||
category,
|
||||
capabilities,
|
||||
website_url,
|
||||
privacy_policy_url,
|
||||
terms_of_service_url,
|
||||
default_prompt,
|
||||
brand_color,
|
||||
composer_icon,
|
||||
logo,
|
||||
screenshots,
|
||||
} = interface;
|
||||
Some(PluginManifestInterface {
|
||||
display_name,
|
||||
short_description,
|
||||
long_description,
|
||||
developer_name,
|
||||
category,
|
||||
capabilities,
|
||||
website_url,
|
||||
privacy_policy_url,
|
||||
terms_of_service_url,
|
||||
default_prompt,
|
||||
brand_color,
|
||||
composer_icon: composer_icon.map(&mut map).transpose()?,
|
||||
logo: logo.map(&mut map).transpose()?,
|
||||
screenshots: screenshots
|
||||
.into_iter()
|
||||
.map(&mut map)
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
})
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
|
||||
Ok(PluginManifest {
|
||||
name,
|
||||
version,
|
||||
description,
|
||||
keywords,
|
||||
paths: PluginManifestPaths {
|
||||
skills: skills.map(&mut map).transpose()?,
|
||||
mcp_servers: mcp_servers.map(&mut map).transpose()?,
|
||||
apps: apps.map(&mut map).transpose()?,
|
||||
hooks,
|
||||
},
|
||||
interface,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user