Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(skills): address review on registry installs

M3gA-Mindcd5a853b0dbc
diff --git a/app/src/services/api/skillRegistryApi.test.ts b/app/src/services/api/skillRegistryApi.test.ts
index 30c9bd7c07..f32354e1c9 100644
--- a/app/src/services/api/skillRegistryApi.test.ts
+++ b/app/src/services/api/skillRegistryApi.test.ts
@@ -25,6 +25,8 @@ describe('skillRegistryApi', () => {
expect(mockCallCoreRpc).toHaveBeenCalledWith({
method: 'openhuman.skill_registry_install',
params: { entry_id: 'demo' },
+ // Locating a skills.sh skill plus the 60s fetch outlasts the default 30s.
+ timeoutMs: 120_000,
});
expect(result.newSkills).toEqual(['demo']);
});
diff --git a/app/src/services/api/skillRegistryApi.ts b/app/src/services/api/skillRegistryApi.ts
index ddfcec9298..f8287ad293 100644
--- a/app/src/services/api/skillRegistryApi.ts
+++ b/app/src/services/api/skillRegistryApi.ts
@@ -16,6 +16,14 @@ const log = debug('skillRegistryApi');
*/
const CATALOG_RPC_TIMEOUT_MS = 120_000;
+/**
+ * An install first locates the skill's SKILL.md (for skills.sh entries that
+ * means probing the GitHub repo and possibly listing it), then fetches it with
+ * the core's 60s download budget. That regularly outlasts the default 30s RPC
+ * timeout, which would report a failure for an install still in progress.
+ */
+const INSTALL_RPC_TIMEOUT_MS = 120_000;
+
/**
* In-memory, session-scoped cache for the unfiltered `browse()` catalog.
*
@@ -185,7 +193,11 @@ export const skillRegistryApi = {
log('install: entryId=%s', entryId);
const response = await callCoreRpc<
Envelope<RawRegistryInstallResult> | RawRegistryInstallResult
- >({ method: 'openhuman.skill_registry_install', params: { entry_id: entryId } });
+ >({
+ method: 'openhuman.skill_registry_install',
+ params: { entry_id: entryId },
+ timeoutMs: INSTALL_RPC_TIMEOUT_MS,
+ });
const raw = unwrap(response);
const result: RegistryInstallResult = {
url: raw.url,
diff --git a/crates/openhuman-core/src/platform/about_app/catalog_tests.rs b/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
index 4839fe6538..fe1cfd8d91 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_tests.rs
@@ -122,6 +122,26 @@ fn persona_pack_reports_github_mascot_manifest_destination() {
);
}
+#[test]
+fn workflow_install_discloses_the_skill_download_hosts() {
+ let cap = lookup("workflows.install").expect("workflow install capability exists");
+ let privacy = cap.privacy.expect("workflow install is privacy-annotated");
+
+ assert!(
+ privacy.leaves_device,
+ "installing fetches SKILL.md from a remote host"
+ );
+ assert_eq!(privacy.data_kind, PrivacyDataKind::Metadata);
+ let haystack = privacy.destinations.join(" | ").to_lowercase();
+ assert!(
+ haystack.contains("clawhub.ai")
+ && haystack.contains("raw.githubusercontent.com")
+ && haystack.contains("api.github.com"),
+ "destinations must name the registry download hosts, got: {:?}",
+ privacy.destinations
+ );
+}
+
#[test]
fn unannotated_capability_serializes_without_privacy_field() {
let cap = lookup("conversation.create").expect("capability exists");
diff --git a/crates/openhuman-core/src/platform/about_app/catalog_workflows_automation.rs b/crates/openhuman-core/src/platform/about_app/catalog_workflows_automation.rs
index 8e244ff16a..5ac0aaf48b 100644
--- a/crates/openhuman-core/src/platform/about_app/catalog_workflows_automation.rs
+++ b/crates/openhuman-core/src/platform/about_app/catalog_workflows_automation.rs
@@ -21,7 +21,19 @@ Capability {
description: "Install a workflow into the local workspace.",
how_to: "Intelligence > Workflows > Install",
status: CapabilityStatus::Stable,
- privacy: None,
+ // Installing fetches the skill's SKILL.md from where it is published:
+ // registry skills from ClawHub or GitHub, others from the URL given.
+ // The request names the skill; no user content is sent.
+ privacy: Some(CapabilityPrivacy {
+ leaves_device: true,
+ data_kind: PrivacyDataKind::Metadata,
+ destinations: &[
+ "ClawHub (clawhub.ai)",
+ "GitHub (raw.githubusercontent.com, api.github.com)",
+ "Hermes skill catalog (hermes-agent.nousresearch.com)",
+ "The host of a SKILL.md URL you install from",
+ ],
+ }),
},
Capability {
id: "workflows.configure",
diff --git a/crates/openhuman-core/src/skills/catalog/download.rs b/crates/openhuman-core/src/skills/catalog/download.rs
index 3ebca0e5b7..7b3d6ac2cc 100644
--- a/crates/openhuman-core/src/skills/catalog/download.rs
+++ b/crates/openhuman-core/src/skills/catalog/download.rs
@@ -77,8 +77,13 @@ impl<'a> SkillsShRef<'a> {
.build()
.map_err(|e| format!("failed to build http client: {e}"))?;
- for url in self.candidate_urls() {
- match client.head(&url).send().await {
+ // Probe every conventional location at once: probed one after another,
+ // each slow miss could spend the whole timeout before the next starts.
+ let candidates = self.candidate_urls();
+ let responses =
+ futures::future::join_all(candidates.iter().map(|url| client.head(url).send())).await;
+ for (url, response) in candidates.into_iter().zip(responses) {
+ match response {
Ok(resp) if resp.status().is_success() => {
tracing::info!(url = %url, "[skill_registry] skills.sh SKILL.md found");
return Ok(url);
@@ -119,27 +124,55 @@ impl<'a> SkillsShRef<'a> {
.json()
.await
.map_err(|e| format!("could not read the {repo} file listing: {e}"))?;
- find_skill_md_in_tree(&tree, self.skill)
- .map(|path| self.raw_url(&path))
- .ok_or_else(|| {
- format!(
- "'{}' is listed on skills.sh, but {repo} has no {}/SKILL.md",
- self.skill, self.skill
- )
- })
+ let skill = self.skill;
+ match find_skill_md_in_tree(&tree, skill) {
+ Ok(path) => Ok(self.raw_url(&path)),
+ Err(TreeMiss::Absent) => Err(format!(
+ "'{skill}' is listed on skills.sh, but {repo} has no {skill}/SKILL.md"
+ )),
+ Err(TreeMiss::Truncated) => Err(format!(
+ "{repo} is too large for GitHub to list in one response, so '{skill}' could not be located"
+ )),
+ Err(TreeMiss::Ambiguous(paths)) => Err(format!(
+ "{repo} has more than one {skill}/SKILL.md ({}), and skills.sh does not say which one it lists",
+ paths.join(", ")
+ )),
+ }
}
}
-/// Path of `<skill>/SKILL.md` at any depth in a GitHub recursive tree listing.
-pub(super) fn find_skill_md_in_tree(tree: &Value, skill: &str) -> Option<String> {
+/// Why a repo tree listing did not yield exactly one skill location.
+#[derive(Debug, PartialEq)]
+pub(super) enum TreeMiss {
+ /// The listing is complete and has no `<skill>/SKILL.md`.
+ Absent,
+ /// GitHub truncated the listing and it has no match, so absence is unproven.
+ Truncated,
+ /// Several directories are named for the skill; picking one would be a guess.
+ Ambiguous(Vec<String>),
+}
+
+/// The single path of `<skill>/SKILL.md` at any depth in a GitHub recursive
+/// tree listing.
+pub(super) fn find_skill_md_in_tree(tree: &Value, skill: &str) -> Result<String, TreeMiss> {
let suffix = format!("/{skill}/SKILL.md");
- tree.get("tree")?
- .as_array()?
- .iter()
+ let mut matches: Vec<String> = tree
+ .get("tree")
+ .and_then(Value::as_array)
+ .into_iter()
+ .flatten()
.filter(|item| item.get("type").and_then(Value::as_str) == Some("blob"))
.filter_map(|item| item.get("path").and_then(Value::as_str))
- .find(|path| path.ends_with(&suffix) || *path == &suffix[1..])
+ .filter(|path| path.ends_with(&suffix) || *path == &suffix[1..])
.map(str::to_string)
+ .collect();
+ let truncated = tree.get("truncated").and_then(Value::as_bool) == Some(true);
+ match matches.len() {
+ 1 => Ok(matches.remove(0)),
+ 0 if truncated => Err(TreeMiss::Truncated),
+ 0 => Err(TreeMiss::Absent),
+ _ => Err(TreeMiss::Ambiguous(matches)),
+ }
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/skills/catalog/download_tests.rs b/crates/openhuman-core/src/skills/catalog/download_tests.rs
index c8a0323aa0..0b445f4a24 100644
--- a/crates/openhuman-core/src/skills/catalog/download_tests.rs
+++ b/crates/openhuman-core/src/skills/catalog/download_tests.rs
@@ -53,13 +53,52 @@ fn find_skill_md_in_tree_matches_the_skill_directory_at_any_depth() {
{ "path": "plugins/x/skills/my-skill/SKILL.md", "type": "blob" },
]});
assert_eq!(
- find_skill_md_in_tree(&tree, "my-skill").as_deref(),
- Some("plugins/x/skills/my-skill/SKILL.md")
+ find_skill_md_in_tree(&tree, "my-skill"),
+ Ok("plugins/x/skills/my-skill/SKILL.md".to_string())
);
let root = json!({ "tree": [{ "path": "my-skill/SKILL.md", "type": "blob" }] });
assert_eq!(
- find_skill_md_in_tree(&root, "my-skill").as_deref(),
- Some("my-skill/SKILL.md")
+ find_skill_md_in_tree(&root, "my-skill"),
+ Ok("my-skill/SKILL.md".to_string())
+ );
+ assert_eq!(
+ find_skill_md_in_tree(&tree, "other-skill"),
+ Err(TreeMiss::Absent)
+ );
+}
+
+#[test]
+fn find_skill_md_in_tree_refuses_to_guess_between_same_named_directories() {
+ let tree = json!({ "tree": [
+ { "path": "plugins/a/my-skill/SKILL.md", "type": "blob" },
+ { "path": "plugins/b/my-skill/SKILL.md", "type": "blob" },
+ ]});
+ assert_eq!(
+ find_skill_md_in_tree(&tree, "my-skill"),
+ Err(TreeMiss::Ambiguous(vec![
+ "plugins/a/my-skill/SKILL.md".to_string(),
+ "plugins/b/my-skill/SKILL.md".to_string(),
+ ]))
+ );
+}
+
+#[test]
+fn find_skill_md_in_tree_does_not_call_a_truncated_listing_proof_of_absence() {
+ let truncated = json!({
+ "truncated": true,
+ "tree": [{ "path": "other/SKILL.md", "type": "blob" }]
+ });
+ assert_eq!(
+ find_skill_md_in_tree(&truncated, "my-skill"),
+ Err(TreeMiss::Truncated)
+ );
+ // A match that did make it into a truncated listing is still usable.
+ let found = json!({
+ "truncated": true,
+ "tree": [{ "path": "deep/my-skill/SKILL.md", "type": "blob" }]
+ });
+ assert_eq!(
+ find_skill_md_in_tree(&found, "my-skill"),
+ Ok("deep/my-skill/SKILL.md".to_string())
);
- assert_eq!(find_skill_md_in_tree(&tree, "other-skill"), None);
}
diff --git a/crates/openhuman-core/src/skills/ops_create_and_url_tests.rs b/crates/openhuman-core/src/skills/ops_create_and_url_tests.rs
index 2d7ef8f036..a496fd74ac 100644
--- a/crates/openhuman-core/src/skills/ops_create_and_url_tests.rs
+++ b/crates/openhuman-core/src/skills/ops_create_and_url_tests.rs
@@ -437,6 +437,14 @@ fn normalize_install_url_accepts_a_file_api_that_names_the_md_in_its_query() {
let err =
normalize_install_url("https://clawhub.ai/api/v1/skills/x/file?path=run.sh").unwrap_err();
assert!(err.contains(".md"), "{err}");
+ // Only ClawHub's file endpoint may name the file in its query.
+ for other in [
+ "https://example.com/api/v1/skills/x/file?path=SKILL.md",
+ "https://clawhub.ai/download?path=SKILL.md",
+ ] {
+ let err = normalize_install_url(other).unwrap_err();
+ assert!(err.contains(".md"), "{other}: {err}");
+ }
}
#[test]
diff --git a/crates/openhuman-core/src/skills/ops_install/url_validation.rs b/crates/openhuman-core/src/skills/ops_install/url_validation.rs
index 19d2cd616c..1816183346 100644
--- a/crates/openhuman-core/src/skills/ops_install/url_validation.rs
+++ b/crates/openhuman-core/src/skills/ops_install/url_validation.rs
@@ -47,12 +47,8 @@ pub(crate) fn normalize_install_url(raw: &str) -> Result<String, String> {
let check = url::Url::parse(&normalized)
.map_err(|e| format!("unsupported url form: parse normalized {normalized:?}: {e}"))?;
- let names_md_file = check.path().to_ascii_lowercase().ends_with(".md")
- // A file API names the file in its query instead (ClawHub's
- // `/skills/<slug>/file?path=SKILL.md`).
- || check
- .query_pairs()
- .any(|(key, value)| key == "path" && value.to_ascii_lowercase().ends_with(".md"));
+ let names_md_file =
+ check.path().to_ascii_lowercase().ends_with(".md") || is_clawhub_file_api(&check);
if !names_md_file {
return Err(format!(
"unsupported url form: path must end in .md, got {normalized:?}"
@@ -62,6 +58,22 @@ pub(crate) fn normalize_install_url(raw: &str) -> Result<String, String> {
Ok(normalized)
}
+/// ClawHub's file API names the file in its query instead of its path:
+/// `https://clawhub.ai/api/v1/skills/<slug>/file?path=SKILL.md`.
+fn is_clawhub_file_api(url: &url::Url) -> bool {
+ let is_file_endpoint = url.path_segments().is_some_and(|segments| {
+ matches!(
+ segments.collect::<Vec<_>>().as_slice(),
+ ["api", "v1", "skills", slug, "file"] if !slug.is_empty()
+ )
+ });
+ url.host_str() == Some("clawhub.ai")
+ && is_file_endpoint
+ && url
+ .query_pairs()
+ .any(|(key, value)| key == "path" && value.to_ascii_lowercase().ends_with(".md"))
+}
+
/// Derive the install directory slug from the SKILL.md frontmatter.
///
/// Prefers `metadata.id` (the spec-aligned identifier) when present. Falls