Skip to content

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

refactor(rpc): move the on-disk session store into openhuman-rpc

Steven Enamakel47e174d53f73
diff --git a/Cargo.toml b/Cargo.toml
index 06f547e8c1..8734be5364 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,7 @@
# Virtual workspace root. Members: `crates/openhuman-core` (package `openhuman`,
# the core library), `crates/openhuman-embed` (library facade),
-# `crates/openhuman-rpc` (JSON-RPC envelopes, client and server, above the core),
-# `crates/openhuman-store-sqlite` (the on-disk session store hosts install), `crates/openhuman-tinyhumans`
+# `crates/openhuman-rpc` (JSON-RPC envelopes, client and server, and the on-disk
+# session store hosts install, above the core), `crates/openhuman-tinyhumans`
# (SDK-backed backend transport + login/session ownership for hosts),
# `crates/openhuman-cli` (the `openhuman-core` binary, developer bins and the
# root integration tests), and `crates/openhuman-tui` (terminal client). `crates/openhuman-app` is deliberately excluded: it is its
@@ -17,7 +17,6 @@ members = [
"crates/openhuman-core",
"crates/openhuman-embed",
"crates/openhuman-rpc",
- "crates/openhuman-store-sqlite",
"crates/openhuman-tinyhumans",
"crates/openhuman-tui",
]
@@ -38,7 +37,6 @@ repository = "https://github.com/tinyhumansai/openhuman"
[workspace.dependencies]
openhuman-core = { path = "crates/openhuman-core", package = "openhuman" }
openhuman-rpc = { path = "crates/openhuman-rpc", default-features = false }
-openhuman-store-sqlite = { path = "crates/openhuman-store-sqlite" }
openhuman-embed = { path = "crates/openhuman-embed", default-features = false }
openhuman-tinyhumans = { path = "crates/openhuman-tinyhumans", default-features = false }
diff --git a/crates/openhuman-rpc/Cargo.toml b/crates/openhuman-rpc/Cargo.toml
index fb1b45edc3..0571b80609 100644
--- a/crates/openhuman-rpc/Cargo.toml
+++ b/crates/openhuman-rpc/Cargo.toml
@@ -32,16 +32,19 @@ server = [
"dep:rand",
"dep:uuid",
"dep:urlencoding",
- "dep:openhuman-store-sqlite",
+ "session-store",
]
+# The on-disk session store (`session_store`): OpenHuman's classic
+# `session_raw/` / `session_db/` / `tinyagents_store/` layout behind
+# TinyAgents' session store port. On with `server`; the TUI, which runs the
+# core without the server, turns it on by itself.
+session-store = ["dep:tinyagents-session", "dep:tinyagents-harness", "dep:chrono", "dep:anyhow"]
# Forwarded so the server's Sentry-routing tests run against a core that
# reports to Sentry.
crash-reporting = ["openhuman-core/crash-reporting"]
[dependencies]
openhuman-core = { path = "../openhuman-core", package = "openhuman", default-features = false }
-# The on-disk session store the app and CLI install (`install_session_store`).
-openhuman-store-sqlite = { workspace = true, optional = true }
log = "0.4"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
@@ -62,6 +65,10 @@ rand = { version = "0.10", optional = true }
uuid = { version = "1", features = ["v4"], optional = true }
urlencoding = { version = "2.1", optional = true }
tinyinference-core = { path = "../../vendor/tinyagents/vendor/tinyinference/crates/tinyinference-core", optional = true }
+# The session store port and the file/SQLite building blocks behind
+# `session_store` (`session-store` feature); same paths as the core's.
+tinyagents-session = { path = "../../vendor/tinyagents/crates/tinyagents-session", optional = true }
+tinyagents-harness = { path = "../../vendor/tinyagents/crates/tinyagents-harness", default-features = false, optional = true }
[dev-dependencies]
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
diff --git a/crates/openhuman-rpc/src/lib.rs b/crates/openhuman-rpc/src/lib.rs
index 8d8ac91531..4157cb8bb6 100644
--- a/crates/openhuman-rpc/src/lib.rs
+++ b/crates/openhuman-rpc/src/lib.rs
@@ -17,6 +17,9 @@
//! and listener, plus the `run_server*` entry points hosts call; and
//! [`http_host`], the static-directory file server whose `http_host.*`
//! controllers the server registers with the core.
+//! - Behind `session-store` (on with `server`): [`session_store`], the
+//! on-disk session store the app, the CLI and the TUI install, so the core
+//! itself carries no storage layout.
#[cfg(feature = "http-client")]
mod client;
@@ -26,6 +29,8 @@ pub mod http_host;
mod origin;
#[cfg(feature = "server")]
pub mod server;
+#[cfg(feature = "session-store")]
+pub mod session_store;
#[cfg(feature = "http-client")]
pub use client::{bearer_header, post_json_rpc, redact_url_for_log, HttpRpcResponse};
diff --git a/crates/openhuman-rpc/src/server/shims.rs b/crates/openhuman-rpc/src/server/shims.rs
index 3e004b24ea..466e677963 100644
--- a/crates/openhuman-rpc/src/server/shims.rs
+++ b/crates/openhuman-rpc/src/server/shims.rs
@@ -153,22 +153,12 @@ async fn run_server_with_services(
// The desktop app and the CLI keep conversations in the classic on-disk
// layout; the core itself carries no storage. Installed before boot so
- // its recovery sweep runs, and resolved per call because the desktop
- // rebinds its workspace when a different user signs in.
- install_session_store();
+ // its recovery sweep runs.
+ crate::session_store::install();
let runtime = builder.build().await?;
super::serve::serve(&runtime, ready_tx, shutdown_token).await
}
-/// Installs the on-disk session store over the current workspace.
-pub fn install_session_store() {
- openhuman_core::agent::session_store::install(std::sync::Arc::new(
- openhuman_store_sqlite::SqliteSessionStores::resolving(
- openhuman_core::agent::session_store::context_workspace_dir,
- ),
- ));
-}
-
fn apply_e2e_tool_groups(
builder: openhuman_core::core::runtime::CoreBuilder,
) -> openhuman_core::core::runtime::CoreBuilder {
diff --git a/crates/openhuman-store-sqlite/src/lib.rs b/crates/openhuman-rpc/src/session_store/mod.rs
similarity index 88%
rename from crates/openhuman-store-sqlite/src/lib.rs
rename to crates/openhuman-rpc/src/session_store/mod.rs
index 8bef188cdf..2357ddcd51 100644
--- a/crates/openhuman-store-sqlite/src/lib.rs
+++ b/crates/openhuman-rpc/src/session_store/mod.rs
@@ -1,4 +1,4 @@
-//! The desktop session store.
+//! The on-disk session store the app, the CLI and the TUI install.
//!
//! [`SqliteSessionStores`] is a
//! [`SessionStoreProvider`](tinyagents_session::port::SessionStoreProvider)
@@ -24,7 +24,7 @@
//!
//! ```
//! use std::sync::Arc;
-//! use openhuman_store_sqlite::SqliteSessionStores;
+//! use openhuman_rpc::session_store::SqliteSessionStores;
//! use tinyagents_session::port::SessionStoreProvider;
//!
//! let dir = tempfile::tempdir().unwrap();
@@ -127,6 +127,16 @@ fn stores_at(workspace: &Path) -> AgentStores {
}
}
+/// Installs [`SqliteSessionStores`] over the current workspace as the
+/// process's session store. Call it before the core boots, so its recovery
+/// sweep runs; the workspace is resolved per call because the desktop rebinds
+/// it when a different user signs in.
+pub fn install() {
+ openhuman_core::agent::session_store::install(Arc::new(SqliteSessionStores::resolving(
+ openhuman_core::agent::session_store::context_workspace_dir,
+ )));
+}
+
#[cfg(test)]
-#[path = "lib_tests.rs"]
+#[path = "mod_tests.rs"]
mod tests;
diff --git a/crates/openhuman-store-sqlite/src/lib_tests.rs b/crates/openhuman-rpc/src/session_store/mod_tests.rs
similarity index 100%
rename from crates/openhuman-store-sqlite/src/lib_tests.rs
rename to crates/openhuman-rpc/src/session_store/mod_tests.rs
diff --git a/crates/openhuman-store-sqlite/Cargo.toml b/crates/openhuman-store-sqlite/Cargo.toml
deleted file mode 100644
index 208c831dd6..0000000000
--- a/crates/openhuman-store-sqlite/Cargo.toml
+++ /dev/null
@@ -1,22 +0,0 @@
-[package]
-name = "openhuman-store-sqlite"
-description = "The desktop session store: OpenHuman's on-disk transcript, run-ledger and turn-state layout behind the TinyAgents session store port"
-version.workspace = true
-edition.workspace = true
-license.workspace = true
-repository.workspace = true
-publish = false
-
-# Deliberately free of the core: this crate only wraps TinyAgents' file and
-# SQLite building blocks behind `SessionStoreProvider`, so the core and embed
-# stay storage-agnostic and a host chooses this layout by installing it.
-[dependencies]
-anyhow = "1"
-chrono = "0.4"
-log = "0.4"
-tinyagents-harness = { path = "../../vendor/tinyagents/crates/tinyagents-harness", default-features = false }
-tinyagents-session = { path = "../../vendor/tinyagents/crates/tinyagents-session" }
-
-[dev-dependencies]
-tempfile = "3"
-tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
diff --git a/crates/openhuman-tui/Cargo.toml b/crates/openhuman-tui/Cargo.toml
index 0c1c666a22..af4605dbe7 100644
--- a/crates/openhuman-tui/Cargo.toml
+++ b/crates/openhuman-tui/Cargo.toml
@@ -17,8 +17,7 @@ path = "src/main.rs"
[dependencies]
openhuman-core.workspace = true
-openhuman-store-sqlite.workspace = true
-openhuman-rpc.workspace = true
+openhuman-rpc = { workspace = true, features = ["session-store"] }
openhuman-tinyhumans.workspace = true
anyhow = "1"
base64 = "0.22"
diff --git a/crates/openhuman-tui/src/runner.rs b/crates/openhuman-tui/src/runner.rs
index 5258dcc3b3..24f686ab58 100644
--- a/crates/openhuman-tui/src/runner.rs
+++ b/crates/openhuman-tui/src/runner.rs
@@ -175,11 +175,7 @@ async fn async_main(
// In-process core: full domains (channel.web_chat needs DomainGroup::Channels,
// so harness() is not enough), no RPC transport, no background services.
// Conversations in the classic on-disk layout, as the desktop keeps them.
- openhuman_core::agent::session_store::install(Arc::new(
- openhuman_store_sqlite::SqliteSessionStores::resolving(
- openhuman_core::agent::session_store::context_workspace_dir,
- ),
- ));
+ openhuman_rpc::session_store::install();
let runtime = Arc::new(
CoreBuilder::new(HostKind::detect_standalone())
.domains(DomainSet::full())