copilot-custom-endpoint 1.4.2 → 1.5.0
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 +7 -5
- package/cli.mjs +11 -4
- package/docs/example-config.md +6 -9
- package/docs/models/kimi.md +1 -1
- package/docs/models/mimo.md +97 -29
- package/package.json +6 -4
- package/proxy/mimo-proxy.mjs +127 -0
package/README.md
CHANGED
|
@@ -21,9 +21,9 @@ That's it. No code, no servers to manage (unless the model specifically needs th
|
|
|
21
21
|
|
|
22
22
|
| Model | Provider | Needs proxy? | Vision | Setup guide |
|
|
23
23
|
| --------------------------- | --------- | ---------------------- | ------------ | -------------------------------------------------------------------------------------------------- |
|
|
24
|
-
| **MiMo V2 Flash** | Xiaomi |
|
|
25
|
-
| **MiMo V2.5** | Xiaomi |
|
|
26
|
-
| **MiMo V2.5 Pro** | Xiaomi |
|
|
24
|
+
| **MiMo V2 Flash** | Xiaomi | Optional (recommended) | ❌ | [Setup](docs/models/mimo.md) |
|
|
25
|
+
| **MiMo V2.5** | Xiaomi | Optional (recommended) | ✅ | [Setup](docs/models/mimo.md) |
|
|
26
|
+
| **MiMo V2.5 Pro** | Xiaomi | Optional (recommended) | ❌ | [Setup](docs/models/mimo.md) |
|
|
27
27
|
| **Kimi K2.7 Code / K2.6** | Moonshot | **Yes** | ✅ | [Setup](docs/models/kimi.md) |
|
|
28
28
|
| **Qwen 3.7 Plus** | DashScope | Optional (recommended) | ✅ | [Setup](docs/models/qwen.md) |
|
|
29
29
|
| **Qwen 3.7 Max** | DashScope | Optional (recommended) | ❌ | [Setup](docs/models/qwen.md) |
|
|
@@ -70,9 +70,10 @@ If a model needs a proxy, the setup guide will tell you to run a command first.
|
|
|
70
70
|
Run from the repo root:
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
|
-
npm run proxy # Start
|
|
73
|
+
npm run proxy # Start all proxies (Kimi + Qwen + MiMo)
|
|
74
74
|
npm run proxy:kimi # Start only the Kimi proxy
|
|
75
75
|
npm run proxy:qwen # Start only the Qwen proxy
|
|
76
|
+
npm run proxy:mimo # Start only the MiMo proxy
|
|
76
77
|
npm run clean:logs # Remove debug_log/
|
|
77
78
|
npm test # Run the test suite
|
|
78
79
|
```
|
|
@@ -80,9 +81,10 @@ npm test # Run the test suite
|
|
|
80
81
|
Or globally via npx (no clone needed):
|
|
81
82
|
|
|
82
83
|
```bash
|
|
83
|
-
npx copilot-custom-endpoint # Start
|
|
84
|
+
npx copilot-custom-endpoint # Start all proxies
|
|
84
85
|
npx copilot-custom-endpoint kimi # Kimi only
|
|
85
86
|
npx copilot-custom-endpoint qwen # Qwen only
|
|
87
|
+
npx copilot-custom-endpoint mimo # MiMo only
|
|
86
88
|
npx copilot-custom-endpoint clean # Remove debug_log/
|
|
87
89
|
```
|
|
88
90
|
|
package/cli.mjs
CHANGED
|
@@ -8,13 +8,14 @@ import { rmSync } from 'node:fs'
|
|
|
8
8
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
9
9
|
const sub = process.argv[2]
|
|
10
10
|
|
|
11
|
-
const usage = `Usage: copilot-custom-endpoint [all|kimi|qwen|clean]
|
|
11
|
+
const usage = `Usage: copilot-custom-endpoint [all|kimi|qwen|mimo|clean]
|
|
12
12
|
|
|
13
13
|
Start a local proxy for VS Code Copilot custom endpoints.
|
|
14
14
|
|
|
15
|
-
copilot-custom-endpoint all Start
|
|
15
|
+
copilot-custom-endpoint all Start all proxies concurrently (default)
|
|
16
16
|
copilot-custom-endpoint kimi Start the Kimi K2 proxy on port 3457
|
|
17
17
|
copilot-custom-endpoint qwen Start the Qwen 3.x proxy on port 3458
|
|
18
|
+
copilot-custom-endpoint mimo Start the MiMo V2.5 proxy on port 3459
|
|
18
19
|
copilot-custom-endpoint clean Remove the debug_log/ directory
|
|
19
20
|
|
|
20
21
|
Environment variables: see --help for each proxy.
|
|
@@ -26,12 +27,18 @@ if (sub === 'clean') {
|
|
|
26
27
|
process.exit(0)
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
if (
|
|
30
|
+
if (
|
|
31
|
+
sub &&
|
|
32
|
+
sub !== 'kimi' &&
|
|
33
|
+
sub !== 'qwen' &&
|
|
34
|
+
sub !== 'mimo' &&
|
|
35
|
+
sub !== 'all'
|
|
36
|
+
) {
|
|
30
37
|
console.error(usage)
|
|
31
38
|
process.exit(1)
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
const targets = sub === 'all' || !sub ? ['kimi', 'qwen'] : [sub]
|
|
41
|
+
const targets = sub === 'all' || !sub ? ['kimi', 'qwen', 'mimo'] : [sub]
|
|
35
42
|
|
|
36
43
|
// Spawn all target proxies and wait for all to exit.
|
|
37
44
|
// This keeps both proxies alive in "all" mode instead of exiting
|
package/docs/example-config.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Full example config
|
|
2
2
|
|
|
3
|
-
Here's a complete, real-world `chatLanguageModels.json` that combines **
|
|
3
|
+
Here's a complete, real-world `chatLanguageModels.json` that combines **the `customendpoint` providers from the live `chatLanguageModels.json`**. Copy what you need, leave the rest out.
|
|
4
4
|
|
|
5
5
|
> **Note:** The `apiKey` fields are left as empty strings — set them via the **Chat: Manage Language Models** UI (Command Palette → right-click provider group → **Update API Key**). After you set a key via the UI, VS Code replaces the empty string with a `${input:chat.lm.secret.<id>}` secret reference.
|
|
6
6
|
>
|
|
7
|
-
>
|
|
7
|
+
> The live config points Qwen at the local proxy (`:3458`) and MiMo at the local proxy (`:3459`). When using a proxy, align the model `requestBody` overrides with the proxy's behavior: Qwen sends no `requestBody` (the proxy manages `enable_thinking` dynamically); MiMo sends only `temperature` and `top_p` (the proxy injects `thinking: {"type": "disabled"}` on tool turns and leaves it absent on plain chat).
|
|
8
8
|
|
|
9
9
|
```json
|
|
10
10
|
[
|
|
@@ -76,14 +76,13 @@ Here's a complete, real-world `chatLanguageModels.json` that combines **all the
|
|
|
76
76
|
{
|
|
77
77
|
"id": "mimo-v2.5-pro",
|
|
78
78
|
"name": "MiMo V2.5 Pro (text)",
|
|
79
|
-
"url": "
|
|
79
|
+
"url": "http://127.0.0.1:3459/v1/chat/completions",
|
|
80
80
|
"toolCalling": true,
|
|
81
81
|
"vision": false,
|
|
82
82
|
"streaming": true,
|
|
83
83
|
"maxInputTokens": 1048576,
|
|
84
84
|
"maxOutputTokens": 131072,
|
|
85
85
|
"requestBody": {
|
|
86
|
-
"thinking": { "type": "disabled" },
|
|
87
86
|
"temperature": 1,
|
|
88
87
|
"top_p": 0.95
|
|
89
88
|
}
|
|
@@ -91,14 +90,13 @@ Here's a complete, real-world `chatLanguageModels.json` that combines **all the
|
|
|
91
90
|
{
|
|
92
91
|
"id": "mimo-v2.5",
|
|
93
92
|
"name": "MiMo V2.5 (vision)",
|
|
94
|
-
"url": "
|
|
93
|
+
"url": "http://127.0.0.1:3459/v1/chat/completions",
|
|
95
94
|
"toolCalling": true,
|
|
96
95
|
"vision": true,
|
|
97
96
|
"streaming": true,
|
|
98
97
|
"maxInputTokens": 1048576,
|
|
99
98
|
"maxOutputTokens": 32768,
|
|
100
99
|
"requestBody": {
|
|
101
|
-
"thinking": { "type": "disabled" },
|
|
102
100
|
"temperature": 1,
|
|
103
101
|
"top_p": 0.95
|
|
104
102
|
}
|
|
@@ -106,14 +104,13 @@ Here's a complete, real-world `chatLanguageModels.json` that combines **all the
|
|
|
106
104
|
{
|
|
107
105
|
"id": "mimo-v2-flash",
|
|
108
106
|
"name": "MiMo V2 Flash (text)",
|
|
109
|
-
"url": "
|
|
107
|
+
"url": "http://127.0.0.1:3459/v1/chat/completions",
|
|
110
108
|
"toolCalling": true,
|
|
111
109
|
"vision": false,
|
|
112
110
|
"streaming": true,
|
|
113
111
|
"maxInputTokens": 262144,
|
|
114
112
|
"maxOutputTokens": 65536,
|
|
115
113
|
"requestBody": {
|
|
116
|
-
"thinking": { "type": "disabled" },
|
|
117
114
|
"temperature": 0.3,
|
|
118
115
|
"top_p": 0.95
|
|
119
116
|
}
|
|
@@ -195,4 +192,4 @@ If you only need one provider, jump straight to its setup guide:
|
|
|
195
192
|
- [MiniMax M3](minimax.md)
|
|
196
193
|
- [GLM (5.1 / 5V Turbo)](glm.md)
|
|
197
194
|
|
|
198
|
-
> **DeepSeek V4 Pro / V4 Flash** use the [DeepSeek V4 for Copilot Chat](https://marketplace.visualstudio.com/items?itemName=Vizards.deepseek-v4-for-copilot) extension
|
|
195
|
+
> **DeepSeek V4 Pro / V4 Flash** use the [DeepSeek V4 for Copilot Chat](https://marketplace.visualstudio.com/items?itemName=Vizards.deepseek-v4-for-copilot) extension. They appear in `chatLanguageModels.json` as `vendor: "deepseek"` (not as a `customendpoint` provider) and are configured via the extension's settings block.
|
package/docs/models/kimi.md
CHANGED
package/docs/models/mimo.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# Xiaomi MiMo — VS Code Custom Endpoint Setup Guide
|
|
2
2
|
|
|
3
|
-
> **TL;DR:** MiMo works
|
|
3
|
+
> **TL;DR:** MiMo works direct with static `thinking: { type: "disabled" }` in `requestBody`, or via `proxy/mimo-proxy.mjs` for dynamic thinking suppression (reasoning visible in plain chat, suppressed in tool loops). Static suppression is simpler; the proxy lets you see reasoning in non-agent chats.
|
|
4
4
|
|
|
5
5
|
## At a Glance
|
|
6
6
|
|
|
7
|
-
| Field | Value
|
|
8
|
-
| ---------------------- |
|
|
9
|
-
| Mode | **Direct** (
|
|
10
|
-
| Vision | ✅ Yes (`mimo-v2.5` only)
|
|
11
|
-
| Tool calling | ✅ Yes (with `thinking: disabled`)
|
|
12
|
-
| Context | 1M (V2.5 Pro / V2.5) / 256K (V2 Flash)
|
|
13
|
-
| Max output | 131072 (V2.5 Pro) / 32768 (V2.5) / 65536 (V2 Flash)
|
|
14
|
-
| Required `requestBody` | `thinking: { type: "disabled" }
|
|
15
|
-
| Endpoint | `https://api.xiaomimimo.com/v1/chat/completions`
|
|
7
|
+
| Field | Value |
|
|
8
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| Mode | **Direct** (proxy optional) |
|
|
10
|
+
| Vision | ✅ Yes (`mimo-v2.5` only) |
|
|
11
|
+
| Tool calling | ✅ Yes (with `thinking: disabled`) |
|
|
12
|
+
| Context | 1M (V2.5 Pro / V2.5) / 256K (V2 Flash) |
|
|
13
|
+
| Max output | 131072 (V2.5 Pro) / 32768 (V2.5) / 65536 (V2 Flash) |
|
|
14
|
+
| Required `requestBody` | Direct: `thinking: { type: "disabled" }`<br>Proxy: none (proxy handles it) |
|
|
15
|
+
| Endpoint | Direct: `https://api.xiaomimimo.com/v1/chat/completions`<br>Proxy: `http://127.0.0.1:3459/v1/chat/completions` |
|
|
16
16
|
|
|
17
17
|
### Models at a glance
|
|
18
18
|
|
|
@@ -26,10 +26,21 @@
|
|
|
26
26
|
|
|
27
27
|
## Quick Start
|
|
28
28
|
|
|
29
|
+
### Direct (no proxy)
|
|
30
|
+
|
|
29
31
|
1. **Edit `chatLanguageModels.json`** — add the MiMo block(s) from [Setup](#setup) below.
|
|
30
32
|
2. **Set your `MIMO_API_KEY`** via Command Palette → **Chat: Manage Language Models**.
|
|
31
33
|
3. **Restart VS Code** and pick "MiMo V2.5 Pro", "MiMo V2.5", or "MiMo V2 Flash".
|
|
32
34
|
|
|
35
|
+
### With optional proxy (dynamic thinking)
|
|
36
|
+
|
|
37
|
+
The `proxy/mimo-proxy.mjs` provides dynamic thinking suppression: reasoning stays ON in plain chat but turns OFF automatically when tools are invoked.
|
|
38
|
+
|
|
39
|
+
- `npm run proxy:mimo` (or `node proxy/mimo-proxy.mjs`) starts the local proxy on `http://127.0.0.1:3459/v1/chat/completions`.
|
|
40
|
+
- `node proxy/mimo-proxy.mjs --help` prints the supported environment variables and defaults.
|
|
41
|
+
|
|
42
|
+
When using the proxy, update your model URLs to `http://127.0.0.1:3459/v1/chat/completions` and **remove** `thinking` from `requestBody`. The proxy handles it dynamically.
|
|
43
|
+
|
|
33
44
|
## Setup
|
|
34
45
|
|
|
35
46
|
### 1. VS Code configuration
|
|
@@ -42,6 +53,8 @@ Config file location:
|
|
|
42
53
|
| macOS | `~/Library/Application Support/Code/User/chatLanguageModels.json` |
|
|
43
54
|
| Linux | `~/.config/Code/User/chatLanguageModels.json` |
|
|
44
55
|
|
|
56
|
+
#### Direct (static `thinking: disabled`)
|
|
57
|
+
|
|
45
58
|
```json
|
|
46
59
|
{
|
|
47
60
|
"name": "MiMo",
|
|
@@ -98,6 +111,61 @@ Config file location:
|
|
|
98
111
|
}
|
|
99
112
|
```
|
|
100
113
|
|
|
114
|
+
#### With proxy (dynamic thinking, no `requestBody` override)
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"name": "MiMo (proxy)",
|
|
119
|
+
"vendor": "customendpoint",
|
|
120
|
+
"apiKey": "",
|
|
121
|
+
"apiType": "chat-completions",
|
|
122
|
+
"models": [
|
|
123
|
+
{
|
|
124
|
+
"id": "mimo-v2.5-pro",
|
|
125
|
+
"name": "MiMo V2.5 Pro (text, proxy)",
|
|
126
|
+
"url": "http://127.0.0.1:3459/v1/chat/completions",
|
|
127
|
+
"toolCalling": true,
|
|
128
|
+
"vision": false,
|
|
129
|
+
"streaming": true,
|
|
130
|
+
"maxInputTokens": 1048576,
|
|
131
|
+
"maxOutputTokens": 131072,
|
|
132
|
+
"requestBody": {
|
|
133
|
+
"temperature": 1,
|
|
134
|
+
"top_p": 0.95
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "mimo-v2.5",
|
|
139
|
+
"name": "MiMo V2.5 (vision, proxy)",
|
|
140
|
+
"url": "http://127.0.0.1:3459/v1/chat/completions",
|
|
141
|
+
"toolCalling": true,
|
|
142
|
+
"vision": true,
|
|
143
|
+
"streaming": true,
|
|
144
|
+
"maxInputTokens": 1048576,
|
|
145
|
+
"maxOutputTokens": 32768,
|
|
146
|
+
"requestBody": {
|
|
147
|
+
"temperature": 1,
|
|
148
|
+
"top_p": 0.95
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"id": "mimo-v2-flash",
|
|
153
|
+
"name": "MiMo V2 Flash (text, proxy)",
|
|
154
|
+
"url": "http://127.0.0.1:3459/v1/chat/completions",
|
|
155
|
+
"toolCalling": true,
|
|
156
|
+
"vision": false,
|
|
157
|
+
"streaming": true,
|
|
158
|
+
"maxInputTokens": 262144,
|
|
159
|
+
"maxOutputTokens": 65536,
|
|
160
|
+
"requestBody": {
|
|
161
|
+
"temperature": 0.3,
|
|
162
|
+
"top_p": 0.95
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
101
169
|
### 2. API key
|
|
102
170
|
|
|
103
171
|
1. Open the Command Palette (`Ctrl+Shift+P`).
|
|
@@ -156,13 +224,13 @@ When thinking is enabled, responses include a `reasoning_content` field alongsid
|
|
|
156
224
|
|
|
157
225
|
## Troubleshooting
|
|
158
226
|
|
|
159
|
-
| Symptom | Likely cause | Fix
|
|
160
|
-
| ------------------------------------------ | -------------------------------------------------------- |
|
|
161
|
-
| HTTP 400 on the second turn of a tool loop | `reasoning_content` missing in history (thinking on) | Add `thinking: { type: "disabled" }` to `requestBody` |
|
|
162
|
-
| Vision request returns an error | Used `mimo-v2.5-pro` or `mimo-v2-flash` (text-only) | Use `mimo-v2.5` for vision
|
|
163
|
-
| Custom `tool_choice` ignored | MiMo only honors `"auto"` | Stick to `auto`
|
|
164
|
-
| 401 Unauthorized | Wrong key, or Token Plan URL used with pay-as-you-go key | Match key prefix (`sk-` vs `tp-`) to the endpoint
|
|
165
|
-
| 429 rate-limited | Concurrent sessions exceeded 100 RPM / 10M TPM | Reduce concurrent agent sessions
|
|
227
|
+
| Symptom | Likely cause | Fix |
|
|
228
|
+
| ------------------------------------------ | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
229
|
+
| HTTP 400 on the second turn of a tool loop | `reasoning_content` missing in history (thinking on) | Add `thinking: { type: "disabled" }` to `requestBody`, or use the proxy (`npm run proxy:mimo`) |
|
|
230
|
+
| Vision request returns an error | Used `mimo-v2.5-pro` or `mimo-v2-flash` (text-only) | Use `mimo-v2.5` for vision |
|
|
231
|
+
| Custom `tool_choice` ignored | MiMo only honors `"auto"` | Stick to `auto` |
|
|
232
|
+
| 401 Unauthorized | Wrong key, or Token Plan URL used with pay-as-you-go key | Match key prefix (`sk-` vs `tp-`) to the endpoint |
|
|
233
|
+
| 429 rate-limited | Concurrent sessions exceeded 100 RPM / 10M TPM | Reduce concurrent agent sessions |
|
|
166
234
|
|
|
167
235
|
## Pricing
|
|
168
236
|
|
|
@@ -194,14 +262,14 @@ This is the same class of problem as Qwen's `reasoning_content` issue, but **str
|
|
|
194
262
|
- **Thinking disabled + tool calling = works** (no `reasoning_content` to preserve).
|
|
195
263
|
- **Thinking enabled + plain chat = works** (no tool calls in history).
|
|
196
264
|
|
|
197
|
-
###
|
|
265
|
+
### Proxy for dynamic thinking suppression
|
|
198
266
|
|
|
199
|
-
|
|
267
|
+
A dynamic proxy (`proxy/mimo-proxy.mjs`) is now available — same pattern as `proxy/qwen-proxy.mjs`. It suppresses thinking only when tools are present, letting plain chat show reasoning while keeping tool loops stable.
|
|
200
268
|
|
|
201
|
-
|
|
269
|
+
- **Plain chat** → `thinking` is removed from the request body, so MiMo uses its API default (enabled for V2.5 Pro / V2.5).
|
|
270
|
+
- **Tool-enabled requests** → `thinking: { type: "disabled" }` is injected, preventing `reasoning_content` 400 errors.
|
|
202
271
|
|
|
203
|
-
|
|
204
|
-
- Static suppression is one less moving part to maintain.
|
|
272
|
+
Static suppression (direct mode) remains a perfectly valid simpler alternative.
|
|
205
273
|
|
|
206
274
|
### Benchmark highlights (from official MiMo V2.5 announcement)
|
|
207
275
|
|
|
@@ -233,13 +301,13 @@ External API checks (curl):
|
|
|
233
301
|
|
|
234
302
|
### Known risks
|
|
235
303
|
|
|
236
|
-
| Risk | Detail | Mitigation
|
|
237
|
-
| ------------------------------------- | ------------------------------------------------------------------ |
|
|
238
|
-
| `reasoning_content` 400 errors | If thinking is accidentally enabled in tool loops, API returns 400 |
|
|
239
|
-
| `tool_choice` only supports `"auto"` | Non-`auto` values are stripped | Should not affect VS Code, which uses `auto`
|
|
240
|
-
| Auth header format | Both `api-key:` and `Authorization: Bearer` work | VS Code sends `Authorization: Bearer` — works directly
|
|
241
|
-
| `temperature` locked in thinking mode | V2.5 Pro / V2.5 force `temperature: 1.0` when thinking is on | Not an issue when thinking is disabled
|
|
242
|
-
| 1M context window | VS Code may not send enough tokens to benefit | Set conservatively; adjust after testing
|
|
304
|
+
| Risk | Detail | Mitigation |
|
|
305
|
+
| ------------------------------------- | ------------------------------------------------------------------ | -------------------------------------------------------------------------- |
|
|
306
|
+
| `reasoning_content` 400 errors | If thinking is accidentally enabled in tool loops, API returns 400 | Set `thinking.type: "disabled"` in `requestBody` (direct) or use the proxy |
|
|
307
|
+
| `tool_choice` only supports `"auto"` | Non-`auto` values are stripped | Should not affect VS Code, which uses `auto` |
|
|
308
|
+
| Auth header format | Both `api-key:` and `Authorization: Bearer` work | VS Code sends `Authorization: Bearer` — works directly |
|
|
309
|
+
| `temperature` locked in thinking mode | V2.5 Pro / V2.5 force `temperature: 1.0` when thinking is on | Not an issue when thinking is disabled |
|
|
310
|
+
| 1M context window | VS Code may not send enough tokens to benefit | Set conservatively; adjust after testing |
|
|
243
311
|
|
|
244
312
|
## References
|
|
245
313
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copilot-custom-endpoint",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Local proxies for VS Code Copilot custom endpoints — Kimi K2
|
|
3
|
+
"version": "1.5.0",
|
|
4
|
+
"description": "Local proxies for VS Code Copilot custom endpoints — Kimi K2, Qwen 3.x & MiMo V2.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
8
|
"copilot-custom-endpoint": "cli.mjs",
|
|
9
9
|
"copilot-custom-endpoint-kimi": "proxy/kimi-proxy.mjs",
|
|
10
|
-
"copilot-custom-endpoint-qwen": "proxy/qwen-proxy.mjs"
|
|
10
|
+
"copilot-custom-endpoint-qwen": "proxy/qwen-proxy.mjs",
|
|
11
|
+
"copilot-custom-endpoint-mimo": "proxy/mimo-proxy.mjs"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
14
|
"README.md",
|
|
@@ -19,9 +20,10 @@
|
|
|
19
20
|
"proxy/"
|
|
20
21
|
],
|
|
21
22
|
"scripts": {
|
|
22
|
-
"proxy": "concurrently --names kimi,qwen --prefix-colors cyan,green \"npm run proxy:kimi\" \"npm run proxy:qwen\"",
|
|
23
|
+
"proxy": "concurrently --names kimi,qwen,mimo --prefix-colors cyan,green,magenta \"npm run proxy:kimi\" \"npm run proxy:qwen\" \"npm run proxy:mimo\"",
|
|
23
24
|
"proxy:kimi": "node proxy/kimi-proxy.mjs",
|
|
24
25
|
"proxy:qwen": "node proxy/qwen-proxy.mjs",
|
|
26
|
+
"proxy:mimo": "node proxy/mimo-proxy.mjs",
|
|
25
27
|
"clean:logs": "node -e \"import{rmSync}from'node:fs';rmSync('debug_log',{recursive:true,force:true});console.log('debug_log/ removed')\"",
|
|
26
28
|
"test": "node --test tests/**/*.test.mjs",
|
|
27
29
|
"lint": "eslint .",
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import 'dotenv/config'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { createProxy } from '../lib/create-proxy.mjs'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Supported model scope for this proxy:
|
|
8
|
+
* - Validated with `mimo-v2.5-pro`, `mimo-v2.5`, and `mimo-v2-flash`.
|
|
9
|
+
* - Expected to work for any MiMo model that supports the `thinking` object
|
|
10
|
+
* with a `type` field on the OpenAI-compatible surface.
|
|
11
|
+
* - Not intended for non-MiMo providers, because the rewrite assumes
|
|
12
|
+
* MiMo's `thinking.type` behavior.
|
|
13
|
+
*/
|
|
14
|
+
const upstreamUrl =
|
|
15
|
+
process.env.MIMO_UPSTREAM_URL ??
|
|
16
|
+
'https://api.xiaomimimo.com/v1/chat/completions'
|
|
17
|
+
const port = Number.parseInt(
|
|
18
|
+
process.env.MIMO_PROXY_PORT ?? process.env.PORT ?? '3459',
|
|
19
|
+
10
|
|
20
|
+
)
|
|
21
|
+
const disableThinkingWithTools =
|
|
22
|
+
(process.env.MIMO_PROXY_DISABLE_THINKING_WITH_TOOLS ?? '1') !== '0'
|
|
23
|
+
const defaultLogPath = fileURLToPath(
|
|
24
|
+
new URL('../debug_log/mimo-proxy.ndjson', import.meta.url)
|
|
25
|
+
)
|
|
26
|
+
const logPath = process.env.MIMO_PROXY_LOG ?? defaultLogPath
|
|
27
|
+
|
|
28
|
+
if (process.argv.includes('--help')) {
|
|
29
|
+
console.log(`MiMo proxy
|
|
30
|
+
|
|
31
|
+
Starts a local HTTP proxy that conditionally injects thinking: { type: "disabled" }
|
|
32
|
+
when the request includes a tools array, letting MiMo models show reasoning in
|
|
33
|
+
plain chat while keeping tool loops stable.
|
|
34
|
+
|
|
35
|
+
Environment variables:
|
|
36
|
+
MIMO_PROXY_PORT Local listen port. Default: 3459 (falls back to PORT)
|
|
37
|
+
MIMO_UPSTREAM_URL Upstream MiMo chat-completions URL.
|
|
38
|
+
Default: https://api.xiaomimimo.com/v1/chat/completions
|
|
39
|
+
MIMO_PROXY_DISABLE_THINKING_WITH_TOOLS
|
|
40
|
+
Inject thinking: { type: "disabled" } when tools are present.
|
|
41
|
+
Default: 1
|
|
42
|
+
MIMO_PROXY_LOG Path to the redacted NDJSON log file.
|
|
43
|
+
|
|
44
|
+
Suggested VS Code model URL:
|
|
45
|
+
http://127.0.0.1:3459/v1/chat/completions
|
|
46
|
+
`)
|
|
47
|
+
process.exit(0)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ---- Provider-specific rewrite logic ----
|
|
51
|
+
|
|
52
|
+
function summarizePayload(payload, hasTools, rewriteInfo) {
|
|
53
|
+
const messages = Array.isArray(payload.messages) ? payload.messages : []
|
|
54
|
+
const tools = Array.isArray(payload.tools) ? payload.tools : []
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
model: payload.model,
|
|
58
|
+
stream: payload.stream,
|
|
59
|
+
hasTools,
|
|
60
|
+
toolCount: tools.length,
|
|
61
|
+
toolChoice: payload.tool_choice,
|
|
62
|
+
...rewriteInfo,
|
|
63
|
+
maxTokens:
|
|
64
|
+
payload.max_tokens ??
|
|
65
|
+
payload.max_completion_tokens ??
|
|
66
|
+
payload.max_output_tokens,
|
|
67
|
+
messageCount: messages.length,
|
|
68
|
+
messageRoles: messages.map((message) => message?.role).slice(0, 16),
|
|
69
|
+
topLevelKeys: Object.keys(payload).sort()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function rewriteMiMo(payload) {
|
|
74
|
+
// Determine if a tool is actually being invoked:
|
|
75
|
+
// - tool_choice is set and not "none"
|
|
76
|
+
// - OR there is a "tool" role message in the conversation
|
|
77
|
+
const messages = Array.isArray(payload.messages) ? payload.messages : []
|
|
78
|
+
const hasToolRole = messages.some((message) => message?.role === 'tool')
|
|
79
|
+
const toolChoice = payload.tool_choice
|
|
80
|
+
const hasActiveToolCall =
|
|
81
|
+
hasToolRole ||
|
|
82
|
+
(toolChoice !== undefined && toolChoice !== 'none' && toolChoice !== null)
|
|
83
|
+
const hasTools = hasActiveToolCall
|
|
84
|
+
const incomingThinkingType = payload?.thinking?.type
|
|
85
|
+
|
|
86
|
+
if (disableThinkingWithTools && hasTools) {
|
|
87
|
+
// Tool-enabled request: suppress thinking to avoid reasoning_content issues
|
|
88
|
+
payload.thinking = { type: 'disabled' }
|
|
89
|
+
} else {
|
|
90
|
+
// Plain chat: remove thinking so the model uses its default (enabled for V2.5 models)
|
|
91
|
+
delete payload.thinking
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const rewrittenThinkingType =
|
|
95
|
+
disableThinkingWithTools && hasTools ? 'disabled' : undefined
|
|
96
|
+
|
|
97
|
+
const summary = summarizePayload(payload, hasTools, {
|
|
98
|
+
incomingThinkingType,
|
|
99
|
+
rewrittenThinkingType
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const modeTag = hasTools ? '[tools]' : '[chat]'
|
|
103
|
+
const consoleMsg = `${modeTag} thinking.type=${String(incomingThinkingType)} -> ${
|
|
104
|
+
hasTools && disableThinkingWithTools ? '"disabled"' : '<deleted>'
|
|
105
|
+
}, model=${payload.model ?? '?'}`
|
|
106
|
+
|
|
107
|
+
return { summary, consoleMsg }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ---- Create and start ----
|
|
111
|
+
|
|
112
|
+
const { start } = createProxy({
|
|
113
|
+
upstreamUrl,
|
|
114
|
+
port,
|
|
115
|
+
logPath,
|
|
116
|
+
label: 'mimo-proxy',
|
|
117
|
+
healthCheckExtras: { disableThinkingWithTools },
|
|
118
|
+
rewriteRequest: rewriteMiMo,
|
|
119
|
+
startupMessages: (_port, _upstreamUrl) => [
|
|
120
|
+
`[mimo-proxy] listening on http://127.0.0.1:${_port}/v1/chat/completions`,
|
|
121
|
+
`[mimo-proxy] forwarding to ${_upstreamUrl}`,
|
|
122
|
+
`[mimo-proxy] disable thinking with tools=${disableThinkingWithTools}`,
|
|
123
|
+
`[mimo-proxy] writing redacted request summaries to ${logPath}`
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
start()
|