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/skills/write_root.rs

Steven Enamakel0cc1527c3767
diff --git a/crates/openhuman-core/src/skills/write_root.rs b/crates/openhuman-core/src/skills/write_root.rs
index ddea36f4ef..709c83f2ed 100644
--- a/crates/openhuman-core/src/skills/write_root.rs
+++ b/crates/openhuman-core/src/skills/write_root.rs
@@ -6,28 +6,63 @@
//! Discovery scans those roots for that agent only, so a skill one agent
//! writes is neither seen by its siblings nor written into the operator's
//! `~/.openhuman`.
+//!
+//! A SaaS profile's default agent has no agent id, but it must not reach the
+//! operator's home either: its skills home is
+//! `<workspace>/agents/default/` ([`DEFAULT_AGENT`]) under the profile's own
+//! workspace, keyed by the tenant rather than the agent. A SaaS task with no
+//! tenant scope gets no home and no install root at all.
+//!
+//! [`DEFAULT_AGENT`]: crate::agent::session_store::DEFAULT_AGENT
use std::path::{Path, PathBuf};
-/// The current agent's skills home under `workspace_dir`, or `None` outside
-/// an embedded agent's context.
+use crate::core::runtime::Tenant;
+
+/// The current tenant's skills home under `workspace_dir`: the embedded
+/// agent's, or a SaaS profile's default agent's. `None` for the desktop's own
+/// default orchestrator (which uses the operator's home) and for a SaaS task
+/// with no scope.
#[must_use]
pub fn agent_skill_home(workspace_dir: &Path) -> Option<PathBuf> {
- let agent = crate::core::runtime::agent_scope::current_agent_id()?;
+ let tenant = crate::core::runtime::current_tenant().ok()?;
+ skill_home_for(&tenant, workspace_dir)
+}
+
+/// [`agent_skill_home`] for an explicit tenant.
+#[must_use]
+pub fn skill_home_for(tenant: &Tenant, workspace_dir: &Path) -> Option<PathBuf> {
+ let agent = match (&tenant.agent, &tenant.profile) {
+ (Some(agent), _) => agent.as_str(),
+ (None, Some(_)) => crate::agent::session_store::DEFAULT_AGENT,
+ (None, None) => return None,
+ };
Some(workspace_dir.join("agents").join(agent))
}
-/// The current agent's skills home under its context's workspace, or `None`
-/// outside an embedded agent's context — for callers that hold no workspace
+/// The current tenant's skills home under its context's workspace, or `None`
+/// where [`agent_skill_home`] has none — for callers that hold no workspace
/// path.
#[must_use]
pub fn current_agent_skill_home() -> Option<PathBuf> {
- let workspace = crate::core::runtime::CoreContext::current()?
+ let saas = crate::core::runtime::is_saas();
+ let workspace = crate::core::runtime::tenant::context_in(saas)?
.workspace_dir()
.ok()?;
agent_skill_home(&workspace)
}
+/// Whether a caller with no tenant skills home may fall back to the
+/// operator's `~/.openhuman`: never in SaaS, where that home is shared by
+/// every user.
+fn operator_home_allowed() -> bool {
+ if crate::core::runtime::is_saas() {
+ log::warn!("[skills] no tenant skills home in SaaS; refusing the operator's home");
+ return false;
+ }
+ true
+}
+
/// The roots an agent's user-scope bundles are discovered from and removed
/// from, newest layout last so it wins a name collision.
#[must_use]
@@ -41,16 +76,19 @@ pub fn agent_user_roots(agent_home: &Path) -> [PathBuf; 2] {
pub fn user_skill_install_root(workspace_dir: &Path, home: Option<&Path>) -> Option<PathBuf> {
match agent_skill_home(workspace_dir) {
Some(agent_home) => Some(agent_home.join("skills")),
+ None if !operator_home_allowed() => None,
None => home.map(|home| home.join(".openhuman").join("skills")),
}
}
/// Where a user-scope workflow is created: the agent's `workflows/` under an
-/// embedded agent's context, else `~/.openhuman/workflows`.
+/// embedded agent's or a SaaS profile's context, else
+/// `~/.openhuman/workflows` (never in SaaS).
#[must_use]
pub fn user_workflow_root(workspace_dir: &Path, home: Option<&Path>) -> Option<PathBuf> {
match agent_skill_home(workspace_dir) {
Some(agent_home) => Some(agent_home.join("workflows")),
+ None if !operator_home_allowed() => None,
None => home.map(|home| home.join(".openhuman").join("workflows")),
}
}