Skip to content

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

feat(modules-linked): add linked modules crate to workspace

Steven Enamakele0a6ae33cd04
diff --git a/Cargo.toml b/Cargo.toml
index 134c0ef917..c3aa48cde6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,6 +16,7 @@ members = [
"crates/openhuman-cli",
"crates/openhuman-core",
"crates/openhuman-embed",
+ "crates/openhuman-modules-linked",
"crates/openhuman-rpc",
"crates/openhuman-tinyhumans",
"crates/openhuman-tui",
diff --git a/crates/openhuman-embed/src/modules.rs b/crates/openhuman-embed/src/modules.rs
index 48ea8ce854..62eac8c522 100644
--- a/crates/openhuman-embed/src/modules.rs
+++ b/crates/openhuman-embed/src/modules.rs
@@ -10,7 +10,9 @@ pub use openhuman_core::modules::ops::set_bundled_releases_dir;
/// executable. Local-development builds only: `openhuman-modules-linked` calls
/// this for each module it links; no shipped host does.
#[cfg(feature = "modules")]
-pub use openhuman_core::modules::linked::{register_linked, LinkedFactory};
+pub use openhuman_core::modules::linked::{
+ is_registered as is_linked_registered, register_linked, LinkedFactory,
+};
/// The browser-control module.
#[cfg(feature = "modules")]
diff --git a/crates/openhuman-modules-linked/Cargo.toml b/crates/openhuman-modules-linked/Cargo.toml
index bddab932bc..f83abfbf85 100644
--- a/crates/openhuman-modules-linked/Cargo.toml
+++ b/crates/openhuman-modules-linked/Cargo.toml
@@ -16,7 +16,9 @@
# `module_export_optional_static!` export) can be linked. These WAIT for the
# upstream static-link work (E0.3) and a re-pin; they have no feature here yet:
# tinycomputer, tinyjuice, tinysearch, tinywallet (module crate lacks
-# `static-link`), tinyhosts (no module crate yet).
+# `static-link`), tinymcp (has `static-link` but does not export
+# `linked_module` yet, only the three ABI items), tinyhosts (no module crate
+# yet).
[package]
name = "openhuman-modules-linked"
description = "Local-development registration of in-process linked modules (never part of a product build)"
@@ -28,12 +30,11 @@ publish = false
[features]
default = []
-all = ["tinybox", "tinychannels", "tinyconnectors", "tinydocs", "tinymcp", "tinyvoice"]
+all = ["tinybox", "tinychannels", "tinyconnectors", "tinydocs", "tinyvoice"]
tinybox = ["dep:tinybox-module"]
tinychannels = ["dep:tinychannels-module"]
tinyconnectors = ["dep:tinyconnectors"]
tinydocs = ["dep:tinydocs-module"]
-tinymcp = ["dep:tinymcp"]
tinyvoice = ["dep:tinyvoice-module"]
[dependencies]
@@ -46,7 +47,6 @@ tinybox-module = { path = "../../vendor/tinybox/crates/tinybox-module", features
tinychannels-module = { path = "../../vendor/tinychannels/crates/tinychannels-module", features = ["static-link"], optional = true }
tinyconnectors = { path = "../../vendor/tinyconnectors/crates/tinyconnectors", default-features = false, features = ["static-link"], optional = true }
tinydocs-module = { path = "../../vendor/tinydocs/crates/tinydocs-module", features = ["static-link"], optional = true }
-tinymcp = { path = "../../vendor/tinymcp/crates/tinymcp", features = ["static-link"], optional = true }
tinyvoice-module = { path = "../../vendor/tinyvoice/crates/tinyvoice-module", default-features = false, features = ["static-link"], optional = true }
[lints.rust]
diff --git a/crates/openhuman-modules-linked/src/lib.rs b/crates/openhuman-modules-linked/src/lib.rs
new file mode 100644
index 0000000000..2798a6ef0e
--- /dev/null
+++ b/crates/openhuman-modules-linked/src/lib.rs
@@ -0,0 +1,79 @@
+//! Linked modules for local development and local tests.
+//!
+//! Module implementation crates never become core dependencies. This crate is
+//! the one place they are linked, and only into a host binary built for local
+//! work: `openhuman-cli` with its non-product `linked-modules` feature. A
+//! shipped or CI build loads pinned, digest-checked releases instead and never
+//! reaches this crate.
+//!
+//! [`install`] registers one factory per enabled module with the core's
+//! `register_linked` seam. Registration alone changes nothing: a module is
+//! served from the executable only when the configuration asks for it
+//! (`[modules] source = "linked"`, `OPENHUMAN_MODULE_SOURCE=linked`, or a
+//! per-module override). Everything else still loads from its release.
+//!
+//! # Which modules are available
+//!
+//! One cargo feature per module, named for its registry id, plus `all`. The
+//! table is what the current vendor pins support:
+//!
+//! | feature | status |
+//! | ---------------- | ------ |
+//! | `tinybox` | linked |
+//! | `tinychannels` | linked |
+//! | `tinyconnectors` | linked |
+//! | `tinydocs` | linked |
+//! | `tinyvoice` | linked |
+//! | `tinymcp` | waits: `static-link` exists but `linked_module` is not exported |
+//! | `tinycomputer` | waits: no `static-link` |
+//! | `tinyjuice` | waits: no `static-link` |
+//! | `tinysearch` | waits: no `static-link` |
+//! | `tinywallet` | waits: no `static-link`; also see the attestation note below |
+//! | `tinyhosts` | waits: no module crate yet |
+//!
+//! The waiting modules need the upstream static-link work (E0.3) and a re-pin;
+//! each gets its feature here, and a line in [`install`], when that lands.
+//!
+//! # Attestation
+//!
+//! A linked module is attested by the executable's digest, not by a release
+//! digest. Confidential members (tinywallet's attested calls) must accept that
+//! digest in test builds for tinywallet to be linkable; until that is
+//! confirmed, treat tinywallet as `source`-only for local testing.
+
+use openhuman_rpc::embed::modules::{register_linked, LinkedFactory};
+
+/// The modules this build links, as `(registry id, factory)`.
+///
+/// Empty when no module feature is enabled.
+#[must_use]
+pub fn linked_modules() -> Vec<(&'static str, LinkedFactory)> {
+ #[allow(unused_mut)]
+ let mut modules: Vec<(&'static str, LinkedFactory)> = Vec::new();
+ #[cfg(feature = "tinybox")]
+ modules.push(("tinybox", tinybox_module::linked_module));
+ #[cfg(feature = "tinychannels")]
+ modules.push(("tinychannels", tinychannels_module::linked_module));
+ #[cfg(feature = "tinyconnectors")]
+ modules.push(("tinyconnectors", tinyconnectors::linked_module));
+ #[cfg(feature = "tinydocs")]
+ modules.push(("tinydocs", tinydocs_module::linked_module));
+ #[cfg(feature = "tinyvoice")]
+ modules.push(("tinyvoice", tinyvoice_module::linked_module));
+ modules
+}
+
+/// Register every enabled module with the core's linked-module seam.
+///
+/// Call once at boot, before the first module load. Idempotent: a repeat call
+/// replaces the same factories.
+pub fn install() {
+ for (id, factory) in linked_modules() {
+ log::debug!("[modules-linked] registering id={id}");
+ register_linked(id, factory);
+ }
+}
+
+#[cfg(test)]
+#[path = "lib_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-modules-linked/src/lib_tests.rs b/crates/openhuman-modules-linked/src/lib_tests.rs
new file mode 100644
index 0000000000..8ff3d5af1f
--- /dev/null
+++ b/crates/openhuman-modules-linked/src/lib_tests.rs
@@ -0,0 +1,32 @@
+use super::*;
+
+#[test]
+fn every_enabled_feature_registers_exactly_its_own_id() {
+ let ids: Vec<&str> = linked_modules().iter().map(|(id, _)| *id).collect();
+ let expected: Vec<&str> = [
+ cfg!(feature = "tinybox").then_some("tinybox"),
+ cfg!(feature = "tinychannels").then_some("tinychannels"),
+ cfg!(feature = "tinyconnectors").then_some("tinyconnectors"),
+ cfg!(feature = "tinydocs").then_some("tinydocs"),
+ cfg!(feature = "tinyvoice").then_some("tinyvoice"),
+ ]
+ .into_iter()
+ .flatten()
+ .collect();
+ assert_eq!(ids, expected);
+}
+
+#[test]
+fn install_is_idempotent() {
+ install();
+ install();
+}
+
+#[cfg(feature = "tinychannels")]
+#[test]
+fn install_makes_the_factory_visible_to_the_core() {
+ install();
+ assert!(openhuman_rpc::embed::modules::is_linked_registered(
+ "tinychannels"
+ ));
+}