Skip to content

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

feat(tools): add apify and linkedin tool schemas

Steven Enamakel81870bdb2548
diff --git a/crates/openhuman-core/src/tools/schemas.rs b/crates/openhuman-core/src/tools/schemas.rs
index 15ae5c9c9e..7679a3d890 100644
--- a/crates/openhuman-core/src/tools/schemas.rs
+++ b/crates/openhuman-core/src/tools/schemas.rs
@@ -10,9 +10,7 @@
#[path = "schemas_tests.rs"]
mod tests;
-mod apify;
mod composio;
-mod linkedin;
mod registry;
mod web_search;
diff --git a/crates/openhuman-core/src/tools/schemas/apify.rs b/crates/openhuman-core/src/tools/schemas/apify.rs
deleted file mode 100644
index a8d487517a..0000000000
--- a/crates/openhuman-core/src/tools/schemas/apify.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-//! Handler for the `tools_apify_linkedin_scrape` controller schema.
-
-use serde_json::{json, Map, Value};
-
-use crate::config::rpc as config_rpc;
-use crate::core::all::ControllerFuture;
-use crate::core::Outcome;
-
-pub(super) fn handle_apify_linkedin_scrape(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let profile_url = params
- .get("profile_url")
- .and_then(Value::as_str)
- .map(str::trim)
- .filter(|s| !s.is_empty())
- .map(str::to_string)
- .ok_or_else(|| "missing or empty `profile_url`".to_string())?;
-
- let config = config_rpc::load_config_with_timeout().await?;
- let client = crate::integrations::build_client(&config).ok_or_else(|| {
- "Apify scrape unavailable — no backend session token. Sign in first.".to_string()
- })?;
-
- let data = super::linkedin::scrape_linkedin_profile(&client, &profile_url)
- .await
- .map_err(|e| format!("Apify LinkedIn scrape failed: {e:#}"))?;
-
- let markdown = super::linkedin::render_profile_markdown(&profile_url, &data);
-
- let payload = json!({ "data": data, "markdown": markdown });
- let log = vec![format!(
- "tools.apify_linkedin_scrape: url={profile_url} markdown_chars={}",
- markdown.chars().count()
- )];
- Outcome::new(payload, log).into_cli_compatible_json()
- })
-}
diff --git a/crates/openhuman-core/src/tools/schemas/linkedin.rs b/crates/openhuman-core/src/tools/schemas/linkedin.rs
deleted file mode 100644
index 0d9c2b5d03..0000000000
--- a/crates/openhuman-core/src/tools/schemas/linkedin.rs
+++ /dev/null
@@ -1,182 +0,0 @@
-//! The Apify LinkedIn profile scrape behind `tools_apify_linkedin_scrape`:
-//! run the `dev_fusion/linkedin-profile-scraper` actor through the backend's
-//! Apify proxy and render the first profile item as Markdown.
-
-use std::sync::Arc;
-
-use serde_json::json;
-
-use crate::integrations::IntegrationClient;
-
-/// Apify actor slug for the LinkedIn profile scraper.
-const LINKEDIN_SCRAPER_ACTOR: &str = "dev_fusion/linkedin-profile-scraper";
-
-/// Call the Apify LinkedIn profile scraper synchronously and return the
-/// first profile item from the dataset.
-pub async fn scrape_linkedin_profile(
- client: &Arc<IntegrationClient>,
- profile_url: &str,
-) -> anyhow::Result<serde_json::Value> {
- let body = json!({
- "actorId": LINKEDIN_SCRAPER_ACTOR,
- "input": {
- "profileUrls": [profile_url],
- },
- "sync": true,
- "timeoutSecs": 120,
- });
-
- tracing::debug!(
- actor = LINKEDIN_SCRAPER_ACTOR,
- url_len = profile_url.len(),
- "[apify:linkedin] invoking Apify actor"
- );
-
- // The backend wraps the Apify response in its standard envelope.
- // `IntegrationClient::post` already unwraps `{ success, data }`.
- let resp: serde_json::Value = client
- .post("/agent-integrations/apify/run", &body)
- .await
- .map_err(|e| anyhow::anyhow!("Apify run failed: {e:#}"))?;
-
- let status = resp
- .get("status")
- .and_then(|v| v.as_str())
- .unwrap_or("UNKNOWN");
-
- if status != "SUCCEEDED" {
- anyhow::bail!("Apify run finished with status: {status}");
- }
-
- // Extract the first item from the inline results array.
- let items = resp
- .get("items")
- .and_then(|v| v.as_array())
- .ok_or_else(|| anyhow::anyhow!("Apify run returned no items array"))?;
-
- items
- .first()
- .cloned()
- .ok_or_else(|| anyhow::anyhow!("Apify run returned an empty items array"))
-}
-
-/// Turn the Apify scrape JSON into clean Markdown.
-pub fn render_profile_markdown(url: &str, data: &serde_json::Value) -> String {
- let s = |key: &str| {
- data.get(key)
- .and_then(|v| v.as_str())
- .unwrap_or("")
- .to_string()
- };
-
- let full_name = s("fullName");
- let headline = s("headline");
- let location = s("addressWithCountry");
- let about = s("about");
- let connections = data.get("connections").and_then(|v| v.as_u64());
- let followers = data.get("followers").and_then(|v| v.as_u64());
-
- let mut md = format!("# User Profile — {full_name}\n\n");
-
- if !headline.is_empty() {
- md.push_str(&format!("**{headline}**\n\n"));
- }
- if !location.is_empty() {
- md.push_str(&format!("Location: {location}\n\n"));
- }
- md.push_str(&format!("LinkedIn: {url}\n\n"));
- if let (Some(c), Some(f)) = (connections, followers) {
- md.push_str(&format!("Connections: {c} | Followers: {f}\n\n"));
- }
-
- if !about.is_empty() {
- md.push_str("## About\n\n");
- md.push_str(&about);
- md.push_str("\n\n");
- }
-
- // Experience
- if let Some(exps) = data.get("experiences").and_then(|v| v.as_array()) {
- if !exps.is_empty() {
- md.push_str("## Experience\n\n");
- for exp in exps {
- let title = exp.get("title").and_then(|v| v.as_str()).unwrap_or("");
- let company = exp.get("subtitle").and_then(|v| v.as_str()).unwrap_or("");
- let duration = exp.get("duration").and_then(|v| v.as_str()).unwrap_or("");
- let caption = exp.get("caption").and_then(|v| v.as_str()).unwrap_or("");
- let desc = exp
- .get("description")
- .and_then(|v| v.as_str())
- .unwrap_or("");
- md.push_str(&format!("- **{title}**"));
- if !company.is_empty() {
- md.push_str(&format!(" at {company}"));
- }
- if !duration.is_empty() {
- md.push_str(&format!(" ({duration})"));
- }
- if !caption.is_empty() {
- md.push_str(&format!(" — {caption}"));
- }
- md.push('\n');
- if !desc.is_empty() {
- md.push_str(&format!(" {desc}\n"));
- }
- }
- md.push('\n');
- }
- }
-
- // Education
- if let Some(edus) = data.get("educations").and_then(|v| v.as_array()) {
- if !edus.is_empty() {
- md.push_str("## Education\n\n");
- for edu in edus {
- let school = edu.get("title").and_then(|v| v.as_str()).unwrap_or("");
- let degree = edu.get("subtitle").and_then(|v| v.as_str()).unwrap_or("");
- md.push_str(&format!("- **{school}**"));
- if !degree.is_empty() {
- md.push_str(&format!(" — {degree}"));
- }
- md.push('\n');
- }
- md.push('\n');
- }
- }
-
- // Languages
- if let Some(langs) = data.get("languages").and_then(|v| v.as_array()) {
- if !langs.is_empty() {
- let names: Vec<&str> = langs
- .iter()
- .filter_map(|l| l.get("name").and_then(|v| v.as_str()))
- .collect();
- if !names.is_empty() {
- md.push_str(&format!("Languages: {}\n\n", names.join(", ")));
- }
- }
- }
-
- // Volunteering
- if let Some(vols) = data.get("volunteering").and_then(|v| v.as_array()) {
- if !vols.is_empty() {
- md.push_str("## Volunteering\n\n");
- for vol in vols {
- let title = vol.get("title").and_then(|v| v.as_str()).unwrap_or("");
- let org = vol.get("subtitle").and_then(|v| v.as_str()).unwrap_or("");
- md.push_str(&format!("- {title}"));
- if !org.is_empty() {
- md.push_str(&format!(" at {org}"));
- }
- md.push('\n');
- }
- md.push('\n');
- }
- }
-
- md
-}
-
-#[cfg(test)]
-#[path = "linkedin_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/tools/schemas/linkedin_tests.rs b/crates/openhuman-core/src/tools/schemas/linkedin_tests.rs
deleted file mode 100644
index 37bcd1caf5..0000000000
--- a/crates/openhuman-core/src/tools/schemas/linkedin_tests.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-use super::*;
-
-#[test]
-fn renders_headline_location_experience_and_education() {
- let data = json!({
- "fullName": "Ada Lovelace",
- "headline": "Analyst",
- "addressWithCountry": "London, UK",
- "about": "First programmer.",
- "connections": 10,
- "followers": 20,
- "experiences": [{"title": "Engineer", "subtitle": "Analytical Engine Co", "duration": "2y", "caption": "remote", "description": "Wrote notes"}],
- "educations": [{"title": "Home", "subtitle": "Mathematics"}],
- "languages": [{"name": "English"}, {"name": "French"}],
- "volunteering": [{"title": "Tutor", "subtitle": "Society"}]
- });
- let md = render_profile_markdown("https://www.linkedin.com/in/ada", &data);
- assert!(md.starts_with("# User Profile — Ada Lovelace"));
- assert!(md.contains("**Analyst**"));
- assert!(md.contains("Location: London, UK"));
- assert!(md.contains("Connections: 10 | Followers: 20"));
- assert!(md.contains("## About\n\nFirst programmer."));
- assert!(md.contains("- **Engineer** at Analytical Engine Co (2y) — remote"));
- assert!(md.contains(" Wrote notes"));
- assert!(md.contains("- **Home** — Mathematics"));
- assert!(md.contains("Languages: English, French"));
- assert!(md.contains("- Tutor at Society"));
-}
-
-#[test]
-fn renders_only_the_url_for_an_empty_profile() {
- let md = render_profile_markdown("https://www.linkedin.com/in/x", &json!({}));
- assert!(md.contains("LinkedIn: https://www.linkedin.com/in/x"));
- assert!(!md.contains("## Experience"));
- assert!(!md.contains("## About"));
-}
diff --git a/crates/openhuman-core/src/tools/schemas/registry.rs b/crates/openhuman-core/src/tools/schemas/registry.rs
index 467b34c53b..15a06e0de1 100644
--- a/crates/openhuman-core/src/tools/schemas/registry.rs
+++ b/crates/openhuman-core/src/tools/schemas/registry.rs
@@ -7,7 +7,6 @@
use crate::core::all::RegisteredController;
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
-use super::apify::handle_apify_linkedin_scrape;
use super::composio::handle_composio_execute;
use super::web_search::{
handle_searxng_search, handle_web_answer, handle_web_contents, handle_web_search,
@@ -20,7 +19,6 @@ pub fn all_controller_schemas() -> Vec<ControllerSchema> {
tools_schemas("tools_web_answer"),
tools_schemas("tools_web_contents"),
tools_schemas("tools_searxng_search"),
- tools_schemas("tools_apify_linkedin_scrape"),
]
}
@@ -46,10 +44,6 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
schema: tools_schemas("tools_searxng_search"),
handler: handle_searxng_search,
},
- RegisteredController {
- schema: tools_schemas("tools_apify_linkedin_scrape"),
- handler: handle_apify_linkedin_scrape,
- },
]
}
@@ -203,33 +197,6 @@ pub fn tools_schemas(function: &str) -> ControllerSchema {
],
outputs: search_outputs("Each item: {title, url, snippet?, published?}."),
},
- "tools_apify_linkedin_scrape" => ControllerSchema {
- namespace: "tools",
- function: "apify_linkedin_scrape",
- description: "Run the Apify LinkedIn profile scraper actor on a single profile \
- URL and return both the raw scraped item and a pre-rendered \
- markdown view of it (same layout as the legacy enrichment pipeline).",
- inputs: vec![FieldSchema {
- name: "profile_url",
- ty: TypeSchema::String,
- comment: "Canonical LinkedIn profile URL (`https://www.linkedin.com/in/<slug>`).",
- required: true,
- }],
- outputs: vec![
- FieldSchema {
- name: "data",
- ty: TypeSchema::Json,
- comment: "Raw scraped profile JSON from Apify.",
- required: true,
- },
- FieldSchema {
- name: "markdown",
- ty: TypeSchema::String,
- comment: "Markdown rendering of the scraped profile (full, pre-summary).",
- required: true,
- },
- ],
- },
_ => ControllerSchema {
namespace: "tools",
function: "unknown",