The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
docs(readme): add module documentation for runtime and profiles
Steven Enamakel6896fbfd62d5
diff --git a/crates/openhuman-core/src/core/runtime/README.md b/crates/openhuman-core/src/core/runtime/README.mdindex 34a15c2f33..a52fc97b53 100644--- a/crates/openhuman-core/src/core/runtime/README.md+++ b/crates/openhuman-core/src/core/runtime/README.md@@ -150,8 +150,8 @@ through `runtime/saas.rs`:- `SaasConfig` is the **operator's** file. It sets `root`,`service_token_file` (defaults to `<root>/service.token`), `tool_allowlist`- (host tool groups, see `user_agents/README.md`), `[sandbox]` (the shell- container), `rpc_allowlist_extra`, `max_agents_open`, `idle_evict_secs`,+ (host tool groups, see `profiles/README.md`), `[sandbox]` (the shell+ container), `rpc_allowlist_extra`, `max_profiles_open`, `profile_ids`, `idle_evict_secs`,`shared_backend_api_key`, `custom_definitions` and `require_user_signature`(default `true`). Unknown keys are refused.- `runtime/boot_guard.rs` refuses the boot, listing every problem at once,diff --git a/crates/openhuman-core/src/profiles/README.md b/crates/openhuman-core/src/profiles/README.mdindex 47c206d3d5..aab57f5287 100644--- a/crates/openhuman-core/src/profiles/README.md+++ b/crates/openhuman-core/src/profiles/README.md@@ -1,38 +1,75 @@-# user_agents+# profiles-In SaaS mode (`core::runtime::Mode::Saas`), each user is served as one agent.-This domain maps a gateway user to that agent, lays out the agent's private-state, forces the config it runs with, and keeps the open agents of the-process. A single-user core never serves it: its controllers belong to-`DomainGroup::Operator`, which only `DomainSet::saas()` enables.+In SaaS mode (`core::runtime::Mode::Saas`), each user is served as one+**profile**: the tenant, with its own config, credential, workspace and+sandbox. This domain maps a gateway user to that profile, lays out the+profile's private state, forces the config it runs with, and keeps the open+profiles of the process. A single-user core never serves it: its controllers+belong to `DomainGroup::Operator`, which only `DomainSet::saas()` enables.++## Layout++```text+<root>/users/<profile-id>/ the desktop's users/<id> shape (config::schema::ProfileLayout)+ profile.toml ProfileMeta+ config.toml the profile's config_path+ workspace/ sessions, memory, threads, cron, cost+ sandbox/ action_dir: the only place it may act+<root>/deprovisioned/<id>-<secs>-<uuid>/ an archived profile+<root>/operator/ the operator plane's own state+```++The desktop config loader resolves a signed-in user's `users/<id>/config.toml`+and `workspace/` through the same `ProfileLayout`, so the two layouts cannot+drift. The older `<root>/agents/u-<hash>/` layout is gone; data left there is+not migrated.++## Profile ids++`[saas] profile_ids` picks how a gateway user id becomes a `ProfileId`:++- `"raw"` (the default): a user id matching `^[a-z0-9][a-z0-9_-]{0,63}$` is+ used unchanged, so the desktop's 24-hex backend ids pass through. `local`,+ `operator` and anything starting with `h-` are reserved.+- Anything else, or every id under `"hashed"`, becomes `h-` + the first 32 hex+ characters of `sha256(user_id)`.++Both forms fit the agent-id charset and can never contain a path separator.+Changing the mode re-maps users onto different profiles.## Files| File | Purpose || --- | --- |-| `types.rs` | `UserAgentId` (`u-` + 32 hex chars of `sha256(user_id)`), its metadata, and the operator-plane result types |-| `layout.rs` | `<root>/agents/<id>/{agent.toml, config.toml, workspace/, sandbox/}`, archived agents, and `agent_config`: the forced paths, memory binding and autonomy policy |-| `host.rs` | `AgentHost`: provisioning, lazy open, LRU and idle eviction (never of an agent in use), each agent's derived `CoreContext`, `current()` |-| `gateway.rs` | Which context a gateway request runs under: the operator plane, or the agent of the user named in `X-OpenHuman-User`, after the signature check |+| `types.rs` | `ProfileId` and `ProfileIdMode`, `ProfileMeta`, and the operator-plane result types |+| `layout.rs` | The SaaS side of the shared `ProfileLayout`, archived profiles, and `profile_config`: the forced paths, memory binding (pinned to the legacy layout) and autonomy policy |+| `host.rs` | `ProfileHost`: provisioning, lazy open, LRU and idle eviction (never of a profile in use), each profile's derived `CoreContext`, `current()` |+| `gateway.rs` | Which context a gateway request runs under: the operator plane, or the profile of the user named in `X-OpenHuman-User`, after the signature check || `surface.rs` | What a user may call: `USER_METHODS`, the exact allowlist applied at dispatch, in the controller list and in `/schema`; the operator scope sees only the operator plane; user thread-id rules |-| `background.rs` | The SaaS background loop: every minute it sweeps idle agents and runs each agent's queued memory jobs (deferred ingests, belief builds) under that agent's context |+| `background.rs` | The SaaS background loop: every minute it sweeps idle profiles and runs each profile's queued memory jobs (deferred ingests, belief builds) under that profile's context || `tools.rs` | Which agent tools a user gets: the operator's host tool groups (`host_files`, `host_shell`), the hard-deny list, the tool-list filter, the approval gate's SaaS verdict, and the container policy for a user's shell |-| `credentials.rs` | A user agent's TinyHumans credential, stored beside its config |+| `credentials.rs` | A profile's TinyHumans credential, stored beside its config || `ops.rs` | `provision` / `deprovision` / `list` / `status` / `set_credential` / `clear_credential`, returning `Outcome<T>` |-| `schemas.rs` | The `user_agents.*` controllers |+| `schemas.rs` | The `profiles.*` controllers (`profile_id` in and out) |## Rules-- **Gateway user ids never leave `ops.rs`.** They are hashed into an agent id- immediately and are never logged, stored or returned.-- **An agent's config is forced, not configured.**- - Every path sits under the agent's directory.- - Memory is bound to the agent (`[memory] agent_id`, `root = user:<id>`).+- **Gateway user ids become profile ids in `ops.rs` and `gateway.rs`.** The+ user id itself is never logged or stored; under raw mode a user id that+ fits the charset *is* the profile id, so use `"hashed"` where user ids must+ not reach paths and logs.+- **A profile's config is forced, not configured.**+ - Every path sits under the profile's directory.+ - Memory is bound to the profile (`[memory] agent_id`, `root = user:<id>`).That binding wins over definition pins and team roots.+ - The memory layout is pinned to the legacy tree (confined to that root by+ `memory::user_scope`). Layout v3 would bind the engine below+ `memory::scope::user_root`, which reads `users/<id>` from the config path+ and would answer `org:<id>` or a minted local root instead.- The autonomy policy is on and supervised, with no auto-approval, no toolinstallation and no trusted roots.-- **The isolation boundary is the agent's `CoreContext`.** It carries the forced- config and `session_agent = <id>`, and the user families (threads, channels+- **The isolation boundary is the profile's `CoreContext`.** It carries the forced+ config and `session_agent = <profile id>`, and the user families (threads, channelsfor web chat, memory), narrowed further by `surface::USER_METHODS`. Work for auser runs under it, which is what the config loader, the session store andthe per-thread caches key on.@@ -41,20 +78,20 @@ process. A single-user core never serves it: its controllers belong togroup in `tool_allowlist`:- `host_files` (`file_read`, `file_write`, `edit`, `apply_patch`, `grep`,`glob`, `list`, `csv_export`, `read_workspace_state`) runs in-process,- confined by the forced policy to the agent's `sandbox/`. In SaaS the+ confined by the forced policy to the profile's `sandbox/`. In SaaS thepolicy grants neither `~/OpenHuman/projects` nor `/tmp/openhuman`, whichevery user would share.- `host_shell` runs every command in a fresh Docker container(`[sandbox]`: image, network, memory and CPU limits): read-only rootfilesystem, all capabilities dropped, no host environment, and the- agent's `sandbox/` as its only writable mount. If the container cannot+ profile's `sandbox/` as its only writable mount. If the container cannotstart, the command fails; it never falls back to the host.- Tools that change the process, install code or reach shared state arehard-denied whatever the allowlist says (`tools::HARD_DENIED`).- There is no per-user approval surface, so the approval gate never parksin SaaS: it allows tools from an allowlisted group and refuses the rest.-- **Deprovisioning archives.** The agent's directory moves to- `<root>/deprovisioned/<id>-<unix-secs>-<uuid>/`. Nothing is deleted. An agent+- **Deprovisioning archives.** The profile's directory moves to+ `<root>/deprovisioned/<id>-<unix-secs>-<uuid>/`. Nothing is deleted. A profilestill in use is not archived; the call fails and can be retried.## Gateway contract@@ -68,12 +105,12 @@ X-OpenHuman-User-Sig: t=<unix secs>,v1=<hex hmac-sha256(token, "<t>.<user id>")>- No user header: the request runs on the operator plane.- With one, `openhuman-rpc`'s `saas_gateway` layer handles it in this order:1. It checks the bearer **before** anything else. An unauthenticated caller- cannot tell which users exist, and cannot open agents.+ cannot tell which users exist, and cannot open profiles.2. It checks the signature: ±60 s, bound to the user id. It is requiredunless the operator sets `require_user_signature = false`.- 3. It opens the user's agent, which must already be provisioned+ 3. It opens the user's profile, which must already be provisioned(`403` otherwise).- 4. It runs the request under that agent's context. A user's context cannot+ 4. It runs the request under that profile's context. A user's context cannotreach the operator plane.- Routes a SaaS core never serves answer `404`: `/v1`, `/events*`, `/ws/*`,`/socket.io`, `/dev/connect` and `/oauth/*`.@@ -81,8 +118,8 @@ X-OpenHuman-User-Sig: t=<unix secs>,v1=<hex hmac-sha256(token, "<t>.<user id>")>## CredentialsThe gateway installs each user's session JWT or API key with-`user_agents.set_credential`. The credential is stored in the agent's own-auth-profile store, so any backend call made under that agent's context+`profiles.set_credential`. The credential is stored in the profile's own+auth-profile store, so any backend call made under that profile's contextresolves that user's credential and no other. The process-wide`auth.set_credential` / `clear_credential` refuse in SaaS mode, because theyactivate a user directory and rebind process globals. The core never validates@@ -98,7 +135,7 @@ or echoes a credential.registers them so user contexts can derive them. The surface gate keeps theoperator scope on the operator plane, so the operator never serves usermethods on its own workspace.-- **Per-user storage.** Threads live under each agent's workspace. The on-disk+- **Per-user storage.** Threads live under each profile's workspace. The on-disksession store is installed for SaaS and resolves the workspace of thecalling context, so transcripts and turn states are per user too.- **Thread ids.** A user may choose ids for their own threads (`threads.upsert`)@@ -106,17 +143,17 @@ or echoes a credential.`channel:`, `proactive:` and `subagent:` are refused.- **Web chat.** `channel.web_chat`, `web_cancel` and the `web_queue_*` methodsare open, along with the turn-starting thread methods. Every `WebChannelEvent` is- stamped with the publishing context's agent (`WebChannelEvent::agent`, never+ stamped with the publishing context's `session_agent` (the profile id) (`WebChannelEvent::agent`, neverserialized). A user's `GET /events?client_id=` stream runs under that user's- gateway scope and carries only events stamped with that user's agent. Two+ gateway scope and carries only events stamped with that user's profile. Twousers on the same client id never see each other's turns. An unstamped eventbelongs to no user. The operator has no chat stream, and browser bind tokensare not accepted in SaaS.-- **Per-agent keys.** The web chat session cache, the in-flight turns and the- parallel (forked) turns are keyed by agent and id, so caller-chosen thread+- **Per-profile keys.** The web chat session cache, the in-flight turns and the+ parallel (forked) turns are keyed by `session_agent` (the profile id) and id, so caller-chosen threadand request ids never collide across users.-- **Deprovisioning** also clears the agent's credential, which lives in the- process keyring under the agent id. Otherwise a re-provisioned user would+- **Deprovisioning** also clears the profile's credential, which lives in the+ process keyring under the profile id. Otherwise a re-provisioned user wouldinherit the old credential.- **Prompt.** In SaaS the runtime section says `Host: hosted` instead of theserver's hostname. The `## User` identity block stays empty, because no@@ -126,17 +163,17 @@ or echoes a credential.A single-user core drains memory jobs from a cron system job behind the process-wide scheduler gate. A SaaS core cannot use either: the cron service is off, and the gate reflects the operator, who holds no credential. So `background::spawn` (started by `saas::build`) runs one loop per process instead. Each tick:-- sweeps idle agents;-- visits every provisioned agent whose workspace has queued memory jobs (`memory::lifecycle::jobs::has_pending`);-- opens that agent and runs its due jobs under the agent's own context, with its config, credential and memory root.+- sweeps idle profiles;+- visits every provisioned profile whose workspace has queued memory jobs (`memory::lifecycle::jobs::has_pending`);+- opens that profile and runs its due jobs under the profile's own context, with its config, credential and memory root.-Agents with nothing queued are not opened.+Profiles with nothing queued are not opened.-On the **first** open of an agent in a process, `recover_workspace` settles anything a previous process left in that agent's workspace:+On the **first** open of a profile in a process, `recover_workspace` settles anything a previous process left in that profile's workspace:- turns that were mid-flight are marked interrupted;- run-ledger rows left running are closed.-A re-open after an eviction never sweeps again, because this process may still be running one of that agent's turns.+A re-open after an eviction never sweeps again, because this process may still be running one of that profile's turns.User cron jobs are not served yet: the cron RPCs are not on the user surface.