@megen-lebar/dsh-reasoning-effort 0.2.3 → 0.2.4

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 (4) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +10 -0
  3. package/lib/client.js +221 -99
  4. package/package.json +4 -4
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  DSH Web GUI「思考强度」配置器插件。在侧边栏新增「思考强度」入口,用可视化面板管理第三方 API 各模型的 reasoning effort,无需手写 YAML。
4
4
 
5
+ 独立仓库:<https://github.com/Jamsharden/dsh-reasoning-effort>
6
+
5
7
  ## 功能
6
8
 
7
9
  - 列出 `settings.yaml` 里 `llm-pi-ai.providers.*` 已配置的 provider 与模型。
@@ -13,6 +15,14 @@ DSH Web GUI「思考强度」配置器插件。在侧边栏新增「思考强度
13
15
  - 面板会显示当前对话的 Provider / 模型并高亮对应条目,避免在同名模型的其他 Provider 上误改配置。
14
16
  - 保存过程有明确的进行中、成功和错误反馈;写入 DSH settings 命名空间 `llm-pi-ai` 后,下一轮对话生效,无需重启。
15
17
 
18
+ ## 安装(npm,推荐)
19
+
20
+ ```powershell
21
+ dsh plugin --profile web add @megen-lebar/dsh-reasoning-effort
22
+ ```
23
+
24
+ 安装后完全退出并重新启动 DSH Web Host,再刷新 GUI。也可用下文的本地 link 方式安装源码。
25
+
16
26
  ## 安装(本地 link,与 dsh-archive-panel 同模式)
17
27
 
18
28
  1. 在 `~/.dsh/profiles/web/package.json` 的 `dependencies` 增加
package/lib/client.js CHANGED
@@ -24,6 +24,25 @@ window.__ModuleLoader__.load({
24
24
  xhigh: "超高",
25
25
  max: "最大",
26
26
  };
27
+ var LEVEL_NOTES = {
28
+ off: "模型直接给出回答,不产生思考内容",
29
+ minimal: "一闪而过的短思考",
30
+ low: "轻量推理,快而省",
31
+ medium: "均衡的日常深度",
32
+ high: "深度推理,质量优先",
33
+ xhigh: "极深推理,慢而彻底",
34
+ max: "不设上限的最大预算",
35
+ };
36
+ var FORMAT_TITLES = {
37
+ openai: "OpenAI 系协议",
38
+ deepseek: "DeepSeek 官方",
39
+ openrouter: "聚合协议",
40
+ together: "Together 协议",
41
+ zai: "智谱 Z.ai 协议",
42
+ qwen: "通义 Qwen 协议",
43
+ "string-thinking": "<think> 标签",
44
+ "ant-ling": "Ling 系协议",
45
+ };
27
46
 
28
47
  var icons = {
29
48
  brain: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9.5 4.5A3.5 3.5 0 0 0 3 6.3a3.6 3.6 0 0 0-.8 5.9A3.6 3.6 0 0 0 5.7 18c1.5 0 2.8-.9 3.8-2.1V4.5Z"/><path d="M14.5 4.5A3.5 3.5 0 0 1 21 6.3a3.6 3.6 0 0 1 .8 5.9 3.6 3.6 0 0 1-3.5 5.8c-1.5 0-2.8-.9-3.8-2.1V4.5Z"/><path d="M5.8 9.2c1.4.1 2.4.9 2.8 2.2M18.2 9.2c-1.4.1-2.4.9-2.8 2.2"/></svg>',
@@ -31,6 +50,7 @@ window.__ModuleLoader__.load({
31
50
  back: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg>',
32
51
  refresh: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.3-5.7L20 8"/><path d="M20 3v5h-5"/></svg>',
33
52
  chevron: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg>',
53
+ caret: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m6 9 6 6 6-6"/></svg>',
34
54
  check: '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m5 12 4 4L19 6"/></svg>',
35
55
  info: '<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 11v5M12 8h.01"/></svg>',
36
56
  };
@@ -111,14 +131,13 @@ window.__ModuleLoader__.load({
111
131
  '[data-dsh-reasoning-card]{background:var(--ink-card);border:1px solid var(--ink-line);border-radius:14px;overflow:hidden}',
112
132
  '[data-dsh-reasoning-divided]>*+*{border-top:1px solid var(--ink-line)}',
113
133
  '[data-dsh-reasoning-toolbar]{display:flex;align-items:center;gap:8px;padding:10px 12px}',
114
- '[data-dsh-reasoning-select],[data-dsh-reasoning-search],[data-dsh-reasoning-wire]{box-sizing:border-box;height:36px;border:1px solid var(--ink-line-strong);border-radius:10px;background:var(--ink-paper);color:var(--ink-text);font:inherit;font-size:12.5px;outline:none;transition:border-color .12s,box-shadow .12s}',
115
- '[data-dsh-reasoning-select]{width:100%;flex:1;min-width:0;padding:0 28px 0 10px}',
134
+ '[data-dsh-reasoning-search],[data-dsh-reasoning-wire]{box-sizing:border-box;height:36px;border:1px solid var(--ink-line-strong);border-radius:10px;background:var(--ink-paper);color:var(--ink-text);font:inherit;font-size:12.5px;outline:none;transition:border-color .12s,box-shadow .12s}',
116
135
  '[data-dsh-reasoning-search]{width:100%;padding:0 12px}',
117
136
  '[data-dsh-reasoning-search-empty]{display:none;padding:20px 14px;text-align:center;font-size:11px;color:var(--ink-mist)}',
118
137
  '[data-dsh-reasoning-search-empty][data-visible]{display:block}',
119
138
  '[data-dsh-reasoning-wire]{width:126px;padding:0 9px;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11.5px;text-align:right}',
120
139
  '[data-dsh-reasoning-wire]:disabled{opacity:.42;border-color:var(--ink-line);background:transparent}',
121
- '[data-dsh-reasoning-select]:focus,[data-dsh-reasoning-search]:focus,[data-dsh-reasoning-wire]:focus{border-color:var(--ink-text);box-shadow:0 0 0 3px var(--ink-focus)}',
140
+ '[data-dsh-reasoning-search]:focus,[data-dsh-reasoning-wire]:focus{border-color:var(--ink-text);box-shadow:0 0 0 3px var(--ink-focus)}',
122
141
  '[data-dsh-reasoning-conversation]{display:flex;align-items:center;gap:10px;padding:12px 14px;border:1px solid var(--ink-line);border-radius:14px;background:var(--ink-card)}',
123
142
  '[data-dsh-reasoning-conversation][data-off]{border-color:var(--ink-cinnabar)}',
124
143
  '[data-dsh-reasoning-conversation-copy]{flex:1;min-width:0}',
@@ -180,7 +199,8 @@ window.__ModuleLoader__.load({
180
199
  '[data-dsh-reasoning-quick]{display:flex;flex-wrap:wrap;gap:8px;padding:0 2px}',
181
200
  '[data-dsh-reasoning-form-row]{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 14px;min-height:56px}',
182
201
  '[data-dsh-reasoning-label]{font-size:12.5px;color:var(--ink-text)}',
183
- '[data-dsh-reasoning-form-row] [data-dsh-reasoning-select]{width:190px;flex:none}',
202
+ '[data-dsh-reasoning-form-row] [data-dsh-reasoning-dd]{width:216px;flex:none}',
203
+ '[data-dsh-reasoning-form-row] [data-dsh-reasoning-dd-pop]{left:auto;right:0;min-width:292px;max-width:100%}',
184
204
  '[data-dsh-reasoning-btn]{min-height:34px;box-sizing:border-box;border-radius:10px;padding:0 14px;border:1px solid var(--ink-line-strong);background:transparent;color:var(--ink-text);font:inherit;font-size:12.5px;cursor:pointer;transition:background-color .12s,border-color .12s,transform .12s,opacity .12s}',
185
205
  '[data-dsh-reasoning-btn]:hover:not(:disabled){background:var(--ink-hover)}',
186
206
  '[data-dsh-reasoning-btn]:active:not(:disabled){transform:translateY(1px)}',
@@ -198,7 +218,7 @@ window.__ModuleLoader__.load({
198
218
  '[data-dsh-reasoning-notice=success]{border-left-color:var(--ink-pine);color:var(--ink-pine)}',
199
219
  '[data-dsh-reasoning-notice=error]{border-left-color:var(--ink-cinnabar);color:var(--ink-cinnabar)}',
200
220
  '[data-dsh-reasoning-view] button:focus-visible{outline:2px solid var(--ink-text);outline-offset:2px}',
201
- '@media(max-width:768px){[data-dsh-reasoning-entry],[data-dsh-reasoning-btn]{min-height:44px}[data-dsh-reasoning-select],[data-dsh-reasoning-dd-btn],[data-dsh-reasoning-search],[data-dsh-reasoning-wire]{height:44px;font-size:16px}[data-dsh-reasoning-model]{min-height:52px}[data-dsh-reasoning-body]{padding:4px 14px 18px}[data-dsh-reasoning-header]{padding:14px 14px 10px}[data-dsh-reasoning-notice]{margin:0 14px}[data-dsh-reasoning-form-row]{flex-wrap:wrap}[data-dsh-reasoning-form-row] [data-dsh-reasoning-select]{flex:1 1 170px;width:auto}[data-dsh-reasoning-wire]{width:112px}[data-dsh-reasoning-actions]{padding:10px 14px calc(10px + env(safe-area-inset-bottom,0px))}}',
221
+ '@media(max-width:768px){[data-dsh-reasoning-entry],[data-dsh-reasoning-btn]{min-height:44px}[data-dsh-reasoning-dd-btn],[data-dsh-reasoning-search],[data-dsh-reasoning-wire]{height:44px;font-size:16px}[data-dsh-reasoning-model]{min-height:52px}[data-dsh-reasoning-body]{padding:4px 14px 18px}[data-dsh-reasoning-header]{padding:14px 14px 10px}[data-dsh-reasoning-notice]{margin:0 14px}[data-dsh-reasoning-form-row]{flex-wrap:wrap}[data-dsh-reasoning-form-row] [data-dsh-reasoning-dd]{flex:1 1 170px;width:auto}[data-dsh-reasoning-wire]{width:112px}[data-dsh-reasoning-actions]{padding:10px 14px calc(10px + env(safe-area-inset-bottom,0px))}}',
202
222
  '@media(prefers-reduced-motion:reduce){[data-dsh-reasoning-entry],[data-dsh-reasoning-view],[data-dsh-reasoning-view] *,[data-dsh-reasoning-icon-btn] svg{transition:none!important;animation:none!important}}',
203
223
  // ── 液态玻璃皮肤:白色玻璃主体 + 青花瓷釉色点缀 + 活水(焦散漂光/折射带呼吸) ──
204
224
  // body 前缀 + !important,覆盖上方水墨纸色规则(注入顺序也在其后)
@@ -214,8 +234,8 @@ window.__ModuleLoader__.load({
214
234
  'body [data-dsh-reasoning-view]::after{content:"";position:absolute;inset:0;z-index:1;pointer-events:none;border-radius:inherit;background-image:url("data:image/svg+xml;utf8,<svg xmlns=%27http://www.w3.org/2000/svg%27 width=%27260%27 height=%27260%27><filter id=%27p%27><feTurbulence type=%27fractalNoise%27 baseFrequency=%270.8%27 numOctaves=%273%27 stitchTiles=%27stitch%27/><feColorMatrix type=%27saturate%27 values=%270%27/></filter><rect width=%27260%27 height=%27260%27 filter=%27url(%23p)%27/></svg>");background-size:260px 260px;opacity:.045;mix-blend-mode:multiply}',
215
235
  'body [data-dsh-reasoning-view]>*{position:relative;z-index:2}',
216
236
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-card]{border-color:rgba(255,255,255,.6)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,1),inset 0 -1px 0 rgba(48,78,128,.1),inset 0 -6px 10px -7px rgba(255,255,255,.5),inset 0 0 18px rgba(255,255,255,.4)!important}',
217
- 'body [data-dsh-reasoning-view] [data-dsh-reasoning-select],body [data-dsh-reasoning-view] [data-dsh-reasoning-search],body [data-dsh-reasoning-view] [data-dsh-reasoning-wire]{background:rgba(255,255,255,.55)!important;border-color:rgba(255,255,255,.75)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,1),inset 0 -1px 0 rgba(48,78,128,.12),inset 0 -5px 8px -6px rgba(255,255,255,.55),inset 0 0 12px rgba(255,255,255,.4)!important}',
218
- 'body [data-dsh-reasoning-view] [data-dsh-reasoning-select]:focus,body [data-dsh-reasoning-view] [data-dsh-reasoning-search]:focus,body [data-dsh-reasoning-view] [data-dsh-reasoning-wire]:focus,body [data-dsh-reasoning-view] [data-dsh-reasoning-select]:focus-visible,body [data-dsh-reasoning-view] [data-dsh-reasoning-search]:focus-visible,body [data-dsh-reasoning-view] [data-dsh-reasoning-wire]:focus-visible{outline:none!important;border-color:rgba(255,255,255,.95)!important;box-shadow:0 0 0 3px rgba(43,88,158,.3),0 0 0 6px rgba(43,88,158,.1),inset 0 1px 0 rgba(255,255,255,.95),inset 0 -1px 0 rgba(48,78,128,.08)!important}',
237
+ 'body [data-dsh-reasoning-view] [data-dsh-reasoning-search],body [data-dsh-reasoning-view] [data-dsh-reasoning-wire]{background:rgba(255,255,255,.55)!important;border-color:rgba(255,255,255,.75)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,1),inset 0 -1px 0 rgba(48,78,128,.12),inset 0 -5px 8px -6px rgba(255,255,255,.55),inset 0 0 12px rgba(255,255,255,.4)!important}',
238
+ 'body [data-dsh-reasoning-view] [data-dsh-reasoning-search]:focus,body [data-dsh-reasoning-view] [data-dsh-reasoning-wire]:focus,body [data-dsh-reasoning-view] [data-dsh-reasoning-search]:focus-visible,body [data-dsh-reasoning-view] [data-dsh-reasoning-wire]:focus-visible{outline:none!important;border-color:rgba(255,255,255,.95)!important;box-shadow:0 0 0 3px rgba(43,88,158,.3),0 0 0 6px rgba(43,88,158,.1),inset 0 1px 0 rgba(255,255,255,.95),inset 0 -1px 0 rgba(48,78,128,.08)!important}',
219
239
  'body [data-dsh-reasoning-view] button:focus-visible{outline:none!important;box-shadow:0 0 0 3px rgba(43,88,158,.26),inset 0 1px 0 rgba(255,255,255,.7)!important}',
220
240
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-conversation]{transition:background-color .12s,box-shadow .12s,transform .12s}',
221
241
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-conversation]:hover{background:rgba(255,255,255,.55)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.9),inset 0 0 18px rgba(255,255,255,.45)!important}',
@@ -223,10 +243,10 @@ window.__ModuleLoader__.load({
223
243
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-mark],body [data-dsh-reasoning-view] [data-dsh-reasoning-icon-btn]{background:rgba(255,255,255,.45)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.8),inset 0 0 8px rgba(255,255,255,.2)!important}',
224
244
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-actions]{background:rgba(255,255,255,.3)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.75)!important}',
225
245
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-title]::before{content:"";display:inline-block;width:8px;height:8px;margin-right:8px;border-radius:2px;background:linear-gradient(135deg,#c2543f,#a03726);box-shadow:0 1px 4px rgba(181,67,47,.45),inset 0 1px 0 rgba(255,255,255,.35);vertical-align:1px}',
226
- ':root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-card],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-select],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-search],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-wire],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-conversation-state],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-mark],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-icon-btn]{background:rgba(255,250,240,.07)!important;border-color:rgba(255,250,240,.15)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.15),inset 0 -1px 0 rgba(0,0,0,.4),inset 0 0 12px rgba(150,180,220,.05)!important}',
246
+ ':root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-card],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-search],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-wire],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-conversation-state],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-mark],:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-icon-btn]{background:rgba(255,250,240,.07)!important;border-color:rgba(255,250,240,.15)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.15),inset 0 -1px 0 rgba(0,0,0,.4),inset 0 0 12px rgba(150,180,220,.05)!important}',
227
247
  ':root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-actions]{background:rgba(255,250,240,.06)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.15)!important}',
228
248
  ':root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-conversation]:hover{background:rgba(255,250,240,.1)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.18),inset 0 0 16px rgba(255,250,240,.08)!important}',
229
- '@media(prefers-color-scheme:dark){:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-card],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-select],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-search],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-wire],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-conversation-state],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-mark],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-icon-btn]{background:rgba(255,250,240,.07)!important;border-color:rgba(255,250,240,.15)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.15),inset 0 -1px 0 rgba(0,0,0,.4),inset 0 0 12px rgba(150,180,220,.05)!important};:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-actions]{background:rgba(255,250,240,.06)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.15)!important};:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-conversation]:hover{background:rgba(255,250,240,.1)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.18),inset 0 0 16px rgba(255,250,240,.08)!important}}',
249
+ '@media(prefers-color-scheme:dark){:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-card],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-search],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-wire],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-conversation-state],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-mark],:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-icon-btn]{background:rgba(255,250,240,.07)!important;border-color:rgba(255,250,240,.15)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.15),inset 0 -1px 0 rgba(0,0,0,.4),inset 0 0 12px rgba(150,180,220,.05)!important};:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-actions]{background:rgba(255,250,240,.06)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.15)!important};:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-conversation]:hover{background:rgba(255,250,240,.1)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.18),inset 0 0 16px rgba(255,250,240,.08)!important}}',
230
250
  // 减少动态偏好:view 本体的焦散动画由上方内置 reduced-motion 规则停用,这里补 ::before 折射带
231
251
  '@media(prefers-reduced-motion:reduce){body [data-dsh-reasoning-view]::before{animation:none!important}}',
232
252
  // ── 瓷上青花 · 晕染艺术:钴青入釉层层晕散 × 底部釉白堆脂 × 玻璃内环(仿 iPhone 双圈口沿) ──
@@ -260,9 +280,17 @@ window.__ModuleLoader__.load({
260
280
  '[data-dsh-reasoning-dd-pop]{position:absolute;z-index:60;left:0;right:0;top:calc(100% + 6px);max-height:262px;overflow:auto;box-sizing:border-box;padding:4px;display:none;border:1px solid var(--ink-line-strong);border-radius:12px;background:var(--ink-card);box-shadow:0 14px 36px rgba(28,26,22,.18)}',
261
281
  '[data-dsh-reasoning-dd][data-open] [data-dsh-reasoning-dd-pop]{display:block;animation:dsh-reasoning-dd-in .16s ease}',
262
282
  '@keyframes dsh-reasoning-dd-in{from{opacity:0;transform:translateY(-4px) scale(.985)}to{opacity:1;transform:none}}',
263
- '[data-dsh-reasoning-dd-row]{display:flex;align-items:center;gap:8px;width:100%;box-sizing:border-box;border:0;background:none;font:inherit;font-size:12.5px;color:var(--ink-text);padding:8px 10px;border-radius:9px;cursor:pointer;text-align:left}',
264
- '[data-dsh-reasoning-dd-name]{flex:none;max-width:58%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
265
- '[data-dsh-reasoning-dd-id]{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink-mist);font-size:11.5px}',
283
+ '[data-dsh-reasoning-dd-row]{display:flex;align-items:center;gap:8px;width:100%;box-sizing:border-box;border:0;background:none;font:inherit;font-size:12.5px;color:var(--ink-text);padding:7px 10px;border-radius:9px;cursor:pointer;text-align:left}',
284
+ '[data-dsh-reasoning-dd-group]{padding:9px 10px 3px;font-size:10px;font-weight:700;letter-spacing:.08em;color:var(--ink-faint)}',
285
+ '[data-dsh-reasoning-dd-group]:not(:first-child){margin-top:3px;border-top:1px solid var(--ink-line)}',
286
+ '[data-dsh-reasoning-dd-body]{flex:1;min-width:0;display:flex;flex-direction:column;gap:1px}',
287
+ '[data-dsh-reasoning-dd-title]{display:flex;align-items:center;gap:7px;min-width:0;font-size:12.5px}',
288
+ '[data-dsh-reasoning-dd-title]>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
289
+ '[data-dsh-reasoning-dd-title] code{flex:none;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:10.5px;font-weight:700;letter-spacing:.03em;padding:1.5px 7px;border-radius:6px;background:var(--ink-soft);color:var(--ink-text)}',
290
+ '[data-dsh-reasoning-dd-note]{font-size:10.5px;line-height:15px;color:var(--ink-mist);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
291
+ '[data-dsh-reasoning-dd-row]:disabled{opacity:.42;cursor:default}',
292
+ '[data-dsh-reasoning-dd-row]:disabled:hover{background:none}',
293
+ '[data-dsh-reasoning-dd][data-drop-up] [data-dsh-reasoning-dd-pop]{top:auto;bottom:calc(100% + 6px)}',
266
294
  '[data-dsh-reasoning-dd-check]{flex:none;display:flex;color:#2b589e;opacity:0;transition:opacity .12s}',
267
295
  '[data-dsh-reasoning-dd-check] svg,[data-dsh-reasoning-dd-arrow] svg{width:14px;height:14px;display:block}',
268
296
  '[data-dsh-reasoning-dd-row][aria-selected=true] [data-dsh-reasoning-dd-check]{opacity:1}',
@@ -273,15 +301,15 @@ window.__ModuleLoader__.load({
273
301
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-btn]{background:linear-gradient(170deg,rgba(255,255,255,.72),rgba(255,255,255,.5))!important;border-color:rgba(255,255,255,.78)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,1),inset 0 -1px 0 rgba(48,78,128,.12),inset 0 0 12px rgba(255,255,255,.4)!important}',
274
302
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-btn]:focus,body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-btn][aria-expanded=true]{border-color:rgba(255,255,255,.95)!important;box-shadow:0 0 0 3px rgba(43,88,158,.28),0 0 0 6px rgba(43,88,158,.1),inset 0 1px 0 rgba(255,255,255,.95)!important}',
275
303
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-pop]{background:linear-gradient(172deg,rgba(255,255,255,.92),rgba(240,247,255,.88))!important;-webkit-backdrop-filter:blur(26px) saturate(180%);backdrop-filter:blur(26px) saturate(180%);border-color:rgba(255,255,255,.82)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,1),inset 0 0 0 1px rgba(43,88,158,.08),inset 0 0 18px rgba(255,255,255,.5),0 18px 44px rgba(28,26,22,.24),0 0 26px rgba(86,140,190,.14)!important}',
276
- 'body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row]:hover,body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row][data-active]{background:rgba(43,88,158,.1)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.7)}',
304
+ 'body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row]:not(:disabled):hover,body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row][data-active]{background:rgba(43,88,158,.1)!important;box-shadow:inset 0 1px 0 rgba(255,255,255,.7)}',
277
305
  'body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row][aria-selected=true]{background:linear-gradient(90deg,rgba(43,88,158,.16),rgba(43,88,158,.05) 58%,rgba(43,88,158,0))!important;box-shadow:inset 2px 0 0 rgba(43,88,158,.68),inset 0 1px 0 rgba(255,255,255,.7)}',
278
306
  ':root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-btn]{background:linear-gradient(170deg,rgba(255,250,240,.09),rgba(255,250,240,.05))!important;border-color:rgba(255,250,240,.16)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.16),inset 0 -1px 0 rgba(0,0,0,.4)!important}',
279
307
  ':root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-pop]{background:linear-gradient(172deg,rgba(52,56,66,.94),rgba(38,40,48,.92))!important;-webkit-backdrop-filter:blur(26px) saturate(170%);backdrop-filter:blur(26px) saturate(170%);border-color:rgba(255,250,240,.14)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.16),inset 0 0 0 1px rgba(150,180,220,.06),0 18px 44px rgba(0,0,0,.5)!important}',
280
- ':root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row]:hover,:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row][data-active]{background:rgba(140,168,224,.14)!important}',
308
+ ':root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row]:not(:disabled):hover,:root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row][data-active]{background:rgba(140,168,224,.14)!important}',
281
309
  ':root[data-theme=dark] body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row][aria-selected=true]{background:linear-gradient(90deg,rgba(140,168,224,.2),rgba(140,168,224,.06) 58%,rgba(140,168,224,0))!important;box-shadow:inset 2px 0 0 rgba(150,178,228,.7)}',
282
310
  '@media(prefers-color-scheme:dark){:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-btn]{background:linear-gradient(170deg,rgba(255,250,240,.09),rgba(255,250,240,.05))!important;border-color:rgba(255,250,240,.16)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.16),inset 0 -1px 0 rgba(0,0,0,.4)!important}}',
283
311
  '@media(prefers-color-scheme:dark){:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-pop]{background:linear-gradient(172deg,rgba(52,56,66,.94),rgba(38,40,48,.92))!important;border-color:rgba(255,250,240,.14)!important;box-shadow:inset 0 1px 0 rgba(255,250,240,.16),inset 0 0 0 1px rgba(150,180,220,.06),0 18px 44px rgba(0,0,0,.5)!important}}',
284
- '@media(prefers-color-scheme:dark){:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row]:hover,:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row][data-active]{background:rgba(140,168,224,.14)!important}}',
312
+ '@media(prefers-color-scheme:dark){:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row]:not(:disabled):hover,:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row][data-active]{background:rgba(140,168,224,.14)!important}}',
285
313
  '@media(prefers-color-scheme:dark){:root:not([data-theme=light]) body [data-dsh-reasoning-view] [data-dsh-reasoning-dd-row][aria-selected=true]{background:linear-gradient(90deg,rgba(140,168,224,.2),rgba(140,168,224,.06) 58%,rgba(140,168,224,0))!important;box-shadow:inset 2px 0 0 rgba(150,178,228,.7)}}',
286
314
  ].join("\n");
287
315
  }
@@ -842,10 +870,13 @@ window.__ModuleLoader__.load({
842
870
  return levels.length ? "官方 " + levels.length + " 档" : "官方推理模型";
843
871
  }
844
872
 
845
- // Custom dropdown for the provider picker: a native <select> popup is
846
- // rendered by the OS and cannot take the panel's porcelain skin.
847
- function providerDropdown() {
848
- var providers = state.list.providers;
873
+ // Shared porcelain listbox behind every picker in the panel. The popup of
874
+ // a native <select> is rendered by the OS and cannot take the panel's
875
+ // skin, so each choice is rebuilt as a trigger button plus a floating
876
+ // listbox. config: { label, value, placeholder, groups: [{ title,
877
+ // options: [{ value, title, code, note, disabled }] }], summarize,
878
+ // onChange }.
879
+ function glassDropdown(config) {
849
880
  var wrapper = el("div", { "data-dsh-reasoning-dd": "" });
850
881
  var label = el("span", { "data-dsh-reasoning-dd-label": "" });
851
882
  var button = el("button", {
@@ -853,47 +884,73 @@ window.__ModuleLoader__.load({
853
884
  "data-dsh-reasoning-dd-btn": "",
854
885
  "aria-haspopup": "listbox",
855
886
  "aria-expanded": "false",
856
- "aria-label": "选择 Provider",
857
- }, [label, el("span", {
858
- "data-dsh-reasoning-dd-arrow": "",
859
- html: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 9l6 6 6-6"/></svg>',
860
- })]);
861
- var popup = el("div", { "data-dsh-reasoning-dd-pop": "", role: "listbox", "aria-label": "Provider 列表" });
862
- var rows = providers.map(function (provider) {
863
- var row = el("button", {
864
- type: "button",
865
- role: "option",
866
- "data-dsh-reasoning-dd-row": "",
867
- "data-value": provider.id,
868
- }, [
869
- el("span", { "data-dsh-reasoning-dd-name": "", text: provider.displayName }),
870
- el("span", { "data-dsh-reasoning-dd-id": "", text: provider.id }),
871
- el("span", {
872
- "data-dsh-reasoning-dd-check": "",
873
- html: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6L9 17l-5-5"/></svg>',
874
- }),
875
- ]);
876
- row.addEventListener("click", function () { pick(provider.id); });
877
- popup.appendChild(row);
878
- return row;
879
- });
887
+ "aria-label": config.label,
888
+ }, [label, el("span", { "data-dsh-reasoning-dd-arrow": "", html: icons.caret })]);
889
+ var popup = el("div", { "data-dsh-reasoning-dd-pop": "", role: "listbox", "aria-label": config.label });
890
+ var options = [];
891
+ var rows = [];
892
+
893
+ for (var g = 0; g < config.groups.length; g++) {
894
+ (function (group) {
895
+ if (group.title) popup.appendChild(el("div", { "data-dsh-reasoning-dd-group": "", text: group.title }));
896
+ for (var i = 0; i < group.options.length; i++) {
897
+ (function (option) {
898
+ var row = el("button", {
899
+ type: "button",
900
+ role: "option",
901
+ "data-dsh-reasoning-dd-row": "",
902
+ "data-value": option.value,
903
+ disabled: !!option.disabled,
904
+ }, [
905
+ el("span", { "data-dsh-reasoning-dd-body": "" }, [
906
+ el("span", { "data-dsh-reasoning-dd-title": "" }, [
907
+ option.code ? el("code", { text: option.code }) : null,
908
+ el("span", { text: option.title }),
909
+ ]),
910
+ option.note ? el("span", { "data-dsh-reasoning-dd-note": "", text: option.note }) : null,
911
+ ]),
912
+ el("span", { "data-dsh-reasoning-dd-check": "", html: icons.check }),
913
+ ]);
914
+ row.addEventListener("click", function () {
915
+ if (option.disabled) return;
916
+ closePopup();
917
+ if (String(option.value) === currentValue()) return;
918
+ config.value = option.value;
919
+ syncSelection();
920
+ config.onChange(option.value);
921
+ });
922
+ options.push(option);
923
+ rows.push(row);
924
+ popup.appendChild(row);
925
+ })(group.options[i]);
926
+ }
927
+ })(config.groups[g]);
928
+ }
880
929
  wrapper.appendChild(button);
881
930
  wrapper.appendChild(popup);
882
931
 
883
932
  var isOpen = false;
884
933
  var activeIndex = -1;
885
934
 
935
+ function currentValue() {
936
+ return config.value == null ? "" : String(config.value);
937
+ }
938
+ function selectedOption() {
939
+ var value = currentValue();
940
+ for (var i = 0; i < options.length; i++) {
941
+ if (String(options[i].value) === value) return options[i];
942
+ }
943
+ return null;
944
+ }
886
945
  function syncSelection() {
946
+ var value = currentValue();
887
947
  for (var i = 0; i < rows.length; i++) {
888
- var selected = rows[i].getAttribute("data-value") === state.providerId;
948
+ var selected = rows[i].getAttribute("data-value") === value;
889
949
  if (selected) activeIndex = i;
890
950
  rows[i].setAttribute("aria-selected", selected ? "true" : "false");
891
951
  }
892
- var current = null;
893
- for (var j = 0; j < providers.length; j++) {
894
- if (providers[j].id === state.providerId) current = providers[j];
895
- }
896
- label.textContent = current ? current.displayName + " · " + current.id : "选择 Provider";
952
+ var current = selectedOption();
953
+ label.textContent = current ? (config.summarize ? config.summarize(current) : current.title) : config.placeholder;
897
954
  }
898
955
  function paintActive() {
899
956
  for (var i = 0; i < rows.length; i++) {
@@ -902,6 +959,25 @@ window.__ModuleLoader__.load({
902
959
  }
903
960
  if (rows[activeIndex]) rows[activeIndex].scrollIntoView({ block: "nearest" });
904
961
  }
962
+ function nearestActivable(start, delta) {
963
+ for (var step = 1; step <= rows.length; step++) {
964
+ var index = ((start + delta * step) % rows.length + rows.length) % rows.length;
965
+ if (!rows[index].disabled) return index;
966
+ }
967
+ return start;
968
+ }
969
+ function placePopup() {
970
+ // Flip above the trigger when the drawer's scroll viewport lacks room
971
+ // below; scrollIntoView then covers whatever clipping remains.
972
+ var viewport = button.closest("[data-dsh-reasoning-scroll]");
973
+ var bounds = viewport ? viewport.getBoundingClientRect() : { top: 0, bottom: window.innerHeight };
974
+ var rect = button.getBoundingClientRect();
975
+ var needed = Math.min(popup.scrollHeight, 262) + 12;
976
+ var below = bounds.bottom - rect.bottom;
977
+ var above = rect.top - bounds.top;
978
+ wrapper.toggleAttribute("data-drop-up", below < needed && above > below);
979
+ popup.scrollIntoView({ block: "nearest" });
980
+ }
905
981
  function onOutside(event) {
906
982
  if (!wrapper.contains(event.target)) closePopup();
907
983
  }
@@ -913,28 +989,34 @@ window.__ModuleLoader__.load({
913
989
  } else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
914
990
  event.preventDefault();
915
991
  var delta = event.key === "ArrowDown" ? 1 : -1;
916
- activeIndex = (activeIndex + delta + rows.length) % rows.length;
992
+ activeIndex = nearestActivable(activeIndex < 0 ? 0 : activeIndex, delta);
917
993
  paintActive();
918
994
  } else if (event.key === "Home") {
919
995
  event.preventDefault();
920
- activeIndex = 0;
996
+ activeIndex = nearestActivable(0, -1);
921
997
  paintActive();
922
998
  } else if (event.key === "End") {
923
999
  event.preventDefault();
924
- activeIndex = rows.length - 1;
1000
+ activeIndex = nearestActivable(rows.length - 1, 1);
925
1001
  paintActive();
926
1002
  } else if (event.key === "Enter") {
927
1003
  event.preventDefault();
928
- if (rows[activeIndex]) pick(rows[activeIndex].getAttribute("data-value"));
1004
+ var row = rows[activeIndex];
1005
+ if (row && !row.disabled) row.click();
929
1006
  }
930
1007
  }
931
1008
  function openPopup() {
932
1009
  if (isOpen) return;
933
1010
  isOpen = true;
934
1011
  syncSelection();
935
- paintActive();
936
1012
  wrapper.setAttribute("data-open", "");
937
1013
  button.setAttribute("aria-expanded", "true");
1014
+ if (activeIndex >= 0) {
1015
+ var row = rows[activeIndex];
1016
+ popup.scrollTop = Math.max(0, row.offsetTop - popup.clientHeight / 2 + row.offsetHeight / 2);
1017
+ }
1018
+ placePopup();
1019
+ paintActive();
938
1020
  document.addEventListener("pointerdown", onOutside, true);
939
1021
  document.addEventListener("keydown", onKeydown, true);
940
1022
  }
@@ -946,15 +1028,6 @@ window.__ModuleLoader__.load({
946
1028
  document.removeEventListener("pointerdown", onOutside, true);
947
1029
  document.removeEventListener("keydown", onKeydown, true);
948
1030
  }
949
- function pick(providerId) {
950
- closePopup();
951
- if (state.providerId === providerId) { syncSelection(); return; }
952
- state.providerId = providerId;
953
- state.providerPinned = true;
954
- state.query = "";
955
- state.notice = null;
956
- publish();
957
- }
958
1031
  button.addEventListener("click", function () {
959
1032
  if (isOpen) closePopup();
960
1033
  else openPopup();
@@ -966,9 +1039,36 @@ window.__ModuleLoader__.load({
966
1039
  }
967
1040
  });
968
1041
  syncSelection();
1042
+ // Lets outside state changes (e.g. unchecking a level row) move the
1043
+ // selection without rebuilding the whole editor.
1044
+ wrapper.setDropdownValue = function (value) {
1045
+ config.value = value;
1046
+ syncSelection();
1047
+ };
969
1048
  return wrapper;
970
1049
  }
971
1050
 
1051
+ function providerDropdown() {
1052
+ return glassDropdown({
1053
+ label: "选择 Provider",
1054
+ value: state.providerId || "",
1055
+ placeholder: "选择 Provider",
1056
+ summarize: function (option) { return option.title + " · " + option.note; },
1057
+ groups: [{
1058
+ options: state.list.providers.map(function (provider) {
1059
+ return { value: provider.id, title: provider.displayName, note: provider.id };
1060
+ }),
1061
+ }],
1062
+ onChange: function (providerId) {
1063
+ state.providerId = providerId;
1064
+ state.providerPinned = true;
1065
+ state.query = "";
1066
+ state.notice = null;
1067
+ publish();
1068
+ },
1069
+ });
1070
+ }
1071
+
972
1072
  function renderModelList(body) {
973
1073
  var list = state.list;
974
1074
  if (!list || !list.providers.length) {
@@ -1094,8 +1194,8 @@ window.__ModuleLoader__.load({
1094
1194
  row.toggleAttribute("data-active", field.checked);
1095
1195
  if (!field.checked && state.edit.defaultReasoning === level) {
1096
1196
  state.edit.defaultReasoning = "";
1097
- var defaultSelect = document.querySelector("[data-dsh-reasoning-default]");
1098
- if (defaultSelect) defaultSelect.value = "";
1197
+ var defaultPicker = document.querySelector("[data-dsh-reasoning-default]");
1198
+ if (defaultPicker && defaultPicker.setDropdownValue) defaultPicker.setDropdownValue("");
1099
1199
  }
1100
1200
  markEdited();
1101
1201
  },
@@ -1114,6 +1214,24 @@ window.__ModuleLoader__.load({
1114
1214
  }
1115
1215
  }
1116
1216
 
1217
+ // Default-strength options for the picker: levels this model does not
1218
+ // enable stay visible but locked, with the reason in the note.
1219
+ function strengthLevelOptions() {
1220
+ var options = [];
1221
+ for (var i = 1; i < LEVELS.length; i++) {
1222
+ var level = LEVELS[i];
1223
+ var enabled = !!state.edit.levels[level].checked;
1224
+ options.push({
1225
+ value: level,
1226
+ code: level,
1227
+ title: LEVEL_LABELS[level],
1228
+ note: enabled ? LEVEL_NOTES[level] : "未在此模型启用",
1229
+ disabled: !enabled,
1230
+ });
1231
+ }
1232
+ return options;
1233
+ }
1234
+
1117
1235
  function renderEditor(body, view) {
1118
1236
  var provider = selectedProvider();
1119
1237
  var model = selectedModel();
@@ -1182,43 +1300,47 @@ window.__ModuleLoader__.load({
1182
1300
  if (state.edit.off) {
1183
1301
  body.appendChild(el("div", { "data-dsh-reasoning-scope-note": "", text: "Provider 默认强度与协议设置保持不变;关闭推理只影响此模型。" }));
1184
1302
  } else {
1185
- var defaultOptions = [
1186
- el("option", { value: "", text: "不设置 Provider 默认值" }),
1187
- el("option", { value: "off", text: "off · 不思考" }),
1188
- ];
1189
- for (var i = 1; i < LEVELS.length; i++) {
1190
- var level = LEVELS[i];
1191
- defaultOptions.push(el("option", {
1192
- value: level,
1193
- text: level + " · " + LEVEL_LABELS[level],
1194
- disabled: !state.edit.levels[level].checked,
1195
- }));
1196
- }
1197
- var defaultSelect = el("select", {
1198
- "data-dsh-reasoning-select": "",
1199
- "data-dsh-reasoning-default": "",
1303
+ var defaultPicker = glassDropdown({
1304
+ label: "新对话默认强度",
1200
1305
  value: state.edit.defaultReasoning,
1201
- onchange: function (event) { state.edit.defaultReasoning = event.target.value; markEdited(); },
1202
- }, defaultOptions);
1306
+ placeholder: "不设置 Provider 默认值",
1307
+ summarize: function (option) { return option.code ? option.code + " · " + option.title : option.title; },
1308
+ groups: [
1309
+ { options: [{ value: "", title: "不设置 Provider 默认值", note: "新对话不预选强度,进对话后手动切换" }] },
1310
+ { title: "关闭推理", options: [{ value: "off", code: "off", title: "不思考", note: LEVEL_NOTES.off }] },
1311
+ { title: "思考等级", options: strengthLevelOptions() },
1312
+ ],
1313
+ onChange: function (value) { state.edit.defaultReasoning = value; markEdited(); },
1314
+ });
1315
+ defaultPicker.setAttribute("data-dsh-reasoning-default", "");
1203
1316
 
1204
- var formatOptions = [el("option", { value: "", text: "自动检测" })];
1205
1317
  var formats = state.list && state.list.thinkingFormats ? state.list.thinkingFormats : [];
1206
- for (var fi = 0; fi < formats.length; fi++) formatOptions.push(el("option", { value: formats[fi], text: formats[fi] }));
1207
- var formatSelect = el("select", {
1208
- "data-dsh-reasoning-select": "",
1318
+ var formatPicker = glassDropdown({
1319
+ label: "思考内容格式",
1209
1320
  value: state.edit.thinkingFormat,
1210
- onchange: function (event) { state.edit.thinkingFormat = event.target.value; markEdited(); },
1211
- }, formatOptions);
1321
+ placeholder: "自动检测",
1322
+ summarize: function (option) { return option.code || option.title; },
1323
+ groups: [{
1324
+ options: [{ value: "", title: "自动检测", note: "按 Provider 协议自动匹配" }].concat(formats.map(function (format) {
1325
+ return { value: format, code: format, title: FORMAT_TITLES[format] || "手动指定的思考协议" };
1326
+ })),
1327
+ }],
1328
+ onChange: function (value) { state.edit.thinkingFormat = value; markEdited(); },
1329
+ });
1212
1330
 
1213
- var effortSelect = el("select", {
1214
- "data-dsh-reasoning-select": "",
1331
+ var effortPicker = glassDropdown({
1332
+ label: "reasoning_effort 参数",
1215
1333
  value: state.edit.supportsReasoningEffort,
1216
- onchange: function (event) { state.edit.supportsReasoningEffort = event.target.value; markEdited(); },
1217
- }, [
1218
- el("option", { value: "", text: "自动检测" }),
1219
- el("option", { value: "true", text: "启用 reasoning_effort" }),
1220
- el("option", { value: "false", text: "不发送 reasoning_effort" }),
1221
- ]);
1334
+ placeholder: "自动检测",
1335
+ groups: [{
1336
+ options: [
1337
+ { value: "", title: "自动检测", note: "按模型与协议自动判断是否携带" },
1338
+ { value: "true", title: "启用 reasoning_effort", note: "请求体携带 reasoning_effort 字段" },
1339
+ { value: "false", title: "不发送 reasoning_effort", note: "兼容不识别该字段的中转站" },
1340
+ ],
1341
+ }],
1342
+ onChange: function (value) { state.edit.supportsReasoningEffort = value; markEdited(); },
1343
+ });
1222
1344
 
1223
1345
  var formSection = el("div", { "data-dsh-reasoning-section": "" }, [
1224
1346
  el("div", { "data-dsh-reasoning-section-head": "" }, [
@@ -1227,13 +1349,13 @@ window.__ModuleLoader__.load({
1227
1349
  ]),
1228
1350
  inkCard([
1229
1351
  el("div", { "data-dsh-reasoning-form-row": "" }, [
1230
- el("label", { "data-dsh-reasoning-label": "", text: "新对话默认强度" }), defaultSelect,
1352
+ el("label", { "data-dsh-reasoning-label": "", text: "新对话默认强度" }), defaultPicker,
1231
1353
  ]),
1232
1354
  el("div", { "data-dsh-reasoning-form-row": "" }, [
1233
- el("label", { "data-dsh-reasoning-label": "", text: "思考内容格式" }), formatSelect,
1355
+ el("label", { "data-dsh-reasoning-label": "", text: "思考内容格式" }), formatPicker,
1234
1356
  ]),
1235
1357
  el("div", { "data-dsh-reasoning-form-row": "" }, [
1236
- el("label", { "data-dsh-reasoning-label": "", text: "reasoning_effort 参数" }), effortSelect,
1358
+ el("label", { "data-dsh-reasoning-label": "", text: "reasoning_effort 参数" }), effortPicker,
1237
1359
  ]),
1238
1360
  ], true),
1239
1361
  ]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@megen-lebar/dsh-reasoning-effort",
3
3
  "description": "DSH Web GUI 思考强度配置器:侧边栏新增「思考强度」入口,可视化管理第三方 API 各模型的 reasoning effort(自动带出官方档位、保留 off、自定义线上拼写),一键写回 settings 的 llm-pi-ai 命名空间,无需手写 YAML。",
4
- "version": "0.2.3",
4
+ "version": "0.2.4",
5
5
  "type": "module",
6
6
  "engines": { "node": "^22.19.0 || >=24.0.0" },
7
7
  "main": "lib/index.js",
@@ -22,9 +22,9 @@
22
22
  },
23
23
  "files": ["lib", "test", "cordis.patch.yml", "README.md"],
24
24
  "publishConfig": { "access": "public" },
25
- "repository": { "type": "git", "url": "git+https://github.com/Jamsharden/dsh-plugins.git", "directory": "packages/dsh-reasoning-effort" },
26
- "bugs": { "url": "https://github.com/Jamsharden/dsh-plugins/issues" },
27
- "homepage": "https://github.com/Jamsharden/dsh-plugins#readme",
25
+ "repository": { "type": "git", "url": "git+https://github.com/Jamsharden/dsh-reasoning-effort.git" },
26
+ "bugs": { "url": "https://github.com/Jamsharden/dsh-reasoning-effort/issues" },
27
+ "homepage": "https://github.com/Jamsharden/dsh-reasoning-effort",
28
28
  "keywords": ["dsh", "deepseek-harness", "reasoning-effort", "web-plugin"],
29
29
  "license": "Apache-2.0"
30
30
  }