Skip to content

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

docs(backend, credentials): update READMEs for channel-message 404 classification and OAuth client-k

Steven Enamakel70a3cce2acaa
diff --git a/crates/openhuman-core/src/backend/README.md b/crates/openhuman-core/src/backend/README.md
index dfc54f88a6..0e67748d15 100644
--- a/crates/openhuman-core/src/backend/README.md
+++ b/crates/openhuman-core/src/backend/README.md
@@ -59,7 +59,13 @@ host attributes traffic to; both are empty/default without a transport.
JSON body, the `BackendCredential` (session JWT → `Authorization: Bearer`,
API key → `x-api-key`) and whether the `{success,data}` envelope is unwrapped.
`BackendTransportError` mirrors the variants the classifiers match on
-(`Http`, `Status`, `Envelope`, `RouteNotExposed`, …) plus `Unavailable`.
+(`Http`, `Status`, `Envelope`, `RouteNotExposed`, …) plus `Unavailable`, and
+the two backend-specific 404 meanings the transport classifies for the core:
+`ChannelMessageNotFound` (a handler says the message is gone) and
+`ChannelMessageRouteMissing` (no route matched — today every `PATCH` edit,
+#5230). The core never inspects a response body to tell them apart; that
+wire knowledge lives in `tinyhumans_sdk::classify` and is applied by
+`openhuman-tinyhumans`'s `map_sdk_error`.
Resolution (`resolve_backend_transport`), first hit wins: the transport bound
to the ambient `CoreContext` (`CoreBuilder::backend_transport`, inherited by
@@ -79,11 +85,11 @@ surface:
- `authed_json` — send an authenticated request and route the result through
`finish_authed_json`.
-- Typed route helpers (`fetch_client_key`, `send_channel_*`,
- `*_channel_thread`) all go through `authed_json` and are bearer-only: the
- core never obtains, exchanges or validates a session. The account-bound
- routes (link tokens, `/auth/me` link checks, OAuth connect / integrations,
- billing, team, webhook tunnels, announcements) are called by
+- Typed route helpers (`send_channel_*`, `*_channel_thread`) all go through
+ `authed_json` and are bearer-only: the core never obtains, exchanges or
+ validates a session. The account-bound routes (link tokens, `/auth/me`
+ link checks, OAuth connect / integrations / client-key handoff, billing,
+ team, webhook tunnels, announcements) are called by
`openhuman-tinyhumans` (`hosted/`) on the TinyHumans SDK's typed clients.
- `url_for`, `raw_client` — URL helpers for callers that need to drive a
non-JSON request (e.g. multipart uploads) without re-implementing TLS/proxy
@@ -108,8 +114,10 @@ The private `BackendClient::finish_authed_json` is the error classification
chokepoint for every `authed_json` 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. `IntegrationClient::map_transport_error`
+reporting, maps a `401` onto `Unauthorized` / `ApiKeyRejected` by the
+credential kind, and maps the transport's typed channel-message 404s onto
+`MessageNotFound` / `ChannelEditUnsupported`. The recovery each variant
+implies is the core's; what a backend response *means* is the transport's. `IntegrationClient::map_transport_error`
(`integrations/client/errors.rs`) plays the same role for integrations.
Route new backend calls through those helpers instead of matching
`BackendTransportError` by hand.
@@ -147,9 +155,13 @@ and telemetry.
## Tests
`client_tests.rs` covers `BackendClient::new` base stripping, `authed_json`
-401/404 classification into `BackendApiError` (including the route-absence
-vs message-gone split for channel edits), `flatten_authed_error`, and
-`backend_api_body_shape`. Transient-transport classification is not unit
+401 classification into `BackendApiError`, `flatten_authed_error`, and
+`backend_api_body_shape`. `client_channel_tests.rs` covers the channel route
+shapes and, with a stub transport, the mapping of the typed channel-message
+404s onto `MessageNotFound` / `ChannelEditUnsupported`. The 404 wire
+classification itself is tested where it lives:
+`vendor/tinyhumans-sdk/tests/classify.rs` and
+`crates/openhuman-tinyhumans/src/transport/channel_404_tests.rs`. Transient-transport classification is not unit
tested here; it relies on
`core::observability::contains_transient_transport_phrase`. `transport/`
carries its own tests (`transport_tests.rs`, `mod_tests.rs`); `classify.rs`
diff --git a/crates/openhuman-core/src/security/credentials/README.md b/crates/openhuman-core/src/security/credentials/README.md
index 19466162aa..284827eba1 100644
--- a/crates/openhuman-core/src/security/credentials/README.md
+++ b/crates/openhuman-core/src/security/credentials/README.md
@@ -24,7 +24,7 @@ Credential management for the backend credential the core authenticates with and
| `core.rs` | `AuthService` facade over `AuthProfilesStore` — store/get/remove/set-active profiles, resolve bearer token, profile-id selection logic (override → active → default → any-for-provider), provider normalization, state-dir derivation. |
| `profiles.rs` | The persistence engine. `AuthProfile` / `TokenSet` / `AuthProfileKind` / `AuthProfilesData` types and `AuthProfilesStore` — atomic JSON read/write, keychain vs encrypted-JSON secret handling, legacy migration, corrupt-store quarantine, PID-aware stale-lock recovery. |
| `api_key.rs` | The `api-key` profile: `store_api_key[_in]`, `get_api_key[_in]`, `has_api_key[_in]`, `clear_api_key`. |
-| `ops.rs` + `ops/` | Business logic + RPC entry points (returns `RpcOutcome<T>`). `ops/credential.rs` (`set_credential` / `clear_credential`, plus the historical `store_session` / `clear_session` names), `ops/user_scope.rs` (user-dir activation and process-global rebinding), `ops/gated_services.rs` (credential-gated services), `ops/boot_env.rs` (env seeding), `ops/session_query.rs` (`auth_get_state`, `auth_get_session_token_json`), `ops/oauth.rs` (`oauth_fetch_client_key` only — its route has no SDK method yet), `ops/provider_credentials.rs`, `ops/composio.rs`, `ops/secrets.rs`. Re-exported as `rpc`. |
+| `ops.rs` + `ops/` | Business logic + RPC entry points (returns `RpcOutcome<T>`). `ops/credential.rs` (`set_credential` / `clear_credential`, plus the historical `store_session` / `clear_session` names), `ops/user_scope.rs` (user-dir activation and process-global rebinding), `ops/gated_services.rs` (credential-gated services), `ops/boot_env.rs` (env seeding), `ops/session_query.rs` (`auth_get_state`, `auth_get_session_token_json`), `ops/provider_credentials.rs`, `ops/composio.rs`, `ops/secrets.rs`. Re-exported as `rpc`. |
| `schemas.rs` | `auth.*` controller schemas + `handle_*` dispatchers delegating to `ops`. Defines `all_controller_schemas` / `all_registered_controllers`. |
| `session_support.rs` | `CredentialKind`, `BackendCredential`, `resolve_backend_credential`, `require_live_session_token`, `has_backend_credential`, `build_session_state`, `get_session_token`, `load_app_session_profile`, `user_id_from_jwt_claims`, local-session detection/slug, field parsing. Shared by RPC and the HTTP host. |
| `identity.rs` | The signed-in user's identity slot (`peek_credential_user_identity`), seeded from the host-supplied payload for prompts and Sentry. |
@@ -40,7 +40,7 @@ Credential management for the backend credential the core authenticates with and
- **Credential kinds** — `session_support::CredentialKind {Session, ApiKey, Local}` (wire values `"session"`, `"api-key"`, `"local"`). `session_support::resolve_backend_credential` returns `BackendCredential::ApiKey` when a key 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. Every backend caller goes through it (integrations, voice, channels, webhooks, hosted proxies); bearer-only seams (connector proxy route, memory-host `SessionBearer`, the Socket.IO handshake) use `backend_bearer_secret`, which returns the key first and the stored session otherwise — the backend accepts a key as `Authorization: Bearer` by its `tiny_` prefix. Cloud embeddings mirror `resolve_bearer`. `has_backend_credential` is the boot-time "signed in?" question the scheduler gate asks; `SessionExpired` is ignored for an API-key runtime and for a local session.
- **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`) — `set_credential`, `clear_credential`, `store_session`, `clear_session`, `SetCredentialRequest`, `seed_api_key_from_env`, `seed_session_from_env`, `auth_get_state`, `auth_get_session_token_json`, `store_provider_credentials`, `remove_provider_credentials`, `list_provider_credentials`, `list_provider_credentials_by_prefix`, `oauth_fetch_client_key`, `encrypt_secret`, `decrypt_secret`, `start_credential_gated_services`, `stop_credential_gated_services`.
+- **Ops/RPC** (`ops`, re-exported as `rpc`) — `set_credential`, `clear_credential`, `store_session`, `clear_session`, `SetCredentialRequest`, `seed_api_key_from_env`, `seed_session_from_env`, `auth_get_state`, `auth_get_session_token_json`, `store_provider_credentials`, `remove_provider_credentials`, `list_provider_credentials`, `list_provider_credentials_by_prefix`, `encrypt_secret`, `decrypt_secret`, `start_credential_gated_services`, `stop_credential_gated_services`.
- **Composio-direct** — `store_composio_api_key`, `get_composio_api_key`, `clear_composio_api_key`, `rpc_store_composio_api_key`.
- **Backend re-exports** — `crate::backend::BackendClient` and `jwt::user_id_from_profile_payload`. The OAuth connect/handoff types (`IntegrationSummary`, `IntegrationTokensHandoff`) and `decrypt_handoff_blob` moved to `crates/openhuman-tinyhumans/src/hosted/oauth/` with the OAuth flows themselves.
- **Schema controllers** — `all_credentials_controller_schemas`, `all_credentials_registered_controllers`.
@@ -58,7 +58,6 @@ Namespace `auth` (JSON-RPC `openhuman.auth_*` / CLI `openhuman-core auth <functi
| `auth_store_provider_credentials` | Store provider credentials for a profile. |
| `auth_remove_provider_credentials` | Remove provider credentials. |
| `auth_list_provider_credentials` | List stored provider credentials (optional provider filter). |
-| `auth_oauth_fetch_client_key` | Fetch one-time client key share for an encrypted integration. |
The account-bound `auth` methods `auth_create_channel_link_token`, `auth_oauth_connect`, `auth_oauth_list_integrations`, `auth_oauth_fetch_integration_tokens` and `auth_oauth_revoke_integration` keep their wire names but are served by `openhuman-tinyhumans` (`hosted::{channel_link, oauth}`, on the TinyHumans SDK), registered only when `openhuman_tinyhumans::install` runs.