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/cron/scheduler_tests.rs,crates/openhuman-core/src/cro

Steven Enamakel3413fca1cbe9
diff --git a/crates/openhuman-core/src/cron/scheduler_tests_part_03_tests.rs b/crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/cron/scheduler_tests_part_03_tests.rs
rename to crates/openhuman-core/src/cron/scheduler_classifier_and_delivery_tests.rs
diff --git a/crates/openhuman-core/src/cron/scheduler_tests_part_04_tests.rs b/crates/openhuman-core/src/cron/scheduler_frequency_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/cron/scheduler_tests_part_04_tests.rs
rename to crates/openhuman-core/src/cron/scheduler_frequency_tests.rs
diff --git a/crates/openhuman-core/src/cron/scheduler_tests_part_02_tests.rs b/crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/cron/scheduler_tests_part_02_tests.rs
rename to crates/openhuman-core/src/cron/scheduler_halt_and_persist_tests.rs
diff --git a/crates/openhuman-core/src/cron/scheduler_tests_part_01_tests.rs b/crates/openhuman-core/src/cron/scheduler_profile_and_shell_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/cron/scheduler_tests_part_01_tests.rs
rename to crates/openhuman-core/src/cron/scheduler_profile_and_shell_tests.rs
diff --git a/crates/openhuman-core/src/cron/scheduler_tests.rs b/crates/openhuman-core/src/cron/scheduler_tests.rs
index 485091fd2d..de9353f6e0 100644
--- a/crates/openhuman-core/src/cron/scheduler_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_tests.rs
@@ -99,11 +99,11 @@ fn next_user_error(
}
}
-#[path = "scheduler_tests_part_01_tests.rs"]
-mod part_01_tests;
-#[path = "scheduler_tests_part_02_tests.rs"]
-mod part_02_tests;
-#[path = "scheduler_tests_part_03_tests.rs"]
-mod part_03_tests;
-#[path = "scheduler_tests_part_04_tests.rs"]
-mod part_04_tests;
+#[path = "scheduler_profile_and_shell_tests.rs"]
+mod profile_and_shell_tests;
+#[path = "scheduler_halt_and_persist_tests.rs"]
+mod halt_and_persist_tests;
+#[path = "scheduler_classifier_and_delivery_tests.rs"]
+mod classifier_and_delivery_tests;
+#[path = "scheduler_frequency_tests.rs"]
+mod frequency_tests;
diff --git a/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs b/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs
index b52803a23d..bf4cb9a1dc 100644
--- a/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/draft_revise.rs
@@ -10,7 +10,7 @@
/// the tool validates via the exact same [`validate_and_migrate_graph`] path
/// `flows_create` uses and echoes an optional `revision` note. It NEVER
/// persists — identical human-in-the-loop invariant to
-/// [`super::tools::ProposeWorkflowTool`].
+/// [`crate::flows::tools::ProposeWorkflowTool`].
pub struct ReviseWorkflowTool {
config: Arc<Config>,
}
diff --git a/crates/openhuman-core/src/flows/builder_tools/kind_reads.rs b/crates/openhuman-core/src/flows/builder_tools/kind_reads.rs
index 8b2e52c262..a12b5031c4 100644
--- a/crates/openhuman-core/src/flows/builder_tools/kind_reads.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/kind_reads.rs
@@ -238,7 +238,7 @@ impl Tool for GetNodeKindContractTool {
None => Ok(ToolResult::error(format!(
"'{kind}' is not a tinyflows node kind — call list_node_kinds for the {} valid \
kinds.",
- super::node_contracts::NODE_KINDS.len()
+ crate::flows::node_contracts::NODE_KINDS.len()
))),
}
}
diff --git a/crates/openhuman-core/src/inference/schemas.rs b/crates/openhuman-core/src/inference/schemas.rs
index e80fd119b8..7e66d418e7 100644
--- a/crates/openhuman-core/src/inference/schemas.rs
+++ b/crates/openhuman-core/src/inference/schemas.rs
@@ -1,5 +1,182 @@
+//! The `inference` RPC controller registry: schemas, handlers, and the
+//! wiring between them.
+
#[cfg(test)]
#[path = "schemas_tests.rs"]
mod tests;
-include!("schemas_part_01.rs");
-include!("schemas_part_02.rs");
+
+mod catalog;
+mod claude_code_handlers;
+mod oauth_handlers;
+mod prompt_handlers;
+mod settings_handlers;
+
+use serde::de::DeserializeOwned;
+use serde_json::{Map, Value};
+
+use crate::core::all::RegisteredController;
+use crate::core::ControllerSchema;
+use crate::rpc::RpcOutcome;
+
+pub use catalog::schemas;
+use claude_code_handlers::*;
+use oauth_handlers::*;
+use prompt_handlers::*;
+use settings_handlers::*;
+
+/// The canonical RPC method name for `inference.agent_chat`.
+///
+/// The controller's `namespace` + `function` combine into the wire method
+/// `openhuman.inference_agent_chat` ([`rpc_method_name`](crate::core::ControllerSchema)).
+/// Host facades (the embed library) reference this constant rather than
+/// spelling the string out, so a rename upstream cannot silently drift an
+/// embedder's dispatch string away from the registered controller.
+pub const INFERENCE_AGENT_CHAT: &str = "openhuman.inference_agent_chat";
+
+pub fn all_controller_schemas() -> Vec<ControllerSchema> {
+ vec![
+ schemas("resolve_model"),
+ schemas("status"),
+ schemas("get_client_config"),
+ schemas("update_model_settings"),
+ schemas("update_local_settings"),
+ schemas("list_models"),
+ schemas("provider_auth_errors"),
+ schemas("device_profile"),
+ schemas("presets"),
+ schemas("apply_preset"),
+ schemas("diagnostics"),
+ schemas("openai_oauth_start"),
+ schemas("openai_oauth_complete"),
+ schemas("openai_oauth_import_codex_cli"),
+ schemas("openai_oauth_status"),
+ schemas("openai_oauth_disconnect"),
+ schemas("summarize"),
+ schemas("prompt"),
+ schemas("vision_prompt"),
+ schemas("test_provider_model"),
+ schemas("should_react"),
+ schemas("analyze_sentiment"),
+ schemas("claude_code_status"),
+ schemas("claude_code_auth_status"),
+ schemas("claude_code_settings"),
+ schemas("claude_code_set_full_access"),
+ ]
+}
+
+pub fn all_registered_controllers() -> Vec<RegisteredController> {
+ vec![
+ RegisteredController {
+ schema: schemas("resolve_model"),
+ handler: handle_inference_resolve_model,
+ },
+ RegisteredController {
+ schema: schemas("status"),
+ handler: handle_inference_status,
+ },
+ RegisteredController {
+ schema: schemas("get_client_config"),
+ handler: handle_inference_get_client_config,
+ },
+ RegisteredController {
+ schema: schemas("update_model_settings"),
+ handler: handle_inference_update_model_settings,
+ },
+ RegisteredController {
+ schema: schemas("update_local_settings"),
+ handler: handle_inference_update_local_settings,
+ },
+ RegisteredController {
+ schema: schemas("list_models"),
+ handler: handle_inference_list_models,
+ },
+ RegisteredController {
+ schema: schemas("provider_auth_errors"),
+ handler: handle_inference_provider_auth_errors,
+ },
+ RegisteredController {
+ schema: schemas("device_profile"),
+ handler: handle_inference_device_profile,
+ },
+ RegisteredController {
+ schema: schemas("presets"),
+ handler: handle_inference_presets,
+ },
+ RegisteredController {
+ schema: schemas("apply_preset"),
+ handler: handle_inference_apply_preset,
+ },
+ RegisteredController {
+ schema: schemas("diagnostics"),
+ handler: handle_inference_diagnostics,
+ },
+ RegisteredController {
+ schema: schemas("openai_oauth_start"),
+ handler: handle_inference_openai_oauth_start,
+ },
+ RegisteredController {
+ schema: schemas("openai_oauth_complete"),
+ handler: handle_inference_openai_oauth_complete,
+ },
+ RegisteredController {
+ schema: schemas("openai_oauth_import_codex_cli"),
+ handler: handle_inference_openai_oauth_import_codex_cli,
+ },
+ RegisteredController {
+ schema: schemas("openai_oauth_status"),
+ handler: handle_inference_openai_oauth_status,
+ },
+ RegisteredController {
+ schema: schemas("openai_oauth_disconnect"),
+ handler: handle_inference_openai_oauth_disconnect,
+ },
+ RegisteredController {
+ schema: schemas("summarize"),
+ handler: handle_inference_summarize,
+ },
+ RegisteredController {
+ schema: schemas("prompt"),
+ handler: handle_inference_prompt,
+ },
+ RegisteredController {
+ schema: schemas("vision_prompt"),
+ handler: handle_inference_vision_prompt,
+ },
+ RegisteredController {
+ schema: schemas("test_provider_model"),
+ handler: handle_inference_test_provider_model,
+ },
+ RegisteredController {
+ schema: schemas("should_react"),
+ handler: handle_inference_should_react,
+ },
+ RegisteredController {
+ schema: schemas("analyze_sentiment"),
+ handler: handle_inference_analyze_sentiment,
+ },
+ RegisteredController {
+ schema: schemas("claude_code_status"),
+ handler: handle_inference_claude_code_status,
+ },
+ RegisteredController {
+ schema: schemas("claude_code_auth_status"),
+ handler: handle_inference_claude_code_auth_status,
+ },
+ RegisteredController {
+ schema: schemas("claude_code_settings"),
+ handler: handle_inference_claude_code_settings,
+ },
+ RegisteredController {
+ schema: schemas("claude_code_set_full_access"),
+ handler: handle_inference_claude_code_set_full_access,
+ },
+ ]
+}
+
+fn deserialize_params<T: DeserializeOwned>(params: Map<String, Value>) -> Result<T, String> {
+ serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))
+}
+
+fn to_json<T: serde::Serialize>(outcome: RpcOutcome<T>) -> Result<Value, String> {
+ outcome.into_cli_compatible_json()
+}
diff --git a/crates/openhuman-core/src/inference/schemas_part_01.rs b/crates/openhuman-core/src/inference/schemas/catalog.rs
similarity index 62%
rename from crates/openhuman-core/src/inference/schemas_part_01.rs
rename to crates/openhuman-core/src/inference/schemas/catalog.rs
index 0ce47107a8..2284d8d1be 100644
--- a/crates/openhuman-core/src/inference/schemas_part_01.rs
+++ b/crates/openhuman-core/src/inference/schemas/catalog.rs
@@ -1,287 +1,7 @@
-use serde::de::{DeserializeOwned, Deserializer};
-use serde::Deserialize;
-use serde_json::{Map, Value};
+//! The `inference.*` controller schemas: one [`ControllerSchema`] per RPC
+//! function, plus the field-shape helpers they are built from.
-use crate::core::all::{ControllerFuture, RegisteredController};
use crate::core::{ControllerSchema, FieldSchema, TypeSchema};
-use crate::config::rpc as config_rpc;
-use crate::rpc::RpcOutcome;
-
-/// The canonical RPC method name for `inference.agent_chat`.
-///
-/// The controller's `namespace` + `function` combine into the wire method
-/// `openhuman.inference_agent_chat` ([`rpc_method_name`](crate::core::ControllerSchema)).
-/// Host facades (the embed library) reference this constant rather than
-/// spelling the string out, so a rename upstream cannot silently drift an
-/// embedder's dispatch string away from the registered controller.
-pub const INFERENCE_AGENT_CHAT: &str = "openhuman.inference_agent_chat";
-
-#[derive(Debug, Deserialize)]
-struct InferenceSummarizeParams {
- text: String,
- max_tokens: Option<u32>,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferencePromptParams {
- prompt: String,
- max_tokens: Option<u32>,
- no_think: Option<bool>,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceVisionPromptParams {
- prompt: String,
- image_refs: Vec<String>,
- max_tokens: Option<u32>,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceResolveModelParams {
- hint: String,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceTestChatModelParams {
- workload: String,
- provider: String,
- prompt: Option<String>,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceShouldReactParams {
- message: String,
- channel_type: String,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceAnalyzeSentimentParams {
- message: String,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceModelRouteUpdate {
- hint: String,
- model: String,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceCloudProviderUpdate {
- id: Option<String>,
- slug: String,
- #[serde(default)]
- label: Option<String>,
- endpoint: String,
- #[serde(default)]
- auth_style: Option<String>,
- #[serde(rename = "type", default)]
- legacy_type: Option<String>,
- #[serde(default)]
- default_model: Option<String>,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceUpdateModelSettingsParams {
- api_url: Option<String>,
- inference_url: Option<String>,
- api_key: Option<String>,
- default_model: Option<String>,
- default_temperature: Option<f64>,
- model_routes: Option<Vec<InferenceModelRouteUpdate>>,
- cloud_providers: Option<Vec<InferenceCloudProviderUpdate>>,
- #[serde(default)]
- model_registry: Option<Vec<crate::config::schema::ModelRegistryEntry>>,
- primary_cloud: Option<String>,
- chat_provider: Option<String>,
- reasoning_provider: Option<String>,
- agentic_provider: Option<String>,
- coding_provider: Option<String>,
- vision_provider: Option<String>,
- memory_provider: Option<String>,
- embeddings_provider: Option<String>,
- heartbeat_provider: Option<String>,
- learning_provider: Option<String>,
- subconscious_provider: Option<String>,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceClaudeCodeSetFullAccessParams {
- /// true → full access (`bypassPermissions` + full toolset); false → the
- /// default `acceptEdits` posture (file edits only).
- enabled: bool,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceUpdateLocalSettingsParams {
- runtime_enabled: Option<bool>,
- opt_in_confirmed: Option<bool>,
- provider: Option<String>,
- #[serde(default, deserialize_with = "deserialize_present_json")]
- base_url: Option<Value>,
- model_id: Option<String>,
- chat_model_id: Option<String>,
- usage_embeddings: Option<bool>,
- usage_heartbeat: Option<bool>,
- usage_learning_reflection: Option<bool>,
- usage_subconscious: Option<bool>,
- api_key: Option<String>,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceListModelsParams {
- provider_id: String,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceApplyPresetParams {
- tier: String,
-}
-
-#[derive(Debug, Deserialize)]
-struct InferenceOpenAiOAuthCompleteParams {
- #[serde(alias = "callbackUrl")]
- callback_url: String,
-}
-
-pub fn all_controller_schemas() -> Vec<ControllerSchema> {
- vec![
- schemas("resolve_model"),
- schemas("status"),
- schemas("get_client_config"),
- schemas("update_model_settings"),
- schemas("update_local_settings"),
- schemas("list_models"),
- schemas("provider_auth_errors"),
- schemas("device_profile"),
- schemas("presets"),
- schemas("apply_preset"),
- schemas("diagnostics"),
- schemas("openai_oauth_start"),
- schemas("openai_oauth_complete"),
- schemas("openai_oauth_import_codex_cli"),
- schemas("openai_oauth_status"),
- schemas("openai_oauth_disconnect"),
- schemas("summarize"),
- schemas("prompt"),
- schemas("vision_prompt"),
- schemas("test_provider_model"),
- schemas("should_react"),
- schemas("analyze_sentiment"),
- schemas("claude_code_status"),
- schemas("claude_code_auth_status"),
- schemas("claude_code_settings"),
- schemas("claude_code_set_full_access"),
- ]
-}
-
-pub fn all_registered_controllers() -> Vec<RegisteredController> {
- vec![
- RegisteredController {
- schema: schemas("resolve_model"),
- handler: handle_inference_resolve_model,
- },
- RegisteredController {
- schema: schemas("status"),
- handler: handle_inference_status,
- },
- RegisteredController {
- schema: schemas("get_client_config"),
- handler: handle_inference_get_client_config,
- },
- RegisteredController {
- schema: schemas("update_model_settings"),
- handler: handle_inference_update_model_settings,
- },
- RegisteredController {
- schema: schemas("update_local_settings"),
- handler: handle_inference_update_local_settings,
- },
- RegisteredController {
- schema: schemas("list_models"),
- handler: handle_inference_list_models,
- },
- RegisteredController {
- schema: schemas("provider_auth_errors"),
- handler: handle_inference_provider_auth_errors,
- },
- RegisteredController {
- schema: schemas("device_profile"),
- handler: handle_inference_device_profile,
- },
- RegisteredController {
- schema: schemas("presets"),
- handler: handle_inference_presets,
- },
- RegisteredController {
- schema: schemas("apply_preset"),
- handler: handle_inference_apply_preset,
- },
- RegisteredController {
- schema: schemas("diagnostics"),
- handler: handle_inference_diagnostics,
- },
- RegisteredController {
- schema: schemas("openai_oauth_start"),
- handler: handle_inference_openai_oauth_start,
- },
- RegisteredController {
- schema: schemas("openai_oauth_complete"),
- handler: handle_inference_openai_oauth_complete,
- },
- RegisteredController {
- schema: schemas("openai_oauth_import_codex_cli"),
- handler: handle_inference_openai_oauth_import_codex_cli,
- },
- RegisteredController {
- schema: schemas("openai_oauth_status"),
- handler: handle_inference_openai_oauth_status,
- },
- RegisteredController {
- schema: schemas("openai_oauth_disconnect"),
- handler: handle_inference_openai_oauth_disconnect,
- },
- RegisteredController {
- schema: schemas("summarize"),
- handler: handle_inference_summarize,
- },
- RegisteredController {
- schema: schemas("prompt"),
- handler: handle_inference_prompt,
- },
- RegisteredController {
- schema: schemas("vision_prompt"),
- handler: handle_inference_vision_prompt,
- },
- RegisteredController {
- schema: schemas("test_provider_model"),
- handler: handle_inference_test_provider_model,
- },
- RegisteredController {
- schema: schemas("should_react"),
- handler: handle_inference_should_react,
- },
- RegisteredController {
- schema: schemas("analyze_sentiment"),
- handler: handle_inference_analyze_sentiment,
- },
- RegisteredController {
- schema: schemas("claude_code_status"),
- handler: handle_inference_claude_code_status,
- },
- RegisteredController {
- schema: schemas("claude_code_auth_status"),
- handler: handle_inference_claude_code_auth_status,
- },
- RegisteredController {
- schema: schemas("claude_code_settings"),
- handler: handle_inference_claude_code_settings,
- },
- RegisteredController {
- schema: schemas("claude_code_set_full_access"),
- handler: handle_inference_claude_code_set_full_access,
- },
- ]
-}
pub fn schemas(function: &str) -> ControllerSchema {
match function {
@@ -638,38 +358,3 @@ fn json_output(name: &'static str, comment: &'static str) -> FieldSchema {
required: true,
}
}
-
-fn handle_inference_resolve_model(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let p = deserialize_params::<InferenceResolveModelParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
- let resolved = crate::inference::provider::factory::resolve_model_for_hint(
- &p.hint, &config,
- );
- // Whether the resolved model accepts image input — drives the chat UI's
- // image-attachment affordance. Managed OpenHuman tiers consult the
- // core-owned per-tier map, which returns `true` for the reasoning and
- // vision tiers (and their `hint:` aliases) and `false` for every other
- // tier; custom/BYOK models are covered by the user's per-model
- // `model_registry.vision` flag.
- let vision =
- crate::inference::model_context::model_supports_vision(&resolved, &config);
- to_json(RpcOutcome::new(
- serde_json::json!({ "model": resolved, "vision": vision }),
- vec![],
- ))
- })
-}
-
-fn handle_inference_status(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(crate::inference::rpc::inference_status(&config).await?)
- })
-}
-
-fn handle_inference_get_client_config(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- to_json(crate::inference::rpc::inference_get_client_config().await?)
- })
-}
diff --git a/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs b/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs
new file mode 100644
index 0000000000..ec716f22ad
--- /dev/null
+++ b/crates/openhuman-core/src/inference/schemas/claude_code_handlers.rs
@@ -0,0 +1,73 @@
+//! Handlers for the Claude Code provider: version and auth probes, and its
+//! full-access setting.
+
+use serde::Deserialize;
+use serde_json::{Map, Value};
+
+use super::{deserialize_params, to_json};
+use crate::config::rpc as config_rpc;
+use crate::core::all::ControllerFuture;
+use crate::rpc::RpcOutcome;
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceClaudeCodeSetFullAccessParams {
+ /// true → full access (`bypassPermissions` + full toolset); false → the
+ /// default `acceptEdits` posture (file edits only).
+ enabled: bool,
+}
+
+pub(super) fn handle_inference_claude_code_status(_params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let status = tokio::task::spawn_blocking(
+ crate::inference::provider::claude_code::version_check::probe,
+ )
+ .await
+ .map_err(|e| format!("claude_code_status join error: {e}"))?;
+ to_json(RpcOutcome::new(status, vec![]))
+ })
+}
+
+pub(super) fn handle_inference_claude_code_auth_status(
+ _params: Map<String, Value>,
+) -> ControllerFuture {
+ Box::pin(async move {
+ let auth = tokio::task::spawn_blocking(
+ crate::inference::provider::claude_code::auth_status::probe,
+ )
+ .await
+ .map_err(|e| format!("claude_code_auth_status join error: {e}"))?;
+ to_json(RpcOutcome::new(auth, vec![]))
+ })
+}
+
+pub(super) fn handle_inference_claude_code_settings(
+ _params: Map<String, Value>,
+) -> ControllerFuture {
+ use crate::inference::provider::claude_code::settings;
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ let settings = settings::load_for_config(&config);
+ log::debug!(
+ "[rpc][inference.claude_code_settings] full_access={}",
+ settings.full_access
+ );
+ to_json(RpcOutcome::new(settings, vec![]))
+ })
+}
+
+pub(super) fn handle_inference_claude_code_set_full_access(
+ params: Map<String, Value>,
+) -> ControllerFuture {
+ use crate::inference::provider::claude_code::settings;
+ Box::pin(async move {
+ let p = deserialize_params::<InferenceClaudeCodeSetFullAccessParams>(params)?;
+ let config = config_rpc::load_config_with_timeout().await?;
+ let settings = settings::save_full_access_for_config(&config, p.enabled)
+ .map_err(|e| format!("failed to persist claude code settings: {e}"))?;
+ log::info!(
+ "[rpc][inference.claude_code_set_full_access] persisted full_access={}",
+ settings.full_access
+ );
+ to_json(RpcOutcome::new(settings, vec![]))
+ })
+}
diff --git a/crates/openhuman-core/src/inference/schemas/oauth_handlers.rs b/crates/openhuman-core/src/inference/schemas/oauth_handlers.rs
new file mode 100644
index 0000000000..20afba3d17
--- /dev/null
+++ b/crates/openhuman-core/src/inference/schemas/oauth_handlers.rs
@@ -0,0 +1,65 @@
+//! Handlers for the OpenAI OAuth flow: start, complete, Codex CLI import,
+//! status, and disconnect.
+
+use serde::Deserialize;
+use serde_json::{Map, Value};
+
+use super::{deserialize_params, to_json};
+use crate::config::rpc as config_rpc;
+use crate::core::all::ControllerFuture;
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceOpenAiOAuthCompleteParams {
+ #[serde(alias = "callbackUrl")]
+ callback_url: String,
+}
+
+pub(super) fn handle_inference_openai_oauth_start(_params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(crate::inference::rpc::inference_openai_oauth_start(&config).await?)
+ })
+}
+
+pub(super) fn handle_inference_openai_oauth_complete(
+ params: Map<String, Value>,
+) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ let payload = deserialize_params::<InferenceOpenAiOAuthCompleteParams>(params)?;
+ to_json(
+ crate::inference::rpc::inference_openai_oauth_complete(
+ &config,
+ payload.callback_url.trim(),
+ )
+ .await?,
+ )
+ })
+}
+
+pub(super) fn handle_inference_openai_oauth_import_codex_cli(
+ _params: Map<String, Value>,
+) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(crate::inference::rpc::inference_openai_oauth_import_codex_cli(&config).await?)
+ })
+}
+
+pub(super) fn handle_inference_openai_oauth_status(
+ _params: Map<String, Value>,
+) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(crate::inference::rpc::inference_openai_oauth_status(&config).await?)
+ })
+}
+
+pub(super) fn handle_inference_openai_oauth_disconnect(
+ _params: Map<String, Value>,
+) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(crate::inference::rpc::inference_openai_oauth_disconnect(&config).await?)
+ })
+}
diff --git a/crates/openhuman-core/src/inference/schemas/prompt_handlers.rs b/crates/openhuman-core/src/inference/schemas/prompt_handlers.rs
new file mode 100644
index 0000000000..5a4ab4a543
--- /dev/null
+++ b/crates/openhuman-core/src/inference/schemas/prompt_handlers.rs
@@ -0,0 +1,117 @@
+//! Handlers that run a model: summarize, prompt, vision prompt, provider
+//! model test, should-react, and sentiment analysis.
+
+use serde::Deserialize;
+use serde_json::{Map, Value};
+
+use super::{deserialize_params, to_json};
+use crate::config::rpc as config_rpc;
+use crate::core::all::ControllerFuture;
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceSummarizeParams {
+ text: String,
+ max_tokens: Option<u32>,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferencePromptParams {
+ prompt: String,
+ max_tokens: Option<u32>,
+ no_think: Option<bool>,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceVisionPromptParams {
+ prompt: String,
+ image_refs: Vec<String>,
+ max_tokens: Option<u32>,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceTestChatModelParams {
+ workload: String,
+ provider: String,
+ prompt: Option<String>,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceShouldReactParams {
+ message: String,
+ channel_type: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceAnalyzeSentimentParams {
+ message: String,
+}
+
+pub(super) fn handle_inference_summarize(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let p = deserialize_params::<InferenceSummarizeParams>(params)?;
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(crate::inference::rpc::inference_summarize(&config, &p.text, p.max_tokens).await?)
+ })
+}
+
+pub(super) fn handle_inference_prompt(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let p = deserialize_params::<InferencePromptParams>(params)?;
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(
+ crate::inference::rpc::inference_prompt(&config, &p.prompt, p.max_tokens, p.no_think)
+ .await?,
+ )
+ })
+}
+
+pub(super) fn handle_inference_vision_prompt(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let p = deserialize_params::<InferenceVisionPromptParams>(params)?;
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(
+ crate::inference::rpc::inference_vision_prompt(
+ &config,
+ &p.prompt,
+ &p.image_refs,
+ p.max_tokens,
+ )
+ .await?,
+ )
+ })
+}
+
+pub(super) fn handle_inference_test_provider_model(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let p = deserialize_params::<InferenceTestChatModelParams>(params)?;
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(
+ crate::inference::rpc::inference_test_provider_model(
+ &config,
+ &p.workload,
+ &p.provider,
+ p.prompt.as_deref().unwrap_or("Hello world"),
+ )
+ .await?,
+ )
+ })
+}
+
+pub(super) fn handle_inference_should_react(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let p = deserialize_params::<InferenceShouldReactParams>(params)?;
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(
+ crate::inference::rpc::inference_should_react(&config, &p.message, &p.channel_type)
+ .await?,
+ )
+ })
+}
+
+pub(super) fn handle_inference_analyze_sentiment(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let p = deserialize_params::<InferenceAnalyzeSentimentParams>(params)?;
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(crate::inference::rpc::inference_analyze_sentiment(&config, &p.message).await?)
+ })
+}
diff --git a/crates/openhuman-core/src/inference/schemas_part_02.rs b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
similarity index 51%
rename from crates/openhuman-core/src/inference/schemas_part_02.rs
rename to crates/openhuman-core/src/inference/schemas/settings_handlers.rs
index 28760388f9..f6b5795a72 100644
--- a/crates/openhuman-core/src/inference/schemas_part_02.rs
+++ b/crates/openhuman-core/src/inference/schemas/settings_handlers.rs
@@ -1,5 +1,126 @@
+//! Handlers for model and provider settings: resolution, status, client
+//! config, model and local-runtime settings updates, model listing, device
+//! profile, auth errors, presets, and diagnostics.
-fn handle_inference_update_model_settings(params: Map<String, Value>) -> ControllerFuture {
+use serde::de::Deserializer;
+use serde::Deserialize;
+use serde_json::{Map, Value};
+
+use super::{deserialize_params, to_json};
+use crate::config::rpc as config_rpc;
+use crate::core::all::ControllerFuture;
+use crate::rpc::RpcOutcome;
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceResolveModelParams {
+ hint: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceModelRouteUpdate {
+ hint: String,
+ model: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceCloudProviderUpdate {
+ id: Option<String>,
+ slug: String,
+ #[serde(default)]
+ label: Option<String>,
+ endpoint: String,
+ #[serde(default)]
+ auth_style: Option<String>,
+ #[serde(rename = "type", default)]
+ legacy_type: Option<String>,
+ #[serde(default)]
+ default_model: Option<String>,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceUpdateModelSettingsParams {
+ api_url: Option<String>,
+ inference_url: Option<String>,
+ api_key: Option<String>,
+ default_model: Option<String>,
+ default_temperature: Option<f64>,
+ model_routes: Option<Vec<InferenceModelRouteUpdate>>,
+ cloud_providers: Option<Vec<InferenceCloudProviderUpdate>>,
+ #[serde(default)]
+ model_registry: Option<Vec<crate::config::schema::ModelRegistryEntry>>,
+ primary_cloud: Option<String>,
+ chat_provider: Option<String>,
+ reasoning_provider: Option<String>,
+ agentic_provider: Option<String>,
+ coding_provider: Option<String>,
+ vision_provider: Option<String>,
+ memory_provider: Option<String>,
+ embeddings_provider: Option<String>,
+ heartbeat_provider: Option<String>,
+ learning_provider: Option<String>,
+ subconscious_provider: Option<String>,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceUpdateLocalSettingsParams {
+ runtime_enabled: Option<bool>,
+ opt_in_confirmed: Option<bool>,
+ provider: Option<String>,
+ #[serde(default, deserialize_with = "deserialize_present_json")]
+ base_url: Option<Value>,
+ model_id: Option<String>,
+ chat_model_id: Option<String>,
+ usage_embeddings: Option<bool>,
+ usage_heartbeat: Option<bool>,
+ usage_learning_reflection: Option<bool>,
+ usage_subconscious: Option<bool>,
+ api_key: Option<String>,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceListModelsParams {
+ provider_id: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub(super) struct InferenceApplyPresetParams {
+ tier: String,
+}
+
+pub(super) fn handle_inference_resolve_model(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let p = deserialize_params::<InferenceResolveModelParams>(params)?;
+ let config = config_rpc::load_config_with_timeout().await?;
+ let resolved =
+ crate::inference::provider::factory::resolve_model_for_hint(&p.hint, &config);
+ // Whether the resolved model accepts image input — drives the chat UI's
+ // image-attachment affordance. Managed OpenHuman tiers consult the
+ // core-owned per-tier map, which returns `true` for the reasoning and
+ // vision tiers (and their `hint:` aliases) and `false` for every other
+ // tier; custom/BYOK models are covered by the user's per-model
+ // `model_registry.vision` flag.
+ let vision = crate::inference::model_context::model_supports_vision(&resolved, &config);
+ to_json(RpcOutcome::new(
+ serde_json::json!({ "model": resolved, "vision": vision }),
+ vec![],
+ ))
+ })
+}
+
+pub(super) fn handle_inference_status(_params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ to_json(crate::inference::rpc::inference_status(&config).await?)
+ })
+}
+
+pub(super) fn handle_inference_get_client_config(_params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move { to_json(crate::inference::rpc::inference_get_client_config().await?) })
+}
+
+pub(super) fn handle_inference_update_model_settings(
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let update = deserialize_params::<InferenceUpdateModelSettingsParams>(params)?;
let patch = config_rpc::ModelSettingsPatch {
@@ -115,7 +236,9 @@ fn handle_inference_update_model_settings(params: Map<String, Value>) -> Control
})
}
-fn handle_inference_update_local_settings(params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_inference_update_local_settings(
+ params: Map<String, Value>,
+) -> ControllerFuture {
Box::pin(async move {
let update = deserialize_params::<InferenceUpdateLocalSettingsParams>(params)?;
let base_url = match update.base_url {
@@ -141,236 +264,44 @@ fn handle_inference_update_local_settings(params: Map<String, Value>) -> Control
})
}
-fn handle_inference_list_models(params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_inference_list_models(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let request = deserialize_params::<InferenceListModelsParams>(params)?;
- to_json(
- crate::inference::rpc::inference_list_models(&request.provider_id).await?,
- )
+ to_json(crate::inference::rpc::inference_list_models(&request.provider_id).await?)
})
}
-fn handle_inference_device_profile(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(
- async move { to_json(crate::inference::rpc::inference_device_profile().await?) },
- )
+pub(super) fn handle_inference_device_profile(_params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move { to_json(crate::inference::rpc::inference_device_profile().await?) })
}
-fn handle_inference_provider_auth_errors(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- to_json(crate::inference::rpc::inference_provider_auth_errors().await?)
- })
+pub(super) fn handle_inference_provider_auth_errors(
+ _params: Map<String, Value>,
+) -> ControllerFuture {
+ Box::pin(async move { to_json(crate::inference::rpc::inference_provider_auth_errors().await?) })
}
-fn handle_inference_presets(_params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_inference_presets(_params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move { to_json(crate::inference::rpc::inference_presets().await?) })
}
-fn handle_inference_apply_preset(params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_inference_apply_preset(params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let request = deserialize_params::<InferenceApplyPresetParams>(params)?;
to_json(crate::inference::rpc::inference_apply_preset(&request.tier).await?)
})
}
-fn handle_inference_openai_oauth_start(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(crate::inference::rpc::inference_openai_oauth_start(&config).await?)
- })
-}
-
-fn handle_inference_openai_oauth_complete(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- let payload = deserialize_params::<InferenceOpenAiOAuthCompleteParams>(params)?;
- to_json(
- crate::inference::rpc::inference_openai_oauth_complete(
- &config,
- payload.callback_url.trim(),
- )
- .await?,
- )
- })
-}
-
-fn handle_inference_openai_oauth_import_codex_cli(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(
- crate::inference::rpc::inference_openai_oauth_import_codex_cli(&config)
- .await?,
- )
- })
-}
-
-fn handle_inference_openai_oauth_status(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(crate::inference::rpc::inference_openai_oauth_status(&config).await?)
- })
-}
-
-fn handle_inference_openai_oauth_disconnect(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(crate::inference::rpc::inference_openai_oauth_disconnect(&config).await?)
- })
-}
-
-fn handle_inference_diagnostics(_params: Map<String, Value>) -> ControllerFuture {
+pub(super) fn handle_inference_diagnostics(_params: Map<String, Value>) -> ControllerFuture {
Box::pin(async move {
let config = config_rpc::load_config_with_timeout().await?;
to_json(crate::inference::rpc::inference_diagnostics(&config).await?)
})
}
-fn handle_inference_summarize(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let p = deserialize_params::<InferenceSummarizeParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(
- crate::inference::rpc::inference_summarize(&config, &p.text, p.max_tokens)
- .await?,
- )
- })
-}
-
-fn handle_inference_prompt(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let p = deserialize_params::<InferencePromptParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(
- crate::inference::rpc::inference_prompt(
- &config,
- &p.prompt,
- p.max_tokens,
- p.no_think,
- )
- .await?,
- )
- })
-}
-
-fn handle_inference_vision_prompt(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let p = deserialize_params::<InferenceVisionPromptParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(
- crate::inference::rpc::inference_vision_prompt(
- &config,
- &p.prompt,
- &p.image_refs,
- p.max_tokens,
- )
- .await?,
- )
- })
-}
-
-fn handle_inference_test_provider_model(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let p = deserialize_params::<InferenceTestChatModelParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(
- crate::inference::rpc::inference_test_provider_model(
- &config,
- &p.workload,
- &p.provider,
- p.prompt.as_deref().unwrap_or("Hello world"),
- )
- .await?,
- )
- })
-}
-
-fn handle_inference_should_react(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let p = deserialize_params::<InferenceShouldReactParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(
- crate::inference::rpc::inference_should_react(
- &config,
- &p.message,
- &p.channel_type,
- )
- .await?,
- )
- })
-}
-
-fn handle_inference_analyze_sentiment(params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let p = deserialize_params::<InferenceAnalyzeSentimentParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
- to_json(
- crate::inference::rpc::inference_analyze_sentiment(&config, &p.message)
- .await?,
- )
- })
-}
-
-fn handle_inference_claude_code_status(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let status = tokio::task::spawn_blocking(
- crate::inference::provider::claude_code::version_check::probe,
- )
- .await
- .map_err(|e| format!("claude_code_status join error: {e}"))?;
- to_json(RpcOutcome::new(status, vec![]))
- })
-}
-
-fn handle_inference_claude_code_auth_status(_params: Map<String, Value>) -> ControllerFuture {
- Box::pin(async move {
- let auth = tokio::task::spawn_blocking(
- crate::inference::provider::claude_code::auth_status::probe,
- )
- .await
- .map_err(|e| format!("claude_code_auth_status join error: {e}"))?;
- to_json(RpcOutcome::new(auth, vec![]))
- })
-}
-
-fn handle_inference_claude_code_settings(_params: Map<String, Value>) -> ControllerFuture {
- use crate::inference::provider::claude_code::settings;
- Box::pin(async move {
- let config = config_rpc::load_config_with_timeout().await?;
- let settings = settings::load_for_config(&config);
- log::debug!(
- "[rpc][inference.claude_code_settings] full_access={}",
- settings.full_access
- );
- to_json(RpcOutcome::new(settings, vec![]))
- })
-}
-
-fn handle_inference_claude_code_set_full_access(params: Map<String, Value>) -> ControllerFuture {
- use crate::inference::provider::claude_code::settings;
- Box::pin(async move {
- let p = deserialize_params::<InferenceClaudeCodeSetFullAccessParams>(params)?;
- let config = config_rpc::load_config_with_timeout().await?;
- let settings = settings::save_full_access_for_config(&config, p.enabled)
- .map_err(|e| format!("failed to persist claude code settings: {e}"))?;
- log::info!(
- "[rpc][inference.claude_code_set_full_access] persisted full_access={}",
- settings.full_access
- );
- to_json(RpcOutcome::new(settings, vec![]))
- })
-}
-
-fn deserialize_params<T: DeserializeOwned>(params: Map<String, Value>) -> Result<T, String> {
- serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))
-}
-
fn deserialize_present_json<'de, D>(deserializer: D) -> Result<Option<Value>, D::Error>
where
D: Deserializer<'de>,
{
Value::deserialize(deserializer).map(Some)
}
-
-fn to_json<T: serde::Serialize>(outcome: RpcOutcome<T>) -> Result<Value, String> {
- outcome.into_cli_compatible_json()
-}