Add OrcaRouter as a first-class Provider with API-key and OAuth 2.0 + PKCE login - #196
Closed
clementguarino06510-glitch wants to merge 1 commit into
Closed
clementguarino06510-glitch wants to merge 1 commit into
clementguarino06510-glitch wants to merge 1 commit into
Conversation
… PKCE login Signed-off-by: clementguarino06510-glitch <clementguarino06510-glitch@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
OrcaRouter is an OpenAI-compatible AI gateway built for both models and agents, with adaptive routing, automatic failover, zero-markup inference, observability, guardrails, and agent-tool governance. It also runs gateway-level, zero-trust security for AI agents on the same endpoint — screening every prompt/response and governing every tool call on a default-deny basis, with no application code changes. Discord: discord.gg/YEubt8enRA · X: https://x.com/OrcaRouter · I'm an engineer on the OrcaRouter team.
This PR registers OrcaRouter as a first-class Endpoint next to HypiHub, reachable through both of the repository's existing seams:
@hypit/provider-orcarouter— the Provider. Inference and model discovery onhttps://api.orcarouter.ai/v1; authorization onhttps://www.orcarouter.ai. Registersorca:GeneratethroughdefineEndpointPackage, and carries its ownapiKeycredential slot with the OrcaRouter label.@hypit/orcarouter— the Model package: a sealed chat request (catalogue model ID, promptText, up to 8 optional imageArtifactreferences) and the replyText.packages/video-cli/src/distribution.tslistsorcarouter.default;docs/guide/providers.md,docs/guide/runtime.mdand theirzhcounterparts describe it;packages/studio/locales/{en,zh-CN}.jsoncarry the panel strings and pass the repository's locale parity check.Nothing existing changes behaviour: HypiHub keeps its media-generation routes untouched.
One credential slot, two authentication entry points
Both entry points resolve to the same
OrcaRouterCredential(packages/provider-orcarouter/src/credentials.ts), andtoken()is the only thing any downstream code sees — the chat endpoint, the catalogue reader and Studio never branch on how the key was obtained.OrcaRouter - APIapiKeyCredentialAdaptersk-orca-…key into the slot; the repository's own credential store (@hypit/credential-store-os/-env) holds itOrcaRouter - AuthpkceCredentialAdapterhypit auth login orcarouter.default, or the Studio panel's authorize button, over the existingCredentialAcquisitionseamFlow choice: B (out-of-band code). Flow A (loopback redirect) is not reachable for the seam this repository already owns:
packages/cli/src/oauth.tssends the RFC 6749response_type/client_id/redirect_uriparameter set to whateveracquireOAuthCredentialis given, and/authdoes not accept it. Rather than add a second, bespoke browser-callback server beside the shipped one, the adapter uses the out-of-band delivery the seam supports: the authorization URL is opened, the code is shown to the person, and the exchange happens in the same process that holds the verifier.S256is mandatory on both the authorize URL and the exchange; no client secret and no pre-registered redirect URI are required. Flow C (device grant) is not implemented and is not a substitute for PKCE.PKCE details, all covered by tests below: a fresh verifier and
statecome fromrandomBytesper attempt; the challenge is unpaddedbase64url(sha256(verifier)); the verifier never leaves the process, never enters a URL, a log or an error; the grantedscopein the exchange response is read and a narrower grant is refused rather than assumed.Credential lifecycle. A PKCE-issued key is a durable OrcaRouter API key, not a refresh token: there is no refresh path anywhere in the change. A
401marks that exact credential generationneedsReauthand later generations are unaffected, so a late failure cannot contaminate a newer login; the stored key is never deleted before a replacement succeeds. Revocation lives at the OrcaRouter console, and the panel links to it.Model catalogue and capability filtering
The model control is a catalogue-backed selector, never a free-text field.
GET /v1/modelson the configured inference origin is the only source of truth, read server-side inpackages/studio/src/server.tswith the account's own key, so the browser never receives the credential.packages/provider-orcarouter/src/catalog.tsholds the filters:supported_endpoint_typescontainsopenai/anthropic/gemini/openai-response, and none ofimage-generation,openai-video,jina-rerank,embeddings,rerank,moderation,audioarchitecture.input_modalitiesexplicitly containing the modality the control uploads — a model that declares nothing fails closedembeddings/image-generation/openai-video/jina-rerankendpoint typeChanging provider, toggling the image attachment, or changing the modality recomputes the selector's options; a selection that is no longer compatible is cleared, not silently kept. Live discovery is authoritative; when it fails the panel shows a small verified cold-start seed marked as degraded (never merged into a successful live read, never a fallback to free text), and a restored model ID is re-validated against the current compatible list before it is kept.
filterCataloglives in one place and every entry point uses it — the Studio panel, the CLI and the tests all read the same function.AI input entry points covered
Traced from the code, not from file names: the repository's remote generation flows through
defineEndpointPackageEndpoints. The others areprovider-hypihub(media-generation jobs in HypiHub's own shape, unchanged),provider-whisperx-local(local speech-to-text) and the local rendering providers, which call no remote AI service. There is no chat/completion, embedding, rerank or agent-tool call site in the tree (grep -rn "chat/completions" packages servicesfinds only a HypiHub test fixture string).So the entry points OrcaRouter can serve are covered, and the ones it cannot are left exactly as they were:
orca:Generate, through the new Provider.imagesport, offered only for catalogue entries that declareimageinput.hypit auth login orcarouter.default(PKCE) andhypit environment(key entry), plus the existing run command against the new Endpoint.Evidence
Automated tests — run through the Provider's own code paths, not around them. 65 new/updated cases in the files below (all passing locally on the repository's declared Node >= 22.15 runtime):
packages/provider-orcarouter/test/credentials.test.ts/api/v1/auth/keyson the auth origin; non-loopback HTTP is refusedpackages/provider-orcarouter/test/connect.test.tspackages/provider-orcarouter/test/catalog.test.tspackages/provider-orcarouter/test/provider.test.tswwwand inference onapi; the catalogue is read with the credential and filtered to the control; a failed catalogue is degraded, not repaired with the seedpackages/provider-orcarouter/test/live.test.tspackages/cli/test/oauth.test.tspackages/studio/test/accounts.test.ts,connect-lifecycle.test.tsneedsReauthis never used for discovery;pagehidereleases the panel so a second authorization starts without remountingLive checks — run against the real service through the new Provider with a configured account key:
GET https://api.orcarouter.ai/v1/modelsreturns the account's own catalogue with vendor namespaces preserved and exactly the chat models the text control offers, and a real chat completion returns non-empty text. Auth requests go towww.orcarouter.ai, inference and discovery toapi.orcarouter.ai/v1.Real UI — the screenshots below are the repository's own Studio page in a real browser (Playwright against
/usr/bin/chromium, 1440x1000), driven against a live catalogue of 16 chat models:auth-methods.png— API Key and Connect-with-OrcaRouter offered side by side, the stored key shown masked (sk-orca-…), controls enabled, and the key itself absent from the page text.text-model-dropdown.png— the text dropdown open with all 16 live chat models.multimodal-model-dropdown.png— after attaching an image: the previous text-only selection is cleared and the dropdown lists exactly the two chat entries whose catalogue records declareimageinput.The three captures above are the campaign's archived evidence for this submission: 1440x1000 PNGs, sha256-bound in
orca-evidence/manifest.json, produced by Playwright against the real Studio server started from this checkout. They are attached by the submission's evidence job rather than linked inline, because this integration has no URL to host them at.Verification status
tsc --noEmitover the whole workspace: clean.pnpm teston the declared runtime: 900 tests, 872 pass, 0 fail, 28 skipped (the skips are the repository's own environment-gated media/ffmpeg cases plus the OrcaRouter live cases when no key is configured).node:module'sregisterHooksbefore any assertion runs; the same 33 fail identically on the untouched base commit, so none of them come from this change.OrcaRouter primary sources
Verified 2026-09-15:
https://api.orcarouter.ai/v1The public site publishes no separate legal-entity or reseller-authorization page and no named maintainer contact; the Trust Centre above is the published compliance surface, and the gateway describes itself as forwarding to upstream providers at their published rates.