runtara_agents/registry.rs
1// Copyright (C) 2025 SyncMyOrders Sp. z o.o.
2// SPDX-License-Identifier: AGPL-3.0-or-later
3//! Agent registry using inventory-based dynamic dispatch
4//!
5//! This module provides capability execution by looking up executors
6//! registered via the `#[capability]` macro at compile time.
7
8use serde_json::Value;
9
10/// Execute an agent capability asynchronously
11///
12/// # Arguments
13/// * `agent_id` - The agent name (e.g., "utils", "transform", "csv")
14/// * `capability_id` - The capability name (e.g., "random-double", "extract")
15/// * `step_inputs` - The input data as JSON Value
16///
17/// # Returns
18/// Result containing the capability result as JSON Value or an error
19///
20/// # Note
21/// This is an async function. Sync capabilities are automatically wrapped
22/// with `tokio::task::spawn_blocking` by the `#[capability]` macro.
23pub async fn execute_capability(
24 agent_id: &str,
25 capability_id: &str,
26 step_inputs: Value,
27) -> Result<Value, String> {
28 runtara_dsl::agent_meta::execute_capability(agent_id, capability_id, step_inputs).await
29}