Skip to content

Commit a24a9f2

Browse files
committed
feat(cli): accept an account alias and "auto" in the Codex pool verbs
`ocx account alias` could name a pool account but nothing else could use the name: `use`, `priority`, `pause`, `resume`, `clear-cooldown`, `remove` and `alias` all wanted the generated `chatgpt-<digits>` id. And the CLI had no way to clear a manual selection, although the route accepts `{ accountId: null }`; the only way back to automatic placement was the dashboard. A small `account-target` module resolves the argument against the pool list: an id as given, `main` as before, otherwise the alias set by the operator. An exact alias wins, a case-insensitive one is taken when it names exactly one account, and two accounts sharing a name is an error rather than a guess. `use <provider> auto` sends the null pin and says so instead of printing the "auto-switch may override this pin" caveat about a pin that no longer exists. `priority` and `remove` keep the wording their existing tests assert for an unknown id. The two suites that mock the proxy with one answer for every path now serve the account list, and the pause tests find the write by path rather than assuming it is the first call. Docs: the `use` section and help block in all eight locales.
1 parent 444cf77 commit a24a9f2

14 files changed

Lines changed: 262 additions & 78 deletions

File tree

docs-site/src/content/docs/fr/reference/cli/providers-accounts.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ Usage: ocx account <list|current|use|refresh|auto-switch|priority|login|reauth|c
109109
110110
list [provider] Codex account pool, OAuth accounts and API keys (identifiers shown masked as the API returns them).
111111
current <provider> Show the active account or key.
112-
use <provider> <id> Switch the active credential; 'main' selects the Codex App login.
112+
use <provider> <id|alias|main|auto> Switch the active credential; 'main' selects the Codex App login, 'auto' clears the selection.
113113
refresh <provider> Force-refresh Codex or provider quota reports.
114114
auto-switch <provider> <on|off|status|threshold N> Control the Codex pool threshold.
115-
priority <provider> <id|main> [first|earlier|normal|later|last|-100..100|reset] Selection order; omit the value to read it.
116-
remove <provider> <id> --yes Remove a stored account or key after an existence check.
115+
priority <provider> <id|alias|main> [first|earlier|normal|later|last|-100..100|reset] Selection order; omit the value to read it.
116+
remove <provider> <id|alias|main> --yes Remove a stored account or key after an existence check.
117117
add-key <provider> [--label <label>] Add a key read only from piped stdin.
118118
login/reauth/code/cancel Run browser or manual-code auth from a headless shell.
119119
reset-credits <id|main> [--consume --yes] Inspect or consume Codex reset credits.
@@ -173,7 +173,7 @@ cet état et quitte toujours 0. `--json` renvoie :
173173
{ provider, type, activeId: string | null, autoSwitchThreshold?: number, account: AccountRow | null }
174174
```
175175

176-
### `ocx account use <provider> <account-or-key-id|main> [--json]`
176+
### `ocx account use <provider> <account-or-key-id|alias|main|auto> [--json]`
177177

178178
Sélectionne un compte Codex, un compte OAuth ou une clé API existant. Pour `openai`, `main` sélectionne la
179179
connexion Codex App. Une sélection en mode Codex Pool efface l'affinité locale du processus et s'applique à la requête suivante,
@@ -189,6 +189,7 @@ Sur un **429**, opencodex respecte `Retry-After`, démarre la temporisation du c
189189
faire basculer la requête vers un autre compte de pool admissible. Ces transitions en cas d’échec restent actives avec
190190
`autoSwitchThreshold: 0` ; ce paramètre désactive uniquement le basculement proactif fondé sur l’utilisation.
191191
`--json` renvoie :
192+
`auto` efface cette sélection pour que le pool place à nouveau le travail selon sa propre stratégie. Un compte Codex peut être désigné par l'alias défini avec `ocx account alias` au lieu de son id ; cela vaut aussi pour `priority`, `pause`, `resume`, `clear-cooldown`, `remove` et `alias`.
192193

193194
```text
194195
{ ok: true, provider, type, activeId }
@@ -216,7 +217,7 @@ openai: { provider, autoSwitchThreshold: number, enabled: boolean }
216217
generic OAuth: { provider, autoSwitchThreshold: number | null, enabled: boolean, poolEnabled: boolean | null, inert: boolean | null }
217218
```
218219

219-
### `ocx account priority <provider> <account-id|main> [<-100..100|first|earlier|normal|later|last|reset>] [--json]`
220+
### `ocx account priority <provider> <account-id|alias|main> [<-100..100|first|earlier|normal|later|last|reset>] [--json]`
220221

221222
Lit ou définit l’ordre de sélection d’un compte du groupe Codex : **une priorité plus élevée est utilisée plus tôt**.
222223
La valeur par défaut est `0` et la plage va de `-100` à `100`. Seul le groupe Codex `openai` peut être ordonné ;
@@ -249,7 +250,7 @@ l'actualisation de son catalogue de modèles reste en attente, la sortie humaine
249250
`ocx sync` conseils de récupération sur stderr. `--json` garde la sortie standard analysable et transporte
250251
`catalogRefreshPending: true` dans l'état de connexion terminé sans avertissement humain.
251252

252-
### `ocx account remove <provider> <id|main> --yes [--json]`
253+
### `ocx account remove <provider> <id|alias|main> --yes [--json]`
253254

254255
Cette suppression gardée et non interactive nécessite `--yes`. Avant de supprimer, il vérifie que l'identifiant
255256
existe; un identifiant manquant quitte 1 sans envoyer DELETE. La connexion principale Codex App ne peut pas être supprimée, donc

docs-site/src/content/docs/ja/reference/cli/providers-accounts.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ Usage: ocx account <list|current|use|refresh|auto-switch|priority|login|reauth|c
8383
8484
list [provider] Codex account pool, OAuth accounts and API keys (identifiers shown masked as the API returns them).
8585
current <provider> Show the active account or key.
86-
use <provider> <id> Switch the active credential; 'main' selects the Codex App login.
86+
use <provider> <id|alias|main|auto> Switch the active credential; 'main' selects the Codex App login, 'auto' clears the selection.
8787
refresh <provider> Force-refresh Codex or provider quota reports.
8888
auto-switch <provider> <on|off|status|threshold N> Control the Codex pool threshold.
89-
priority <provider> <id|main> [first|earlier|normal|later|last|-100..100|reset] Selection order; omit the value to read it.
90-
remove <provider> <id> --yes Remove a stored account or key after an existence check.
89+
priority <provider> <id|alias|main> [first|earlier|normal|later|last|-100..100|reset] Selection order; omit the value to read it.
90+
remove <provider> <id|alias|main> --yes Remove a stored account or key after an existence check.
9191
add-key <provider> [--label <label>] Add a key read only from piped stdin.
9292
login/reauth/code/cancel Run browser or manual-code auth from a headless shell.
9393
reset-credits <id|main> [--consume --yes] Inspect or consume Codex reset credits.
@@ -131,7 +131,7 @@ Codex pool selection applies to the next request after clearing existing affinit
131131
{ provider, type, activeId: string | null, autoSwitchThreshold?: number, account: AccountRow | null }
132132
```
133133

134-
### `ocx account use <provider> <account-or-key-id|main> [--json]`
134+
### `ocx account use <provider> <account-or-key-id|alias|main|auto> [--json]`
135135

136136
既存の Codex アカウント、OAuth アカウント、または API key を選びます。`openai``main` は Codex App ログインを
137137
選択します。Codex Pool の選択は process-local affinity を消去し、既存の表示タスクを含む次のリクエストから適用されます。プロキシ再起動や affinity eviction 後もタスクは未紐付けになり得ますが、処理中のリクエストは取得済みアカウントを維持します。この選択は Pool routing のみを制御し、Direct mode は caller-owned/native main credential を使い続けます。使用量ベースのプロアクティブ切り替え、401/403 再認証、429/retry-after cooldown、除外、出力前 429/402 の障害回復により、後で別の適格 Pool アカウントが選ばれる場合があります。これらの回復経路は使用量ベース切り替えが off でも有効です。アカウント変更後も OpenCodex は会話コンテキストを再生しますが、provider prompt cache は再ウォームアップが必要な場合があります。
@@ -140,6 +140,7 @@ Codex pool selection applies to the next request after clearing existing affinit
140140
**429** では `Retry-After` を尊重してアカウントの cooldown を開始し、affinity を解除したうえで、
141141
別の適格な Pool アカウントへリクエストを切り替えることがあります。これらの障害回復は
142142
`autoSwitchThreshold: 0` でも有効であり、`0` が無効にするのは使用量に基づく予防的な切り替えだけです。
143+
`auto` はその選択を解除し、プールが自身の戦略で再び配置するようにします。Codex アカウントは id の代わりに `ocx account alias` で付けたエイリアスでも指定でき、`priority``pause``resume``clear-cooldown``remove``alias` でも同様です。
143144

144145
```text
145146
{ ok: true, provider, type, activeId }
@@ -160,7 +161,7 @@ openai: { provider, autoSwitchThreshold: number, enabled: boolean }
160161
generic OAuth: { provider, autoSwitchThreshold: number | null, enabled: boolean, poolEnabled: boolean | null, inert: boolean | null }
161162
```
162163

163-
### `ocx account priority <provider> <account-id|main> [<-100..100|first|earlier|normal|later|last|reset>] [--json]`
164+
### `ocx account priority <provider> <account-id|alias|main> [<-100..100|first|earlier|normal|later|last|reset>] [--json]`
164165

165166
Codex pool のアカウント別選択順を読み書きします。**値が大きいほど先に使われ**、既定は `0`、範囲は
166167
`-100` から `100` です。順序を持つのは `openai` の Codex pool だけなので、他のプロバイダーは終了コード
@@ -187,7 +188,7 @@ preemption が未バインドリクエストを直ちに引き上げます。既
187188

188189
ヘッドレス シェルからブラウザベースまたは手動コードのアカウント認証を実行します。プロバイダー固有のコマンド形式には `ocx account --help` を使用します。Codex account login は保存済みでも catalog refresh が保留中なら成功終了し、human output の stderr に固定の `ocx sync` 案内を出します。`--json` は案内を混ぜず、完了 state に `catalogRefreshPending: true` を保持します。
189190

190-
### `ocx account remove <provider> <id|main> --yes [--json]`
191+
### `ocx account remove <provider> <id|alias|main> --yes [--json]`
191192

192193
この保護された非対話型削除には `--yes` が必要です。削除する前に、ID が存在することが確認されます。 ID が欠落している場合は、DELETE を送信せずに 1 が終了します。メインの Codex App ログインは削除できないため、`remove openai main --yes` は拒否されます。削除後、ファミリーは再度読み取られます。固定された Codex アカウントを削除すると、ピンがクリアされ、自動選択に戻ります。 OAuth は最初に残ったアカウントを昇格させるか、何も報告しません。 API キー プールは、最初に残っているキーを昇格するか、何も報告しません。 `--json` の成功と失敗の形状は次のとおりです。
193194

docs-site/src/content/docs/ko/reference/cli/providers-accounts.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ Usage: ocx account <list|current|use|refresh|auto-switch|priority|login|reauth|c
149149
150150
list [provider] Codex account pool, OAuth accounts and API keys (identifiers shown masked as the API returns them).
151151
current <provider> Show the active account or key.
152-
use <provider> <id> Switch the active credential; 'main' selects the Codex App login.
152+
use <provider> <id|alias|main|auto> Switch the active credential; 'main' selects the Codex App login, 'auto' clears the selection.
153153
refresh <provider> Force-refresh Codex or provider quota reports.
154154
auto-switch <provider> <on|off|status|threshold N> Control the Codex pool threshold.
155-
priority <provider> <id|main> [first|earlier|normal|later|last|-100..100|reset] Selection order; omit the value to read it.
156-
remove <provider> <id> --yes Remove a stored account or key after an existence check.
155+
priority <provider> <id|alias|main> [first|earlier|normal|later|last|-100..100|reset] Selection order; omit the value to read it.
156+
remove <provider> <id|alias|main> --yes Remove a stored account or key after an existence check.
157157
add-key <provider> [--label <label>] Add a key read only from piped stdin.
158158
login/reauth/code/cancel Run browser or manual-code auth from a headless shell.
159159
reset-credits <id|main> [--consume --yes] Inspect or consume Codex reset credits.
@@ -197,7 +197,7 @@ Codex pool selection applies to the next request after clearing existing affinit
197197
{ provider, type, activeId: string | null, autoSwitchThreshold?: number, account: AccountRow | null }
198198
```
199199

200-
### `ocx account use <provider> <account-or-key-id|main> [--json]`
200+
### `ocx account use <provider> <account-or-key-id|alias|main|auto> [--json]`
201201

202202
기존 Codex 계정, OAuth 계정 또는 API key를 선택합니다. `openai`에서 `main`은 Codex App 로그인을
203203
선택합니다. Codex Pool 선택은 프로세스 로컬 affinity를 지우고 기존에 보이던 작업을 포함한 다음 요청부터 적용됩니다. 프록시 재시작이나 affinity eviction 뒤에도 작업이 바인딩 없는 상태가 될 수 있지만, 진행 중인 요청은 이미 확보한 계정을 유지합니다. 이 선택은 Pool 라우팅만 제어하며 Direct mode는 호출자 소유/native main credential을 계속 사용합니다. 사용량 기반 선제 전환, 401/403 재인증, 429/retry-after cooldown, 제외, 출력 전 429/402 실패 복구는 나중에 다른 적격 Pool 계정을 선택할 수 있습니다. 이러한 복구 경로는 사용량 기반 전환이 꺼져 있어도 동작합니다. 계정이 바뀌어도 OpenCodex는 대화 문맥을 재생하지만 프로바이더 측 prompt cache는 다시 예열해야 할 수 있습니다.
@@ -206,6 +206,7 @@ Codex pool selection applies to the next request after clearing existing affinit
206206
**429**에서는 `Retry-After`를 준수해 계정 cooldown을 시작하고 affinity를 해제한 뒤,
207207
다른 적격 Pool 계정으로 요청을 전환할 수 있습니다. 이러한 실패 복구는
208208
`autoSwitchThreshold: 0`에서도 계속 작동하며, `0`은 사용량 기반 선제 전환만 비활성화합니다.
209+
`auto`는 그 선택을 지워 풀이 다시 자체 전략으로 작업을 배치하게 합니다. Codex 계정은 id 대신 `ocx account alias`로 지정한 별칭으로도 가리킬 수 있으며, `priority`, `pause`, `resume`, `clear-cooldown`, `remove`, `alias`에서도 마찬가지입니다.
209210

210211
```text
211212
{ ok: true, provider, type, activeId }
@@ -226,7 +227,7 @@ openai: { provider, autoSwitchThreshold: number, enabled: boolean }
226227
generic OAuth: { provider, autoSwitchThreshold: number | null, enabled: boolean, poolEnabled: boolean | null, inert: boolean | null }
227228
```
228229

229-
### `ocx account priority <provider> <account-id|main> [<-100..100|first|earlier|normal|later|last|reset>] [--json]`
230+
### `ocx account priority <provider> <account-id|alias|main> [<-100..100|first|earlier|normal|later|last|reset>] [--json]`
230231

231232
Codex pool 계정 하나의 선택 순서를 읽거나 설정합니다. **값이 클수록 먼저** 쓰이고 기본값은 `0`,
232233
범위는 `-100`부터 `100`까지입니다. 순서를 갖는 것은 `openai` Codex pool뿐이므로 다른 프로바이더는
@@ -252,7 +253,7 @@ Codex pool 계정 하나의 선택 순서를 읽거나 설정합니다. **값이
252253

253254
헤드리스 셸에서 브라우저 기반 또는 수동 코드 계정 인증을 실행합니다. 제공자별 명령 형태는 `ocx account --help`를 보십시오. Codex account login이 저장되었지만 catalog refresh가 보류 중이면 성공으로 종료하고 human output의 stderr에 고정된 `ocx sync` 안내를 표시합니다. `--json`은 안내를 섞지 않고 완료 state의 `catalogRefreshPending: true`를 유지합니다.
254255

255-
### `ocx account remove <provider> <id|main> --yes [--json]`
256+
### `ocx account remove <provider> <id|alias|main> --yes [--json]`
256257

257258
이 보호된 비대화형 삭제는 `--yes`를 요구합니다. 삭제하기 전에 id가 존재하는지 확인하며, 없는 id는 DELETE를 보내지 않고 종료 코드 1로 끝납니다. Codex App의 main 로그인은 제거할 수 없으므로 `remove openai main --yes`는 거부됩니다. 삭제 후에는 해당 계열을 다시 읽습니다. 고정된 Codex 계정을 제거하면 고정이 풀리고 자동 선택으로 돌아갑니다. OAuth는 남아 있는 첫 번째 계정으로 승격하거나 없다고 보고합니다. API 키 풀은 남아 있는 첫 번째 키로 승격하거나 없다고 보고합니다. `--json`의 성공 및 실패 형식은 다음과 같습니다:
258259

docs-site/src/content/docs/reference/cli/providers-accounts.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,11 @@ Usage: ocx account <list|current|use|refresh|auto-switch|priority|login|reauth|c
211211
212212
list [provider] Codex account pool, OAuth accounts and API keys (identifiers shown masked as the API returns them).
213213
current <provider> Show the active account or key.
214-
use <provider> <id> Switch the active credential; 'main' selects the Codex App login.
214+
use <provider> <id|alias|main|auto> Switch the active credential; 'main' selects the Codex App login, 'auto' clears the selection.
215215
refresh <provider> Force-refresh Codex or provider quota reports.
216216
auto-switch <provider> <on|off|status|threshold N> Control the Codex pool threshold.
217-
priority <provider> <id|main> [first|earlier|normal|later|last|-100..100|reset] Selection order; omit the value to read it.
218-
remove <provider> <id> --yes Remove a stored account or key after an existence check.
217+
priority <provider> <id|alias|main> [first|earlier|normal|later|last|-100..100|reset] Selection order; omit the value to read it.
218+
remove <provider> <id|alias|main> --yes Remove a stored account or key after an existence check.
219219
add-key <provider> [--label <label>] Add a key read only from piped stdin.
220220
login/reauth/code/cancel Run browser or manual-code auth from a headless shell.
221221
reset-credits <id|main> [--consume --yes] Inspect or consume Codex reset credits.
@@ -313,7 +313,7 @@ that state and still exits 0. `--json` returns:
313313
{ provider, type, activeId: string | null, autoSwitchThreshold?: number, account: AccountRow | null }
314314
```
315315

316-
### `ocx account use <provider> <account-or-key-id|main> [--json]`
316+
### `ocx account use <provider> <account-or-key-id|alias|main|auto> [--json]`
317317

318318
Selects an existing Codex account, OAuth account, or API key. For `openai`, `main` selects the Codex
319319
App login. A Codex Pool selection clears process-local affinity and applies to the next request,
@@ -329,6 +329,7 @@ On a **429**, opencodex honors `Retry-After`, starts the account cooldown, clear
329329
rotate the request to another eligible Pool account. These failure transitions remain active with
330330
`autoSwitchThreshold: 0`; that setting disables only usage-based proactive switching.
331331
`--json` returns:
332+
`auto` clears that selection so the pool places work by its own strategy again. Any Codex account can be named by the alias set with `ocx account alias` instead of its id; that holds for `priority`, `pause`, `resume`, `clear-cooldown`, `remove` and `alias` too.
332333

333334
```text
334335
{ ok: true, provider, type, activeId }
@@ -356,7 +357,7 @@ openai: { provider, autoSwitchThreshold: number, enabled: boolean }
356357
generic OAuth: { provider, autoSwitchThreshold: number | null, enabled: boolean, poolEnabled: boolean | null, inert: boolean | null }
357358
```
358359

359-
### `ocx account priority <provider> <account-id|main> [<-100..100|first|earlier|normal|later|last|reset>] [--json]`
360+
### `ocx account priority <provider> <account-id|alias|main> [<-100..100|first|earlier|normal|later|last|reset>] [--json]`
360361

361362
Reads or sets one Codex pool account's selection order: **higher is used earlier**, the default is
362363
`0`, and the range is `-100` through `100`. Only the `openai` Codex pool is ordered, so other
@@ -417,7 +418,7 @@ machine"** checkbox on the add-account modal. That setting already means the ope
417418
sitting at the proxy host, which is exactly when a callback URL is useless — so ticking it
418419
switches the Codex login to the device flow and shows a copyable code instead.
419420

420-
### `ocx account remove <provider> <id|main> --yes [--json]`
421+
### `ocx account remove <provider> <id|alias|main> --yes [--json]`
421422

422423
This guarded, non-interactive deletion requires `--yes`. Before deleting, it verifies that the id
423424
exists; a missing id exits 1 without sending DELETE. The main Codex App login cannot be removed, so

0 commit comments

Comments
 (0)