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

+49 -1
View File
@@ -107,7 +107,55 @@ struct ProviderProbeTests {
#expect(foreignStatus == 502)
}
// MARK: Chat decode — the three SSE dialects
// MARK: Chat decode — the SSE dialects
// Scenario: Nous Portal decode — From user story #175
// Given the portal's OpenAI-compatible chat SSE (live-captured
// 2026-11-05: delta.content chunks, finish stop) and its bare
// {status, message} error envelope (no error object — a bad model id
// answers HTTP 404 + message)
// When the probe decodes a nous response
// Then content decodes works, and the error decodes requestFailed
// carrying the portal's own message — never a bare "HTTP 404".
@Test func `nous sse decodes works and the portal error envelope carries its message`() {
let sse = """
data: {"choices":[{"delta":{"content":"Hi there!"},"finish_reason":null}]}
data: {"choices":[{"delta":{},"finish_reason":"stop"}]}
data: [DONE]
"""
guard case .works = ProviderProbe.decodeChat(
provider: .nous, body: Data(sse.utf8), modelCount: 385, latencyMS: 900,
) else {
Issue.record("expected works over the portal SSE")
return
}
guard case let .requestFailed(status, detail) = ProviderProbe.decodeError(
status: 404,
body: probeData(
#"{"status":404,"message":"Model 'x' not found in our configuration."}"#,
),
provider: .nous,
) else {
Issue.record("expected requestFailed for the portal envelope")
return
}
#expect(status == 404)
#expect(detail.contains("not found"))
// Finish-audit #175: the fallback credential's own failure mode —
// 401 over the bare envelope decodes authFailed carrying the
// message (an expired/revoked agent_key).
guard case let .authFailed(authDetail) = ProviderProbe.decodeError(
status: 401,
body: probeData(#"{"status":401,"message":"token expired"}"#),
provider: .nous,
) else {
Issue.record("expected authFailed for the bare 401 envelope")
return
}
#expect(authDetail.contains("token expired"))
}
@Test func `zai sse content decodes works and empty length decodes starved`() {
let sse = """