Skip to content

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

4.5 KB
Raw Blame
//! RPC-facing operations for the Composio domain.
//!
//! Each `composio_*` function wraps a [`ComposioClient`] call, translates
//! errors to strings, and returns an [`Outcome`] so the controller
//! schemas can log a user-visible line. The handlers in [`super::schemas`]
//! call into these.
//!
//! These ops are also callable directly from other domains (e.g. the
//! agent harness) when they need composio data at runtime.
//!
//! ## Module layout
//!
//! | Sub-module        | Contents                                                           |
//! |-------------------|--------------------------------------------------------------------|
//! | `error_utils`     | `OpResult`, `report_composio_op_error`, helpers |
//! | `toolkits`        | `composio_list_toolkits`, `composio_list_capabilities`, ...        |
//! | `connections`     | `composio_list_connections`, `composio_authorize`, `_delete_...`, `active_connection_ids` |
//! | `tools_ops`       | `composio_list_tools`                                              |
//! | `execute`         | `composio_execute`                                                 |
//! | `triggers`        | GitHub repos + trigger CRUD + trigger history                      |
//! | `providers_ops`   | `composio_get_user_profile`, `composio_refresh_all_identities`     |
//! | `direct_mode`     | `composio_get_mode`, `composio_set_api_key`, `_clear_...`          |
//! | `scope_prefs`     | per-toolkit agent scope prefs, forwarded to the connector module   |

mod connections;
mod direct_mode;
mod error_utils;
mod execute;
mod providers_ops;
mod scope_prefs;
mod toolkits;
mod tools_ops;
mod triggers;

// ── Public re-exports (match original ops.rs public surface) ───────────────

#[cfg(feature = "flows")]
pub(crate) use connections::flow_connection_entries;
#[cfg(all(test, feature = "flows"))]
pub(crate) use connections::title_case_toolkit;
pub use connections::{
    active_connection_ids, composio_authorize, composio_delete_connection,
    composio_list_connections, ComposioDeleteResult,
};
pub use direct_mode::{composio_clear_api_key, composio_get_mode, composio_set_api_key};
pub(crate) use error_utils::{report_composio_op_error, should_forward_tags};
pub use execute::composio_execute;
pub use providers_ops::{
    composio_get_user_profile, composio_refresh_all_identities, RefreshIdentitiesReport,
};
pub use toolkits::{
    composio_list_agent_ready_toolkits, composio_list_capabilities, composio_list_toolkits,
};
pub use tools_ops::composio_list_tools;
pub use triggers::{
    composio_create_trigger, composio_disable_trigger, composio_enable_trigger,
    composio_list_available_triggers, composio_list_github_repos, composio_list_trigger_history,
    composio_list_triggers,
};
// The `composio.{get,set}_user_scopes` handlers' storage half.
pub(crate) use scope_prefs::{
    ensure_migrated as ensure_user_scopes_migrated, load as load_user_scope_pref,
    save as save_user_scope_pref,
};

// ── Re-export connected_integrations public items ──────────────────────────
// (originally at the bottom of ops.rs)

pub use super::connected_integrations::{
    cached_active_integrations, connected_set_hash, fetch_connected_integrations,
    fetch_connected_integrations_status, invalidate_connected_integrations_cache,
    FetchConnectedIntegrationsStatus,
};

// ── Type aliases re-exported for callers ──────────────────────────────────

pub use super::types::{ComposioConnection as Connection, ComposioToolSchema as ToolSchemaType};

// ── Test-only re-exports (pub(crate) to match original visibility) ─────────

#[cfg(test)]
pub(crate) use super::connected_integrations::cache_key;
#[cfg(test)]
pub(crate) use super::connected_integrations::{CachedIntegrations, INTEGRATIONS_CACHE};
#[cfg(test)]
pub(crate) use crate::integrations::ConnectedIntegration;
#[cfg(test)]
pub(crate) use std::time::{Duration, Instant};

// Private items needed by the test module via `use super::*`
#[cfg(test)]
pub(crate) use super::connected_integrations::sync_cache_with_connections;
#[cfg(test)]
pub(crate) use crate::config::Config;
#[cfg(test)]
pub(crate) use connections::enrich_connections_with_identity;
#[cfg(test)]
pub(crate) use error_utils::{
    backend_mode_without_session, classify_composio_failure_tag, direct_mode_without_key,
    extract_backend_returned_status,
};
#[cfg(test)]
#[path = "../ops_tests.rs"]
mod tests;