mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
[codex] remove EnvironmentPathRef (#27433)
We're switching to using a static encoding of the host path in `PathUri`. We may need a type like this again but we can add it when it's more compelling. Stacked on #27454.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use codex_core_skills::model::SkillDependencies;
|
||||
use codex_exec_server::EnvironmentPathRef;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
|
||||
/// Source authority that owns a skill package and must be used to read it.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
@@ -62,7 +62,7 @@ pub struct SkillPackageId(pub String);
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct SkillResourceId {
|
||||
id: String,
|
||||
environment_path: Option<EnvironmentPathRef>,
|
||||
environment_path: Option<EnvironmentSkillResource>,
|
||||
}
|
||||
|
||||
impl SkillResourceId {
|
||||
@@ -73,10 +73,17 @@ impl SkillResourceId {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn environment(id: impl Into<String>, path: EnvironmentPathRef) -> Self {
|
||||
pub fn environment(
|
||||
id: impl Into<String>,
|
||||
environment_id: impl Into<String>,
|
||||
path: AbsolutePathBuf,
|
||||
) -> Self {
|
||||
Self {
|
||||
id: id.into(),
|
||||
environment_path: Some(path),
|
||||
environment_path: Some(EnvironmentSkillResource {
|
||||
environment_id: environment_id.into(),
|
||||
path,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +91,19 @@ impl SkillResourceId {
|
||||
&self.id
|
||||
}
|
||||
|
||||
pub(crate) fn environment_path(&self) -> Option<&EnvironmentPathRef> {
|
||||
self.environment_path.as_ref()
|
||||
pub(crate) fn environment_path(&self) -> Option<(&str, &AbsolutePathBuf)> {
|
||||
self.environment_path
|
||||
.as_ref()
|
||||
.map(|resource| (resource.environment_id.as_str(), &resource.path))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
struct EnvironmentSkillResource {
|
||||
environment_id: String,
|
||||
path: AbsolutePathBuf,
|
||||
}
|
||||
|
||||
/// Metadata shown in the always-visible skills catalog.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct SkillCatalogEntry {
|
||||
|
||||
@@ -6,7 +6,6 @@ use codex_core_skills::filter_skill_load_outcome_for_product;
|
||||
use codex_core_skills::loader::SkillRoot;
|
||||
use codex_core_skills::loader::load_skills_from_roots;
|
||||
use codex_exec_server::EnvironmentManager;
|
||||
use codex_exec_server::EnvironmentPathRef;
|
||||
use codex_protocol::capabilities::CapabilityRootLocation;
|
||||
use codex_protocol::protocol::Product;
|
||||
use codex_protocol::protocol::SkillScope;
|
||||
@@ -99,7 +98,7 @@ impl SkillProvider for ExecutorSkillProvider {
|
||||
enabled,
|
||||
authority.clone(),
|
||||
&selected_root_id,
|
||||
Arc::clone(&file_system),
|
||||
&environment_id,
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -121,13 +120,19 @@ impl SkillProvider for ExecutorSkillProvider {
|
||||
"executor skill resource does not match its package",
|
||||
));
|
||||
}
|
||||
let Some(resource_path) = request.resource.environment_path() else {
|
||||
let Some((environment_id, resource_path)) = request.resource.environment_path() else {
|
||||
return Err(SkillProviderError::new(
|
||||
"executor skill resource is not bound to an environment",
|
||||
));
|
||||
};
|
||||
let contents = resource_path
|
||||
.read_to_string(/*sandbox*/ None)
|
||||
let Some(environment) = self.environment_manager.get_environment(environment_id) else {
|
||||
return Err(SkillProviderError::new(format!(
|
||||
"executor skill resource references unavailable environment `{environment_id}`"
|
||||
)));
|
||||
};
|
||||
let contents = environment
|
||||
.get_filesystem()
|
||||
.read_file_text(resource_path, /*sandbox*/ None)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
SkillProviderError::new(format!(
|
||||
@@ -153,7 +158,7 @@ fn catalog_entry_from_skill(
|
||||
enabled: bool,
|
||||
authority: SkillAuthority,
|
||||
selected_root_id: &str,
|
||||
file_system: Arc<dyn codex_exec_server::ExecutorFileSystem>,
|
||||
environment_id: &str,
|
||||
) -> SkillCatalogEntry {
|
||||
let skill_path = skill.path_to_skills_md.to_string_lossy().into_owned();
|
||||
let normalized_path = skill_path.replace('\\', "/");
|
||||
@@ -168,7 +173,8 @@ fn catalog_entry_from_skill(
|
||||
skill.description.clone(),
|
||||
SkillResourceId::environment(
|
||||
display_path.clone(),
|
||||
EnvironmentPathRef::new(file_system, skill.path_to_skills_md.clone()),
|
||||
environment_id,
|
||||
skill.path_to_skills_md.clone(),
|
||||
),
|
||||
)
|
||||
.with_short_description(skill.short_description.clone())
|
||||
|
||||
Reference in New Issue
Block a user