dsh-tap 0.20.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.
Files changed (121) hide show
  1. package/AGENTS.md +99 -0
  2. package/CHANGELOG.md +751 -0
  3. package/LICENSE +21 -0
  4. package/README.en.md +59 -0
  5. package/README.md +256 -0
  6. package/cordis.patch.yml +385 -0
  7. package/core/bridge.js +698 -0
  8. package/core/json-store.js +91 -0
  9. package/core/rotation.js +108 -0
  10. package/core/usage-meter.js +176 -0
  11. package/docs/diagnosis-cache-quota.md +181 -0
  12. package/docs/diagnosis-qoder-flash.md +67 -0
  13. package/docs/diagnosis-trae-3003.md +302 -0
  14. package/docs/goals/bridge-port-host-split.md +91 -0
  15. package/docs/goals/desktop-adaptation.md +106 -0
  16. package/docs/goals/qoder-cn-provider-design.md +308 -0
  17. package/docs/goals/settings-card-ux-redesign-plan.md +1680 -0
  18. package/docs/goals/settings-card-ux-redesign.md +162 -0
  19. package/docs/goals/trae-agent-v3.md +41 -0
  20. package/docs/goals/trae-work-cn-repair.md +44 -0
  21. package/docs/goals/v0.8-/351/242/235/345/272/246/345/217/257/350/247/201-/346/250/241/345/236/213/345/212/250/346/200/201/345/214/226-/345/244/232/346/234/215/345/212/241/345/225/206.md +85 -0
  22. package/docs/pitfalls.md +105 -0
  23. package/docs/reverse/trae-cloud-api.md +218 -0
  24. package/docs/reverse/trae-model-catalog.md +129 -0
  25. package/docs/reverse/traework-cn.md +520 -0
  26. package/docs/rules/STATE.md +198 -0
  27. package/docs/rules/content-moderation.md +54 -0
  28. package/docs/rules/dev-role-boundary.md +94 -0
  29. package/docs/rules/extra-providers.md +42 -0
  30. package/docs/rules/gateway-facts.md +91 -0
  31. package/docs/rules/oauth-handshake.md +76 -0
  32. package/docs/rules/prompt-cache.md +93 -0
  33. package/docs/rules/quota-signals.md +125 -0
  34. package/docs/rules/routing.md +84 -0
  35. package/docs/rules/templates/oauth-reverse-checklist.md +42 -0
  36. package/docs/rules/trae-surface.md +242 -0
  37. package/docs/rules/ua-validation.md +81 -0
  38. package/host-config.js +282 -0
  39. package/index.js +2306 -0
  40. package/lib/client.js +2893 -0
  41. package/local-scan.js +104 -0
  42. package/package.json +82 -0
  43. package/providers/ark/index.js +11 -0
  44. package/providers/bailian/index.js +10 -0
  45. package/providers/bigmodel/index.js +11 -0
  46. package/providers/codebuddy/agenttool.js +122 -0
  47. package/providers/codebuddy/catalog.js +227 -0
  48. package/providers/codebuddy/errors.js +44 -0
  49. package/providers/codebuddy/headers.js +36 -0
  50. package/providers/codebuddy/images.js +125 -0
  51. package/providers/codebuddy/index.js +123 -0
  52. package/providers/codebuddy/oauth.js +279 -0
  53. package/providers/deepseek/index.js +11 -0
  54. package/providers/moonshot/index.js +11 -0
  55. package/providers/openai-compat.js +177 -0
  56. package/providers/openrouter/index.js +27 -0
  57. package/providers/qoder/catalog.js +145 -0
  58. package/providers/qoder/cosy.js +419 -0
  59. package/providers/qoder/gateway.js +563 -0
  60. package/providers/qoder/index.js +116 -0
  61. package/providers/qoder/oauth.js +364 -0
  62. package/providers/qoder/qoder_auth.wasm +0 -0
  63. package/providers/qoder/quota.js +56 -0
  64. package/providers/qwen/index.js +15 -0
  65. package/providers/tool-pairing.js +129 -0
  66. package/providers/trae/catalog.js +103 -0
  67. package/providers/trae/errors.js +85 -0
  68. package/providers/trae/gateway.js +853 -0
  69. package/providers/trae/index.js +126 -0
  70. package/providers/trae/oauth.js +443 -0
  71. package/providers/trae/quota.js +75 -0
  72. package/providers/trae/remote.js +365 -0
  73. package/scripts/capture-cache.mjs +65 -0
  74. package/scripts/capture-traffic.mjs +83 -0
  75. package/scripts/hermes-probe-dev-role.mjs +263 -0
  76. package/scripts/measure-latency.mjs +253 -0
  77. package/scripts/probe-ark-thinking.mjs +298 -0
  78. package/scripts/probe-cache-decline.mjs +292 -0
  79. package/scripts/probe-cache-ttl.mjs +221 -0
  80. package/scripts/probe-cache.mjs +156 -0
  81. package/scripts/probe-codebuddy-efforts.mjs +355 -0
  82. package/scripts/probe-codebuddy-tier-wiring.mjs +244 -0
  83. package/scripts/probe-effort-gaps.mjs +133 -0
  84. package/scripts/probe-media.mjs +115 -0
  85. package/scripts/probe-moderation.mjs +159 -0
  86. package/scripts/probe-oauth.mjs +617 -0
  87. package/scripts/probe-qoder-attribution-arm8.mjs +92 -0
  88. package/scripts/probe-qoder-attribution-arm9.mjs +102 -0
  89. package/scripts/probe-qoder-attribution.mjs +266 -0
  90. package/scripts/probe-qoder-flash-confirm.mjs +94 -0
  91. package/scripts/probe-qoder-live.mjs +344 -0
  92. package/scripts/probe-qoder-matrix.mjs +274 -0
  93. package/scripts/probe-qoder-null-content.mjs +153 -0
  94. package/scripts/probe-qoder-pairing.mjs +308 -0
  95. package/scripts/probe-qoder-quota.mjs +162 -0
  96. package/scripts/probe-qoder-thinking-config.mjs +52 -0
  97. package/scripts/probe-qoder-thinking-efforts.mjs +269 -0
  98. package/scripts/probe-quota.mjs +136 -0
  99. package/scripts/probe-quota2.mjs +144 -0
  100. package/scripts/probe-routing.mjs +226 -0
  101. package/scripts/probe-trae-3003-diagnosis.mjs +139 -0
  102. package/scripts/probe-trae-agent-v3.mjs +399 -0
  103. package/scripts/probe-trae-efforts.mjs +149 -0
  104. package/scripts/probe-trae-live.mjs +147 -0
  105. package/scripts/probe-trae-max-effort.mjs +179 -0
  106. package/scripts/probe-trae-model-routing.mjs +381 -0
  107. package/scripts/probe-trae-thinking-scene.mjs +238 -0
  108. package/scripts/probe-trae-transport-outage.mjs +176 -0
  109. package/scripts/probe-ua.mjs +508 -0
  110. package/scripts/trae-model-catalog.mjs +632 -0
  111. package/scripts/verify-agents-md.mjs +45 -0
  112. package/scripts/verify-bridge.mjs +1041 -0
  113. package/scripts/verify-core-generic.mjs +302 -0
  114. package/scripts/verify-desktop-acceptance.mjs +184 -0
  115. package/scripts/verify-host-config.mjs +265 -0
  116. package/scripts/verify-models.mjs +390 -0
  117. package/scripts/verify-providers.mjs +255 -0
  118. package/scripts/verify-qoder-provider.mjs +1020 -0
  119. package/scripts/verify-rotation.mjs +308 -0
  120. package/scripts/verify-trae-model-catalog.mjs +284 -0
  121. package/scripts/verify-trae-provider.mjs +1451 -0
@@ -0,0 +1,385 @@
1
+ # dsh-tap — CodeBuddy provider bundle
2
+ #
3
+ # Overrides three rows from dsh-base:
4
+ #
5
+ # 1. `llm-pi-ai` — the codebuddy route: an OpenAI-compatible (Chat
6
+ # Completions, streaming-only) gateway behind the plugin's loopback
7
+ # stream bridge at 127.0.0.1:3901, serving 18 models.
8
+ # 2. `agent-default-model` — select deepseek-v3 by default.
9
+ # 3. `web` — pin dsh's stock web_search/web_fetch tools onto the codebuddy
10
+ # backends registered by index.js. Without the pin, multiple usable
11
+ # providers (e.g. the bundled web-fetch-http) make selection AMBIGUOUS.
12
+ #
13
+ # Credentials: the route points at the bridge and carries a SENTINEL
14
+ # Authorization header, so no apiKeyEnv is named (a named-but-unset ref
15
+ # fails requests with MISSING_CREDENTIAL; pi-ai only insists on "a key or
16
+ # an Authorization header", and the OpenAI SDK's defaultHeaders override
17
+ # its authHeaders, so the sentinel is what goes on the wire). The bridge
18
+ # replaces the sentinel with the real credential per request — OAuth
19
+ # tokens or the active API key, resolved by index.js (resolveCredential).
20
+ # This file therefore carries no secrets, and OAuth login in the settings
21
+ # card covers the main chat path too.
22
+ #
23
+ # NOTE: this patch REPLACES the whole `config` of each row, so every key the
24
+ # row needs must be restated here.
25
+ #
26
+ # Model sources (checked 2026-08-16):
27
+ # - Sizes and `input` follow the gateway's own catalog, GET /v3/config
28
+ # (auth via the `x-api-key` header; the UA must match the CLI shape,
29
+ # e.g. "CLI/unknown CodeBuddy/2.136.0" — the /v2 client UA is rejected
30
+ # with error 12403). dsh's built-in discovery cannot work here: the
31
+ # gateway has no OpenAI-style GET /models endpoint. Refresh with:
32
+ # node scripts/verify-models.mjs --sync
33
+ # - Ids the catalog no longer lists (deepseek-v3 / v3.2 / r1, kimi-k3,
34
+ # hy3-preview, auto) still serve on /v2 as of 2026-08-16; their sizes
35
+ # keep each model's official spec. Unknown ids return error 11102.
36
+ # - reasoningEfforts verified 2026-08-16 with `verify-models.mjs --efforts`:
37
+ # the gateway accepts off/low/medium/high/max spellings across GLM, Kimi,
38
+ # MiniMax and Hunyuan. Models that think even without the parameter
39
+ # (kimi-k2.7 / k3 / k3-1, minimax-m2.7) offer no `off`; the rest map
40
+ # `off` to omitting the parameter (verified: no reasoning_content).
41
+ # Reasoning length per level is adaptive, not strictly monotonic.
42
+ # - reasoningEfforts RE-verified 2026-09-22 with
43
+ # `node scripts/probe-codebuddy-efforts.mjs` (162 arms, evidence
44
+ # docs/probes/codebuddy-efforts-matrix-2026-09-22.json; decision table via
45
+ # `--summarize`), 5 weeks after the first pass. Outcomes:
46
+ # * `off` REMOVED from hy3 and hy3-preview — both now think on the omitted
47
+ # parameter (reasoning_content ~600 chars on every arm), so the old
48
+ # "off = omit the parameter" entry had become a no-op switch. `off` stays
49
+ # on models whose omission still yields no reasoning (deepseek-v3.2 / r1
50
+ # family, v4-pro, v4-flash, GLM 5.1/5.2/5v-turbo, Kimi k2.5/k2.6, m3).
51
+ # * SIZES corrected against the current catalog (maxTokens 50000 -> 128000
52
+ # for deepseek-v4-pro, 48000 -> 64000 for glm-5.2, 128000 -> 64000 for
53
+ # minimax-m3).
54
+ # * NEW static entries for catalog-only models that are routable AND whose
55
+ # effort parameter measurably works (probe 200 + reasoning changes):
56
+ # deepseek-v4.1-flash, deepseek-v3-2-volc, glm-5.3, glm-5.0-turbo, hy3-x.
57
+ # They carry no `off` where omission thinks (glm-5.3 / hy3-x).
58
+ # * Newer models declare their tiers in the catalog itself
59
+ # (`reasoning.supportedEfforts` / `canDisableThinking` / `defaultEffort`)
60
+ # — glm-5.3-flash, kimi-k2.8-preview, hy4-preview. Those are NOT listed
61
+ # here: index.js derives their tier table from the declaration at sync
62
+ # time (see `catalogReasoningEfforts`), and no wire spelling was found
63
+ # that actually turns thinking off on them, so no `off` is offered.
64
+ # * Catalog entries the chat endpoint refuses with 11102 (glm-4.6v,
65
+ # kimi-k2-thinking, minimax-m2.5, hy4-preview-x) are deliberately NOT
66
+ # added — catalog presence does not imply routability (routing.md R-R3).
67
+
68
+ # Insert this package into the profile's plugin entry list so cordis loads
69
+ # index.js (the runtime layer registering the codebuddy web providers).
70
+ - insert:
71
+ - id: dsh-tap
72
+ name: 'dsh-tap'
73
+
74
+ - id: llm-pi-ai
75
+ config:
76
+ providers:
77
+ codebuddy:
78
+ displayName: CodeBuddy
79
+ api: openai-completions
80
+ # Main chat goes through the plugin's loopback stream bridge, which
81
+ # owns credential resolution (OAuth or API key, per the settings
82
+ # card). The port must match the bridge's (bridgePort, default
83
+ # 3901) — change both or chat breaks.
84
+ baseURL: http://127.0.0.1:3901/v2
85
+ # Identify as the CodeBuddy CLI client — the same marker set the
86
+ # official CLI sends (verified from its logs: ideType/ideName "CLI",
87
+ # X-IDE-* headers). Gateway-side logs and routing use these to show
88
+ # CodeBuddy traffic. Values copied from @tencent-ai/codebuddy-code.
89
+ # (User-Agent is replaced by dsh's own attribution UA on the way
90
+ # out; the /v2 chat endpoint does not enforce a client UA.)
91
+ headers:
92
+ # Sentinel: pi-ai refuses to send without a key or an
93
+ # Authorization header, and defaultHeaders beat the OpenAI SDK's
94
+ # authHeaders — the bridge replaces this value with the resolved
95
+ # credential, never forwarding it upstream.
96
+ Authorization: Bearer dsh-codebuddy-bridge
97
+ X-IDE-Type: CLI
98
+ X-IDE-Name: CLI
99
+ X-IDE-Version: 2.133.1
100
+ X-Product-Version: 2.133.1
101
+ X-Requested-With: XMLHttpRequest
102
+ X-Private-Data: "false"
103
+ # The endpoint speaks OpenAI-dialect reasoning (reasoning_effort),
104
+ # not DeepSeek-dialect `thinking`. Tell pi-ai explicitly, otherwise it
105
+ # guesses from the URL and sends `thinking`, which the gateway answers
106
+ # with finish_reason=content_filter.
107
+ # Session attribution (v0.5.5-A): dsh upstream already supplies the
108
+ # per-request sessionId (dsh-agent-loop sets sessionId: session.id);
109
+ # these switches let pi-ai emit it as the gateway's affinity headers
110
+ # (openai format: session_id / x-client-request-id / x-session-affinity).
111
+ compat:
112
+ thinkingFormat: openai
113
+ supportsReasoningEffort: true
114
+ models:
115
+ # DeepSeek
116
+ - id: deepseek-v3
117
+ name: DeepSeek V3
118
+ contextWindow: 131072
119
+ maxTokens: 32768
120
+ - id: deepseek-v3.2
121
+ name: DeepSeek V3.2
122
+ contextWindow: 131072
123
+ maxTokens: 32768
124
+ # 2026-09-22 补表:旧清单漏了这条,实测档位有效(omit 无思考、
125
+ # low/medium/high/max 各出 147–248 字推理)——与 v4 家族同形。
126
+ reasoningEfforts:
127
+ off:
128
+ low: low
129
+ medium: medium
130
+ high: high
131
+ max: max
132
+ - id: deepseek-r1
133
+ name: DeepSeek R1
134
+ contextWindow: 131072
135
+ maxTokens: 32768
136
+ reasoningEfforts:
137
+ low: low
138
+ medium: medium
139
+ high: high
140
+ max: max
141
+ - id: deepseek-v4-pro
142
+ name: DeepSeek V4 Pro
143
+ contextWindow: 1000000
144
+ maxTokens: 128000
145
+ input: [text, image]
146
+ reasoningEfforts:
147
+ off:
148
+ low: low
149
+ medium: medium
150
+ high: high
151
+ max: max
152
+ - id: deepseek-v4-flash
153
+ name: DeepSeek V4 Flash
154
+ contextWindow: 1000000
155
+ maxTokens: 50000
156
+ input: [text, image]
157
+ reasoningEfforts:
158
+ off:
159
+ low: low
160
+ medium: medium
161
+ high: high
162
+ max: max
163
+ # 2026-09-22 新增(目录可路由 + 档位实测有效;非 CLI 名单但 /v2 可用)
164
+ - id: deepseek-v4.1-flash
165
+ name: DeepSeek V4.1 Flash
166
+ contextWindow: 1000000
167
+ maxTokens: 128000
168
+ input: [text, image]
169
+ reasoningEfforts:
170
+ off:
171
+ low: low
172
+ medium: medium
173
+ high: high
174
+ max: max
175
+ - id: deepseek-v3-2-volc
176
+ name: DeepSeek V3.2 Volc
177
+ contextWindow: 96000
178
+ maxTokens: 32000
179
+ reasoningEfforts:
180
+ off:
181
+ low: low
182
+ medium: medium
183
+ high: high
184
+ max: max
185
+ # Zhipu GLM
186
+ - id: glm-5.1
187
+ name: GLM 5.1
188
+ contextWindow: 200000
189
+ maxTokens: 48000
190
+ input: [text, image]
191
+ reasoningEfforts:
192
+ off:
193
+ low: low
194
+ medium: medium
195
+ high: high
196
+ max: max
197
+ - id: glm-5.2
198
+ name: GLM 5.2
199
+ contextWindow: 1000000
200
+ maxTokens: 64000
201
+ input: [text, image]
202
+ reasoningEfforts:
203
+ off:
204
+ low: low
205
+ medium: medium
206
+ high: high
207
+ max: max
208
+ # 2026-09-22 新增:省略参数即思考(omit 臂 reason≈1.2k)→ 无 off 档
209
+ - id: glm-5.3
210
+ name: GLM 5.3
211
+ contextWindow: 1000000
212
+ maxTokens: 64000
213
+ input: [text, image]
214
+ reasoningEfforts:
215
+ low: low
216
+ medium: medium
217
+ high: high
218
+ max: max
219
+ - id: glm-5.0-turbo
220
+ name: GLM 5.0 Turbo
221
+ contextWindow: 200000
222
+ maxTokens: 48000
223
+ reasoningEfforts:
224
+ off:
225
+ low: low
226
+ medium: medium
227
+ high: high
228
+ max: max
229
+ - id: glm-5v-turbo
230
+ name: GLM 5V Turbo
231
+ contextWindow: 200000
232
+ maxTokens: 64000
233
+ input: [text, image]
234
+ reasoningEfforts:
235
+ off:
236
+ low: low
237
+ medium: medium
238
+ high: high
239
+ max: max
240
+ # Moonshot Kimi
241
+ - id: kimi-k2.5
242
+ name: Kimi K2.5
243
+ contextWindow: 164000
244
+ maxTokens: 32000
245
+ input: [text, image]
246
+ reasoningEfforts:
247
+ off:
248
+ low: low
249
+ medium: medium
250
+ high: high
251
+ max: max
252
+ - id: kimi-k2.6
253
+ name: Kimi K2.6
254
+ contextWindow: 256000
255
+ maxTokens: 32000
256
+ input: [text, image]
257
+ reasoningEfforts:
258
+ off:
259
+ low: low
260
+ medium: medium
261
+ high: high
262
+ max: max
263
+ - id: kimi-k2.7
264
+ name: Kimi K2.7
265
+ contextWindow: 256000
266
+ maxTokens: 32000
267
+ input: [text, image]
268
+ reasoningEfforts:
269
+ low: low
270
+ medium: medium
271
+ high: high
272
+ max: max
273
+ - id: kimi-k3
274
+ name: Kimi K3
275
+ contextWindow: 262144
276
+ maxTokens: 32768
277
+ reasoningEfforts:
278
+ low: low
279
+ medium: medium
280
+ high: high
281
+ max: max
282
+ - id: kimi-k3-1
283
+ name: Kimi K3.1
284
+ contextWindow: 1000000
285
+ maxTokens: 32000
286
+ input: [text, image]
287
+ reasoningEfforts:
288
+ low: low
289
+ medium: medium
290
+ high: high
291
+ max: max
292
+ # MiniMax
293
+ - id: minimax-m2.7
294
+ name: MiniMax M2.7
295
+ contextWindow: 200000
296
+ maxTokens: 48000
297
+ input: [text, image]
298
+ reasoningEfforts:
299
+ low: low
300
+ medium: medium
301
+ high: high
302
+ max: max
303
+ - id: minimax-m3
304
+ name: MiniMax M3
305
+ contextWindow: 512000
306
+ maxTokens: 64000
307
+ input: [text, image]
308
+ reasoningEfforts:
309
+ off:
310
+ low: low
311
+ medium: medium
312
+ high: high
313
+ max: max
314
+ # Tencent Hunyuan
315
+ # 2026-09-22:hy3 / hy3-preview 的 off 档撤销——省略参数两模型都照常
316
+ # 思考(六臂 reason≈510–625),off 已成假开关(宿主选择器会出 Off)。
317
+ - id: hy3
318
+ name: Hunyuan Hy3
319
+ contextWindow: 192000
320
+ maxTokens: 64000
321
+ input: [text, image]
322
+ reasoningEfforts:
323
+ low: low
324
+ medium: medium
325
+ high: high
326
+ max: max
327
+ - id: hy3-x
328
+ name: Hunyuan Hy3 X
329
+ contextWindow: 192000
330
+ maxTokens: 64000
331
+ input: [text, image]
332
+ reasoningEfforts:
333
+ low: low
334
+ medium: medium
335
+ high: high
336
+ max: max
337
+ - id: hy3-preview
338
+ name: Hunyuan Hy3 Preview
339
+ contextWindow: 262144
340
+ maxTokens: 32768
341
+ reasoningEfforts:
342
+ low: low
343
+ medium: medium
344
+ high: high
345
+ max: max
346
+ # Auto routing
347
+ - id: auto
348
+ name: Auto
349
+ contextWindow: 262144
350
+ maxTokens: 32768
351
+
352
+ # TraeWork CN channel (v0.8.x): OAuth subscription quota via the
353
+ # plugin's OpenAI<->Trae translation gateway at 127.0.0.1:3902
354
+ # (default; must match traeBridgePort).
355
+ #
356
+ # 0.8.7 NOTE — no static trae base here anymore (dsh 0.1.1-rc.2
357
+ # adaptation): llm-pi-ai now REJECTS a non-catalog route with an empty
358
+ # models list at apply time (throwing takes down the whole llm-pi-ai
359
+ # fiber), so the "empty-list shadowing" trick for disabling the channel
360
+ # no longer works. Route EXISTENCE is now the whole story, owned by the
361
+ # settings.yaml mirror index.js maintains (llm-pi-ai.providers.trae as a
362
+ # COMPLETE block): enabled+synced -> full block (displayName/api/
363
+ # baseURL/headers/models, baseURL following traeBridgePort);
364
+ # disabled/unsynced -> the block is DELETED (route gone, picker hides
365
+ # the channel, no restart). With no patch-layer base, deletion leaves
366
+ # no stale fallback to shadow. Same sentinel-Authorization mechanics
367
+ # as the codebuddy route: the gateway replaces the static header per
368
+ # request with the resolved OAuth credential (Cloud-IDE-JWT +
369
+ # x-cloudide-token). reasoning_effort dialect unverified against the
370
+ # Trae gateway — compat left off until the live probe pins it
371
+ # (docs/reverse/trae-cloud-api.md).
372
+ # UPGRADE NOTE: a settings.yaml trae block written by <=0.8.5 carries
373
+ # only the models path (it leaned on this base for the other fields);
374
+ # remove it before the first 0.1.1-rc.2 boot, or llm-pi-ai fails on
375
+ # the missing baseURL before this plugin can rewrite it.
376
+
377
+ - id: agent-default-model
378
+ config:
379
+ provider: codebuddy
380
+ model: deepseek-v3
381
+
382
+ - id: web
383
+ config:
384
+ searchProvider: codebuddy
385
+ fetchProvider: codebuddy