mirror of
https://github.com/openai/codex.git
synced 2026-12-03 00:41:03 +00:00
Merge remote-tracking branch 'origin/main' into dev/stevenlee/plugin-service-preview-routing
# Conflicts: # codex-rs/app-server/src/request_processors/plugins.rs # codex-rs/codex-mcp/src/codex_apps.rs # codex-rs/codex-mcp/src/connection_manager_tests.rs # codex-rs/codex-mcp/src/mcp/mod.rs # codex-rs/core/src/connectors.rs # codex-rs/core/src/mcp_tool_call_tests.rs # codex-rs/core/src/session/mcp.rs # codex-rs/core/src/session/session.rs
This commit is contained in:
@@ -10,7 +10,9 @@ pub mod plugin_service_routing;
|
||||
|
||||
pub use plugin_namespace::DISCOVERABLE_PLUGIN_MANIFEST_PATHS;
|
||||
pub use plugin_namespace::find_plugin_manifest_path;
|
||||
pub use plugin_namespace::plugin_namespace_for_root_uri;
|
||||
pub use plugin_namespace::plugin_namespace_for_skill_path;
|
||||
pub use plugin_namespace::plugin_namespace_for_skill_uri;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct PluginSkillRoot {
|
||||
|
||||
@@ -24,15 +24,15 @@ struct RawPluginManifestName {
|
||||
name: String,
|
||||
}
|
||||
|
||||
async fn plugin_manifest_name(
|
||||
/// Returns the plugin manifest `name` defined directly below `plugin_root`.
|
||||
pub async fn plugin_namespace_for_root_uri(
|
||||
fs: &dyn ExecutorFileSystem,
|
||||
plugin_root: &AbsolutePathBuf,
|
||||
plugin_root: &PathUri,
|
||||
) -> Option<String> {
|
||||
let mut manifest_path = None;
|
||||
for relative_path in DISCOVERABLE_PLUGIN_MANIFEST_PATHS {
|
||||
let candidate = plugin_root.join(relative_path);
|
||||
let candidate_uri = PathUri::from_abs_path(&candidate);
|
||||
match fs.get_metadata(&candidate_uri, /*sandbox*/ None).await {
|
||||
let candidate = plugin_root.join(relative_path).ok()?;
|
||||
match fs.get_metadata(&candidate, /*sandbox*/ None).await {
|
||||
Ok(metadata) if metadata.is_file => {
|
||||
manifest_path = Some(candidate);
|
||||
break;
|
||||
@@ -40,20 +40,16 @@ async fn plugin_manifest_name(
|
||||
Ok(_) | Err(_) => {}
|
||||
}
|
||||
}
|
||||
let manifest_path = manifest_path?;
|
||||
let manifest_path_uri = PathUri::from_abs_path(&manifest_path);
|
||||
let contents = fs
|
||||
.read_file_text(&manifest_path_uri, /*sandbox*/ None)
|
||||
.read_file_text(&manifest_path?, /*sandbox*/ None)
|
||||
.await
|
||||
.ok()?;
|
||||
let RawPluginManifestName { name: raw_name } = serde_json::from_str(&contents).ok()?;
|
||||
Some(
|
||||
plugin_root
|
||||
.file_name()
|
||||
.and_then(|entry| entry.to_str())
|
||||
.basename()
|
||||
.filter(|_| raw_name.trim().is_empty())
|
||||
.unwrap_or(raw_name.as_str())
|
||||
.to_string(),
|
||||
.unwrap_or(raw_name),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -63,10 +59,20 @@ pub async fn plugin_namespace_for_skill_path(
|
||||
fs: &dyn ExecutorFileSystem,
|
||||
path: &AbsolutePathBuf,
|
||||
) -> Option<String> {
|
||||
for ancestor in path.ancestors() {
|
||||
if let Some(name) = plugin_manifest_name(fs, &ancestor).await {
|
||||
plugin_namespace_for_skill_uri(fs, &PathUri::from_abs_path(path)).await
|
||||
}
|
||||
|
||||
/// Returns the plugin manifest `name` for the nearest URI ancestor of `path`.
|
||||
pub async fn plugin_namespace_for_skill_uri(
|
||||
fs: &dyn ExecutorFileSystem,
|
||||
path: &PathUri,
|
||||
) -> Option<String> {
|
||||
let mut ancestor = Some(path.clone());
|
||||
while let Some(path) = ancestor {
|
||||
if let Some(name) = plugin_namespace_for_root_uri(fs, &path).await {
|
||||
return Some(name);
|
||||
}
|
||||
ancestor = path.parent();
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user