Skip to content

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

refactor(doctor): replace include!-based module split with real submodules

Steven Enamakel0c69c5d39883
diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs
new file mode 100644
index 0000000000..5a0aa8930d
--- /dev/null
+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs
@@ -0,0 +1,28 @@
+//! Tool-discovery and execution handlers: `list_tools`, `execute`.
+
+use serde_json::{Map, Value};
+
+use crate::config::rpc as config_rpc;
+use crate::core::all::ControllerFuture;
+use crate::integrations::composio::ops;
+
+use super::util::{read_optional, read_required_non_empty, to_json};
+
+pub(super) fn handle_list_tools(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ let toolkits = read_optional::<Vec<String>>(&params, "toolkits")?;
+ let tags = read_optional::<Vec<String>>(&params, "tags")?;
+ to_json(ops::composio_list_tools(&config, toolkits, tags).await?)
+ })
+}
+
+pub(super) fn handle_execute(params: Map<String, Value>) -> ControllerFuture {
+ Box::pin(async move {
+ let config = config_rpc::load_config_with_timeout().await?;
+ let tool = read_required_non_empty(&params, "tool")?;
+ let arguments = read_optional::<Value>(&params, "arguments")?;
+ let connection_id = read_optional::<String>(&params, "connection_id")?;
+ to_json(ops::composio_execute(&config, &tool, arguments, connection_id.as_deref()).await?)
+ })
+}
diff --git a/crates/openhuman-core/src/memory/tree/tree/rpc/chunks.rs b/crates/openhuman-core/src/memory/tree/tree/rpc/chunks.rs
new file mode 100644
index 0000000000..db80064f55
--- /dev/null
+++ b/crates/openhuman-core/src/memory/tree/tree/rpc/chunks.rs
@@ -0,0 +1,132 @@
+//! Chunk read handlers: `memory_tree_list_chunks` and `memory_tree_get_chunk`.
+
+use serde::{Deserialize, Serialize};
+
+use crate::config::Config;
+use crate::memory::api::provider::ChunkQuery;
+use crate::rpc::RpcOutcome;
+use tinymemory_api::chunks::{Chunk, SourceKind};
+
+/// Query shape for the `list_chunks` RPC.
+#[derive(Clone, Debug, Default, Serialize, Deserialize)]
+pub struct ListChunksRequest {
+ #[serde(default)]
+ pub source_kind: Option<String>,
+ #[serde(default)]
+ pub source_id: Option<String>,
+ #[serde(default)]
+ pub owner: Option<String>,
+ #[serde(default)]
+ pub since_ms: Option<i64>,
+ #[serde(default)]
+ pub until_ms: Option<i64>,
+ #[serde(default)]
+ pub limit: Option<usize>,
+}
+
+/// Response shape for the `list_chunks` RPC.
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct ListChunksResponse {
+ pub chunks: Vec<Chunk>,
+}
+
+/// `list_chunks` RPC handler. Filters and returns persisted chunks ordered by
+/// timestamp DESC.
+///
+/// `scope` is `None`, which is not an oversight: this listing has never
+/// applied the per-turn source allowlist — the engine query it replaced set
+/// `source_scope: None` — and it is reached by inspection surfaces rather than
+/// by an agent turn. Narrowing it here would be a policy change wearing a
+/// routing change's clothes.
+pub async fn list_chunks_rpc(
+ config: &Config,
+ req: ListChunksRequest,
+) -> Result<RpcOutcome<ListChunksResponse>, String> {
+ // Parsed before the driver is resolved so an unknown kind stays a caller
+ // error naming the offending value, rather than a driver round trip that
+ // returns nothing and looks like an empty store.
+ let query = ChunkQuery {
+ source_kind: match req.source_kind.as_deref() {
+ None => None,
+ Some(s) => Some(SourceKind::parse(s)?),
+ },
+ source_id: req.source_id,
+ owner: req.owner,
+ since_ms: req.since_ms,
+ until_ms: req.until_ms,
+ limit: req.limit,
+ offset: None,
+ exclude_dropped: false,
+ // The filtered-listing predicates this request does not carry. An empty
+ // predicate is unfiltered, so the defaults leave the query exactly as
+ // narrow as the fields above already make it.
+ ..Default::default()
+ };
+
+ // No `spawn_blocking`: the driver owns whether its own reads block, and the
+ // module's do not run on this thread at all.
+ let binding = crate::memory::binding::for_config(config)?;
+ let rows = match binding.provider().as_chunks() {
+ Some(chunks) => chunks
+ .list_chunks(&query, None)
+ .await
+ .map_err(|e| format!("list_chunks: {e}"))?,
+ // Read-only, so an empty page is the honest answer: a driver with no
+ // chunk tier holds no rows to list, which is a true statement about it
+ // rather than a fault the caller can act on.
+ None => {
+ log::debug!(
+ "[memory-tree][rpc] list_chunks: driver '{}' does not serve Chunks; reporting empty",
+ binding.driver_id()
+ );
+ Vec::new()
+ }
+ };
+
+ let n = rows.len();
+ Ok(RpcOutcome::single_log(
+ ListChunksResponse { chunks: rows },
+ format!("memory_tree: list_chunks n={n}"),
+ ))
+}
+
+/// Request shape for the `get_chunk` RPC.
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct GetChunkRequest {
+ pub id: String,
+}
+
+/// Response shape for the `get_chunk` RPC.
+#[derive(Clone, Debug, Serialize, Deserialize)]
+pub struct GetChunkResponse {
+ pub chunk: Option<Chunk>,
+}
+
+/// `get_chunk` RPC handler. Returns the chunk identified by `id`, or `None`.
+pub async fn get_chunk_rpc(
+ config: &Config,
+ req: GetChunkRequest,
+) -> Result<RpcOutcome<GetChunkResponse>, String> {
+ let binding = crate::memory::binding::for_config(config)?;
+ let chunk = match binding.provider().as_chunks() {
+ Some(chunks) => chunks
+ .get_chunk(&req.id)
+ .await
+ .map_err(|e| format!("get_chunk: {e}"))?,
+ // `None` is already this handler's answer for an id the store does not
+ // hold, and a driver with no chunk tier holds none — so the degrade is
+ // indistinguishable from the ordinary miss, which is what makes it safe
+ // here and not on a write.
+ None => {
+ log::debug!(
+ "[memory-tree][rpc] get_chunk: driver '{}' does not serve Chunks; reporting none",
+ binding.driver_id()
+ );
+ None
+ }
+ };
+ Ok(RpcOutcome::single_log(
+ GetChunkResponse { chunk },
+ format!("memory_tree: get_chunk id={}", req.id),
+ ))
+}
diff --git a/crates/openhuman-core/src/platform/doctor/core.rs b/crates/openhuman-core/src/platform/doctor/core.rs
index 56c5bd2c18..9c311722bd 100644
--- a/crates/openhuman-core/src/platform/doctor/core.rs
+++ b/crates/openhuman-core/src/platform/doctor/core.rs
@@ -1,5 +1,22 @@
+//! The doctor report: config, workspace, daemon, environment, memory, and
+//! agent-SDK diagnostic checks, plus the model-probe report.
+//!
+//! Split by responsibility rather than by line count — see `core/*.rs`. This
+//! file only wires the submodules together and re-exports the public API.
+
#[cfg(test)]
#[path = "core_tests.rs"]
mod tests;
-include!("core_part_01.rs");
-include!("core_part_02.rs");
+
+mod config_checks;
+mod daemon_env_checks;
+mod memory_agent_checks;
+mod run;
+mod types;
+mod workspace_checks;
+
+pub use run::{run, run_models, MemoryChunkCount};
+pub use types::{
+ DiagnosticItem, DoctorReport, DoctorSummary, ModelProbeEntry, ModelProbeOutcome,
+ ModelProbeReport, ModelProbeSummary, Severity,
+};
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_part_02_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/tools/impl/system/shell_tests_part_02_tests.rs
rename to crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs
diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_part_01_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/tools/impl/system/shell_tests_part_01_tests.rs
rename to crates/openhuman-core/src/tools/impl/system/shell_tests_schema_and_env_tests.rs