Skip to content

fix: vanilla-agent onboarding — auth cast, available-models 404 fallback#265

Merged
outsourc-e merged 2 commits intomainfrom
fix/auth-cast-and-onboarding-issues
May 3, 2026
Merged

fix: vanilla-agent onboarding — auth cast, available-models 404 fallback#265
outsourc-e merged 2 commits intomainfrom
fix/auth-cast-and-onboarding-issues

Conversation

@outsourc-e
Copy link
Copy Markdown
Owner

Summary

Three small fixes that together unblock onboarding on a fresh pnpm install against vanilla nousresearch/hermes-agent (any version through 2026-05).

1. isAuthenticated() as unknown as Response cast was throwing 500 at runtime

isAuthenticated() returns boolean, not Response. The cast silenced the TypeScript error but threw HTTPError → 500 at runtime because the framework received false, not a Response. This broke /api/connection-status entirely on protected setups, preventing ONBOARDING_KEY from persisting on fresh installs.

PR #246 (just-merged) copied the same broken pattern into /api/system-metrics. Both now use the canonical pattern:

if (!isAuthenticated(request)) {
  return json({ error: 'Unauthorized' }, { status: 401 })
}

Refs #261 (which spotted the cast in connection-status.ts).

2. /api/claude-proxy/api/available-models returned 404 on vanilla agent

Vanilla hermes-agent doesn't expose /api/available-models — that's a legacy fork-only endpoint. Chat composer + settings dialog hit it expecting it to work, got 404, fell through to broken UI states where the provider model picker was empty.

Fix: when proxying GET /api/available-models and upstream returns 404, synthesize a compatible { models: [...] } response from /v1/models filtered by ?provider=.

3. claude-proxy bearer token wasn't honoring HERMES_API_TOKEN

Same fix that PR #234 applied to openai-compat-api.ts, now extended to the proxy path: read at request time, prefer HERMES_API_TOKEN, fall back to CLAUDE_API_TOKEN. Without this, deployments that follow the README's "set HERMES_API_TOKEN" instruction had the proxy 401 on every call.

Why this together

These three fixes share a common root cause: the migration from ClaudeHermes left behind a few thin layers (the auth cast pattern, the available-models legacy endpoint, env var precedence) that work on the dev machine but break the moment a new user tries to onboard against a clean vanilla agent.

Test plan

  • pnpm build clean
  • /api/connection-status no longer 500s on auth-protected setups
  • /api/claude-proxy/api/available-models?provider=openrouter falls back gracefully when upstream 404s

Refs

Resolves #263 partially (combined with PR #234 covers all bearer-token paths)
Refs #261 (auth cast pattern + provider model picker)

Aurora release bot added 2 commits May 3, 2026 09:36
…h proper 401

isAuthenticated() returns boolean. The previous pattern:

  const authResult = isAuthenticated(request)
  if (authResult !== true) return authResult as unknown as Response

silenced the TypeScript error but threw HTTPError -> 500 at runtime
because the framework received `false` instead of a Response. This
broke /api/connection-status entirely on protected setups (causing
ONBOARDING_KEY to never persist on fresh installs) and would have
broken the just-merged /api/system-metrics in the same way.

Replace with the canonical pattern used by every other API route:

  if (!isAuthenticated(request)) {
    return json({ error: 'Unauthorized' }, { status: 401 })
  }

Refs #261 (which spotted the pattern in connection-status), #246
(which copied the broken pattern into system-metrics).
…on vanilla agent

Vanilla hermes-agent (any version through 2026-05) does not expose
`/api/available-models` \u2014 that endpoint is legacy fork-only. The chat
composer + settings dialog hit `/api/claude-proxy/api/available-models`
expecting it to work, get 404, and fall through to broken UI states
where the model picker is empty.

Fix: when proxying GET /api/available-models and the upstream returns
404, synthesize a compatible `{ models: [...] }` response from
/v1/models filtered by ?provider= so the picker keeps working.

Also: read the bearer token at request time using the same precedence
as the rest of the codebase (HERMES_API_TOKEN || CLAUDE_API_TOKEN ||
module-level BEARER_TOKEN). PR #234 fixed this in openai-compat-api.ts;
this catches the proxy path that was missed.

Refs #261.
@outsourc-e outsourc-e merged commit 371ffb4 into main May 3, 2026
3 checks passed
@outsourc-e outsourc-e deleted the fix/auth-cast-and-onboarding-issues branch May 3, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat does not work - 401 error

1 participant