copilot-custom-endpoint 1.6.7 → 1.6.9

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.
@@ -1,43 +1,40 @@
1
1
  # Qwen (DashScope) — VS Code Custom Endpoint Setup Guide
2
2
 
3
- > **TL;DR:** The live config points `qwen3.7-plus` (vision) and `qwen3.7-max` (text-only) at `proxy/qwen-proxy.mjs` for dynamic thinking suppression: reasoning stays ON in plain chat but turns OFF automatically when tools are invoked. A direct DashScope path with static `enable_thinking: false` is also supported if you prefer not to run the proxy.
3
+ > **TL;DR:** `qwen3.7-plus` (vision) and `qwen3.7-max` (text) work both direct and via the local proxy. The proxy gives you dynamic thinking suppression: reasoning stays ON in plain chat but turns OFF automatically when tools are invoked. The direct path is simpler if you don't need reasoning in chat.
4
4
 
5
5
  ## At a Glance
6
6
 
7
7
  | Field | Value |
8
8
  | ------------------------------- | -------------------------------------------------------------------------------- |
9
9
  | Mode | **Proxy** (local on `:3458`) **or** **Direct** (static `enable_thinking: false`) |
10
- | Billing | **Pay-as-You-Go only** — no subscription; 1M-token free quota for new users |
10
+ | Billing | **Pay-as-You-Go only** — 1M-token free quota for new users |
11
11
  | Vision | ✅ Yes (`qwen3.7-plus`) |
12
12
  | Tool calling | ✅ Yes |
13
13
  | Context | 1M |
14
14
  | Required `requestBody` (direct) | `enable_thinking: false` |
15
- | Required `requestBody` (proxy) | none — proxy injects based on tool activity in the conversation |
15
+ | Required `requestBody` (proxy) | none — proxy injects based on tool activity |
16
16
  | Endpoint | `https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions` |
17
17
  | Proxy endpoint | `http://127.0.0.1:3458/v1/chat/completions` |
18
18
 
19
- ### Models at a glance
19
+ ### Models
20
20
 
21
21
  | Model | Vision | Role |
22
22
  | -------------- | ------ | -------------------------------------- |
23
23
  | `qwen3.7-plus` | ✅ Yes | Primary model with image understanding |
24
24
  | `qwen3.7-max` | ❌ No | Larger text-only model |
25
25
 
26
- > The live `chatLanguageModels.json` points Qwen models at the local proxy by default; the direct DashScope URL is shown for users who prefer a static `enable_thinking: false` setup.
26
+ > The live `chatLanguageModels.json` points Qwen at the local proxy by default; the direct DashScope URL is shown below for users who prefer a static `enable_thinking: false` setup.
27
27
 
28
- ## Quick Start — With Proxy (Recommended)
28
+ ## Quick Start — With Proxy (recommended)
29
29
 
30
- 1. **Start the proxy** — choose one:
31
- - `npm run proxy:qwen` (from the repo root)
32
- - `npx copilot-custom-endpoint qwen` (standalone, no clone needed)
33
- - `npx copilot-custom-endpoint` (also starts the Kimi and MiMo proxies concurrently)
34
- 2. **Edit `chatLanguageModels.json`** — use the proxy-path block from [Setup § Proxy](#proxy-path) below.
35
- 3. **Set your DashScope API key** via the Language Models UI.
30
+ 1. **Start the proxy:** `npm run proxy:qwen` (or `npx copilot-custom-endpoint qwen`).
31
+ 2. **Use the proxy-path JSON snippet** below.
32
+ 3. **Set your DashScope API key** via Command Palette → **Chat: Manage Language Models**.
36
33
  4. **Restart VS Code.** Reasoning will be visible in plain chat and suppressed on tool turns.
37
34
 
38
- ## Quick Start — Direct Path (No Proxy)
35
+ ## Quick Start — Direct (no proxy)
39
36
 
40
- 1. **Edit `chatLanguageModels.json`** — add the Qwen block from [Setup § Direct](#direct-path) below.
37
+ 1. **Use the direct-path JSON snippet** below.
41
38
  2. **Set your `DASHSCOPE_API_KEY`** via Command Palette → **Chat: Manage Language Models**.
42
39
  3. **Restart VS Code** and pick "Qwen 3.7 Plus" or "Qwen 3.7 Max".
43
40
 
@@ -47,13 +44,21 @@
47
44
 
48
45
  DashScope is region-specific — your API key only works on the endpoint it was created for:
49
46
 
50
- | Region | Endpoint |
51
- | ---------------------------------- | ------------------------------------------------------------------------- |
52
- | **Singapore (used in this guide)** | `https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions` |
53
- | China (Beijing) | `https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions` |
54
- | US (Virginia) | `https://dashscope-us.aliyuncs.com/compatible-mode/v1/chat/completions` |
47
+ | Region | Endpoint |
48
+ | ------------- | ------------------------------------------------------------------------- |
49
+ | Singapore | `https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions` |
50
+ | China | `https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions` |
51
+ | US (Virginia) | `https://dashscope-us.aliyuncs.com/compatible-mode/v1/chat/completions` |
55
52
 
56
- ### Direct path
53
+ ### 1. VS Code configuration
54
+
55
+ | OS | Path |
56
+ | ------- | ----------------------------------------------------------------- |
57
+ | Windows | `%APPDATA%\Code\User\chatLanguageModels.json` |
58
+ | macOS | `~/Library/Application Support/Code/User/chatLanguageModels.json` |
59
+ | Linux | `~/.config/Code/User/chatLanguageModels.json` |
60
+
61
+ #### Direct path
57
62
 
58
63
  ```json
59
64
  {
@@ -69,9 +74,7 @@ DashScope is region-specific — your API key only works on the endpoint it was
69
74
  "toolCalling": true,
70
75
  "vision": false,
71
76
  "streaming": true,
72
- "requestBody": {
73
- "enable_thinking": false
74
- }
77
+ "requestBody": { "enable_thinking": false }
75
78
  },
76
79
  {
77
80
  "id": "qwen3.7-plus",
@@ -80,51 +83,29 @@ DashScope is region-specific — your API key only works on the endpoint it was
80
83
  "toolCalling": true,
81
84
  "vision": true,
82
85
  "streaming": true,
83
- "requestBody": {
84
- "enable_thinking": false
85
- }
86
+ "requestBody": { "enable_thinking": false }
86
87
  }
87
88
  ]
88
89
  }
89
90
  ```
90
91
 
91
- > **`enable_thinking: false`** suppresses the Qwen3 family's default thinking mode, which prevents `reasoning_content` issues during tool loops.
92
-
93
- > **Live config note:** The checked-in `chatLanguageModels.json` points Qwen at the local proxy (`http://127.0.0.1:3458`) with no `requestBody` override, so the proxy manages `enable_thinking` dynamically. Use the snippet above only if you are not running the proxy.
92
+ > The live `chatLanguageModels.json` points Qwen at the local proxy with no `requestBody` override; use the snippet above only if you're not running the proxy.
94
93
 
95
- ### Proxy path
96
-
97
- #### 1. Start the proxy
98
-
99
- ```bash
100
- node proxy/qwen-proxy.mjs
101
- ```
94
+ #### Proxy path
102
95
 
103
- Expected output:
96
+ 1. Start the proxy:
104
97
 
105
- ```
106
- [qwen-proxy] listening on http://127.0.0.1:3458/v1/chat/completions
107
- [qwen-proxy] forwarding to https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions
108
- ```
98
+ ```bash
99
+ node proxy/qwen-proxy.mjs
100
+ ```
109
101
 
110
- Verify it's alive:
102
+ Verify:
111
103
 
112
- ```bash
113
- curl http://127.0.0.1:3458/healthz
114
- ```
104
+ ```bash
105
+ curl http://127.0.0.1:3458/healthz
106
+ ```
115
107
 
116
- Expected response:
117
-
118
- ```json
119
- {
120
- "ok": true,
121
- "upstreamUrl": "https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions",
122
- "port": 3458,
123
- "disableThinkingWithTools": true
124
- }
125
- ```
126
-
127
- #### 2. Update VS Code config — point URLs to the proxy and remove `requestBody.enable_thinking`
108
+ 2. Use this snippet (URLs point at the proxy; no `requestBody` override):
128
109
 
129
110
  ```json
130
111
  {
@@ -157,68 +138,40 @@ Expected response:
157
138
 
158
139
  #### Proxy environment variables
159
140
 
160
- All can be set in a `.env` file at the repo root (both proxies `import 'dotenv/config'` automatically).
141
+ Set in `.env` at the repo root.
161
142
 
162
143
  | Variable | Default | Purpose |
163
144
  | ---------------------------------------- | ------------------------------------------------------------------------- | -------------------------------------------------- |
164
- | `QWEN_PROXY_PORT` | `3458` (falls back to `PORT`) | Local listen port |
145
+ | `QWEN_PROXY_PORT` | `3458` | Local listen port |
165
146
  | `QWEN_UPSTREAM_URL` | `https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions` | Upstream DashScope endpoint |
166
- | `QWEN_PROXY_LOG` | `debug_log/qwen-proxy.ndjson` (relative to proxy script) | Redacted NDJSON log path |
147
+ | `QWEN_PROXY_LOG` | `debug_log/qwen-proxy.ndjson` | Redacted NDJSON log path |
167
148
  | `QWEN_PROXY_DISABLE_THINKING_WITH_TOOLS` | `1` | Set to `0` to skip tool-aware thinking suppression |
168
149
 
169
- #### Proxy request rewriting rules
150
+ #### What the proxy does
170
151
 
171
- The proxy detects active tool use by examining the conversation state, not just the `tools` array:
152
+ The proxy detects active tool use by examining the conversation state (a `"tool"`-role message in history or a non-default `tool_choice`), not just the presence of a `tools` array. This correctly handles tool-enabled conversations even when the client sends `tools` in an earlier request but omits it from subsequent turns.
172
153
 
173
- | Condition | Action |
174
- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
175
- | A `"tool"`-role message exists in the conversation **or** `tool_choice` is set to a non-default value | Set `body.enable_thinking = false` |
176
- | No tool-role messages and no non-default `tool_choice` (plain chat) | Delete `body.enable_thinking` (let model default to `true`) |
154
+ | Condition | Action |
155
+ | ------------------------------------------------------------- | ------------------------------------- |
156
+ | Tool-role message in history **or** non-default `tool_choice` | Inject `enable_thinking: false` |
157
+ | Plain chat (no tool activity) | Delete `enable_thinking` (default ON) |
177
158
 
178
- > **Why delete rather than set `true`?** Omitting the key lets Qwen use its built-in default (`true`). Deletion is closer to "don't interfere."
179
- >
180
- > **Why not check `body.tools`?** The proxy checks for tool _activity_ — tool results in the message history or an explicit `tool_choice` directive — rather than the mere presence of a tools array. This correctly handles tool-enabled conversations even when the client sends `tools` in an earlier request but omits it from subsequent turns.
181
- >
182
- > **Proxy vs. direct:** The live config uses the proxy URL with no `requestBody` override so this dynamic behavior is applied to every request. The direct-path snippet above keeps `enable_thinking: false` static in `requestBody` as a no-proxy alternative.
159
+ ### 2. API key
183
160
 
184
- ### API key
185
-
186
- DashScope is **Pay-as-You-Go only** — there is no monthly subscription plan. However, Alibaba Cloud grants a **free quota** of **1M input + 1M output tokens per model** (valid 90 days) for new Model Studio users. Prepaid token resource packages are also available through the Alibaba Cloud console for discounted rates, but these are prepaid credits, not a subscription.
161
+ DashScope is **Pay-as-You-Go only** — but new Model Studio users get **1M input + 1M output tokens per model free for 90 days**. Prepaid token packages are also available.
187
162
 
188
163
  1. Open the Command Palette (`Ctrl+Shift+P`).
189
164
  2. Run **Chat: Manage Language Models**.
190
165
  3. Find the **Qwen** group → **Update API Key**.
191
166
  4. Paste your DashScope API key.
192
167
 
193
- > After setting via the UI, VS Code replaces `"apiKey": ""` with a `${input:chat.lm.secret.<id>}` reference. API keys are generated at `dashscope-intl.aliyuncs.com` (international) or `dashscope.aliyuncs.com` (China) and are region-specific.
194
-
195
- ## Configuration Reference
196
-
197
- ### Thinking mode
198
-
199
- The Qwen3 hybrid-thinking models default to `enable_thinking: true`, producing `reasoning_content` in responses. This is **harmless in plain chat** (you see the model's reasoning) but **breaks agent/tool-calling loops**: VS Code may not preserve `reasoning_content` in follow-up tool-result messages, and the model may reject the continuation.
200
-
201
- | Mode | Plain chat | Tool turns |
202
- | ------------------- | ------------------------------- | ----------------------------- |
203
- | Direct path | Thinking OFF (always) | Thinking OFF |
204
- | Proxy path | Thinking ON (default preserved) | Thinking OFF (auto-injected) |
205
- | No config (default) | Thinking ON | Risk: history may be rejected |
206
-
207
- > The live `chatLanguageModels.json` uses the proxy path by default, so plain-chat reasoning is visible and tool turns are stable.
208
-
209
- ### Vision (`qwen3.7-plus`)
210
-
211
- - Image input via OpenAI-compatible `content` array format (base64 data URIs).
212
- - **External image URLs may fail** if DashScope's servers cannot reach them — base64-encoded images work reliably.
213
- - **Image attachment behavior**: Unlike some other models, Qwen may fail to read images that are directly dragged and dropped into the Copilot Chat. If this happens, provide the absolute file path to the image (e.g., `c:\path\to\image.png`) in your prompt as a reliable workaround.
214
- - **Pricing**: **$0.40 / $1.60 per 1M input/output (≤ 256K)** and **$1.20 / $4.80 per 1M (> 256K)**.
168
+ > VS Code replaces `"apiKey": ""` with a `${input:chat.lm.secret.<id>}` reference. Keys are region-specific.
215
169
 
216
- ### Capabilities
170
+ ## Notes
217
171
 
218
- - Streaming (SSE, `data: [DONE]` terminator).
219
- - Tool calling with `tools` array and `tool_calls` response.
220
- - Vision (image input) on `qwen3.7-plus`.
221
- - Non-OpenAI extras: `enable_thinking`, `thinking_budget`, `enable_search` (via `extra_body`).
172
+ - **Vision (`qwen3.7-plus`)** uses OpenAI-compatible `content` array format. Base64 data URIs work reliably; external image URLs may fail if DashScope can't reach them. If a drag-and-drop image fails to load, providing the absolute file path (e.g. `c:\path\to\image.png`) in the prompt is a reliable workaround.
173
+ - **Thinking trade-off:** Direct = thinking always off (loops stable, no reasoning visible). Proxy = thinking on in plain chat, off in tool turns.
174
+ - **`tool_choice` only supports `auto`** — don't override it (VS Code's default is `auto`).
222
175
 
223
176
  ## Troubleshooting
224
177
 
@@ -229,7 +182,6 @@ The Qwen3 hybrid-thinking models default to `enable_thinking: true`, producing `
229
182
  | Tool loops still fail with proxy | Proxy not rewriting | Check `debug_log/qwen-proxy.ndjson` — verify `hasTools: true` requests have `rewrittenEnableThinking: false` |
230
183
  | Vision fails with external image URL | DashScope couldn't reach the URL | Use a base64 data URI instead |
231
184
  | 401 Unauthorized | API key region mismatch | Match your key to the regional endpoint |
232
- | Intermittent `net::ERR_CONNECTION_RESET` | Transient VS Code / Electron transport | Retry; not reproducible via `curl` or Node.js |
233
185
  | Want to switch back to direct | Proxy mode active | Revert `url` to DashScope endpoint and restore `requestBody.enable_thinking: false` |
234
186
 
235
187
  ## Pricing
@@ -241,98 +193,4 @@ For the cross-provider comparison, see [docs/pricing.md](../pricing.md). DashSco
241
193
  | `qwen3.7-plus` | $0.40 / 1M | $1.20 / 1M | $1.60 / 1M | $4.80 / 1M |
242
194
  | `qwen3.7-max` | $2.50 / 1M (≤ 1M) | — | $7.50 / 1M (≤ 1M) | — |
243
195
 
244
- > **Free quota:** DashScope offers 1M input + 1M output tokens per model, valid for 90 days after activating Model Studio.
245
-
246
- ---
247
-
248
- ## Background & Findings
249
-
250
- > This appendix preserves the validation narrative for future reference. It is not required to use the model.
251
-
252
- ### Why a proxy is useful (and why a static `enable_thinking: false` is enough)
253
-
254
- Both work — pick based on your preference:
255
-
256
- - **Direct path** is the simplest: static `enable_thinking: false` suppresses reasoning in all requests. Tool loops stay stable. Trade-off: you never see the model's thought process.
257
- - **Proxy path** is dynamic: reasoning stays ON in plain chat (you see it), and the proxy automatically sets `enable_thinking: false` when `tools` is present (loops stay stable). Best of both worlds, at the cost of running a local process.
258
-
259
- ### Validation results (June 1, 2026)
260
-
261
- #### Proxy validation (8 checks, all passed)
262
-
263
- | # | Check | Result |
264
- | --- | ---------------------------------------- | -------------------------------------------------------------------------------- |
265
- | 1 | Proxy starts | ✅ `--help` prints correct usage and defaults |
266
- | 2 | Health check | ✅ Returns `{"ok":true,"port":3458,...}` |
267
- | 3 | Plain chat (no tools) → thinking ON | ✅ Response contains `reasoning_content`; `enable_thinking` deleted |
268
- | 4 | Tool chat (tools present) → thinking OFF | ✅ No `reasoning_content`; clean `tool_calls`; `enable_thinking: false` injected |
269
- | 5 | Streaming passthrough | ✅ SSE chunks arrive correctly with `text/event-stream` |
270
- | 6 | Error passthrough | ✅ Invalid JSON returns HTTP 400 with useful error message |
271
- | 7 | Auth passthrough | ✅ Missing key → 401; valid key → 200 |
272
- | 8 | Logging | ✅ All entries redact `Authorization: Bearer <redacted>` |
273
-
274
- #### Direct-path validation — `qwen3.7-max`
275
-
276
- | Capability | Result | Notes |
277
- | -------------------------------------------- | ------ | ---------------------------------------------------------------------- |
278
- | Non-streaming chat (curl) | ✅ | HTTP 200, valid assistant message; `reasoning_content` present |
279
- | Streaming chat (curl) | ✅ | HTTP 200, SSE chunks; `reasoning_content` streamed alongside `content` |
280
- | Tool-enabled chat (thinking on) | ✅ | HTTP 200, `finish_reason: tool_calls` — `reasoning_content` present |
281
- | Tool-enabled chat (`enable_thinking: false`) | ✅ | HTTP 200, clean OpenAI shape, no `reasoning_content`, 25 tokens vs 170 |
282
- | Model appears in VS Code picker | ✅ | "Agent \| Qwen 3.7 Max" confirmed |
283
- | Plain chat in VS Code | ✅ | Streaming output confirmed |
284
- | Streaming in VS Code | ✅ | Token-by-token streaming confirmed |
285
- | Tool / agent use in VS Code | ✅ | Browser tool invoked successfully |
286
-
287
- #### Direct-path validation — `qwen3.7-plus`
288
-
289
- | Capability | Result | Notes |
290
- | -------------------------------------------- | ------ | ---------------------------------------------------------------------------- |
291
- | Non-streaming chat (curl) | ✅ | HTTP 200; `reasoning_content` present (727 reasoning tokens) |
292
- | Streaming chat (curl) | ✅ | SSE chunks with `reasoning_content` deltas streaming correctly |
293
- | Tool-enabled chat (`enable_thinking: false`) | ✅ | Clean `tool_calls`, no `reasoning_content`, 25 tokens |
294
- | Vision: image + text (curl, base64) | ✅ | Model correctly identified a 10×10 test pattern; `image_tokens: 66` |
295
- | Vision: image + text (curl, external URL) | ❌ | `Failed to download multimodal content` — DashScope couldn't reach Wikipedia |
296
- | Model appears in VS Code picker | ✅ | "Agent \| Qwen 3.7 Plus" confirmed |
297
- | Plain chat in VS Code | ✅ | Streaming output confirmed |
298
- | Streaming in VS Code | ✅ | Token-by-token streaming confirmed |
299
- | Tool / agent use in VS Code | ✅ | Browser tool invoked to open Qwen docs and Google |
300
- | Vision in VS Code | ✅ | Image attachment analyzed correctly |
301
-
302
- #### Intermittent `ERR_CONNECTION_RESET` investigation
303
-
304
- A `net::ERR_CONNECTION_RESET` was observed once during `qwen3.7-plus` validation, but did not reproduce on the same machine outside VS Code:
305
-
306
- - Direct `curl` POST to DashScope Singapore → HTTP 200.
307
- - Direct Node.js HTTPS POST → HTTP 200.
308
- - Direct Node.js HTTPS **streaming** POST with full `qwen3.7-plus.md` content embedded → HTTP 200.
309
-
310
- Conclusion: not a DashScope or Qwen model incompatibility. Evidence points to an intermittent VS Code / Electron transport issue or transient network interruption local to the editor process.
311
-
312
- ### Final verdict
313
-
314
- | Criterion | `qwen3.7-max` | `qwen3.7-plus` |
315
- | ---------------------- | -------------- | -------------- |
316
- | Plain chat | ✅ | ✅ |
317
- | Streaming chat | ✅ | ✅ |
318
- | Tool-enabled agent use | ✅ | ✅ |
319
- | Vision | ❌ (text-only) | ✅ |
320
- | Without a proxy | ✅ | ✅ |
321
-
322
- ### Known limitations
323
-
324
- - GitHub Copilot inline completions and semantic-search features remain outside scope.
325
- - One intermittent VS Code-side `net::ERR_CONNECTION_RESET` was observed — not reproducible externally, treated as transient transport issue.
326
- - External image URLs may fail if DashScope's servers cannot reach them; base64-encoded images work reliably.
327
- - Vision is not supported on `qwen3.7-max` (text-generation model).
328
- - `maxInputTokens` / `maxOutputTokens` not yet confirmed from official DashScope documentation.
329
- - API keys are region-specific — a key created for one regional endpoint will not work with another.
330
-
331
- ## References
332
-
333
- - VS Code custom endpoint docs: `https://code.visualstudio.com/docs/copilot/customization/language-models#_add-a-custom-endpoint-model`
334
- - DashScope OpenAI-compatible Chat Completions overview: `https://help.aliyun.com/zh/model-studio/compatibility-of-openai-with-dashscope`
335
- - DashScope model index: `https://help.aliyun.com/zh/model-studio/getting-started/models`
336
- - DashScope vision model guide: `https://help.aliyun.com/zh/model-studio/vision`
337
- - DashScope pricing: `https://www.alibabacloud.com/help/en/model-studio/billing-for-model-studio`
338
- - Kimi K2.6 validation record (separate provider): [kimi.md](kimi.md)
196
+ > Free quota: 1M input + 1M output tokens per model, valid 90 days after activating Model Studio.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilot-custom-endpoint",
3
- "version": "1.6.7",
3
+ "version": "1.6.9",
4
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",
@@ -57,4 +57,4 @@
57
57
  "dependencies": {
58
58
  "dotenv": "^17.4.2"
59
59
  }
60
- }
60
+ }