GeezerVison is showing github.com — feat(providers): add Nous Portal (Nous Research) OAuth provider — dev… · lidge-jun/opencodex@3c5d435
File treeExpand file treeCollapse file tree Open diff view settings docs-site/src/content/docs
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: docs-site/src/content/docs/guides/providers.md +3-2Lines changed: 3 additions & 2 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -89,7 +89,7 @@ The ChatGPT passthrough catalog also layers in the bare GPT-5.6 Sol/Terra/Luna s | 89 | 89 |
| 90 | 90 | ## 2. Account login (OAuth) | 91 | 91 |
| 92 | | -Seven provider presets use OAuth login — plus GitHub Copilot via an experimental unofficial | | 92 | +Eight provider presets use OAuth login — plus GitHub Copilot via an experimental unofficial | 93 | 93 | device-flow bridge. opencodex stores their credentials in | 94 | 94 | `~/.opencodex/auth.json` and refreshes them automatically. `chatgpt` is also accepted by the login | 95 | 95 | CLI; it acquires a ChatGPT credential while creating a `forward`-mode provider entry. | @@ -98,6 +98,7 @@ CLI; it acquires a ChatGPT credential while creating a `forward`-mode provider e | 98 | 98 | ocx login xai # xAI Grok | 99 | 99 | ocx login anthropic # Anthropic Claude (Pro/Max) | 100 | 100 | ocx login kimi # Moonshot Kimi | | 101 | +ocx login nous # Nous Portal (device grant; free + paid models) | 101 | 102 | ocx login kiro # import kiro-cli credentials (or token fallback) | 102 | 103 | ocx login google-antigravity | 103 | 104 | ocx login cursor # standalone Cursor PKCE login | @@ -112,6 +113,7 @@ ocx logout <provider> | 112 | 113 | | `xai` | `openai-chat` | `https://api.x.ai/v1` | Live-first Grok catalog; `grok-4.5` is the fallback default. | | 113 | 114 | | `anthropic` | `anthropic` | `https://api.anthropic.com` | Claude models; live model list fetched from `/v1/models`. | | 114 | 115 | | `kimi` | `openai-chat` | `https://api.kimi.com/coding/v1` | Kimi K2.7/K2.6/K2.5 coding models. | | | 116 | +| `nous` | `openai-chat` | `https://inference-api.nousresearch.com/v1` | Nous Research subscription gateway (same backend Hermes Agent uses). Device-grant login against `portal.nousresearch.com`; the access token is the per-request inference JWT. Mixed paid + `:free` model catalog (`tencent/hy3:free`, `stepfun/step-3.7-flash:free`, ...) discovered live from the signed-in account. Refresh tokens are single-use and rotated on every refresh. | | 115 | 117 | | `kiro` | `kiro` | `https://runtime.us-east-1.kiro.dev` | Initial login imports the installed, signed-in `kiro-cli` session (on Unix, install with `curl -fsSL https://cli.kiro.dev/install | bash`; on Windows PowerShell, use `irm 'https://cli.kiro.dev/install.ps1' | iex`; then run `kiro-cli login`). **Add account** logs `kiro-cli` out, starts a fresh browser login that switches the account used by `kiro-cli`, and stores account-scoped profile metadata. Existing OpenCodex accounts are preserved, and cancellation or failure restores the previous `kiro-cli` session. | | 116 | 118 | | `google-antigravity` | `google` | `https://daily-cloudcode-pa.googleapis.com` | Google OAuth over the Cloud Code Assist wire. Live discovery uses CCA's authenticated `v1internal:fetchAvailableModels` endpoint and publishes the agent models available to the signed-in account; the maintained catalog remains the fallback. | | 117 | 119 | | `cursor` | `cursor` | `https://api2.cursor.sh` | Experimental PKCE login, live HTTP/2 transport, and account-filtered model discovery. | | @@ -506,4 +508,3 @@ Providers with a live probe: OpenAI/Codex, Anthropic, xAI, Cursor, Kimi, | 506 | 508 | Google Antigravity, OpenRouter, DeepSeek, ClinePass, Z.AI, MiniMax, | 507 | 509 | Moonshot, Venice, Synthetic, DeepInfra, Neuralwatt, and any a6api-backed | 508 | 510 | custom provider. | 509 | | - | |
Collapse file Copy file name to clipboardExpand all lines: docs-site/src/content/docs/ja/guides/providers.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -52,7 +52,7 @@ Codex login を Pool モードで使うと、Providers の概要には任意の | 52 | 52 | | --- | --- | --- | | 53 | 53 | | `key` | API キーを送信します(`Authorization: Bearer …`、またはアダプターにより `x-api-key` / `api-key`)。キーはリテラルまたは `${ENV_VAR}` 参照です。 | 大半のプロバイダー。 | | 54 | 54 | | `forward` | **受け取った Codex 認証ヘッダーを**プロバイダーにそのまま中継します — キーを保存しません。ChatGPT ログインのパススルーです。 | OpenAI(`openai-responses` アダプター)。 | | 55 | | -| `oauth` | 保存された OAuth アクセストークンを読み込み bearer キーとして使い、期限切れ前に自動更新します。 | xAI、Anthropic、Kimi、Kiro、Google Antigravity、Cursor。 | | | 55 | +| `oauth` | 保存された OAuth アクセストークンを読み込み bearer キーとして使い、期限切れ前に自動更新します。 | xAI、Anthropic、Kimi、Kiro、Google Antigravity、Cursor、Nous Portal。 | | 56 | 56 |
| 57 | 57 | [`retryOn429`](/ja/reference/configuration/)(同一キーでの 429 リトライ)は API キー プロバイダー | 58 | 58 | (`authMode: "key"`)のみに適用されます。OAuth・forward・ローカル プリセットは除外されます — | |
Collapse file Copy file name to clipboardExpand all lines: docs-site/src/content/docs/ko/guides/providers.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -51,7 +51,7 @@ shipped v1 config는 marker 2의 단일 옵션 행으로 자동 이관됩니다. | 51 | 51 | | --- | --- | --- | | 52 | 52 | | `key` | API 키를 전송합니다(`Authorization: Bearer …`, 또는 어댑터에 따라 `x-api-key` / `api-key`). 키는 리터럴이거나 `${ENV_VAR}` 참조일 수 있습니다. | 대부분의 프로바이더. | | 53 | 53 | | `forward` | **수신된 Codex 인증 헤더를** 프로바이더에 그대로 중계합니다 — 키를 저장하지 않습니다. ChatGPT 로그인 패스스루입니다. | OpenAI (`openai-responses` 어댑터). | | 54 | | -| `oauth` | 저장된 OAuth 액세스 토큰을 불러와 bearer 키로 사용하며, 만료 전에 자동 갱신합니다. | xAI, Anthropic, Kimi, Kiro, Google Antigravity, Cursor. | | | 54 | +| `oauth` | 저장된 OAuth 액세스 토큰을 불러와 bearer 키로 사용하며, 만료 전에 자동 갱신합니다. | xAI, Anthropic, Kimi, Kiro, Google Antigravity, Cursor, Nous Portal. | | 55 | 55 |
| 56 | 56 | [`retryOn429`](/ko/reference/configuration/)(동일 키 429 재시도)는 API 키 프로바이더 | 57 | 57 | (`authMode: "key"`)에만 적용됩니다. OAuth·forward·로컬 프리셋은 제외됩니다 — 같은 토큰을 | |
Collapse file Copy file name to clipboardExpand all lines: docs-site/src/content/docs/ru/guides/providers.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -60,7 +60,7 @@ description: Все способы, которыми opencodex аутентиф | 60 | 60 | | --- | --- | --- | | 61 | 61 | | `key` | Отправляет ваш API-ключ (`Authorization: Bearer …` либо `x-api-key` / `api-key` в зависимости от адаптера). Ключ может быть литералом или ссылкой вида `${ENV_VAR}`. | Большинство провайдеров. | | 62 | 62 | | `forward` | Передаёт провайдеру **входящие заголовки аутентификации Codex** без изменений — ключ не хранится. Это сквозной режим (passthrough) входа через ChatGPT. | OpenAI (адаптер `openai-responses`). | | 63 | | -| `oauth` | Берёт сохранённый OAuth-токен доступа (автоматически обновляется до истечения срока) и использует его как bearer-ключ. | xAI, Anthropic, Kimi, Kiro, Google Antigravity, Cursor, GitHub Copilot. | | | 63 | +| `oauth` | Берёт сохранённый OAuth-токен доступа (автоматически обновляется до истечения срока) и использует его как bearer-ключ. | xAI, Anthropic, Kimi, Kiro, Google Antigravity, Cursor, GitHub Copilot, Nous Portal. | | 64 | 64 |
| 65 | 65 | Повтор при 429 на том же ключе ([`retryOn429`](/ru/reference/configuration/)) применим только к | 66 | 66 | провайдерам с API-ключом (`authMode: "key"`). Пресеты OAuth, forward и local исключены — их | |
Collapse file Copy file name to clipboardExpand all lines: docs-site/src/content/docs/zh-cn/guides/providers.md +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -48,7 +48,7 @@ shipped v1 配置自动迁移到 marker 2 的单一选项行。原配置只保 | 48 | 48 | | --- | --- | --- | | 49 | 49 | | `key` | 发送你的 API 密钥(`Authorization: Bearer …`,或按 adapter 使用 `x-api-key` / `api-key`)。密钥可以是字面值,也可以是 `${ENV_VAR}` 引用。 | 大多数提供商。 | | 50 | 50 | | `forward` | 将**你传入的 Codex 认证请求头**原样转发给提供商——不存储任何密钥。这就是 ChatGPT 登录的透传方式。 | OpenAI(`openai-responses` adapter)。 | | 51 | | -| `oauth` | 读取已存储的 OAuth 访问令牌(过期前自动刷新),并将其用作 bearer 密钥。 | xAI、Anthropic、Kimi、Kiro、Google Antigravity、Cursor。 | | | 51 | +| `oauth` | 读取已存储的 OAuth 访问令牌(过期前自动刷新),并将其用作 bearer 密钥。 | xAI、Anthropic、Kimi、Kiro、Google Antigravity、Cursor、Nous Portal。 | | 52 | 52 |
| 53 | 53 | [`retryOn429`](/zh-cn/reference/configuration/)(同 key 的 429 重试)仅适用于 API-key 提供商 | 54 | 54 | (`authMode: "key"`)。OAuth、forward 与本地预设均被排除——同一 token 绝不可重放,本地运行时 | |
Collapse file Copy file name to clipboardExpand all lines: src/oauth/index.ts +13Lines changed: 13 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,7 @@ import { getAccountCredential, getAccountSet, removeAccount, saveAccountCredenti | 8 | 8 | import { loginXai, refreshXaiToken, XAI_LOCAL_CLI_DETACH_WARNING, XaiTokenRequestError } from "./xai"; | 9 | 9 | import { ANTHROPIC_OAUTH_BETA, AnthropicTokenError, loginAnthropic, refreshAnthropicToken } from "./anthropic"; | 10 | 10 | import { loginKimi, refreshKimiToken } from "./kimi"; | | 11 | +import { loginNous, NousTokenError, refreshNousToken } from "./nous"; | 11 | 12 | import { loginChatGPT, refreshChatGPTToken } from "./chatgpt"; | 12 | 13 | import { loginAntigravity, refreshAntigravityToken } from "./google-antigravity"; | 13 | 14 | import { loginCursor, refreshCursorToken } from "./cursor"; | @@ -194,6 +195,17 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderDef> = { | 194 | 195 | providerConfig: oauthConfig("kimi"), | 195 | 196 | defaultModel: oauthDefaultModel("kimi"), | 196 | 197 | }, | | 198 | + nous: { | | 199 | + // Nous Portal device-grant login (RFC 8628) against portal.nousresearch.com. | | 200 | + // The access token is the per-request inference JWT (scope inference:invoke). | | 201 | + // Refresh tokens are single-use and rotated server-side on every refresh: | | 202 | + // keep background refresh lazy-only (the default) so concurrent refreshes | | 203 | + // cannot trip the Portal's token-reuse revocation. | | 204 | + login: (ctrl) => loginNous(ctrl), | | 205 | + refresh: (rt, signal) => refreshNousToken(rt, signal), | | 206 | + providerConfig: oauthConfig("nous"), | | 207 | + defaultModel: oauthDefaultModel("nous"), | | 208 | + }, | 197 | 209 | kiro: { | 198 | 210 | login: (ctrl, opts) => loginKiro(ctrl, { forceLogin: opts?.forceLogin }), | 199 | 211 | refresh: (rt, signal, credential) => refreshKiroToken(rt, signal, credential), | @@ -436,6 +448,7 @@ function terminal(error:unknown):boolean{ | 436 | 448 | if(error instanceof XaiTokenRequestError)return ["invalid_grant","refresh_token_reused","revoked_token"].includes(error.oauthError??""); | 437 | 449 | if(error instanceof AnthropicTokenError)return (error.httpStatus===400||error.httpStatus===401)&&["invalid_grant","refresh_token_reused","revoked","revoked_token","refresh_token_revoked"].includes(error.oauthError??""); | 438 | 450 | if(error instanceof KiroTokenRefreshError)return (error.httpStatus===400||error.httpStatus===401)&&error.oauthError!==undefined; | | 451 | + if(error instanceof NousTokenError)return ["invalid_grant","refresh_token_reused","revoked","revoked_token","expired_token"].includes(error.oauthError??""); | 439 | 452 | return isTerminalRefreshError(error); | 440 | 453 | } | 441 | 454 | function authoritative(stored:OAuthCredentials,active:boolean,now:()=>number):OAuthCredentials{if(stored.source!=="local-cli")return stored;const disk=detectGrokCliToken();if(!disk)return stored;const allowed=isSameGrokIdentity(stored,disk)||(active&&!hasComparableGrokIdentity(stored,disk));return allowed&&shouldAdoptGrokGeneration(stored,disk,now(),REFRESH_SKEW_MS)?disk:stored;} | |
|