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
feat(jev): add configurable Jev route with env-based key resolution
Steven Enamakelbbf9d00f5f50
diff --git a/crates/openhuman-tinyhumans/src/jev/mod.rs b/crates/openhuman-tinyhumans/src/jev/mod.rsindex aca893176b..6983e82509 100644--- a/crates/openhuman-tinyhumans/src/jev/mod.rs+++ b/crates/openhuman-tinyhumans/src/jev/mod.rs@@ -4,9 +4,11 @@//! tool and ranks searches with whatever ranker the process installed//! (`openhuman_core::agent::tinyagents::discovery`). This module installs//! [`TinyHumansJevRanker`]: `tinytools_jev::JevRanker` — BM25 retrieval to a-//! shortlist, one Jev `Choice` to decide — reached through the backend's-//! `/agent-integrations/openrouter/systemone` proxy with the same credential-//! every other backend call uses.+//! shortlist, one Jev `Choice` to decide — reached over the route+//! `agent.tool_search.jev_route` selects: the TinyHumans backend's+//! `/agent-integrations/openrouter/systemone` proxy (the default under `auto`+//! when a TinyHumans credential exists), TypeSafe's own API, or OpenRouter's+//! System One API (see `route`).//!//! The credential is resolved **per search**, not at install: a desktop//! signs in and out while the process runs, and a search must follow the@@ -17,9 +19,11 @@mod evaluator;mod ranker;+mod route;pub use evaluator::TinyJevEvaluator;pub use ranker::TinyHumansJevRanker;+pub use route::{JevRoute, OPENROUTER_API_KEY_ENV, TYPESAFE_API_KEY_ENV};use std::sync::Arc;diff --git a/crates/openhuman-tinyhumans/src/jev/ranker.rs b/crates/openhuman-tinyhumans/src/jev/ranker.rsindex 3ce45d5b39..0b2fb18c19 100644--- a/crates/openhuman-tinyhumans/src/jev/ranker.rs+++ b/crates/openhuman-tinyhumans/src/jev/ranker.rs@@ -9,17 +9,16 @@ use std::{use std::{future::Future, pin::Pin, sync::Arc, time::Duration};-use crate::backend::url::effective_backend_api_url;use openhuman_core::agent::tinyagents::discovery::{embedding_provider_is_usable, embedding_tool_ranker,};use openhuman_core::config::Config;-use openhuman_core::security::credentials::session_support::resolve_backend_credential;-use tinyjevclient::{Client, ClientConfig};+use tinyjevclient::Client;use tinytools::{RankCandidate, RankContext, RankError, RankHit, ToolRanker};use tinytools_jev::{JevRanker, JevRankerConfig, JevStrategy};use super::evaluator::TinyJevEvaluator;+use super::route::{self, EnvLookup};/// How the ranker reads the config a search runs under. The default is the/// core's own read path (the embedder's config when one is bound, else the@@ -27,11 +26,17 @@ use super::evaluator::TinyJevEvaluator;pub type ConfigLoader =Arc<dyn Fn() -> Pin<Box<dyn Future<Output = Result<Config, String>> + Send>> + Send + Sync>;-/// A [`JevRanker`] bound to whichever credential and backend the process has-/// at search time.+/// Where the ranker reads the two env-provided Jev keys. The default is the+/// process environment; a test hands in a fixed table.+pub type EnvLoader = Arc<dyn Fn(&str) -> Option<String> + Send + Sync>;++/// A [`JevRanker`] bound to the Jev route the config selects+/// (`agent.tool_search.jev_route`) and the credential for it, resolved at+/// search time.pub struct TinyHumansJevRanker {config: JevRankerConfig,load_config: ConfigLoader,+ env: EnvLoader,/// Deadline for one evaluation. Measured through the TinyHumans proxy/// (2026-09) one evaluation takes 0.7–1.9 s at p50 and the family/// strategy runs its second-stage evaluations concurrently, so six@@ -84,11 +89,19 @@ impl TinyHumansJevRanker {load_config: Arc::new(|| {Box::pin(openhuman_core::config::ops::load_config_with_timeout())}),+ env: Arc::new(route::process_env),deadline: DEFAULT_DEADLINE,cached: Mutex::new(None),}}+ /// Reads `TYPESAFE_API_KEY` / `OPENROUTER_API_KEY` through `env` instead of+ /// the process environment.+ pub fn with_env_loader(mut self, env: EnvLoader) -> Self {+ self.env = env;+ self+ }+/// Sets the per-evaluation deadline.pub fn with_deadline(mut self, deadline: Duration) -> Self {self.deadline = deadline;@@ -114,14 +127,11 @@ impl TinyHumansJevRanker {.map_err(|error| RankError::Backend {reason: format!("config unavailable: {error}"),})?;- let credential = resolve_backend_credential(&config).map_err(|reason| {- // The message names what is missing, never a secret.- RankError::Backend {- reason: format!("no TinyHumans credential ({reason})"),- }- })?;- let base_url = effective_backend_api_url(&config.api_url);- let fingerprint = fingerprint(credential.secret(), &base_url);+ let env: EnvLookup<'_> = &*self.env;+ let resolved = route::resolve(&config, env)?;+ let base_url = resolved.client.base_url.clone();+ let route_label = resolved.route.label();+ let fingerprint = fingerprint(&format!("{route_label}:{}", resolved.secret), &base_url);let mut cached = self.cached@@ -133,8 +143,7 @@ impl TinyHumansJevRanker {{return Ok(entry.ranker.clone());}- let mut client_config = ClientConfig::tinyhumans_openrouter(credential.into_secret());- client_config.base_url = base_url.clone();+ let client_config = resolved.client;let client = Client::new(client_config).map_err(|error| RankError::invalid_input(error.to_string()))?;let evaluator: Arc<dyn tinytools_jev::JevEvaluator> =@@ -152,7 +161,7 @@ impl TinyHumansJevRanker {self.config.clone().with_retriever(retriever.clone()),);log::info!(- "[tool-search] jev ranker bound to backend {} ({})",+ "[tool-search] jev ranker bound to route={route_label} backend {} ({})",openhuman_core::util::redact::redact_url_for_log(&base_url),if fingerprint_changed(cached.as_ref(), fingerprint) {"credential or backend changed"