mimo2codex 0.1.3 → 0.1.6

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/AGENTS.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # Agent instructions for the mimo2codex repo
2
2
 
3
3
  This repo is a local proxy that lets the latest OpenAI Codex CLI / desktop talk
4
- to **Xiaomi MiMo V2.5** by translating the Responses API to MiMo's Chat
5
- Completions API. When you (the agent) run inside Codex pointed at this proxy,
6
- the chat backend is **MiMo, not OpenAI** adjust your assumptions accordingly.
4
+ to **Xiaomi MiMo V2.5** and **DeepSeek V4 Pro** by translating the Responses
5
+ API to upstream Chat Completions. Routing is per-request: the client-supplied
6
+ `model` field decides which provider serves the request (see `src/providers/`
7
+ and `src/server.ts:selectProvider`). When you (the agent) run inside Codex
8
+ pointed at this proxy, the chat backend is **MiMo or DeepSeek, not OpenAI** —
9
+ adjust your assumptions accordingly.
7
10
 
8
11
  ## Hard rules
9
12
 
@@ -28,8 +31,20 @@ the chat backend is **MiMo, not OpenAI** — adjust your assumptions accordingly
28
31
 
29
32
  ## Where things are
30
33
 
31
- - `src/` — TypeScript source for the mimo2codex proxy itself (Node 18+).
32
- Compiled to `dist/` via `npm run build`. Tests in `test/`.
34
+ - `src/` — TypeScript source for the proxy (Node 18+). Compiled to `dist/`
35
+ via `npm run build`. Tests in `test/` (vitest, 100 cases).
36
+ - `providers/` — Provider abstraction (`types.ts`, `mimo.ts`, `deepseek.ts`,
37
+ `registry.ts`). MiMo-specific behavior (web_search builtin, thinking
38
+ injection, token-plan host inference) is confined to `mimo.ts` hooks; do
39
+ NOT leak it to the generic translate/upstream layers.
40
+ - `db/` — better-sqlite3 persistence (chat logs, model catalog, aliases,
41
+ settings). Default at `~/.mimo2codex/data.db`. Disabled with `--no-admin`.
42
+ - `admin/router.ts` — `/admin/api/*` REST + SPA hosting at `/admin/`.
43
+ - `translate/`, `upstream/`, `util/` — generic, provider-agnostic.
44
+ - `web/` — Vite + React 18 admin console (separate workspace). Builds to
45
+ `dist/web/`. Run `npm run web:install` once, then `npm run web:build` (or
46
+ `npm run build:all` to do both backend + frontend). Dev: `npm run web:dev`
47
+ on port 5173 with `/admin/api` proxied to 8788.
33
48
  - `scripts/install.sh` and `scripts/install.ps1` — bootstrap scripts (clone or
34
49
  in-repo run, install deps, build, test).
35
50
  - `mimoskill/` — a self-contained directory with helpers for MiMo + workarounds
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > English · [中文文档](./README.zh.md)
4
4
 
5
- Local proxy that lets the **latest OpenAI Codex CLI / desktop** talk to **Xiaomi MiMo V2.5**, by translating Codex's Responses API ↔ MiMo's Chat Completions API on the fly. Stateless, no telemetry, runs on `127.0.0.1`.
5
+ Local proxy that lets the **latest OpenAI Codex CLI / desktop** talk to **Xiaomi MiMo V2.5** and **DeepSeek V4 Pro**, by translating Codex's Responses API ↔ upstream Chat Completions on the fly. Per-request routing by `model` field, optional admin web console, runs on `127.0.0.1`.
6
6
 
7
7
  ![mimo2codex install + run](https://raw.githubusercontent.com/7as0nch/mimo2codex/main/images/npminstall.jpg)
8
8
 
@@ -15,11 +15,17 @@ Conceptually a sibling of [openrouter](https://openrouter.ai), [claude-code-rout
15
15
  ## What works
16
16
 
17
17
  - ✅ Codex CLI `wire_api = "responses"` and Codex desktop app
18
+ - ✅ Multi-provider — **MiMo** + **DeepSeek**, mixed within one process (per-request routing by `model` field)
19
+ - ✅ MiMo models: `mimo-v2.5-pro` / `mimo-v2.5-pro[1m]` / `mimo-v2-flash`
20
+ - ✅ DeepSeek models: `deepseek-v4-pro` (default) / `deepseek-v4-flash` / `deepseek-chat` / `deepseek-reasoner`
18
21
  - ✅ Tool calling — function tools, parallel calls, `local_shell`, `custom`, MCP `namespace`
19
- - ✅ Web search — translated to MiMo's native `web_search` builtin (requires plugin activation)
22
+ - ✅ Web search — translated to MiMo's native `web_search` builtin (requires plugin activation); auto-skipped on DeepSeek
20
23
  - ✅ Vision — only `mimo-v2.5` and `mimo-v2-omni`; pro/flash auto-strip images with a placeholder
21
24
  - ✅ 1M context — pass `mimo-v2.5-pro[1m]`
22
25
  - ✅ Reasoning passthrough (with `--no-reasoning` to hide)
26
+ - ✅ MiMo host auto-routing — `tp-*` keys → token-plan host, `sk-*` keys → pay-as-you-go host
27
+ - ✅ Local admin web UI at `http://127.0.0.1:8788/admin/` — model catalog, alias mgmt, chat logs, token stats, provider config
28
+ - ✅ sqlite persistence (default `~/.mimo2codex/data.db`, override with `--data-dir`)
23
29
  - ✅ cc-switch integration (`mimo2codex print-cc-switch` outputs paste-ready snippets)
24
30
  - ⚠️ **`/hatch` custom pet generation** — pure MiMo can't do this. Codex's `/hatch` is hardcoded to call OpenAI's `image_gen` tool client-side, and we can't intercept that from the proxy layer. MiMo also has no image-generation endpoint. Workaround via `mimoskill/` (free, no OpenAI key required) — see below.
25
31
 
@@ -52,18 +58,43 @@ Requires Node.js ≥ 18.
52
58
 
53
59
  ## Use
54
60
 
55
- ### 1. Get a MiMo API key
61
+ ### 1. Get an API key
56
62
 
57
- [platform.xiaomimimo.com](https://platform.xiaomimimo.com) Console API Keys. Either pay-as-you-go (`sk-xxx`) or token-plan (`tp-xxx`).
63
+ | Provider | Console | Key prefix |
64
+ |---|---|---|
65
+ | MiMo | [platform.xiaomimimo.com](https://platform.xiaomimimo.com) → Console → API Keys | `sk-` (pay-as-you-go) / `tp-` (token-plan) |
66
+ | DeepSeek | [api-docs.deepseek.com](https://api-docs.deepseek.com/zh-cn/) | `sk-` |
58
67
 
59
68
  ### 2. Start the proxy
60
69
 
70
+ **MiMo only** (default):
71
+
61
72
  ```bash
62
73
  export MIMO_API_KEY=sk-xxxxxxxxxxxxxxxx
63
74
  mimo2codex
64
75
  ```
65
76
 
66
- The startup banner prints the exact `auth.json` + `config.toml` snippets to paste into `~/.codex/`. Default works for both Codex CLI and desktop without any env-var dance.
77
+ **DeepSeek only**:
78
+
79
+ ```bash
80
+ export DS_API_KEY=sk-xxxxxxxxxxxxxxxx # or DEEPSEEK_API_KEY
81
+ mimo2codex --model ds
82
+ ```
83
+
84
+ **Both providers at once** (per-request routing — sending `mimo-v2.5-pro` goes to MiMo, sending `deepseek-v4-pro` goes to DeepSeek):
85
+
86
+ ```bash
87
+ export MIMO_API_KEY=sk-mimo-key
88
+ export DS_API_KEY=sk-deepseek-key
89
+ mimo2codex # default fallback: mimo
90
+ mimo2codex --model ds # default fallback: ds (unknown model fields go to ds)
91
+ ```
92
+
93
+ The startup banner prints the `auth.json` + `config.toml` snippets, the enabled providers, the admin UI URL and the data directory. Default works for both Codex CLI and desktop without any env-var dance.
94
+
95
+ > **What `--model` actually does**: it picks the **default / fallback** provider — not a hard switch. When the client-supplied `model` field matches any enabled provider's catalog (including aliases), the request is routed to that provider regardless of `--model`. `--model` only matters when:
96
+ > 1. Only one provider's key is configured — `--model` must point at it, otherwise startup errors out.
97
+ > 2. The client sends a model id that no provider recognizes (e.g. `gpt-4o`) — it falls back to the `--model` provider's `defaultModel`.
67
98
 
68
99
  ### 3. Configure Codex
69
100
 
@@ -96,14 +127,46 @@ Pet, tool calls, reasoning, multi-turn — all just work. Pass `--no-reasoning`
96
127
 
97
128
  cc-switch's "Fetch Models" button calls `/v1/models`, which mimo2codex implements — the dropdown auto-lists `mimo-v2.5-pro`, `mimo-v2.5-pro[1m]`, `mimo-v2-flash`.
98
129
 
130
+ ## Admin console
131
+
132
+ Browse to `http://127.0.0.1:8788/admin/` after start.
133
+
134
+ **Dashboard** — 24h / 7d / 30d token usage, error rate, requests aggregated by provider/model, model-mapping records, last 10 requests.
135
+
136
+ ![Admin console · dashboard](https://raw.githubusercontent.com/7as0nch/mimo2codex/main/images/admin-dashboard.png)
137
+
138
+ **Logs** — filter by provider, paginate by time, prune old records; status codes are color-coded and error snippets expand inline.
139
+
140
+ ![Admin console · chat logs](https://raw.githubusercontent.com/7as0nch/mimo2codex/main/images/admin-logs.png)
141
+
142
+ **Models** — provider tabs; builtin models are read-only, custom models + aliases (client-supplied `model` → upstream id) editable.
143
+
144
+ **Settings** — provider status, base URL, default model, UI prefs. **API keys are not stored in the UI** — they must come from environment variables; the UI only displays status and copy-paste shell snippets.
145
+
146
+ Data lives in sqlite (`~/.mimo2codex/data.db`); override with `--data-dir <path>` or disable entirely with `--no-admin`.
147
+
148
+ ### Providers and model ids
149
+
150
+ | Provider | Shortcut | Env var | Default base URL | Default model | Models |
151
+ |---|---|---|---|---|---|
152
+ | MiMo | `mimo` | `MIMO_API_KEY` | `https://api.xiaomimimo.com/v1` | `mimo-v2.5-pro` | `mimo-v2.5-pro` / `mimo-v2.5-pro[1m]` / `mimo-v2-flash` |
153
+ | DeepSeek | `ds` | `DS_API_KEY` or `DEEPSEEK_API_KEY` | `https://api.deepseek.com/v1` | `deepseek-v4-pro` | `deepseek-v4-pro` / `deepseek-v4-flash` / `deepseek-chat`* / `deepseek-reasoner`* |
154
+
155
+ *legacy, deprecated 2026-07-24, both alias the v4-flash thinking / non-thinking modes.
156
+
157
+ > MiMo's `tp-*` keys auto-route to the token-plan host (`https://token-plan-cn.xiaomimimo.com/v1`); `sk-*` keys use the pay-as-you-go host. Setting `MIMO_BASE_URL` / `--base-url` explicitly overrides this; the startup banner prints a ⚠ warning if your key prefix and host don't match.
158
+
99
159
  ## CLI flags
100
160
 
101
161
  | Flag | Env | Default | Notes |
102
162
  |---|---|---|---|
163
+ | `--model <shortcut>` | `MIMO2CODEX_DEFAULT_PROVIDER` | `mimo` | default provider: `mimo` or `ds` |
103
164
  | `--port`, `-p` | `MIMO2CODEX_PORT` | `8788` | listen port |
104
165
  | `--host` | `MIMO2CODEX_HOST` | `127.0.0.1` | bind host |
105
- | `--base-url` | `MIMO_BASE_URL` | `https://api.xiaomimimo.com/v1` | use `https://token-plan-cn.xiaomimimo.com/v1` for `tp-*` keys |
106
- | `--api-key` | `MIMO_API_KEY` | _required_ | upstream MiMo key |
166
+ | `--base-url` | `MIMO_BASE_URL` / `DEEPSEEK_BASE_URL` | see table above | base URL for the default provider |
167
+ | `--api-key` | `MIMO_API_KEY` / `DS_API_KEY` / `DEEPSEEK_API_KEY` | _at least one required_ | api key for the default provider (other providers read their own env vars) |
168
+ | `--data-dir <path>` | `MIMO2CODEX_DATA_DIR` | `~/.mimo2codex` | sqlite + admin UI data directory |
169
+ | `--no-admin` | `MIMO2CODEX_NO_ADMIN=1` | off | disable the admin UI + sqlite logging |
107
170
  | `--no-reasoning` | `MIMO2CODEX_NO_REASONING=1` | off | hide reasoning from Codex (still preserved between turns) |
108
171
  | `--verbose`, `-v` | `MIMO2CODEX_VERBOSE=1` | off | log every translated request body |
109
172
 
@@ -177,6 +240,57 @@ If you actually want web search to work upstream, activate the Web Search Plugin
177
240
 
178
241
  </details>
179
242
 
243
+ <details>
244
+ <summary><b>Startup banner shows ⚠ "sk-* key needs the pay-as-you-go host..." / "tp-* key needs the token-plan host..."</b></summary>
245
+
246
+ Stale `MIMO_BASE_URL` in your shell is overriding the key-prefix inference. Resolution priority is `--base-url > MIMO_BASE_URL > key-prefix inference > default`, so env wins over inference.
247
+
248
+ PowerShell:
249
+
250
+ ```powershell
251
+ echo $env:MIMO_BASE_URL # check
252
+ Remove-Item Env:MIMO_BASE_URL # clear in current session
253
+ [Environment]::GetEnvironmentVariable('MIMO_BASE_URL','User') # check user-level
254
+ [Environment]::SetEnvironmentVariable('MIMO_BASE_URL',$null,'User') # remove user-level permanently
255
+ ```
256
+
257
+ bash / zsh:
258
+
259
+ ```bash
260
+ echo $MIMO_BASE_URL
261
+ unset MIMO_BASE_URL
262
+ ```
263
+
264
+ Once cleared, `sk-*` keys auto-use `https://api.xiaomimimo.com/v1` and `tp-*` keys auto-use `https://token-plan-cn.xiaomimimo.com/v1`.
265
+
266
+ </details>
267
+
268
+ <details>
269
+ <summary><b>DeepSeek returns 401 Unauthorized</b></summary>
270
+
271
+ Confirm `DS_API_KEY` (or `DEEPSEEK_API_KEY`) is what's actually being picked up — DeepSeek keys are issued on the DeepSeek console only and don't interchange with MiMo keys.
272
+
273
+ ```bash
274
+ mimo2codex --model ds --verbose
275
+ # The startup banner prints `api key: sk-x…xxxx` — verify it's the DS one.
276
+ ```
277
+
278
+ </details>
279
+
280
+ <details>
281
+ <summary><b>Admin UI returns 503 "Admin UI not built"</b></summary>
282
+
283
+ The frontend bundle hasn't been built yet. Run `npm run build:all` (compiles backend with tsc, then frontend with vite) to populate `dist/web/`. To build only the frontend: `npm run web:install && npm run web:build`.
284
+
285
+ </details>
286
+
287
+ <details>
288
+ <summary><b>better-sqlite3 fails to compile during npm install</b></summary>
289
+
290
+ Usually caused by an unusual Node distribution (e.g., Electron-bundled Node). Node ≥ 18 from nodejs.org normally pulls a prebuilt binary without invoking node-gyp. If you only want the proxy and not the admin UI, pass `--no-admin` — the db module is not loaded in that mode.
291
+
292
+ </details>
293
+
180
294
  <details>
181
295
  <summary><b>Codex says "I'll do X" then ends the turn without calling any tool</b></summary>
182
296
 
@@ -255,11 +369,18 @@ For higher quality, set `PET_OPENAI_API_KEY=sk-real-openai-key` (separate from `
255
369
  ![Project structure](https://raw.githubusercontent.com/7as0nch/mimo2codex/main/tutorial-video/assets/04-agent-docs.jpg)
256
370
 
257
371
  ```
258
- src/ # TypeScript source (cli, server, translate, upstream, util)
259
- test/ # 46 vitest tests
372
+ src/
373
+ cli.ts, server.ts, config.ts # entry, routing, multi-provider config
374
+ providers/{types,mimo,deepseek,registry}.ts # Provider abstraction + MiMo / DeepSeek impls
375
+ upstream/openaiCompatClient.ts # generic Chat Completions client + provider error hook
376
+ translate/ # Responses ↔ Chat Completions translation
377
+ admin/router.ts # /admin/api/* REST + /admin/* SPA static hosting
378
+ db/{index,logs,settings,models}.ts # better-sqlite3 layer + migrations + seed
379
+ test/ # 100 vitest cases
380
+ web/ # Vite + React 18 admin console (builds to dist/web/)
260
381
  mimoskill/ # MiMo helpers + pet generation workaround
261
382
  scripts/install.{sh,ps1} # one-liner bootstrap
262
- dist/ # tsc output (generated)
383
+ dist/ # tsc + vite output (generated)
263
384
  AGENTS.md # Codex-agent instructions (don't import openai, use mimoskill)
264
385
  PUBLISHING.md # maintainer release runbook
265
386
  ```
@@ -269,12 +390,16 @@ PUBLISHING.md # maintainer release runbook
269
390
  ```bash
270
391
  git clone https://github.com/7as0nch/mimo2codex && cd mimo2codex
271
392
  npm install
272
- npm run dev # tsx, no build step
273
- npm test # 46 vitest cases
274
- npm run build # produces dist/
393
+ npm run web:install # frontend deps (first run only)
394
+ npm run dev # backend via tsx, no build step
395
+ npm run web:dev # vite dev server (5173, proxies /admin/api → 8788) — separate terminal
396
+ npm test # 100 vitest cases
397
+ npm run build # backend only → dist/cli.js
398
+ npm run web:build # frontend only → dist/web/
399
+ npm run build:all # both at once
275
400
  ```
276
401
 
277
- To register `mimo2codex` globally from your local checkout: `npm run build && npm link`.
402
+ To register `mimo2codex` globally from your local checkout: `npm run build:all && npm link`.
278
403
 
279
404
  ## License
280
405
 
package/README.zh.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > [English](./README.md) · 中文
4
4
 
5
- 让**最新版** OpenAI Codex CLI / Codex 桌面端无缝接入**小米 MiMo V2.5** 的本地代理。把 Codex 的 Responses API 实时翻译成 MiMo 的 Chat Completions API,纯本地无状态。
5
+ 让**最新版** OpenAI Codex CLI / Codex 桌面端无缝接入**小米 MiMo V2.5** 与 **DeepSeek V4 Pro** 的本地代理。把 Codex 的 Responses API 实时翻译成上游的 Chat Completions API,按客户端发的 `model` 字段在 provider 之间自动路由。可配 admin Web 控制台。
6
6
 
7
7
  ![mimo2codex 安装与启动](https://raw.githubusercontent.com/7as0nch/mimo2codex/main/images/npminstall.jpg)
8
8
 
@@ -15,11 +15,17 @@
15
15
  ## 支持
16
16
 
17
17
  - ✅ Codex CLI 0.x(`wire_api = "responses"`)+ 桌面端
18
+ - ✅ 多 provider:**MiMo** + **DeepSeek**,同实例混用(按 `model` 字段路由)
19
+ - ✅ MiMo 模型:`mimo-v2.5-pro` / `mimo-v2.5-pro[1m]` / `mimo-v2-flash`
20
+ - ✅ DeepSeek 模型:`deepseek-v4-pro`(默认)/ `deepseek-v4-flash` / `deepseek-chat` / `deepseek-reasoner`
18
21
  - ✅ 工具调用——function tools、并行调用、`local_shell`、`custom`、MCP `namespace`
19
- - ✅ 联网搜索——翻译成 MiMo 原生 `web_search` builtin(需在控制台激活 Web Search Plugin
22
+ - ✅ 联网搜索——翻译成 MiMo 原生 `web_search` builtin(需在控制台激活 Web Search Plugin);DeepSeek 路径自动跳过
20
23
  - ✅ 视觉——`mimo-v2.5` / `mimo-v2-omni` 走视觉路径;pro/flash 自动剥图 + 占位文本
21
24
  - ✅ 1M 长上下文——传 `mimo-v2.5-pro[1m]`
22
25
  - ✅ 思维链透传(`--no-reasoning` 隐藏)
26
+ - ✅ MiMo 主机自动切换:`tp-*` key → token-plan 主机,`sk-*` key → pay-as-you-go 主机
27
+ - ✅ 本地 Admin Web UI(`http://127.0.0.1:8788/admin/`):模型清单 / 别名管理 / 聊天日志 / Token 统计 / Provider 配置
28
+ - ✅ sqlite 持久化(默认 `~/.mimo2codex/data.db`,`--data-dir` 可改)
23
29
  - ✅ cc-switch 集成(`mimo2codex print-cc-switch` 输出粘贴片段)
24
30
  - ⚠️ **`/hatch` 自定义宠物生成**——纯 MiMo 做不到。Codex 的 `/hatch` 在客户端硬编码调 OpenAI 的 `image_gen` 工具,这步代理拦不住;MiMo 自己又没有图像生成 endpoint。绕路方案走 `mimoskill/`(免费,不要 OpenAI key),见下文。
25
31
 
@@ -52,18 +58,43 @@ irm https://raw.githubusercontent.com/7as0nch/mimo2codex/main/scripts/install.ps
52
58
 
53
59
  ## 使用
54
60
 
55
- ### 1. 拿一个 MiMo API Key
61
+ ### 1. API Key
56
62
 
57
- [platform.xiaomimimo.com](https://platform.xiaomimimo.com) 控制台 API Keys 创建。`sk-` 开头是按量付费,`tp-` 开头是 Token 套餐。
63
+ | Provider | 控制台 | Key 前缀 |
64
+ |---|---|---|
65
+ | MiMo | [platform.xiaomimimo.com](https://platform.xiaomimimo.com) → 控制台 → API Keys | `sk-`(按量)/ `tp-`(Token 套餐) |
66
+ | DeepSeek | [api-docs.deepseek.com](https://api-docs.deepseek.com/zh-cn/) | `sk-` |
58
67
 
59
68
  ### 2. 启动代理
60
69
 
70
+ **只用 MiMo**(默认):
71
+
61
72
  ```bash
62
73
  export MIMO_API_KEY=sk-xxxxxxxxxxxxxxxx
63
74
  mimo2codex
64
75
  ```
65
76
 
66
- 启动横幅会直接打印好该贴到 `~/.codex/` 的 `auth.json` 和 `config.toml` 内容。默认走 auth.json 方式——CLI 和桌面端都能用,不依赖任何环境变量。
77
+ **只用 DeepSeek**:
78
+
79
+ ```bash
80
+ export DS_API_KEY=sk-xxxxxxxxxxxxxxxx # 或 DEEPSEEK_API_KEY
81
+ mimo2codex --model ds
82
+ ```
83
+
84
+ **两个 provider 同时启用**(请求按 `model` 字段自动路由——发 `mimo-v2.5-pro` 走 MiMo、发 `deepseek-v4-pro` 走 DeepSeek):
85
+
86
+ ```bash
87
+ export MIMO_API_KEY=sk-mimo-key
88
+ export DS_API_KEY=sk-deepseek-key
89
+ mimo2codex # 默认 mimo
90
+ mimo2codex --model ds # 默认 ds(未匹配的 model 字段走 ds)
91
+ ```
92
+
93
+ 启动横幅会直接打印好该贴到 `~/.codex/` 的 `auth.json` 和 `config.toml` 内容,并显示已启用的 provider、admin UI 地址、数据目录。默认走 auth.json 方式——CLI 和桌面端都能用,不依赖任何环境变量。
94
+
95
+ > **`--model` 的语义**:决定**默认 / fallback** provider,不是硬开关。当客户端发的 `model` 字段命中任一已启用 provider 的目录(含别名)时,**自动按该 provider 路由**,与 `--model` 无关。`--model` 只在两种情况下生效:
96
+ > 1. 只配了一个 provider 的 key——必须把 `--model` 指到那个 provider,否则启动报错
97
+ > 2. 客户端发了未知的 model 字段(如 `gpt-4o`)——走 `--model` 指定 provider 的 `defaultModel`
67
98
 
68
99
  ### 3. 配置 Codex
69
100
 
@@ -96,15 +127,47 @@ codex
96
127
 
97
128
  cc-switch 的「获取模型」按钮调 `/v1/models`,mimo2codex 已实现——下拉里能直接选 `mimo-v2.5-pro` / `mimo-v2.5-pro[1m]` / `mimo-v2-flash`。
98
129
 
130
+ ## Admin 控制台
131
+
132
+ 启动后浏览器访问 `http://127.0.0.1:8788/admin/`。
133
+
134
+ **概览**——24h / 7d / 30d Token 用量、错误率、按 provider/模型聚合的请求统计、模型映射记录、最近 10 条请求。
135
+
136
+ ![Admin 控制台 · 概览](https://raw.githubusercontent.com/7as0nch/mimo2codex/main/images/admin-dashboard.png)
137
+
138
+ **日志**——按 provider 过滤、按时间分页、按时间清理旧记录;状态码异常着色、错误片段就地展开。
139
+
140
+ ![Admin 控制台 · 聊天日志](https://raw.githubusercontent.com/7as0nch/mimo2codex/main/images/admin-logs.png)
141
+
142
+ **模型**——按 provider tab 切换;内置模型只读,可新增自定义模型 + 别名(客户端发的 model 字段 → 上游 ID 的映射)。
143
+
144
+ **设置**——provider 状态、base URL、默认模型、UI 偏好。**API key 不在 UI 里存储**——必须走环境变量,UI 只展示状态 + 操作指引。
145
+
146
+ 数据存 sqlite(`~/.mimo2codex/data.db`),可 `--data-dir <path>` 改路径,或 `--no-admin` 关闭。
147
+
148
+ ### Provider 与模型 ID
149
+
150
+ | Provider | 短码 | Env 变量 | 默认 baseUrl | 默认模型 | 模型清单 |
151
+ |---|---|---|---|---|---|
152
+ | MiMo | `mimo` | `MIMO_API_KEY` | `https://api.xiaomimimo.com/v1` | `mimo-v2.5-pro` | `mimo-v2.5-pro` / `mimo-v2.5-pro[1m]` / `mimo-v2-flash` |
153
+ | DeepSeek | `ds` | `DS_API_KEY` 或 `DEEPSEEK_API_KEY` | `https://api.deepseek.com/v1` | `deepseek-v4-pro` | `deepseek-v4-pro` / `deepseek-v4-flash` / `deepseek-chat`* / `deepseek-reasoner`* |
154
+
155
+ *legacy,2026-07-24 弃用,对应 v4-flash 的非思考 / 思考双模。
156
+
157
+ > MiMo 的 `tp-*` key 自动用 token-plan 主机(`https://token-plan-cn.xiaomimimo.com/v1`),`sk-*` key 自动用 pay-as-you-go 主机。如果你显式设了 `MIMO_BASE_URL` / `--base-url`,那就以你的为准;启动横幅在 key 前缀和主机不匹配时会打 ⚠ 警告。
158
+
99
159
  ## CLI 参数速查
100
160
 
101
161
  | 参数 | 环境变量 | 默认 | 说明 |
102
162
  |---|---|---|---|
163
+ | `--model <shortcut>` | `MIMO2CODEX_DEFAULT_PROVIDER` | `mimo` | 默认 provider:`mimo` 或 `ds` |
103
164
  | `--port`, `-p` | `MIMO2CODEX_PORT` | `8788` | 监听端口 |
104
165
  | `--host` | `MIMO2CODEX_HOST` | `127.0.0.1` | 绑定地址 |
105
- | `--base-url` | `MIMO_BASE_URL` | `https://api.xiaomimimo.com/v1` | Token 套餐改 `https://token-plan-cn.xiaomimimo.com/v1` |
106
- | `--api-key` | `MIMO_API_KEY` | _必填_ | 上游 MiMo Key |
107
- | `--no-reasoning` | `MIMO2CODEX_NO_REASONING=1` | | 终端不显示思考(多轮工具调用仍回填给 MiMo) |
166
+ | `--base-url` | `MIMO_BASE_URL` / `DEEPSEEK_BASE_URL` | 见上表 | 当前默认 provider 的 base URL |
167
+ | `--api-key` | `MIMO_API_KEY` / `DS_API_KEY` / `DEEPSEEK_API_KEY` | _至少一个必填_ | 当前默认 provider key(其他 provider 走对应 env 变量) |
168
+ | `--data-dir <path>` | `MIMO2CODEX_DATA_DIR` | `~/.mimo2codex` | sqlite + admin UI 数据目录 |
169
+ | `--no-admin` | `MIMO2CODEX_NO_ADMIN=1` | 关 | 关闭 admin UI 与 sqlite 日志 |
170
+ | `--no-reasoning` | `MIMO2CODEX_NO_REASONING=1` | 关 | 终端不显示思考(多轮工具调用仍回填给上游) |
108
171
  | `--verbose`, `-v` | `MIMO2CODEX_VERBOSE=1` | 关 | 打印每次翻译的请求体 |
109
172
 
110
173
  子命令:
@@ -168,6 +231,57 @@ MiMo 的图像 API 要求每条带图消息必须同时有 `text` part。mimo2co
168
231
 
169
232
  </details>
170
233
 
234
+ <details>
235
+ <summary><b>启动横幅打 ⚠ 警告 "sk-* key 通常需要 pay-as-you-go 主机..." / "tp-* key 通常需要 token-plan 主机..."</b></summary>
236
+
237
+ `MIMO_BASE_URL` 残留在 shell 环境里覆盖了基于 key 前缀的自动推断。优先级是 `--base-url > MIMO_BASE_URL > 键前缀推断 > 默认`,env 比推断高。
238
+
239
+ PowerShell:
240
+
241
+ ```powershell
242
+ echo $env:MIMO_BASE_URL # 看一下
243
+ Remove-Item Env:MIMO_BASE_URL # 当前会话清掉
244
+ [Environment]::GetEnvironmentVariable('MIMO_BASE_URL','User') # 看用户级
245
+ [Environment]::SetEnvironmentVariable('MIMO_BASE_URL',$null,'User') # 永久清掉用户级
246
+ ```
247
+
248
+ bash / zsh:
249
+
250
+ ```bash
251
+ echo $MIMO_BASE_URL
252
+ unset MIMO_BASE_URL
253
+ ```
254
+
255
+ 清掉后 `sk-*` 自动走 `https://api.xiaomimimo.com/v1`,`tp-*` 自动走 `https://token-plan-cn.xiaomimimo.com/v1`。
256
+
257
+ </details>
258
+
259
+ <details>
260
+ <summary><b>DeepSeek 报 401 Unauthorized</b></summary>
261
+
262
+ 确认走了 `DS_API_KEY` 或 `DEEPSEEK_API_KEY`,并且 key 没贴错(DeepSeek 的 key 只在它自家控制台拿,不和 MiMo 互通)。
263
+
264
+ ```bash
265
+ mimo2codex --model ds --verbose
266
+ # 启动横幅会显示 api key: sk-x…xxxx,确认是 DS 那把
267
+ ```
268
+
269
+ </details>
270
+
271
+ <details>
272
+ <summary><b>Admin UI 打开是 503 "Admin UI not built"</b></summary>
273
+
274
+ 前端没构建过。`npm run build:all`(先 tsc 后端,再 vite 前端)一次性产出 `dist/cli.js` + `dist/web/`。或者只跑前端构建:`npm run web:install && npm run web:build`。
275
+
276
+ </details>
277
+
278
+ <details>
279
+ <summary><b>better-sqlite3 在 npm install 时编译失败</b></summary>
280
+
281
+ 通常是用了非主流 Node 版本(或 Electron 内置 Node)。要求 Node ≥ 18,绝大多数系统自动下载 prebuilt 二进制,不需要本地编译器。如果只想用代理本身不要 admin UI,加 `--no-admin`,db 模块就不会被加载。
282
+
283
+ </details>
284
+
171
285
  <details>
172
286
  <summary><b>Codex 说"我现在做 X"然后回合就结束了,没真调工具</b></summary>
173
287
 
@@ -246,11 +360,18 @@ bash mimoskill/scripts/install_pet.sh pet.png shiba
246
360
  ![项目结构](https://raw.githubusercontent.com/7as0nch/mimo2codex/main/tutorial-video/assets/04-agent-docs.jpg)
247
361
 
248
362
  ```
249
- src/ # TypeScript 源码(cli、server、translate、upstream、util)
250
- test/ # 46 vitest 用例
363
+ src/
364
+ cli.ts, server.ts, config.ts # 入口 + 路由 + 多 provider 配置
365
+ providers/{types,mimo,deepseek,registry}.ts # Provider 抽象 + MiMo / DeepSeek 实现
366
+ upstream/openaiCompatClient.ts # 通用 Chat Completions 客户端 + provider error hook
367
+ translate/ # Responses API ↔ Chat Completions API 翻译
368
+ admin/router.ts # /admin/api/* REST + /admin/* SPA 静态托管
369
+ db/{index,logs,settings,models}.ts # better-sqlite3 持久化层 + migrations + seed
370
+ test/ # 100 个 vitest 用例
371
+ web/ # Vite + React 18 控制台(构建产物 dist/web/)
251
372
  mimoskill/ # MiMo 辅助工具 + 宠物生成绕路方案
252
373
  scripts/install.{sh,ps1} # 一键安装脚本
253
- dist/ # tsc 编译产物
374
+ dist/ # tsc + vite 编译产物
254
375
  AGENTS.md # Codex agent 说明(不要装 openai,用 mimoskill)
255
376
  PUBLISHING.md # 维护者发布手册
256
377
  ```
@@ -260,12 +381,16 @@ PUBLISHING.md # 维护者发布手册
260
381
  ```bash
261
382
  git clone https://github.com/7as0nch/mimo2codex && cd mimo2codex
262
383
  npm install
263
- npm run dev # tsx 直接跑,不用构建
264
- npm test # 46 vitest
265
- npm run build # 产出 dist/
384
+ npm run web:install # 安装前端依赖(仅首次)
385
+ npm run dev # tsx 跑后端,不用构建(默认 admin UI 仍生效但需要先 web:build 一次)
386
+ npm run web:dev # 另开窗口跑 vite dev(5173,自动 proxy /admin/api → 8788)
387
+ npm test # 100 个 vitest
388
+ npm run build # 仅后端 → dist/cli.js
389
+ npm run web:build # 仅前端 → dist/web/
390
+ npm run build:all # 一把全打
266
391
  ```
267
392
 
268
- 把本地代码注册成全局 `mimo2codex` 命令:`npm run build && npm link`。
393
+ 把本地代码注册成全局 `mimo2codex` 命令:`npm run build:all && npm link`。
269
394
 
270
395
  ## 许可证
271
396