Skip to content

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

chore: files changed crates/openhuman-core/src/inference/provider/ops/models/local_runtime.rs,crates

Steven Enamakel8850515f8a78
diff --git a/crates/openhuman-core/src/inference/provider/ops/models/local_runtime.rs b/crates/openhuman-core/src/inference/provider/ops/models/local_runtime.rs
new file mode 100644
index 0000000000..5bc1c97117
--- /dev/null
+++ b/crates/openhuman-core/src/inference/provider/ops/models/local_runtime.rs
@@ -0,0 +1,57 @@
+//! Synthesized `cloud_providers` entries for well-known local-runtime slugs.
+
+use super::*;
+
+/// Synthesize a transient [`CloudProviderCreds`] entry for the well-known
+/// local-runtime slugs (`ollama`, `lmstudio`) so [`super::list_configured_models`]
+/// can probe their OpenAI-compatible `/v1/models` endpoint even when the
+/// user has not registered a matching `cloud_providers` row.
+///
+/// Background: the AI settings panel registers an `ollama` `cloud_providers`
+/// entry when the user configures Ollama (see comment on
+/// [`crate::config::schema::cloud_providers::is_slug_reserved`]),
+/// but in practice some users hit
+/// `inference_list_models("ollama")` without that entry — config drift,
+/// flush-vs-probe race, or upgrade from a build that only persisted
+/// `config.local_ai.base_url`. Sentry TAURI-RUST-28Z captures this:
+/// 24 events / 7d, all `domain=rpc, method=openhuman.inference_list_models,
+/// operation=invoke_method`. Without this fallback, the dropdown surfaces
+/// the bare `"no cloud provider with id or slug 'ollama' found"` error
+/// (also visible in the Sentry breadcrumb) instead of returning models.
+///
+/// Returns `None` for any slug that is not a recognized local-runtime
+/// alias — callers continue down the normal "no cloud provider" error
+/// path for `openai` / `anthropic` / opaque ids / typos.
+pub fn synthesize_local_runtime_entry(
+ slug: &str,
+ config: &crate::config::Config,
+) -> Option<crate::config::schema::cloud_providers::CloudProviderCreds> {
+ use crate::config::schema::cloud_providers::{AuthStyle, CloudProviderCreds};
+
+ let endpoint = match slug {
+ // Ollama's OpenAI-compatible surface at `<base>/v1/models` returns
+ // the same `{"data": [...]}` shape the existing parser handles, so
+ // we route through that rather than the native `/api/tags`.
+ "ollama" => {
+ let base = crate::inference::local::ollama_base_url_from_config(config);
+ format!("{}/v1", base.trim_end_matches('/'))
+ }
+ // `lm_studio_base_url` already ends in `/v1`.
+ "lmstudio" => crate::inference::local::lm_studio::lm_studio_base_url(config),
+ _ => return None,
+ };
+
+ Some(CloudProviderCreds {
+ id: format!("synthetic_local_{slug}"),
+ slug: slug.to_string(),
+ label: slug.to_string(),
+ endpoint,
+ // Local runtimes accept unauthenticated requests on loopback.
+ // The probe at `<endpoint>/models` runs without an Authorization
+ // header — `lookup_key_for_slug` may still return a key, but
+ // `AuthStyle::None` ignores it (see auth-style match below).
+ auth_style: AuthStyle::None,
+ legacy_type: None,
+ default_model: None,
+ })
+}
diff --git a/crates/openhuman-core/src/integrations/composio/catalog/lookups.rs b/crates/openhuman-core/src/integrations/composio/catalog/lookups.rs
new file mode 100644
index 0000000000..81daea04fe
--- /dev/null
+++ b/crates/openhuman-core/src/integrations/composio/catalog/lookups.rs
@@ -0,0 +1,48 @@
+//! Thin per-slug projections over [`super::contract::fetch_live_toolkit_catalog`]'s
+//! live [`super::contract::ToolContract`]s: required-argument names and
+//! response/output field names.
+
+use super::contract::fetch_live_toolkit_catalog;
+use crate::config::Config;
+
+
+/// Best-effort lookup of a Composio action's **required** top-level parameter
+/// names — a thin projection over [`fetch_live_toolkit_catalog`]'s
+/// [`ToolContract`]s (this used to run its own independent
+/// `REQUIRED_ARGS_CACHE`-backed fetch; existing callers — the required-arg
+/// preflight, `graph_wiring_warnings` — keep this exact signature).
+///
+/// Returns `None` when the schema is unavailable — unknown toolkit, client
+/// construction failure, a failed/empty listing, or the slug isn't present
+/// in the toolkit's live catalog — so callers can skip the preflight rather
+/// than block execution on a catalog hiccup.
+pub(crate) async fn composio_required_args(config: &Config, slug: &str) -> Option<Vec<String>> {
+ let toolkit = crate::integrations::composio::providers::toolkit_from_slug(slug)?;
+ let contracts = fetch_live_toolkit_catalog(config, &toolkit).await?;
+ contracts
+ .iter()
+ .find(|c| c.slug.eq_ignore_ascii_case(slug))
+ .map(|c| c.required_args.clone())
+}
+
+/// Best-effort lookup of a Composio action's **response/output** top-level
+/// field names — the output-side analogue of [`composio_required_args`],
+/// now a thin projection over [`fetch_live_toolkit_catalog`]'s
+/// [`ToolContract`]s (replaces the standalone `RESPONSE_FIELDS_CACHE`-backed
+/// fetch; `search_tool_catalog`'s grounding keeps this exact signature).
+///
+/// Returns `None` when no output schema is known for the slug — unknown
+/// toolkit, client construction failure, a failed/empty listing, the slug
+/// isn't in the live catalog, or a real action whose listing doesn't
+/// publish `output_parameters` — so callers degrade to "output shape
+/// unknown" rather than blocking or guessing. `Some(vec![])` means the
+/// schema was found but names no top-level properties.
+pub(crate) async fn composio_response_fields(config: &Config, slug: &str) -> Option<Vec<String>> {
+ let toolkit = crate::integrations::composio::providers::toolkit_from_slug(slug)?;
+ let contracts = fetch_live_toolkit_catalog(config, &toolkit).await?;
+ let contract = contracts
+ .iter()
+ .find(|c| c.slug.eq_ignore_ascii_case(slug))?;
+ contract.output_schema.as_ref()?;
+ Some(contract.output_fields.clone())
+}