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/api/README.md,crates/openhuman-core/src/config/schema

Steven Enamakel0ff74de48627
diff --git a/crates/openhuman-core/src/api/README.md b/crates/openhuman-core/src/api/README.md
index e2c81b3936..0a9f8b8848 100644
--- a/crates/openhuman-core/src/api/README.md
+++ b/crates/openhuman-core/src/api/README.md
@@ -14,6 +14,7 @@ backend. Route implementations themselves live in
| `jwt.rs` | Session-token load and `Authorization` header formatting |
| `product.rs` | `x-sdk-name` product-attribution header |
| `rest.rs` | `BackendOAuthClient`, typed `BackendApiError`, and the error-classification chokepoint |
+| `rest_tests.rs` | Tests for `rest.rs` (included via `#[path]`) |
| `socket.rs` | Socket.IO (Engine.IO v4) WebSocket URL construction |
| `models/` | Serde DTOs shared across auth and realtime call sites |
@@ -24,41 +25,59 @@ or an LLM inference endpoint. Two families are resolved separately because a
`config.api_url` pointed at a local model runner (Ollama, vLLM, LM Studio)
only speaks `/v1/chat/completions` and 404s on every other path:
-- `effective_api_url` / `effective_inference_url` — chat/inference base,
- falling back through `config.api_url` → `BACKEND_URL`/`VITE_BACKEND_URL` env
- → compile-time `option_env!` → environment default.
+- `effective_api_url` — chat/inference base: non-empty `config.api_url` →
+ `BACKEND_URL`/`VITE_BACKEND_URL` runtime env → the same keys baked in via
+ `option_env!` → environment default. `effective_inference_url` returns an
+ explicit `inference_url` override verbatim, otherwise joins
+ `OPENHUMAN_INFERENCE_PATH` (`/openai/v1/chat/completions`) onto
+ `effective_api_url`.
- `effective_backend_api_url` — base for all control-plane calls (auth,
billing, team, integrations, voice, sockets, …). Skips the user's
- `api_url` override when it `looks_like_local_ai_endpoint` or
- `looks_like_inference_provider_endpoint` and is not the OpenHuman backend
- itself, so pointing `api_url` at Ollama or `openrouter.ai` doesn't also
- misroute `/teams/me/usage` and billing calls there.
-- `normalize_api_base_url` — strips path/query/fragment so relative joins
- resolve correctly.
+ `api_url` override when it `looks_like_local_ai_endpoint`,
+ `looks_like_inference_provider_endpoint`, or resolves to a builtin cloud
+ provider host (`config::schema::cloud_providers`) and is not the OpenHuman
+ backend itself, so pointing `api_url` at Ollama or `openrouter.ai` doesn't
+ also misroute `/teams/me/usage` and billing calls there. Falls through the
+ same env/default chain, passed through `normalize_backend_api_base_url`
+ (`pub(crate)`) which strips an inference-style path from a misconfigured
+ `BACKEND_URL`.
+- `normalize_api_base_url` — trims whitespace and trailing slashes only; it
+ is a cheap string operation with no URL parsing. `api_url(base, path)` is
+ the matching join helper.
- `DEFAULT_API_BASE_URL` (`https://api.tinyhumans.ai`) /
- `DEFAULT_STAGING_API_BASE_URL`, selected via `OPENHUMAN_APP_ENV` /
- `VITE_OPENHUMAN_APP_ENV` (`api_base_from_env`).
+ `DEFAULT_STAGING_API_BASE_URL` (`https://staging-api.tinyhumans.ai`),
+ chosen by `default_api_base_url_for_env` from `app_env_from_env`, which
+ reads `OPENHUMAN_APP_ENV` / `VITE_OPENHUMAN_APP_ENV` (`APP_ENV_VAR` /
+ `VITE_APP_ENV_VAR`) at runtime, then compile time. `api_base_from_env` is
+ the separate `BACKEND_URL` / `VITE_BACKEND_URL` lookup; both check each key
+ independently so an empty primary never shadows the secondary.
- `looks_like_local_ai_endpoint` / `looks_like_inference_provider_endpoint` —
heuristics documented in-file; both are intentionally tight to avoid
misclassifying real custom backends or ephemeral test mock servers.
## `jwt.rs`
-`get_session_token` reads the current session token out of the credentials
-store (`crate::security::credentials`). Token *parsing* and header
+`get_session_token` is a re-export of
+`crate::security::credentials::session_support::get_session_token` (with
+`APP_SESSION_PROVIDER` and `DEFAULT_AUTH_PROFILE_NAME`), so callers keep one
+import path for "where the token lives". Token *parsing* and header
*formatting* — `bearer_authorization_value`, `decode_jwt_payload` — are
re-exported from `tinyhumans_sdk::jwt` rather than reimplemented, since they
are properties of the backend's token format that every host needs.
`decode_jwt_exp` wraps the SDK's Unix-seconds `exp` decoder in the `chrono`
type the credentials store uses, so an expired token can be rejected locally
-instead of round-tripping to a guaranteed 401.
+instead of round-tripping to a guaranteed 401. It does not verify the
+signature; the backend stays the authority.
## `product.rs`
`ProductIdentity` / `set_product_identity` attach a sanitized `x-sdk-name`
header (`PRODUCT_IDENTITY_HEADER`) to every backend-bound request, so the
backend can attribute calls to OpenHuman, OpenCompany, or Medulla even though
-all three share one login and reach the backend through this crate. The
+all three share one login and reach the backend through this crate.
+`ProductIdentity::new` keeps ASCII alphanumerics plus `.`, `_`, `-`,
+lower-cases, truncates to 64 bytes, and returns `None` when nothing survives,
+so the wrapped value can never break `HeaderValue` construction. The
identity is process-wide (a `OnceLock<RwLock<ProductIdentity>>`), not a
constructor parameter, because `BackendOAuthClient` is built at dozens of
call sites across domains. **Call `set_product_identity` once at startup,
@@ -75,16 +94,24 @@ serializes them to avoid cross-module races.
## `rest.rs`
`BackendOAuthClient` wraps `tinyhumans_sdk::TinyHumansClient` with an
-OpenHuman-configured `reqwest::Client` (product-identity default headers,
-normalized base URL). Key surface:
+OpenHuman-configured `reqwest::Client` (`x-core-version`, optional
+`x-tauri-version`, and `x-sdk-name` default headers; platform TLS via
+`util::tls`; base URL stripped to its origin). Key surface:
- `authed_json` / `fetch_billing_summary` — send an authenticated request and
route the result through `finish_authed_json`.
+- Typed route helpers (`fetch_current_user`, `create_channel_link_token`,
+ `list_integrations`, `fetch_integration_tokens_handoff`, `fetch_client_key`,
+ `send_channel_*`, `*_channel_thread`, `revoke_integration`) all go through
+ `authed_json`. `consume_login_token` is the exception: it calls the SDK's
+ typed `auth()` API directly.
- `connect`, `login_url`, `url_for`, `raw_client` — OAuth connect flow and
URL helpers for callers that need to drive a non-JSON request (e.g.
multipart uploads) without re-implementing TLS/proxy setup.
- `ConnectResponse`, `IntegrationSummary`, `IntegrationTokensHandoff` — typed
backend response shapes.
+- `user_id_from_auth_me_payload` / `user_id_from_profile_payload` — pull the
+ user id out of the `/auth/me` envelope variants.
- `decrypt_handoff_blob` — AES-256-GCM decrypt for integration token handoff,
compatible with the backend's `encryptMessageFromString`.
@@ -103,8 +130,10 @@ classification chokepoint for every `authed_json`/`fetch_billing_summary`
call: it walks the `reqwest`/`hyper`/`rustls` error source chain (not just the
top-level message) to distinguish a transient transport failure from one
worth reporting, and turns specific status/path combinations into the typed
-`BackendApiError` variants above. There is no separate `classify_sdk_error`
-function — this method is the equivalent chokepoint.
+`BackendApiError` variants above. `IntegrationClient::map_sdk_error`
+(`integrations/client_part_01.rs`) plays the same role for integrations.
+Route new SDK calls through those helpers instead of matching
+`tinyhumans_sdk::Error` by hand.
## `socket.rs`
@@ -119,7 +148,8 @@ see [`models/mod.rs`](models/mod.rs) for the full list.
## Backend request rules (from `AGENTS.md`)
-- Add missing backend routes to `vendor/tinyhumans-sdk`, not to `src/api/`.
+- Add missing backend routes to `vendor/tinyhumans-sdk`, not to
+ `crates/openhuman-core/src/api/`.
- Every TinyHumans backend request must carry a sanitized `x-sdk-name`:
`BackendOAuthClient`, `IntegrationClient` (except redirected file
downloads), `MedullaClient` (including its separate SSE handshake),
@@ -131,16 +161,24 @@ see [`models/mod.rs`](models/mod.rs) for the full list.
## Called by
-77 files under `crates/openhuman-core/src` reference `crate::api::`. Heaviest
-consumers: `platform/socket/` (realtime client), `hosted/*` (billing,
-referral, announcements, team), `medulla/client/`, `integrations/` and
-`integrations/composio/`, `channels/controllers/` and `channels/bus*.rs`,
-`security/credentials/` (token storage feeding `jwt::get_session_token`), and
+74 files outside `api/` reference `crate::api::`
+(`grep -rl 'crate::api::' crates/openhuman-core/src`). Heaviest consumers:
+`platform/socket/` (realtime client), `hosted/*` (billing, referral,
+announcements, team), `medulla/client/`, `integrations/` and
+`integrations/composio/`, `channels/controllers/ops/` and
+`channels/bus_part_*.rs` (which match on `BackendApiError` variants),
+`security/credentials/` (defines the `get_session_token` that `jwt.rs`
+re-exports; consumes `BackendOAuthClient`, `flatten_authed_error`,
+`decode_jwt_exp`, and re-exports the OAuth types), `voice/`,
+`agent/progress_tracing/` (Langfuse ingestion URL and `x-sdk-name`), and
`inference/provider/`, `inference/embeddings/`, `inference/voice/` (backend
inference proxy and cloud transcription/embeddings).
## Tests
-`rest_tests.rs` covers `BackendOAuthClient`, `BackendApiError` classification,
-and `decrypt_handoff_blob`. `jwt.rs` and `product.rs` carry their own
-`#[cfg(test)]` modules.
+`rest_tests.rs` covers `BackendOAuthClient::new` base stripping,
+`finish_authed_json` classification (transport vs status, 401/404 typed
+errors), `flatten_authed_error`, `user_id_from_*_payload`,
+`sanitize_client_version`, `backend_api_body_shape`, and
+`decrypt_handoff_blob`. `config.rs`, `jwt.rs`, `product.rs`, and `socket.rs`
+carry their own `#[cfg(test)]` modules.
diff --git a/crates/openhuman-core/src/config/schemas/mod.rs b/crates/openhuman-core/src/config/schemas/mod.rs
index b2643cf104..9b1fd4ab74 100644
--- a/crates/openhuman-core/src/config/schemas/mod.rs
+++ b/crates/openhuman-core/src/config/schemas/mod.rs
@@ -1,18 +1,22 @@
//! Controller schemas and thin RPC handlers for the `config` namespace.
//!
//! `all_controller_schemas` / `all_registered_controllers` are re-exported from
-//! `config::mod` as `all_config_controller_schemas` / `all_config_registered_controllers`
-//! and wired into the global registry in `core/all.rs`. Handlers here are thin:
-//! they deserialize params, delegate to `config::ops` (re-exported as `config::rpc`)
-//! for the actual mutation/read, and shape the `RpcOutcome` response.
+//! `config::mod` as `all_config_controller_schemas` / `all_config_registered_controllers`;
+//! `core/all.rs` registers the latter under `DomainGroup::Config` (the schema-only
+//! list is consumed by tests). Handlers here are thin: they deserialize params,
+//! delegate to `config::ops` (re-exported as `config::rpc`) for the actual
+//! mutation/read, and shape the `RpcOutcome` response.
//!
//! - `controllers.rs` — `include!`s `controllers_part_01.rs` / `controllers_part_02.rs`
//! (split for file-size only; together they define every handler and the
//! `all_controller_schemas` / `all_registered_controllers` lists).
//! - `helpers.rs` — param-deserialization update structs (`*SettingsUpdate`,
//! `*Params`) and small JSON helpers (`deserialize_params`, `to_json`, etc.).
-//! - `schema_defs.rs` — the `ControllerSchema` definitions looked up by name
-//! via `schemas(function)`.
+//! - `schema_defs.rs` — `schemas(function)`, the by-name `ControllerSchema`
+//! lookup, dispatching to the `schemas_schema_part_01.rs` /
+//! `schemas_schema_part_02.rs` `#[path]` submodules that hold the definitions.
+//!
+//! Tests: `../schemas_tests.rs` (mounted below) and `controllers_tests.rs`.
//!
//! Methods exposed under `config.*`: `get_config`, `get_client_config`,
//! `update_model_settings`, `update_memory_settings`, `update_runtime_settings`,
diff --git a/scripts/ci/README.md b/scripts/ci/README.md
index e9d505a325..d3d73daf3a 100644
--- a/scripts/ci/README.md
+++ b/scripts/ci/README.md
@@ -1,7 +1,7 @@
# `scripts/ci/`
-Merge-gate scripts run by `.github/workflows/ci-lite.yml` and `ci-full.yml`,
-plus the data files some of them read. Each script's header comment is the
+Merge-gate scripts run by `.github/workflows/ci-lite.yml` (the PR lane), plus
+the data files some of them read. Each script's header comment is the
authoritative spec; this is an index so a CI failure log points somewhere.
| File | Checks |
@@ -15,7 +15,7 @@ authoritative spec; this is an index so a CI failure log points somewhere.
| `rust-coverage-changed.sh` | PR fast-lane: runs `cargo-llvm-cov` scoped to only the domains/tests a PR touched instead of the full suite, and escalates to the full suite when scoping selects zero tests. |
| `vitest-changed-coverage.sh` | Frontend counterpart — runs `vitest related` against changed files instead of the full unit suite. |
| `assert-coverage-presence.sh` + `coverage-presence-allowlist.txt` | Fails when a changed Rust file produced no lcov records at all, meaning no lane even compiled it (openhuman#5593). Allowlist entries must document, inline, which gate excludes the file and why that's intended. |
-| `list-feature-gated-rust-tests.mjs` | Enumerates tests under `crates/openhuman-core/src` gated behind a Cargo feature, for cross-checking against what the coverage lanes actually exercise. |
+| `list-feature-gated-rust-tests.mjs` | Prints every file under `crates/openhuman-core/src` that carries tests behind a product feature gate (`voice`, `media`, `web3`, `meet`, `mcp`, `skills`, `flows`, `channels`, `contacts`). `ci-lite.yml`'s feature-gate smoke lane diffs the output against a checked-in EXPECTED list so a new gated test file forces the scoped `cargo test` filter to be extended (#5022). |
| `orch-ip-gate.sh` | Blocks the server-side orchestration "brain" (reasoning/wake graph, its prompts, per-agent model-selection metadata) from re-entering this open client repo. |
`rust-coverage-changed.sh` and `vitest-changed-coverage.sh` both feed the PR
@@ -26,10 +26,12 @@ CI Gate's changed-line diff-cover check (>= 80%) in `ci-lite.yml`.
Only `check-openhuman-rust-layout.mjs` is wired to a pnpm script
(`pnpm rust:layout`); the rest are invoked directly, e.g.
`node scripts/ci/check-feature-forwarding.mjs` or
-`bash scripts/ci/orch-ip-gate.sh`, and can be run the same way locally. All of
-them are invoked from `.github/workflows/ci-lite.yml` and, for the full
-suites, `ci-full.yml` — grep those workflows for a script's name to see its
-exact invocation and any required environment.
+`bash scripts/ci/orch-ip-gate.sh`, and can be run the same way locally. Every
+gate here runs from `.github/workflows/ci-lite.yml`; `ci-full.yml` does not
+call any of them, and only reaches `product-features.sh` indirectly through
+`test-reusable.yml`. Grep `ci-lite.yml` for a script's name to see its exact
+invocation and any required environment (the coverage scripts read `FULL` and
+`CHANGED_FILES` from the workflow's paths-filter step).
Long-running CI commands (the coverage lanes) go through
`scripts/ci-cancel-aware.sh`, which lives directly under `scripts/`, not here.