tokenmix 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,6 +18,7 @@ npx tokenmix kilo # print Kilo Code VSCode configuration
18
18
  npx tokenmix cline # print Cline VSCode configuration
19
19
  npx tokenmix roo # print Roo Code VSCode configuration
20
20
  npx tokenmix continue # print Continue config.yaml snippet
21
+ npx tokenmix codex # install + configure + start Codex
21
22
  ```
22
23
 
23
24
  ### Alternative login modes
@@ -38,6 +39,7 @@ npx tokenmix login --key sk-tm-... # supply API key directly (for CI
38
39
  | [Cline](https://github.com/cline/cline) | VSCode extension | config-only |
39
40
  | [Roo Code](https://github.com/RooCodeInc/Roo-Code) | VSCode extension | config-only |
40
41
  | [Continue](https://github.com/continuedev/continue) | VSCode / JetBrains | config-only |
42
+ | [Codex](https://github.com/openai/codex) | `npm i -g @openai/codex` | full auto |
41
43
 
42
44
  ## Commands
43
45
 
@@ -57,6 +59,7 @@ tokenmix kilo Print Kilo Code configuration
57
59
  tokenmix cline Print Cline configuration
58
60
  tokenmix roo Print Roo Code configuration
59
61
  tokenmix continue Print Continue config.yaml snippet
62
+ tokenmix codex [args...] Launch Codex via TokenMix
60
63
  ```
61
64
 
62
65
  ## Language
@@ -0,0 +1,80 @@
1
+ import { commandExists, run, captureRun } from '../utils/exec.js';
2
+ import { t } from '../i18n/index.js';
3
+ const CODEX_BIN = 'codex';
4
+ const CODEX_NPM_PACKAGE = '@openai/codex';
5
+ // Codex custom provider id. Must NOT collide with Codex's reserved built-in
6
+ // provider ids (openai / ollama / lmstudio).
7
+ const PROVIDER_ID = 'tokenmix';
8
+ // Env var Codex reads for the bearer token (the provider's `env_key`). We set it
9
+ // at launch from the user's TokenMix key — nothing is written to ~/.codex.
10
+ const KEY_ENV = 'TOKENMIX_API_KEY';
11
+ async function installCheck() {
12
+ const bin = await commandExists(CODEX_BIN);
13
+ if (!bin) {
14
+ const cmd = `npm install -g ${CODEX_NPM_PACKAGE}`;
15
+ return {
16
+ installed: false,
17
+ hint: t('install.willInstallVia', { cmd }),
18
+ installCmd: cmd,
19
+ };
20
+ }
21
+ try {
22
+ const v = await captureRun(CODEX_BIN, ['--version']);
23
+ return { installed: true, version: v.stdout.trim() };
24
+ }
25
+ catch {
26
+ return { installed: true };
27
+ }
28
+ }
29
+ async function install() {
30
+ await run('npm', ['install', '-g', CODEX_NPM_PACKAGE]);
31
+ }
32
+ async function configure(apiKey, baseUrl, defaultModel) {
33
+ // We do NOT write ~/.codex/config.toml. Codex accepts a whole custom provider
34
+ // via `--config` overrides at launch, and reads the key from the env var named
35
+ // by the provider's env_key — so we pass everything through env and inject the
36
+ // overrides in launch(). This never touches the user's Codex config or login.
37
+ return {
38
+ envVars: {
39
+ [KEY_ENV]: apiKey,
40
+ TOKENMIX_BASE_URL: `${baseUrl}/v1`,
41
+ },
42
+ notes: [t('codex.noteUsing'), t('codex.noteModel', { model: defaultModel })],
43
+ };
44
+ }
45
+ // Build the `--config key=value` overrides that register tokenmix as a custom
46
+ // OpenAI-compatible provider. wire_api MUST be "responses": Codex 0.135+ dropped
47
+ // support for "chat" (openai/codex#7782), and tokenmix's gateway implements the
48
+ // Responses API specifically for Codex clients (POST /v1/responses).
49
+ export function providerOverrides(baseUrl, model) {
50
+ return [
51
+ '--config', `model_provider="${PROVIDER_ID}"`,
52
+ '--config', `model="${model}"`,
53
+ '--config', `model_providers.${PROVIDER_ID}.name="TokenMix"`,
54
+ '--config', `model_providers.${PROVIDER_ID}.base_url="${baseUrl}"`,
55
+ '--config', `model_providers.${PROVIDER_ID}.env_key="${KEY_ENV}"`,
56
+ '--config', `model_providers.${PROVIDER_ID}.wire_api="responses"`,
57
+ ];
58
+ }
59
+ async function launch(args, env) {
60
+ const baseUrl = env.TOKENMIX_BASE_URL;
61
+ // Info-only invocations (`codex --version` / `--help`) reach launch with an
62
+ // empty env (no credentials). Just forward — don't inject a half-built provider.
63
+ if (!baseUrl) {
64
+ await run(CODEX_BIN, args, { env });
65
+ return;
66
+ }
67
+ const model = env.TOKENMIX_DEFAULT_MODEL ?? 'claude-sonnet-4.6';
68
+ // Our overrides go first so user-supplied args (e.g. `--config model=...`) win.
69
+ await run(CODEX_BIN, [...providerOverrides(baseUrl, model), ...args], { env });
70
+ }
71
+ export const CodexAgent = {
72
+ id: 'codex',
73
+ displayName: 'Codex',
74
+ description: 'openai/codex — OpenAI coding agent CLI',
75
+ installMode: 'auto-npm',
76
+ installCheck,
77
+ install,
78
+ configure,
79
+ launch,
80
+ };
@@ -5,6 +5,7 @@ import { KiloAgent } from './kilo.js';
5
5
  import { ClineAgent } from './cline.js';
6
6
  import { RooAgent } from './roo.js';
7
7
  import { ContinueAgent } from './continue.js';
8
+ import { CodexAgent } from './codex.js';
8
9
  // Ordered by historical ARPU on tokenmix (highest first). New agents go to the bottom.
9
10
  export const AGENTS = [
10
11
  OpenCodeAgent,
@@ -14,6 +15,7 @@ export const AGENTS = [
14
15
  ClineAgent,
15
16
  RooAgent,
16
17
  ContinueAgent,
18
+ CodexAgent,
17
19
  ];
18
20
  export function findAgent(id) {
19
21
  return AGENTS.find((a) => a.id === id);
@@ -33,6 +33,8 @@ function agentDesc(id, fallback) {
33
33
  return t('desc.roo');
34
34
  case 'continue':
35
35
  return t('desc.continue');
36
+ case 'codex':
37
+ return t('desc.codex');
36
38
  default:
37
39
  return fallback;
38
40
  }
@@ -85,6 +85,7 @@ export const en = {
85
85
  'desc.cline': 'cline/cline — VSCode extension (config-only)',
86
86
  'desc.roo': 'RooCodeInc/Roo-Code — VSCode extension (config-only)',
87
87
  'desc.continue': 'continuedev/continue — VSCode/JetBrains extension (config file)',
88
+ 'desc.codex': 'openai/codex — OpenAI coding agent CLI',
88
89
  // install hints
89
90
  'install.willInstallVia': 'Will install via: {cmd}',
90
91
  'aider.hintNeedPython': 'Aider requires Python 3. Install Python 3 from https://python.org/downloads, then come back and run `tokenmix aider` again.',
@@ -130,6 +131,9 @@ export const en = {
130
131
  'continue.noteKeepPrivate': 'Keep this API key private — anyone with it can spend your TokenMix balance.',
131
132
  'continue.hintMarketplace': 'Install "Continue" from the VSCode marketplace, then add the config below.',
132
133
  'continue.hintNoVscode': 'VSCode not detected on PATH. Install VSCode, then add the Continue extension, then use the config below.',
134
+ // codex configure notes (auto-npm CLI; launched with --config provider injection)
135
+ 'codex.noteUsing': 'Codex will use TokenMix via an OpenAI-compatible provider — your ~/.codex/config.toml is left untouched.',
136
+ 'codex.noteModel': 'Default model: {model} — override with `--config model=...`.',
133
137
  // command / option descriptions (--help)
134
138
  'cmd.program': 'Zero-config CLI to use any open-source coding agent with TokenMix as the unified LLM backend.',
135
139
  'cmd.login': 'Log in to TokenMix (default: browser device authorization)',
@@ -234,6 +238,7 @@ export const zh = {
234
238
  'desc.cline': 'cline/cline — VSCode 扩展(仅配置)',
235
239
  'desc.roo': 'RooCodeInc/Roo-Code — VSCode 扩展(仅配置)',
236
240
  'desc.continue': 'continuedev/continue — VSCode/JetBrains 扩展(配置文件)',
241
+ 'desc.codex': 'openai/codex — OpenAI 编程 agent CLI',
237
242
  // install hints
238
243
  'install.willInstallVia': '将自动安装:{cmd}',
239
244
  'aider.hintNeedPython': 'Aider 需要 Python 3。请从 https://python.org/downloads 安装 Python 3,然后重新运行 `tokenmix aider`。',
@@ -276,6 +281,8 @@ export const zh = {
276
281
  'continue.noteKeepPrivate': '请妥善保管此 API 密钥 —— 任何人拿到它都能消耗你的 TokenMix 余额。',
277
282
  'continue.hintMarketplace': '从 VSCode 应用市场安装 "Continue",然后添加下面的配置。',
278
283
  'continue.hintNoVscode': '未在 PATH 中检测到 VSCode。请先安装 VSCode,再添加 Continue 扩展,然后使用下面的配置。',
284
+ 'codex.noteUsing': 'Codex 将通过 OpenAI 兼容的 provider 使用 TokenMix —— 不会改动你的 ~/.codex/config.toml。',
285
+ 'codex.noteModel': '默认模型:{model} —— 可用 `--config model=...` 覆盖。',
279
286
  // command / option descriptions (--help)
280
287
  'cmd.program': '零配置 CLI:以 TokenMix 作为统一 LLM 后端,驱动任意开源编程 agent。',
281
288
  'cmd.login': '登录 TokenMix(默认:浏览器设备授权)',
@@ -371,6 +378,7 @@ export const ja = {
371
378
  'desc.cline': 'cline/cline — VSCode 拡張機能(設定のみ)',
372
379
  'desc.roo': 'RooCodeInc/Roo-Code — VSCode 拡張機能(設定のみ)',
373
380
  'desc.continue': 'continuedev/continue — VSCode/JetBrains 拡張機能(設定ファイル)',
381
+ 'desc.codex': 'openai/codex — OpenAI のコーディング agent CLI',
374
382
  'install.willInstallVia': '次の方法でインストールします:{cmd}',
375
383
  'aider.hintNeedPython': 'Aider には Python 3 が必要です。https://python.org/downloads から Python 3 をインストールし、再度 `tokenmix aider` を実行してください。',
376
384
  'aider.hintNotInstalled': 'Aider はインストールされていません。別のターミナルで次を実行してください:\n {cmd}\nその後 `tokenmix aider` を再実行してください — TokenMix のログインは保存済みなので自動的に反映されます。',
@@ -408,6 +416,8 @@ export const ja = {
408
416
  'continue.noteKeepPrivate': 'この API キーは公開しないでください — 入手した人は誰でもあなたの TokenMix 残高を使えます。',
409
417
  'continue.hintMarketplace': 'VSCode マーケットプレイスから "Continue" をインストールし、下の設定を追加してください。',
410
418
  'continue.hintNoVscode': 'PATH に VSCode が見つかりません。VSCode をインストールし、Continue 拡張機能を追加してから、下の設定を使用してください。',
419
+ 'codex.noteUsing': 'Codex は OpenAI 互換プロバイダー経由で TokenMix を使用します — ~/.codex/config.toml は変更されません。',
420
+ 'codex.noteModel': 'デフォルトモデル:{model} — `--config model=...` で上書きできます。',
411
421
  'cmd.program': 'TokenMix を統一 LLM バックエンドとして、あらゆるオープンソースのコーディング agent を使うためのゼロ設定 CLI。',
412
422
  'cmd.login': 'TokenMix にログイン(デフォルト:ブラウザでのデバイス認証)',
413
423
  'cmd.loginKey': 'API キーを直接貼り付け(ブラウザ認証をスキップ、CI に便利)',
@@ -502,6 +512,7 @@ export const ko = {
502
512
  'desc.cline': 'cline/cline — VSCode 확장 (설정 전용)',
503
513
  'desc.roo': 'RooCodeInc/Roo-Code — VSCode 확장 (설정 전용)',
504
514
  'desc.continue': 'continuedev/continue — VSCode/JetBrains 확장 (설정 파일)',
515
+ 'desc.codex': 'openai/codex — OpenAI 코딩 agent CLI',
505
516
  'install.willInstallVia': '다음 방법으로 설치합니다: {cmd}',
506
517
  'aider.hintNeedPython': 'Aider에는 Python 3가 필요합니다. https://python.org/downloads 에서 Python 3를 설치한 뒤 다시 `tokenmix aider`를 실행하세요.',
507
518
  'aider.hintNotInstalled': 'Aider가 설치되어 있지 않습니다. 다른 터미널에서 다음을 실행하세요:\n {cmd}\n그런 다음 다시 `tokenmix aider`를 실행하세요 — TokenMix 로그인이 이미 저장되어 있어 자동으로 적용됩니다.',
@@ -539,6 +550,8 @@ export const ko = {
539
550
  'continue.noteKeepPrivate': '이 API 키를 비공개로 유지하세요 — 키를 가진 사람은 누구나 당신의 TokenMix 잔액을 쓸 수 있습니다.',
540
551
  'continue.hintMarketplace': 'VSCode 마켓플레이스에서 "Continue"를 설치한 뒤 아래 설정을 추가하세요.',
541
552
  'continue.hintNoVscode': 'PATH에서 VSCode를 찾을 수 없습니다. VSCode를 설치하고 Continue 확장을 추가한 뒤 아래 설정을 사용하세요.',
553
+ 'codex.noteUsing': 'Codex는 OpenAI 호환 provider를 통해 TokenMix를 사용합니다 — ~/.codex/config.toml은 변경되지 않습니다.',
554
+ 'codex.noteModel': '기본 모델: {model} — `--config model=...`으로 재정의할 수 있습니다.',
542
555
  'cmd.program': 'TokenMix를 통합 LLM 백엔드로 사용하여 모든 오픈소스 코딩 agent를 쓰는 제로 설정 CLI.',
543
556
  'cmd.login': 'TokenMix에 로그인 (기본값: 브라우저 기기 인증)',
544
557
  'cmd.loginKey': 'API 키를 직접 붙여넣기 (브라우저 절차 생략, CI에 유용)',
@@ -633,6 +646,7 @@ export const es = {
633
646
  'desc.cline': 'cline/cline — extensión de VSCode (solo configuración)',
634
647
  'desc.roo': 'RooCodeInc/Roo-Code — extensión de VSCode (solo configuración)',
635
648
  'desc.continue': 'continuedev/continue — extensión de VSCode/JetBrains (archivo de configuración)',
649
+ 'desc.codex': 'openai/codex — CLI del agente de programación de OpenAI',
636
650
  'install.willInstallVia': 'Se instalará mediante: {cmd}',
637
651
  'aider.hintNeedPython': 'Aider requiere Python 3. Instala Python 3 desde https://python.org/downloads y vuelve a ejecutar `tokenmix aider`.',
638
652
  'aider.hintNotInstalled': 'Aider no está instalado. Ejecuta esto en otra terminal:\n {cmd}\nLuego vuelve a ejecutar `tokenmix aider`: tu sesión de TokenMix ya está guardada, así que se detectará automáticamente.',
@@ -670,6 +684,8 @@ export const es = {
670
684
  'continue.noteKeepPrivate': 'Mantén privada esta clave de API: cualquiera que la tenga puede gastar tu saldo de TokenMix.',
671
685
  'continue.hintMarketplace': 'Instala "Continue" desde el marketplace de VSCode y luego añade la configuración de abajo.',
672
686
  'continue.hintNoVscode': 'No se detectó VSCode en el PATH. Instala VSCode, añade la extensión Continue y luego usa la configuración de abajo.',
687
+ 'codex.noteUsing': 'Codex usará TokenMix mediante un proveedor compatible con OpenAI: tu ~/.codex/config.toml no se modifica.',
688
+ 'codex.noteModel': 'Modelo por defecto: {model} — anúlalo con `--config model=...`.',
673
689
  'cmd.program': 'CLI sin configuración para usar cualquier agent de programación de código abierto con TokenMix como backend LLM unificado.',
674
690
  'cmd.login': 'Inicia sesión en TokenMix (predeterminado: autorización de dispositivo por navegador)',
675
691
  'cmd.loginKey': 'Pega una clave de API directamente (omite el navegador, útil para CI)',
@@ -764,6 +780,7 @@ export const fr = {
764
780
  'desc.cline': 'cline/cline — extension VSCode (configuration seule)',
765
781
  'desc.roo': 'RooCodeInc/Roo-Code — extension VSCode (configuration seule)',
766
782
  'desc.continue': 'continuedev/continue — extension VSCode/JetBrains (fichier de configuration)',
783
+ 'desc.codex': 'openai/codex — CLI de l’agent de codage d’OpenAI',
767
784
  'install.willInstallVia': 'Sera installé via : {cmd}',
768
785
  'aider.hintNeedPython': 'Aider nécessite Python 3. Installez Python 3 depuis https://python.org/downloads, puis relancez `tokenmix aider`.',
769
786
  'aider.hintNotInstalled': 'Aider n’est pas installé. Exécutez ceci dans un autre terminal :\n {cmd}\nPuis relancez `tokenmix aider` — votre connexion TokenMix est déjà enregistrée, elle sera donc prise en compte automatiquement.',
@@ -801,6 +818,8 @@ export const fr = {
801
818
  'continue.noteKeepPrivate': 'Gardez cette clé API privée — quiconque la détient peut dépenser votre solde TokenMix.',
802
819
  'continue.hintMarketplace': 'Installez « Continue » depuis la marketplace VSCode, puis ajoutez la configuration ci-dessous.',
803
820
  'continue.hintNoVscode': 'VSCode introuvable dans le PATH. Installez VSCode, ajoutez l’extension Continue, puis utilisez la configuration ci-dessous.',
821
+ 'codex.noteUsing': 'Codex utilisera TokenMix via un fournisseur compatible OpenAI — votre ~/.codex/config.toml n’est pas modifié.',
822
+ 'codex.noteModel': 'Modèle par défaut : {model} — remplacez-le avec `--config model=...`.',
804
823
  'cmd.program': 'CLI sans configuration pour utiliser n’importe quel agent de codage open source avec TokenMix comme backend LLM unifié.',
805
824
  'cmd.login': 'Se connecter à TokenMix (par défaut : autorisation de l’appareil via le navigateur)',
806
825
  'cmd.loginKey': 'Coller directement une clé API (ignore le navigateur, utile pour la CI)',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokenmix",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Zero-config CLI to use any open-source coding agent with TokenMix as the unified LLM backend.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,6 +30,7 @@
30
30
  "cline",
31
31
  "roo-code",
32
32
  "continue",
33
+ "codex",
33
34
  "coding-agent"
34
35
  ],
35
36
  "license": "MIT",