Skip to content

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

feat(modules): add source spec for building modules from vendored gitlinks

Steven Enamakelfd4754f00650
diff --git a/crates/openhuman-core/src/modules/types.rs b/crates/openhuman-core/src/modules/types.rs
index fcad3998b6..671a7d72ee 100644
--- a/crates/openhuman-core/src/modules/types.rs
+++ b/crates/openhuman-core/src/modules/types.rs
@@ -26,6 +26,8 @@ pub struct ModuleRecord {
pub assets: &'static [PlatformAsset],
/// When the module is loaded.
pub load: LoadPolicy,
+ /// How to build the module from its vendored gitlink, for local use.
+ pub source: SourceSpec,
}
impl ModuleRecord {
@@ -36,6 +38,41 @@ impl ModuleRecord {
}
}
+/// How to build a module's native library from its gitlink under `vendor/`.
+///
+/// Used only by `scripts/modules/build.mjs` and the `source` mode, both for
+/// local development and local tests. It says nothing about legitimacy: the
+/// registry digests in [`PlatformAsset`] are the only pins, and a local build
+/// is trusted by the operator through a `modules.toml` the build step writes
+/// beside the artifact.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct SourceSpec {
+ /// Directory name under `vendor/` holding the module's repository.
+ pub submodule: &'static str,
+ /// Path of the module crate's `Cargo.toml`, relative to the submodule.
+ pub manifest: &'static str,
+ /// Cargo package that produces the `cdylib`.
+ pub package: &'static str,
+ /// Library file stem Cargo emits, without the platform prefix or suffix.
+ pub lib_name: &'static str,
+ /// Cargo features to enable on top of the package defaults.
+ pub features: &'static [&'static str],
+}
+
+impl SourceSpec {
+ /// The file name Cargo gives the built library on this platform.
+ #[must_use]
+ pub fn artifact_filename(&self) -> String {
+ if cfg!(target_os = "windows") {
+ format!("{}.dll", self.lib_name)
+ } else if cfg!(target_os = "macos") {
+ format!("lib{}.dylib", self.lib_name)
+ } else {
+ format!("lib{}.so", self.lib_name)
+ }
+ }
+}
+
/// One published artifact and the digest that makes it legitimate.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PlatformAsset {