@chatcode/cco-llm-chatcode-config 0.1.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/README.zh.md +133 -0
  4. package/cordis.patch.yml +4 -0
  5. package/cordis.web.patch.yml +12 -0
  6. package/docs/chatcode-login.md +88 -0
  7. package/docs/chatcode-login.zh.md +179 -0
  8. package/docs/chatcode-models.md +29 -0
  9. package/docs/chatcode-models.zh.md +29 -0
  10. package/docs/chatcode-reporting.md +96 -0
  11. package/docs/chatcode-reporting.zh.md +96 -0
  12. package/docs/decisions/2026-08-31-chatcode-model-source.md +39 -0
  13. package/docs/decisions/2026-08-31-chatcode-model-source.zh.md +39 -0
  14. package/docs/decisions/2026-09-16-actual-model-adapter-routing.md +31 -0
  15. package/docs/decisions/2026-09-16-actual-model-adapter-routing.zh.md +31 -0
  16. package/lib/client.js +469 -0
  17. package/lib/index.d.ts +263 -0
  18. package/lib/index.d.ts.map +1 -0
  19. package/lib/index.js +4873 -0
  20. package/lib/index.js.map +1 -0
  21. package/lib/startup-gate-BaCbWaKH.js +164 -0
  22. package/lib/startup-gate-BaCbWaKH.js.map +1 -0
  23. package/lib/web-startup.d.ts +9 -0
  24. package/lib/web-startup.d.ts.map +1 -0
  25. package/lib/web-startup.js +20 -0
  26. package/lib/web-startup.js.map +1 -0
  27. package/package.json +121 -0
  28. package/vendor/README.md +7 -0
  29. package/vendor/dsh-llm-pi-ai/LICENSE +21 -0
  30. package/vendor/dsh-llm-pi-ai/README.i18n.yaml +6 -0
  31. package/vendor/dsh-llm-pi-ai/README.md +238 -0
  32. package/vendor/dsh-llm-pi-ai/README.zh.md +238 -0
  33. package/vendor/dsh-llm-pi-ai/package.json +65 -0
  34. package/vendor/dsh-llm-pi-ai/src/adapter.ts +434 -0
  35. package/vendor/dsh-llm-pi-ai/src/auth.ts +241 -0
  36. package/vendor/dsh-llm-pi-ai/src/catalog.ts +908 -0
  37. package/vendor/dsh-llm-pi-ai/src/config.ts +478 -0
  38. package/vendor/dsh-llm-pi-ai/src/context.ts +349 -0
  39. package/vendor/dsh-llm-pi-ai/src/discovery.ts +284 -0
  40. package/vendor/dsh-llm-pi-ai/src/index.ts +336 -0
  41. package/vendor/dsh-llm-pi-ai/src/invariant.ts +30 -0
  42. package/vendor/dsh-llm-pi-ai/src/login.ts +161 -0
  43. package/vendor/dsh-llm-pi-ai/src/provider.ts +192 -0
  44. package/vendor/dsh-llm-pi-ai/src/replay.ts +249 -0
  45. package/vendor/dsh-llm-pi-ai/src/stream.ts +232 -0
  46. package/vendor/dsh-llm-pi-ai/tests/adapter.e2e.ts +168 -0
  47. package/vendor/dsh-llm-pi-ai/tests/adapter.spec.ts +1034 -0
  48. package/vendor/dsh-llm-pi-ai/tests/assemble.ts +32 -0
  49. package/vendor/dsh-llm-pi-ai/tests/auth-double.ts +39 -0
  50. package/vendor/dsh-llm-pi-ai/tests/auth.spec.ts +221 -0
  51. package/vendor/dsh-llm-pi-ai/tests/catalog.spec.ts +1220 -0
  52. package/vendor/dsh-llm-pi-ai/tests/config.spec.ts +111 -0
  53. package/vendor/dsh-llm-pi-ai/tests/context.spec.ts +474 -0
  54. package/vendor/dsh-llm-pi-ai/tests/convert.spec.ts +922 -0
  55. package/vendor/dsh-llm-pi-ai/tests/discovery.spec.ts +374 -0
  56. package/vendor/dsh-llm-pi-ai/tests/dynamic-config.spec.ts +241 -0
  57. package/vendor/dsh-llm-pi-ai/tests/fixtures/qr-code.png +0 -0
  58. package/vendor/dsh-llm-pi-ai/tests/loader-composition.spec.ts +244 -0
  59. package/vendor/dsh-llm-pi-ai/tests/login.spec.ts +198 -0
  60. package/vendor/dsh-llm-pi-ai/tests/mock-server.ts +82 -0
  61. package/vendor/dsh-llm-pi-ai/tests/provider-apis.e2e.ts +266 -0
  62. package/vendor/dsh-llm-pi-ai/tests/sdk-options.spec.ts +106 -0
  63. package/vendor/dsh-llm-pi-ai/tsconfig.json +4 -0
  64. package/vendor/dsh-llm-pi-ai/tsconfig.upstream.json +51 -0
package/lib/client.js ADDED
@@ -0,0 +1,469 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@chatcode/cco-llm-chatcode-config",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ //#region src/client/style.ts
8
+ /** Styles are injected by the browser entry so the plugin remains self-contained. */
9
+ const modelConfigurationStyles = `
10
+ .chatcode-model-configuration {
11
+ display: flex;
12
+ max-width: 720px;
13
+ flex-direction: column;
14
+ gap: 20px;
15
+ margin-top: 20px;
16
+ color: var(--dsw-alias-label-primary);
17
+ }
18
+
19
+ .chatcode-model-configuration__header {
20
+ display: flex;
21
+ flex-direction: column;
22
+ gap: 4px;
23
+ }
24
+
25
+ .chatcode-model-configuration__title {
26
+ margin: 0;
27
+ font-size: 16px;
28
+ font-weight: 600;
29
+ line-height: 24px;
30
+ }
31
+
32
+ .chatcode-model-configuration__intro,
33
+ .chatcode-model-configuration__description,
34
+ .chatcode-model-configuration__empty,
35
+ .chatcode-model-configuration__notice {
36
+ margin: 0;
37
+ color: var(--dsw-alias-label-tertiary);
38
+ font-size: 13px;
39
+ line-height: 20px;
40
+ }
41
+
42
+ .chatcode-model-configuration__sources {
43
+ display: flex;
44
+ flex-direction: column;
45
+ gap: 16px;
46
+ }
47
+
48
+ .chatcode-model-configuration__source {
49
+ display: flex;
50
+ flex-direction: column;
51
+ gap: 10px;
52
+ }
53
+
54
+ .chatcode-model-configuration__source-heading,
55
+ .chatcode-model-configuration__model-head {
56
+ display: flex;
57
+ align-items: center;
58
+ gap: 8px;
59
+ }
60
+
61
+ .chatcode-model-configuration__model-head {
62
+ justify-content: space-between;
63
+ }
64
+
65
+ .chatcode-model-configuration__model-actions {
66
+ display: inline-flex;
67
+ flex: 0 0 auto;
68
+ gap: 6px;
69
+ }
70
+
71
+ .chatcode-model-configuration__text-button {
72
+ padding: 1px 6px;
73
+ border: 0;
74
+ border-radius: 4px;
75
+ background: transparent;
76
+ color: var(--dsw-alias-label-secondary);
77
+ cursor: pointer;
78
+ font: inherit;
79
+ font-size: 12px;
80
+ line-height: 20px;
81
+ }
82
+
83
+ .chatcode-model-configuration__text-button:hover {
84
+ background: var(--dsw-alias-fill-secondary);
85
+ color: var(--dsw-alias-label-primary);
86
+ }
87
+
88
+ .chatcode-model-configuration__text-button--danger:hover {
89
+ background: var(--dsw-alias-fill-danger, #fff1f0);
90
+ color: var(--dsw-alias-label-danger, #d92d20);
91
+ }
92
+
93
+ .chatcode-model-configuration__add {
94
+ align-self: flex-start;
95
+ padding: 4px 10px;
96
+ border: 1px dashed var(--dsw-alias-border-l2);
97
+ border-radius: 6px;
98
+ background: transparent;
99
+ color: var(--dsw-alias-label-primary);
100
+ cursor: pointer;
101
+ font: inherit;
102
+ font-size: 13px;
103
+ line-height: 20px;
104
+ }
105
+
106
+ .chatcode-model-configuration__add:hover {
107
+ border-style: solid;
108
+ background: var(--dsw-alias-fill-secondary);
109
+ }
110
+
111
+ .chatcode-model-configuration__form {
112
+ display: flex;
113
+ flex-direction: column;
114
+ gap: 12px;
115
+ padding: 14px;
116
+ border: 1px solid var(--dsw-alias-border-l2);
117
+ border-radius: 12px;
118
+ background: var(--dsw-alias-fill-secondary, transparent);
119
+ }
120
+
121
+ .chatcode-model-configuration__form-title {
122
+ margin: 0;
123
+ font-size: 14px;
124
+ font-weight: 600;
125
+ line-height: 22px;
126
+ }
127
+
128
+ .chatcode-model-configuration__form-grid {
129
+ display: grid;
130
+ grid-template-columns: repeat(2, minmax(0, 1fr));
131
+ gap: 10px 12px;
132
+ }
133
+
134
+ .chatcode-model-configuration__field {
135
+ display: flex;
136
+ flex-direction: column;
137
+ gap: 4px;
138
+ min-width: 0;
139
+ }
140
+
141
+ .chatcode-model-configuration__field--wide {
142
+ grid-column: 1 / -1;
143
+ }
144
+
145
+ .chatcode-model-configuration__field-label {
146
+ color: var(--dsw-alias-label-secondary);
147
+ font-size: 12px;
148
+ line-height: 18px;
149
+ }
150
+
151
+ .chatcode-model-configuration__input,
152
+ .chatcode-model-configuration__textarea {
153
+ box-sizing: border-box;
154
+ width: 100%;
155
+ min-height: 32px;
156
+ padding: 5px 8px;
157
+ border: 1px solid var(--dsw-alias-border-l2);
158
+ border-radius: 6px;
159
+ outline: none;
160
+ background: var(--dsw-alias-background-base, #fff);
161
+ color: var(--dsw-alias-label-primary);
162
+ font: inherit;
163
+ font-size: 13px;
164
+ line-height: 20px;
165
+ }
166
+
167
+ .chatcode-model-configuration__textarea {
168
+ min-height: 58px;
169
+ resize: vertical;
170
+ }
171
+
172
+ .chatcode-model-configuration__input:focus,
173
+ .chatcode-model-configuration__textarea:focus {
174
+ border-color: var(--dsw-alias-border-brand, #e03131);
175
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--dsw-alias-fill-brand, #e03131) 14%, transparent);
176
+ }
177
+
178
+ .chatcode-model-configuration__form-actions {
179
+ display: flex;
180
+ justify-content: flex-end;
181
+ gap: 8px;
182
+ }
183
+
184
+ .chatcode-model-configuration__form-button {
185
+ padding: 5px 12px;
186
+ border: 1px solid var(--dsw-alias-border-l2);
187
+ border-radius: 6px;
188
+ background: transparent;
189
+ color: var(--dsw-alias-label-primary);
190
+ cursor: pointer;
191
+ font: inherit;
192
+ font-size: 13px;
193
+ line-height: 20px;
194
+ }
195
+
196
+ .chatcode-model-configuration__form-button--primary {
197
+ border-color: var(--dsw-alias-fill-brand, #e03131);
198
+ background: var(--dsw-alias-fill-brand, #e03131);
199
+ color: #fff;
200
+ }
201
+
202
+ .chatcode-model-configuration__form-button:disabled,
203
+ .chatcode-model-configuration__add:disabled,
204
+ .chatcode-model-configuration__text-button:disabled {
205
+ cursor: not-allowed;
206
+ opacity: .52;
207
+ }
208
+
209
+ .chatcode-model-configuration__form-error {
210
+ margin: 0;
211
+ color: var(--dsw-alias-label-danger, #d92d20);
212
+ font-size: 12px;
213
+ line-height: 18px;
214
+ }
215
+
216
+ @media (max-width: 560px) {
217
+ .chatcode-model-configuration__form-grid { grid-template-columns: 1fr; }
218
+ .chatcode-model-configuration__field--wide { grid-column: auto; }
219
+ }
220
+
221
+ .chatcode-model-configuration__source-title {
222
+ margin: 0;
223
+ font-size: 14px;
224
+ font-weight: 600;
225
+ line-height: 22px;
226
+ }
227
+
228
+ .chatcode-model-configuration__read-only {
229
+ box-sizing: border-box;
230
+ padding: 1px 6px;
231
+ border: 1px solid var(--dsw-alias-border-l3);
232
+ border-radius: 4px;
233
+ color: var(--dsw-alias-label-tertiary);
234
+ font-size: 11px;
235
+ font-weight: 500;
236
+ line-height: 16px;
237
+ }
238
+
239
+ .chatcode-model-configuration__models {
240
+ display: flex;
241
+ flex-direction: column;
242
+ gap: 8px;
243
+ margin: 0;
244
+ padding: 0;
245
+ list-style: none;
246
+ }
247
+
248
+ .chatcode-model-configuration__model {
249
+ display: flex;
250
+ flex-direction: column;
251
+ gap: 4px;
252
+ padding: 12px 14px;
253
+ border: 1px solid var(--dsw-alias-border-l2);
254
+ border-radius: 12px;
255
+ background: var(--dsw-alias-background-base, transparent);
256
+ }
257
+
258
+ .chatcode-model-configuration__model-name {
259
+ overflow: hidden;
260
+ color: var(--dsw-alias-label-primary);
261
+ font-size: 14px;
262
+ font-weight: 500;
263
+ line-height: 22px;
264
+ text-overflow: ellipsis;
265
+ white-space: nowrap;
266
+ }
267
+
268
+ .chatcode-model-configuration__model-id {
269
+ overflow: hidden;
270
+ color: var(--dsw-alias-label-tertiary);
271
+ font-size: 12px;
272
+ line-height: 18px;
273
+ text-overflow: ellipsis;
274
+ white-space: nowrap;
275
+ }
276
+
277
+ .chatcode-model-configuration__switch-row {
278
+ display: flex;
279
+ align-items: center;
280
+ justify-content: space-between;
281
+ gap: 16px;
282
+ padding: 12px 14px;
283
+ border: 1px solid var(--dsw-alias-border-l2);
284
+ border-radius: 12px;
285
+ }
286
+
287
+ .chatcode-model-configuration__switch-copy {
288
+ display: flex;
289
+ flex-direction: column;
290
+ gap: 2px;
291
+ }
292
+
293
+ .chatcode-model-configuration__switch-label {
294
+ color: var(--dsw-alias-label-primary);
295
+ font-size: 14px;
296
+ font-weight: 500;
297
+ line-height: 22px;
298
+ }
299
+
300
+ .chatcode-model-configuration__switch {
301
+ position: relative;
302
+ flex: 0 0 auto;
303
+ width: 38px;
304
+ height: 22px;
305
+ padding: 0;
306
+ border: 0;
307
+ border-radius: 999px;
308
+ background: var(--dsw-alias-fill-quaternary, #d9d9d9);
309
+ cursor: pointer;
310
+ transition: background-color 160ms ease;
311
+ }
312
+
313
+ .chatcode-model-configuration__switch[aria-checked='true'] {
314
+ background: var(--dsw-alias-fill-brand, #e03131);
315
+ }
316
+
317
+ .chatcode-model-configuration__switch:focus-visible {
318
+ outline: 2px solid var(--dsw-alias-border-brand, #e03131);
319
+ outline-offset: 2px;
320
+ }
321
+
322
+ .chatcode-model-configuration__switch:disabled {
323
+ cursor: not-allowed;
324
+ opacity: .52;
325
+ }
326
+
327
+ .chatcode-model-configuration__switch-thumb {
328
+ position: absolute;
329
+ top: 3px;
330
+ left: 3px;
331
+ width: 16px;
332
+ height: 16px;
333
+ border-radius: 50%;
334
+ background: #fff;
335
+ box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
336
+ transition: transform 160ms ease;
337
+ }
338
+
339
+ .chatcode-model-configuration__switch[aria-checked='true'] .chatcode-model-configuration__switch-thumb {
340
+ transform: translateX(16px);
341
+ }
342
+
343
+ .chatcode-model-configuration__retry {
344
+ align-self: flex-start;
345
+ padding: 4px 10px;
346
+ border: 1px solid var(--dsw-alias-border-l2);
347
+ border-radius: 6px;
348
+ background: transparent;
349
+ color: var(--dsw-alias-label-primary);
350
+ cursor: pointer;
351
+ font: inherit;
352
+ font-size: 13px;
353
+ line-height: 20px;
354
+ }
355
+
356
+ .chatcode-model-configuration__retry:hover {
357
+ background: var(--dsw-alias-fill-secondary);
358
+ }
359
+ `;
360
+ //#endregion
361
+ //#region src/client/index.ts
362
+ /** Browser extension rendering the MAAS availability switch in the native Models page. */
363
+ const React = require("react");
364
+ const SETTINGS_NAMESPACE = "llm-chatcode-config";
365
+ const LOG_PREFIX = "[dsh-llm-chatcode-config]";
366
+ const en = {
367
+ title: "Model configuration",
368
+ description: "Custom models are managed by the native Models page. CodingPlan and MAAS models remain available in the conversation model selector.",
369
+ maas: "MAAS platform",
370
+ maasDescription: "Enable MAAS models for the conversation model selector.",
371
+ maasToggle: "Enable MAAS models",
372
+ maasUpdating: "Updating MAAS setting…",
373
+ maasUnavailable: "MAAS setting is unavailable."
374
+ };
375
+ const zh = {
376
+ title: "模型配置",
377
+ description: "自定义模型由原生模型页面管理;CodingPlan 与 MAAS 模型继续在对话模型选择中提供。",
378
+ maas: "Maas平台",
379
+ maasDescription: "开启后,MAAS 模型会出现在对话模型选择中。",
380
+ maasToggle: "启用 MAAS 模型",
381
+ maasUpdating: "正在更新 MAAS 设置…",
382
+ maasUnavailable: "MAAS 设置不可用。"
383
+ };
384
+ function installStyles() {
385
+ const documentRef = globalThis.document;
386
+ if (documentRef === void 0 || documentRef.querySelector("style[data-dsh-llm-chatcode-config]") !== null) return () => void 0;
387
+ const style = documentRef.createElement("style");
388
+ style.setAttribute("data-dsh-llm-chatcode-config", "true");
389
+ style.textContent = modelConfigurationStyles;
390
+ documentRef.head.appendChild(style);
391
+ return () => style.parentNode?.removeChild(style);
392
+ }
393
+ const inject = [
394
+ "slots",
395
+ "locale",
396
+ "settingsScope"
397
+ ];
398
+ function ModelConfigurationCard(props) {
399
+ const injected = props;
400
+ if (injected.scope === void 0 || injected.t === void 0) return null;
401
+ const { scope, t } = injected;
402
+ const [updating, setUpdating] = React.useState(false);
403
+ const settings = React.useSyncExternalStore(scope.subscribe.bind(scope), scope.getSnapshot.bind(scope));
404
+ const element = React.createElement;
405
+ return element("section", { className: "chatcode-model-configuration" }, element("div", { className: "chatcode-model-configuration__header" }, element("h3", { className: "chatcode-model-configuration__title" }, t("title")), element("p", { className: "chatcode-model-configuration__intro" }, t("description"))), element("section", { className: "chatcode-model-configuration__source" }, element("h4", { className: "chatcode-model-configuration__source-title" }, t("maas")), element("p", { className: "chatcode-model-configuration__description" }, t("maasDescription")), settings.status === "ready" ? element("div", { className: "chatcode-model-configuration__switch-row" }, element("div", { className: "chatcode-model-configuration__switch-copy" }, element("span", { className: "chatcode-model-configuration__switch-label" }, updating ? t("maasUpdating") : t("maasToggle"))), element("button", {
406
+ type: "button",
407
+ role: "switch",
408
+ "aria-checked": settings.value?.enableMaas === true,
409
+ "aria-label": t("maasToggle"),
410
+ className: "chatcode-model-configuration__switch",
411
+ disabled: !settings.writable || updating,
412
+ onClick: () => {
413
+ const next = settings.value?.enableMaas !== true;
414
+ console.info(`${LOG_PREFIX} MAAS switch clicked; enableMaas=${String(next)}`);
415
+ setUpdating(true);
416
+ scope.set("enableMaas", next).then(() => {
417
+ console.info(`${LOG_PREFIX} MAAS setting write succeeded; enableMaas=${String(next)}`);
418
+ }, (error) => {
419
+ console.error(`${LOG_PREFIX} MAAS setting write failed`, error);
420
+ }).finally(() => {
421
+ setUpdating(false);
422
+ });
423
+ }
424
+ }, element("span", { className: "chatcode-model-configuration__switch-thumb" }))) : element("p", { className: "chatcode-model-configuration__notice" }, t("maasUnavailable"))));
425
+ }
426
+ function apply(ctx) {
427
+ console.info(`${LOG_PREFIX} Web client extension apply() called`);
428
+ ctx.effect(() => installStyles(), "chatcode-models: styles");
429
+ ctx.effect(() => ctx.locale.register("settings.chatcodeModels", {
430
+ zh,
431
+ en
432
+ }), "chatcode-models: dictionaries");
433
+ const scope = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
434
+ ctx.effect(() => {
435
+ let previous = "";
436
+ const report = () => {
437
+ const snapshot = scope.getSnapshot();
438
+ const summary = JSON.stringify({
439
+ status: snapshot.status,
440
+ writable: snapshot.writable,
441
+ enableMaas: snapshot.value?.enableMaas
442
+ });
443
+ if (summary === previous) return;
444
+ previous = summary;
445
+ console.info(`${LOG_PREFIX} settingsScope snapshot ${summary}`);
446
+ };
447
+ report();
448
+ return scope.subscribe(report);
449
+ }, "chatcode-models: settings diagnostics");
450
+ const t = ctx.locale.bind("settings.chatcodeModels");
451
+ ctx.slots.inject("settings.models.footer", () => {
452
+ console.info(`${LOG_PREFIX} registering settings.models.footer card`);
453
+ return ctx.slots.register({
454
+ name: "settings.models.footer",
455
+ id: "chatcode-models",
456
+ locale: "settings.chatcodeModels",
457
+ inject: () => ({
458
+ scope,
459
+ t
460
+ })
461
+ }, ModelConfigurationCard);
462
+ });
463
+ }
464
+ //#endregion
465
+ exports.apply = apply;
466
+ exports.inject = inject;
467
+ return module.exports;
468
+ }
469
+ });