feat(settings): add Nous Portal provider (#175)
CI / ci (push) Canceled after 0s

Settings gains hermes' `nous` slug as a fourth provider on every
surface and the Provider Keys page — endpoint
https://inference-api.nousresearch.com/v1, NOUS_API_KEY, the
5-level OpenAI-compatible effort ladder, switch flagship
anthropic/claude-sonnet-5 (live-probed: the portal's docs-listed
Hermes-4 ids 404 — the inference API serves the OpenRouter catalog,
so the switch keeps the app's sonnet posture billed through Nous).
The probe speaks plain OpenAI chat-completions; an unkeyed test
borrows the shared Portal session's agent_key (the engine's own
credential — hermes' nous runtime is OAuth-only, and a portal key
and subscription bill the same account credits), gated to the
official https endpoint so the implicit credential never rides a
user-edited URL. Pass readiness rides the same fallback, so a
logged-in machine runs passes with no key. Suite 635.

Closes #175
This commit is contained in:
AlexKucera committed 2026-11-05 15:59:41 +01:00
1 parent d305f822aa
commit b2db859887
15 files changed
+410 -30

No files matched your search

+16 -2
View File
@@ -222,11 +222,14 @@ final class MentorSessionModel {
/// #137: a model-change restart requested mid-turn — fires at turn end
/// (firePendingRestartIfRequested), whichever engine streamed.
private var pendingRestart = false
/// #137 (S4): per-pass readiness (refreshPassReadiness, same-file #137
/// #137: per-pass readiness (refreshPassReadiness, same-file #137
/// extension) + the injectable read seam (tests). Stored in the class
/// body — extensions carry no stored state.
private(set) var passReadiness: [PassKind: PassReadiness] = [:]
var passReadinessWriter: (any SettingsWriting)?
/// #175: the shared Portal auth store for the nous keyless readiness
/// fallback — injectable so tests never read the machine's real login.
var portalAuthPath: String = PortalAuth.defaultAuthPath
/// The gate's winning binary path (no re-probe — map decision). Set by the
/// app when the gate passes; tests inject directly.
@@ -716,7 +719,18 @@ extension MentorSessionModel {
}
var keys: [ModelProvider: String] = [:]
for provider in Set(providers.values.compactMap(\.self)) {
keys[provider] = await (try? writer.readProviderKey(provider: provider)) ?? ""
var key = await (try? writer.readProviderKey(provider: provider)) ?? ""
// #175: nous runs on the shared Portal login — an empty `.env`
// key is not a blocker when the session's agent_key exists (the
// engine's own credential; API key and subscription bill the
// same account credits).
if provider == .nous, key.isEmpty {
let path = portalAuthPath
key = await Task.detached(priority: .utility) {
PortalAuth.sessionKey(authJSONPath: path) ?? ""
}.value
}
keys[provider] = key
}
for surface in [ProfileSurface.pass1, .pass2] {
let kind: PassKind = surface == .pass1 ? .pass1 : .pass2