Skip to content

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

fix(search): handle stale state in tavily extract tool

Steven Enamakela69591ae3c6d
diff --git a/crates/openhuman-core/src/desktop/app_state/ops/staleness.rs b/crates/openhuman-core/src/desktop/app_state/ops/staleness.rs
index 75e47a9e3e..cdee025de4 100644
--- a/crates/openhuman-core/src/desktop/app_state/ops/staleness.rs
+++ b/crates/openhuman-core/src/desktop/app_state/ops/staleness.rs
@@ -50,7 +50,7 @@ fn note_current_user_success(api_base: &str, token: &str) {
/// The stamp itself, taking the guard rather than the lock, so a caller that
/// must decide *under* the lock can do so without re-entering it.
-fn note_current_user_success_locked(
+pub(super) fn note_current_user_success_locked(
success: &mut Option<CurrentUserSuccess>,
api_base: &str,
token: &str,
@@ -64,7 +64,7 @@ fn note_current_user_success_locked(
/// Forget the success stamp on sign-out, so the next account does not inherit
/// this one's freshness.
-fn clear_current_user_success() {
+pub(super) fn clear_current_user_success() {
*LAST_CURRENT_USER_SUCCESS.lock() = None;
}
@@ -80,7 +80,7 @@ fn clear_current_user_success() {
/// this process — the stored snapshot then came off disk, and its true age is
/// not knowable from here. A success recorded against a different `(api_base,
/// token)` is somebody else's freshness and is not reported as this one's.
-fn current_user_staleness(api_base: &str, token: &str) -> (bool, Option<u64>) {
+pub(super) fn current_user_staleness(api_base: &str, token: &str) -> (bool, Option<u64>) {
let stale = CURRENT_USER_FAILURE
.lock()
.as_ref()
diff --git a/crates/openhuman-core/src/integrations/composio/client/triggers.rs b/crates/openhuman-core/src/integrations/composio/client/triggers.rs
new file mode 100644
index 0000000000..006191774b
--- /dev/null
+++ b/crates/openhuman-core/src/integrations/composio/client/triggers.rs
@@ -0,0 +1,144 @@
+//! [`ComposioClient`]'s GitHub-repo listing and trigger-management surface:
+//! `list_github_repos`, `create_trigger`, `list_available_triggers`,
+//! `list_active_triggers`, `enable_trigger`, and `disable_trigger` (the
+//! latter via the shared `raw_delete` helper in [`super::connections`]).
+
+use anyhow::Result;
+
+use super::connections::ComposioClient;
+use super::super::types::{
+ ComposioActiveTriggersResponse, ComposioAvailableTriggersResponse,
+ ComposioCreateTriggerResponse, ComposioDisableTriggerResponse, ComposioEnableTriggerResponse,
+ ComposioGithubReposResponse,
+};
+
+impl ComposioClient {
+ pub async fn list_github_repos(
+ &self,
+ connection_id: Option<&str>,
+ ) -> Result<ComposioGithubReposResponse> {
+ let path = match connection_id.map(str::trim).filter(|id| !id.is_empty()) {
+ Some(id) => format!("/agent-integrations/composio/github/repos?connectionId={id}"),
+ None => "/agent-integrations/composio/github/repos".to_string(),
+ };
+ tracing::debug!(path = %path, "[composio] list_github_repos");
+ self.inner.get::<ComposioGithubReposResponse>(&path).await
+ }
+
+ /// `POST /agent-integrations/composio/triggers` — create a trigger
+ /// instance for the authenticated user.
+ pub async fn create_trigger(
+ &self,
+ slug: &str,
+ connection_id: Option<&str>,
+ trigger_config: Option<serde_json::Value>,
+ ) -> Result<ComposioCreateTriggerResponse> {
+ let slug = slug.trim();
+ if slug.is_empty() {
+ anyhow::bail!("composio.create_trigger: slug must not be empty");
+ }
+ let mut body = json!({ "slug": slug });
+ if let Some(connection_id) = connection_id.map(str::trim).filter(|id| !id.is_empty()) {
+ body["connectionId"] = json!(connection_id);
+ }
+ if let Some(config) = trigger_config {
+ body["triggerConfig"] = config;
+ }
+ tracing::debug!(slug = %slug, "[composio] create_trigger");
+ self.inner
+ .post::<ComposioCreateTriggerResponse>("/agent-integrations/composio/triggers", &body)
+ .await
+ }
+
+ // ── Trigger management (PR #671) ────────────────────────────────
+
+ /// `GET /agent-integrations/composio/triggers/available` — catalog of
+ /// triggers the user could enable for a toolkit. For GitHub the
+ /// backend fans out into per-repo entries scoped by `connection_id`.
+ pub async fn list_available_triggers(
+ &self,
+ toolkit: &str,
+ connection_id: Option<&str>,
+ ) -> Result<ComposioAvailableTriggersResponse> {
+ let toolkit = toolkit.trim();
+ if toolkit.is_empty() {
+ anyhow::bail!("composio.list_available_triggers: toolkit must not be empty");
+ }
+ let toolkit_q = urlencoding::encode(toolkit);
+ let path = match connection_id.map(str::trim).filter(|id| !id.is_empty()) {
+ Some(id) => format!(
+ "/agent-integrations/composio/triggers/available?toolkit={toolkit_q}&connectionId={}",
+ urlencoding::encode(id)
+ ),
+ None => format!(
+ "/agent-integrations/composio/triggers/available?toolkit={toolkit_q}"
+ ),
+ };
+ tracing::debug!(path = %path, "[composio] list_available_triggers");
+ self.inner
+ .get::<ComposioAvailableTriggersResponse>(&path)
+ .await
+ }
+
+ /// `GET /agent-integrations/composio/triggers` — currently enabled
+ /// triggers for the user, optionally filtered to a toolkit.
+ pub async fn list_active_triggers(
+ &self,
+ toolkit: Option<&str>,
+ ) -> Result<ComposioActiveTriggersResponse> {
+ let path = match toolkit.map(str::trim).filter(|t| !t.is_empty()) {
+ Some(t) => format!(
+ "/agent-integrations/composio/triggers?toolkit={}",
+ urlencoding::encode(t)
+ ),
+ None => "/agent-integrations/composio/triggers".to_string(),
+ };
+ tracing::debug!(path = %path, "[composio] list_active_triggers");
+ self.inner
+ .get::<ComposioActiveTriggersResponse>(&path)
+ .await
+ }
+
+ /// `POST /agent-integrations/composio/triggers` — enable a single
+ /// trigger on a connection the caller owns.
+ pub async fn enable_trigger(
+ &self,
+ connection_id: &str,
+ slug: &str,
+ trigger_config: Option<serde_json::Value>,
+ ) -> Result<ComposioEnableTriggerResponse> {
+ let connection_id = connection_id.trim();
+ let slug = slug.trim();
+ if connection_id.is_empty() {
+ anyhow::bail!("composio.enable_trigger: connectionId must not be empty");
+ }
+ if slug.is_empty() {
+ anyhow::bail!("composio.enable_trigger: slug must not be empty");
+ }
+ let mut body = json!({ "connectionId": connection_id, "slug": slug });
+ if let Some(config) = trigger_config {
+ body["triggerConfig"] = config;
+ }
+ tracing::debug!(slug = %slug, connection_id = %connection_id, "[composio] enable_trigger");
+ self.inner
+ .post::<ComposioEnableTriggerResponse>("/agent-integrations/composio/triggers", &body)
+ .await
+ }
+
+ /// `DELETE /agent-integrations/composio/triggers/:triggerId`.
+ pub async fn disable_trigger(
+ &self,
+ trigger_id: &str,
+ ) -> Result<ComposioDisableTriggerResponse> {
+ let trigger_id = trigger_id.trim();
+ if trigger_id.is_empty() {
+ anyhow::bail!("composio.disable_trigger: triggerId must not be empty");
+ }
+ tracing::debug!(trigger_id = %trigger_id, "[composio] disable_trigger");
+ self.raw_delete::<ComposioDisableTriggerResponse>(&format!(
+ "/agent-integrations/composio/triggers/{}",
+ urlencoding::encode(trigger_id)
+ ))
+ .await
+ }
+}
diff --git a/crates/openhuman-core/src/search/tools/tavily/extract_tool.rs b/crates/openhuman-core/src/search/tools/tavily/extract_tool.rs
index 8f4488659f..90d648a878 100644
--- a/crates/openhuman-core/src/search/tools/tavily/extract_tool.rs
+++ b/crates/openhuman-core/src/search/tools/tavily/extract_tool.rs
@@ -1,7 +1,7 @@
//! `TavilyExtractTool`: full page content retrieval via `POST /extract`.
use super::client::TavilyClient;
-use super::types::{copy_string, non_empty};
+use super::types::{copy_string, non_empty, TavilyExtractResponse, TavilyExtractResult};
use crate::tools::traits::{Tool, ToolCallOptions, ToolResult};
use async_trait::async_trait;
use serde_json::{json, Value};