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(embed): document two-step Runtime/Agent API and API-key auth
Steven Enamakel0b72d8746d70
diff --git a/AGENTS.md b/AGENTS.mdindex cd40b3ae3b..9b7cd1e1f1 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -245,12 +245,24 @@ progress events.- Use the `tinytools` copy vendored through `vendor/tinyagents/`; a second pathcreates incompatible Rust types.- Keep conversions mechanical. Policy decisions belong in OpenHuman.-- `openhuman_embed::Harness` is the public prompt-to-reply API. Calls go through- `CoreRuntime::invoke`, not directly to domain operations.+- `openhuman_embed::Runtime` → `Agent` is the public library API: one runtime+ per process (features, services, backend URL, TinyHumans API key), then any+ number of independently configured agents on it (`AgentSpec`: provider,+ access, `action_dir`, MCP servers, skills, prompt, tool scope, sandbox).+ `Harness` is the one-agent shorthand over the same two types. Agent turns+ dispatch natively (`inference::local::ops::agent_chat_for`) under the+ agent's own `CoreContext` (`CoreContext::derive_with`); other facade calls+ go through `CoreRuntime::invoke`.- Set `config_path` with `workspace_dir`, and set a turn origin with its access- tier. `Access::full()` configures both access fields.-- Use one `Harness` per process. Copy skills into its workspace because skill- discovery rejects symlinked bundles.+ tier. `Access::full()` configures both access fields. Every agent on a+ runtime shares its `config_path` (credentials, keyring, API key).+- Copy skills into an agent's `personalities/<id>/skills/` (what+ `AgentSpec::skills_dir` does) because skill discovery rejects symlinked+ bundles. Library agents hide the operator's `~/.openhuman/skills` unless+ `include_user_skills(true)`.+- Library mode has no user login: the runtime's API key rides managed+ inference as `Authorization: Bearer` and backend REST as `x-api-key`+ (`security::credentials::api_key`, `session_support::BackendCredential`).`CoreBuilder` controls background services with `ServiceSet`, runtime domainswith `DomainSet`, and tool visibility with `ToolGroups`. These controls onlydiff --git a/crates/openhuman-core/src/security/credentials/README.md b/crates/openhuman-core/src/security/credentials/README.mdindex 766cacd49c..14004a4c25 100644--- a/crates/openhuman-core/src/security/credentials/README.md+++ b/crates/openhuman-core/src/security/credentials/README.md@@ -31,7 +31,8 @@ Credential management for the OpenHuman app session and provider/OAuth auth prof## Public surface- **`AuthService`** (`core.rs`) — `from_config`, `new`, `load_profiles`, `store_provider_token`, `set_active_profile`, `remove_profile`, `get_profile`, `get_provider_bearer_token`.-- **Constants** — `APP_SESSION_PROVIDER` (`"app-session"`), `DEFAULT_AUTH_PROFILE_NAME` (`"default"`), `COMPOSIO_DIRECT_PROVIDER` (`"composio-direct"`).+- **Constants** — `APP_SESSION_PROVIDER` (`"app-session"`), `DEFAULT_AUTH_PROFILE_NAME` (`"default"`), `COMPOSIO_DIRECT_PROVIDER` (`"composio-direct"`), `api_key::API_KEY_PROVIDER` (`"api-key"`).+- **API key (library mode)** — `api_key::{store_api_key, store_api_key_in, get_api_key, get_api_key_in, has_api_key, clear_api_key}` keep a TinyHumans API key as the `api-key` profile. `session_support::resolve_backend_credential` returns `BackendCredential::ApiKey` when one is stored (before any session classification) and `BackendCredential::Session` otherwise; `BackendOAuthClient::authed_json` sends an API key as `x-api-key` and a session as `Authorization: Bearer`, while `OpenHumanBackendModel::resolve_bearer` sends the key as the bearer for managed inference. `has_backend_credential` is the boot-time "signed in?" question the scheduler gate asks; `SessionExpired` is ignored for an API-key runtime.- **Helpers** — `normalize_provider`, `default_profile_id`, `select_profile_id`, `state_dir_from_config`, `profile_id`.- **Types** (`profiles.rs`) — `AuthProfile`, `AuthProfileKind` (`OAuth`/`Token`), `TokenSet`, `AuthProfilesData`, `AuthProfilesStore`.- **Ops/RPC** (`ops`, re-exported as `rpc`) — `store_session`, `clear_session`, `auth_get_state`, `auth_get_session_token_json`, `auth_get_me`, `consume_login_token`, `auth_create_channel_link_token`, `store_provider_credentials`, `remove_provider_credentials`, `list_provider_credentials`, `list_provider_credentials_by_prefix`, `oauth_connect`, `oauth_list_integrations`, `oauth_fetch_integration_tokens`, `oauth_fetch_client_key`, `oauth_revoke_integration`, `encrypt_secret`, `decrypt_secret`, `start_login_gated_services`, `stop_login_gated_services`.@@ -41,6 +42,8 @@ Credential management for the OpenHuman app session and provider/OAuth auth prof## RPC / controllers+`auth.store_api_key` (`{ key }`) and `auth.clear_api_key` manage the API-key profile; `auth.get_state` reports `credential: "session" | "api-key"` alongside `isAuthenticated`.+Namespace `auth` (JSON-RPC `openhuman.auth_*` / CLI). Defined in `schemas.rs`:| Method | Description |diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.mdindex d623ba785b..f22224473c 100644--- a/docs/TEST-COVERAGE-MATRIX.md+++ b/docs/TEST-COVERAGE-MATRIX.md@@ -637,7 +637,7 @@ End-to-end coverage of the agent harness via the web-chat RPC surface against an| ID | Feature | Layer | Test path(s) | Status | Notes || ------ | -------------------------------------------------------------- | ----- | ------------------------------------------------------------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------------- || 16.1.1 | End-to-end turn with no transport and no background services | RI | `crates/openhuman-embed/tests/harness_embed.rs` | ✅ | Real login-free `HostKind::Library` turn against a wiremock provider; asserts the request landed on the caller's endpoint, no RPC listener was bound, continuity across two turns, then 100 distinct sessions overlap on the same live core without fake auth; also checks `session_db` placement and workspace removal on drop |-| 16.1.2 | Turn wire contract (`TurnRequest` ↔ `inference.agent_chat`) | RU | `crates/openhuman-embed/src/agent_tests.rs` | ✅ | Field names checked **both ways** against the registered controller schema — `AgentChatParams` carries no `rename_all`, so an upstream rename is otherwise a silent runtime failure; plus absent-option omission |+| 16.1.2 | Turn wire contract (`TurnRequest` ↔ `inference.agent_chat`) | RU | `crates/openhuman-embed/src/turn_tests.rs` | ✅ | Field names checked **both ways** against the registered controller schema — `AgentChatParams` carries no `rename_all`, so an upstream rename is otherwise a silent runtime failure; plus absent-option omission || 16.1.3 | Embedder-supplied config reaches handlers, not just boot | RU | `crates/openhuman-core/src/core/runtime/context.rs` (`*_embedder_config`) | ✅ | `CoreBuilder::config` is published on `CoreContext` and preferred by `load_config_with_timeout`; without it every handler re-resolves the process-global workspace || 16.1.4 | Workspace lifetime and credential isolation | RU | `crates/openhuman-embed/src/harness/workspace_tests.rs` | ✅ | Ephemeral removed on drop, `Dir` persists, `action_dir` never inside the workspace, and `config_path` beside it — its parent is where auth profiles and the keyring resolve || 16.1.5 | Access tier sets the autonomy level **and** the turn origin | RU | `crates/openhuman-embed/src/harness/access_tests.rs` | ✅ | The fail-closed trap: tier alone leaves every acting tool refusing while the transcript still reads plausibly. Also pins tool-install and `auto_approve_all` staying off at `full()` |@@ -645,7 +645,9 @@ End-to-end coverage of the agent harness via the web-chat RPC surface against an| 16.1.7 | Session store (`Core::auth`) | RU | `crates/openhuman-embed/src/auth_tests.rs` | ✅ | Local-session token shape + user payload, backend/local discrimination, `AuthState` and token-payload decoding incl. the signed-out shapes || 16.1.8 | MCP servers declared programmatically | RU | `crates/openhuman-embed/src/harness/mcp_tests.rs` | ✅ | stdio/HTTP transports mutually exclusive, enabled by default, env accumulation, allow/deny filters, auth carried through || 16.1.9 | Skill bundles installed into the workspace | RU | `crates/openhuman-embed/src/harness/skills_tests.rs` | ✅ | Copied not linked (discovery rejects symlinked bundles and manifests by design); symlinks skipped both as bundles and inside them; `Inherit` refuses the copy |-| 16.1.10 | One harness per process | RU+RI | `crates/openhuman-embed/src/harness/builder_tests.rs`, `crates/openhuman-embed/tests/harness_embed.rs` | ✅ | Second build returns `AlreadyRunning` rather than sharing process-global keyring/event-bus/subscribers; a failed build releases the slot so a retry is possible |+| 16.1.10 | One runtime per process | RU+RI | `crates/openhuman-embed/src/runtime/builder_tests.rs`, `crates/openhuman-embed/tests/harness_embed.rs` | ✅ | A second `Runtime` (or `Harness`) returns `AlreadyRunning` rather than sharing process-global keyring/event-bus/subscribers; a failed build releases the slot so a retry is possible |+| 16.1.11 | Many agents on one runtime | RU+RI | `crates/openhuman-embed/src/agent/spec_tests.rs`, `crates/openhuman-embed/tests/runtime_agents.rs` | ✅ | Three agents with different providers, access tiers, skills, MCP servers and action dirs; turns land on their own provider; per-agent MCP visibility; thread-scoped resume; duplicate/invalid ids and widening are refused |+| 16.1.12 | API-key credential for library mode | RU+RI | `crates/openhuman-core/src/security/credentials/api_key_tests.rs`, `crates/openhuman-embed/tests/runtime_agents.rs` | ✅ | Key stored as an `api-key` auth profile; wins over an expired session; managed inference sends it as a bearer with no `x-api-key`; auth state reports `credential = "api-key"` |## Summarydiff --git a/docs/library-minimal-recipe.md b/docs/library-minimal-recipe.mdindex f0e3227fdd..a92993cc68 100644--- a/docs/library-minimal-recipe.md+++ b/docs/library-minimal-recipe.md@@ -33,6 +33,31 @@ cargo build --release \There is **no** `library-minimal` meta-feature in `Cargo.toml`, on purpose — see[Why no alias](#why-no-cargotoml-alias) below.+Usage against this recipe is the two-step API: one `Runtime` per process,+then agents on it. `DomainSet` families are registered at runtime build time+and agents can only narrow them, so include `mcp` / `skills` in both the+Cargo features **and** the runtime's `DomainSet` (the builder's default does)+if any agent will declare servers or skills.++```rust,no_run+use openhuman_embed::{Access, AgentSpec, Runtime, Workspace};++# async fn demo() -> Result<(), Box<dyn std::error::Error>> {+let runtime = Runtime::builder()+ .workspace(Workspace::dir("/var/lib/opencompany/openhuman"))+ .api_key(std::env::var("TINYHUMANS_API_KEY")?)+ .build()+ .await?;+let worker = runtime.agent(+ AgentSpec::new("worker-1")+ .access(Access::full())+ .action_dir("/srv/jobs/1"),+)?;+println!("{}", worker.run("Start the job.").await?.reply);+# Ok(())+# }+```+## Keep / drop tableThe single `default` list this session was written against no longer exists.diff --git a/gitbooks/developing/architecture/agent-harness.md b/gitbooks/developing/architecture/agent-harness.mdindex ed3ca3b837..3c6ea54870 100644--- a/gitbooks/developing/architecture/agent-harness.md+++ b/gitbooks/developing/architecture/agent-harness.md@@ -9,23 +9,54 @@ icon: layer-group## Embedding OpenHuman as a library-`openhuman_embed::Harness` builds one in-process core for a caller that supplies-its workspace, provider endpoint and credential, skills, MCP servers, and tool-policy. Such a harness identifies as `HostKind::Library`: inference does not-depend on OpenHuman app login, including inference-readiness checks for workflow-agent nodes. Backend features such as integrations and managed services still-need whatever identity their endpoint requires.--Build one harness and issue concurrent `run` or `turn(...).send()` calls on it;-do not build one core per agent. Each call owns a distinct session unless a-prior session id is supplied. The conversation store coordinates metadata per-workspace and message writes per thread, so independent agents do not serialize-on one process-wide store mutex.--`Workspace::Inherit` together with `Provider::inherit()` is deliberately not-library-routed inference. It borrows the installed OpenHuman configuration and-therefore keeps the installed application's session checks. Supply an explicit-provider when embedding without app login.+`openhuman_embed` exposes a two-step API. `Runtime::builder()` boots one+in-process core per process — background services, registered domain+families, backend URL and the TinyHumans API key — and `Runtime::agent(spec)`+instantiates any number of agents on it. Each `AgentSpec` fully describes+one agent: provider endpoint and model, access tier, `action_dir`, MCP+servers, skill bundles, system prompt, tool scope, sandbox mode, allowlists,+and a narrowed `DomainSet` / `ToolGroups`. A runtime identifies as+`HostKind::Library`: inference does not depend on OpenHuman app login,+including inference-readiness checks for workflow agent nodes.++Per-agent isolation is a context, not a second core. `Runtime::agent` clones+the runtime's base `Config`, applies the spec, and derives a child+`CoreContext` (`CoreContext::derive_with`) carrying that config, the agent's+domain set, tool groups and skill-root policy. Every turn is dispatched under+that context (`CoreRuntime::run_in` → `agent_chat_for` with an explicit+`AgentDefinition` and `AgentProfile`), so the config loader, the domain gate,+the tool-group filter and skill discovery all read the agent's own settings.+Transcripts are keyed by agent id and a turn resumes only its own thread.++Layout under a runtime-owned root: `<root>/config.toml` and the credential+store; `<root>/workspace/` with the session database, `session_raw/`+transcripts and each agent's `personalities/<id>/skills/`; and+`<root>/agents/<id>/action/` as each agent's default working root (a sibling+of the workspace, never inside it).++`Harness` is the one-agent shorthand: a runtime plus one agent named+`harness`. Build one runtime and issue concurrent `run` or `turn(...).send()`+calls on its agents; do not build one core per agent. Each call owns a+distinct session unless a prior session id is supplied.++Authentication in library mode is the TinyHumans API key+(`RuntimeBuilder::api_key`), stored as an `api-key` auth profile beside the+runtime's `config.toml`. Managed inference sends it as a bearer to the+OpenAI-compatible endpoint; backend REST calls send `x-api-key`; there is no+session JWT and nothing to expire. Agents that name their own `Provider`+(BYOK) never touch it. Backend features that need a signed-in user still+take `HarnessBuilder::session`.++`Workspace::Inherit` together with `Provider::inherit()` and no API key is+deliberately not library-routed inference. It borrows the installed+OpenHuman configuration and therefore keeps the installed application's+session checks. Supply an explicit provider or an API key when embedding+without app login.++Some settings remain runtime-wide for every agent (the live autonomy policy's+`auto_approve*`, the approval gate switch, the sub-agent catalogue, the+config sub-agents re-read); the crate README lists them under "Still+runtime-wide".> **Status (issue #4249, tinyagents migration):** the agent turn no longer runs> on the in-tree `run_turn_engine` loop. **All three entry points (`Agent::turn`,