openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

feat(providers): add OrcaRouter as built-in cloud provider

Open xilema2 opened this issue 6 months ago • 1 comments

Summary

  • Add OrcaRouter as a built-in slug alongside openai / anthropic / openrouter / custom in the AI Settings panel.
  • Wire https://api.orcarouter.ai/v1 + Bearer auth as the default endpoint / auth style, mirroring how OpenRouter is handled today.
  • Migrate legacy type = "orcarouter" config entries to the new slug-keyed shape (label, endpoint, auth_style) via the existing migrate_legacy_fields path.
  • Whitelist provider.orcarouter in the proxy service-key list so users can route OrcaRouter calls through a configured proxy.
  • Unit tests: factory builds orcarouter:<model> against an OrcaRouter cloud_providers entry; legacy type = orcarouter entry produces the correct slug / label / endpoint / auth_style.

Problem

OpenHuman already supports OpenAI-compatible multi-provider routers (e.g. OpenRouter) as first-class chips in the AI Settings panel, but OrcaRouter is not in the built-in list. Today a user has to add it as a custom provider and re-enter its endpoint each time, which loses the consistency the panel offers for other well-known meta-routers.

OrcaRouter is OpenAI-API-compatible (Authorization: Bearer … at https://api.orcarouter.ai/v1), so the work needed is purely metadata + UI surfacing — no new transport code, no new auth style.

Solution

  • src/openhuman/config/schema/cloud_providers.rs
    • Add "orcarouter" to legacy_label_for (→ "OrcaRouter") and legacy_default_endpoint (→ https://api.orcarouter.ai/v1).
    • Add Orcarouter to the legacy CloudProviderType enum and the three small match arms (default_endpoint, label, as_str). auth_style() falls through the existing catch-all to AuthStyle::Bearer.
  • src/openhuman/config/schema/proxy.rs — add "provider.orcarouter" to SUPPORTED_PROXY_SERVICE_KEYS.
  • src/openhuman/config/schema/types.rs — extend the provider-grammar doc-comment.
  • src/openhuman/inference/provider/factory_test.rs — add orcarouter_slug_model (builds orcarouter:orcarouter/auto against a config entry) and orcarouter_legacy_type_seeds_defaults (migration produces correct slug / label / endpoint / auth).
  • app/src/components/settings/panels/AIPanel.tsx
    • Add orcarouter to BUILTIN_PROVIDER_META (display label + chip tone).
    • Include orcarouter in the three slug arrays used for chip rendering, the default-slug picker, and the AddProvider/EditProvider <select>.
    • Add an API-key placeholder branch for orcarouter.
    • Extend defaultEndpointFor('orcarouter') → https://api.orcarouter.ai/v1.
  • app/src/utils/tauriCommands/config.ts — extend the legacy CloudProviderType union with 'orcarouter'.

No changes to provider transport, no new RPC, no protocol changes.

Submission Checklist

  • [x] Tests added or updated (happy path + at least one failure / edge case) — two new Rust tests in factory_test.rs (happy-path slug routing + legacy-config migration).
  • [x] Diff coverage ≥ 80% — every new/changed line in Rust is covered by the two new factory_test cases or by the existing AIPanel.test.tsx suite. Will be confirmed by CI.
  • [x] Coverage matrix updated — N/A: behaviour-only addition (one extra built-in slug option in an existing surface).
  • [x] All affected feature IDs from the matrix are listed in the PR description under ## Related — N/A: see above.
  • [x] No new external network dependencies introduced — endpoint is exercised only through the existing OpenAI-compatible code path; tests don't hit the network.
  • [x] Manual smoke checklist updated if this touches release-cut surfaces — N/A: additive built-in option in AI Settings, no release-cut surface change.
  • [x] Linked issue closed via Closes #NNN in the ## Related section — N/A: no linked issue.

Impact

  • Runtime: desktop only (the only shipped target). Frontend gains one extra chip + dropdown option; Rust core gains one extra match arm. No migrations, no persistence changes — cloud_providers is already user-extensible.
  • Compatibility: existing user configs with type = "openrouter" or any other slug are untouched. Users who had previously added OrcaRouter manually as custom are unaffected (custom entries keep working).
  • Security: API keys still live in auth-profiles.json via AuthService, keyed by provider:orcarouter, identical to the other slug-keyed entries. No new secret-handling code path.

Related

  • Closes: N/A
  • Follow-up PR(s)/TODOs: none

AI Authored PR Metadata

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: feat/orcarouter-provider
  • Commit SHA: 75153c38 (tip; 68b01f6f main change + 75153c38 prettier wrap)

Validation Run

  • [x] pnpm typecheck — pass (tsc --noEmit on app/)
  • [x] pnpm lint — pass (0 errors on changed files; 46 pre-existing warnings in untouched files)
  • [x] prettier --check on changed files — pass
  • [x] Vitest AIPanel.test.tsx — 15 / 15 passed
  • [x] cargo check --lib — pass (Rust 1.93.0 MSVC)
  • [x] cargo test factory — 32 / 32 passed, including the two new orcarouter_* cases
  • [x] cargo test cloud_providers — 2 / 2 passed
  • [x] cargo fmt --check on changed files — pass

Validation Blocked

  • command: git push (pre-push husky hook)
  • error: Pre-push hook runs prettier --write . (would reformat ~858 unrelated files repo-wide that are already prettier-dirty on main) and pnpm rust:format (cargo not on the hook's PATH in this shell). Both failures are unrelated to the changes in this PR — the touched files were individually validated with prettier --check and cargo fmt --check and are clean.
  • impact: Pushed with --no-verify per CLAUDE.md git-workflow guidance for unrelated hook breakage. Per-file format checks above already confirm the diff itself is clean.

Behavior Changes

  • Intended behavior change: users can pick OrcaRouter from the built-in provider list in AI Settings instead of having to enter a custom endpoint.
  • User-visible effect: new "OrcaRouter" chip + dropdown option in the AI Settings panel; selecting it pre-fills https://api.orcarouter.ai/v1 and Bearer auth.

Parity Contract

  • Legacy behavior preserved: existing slugs (openai, anthropic, openrouter, custom) unchanged. The catch-all _ => "Custom" / _ => AuthStyle::Bearer branches remain intact, so any unknown legacy slug still falls back the same way.
  • Guard / fallback / dispatch parity checks: factory routing (<slug>:<model> grammar) already dispatches OrcaRouter via the generic Bearer OpenAI-compatible provider — no new dispatch branch added.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none
  • Canonical PR: this one
  • Resolution: N/A

Disclosure: I'm an engineer on the OrcaRouter team. OrcaRouter (https://www.orcarouter.ai) is an OpenAI-API-compatible multi-provider LLM router; this PR only adds it to the built-in slug list and does not embed any router-side source.

Summary by CodeRabbit

New Features

  • Added OrcaRouter as a new cloud provider option. Users can now toggle it on/off in the provider settings, configure connection credentials, and route workloads to OrcaRouter.

Review Change Stack

xilema2 avatar May 19 '26 08:05 xilema2

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9a596f74-ab8b-464f-9397-40267a8bd8c7

📥 Commits

Reviewing files that changed from the base of the PR and between 75153c383710bf2c0bf246c6f11a4f63397f5765 and 2cb07bd0bb2d9fa1d193c1d12e5780a3ac6a2dee.

📒 Files selected for processing (1)
  • app/src/components/settings/panels/AIPanel.tsx

📝 Walkthrough

Walkthrough

Adds OrcaRouter as a built-in cloud provider: backend enum + metadata and legacy mappings, config docs and proxy key, frontend type and AIPanel UI updates (chips, placeholders, defaults, endpoint), and unit tests for parsing and legacy migration.

Changes

OrcaRouter Provider Integration

Layer / File(s) Summary
Backend provider schema: enum variant and metadata methods
src/openhuman/config/schema/cloud_providers.rs
CloudProviderType enum gains the Orcarouter variant. Methods default_endpoint(), label(), and as_str() are updated to handle the new variant. Legacy mapping helpers (legacy_label_for, legacy_default_endpoint) map orcarouter to "OrcaRouter" and https://api.orcarouter.ai/v1.
Backend configuration schema and proxy service support
src/openhuman/config/schema/types.rs, src/openhuman/config/schema/proxy.rs
Configuration docs add orcarouter:<model> provider-string grammar; SUPPORTED_PROXY_SERVICE_KEYS now includes provider.orcarouter.
Frontend TypeScript type definition
app/src/utils/tauriCommands/config.ts
CloudProviderType union reformatted to multiline and includes the orcarouter literal.
Frontend UI integration in AIPanel
app/src/components/settings/panels/AIPanel.tsx
Adds orcarouter to built-in provider metadata (label/tone), API-key placeholder (sk-orca-...), provider chips toggle list (connect/disconnect + routing scrub), CloudProviderEditor default slug candidates, provider dropdown options, and defaultEndpointFor mapping to https://api.orcarouter.ai/v1.
Unit tests for orcarouter provider handling
src/openhuman/inference/provider/factory_test.rs
New tests assert orcarouter:<model> routes to expected model ids and that legacy legacy_type = "orcarouter" migrates slug, label, endpoint, and auth_style correctly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

A rabbit hops through orca-routed seas,
Slugs and endpoints carried on the breeze,
Configs whisper, schemas hum in tune,
UI chips glow beneath the moon,
Tests nibble paths to keep them true. 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'feat(providers): add OrcaRouter as built-in cloud provider' directly and clearly summarizes the main change: adding OrcaRouter as a built-in cloud provider across both backend config and frontend UI.
Docstring Coverage ✅ Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar May 19 '26 08:05 coderabbitai[bot]